Skip to content

feat(menu): spectrum 2 migration #3686

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 20 commits into
base: spectrum-two
Choose a base branch
from
Open

Conversation

5t3ph
Copy link
Contributor

@5t3ph 5t3ph commented Apr 30, 2025

Description

First of all, big s/o to @rise-erpelding for the original work in #2802 🙌

S2 Menu references:

New features

  • thumbnail - replaces the icon
  • section header description
  • external link icon - rendered in the actions area
    • Note: There is an outstanding issue to add the correct icon to the system, so the current icon in use is temporary
  • updated icon names for ones that were unavailable in the new set

Also of note is that the grid-template-areas for spectrum-Menu-item were updated to accomodate the positioning of elements relative to the thumbnail.

Tokens update

Since @adobe/spectrum-tokens has been updated to include many tokens relating to the menu component, including some that replace custom tokens that had previously been added. As such, these custom menu item color tokens that are now available from @adobe/spectrum-tokens have been removed.

One special case is --spectrum-menu-item-background-color-default which was spec'd to have "0% opacity" which for a CSS background color translates to transparent so that token is redefined as such. So, menu-item-background-opacity was not used.

Additionally, due to the margin required for the focus indicator previously implemented, the "new" token menu-item-to-item was not implemented as it compounded that margin.

New mods

  • --mod-menu-item-linkout-icon-height
  • --mod-menu-item-linkout-icon-width
  • --mod-menu-item-thumbnail-height
  • --mod-menu-item-thumbnail-opacity-disabled
  • --mod-menu-item-thumbnail-to-label
  • --mod-menu-item-thumbnail-width
  • --mod-menu-item-top-to-thumbnail
  • --mod-menu-section-description-color
  • --mod-menu-section-description-font-size
  • --mod-menu-section-description-font-weight
  • --mod-menu-section-description-line-height
  • --mod-menu-section-description-line-height-cjk
  • --mod-menu-section-header-to-description

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

  • New features added are visible in Storybook and are covered by a Chromatic testing view for one or more stories on the menu component.
    • Thumbnail
    • Section description
    • External link
  • As shown in "Test" mode for "Menu item": menu item elements (icon, thumbnail, checkmarks, checkboxes, switches, external linkout, etc.) all play nicely with each other and nothing appears out of place when combining various elements
    • No selection mode
    • Single select mode
    • Multi-select mode with switches
    • Multi-select mode with checkboxes
    • Drill-in
    • Truncation
    • Text wrapping
  • Menu items and other components within menu behave as expected on hover/active/focus states (for instance, nothing disappears that shouldn't, disabled items don't get hover/active states or pointer cursors, contrast seems appropriate)
    • In regular light/dark contexts
    • In Windows High Contrast Mode
  • New tokens listed in Figma are used - exceptions of menu-item-background-opacity and menu-item-to-item as explained above
    • menu-item-label-to-description size tokens
    • section-header-to-description size tokens
    • menu-top-to-thumbnail size tokens
    • text-to-visual-400 (used for thumbnail to label inline spacing)
    • link-out-icon size tokens
  • Menu matches the design spec
    • Layout - heights and spacings appear to match spec, and corner rounding tokens are in use (Note: Sub-menu alignment with menu item is outside of the scope of Spectrum CSS, I think)
    • Assets - icons, checkboxes, and thumbnails are appropriately sized (Reminder: External link icon needs to be updated to S2 icon when these icons are available to us)
    • Colors - background and content colors use the appropriate color tokens
    • Typography - menu headers and items are using the appropriate typography tokens

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

Note: The desktop guide shows that when thumbnail is active, the selected state check or checkbox should be center aligned

image image image image image

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. ✨

@5t3ph 5t3ph added size-5 L ~30-42hrs; lots of effort or complexity, most of a sprint needed to complete. skip_vrt Add to a PR to skip running VRT (but still pass the action) ready-for-review S2 Spectrum 2 labels Apr 30, 2025
@5t3ph 5t3ph requested a review from rise-erpelding April 30, 2025 22:07
Copy link

changeset-bot bot commented Apr 30, 2025

🦋 Changeset detected

Latest commit: ed988bc

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/menu 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

@5t3ph 5t3ph mentioned this pull request Apr 30, 2025
31 tasks
Copy link
Contributor

github-actions bot commented Apr 30, 2025

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

Copy link
Contributor

github-actions bot commented Apr 30, 2025

File metrics

Summary

Total size: 1.38 MB*
No change in file sizes

Package Size Minified Gzipped
colorarea 3.64 KB 3.44 KB 1.01 KB
colorhandle 4.03 KB 3.82 KB 1.05 KB
colorslider 4.10 KB 3.87 KB 1.07 KB
colorwheel 5.50 KB 5.18 KB 1.36 KB
menu 47.05 KB 44.81 KB 5.03 KB
slider 29.35 KB 27.70 KB 3.66 KB

File change details

colorarea

Filename Head Minified Gzipped Compared to base
index.css 3.64 KB 3.44 KB 1.01 KB 🟢 ⬇ 0.02 KB
metadata.json 1.69 KB - - -

colorhandle

Filename Head Minified Gzipped Compared to base
index.css 4.03 KB 3.82 KB 1.05 KB 🟢 ⬇ 0.07 KB
metadata.json 1.87 KB - - -

colorslider

Filename Head Minified Gzipped Compared to base
index.css 4.10 KB 3.87 KB 1.07 KB 🟢 ⬇ 0.02 KB
metadata.json 2.12 KB - - -

colorwheel

Filename Head Minified Gzipped Compared to base
index.css 5.50 KB 5.18 KB 1.36 KB 🟢 ⬇ 0.02 KB
metadata.json 2.05 KB - - -

menu

Filename Head Minified Gzipped Compared to base
index.css 47.05 KB 44.81 KB 5.03 KB 🔴 ⬆ 5.68 KB
metadata.json 23.40 KB - - 🔴 ⬆ 3.51 KB

slider

Filename Head Minified Gzipped Compared to base
index.css 29.35 KB 27.70 KB 3.66 KB 🟢 ⬇ 0.14 KB
metadata.json 12.82 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.

@castastrophe castastrophe force-pushed the spectrum-two branch 2 times, most recently from 7e8269c to 4ce8d19 Compare May 5, 2025 21:18
Comment on lines 347 to 352
{
testHeading: "With multi-select switch",
selectionMode: "multiple",
hasActions: true,
include: ["Truncation", "Text wrapping"],
include: ["Truncation", "Truncation with thumbnails", "Text wrapping", "Text wrapping with thumbnails"],
},
Copy link
Contributor

Choose a reason for hiding this comment

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

This and the other test case multi-select switch cuts off the switch on the right side. I wonder if there should be a minimum inline size for this variant.

Comment on lines 736 to 738
.spectrum-Menu-itemLabel--truncate {
text-overflow: ellipsis;
white-space: nowrap;
Copy link
Contributor

Choose a reason for hiding this comment

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

I see this has been added, but I don't see the ellipsis taking effect in the controls instead the menu items get longer. Should there be an inline size placed when this class is added in the template?

Copy link
Contributor

Choose a reason for hiding this comment

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

Line 274 I think for the Menu Item. I added a code block in the styleMap just to see that truncation take effect. I'm sure you have a better way 😁

  style=${styleMap({
		...customStyles,
		...(shouldTruncate ? { width: "200px" } : {}),
	})}

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-5 L ~30-42hrs; lots of effort or complexity, most of a sprint needed to complete. 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