Skip to content

Commit

Permalink
feat(menu): migrate to spectrum-tokens + add new features (#1942)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: migrates the Menu to `@adobe/spectrum-tokens`

* feat(menu)!: migrate to spectrum-tokens

* docs(site): update menu usage in the docs site

* fix(menu): use correct guidelines link in docs

* feat(menu): make medium size styles the default

Make .spectrum-Menu--sizeM the default; move its custom properties to
the parent class, and move sizing styles underneath the parent class
custom property definitions.

* fix(menu): set color property where fill is used

Add color declaration wherever there is 'fill', per SWC request. Because
"using fill to set the colour of icons in the menu css isn't
compatible with the way we process our icons, so the icons aren't
colouring properly or changing depending on the state".

* fix(menu): checkmark margin to fix alignment of selected items

Selected menu items with checkmark were shifting 2 pixels as compared
to the non-selected menu items. Looking over the updated design, the
text-to-control-* tokens are used for the space between the checkmark
and the text.

* fix(menu): section heading top and bottom spacing

When a section heading was above menu items, it previously looked
strange because of the lack of space. The sectionHeading also needs
top and bottom padding.

* fix(menu): organize stories under components category

* feat(menu): simplify cjk style rules

Replace unnecessary CJK style rules with a change to the relevant custom
property values.

* refactor(menu): simplify high contrast mode styles with fixes

- Simplify high contrast mode styles. Less custom properties are needed.
- Fix for hover causing things to disappear on collapsible items. Fix
  may need to be replaced later with one that addresses the regular
  styles for children of menu-item being applied to the nested menu
  items in the collapsible variant.
- Remove skin.css as part of tokens migration. Its rules should already
  be handled now by the index.css.

* feat(menu): create new stories and finalize existing stories

Updates the Menu stories to account for additional variants on the docs
and changes to markup. Adds several new stories.

* fix(menu): update for selected states and keyboard focus

- Use state class naming instead of modifier class naming for
  is-selected and is-selectable.
- Show focus indicator line only with :focus-visible for keyboard focus
- Simplify RTL/LTR change of focus indicator with scalar custom prop

* feat(menu): story for drill-in variant

Add story for drill-in variant. Also makes isSelectable false by default
and change some stories to set it to false to better align with docs
examples.

* fix(menu): use child combinator to limit styles applied for nested

In the collapsible variant, style rules applying to children of a menu
item were also applying to the nested menu child items. This was causing
some issues with high contrast hovers and could also be noticed by
changing a mod like --mod-menu-item-label-content-color-hover and then
hovering over the parent menu item in the collapsible variant (this
would also change the color of all the child menu items).

* docs(menu): remove submenu from drill-in example

The displayed submenu for the drill-in example was not how submenus
should be displayed per the guidelines. They need to be positioned, and
are shown as being within another popover. Showing this adjacent menu
like this could cause some confusion as to its usage; the adjacent menu
was not positioned properly and does not have any separate styles within
the CSS for doing so.

* fix(menu): collapsible - remove extra indentation for sub items

For the collapsible variant:
The child menu items under a parent menu item that contains a workflow
icon should not show extra indentation, otherwise it looks like a
different tier when next to a menu item without an icon. Confirmed
with design team.

All sub-items are now indented to after the chevron and the start of the
parent item text/heading.

* feat(menu): add collapsible story

Add Collapsible story to menu in Storybook, based on example from docs
example.

* feat(menu): add t-shirt sizing to storybook

Add control for t-shirt sizing to menu stories. Adds the size class to
various elements.

* fix(menu): fixes for menu usage in docs site search and popovers

Fixes for several issues with the menu that is displayed in the docs
site search results, and theme/scale/direction popovers.

- Makes the adjacentText classes the default margin, allowing them to
  be removed (which fixes checkbox spacing in theme/scale popovers).
- Fixes extra top and bottom margin appearing in menu for docs
  theme/scale popovers. This was showing user agent values for top and
  bottom margin. In production, they were previously set to a popover
  padding token, which added more space than on the design (popover
  component already has padding).
- Fixes search results menu showing incorrectly because of difference in
  the JS created markup related to section headers.

* chore(menu): manual version increase for beta release

* fix(menu): spacing adjustments including divider inline margin

- Includes spacing on left and right of divider to match the same
  spacing used on left and right of menu item labels and heading.
- Remove extra padding on presentational list items used for section
  header and divider examples.
- Simplify rules for padding on sectionHeading. Default inline padding
  and remove inline padding on collapsible variant.

* feat(menu): use top to checkmark token and handle wrapping text

- Use new spectrum-menu-item-top-to-selected-icon-* tokens
- Handle alignment of icon and checkmark when text is wrapping, so icons
  are aligned top and not center, and stay in alignment with each other
  with use of new token.
- Updates stories to make sure edge case with selected + icon + wrapping
  text is represented.

* fix(menu): storybook - ensure long text wraps on wide screens

Wrapping text examples need a max-width on the container to ensure that
they are wrapping when stories are viewed at higher resolutions.

Also updates generated mods file.

* refactor(menu): remove two withAdjacentIcon classes

Per PR feedback, these classes appear to be no longer needed as they are
using the same token value.

* chore(menu): new beta release

* fix(menu): remove excess margin from drill-in chevron

Zero out the margin-inline-end for the chevron used at the end
of the drill-in menu items.

* chore(menu): version increase for beta release

* fix(menu): divider margin update and new tokens package version

Update divider margin-block to agree with newly added token for the
divider height. Sets minimum tokens package version to 11.0.2 where this
--spectrum-menu-item-section-divider-height token was added.

* fix(menu): use smaller divider instead of medium

Replace medium divider with small divider in examples and storybook
markup. Updates migration guide to note the change. Removes unnecessary
large divider possibility from CSS, as that should never be used here
according to divider guidelines.

* docs(menu): fix migration guide not appearing and add docs

Fix migration guide section no appearing in docs because it was named
'section' and not 'sections' in the YML.

Adds new standard section about -mod custom properties.

* chore(menu): manual version increase + update tokens dep

---------

Co-authored-by: Josh Winn <965114+jawinn@users.noreply.github.com>
  • Loading branch information
pfulton and jawinn committed Aug 4, 2023
1 parent b89af93 commit d961abd
Show file tree
Hide file tree
Showing 14 changed files with 2,436 additions and 663 deletions.
1 change: 0 additions & 1 deletion components/menu/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# @spectrum-css/menu

> The Spectrum CSS menu component
This package is part of the [Spectrum CSS project](https://github.com/adobe/spectrum-css).
Expand Down
2 changes: 1 addition & 1 deletion components/menu/gulpfile.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require("@spectrum-css/component-builder");
module.exports = require('@spectrum-css/component-builder-simple');
781 changes: 651 additions & 130 deletions components/menu/index.css

Large diffs are not rendered by default.

1,250 changes: 1,132 additions & 118 deletions components/menu/metadata/menu.yml

Large diffs are not rendered by default.

67 changes: 67 additions & 0 deletions components/menu/metadata/mods.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
| Modifiable Custom Properties |
| ------------------------------------------------------------------ |
| `--mod-menu-checkmark-display` |
| `--mod-menu-checkmark-icon-color-default` |
| `--mod-menu-checkmark-icon-color-down` |
| `--mod-menu-checkmark-icon-color-focus` |
| `--mod-menu-checkmark-icon-color-hover` |
| `--mod-menu-collapsible-icon-color` |
| `--mod-menu-drillin-icon-color-default` |
| `--mod-menu-drillin-icon-color-down` |
| `--mod-menu-drillin-icon-color-focus` |
| `--mod-menu-drillin-icon-color-hover` |
| `--mod-menu-item-background-color-default` |
| `--mod-menu-item-background-color-down` |
| `--mod-menu-item-background-color-hover` |
| `--mod-menu-item-background-color-key-focus` |
| `--mod-menu-item-bottom-edge-to-text` |
| `--mod-menu-item-checkmark-height` |
| `--mod-menu-item-checkmark-width` |
| `--mod-menu-item-collapsible-no-icon-submenu-item-padding-x-start` |
| `--mod-menu-item-description-color-default` |
| `--mod-menu-item-description-color-disabled` |
| `--mod-menu-item-description-color-down` |
| `--mod-menu-item-description-color-focus` |
| `--mod-menu-item-description-color-hover` |
| `--mod-menu-item-description-font-size` |
| `--mod-menu-item-description-line-height` |
| `--mod-menu-item-description-line-height-cjk` |
| `--mod-menu-item-focus-indicator-color` |
| `--mod-menu-item-focus-indicator-width` |
| `--mod-menu-item-icon-height` |
| `--mod-menu-item-icon-width` |
| `--mod-menu-item-label-content-color-default` |
| `--mod-menu-item-label-content-color-disabled` |
| `--mod-menu-item-label-content-color-down` |
| `--mod-menu-item-label-content-color-focus` |
| `--mod-menu-item-label-content-color-hover` |
| `--mod-menu-item-label-font-size` |
| `--mod-menu-item-label-icon-color-default` |
| `--mod-menu-item-label-icon-color-disabled` |
| `--mod-menu-item-label-icon-color-down` |
| `--mod-menu-item-label-icon-color-focus` |
| `--mod-menu-item-label-icon-color-hover` |
| `--mod-menu-item-label-inline-edge-to-content` |
| `--mod-menu-item-label-line-height` |
| `--mod-menu-item-label-line-height-cjk` |
| `--mod-menu-item-label-text-to-visual` |
| `--mod-menu-item-label-to-description-spacing` |
| `--mod-menu-item-label-to-value-area-min-spacing` |
| `--mod-menu-item-min-height` |
| `--mod-menu-item-selectable-edge-to-text-not-selected` |
| `--mod-menu-item-text-to-control` |
| `--mod-menu-item-top-edge-to-text` |
| `--mod-menu-item-top-to-checkmark` |
| `--mod-menu-item-value-color-default` |
| `--mod-menu-item-value-color-down` |
| `--mod-menu-item-value-color-focus` |
| `--mod-menu-item-value-color-hover` |
| `--mod-menu-section-divider-margin-block` |
| `--mod-menu-section-header-bottom-edge-to-text` |
| `--mod-menu-section-header-color` |
| `--mod-menu-section-header-font-size` |
| `--mod-menu-section-header-font-weight` |
| `--mod-menu-section-header-line-height` |
| `--mod-menu-section-header-line-height-cjk` |
| `--mod-menu-section-header-min-width` |
| `--mod-menu-section-header-top-edge-to-text` |
12 changes: 6 additions & 6 deletions components/menu/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@spectrum-css/menu",
"version": "4.0.50",
"version": "5.0.0-beta.7",
"description": "The Spectrum CSS menu component",
"license": "Apache-2.0",
"author": "Adobe",
Expand All @@ -13,20 +13,20 @@
"bugs": {
"url": "https://github.com/adobe/spectrum-css/issues"
},
"main": "dist/index-vars.css",
"main": "dist/index.css",
"scripts": {
"build": "gulp"
},
"peerDependencies": {
"@spectrum-css/divider": ">=1 <=2",
"@spectrum-css/divider": ">=2",
"@spectrum-css/icon": ">=3",
"@spectrum-css/vars": ">=9"
"@spectrum-css/tokens": ">=11.1.0"
},
"devDependencies": {
"@spectrum-css/component-builder": "^4.0.12",
"@spectrum-css/component-builder-simple": "^2.0.15",
"@spectrum-css/divider": "^2.1.15",
"@spectrum-css/icon": "^3.0.50",
"@spectrum-css/vars": "^9.0.8",
"@spectrum-css/tokens": "^11.1.0",
"gulp": "^4.0.0"
},
"publishConfig": {
Expand Down
111 changes: 0 additions & 111 deletions components/menu/skin.css

This file was deleted.

Loading

0 comments on commit d961abd

Please sign in to comment.