diff --git a/packages/base-styles/internal/_wpds-token-fallbacks.scss b/packages/base-styles/internal/_wpds-token-fallbacks.scss index e4863a5cbf8b58..85c3a5c6e16450 100644 --- a/packages/base-styles/internal/_wpds-token-fallbacks.scss +++ b/packages/base-styles/internal/_wpds-token-fallbacks.scss @@ -173,13 +173,13 @@ $fallbacks: ( "--wpds-dimension-surface-width-xl": "720px", "--wpds-dimension-surface-width-xs": "240px", "--wpds-elevation-lg": - "0px 4px 10px #0000000e, 0px 20px 48px #0000000e, inset 0px 1px #fff0", + "0px 4px 10px #00000015, 0px 20px 48px #00000015, inset 0px 1px #fff0", "--wpds-elevation-md": - "0px 2px 4px #0000000e, 0px 8px 20px #0000000e, inset 0px 1px #fff0", + "0px 2px 4px #00000015, 0px 8px 20px #00000015, inset 0px 1px #fff0", "--wpds-elevation-sm": - "0px 1px 2px #0000000e, 0px 3px 8px #0000000e, inset 0px 1px #fff0", + "0px 1px 2px #00000015, 0px 3px 8px #00000015, inset 0px 1px #fff0", "--wpds-elevation-xs": - "0px 1px 1px #0000000e, 0px 1px 3px #0000000e, inset 0px 1px #fff0", + "0px 1px 1px #00000015, 0px 1px 3px #00000015, inset 0px 1px #fff0", "--wpds-motion-duration-lg": "300ms", "--wpds-motion-duration-md": "200ms", "--wpds-motion-duration-sm": "100ms", diff --git a/packages/components/CHANGELOG.md b/packages/components/CHANGELOG.md index b49c5b5ef48c9d..b80a0c7c8c6531 100644 --- a/packages/components/CHANGELOG.md +++ b/packages/components/CHANGELOG.md @@ -6,6 +6,7 @@ - `ToolsPanel`: Use WPDS colors for the reset label and the disabled "Reset all" menu item. Legacy `--wp-components-color-accent-darker-10` overrides no longer affect them ([#86797](https://github.com/WordPress/gutenberg/pull/86797)). - `CustomSelectControl`, `FormToggle`, `Menu`, `Modal`, `Popover`, `ResizableBox`, `Snackbar`, and `Tooltip`: Use the `--wpds-elevation-*` tokens for their shadows, which get stronger on darker `ThemeProvider` backgrounds ([#87287](https://github.com/WordPress/gutenberg/pull/87287)). +- `Menu` and `Popover`: Remove the visible stroke, so the elevation shadow alone separates them from the page. `Popover` keeps its stroke in the alternate style and an outline in forced-colors mode. - `Badge`: Use the `--wpds-typography-line-height-sm` token for its line height ([#87154](https://github.com/WordPress/gutenberg/pull/87154)). - `TimePicker`: Use the WordPress UI select for choosing a month ([#87079](https://github.com/WordPress/gutenberg/pull/87079)). - `QueryControls`: Use the WordPress UI select for the Order by field and show a placeholder when the current sort is missing or unavailable ([#87078](https://github.com/WordPress/gutenberg/pull/87078)). diff --git a/packages/components/src/menu/style.module.scss b/packages/components/src/menu/style.module.scss index 1ea2f1e7e31fef..194a10e213d5de 100644 --- a/packages/components/src/menu/style.module.scss +++ b/packages/components/src/menu/style.module.scss @@ -29,7 +29,9 @@ background-color: $components-color-background; border-radius: $radius-medium; - box-shadow: 0 0 0 $border-width $components-color-gray-300, var(--wpds-elevation-md); + // No stroke: the elevation shadow alone separates the menu from what's + // beneath it. Forced colors gets the `.menu` outline instead. + box-shadow: var(--wpds-elevation-md); &:where(.is-toolbar) { box-shadow: 0 0 0 $border-width $components-color-foreground; diff --git a/packages/components/src/popover/style.scss b/packages/components/src/popover/style.scss index fcc02a9c6bcd1e..41cc467b6ac124 100644 --- a/packages/components/src/popover/style.scss +++ b/packages/components/src/popover/style.scss @@ -5,7 +5,6 @@ $arrow-triangle-base-size: 14px; -$shadow-popover-border-default: 0 0 0 var(--wpds-border-width-xs) var(--wpds-color-stroke-surface-neutral); $shadow-popover-border-default-alternate: 0 0 0 $border-width $gray-900; $shadow-popover-border-top-only: 0 calc(var(--wpds-border-width-xs) * -1) 0 0 var(--wpds-color-stroke-surface-neutral); $shadow-popover-border-top-only-alternate: 0 #{-$border-width} 0 $gray-900; @@ -26,8 +25,9 @@ $shadow-popover-border-top-only-alternate: 0 #{-$border-width} 0 $gray-900; .components-popover__content { background: var(--wpds-color-background-surface-neutral-strong); - // The stroke stays on the box-shadow, since consumers override it there. - box-shadow: $shadow-popover-border-default, var(--wpds-elevation-md); + // No stroke: the elevation shadow alone separates the popover from what's + // beneath it. Forced colors still gets an outline (see below). + box-shadow: var(--wpds-elevation-md); border-radius: var(--wpds-border-radius-md); box-sizing: border-box; width: min-content; @@ -143,10 +143,11 @@ $shadow-popover-border-top-only-alternate: 0 #{-$border-width} 0 $gray-900; } .components-popover__triangle-border { - // Stroke colors are the same as the .components-popover__content's outline + // The default popover has no stroke, so neither does its arrow. The + // alternate and forced-colors treatments below still draw one. fill: transparent; stroke-width: var(--wpds-border-width-xs); - stroke: var(--wpds-color-stroke-surface-neutral); + stroke: transparent; .is-alternate & { stroke: $gray-900; diff --git a/packages/theme/CHANGELOG.md b/packages/theme/CHANGELOG.md index de1e6ba29254f4..c9a8f892d11161 100644 --- a/packages/theme/CHANGELOG.md +++ b/packages/theme/CHANGELOG.md @@ -4,7 +4,7 @@ ### New Features -- Add `--wpds-elevation-xs`, `--wpds-elevation-sm`, `--wpds-elevation-md`, and `--wpds-elevation-lg` shadow tokens. Each level is two black shadows and a 1px inset white highlight along the top edge. `ThemeProvider` strengthens both as the background seed gets darker: the shadows from 5% opacity on white to 30% on black, and the highlight from 0% to 10% ([#87287](https://github.com/WordPress/gutenberg/pull/87287)). +- Add `--wpds-elevation-xs`, `--wpds-elevation-sm`, `--wpds-elevation-md`, and `--wpds-elevation-lg` shadow tokens. Each level is two black shadows and a 1px inset white highlight along the top edge. `ThemeProvider` strengthens both as the background seed gets darker: the shadows from 8% opacity on white to 30% on black, and the highlight from 0% to 10% ([#87287](https://github.com/WordPress/gutenberg/pull/87287)). ### Internal diff --git a/packages/theme/README.md b/packages/theme/README.md index 3946866f176d4b..4d98118ebc50e1 100644 --- a/packages/theme/README.md +++ b/packages/theme/README.md @@ -229,7 +229,7 @@ The `cornerRadius` prop sets the overall roundness preset for the theme subtree. `ThemeProvider` has no light or dark mode. It accepts color seeds and turns them into semantic design tokens. Consumers define light and dark themes by choosing those seeds: a light background seed makes the generated color ramp favor darker contrasting colors, while a dark background seed makes it favor lighter contrasting colors. The primary seed controls the accent color rather than the overall light or dark appearance. -The background seed also sets the strength of the `--wpds-elevation-*` shadows. Black shadows show less against a dark background, so their opacity increases as the background gets darker, from 5% on white to 30% on black. Each level also has a 1px white highlight inset along its top edge, which follows the same curve: invisible on white, up to 10% on black. +The background seed also sets the strength of the `--wpds-elevation-*` shadows. Black shadows show less against a dark background, so their opacity increases as the background gets darker, from 8% on white to 30% on black. Each level also has a 1px white highlight inset along its top edge, which follows the same curve: invisible on white, up to 10% on black. ### Nesting Providers diff --git a/packages/theme/prebuilt/css/design-tokens.css b/packages/theme/prebuilt/css/design-tokens.css index 47e70dcc3434c2..2f9dd30da2d5bd 100644 --- a/packages/theme/prebuilt/css/design-tokens.css +++ b/packages/theme/prebuilt/css/design-tokens.css @@ -313,16 +313,16 @@ --wpds-dimension-surface-width-xs: 240px; /* Elevation for surfaces that sit above the whole page, such as dialogs and drawers. */ --wpds-elevation-lg: - 0px 4px 10px #0000000e, 0px 20px 48px #0000000e, inset 0px 1px #fff0; + 0px 4px 10px #00000015, 0px 20px 48px #00000015, inset 0px 1px #fff0; /* Elevation for floating surfaces anchored to a trigger, such as popovers and menus. */ --wpds-elevation-md: - 0px 2px 4px #0000000e, 0px 8px 20px #0000000e, inset 0px 1px #fff0; + 0px 2px 4px #00000015, 0px 8px 20px #00000015, inset 0px 1px #fff0; /* Elevation for small transient surfaces close to their trigger, such as tooltips. */ --wpds-elevation-sm: - 0px 1px 2px #0000000e, 0px 3px 8px #0000000e, inset 0px 1px #fff0; + 0px 1px 2px #00000015, 0px 3px 8px #00000015, inset 0px 1px #fff0; /* Elevation for small controls raised slightly above their surface, such as a switch thumb. */ --wpds-elevation-xs: - 0px 1px 1px #0000000e, 0px 1px 3px #0000000e, inset 0px 1px #fff0; + 0px 1px 1px #00000015, 0px 1px 3px #00000015, inset 0px 1px #fff0; /* Deliberate animations like slides and reveals */ --wpds-motion-duration-lg: 300ms; /* Standard transitions like menus and popovers */ diff --git a/packages/theme/prebuilt/js/design-token-fallbacks.mjs b/packages/theme/prebuilt/js/design-token-fallbacks.mjs index 2602e1921cbc01..7c3cb6316583a9 100644 --- a/packages/theme/prebuilt/js/design-token-fallbacks.mjs +++ b/packages/theme/prebuilt/js/design-token-fallbacks.mjs @@ -171,13 +171,13 @@ export default { '--wpds-dimension-surface-width-xl': '720px', '--wpds-dimension-surface-width-xs': '240px', '--wpds-elevation-lg': - '0px 4px 10px #0000000e, 0px 20px 48px #0000000e, inset 0px 1px #fff0', + '0px 4px 10px #00000015, 0px 20px 48px #00000015, inset 0px 1px #fff0', '--wpds-elevation-md': - '0px 2px 4px #0000000e, 0px 8px 20px #0000000e, inset 0px 1px #fff0', + '0px 2px 4px #00000015, 0px 8px 20px #00000015, inset 0px 1px #fff0', '--wpds-elevation-sm': - '0px 1px 2px #0000000e, 0px 3px 8px #0000000e, inset 0px 1px #fff0', + '0px 1px 2px #00000015, 0px 3px 8px #00000015, inset 0px 1px #fff0', '--wpds-elevation-xs': - '0px 1px 1px #0000000e, 0px 1px 3px #0000000e, inset 0px 1px #fff0', + '0px 1px 1px #00000015, 0px 1px 3px #00000015, inset 0px 1px #fff0', '--wpds-motion-duration-lg': '300ms', '--wpds-motion-duration-md': '200ms', '--wpds-motion-duration-sm': '100ms', diff --git a/packages/theme/prebuilt/js/design-tokens.mjs b/packages/theme/prebuilt/js/design-tokens.mjs index 0182e734f02809..bb44082af630e0 100644 --- a/packages/theme/prebuilt/js/design-tokens.mjs +++ b/packages/theme/prebuilt/js/design-tokens.mjs @@ -2660,7 +2660,7 @@ export const tokens = /** @type {const} */ ( { $type: 'shadow', group: 'elevation', fallback: - '0px 1px 1px #0000000e, 0px 1px 3px #0000000e, inset 0px 1px #fff0', + '0px 1px 1px #00000015, 0px 1px 3px #00000015, inset 0px 1px #fff0', modes: { default: { $value: [ @@ -2668,7 +2668,7 @@ export const tokens = /** @type {const} */ ( { color: { colorSpace: 'srgb', components: [ 0, 0, 0 ], - alpha: 0.053, + alpha: 0.083, }, offsetX: { value: 0, @@ -2692,7 +2692,7 @@ export const tokens = /** @type {const} */ ( { color: { colorSpace: 'srgb', components: [ 0, 0, 0 ], - alpha: 0.053, + alpha: 0.083, }, offsetX: { value: 0, @@ -2737,7 +2737,7 @@ export const tokens = /** @type {const} */ ( { inset: true, }, ], - css: '0px 1px 1px #0000000e, 0px 1px 3px #0000000e, inset 0px 1px #fff0', + css: '0px 1px 1px #00000015, 0px 1px 3px #00000015, inset 0px 1px #fff0', }, }, }, @@ -2747,7 +2747,7 @@ export const tokens = /** @type {const} */ ( { $type: 'shadow', group: 'elevation', fallback: - '0px 1px 2px #0000000e, 0px 3px 8px #0000000e, inset 0px 1px #fff0', + '0px 1px 2px #00000015, 0px 3px 8px #00000015, inset 0px 1px #fff0', modes: { default: { $value: [ @@ -2755,7 +2755,7 @@ export const tokens = /** @type {const} */ ( { color: { colorSpace: 'srgb', components: [ 0, 0, 0 ], - alpha: 0.053, + alpha: 0.083, }, offsetX: { value: 0, @@ -2779,7 +2779,7 @@ export const tokens = /** @type {const} */ ( { color: { colorSpace: 'srgb', components: [ 0, 0, 0 ], - alpha: 0.053, + alpha: 0.083, }, offsetX: { value: 0, @@ -2824,7 +2824,7 @@ export const tokens = /** @type {const} */ ( { inset: true, }, ], - css: '0px 1px 2px #0000000e, 0px 3px 8px #0000000e, inset 0px 1px #fff0', + css: '0px 1px 2px #00000015, 0px 3px 8px #00000015, inset 0px 1px #fff0', }, }, }, @@ -2834,7 +2834,7 @@ export const tokens = /** @type {const} */ ( { $type: 'shadow', group: 'elevation', fallback: - '0px 2px 4px #0000000e, 0px 8px 20px #0000000e, inset 0px 1px #fff0', + '0px 2px 4px #00000015, 0px 8px 20px #00000015, inset 0px 1px #fff0', modes: { default: { $value: [ @@ -2842,7 +2842,7 @@ export const tokens = /** @type {const} */ ( { color: { colorSpace: 'srgb', components: [ 0, 0, 0 ], - alpha: 0.053, + alpha: 0.083, }, offsetX: { value: 0, @@ -2866,7 +2866,7 @@ export const tokens = /** @type {const} */ ( { color: { colorSpace: 'srgb', components: [ 0, 0, 0 ], - alpha: 0.053, + alpha: 0.083, }, offsetX: { value: 0, @@ -2911,7 +2911,7 @@ export const tokens = /** @type {const} */ ( { inset: true, }, ], - css: '0px 2px 4px #0000000e, 0px 8px 20px #0000000e, inset 0px 1px #fff0', + css: '0px 2px 4px #00000015, 0px 8px 20px #00000015, inset 0px 1px #fff0', }, }, }, @@ -2921,7 +2921,7 @@ export const tokens = /** @type {const} */ ( { $type: 'shadow', group: 'elevation', fallback: - '0px 4px 10px #0000000e, 0px 20px 48px #0000000e, inset 0px 1px #fff0', + '0px 4px 10px #00000015, 0px 20px 48px #00000015, inset 0px 1px #fff0', modes: { default: { $value: [ @@ -2929,7 +2929,7 @@ export const tokens = /** @type {const} */ ( { color: { colorSpace: 'srgb', components: [ 0, 0, 0 ], - alpha: 0.053, + alpha: 0.083, }, offsetX: { value: 0, @@ -2953,7 +2953,7 @@ export const tokens = /** @type {const} */ ( { color: { colorSpace: 'srgb', components: [ 0, 0, 0 ], - alpha: 0.053, + alpha: 0.083, }, offsetX: { value: 0, @@ -2998,7 +2998,7 @@ export const tokens = /** @type {const} */ ( { inset: true, }, ], - css: '0px 4px 10px #0000000e, 0px 20px 48px #0000000e, inset 0px 1px #fff0', + css: '0px 4px 10px #00000015, 0px 20px 48px #00000015, inset 0px 1px #fff0', }, }, }, diff --git a/packages/theme/src/elevation.ts b/packages/theme/src/elevation.ts index b8c4d78e00a89c..1ea46778cab2b1 100644 --- a/packages/theme/src/elevation.ts +++ b/packages/theme/src/elevation.ts @@ -4,7 +4,7 @@ import { ColorSpace, getLuminance, sRGB } from 'colorjs.io/fn'; * Shadow opacity range. The lightest background (white) gets `min`, the * darkest (black) gets `max`. */ -const ELEVATION_OPACITY = { min: 0.05, max: 0.3 }; +const ELEVATION_OPACITY = { min: 0.08, max: 0.3 }; /** * Top-edge highlight opacity range. White gets `min` (no highlight), black diff --git a/packages/theme/src/stories/elevation.story.tsx b/packages/theme/src/stories/elevation.story.tsx index 8e15dd666939e4..e266f68c8c2bde 100644 --- a/packages/theme/src/stories/elevation.story.tsx +++ b/packages/theme/src/stories/elevation.story.tsx @@ -6,13 +6,11 @@ import { getElevationOpacity, getHighlightOpacity } from '../elevation'; const LEVELS = [ { token: '--wpds-elevation-xs', usage: 'Switch thumb' }, { token: '--wpds-elevation-sm', usage: 'Tooltip' }, - { token: '--wpds-elevation-md', usage: 'Popover, menu', stroke: true }, + { token: '--wpds-elevation-md', usage: 'Popover, menu' }, { token: '--wpds-elevation-lg', usage: 'Dialog, drawer' }, ]; -type Strokes = 'as used' | 'none' | 'all'; - -type Args = { background: string; strokes: Strokes }; +type Args = { background: string; strokes: boolean }; const text: CSSProperties = { color: 'var(--wpds-color-foreground-content-neutral)', @@ -30,7 +28,7 @@ const Levels = ( { strokes, }: { title: ReactNode; - strokes: Strokes; + strokes: boolean; } ) => (