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

Follow up design tweaks for global styles presets #60031

Merged
merged 18 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from 12 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
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,11 @@ function ColorToolsPanel( {

return (
<ToolsPanel
label={ __( 'Color' ) }
label={ __( 'Elements' ) }
resetAll={ resetAll }
panelId={ panelId }
hasInnerWrapper
headingLevel={ 3 }
className="color-block-support-panel"
__experimentalFirstVisibleItemClass="first"
__experimentalLastVisibleItemClass="last"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function FontFamilies() {
/>
) }

<VStack spacing={ 3 }>
<VStack spacing={ 2 }>
richtabor marked this conversation as resolved.
Show resolved Hide resolved
<HStack justify="space-between">
<Subtitle level={ 3 }>{ __( 'Fonts' ) }</Subtitle>
<HStack justify="flex-end">
Expand Down
4 changes: 3 additions & 1 deletion packages/edit-site/src/components/global-styles/palette.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ function Palette( { name } ) {
</ColorIndicatorWrapper>
) ) }
</ZStack>
<FlexItem>{ paletteButtonText }</FlexItem>
<FlexItem className="edit-site-global-styles-screen-colors__palette-count">
{ paletteButtonText }
</FlexItem>
</HStack>
</NavigationButtonAsItem>
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ const StylesPreviewColors = ( { label, isFocused, withHoverView } ) => {
} }
>
<HStack
spacing={ 10 * ratio }
spacing={ 5 * ratio }
justify="center"
style={ {
height: '100%',
overflow: 'hidden',
} }
>
<HighlightedColors
normalizedColorSwatchSize={ 66 }
normalizedColorSwatchSize={ 56 }
ratio={ ratio }
/>
</HStack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ function ScreenColors() {
<ScreenHeader
title={ __( 'Colors' ) }
description={ __(
'Manage palettes and the default color of different global elements on the site.'
'Palette colors and the application of those colors on site elements.'
) }
/>
<div className="edit-site-global-styles-screen-colors">
<VStack spacing={ 6 }>
<ColorVariations />
<VStack spacing={ 7 }>
<ColorVariations title={ __( 'Presets' ) } />
<Palette />
<StylesColorPanel
inheritedValue={ inheritedStyle }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ function ScreenTypography() {
<ScreenHeader
title={ __( 'Typography' ) }
description={ __(
'Manage the typography settings for different elements.'
'Typography styles and the application of those styles on site elements.'
) }
/>
<div className="edit-site-global-styles-screen-typography">
<VStack spacing={ 6 }>
<TypographyVariations />
<VStack spacing={ 7 }>
<TypographyVariations title={ __( 'Presets' ) } />
{ ! window.__experimentalDisableFontLibrary && (
<VStack spacing={ 3 }>
{ fontLibraryEnabled && <FontFamilies /> }
Expand Down
20 changes: 17 additions & 3 deletions packages/edit-site/src/components/global-styles/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
}

.edit-site-global-styles-preview__iframe {
border-radius: $radius-block-ui;
display: block;
border-radius: $radius-block-ui + 1px; // Visually resembles the $radius-block-ui.
max-width: 100%;
display: block;
width: 100%;
}

Expand Down Expand Up @@ -53,15 +53,29 @@
}

.edit-site-global-styles-screen-colors {
margin: $grid-unit-20;
margin: $grid-unit-10 $grid-unit-20 $grid-unit-20;
richtabor marked this conversation as resolved.
Show resolved Hide resolved

.color-block-support-panel {
padding-left: 0;
padding-right: 0;
padding-top: 0;
border-top: none;
row-gap: calc(#{$grid-unit-05} * 3);
}
}

.edit-site-global-styles-screen-colors__palette-count {
color: $gray-700;
}

.edit-site-global-styles-sidebar__more-menu > .components-button.has-icon {
richtabor marked this conversation as resolved.
Show resolved Hide resolved
// Make the DropdownMenu the same size as the rest of the buttons, as it does not support "compact" size.
height: $grid-unit-40;
min-width: $grid-unit-40;
padding: 0;
width: $grid-unit-40;
}

.edit-site-global-styles-header__description {
padding: 0 $grid-unit-20;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,45 @@
cursor: pointer;

.edit-site-global-styles-variations_item-preview {
padding: $border-width * 2;
border-radius: $radius-block-ui;
box-shadow: 0 0 0 $border-width $gray-200;
// Shown in Windows 10 high contrast mode.
outline: 1px solid transparent;
position: relative;
transition: box-shadow 0.1s linear;

&::after {
richtabor marked this conversation as resolved.
Show resolved Hide resolved
content: "";
position: absolute;
top: -$border-width;
left: -$border-width;
bottom: -$border-width;
right: -$border-width;
border-radius: $radius-block-ui + $border-width; // Visually resembles the $radius-block-ui.
box-shadow: inset 0 0 0 $border-width rgba(0, 0, 0, 0.2);
// Show a thin outline in Windows high contrast mode, otherwise the button is invisible.
border: $border-width solid transparent;
box-sizing: inherit;
transition: box-shadow 0.1s linear;
}

.edit-site-global-styles-color-variations & {
padding: $grid-unit-10;
}
}

&.is-active .edit-site-global-styles-variations_item-preview {
box-shadow: 0 0 0 $border-width $gray-900;
// Shown in Windows 10 high contrast mode.
outline-width: 3px;
}

&:hover .edit-site-global-styles-variations_item-preview {
box-shadow: 0 0 0 $border-width var(--wp-admin-theme-color);
&:not(.is-active):hover .edit-site-global-styles-variations_item-preview::after {
box-shadow: inset 0 0 0 $border-width rgba(0, 0, 0, 0.4);
}

&:focus .edit-site-global-styles-variations_item-preview {
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
}
&.is-active .edit-site-global-styles-variations_item-preview,
&:focus-visible .edit-site-global-styles-variations_item-preview {
box-shadow: inset 0 0 0 $border-width $white, 0 0 0 var(--wp-admin-border-width-focus) $gray-900;

&:focus-visible {
// Shown in Windows 10 high contrast mode.
outline: 3px solid transparent;
outline-offset: 0;
outline-width: 3px;

&::after {
box-shadow: inset 0 0 0 1px $white;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import {
import Variation from './variation';
import StylesPreviewColors from '../preview-colors';
import { useColorVariations } from '../hooks';
import Subtitle from '../subtitle';

export default function ColorVariations() {
export default function ColorVariations( { title, gap = 2 } ) {
const colorVariations = useColorVariations();

if ( ! colorVariations?.length ) {
Expand All @@ -22,7 +23,8 @@ export default function ColorVariations() {

return (
<VStack spacing={ 3 }>
<Grid columns={ 3 }>
{ title && <Subtitle level={ 3 }>{ title }</Subtitle> }
<Grid columns={ 3 } gap={ gap }>
{ colorVariations.map( ( variation, index ) => (
<Variation key={ index } variation={ variation }>
{ () => <StylesPreviewColors /> }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ import { useTypographyVariations } from '../hooks';
import TypographyExample from '../typography-example';
import PreviewIframe from '../preview-iframe';
import Variation from './variation';
import Subtitle from '../subtitle';

export default function TypographyVariations() {
export default function TypographyVariations( { title, gap = 2 } ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not super keen on adding gap as a prop. Style variations have a gap of 3 in both contexts, so I'd rather keep that for consistency and simplicity.

Copy link
Member Author

Choose a reason for hiding this comment

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

Style variations have a gap of 3 in both contexts, so I'd rather keep that for consistency and simplicity.

They shouldn't though. In the smaller context of the Inspector, the gap should be 2, but in the wider context of the dark material, they need a gap of 3.

Copy link
Member Author

Choose a reason for hiding this comment

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

If you have another idea to achieve the same result, I'm open to it.

Copy link
Contributor

Choose a reason for hiding this comment

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

I updated the styles tiles to use a gap of 3 in site view.

const typographyVariations = useTypographyVariations();

if ( ! typographyVariations?.length ) {
Expand All @@ -24,8 +25,10 @@ export default function TypographyVariations() {

return (
<VStack spacing={ 3 }>
{ title && <Subtitle level={ 3 }>{ title }</Subtitle> }
<Grid
columns={ 3 }
gap={ gap }
className="edit-site-global-styles-style-variations-container"
>
{ typographyVariations &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,13 @@ function SidebarNavigationScreenGlobalStylesContent() {
>
<StyleVariationsContainer />
{ colorVariations?.length && (
<div>
<h3 className="edit-site-global-styles-variation-title">
{ __( 'Colors' ) }
</h3>
<ColorVariations />
</div>
<ColorVariations title={ __( 'Colors' ) } gap={ 3 } />
) }
{ typographyVariations?.length && (
<div>
<h3 className="edit-site-global-styles-variation-title">
{ __( 'Typography' ) }
</h3>
<TypographyVariations />
</div>
<TypographyVariations
title={ __( 'Typography' ) }
gap={ 3 }
/>
) }
</VStack>
</BlockEditorProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,21 @@
font-weight: 500;
}

.edit-site-sidebar-navigation-screen__content .edit-site-global-styles-style-variations-container {
.edit-site-sidebar-navigation-screen__content .edit-site-global-styles-variations_item {
.edit-site-global-styles-variations_item-preview {
box-shadow: 0 0 0 $border-width $gray-900;
}
.edit-site-global-styles-variations_item.is-active .edit-site-global-styles-variations_item-preview {
box-shadow: 0 0 0 $border-width $gray-100;
}
.edit-site-global-styles-variations_item:hover .edit-site-global-styles-variations_item-preview {
box-shadow: 0 0 0 $border-width var(--wp-admin-theme-color);
}
.edit-site-global-styles-variations_item:focus .edit-site-global-styles-variations_item-preview {
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);

&:focus .edit-site-global-styles-variations_item-preview,
&.is-active .edit-site-global-styles-variations_item-preview {
box-shadow: inset 0 0 0 $border-width $gray-900, 0 0 0 var(--wp-admin-border-width-focus) $white;

// Shown in Windows 10 high contrast mode.
outline-width: 3px;

&::after {
box-shadow: inset 0 0 0 1px $gray-900;
}
}
}

Expand Down
Loading