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

Support primary and accent variants for toggle and menu buttons #1934

Merged
merged 18 commits into from
Mar 26, 2024

Conversation

m-akinc
Copy link
Contributor

@m-akinc m-akinc commented Mar 14, 2024

Pull Request

🀨 Rationale

Fixes: #1906

πŸ‘©β€πŸ’» Implementation

  • The ask was for the accent appearance variant on the menu button, but because the menu button uses the toggle button internally, I added the appearance-variant attribute to both toggle and menu button.
  • I added support for both primary and accent appearance variants.
  • When adding the new attribute states to the toggle and menu button matrix stories, I moved some common button state arrays to a new file in patterns/buttons/tests.
  • While examining visual designs/colors, I found and fixed several issues:
    • The DigitalGreenDark token value was incorrect, based on the Figma document. I updated this value, which affected block-accent button color and the rich-text mention font color.
    • Anchors in active, prominent, and prominent+active states were using the wrong color tokens.
    • The icon color for outline-accent buttons should match the text color, but didn't.
    • After consulting with Brandon, he directed me to change the active/pressed colors for the block-primary and block-accent button appearances so they would be consistent with other button active/pressed colors. Previously, they were slightly darker versions of the primary and accent colors (see below). This allowed me to remove the two, now-unused tokens: buttonFillActivePrimaryColor and buttonFillAccentActiveColor.
      image

To avoid increasing the size of this PR, Angular/Blazor support will be added in a follow-up PR.

πŸ§ͺ Testing

Lots of manual state styling testing in Storybook. Also Chromatic visual tests.

βœ… Checklist

  • I have updated the project documentation to reflect my changes or determined no changes are needed.

@m-akinc
Copy link
Contributor Author

m-akinc commented Mar 15, 2024

@msmithNI do you mind buddying this?

@m-akinc m-akinc requested a review from msmithNI March 15, 2024 22:41
@m-akinc m-akinc marked this pull request as ready for review March 18, 2024 21:19
@m-akinc m-akinc requested a review from rajsite March 20, 2024 23:53
m-akinc added a commit that referenced this pull request Mar 21, 2024
## 🀨 Rationale

I encountered a couple design tokens with names that felt inconsistent:
`buttonFillActivePrimaryColor`
`buttonFillAccentActiveColor`

It seemed like the appearance variant ("accent" or "primary") should be
in the same relative position within the name, but our naming convention
dictated these names instead.

## πŸ‘©β€πŸ’» Implementation

Treat common state descriptors ("active", "disabled", "hover", and
"selected") as a separate category of name segment than other
distinguishing descriptors (like "accent" and "primary"). So instead of
our old structure:

`[element]-[part]-[state]-[token_type]`

we now have:

`[element]-[part]-[state]-[variant]-[token_type]`

Luckily, the only existing token that violates this updated naming
scheme is `buttonFillAccentActiveColor` (which should instead be
`buttonFillActiveAccentColor`) and that token is being removed in
[another PR](#1934).

## πŸ§ͺ Testing

N/A

## βœ… Checklist

- [x] I have updated the project documentation to reflect my changes or
determined no changes are needed.

---------

Co-authored-by: Milan Raj <[email protected]>
Comment on lines 14 to 22
export const appearanceStates: [string, string | undefined][] = Object.entries(
ButtonAppearance
).map(([key, value]) => [pascalCase(key), value]);
export type AppearanceState = (typeof appearanceStates)[number];

export const appearanceVariantStates: [string, string | undefined][] = Object.entries(ButtonAppearanceVariant).map(([key, value]) => [
pascalCase(key),
value
]);
Copy link
Member

Choose a reason for hiding this comment

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

You lose as const-ness typing of the enum states this way. Also it's not easier to read and not really changing often so don't think being explicit is a maintenance burden. Think it's better to have the stronger type

image

Compared to

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had just copied these as they were. I'll change them.

@m-akinc m-akinc requested a review from rajsite March 25, 2024 23:08
Copy link
Contributor

@TrevorKarjanis TrevorKarjanis left a comment

Choose a reason for hiding this comment

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

I'm approving just because I can.

@m-akinc m-akinc merged commit 594ac22 into main Mar 26, 2024
11 checks passed
@m-akinc m-akinc deleted the users/makinc/menu-button-accent branch March 26, 2024 20:27
rajsite added a commit that referenced this pull request Mar 28, 2024
# Pull Request

## 🀨 Rationale

Makes the following bits more consistent in the storybook matrix tests:
- All the states enums use the normal enum pattern ([instead of
programmatic enum definition which looses some
typing](#1934 (comment)))
- All the states are defined first before the storybook metadata
definition
- All the states use the naming convention of `blahStates` for the state
dimension and `BlahState` for the individual state type
- File specific states were put in alphabetical order

## πŸ‘©β€πŸ’» Implementation

See above.

## πŸ§ͺ Testing

Should not result in any changes in stories except for one change in
dialogs where I have the state name render on the page instead of the
state value which is a long CSS string.

## βœ… Checklist

- [x] I have updated the project documentation to reflect my changes or
determined no changes are needed. Hoping folks just copy and paste the
patterns, didn't seem worth a doc update.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Accent appearance variant for nimble-menu-button
7 participants