Skip to content

Commit

Permalink
Components: use new theming accent color in all components (#45289)
Browse files Browse the repository at this point in the history
  • Loading branch information
chad1008 authored Nov 9, 2022
1 parent d8a4c9c commit 3afffb3
Show file tree
Hide file tree
Showing 26 changed files with 53 additions and 46 deletions.
4 changes: 4 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@

- `NumberControl`: Replace `hideHTMLArrows` prop with `spinControls` prop. Allow custom spin controls via `spinControls="custom"` ([#45333](https://github.com/WordPress/gutenberg/pull/45333)).

### 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
6 changes: 3 additions & 3 deletions packages/components/src/checkbox-control/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ $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;

// 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);
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
4 changes: 2 additions & 2 deletions packages/components/src/form-token-field/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,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 +183,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;
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
2 changes: 1 addition & 1 deletion packages/components/src/search-control/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

&: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;
}

&::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 @@ -65,8 +65,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 @@ -400,8 +400,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.themeDark10 };
font-size: 11px;
font-weight: 500;
line-height: 1.4;
Expand Down
6 changes: 4 additions & 2 deletions packages/components/src/utils/colors-values.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ 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 = {
theme: ADMIN.theme,
themeDark10: ADMIN.themeDark10,
background: white,
backgroundDisabled: GRAY[ 100 ],
border: GRAY[ 700 ],
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

0 comments on commit 3afffb3

Please sign in to comment.