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: Update default accent color #50193

Merged
merged 15 commits into from
May 5, 2023
6 changes: 5 additions & 1 deletion bin/packages/build-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ async function buildCSS( file ) {
]
// Editor styles should be excluded from the default CSS vars output.
.concat(
file.includes( 'common.scss' ) || ! file.includes( 'block-library' )
file.includes( 'common.scss' ) ||
! (
file.includes( 'block-library' ) ||
file.includes( 'components' )
)
? [ 'default-custom-properties' ]
: []
)
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/button/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,12 @@
padding: $grid-unit-15 * 0.5; // This reduces the horizontal padding on tertiary/text buttons, so as to space them optically.

&:hover:not(:disabled) {
// TODO: Prepare for theming (https://github.com/WordPress/gutenberg/pull/45466/files#r1030872724)
background: rgba(var(--wp-admin-theme-color--rgb), 0.04);
}

&:active:not(:disabled) {
// TODO: Prepare for theming (https://github.com/WordPress/gutenberg/pull/45466/files#r1030872724)
Comment on lines +166 to +171
Copy link
Member Author

Choose a reason for hiding this comment

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

These styles were added after our initial theming effort. Adding a TODO comment now.

background: rgba(var(--wp-admin-theme-color--rgb), 0.08);
}

Expand Down
6 changes: 6 additions & 0 deletions packages/components/src/style.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// Include the default WP Components color variables.
// TODO: Remove this once all admin-scheme variables are accounted for in the wp-components fallback values.
:root {
@include admin-scheme(#3858e9);
}

// Variables
@import "./utils/theme-variables.scss";

Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/theme/color-algorithms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function checkContrasts(
outputs: ThemeOutputValues[ 'colors' ]
) {
const background = inputs.background || COLORS.white;
const accent = inputs.accent || '#007cba';
const accent = inputs.accent || '#3858e9';
const foreground = outputs.foreground || COLORS.gray[ 900 ];
const gray = outputs.gray || COLORS.gray;

Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/theme/stories/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export const ColorScheme: ComponentStory< typeof Theme > = ( {
);
};
ColorScheme.args = {
accent: '#007cba',
accent: '#3858e9',
background: '#fff',
};
ColorScheme.argTypes = {
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/theme/test/color-algorithms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe( 'Theme color algorithms', () => {

generateThemeVariables( { background: '#eee' } );
expect( console ).toHaveWarnedWith(
'wp.components.Theme: The background color ("#eee") does not have sufficient contrast against the accent color ("#007cba").'
'wp.components.Theme: The background color ("#eee") does not have sufficient contrast against the accent color ("#3858e9").'
);
} );

Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/utils/colors-values.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ const ALERT = {

// Matches @wordpress/base-styles
mirka marked this conversation as resolved.
Show resolved Hide resolved
const ADMIN = {
theme: 'var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba))',
theme: 'var(--wp-components-color-accent, var(--wp-admin-theme-color, #3858e9))',
themeDark10:
'var(--wp-components-color-accent-darker-10, var(--wp-admin-theme-color-darker-10, #006ba1))',
'var(--wp-components-color-accent-darker-10, var(--wp-admin-theme-color-darker-10, #2145e6))',
mirka marked this conversation as resolved.
Show resolved Hide resolved
};

const UI = {
Expand Down
8 changes: 4 additions & 4 deletions packages/components/src/utils/theme-variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
//
// If the `--wp-components-color-accent` variable is not defined, fallback to
// `--wp-admin-theme-color`. If the `--wp-admin-theme-color` variable is not
// defined, fallback to the default theme color (WP blue).
$components-color-accent: var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
$components-color-accent-darker-10: var(--wp-components-color-accent-darker-10, var(--wp-admin-theme-color-darker-10, #006ba1));
$components-color-accent-darker-20: var(--wp-components-color-accent-darker-20, var(--wp-admin-theme-color-darker-20, #005a87));
// defined, fallback to the default theme color (WP blueberry).
$components-color-accent: var(--wp-components-color-accent, var(--wp-admin-theme-color, #3858e9));
$components-color-accent-darker-10: var(--wp-components-color-accent-darker-10, var(--wp-admin-theme-color-darker-10, #2145e6));
$components-color-accent-darker-20: var(--wp-components-color-accent-darker-20, var(--wp-admin-theme-color-darker-20, #183ad6));
mirka marked this conversation as resolved.
Show resolved Hide resolved

// Used when placing text on the accent color.
$components-color-accent-inverted: var(--wp-components-color-accent-inverted, $white);
Expand Down
4 changes: 2 additions & 2 deletions storybook/decorators/with-theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ const themes = {
accent: '#3858e9',
background: '#f0f0f0',
},
modern: {
accent: '#3858e9',
classic: {
accent: '#007cba',
},
};

Expand Down
3 changes: 1 addition & 2 deletions storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { WithMarginChecker } from './decorators/with-margin-checker';
import { WithMaxWidthWrapper } from './decorators/with-max-width-wrapper';
import { WithRTL } from './decorators/with-rtl';
import { WithTheme } from './decorators/with-theme';
import './style.scss';

export const globalTypes = {
direction: {
Expand All @@ -31,7 +30,7 @@ export const globalTypes = {
{ value: 'default', title: 'Default' },
{ value: 'darkBg', title: 'Dark (background)' },
{ value: 'lightGrayBg', title: 'Light gray (background)' },
{ value: 'modern', title: 'Modern (accent)' },
{ value: 'classic', title: 'Classic (accent)' },
],
},
},
Expand Down
11 changes: 0 additions & 11 deletions storybook/style.scss
Copy link
Member Author

Choose a reason for hiding this comment

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

These base styles are/should be provided by the wp packages themselves.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this file not necessary anymore? Was its actual only purpose to load --wp-admin--* variables?

Copy link
Member Author

Choose a reason for hiding this comment

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

In fact I don't know if this file was ever needed. The packages we showcase in Storybook already have the --wp-admin-* variables loaded in their main stylesheets, and any Sass dependency imports should already have been dealt with at package build time before anything hits Storybook.

This file was deleted.