Skip to content

Commit

Permalink
Components: Add eslint rule for theme var regressions (#58130)
Browse files Browse the repository at this point in the history
* Components: Add eslint rule for theme var regressions

* Fix in ItemGroup and DropdownMenuV2

* Update changelog

* Fix new lint error in PaletteEdit

* Fix changelog placement

Including some entries from my recent PRs
  • Loading branch information
mirka authored Jan 25, 2024
1 parent 3a283bc commit c94f863
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 11 deletions.
20 changes: 20 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,26 @@ module.exports = {
'jsdoc/require-param': 'off',
},
},
{
files: [ 'packages/components/src/**' ],
excludedFiles: [ 'packages/components/src/utils/colors-values.js' ],
rules: {
'no-restricted-syntax': [
'error',
{
selector: 'Literal[value=/--wp-admin-theme-/]',
message:
'--wp-admin-theme-* variables do not support component theming. Use variables from the COLORS object in packages/components/src/utils/colors-values.js instead.',
},
{
selector:
'TemplateElement[value.cooked=/--wp-admin-theme-/]',
message:
'--wp-admin-theme-* variables do not support component theming. Use variables from the COLORS object in packages/components/src/utils/colors-values.js instead.',
},
],
},
},
{
files: [ 'packages/components/src/**' ],
excludedFiles: [ 'packages/components/src/**/@(test|stories)/**' ],
Expand Down
11 changes: 9 additions & 2 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

## Unreleased

### Bug Fix

- `PaletteEdit`: Fix palette item accessibility in details view ([#58214](https://github.com/WordPress/gutenberg/pull/58214)).

### Experimental

- `Guide`, `Modal`: Restore accent color themability ([#58098](https://github.com/WordPress/gutenberg/pull/58098)).
- `DropdownMenuV2`: Restore accent color themability ([#58130](https://github.com/WordPress/gutenberg/pull/58130)).

## 25.16.0 (2024-01-24)

### Enhancements
Expand All @@ -19,13 +28,11 @@

- `ToggleGroupControl`: Improve controlled value detection ([#57770](https://github.com/WordPress/gutenberg/pull/57770)).
- `Tooltip`: Improve props forwarding to children of nested `Tooltip` components ([#57878](https://github.com/WordPress/gutenberg/pull/57878)).
- `PaletteEdit`: Fix palette item accessibility in details view ([#58214](https://github.com/WordPress/gutenberg/pull/58214)).
- `Tooltip`: revert prop types to only accept component-specific props ([#58125](https://github.com/WordPress/gutenberg/pull/58125)).
- `Button`: prevent the component from trashing and re-creating the HTML element ([#56490](https://github.com/WordPress/gutenberg/pull/56490)).

### Experimental

- `Guide`, `Modal`: Restore accent color themability ([#58098](https://github.com/WordPress/gutenberg/pull/58098)).
- `BoxControl`: Update design ([#56665](https://github.com/WordPress/gutenberg/pull/56665)).
- `CustomSelect`: adjust `renderSelectedValue` to fix sizing ([#57865](https://github.com/WordPress/gutenberg/pull/57865)).
- `Theme`: Set `color` on wrapper div ([#58095](https://github.com/WordPress/gutenberg/pull/58095)).
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/dropdown-menu-v2/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ const baseItem = css`
/* Keyboard focus (focus-visible) */
&[data-focus-visible] {
box-shadow: 0 0 0 1.5px var( --wp-admin-theme-color );
box-shadow: 0 0 0 1.5px ${ COLORS.theme.accent };
/* Only visible in Windows High Contrast mode */
outline: 2px solid transparent;
Expand Down
5 changes: 1 addition & 4 deletions packages/components/src/item-group/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ export const unstyledButton = ( as: 'a' | 'button' ) => {
&:focus-visible {
box-shadow: 0 0 0 var( --wp-admin-border-width-focus )
var(
--wp-components-color-accent,
var( --wp-admin-theme-color, ${ COLORS.theme.accent } )
);
${ COLORS.theme.accent };
// Windows high contrast mode.
outline: 2px solid transparent;
outline-offset: 0;
Expand Down
5 changes: 1 addition & 4 deletions packages/components/src/palette-edit/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,7 @@ export const PaletteItem = styled( View )`
&:focus-visible {
border-color: transparent;
box-shadow: 0 0 0 var( --wp-admin-border-width-focus )
var(
--wp-components-color-accent,
var( --wp-admin-theme-color, ${ COLORS.theme.accent } )
);
${ COLORS.theme.accent };
// Windows high contrast mode.
outline: 2px solid transparent;
outline-offset: 0;
Expand Down

0 comments on commit c94f863

Please sign in to comment.