Skip to content
Draft
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
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions packages/global-styles-ui/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Enhancements

- Use theme colors for the outlines of the color, typography, and style variation cards, and for their preview background and text when the site defines no colors ([#87913](https://github.com/WordPress/gutenberg/pull/87913)).

## 2.3.0 (2026-12-02)

### Enhancements
Expand Down
1 change: 1 addition & 0 deletions packages/global-styles-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"@testing-library/dom": "^10.4.2",
"@testing-library/react": "^16.3.3",
"@testing-library/user-event": "^14.6.13",
"@wordpress/theme": "file:../theme",
"vitest": "^5.1.1",
"vitest-browser-react": "^2.3.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/global-styles-ui/src/preview-styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function PreviewStyles( {
const [ headingFontWeight = fontWeight ] = useStyle< string >(
'elements.h1.typography.fontWeight'
);
const [ textColor = 'black' ] = useStyle< string >( 'color.text' );
const [ textColor ] = useStyle< string >( 'color.text' );
const [ headingColor = textColor ] = useStyle< string >(
'elements.h1.color.text'
);
Expand Down
10 changes: 8 additions & 2 deletions packages/global-styles-ui/src/preview-wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,13 @@ function PreviewWrapper( {
isFocused,
withHoverView,
}: PreviewWrapperProps ) {
const [ backgroundColor = 'white' ] =
useStyle< string >( 'color.background' );
// Without the site's own colors, the preview uses the host's surface and
// text colors, so it stays readable in any theme.
const [
backgroundColor = 'var(--wpds-color-background-surface-neutral-strong)',
] = useStyle< string >( 'color.background' );
const [ textColor = 'var(--wpds-color-foreground-content-neutral)' ] =
useStyle< string >( 'color.text' );
const [ gradientValue ] = useStyle< string >( 'color.gradient' );
const disableMotion = useReducedMotion();
const [ isHovered, setIsHovered ] = useState( false );
Expand Down Expand Up @@ -117,6 +122,7 @@ function PreviewWrapper( {
height: normalizedHeight * ratio,
width: '100%',
background: gradientValue ?? backgroundColor,
color: textColor,
} }
initial="start"
animate={
Expand Down
31 changes: 21 additions & 10 deletions packages/global-styles-ui/src/variations/style.scss
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
@use "@wordpress/base-styles/colors" as *;
@use "@wordpress/base-styles/variables" as *;

.global-styles-ui-variations_item {
box-sizing: border-box;
// To round the outline in Windows 10 high contrast mode.
cursor: var(--wpds-cursor-control);
// The preview draws the focus ring, so the item doesn't draw its own.
outline: none;

.global-styles-ui-variations_item-preview {
border-radius: var(--wpds-border-radius-sm);
outline: $border-width solid rgba($black, 0.1);
outline: $border-width solid var(--wpds-color-stroke-interactive-neutral);
outline-offset: -$border-width;
overflow: hidden;
position: relative;
Expand All @@ -26,18 +27,28 @@
}
}

&:not(.is-active):hover .global-styles-ui-variations_item-preview {
outline-color: rgba($black, 0.3);
&:hover .global-styles-ui-variations_item-preview {
outline-color: var(--wpds-color-stroke-interactive-neutral-active);
}

&.is-active .global-styles-ui-variations_item-preview,
&:focus-visible .global-styles-ui-variations_item-preview {
outline-color: $gray-900;
outline-offset: $border-width;
outline-width: var(--wp-admin-border-width-focus);
// The selected and focus rings are drawn outside the preview. A
// surface-colored band fills the gap between them and the preview, so they
// keep their contrast whatever colors the preview shows.
&.is-active,
&:focus-visible {
.global-styles-ui-variations_item-preview {
outline-offset: $border-width;
outline-width: var(--wpds-border-width-focus);
box-shadow: 0 0 0 $border-width var(--wpds-color-background-surface-neutral-strong);
}
}

// After hover, so hovering keeps the selected and focus rings.
&.is-active .global-styles-ui-variations_item-preview {
outline-color: var(--wpds-color-foreground-interactive-neutral);
}

&:focus-visible .global-styles-ui-variations_item-preview {
outline-color: var(--wp-admin-theme-color);
outline-color: var(--wpds-color-stroke-focus);
}
}
Loading
Loading