Skip to content
Closed
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
8 changes: 4 additions & 4 deletions packages/base-styles/internal/_wpds-token-fallbacks.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)).
Expand Down
4 changes: 3 additions & 1 deletion packages/components/src/menu/style.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 6 additions & 5 deletions packages/components/src/popover/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion packages/theme/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion packages/theme/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions packages/theme/prebuilt/css/design-tokens.css
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
8 changes: 4 additions & 4 deletions packages/theme/prebuilt/js/design-token-fallbacks.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
32 changes: 16 additions & 16 deletions packages/theme/prebuilt/js/design-tokens.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2660,15 +2660,15 @@ 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: [
{
color: {
colorSpace: 'srgb',
components: [ 0, 0, 0 ],
alpha: 0.053,
alpha: 0.083,
},
offsetX: {
value: 0,
Expand All @@ -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,
Expand Down Expand Up @@ -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',
},
},
},
Expand All @@ -2747,15 +2747,15 @@ 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: [
{
color: {
colorSpace: 'srgb',
components: [ 0, 0, 0 ],
alpha: 0.053,
alpha: 0.083,
},
offsetX: {
value: 0,
Expand All @@ -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,
Expand Down Expand Up @@ -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',
},
},
},
Expand All @@ -2834,15 +2834,15 @@ 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: [
{
color: {
colorSpace: 'srgb',
components: [ 0, 0, 0 ],
alpha: 0.053,
alpha: 0.083,
},
offsetX: {
value: 0,
Expand All @@ -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,
Expand Down Expand Up @@ -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',
},
},
},
Expand All @@ -2921,15 +2921,15 @@ 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: [
{
color: {
colorSpace: 'srgb',
components: [ 0, 0, 0 ],
alpha: 0.053,
alpha: 0.083,
},
offsetX: {
value: 0,
Expand All @@ -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,
Expand Down Expand Up @@ -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',
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/theme/src/elevation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 8 additions & 13 deletions packages/theme/src/stories/elevation.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)',
Expand All @@ -30,7 +28,7 @@ const Levels = ( {
strokes,
}: {
title: ReactNode;
strokes: Strokes;
strokes: boolean;
} ) => (
<div
style={ {
Expand All @@ -49,17 +47,15 @@ const Levels = ( {
gap: '2rem',
} }
>
{ LEVELS.map( ( { token, usage, stroke } ) => (
{ LEVELS.map( ( { token, usage } ) => (
<div
key={ token }
style={ {
...text,
backgroundColor:
'var(--wpds-color-background-surface-neutral-strong)',
borderRadius: 'var(--wpds-border-radius-md)',
border: (
strokes === 'as used' ? stroke : strokes === 'all'
)
border: strokes
? 'var(--wpds-border-width-xs) solid var(--wpds-color-stroke-surface-neutral)'
: undefined,
boxShadow: `var(${ token })`,
Expand Down Expand Up @@ -89,15 +85,14 @@ const meta: Meta< Args > = {
title: 'Design System/Theme/Elevation',
args: {
background: '#fcfcfc',
strokes: 'as used',
strokes: false,
},
argTypes: {
background: { control: 'color' },
strokes: {
control: 'inline-radio',
options: [ 'as used', 'none', 'all' ],
control: 'boolean',
description:
'Which cards get a stroke. "as used" matches the components: only popovers and menus have one.',
'Add a stroke to every card. Popovers and menus have no stroke, so the shadow alone separates them from the page.',
},
},
parameters: {
Expand Down
6 changes: 3 additions & 3 deletions packages/theme/src/test/elevation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ describe( 'elevation', () => {
} );

it( 'increases shadow opacity as the background gets darker', () => {
expect( getElevationOpacity( '#ffffff' ) ).toBe( 0.05 );
expect( getElevationOpacity( '#777777' ) ).toBe( 0.193 );
expect( getElevationOpacity( '#1e1e1e' ) ).toBe( 0.272 );
expect( getElevationOpacity( '#ffffff' ) ).toBe( 0.08 );
expect( getElevationOpacity( '#777777' ) ).toBe( 0.206 );
expect( getElevationOpacity( '#1e1e1e' ) ).toBe( 0.275 );
expect( getElevationOpacity( '#000000' ) ).toBe( 0.3 );
} );
} );
Loading
Loading