feat(rating): S2 migration#3627
Conversation
🦋 Changeset detectedLatest commit: 9b25e3a The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
16bbd31 to
39389fc
Compare
405e351 to
10ba423
Compare
31bfeaa to
4dd1d56
Compare
File metricsSummaryTotal size: 1.38 MB* Table reports on changes to a package's main file. Other changes can be found in the collapsed Details section below.
File change detailsrating
tokens
* An ASCII character in UTF-8 is 8 bits or 1 byte. |
|
🚀 Deployed on https://pr-3627--spectrum-css.netlify.app |
11b8fdd to
c78df20
Compare
3dd7f1d to
2d5dd3b
Compare
2d5dd3b to
6b03e9e
Compare
castastrophe
left a comment
There was a problem hiding this comment.
Left a few suggestions for optimizing the tests and storybook. Otherwise approved but I do think we should push back on design designating a default size other than medium if medium exists. It's really confusing for developers and it's not the norm in our system right now.
6b03e9e to
0bf7c47
Compare
d634218 to
e576f59
Compare
rise-erpelding
left a comment
There was a problem hiding this comment.
Thanks for the documentation additions here, particularly for Tooltip and Partial Star! The rating with tooltip instance in the testing grid also looks great!
I left a few thoughts on showing :hover in the testing grid, plus I still think the focus state needs a little bit of work, and we need to make sure our changeset is freshly updated.
| &.is-focused { | ||
| padding-block: calc(var(--mod-rating-top-to-content-area, var(--spectrum-rating-top-to-content-area)) + var(--mod-rating-focus-indicator-gap, var(--spectrum-rating-focus-indicator-gap))) calc(var(--mod-rating-bottom-to-content-area, var(--spectrum-rating-bottom-to-content-area)) + var(--mod-rating-focus-indicator-gap, var(--spectrum-rating-focus-indicator-gap))); | ||
| padding-inline: calc(var(--mod-rating-edge-to-content-area, var(--spectrum-rating-edge-to-content-area)) + var(--mod-rating-focus-indicator-gap, var(--spectrum-rating-focus-indicator-gap))); | ||
| box-shadow: 0 0 0 var(--mod-rating-focus-indicator-thickness, var(--spectrum-rating-focus-indicator-thickness)) var(--mod-rating-focus-indicator-color, var(--spectrum-rating-focus-indicator-color)); |
There was a problem hiding this comment.
I'm still seeing the stars hopping around here, here's a different view to try to explain what I think might be going on, initially .spectrum-Rating has padding on it like this, 6px on each side:
Then, when the focus state is applied, it has padding like this, 8px on each side, plus the inner dimensions of .spectrum-Rating have changed from above:
So I think that explains why, if I apply the focus state, I'll see the stars move slightly to the right, then back to the left if the focus state is removed.
I do also see the stars change position slightly if the focus state is applied and I hover over each of the individual stars. I'm not totally sure if that's related to this issue or if it's a separate issue though.
| &:hover .spectrum-Rating-icon, | ||
| &.is-hovered .spectrum-Rating-icon { | ||
| /* Make all stars selected when the component is hovered */ | ||
| color: var(--highcontrast-rating-emphasized-icon-color-default, var(--mod-rating-emphasized-icon-color-default, var(--spectrum-rating-emphasized-icon-color-default))); | ||
|
|
||
| &.is-hovered, |
There was a problem hiding this comment.
This is something I definitely want to ask and clarify about with our team as a whole because I ran into this same issue with :active on a different PR review, but I believe that the PostCSS pseudo-classes plugin takes care of this, you can see if you yarn build and look at the dist/index.css for Rating, it adds the companion classes automatically so we don't have to, in this case, the postcss.config.js has it set to prefix states with "is-", so you should see it adding .is-hover anywhere where :hover is used.
(Now, for me, the question is, why do we see this so often in CSS files if PostCSS takes care of it for us? But I think in this case we'll be ok reverting this back to what it was before.)
With that, we can also change the setup in template.js to set that .is-hover class based on the arg, and it should work pretty much the same as what you have already, but will leverage PostCSS. I'll stick a comment down there also!
There was a problem hiding this comment.
Oh awesome! Yay postcss! I reverted those classes and update the template and the testing grid looks good/in line with what I'd expect. ✨
There was a problem hiding this comment.
Oh yes, so PostCSS adds the is-prefix to states only in the Storybook version of the assets. We could ship it but in the past I think we discussed it and decided not to.
Co-authored-by: rise-erpelding <54716846+rise-erpelding@users.noreply.github.com>
b7f74c7 to
00f6c60
Compare
c4fecd3 to
91d054f
Compare
eb547dd to
0a8b52e
Compare
rise-erpelding
left a comment
There was a problem hiding this comment.
Leaving a quick note on the focus state and the emphasized hovered story!
| padding-block-start: calc(var(--mod-rating-top-to-content-area, var(--spectrum-rating-top-to-content-area)) + var(--mod-rating-focus-indicator-gap, var(--spectrum-rating-focus-indicator-gap))); | ||
| padding-block-end: calc(var(--mod-rating-bottom-to-content-area, var(--spectrum-rating-bottom-to-content-area)) + var(--mod-rating-focus-indicator-gap, var(--spectrum-rating-focus-indicator-gap))); | ||
| padding-inline: var(--mod-rating-edge-to-content-area, var(--spectrum-rating-edge-to-content-area)); |
There was a problem hiding this comment.
This does keep our stars from jumping around, but effectively now the padding-inline doesn't change between focused and not focused, and we're adding extra padding to account for that focus indicator gap only on the top and bottom and missing it on the sides.
Typically the components here don't use padding to create the focus indicator gap and I'm wondering if that's part of the reason why, if you search the repo for focus-indicator-gap a lot of the components will set a focus indicator with the ::after pseudo-element and the gap is a margin on that ::after.
It's probably not the only way though, you could definitely explore an approach using outline and outline-offset, it looks like that's what switch does!
There was a problem hiding this comment.
Just pushed up 9b25e3a to address this using outline + outline-offset like we discussed. ✨
* fix(rating): active state star icon * chore(rating): adopt spacing tokens * chore(rating): remove underline when hovering over active rating stars * chore(rating): update color custom properties * chore(rating): size control * chore(rating): size stories * chore(rating): draft changeset * chore(rating): rating component hover logic * chore(rating): update changelog * chore(rating): add tooltip example, control and tests * chore(rating): refactor isFocused to isKeyboardFocused * fix(rating): default to medium size; remove unnecessary tests and template * fix(rating): update changeset heading depth * fix(rating): remove unused key-focus color styles * chore(rating): separate styles from custom properties; implement spacing tokens * chore(rating): application of rating height tokens * chore(rating): fix focus state + sizing * chore(rating): apply focus indicator gap * chore(rating): apply S2 down state * chore(rating): update changelog * fix(rating): corrects padding issues, flex alignment and removes unused property * chore(rating): add configurable filled star mask with mod to control fill percentage; update docs * fix(rating): remove unnecessary focus states * fix(rating): docs, changelog, testing and style updates * chore(rating): add emphasized + hovered story and test * chore(rating): remove duplicate mod * chore(rating): add removed mod * fix(rating): typo in class name Co-authored-by: rise-erpelding <54716846+rise-erpelding@users.noreply.github.com> * chore(rating): remove incorrect mods and custom properties from changelog * fix(rating): remove emphasized state from hover test * fix(rating): adjust block and inline padding for focus states * fix(rating): remove manual hover classes, update class names in template * fix(rating): change EmphasizedHovered story name to Hovered * Revert "fix(rating): adjust block and inline padding for focus states" This reverts commit 2175ea7. * fix(rating): replace padding with outline and outline-offset --------- Co-authored-by: rise-erpelding <54716846+rise-erpelding@users.noreply.github.com>


Description
CSS-1141This migrates the
ratingcomponent to S2. Custom properties have been remapped and added per the design specification.Additions
The medium component variation is the default and a t-shirt size medium variation has been added.
A tooltip may be displayed to a user indicating whether interacting with the component will clear or edit the rating. A control and documentation example have been added.
A rating may have a partially filled star. The width and fill of this star is controlled by adding
.is-partialto the parentspanwith classes ofspectrum-Rating-iconandis-selectedand then setting--mod-rating-icon-fillto the necessary fill percentage (e.g.50%).New mods
--mod-rating-width--mod-rating-height--mod-rating-bottom-to-content-area--mod-rating-edge-to-content-area--mod-rating-top-to-content-area--mod-rating-top-to-content-area--mod-rating-icon-fillRemoved mods
--mod-rating-icon-spacing-vertical-top--mod-rating-icon-count--mod-rating-indicator-border-radius--mod-rating-indicator-heightNew custom properties
--spectrum-rating-width--spectrum-component-size-difference-down--spectrum-component-size-minimum-perspective-down--spectrum-corner-radius-medium-size-medium--spectrum-corner-radius-medium-size-small--spectrum-neutral-content-color-default--spectrum-neutral-content-color-down--spectrum-neutral-content-color-hover--spectrum-spacing-75--spectrum-workflow-icon-size-100--spectrum-workflow-icon-size-75Removed custom properties
--spectrum-rating-indicator-width--spectrum-rating-icon-color-key-focus--spectrum-rating-icon-spacing-vertical-top--spectrum-rating-focus-indicator-gap--spectrum-rating-indicator-height--spectrum-rating-indicator-border-radius--spectrum-accent-content-color-key-focus--spectrum-border-width-200--spectrum-component-top-to-workflow-icon-100--spectrum-corner-radius-100--spectrum-neutral-subdued-content-color-default--spectrum-neutral-subdued-content-color-down--spectrum-neutral-subdued-content-color-hover--spectrum-neutral-subdued-content-color-key-focus--spectrum-workflow-icon-size-100Validation steps
isFocusedhas been changed toisKeyboardFocusedTo-do list