Skip to content

Commit

Permalink
DropdownMenu V2: use themed color variables (#64647)
Browse files Browse the repository at this point in the history
* Use foreground theme color instead of hardcoded gray 900

* Use shared theme variable for gray 700 text

* Use theme variables for remaining colors.gray variables

* Update comments

* Extract lighter background color

* CHANGELOG

---

Co-authored-by: ciampo <[email protected]>
Co-authored-by: mirka <[email protected]>
  • Loading branch information
3 people authored Aug 21, 2024
1 parent 543a469 commit cc8009e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
- `Composite` v2: add `Hover` and `Typeahead` subcomponents ([#64399](https://github.com/WordPress/gutenberg/pull/64399)).
- `Composite` v2: add focus-related props to `Composite`and`Composite.Item` subcomponents ([#64450](https://github.com/WordPress/gutenberg/pull/64450)).
- `Composite` v2: add `Context` subcomponent ([#64493](https://github.com/WordPress/gutenberg/pull/64493)).
- `DropdownMenu` v2: use themed color variables ([#64647](https://github.com/WordPress/gutenberg/pull/64647)).
- `CustomSelectControl`: Improve type inferring ([#64412](https://github.com/WordPress/gutenberg/pull/64412)).
- Update `ariakit` to version `0.4.10` ([#64637](https://github.com/WordPress/gutenberg/pull/64637)).

Expand Down
26 changes: 14 additions & 12 deletions packages/components/src/dropdown-menu-v2/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ const ITEM_PADDING_BLOCK = space( 2 );
const ITEM_PADDING_INLINE = space( 3 );

// TODO:
// - those values are different from saved variables?
// - should bring this into the config, and make themeable
// - border color and divider color are different?
const DEFAULT_BORDER_COLOR = COLORS.gray[ 300 ];
const DIVIDER_COLOR = COLORS.gray[ 200 ];
const TOOLBAR_VARIANT_BORDER_COLOR = COLORS.gray[ '900' ];
// - border color and divider color are different from COLORS.theme variables
// - lighter text color is not defined in COLORS.theme, should it be?
// - lighter background color is not defined in COLORS.theme, should it be?
const DEFAULT_BORDER_COLOR = COLORS.theme.gray[ 300 ];
const DIVIDER_COLOR = COLORS.theme.gray[ 200 ];
const LIGHTER_TEXT_COLOR = COLORS.theme.gray[ 700 ];
const LIGHT_BACKGROUND_COLOR = COLORS.theme.gray[ 100 ];
const TOOLBAR_VARIANT_BORDER_COLOR = COLORS.theme.foreground;
const DEFAULT_BOX_SHADOW = `0 0 0 ${ CONFIG.borderWidth } ${ DEFAULT_BORDER_COLOR }, ${ CONFIG.elevationXSmall }`;
const TOOLBAR_VARIANT_BOX_SHADOW = `0 0 0 ${ CONFIG.borderWidth } ${ TOOLBAR_VARIANT_BORDER_COLOR }`;

Expand Down Expand Up @@ -149,7 +151,7 @@ const baseItem = css`
font-weight: normal;
line-height: 20px;
color: ${ COLORS.gray[ 900 ] };
color: ${ COLORS.theme.foreground };
border-radius: ${ CONFIG.radiusSmall };
padding-block: ${ ITEM_PADDING_BLOCK };
Expand Down Expand Up @@ -193,8 +195,8 @@ const baseItem = css`
/* When the item is the trigger of an open submenu */
${ DropdownMenu }:not(:focus) &:not(:focus)[aria-expanded="true"] {
background-color: ${ COLORS.gray[ 100 ] };
color: ${ COLORS.gray[ 900 ] };
background-color: ${ LIGHT_BACKGROUND_COLOR };
color: ${ COLORS.theme.foreground };
}
svg {
Expand Down Expand Up @@ -238,7 +240,7 @@ export const ItemPrefixWrapper = styled.span`
align-items: center;
justify-content: center;
color: ${ COLORS.gray[ '700' ] };
color: ${ LIGHTER_TEXT_COLOR };
/*
* When the parent menu item is active, except when it's a non-focused/hovered
Expand Down Expand Up @@ -284,7 +286,7 @@ export const ItemSuffixWrapper = styled.span`
justify-content: center;
gap: ${ space( 3 ) };
color: ${ COLORS.gray[ '700' ] };
color: ${ LIGHTER_TEXT_COLOR };
/*
* When the parent menu item is active, except when it's a non-focused/hovered
Expand Down Expand Up @@ -343,7 +345,7 @@ export const DropdownMenuItemLabel = styled( Truncate )`
export const DropdownMenuItemHelpText = styled( Truncate )`
font-size: ${ font( 'helpText.fontSize' ) };
line-height: 16px;
color: ${ COLORS.gray[ '700' ] };
color: ${ LIGHTER_TEXT_COLOR };
word-break: break-all;
[data-active-item]:not( [data-focus-visible] ) *:not( ${ DropdownMenu } ) &,
Expand Down

0 comments on commit cc8009e

Please sign in to comment.