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

Fix-up Post Editor’s preferences modal #35369

Merged
merged 8 commits into from
Oct 15, 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
51 changes: 30 additions & 21 deletions packages/edit-post/src/components/preferences-modal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ import {
__experimentalItemGroup as ItemGroup,
__experimentalItem as Item,
__experimentalHStack as HStack,
__experimentalText as Text,
__experimentalTruncate as Truncate,
FlexItem,
Modal,
TabPanel,
Button,
Card,
CardHeader,
CardBody,
} from '@wordpress/components';
import { isRTL, __ } from '@wordpress/i18n';
Expand Down Expand Up @@ -325,10 +327,10 @@ export default function PreferencesModal() {
);
} else {
modalContent = (
<Card isBorderless>
<CardBody>
<NavigatorProvider initialPath="/">
<NavigatorScreen path="/">
<NavigatorProvider initialPath="/">
<NavigatorScreen path="/">
<Card isBorderless size="small">
<CardBody>
Comment on lines -328 to +333
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Putting the Cards and CardBodys inside the NavigatorScreens prevents the clipping of focus indicators and allows the root screen to use a padding different from the child screens.

<ItemGroup>
{ tabs.map( ( tab ) => {
return (
Expand Down Expand Up @@ -358,12 +360,21 @@ export default function PreferencesModal() {
);
} ) }
</ItemGroup>
</NavigatorScreen>
{ sections.map( ( section ) => {
return (
<NavigatorScreen
key={ `${ section.name }-menu` }
path={ section.name }
</CardBody>
</Card>
</NavigatorScreen>
{ sections.map( ( section ) => {
return (
<NavigatorScreen
key={ `${ section.name }-menu` }
path={ section.name }
>
<Card isBorderless size="large">
<CardHeader
isBorderless={ false }
justify="left"
size="small"
gap="6"
>
<NavigationButton
path="/"
Expand All @@ -374,17 +385,15 @@ export default function PreferencesModal() {
aria-label={ __(
'Navigate to the previous view'
) }
>
{ __( 'Back' ) }
</NavigationButton>
<h2>{ section.tabLabel }</h2>
{ section.content }
</NavigatorScreen>
);
} ) }
</NavigatorProvider>
</CardBody>
</Card>
/>
<Text size="16">{ section.tabLabel }</Text>
</CardHeader>
<CardBody>{ section.content }</CardBody>
</Card>
</NavigatorScreen>
);
} ) }
</NavigatorProvider>
);
}
return (
Expand Down
46 changes: 6 additions & 40 deletions packages/edit-post/src/components/preferences-modal/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ $vertical-tabs-width: 160px;
height: 70%;
}

// Clears spacing to flush fit the navigation component to the modal edges.
// Clears spacing to flush fit the navigator component to the modal edges.
@media (max-width: #{ ($break-medium - 1) }) {
.components-modal__content {
padding: 0;
Expand All @@ -23,45 +23,10 @@ $vertical-tabs-width: 160px;
content: none;
}
}
}

.components-navigation {
padding: 0;
max-height: 100%;
overflow-y: auto;
color: $black;

> * {
// Matches spacing cleared from the modal content element.
padding: $grid-unit-30 $grid-unit-40;
}

.components-navigation__menu {
margin: 0;

.components-navigation__item {
& > button {
padding: 3px $grid-unit-20;
height: $grid-unit-60;
// Aligns button text instead of button box.
margin: 0 #{-$grid-unit-20};
width: calc(#{$grid-unit-40} + 100%);
&:focus {
font-weight: 500;
}
}
}
.components-navigation__menu-title-heading {
border-bottom: 1px solid $gray-300;
padding-left: 0;
padding-right: 0;
}
.components-navigation__back-button {
padding-left: 0;
}
.edit-post-preferences-modal__custom-fields-confirmation-button {
width: auto;
}
// Keep the navigator component from overflowing the modal content area
// to ensure that sticky position elements stick where intended.
.components-navigator-provider {
height: 100%;
}
}

Expand Down Expand Up @@ -102,6 +67,7 @@ $vertical-tabs-width: 160px;
&__section-title {
font-size: 0.9rem;
font-weight: 600;
margin-top: 0;
}

&__option {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,17 @@ exports[`PreferencesModal should match snapshot when the modal is active small v
onRequestClose={[Function]}
title="Preferences"
>
<Card
isBorderless={true}
<NavigatorProvider
initialPath="/"
>
<CardBody>
<NavigatorProvider
initialPath="/"
<NavigatorScreen
path="/"
>
<Card
isBorderless={true}
size="small"
>
<NavigatorScreen
path="/"
>
<CardBody>
<ItemGroup>
<NavigationButton
as={
Expand Down Expand Up @@ -169,10 +170,22 @@ exports[`PreferencesModal should match snapshot when the modal is active small v
</HStack>
</NavigationButton>
</ItemGroup>
</NavigatorScreen>
<NavigatorScreen
key="general-menu"
path="general"
</CardBody>
</Card>
</NavigatorScreen>
<NavigatorScreen
key="general-menu"
path="general"
>
<Card
isBorderless={true}
size="large"
>
<CardHeader
gap="6"
isBorderless={false}
justify="left"
size="small"
>
<NavigationButton
aria-label="Navigate to the previous view"
Expand All @@ -188,12 +201,14 @@ exports[`PreferencesModal should match snapshot when the modal is active small v
}
isBack={true}
path="/"
/>
<Text
size="16"
>
Back
</NavigationButton>
<h2>
General
</h2>
</Text>
</CardHeader>
<CardBody>
<Section
description="Customize options related to the block editor interface and editing flow."
title="Appearance"
Expand Down Expand Up @@ -224,10 +239,22 @@ exports[`PreferencesModal should match snapshot when the modal is active small v
label="Display block breadcrumbs"
/>
</Section>
</NavigatorScreen>
<NavigatorScreen
key="blocks-menu"
path="blocks"
</CardBody>
</Card>
</NavigatorScreen>
<NavigatorScreen
key="blocks-menu"
path="blocks"
>
<Card
isBorderless={true}
size="large"
>
<CardHeader
gap="6"
isBorderless={false}
justify="left"
size="small"
>
<NavigationButton
aria-label="Navigate to the previous view"
Expand All @@ -243,12 +270,14 @@ exports[`PreferencesModal should match snapshot when the modal is active small v
}
isBack={true}
path="/"
/>
<Text
size="16"
>
Back
</NavigationButton>
<h2>
Blocks
</h2>
</Text>
</CardHeader>
<CardBody>
<Section
description="Customize how you interact with blocks in the block library and editing canvas."
title="Block interactions"
Expand All @@ -270,10 +299,22 @@ exports[`PreferencesModal should match snapshot when the modal is active small v
>
<WithSelect(BlockManager) />
</Section>
</NavigatorScreen>
<NavigatorScreen
key="panels-menu"
path="panels"
</CardBody>
</Card>
</NavigatorScreen>
<NavigatorScreen
key="panels-menu"
path="panels"
>
<Card
isBorderless={true}
size="large"
>
<CardHeader
gap="6"
isBorderless={false}
justify="left"
size="small"
>
<NavigationButton
aria-label="Navigate to the previous view"
Expand All @@ -289,12 +330,14 @@ exports[`PreferencesModal should match snapshot when the modal is active small v
}
isBack={true}
path="/"
/>
<Text
size="16"
>
Back
</NavigationButton>
<h2>
Panels
</h2>
</Text>
</CardHeader>
<CardBody>
<Section
description="Choose what displays in the panel."
title="Document settings"
Expand Down Expand Up @@ -339,9 +382,9 @@ exports[`PreferencesModal should match snapshot when the modal is active small v
description="Add extra areas to the editor."
title="Additional"
/>
</NavigatorScreen>
</NavigatorProvider>
</CardBody>
</Card>
</CardBody>
</Card>
</NavigatorScreen>
</NavigatorProvider>
</Modal>
`;