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(tag): migrate to Spectrum 2 #2649

Open
wants to merge 5 commits into
base: spectrum-two
Choose a base branch
from

Conversation

rise-erpelding
Copy link
Collaborator

@rise-erpelding rise-erpelding commented Apr 8, 2024

Description

Migrates the Tag component to Spectrum 2, using new and updated tokens, removing borders, and adding the ability to embed the Thumbnail component.

Express and Spectrum themes removed

Express and Spectrum themes in express.css and spectrum.css respectively have been removed, and relevant styles moved into the index.css file.

Medium is default size

All sizeM styles are now the default.

New tokens

New tokens for Spectrum 2, including

  • corner rounding (now scales with Tag size)
  • minimum and maximum width
  • updated spacing tokens

Color and border changes

  • Borders have been removed (they have become transparent in most cases; if Windows high-contrast mode is used, Tag still has borders)
  • Background and content colors have been adjusted slightly to match Spectrum 2 design spec

Thumbnail added

Tag with Thumbnail is now a visual that is supported (along with Avatar and Icon).

Visuals scale with size change

Small, medium, and large Tags each have appropriately sized icons, avatars, or thumbnails which scale as the component changes size.

Spacing Adjustments

Spacing has been adjusted to match design spec for S2:
Tag with label only
The tag (.spectrum-Tag) controls the inline-start spacing, while the label (.spectrum-itemLabel) controls the inline-end spacing. Border width is subtracted when setting the margin/padding. Note that .spectrum-Tag uses inline-start padding because it’s inline-flex.

Tag with label and clear button
The correct clear button inline-start and inline-end spacing are applied to .spectrum-Tag-clearButton, but since the spacing from the label is still being applied (which has the border width subtracted), this is subtracted from the margin-inline-start being added. This results in 1px of margin being added to the start of the clear button for M and L variants, because the margin being applied to the label is 1px smaller to account for border width.

Tag with Visual (Icon, Avatar, Thumbnail)
These all use the same spacing tokens (component-edge-to-visual, component-text-to-visual) but there are individual custom props for each visual type to try to avoid issues with migration. Inline-start margin on the visual is offset negatively to account for the difference between the tag padding and what the edge-to-visual value should be. Inline-end spacing remains the same as before.

CSS-618

How and where has this been tested?

Please tag yourself on the tests you've marked complete to confirm the tests have been run by someone other than the author.

Validation steps

  • Validate colors (emphasized, invalid, selected, default)
  • Validate disabled state (should not have hover state, should not have pointer cursor for clear button, avatars/thumbnails should be dimming)
  • View testing preview - are any variants missing that could be useful?

Validate Spacing at each size:

  • Label only
  • Label with clear button
  • Label with Icon
  • Label with Avatar
  • Label with Thumbnail
  • Label with Visual (Avatar, Thumbnail, or Icon) and clear button

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 documentation, I have updated the documentation accordingly.
  • ✨ This pull request is ready to merge. ✨

Copy link
Contributor

github-actions bot commented Apr 8, 2024

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

Copy link
Contributor

github-actions bot commented Apr 8, 2024

File metrics

Summary

Total size: 4.52 MB*
Total change (Δ): ⬇ 36.60 KB (-0.78%)

Table reports on changes to a package's main file. Other changes can be found in the collapsed Details section below.

Package Size Δ
tag 27.69 KB ⬇ 8.70 KB

Details

tag

File Head Base Δ
index-base.css 27.69 KB 31.03 KB ⬇ 3.34 KB (-10.77%)
index-vars.css 27.69 KB 36.39 KB ⬇ 8.70 KB (-23.91%)
index.css 27.69 KB 36.39 KB ⬇ 8.70 KB (-23.91%)
metadata.json 13.68 KB 17.08 KB ⬇ 3.40 KB (-19.92%)
index-theme.css - 5.94 KB 🚨 deleted, moved, or renamed
themes/express.css - 3.25 KB 🚨 deleted, moved, or renamed
themes/spectrum.css - 3.27 KB 🚨 deleted, moved, or renamed
* Size determined by adding together the size of the main file for all packages in the library.
* Results are not gzipped or minified.
* An ASCII character in UTF-8 is 8 bits or 1 byte.

@rise-erpelding rise-erpelding force-pushed the rise-erpelding/css-618-migrate-tag branch 2 times, most recently from e51d226 to 25f08ea Compare April 10, 2024 00:01
@rise-erpelding rise-erpelding added the run_vrt For use on PRs looking to kick off VRT label Apr 10, 2024
@rise-erpelding rise-erpelding force-pushed the rise-erpelding/css-618-migrate-tag branch from 25f08ea to 9ef3bbe Compare April 10, 2024 15:59
/* Passthrough for nested component(s) */
--mod-avatar-inline-size: var(--mod-tag-avatar-size, var(--spectrum-tag-avatar-size));
--mod-avatar-block-size: var(--mod-tag-avatar-size, var(--spectrum-tag-avatar-size));
--mod-thumbnail-size: var(--mod-tag-thumbnail-size, var(--spectrum-tag-thumbnail-size));
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These three are following the same approach used for Thumbnails in Table to scale the size of the thumbnail or avatar in the CSS. It looks like another previously used option was to control the sizing in the component such as with Tree View although it seems like this approach would make it easier for scaling to be forgotten.

@@ -130,26 +129,233 @@ export default {
type: "migrated",
},
},
decorators: [
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These changes for the Chromatic coverage are modeled after how Button and Action Button are displaying variants in different sections.

@rise-erpelding rise-erpelding marked this pull request as ready for review April 10, 2024 16:34
Copy link
Collaborator

@mdt2 mdt2 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 Rise! The Chromatic coverage and Storybook control updates are awesome 👏 Just a couple things:

  • It might be helpful for SWC if we provide them a list of changed/added mods in the docs

  • It looks like Avatar dims when the tag is disabled, which is a carryover from S1. I'm wondering if Thumbnail should behave similarly. Just something to check on during design review

  • Let's also make sure we check on the Invalid disabled state in design review 🤔 I'm wondering if this should look like the other disabled states:

    Screen_Shot_2024-04-10_at_3_31_44_PM

  • WHCM is looking great 👏 The only one that is questionable is Invalid Default when dark mode is turned on. I wonder if we could make this look more like what we have in prod now when forced colors is on?

    Screen Shot 2024-04-10 at 3 40 06 PM

Comment on lines 242 to 241
content: [
{
xxs: "Extra-extra-small",
xs: "Extra-small",
s: "Small",
m: "Medium",
l: "Large",
xl: "Extra-large",
xxl: "Extra-extra-large",
}[size],
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need all these sizes, or just small, medium, and large? 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I copied this from button/action button, which also don't have as wide a spread of sizes as there are options listed here, and wondered the same thing. I tend to agree and would err on the side of removing the extra sizes unless there's a compelling reason to keep them--I'll plan to take them out.

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.

Excellent work on this! This is really close and I only noticed a few small things.

I noticed in the separate Foundations and components changelog that it said "Updated label weight to medium", though I didn't see that listed in changed tokens on the spec. Does the font-weight need to change from regular to --spectrum-medium-font-weight?

I noticed the same thing as Melissa on the invalid + selected + disabled. This issue exists on prod too, so it's not specific to your PR. Disabled styling should likely take precedence there.

The only other thing I was wondering about was the foundations changelog item that said "Should have [...] new down state scale tokens". I'm not sure what design was expecting with that---are they expecting it to scale on click when the close button is clicked and is there something we need to do to support that for SWC? That may be something to bring up in design validation.

components/actionbutton/stories/actionbutton.stories.js Outdated Show resolved Hide resolved
Comment on lines 39 to 54
visual: {
name: "Visual",
type: { name: "string" },
table: {
type: { summary: "string" },
category: "Component",
},
options: [
"None",
"Avatar",
"Icon",
"Thumbnail",
],
control: "select",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice work combining these into a single control!
It might be worth also adding a description to this, like "The type of visual element displayed before the label".

@rise-erpelding rise-erpelding force-pushed the rise-erpelding/css-618-migrate-tag branch from bdd990d to b63ddb9 Compare April 12, 2024 00:09
@rise-erpelding rise-erpelding removed the run_vrt For use on PRs looking to kick off VRT label Apr 12, 2024
@rise-erpelding rise-erpelding force-pushed the rise-erpelding/css-618-migrate-tag branch from b63ddb9 to 18c75c9 Compare April 12, 2024 00:19
@rise-erpelding rise-erpelding force-pushed the rise-erpelding/css-618-migrate-tag branch 3 times, most recently from d746d04 to 54e23c4 Compare April 12, 2024 19:01
@rise-erpelding
Copy link
Collaborator Author

rise-erpelding commented Apr 12, 2024

Thanks for the feedback! Here's a list of things that have been fixed since being reviewed and a list of outstanding questions:

Fixes made:

  • Unneeded sizes have been removed from the object mapping size abbreviations to size words
  • Description added for Visual select menu in Storybook
  • Font-weight updated to medium (was previously regular)
  • List of mods added
  • Added Thumbnail opacity when disabled, I can easily remove it if for some reason it’s not wanted though
  • Invalid variant color changes for WHCM

Questions for design:

  • Thumbnail opacity is decreased when tag is disabled, similar to Avatar—there was no design spec for this so wanted to confirm that’s wanted here.
  • Invalid disabled selected state - this looks just like Invalid selected and it seems like perhaps disabled styles ought to take precedence here.
  • Should we be using down state scale tokens?

@rise-erpelding rise-erpelding force-pushed the rise-erpelding/css-618-migrate-tag branch 3 times, most recently from 77c664d to e987a9d Compare April 16, 2024 16:23
@@ -242,7 +262,8 @@ governing permissions and limitations under the License.

/* use negative margin to cancel label to edge margin, then add clear button start margin */
margin-inline-start: calc(var(--mod-tag-label-to-clear-icon, var(--spectrum-tag-label-to-clear-icon))
- (var(--mod-tag-label-spacing-inline-end, var(--spectrum-tag-label-spacing-inline-end))));
- calc(var(--mod-tag-label-spacing-inline-end, var(--spectrum-tag-label-spacing-inline-end))
- var(--mod-tag-border-width, var(--spectrum-tag-border-width))));
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Since the label to edge margin had 1px removed to account for the border-width, this is subtracted here... this is a little complicated, and operationally turns into label-to-clear-icon - label-spacing-inline-end + -border-width. I think it's maybe slightly easier to reason through with a calc() inside the calc() but we definitely can do it another way if that seems easier.

@rise-erpelding rise-erpelding added the run_vrt For use on PRs looking to kick off VRT label Apr 17, 2024
@pfulton pfulton force-pushed the spectrum-two branch 2 times, most recently from f3dd9ff to 9931a8e Compare April 19, 2024 18:22
Copy link

changeset-bot bot commented Apr 19, 2024

⚠️ No Changeset found

Latest commit: fb7d0e3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@rise-erpelding rise-erpelding force-pushed the rise-erpelding/css-618-migrate-tag branch from cd3b43a to 63683bd Compare April 19, 2024 19:17
@castastrophe castastrophe force-pushed the spectrum-two branch 5 times, most recently from 6dbc850 to ae7aedd Compare April 26, 2024 20:37
@rise-erpelding rise-erpelding force-pushed the rise-erpelding/css-618-migrate-tag branch from 63683bd to 62ff0bc Compare April 29, 2024 17:06
@pfulton pfulton force-pushed the spectrum-two branch 2 times, most recently from e0e0fd2 to 698e904 Compare May 3, 2024 18:39
@rise-erpelding rise-erpelding force-pushed the rise-erpelding/css-618-migrate-tag branch from 62ff0bc to 5d9afa3 Compare May 14, 2024 19:50
- Remove Express and Spectrum themes
- Use size M properties as default
- Add tokens for S2, including:
  - corner rounding (corner-radius-medium-size-<Tshirt size>)
  - minimum width (tag-minimum-width-<Tshirt size>)
  - maximum width (tag-maximum-width-multiplier)
  - clear button spacing (tag-label-to-clear-icon-<Tshirt size>,
    tag-edge-to-clear-icon-<Tshirt size>)
  - Adds CJK line height
- Add or adjust background colors for variants
- Remove borders (makes them transparent except for WHCM)
- Update font-weight to be medium rather than regular
- Scale avatar sizing
- Support thumbnail within Tag
- Simplify switch options by adding select menu for the visual type
  (Avatar, Icon, or Thumbnail) displayed on Tag
- Remove Avatar and Icon stories from Storybook
- Add Chromatic coverage showing multiple variants on one screen
- also allows clear button start spacing to be set to its true value
instead of a value offsetting the label spacing and border
- removes disabled state from invalid variants
- removes avatar/icon/thumbnail from invalid variants
- also removes selected & disabled variant in testing preview
- "disabled" is no longer a control when invalid is true
@rise-erpelding rise-erpelding force-pushed the rise-erpelding/css-618-migrate-tag branch from 5d9afa3 to fb7d0e3 Compare May 14, 2024 19:52
@rise-erpelding rise-erpelding removed the run_vrt For use on PRs looking to kick off VRT label May 14, 2024
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.

None yet

3 participants