-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Mobile] Update toolbar icons and colors (#52336)
* Update toolbar icons and colors * Update colors to add $app-safe-area-background * Button component - Update icon colors * SVG component - Update colors to support dark/light themes * ToolbarGroup - Update border colors * HeaderToolbar - Update colors * Layout - Update safe area color * TextColor Format - Update toolbar icon styles * Update changelog * Add missing file extension * Update styleMock * Update BlockMover snapshot * Restores the Fill/Slot logic for the BlockSettingsButton * Adds initial Block Toolbar integration tests related to the block settings button * Add missing style to the styleMock file * Update usage of Platform * Rename $app-safe-area-background to $app-safe-area-background-dark
- Loading branch information
Gerardo Pacheco
authored
Jul 17, 2023
1 parent
32278f0
commit 372b9b1
Showing
19 changed files
with
222 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 28 additions & 13 deletions
41
packages/block-editor/src/components/block-settings/button.native.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,35 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { ToolbarGroup, ToolbarButton } from '@wordpress/components'; | ||
import { createSlotFill, ToolbarButton } from '@wordpress/components'; | ||
import { __ } from '@wordpress/i18n'; | ||
import { withDispatch } from '@wordpress/data'; | ||
import { cog } from '@wordpress/icons'; | ||
|
||
const SettingsButton = ( { onOpenBlockSettings } ) => { | ||
return ( | ||
<ToolbarGroup> | ||
<ToolbarButton | ||
title={ __( 'Open Settings' ) } | ||
icon={ cog } | ||
onClick={ onOpenBlockSettings } | ||
/> | ||
</ToolbarGroup> | ||
); | ||
}; | ||
const { Fill, Slot } = createSlotFill( 'SettingsToolbarButton' ); | ||
|
||
export default SettingsButton; | ||
const SettingsButton = ( { openGeneralSidebar } ) => ( | ||
<ToolbarButton | ||
title={ __( 'Open Settings' ) } | ||
icon={ cog } | ||
onClick={ openGeneralSidebar } | ||
/> | ||
); | ||
|
||
const SettingsButtonFill = ( props ) => ( | ||
<Fill> | ||
<SettingsButton { ...props } /> | ||
</Fill> | ||
); | ||
|
||
const SettingsToolbarButton = withDispatch( ( dispatch ) => { | ||
const { openGeneralSidebar } = dispatch( 'core/edit-post' ); | ||
|
||
return { | ||
openGeneralSidebar: () => openGeneralSidebar( 'edit-post/block' ), | ||
}; | ||
} )( SettingsButtonFill ); | ||
|
||
SettingsToolbarButton.Slot = Slot; | ||
|
||
export default SettingsToolbarButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
packages/block-editor/src/components/block-toolbar/test/index.native.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { | ||
addBlock, | ||
fireEvent, | ||
getBlock, | ||
initializeEditor, | ||
setupCoreBlocks, | ||
} from 'test/helpers'; | ||
|
||
setupCoreBlocks(); | ||
|
||
describe( 'Block Toolbar', () => { | ||
it( "doesn't render the block settings button if there aren't any settings for the current selected block", async () => { | ||
// Arrange | ||
const screen = await initializeEditor(); | ||
await addBlock( screen, 'Image' ); | ||
|
||
// Act | ||
fireEvent( | ||
screen.getByTestId( 'media-options-picker' ), | ||
'backdropPress' | ||
); | ||
|
||
// Assert | ||
expect( screen.queryByLabelText( 'Open Settings' ) ).toBeNull(); | ||
} ); | ||
|
||
it( 'renders the block settings button for the current selected block', async () => { | ||
// Arrange | ||
const screen = await initializeEditor(); | ||
await addBlock( screen, 'Paragraph' ); | ||
|
||
// Act | ||
const paragraphBlock = await getBlock( screen, 'Paragraph' ); | ||
fireEvent.press( paragraphBlock ); | ||
|
||
// Assert | ||
expect( screen.queryByLabelText( 'Open Settings' ) ).toBeVisible(); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.components-button-light--active { | ||
border-color: $light-dim; | ||
background-color: $light-dim; | ||
} | ||
|
||
.components-button-dark--active { | ||
border-color: $dark-quaternary; | ||
background-color: $dark-quaternary; | ||
} |
5 changes: 2 additions & 3 deletions
5
packages/components/src/toolbar/toolbar-group/style.native.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
.container { | ||
flex-direction: row; | ||
border-left-width: 1px; | ||
border-color: #e9eff3; | ||
border-color: $light-quaternary; | ||
padding-left: 5px; | ||
padding-right: 5px; | ||
} | ||
|
||
.containerDark { | ||
border-color: #525354; | ||
border-color: $dark-quaternary; | ||
} |
29 changes: 12 additions & 17 deletions
29
packages/components/src/toolbar/toolbar-group/toolbar-group-container.native.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,26 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { View } from 'react-native'; | ||
import { StyleSheet, View } from 'react-native'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { withPreferredColorScheme } from '@wordpress/compose'; | ||
import { usePreferredColorSchemeStyle } from '@wordpress/compose'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import styles from './style.scss'; | ||
|
||
const ToolbarGroupContainer = ( { | ||
getStylesFromColorScheme, | ||
passedStyle, | ||
children, | ||
} ) => ( | ||
<View | ||
style={ [ | ||
getStylesFromColorScheme( styles.container, styles.containerDark ), | ||
passedStyle, | ||
] } | ||
> | ||
{ children } | ||
</View> | ||
); | ||
const ToolbarGroupContainer = ( { passedStyle, children } ) => { | ||
const groupStyles = [ | ||
usePreferredColorSchemeStyle( styles.container, styles.containerDark ), | ||
{ borderLeftWidth: StyleSheet.hairlineWidth }, | ||
passedStyle, | ||
]; | ||
|
||
export default withPreferredColorScheme( ToolbarGroupContainer ); | ||
return <View style={ groupStyles }>{ children }</View>; | ||
}; | ||
|
||
export default ToolbarGroupContainer; |
Oops, something went wrong.