Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Site Editor: Allow global styles sidebar panels to fill vertical space #36845

Merged
merged 2 commits into from
Dec 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 50 additions & 25 deletions packages/edit-site/src/components/global-styles/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,46 +22,68 @@ import ScreenTextColor from './screen-text-color';
import ScreenLinkColor from './screen-link-color';
import ScreenLayout from './screen-layout';

function GlobalStylesNavigationScreen( { className, ...props } ) {
return (
<NavigatorScreen
className={ [
'edit-site-global-styles-sidebar__navigator-screen',
className,
]
.filter( Boolean )
.join( ' ' ) }
{ ...props }
/>
);
}

function ContextScreens( { name } ) {
const parentMenu = name === undefined ? '' : '/blocks/' + name;

return (
<>
<NavigatorScreen path={ parentMenu + '/typography' }>
<GlobalStylesNavigationScreen path={ parentMenu + '/typography' }>
<ScreenTypography name={ name } />
</NavigatorScreen>
</GlobalStylesNavigationScreen>

<NavigatorScreen path={ parentMenu + '/typography/text' }>
<GlobalStylesNavigationScreen
path={ parentMenu + '/typography/text' }
>
<ScreenTypographyElement name={ name } element="text" />
</NavigatorScreen>
</GlobalStylesNavigationScreen>

<NavigatorScreen path={ parentMenu + '/typography/link' }>
<GlobalStylesNavigationScreen
path={ parentMenu + '/typography/link' }
>
<ScreenTypographyElement name={ name } element="link" />
</NavigatorScreen>
</GlobalStylesNavigationScreen>

<NavigatorScreen path={ parentMenu + '/colors' }>
<GlobalStylesNavigationScreen path={ parentMenu + '/colors' }>
<ScreenColors name={ name } />
</NavigatorScreen>
</GlobalStylesNavigationScreen>

<NavigatorScreen path={ parentMenu + '/colors/palette' }>
<GlobalStylesNavigationScreen
path={ parentMenu + '/colors/palette' }
>
<ScreenColorPalette name={ name } />
</NavigatorScreen>
</GlobalStylesNavigationScreen>

<NavigatorScreen path={ parentMenu + '/colors/background' }>
<GlobalStylesNavigationScreen
path={ parentMenu + '/colors/background' }
>
<ScreenBackgroundColor name={ name } />
</NavigatorScreen>
</GlobalStylesNavigationScreen>

<NavigatorScreen path={ parentMenu + '/colors/text' }>
<GlobalStylesNavigationScreen path={ parentMenu + '/colors/text' }>
<ScreenTextColor name={ name } />
</NavigatorScreen>
</GlobalStylesNavigationScreen>

<NavigatorScreen path={ parentMenu + '/colors/link' }>
<GlobalStylesNavigationScreen path={ parentMenu + '/colors/link' }>
<ScreenLinkColor name={ name } />
</NavigatorScreen>
</GlobalStylesNavigationScreen>

<NavigatorScreen path={ parentMenu + '/layout' }>
<GlobalStylesNavigationScreen path={ parentMenu + '/layout' }>
<ScreenLayout name={ name } />
</NavigatorScreen>
</GlobalStylesNavigationScreen>
</>
);
}
Expand All @@ -70,22 +92,25 @@ function GlobalStylesUI() {
const blocks = getBlockTypes();

return (
<NavigatorProvider initialPath="/">
<NavigatorScreen path="/">
<NavigatorProvider
className="edit-site-global-styles-sidebar__navigator-provider"
initialPath="/"
>
<GlobalStylesNavigationScreen path="/">
<ScreenRoot />
</NavigatorScreen>
</GlobalStylesNavigationScreen>

<NavigatorScreen path="/blocks">
<GlobalStylesNavigationScreen path="/blocks">
<ScreenBlockList />
</NavigatorScreen>
</GlobalStylesNavigationScreen>

{ blocks.map( ( block ) => (
<NavigatorScreen
<GlobalStylesNavigationScreen
key={ 'menu-block-' + block.name }
path={ '/blocks/' + block.name }
>
<ScreenBlock name={ block.name } />
</NavigatorScreen>
</GlobalStylesNavigationScreen>
) ) }

<ContextScreens />
Expand Down
2 changes: 2 additions & 0 deletions packages/edit-site/src/components/sidebar/default-sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default function DefaultSidebar( {
closeLabel,
header,
headerClassName,
panelClassName,
} ) {
return (
<>
Expand All @@ -27,6 +28,7 @@ export default function DefaultSidebar( {
closeLabel={ closeLabel }
header={ header }
headerClassName={ headerClassName }
panelClassName={ panelClassName }
>
{ children }
</ComplementaryArea>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default function GlobalStylesSidebar() {
title={ __( 'Styles' ) }
icon={ styles }
closeLabel={ __( 'Close global styles sidebar' ) }
panelClassName="edit-site-global-styles-sidebar__panel"
header={
<Flex>
<FlexBlock>
Expand Down
17 changes: 17 additions & 0 deletions packages/edit-site/src/components/sidebar/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,23 @@
}
}

.edit-site-global-styles-sidebar {
display: flex;
flex-direction: column;
height: 100%;

&__panel,
&__navigator-provider {
display: flex;
flex-direction: column;
flex: 1;
}

&__navigator-screen {
flex: 1;
}
}

.edit-site-global-styles-sidebar .interface-complementary-area-header .components-button.has-icon {
margin-left: 0;
}
Expand Down