Skip to content

Commit

Permalink
Components: Clean up unused and duplicate COLORS values (#43445)
Browse files Browse the repository at this point in the history
* Remove unused colors

* Fix incorrect fallback values for theme colors

* Remove unused color

It's only used in the RangeControl Wrapper, and it always gets overriden by another color.

* Consolidate admin.theme with ui.theme

* Consolidate `mediumGray.text` with `gray[ 700 ]`

* Remove unused lightGray values

* Simplify `white` color

* Rename G2.gray

* Add missing $gray-800

* Add deprecation warnings

* Remove unused deprecated grays

* Move out non-deprecated placeholder colors

* Improve comments

* Add changelog

* Update snapshots

* Add Object.freeze for better type checking

* Fix existing lint errors

* Fixup remaining blues
  • Loading branch information
mirka authored Aug 23, 2022
1 parent b439e5f commit 19efda3
Show file tree
Hide file tree
Showing 17 changed files with 72 additions and 170 deletions.
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
### Internal

- `Tooltip`: Refactor tests to `@testing-library/react` ([#43061](https://github.com/WordPress/gutenberg/pull/43061)).
- Clean up unused and duplicate `COLORS` values ([#43445](https://github.com/WordPress/gutenberg/pull/43445)).
- Update `floating-ui` to the latest version ([#43206](https://github.com/WordPress/gutenberg/pull/43206)).
- `DateTimePicker`, `TimePicker`, `DatePicker`: Switch from `moment` to `date-fns` ([#43005](https://github.com/WordPress/gutenberg/pull/43005)).
- `DatePicker`: Switch from `react-dates` to `use-lilius` ([#43005](https://github.com/WordPress/gutenberg/pull/43005)).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ export const Row = styled.div`
const pointActive = ( { isActive } ) => {
const boxShadow = isActive ? `0 0 0 2px ${ COLORS.gray[ 900 ] }` : null;
const pointColor = isActive ? COLORS.gray[ 900 ] : COLORS.lightGray[ 800 ];
const pointColorHover = isActive
? COLORS.gray[ 900 ]
: COLORS.blue.medium.focus;
const pointColorHover = isActive ? COLORS.gray[ 900 ] : COLORS.ui.theme;

return css`
box-shadow: ${ boxShadow };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ export const CircleIndicatorWrapper = styled.div`
`;

export const CircleIndicator = styled.div`
background: ${ COLORS.admin.theme };
background: ${ COLORS.ui.theme };
border-radius: 50%;
border: ${ INNER_CIRCLE_SIZE }px solid ${ COLORS.admin.theme };
border: ${ INNER_CIRCLE_SIZE }px solid ${ COLORS.ui.theme };
bottom: 0;
box-sizing: border-box;
display: block;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const StyledHelp = styled.p`
margin-bottom: 0;
font-size: ${ font( 'helpText.fontSize' ) };
font-style: normal;
color: ${ COLORS.mediumGray.text };
color: ${ COLORS.gray[ 700 ] };
${ deprecatedMarginHelp }
`;
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/base-field/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const BaseField = css`
&:focus,
&[data-focused='true'] {
border-color: ${ COLORS.admin.theme };
border-color: ${ COLORS.ui.theme };
box-shadow: ${ CONFIG.controlBoxShadowFocus };
}
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ exports[`base field should render correctly 1`] = `
.emotion-0:focus,
.emotion-0[data-focused='true'] {
border-color: var( --wp-admin-theme-color, #00669b);
box-shadow: 0 0 0 0.5px var( --wp-admin-theme-color, #00669b);
border-color: var( --wp-admin-theme-color, #007cba);
box-shadow: 0 0 0 0.5px var( --wp-admin-theme-color, #007cba);
}
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export const Container = styled.div`

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

export const PointerIconPathFill = styled( Path )`
fill: ${ COLORS.blue.wordpress[ 700 ] };
fill: ${ COLORS.ui.theme };
`;
6 changes: 3 additions & 3 deletions packages/components/src/item-group/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ export const unstyledButton = css`
text-align: left;
&:hover {
color: ${ COLORS.admin.theme };
color: ${ COLORS.ui.theme };
}
&:focus {
background-color: transparent;
color: ${ COLORS.admin.theme };
border-color: ${ COLORS.admin.theme };
color: ${ COLORS.ui.theme };
border-color: ${ COLORS.ui.theme };
outline: 3px solid transparent;
}
`;
Expand Down
11 changes: 6 additions & 5 deletions packages/components/src/palette-edit/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const IndicatorStyled = styled( CircularOptionPicker.Option )`
export const NameInputControl = styled( InputControl )`
${ InputControlContainer } {
background: ${ COLORS.gray[ 100 ] };
border-radius: ${ CONFIG.controlBorderRadius }};
border-radius: ${ CONFIG.controlBorderRadius };
${ Input }${ Input }${ Input }${ Input } {
height: ${ space( 8 ) };
}
Expand Down Expand Up @@ -58,7 +58,7 @@ export const PaletteItem = styled( View )`
border-top-color: transparent;
}
&.is-selected {
border-color: ${ COLORS.blue.wordpress[ 700 ] };
border-color: ${ COLORS.ui.theme };
}
`;

Expand All @@ -69,7 +69,7 @@ export const NameContainer = styled.div`
white-space: nowrap;
overflow: hidden;
${ PaletteItem }:hover & {
color: var( --wp-admin-theme-color, ${ COLORS.blue.wordpress[ 700 ] } );
color: ${ COLORS.ui.theme };
}
`;

Expand All @@ -95,8 +95,9 @@ export const PaletteHStackHeader = styled( HStack )`
export const PaletteEditStyles = styled( View )`
&&& {
.components-button.has-icon {
min-width: 0;
padding: 0;
min-width: 0;
padding: 0;
}
}
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ const wrapperMargin = ( { marks, __nextHasNoMarginBottom }: WrapperProps ) => {
};

export const Wrapper = styled.div< WrapperProps >`
color: ${ COLORS.blue.medium.focus };
display: block;
flex: 1;
position: relative;
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/text/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const destructive = css`
`;

export const muted = css`
color: ${ COLORS.mediumGray.text };
color: ${ COLORS.gray[ 700 ] };
`;

export const highlighterText = css`
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/text/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe( 'Text', () => {
<Text variant="muted">Lorem ipsum.</Text>
);
expect( container.firstChild ).toHaveStyle( {
color: COLORS.mediumGray.text,
color: COLORS.gray[ 700 ],
} );
} );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ exports[`ToggleGroupControl should render correctly with icons 1`] = `
}
.emotion-6:focus-within {
border-color: var( --wp-admin-theme-color-darker-10, #007cba);
box-shadow: 0 0 0 0.5px var( --wp-admin-theme-color, #00669b);
border-color: var( --wp-admin-theme-color-darker-10, #006ba1);
box-shadow: 0 0 0 0.5px var( --wp-admin-theme-color, #007cba);
outline: none;
z-index: 1;
}
Expand Down Expand Up @@ -326,8 +326,8 @@ exports[`ToggleGroupControl should render correctly with text options 1`] = `
}
.emotion-6:focus-within {
border-color: var( --wp-admin-theme-color-darker-10, #007cba);
box-shadow: 0 0 0 0.5px var( --wp-admin-theme-color, #00669b);
border-color: var( --wp-admin-theme-color-darker-10, #006ba1);
box-shadow: 0 0 0 0.5px var( --wp-admin-theme-color, #007cba);
outline: none;
z-index: 1;
}
Expand Down
Loading

0 comments on commit 19efda3

Please sign in to comment.