Skip to content

Commit

Permalink
Editor Sidebar: Improve screen title UI
Browse files Browse the repository at this point in the history
  • Loading branch information
t-hamano committed Apr 27, 2024
1 parent 352a397 commit e5b999e
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 30 deletions.
13 changes: 6 additions & 7 deletions src/editor-sidebar/create-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ import {
TextControl,
TextareaControl,
} from '@wordpress/components';
import { chevronLeft, addCard, copy } from '@wordpress/icons';
import { addCard, copy } from '@wordpress/icons';

import ScreenHeader from './screen-header';

export const CreateThemePanel = ( { createType } ) => {
const { createErrorNotice } = useDispatch( noticesStore );
Expand Down Expand Up @@ -148,12 +150,9 @@ export const CreateThemePanel = ( { createType } ) => {

return (
<PanelBody>
<Heading>
<NavigatorToParentButton icon={ chevronLeft }>
{ __( 'Create Theme', 'create-block-theme' ) }
</NavigatorToParentButton>
</Heading>

<ScreenHeader
title={ __( 'Create Theme', 'create-block-theme' ) }
/>
<VStack>
<TextControl
label={ __( 'Theme name', 'create-block-theme' ) }
Expand Down
13 changes: 6 additions & 7 deletions src/editor-sidebar/create-variation-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ import {
Button,
TextControl,
} from '@wordpress/components';
import { chevronLeft, copy } from '@wordpress/icons';
import { copy } from '@wordpress/icons';
import { postCreateThemeVariation } from '../resolvers';

import ScreenHeader from './screen-header';

export const CreateVariationPanel = () => {
const { createErrorNotice } = useDispatch( noticesStore );

Expand Down Expand Up @@ -50,12 +52,9 @@ export const CreateVariationPanel = () => {

return (
<PanelBody>
<Heading>
<NavigatorToParentButton icon={ chevronLeft }>
{ __( 'Create Variation', 'create-block-theme' ) }
</NavigatorToParentButton>
</Heading>

<ScreenHeader
title={ __( 'Create Variation', 'create-block-theme' ) }
/>
<VStack>
<Text>
{ __(
Expand Down
13 changes: 6 additions & 7 deletions src/editor-sidebar/save-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import {
Button,
CheckboxControl,
} from '@wordpress/components';
import { chevronLeft, archive } from '@wordpress/icons';
import { archive } from '@wordpress/icons';

import ScreenHeader from './screen-header';

export const SaveThemePanel = () => {
const [ saveOptions, setSaveOptions ] = useState( {
Expand Down Expand Up @@ -61,12 +63,9 @@ export const SaveThemePanel = () => {

return (
<PanelBody>
<Heading>
<NavigatorToParentButton icon={ chevronLeft }>
{ __( 'Save Changes', 'create-block-theme' ) }
</NavigatorToParentButton>
</Heading>

<ScreenHeader
title={ __( 'Save Changes', 'create-block-theme' ) }
/>
<VStack>
<CheckboxControl
label="Save Fonts"
Expand Down
42 changes: 42 additions & 0 deletions src/editor-sidebar/screen-header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import {
// eslint-disable-next-line
__experimentalHStack as HStack,
// eslint-disable-next-line
__experimentalVStack as VStack,
// eslint-disable-next-line
__experimentalSpacer as Spacer,
// eslint-disable-next-line
__experimentalHeading as Heading,
// eslint-disable-next-line
__experimentalNavigatorToParentButton as NavigatorToParentButton,
} from '@wordpress/components';
import { isRTL, __ } from '@wordpress/i18n';
import { chevronRight, chevronLeft } from '@wordpress/icons';

const ScreenHeader = ( { title, onBack } ) => {
return (
<Spacer marginBottom={ 0 } paddingBottom={ 4 }>
<HStack spacing={ 2 }>
<NavigatorToParentButton
style={ { minWidth: 24, padding: 0 } }
icon={ isRTL() ? chevronRight : chevronLeft }
size="small"
label={ __( 'Back', 'create-block-theme' ) }
onClick={ onBack }
/>
<Spacer>
<Heading
level={ 2 }
size={ 13 }
// Need to override the too specific bottom margin for complementary areas.
style={ { margin: 0 } }
>
{ title }
</Heading>
</Spacer>
</HStack>
</Spacer>
);
};

export default ScreenHeader;
16 changes: 7 additions & 9 deletions src/plugin-sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import {
edit,
code,
chevronRight,
chevronLeft,
addCard,
blockMeta,
} from '@wordpress/icons';
Expand All @@ -45,6 +44,7 @@ import ThemeJsonEditorModal from './editor-sidebar/json-editor-modal';
import { SaveThemePanel } from './editor-sidebar/save-panel';
import { CreateVariationPanel } from './editor-sidebar/create-variation-panel';
import { ThemeMetadataEditorModal } from './editor-sidebar/metadata-editor-modal';
import ScreenHeader from './editor-sidebar/screen-header';
import { downloadExportedTheme } from './resolvers';

const CreateBlockThemePlugin = () => {
Expand Down Expand Up @@ -181,14 +181,12 @@ const CreateBlockThemePlugin = () => {

<NavigatorScreen path="/clone">
<PanelBody>
<Heading>
<NavigatorToParentButton icon={ chevronLeft }>
{ __(
'Create Block Theme',
'create-block-theme'
) }
</NavigatorToParentButton>
</Heading>
<ScreenHeader
title={ __(
'Create Block Theme',
'create-block-theme'
) }
/>
<VStack>
<Text>
{ __(
Expand Down

0 comments on commit e5b999e

Please sign in to comment.