8000 feat(taggroup): spectrum 2 migration by rise-erpelding · Pull Request #3966 · adobe/spectrum-css · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(taggroup): spectrum 2 migration #3966

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

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

Conversation

rise-erpelding
Copy link
Collaborator
@rise-erpelding rise-erpelding commented Jun 18, 2025

Description

The Spectrum 2 version of Tag Group is a major change from its Spectrum 1 counterpart.

Style changes

  • Use of new tokens and custom properties for spacing tags. The method of spacing between tags has changed. Where previously tags were spaced using tokens to represent inline and block margins on each tag, tags are now spaced by tokens representing the gaps between tags.
  • Rather than being a single size, Tag group now comes in t-shirt sizes: Small, medium, and large. These sizes should determine the sizes of the embedded components, but also the spacing between tags.
  • Tag group can now accommodate a side label. To do so, it makes use of a grid layout.
  • In order to match the layout in the spec, more embedded components besides Tag have been added. Field label, Help text, and Action button (quiet) components have been added to the Storybook implementation, and styles are set for these embedded components within the tag group layout.

In order to support the aforementioned spacing changes, the two mod properties for margin have been removed:

  • --mod-tag-group-item-margin-block
  • --mod-tag-group-item-margin-inline

Instead, please customize spacing between tags with:

  • --mod-tag-group-block-tag-spacing
  • --mod-tag-group-inline-tag-spacing

These custom properties may need to be set to be double the previous margin values in order to achieve the same spacing.

To support custom spacing of the embedded components, several other new mod properties have been added:

  • --mod-tag-group-block-spacing-label-to-tags
  • --mod-tag-group-inline-spacing-label-to-tags
  • --mod-tag-group-spacing-help-text-to-tags

To support the optional empty state (when there are no tags in the tag group), several passthroughs to modify the body typography text element have been added, including:

  • --mod-body-cjk-line-height
  • --mod-body-font-size
  • --mod-body-line-height
  • --mod-body-margin-end
  • --mod-body-margin-start

Template and Storybook changes

In addition to styling changes, several additions to the markup have been made here, and to better support these changes, Storybook controls have also been updated:

  • The down state decorator was added to the tag group story to include the down states for tags and action button.
  • In order to give Storybook users control over how many tags appear in the tag group, a "number of tags" control has been added, with options to display between 0 and 30 tags. An items array is also supported for more granular control
  • Logic to accommodate Empty state has been added to the template. To render the placeholder text, the body typography element is currently used.
  • New stories to display empty state, side label positioning, and embedded components have been added to the Storybook Docs page.

Because of the drastic layout and feature changes in this component migration, the testing has also changed. The testing grid continues to include removable tags, sizing, and tags that wrap to multiple lines, but also shows the other embedded components that have been added. Empty state and side label variants are also added as test cases.

Questions/things I'd love feedback on

  • Empty state--should we do more? We did not implement this feature, which shows placeholder text if there are no tags, for Spectrum 1. There wasn't any guidance on how this should look in the S2 specs, but React does include it in their implementation. It looks reasonably close to what I see in the design docs for S1 in color/relative font size, but really doesn't align nicely, particularly for the side label variant. I did ask for design guidance on this, but for now since there are no tokens for the placeholder text, there are no styles set for it either. It uses only a Body typography element.
  • As it is now, I think the placement of the action button does match the spec, but also feels oddly aligned because the text is start-aligned with the first tag rather than the field label. If there's something I missed that would help, I'd love to know about it! I did see that React's action button still appears inline with the tags.
  • Tags support an avatar, thumbnail, or icon. This is shown in one of the stories on the Docs page, but doesn't have to be. Is there value in showing those visuals? Any testing of them should be covered in the Tag component.
  • Grid layout. Is this the right choice? It seems to be how we format other components with side label variants, and it isn't as dependent on markup as flexbox.

CSS-1037

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

  • Confirm that all Tag group tokens found in the S2 spec have been used
  • The layout doesn't break in any variant with any reasonable content added
  • Storybook controls added work and make sense for the component
  • Testing template covers variations of Tag Group
  • Changeset has been added and includes relevant documentation about changes for consumers
  • Documentation is clear and free of spelling/grammar issues

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

image

To-do list

  • I have read the contribution guidelines.
  • I have updated relevant storybook stories and templates.
  • If my change impacts documentation, I have updated the documentation accordingly.
  • ✨ This pull request is ready to merge. ✨

Copy link
changeset-bot bot commented Jun 18, 2025

🦋 Changeset detected

Latest commit: 1590852

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

This PR includes changesets to release 3 packages
Name Type
@spectrum-css/taggroup Major
@spectrum-css/bundle Patch
@spectrum-css/preview Patch

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

@rise-erpelding rise-erpelding added wip This is a work in progress, don't judge. S2 Spectrum 2 labels Jun 18, 2025
Copy link
Contributor
github-actions bot commented Jun 18, 2025

File metrics

Summary

Total size: 1.43 MB*

Package Size Minified Gzipped
taggroup 3.54 KB 3.35 KB 0.89 KB

taggroup

Filename Head Minified Gzipped Compared to base
index.css 3.54 KB 3.35 KB 0.89 KB 🔴 ⬆ 2.46 KB
metadata.json 1.97 KB - - 🔴 ⬆ 1.58 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 Jun 18, 2025

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

@rise-erpelding rise-erpelding added the size-3 M ~18-30hrs; moderate effort or complexity, several work days needed. label Jun 18, 2025
@rise-erpelding rise-erpelding force-pushed the rise-erpelding/css-1037-s2-tag-group branch from f353caa to ff4d3d4 Compare June 18, 2025 14:31
@rise-erpelding rise-erpelding self-assigned this Jun 18, 2025
@rise-erpelding rise-erpelding added ready-for-review and removed wip This is a work in progress, don't judge. labels Jun 18, 2025
@marissahuysentruyt marissahuysentruyt added the skip_vrt Add to a PR to skip running VRT (but still pass the action) label Jun 20, 2025
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.

Looking really great! My biggest change request is regarding that icon control I mentioned. Otherwise, I see all the tokens, I left a few tiny typo & story suggestions, and the testing grid looks good!

@@ -23,31 +25,78 @@ export default {
else value.table = { ...value.table, category: "Tag settings" };
Copy link
Collaborator

Choose a reason for hiding this comment

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

The tag settings include a disabled control. Do you think we should include any documentation anywhere on "not disabling entire tag groups?" I found a section about that, but I'm not sure if that's something we would want in tag group (like a story, although it feels sort of weird to showcase an entire story just to say "don't do this,") or if it should be with the disabled tag story (that already exists).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure, that's a good callout, I can add this!

Am I correct in interpreting this to mean that while we shouldn't disable all the tags, it's ok to disable some tags? Since I don't think we usually show non-examples in our Storybook, I decided to show an example with 1 tag disabled. Are we ok with this?

Also, that 1 disabled tag template currently is defined in the test file along with all the others, but I don't know that it's worthwhile to add a test for this, so it's defined in the test template and only used in the documentation. I think I like the idea of keeping it there, since the alternatives would be moving some of the templating to the stories file (which we worked to get away from for awhile), or moving it back to the template. I kind of like the idea of a cleaner template, but let me know what you think!

Copy link
Contributor

Choose a reason for hiding this comment

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

@rise-erpelding, playing around with the disabled state in Figma I see that the disabled state affects the action button labeled "Show all". So maybe the disabled is only action button specific

Copy link
Collaborator

Choose a reason for hiding this comment

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

@rise-erpelding yeah, I would interpret it the same as you- we should disable all the tags at once in a tag group, but it's ok to disable some tags. I like the story example, and I think the disabled template you mentioned is fine in the test file, too.

Copy link
Contributor
github-actions bot commented Jun 20, 2025

📚 Branch preview

PR #3966 has been deployed to Azure Blob Storage: https://spectrumcss.z13.web.core.windows.net/pr-3966/index.html.

@rise-erpelding rise-erpelding force-pushed the rise-erpelding/css-1037-s2-tag-group branch 2 times, most recently from 09f92d9 to b820eff Compare June 23, 2025 19:38
Comment on lines 20 to 31
8000

/* passthroughs for body typography element in empty state */
--mod-body-line-height: var(--spectrum-line-height-100);
--mod-body-font-size: var(--spectrum-font-size-100);
--mod-body-margin-start: var(--spectrum-component-top-to-text-100);
--mod-body-margin-end: var(--spectrum-component-bottom-to-text-100);

&:lang(ja),
&:lang(zh),
&:lang(ko) {
--mod-body-cjk-line-height: var(--spectrum-cjk-line-height-100);
}
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 asked about empty state in the implementations channel, and my understanding from the responses there is that there is no design guidance for empty state, but React still supports it because it's a little weird to have nothing there if there are no tags.

Following suit seems to make sense here and I couldn't get their storybook to cooperate to see what it would look like with no tags & side label, but I'd guess they have fewer layout issues because the empty state font is the same as the field label.

I used the passthroughs on the typography body to adjust the font size and line height to match field label, and also add the same spacing as seen there. That lines it up with field label so that it looks a bit nicer with the side label variant:

image

Open to thoughts on this though. I can remove the passthroughs if they feel too heavy-handed.

@rise-erpelding rise-erpelding force-pushed the rise-erpelding/css-1037-s2-tag-group branch from b820eff to e01bb83 Compare June 23, 2025 20:47
/**
* Avoid disabling an entire tag group. In cases where users can't interact with an entire group of tags, consider either using non-removable tags or hiding the tag group altogether. Don't disable all individual tags; having a tag group that's disabled isn't accessible and it can be frustrating for users.
*/
export const Disabled = TagGroupDisabledItem.bind({});
Copy link
Contributor

Choose a reason for hiding this comment

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

There's an example for disabling the action button as well in Figma. It wasn't documented in the specs but it's configurable prop. I have an example here

},
control: "text",
},
hasDisabledActionButton: {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There's now a hasDisabledActionButton control and a new category for action button settings. We could do more with the action button, let me know if you think that's valuable.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think it's necessary to put more controls for the action button in here- we have a really thorough action button docs page that we linked to already, so I think this is plenty as is!

We could, however, add if: { arg: "actionButtonText", truthy: true }, so that this arg only shows up when the action button renders/has label text.

/**
* Avoid disabling an entire tag group. In cases where users can't interact with an entire group of tags, consider either using non-removable tags or hiding the tag group altogether. Don't disable all individual tags; having a tag group that's disabled isn't accessible and it can be frustrating for users.
*
* Individual tags may be disabled, and the action button may also be disabled, as seen below.
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've also updated this story to include one disabled tag and a disabled action button. I did keep this out of the tests, I'm not sure how valuable it is to show disabled states here when they're already covered within the respective tests for tag and action button, but open to hearing other arguments!

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't really think we need to capture them in the tag group tests- like you said, disabled states has already been covered in tag and action button themselves.

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 is another migration done ✅

I left an idea for the new hasDisabledActionButton control, and maybe one other documentation thing for the wrapping story, but I'm good to approve!

@@ -23,31 +25,78 @@ export default {
else value.table = { ...value.table, category: "Tag settings" };
Copy link
Collaborator

Choose a reason for hiding this comment

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

@rise-erpelding yeah, I would interpret it the same as you- we should disable all the tags at once in a tag group, but it's ok to disable some tags. I like the story example, and I think the disabled template you mentioned is fine in the test file, too.

},
control: "text",
},
hasDisabledActionButton: {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think it's necessary to put more controls for the action button in here- we have a really thorough action button docs page that we linked to already, so I think this is plenty as is!

We could, however, add if: { arg: "actionButtonText", truthy: true }, so that this arg only shows up when the action button renders/has label text.

isRemovable: true,
isEmphasized: false,
customStyles: {"max-width": "300px"},
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think this is blocking anything, but do we want to update this to max-inline-size at all? Should we also mention that "implementations can set a max inline size on .spectrum-TagGroup to facilitate wrapping?"

I don't think either are technically blocking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-review S2 Spectrum 2 size-3 M ~18-30hrs; moderate effort or complexity, several work days needed. skip_vrt Add to a PR to skip running VRT (but still pass the action)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0