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

(JS) Color Values: Rename brand to theme. Add fallback values. #24059

Merged
merged 1 commit into from
Jul 20, 2020
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ export const Container = styled.div`

export const Side = styled.div`
box-sizing: border-box;
background: ${ color( 'ui.brand' ) };
background: ${ color( 'blue.wordpress.700' ) };
background: ${ color( 'ui.theme' ) };
filter: brightness( 1 );
opacity: 0;
position: absolute;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@ export const PointerIconPathOutline = styled( Path )`
`;

export const PointerIconPathFill = styled( Path )`
fill: ${ color( 'ui.brand' ) };
fill: ${ color( 'blue.wordpress.700' ) };
fill: ${ color( 'ui.theme' ) };
`;
2 changes: 1 addition & 1 deletion packages/components/src/range-control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function RangeControl(
beforeIcon,
className,
currentInput,
color: colorProp = color( 'ui.brand' ),
color: colorProp = color( 'ui.theme' ),
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any reason why not all use cases have fallbacks like this one?

Copy link
Author

Choose a reason for hiding this comment

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

This value is (eventually) passed into the styled generated component, which has a fallback:
https://github.com/WordPress/gutenberg/pull/24059/files#diff-bc2454ef211a3ab799a3f1c4dfe936c1R36

This workflow isn't ideal 🤦‍♀️ . I'm looking into an automated solution now.
I have something in mind 🤞

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed that automating would be good or at least a lint rule. But I'm willing to include this fix quickly if you think it's ready as is?

Copy link
Author

Choose a reason for hiding this comment

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

It is ready as is 👍

disabled = false,
help,
initialPosition,
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/range-control/stories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const DefaultExample = () => {
afterIcon: text( 'afterIcon', '' ),
allowReset: boolean( 'allowReset', false ),
beforeIcon: text( 'beforeIcon', '' ),
color: text( 'color', color( 'ui.brand' ) ),
color: text( 'color', color( 'ui.theme' ) ),
disabled: boolean( 'disabled', false ),
help: text( 'help', '' ),
label: text( 'label', 'Range Label' ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const wrapperMargin = ( { marks } ) =>

export const Wrapper = styled.span`
box-sizing: border-box;
color: ${ color( 'blue.medium.focus' ) };
display: block;
flex: 1;
padding-top: 15px;
Expand Down
10 changes: 8 additions & 2 deletions packages/components/src/utils/colors-values.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,18 @@ export const ALERT = {
green: '#4ab866',
};

export const ADMIN = {
theme: `var( --wp-admin-theme-color, ${ BLUE.wordpress[ 700 ] })`,
themeDark10: `var( --wp-admin-theme-color-darker-10, ${ BLUE.medium.focus })`,
};

// Namespaced values for raw colors hex codes
export const UI = {
theme: ADMIN.theme,
background: BASE.white,
backgroundDisabled: LIGHT_GRAY[ 200 ],
brand: `var( --wp-admin-theme-color, ${ BLUE.wordpress[ 700 ] })`,
border: G2.darkGray.primary,
borderFocus: `var( --wp-admin-theme-color-darker-10, ${ BLUE.medium.focus })`,
borderFocus: ADMIN.themeDark10,
borderDisabled: DARK_GRAY[ 700 ],
borderLight: LIGHT_GRAY[ 600 ],
label: DARK_GRAY[ 500 ],
Expand All @@ -158,6 +163,7 @@ export const COLORS = {
lightGrayLight: LIGHT_OPACITY_LIGHT,
blue: merge( {}, BLUE, G2.blue ),
alert: ALERT,
admin: ADMIN,
ui: UI,
};

Expand Down