Skip to content
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
4 changes: 4 additions & 0 deletions packages/base-styles/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Internal

- Regenerate the WPDS fallback map with the solid neutral interactive background state tokens. ([#82391](https://github.com/WordPress/gutenberg/pull/82391))

### Enhancements

- Add a `$block-bg-padding` variable that resolves the default background padding through the `--wp--style--block-background-padding` custom property, keeping the existing values as its fallback ([#82024](https://github.com/WordPress/gutenberg/pull/82024)).
Expand Down
3 changes: 3 additions & 0 deletions packages/base-styles/internal/_wpds-token-fallbacks.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ $fallbacks: (
"--wpds-color-background-interactive-error-weak": "#0000",
"--wpds-color-background-interactive-error-weak-active": "#f6e6e3",
"--wpds-color-background-interactive-error-weak-disabled": "#0000",
"--wpds-color-background-interactive-neutral": "#fff",
"--wpds-color-background-interactive-neutral-active": "#fff",
"--wpds-color-background-interactive-neutral-disabled": "#fff",
"--wpds-color-background-interactive-neutral-strong": "#2d2d2d",
"--wpds-color-background-interactive-neutral-strong-active": "#1e1e1e",
"--wpds-color-background-interactive-neutral-strong-disabled": "#e6e6e6",
Expand Down
1 change: 1 addition & 0 deletions packages/dataviews/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

### Enhancements

- Give unselected multi-selection filter indicators solid, themed backgrounds. ([#82391](https://github.com/WordPress/gutenberg/pull/82391))
- Validated form controls: Use `--wpds-color-stroke-interactive-error` for the invalid-state focus ring and border ([#82410](https://github.com/WordPress/gutenberg/pull/82410)).
- DataForm: Communicate the timezone a `datetime` value is edited in. When the site timezone differs from the visitor's, the control renders help text under the input naming the site timezone: the zone name (e.g. `(CEST) Europe/Madrid`) or the UTC offset for sites pinned to one ([#82291](https://github.com/WordPress/gutenberg/pull/82291)).
- Export the `DataViewsProps` and `ItemWithId` types ([#82326](https://github.com/WordPress/gutenberg/pull/82326)).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,9 @@
}

.dataviews-filters__search-widget-listitem-multi-selection {
/* stylelint-disable-next-line plugin-wpds/no-token-fallback-values -- Preserve custom background theming with older @wordpress/theme runtimes that do not set this token. */
background-color: var(--wpds-color-background-interactive-neutral, var(--wpds-color-background-surface-neutral-strong));
border-color: var(--wpds-color-stroke-interactive-brand-active);
background: var(--wpds-color-background-surface-neutral-strong);

&.is-selected {
border-color: var(--wpds-color-stroke-interactive-brand-active);
Expand Down Expand Up @@ -289,7 +290,8 @@

@include checkbox-control;
position: relative;
background: var(--wpds-color-background-interactive-neutral-weak);
/* stylelint-disable-next-line plugin-wpds/no-token-fallback-values -- Preserve custom background theming with older @wordpress/theme runtimes that do not set this token. */
background: var(--wpds-color-background-interactive-neutral, var(--wpds-color-background-surface-neutral-strong));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Confirmed that the fallback injection plugin will turn this into var(--wpds-color-background-interactive-neutral, var(--wpds-color-background-surface-neutral-strong, #fff)), which I guess is what we want.

Preserve theming when WordPress supplies an older token stylesheet

To be clear though, WordPress supplying an old token stylesheet is not going to be a problem, because we have fallbacks. The problem is only when an old wp.theme.ThemeProvider is wrapping DataViews using a non-default background seed, I think. Which I don't think anybody is doing, because DataViews itself is not really theme-ready yet.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yep, an older ThemeProvider with a custom background seed is the case this protects 👌

I updated the comments to say that explicitly and kept the fallback consistent across the affected controls.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If this kind of thing happens a lot, we may want to handle back compat fallbacks in our fallback plugins eventually.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, let's keep an eye

color: var(--wpds-color-foreground-content-neutral);
margin: 0;
padding: 0;
Expand Down
4 changes: 4 additions & 0 deletions packages/theme/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### New Features

- Add neutral interactive background tokens for resting, active, and disabled input and selection control states. ([#82391](https://github.com/WordPress/gutenberg/pull/82391))

### Documentation

- Explain how consumers define light and dark themes through `ThemeProvider` color seeds ([#82039](https://github.com/WordPress/gutenberg/pull/82039)).
Expand Down
3 changes: 3 additions & 0 deletions packages/theme/docs/tokens.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ The semantic token set is role-based, not a complete matrix of every property, t
| `--wpds-color-background-surface-caution-weak` | Background color for surfaces with caution tone and weak emphasis. |
| `--wpds-color-background-surface-error` | Background color for surfaces with error tone and normal emphasis. |
| `--wpds-color-background-surface-error-weak` | Background color for surfaces with error tone and weak emphasis. |
| `--wpds-color-background-interactive-neutral` | Solid background color for neutral interactive controls, such as input fields and unchecked checkboxes. |
| `--wpds-color-background-interactive-neutral-active` | Solid background color for neutral interactive controls that are hovered, focused, or active. |
| `--wpds-color-background-interactive-neutral-disabled` | Solid background color for neutral interactive controls in their disabled state. |
| `--wpds-color-background-interactive-neutral-strong` | Background color for interactive elements with neutral tone and strong emphasis. |
| `--wpds-color-background-interactive-neutral-strong-active` | Background color for interactive elements with neutral tone and strong emphasis that are hovered, focused, or active. |
| `--wpds-color-background-interactive-neutral-strong-disabled` | Background color for interactive elements with neutral tone and strong emphasis, in their disabled state. |
Expand Down
6 changes: 6 additions & 0 deletions packages/theme/prebuilt/css/design-tokens.css
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@
--wpds-color-background-surface-error: #f6e6e3;
/* Background color for surfaces with error tone and weak emphasis. */
--wpds-color-background-surface-error-weak: #fff6f5;
/* Solid background color for neutral interactive controls, such as input fields and unchecked checkboxes. */
--wpds-color-background-interactive-neutral: #fff;
/* Solid background color for neutral interactive controls that are hovered, focused, or active. */
--wpds-color-background-interactive-neutral-active: #fff;
/* Solid background color for neutral interactive controls in their disabled state. */
--wpds-color-background-interactive-neutral-disabled: #fff;
/* Background color for interactive elements with neutral tone and strong emphasis. */
--wpds-color-background-interactive-neutral-strong: #2d2d2d;
/* Background color for interactive elements with neutral tone and strong emphasis that are hovered, focused, or active. */
Expand Down
3 changes: 3 additions & 0 deletions packages/theme/prebuilt/js/design-token-fallbacks.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ export default {
'--wpds-color-background-interactive-error-weak': '#0000',
'--wpds-color-background-interactive-error-weak-active': '#f6e6e3',
'--wpds-color-background-interactive-error-weak-disabled': '#0000',
'--wpds-color-background-interactive-neutral': '#fff',
'--wpds-color-background-interactive-neutral-active': '#fff',
'--wpds-color-background-interactive-neutral-disabled': '#fff',
'--wpds-color-background-interactive-neutral-strong': '#2d2d2d',
'--wpds-color-background-interactive-neutral-strong-active': '#1e1e1e',
'--wpds-color-background-interactive-neutral-strong-disabled': '#e6e6e6',
Expand Down
3 changes: 3 additions & 0 deletions packages/theme/prebuilt/js/design-tokens.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ export default [
'--wpds-color-background-surface-caution-weak',
'--wpds-color-background-surface-error',
'--wpds-color-background-surface-error-weak',
'--wpds-color-background-interactive-neutral',
'--wpds-color-background-interactive-neutral-active',
'--wpds-color-background-interactive-neutral-disabled',
'--wpds-color-background-interactive-neutral-strong',
'--wpds-color-background-interactive-neutral-strong-active',
'--wpds-color-background-interactive-neutral-strong-disabled',
Expand Down
7 changes: 6 additions & 1 deletion packages/theme/src/prebuilt/ts/color-tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,12 @@ export default {
'background-interactive-neutral-strong-disabled',
],
'bg-surface4': [ 'background-interactive-neutral-weak-active' ],
'bg-surface3': [ 'background-surface-neutral-strong' ],
'bg-surface3': [
'background-interactive-neutral',
'background-interactive-neutral-active',
'background-interactive-neutral-disabled',
'background-surface-neutral-strong',
],
'bg-fgSurface4': [
'foreground-content-neutral',
'foreground-interactive-neutral',
Expand Down
1 change: 1 addition & 0 deletions packages/theme/src/prebuilt/ts/token-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export type SurfaceBackgroundColor =
* Background color variants for interactive elements.
*/
export type InteractiveBackgroundColor =
| 'neutral'
| 'neutral-strong'
| 'neutral-weak'
| 'brand-strong'
Expand Down
20 changes: 20 additions & 0 deletions packages/theme/src/semantic-color-contrast-pairs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@
export const MINIMUM_TEXT_CONTRAST = 4.5;

export const SEMANTIC_COLOR_CONTRAST_PAIRS = [
{
background: 'background.interactive.neutral',
foreground: 'foreground.interactive.neutral',
},
{
background: 'background.interactive.neutral',
foreground: 'foreground.interactive.neutral-weak',
},
{
background: 'background.interactive.neutral-active',
foreground: 'foreground.interactive.neutral',
},
{
background: 'background.interactive.neutral-active',
foreground: 'foreground.interactive.neutral-weak',
},
{
background: 'background.interactive.neutral-weak-active',
foreground: 'foreground.interactive.neutral-active',
},
{
background: 'background.surface.neutral',
foreground: 'foreground.content.neutral',
Expand Down
21 changes: 21 additions & 0 deletions packages/theme/src/test/build-plugin-parity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,27 @@ describe( 'design token fallback build plugin parity', () => {
);
} );

it( 'keeps nested token fallbacks aligned across PostCSS and Lightning CSS', async () => {
const filename = join( fixturesDirectory, 'nested-fallback.css' );
const source = `
.fixture {
background: var(--wpds-color-background-interactive-neutral-active, var(--wpds-color-background-surface-neutral-strong));
}`;
const postcssResult = await postcss( [ postcssPlugin ] ).process(
source,
{ from: filename }
);
const lightningcssResult = transformWithLightningcss(
source,
filename
);
const expected =
'var(--wpds-color-background-interactive-neutral-active, var(--wpds-color-background-surface-neutral-strong, #fff))';

expect( postcssResult.css ).toContain( expected );
expect( lightningcssResult ).toContain( expected );
} );

it( 'leaves an empty var() fallback untouched in PostCSS', async () => {
const source = await readFile( emptyFallbackCssFixture, 'utf8' );
const result = await postcss( [ postcssPlugin ] ).process( source, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,29 @@ describe( 'useThemeProviderStyles', () => {
).toBe( '#1e90ff' );
} );

it( 'emits neutral interactive background state properties from the background ramp', () => {
const { result } = renderHook( () =>
useThemeProviderStyles( { color: { background: '#222222' } } )
);
const styles = result.current.themeProviderStyles;

expect(
styles[ '--wpds-color-background-interactive-neutral' ]
).toBe(
styles[ '--wpds-color-background-surface-neutral-strong' ]
);
expect(
styles[ '--wpds-color-background-interactive-neutral-active' ]
).toBe(
styles[ '--wpds-color-background-surface-neutral-strong' ]
);
expect(
styles[ '--wpds-color-background-interactive-neutral-disabled' ]
).toBe(
styles[ '--wpds-color-background-surface-neutral-strong' ]
);
} );

it( 're-emits inherited color tokens so portaled subtrees can re-apply them', () => {
const wrapper = ( { children }: { children: ReactNode } ) => (
<ThemeProvider
Expand Down
12 changes: 12 additions & 0 deletions packages/theme/tokens/color.json
Original file line number Diff line number Diff line change
Expand Up @@ -1162,6 +1162,18 @@
}
},
"interactive": {
"neutral": {
"$value": "{wpds-color.primitive.bg.surface3}",
"$description": "Solid background color for neutral interactive controls, such as input fields and unchecked checkboxes."
},
"neutral-active": {
"$value": "{wpds-color.primitive.bg.surface3}",
"$description": "Solid background color for neutral interactive controls that are hovered, focused, or active."
},
"neutral-disabled": {
"$value": "{wpds-color.primitive.bg.surface3}",
"$description": "Solid background color for neutral interactive controls in their disabled state."
},
"neutral-strong": {
"$value": "{wpds-color.primitive.bg.bgFillInverted1}",
"$description": "Background color for interactive elements with neutral tone and strong emphasis."
Expand Down
1 change: 1 addition & 0 deletions packages/ui/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

### Enhancements

- Give input fields and checkboxes solid, state-aware themed backgrounds while keeping minimal Select triggers transparent. ([#82391](https://github.com/WordPress/gutenberg/pull/82391))
- `AlertDialog`, `Dialog`, `Drawer`, `Popover`, and `Tooltip`: Derive Trigger props from the corresponding Base UI components. ([#81824](https://github.com/WordPress/gutenberg/pull/81824))
- `Autocomplete.Status`, `Combobox.Status`: Add a `Status` subcomponent that announces async list status to screen readers. Item popups give Status its own collapsing grid row so a visible result count sits above the list without overlaying items ([#82195](https://github.com/WordPress/gutenberg/pull/82195)).
- `Autocomplete.Popup`, `Combobox.Popup`, `SearchableChipSelect`, `SearchableChipSelectControl`, `Select.Popup`, and `SelectControl`: Add `width` on Popups and `popupWidth` on composites, with preset width constraints (`anchor`, `content`, `sm`, `md`, `lg`, and `available`) for the item popup. `SelectControl` defaults to `content` to preserve prior popup sizing ([#82087](https://github.com/WordPress/gutenberg/pull/82087), [#82193](https://github.com/WordPress/gutenberg/pull/82193)).
Expand Down
8 changes: 6 additions & 2 deletions packages/ui/src/form/primitives/checkbox/style.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@
var(--wpds-border-width-xs) solid
var(--wpds-color-stroke-interactive-neutral);
padding: 0;
background-color: var(--wpds-color-background-interactive-neutral-weak);
/* stylelint-disable-next-line plugin-wpds/no-token-fallback-values -- Preserve custom background theming with older @wordpress/theme runtimes that do not set this token. */
background-color: var(--wpds-color-background-interactive-neutral, var(--wpds-color-background-surface-neutral-strong));

&:not([data-disabled]) {
cursor: var(--wpds-cursor-control);
}

[data-highlighted] &,
&:hover {
/* stylelint-disable-next-line plugin-wpds/no-token-fallback-values -- Preserve custom background theming with older @wordpress/theme runtimes that do not set this token. */
background-color: var(--wpds-color-background-interactive-neutral-active, var(--wpds-color-background-surface-neutral-strong));
border-color: var(--wpds-color-stroke-interactive-neutral-active);
}

Expand All @@ -34,7 +37,8 @@
}

&[data-disabled] {
background-color: var(--wpds-color-background-interactive-neutral-weak-disabled);
/* stylelint-disable-next-line plugin-wpds/no-token-fallback-values -- Preserve custom background theming with older @wordpress/theme runtimes that do not set this token. */
background-color: var(--wpds-color-background-interactive-neutral-disabled, var(--wpds-color-background-surface-neutral-strong));
border-color: var(--wpds-color-stroke-interactive-neutral-disabled);
color: var(--wpds-color-foreground-interactive-neutral-disabled);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

display: flex;
height: var(--wpds-dimension-size-lg);
background-color: var(--wpds-color-background-interactive-neutral-weak);
/* stylelint-disable-next-line plugin-wpds/no-token-fallback-values -- Preserve custom background theming with older @wordpress/theme runtimes that do not set this token. */
background-color: var(--wpds-color-background-interactive-neutral, var(--wpds-color-background-surface-neutral-strong));
border-width: var(--wpds-border-width-xs);
border-style: solid;
border-color: var(--wpds-color-stroke-interactive-neutral);
Expand All @@ -33,7 +34,8 @@

&.is-disabled,
&:has([data-can-disable-input-layout][data-disabled]) {
background-color: var(--wpds-color-background-interactive-neutral-weak-disabled);
/* stylelint-disable-next-line plugin-wpds/no-token-fallback-values -- Preserve custom background theming with older @wordpress/theme runtimes that do not set this token. */
background-color: var(--wpds-color-background-interactive-neutral-disabled, var(--wpds-color-background-surface-neutral-strong));
border-color: var(--wpds-color-stroke-interactive-neutral-disabled);
color: var(--wpds-color-foreground-interactive-neutral-disabled);

Expand All @@ -44,6 +46,7 @@
}

&.is-borderless {
background-color: var(--wpds-color-background-interactive-neutral-weak);
border-color: transparent;
Comment on lines 48 to 50

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There's a specificity bug here, but it's preexisting and out of scope so I'll fix it separately.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

}

Expand All @@ -55,6 +58,8 @@
}

&:hover:not(.is-disabled, :has([data-can-disable-input-layout][data-disabled]), .is-borderless) {
/* stylelint-disable-next-line plugin-wpds/no-token-fallback-values -- Preserve custom background theming with older @wordpress/theme runtimes that do not set this token. */
background-color: var(--wpds-color-background-interactive-neutral-active, var(--wpds-color-background-surface-neutral-strong));
border-color: var(--wpds-color-stroke-interactive-neutral-active);
}

Expand Down
Loading