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

feat(radio): adding new colors, type, and size tokens, invalid state, WHCM #3555

Merged

Conversation

aramos-adobe
Copy link
Contributor

@aramos-adobe aramos-adobe commented Feb 13, 2025

Radio S2 Migration

Updates:

  • Now has an invalid/error state
  • High contrast tokens have been modified
  • Typography tokens modified

New tokens

--spectrum-radio-invalid-color-default
--spectrum-radio-invalid-color-hover
--spectrum-radio-invalid-color-down
--spectrum-radio-invalid-color-key-focus
--spectrum-radio-border-width
--spectrum-radio-text-font-weight
--spectrum-radio-text-font-style

Modified tokens

--spectrum-radio-emphasized-accent-color
--spectrum-radio-emphasized-accent-color-hover
--spectrum-radio-emphasized-accent-color-down
--spectrum-radio-emphasized-accent-color-focus

Validation steps

  • Review Radio story
  • Review test environment
Screenshot 2025-02-25 at 12 54 47 PM Screenshot 2025-02-13 at 4 05 05 PM

Regression testing

Validate:

  1. The documentation pages for at least two other components are still loading, including:
  • The pages render correctly, are accessible, and are responsive.
  1. If components have been modified, VRTs have been run on this branch:
  • VRTs have been run and looked at.
  • Any VRT changes have been accepted (by reviewer and/or PR author), or there are no changes.

Screenshots

To-do list

  • I have read the contribution guidelines.
  • I have updated relevant storybook stories and templates.
  • I have tested these changes in Windows High Contrast mode.
  • If my change impacts other components, I have tested to make sure they don't break.
  • If my change impacts documentation, I have updated the documentation accordingly.
  • ✨ This pull request is ready to merge. ✨

Copy link

changeset-bot bot commented Feb 13, 2025

🦋 Changeset detected

Latest commit: a6365c3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@spectrum-css/radio Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@aramos-adobe aramos-adobe changed the base branch from spectrum-2 to spectrum-two February 13, 2025 19:45
Copy link
Contributor

github-actions bot commented Feb 13, 2025

File metrics

Summary

Total size: 1.37 MB*

Package Size Minified Gzipped
radio 15.92 KB 15.10 KB 2.25 KB

radio

Filename Head Minified Gzipped Compared to base
index.css 15.92 KB 15.10 KB 2.25 KB 🔴 ⬆ 0.70 KB
metadata.json 8.93 KB - - 🔴 ⬆ 0.28 KB
* Size is the sum of all main files for packages in the library.
* An ASCII character in UTF-8 is 8 bits or 1 byte.

Copy link
Contributor

github-actions bot commented Feb 13, 2025

🚀 Deployed on https://pr-3555--spectrum-css.netlify.app

@aramos-adobe aramos-adobe force-pushed the aramos-adobe/css712-radio-group-s2-migration branch from 8dee413 to a46599d Compare February 13, 2025 20:07
@aramos-adobe aramos-adobe self-assigned this Feb 13, 2025
@castastrophe castastrophe force-pushed the spectrum-two branch 5 times, most recently from d5e72d4 to 0f14273 Compare February 24, 2025 22:39
@aramos-adobe aramos-adobe force-pushed the aramos-adobe/css712-radio-group-s2-migration branch from 0704a09 to 63b2cc9 Compare February 25, 2025 17:49
@aramos-adobe aramos-adobe force-pushed the aramos-adobe/css712-radio-group-s2-migration branch from 8e3b47f to 75c6f2b Compare March 3, 2025 15:25
Copy link
Collaborator

@jawinn jawinn left a comment

Choose a reason for hiding this comment

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

Nice work. Visually everything is looking good to me.
Just a few suggestions here that are mostly Storybook related.

@aramos-adobe aramos-adobe requested a review from jawinn March 6, 2025 15:33
Copy link
Member

@cdransf cdransf left a comment

Choose a reason for hiding this comment

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

Looks awesome! ✨

Copy link
Collaborator

@marissahuysentruyt marissahuysentruyt left a comment

Choose a reason for hiding this comment

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

This is looking really good! I was just working on checkbox, which I remembered was used in field group. So as I was reviewing this, I had field group in my head to check, and sure enough, I have a question for you 😸

Because field group calls for radios, I think we'll have to update field group template to pass its isInvalid arg all the way through to the radio components. Currently, in field group, I'm not seeing the new error/invalid state.
Screenshot 2025-03-12 at 4 02 02 PM

Is that how you would interpret the Figma note that the "s2 visual is not available?" And that the invalid radio groups just don't have their appropriate red border colors yet?

Screenshot 2025-03-12 at 4 03 34 PM

"@spectrum-css/radio": major
---

# Radio S2 Migration
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is just a personal preference, but I'd actually love the PR to have this title! I feel like it would make it really easy to search for in the future.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Me too! Do try to avoid using the h1 though, that's reserved for # Change Log. I recommend ### because it typically nests under the h2 version number.

...customClasses.reduce((a, c) => ({ ...a, [c]: true }), {}),
})}
style=${styleMap(customStyles)}
>
<input
type="radio"
name=${name}
class="${rootClass}-input"
class=${classMap({["is-focus-visible"]: isFocused, [`${rootClass}-input`]: true })}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I have a question and then a suggestion for this line.

My question is why did you end up putting the isFocused arg here, as opposed to with the rest of the isHovered and isInvalid args? Is that in line with changes you did with checkbox (I haven't looked at that PR yet).

This is strictly a suggestion for readability:
Would you mind putting these on separate lines, like the classMap on the parent div? I think it's a little easier to read when they're listed on separate lines instead of just comma-separated.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh- semi related to this. Right now, we can tab focus to a disabled radio, which isn't correct.

Screenshot 2025-03-12 at 5 15 49 PM

I think here we need:
["is-focus-visible"]: isFocused && !isDisabled

Comment on lines 57 to 60
--spectrum-radio-button-checked-border-color-default: var(--spectrum-neutral-content-color-default);
--spectrum-radio-button-checked-border-color-hover: var(--spectrum-neutral-content-color-hover);
--spectrum-radio-button-checked-border-color-down: var(--spectrum-neutral-content-color-down);
--spectrum-radio-button-checked-border-color-focus: var(--spectrum-neutral-content-color-key-focus);
Copy link
Collaborator

Choose a reason for hiding this comment

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

These sort of feel like duplicates to me. Could we rework any of the selectors that include :checked to just use the unchecked custom properties instead? I can't comment at line 133, but I was thinking something like:

&:hover {
		/*indicator hover */
		.spectrum-Radio-button::before,
		.spectrum-Radio-input:checked + .spectrum-Radio-button::before {
			border-color: var(--highcontrast-radio-button-border-color-hover, var(--mod-radio-button-border-color-hover, var(--spectrum-radio-button-border-color-hover)));
		}

		.spectrum-Radio-label {
			color: var(--highcontrast-radio-neutral-content-color-hover, var(--mod-radio-neutral-content-color-hover, var(--spectrum-radio-neutral-content-color-hover)));
		}
	}

Does that still do everything we need it to do? My gut says that the "checked" and "unchecked" colors were pointing to the same resolved tokens- just one was using the global (gray-900) colors, and the other was using the aliases (neutral-background-color-selected-hover).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Happy to pair on this if I'm not making sense 🍐

@aramos-adobe
Copy link
Contributor Author

This is looking really good! I was just working on checkbox, which I remembered was used in field group. So as I was reviewing this, I had field group in my head to check, and sure enough, I have a question for you 😸

Because field group calls for radios, I think we'll have to update field group template to pass its isInvalid arg all the way through to the radio components. Currently, in field group, I'm not seeing the new error/invalid state. Screenshot 2025-03-12 at 4 02 02 PM

Is that how you would interpret the Figma note that the "s2 visual is not available?" And that the invalid radio groups just don't have their appropriate red border colors yet?

Screenshot 2025-03-12 at 4 03 34 PM

Based on what React Spectrum's got it looks like this:

@@ -15,6 +16,9 @@ export const Template = ({
isChecked = false,
isDisabled = false,
isReadOnly = false,
isFocused = false,
isInvalid = false,
Copy link
Collaborator

Choose a reason for hiding this comment

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

@aramos-adobe Based on that React link you sent me, I do think we need to pass the isInvalid arg to the radio components in field group. Right, they do not have the updated border colors. (I think I left a screenshot in my original note about this)

Thanks for sending that! 👍

Copy link
Collaborator

@marissahuysentruyt marissahuysentruyt left a comment

Choose a reason for hiding this comment

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

Nice work on this! The tokens look good! I'm glad we double checked the error state and those negative tokens that were mentioned in the Figma specs.

This is another suggestion, and doesn't block an approval, but it was a thought I had. We could add some more test cases to make sure we don't miss any combination states:

  • checked + hovered
  • disabled + checked + hovered
  • readOnly + checked +hovered
  • active (to show the "down" state/perspective change, but this includes adding more to the template and an extra control)
Screenshot 2025-03-17 at 2 22 59 PM

I think some of these (or similar) are in the checkbox tests, so I was wondering if it would be helpful to expand the radio coverage in a similar way.


Updates:

- Now has an invalid/error state
Copy link
Collaborator

Choose a reason for hiding this comment

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

In that thread on slack when we asked about the red error border color, it sounded to me like those negative tokens called out in the radio Figma specs were incorrectly added. We should probably delete all of the new invalid CSS and the changeset mentions 😭

Copy link
Collaborator

Choose a reason for hiding this comment

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

@aramos-adobe I think you already deleted most of the invalid CSS, but I found just a couple instances of some invalid stuff here in the changeset, and then an arg in the stories file. 👍

@@ -14,7 +14,6 @@
".spectrum-Combobox--quiet .spectrum-Combobox-textfield.is-readOnly.is-disabled .spectrum-Combobox-input:read-only",
".spectrum-Combobox--quiet .spectrum-Combobox-textfield.is-readOnly.is-invalid > .spectrum-Combobox-input:read-only",
".spectrum-Combobox--quiet.spectrum-Combobox--sizeL",
".spectrum-Combobox--quiet.spectrum-Combobox--sizeM",
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if this snuck in during a rebase? I don't remember seeing a combobox diff before.

},
args: {
rootClass: "spectrum-Radio",
size: "m",
label: "Label",
isEmphasized: false,
isChecked: false,
isInvalid: false,
Copy link
Collaborator

Choose a reason for hiding this comment

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

We probably don't need this isInvalid arg anymore. I think it's causing an uncategorized argument in the controls:

Screenshot 2025-03-17 at 2 13 59 PM

Copy link
Collaborator

@marissahuysentruyt marissahuysentruyt left a comment

Choose a reason for hiding this comment

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

I think this just needs to be built again to update the metadata for radio & combobox (I'm getting metadata updates when I run this locally on my end!), but it's looking great! Thanks for all your hard work on this!

@castastrophe castastrophe added size-3 M ~18-30hrs; moderate effort or complexity, several work days needed. ready-to-merge labels Mar 19, 2025
}
],
stateData: [
{
testHeading: "Checked",
isChecked: true,
},
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Love this test expansion 💃

@aramos-adobe aramos-adobe merged commit 0af6461 into spectrum-two Mar 20, 2025
12 checks passed
@aramos-adobe aramos-adobe deleted the aramos-adobe/css712-radio-group-s2-migration branch March 20, 2025 14:08
@github-actions github-actions bot mentioned this pull request Mar 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge S2 Spectrum 2 size-3 M ~18-30hrs; moderate effort or complexity, several work days needed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants