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 1 commit 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

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: ff4d3d4

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.42 MB*
Total change (Δ): 🔴 ⬆ < 0.01 KB (0.00%)

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

Package Size Minified Gzipped Δ
accordion 17.50 KB 16.72 KB 2.37 KB 🟢 ⬇ 2.47 KB
contextualhelp 2.20 KB 2.11 KB 0.73 KB 🟢 ⬇ 2.29 KB
taggroup 2.77 KB 2.62 KB 0.77 KB 🔴 ⬆ 1.69 KB

File change details

accordion

Filename Head Minified Gzipped Compared to base
index.css 17.50 KB 16.72 KB 2.37 KB 🟢 ⬇ 2.47 KB
metadata.json 9.37 KB - - 🟢 ⬇ 1.50 KB

contextualhelp

Filename Head Minified Gzipped Compared to base
index.css 2.20 KB 2.11 KB 0.73 KB 🟢 ⬇ 2.29 KB
metadata.json 1.27 KB - - 🟢 ⬇ 1.44 KB

taggroup

Filename Head Minified Gzipped Compared to base
index.css 2.77 KB 2.62 KB 0.77 KB 🔴 ⬆ 1.69 KB
metadata.json 1.29 KB - - 🔴 ⬆ 0.92 KB

tokens

Filename Head Minified Gzipped Compared to base
css/dark-vars.css 46.24 KB - - -
css/global-vars.css 80.22 KB - - 🔴 ⬆ < 0.01 KB
css/index.css 259.43 KB - - 🔴 ⬆ < 0.01 KB
css/large-vars.css 44.17 KB - - -
css/light-vars.css 46.24 KB - - -
css/medium-vars.css 44.29 KB - - 🔴 ⬆ < 0.01 KB
json/tokens.json 410.29 KB - - 🔴 ⬆ < 0.01 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!

}, context)}
`)}
${when(actionButtonText, () => html`
${ActionButton({
Copy link
Collaborator

Choose a reason for hiding this comment

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

To respond to your concerns about the text alignment- I think this is fine, at least for a first pass. The text is aligned like this in Figma, with the field label text right up against the container, but then some gap-age for the tags' and this quite action button's text. The button is lined up with the edge of the container even though we can't see the edge of the button, as are the tags, so to me, it's fine.

I looked at the React tag group link you had too, and their's looks to have the text visually offset so, I don't personally have much of a concern about it.

Screenshot 2025-06-20 at 4 34 42 PM Screenshot 2025-06-20 at 4 34 16 PM

helpText: "",
actionButtonText: "",
};

Copy link
Collaborator

Choose a reason for hiding this comment

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

What do you think about adding a sizes story? We can mention the default size is medium for tag group (I think that's right).

/**
 * Tag groups are available in different sizes to match the size of the tags within them.
 */
export const Sizing = (args, context) => Sizes({
	Template,
	withHeading: false,
	withBorder: false,
	...args,
}, context);
Sizing.tags = ["!dev"];
Sizing.parameters = {
	chromatic: { disableSnapshot: true },
};
Screenshot 2025-06-20 at 4 56 17 PM

(obviously my quick attempt at docs was super duper generic 😆)

Copy link
Collaborator

Choose a reason for hiding this comment

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

or no, was TagGroupSizingTemplate meant to be imported here too?

Comment on lines +16 to +19
{ label: "Sports" },
{ label: "Surfing" },
{ label: "Water" },
{ label: "Hawaii" },
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's almost like Hawaii was on your mind!!!!

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

Instead, please customize spacing between tags with:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I like the voice you took in the changeset, like instructing what someone would need to do to migrate to this version. I might steal that 😊

Comment on lines +27 to +30
.spectrum-TagGroup--sizeL {
--spectrum-tag-group-inline-tag-spacing: var(--spectrum-spacing-200);
--spectrum-tag-group-block-tag-spacing: var(--spectrum-spacing-200);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

We may not even really need this selector, since it's exactly the same values as the medium tag group. I can, however, see an argument for keeping it anyways, just to make it clear where the large styles live. It follows our preferred t-shirt sizing pattern regardless.

@@ -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).

},
numberOfTags: {
name: "Number of tags",
description: "The number of tags to display in the tag group.",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Feel free to disregard, but you could add the blurb like you have for action button & help text. Something like, "If there are no tags, the empty state will render?" I don't know, maybe not...

};

/**
* A tag group on its own should always have a label. Labels can be placed either on top or on the side on the tags, but top labels are the default and are recommended because they work better with long copy, localization, and responsive layouts.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since this story technically gets removed from the docs page, do we need to have the JSDoc? It looks like it's repeated anyways with the "Label position - default/top" story.

// ********* DOCS ONLY ********* //
/**
* A tag group on its own should always have a label. Labels can be placed either on top or on the side on the tags, but top labels are the default and are recommended because they work better with long copy, localization, and responsive layouts.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just a typo:
"...on top, or on the side of the tags..."

},
],
};

/**
* A single quiet action button may be included at the end of a tag group if the action affects the entire group. Common actions include "show all", "show less", and "clear all". A counter of the number of tags can be included in the action button label if appropriate for the context.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just a few typos: the commas & period for the "common actions" should be inside of the quotes.

"show all," "show less," and "clear all."

Copy link
Contributor

📚 Branch preview

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

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.

2 participants