Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Components: use new theming accent color in all components #45289

Merged
merged 35 commits into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
32ea922
update emotion color value variables
chad1008 Oct 25, 2022
bd8d776
update AnglePickerControl component color variables
chad1008 Oct 25, 2022
19a4342
simplify AnglePickerControl color declaration
chad1008 Oct 26, 2022
3ca9aac
update Autocomplete color variable
chad1008 Oct 26, 2022
2b4b9d3
update BaseField snapshot color variable
chad1008 Oct 26, 2022
d4738d9
update CheckboxControl color variables
chad1008 Oct 26, 2022
6c927e0
add explicit border color to CheckboxControl input when focused
chad1008 Oct 26, 2022
6ab0cd9
update ColorPalette color variable
chad1008 Oct 26, 2022
f60dd7b
update DropZone color variable
chad1008 Oct 26, 2022
ce2d6b6
update FormToggle color variable
chad1008 Oct 26, 2022
014fc5d
update FormTokenfield color variables
chad1008 Oct 26, 2022
4ca7afb
update navigate-regions color variables
chad1008 Oct 26, 2022
0be1ffb
update CheckboxControl's overrides for @wordpress/base-styles mixins
chad1008 Oct 26, 2022
324fd16
update FormTokenField's overrides for @wordpress/base-styles mixins
chad1008 Oct 26, 2022
c9183b0
update MenuItem color variable
chad1008 Oct 26, 2022
3b9fc6d
update Notice color variable
chad1008 Oct 26, 2022
63ce620
update Panel color variable
chad1008 Oct 26, 2022
487d7ec
update RangeControl color variables
chad1008 Oct 26, 2022
c8b8872
update ResizableBox color variables
chad1008 Oct 26, 2022
8cc2715
update SearchControl color variable
chad1008 Oct 26, 2022
f66c05f
update SearchControl's override for @wordpress/base-styles mixins
chad1008 Oct 26, 2022
891fc6f
update SnackBar color variable
chad1008 Oct 26, 2022
98f1898
update Spinner color variable
chad1008 Oct 26, 2022
1bd21f4
update TabPanel color variables
chad1008 Oct 27, 2022
f0c9bfb
update ToggleGroupControl snapshot color variables
chad1008 Oct 27, 2022
a03c416
update ToolsPanel color variable
chad1008 Oct 27, 2022
920fc07
update utils/input color variables (used for TextAreaControl)
chad1008 Oct 27, 2022
95a90a0
Add override for block mover handle focused state
chad1008 Oct 27, 2022
06ac815
update CHANGELOG
chad1008 Oct 27, 2022
b46a409
update `Notice` Readme
chad1008 Oct 27, 2022
afbde74
update preferences modal unit test snapshot
chad1008 Nov 1, 2022
ed277e0
update post-publish-panel unit test snapshot
chad1008 Nov 1, 2022
7b5a322
add missing semicolon
chad1008 Nov 1, 2022
78fe867
Revert all @base-styles overrides to be addressed separately
chad1008 Nov 3, 2022
a4151e4
expose COLORS.ui.themeDark10 for uses where it makes more sense seman…
chad1008 Nov 3, 2022
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/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
- `Autocomplete`: use Popover's new `placement` prop instead of legacy `position` prop ([#44396](https://github.com/WordPress/gutenberg/pull/44396/)).
- `FontSizePicker`: Add more comprehensive tests ([#45298](https://github.com/WordPress/gutenberg/pull/45298)).

### Experimental
- Theming: updated Components package to utilize the new `accent` prop of the experimental `Theme` component.


## 21.3.0 (2022-10-19)

### Bug Fix
Expand Down
3 changes: 2 additions & 1 deletion packages/components/src/angle-picker-control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { Root } from './styles/angle-picker-control-styles';
import { space } from '../ui/utils/space';
import { Text } from '../text';
import { Spacer } from '../spacer';
import { COLORS } from '../utils/colors-values';

export default function AnglePickerControl( {
/** Start opting into the new margin-free styles that will become the default in a future version. */
Expand Down Expand Up @@ -70,7 +71,7 @@ export default function AnglePickerControl( {
marginBottom={ 0 }
marginRight={ space( 3 ) }
style={ {
color: 'var( --wp-admin-theme-color )',
color: COLORS.ui.theme,
} }
>
°
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/autocomplete/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
width: 100%;

&.is-selected {
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) $components-color-accent;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ exports[`base field should render correctly 1`] = `

.emotion-0:focus,
.emotion-0[data-focused='true'] {
border-color: var( --wp-admin-theme-color, #007cba);
box-shadow: 0 0 0 0.5px var( --wp-admin-theme-color, #007cba);
border-color: var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
box-shadow: 0 0 0 0.5px var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
}

<div
Expand Down
5 changes: 5 additions & 0 deletions packages/components/src/button/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,11 @@
.components-visually-hidden {
height: auto;
}

// Override for theming on the block mover handle. `.block-editor-block-mover__drag-handle` was needed for specificity to override declaration order.
.components-accessible-toolbar &.block-editor-block-mover__drag-handle:focus::before {
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) $components-color-accent, inset 0 0 0 4px $white;
}
Copy link
Member

Choose a reason for hiding this comment

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

I am very reluctant to let block-editor taint this file again because Marco just recently cleaned it up 😄

I'm thinking we should leave all the non-components-package stuff for later so we can address it in a coordinated way.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm thinking we should leave all the non-components-package stuff for later so we can address it in a coordinated way.

Do you mean all overrides, including the ones related to the base styles? Or just the overrides needed for other packages too (i.e block editor) ?

Copy link
Member

Choose a reason for hiding this comment

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

In this comment I was referring to the latter (other packages like block-editor). But yeah, I think base-styles is better addressed separately as well.

The basic principle I'm trying to stick with is that Theme is a wp-components concept, and wp-components is the upstream dependency, so if downstream packages like block-editor want to participate they need to use whatever API that wp-components has provided. What that API should look like is to be decided, but we'll probably need to export $components-color-accent, COLORS.ui.theme, etc from wp-components.

Copy link
Contributor

Choose a reason for hiding this comment

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

In this comment I was referring to the latter (other packages like block-editor). But yeah, I think base-styles is better addressed separately as well.

The basic principle I'm trying to stick with is that Theme is a wp-components concept, and wp-components is the upstream dependency, so if downstream packages like block-editor want to participate they need to use whatever API that wp-components has provided.

Agreed on both points.

What that API should look like is to be decided, but we'll probably need to export $components-color-accent, COLORS.ui.theme, etc from wp-components.

We'll have to be careful in doing this, since we won't be able to undo these API decisions (because of WordPress backwards compat rules).

I also wonder what is the better format to expose those theme variables — as Sass + Emotion vars, as CSS vars.

}

@keyframes components-button__busy-animation {
Expand Down
10 changes: 6 additions & 4 deletions packages/components/src/checkbox-control/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,18 @@ $checkbox-input-size-sm: 24px; // Width & height for small viewports.
@include reduce-motion("transition");

&:focus {
box-shadow: 0 0 0 ($border-width * 2) $white, 0 0 0 ($border-width * 2 + $border-width-focus) var(--wp-admin-theme-color);
box-shadow: 0 0 0 ($border-width * 2) $white, 0 0 0 ($border-width * 2 + $border-width-focus) $components-color-accent;
border-color: $components-color-accent;
Copy link
Contributor Author

@chad1008 chad1008 Oct 26, 2022

Choose a reason for hiding this comment

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

border-color was added because without it, the focused input box retained the default --wp-admin-theme-color border color:

Before: After:
Screen Shot 2022-10-26 at 07 43 30 Screen Shot 2022-10-26 at 07 43 09

I wasn't able to identify the source of the clashing style, so it's either something coming from outside the package, or just something more experienced eyes will be able to locate more easily 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On second thought, as I continue working this doesn't feel like the right solution. I'm seeing other, similar border issues (e.g. on FormTokenField).

They look suspiciously like the focus styles in utils/input/base.js (which will be updated during the course of this PR), but updating the vars in that file doesn't seem to have an impact. Once I sort out what's actually going on, this added border-color declaration will probably be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After some guidance from @ciampo, was able to identify the @wordpress/base-styles mixins that were at the root of these colors. I've also added &[aria-checked="mixed"] to the CheckboxControl's styles, as that was also using the --wp-admin-theme-color in the mixin.

Copy link
Contributor

Choose a reason for hiding this comment

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

@mirka this may be a recurring theme (pun not intended) — some styles may come from the base-styles package, and we'll have to decide if we should override them in the components package with our own theme variable, or if we should just leave them as they are.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There were a few more of these as well. I've added comments and/or isolated those changes in separate commits so they're easy to remove if we decide to leave them alone for the time being.

Copy link
Member

Choose a reason for hiding this comment

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

Interesting! I played around with how CSS variable reassignment works to see if it would suffice for our use case, but unfortunately it all becomes circular so it won't work 😂

.component-foo {
  // It would've been nice if the var() was evaluated before assignment, but it doesn't work like that 🙃
  --wp-admin-theme-color: var(--wp-admin-theme-color, somefallback);

  @include some-base-styles-mixin;
}

I am actually now considering decoupling wp-components from some of the base-styles mixins (i.e. copy/paste the relevant stuff over). The mixin dependencies were already hard to work with in wp-components, not to mention being a blocker for Emotion migration. In this CheckboxControl for example, you can see some of the styles are duplicated for some/no reason. And the fact that WP's "canonical" CheckboxControl styles have already diverged from the base-styles mixin means that the mixin isn't useful for style consistency anyway 🤷

tl;dr — For this PR I am fine with leaving the base-styles overrides out, so we can address them in a coordinated way later.

Copy link
Contributor

Choose a reason for hiding this comment

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

I am actually now considering decoupling wp-components from some of the base-styles mixins

That's my gut feeling too. On one hand, those mixins have the potential to provide consistent styles throughout the whole Gutenberg repo — but on the other hand, they are written in a way that makes them too leaky and hard to work with as a "loose" dependency.

If the net result is that today we have to write many overrides for those mixins anyway, I agree that we should decouple them from wpcomponents, and move over the relevant stuff in a way that works better for the package

Copy link
Contributor

Choose a reason for hiding this comment

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

tl;dr — For this PR I am fine with leaving the base-styles overrides out, so we can address them in a coordinated way later.

Should we have a tracking issue where we list the overrides? Or do you think that the problem is so widespread that it's a wasted effort?

Copy link
Member

Choose a reason for hiding this comment

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

Should we have a tracking issue where we list the overrides? Or do you think that the problem is so widespread that it's a wasted effort?

If it's useful for task coordination, sure. I think it's mostly just @include input-control.

Copy link
Contributor

Choose a reason for hiding this comment

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

Cool. I also proposed it since Chad mentioned that there are a few instances where he had to add such overrides:

I've added comments and/or isolated those changes in separate commits so they're easy to remove if we decide to leave them alone for the time being.


// Only visible in Windows High Contrast mode.
outline: 2px solid transparent;
}

&:checked,
&:indeterminate {
background: var(--wp-admin-theme-color);
border-color: var(--wp-admin-theme-color);
&:indeterminate,
&[aria-checked="mixed"] {
background: $components-color-accent;
border-color: $components-color-accent;

// Hide default checkbox styles in IE.
&::-ms-check {
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/color-palette/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
outline: 1px solid transparent;

&:focus {
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) $components-color-accent;
// Show a outline in Windows high contrast mode.
outline-width: 2px;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/drop-zone/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
height: 100%;
width: 100%;
display: flex;
background-color: var(--wp-admin-theme-color);
background-color: $components-color-accent;
align-items: center;
justify-content: center;
z-index: z-index(".components-drop-zone__content");
Expand Down
6 changes: 3 additions & 3 deletions packages/components/src/form-toggle/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ $toggle-border-width: 1px;

// Checked state.
&.is-checked .components-form-toggle__track {
background-color: var(--wp-admin-theme-color);
border: $toggle-border-width solid var(--wp-admin-theme-color);
background-color: $components-color-accent;
border: $toggle-border-width solid $components-color-accent;
border: #{ $toggle-height * 0.5 } solid transparent; // Expand the border to fake a solid in Windows High Contrast Mode.
}

.components-form-toggle__input:focus + .components-form-toggle__track {
box-shadow: 0 0 0 2px $white, 0 0 0 (2px + $border-width-focus) var(--wp-admin-theme-color);
box-shadow: 0 0 0 2px $white, 0 0 0 (2px + $border-width-focus) $components-color-accent;

// Windows High Contrast mode will show this outline, but not the box-shadow.
outline: 2px solid transparent;
Expand Down
11 changes: 9 additions & 2 deletions packages/components/src/form-token-field/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@

&.is-active {
@include input-style__focus();
border-color: $components-color-accent;
box-shadow: 0 0 0 ($border-width-focus - $border-width) $components-color-accent;
}

&:focus {
border-color: $components-color-accent;
box-shadow: 0 0 0 ($border-width-focus - $border-width) $components-color-accent;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

border-color and box-shadow were previously defined by @wordpress/base-styles for both .is-active and :focus. For now, overrides have been added to the component styles to allow theming to take effect.

}

// Token input
Expand Down Expand Up @@ -88,7 +95,7 @@

.components-form-token-field__token-text {
background: transparent;
color: var(--wp-admin-theme-color);
color: $components-color-accent;
}

.components-form-token-field__remove-token {
Expand Down Expand Up @@ -183,7 +190,7 @@
cursor: pointer;

&.is-selected {
background: var(--wp-admin-theme-color);
background: $components-color-accent;
color: $white;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
right: 0;
pointer-events: none;
outline: 4px solid transparent; // Shown in Windows High Contrast mode.
box-shadow: inset 0 0 0 4px var(--wp-admin-theme-color);
box-shadow: inset 0 0 0 4px $components-color-accent;
}

@supports ( outline-offset: 1px ) {
Expand All @@ -24,7 +24,7 @@

&:focus {
outline-style: solid;
outline-color: var(--wp-admin-theme-color);
outline-color: $components-color-accent;
outline-width: 4px;
outline-offset: -4px;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/menu-item/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
// Override the button component's tertiary background and color.
&.is-tertiary {
background: none;
color: var(--wp-admin-theme-color-darker-10);
color: $components-color-accent-darker-10;
opacity: 0.3;
}
}
Expand Down
3 changes: 2 additions & 1 deletion packages/components/src/notice/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ Notices display at the top of the screen, below any toolbars anchored to the top
Notices are color-coded to indicate the type of message being communicated:

- **Default** notices have **no background**.
- **Informational** notices are **blue.**
- **Informational** notices are **blue** by default.
- If there is a parent `Theme` component with an `accent` color prop, informational notices will take on that color instead.
- **Success** notices are **green.**
- **Warning** notices are **yellow\*\***.\*\*
- **Error** notices are **red.**
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/notice/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
font-family: $default-font;
font-size: $default-font-size;
background-color: $white;
border-left: 4px solid var(--wp-admin-theme-color);
border-left: 4px solid $components-color-accent;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is an interesting case for theming... on some themes (like the "Sunset" theme we're currently using in Storybook) the notices can take on an orange color. With another theme it could even be red. These colors on notices usually have more meaning than they would in other components, indicating the severity/urgency of the notice.

Not sure if/how that impacts how we'd want to apply theming on this component.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's an interesting point. I will note that the success, warning and error statues of notice already have a hardcoded border color (a few lines below in this file), and so this specific rule would only affect the "default" and
"informational" statuses.

Current behaviour is also explained in the README — we should keep that in mind in case it needs updating too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Current behaviour is also explained in the README — we should keep that in mind in case it needs updating too

Good call. I've added an update to the README ✅

margin: 5px 15px 2px;
padding: 8px 12px;
align-items: center;
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/panel/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
height: auto;

&:focus {
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) $components-color-accent;
border-radius: 0;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ const thumbColor = ( { disabled }: ThumbProps ) =>
background-color: ${ COLORS.gray[ 400 ] };
`
: css`
background-color: var( --wp-admin-theme-color );
background-color: ${ COLORS.ui.theme };
`;

export const ThumbWrapper = styled.span`
Expand Down Expand Up @@ -205,7 +205,7 @@ const thumbFocus = ( { isFocused }: ThumbProps ) => {
&::before {
content: ' ';
position: absolute;
background-color: var( --wp-admin-theme-color );
background-color: ${ COLORS.ui.theme };
opacity: 0.4;
border-radius: 50%;
height: ${ thumbSize + 8 }px;
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/resizable-box/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ $resize-handler-container-size: $resize-handler-size + ($grid-unit-05 * 2); // M
top: calc(50% - #{ceil($resize-handler-size * 0.5)});
right: calc(50% - #{ceil($resize-handler-size * 0.5)});

box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) $components-color-accent;
// Only visible in Windows High Contrast mode.
outline: 2px solid transparent;
}
Expand All @@ -47,7 +47,7 @@ $resize-handler-container-size: $resize-handler-size + ($grid-unit-05 * 2); // M
content: "";
width: 3px;
height: 3px;
background: var(--wp-admin-theme-color);
background: $components-color-accent;
cursor: inherit;
position: absolute;
top: calc(50% - 1px);
Expand Down
3 changes: 2 additions & 1 deletion packages/components/src/search-control/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

&:focus {
background: $white;
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) $components-color-accent;
border-color: $components-color-accent;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

border-color was previously defined by @wordpress/base-styles for:focus. For now, an override has been added to the component styles to allow theming to take effect.

}

&::placeholder {
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/snackbar/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
&:focus {
box-shadow:
0 0 0 1px $white,
0 0 0 3px var(--wp-admin-theme-color);
0 0 0 3px $components-color-accent;
}

&.components-snackbar-explicit-dismiss {
Expand Down Expand Up @@ -64,7 +64,7 @@
}

&:hover {
color: var(--wp-admin-theme-color);
color: $components-color-accent;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/spinner/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const StyledSpinner = styled.svg`
display: inline-block;
margin: 5px 11px 0;
position: relative;
color: var( --wp-admin-theme-color );
color: ${ COLORS.ui.theme };
overflow: visible;
`;

Expand Down
9 changes: 4 additions & 5 deletions packages/components/src/tab-panel/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,12 @@
}

&:focus:not(:disabled) {
box-shadow: inset 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
box-shadow: inset 0 var(--wp-admin-border-width-focus) $components-color-accent;
}


&.is-active {
// The transparent shadow ensures no jumpiness when focus animates on an active tab.
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) transparent, inset 0 0 -$border-width-tab 0 0 var(--wp-admin-theme-color);
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) transparent, inset 0 0 -$border-width-tab 0 0 $components-color-accent;
position: relative;

// This border appears in Windows High Contrast mode instead of the box-shadow.
Expand All @@ -55,10 +54,10 @@
}

&:focus {
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) $components-color-accent;
}

&.is-active:focus {
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color), inset 0 -#{$border-width-tab * 2} 0 0 var(--wp-admin-theme-color);
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) $components-color-accent, inset 0 -#{$border-width-tab * 2} 0 0 $components-color-accent;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ exports[`ToggleGroupControl should render correctly with icons 1`] = `
}

.emotion-8:focus-within {
border-color: var( --wp-admin-theme-color-darker-10, #006ba1);
box-shadow: 0 0 0 0.5px var( --wp-admin-theme-color, #007cba);
border-color: var(--wp-components-color-accent-darker-10, var(--wp-admin-theme-color-darker-10, #006ba1));
box-shadow: 0 0 0 0.5px var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
outline: none;
z-index: 1;
}
Expand Down Expand Up @@ -402,8 +402,8 @@ exports[`ToggleGroupControl should render correctly with text options 1`] = `
}

.emotion-8:focus-within {
border-color: var( --wp-admin-theme-color-darker-10, #006ba1);
box-shadow: 0 0 0 0.5px var( --wp-admin-theme-color, #007cba);
border-color: var(--wp-components-color-accent-darker-10, var(--wp-admin-theme-color-darker-10, #006ba1));
box-shadow: 0 0 0 0.5px var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
outline: none;
z-index: 1;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/tools-panel/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export const DropdownMenu = css`
`;

export const ResetLabel = styled.span`
color: var( --wp-admin-theme-color-darker-10 );
color: ${ COLORS.ui.borderFocus };
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Along with this change, there are a couple of other pre-existing places in the codebase where this variable is being used for things other than a border... do we want to consider renaming it in utils/color-values.js in a followup PR?

Copy link
Member

Choose a reason for hiding this comment

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

We haven't yet audited these "semantic" color variables yet, so I don't know whether any of them are still relevant. The semantics are potentially useful when theming so we should keep them around until we audit them. That also means I don't want to force any new usages into these existing semantics if it doesn't make sense.

This ResetLabel isn't related to a borderFocus, so I would consider exposing a COLORS.ui.themeDark10 that we can use here. (Aaand it looks like you already did that! 😄)

Also unclear why this ResetLabel is a darker-10 and not just the theme color 🤔 Do you remember, @aaronrobertshaw?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also unclear why this ResetLabel is a darker-10 and not just the theme color 🤔 Do you remember

Thanks for the ping.

I'm drawing a blank on why that CSS var was actually used.

As long as the color of the ResetLabel matches the "Saved" in the top toolbar when saving a draft post it will satisfy the request here.

Further context and history can be found in #44260.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Was looking at this with @mirka a little and this button doesn't have a disabled state, the 'reset' just isn't displayed when it isn't an option.

Looking at the focused/hovered state, I think I'd recommend we keep the current darker color. If the Reset span is given the same accent color as the rest of the list item, it becomes difficult to differentiate which button you're actually interacting with:

Screen.Recording.2022-11-03.at.11.36.59.mov

With the current darker color, there's at least a little contrast creating some distinction, though it is really subtle. We may want something with more contrast/decoration, but probably not something for this PR.

Any objection to keeping the slightly darker reset for now, using the newly exposed variable?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, we can keep it as is 👍 Thanks for looking into it.

font-size: 11px;
font-weight: 500;
line-height: 1.4;
Expand Down
5 changes: 3 additions & 2 deletions packages/components/src/utils/colors-values.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ const ALERT = {

// Matches @wordpress/base-styles
const ADMIN = {
theme: 'var( --wp-admin-theme-color, #007cba)',
themeDark10: 'var( --wp-admin-theme-color-darker-10, #006ba1)',
theme: 'var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba))',
themeDark10:
'var(--wp-components-color-accent-darker-10, var(--wp-admin-theme-color-darker-10, #006ba1))',
};

const UI = {
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/utils/input/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ export const inputStyleNeutral = css`
`;

export const inputStyleFocus = css`
border-color: var( --wp-admin-theme-color );
border-color: ${ COLORS.ui.theme };
box-shadow: 0 0 0
calc( ${ CONFIG.borderWidthFocus } - ${ CONFIG.borderWidth } )
var( --wp-admin-theme-color );
${ COLORS.ui.theme };

// Windows High Contrast mode will show this outline, but not the box-shadow.
outline: 2px solid transparent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -580,13 +580,13 @@ exports[`EditPostPreferencesModal should match snapshot when the modal is active
}

.emotion-13:hover {
color: var( --wp-admin-theme-color, #007cba);
color: var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
}

.emotion-13:focus {
background-color: transparent;
color: var( --wp-admin-theme-color, #007cba);
border-color: var( --wp-admin-theme-color, #007cba);
color: var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
border-color: var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
outline: 3px solid transparent;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ exports[`PostPublishPanel should render the spinner if the post is being saved 1
display: inline-block;
margin: 5px 11px 0;
position: relative;
color: var( --wp-admin-theme-color );
color: var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
overflow: visible;
}

Expand Down