diff --git a/.changeset/angry-needles-behave.md b/.changeset/angry-needles-behave.md new file mode 100644 index 00000000000..006d6f8de2b --- /dev/null +++ b/.changeset/angry-needles-behave.md @@ -0,0 +1,23 @@ +--- +"@spectrum-css/radio": major +--- + +### Spectrum 2 migration + +Updates: + +- High contrast tokens have been modified +- Typography tokens modified + +#### New tokens + +`--spectrum-radio-border-width` +`--spectrum-radio-text-font-weight` +`--spectrum-radio-text-font-style` + +#### Updated tokens + +`--spectrum-radio-emphasized-accent-color` +`--spectrum-radio-emphasized-accent-color-hover` +`--spectrum-radio-emphasized-accent-color-down` +`--spectrum-radio-emphasized-accent-color-focus` diff --git a/.changeset/beige-dragons-tickle.md b/.changeset/beige-dragons-tickle.md new file mode 100644 index 00000000000..0d57ad667ec --- /dev/null +++ b/.changeset/beige-dragons-tickle.md @@ -0,0 +1,28 @@ +--- +"@spectrum-css/illustratedmessage": major +"@spectrum-css/dropzone": major +--- + +### S2 Illustrated Message Migration + +This migration contains new tokens for t-shirt sizes (S, M, L), vertical and horizontal orientation along with their maximum width, illustration sizes, and content spacing. + +#### Illustrated Message + +New properties +`--spectrum-illustrated-message-heading-to-description` +`--spectrum-illustrated-message-illustration-to-heading` +`--spectrum-illustrated-message-illustration-to-content` +`--spectrum-illustrated-message-description-to-action` +`--spectrum-illustrated-message-illustration-color` +`--spectrum-illustrated-message-illustration-size` +`--spectrum-illustrated-message-small-cjk-title-font-size` +`--spectrum-illustrated-message-large-cjk-title-font-size` +`--spectrum-illustrated-message-large-body-font-size` +`--spectrum-illustrated-message-horizontal-maximum-width` + +Removed properties +`--spectrum-illustrated-message-title-to-heading` +`--spectrum-illustrated-message-description-max-inline-size` +`--spectrum-illustrated-message-heading-max-inline-size` +`--spectrum-illustrated-message-illustration-accent-color` diff --git a/.changeset/big-beds-care.md b/.changeset/big-beds-care.md new file mode 100644 index 00000000000..897c13c9190 --- /dev/null +++ b/.changeset/big-beds-care.md @@ -0,0 +1,13 @@ +--- +"@spectrum-css/dropzone": major +--- + +### Spectrum 2 migration + +Since dropzone shares a lot of illustrated message's new content tokens (typography and spacing), tons of unused`--mods` were removed. + +The component reflects the [new design](https://www.figma.com/design/eoZHKJH9a3LJkHYCGt60Vb/S2-token-specs?node-id=10141-2822&m=dev) of the borders that includes dash length and dash gap. + +#### SVG Border + +To support the intention of the design, an SVG element is used. There are tokens to adjust the length of dashed lines and the gap between them. It's understood it may be too much to consume an additional element so there's a fallback where the SVG element is not necessary - dropzone will use the standard `border` CSS property. diff --git a/.changeset/big-glasses-check.md b/.changeset/big-glasses-check.md new file mode 100644 index 00000000000..a87529b6de6 --- /dev/null +++ b/.changeset/big-glasses-check.md @@ -0,0 +1,13 @@ +--- +"@spectrum-css/accordion": major +"@spectrum-css/actionbar": major +"@spectrum-css/actiongroup": major +--- + +This update removes `--mod-*` custom property hooks per SWC-1264, see also the RFC for extensible styling. + +- Remove all `--mod-*` custom property hooks. +- Keep existing class selectors and variants unchanged. +- Update stories to reflect the removal of the `--mod-*` override layer. + +Breaking change: the `--mod-*` override layer is removed. Consumers should set `--spectrum-*` variables directly where customization is needed. diff --git a/.changeset/big-jars-pump.md b/.changeset/big-jars-pump.md new file mode 100644 index 00000000000..ced1eb81a9c --- /dev/null +++ b/.changeset/big-jars-pump.md @@ -0,0 +1,70 @@ +--- +"@spectrum-css/inlinealert": major +--- + +#### Spectrum 2 migration + +This migrates the `in-line alert` component to Spectrum 2. Custom properties have been updated and added per the design specification. + +Subtle and bold treatments have been added for each badge variant. + +To use the subtle treatment, you will need to apply the `spectrum-InLineAlert--subtle` class: + +```html +
+
+ Info variant with subtle fill + +
+
This is an alert.
+
+``` + +To use the bold treatment (which is reserved for high-attention alerts only), you will need to apply the `spectrum-InLineAlert--bold` class: + +```html +
+
+ Info variant with bold fill + +
+
This is an alert.
+
+``` + +Because subtle and bold treatments draw a similar level of attention you should choose only one to use consistently within a single product. + +##### New custom properties + +`--spectrum-inlinealert-min-spacing-header-to-icon` +`--spectrum-inlinealert-spacing-content-link-button` +`--spectrum-inlinealert-spacing-header-content` + +##### Removed custom properties + +`--spectrum-inlinealert-spacing-header-content-button` +`--spectrum-inlinealert-spacing-header-to-icon` diff --git a/.changeset/brave-bikes-teach.md b/.changeset/brave-bikes-teach.md new file mode 100644 index 00000000000..76b67bc09a7 --- /dev/null +++ b/.changeset/brave-bikes-teach.md @@ -0,0 +1,61 @@ +--- +"@spectrum-css/actionmenu": major +"@spectrum-css/actionbutton": minor +"@spectrum-css/menu": patch +"@spectrum-css/actiongroup": patch +--- + +### Action menu component (now with custom styles!) + +Introduces `@spectrum-css/actionmenu`, a composition of `ActionButton`, `Popover`, and `Menu` to present action lists from a trigger. Now with custom styles! + +- Adds wrapper classes: `spectrum-ActionMenu`, `spectrum-ActionMenu-trigger`, `spectrum-ActionMenu-popover`, and `spectrum-ActionMenu-menu`. +- Supports long press triggers and four placements (start/end, top/bottom) via the underlying popover API. +- Design reference: [Figma S2 token specs](https://www.figma.com/design/eoZHKJH9a3LJkHYCGt60Vb/S2-token-specs?node-id=20959-21513&node-type=frame&t=jbePQKK1yLdrHG2M-11). + +#### Migration notes + +- If you previously composed an action menu manually (action button + popover + menu), you can adopt the new wrapper classes without changing the underlying markup semantics. Ensure the trigger has `aria-haspopup="menu"` and manages `aria-expanded` according to your application logic. +- For spacing customizations previously done with ad‑hoc margins, switch to the new `--spectrum-actionmenu-button-to-menu-gap` custom property. + +Example markup: + +```html +
+ +
+ +
+ + + +
+``` + +### Menu refinements + +Updates `@spectrum-css/menu` styles to align with latest Spectrum 2 design specifications and improve accessibility. + +- Updated `.is-selectableMultiple .spectrum-Menu-itemCheckbox` to `.is-selectableMultiple:not(:has(.is-selectable)) .spectrum-Menu-itemCheckbox` to prevent clash with the `.is-selectable` placement. +- Non-breaking; no class or DOM changes required. + +### Action button refinements + +- Selection styling now applies when components use ARIA pressed/expanded semantics, not just `.is-selected`. +- Implemented with `:where()` to keep selector specificity low and prevent downstream specificity battles. +- Non-breaking; no class changes required. + +### Action group refinements + +Aligns selection behavior of grouped items with action button updates. + +- Adds `:where([aria-pressed="true"], [aria-expanded="true"])` alongside `.is-selected` on items to cover more accessibility use-cases while keeping specificity low. +- Non-breaking; no class changes required. diff --git a/.changeset/breezy-impalas-push.md b/.changeset/breezy-impalas-push.md new file mode 100644 index 00000000000..e39b5117aec --- /dev/null +++ b/.changeset/breezy-impalas-push.md @@ -0,0 +1,11 @@ +--- +"@spectrum-css/switch": patch +--- + +### S2 switch fixes + +This work addresses minor regressions in the Switch component. Animation tokens are reimplemented and their usage updated within the style definitions. + +Reference: + +- [S2 switch migration](https://github.com/adobe/spectrum-css/pull/2651) diff --git a/.changeset/calm-hats-sleep.md b/.changeset/calm-hats-sleep.md new file mode 100644 index 00000000000..8b357dbd180 --- /dev/null +++ b/.changeset/calm-hats-sleep.md @@ -0,0 +1,5 @@ +--- +"@spectrum-css/bundle": major +--- + +Release bundle with the latest styles on the S2 feature branch. diff --git a/.changeset/chatty-lands-attack.md b/.changeset/chatty-lands-attack.md new file mode 100644 index 00000000000..23e369070fb --- /dev/null +++ b/.changeset/chatty-lands-attack.md @@ -0,0 +1,28 @@ +--- +"@spectrum-css/accordion": major +--- + +### Spectrum 2 migration + +Accordion now uses Spectrum 2 tokens and specifications. + +New sized tokens are used for corner rounding, the spacing around the disclosure icon, and +the spacing around the content area. + +#### New features + +- Adds the optional "quiet" style, which does not show dividers between accordion items. +- Adds CSS transition to animate the rotation of the disclosure indicator when expanding and + collapsing the accordion item. +- Adds no inline padding variant (`.spectrum-Accordion--noInlinePadding`) in which the item + header does not have padding. +- Per design spec, accordion items have a min-width and default width. Default width should not be smaller than + `--spectrum-accordion-item-minimum-width`. + +#### Markup changes + +The HTML markup has changed slightly for the accordion header. The disclosure icon has been moved +from outside the button (`spectrum-Accordion-itemHeader`), to within the button. The extra +element with class `spectrum-Accordion-itemIconContainer`, previously wrapping the icon, has +been removed. A span with class `spectrum-Accordion-itemTitle` has been added around the heading +text. diff --git a/.changeset/chilled-peaches-enjoy.md b/.changeset/chilled-peaches-enjoy.md new file mode 100644 index 00000000000..405d1e676dc --- /dev/null +++ b/.changeset/chilled-peaches-enjoy.md @@ -0,0 +1,11 @@ +--- +"@spectrum-css/actionbutton": major +--- + +Action button now uses Spectrum 2 tokens and design specifications. A few notable changes: + +- Medium is now the default size and `.spectrum-ActionButton--sizeM` has been removed. +- Includes the Spectrum 2 down state transform. +- The component border was not removed and its color was changed to `transparent` in order to continue support for Windows High Contrast / forced colors, which still shows a border. +- Some selectors to target the icon + text button and the icon-only button have been simplified using `:has`. This removes some overly complex `calc()` functions used for inline spacing, uses the design tokens more directly, and removes the previously documented need for the component's child elements to use a specific source order. +- Background and content colors were updated. diff --git a/.changeset/chilly-peaches-sniff.md b/.changeset/chilly-peaches-sniff.md new file mode 100644 index 00000000000..23a91d74948 --- /dev/null +++ b/.changeset/chilly-peaches-sniff.md @@ -0,0 +1,7 @@ +--- +"@spectrum-css/statuslight": major +--- + +#### Spectrum 2 migration + +New non-semantic colors were added to the variants list, while the `accent` semantic variant was removed. There were also some new and updated color and text-to-visual tokens used to match the designs, along with normalizing font family, font style, and font weight. diff --git a/.changeset/chubby-mirrors-wish.md b/.changeset/chubby-mirrors-wish.md new file mode 100644 index 00000000000..b16a3351d8c --- /dev/null +++ b/.changeset/chubby-mirrors-wish.md @@ -0,0 +1,6 @@ +--- +"@spectrum-css/sidenav": patch +"@spectrum-css/tooltip": patch +--- + +Replace deprecated `word-break: break-word` with `overflow-wrap: break-word` to align with modern CSS standards and improve cross-browser compatibility. This property was deprecated in Chrome 44 (July 2015) in favor of the standardized `overflow-wrap` property. diff --git a/.changeset/clean-oranges-smell.md b/.changeset/clean-oranges-smell.md new file mode 100644 index 00000000000..3deb7bdb737 --- /dev/null +++ b/.changeset/clean-oranges-smell.md @@ -0,0 +1,11 @@ +--- +"@spectrum-css/preview": major +--- + +Updates Storybook to use the latest icon sets for Spectrum 2. Includes changes to the directories that +are used for loading in the sprite sheet and the individual icons, as they have moved. + +The global Icon Loader has been updated to apply the existing key name renaming from file names to icon +names. This is now done once at the loader step, rather than each time within the Icon component template. +The loader also now excludes the handful of 22x20 workflow icons, as these are not yet handled within the +design system. diff --git a/.changeset/cool-wolves-like.md b/.changeset/cool-wolves-like.md new file mode 100644 index 00000000000..ca4d7e40b8f --- /dev/null +++ b/.changeset/cool-wolves-like.md @@ -0,0 +1,13 @@ +--- +"@spectrum-css/tokens": minor +--- + +`@adobe/spectrum-tokens@13.12.0` ->`@adobe/spectrum-tokens@13.13.0` + +### Added + +- `--spectrum-select-box-horizontal-minimum-width`: `188px` (desktop), `220px` (mobile) + +### Updated + +- `--spectrum-select-box-edge-to-checkbox`: Updated from a variable sizing based on the viewport to a fixed value (`8px`). diff --git a/.changeset/cute-pillows-stand.md b/.changeset/cute-pillows-stand.md new file mode 100644 index 00000000000..99bfac2be60 --- /dev/null +++ b/.changeset/cute-pillows-stand.md @@ -0,0 +1,7 @@ +--- +"@spectrum-css/statuslight": patch +--- + +### S2 status light fix + +This work removes the reference to `default-font-family` in favor for `sans-font-family-stack` to ensure the status light's font renders appropriately for web. diff --git a/.changeset/cute-windows-unite.md b/.changeset/cute-windows-unite.md new file mode 100644 index 00000000000..a32d9caff7b --- /dev/null +++ b/.changeset/cute-windows-unite.md @@ -0,0 +1,5 @@ +--- +"@spectrum-css/ui-icons": minor +--- + +Updates ui-icons to include linkout-75 icon. diff --git a/.changeset/deep-sloths-fetch.md b/.changeset/deep-sloths-fetch.md new file mode 100644 index 00000000000..51b4c6d2951 --- /dev/null +++ b/.changeset/deep-sloths-fetch.md @@ -0,0 +1,18 @@ +--- +"@spectrum-css/actionbar": major +--- + +### Actionbar S2 Migration + +Action bar now has some updated colors, corner radius, and icons. There's a new look to the default and emphasized variants. + +The emphasized has changed from an `accent` background color to a `neutral` background color. In light mode, the clear button and action buttons are `staticWhite` and in dark mode they are `staticBlack`. + +#### New tokens + +`--spectrum-actionbar-emphasized-actionbutton-label-color` +`--spectrum-actionbar-emphasized-icon-color` +`--spectrum-actionbar-minimum-width` +`--spectrum-actionbar-spacing-label-to-action-group` +`--spectrum-actionbar-spacing-action-group-edge` +`--spectrum-actionbar-close-button-to-counter` diff --git a/.changeset/dirty-melons-look.md b/.changeset/dirty-melons-look.md new file mode 100644 index 00000000000..790dd58227b --- /dev/null +++ b/.changeset/dirty-melons-look.md @@ -0,0 +1,5 @@ +--- +"@spectrum-css/swatch": patch +--- + +Updates the add swatch icon to use the ui rather than workflow icon diff --git a/.changeset/early-ends-fail.md b/.changeset/early-ends-fail.md new file mode 100644 index 00000000000..f37d0e64b3f --- /dev/null +++ b/.changeset/early-ends-fail.md @@ -0,0 +1,5 @@ +--- +"@spectrum-css/icon": minor +--- + +Adds icon class for link out 75 icon diff --git a/.changeset/eighty-terms-lead.md b/.changeset/eighty-terms-lead.md new file mode 100644 index 00000000000..f74d461dc2b --- /dev/null +++ b/.changeset/eighty-terms-lead.md @@ -0,0 +1,44 @@ +--- +"@spectrum-css/rating": major +--- + +#### Spectrum 2 migration + +This migrates the `rating` component to S2. Custom properties have been remapped and added per the design specification. + +##### Additions + +The medium component variation is the default and a t-shirt size medium variation has been added. + +A tooltip may be displayed to a user indicating whether interacting with the component will clear or edit the rating. A control and documentation example have been added. + +A rating may have a partially filled star. The width and fill of this star is controlled by adding `.is-partial` to the parent `span` with classes of `spectrum-Rating-icon` and `is-selected` and then setting the fill to the necessary percentage (e.g. `50%`). + +##### New custom properties + +`--spectrum-rating-width` +`--spectrum-component-size-difference-down` +`--spectrum-component-size-minimum-perspective-down` +`--spectrum-corner-radius-medium-size-medium` +`--spectrum-corner-radius-medium-size-small` +`--spectrum-neutral-content-color-default` +`--spectrum-neutral-content-color-down` +`--spectrum-neutral-content-color-hover` +`--spectrum-spacing-75` +`--spectrum-workflow-icon-size-75` + +##### Removed custom properties + +`--spectrum-rating-indicator-width` +`--spectrum-rating-icon-color-key-focus` +`--spectrum-rating-icon-spacing-vertical-top` +`--spectrum-rating-indicator-height` +`--spectrum-rating-indicator-border-radius` +`--spectrum-accent-content-color-key-focus` +`--spectrum-border-width-200` +`--spectrum-component-top-to-workflow-icon-100` +`--spectrum-corner-radius-100` +`--spectrum-neutral-subdued-content-color-default` +`--spectrum-neutral-subdued-content-color-down` +`--spectrum-neutral-subdued-content-color-hover` +`--spectrum-neutral-subdued-content-color-key-focus` diff --git a/.changeset/fair-coins-buy.md b/.changeset/fair-coins-buy.md new file mode 100644 index 00000000000..8971c89f310 --- /dev/null +++ b/.changeset/fair-coins-buy.md @@ -0,0 +1,7 @@ +--- +"@spectrum-css/link": patch +--- + +### S2 link fix + +This work adds the static color focus ring tokens to links (so that static white and static black links do _not_ have the usual blue focus ring). diff --git a/.changeset/few-candles-sniff.md b/.changeset/few-candles-sniff.md new file mode 100644 index 00000000000..f024d8d300c --- /dev/null +++ b/.changeset/few-candles-sniff.md @@ -0,0 +1,17 @@ +--- +"@spectrum-css/pickerbutton": major +--- + +The picker button component has been migrated to Spectrum 2. The picker button uses the same design spec as infield button and in some cases may be able to be used interchangeably with it. Its updated features include: + +- Corner rounding updates - corner rounding differs by the component's t-shirt size, but otherwise is a standard size. This means that the rounded variant of picker button with increased corner rounding and the position variants of picker button that helped the picker button fit snugly within either side of an input have been removed. +- Color and spacing updates to match S2 spec +- Added WHCM support +- Updated S2 down state +- Removed focus styles: there are no spec'd focus styles in S2, therefore these styles have been removed. +- The label variant of picker button has been removed. +- Removal of `.spectrum-PickerButton--uiicononly`, `.spectrum-PickerButton--icononly`, and `.spectrum-PickerButton--textuiicon` classes: + - The picker button featuring a UI icon is the default variant, so no additional `.spectrum-PickerButton--uiicononly` class needs to be applied. + - The `.spectrum-PickerButton--icononly` class has been renamed to `.spectrum-PickerButton--workflowicon` to clarify when it should be used. Applying `.spectrum-PickerButton--workflowicon` when using a workflow icon instead is recommended, but probably not required. + - Because the picker button no longer supports a label, there is no need for a `--textuiicon` variant which is why that class has been removed. +- The `.is-open` state can continue to be used as before. diff --git a/.changeset/few-tigers-say.md b/.changeset/few-tigers-say.md new file mode 100644 index 00000000000..9aff7134308 --- /dev/null +++ b/.changeset/few-tigers-say.md @@ -0,0 +1,105 @@ +--- +"@spectrum-css/tokens": minor +--- + +Updated from [@adobe/spectrum-tokens](https://github.com/adobe/spectrum-tokens) [13.10.1](https://github.com/adobe/spectrum-tokens/releases/tag/%40adobe/spectrum-tokens%4013.10.1) -> [13.12.0](https://github.com/adobe/spectrum-tokens/releases/tag/%40adobe/spectrum-tokens%4013.12.0). + +### Newly deprecated + +- `--spectrum-card-minimum-width`: This token has been deprecated, use `--spectrum-card-minimum-width-default` instead. +- `--spectrum-tree-view-item-to-item`: This token has been deprecated, use `--spectrum-tree-view-item-to-item-default` instead. + +### Newly added + +| Token name | Token value | +| ------------------------------------------------ | -------------------------------------- | +| `--spectrum-component-xs-regular-font-family` | `--spectrum-sans-serif-font-family` | +| `--spectrum-component-xs-regular-font-size` | `--spectrum-font-size-50` | +| `--spectrum-component-xs-regular-font-weight` | `--spectrum-regular-font-weight` | +| `--spectrum-component-xs-regular-letter-spacing` | `--spectrum-letter-spacing` | +| `--spectrum-component-xs-regular-line-height` | `--spectrum-line-height-font-size-50` | +| `--spectrum-component-xs-medium-font-family` | `--spectrum-sans-serif-font-family` | +| `--spectrum-component-xs-medium-font-size` | `--spectrum-font-size-50` | +| `--spectrum-component-xs-medium-font-weight` | `--spectrum-medium-font-weight` | +| `--spectrum-component-xs-medium-letter-spacing` | `--spectrum-letter-spacing` | +| `--spectrum-component-xs-medium-line-height` | `--spectrum-line-height-font-size-50` | +| `--spectrum-component-xs-bold-font-family` | `--spectrum-sans-serif-font-family` | +| `--spectrum-component-xs-bold-font-size` | `--spectrum-font-size-50` | +| `--spectrum-component-xs-bold-font-weight` | `--spectrum-bold-font-weight` | +| `--spectrum-component-xs-bold-letter-spacing` | `--spectrum-letter-spacing` | +| `--spectrum-component-xs-bold-line-height` | `--spectrum-line-height-font-size-50` | +| `--spectrum-component-s-regular-font-family` | `--spectrum-sans-serif-font-family` | +| `--spectrum-component-s-regular-font-size` | `--spectrum-font-size-75` | +| `--spectrum-component-s-regular-font-weight` | `--spectrum-regular-font-weight` | +| `--spectrum-component-s-regular-letter-spacing` | `--spectrum-letter-spacing` | +| `--spectrum-component-s-regular-line-height` | `--spectrum-line-height-font-size-75` | +| `--spectrum-component-s-medium-font-family` | `--spectrum-sans-serif-font-family` | +| `--spectrum-component-s-medium-font-size` | `--spectrum-font-size-75` | +| `--spectrum-component-s-medium-font-weight` | `--spectrum-medium-font-weight` | +| `--spectrum-component-s-medium-letter-spacing` | `--spectrum-letter-spacing` | +| `--spectrum-component-s-medium-line-height` | `--spectrum-line-height-font-size-75` | +| `--spectrum-component-s-bold-font-family` | `--spectrum-sans-serif-font-family` | +| `--spectrum-component-s-bold-font-size` | `--spectrum-font-size-75` | +| `--spectrum-component-s-bold-font-weight` | `--spectrum-bold-font-weight` | +| `--spectrum-component-s-bold-letter-spacing` | `--spectrum-letter-spacing` | +| `--spectrum-component-s-bold-line-height` | `--spectrum-line-height-font-size-75` | +| `--spectrum-component-m-regular-font-family` | `--spectrum-sans-serif-font-family` | +| `--spectrum-component-m-regular-font-size` | `--spectrum-font-size-100` | +| `--spectrum-component-m-regular-font-weight` | `--spectrum-regular-font-weight` | +| `--spectrum-component-m-regular-letter-spacing` | `--spectrum-letter-spacing` | +| `--spectrum-component-m-regular-line-height` | `--spectrum-line-height-font-size-100` | +| `--spectrum-component-m-medium-font-family` | `--spectrum-sans-serif-font-family` | +| `--spectrum-component-m-medium-font-size` | `--spectrum-font-size-100` | +| `--spectrum-component-m-medium-font-weight` | `--spectrum-medium-font-weight` | +| `--spectrum-component-m-medium-letter-spacing` | `--spectrum-letter-spacing` | +| `--spectrum-component-m-medium-line-height` | `--spectrum-line-height-font-size-100` | +| `--spectrum-component-m-bold-font-family` | `--spectrum-sans-serif-font-family` | +| `--spectrum-component-m-bold-font-size` | `--spectrum-font-size-100` | +| `--spectrum-component-m-bold-font-weight` | `--spectrum-bold-font-weight` | +| `--spectrum-component-m-bold-letter-spacing` | `--spectrum-letter-spacing` | +| `--spectrum-component-m-bold-line-height` | `--spectrum-line-height-font-size-100` | +| `--spectrum-component-l-regular-font-family` | `--spectrum-sans-serif-font-family` | +| `--spectrum-component-l-regular-font-size` | `--spectrum-font-size-200` | +| `--spectrum-component-l-regular-font-weight` | `--spectrum-regular-font-weight` | +| `--spectrum-component-l-regular-letter-spacing` | `--spectrum-letter-spacing` | +| `--spectrum-component-l-regular-line-height` | `--spectrum-line-height-font-size-200` | +| `--spectrum-component-l-medium-font-family` | `--spectrum-sans-serif-font-family` | +| `--spectrum-component-l-medium-font-size` | `--spectrum-font-size-200` | +| `--spectrum-component-l-medium-font-weight` | `--spectrum-medium-font-weight` | +| `--spectrum-component-l-medium-letter-spacing` | `--spectrum-letter-spacing` | +| `--spectrum-component-l-medium-line-height` | `--spectrum-line-height-font-size-200` | +| `--spectrum-component-l-bold-font-family` | `--spectrum-sans-serif-font-family` | +| `--spectrum-component-l-bold-font-size` | `--spectrum-font-size-200` | +| `--spectrum-component-l-bold-font-weight` | `--spectrum-bold-font-weight` | +| `--spectrum-component-l-bold-letter-spacing` | `--spectrum-letter-spacing` | +| `--spectrum-component-l-bold-line-height` | `--spectrum-line-height-font-size-200` | +| `--spectrum-component-xl-regular-font-family` | `--spectrum-sans-serif-font-family` | +| `--spectrum-component-xl-regular-font-size` | `--spectrum-font-size-300` | +| `--spectrum-component-xl-regular-font-weight` | `--spectrum-regular-font-weight` | +| `--spectrum-component-xl-regular-letter-spacing` | `--spectrum-letter-spacing` | +| `--spectrum-component-xl-regular-line-height` | `--spectrum-line-height-font-size-300` | +| `--spectrum-component-xl-medium-font-family` | `--spectrum-sans-serif-font-family` | +| `--spectrum-component-xl-medium-font-size` | `--spectrum-font-size-300` | +| `--spectrum-component-xl-medium-font-weight` | `--spectrum-medium-font-weight` | +| `--spectrum-component-xl-medium-letter-spacing` | `--spectrum-letter-spacing` | +| `--spectrum-component-xl-medium-line-height` | `--spectrum-line-height-font-size-300` | +| `--spectrum-component-xl-bold-font-family` | `--spectrum-sans-serif-font-family` | +| `--spectrum-component-xl-bold-font-size` | `--spectrum-font-size-300` | +| `--spectrum-component-xl-bold-font-weight` | `--spectrum-bold-font-weight` | +| `--spectrum-component-xl-bold-letter-spacing` | `--spectrum-letter-spacing` | +| `--spectrum-component-xl-bold-line-height` | `--spectrum-line-height-font-size-300` | +| `--spectrum-component-padding-vertical-50` | `3px` (desktop) and `5px` (mobile) | +| `--spectrum-component-padding-vertical-75` | `4px` (desktop) and `5px` (mobile) | +| `--spectrum-component-padding-vertical-100` | `7px` (desktop) and `9px` (mobile) | +| `--spectrum-component-padding-vertical-200` | `10px` (desktop) and `13px` (mobile) | +| `--spectrum-component-padding-vertical-300` | `13px` (desktop) and `17px` (mobile) | +| `--spectrum-card-minimum-width-default` | `100px` | +| `--spectrum-tree-view-item-to-item-default` | `-1px` | + +### Updated + +- `--spectrum-sans-serif-font-family`: `Adobe Clean` -> `Adobe Clean Spectrum VF` +- `--spectrum-accordion-top-to-text-compact-medium`: `5px` -> `8px` +- `--spectrum-accordion-top-to-text-spacious-medium`: `16px` -> `13px` (desktop) and `19px` -> `15px` (mobile) +- `--spectrum-accordion-focus-indicator-gap`: `0px` -> `2px` +- `--spectrum-accordion-top-to-text-medium`: `12px` -> `9px` (desktop) and `16px` -> `10px` (mobile) diff --git a/.changeset/flat-snails-admire.md b/.changeset/flat-snails-admire.md new file mode 100644 index 00000000000..eeaa8dde839 --- /dev/null +++ b/.changeset/flat-snails-admire.md @@ -0,0 +1,7 @@ +--- +"@spectrum-css/infieldprogresscircle": major +--- + +#### Spectrum 2 migration + +In-field progress circle is a new component created to replace progress circle (size S) in t-shirt size components. The button, textfield, combo box, and picker `template.js` files have all been updated to call for infield progress circles. This component comes in four sizes: (S, M, L, XL), has updated color variants (default, white, black), and has a unified track thickness. diff --git a/.changeset/fluffy-hands-appear.md b/.changeset/fluffy-hands-appear.md new file mode 100644 index 00000000000..9ab1060e135 --- /dev/null +++ b/.changeset/fluffy-hands-appear.md @@ -0,0 +1,5 @@ +--- +"@spectrum-css/switch": patch +--- + +Fix active down state specificity by increasing the specificity of the active state selector. This change was necessary because the `postcss-hover-media-feature` plugin converts hover styles into a media query for devices that support hover. Without this adjustment, the hover styles could override the active down state styles due to the way CSS specificity and order are handled. By adding the additional `.spectrum-Switch` class in the active state selector, we ensure that the active state takes precedence over the hover state, maintaining the correct visual behavior of the switch component across different interaction states. diff --git a/.changeset/four-lemons-warn.md b/.changeset/four-lemons-warn.md new file mode 100644 index 00000000000..cfe87ba94ec --- /dev/null +++ b/.changeset/four-lemons-warn.md @@ -0,0 +1,22 @@ +--- +"@spectrum-css/combobox": major +"@spectrum-css/helptext": minor +--- + +### Combobox S2 migration + +#### New changes + +- Removed quiet styling variant +- Updated corner radius to match S2 specifications +- Changed outline thickness for better visibility +- Replaced picker button with in-field button component +- Added help text along with invalid state +- Modified the WHCM invalid/error state in help text + +### New tokens + +`--spectrum-combobox-font-weight` +`--spectrum-combobox-line-height-cjk` +`--spectrum-combobox-spacing-alert-icon-to-text` +`--spectrum-combobox-spacing-to-help-text` diff --git a/.changeset/fresh-crabs-deliver.md b/.changeset/fresh-crabs-deliver.md new file mode 100644 index 00000000000..faec2d41674 --- /dev/null +++ b/.changeset/fresh-crabs-deliver.md @@ -0,0 +1,16 @@ +--- +"@spectrum-css/breadcrumb": major +--- + +#### Spectrum 2 Breadcrumbs migration + +The breadcrumbs component is now updated to use the S2 specs and tokens. This includes updated spacing, heights, colors, font sizes, etc. + +There has been a major design change to the variant classes related to density and sizing, to align their terminology better with t-shirt sizes: + +- The "compact" variant no longer exists. The `spectrum-Breadcrumbs--compact` class and associated custom properties are removed. The default (medium) breadcrumbs are now sized similar to what was previously called compact. +- There is a new "large" variant, which uses the `spectrum-Breadcrumbs--sizeL` class. This is sized similarly to what was previously the default. + +In the multiline variant, the size of the title item can optionally be customized using an additional child heading element that applies one of the +typography component's `spectrum-Heading--size*` classes. The preferred sizes specified in the design spec are small, medium, large (default), and +extra-large. If an additional heading element is not used within the title item, the text will still be sized correctly to the default. diff --git a/.changeset/fresh-kings-slide.md b/.changeset/fresh-kings-slide.md new file mode 100644 index 00000000000..dbbbf1232bc --- /dev/null +++ b/.changeset/fresh-kings-slide.md @@ -0,0 +1,13 @@ +--- +"@spectrum-css/tabs": major +--- + +Tab has now been migrated to Spectrum 2. This migration brings with it several major changes: + +- Emphasized variant has been removed +- The divider line has been removed and all variants now resemble what was formerly the quiet variant +- Removal of t-shirt sizes (only one size is available) +- Updated high contrast styles +- The focus indicator's size has changed to accommodate the selection indicator inside of the focus outline + +Overflow and vertical variants, aside from what applies from the notes above, remain mostly unchanged and currently are not fully supported in S2. One exception: a bug fix was made to allow density variants to be visible in the overflow variant (previously, the overflow variant was identical for both densities). diff --git a/.changeset/fresh-seahorses-join.md b/.changeset/fresh-seahorses-join.md new file mode 100644 index 00000000000..c61e578bd5b --- /dev/null +++ b/.changeset/fresh-seahorses-join.md @@ -0,0 +1,9 @@ +--- +"@spectrum-css/button": patch +--- + +#### Remove spectrum-ButtonWithFocusRing placeholder class extend + +Removes the need for the extend from this placeholder class, as the styles it provides have diverged slightly from what is in button and it was causing some unnecessary CSS to override. + +This should not result in any changed visuals or behavior, as the same CSS has been integrated. diff --git a/.changeset/fresh-spoons-try.md b/.changeset/fresh-spoons-try.md new file mode 100644 index 00000000000..39f9d2e0885 --- /dev/null +++ b/.changeset/fresh-spoons-try.md @@ -0,0 +1,7 @@ +--- +"@spectrum-css/logicbutton": patch +--- + +### S2 logic button fix + +Adds `border-style: solid` to the styles to avoid a 3D effect on the border. diff --git a/.changeset/friendly-dolls-raise.md b/.changeset/friendly-dolls-raise.md new file mode 100644 index 00000000000..e8504c217f4 --- /dev/null +++ b/.changeset/friendly-dolls-raise.md @@ -0,0 +1,5 @@ +--- +"@spectrum-css/avatar": major +--- + +Adds support for new avatar-size tokens (avatar-size-800 to avatar-size-1500). Updates avatar component story to support new sizes. Adds support for avatar-border-color and avatar-border-thickness. diff --git a/.changeset/giant-windows-smoke.md b/.changeset/giant-windows-smoke.md new file mode 100644 index 00000000000..81eb99b8d9e --- /dev/null +++ b/.changeset/giant-windows-smoke.md @@ -0,0 +1,15 @@ +--- +"@spectrum-css/colorwheel": major +--- + +#### Spectrum 2 migration + +This change migrates the colorwheel component to S2. It adds the `--spectrum-colorwheel-border-color-rgb` and `--spectrum-colorwheel-border-opacity` custom properties. It updates `--spectrum-colorwheel-border-color` to leverage these tokens in an `rgba(...)` function. + +This removes the `spectrum-ColorWheel-border` and associated template DOM node as the outside/underlying border are no longer present in the S2 designs. `::before` and `::after` pseudo elements are now used to draw the exterior and interior borders that overlay the exterior and interior edges of the color wheel. + +Support is provided for the `240px` and `192px` sizes outlined in the design requirements. + +The `forced-colors` media query has been moved to the bottom of the file consistent with our other component implementations. + +Stories, tests and documentation have been updated to be consistent with these changes. diff --git a/.changeset/gold-cats-hide.md b/.changeset/gold-cats-hide.md new file mode 100644 index 00000000000..301105abfa2 --- /dev/null +++ b/.changeset/gold-cats-hide.md @@ -0,0 +1,9 @@ +--- +"@spectrum-css/popover": minor +--- + +Restores drop shadow for nested popovers. This is done by moving the default popover to `box-shadow` and using `filter` for popovers with tip. This allows for visual consistency across all popovers. + +#### New custom properties + +`--spectrum-popover-box-shadow` diff --git a/.changeset/good-times-dress.md b/.changeset/good-times-dress.md new file mode 100644 index 00000000000..9bdfd26eb7f --- /dev/null +++ b/.changeset/good-times-dress.md @@ -0,0 +1,11 @@ +--- +"@spectrum-css/tokens": patch +--- + +Updated from [@adobe/spectrum-tokens](https://github.com/adobe/spectrum-tokens) [13.15.0](https://github.com/adobe/spectrum-tokens/releases/tag/%40adobe/spectrum-tokens%4013.15.0) -> [13.15.1](https://github.com/adobe/spectrum-tokens/releases/tag/%40adobe/spectrum-tokens%4013.15.1). + +### Updated + +- `--spectrum-standard-panel-gripper-color`: Updated from `var(--spectrum-gray-200)` to `var(--spectrum-gray-500)`. + +- [#593](https://github.com/adobe/spectrum-tokens/pull/593) [`1e860c4`](https://github.com/adobe/spectrum-tokens/commit/1e860c4436c58ceca6f4500ea7e24d6d8cdd20c8) Thanks [@mrcjhicks](https://github.com/mrcjhicks)! diff --git a/.changeset/green-falcons-rush.md b/.changeset/green-falcons-rush.md new file mode 100644 index 00000000000..56fd9dc0307 --- /dev/null +++ b/.changeset/green-falcons-rush.md @@ -0,0 +1,5 @@ +--- +"@spectrum-css/infieldbutton": patch +--- + +Updates transition to use `background-color` instead of `border-color`. Fixes a flash bug in WHCM: when hovered, the infield button was flashing/blinking before changing to the appropriate hover color. diff --git a/.changeset/grumpy-ghosts-serve.md b/.changeset/grumpy-ghosts-serve.md new file mode 100644 index 00000000000..9e41cf4bc15 --- /dev/null +++ b/.changeset/grumpy-ghosts-serve.md @@ -0,0 +1,7 @@ +--- +"@spectrum-css/picker": major +--- + +#### Picker: remove quiet variant + +This removes the quiet variant for the picker component based on design feedback. Prior to this change, there was an odd state where the quiet picker scaled with the foundations down state applied. diff --git a/.changeset/healthy-chicken-clap.md b/.changeset/healthy-chicken-clap.md new file mode 100644 index 00000000000..b8c5652690e --- /dev/null +++ b/.changeset/healthy-chicken-clap.md @@ -0,0 +1,23 @@ +--- +"@spectrum-css/textfield": major +--- + +#### Migrate to Spectrum 2 + +- Default styles are used for medium +- Removal of quiet variant +- Style adjustments to match design spec: + - Spacing start/end edge to value for XL component should use `component-edge-to-text-300`, not `-200` + - Spacing top edge to value should change with size, now uses different spacing tokens for each component tshirt size according to spec (`component-top-to-text-75`, `-100`, `-200`, and `-300`) + - Spacing bottom edge to value should change with size, now uses different spacing tokens for each component tshirt size according to spec (`component-bottom-to-text-75`, `-100`, `-200`, and `-300`) + - Border thickness has been increased to 2px, and border colors have been updated to match spec + - Adjust side label inline spacing to field, should be `spacing-200` for all tshirt sizes + - Change disabled background color to `gray-25` + - Change disabled-border-color from transparent to `disabled-border-color` +- Use new and updated tokens: + - use tokens for textfield width (`field-default-width-small`, `-medium`, `-large`, `-extra-large`) + - use updated corner radius tokens + - use different component-bottom-to-text tokens for character-count-spacing-block + - update tokens for alert icon block spacing + - update tokens for alert and invalid inline-start spacing + - update font tokens diff --git a/.changeset/hip-shoes-listen.md b/.changeset/hip-shoes-listen.md new file mode 100644 index 00000000000..5fb94d03452 --- /dev/null +++ b/.changeset/hip-shoes-listen.md @@ -0,0 +1,5 @@ +--- +"@spectrum-css/tokens": patch +--- + +Adds `--spectrum-table-selected-row-background-color-rgb` to `light-vars.css` and `dark-vars.css` for custom tokens. diff --git a/.changeset/honest-animals-stop.md b/.changeset/honest-animals-stop.md new file mode 100644 index 00000000000..b0ed21b7a14 --- /dev/null +++ b/.changeset/honest-animals-stop.md @@ -0,0 +1,7 @@ +--- +"@spectrum-css/fieldlabel": patch +--- + +#### Fix fieldlabel required icon wrapping + +Addresses case where fieldlabel required icon could appear on its own line when wrapping by applying text-wrap: pretty; to the parent label class and adding a non-breaking space character between the label content and required marker. diff --git a/.changeset/hot-books-fail.md b/.changeset/hot-books-fail.md new file mode 100644 index 00000000000..c42b80dc04b --- /dev/null +++ b/.changeset/hot-books-fail.md @@ -0,0 +1,7 @@ +--- +"@spectrum-css/picker": major +--- + +#### Spectrum 2 migration + +Picker now uses Spectrum 2 tokens and specifications. diff --git a/.changeset/itchy-kids-travel.md b/.changeset/itchy-kids-travel.md new file mode 100644 index 00000000000..72a186d58d5 --- /dev/null +++ b/.changeset/itchy-kids-travel.md @@ -0,0 +1,20 @@ +--- +"@spectrum-css/progresscircle": major +--- + +### Spectrum 2 progress circle migration + +This is the Spectrum 2 styles migration of the progress circle. The original markup has changed to an svg and circle element to allow CSS styles such as `stroke-linecap`. This was necessary to match the design. The `--small/--medium/--large` sizing classes have been deprecated in favor of t-shirt classes `--sizeS/--sizeM/--sizeL` + +#### Animation + +`@keyframes spectrum-dashoffset-animation`: +This animation was created by React Spectrum and used to keep the same speed and bezier curve. + +#### Removed properties + +`--spectrum-progress-circle-track-border-color-over-background` +`--spectrum-progress-circle-fill-border-color-over-background` +`--spectrum-progress-circle-track-border-style` +`--spectrum-progress-circle-track-border-style` +`--spectrum-progress-circle-track-border-style` diff --git a/.changeset/itchy-shrimps-help.md b/.changeset/itchy-shrimps-help.md new file mode 100644 index 00000000000..68598dd4f7c --- /dev/null +++ b/.changeset/itchy-shrimps-help.md @@ -0,0 +1,5 @@ +--- +"@spectrum-css/picker": patch +--- + +S2 Popover has an updated default position, bottom-start. The correct `.spectrum-Popover--bottom-start` class was added to the open popover selector blocks for picker so that the spacing from the picker to the popover is correctly adjusted. diff --git a/.changeset/itchy-waves-work.md b/.changeset/itchy-waves-work.md new file mode 100644 index 00000000000..ba217731a17 --- /dev/null +++ b/.changeset/itchy-waves-work.md @@ -0,0 +1,34 @@ +--- +"@spectrum-css/stepper": major +--- + +### Number field S2 Migration + +This work migrations the stepper/number field component to Spectrum 2! 🎉 The S1 stepper was very minimal, and didn't align with SWC or React's implementation. This migration should bring parity to the CSS component. New features include: + +- the display name for this component has changed from `stepper` to `number field` (based on design's, React's and SWC's naming conventions.) + - _**Note:**_ The NPM package name has remained as "stepper," and hasn't yet changed to "number field."" +- an error state with alert icon +- optional help text +- embedded field label & optional positions + +#### Quick overview + +Because of all the new features and to align more with design, SWC and React, below is a quick recap of the following tokens & classes that have been renamed in the CSS: + +- All `.spectrum-Stepper*` class names have been converted to `.spectrum-NumberField*` +- The `.hide-stepper` class has been converted to `.spectrum-NumberField--hiddenStepper` +- Custom properties have been renamed from `--spectrum-stepper*` to `--spectrum-numberfield*` +- Markup has changed +- Styling lives on different elements +- Lots more Chromatic test coverage + +#### Markup + +Following React's lead, the markup of the number field has changed. More obviously, help text and field label components are embedded into `.spectrum-NumberField`, instead of necessitating separate components. The number field now incorporates an error state that better reflects the embedded textfield's error state, so there is now an alert icon within the markup in an invalid number field. Additionally, a new `.spectrum-NumberField-inputs` containing wrapper was introduced to encapsulate the textfield element and infield button elements. This container allowed for some extra alignment styles for those 2 elements and then freed up the opportunity to introduced an "unstyled" `input` (as described more below). Custom classes were also added to the nested textfield and input elements to ensure styles for number field were passed correctly to the correct elements (`.spectrum-NumberField-textfield` and `.spectrum-NumberField-input`). + +Stemming from the infield button S2 migration, there is also an extra container for the inline (previously "stacked") stepper buttons. + +#### Styling + +The `.spectrum-NumberField-textfield` div is where the S2 design language lives (instead of on the input element), while the actual `input` (`.spectrum-NumberField-input`) is unstyled and incorporated more subtly. Breaking changes were introduced in all previous custom properties, where any `--spectrum-stepper-*` properties were renamed to `--spectrum-numberfield-*`. This also applied to class names, where `.spectrum-Stepper` changed to `.spectrum-NumberField`. The `hide-stepper` class has also been updated to match our class naming conventions (`.spectrum-NumberField--hiddenStepper`). diff --git a/.changeset/khaki-icons-hammer.md b/.changeset/khaki-icons-hammer.md new file mode 100644 index 00000000000..d03c36f36ea --- /dev/null +++ b/.changeset/khaki-icons-hammer.md @@ -0,0 +1,15 @@ +--- +"@spectrum-css/tag": major +--- + +Tag now uses Spectrum 2 tokens and specifications: + +- The invalid variant has been removed, tag errors are now displayed with help text within the tag group only. +- Borders remain in high contrast but are otherwise transparent. +- Thumbnail has been added as a visual option. +- Tag now has a max-inline-size. +- Read-only tags are now supported. +- Passthroughs for clear button have been updated to match the current spec. +- Default t-shirt size for tag is small. +- Clear button has accessibly sized target. +- Emphasized tags have accent coloring only when they are selected. diff --git a/.changeset/kind-cycles-check.md b/.changeset/kind-cycles-check.md new file mode 100644 index 00000000000..958e00b5267 --- /dev/null +++ b/.changeset/kind-cycles-check.md @@ -0,0 +1,6 @@ +--- +"@spectrum-css/preview": minor +--- + +- _feature_: Add the `resetArgs` function to the argEvents decorator +- _fix_: Resolve minor lint warnings in the Storybook CSS assets diff --git a/.changeset/late-worms-reply.md b/.changeset/late-worms-reply.md new file mode 100644 index 00000000000..145328d49ca --- /dev/null +++ b/.changeset/late-worms-reply.md @@ -0,0 +1,7 @@ +--- +"@spectrum-css/floatingactionbutton": patch +--- + +## S2 floating action button fix + +Opts to use the color property as opposed to fill for the icon. This correctly passes the floating action button icon colors to the component, to override the fill property style that is set on the embedded `.spectrum-Icon`. diff --git a/.changeset/legal-lands-warn.md b/.changeset/legal-lands-warn.md new file mode 100644 index 00000000000..7b4615bf3eb --- /dev/null +++ b/.changeset/legal-lands-warn.md @@ -0,0 +1,24 @@ +--- +"@spectrum-css/contextualhelp": major +--- + +#### S2 migration for contextual help + +This migrates the contextual help component to the latest Spectrum 2 designs. Custom properties have been remapped and added per the design specification. + +Typographic and color tokens have been updated per design specifications. + +All existing popover positioning variations are supported. + +##### New custom properties + +`--spectrum-contextual-help-body-color` +`--spectrum-contextual-help-body-line-height` +`--spectrum-contextual-help-body-sans-serif-font-family` +`--spectrum-contextual-help-body-sans-serif-font-style` +`--spectrum-contextual-help-body-sans-serif-font-weight` +`--spectrum-contextual-help-title-color` +`--spectrum-contextual-help-title-font-style` +`--spectrum-contextual-help-title-font-weight` +`--spectrum-contextual-help-title-line-height` +`--spectrum-contextual-help-title-sans-serif-font-family` diff --git a/.changeset/lemon-flowers-poke.md b/.changeset/lemon-flowers-poke.md new file mode 100644 index 00000000000..6c4ea179ad0 --- /dev/null +++ b/.changeset/lemon-flowers-poke.md @@ -0,0 +1,42 @@ +--- +"@spectrum-css/alertdialog": major +--- + +#### S2 migration for alert dialog + +This migrates the `alert dialog` component to the latest Spectrum 2 designs. Custom properties have been remapped and added per the design specification. + +The icon in the dialog header has been moved from the right side to the left. + +The dialog divider has been removed. + +Primary button style has been updated to filled. + +The following variants remain supported: + +- Confirmation +- Information +- Destructive +- Warning (with `AlertDiamond` icon) +- Error (with `AlertTriangle` icon) + +Dialog buttons may be displayed either horizontally or vertically. + +##### Removed custom properties + +`--spectrum-alert-dialog-description-to-buttons` +`--spectrum-alert-dialog-divider-to-description` +`--spectrum-alert-dialog-padding` +`--spectrum-alert-dialog-title-size` +`--spectrum-alert-dialog-title-to-divider` +`--spectrum-alert-dialog-title-to-icon` + +##### New custom properties + +`--spectrum-alert-dialog-background-color` +`--spectrum-alert-dialog-corner-radius` +`--spectrum-alert-dialog-description-font-size` +`--spectrum-alert-dialog-description-to-button-group` +`--spectrum-alert-dialog-edge-to-content` +`--spectrum-alert-dialog-heading-size` +`--spectrum-alert-dialog-title-to-description` diff --git a/.changeset/lemon-weeks-work.md b/.changeset/lemon-weeks-work.md new file mode 100644 index 00000000000..3ac5745d3eb --- /dev/null +++ b/.changeset/lemon-weeks-work.md @@ -0,0 +1,11 @@ +--- +"@spectrum-css/tokens": minor +--- + +#### Tokens + +Adds custom vars for coachmark action menu vertical spacing. These help provide consistent spacing between states when the action menu is and is not visible. + +In `tokens/custom/large-vars.css`: `--spectrum-coachmark-action-menu-vertical-offset`. + +In `tokens/custom/medium-vars.css`: `--spectrum-coachmark-action-menu-vertical-offset`. diff --git a/.changeset/light-years-speak.md b/.changeset/light-years-speak.md new file mode 100644 index 00000000000..f9438689e7b --- /dev/null +++ b/.changeset/light-years-speak.md @@ -0,0 +1,9 @@ +--- +"@spectrum-css/tooltip": major +--- + +#### Spectrum 2 migration + +This migration includes updated colors, rounding, a bigger tip, and the removal of variants (only neutral is available in Spectrum 2). As a result of the deprecation of variants, icons have also been removed. + +The redesign of the tip, specifically the rounding, required a reworking of how we use clip-path and transform. diff --git a/.changeset/long-carrots-sleep.md b/.changeset/long-carrots-sleep.md new file mode 100644 index 00000000000..03362d6c3da --- /dev/null +++ b/.changeset/long-carrots-sleep.md @@ -0,0 +1,15 @@ +--- +"@spectrum-css/search": major +--- + +## S2 Collapsed search field + +The search component allows for a minimized state where the search field is collapsed to a button. + +### Anatomy + +The collapsed state consists of a single action button that has a hover, keyboard focused, and disabled state. This state is triggered by the `is-collapsed` class on the search component. When the search field is in this state, the textfield is hidden and the search button is displayed. The button can be hovered and focused, and will expand the search field when clicked. + +### Usage + +The collapsed state is used to reduce the amount of space taken up by the search field. It is most commonly used next a filter button to allow users to quickly search and filter content. diff --git a/.changeset/lovely-geckos-hammer.md b/.changeset/lovely-geckos-hammer.md new file mode 100644 index 00000000000..00550a17385 --- /dev/null +++ b/.changeset/lovely-geckos-hammer.md @@ -0,0 +1,5 @@ +--- +"@spectrum-css/link": minor +--- + +Fixes keyboard focus shift by changing padding to outline-offset diff --git a/.changeset/mean-eggs-learn.md b/.changeset/mean-eggs-learn.md new file mode 100644 index 00000000000..7df3bbecb4c --- /dev/null +++ b/.changeset/mean-eggs-learn.md @@ -0,0 +1,5 @@ +--- +"@spectrum-css/thumbnail": minor +--- + +Replaces `corner-radius-75` with `thumbnail-corner-radius`. diff --git a/.changeset/metal-fireants-switch.md b/.changeset/metal-fireants-switch.md new file mode 100644 index 00000000000..6d8fa2eba84 --- /dev/null +++ b/.changeset/metal-fireants-switch.md @@ -0,0 +1,16 @@ +--- +"@spectrum-css/dialog": major +"@spectrum-css/modal": patch +"@spectrum-css/underlay": patch +--- + +#### Spectrum 2 Standard dialog migration + +This is the migration for standard dialog. The Divider component is no longer supported in S2 dialogs. In addition, some new and updated tokens are in place to update dialog corner rounding, font treatments, spacing/padding, and maximum/minimum widths. There were several new elements implemented as well, including optional header and footer content, hero/cover images, checkbox and text-only options in the footer content area. + +The `.spectrum-Dialog--small`, `.spectrum-Dialog--medium`, and `.spectrum-Dialog--large` sizing classes were deprecated and removed from the CSS in favor of the t-shirt sizes. Additionally, the spelling of the `.spectrum-Dialog--dismissable` class was corrected to `.spectrum-Dialog--dismissible`. + +Modal and underlay updates + +- Modal component now uses the updated corner rounding. +- Underlay has an updated comment that addresses the overlay-color/overlay-opacity tokens. diff --git a/.changeset/mighty-pigs-accept.md b/.changeset/mighty-pigs-accept.md new file mode 100644 index 00000000000..a7be20caa74 --- /dev/null +++ b/.changeset/mighty-pigs-accept.md @@ -0,0 +1,9 @@ +--- +"@spectrum-css/progressbar": minor +"@spectrum-css/meter": minor +--- + +Adjust progressbar styles, story and template to support proper width token and sizes for medium (desktop) and large (mobile) platforms. + +- Progress bar and meter now use the same tokens to control their width. +- Progress bar and meter now have a set width regardless of t-shirt size. diff --git a/.changeset/modern-chairs-sit.md b/.changeset/modern-chairs-sit.md new file mode 100644 index 00000000000..8352f4bf418 --- /dev/null +++ b/.changeset/modern-chairs-sit.md @@ -0,0 +1,18 @@ +--- +"@spectrum-css/dialog": major +"@spectrum-css/modal": minor +--- + +#### S2 Takeover dialog + +This is the migration for the fullscreen/fullscreenTakeover dialog stories (these stories correspond to the "takeover dialog" in Figma). The Divider component support was removed in S2 standard dialog migration ([#2860](https://github.com/adobe/spectrum-css/pull/2860)). New and updated tokens are in place to update fullscreen/fullscreenTakeover dialog sizing, grid spacing, spacing in the header, and font sizes. Fullscreen/fullscreenTakeover dialogs do not support additional footer content or checkboxes (in comparison to the standard dialog). + +Takeover dialogs also support replacing text in the header and body areas with other components. This required an additional `.spectrum-Dialog-headerContentWrapper` element that should center whatever component/content within. + +Class names updated to match naming convention (remove hyphens and capitalize second word): +`.spectrum-Dialog-header-content` > `.spectrum-Dialog-headerContent` +`.spectrum-Dialog-footer-content` > `.spectrum-Dialog-footerContent` + +#### Modal updates + +- Modal component now uses the updated margin token (`window-to-edge`) found in the takeover dialog design specs. This work also introduced `--spectrum-modal-takeover-window-to-edge` diff --git a/.changeset/modern-times-happen.md b/.changeset/modern-times-happen.md new file mode 100644 index 00000000000..b0fbcf5316b --- /dev/null +++ b/.changeset/modern-times-happen.md @@ -0,0 +1,5 @@ +--- +"@spectrum-css/popover": patch +--- + +Popover positioning "top-left" and "top-right" were using inline properties which caused the spacings to swap in RTL mode. This was unintended as the "right" and "left" naming conventions are meant to retain their location in LTR or RTL mode. diff --git a/.changeset/nasty-rats-rhyme.md b/.changeset/nasty-rats-rhyme.md new file mode 100644 index 00000000000..f1cd0b500bd --- /dev/null +++ b/.changeset/nasty-rats-rhyme.md @@ -0,0 +1,5 @@ +--- +"@spectrum-css/bundle": major +--- + +Updated picker and table changes brought into the released bundle. diff --git a/.changeset/neat-schools-take.md b/.changeset/neat-schools-take.md new file mode 100644 index 00000000000..e72a9fc0598 --- /dev/null +++ b/.changeset/neat-schools-take.md @@ -0,0 +1,12 @@ +--- +"@spectrum-css/clearbutton": major +--- + +#### S2 migration for clear button + +This migrates the clear button component to the latest Spectrum 2 designs. Custom properties have been remapped and added per the design specification. + +- The quiet variant has been remove as all clear buttons have a transparent background. +- The over-background and static color variants have been removed. +- Test and stories for deprecated variants have been removed. +- The down state has been added, corresponding controls and tests have been added. diff --git a/.changeset/nice-cows-shout.md b/.changeset/nice-cows-shout.md new file mode 100644 index 00000000000..ae192e1eedd --- /dev/null +++ b/.changeset/nice-cows-shout.md @@ -0,0 +1,44 @@ +--- +"@spectrum-css/coachmark": major +--- + +### Spectrum 2 coachmark migration + +This migrates the `coachmark` component to S2. Custom properties have been remapped per the design spec. + +| Before | After | +| -------------------------------------------- | ------------------------------------------------- | +| `--spectrum-heading-sans-serif-font-weight` | `--spectrum-title-sans-serif-font-weight` | +| `--spectrum-coach-mark-title-size` | `--spectrum-coach-mark-title-font-size` | +| `--spectrum-heading-line-height` | `--spectrum-title-line-height` | +| `--spectrum-heading-serif-font-style` | `--spectrum-title-serif-font-style` | +| `--spectrum-coach-mark-body-size` | `--spectrum-coach-mark-body-font-size` | +| `--spectrum-body-sans-serif-font-style` | `--spectrum-body-serif-font-style` | +| `--spectrum-coach-mark-pagination-body-size` | `--spectrum-coach-mark-pagination-body-font-size` | + +#### New properties + +```css +--spectrum-coachmark-media-fixed-height +--spectrum-coachmark-media-min-height +--spectrum-coachmark-menu-display +--spectrum-coachmark-menu-mobile-display +--spectrum-coachmark-min-width +--spectrum-coachmark-padding +--spectrum-coachmark-step-color +--spectrum-coachmark-step-font-size +--spectrum-coachmark-step-font-style +--spectrum-coachmark-step-text-font-weight +--spectrum-coachmark-step-text-line-height +--spectrum-coachmark-step-to-bottom +--spectrum-coachmark-title-color +--spectrum-coachmark-title-font-family +--spectrum-coachmark-title-font-size +--spectrum-coachmark-title-font-style +--spectrum-coachmark-title-text-font-weight +--spectrum-coachmark-title-text-line-height +``` + +## Additions + +Adds `--spectrum-coachmark-media-fixed-height` for fixed `4:3` image variant. This variation has been added to the `coachmark` component story as a boolean control labeled as `Fixed image height`. The class is conditionally added within the `hasImage` block and, as such, will only impact rendering when `hasImage` is also `true`. diff --git a/.changeset/nine-kings-repair.md b/.changeset/nine-kings-repair.md new file mode 100644 index 00000000000..91e0fb36db6 --- /dev/null +++ b/.changeset/nine-kings-repair.md @@ -0,0 +1,11 @@ +--- +"@spectrum-css/button": major +--- + +#### S2 Button migration + +Button now uses Spectrum 2 tokens and specifications, which includes many color changes to all variants. A few other notable changes: + +- Outline buttons are no longer available in accent and negative options - use the filled variant instead. +- Medium size is now the default. The class `.spectrum-Button--sizeM` is now unnecessary for this size, and has been removed. +- The `.spectrum-Button--fill` class is no longer needed and has been removed. diff --git a/.changeset/old-goats-chew.md b/.changeset/old-goats-chew.md new file mode 100644 index 00000000000..92074ba5f71 --- /dev/null +++ b/.changeset/old-goats-chew.md @@ -0,0 +1,5 @@ +--- +"@spectrum-css/tokens": patch +--- + +Adds `--spectrum-corner-radius-1000: 9999px;` to global-vars.css to override value of 0.5. This should ensure our components that use this custom property are properly rounded (i.e. the fully rounded swatch or search field) diff --git a/.changeset/olive-tools-hang.md b/.changeset/olive-tools-hang.md new file mode 100644 index 00000000000..4f8a291984d --- /dev/null +++ b/.changeset/olive-tools-hang.md @@ -0,0 +1,57 @@ +--- +"@spectrum-css/ui-icons": major +--- + +Iconography in v1 inclued 2 sizes, `medium` and `large`, as well as a single SVG asset that included both versions to be toggled with classes via CSS (found in folder`combined`). Icons in v2 no longer have multiple sizes and all assets are sourced from a single folder`svg` which can be found in the `dist` directory of this workspace. **Raw SVG assets can no longer be sourced from the top-level of the workspace and must be loaded from `@spectrum-css/ui-icons/dist/svg/*.svg` instead.** Please find below an outline of the new, deprecated, and unchanged icons. + +| Icon name | Migration notes | +| ----------------- | --------------- | +| Arrow75 | Deprecated | +| Arrow100 | - | +| Arrow200 | Deprecated | +| Arrow300 | Deprecated | +| Arrow400 | - | +| Arrow500 | Deprecated | +| Arrow600 | Deprecated | +| Asterisk75 | Deprecated | +| Asterisk100 | - | +| Asterisk200 | - | +| Asterisk300 | - | +| Checkmark50 | - | +| Checkmark75 | - | +| Checkmark100 | - | +| Checkmark200 | - | +| Checkmark300 | - | +| Checkmark400 | - | +| Checkmark500 | Deprecated | +| Checkmark600 | Deprecated | +| Chevron50 | - | +| Chevron75 | - | +| Chevron100 | - | +| Chevron200 | - | +| Chevron300 | - | +| Chevron400 | - | +| Chevron500 | Deprecated | +| Chevron600 | Deprecated | +| CornerTriangle75 | - | +| CornerTriangle100 | - | +| CornerTriangle200 | - | +| CornerTriangle300 | - | +| Cross75 | - | +| Cross100 | - | +| Cross200 | - | +| Cross300 | - | +| Cross400 | - | +| Cross500 | - | +| Cross600 | - | +| Dash50 | - | +| Dash75 | - | +| Dash100 | - | +| Dash200 | - | +| Dash300 | - | +| Dash400 | Deprecated | +| Dash500 | Deprecated | +| Dash600 | Deprecated | +| SingleGripper | Deprecated | +| DoubleGripper | Deprecated | +| TripleGripper | Deprecated | diff --git a/.changeset/open-squids-refuse.md b/.changeset/open-squids-refuse.md new file mode 100644 index 00000000000..e63c2bfcf56 --- /dev/null +++ b/.changeset/open-squids-refuse.md @@ -0,0 +1,20 @@ +--- +"@spectrum-css/picker": major +--- + +### S2 Picker component refactor + +- Refactors Picker component to use proper custom property naming conventions +- Adds size-specific animation distances for Popover component +- Improves component structure with proper class by renaming `spectrum-Picker` to `spectrum-Picker-button` +- `spectrum-Picker` now encapsulates help text, label, and popover components +- Adds `flex-shrink` to progress circle for better layout control when truncation and loading is visible +- Updates Popover animation distance to use `spectrum-Picker` custom properties + +#### New token + +`--spectrum-picker-popover-animation-distance` + +#### Renamed tokens + +`spectrum-picker-spacing-picker-to-popover` --> `--spectrum-picker-popover-animation-distance` diff --git a/.changeset/petite-toys-greet.md b/.changeset/petite-toys-greet.md new file mode 100644 index 00000000000..e10819b3e31 --- /dev/null +++ b/.changeset/petite-toys-greet.md @@ -0,0 +1,42 @@ +--- +"@spectrum-css/table": major +--- + +### S2 table migration + +Compared to the S1 table, this component has updated corner rounding, updated color tokens, some updated spacing, and an overall refreshed look. + +#### Net-new features + +- The S2 table supports an empty state, rendering an illustrated message component. +- As data is loading to the table, this component will render a progress circle during the loading state. +- There are 2 selection modes: single-select and multi-select. Multi-select tables (`selectionMode: "multiple"`) render an indeterminate checkbox in the `thead`/`div` equivalent. Single-select tables (`selectionMode: "single"`) do not render the indeterminate checkbox in the header row. (Note: the `selectionMode` arg is disabled and will not render in the Storybook control table.) +- For tables with sortable column, there are three new S2 icons used: `Sort` to indicate "general" sorting, `SortUp` for ascending sort direction, `SortDown` for descending sort direction. +- Tables support thumbnail, avatar, and icon components as content within a cell. +- Focus indicators for entire rows have been updated for rows to include a side focus indicator. + +#### Description of other S2 table work + +T-shirt sizing for tables is not technically supported, so t-shirt size classes (i.e. `.spectrum-Table--sizeS`), have been removed across all density variants. + +The `.spectrum-Table-cell--alignRight` class has been renamed to `.spectrum-Table-cell--alignEnd` to reflect the preference for "logical" positioning. The `.spectrum-Table-cell--alignCenter` class has been refactored to `.spectrum-Table-cell--alignStart`. + +In S1, the CSS table component only supported thumbnails. Because the S2 table supports thumbnails, as well as avatars and icons, most of the language regarding thumbnails has also changed. For instance, the `showThumbnail` storybook arg was refactored to `visualElement`. The following CSS classes have been removed or refactored to remove the thumbnail language in favor of "visual" instead: + +- `.spectrum-Table-thumbnailInner` >> `.spectrum-Table-visualInner` + +- `.spectrum-Table-row--thumbnail` >> **removed** +- `.spectrum-Table-cell--thumbnail` >> **removed** +- `.spectrum-Table-thumbnailInner` >> **removed** +- `.spectrum-Table-thumbnailContent` >> **removed** +- `.spectrum-Table-thumbnailInner` >> **removed** + +The drop zones have been refactored to approach the drop zone indicators as pseudo elements, as opposed to `outline` properties. + +Because there are multiple sort icons in the S2 table, `.spectrum-Table-sortedIcon` has been renamed to `.spectrum-Table-sortIcon`. + +Individual cell focus rings have rounded corners. + +The outer table border extends all the way around the `thead`/`div` equivalent. + +In Storybook, several new stories have been added to the docs page and the testing grid for Chromatic. These stories include `EmptyState`, `LoadingState`, `SingleSelect`, `NumericalData`, `TableStates`, `Sortable`. Documentation has been added for each of these stories, as well as expanded in other stories. diff --git a/.changeset/plain-papayas-wish.md b/.changeset/plain-papayas-wish.md new file mode 100644 index 00000000000..9ed7717e653 --- /dev/null +++ b/.changeset/plain-papayas-wish.md @@ -0,0 +1,45 @@ +--- +"@spectrum-css/tokens": minor +--- + +Updated from [@adobe/spectrum-tokens](https://github.com/adobe/spectrum-tokens) [13.15.1](https://github.com/adobe/spectrum-tokens/releases/tag/%40adobe/spectrum-tokens%4013.15.1) -> [13.16.0](https://github.com/adobe/spectrum-tokens/releases/tag/%40adobe/spectrum-tokens%4013.16.0). + +### Deprecated + +- `--spectrum-side-navigation-maximum-width` +- `--spectrum-side-navigation-with-icon-second-level-edge-to-text` +- `--spectrum-side-navigation-with-icon-third-level-edge-to-text` + +### Added + +- `--spectrum-side-navigation-counter-to-disclosure` +- `--spectrum-side-navigation-edge-to-indicator` +- `--spectrum-side-navigation-indicator-to-content` +- `--spectrum-side-navigation-second-level-edge-to-indicator` +- `--spectrum-side-navigation-second-level-with-icon-edge-to-text` +- `--spectrum-side-navigation-second-level-with-icon-edge-to-indicator` +- `--spectrum-side-navigation-third-level-edge-to-indicator` +- `--spectrum-side-navigation-third-level-with-icon-edge-to-text` +- `--spectrum-side-navigation-third-level-with-icon-edge-to-indicator` +- `--spectrum-side-navigation-trailing-accessory-area-to-edge` +- `--spectrum-side-navigation-indicator-height` +- `--spectrum-side-navigation-indicator-thickness` +- `--spectrum-side-navigation-edge-to-indicator` +- `--spectrum-side-navigation-indicator-to-content` +- `--spectrum-side-navigation-second-level-edge-to-indicator` +- `--spectrum-side-navigation-second-level-with-icon-edge-to-text` +- `--spectrum-side-navigation-second-level-with-icon-edge-to-indicator` +- `--spectrum-side-navigation-third-level-edge-to-indicator` +- `--spectrum-side-navigation-third-level-with-icon-edge-to-text` +- `--spectrum-side-navigation-third-level-with-icon-edge-to-indicator` +- `--spectrum-side-navigation-trailing-accessory-area-to-edge` +- `--spectrum-side-navigation-indicator-height` +- `--spectrum-side-navigation-indicator-thickness` + +### Updated + +- `--spectrum-side-navigation-minimum-width`: Updated from `160px` to `144px` (desktop) and `200px` to `180px` (mobile). +- `--spectrum-side-navigation-second-level-edge-to-text`: Updated from `24px` to `38px` (desktop) and `30px` to `44px` (mobile). +- `--spectrum-side-navigation-third-level-edge-to-text`: Updated from `36px` to `64px` (desktop) and `45px` to `70px` (mobile). +- `--spectrum-side-navigation-with-icon-second-level-edge-to-text`: Updated from `50px` to `--spectrum-side-navigation-second-level-with-icon-edge-to-text` (desktop) and `62px` to `side-navigation-second-level-with-icon-edge-to-text` (mobile). +- `--spectrum-side-navigation-with-icon-third-level-edge-to-text`: Updated from `62px` to `--spectrum-side-navigation-third-level-with-icon-edge-to-text` (desktop) and `77px` to `--spectrum-side-navigation-third-level-with-icon-edge-to-text` (mobile). diff --git a/.changeset/polite-apes-think.md b/.changeset/polite-apes-think.md new file mode 100644 index 00000000000..0097b00967a --- /dev/null +++ b/.changeset/polite-apes-think.md @@ -0,0 +1,5 @@ +--- +"@spectrum-css/dialog": minor +--- + +Increases flexibility and responsiveness of the dialog header. A container query for the `.spectrum-Dialog` was added, which now triggers the reflow of the `.spectrum-Dialog--fullscreen`/`.spectrum-Dialog--fullscreenTakeover` content grid. This is particularly useful when the component slot is utilized to add other components as additional content in fullscreen/fullscreenTakeover dialogs' header areas by allowing the content to reflow sooner. diff --git a/.changeset/polite-moments-stay.md b/.changeset/polite-moments-stay.md new file mode 100644 index 00000000000..938ebb21c8f --- /dev/null +++ b/.changeset/polite-moments-stay.md @@ -0,0 +1,5 @@ +--- +"@spectrum-css/modal": patch +--- + +In Spectrum 2, elements that would typically be children of a modal (like dialogs, alert dialogs, and tray) have background-color token specs defined. Because modal _also_ had a defined background color, there was some antialiasing bleed-through happening on the corners, since both the modal and its child now had background colors on top of each other. `--spectrum-modal-background-color` is now redefined as `transparent` to avoid these conflicts in S2. diff --git a/.changeset/pre.json b/.changeset/pre.json new file mode 100644 index 00000000000..e73cc92543b --- /dev/null +++ b/.changeset/pre.json @@ -0,0 +1,213 @@ +{ + "mode": "pre", + "tag": "next", + "initialVersions": { + "@spectrum-tools/gh-action-file-diff": "2.1.0", + "@spectrum-css/preview": "11.0.1-next.2", + "@spectrum-css/accordion": "7.0.1", + "@spectrum-css/actionbar": "10.0.1", + "@spectrum-css/actionbutton": "7.0.1", + "@spectrum-css/actiongroup": "6.0.1", + "@spectrum-css/actionmenu": "7.0.0", + "@spectrum-css/alertbanner": "3.0.1", + "@spectrum-css/alertdialog": "4.0.1", + "@spectrum-css/asset": "7.0.1", + "@spectrum-css/assetcard": "5.0.1", + "@spectrum-css/assetlist": "8.0.1", + "@spectrum-css/avatar": "9.0.1", + "@spectrum-css/badge": "6.0.1", + "@spectrum-css/breadcrumb": "11.0.1", + "@spectrum-css/button": "14.0.1", + "@spectrum-css/buttongroup": "9.0.1", + "@spectrum-css/calendar": "7.0.1", + "@spectrum-css/card": "11.0.1", + "@spectrum-css/checkbox": "10.0.1", + "@spectrum-css/clearbutton": "7.0.1", + "@spectrum-css/closebutton": "6.0.1", + "@spectrum-css/coachindicator": "4.0.1", + "@spectrum-css/coachmark": "9.0.1", + "@spectrum-css/colorarea": "7.0.1", + "@spectrum-css/colorhandle": "10.0.1", + "@spectrum-css/colorloupe": "7.0.1", + "@spectrum-css/colorslider": "8.0.1", + "@spectrum-css/colorwheel": "6.0.1", + "@spectrum-css/combobox": "4.0.1", + "@spectrum-css/contextualhelp": "5.0.1", + "@spectrum-css/datepicker": "4.0.1", + "@spectrum-css/dial": "5.0.1", + "@spectrum-css/dialog": "12.0.1", + "@spectrum-css/divider": "5.0.1", + "@spectrum-css/dropindicator": "7.0.1", + "@spectrum-css/dropzone": "8.0.1", + "@spectrum-css/fieldgroup": "7.0.1", + "@spectrum-css/fieldlabel": "10.0.1", + "@spectrum-css/floatingactionbutton": "4.0.1", + "@spectrum-css/form": "1.0.1", + "@spectrum-css/helptext": "7.0.1", + "@spectrum-css/icon": "9.0.1", + "@spectrum-css/illustratedmessage": "9.0.1", + "@spectrum-css/infieldbutton": "6.0.1", + "@spectrum-css/inlinealert": "10.0.1", + "@spectrum-css/link": "7.0.1", + "@spectrum-css/logicbutton": "6.0.1", + "@spectrum-css/menu": "9.0.1", + "@spectrum-css/meter": "1.0.1", + "@spectrum-css/miller": "8.0.1", + "@spectrum-css/modal": "7.0.1", + "@spectrum-css/opacitycheckerboard": "4.0.1", + "@spectrum-css/page": "9.0.1", + "@spectrum-css/pagination": "10.0.1", + "@spectrum-css/picker": "9.0.1", + "@spectrum-css/pickerbutton": "6.0.1", + "@spectrum-css/popover": "8.0.1", + "@spectrum-css/progressbar": "6.0.1", + "@spectrum-css/progresscircle": "5.0.1", + "@spectrum-css/radio": "10.0.1", + "@spectrum-css/rating": "6.0.1", + "@spectrum-css/search": "8.0.1", + "@spectrum-css/sidenav": "7.0.1", + "@spectrum-css/slider": "6.0.1", + "@spectrum-css/splitview": "7.0.1", + "@spectrum-css/statuslight": "9.0.1", + "@spectrum-css/steplist": "7.0.1", + "@spectrum-css/stepper": "7.0.1", + "@spectrum-css/swatch": "8.0.1", + "@spectrum-css/swatchgroup": "5.0.1", + "@spectrum-css/switch": "6.0.1", + "@spectrum-css/table": "8.0.1", + "@spectrum-css/tabs": "6.0.1", + "@spectrum-css/tag": "10.0.1", + "@spectrum-css/taggroup": "7.0.1", + "@spectrum-css/textfield": "8.0.1", + "@spectrum-css/thumbnail": "8.0.1", + "@spectrum-css/toast": "11.0.1", + "@spectrum-css/tooltip": "7.0.1", + "@spectrum-css/tray": "5.0.1", + "@spectrum-css/treeview": "12.0.1", + "@spectrum-css/typography": "8.0.1", + "@spectrum-css/underlay": "6.0.1", + "@spectrum-css/well": "7.0.1", + "@spectrum-tools/postcss-rgb-mapping": "1.0.0", + "@spectrum-tools/stylelint-no-missing-var": "2.0.1", + "@spectrum-tools/stylelint-no-unknown-custom-properties": "2.0.2", + "@spectrum-tools/stylelint-no-unused-custom-properties": "2.0.3", + "@spectrum-css/tokens": "16.0.0", + "@spectrum-css/bundle": "1.0.0", + "@spectrum-css/generator": "4.1.0", + "@spectrum-css/ui-icons": "1.1.2", + "@spectrum-css/infieldprogresscircle": "0.0.0", + "@spectrum-tools/changesets-changelog-github": "0.0.0" + }, + "changesets": [ + "angry-needles-behave", + "beige-dragons-tickle", + "big-beds-care", + "big-glasses-check", + "big-jars-pump", + "brave-bikes-teach", + "breezy-impalas-push", + "calm-hats-sleep", + "chatty-lands-attack", + "chilled-peaches-enjoy", + "chilly-peaches-sniff", + "chubby-mirrors-wish", + "clean-oranges-smell", + "cool-wolves-like", + "cute-pillows-stand", + "cute-windows-unite", + "deep-sloths-fetch", + "dirty-melons-look", + "early-ends-fail", + "eighty-terms-lead", + "fair-coins-buy", + "few-candles-sniff", + "few-tigers-say", + "flat-snails-admire", + "fluffy-hands-appear", + "four-lemons-warn", + "fresh-crabs-deliver", + "fresh-kings-slide", + "fresh-seahorses-join", + "fresh-spoons-try", + "friendly-dolls-raise", + "giant-windows-smoke", + "gold-cats-hide", + "good-times-dress", + "green-falcons-rush", + "grumpy-ghosts-serve", + "healthy-chicken-clap", + "hip-shoes-listen", + "honest-animals-stop", + "hot-books-fail", + "itchy-kids-travel", + "itchy-shrimps-help", + "itchy-waves-work", + "khaki-icons-hammer", + "kind-cycles-check", + "late-worms-reply", + "legal-lands-warn", + "lemon-flowers-poke", + "lemon-weeks-work", + "light-years-speak", + "long-carrots-sleep", + "lovely-geckos-hammer", + "mean-eggs-learn", + "metal-fireants-switch", + "mighty-pigs-accept", + "modern-chairs-sit", + "modern-times-happen", + "nasty-rats-rhyme", + "neat-schools-take", + "nice-cows-shout", + "nine-kings-repair", + "old-goats-chew", + "olive-tools-hang", + "open-squids-refuse", + "petite-toys-greet", + "polite-apes-think", + "polite-moments-stay", + "proud-jokes-rule", + "proud-schools-reply", + "public-facts-boil", + "puny-kids-rhyme", + "ready-apes-pull", + "real-jobs-flow", + "red-kiwis-flash", + "ripe-symbols-wear", + "ripe-toys-invent", + "rotten-meals-share", + "serious-cameras-hammer", + "serious-clouds-jam", + "shaggy-schools-sing", + "shiny-taxis-tease", + "shy-actors-behave", + "six-donuts-march", + "slow-eyes-lay", + "small-berries-dream", + "small-impalas-search", + "smart-spoons-sneeze", + "sour-donuts-go", + "spicy-rings-cough", + "spotty-bats-deny", + "spotty-onions-study", + "stale-pans-carry", + "strange-glasses-allow", + "strong-pianos-work", + "stupid-lemons-battle", + "sweet-badgers-melt", + "sweet-brooms-fetch", + "tame-bobcats-beam", + "tame-knives-train", + "tasty-eagles-draw", + "tasty-planes-design", + "thick-ears-win", + "tiny-candles-win", + "tiny-taxis-show", + "true-shrimps-dream", + "twenty-ravens-divide", + "twenty-tables-know", + "upset-roses-live", + "warm-loops-guess", + "wild-lemons-spend" + ] +} diff --git a/.changeset/proud-jokes-rule.md b/.changeset/proud-jokes-rule.md new file mode 100644 index 00000000000..5749fd0607a --- /dev/null +++ b/.changeset/proud-jokes-rule.md @@ -0,0 +1,7 @@ +--- +"@spectrum-css/progressbar": major +--- + +#### Spectrum 2 migration + +Progress bar now uses Spectrum 2 tokens and specifications. This migration includes updated colors, font sizes, and spacing. diff --git a/.changeset/proud-schools-reply.md b/.changeset/proud-schools-reply.md new file mode 100644 index 00000000000..16b591f48b3 --- /dev/null +++ b/.changeset/proud-schools-reply.md @@ -0,0 +1,32 @@ +--- +"@spectrum-css/swatchgroup": major +"@spectrum-css/swatch": major +"@spectrum-css/tokens": minor +--- + +#### S2 migration for Swatch group + +This migrates the `swatch` and `swatchgroup` components to the latest Spectrum 2 designs. Custom properties have been remapped and added per the design specification. + +An `Add Swatch` variant has been added with the required color tokens and the specified add UI icon. + +The `Add Swatch` and `Mixed Value` variants may not be combined with background colors or images. To implement the `Add Swatch` you need to apply the `is-addSwatch` class to the `spectrum-Swatch` element. `Add swatch` keyboard focus may be applied by adding the `is-keyboardFocused` class to this combination of classes. + +The `spectrum-Swatch-icon` is used to set the expected color to icons contained within the swatch. + +The light and no border variants have been removed. Individual swatches have a border set to `--spectrum-gray-1000` at `42%` opacity, while the border opacity is set to `20%` in swatch groups. + +##### Removed custom properties + +`--spectrum-swatch-border-color` +`--spectrum-swatch-dash-icon-color` (replaced by `--spectrum-swatch-icon-color`) + +##### New custom properties + +`--spectrum-swatch-border-color-rgb` +`--spectrum-swatch-border-opacity` +`--spectrum-corner-radius-full` +`--spectrum-corner-radius-none` +`--spectrum-swatch-disabled-icon-border-opacity` +`--spectrum-swatch-icon-color` +`--spectrum-swatch-rectangle-width-multiplier` diff --git a/.changeset/public-facts-boil.md b/.changeset/public-facts-boil.md new file mode 100644 index 00000000000..a56c5aa601e --- /dev/null +++ b/.changeset/public-facts-boil.md @@ -0,0 +1,14 @@ +--- +"@spectrum-css/taggroup": major +--- + +### Spectrum 2 Tag Group migration + +The Spectrum 2 version of Tag Group is a major change from its Spectrum 1 counterpart. + +Major style changes include: + +- 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. diff --git a/.changeset/puny-kids-rhyme.md b/.changeset/puny-kids-rhyme.md new file mode 100644 index 00000000000..92b42d35e33 --- /dev/null +++ b/.changeset/puny-kids-rhyme.md @@ -0,0 +1,76 @@ +--- +"@spectrum-css/tokens": minor +--- + +Package update from `@adobe/spectrum-tokens@13.0.0-beta.58` to `@adobe/spectrum-tokens@13.3.0`. + +#### New custom properties + +- `--spectrum-card-background-loading-color` +- `--spectrum-card-background-well-color` +- `--spectrum-card-default-width-extra-small` +- `--spectrum-card-default-width-small` +- `--spectrum-card-default-width-medium` +- `--spectrum-card-default-width-large` +- `--spectrum-card-default-width-extra-large` +- `--spectrum-card-description-to-footer` +- `--spectrum-card-edge-to-content-default-extra-small` +- `--spectrum-card-edge-to-content-default-small` +- `--spectrum-card-edge-to-content-default-medium` +- `--spectrum-card-edge-to-content-default-large` +- `--spectrum-card-edge-to-content-default-extra-large` +- `--spectrum-card-edge-to-content-compact-extra-small` +- `--spectrum-card-edge-to-content-compact-small` +- `--spectrum-card-edge-to-content-compact-medium` +- `--spectrum-card-edge-to-content-compact-large` +- `--spectrum-card-edge-to-content-compact-extra-large` +- `--spectrum-card-edge-to-content-spacious-extra-small` +- `--spectrum-card-edge-to-content-spacious-small` +- `--spectrum-card-edge-to-content-spacious-medium` +- `--spectrum-card-edge-to-content-spacious-large` +- `--spectrum-card-edge-to-content-spacious-extra-large` +- `--spectrum-card-header-to-description` +- `--spectrum-card-minimum-width-extra-small` +- `--spectrum-card-minimum-width-small` +- `--spectrum-card-minimum-width-medium` +- `--spectrum-card-minimum-width-large` +- `--spectrum-card-minimum-width-extra-large` +- `--spectrum-card-maximum-width-extra-small` +- `--spectrum-card-maximum-width-small` +- `--spectrum-card-maximum-width-medium` +- `--spectrum-card-maximum-width-large` +- `--spectrum-card-maximum-width-extra-large` +- `--spectrum-card-minimum-height-extra-small` +- `--spectrum-card-minimum-height-small` +- `--spectrum-card-minimum-height-medium` +- `--spectrum-card-minimum-height-large` +- `--spectrum-card-minimum-height-extra-large` +- `--spectrum-card-selection-background-size-small` +- `--spectrum-card-selection-background-size-medium` +- `--spectrum-card-selection-background-size-large` +- `--spectrum-card-selection-background-size-extra-large` +- `--spectrum-collection-card-minimum-height-extra-small` +- `--spectrum-collection-card-minimum-height-small` +- `--spectrum-collection-card-minimum-height-medium` +- `--spectrum-collection-card-minimum-height-large` +- `--spectrum-collection-card-minimum-height-extra-large` +- `--spectrum-collection-card-minimum-height-hero-extra-small` +- `--spectrum-collection-card-minimum-height-hero-small` +- `--spectrum-collection-card-minimum-height-hero-medium` +- `--spectrum-collection-card-minimum-height-hero-large` +- `--spectrum-collection-card-minimum-height-hero-extra-large` +- `--spectrum-segmented-control-item-maximum-width` +- `--spectrum-user-card-minimum-height-small` +- `--spectrum-user-card-minimum-height-medium` +- `--spectrum-user-card-minimum-height-large` +- `--spectrum-user-card-minimum-height-extra-large` +- `--spectrum-user-card-minimum-height-title-below-small` +- `--spectrum-user-card-minimum-height-title-below-medium` +- `--spectrum-user-card-minimum-height-title-below-large` +- `--spectrum-user-card-minimum-height-title-below-extra-large` + +#### Updated custom properties + +- `--spectrum-card-selection-background-color` was mapped to `var(--spectrum-gray-100)`; updated to: + - light: `var(--spectrum-transparent-white-600)` + - dark: `var(--spectrum-transparent-black-600)` diff --git a/.changeset/ready-apes-pull.md b/.changeset/ready-apes-pull.md new file mode 100644 index 00000000000..73b00003a8a --- /dev/null +++ b/.changeset/ready-apes-pull.md @@ -0,0 +1,33 @@ +--- +"@spectrum-css/coachindicator": patch +"@spectrum-css/alertbanner": patch +"@spectrum-css/colorhandle": patch +"@spectrum-css/colorslider": patch +"@spectrum-css/inlinealert": patch +"@spectrum-css/breadcrumb": patch +"@spectrum-css/colorwheel": patch +"@spectrum-css/datepicker": patch +"@spectrum-css/assetcard": patch +"@spectrum-css/thumbnail": patch +"@spectrum-css/calendar": patch +"@spectrum-css/combobox": patch +"@spectrum-css/dropzone": patch +"@spectrum-css/treeview": patch +"@spectrum-css/underlay": patch +"@spectrum-css/sidenav": patch +"@spectrum-css/stepper": patch +"@spectrum-css/card": patch +"@spectrum-css/dial": patch +"@spectrum-css/page": patch +"@spectrum-css/well": patch +--- + +## Minor linting fixes + +- Removed unused custom properties across multiple components +- Fixed color function notation by converting `rgba()` to `rgb()` where appropriate +- Removed duplicate custom property declarations +- Fixed deprecated CSS properties (e.g., `word-wrap` → `overflow-wrap`) +- Removed unnecessary stylelint-disable comments + +_No visual or functional changes to components._ diff --git a/.changeset/real-jobs-flow.md b/.changeset/real-jobs-flow.md new file mode 100644 index 00000000000..92fc22e8684 --- /dev/null +++ b/.changeset/real-jobs-flow.md @@ -0,0 +1,17 @@ +--- +"@spectrum-css/table": minor +--- + +### S2 table migration (continued) + +#### Net-new features + +- New sparkline SVGs available for cell content + +#### Description of other S2 table work + +A new `.spectrum-Table-headCell--alignEnd` class was created to correspond to tables that may have end-aligned numerical data so the head cell follows the text alignment correctly. + +Semantically, if a table should enable column sorting, the content of a column's head cell should actually be a button, since it is triggering an action. If the column header cell could trigger a menu, the content of that cell should also be a button. New markup has been included to improve the semantic design of the content of header cells, utilizing button components to signify an action can be triggered, or a menu can be triggered. + +In Storybook, new stories have been added to the docs page and the testing grid for Chromatic. These stories include `WithMenuButton`, `WithChartContent`. Documentation has been added for each of these stories, as well as expanded in other stories. diff --git a/.changeset/red-kiwis-flash.md b/.changeset/red-kiwis-flash.md new file mode 100644 index 00000000000..29721dd6f84 --- /dev/null +++ b/.changeset/red-kiwis-flash.md @@ -0,0 +1,13 @@ +--- +"@spectrum-css/toast": major +--- + +### Spectrum 2 toast migration + +This migrates the `toast` component to S2. Custom properties have been remapped per the design specification. The toast no longer supports a divider. + +#### Tokens + +| Before | After | +| ---------------------------- | ---------------------------- | +| --spectrum-corner-radius-100 | --spectrum-corner-radius-800 | diff --git a/.changeset/ripe-symbols-wear.md b/.changeset/ripe-symbols-wear.md new file mode 100644 index 00000000000..ec8119cbde2 --- /dev/null +++ b/.changeset/ripe-symbols-wear.md @@ -0,0 +1,5 @@ +--- +"@spectrum-css/popover": patch +--- + +Defines the missing `--spectrum-popover-border-width` custom property. The variable was already being used in our style definitions, but its value was lost at some point so it was undefined in the browser. This work should correct that. diff --git a/.changeset/ripe-toys-invent.md b/.changeset/ripe-toys-invent.md new file mode 100644 index 00000000000..5bf3e004a2b --- /dev/null +++ b/.changeset/ripe-toys-invent.md @@ -0,0 +1,5 @@ +--- +"@spectrum-css/tokens": minor +--- + +Adds custom tokens for Tabs in Spectrum 2. This is intended to be a temporary change until the tokens have been added to the spectrum-tokens package. diff --git a/.changeset/rotten-meals-share.md b/.changeset/rotten-meals-share.md new file mode 100644 index 00000000000..ab1c7b55838 --- /dev/null +++ b/.changeset/rotten-meals-share.md @@ -0,0 +1,7 @@ +--- +"@spectrum-css/popover": major +--- + +### Spectrum 2 Popover migration + +The Spectrum 2 popover using new tokens for border color, padding, corner radius and elevation/drop shadows. diff --git a/.changeset/serious-cameras-hammer.md b/.changeset/serious-cameras-hammer.md new file mode 100644 index 00000000000..95e2206d994 --- /dev/null +++ b/.changeset/serious-cameras-hammer.md @@ -0,0 +1,20 @@ +--- +"@spectrum-css/badge": major +--- + +This migrates the base Badge component to S2 designs, but does not include the "Notification" or "Highlight" types. + +- New semantic color: "notice" +- Updated/expanded non-semantic colors + - **New colors**: + - pink + - turquoise + - brown + - cinnamon + - silver +- New "styles" to be used alongside a color choice, such as `spectrum-Badge--accent spectrum-Badge--style-subtle` + - subtle (lighter version of bg color) + - outline (border color, only semantic colors) +- Updated border-radius per size +- Updated border-width + - updated related padding/margin definitions to account for border-width diff --git a/.changeset/serious-clouds-jam.md b/.changeset/serious-clouds-jam.md new file mode 100644 index 00000000000..27a3928b0f8 --- /dev/null +++ b/.changeset/serious-clouds-jam.md @@ -0,0 +1,11 @@ +--- +"@spectrum-css/colorslider": minor +--- + +#### S2 colorslider migration + +This migrates the `colorslider` component to S2. Custom properties have been remapped per the design spec. + +| Before | After | +| ------------------------- | -------------------------- | +| `--spectrum-gray-900-rgb` | `--spectrum-gray-1000-rgb` | diff --git a/.changeset/shaggy-schools-sing.md b/.changeset/shaggy-schools-sing.md new file mode 100644 index 00000000000..613b88d9b8a --- /dev/null +++ b/.changeset/shaggy-schools-sing.md @@ -0,0 +1,10 @@ +--- +"@spectrum-css/search": major +--- + +### Spectrum 2 search migration + +Search now uses Spectrum 2 tokens and specifications. The following items have been adjusted: + +- Quiet variant has been deprecated and code removed. +- Updates to colors, corner rounding, and spacing. diff --git a/.changeset/shiny-taxis-tease.md b/.changeset/shiny-taxis-tease.md new file mode 100644 index 00000000000..3f4ebdeed89 --- /dev/null +++ b/.changeset/shiny-taxis-tease.md @@ -0,0 +1,26 @@ +--- +"@spectrum-css/actionbutton": major +"@spectrum-css/colorslider": major +"@spectrum-css/progressbar": major +"@spectrum-css/breadcrumb": major +"@spectrum-css/colorloupe": major +"@spectrum-css/colorwheel": major +"@spectrum-css/pagination": major +"@spectrum-css/accordion": major +"@spectrum-css/assetlist": major +"@spectrum-css/colorarea": major +"@spectrum-css/calendar": major +"@spectrum-css/combobox": major +"@spectrum-css/steplist": major +"@spectrum-css/treeview": major +"@spectrum-css/popover": major +"@spectrum-css/tooltip": major +"@spectrum-css/slider": major +"@spectrum-css/switch": major +"@spectrum-css/radio": major +"@spectrum-css/table": major +"@spectrum-css/menu": major +"@spectrum-css/tabs": major +--- + +This update removes the `dir` attribute polyfill (served via a PostCSS transform to compiled assets) as the fallback is no longer necessary. The`dir` attribute support is available in all supported browsers and has been tested to correctly inherit inside web component shadow DOMs. This is a breaking change **only** to those relying on the `dir` attribute being present for styling, however, the `:dir` pseudo will correctly inherit values from their containers. To correctly determine the `dir` value of a node using JavaScript, you can use `getComputedStyle(node).direction`. diff --git a/.changeset/shy-actors-behave.md b/.changeset/shy-actors-behave.md new file mode 100644 index 00000000000..d1dd3eaf94a --- /dev/null +++ b/.changeset/shy-actors-behave.md @@ -0,0 +1,48 @@ +--- +"@spectrum-css/slider": major +--- + +#### New features + +- Emphasized track fill color +- Precision control handle +- Large and thin track heights +- Embedded editable text field component + +#### Visual changes + +- No longer a gap between slider handle and the track +- Updated dimensions of slider handles for each size variant +- Updated WHCM for all variants + +#### New tokens + +`--spectrum-slider-control-to-field-label-editable-extra-large` +`--spectrum-slider-control-to-field-label-editable-large` +`--spectrum-slider-control-to-field-label-editable-medium` +`--spectrum-slider-control-to-field-label-editable-small` +`--spectrum-slider-control-to-side-field-label-extra-large` +`--spectrum-slider-control-to-side-field-label-large` +`--spectrum-slider-control-to-side-field-label-medium` +`--spectrum-slider-control-to-side-field-label-small` +`--spectrum-slider-control-to-text-field-extra-large` +`--spectrum-slider-control-to-text-field-large` +`--spectrum-slider-control-to-text-field-medium` +`--spectrum-slider-control-to-text-field-small` +`--spectrum-slider-editable-control-to-field-label` +`--spectrum-slider-editable-control-to-text-field` +`--spectrum-slider-editable-field-inline-size-extra-large` +`--spectrum-slider-editable-field-inline-size-large` +`--spectrum-slider-editable-field-inline-size-medium` +`--spectrum-slider-editable-field-inline-size-small` +`--spectrum-slider-emphasized-track-fill-color` +`--spectrum-slider-precision-handle-height` +`--spectrum-slider-precision-handle-height-extra-large` +`--spectrum-slider-precision-handle-height-large` +`--spectrum-slider-precision-handle-height-medium` +`--spectrum-slider-precision-handle-height-small` +`--spectrum-slider-precision-handle-width` +`--spectrum-slider-handle-extra-large` +`--spectrum-slider-handle-large` +`--spectrum-slider-handle-medium` +`--spectrum-slider-handle-small` diff --git a/.changeset/six-donuts-march.md b/.changeset/six-donuts-march.md new file mode 100644 index 00000000000..40a42da4456 --- /dev/null +++ b/.changeset/six-donuts-march.md @@ -0,0 +1,34 @@ +--- +"@spectrum-css/checkbox": major +--- + +### Spectrum 2 checkbox migration + +Checkbox's control and color tokens have been updated by the latest S2 tokens: + +#### Updates + +- Checkbox has a background color token: `--spectrum-checkbox-background-color` +- New typography additions: line-height, font-weight, and font style +- `spectrum-Checkbox--sizeM` is now the default style settings of the component. +- Removed interactive state selectors in `--emphasized` variant that was overriding other variants +- Refactored WHCM settings for read-only and disabled states + +#### New tokens + +`--spectrum-component-size-width-ratio-down` +`--spectrum-checkbox-bottom-to-text` +`--spectrum-checkbox-top-to-control` +`--spectrum-accent-content-color-default` +`--spectrum-accent-content-color-hover` +`--spectrum-accent-content-color-down` +`--spectrum-accent-content-color-key-focus` + +#### Updated tokens + +`--spectrum-checkbox-checkmark-color` +`--spectrum-checkbox-invalid-color-down` +`--spectrum-checkbox-control-color-default` +`--spectrum-checkbox-control-color-hover` +`--spectrum-checkbox-control-color-down` +`--spectrum-checkbox-control-color-focus` diff --git a/.changeset/slow-eyes-lay.md b/.changeset/slow-eyes-lay.md new file mode 100644 index 00000000000..c34dcfb1eb1 --- /dev/null +++ b/.changeset/slow-eyes-lay.md @@ -0,0 +1,20 @@ +--- +"@spectrum-css/divider": major +--- + +### Spectrum 2 divider migration + +This migrates the `divider` component to S2. Custom properties have been remapped and updated per the design spec. + +#### New properties + +```css +--spectrum-divider-horizontal-minimum-width +--spectrum-divider-vertical-minimum-height +``` + +#### Additions + +This adds new minimum width and height tokens for the divider and the `minDimensionValues` arg has been removed in favor of these tokens and the rules with which they're applied. + +The default size for the Storybook control has been changed to `medium` (the new default size for the component). All sizes are now displayed for the static color variants in the docs. diff --git a/.changeset/small-berries-dream.md b/.changeset/small-berries-dream.md new file mode 100644 index 00000000000..c255c3941c5 --- /dev/null +++ b/.changeset/small-berries-dream.md @@ -0,0 +1,16 @@ +--- +"@spectrum-css/menu": minor +--- + +This handles a few remaining items from the initial S2 migration: + +- update to use the correct "LinkOut" icon (previously unavailable) +- add "Unavailable" icon + - the functionality in WC will be to open an explanatory popover + +Additionally, per design review, updates were made regarding valid feature combos: + +- **Not allowed:** + - external links with: thumbnails, drill-in, unavailable, or selection modes + - thumbnails with: drill-in, external links + - new "unavailable" with: selection modes, external links diff --git a/.changeset/small-impalas-search.md b/.changeset/small-impalas-search.md new file mode 100644 index 00000000000..53317c408e0 --- /dev/null +++ b/.changeset/small-impalas-search.md @@ -0,0 +1,10 @@ +--- +"@spectrum-css/statuslight": patch +--- + +Removes references to the accent variant, since the accent status light was deprecated in S2. + +Removed variant: + +`.spectrum-StatusLight--accent` +`--spectrum-statuslight-semantic-accent-color` diff --git a/.changeset/smart-spoons-sneeze.md b/.changeset/smart-spoons-sneeze.md new file mode 100644 index 00000000000..0f5c77fc207 --- /dev/null +++ b/.changeset/smart-spoons-sneeze.md @@ -0,0 +1,15 @@ +--- +"@spectrum-css/button": patch +--- + +### S2 button fixes + +This work addresses some regressions noticed in the migrated S2 button. Mainly, the borders were gray where they were not supposed to be. Most of the changes are to ensure that the correct S2 tokens are being used appropriately in the styles and button follows the S2 design specs. + +Additionally, there was some missing style support for the `.spectrum-Button--noWrap` option, so this work reimplements a "no wrapping" option for button components, and removes some of the repetitiveness in the no wrap test cases and story. + +PRs used as reference: + +- [S2 button migration](https://github.com/adobe/spectrum-css/pull/2600) +- [Add text wrapping option](https://github.com/adobe/spectrum-css/pull/3086) +- [PostCSS plugin updates/fixes](https://github.com/adobe/spectrum-css/pull/3502) diff --git a/.changeset/sour-donuts-go.md b/.changeset/sour-donuts-go.md new file mode 100644 index 00000000000..74e3344e91c --- /dev/null +++ b/.changeset/sour-donuts-go.md @@ -0,0 +1,16 @@ +--- +"@spectrum-css/meter": major +"@spectrum-css/progressbar": major +--- + +### S2 meter migration with base progress bar updates + +This migration updates the meter component and the progress bar component. Both needed the track to have a full corner radius to make the rounded look. The progress bar's HTML template now includes the help text component but it is only used in the meter. Also includes a bug fix for progress bar in order to better support the side label variant. + +#### New updates + +- Includes `--sizeM` and `--sizeXL` (using progress bar's sizes) +- Includes help text component for more context +- Shares progress bar's field label typography +- Added help text visual test +- Added static black variant diff --git a/.changeset/spicy-rings-cough.md b/.changeset/spicy-rings-cough.md new file mode 100644 index 00000000000..ccc57e330ff --- /dev/null +++ b/.changeset/spicy-rings-cough.md @@ -0,0 +1,5 @@ +--- +"@spectrum-css/accordion": minor +--- + +Accordion now supports direct actions. Direct actions, which may consist of a quiet action button or a switch, or both, may be added to each accordion item's heading. Direct action items are vertically centered within the heading's first line of text for all sizes and densities, and maintain their own individual key focus states. diff --git a/.changeset/spotty-bats-deny.md b/.changeset/spotty-bats-deny.md new file mode 100644 index 00000000000..777416c1c4d --- /dev/null +++ b/.changeset/spotty-bats-deny.md @@ -0,0 +1,28 @@ +--- +"@spectrum-css/card": major +--- + +Previously: + +```css +.spectrum-Card.is-selected::before { + background-color: rgba( + var(--spectrum-card-selected-background-color-rgb), + var(--spectrum-card-selected-background-opacity) + ); +} +``` + +Styles now use `--spectrum-card-selection-background-color` which maps to a transparent global property of `--spectrum-transparent-(black|white)-600` depending on color context. + +Updated: + +```css +.spectrum-Card.is-selected::before { + background-color: var(--spectrum-card-selection-background-color); +} +``` + +#### Removed variants + +Removed the quiet variant which is no longer supported in Spectrum 2. diff --git a/.changeset/spotty-onions-study.md b/.changeset/spotty-onions-study.md new file mode 100644 index 00000000000..748417e1c22 --- /dev/null +++ b/.changeset/spotty-onions-study.md @@ -0,0 +1,7 @@ +--- +"@spectrum-css/colorarea": major +--- + +#### Spectrum 2 migration + +This change migrates the `colorarea` component to S2. It leverages updated tokens and the `rgba(...)` color function, replacing the existing `TODO` and hardcoded values. diff --git a/.changeset/stale-pans-carry.md b/.changeset/stale-pans-carry.md new file mode 100644 index 00000000000..cc5f5eacb16 --- /dev/null +++ b/.changeset/stale-pans-carry.md @@ -0,0 +1,7 @@ +--- +"@spectrum-css/tooltip": minor +--- + +#### S2: restore negative and informative semantic variants + +This restores the negative and informative tooltip semantic variant styles, story controls and test cases. Icons have been removed for all variants as they are not present in the specifications provided by design. diff --git a/.changeset/strange-glasses-allow.md b/.changeset/strange-glasses-allow.md new file mode 100644 index 00000000000..3d89c6a85a4 --- /dev/null +++ b/.changeset/strange-glasses-allow.md @@ -0,0 +1,7 @@ +--- +"@spectrum-css/colorloupe": major +--- + +#### Spectrum 2 migration + +Migrates color loupe to Spectrum 2 tokens. Color loupe now uses the new drop shadow tokens `--spectrum-drop-shadow-elevated-x`, `--spectrum-drop-shadow-elevated-y`, `--spectrum-drop-shadow-elevated-blur`, and `--spectrum-drop-shadow-elevated-color` rather than specific color loupe tokens. diff --git a/.changeset/strong-pianos-work.md b/.changeset/strong-pianos-work.md new file mode 100644 index 00000000000..13db65ae7ab --- /dev/null +++ b/.changeset/strong-pianos-work.md @@ -0,0 +1,15 @@ +--- +"@spectrum-css/menu": major +--- + +### Spectrum 2 migration + +Menu now uses Spectrum 2 tokens and specifications. + +Removes custom menu item background color tokens: `@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. + +In addition to other small token and minor style changes, there were several new features that were added to this version of menu, including: + +- A thumbnail can now be used in place of an icon +- A section description can now be included below the menu section heading +- The actions area previously held action switches for multi-select, and in this version, an external link action icon can be included in that area diff --git a/.changeset/stupid-lemons-battle.md b/.changeset/stupid-lemons-battle.md new file mode 100644 index 00000000000..0173b1791a4 --- /dev/null +++ b/.changeset/stupid-lemons-battle.md @@ -0,0 +1,89 @@ +--- +"@spectrum-css/tokens": minor +--- + +### @adobe/spectrum-tokens@13.7.0 + +#### Minor Changes + +[#499 0c1a81b](https://github.com/adobe/spectrum-css/pull/499) Thanks [@larz0](https://github.com/larz0)! + +Added new accodion tokens + +
Added (19)
+ +- `accordion-edge-to-content-area-small` +- `accordion-edge-to-content-area-medium` +- `accordion-edge-to-content-area-large` +- `accordion-edge-to-content-area-extra-large` +- `single-calendar-popover-minimum-width` +- `single-calendar-popover-minimum-height` +- `double-calendar-popover-minimum-width` +- `double-calendar-popover-minimum-height` +- `triple-calendar-popover-minimum-width` +- `triple-calendar-popover-minimum-height` +- `date-field-minimum-width` +- `date-field-text-to-visual` +- `time-field-minimum-width` +- `time-field-text-to-visual` +- `date-picker-visual-to-field-button` +- `date-picker-text-to-visual` +- `date-picker-minimum-width` +- `segmented-text-field-gap` +- `segmented-text-field-rounding` + +
+ +### @adobe/spectrum-tokens@13.6.0 + +#### Minor Changes + +[#497 fc0682e](https://github.com/adobe/spectrum-css/pull/497) Thanks [@larz0](https://github.com/larz0)! + +Added horizontal card tokens. + +
Added (3) + +- `card-horizontal-edge-to-content-compact` +- `card-horizontal-edge-to-content-default` +- `card-horizontal-edge-to-content-spacious` + +
+ +### @adobe/spectrum-tokens@13.5.0 + +#### Minor Changes + +[#494 f569623](https://github.com/adobe/spectrum-css/pull/494) Thanks [@larz0](https://github.com/larz0)! + +Added vf-related-line-height tokens for desktop and mobile. These tokens are required for the upcoming composite typography tokens. + +
+Newly Deprecated (1) + +- `drop-zone-content-maximum-width` + +
+
+Added (18) + +- `line-height-font-size-25` +- `line-height-font-size-50` +- `line-height-font-size-75` +- `line-height-font-size-100` +- `line-height-font-size-200` +- `line-height-font-size-300` +- `line-height-font-size-400` +- `line-height-font-size-500` +- `line-height-font-size-600` +- `line-height-font-size-700` +- `line-height-font-size-800` +- `line-height-font-size-900` +- `line-height-font-size-1000` +- `line-height-font-size-1100` +- `line-height-font-size-1200` +- `line-height-font-size-1300` +- `line-height-font-size-1400` +- `line-height-font-size-1500` + +
diff --git a/.changeset/sweet-badgers-melt.md b/.changeset/sweet-badgers-melt.md new file mode 100644 index 00000000000..a18c7223087 --- /dev/null +++ b/.changeset/sweet-badgers-melt.md @@ -0,0 +1,14 @@ +--- +"@spectrum-css/accordion": minor +--- + +Changes values of `--spectrum-accordion-item-minimum-height` to align more closely with design spec, this affects the minimum height of accordion items for some combinations of size/density by giving them more space. + +New accordion minimum heights will use the heights/tokens: + +| Size | Compact | Regular | Spacious | +| ---- | --------------------------- | --------------------------- | --------------------------- | +| S | 24px/`component-height-75` | 32px/`component-height-100` | 40px/`component-height-200` | +| M | 32px/`component-height-100` | 40px/`component-height-200` | 48px/`component-height-300` | +| L | 40px/`component-height-200` | 48px/`component-height-300` | 56px/`component-height-400` | +| XL | 48px/`component-height-300` | 56px/`component-height-400` | 64px/`component-height-500` | diff --git a/.changeset/sweet-brooms-fetch.md b/.changeset/sweet-brooms-fetch.md new file mode 100644 index 00000000000..23d212be9a5 --- /dev/null +++ b/.changeset/sweet-brooms-fetch.md @@ -0,0 +1,417 @@ +--- +"@spectrum-css/tokens": minor +--- + +### Tokens changed + +

Updated from @adobe/spectrum-tokens@13.7.0 to @adobe/spectrum-tokens@13.10.0.

+ +

This update introduces new tokens for accordion, field disclosure icons, icon sizes (add, drag handle, gripper, link out), and tag field dimensions, along with stack item and list view global properties.

+ +

Note that deprecated tokens are still available but will be removed in a future release. Please migrate to new tokens as appropriate.

+ +
+ Newly deprecated + +
+ +
+ Added + +
+ +
+ Updated + +
diff --git a/.changeset/tame-bobcats-beam.md b/.changeset/tame-bobcats-beam.md new file mode 100644 index 00000000000..9a40593d401 --- /dev/null +++ b/.changeset/tame-bobcats-beam.md @@ -0,0 +1,7 @@ +--- +"@spectrum-css/alertbanner": major +--- + +### Spectrum 2 alert banner migration + +Alert banner now uses Spectrum 2 tokens and specifications. In this new design, the divider has been removed. diff --git a/.changeset/tame-knives-train.md b/.changeset/tame-knives-train.md new file mode 100644 index 00000000000..2c774a96d25 --- /dev/null +++ b/.changeset/tame-knives-train.md @@ -0,0 +1,5 @@ +--- +"@spectrum-css/icon": major +--- + +Updates the icon component to use the new Spectrum 2 icon sets. The `.spectrum-UIIcon--medium` and `.spectrum-UIIcon--large` classes have been removed, as UI icons are now delivered with a single SVG. The color property also now makes use of the `--iconPrimary` custom property that is defined in some of the SVG files. Storybook has been updated to use and load the new SVGs, whose name format and directories have changed. diff --git a/.changeset/tasty-eagles-draw.md b/.changeset/tasty-eagles-draw.md new file mode 100644 index 00000000000..e6f282261c0 --- /dev/null +++ b/.changeset/tasty-eagles-draw.md @@ -0,0 +1,28 @@ +--- +"@spectrum-css/link": major +--- + +### Spectrum 2 link migration + +The link component is updated with S2 specifications, colors, and typography. There is a new inline variant which uses the `.spectrum-Link--inline` class and the default is the standalone variant. + +#### Note + +- Quiet styling does not apply to the inline variant so that it is distinguishable from the surrounding text and the underline indicator is clear + +#### Color + +`spectrum-link-focus-indicator-color` +`spectrum-link-focus-indicator-thickness` +`spectrum-link-focus-indicator-gap` +`spectrum-link-corner-radius` + +#### Typography + +`spectrum-link-line-height` +`spectrum-link-line-height-cjk-100` +`spectrum-link-font-size` +`spectrum-link-font-style` +`spectrum-link-font-weight` +`spectrum-link-text-underline-thickness` +`spectrum-link-text-underline-gap` diff --git a/.changeset/tasty-planes-design.md b/.changeset/tasty-planes-design.md new file mode 100644 index 00000000000..e596a8dcecf --- /dev/null +++ b/.changeset/tasty-planes-design.md @@ -0,0 +1,49 @@ +--- +"@spectrum-css/tokens": minor +--- + +Updated from [@adobe/spectrum-tokens](https://github.com/adobe/spectrum-tokens) [13.14.0](https://github.com/adobe/spectrum-tokens/releases/tag/%40adobe/spectrum-tokens%4013.14.0) -> [13.15.0](https://github.com/adobe/spectrum-tokens/releases/tag/%40adobe/spectrum-tokens%4013.15.0). + +### Newly added + +| Token name | Token value | +| --------------------------------------------------- | --------------------------------------------------------------- | +| `--spectrum-static-fuchsia-400` | `rgb(247, 181, 255)` | +| `--spectrum-static-fuchsia-600` | `rgb(236, 105, 255)` | +| `--spectrum-static-fuchsia-800` | `rgb(200, 68, 220)` | +| `--spectrum-static-indigo-400` | `rgb(192, 201, 255)` | +| `--spectrum-static-indigo-600` | `rgb(145, 151, 254)` | +| `--spectrum-static-indigo-800` | `rgb(122, 106, 253)` | +| `--spectrum-static-magenta-400` | `rgb(255, 185, 208)` | +| `--spectrum-static-magenta-600` | `rgb(255, 112, 159)` | +| `--spectrum-static-magenta-800` | `rgb(240, 45, 110)` | +| `--spectrum-static-red-400` | `rgb(255, 188, 180)` | +| `--spectrum-static-red-600` | `rgb(255, 118, 101)` | +| `--spectrum-static-red-800` | `rgb(240, 56, 35)` | +| `--spectrum-static-cyan-400` | `rgb(138, 213, 255)` | +| `--spectrum-static-cyan-600` | `rgb(48, 167, 254)` | +| `--spectrum-static-cyan-800` | `rgb(18, 134, 205)` | +| `--spectrum-static-chartreuse-400` | `rgb(182, 219, 0)` | +| `--spectrum-static-chartreuse-600` | `rgb(143, 172, 0)` | +| `--spectrum-static-chartreuse-800` | `rgb(114, 137, 0)` | +| `--spectrum-static-green-400` | `rgb(107, 227, 162)` | +| `--spectrum-static-green-600` | `rgb(107, 227, 162)` | +| `--spectrum-static-green-800` | `rgb(7, 147, 85)` | +| `--spectrum-static-orange-400` | `rgb(255, 193, 94)` | +| `--spectrum-static-orange-600` | `rgb(252, 125, 0)` | +| `--spectrum-static-orange-800` | `rgb(212, 91, 0)` | +| `--spectrum-static-purple-400` | `rgb(221, 193, 246)` | +| `--spectrum-static-purple-600` | `rgb(191, 138, 238)` | +| `--spectrum-static-purple-800` | `rgb(166, 92, 231)` | +| `--spectrum-static-turquoise-400` | `rgb(111, 221, 228)` | +| `--spectrum-static-turquoise-600` | `rgb(15, 177, 192)` | +| `--spectrum-static-turquoise-800` | `rgb(10, 141, 153)` | +| `--spectrum-gradient-stop-1-avatar` | `0` | +| `--spectrum-gradient-stop-2-avatar` | `0.6666` | +| `--spectrum-gradient-stop-3-avatar` | `1` | +| `--spectrum-drop-shadow-ambient-color` | `rgba(0, 0, 0, 0.08)` (light)
`rgba(0, 0, 0, 0.24)` (dark) | +| `--spectrum-drop-shadow-transition-color` | `rgba(0, 0, 0, 0.04)` (light)
`rgba(0, 0, 0, 0.12)` (dark) | +| `--spectrum-drop-shadow-emphasized-key-color` | `rgba(0, 0, 0, 0.08)` (light)
`rgba(0, 0, 0, 0.24)` (dark) | +| `--spectrum-drop-shadow-emphasized-hover-key-color` | `rgba(0, 0, 0, 0.12)` (light)
`rgba(0, 0, 0, 0.36)` (dark) | +| `--spectrum-drop-shadow-elevated-key-color` | `rgba(0, 0, 0, 0.12)` (light)
`rgba(0, 0, 0, 0.36)` (dark) | +| `--spectrum-drop-shadow-dragged-key-color` | `rgba(0, 0, 0, 0.16)` (light)
`rgba(0, 0, 0, 0.48)` (dark) | diff --git a/.changeset/thick-ears-win.md b/.changeset/thick-ears-win.md new file mode 100644 index 00000000000..6ed63c2d287 --- /dev/null +++ b/.changeset/thick-ears-win.md @@ -0,0 +1,15 @@ +--- +"@spectrum-css/colorhandle": minor +"@spectrum-css/colorslider": minor +"@spectrum-css/colorarea": minor +"@spectrum-css/colorwheel": minor +"@spectrum-css/slider": minor +--- + +#### Including the touch action rule for draggable content + +The slider, color slider, color area, color wheel, color handle all deserve to have their touch-action property managed so that trying to set the value of those interfaces doesn't cause page scrolling in touch context. + +Adding `touch-action: none` to a slider or any draggable component is necessary to prevent the browser's default touch behaviors—such as scrolling, pinch-zooming, or double-tap zooming from interfering with the component's intended interaction. + +These components also include `user-select: none` to prevent selection or highlighting of any text elements. diff --git a/.changeset/tiny-candles-win.md b/.changeset/tiny-candles-win.md new file mode 100644 index 00000000000..dbed7db2f34 --- /dev/null +++ b/.changeset/tiny-candles-win.md @@ -0,0 +1,5 @@ +--- +"@spectrum-css/icon": minor +--- + +Updates the icon component to use size tokens for newly added ui icons. diff --git a/.changeset/tiny-taxis-show.md b/.changeset/tiny-taxis-show.md new file mode 100644 index 00000000000..d3c02ead3d6 --- /dev/null +++ b/.changeset/tiny-taxis-show.md @@ -0,0 +1,15 @@ +--- +"@spectrum-css/tokens": patch +--- + +Updated from [@adobe/spectrum-tokens](https://github.com/adobe/spectrum-tokens) v13.10.0 -> [13.10.1](https://github.com/adobe/spectrum-tokens/releases/tag/%40adobe/spectrum-tokens%4013.10.1). + +- [#517](https://github.com/adobe/spectrum-tokens/pull/517) [`8f8f8a6`](https://github.com/adobe/spectrum-tokens/commit/8f8f8a60b7adf5105ced4f914cf30928117ddc5e) Thanks [@larz0](https://github.com/larz0)! + +#### Updated tokens + +- `accordion-focus-indicator-gap` + - value: `0px` -> `2px` +- `accordion-top-to-text-medium` + - desktop.value: `12px` -> `9px` + - mobile.value: `16px` -> `10px` diff --git a/.changeset/true-shrimps-dream.md b/.changeset/true-shrimps-dream.md new file mode 100644 index 00000000000..7c08c824e00 --- /dev/null +++ b/.changeset/true-shrimps-dream.md @@ -0,0 +1,22 @@ +--- +"@spectrum-css/infieldbutton": major +--- + +### Spectrum 2 infield button migration + +In-field buttons are used to represent actions within input fields. They're currently used inside number field. This component has updated colors, corner radius, and icons compared to the Spectrum 1 version. The "Error" and "Key-focus" variants have been removed, since this now utilizes those states from the parent component. + +The position styles and controls have also been removed now that there's a consistent corner radius. + +#### New tokens + +These new tokens are the inline variant & stepper (number field) use case. The padding changes here. + +`--spectrum-in-field-button-side-edge-to-fill-small` +`--spectrum-in-field-button-side-edge-to-fill-medium` +`--spectrum-in-field-button-side-edge-to-fill-large` +`--spectrum-in-field-button-side-edge-to-fill-extra-large` +`--spectrum-field-edge-to-icon-75` +`--spectrum-field-edge-to-icon-100` +`--spectrum-field-edge-to-icon-200` +`--spectrum-field-edge-to-icon-300` diff --git a/.changeset/twenty-ravens-divide.md b/.changeset/twenty-ravens-divide.md new file mode 100644 index 00000000000..3f35fb27c18 --- /dev/null +++ b/.changeset/twenty-ravens-divide.md @@ -0,0 +1,7 @@ +--- +"@spectrum-css/coachmark": minor +--- + +CSS references to popover custom properties/tokens were updated to reflect changes in the popover ([#3365](https://github.com/adobe/spectrum-css/pull/3365)). The corner radius token was updated to correspond to the new S2 popover corner radius. + +- `--spectrum-border-width-100` was updated to `--spectrum-corner-radius-large-default` diff --git a/.changeset/twenty-tables-know.md b/.changeset/twenty-tables-know.md new file mode 100644 index 00000000000..ddb0511a1ad --- /dev/null +++ b/.changeset/twenty-tables-know.md @@ -0,0 +1,10 @@ +--- +"@spectrum-css/opacitycheckerboard": major +"@spectrum-css/thumbnail": minor +--- + +#### S2 thumbnail migration + +Adds thumbnail specific `thumbnail-opacity-checkerboard-square-size` token aliased to `--spectrum-opacity-checkerboard-size`. This impacts the display of the `opacity-checkerboard` when used within the `thumbnail` component. + +This also corrects an issue with a token name in the `thumbnail` component by renaming `--spectrum-thumbnail-border-color-opacity` to `--spectrum-thumbnail-border-opacity`. diff --git a/.changeset/upset-roses-live.md b/.changeset/upset-roses-live.md new file mode 100644 index 00000000000..6e812c7515c --- /dev/null +++ b/.changeset/upset-roses-live.md @@ -0,0 +1,90 @@ +--- +"@spectrum-css/ui-icons": minor +--- + +Makes updates to the initial S2 icons update to include some additional icons with names as follows: + +| Icon name | +| ----------------- | +| Add50 | +| Add75 | +| Add100 | +| Add200 | +| Add300 | +| DragHandle75 | +| DragHandle100 | +| DragHandle200 | +| DragHandle300 | +| Gripper100 | +| LinkOut100 | +| LinkOut200 | +| LinkOut300 | +| LinkOut400 | + +Such that the full set of changes for Spectrum 2 is as follows: + +| Icon name | Migration notes | +| ----------------- | --------------- | +| Add50 | **New** | +| Add75 | **New** | +| Add100 | **New** | +| Add200 | **New** | +| Add300 | **New** | +| Arrow75 | Deprecated | +| Arrow100 | - | +| Arrow200 | Deprecated | +| Arrow300 | Deprecated | +| Arrow400 | - | +| Arrow500 | Deprecated | +| Arrow600 | Deprecated | +| Asterisk75 | Deprecated | +| Asterisk100 | - | +| Asterisk200 | - | +| Asterisk300 | - | +| Checkmark50 | - | +| Checkmark75 | - | +| Checkmark100 | - | +| Checkmark200 | - | +| Checkmark300 | - | +| Checkmark400 | - | +| Checkmark500 | Deprecated | +| Checkmark600 | Deprecated | +| Chevron50 | - | +| Chevron75 | - | +| Chevron100 | - | +| Chevron200 | - | +| Chevron300 | - | +| Chevron400 | - | +| Chevron500 | Deprecated | +| Chevron600 | Deprecated | +| CornerTriangle75 | - | +| CornerTriangle100 | - | +| CornerTriangle200 | - | +| CornerTriangle300 | - | +| Cross75 | - | +| Cross100 | - | +| Cross200 | - | +| Cross300 | - | +| Cross400 | - | +| Cross500 | - | +| Cross600 | - | +| Dash50 | - | +| Dash75 | - | +| Dash100 | - | +| Dash200 | - | +| Dash300 | - | +| Dash400 | Deprecated | +| Dash500 | Deprecated | +| Dash600 | Deprecated | +| DragHandle75 | **New** | +| DragHandle100 | **New** | +| DragHandle200 | **New** | +| DragHandle300 | **New** | +| Gripper100 | **New** | +| SingleGripper | Deprecated | +| DoubleGripper | Deprecated | +| TripleGripper | Deprecated | +| LinkOut100 | **New** | +| LinkOut200 | **New** | +| LinkOut300 | **New** | +| LinkOut400 | **New** | diff --git a/.changeset/warm-loops-guess.md b/.changeset/warm-loops-guess.md new file mode 100644 index 00000000000..80e75cc9e1f --- /dev/null +++ b/.changeset/warm-loops-guess.md @@ -0,0 +1,12 @@ +--- +"@spectrum-css/picker": patch +--- + +### S2 picker fixes + +This work addresses some regressions noticed in the migrated S2 picker component. Mainly, S2 border colors were fixed (most of them are transparent, including disabled). + +PRs used as reference: + +- [Picker docs to storybook migration](https://github.com/adobe/spectrum-css/pull/3200) +- [S2 picker migration](https://github.com/adobe/spectrum-css/pull/2697) diff --git a/.changeset/weak-colts-divide.md b/.changeset/weak-colts-divide.md new file mode 100644 index 00000000000..ff44b2c645f --- /dev/null +++ b/.changeset/weak-colts-divide.md @@ -0,0 +1,21 @@ +--- +"@spectrum-css/alertdialog": major +"@spectrum-css/asset": major +"@spectrum-css/assetcard": major +"@spectrum-css/assetlist": major +"@spectrum-css/avatar": major +"@spectrum-css/badge": major +"@spectrum-css/miller": major +"@spectrum-css/well": major +"@spectrum-css/page": major +--- + +This update removes `--mod-*` custom property hooks per SWC-1264, see also the RFC for extensible styling. In addition, this update cleans up any component-level custom properties that did not rely on the CSS cascade to define the styles; this was done to reduce the number of custom properties that are defined at the component level and trim down the size of the CSS we are shipping to consumers. + +- Remove all `--mod-*` custom property hooks. +- Keep existing class selectors and variants unchanged. +- Update stories to reflect the removal of the `--mod-*` override layer. +- Remove any component-level custom properties that did not rely on the CSS cascade to define the styles. +- Remove any high contrast mode styles being used where the default styles are sufficient. + +Breaking change: the `--mod-*` override layer is removed. Consumers should set `--spectrum-*` variables directly where customization is needed. diff --git a/.changeset/wild-lemons-spend.md b/.changeset/wild-lemons-spend.md new file mode 100644 index 00000000000..59f5b1782cf --- /dev/null +++ b/.changeset/wild-lemons-spend.md @@ -0,0 +1,14 @@ +--- +"@spectrum-css/helptext": major +--- + +### Spectrum 2 help text migration + +The help text S2 component has some updated spacing and typography tokens. The error message validation icon has also been updated. + +#### Deprecated tokens + +`--spectrum-help-text-top-to-workflow-icon-small` +`--spectrum-help-text-top-to-workflow-icon-medium` +`--spectrum-help-text-top-to-workflow-icon-large` +`--spectrum-help-text-top-to-workflow-icon-extra-large` diff --git a/.cursor/rules/github-description.mdc b/.cursor/rules/github-description.mdc index b3de3947ee9..ed717670e5c 100644 --- a/.cursor/rules/github-description.mdc +++ b/.cursor/rules/github-description.mdc @@ -1,3 +1,224 @@ +--- +description: Writing a GitHub pull request +alwaysApply: false +--- +# GitHub description guidelines + +Note for Cursor: If a ticket (GitHub issue or Jira ticket) is not provided by the prompt, prompt the user to supply one before generating the description or pull request content. + +When prompted to create a GitHub description, output the following: + +- Title +- Labels +- Description + +Output results in the chat window in a way that can be copied and pasted into GitHub. + +## GitHub markdown formatting rules + +Use these syntax rules when writing GitHub descriptions: + +- `##` through `######` - Headings (use `##` for main, `###` for secondary, etc.) +- `**text**` - Bold text +- `` `code` `` - Inline code +- ```` ```language` ``` - Language-specific code blocks +- `[text](url)` - Links +- `-` - Bullet points +- `1.` - Numbered list items +- `>` - Blockquotes for important notes +- `~~text~~` - Strikethrough for deprecated content + +## Title format + +- Use the format: `[Component] Brief description of change or issue` +- Keep titles concise but descriptive (under 80 characters) +- Use present tense for the description (e.g., "Add" not "Added") +- For PRs, include the component name in brackets if applicable + +## Description structure + +- Present title, labels, and type before description content +- Include links to related issues, RFCs, or documentation when applicable +- All descriptions must include clear acceptance criteria or expected outcomes +- Provide enough context so anyone can understand the objective +- Use prefixes in titles: [Bug], [Fix], [Docs], [Refactor], [Research], [S2], [Test] + +Examples: + +- [bug]: +- [Bug(component)]: +- [fix]: +- [Fix(component)]: +- [docs]: +- [Docs(component)]: + +## Severity classification + +- SEV1: Critical - System down, data loss, security breach +- SEV2: High - Major feature broken, significant user impact +- SEV3: Medium - Feature partially broken, moderate impact +- SEV4: Low - Minor issues, minimal user impact +- SEV5: Trivial - Cosmetic issues, no functional impact + +## Best practices + +- Link to relevant issues using the format: `#issue-number` +- Include component name in brackets if applicable: `[sp-button]` +- Add relevant labels for easier filtering +- Attach screenshots or videos for visual changes +- Reference design specs or documentation when available +- Use descriptive commit messages when linking to PRs +- Include reproduction steps for bugs +- Add environment information when relevant + +## Acceptance criteria + +- Write criteria in "Given/When/Then" format +- Make criteria specific and testable +- Include edge cases and error scenarios +- Consider accessibility requirements +- Include performance considerations when relevant + +## Labels + +Use the following labels to categorize pull requests. Only use labels that exist in the repository: + +### Priority and release labels + +- `1.0.0`: Issues that should be addressed for a 1.0 release +- `2.0.0`: Issues for 2.0 release +- `Breaking`: Breaking changes + +### Platform and browser labels + +- `Android`: Android-specific issues +- `Browser: Chrome`: Chrome browser issues +- `Browser: Edge (Legacy)`: Issue with pre-chromium Edge +- `Browser: FireFox`: Firefox browser issues +- `Browser: Safari`: Safari browser issues + +### Development and process labels + +- `a11y`: Issues related to accessibility +- `API`: Changes to component APIs or interfaces + +### Additional labels (partial list) + +Note: The repository has 160 labels total. For a complete list, visit [https://github.com/adobe/spectrum-web-components/labels](https://github.com/adobe/spectrum-web-components/labels) + +Common additional labels include: + +- `chore`: Routine tasks, maintenance, or non-feature changes +- `dependencies`: Updates or changes to project dependencies +- `docs`: Documentation updates or improvements +- `enhancement`: Improvements to existing features +- `feature`: New feature implementations +- `i18n`: Internationalization and localization work +- `iOS`: iOS-specific issues and bugs +- `mobile`: Mobile platform issues and responsive design +- `performance`: Performance-related improvements or regressions +- `refactor`: Code restructuring and refactoring work +- `regression`: Previously working functionality that is now broken +- `release`: Release process or versioning changes +- `research`: Tasks requiring investigation or research +- `RFC`: Request for Comments or design discussions +- `testing`: Test implementation or testing infrastructure work + +## Pull request guidelines + +- Use conventional commit messages +- Keep PRs focused and small when possible +- Include tests for new features +- Update documentation when APIs change +- Add screenshots for visual changes +- Link to related issues using keywords like "Fixes #123" or "Closes #456" +- Request reviews from appropriate team members +- Use draft PRs for work in progress + +## Templates + +### Pull request template + +**Note:** All pull requests should include the `ready-for-review` label. + +**When returning the template, check off the author requirements in the Author's checklist section. Do not check off the Manual review test cases or Device review sections as these are for reviewers to complete.** + +```markdown + + +## Description + + + +## Motivation and context + + + +## Related issue(s) + + + +- fixes [Issue Number] + +## Screenshots (if appropriate) + + +## Author's checklist + + + +- [ ] I have read the **[CONTRIBUTING](<(https://github.com/adobe/spectrum-web-components/blob/main/CONTRIBUTING.md)>)** and **[PULL_REQUESTS](<(https://github.com/adobe/spectrum-web-components/blob/main/PULL_REQUESTS.md)>)** documents. +- [ ] I have reviewed at the Accessibility Practices for this feature, see: [Aria Practices](https://www.w3.org/TR/wai-aria-practices/) +- [ ] I have added automated tests to cover my changes. +- [ ] I have included a well-written changeset if my change needs to be published. +- [ ] I have included updated documentation if my change required it. + + +## Reviewer's checklist + +- [ ] Includes a Github Issue with appropriate flag or Jira ticket number without a link +- [ ] Includes thoughtfully written changeset if changes suggested include `patch`, `minor`, or `major` features +- [ ] Automated tests cover all use cases and follow best practices for writing +- [ ] Validated on all supported browsers +- [ ] All VRTs are approved before the author can update Golden Hash + +### Manual review test cases + + + +- [ ] _Descriptive Test Statement_ + + 1. Go [here](url) + 2. Do this action + 3. Expect this result + +- [ ] _Descriptive Test Statement_ + 1. Go [here](url) + 2. Do this action + 3. Expect this result + +### Device review + + + +- [ ] Did it pass in Desktop? +- [ ] Did it pass in (emulated) Mobile? +- [ ] Did it pass in (emulated) iPad? + +``` # GitHub description guidelines Note for Cursor: If a ticket (GitHub issue or Jira ticket) is not provided by the prompt, prompt the user to supply one before generating the description or pull request content. diff --git a/.env.example b/.env.example index 040d2780a41..1834f01232a 100644 --- a/.env.example +++ b/.env.example @@ -19,3 +19,6 @@ WATCH_MODE=true NX_VERBOSE_LOGGING=false NX_SKIP_NX_CACHE=false NX_PERF_LOGGING=false + +ARTIFACTORY_API_KEY= +ARTIFACTORY_API_TOKEN= diff --git a/.github/QUICK-START.md b/.github/QUICK-START.md index 8579ccf031d..4b97fcab7e8 100644 --- a/.github/QUICK-START.md +++ b/.github/QUICK-START.md @@ -16,7 +16,7 @@ Spectrum CSS components utilize custom properties in order to change themes and ``` -Use the `index.css` files in your project to include component and global styles ([Spectrum and Express contexts](https://github.com/adobe/spectrum-css?tab=readme-ov-file#visual-language), [background theme/colorstop](https://github.com/adobe/spectrum-css?tab=readme-ov-file#themes-colorstops), [platform scaling](https://github.com/adobe/spectrum-css?tab=readme-ov-file#scales), etc.) for the component. If you don't need all of the global styles, peek at the docs for [including assets](https://github.com/adobe/spectrum-css?tab=readme-ov-file#including-assets)). Use this file by including the stylesheet (plus stylesheets for dependencies) in the `` tag: +Use the `index.css` files in your project to include component and global styles ([background theme/colorstop](https://github.com/adobe/spectrum-css?tab=readme-ov-file#themes-colorstops), [platform scaling](https://github.com/adobe/spectrum-css?tab=readme-ov-file#scales), etc.) for the component. If you don't need all of the global styles, peek at the docs for [including assets](https://github.com/adobe/spectrum-css?tab=readme-ov-file#including-assets)). Use this file by including the stylesheet (plus stylesheets for dependencies) in the `` tag: ```html @@ -55,11 +55,7 @@ To put it all together, your final html file will look like this: /> - diff --git a/.github/actions/file-diff/README.md b/.github/actions/file-diff/README.md index 7b66ed2858e..e20ef0d7b0b 100644 --- a/.github/actions/file-diff/README.md +++ b/.github/actions/file-diff/README.md @@ -48,5 +48,4 @@ with: base-path: ${{ github.workspace }}/base-branch file-glob-pattern: | components/*/dist/*.{css,json} - components/*/dist/themes/*.css ``` diff --git a/.github/actions/file-diff/action.yml b/.github/actions/file-diff/action.yml index 66e30f6c2b3..20b9e477638 100644 --- a/.github/actions/file-diff/action.yml +++ b/.github/actions/file-diff/action.yml @@ -31,5 +31,5 @@ outputs: total-size: description: "Total size of the files in bytes." runs: - using: "node20" + using: "node24" main: "index.js" diff --git a/.github/renovate.json b/.github/renovate.json index 2bdf0e4b8bb..1c026bc8876 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -8,16 +8,10 @@ "group:vite" ], "labels": ["dependencies", "skip_vrt", "ready-for-review"], - "rangeStrategy": "bump", "packageRules": [ { - "matchDatasources": ["npm"], - "minimumReleaseAge": "1 month" - }, - { - "matchUpdateTypes": ["major"], - "matchBaseBranches": ["main"], - "enabled": false + "matchDatasources": ["npm"], + "minimumReleaseAge": "1 month" }, { "groupName": "storybook ecosystem", diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0891debf247..7e4b0a9f689 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,7 +4,7 @@ name: Validate successful build # in several environments: # # Systems: Ubuntu, MacOS, // Windows -# Node: 20 +# Node: 22 # # After the build is successful, the compiled assets are uploaded as an artifact # to the workflow run. This allows us to download the compiled assets and use @@ -17,12 +17,15 @@ on: workflow_dispatch: inputs: system: + description: "The system to build on" required: false default: "macos-latest" node-version: + description: "The Node.js version to use" required: false - default: "20" + default: "22" experimental: + description: "Whether to run experimental builds" required: false default: "false" ref: @@ -37,7 +40,7 @@ on: node-version: required: false type: string - default: "20" + default: "22" experimental: required: false type: boolean @@ -89,7 +92,7 @@ jobs: fetch-depth: 0 - name: Use Node LTS version - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: node-version: ${{ matrix.node-version }} cache: yarn @@ -117,14 +120,15 @@ jobs: ## --- BUILD --- ## - name: Build components & ui-icons shell: bash - run: yarn ci + # add and lint-staged to catch any formatting fixes before diffing + run: yarn ci && git add . && yarn lint-staged ## --- UPLOAD (only ubuntu-latest at the moment) --- ## - name: Upload compiled assets & NX performance profile continue-on-error: true id: upload if: ${{ matrix.system == 'ubuntu-latest' }} - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v5 with: path: | ${{ github.workspace }}/components/*/dist/** @@ -161,7 +165,7 @@ jobs: - name: Upload changes if: ${{ failure() }} - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v5 with: path: changes.diff name: changes.diff diff --git a/.github/workflows/compare-results.yml b/.github/workflows/compare-results.yml index e387a448a55..5509737bc4f 100644 --- a/.github/workflows/compare-results.yml +++ b/.github/workflows/compare-results.yml @@ -50,9 +50,9 @@ jobs: ## --- SETUP --- ## - name: Use Node LTS version - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: - node-version: 20.19.5 + node-version: 22.21.0 cache: yarn cache-dependency-path: yarn.lock @@ -68,7 +68,7 @@ jobs: path: | .cache/yarn node_modules - key: ubuntu-latest-node20-${{ hashFiles('yarn.lock') }} + key: ubuntu-latest-node22-${{ hashFiles('yarn.lock') }} ## --- INSTALL --- ## # note: if cache-hit isn't needed b/c yarn will leverage the cache if it exists @@ -86,16 +86,16 @@ jobs: echo "base-path=${BRANCH//\//_}" >> "$GITHUB_OUTPUT" - name: Download build artifacts for head - uses: actions/download-artifact@v5 + uses: actions/download-artifact@v6 with: - name: ubuntu-latest-node20-compiled-assets-${{ steps.derive-key.outputs.head-path }} + name: ubuntu-latest-node22-compiled-assets-${{ steps.derive-key.outputs.head-path }} path: ${{ github.workspace }}/${{ steps.derive-key.outputs.head-path }} merge-multiple: true - name: Download build artifacts for base - uses: actions/download-artifact@v5 + uses: actions/download-artifact@v6 with: - name: ubuntu-latest-node20-compiled-assets-${{ steps.derive-key.outputs.base-path }} + name: ubuntu-latest-node22-compiled-assets-${{ steps.derive-key.outputs.base-path }} path: ${{ github.workspace }}/${{ steps.derive-key.outputs.base-path }} merge-multiple: true @@ -120,7 +120,7 @@ jobs: - name: Upload changes if: ${{ steps.compare.outputs.has-changed }} - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v5 with: name: rich-diff path: | @@ -155,10 +155,10 @@ jobs: run: | BRANCH=${{ matrix.branch }} BRANCH=${BRANCH//\//_} - echo "key=ubuntu-latest-node20-compiled-assets-${BRANCH}" >> "$GITHUB_OUTPUT" + echo "key=ubuntu-latest-node22-compiled-assets-${BRANCH}" >> "$GITHUB_OUTPUT" - name: Check if build artifacts already exist - uses: actions/download-artifact@v5 + uses: actions/download-artifact@v6 id: artifact-found continue-on-error: true with: @@ -177,9 +177,9 @@ jobs: ## --- SETUP --- ## - name: Use Node LTS version - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: - node-version: 20.19.5 + node-version: 22.21.0 cache: yarn - name: Enable Corepack @@ -194,7 +194,7 @@ jobs: path: | .cache/yarn node_modules - key: ubuntu-latest-node20-${{ hashFiles('yarn.lock') }} + key: ubuntu-latest-node22-${{ hashFiles('yarn.lock') }} ## --- INSTALL --- ## # note: if cache-hit isn't needed b/c yarn will leverage the cache if it exists @@ -206,7 +206,7 @@ jobs: - name: Check for built assets continue-on-error: true id: download - uses: actions/download-artifact@v5 + uses: actions/download-artifact@v6 with: path: | ${{ github.workspace }}/components/*/dist/** @@ -223,7 +223,7 @@ jobs: if: ${{ steps.download.outcome != 'success' }} continue-on-error: true id: upload - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v5 with: path: | ${{ github.workspace }}/components/*/dist/** diff --git a/.github/workflows/development.yml b/.github/workflows/development.yml index 0e54255c796..da896d6a2bb 100644 --- a/.github/workflows/development.yml +++ b/.github/workflows/development.yml @@ -53,7 +53,7 @@ jobs: - macos-latest - ubuntu-latest node-version: - - 20 + - 22 # experimental: # - false # include: @@ -106,8 +106,6 @@ jobs: files_yaml: | styles: - components/*/index.css - - components/*/themes/spectrum.css - - components/*/themes/express.css eslint: - components/*/stories/*.js mdlint: @@ -117,7 +115,7 @@ jobs: - components/*/*.md - plugins/*/*.md - tokens/*.md - - tools/*/*.md + - bundle/*.md - ui-icons/*.md plugins: - plugins/**/* @@ -153,9 +151,9 @@ jobs: uses: actions/checkout@v5 - name: Use Node LTS version - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: - node-version: 20.19.5 + node-version: 22.21.0 cache: yarn - name: Enable Corepack @@ -170,7 +168,7 @@ jobs: path: | .cache/yarn node_modules - key: ubuntu-latest-node20-${{ hashFiles('yarn.lock') }} + key: ubuntu-latest-node22-${{ hashFiles('yarn.lock') }} ## --- INSTALL --- ## # If statement isn't needed here b/c yarn will leverage the cache if it exists diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 3eab2595c84..07c5e3460d0 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -63,9 +63,9 @@ jobs: fetch-depth: 0 - name: Use Node LTS version - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: - node-version: 20.19.5 + node-version: 22.21.0 cache: yarn - name: Enable Corepack @@ -80,7 +80,7 @@ jobs: path: | .cache/yarn node_modules - key: ubuntu-latest-node20-${{ hashFiles('yarn.lock') }} + key: ubuntu-latest-node22-${{ hashFiles('yarn.lock') }} ## --- INSTALL --- ## # If statement isn't needed here b/c yarn will leverage the cache if it exists @@ -102,7 +102,7 @@ jobs: filter_mode: diff_context level: error reporter: github-pr-review - # stylelint_input: "components/*/index.css components/*/themes/*.css" + # stylelint_input: "components/*/index.css" stylelint_input: "${{ inputs.styles_added_files }} ${{ inputs.styles_modified_files }}" stylelint_config: "${{ github.workspace }}/stylelint.config.js" packages: 'stylelint-header stylelint-config-standard stylelint-selector-bem-pattern stylelint-order stylelint-use-logical' diff --git a/.github/workflows/production.yml b/.github/workflows/production.yml index 40599d4c270..93a37fcd208 100644 --- a/.github/workflows/production.yml +++ b/.github/workflows/production.yml @@ -36,7 +36,7 @@ jobs: - macos-latest - ubuntu-latest node-version: - - 20 + - 22 uses: ./.github/workflows/build.yml with: system: ${{ matrix.system }} diff --git a/.github/workflows/publish-site.yml b/.github/workflows/publish-site.yml index 3fe0441e87c..e5257c00d25 100644 --- a/.github/workflows/publish-site.yml +++ b/.github/workflows/publish-site.yml @@ -47,9 +47,9 @@ jobs: fetch-depth: 0 - name: Use Node LTS version - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: - node-version: 20.19.5 + node-version: 22.21.0 cache: yarn - name: Enable Corepack @@ -71,7 +71,7 @@ jobs: path: | .cache/yarn node_modules - key: ubuntu-latest-node20-${{ hashFiles('yarn.lock') }} + key: ubuntu-latest-node22-${{ hashFiles('yarn.lock') }} ## --- INSTALL --- ## - name: Install dependencies @@ -105,7 +105,7 @@ jobs: echo "docs_url=${docs_url}" >> $GITHUB_OUTPUT echo "Deployed to: ${docs_url}" - name: Post Previews Comment - uses: actions/github-script@v7 + uses: actions/github-script@v8 with: script: | const { buildPreviewURLComment } = await import('${{ github.workspace }}/.github/scripts/build-preview-urls-comment.js'); diff --git a/.github/workflows/release-snapshot.yml b/.github/workflows/release-snapshot.yml index d6bfff37d80..ad33cc565c7 100644 --- a/.github/workflows/release-snapshot.yml +++ b/.github/workflows/release-snapshot.yml @@ -29,9 +29,9 @@ jobs: echo "authorName=$(git log -1 --pretty=format:'%an')" >> $GITHUB_OUTPUT echo "authorEmail=$(git log -1 --pretty=format:'%ae')" >> $GITHUB_OUTPUT - name: Setup Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: - node-version: 20.19.5 + node-version: 22.21.0 cache: yarn - name: Install Dependencies run: yarn install --frozen-lockfile diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ff41a08468e..871541dacd9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,9 +17,9 @@ jobs: uses: actions/checkout@v5 - name: Setup Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: - node-version: 20.19.5 + node-version: 22.21.0 cache: yarn - name: Install Dependencies diff --git a/.github/workflows/vrt.yml b/.github/workflows/vrt.yml index 2021103c81d..5c95299f662 100644 --- a/.github/workflows/vrt.yml +++ b/.github/workflows/vrt.yml @@ -54,9 +54,9 @@ jobs: CHROMATIC_SLUG: ${{ github.repository }} - name: Use Node LTS version - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: - node-version: 20.19.5 + node-version: 22.21.0 cache: yarn - name: Enable Corepack @@ -71,7 +71,7 @@ jobs: path: | .cache/yarn node_modules - key: ubuntu-latest-node20-${{ hashFiles('yarn.lock') }} + key: ubuntu-latest-node22-${{ hashFiles('yarn.lock') }} ## --- INSTALL --- ## - name: Install dependencies @@ -93,7 +93,7 @@ jobs: exitOnceUploaded: true onlyChanged: true traceChanged: true - untraced: ".github/* plugins/stylelint-*/* tools/* .changeset/*" - autoAcceptChanges: "main" + untraced: ".github/* plugins/stylelint-*/* bundle/* .changeset/*" + autoAcceptChanges: "(main|spectrum-two)" # Lets VRT pass without running so as not to waste snapshots skip: ${{ inputs.skip }} diff --git a/.markdownlint.json b/.markdownlint.json index 3eb2b8c2789..427f41c1a92 100644 --- a/.markdownlint.json +++ b/.markdownlint.json @@ -1,7 +1,7 @@ { "extends": "markdownlint/style/prettier", "first-line-h1": false, - "no-inline-html": false, + "no-inline-html": false, "no-bare-urls": false, "no-duplicate-heading": { "siblings_only": true diff --git a/.nvmrc b/.nvmrc index fc9099892a5..aa50a62f219 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -20.19.5 +22.21.0 diff --git a/.prettierignore b/.prettierignore index 13158ed8ac2..bb4ffd976d5 100644 --- a/.prettierignore +++ b/.prettierignore @@ -3,6 +3,7 @@ **/.svn **/.hg **/node_modules +yarn.lock # Compiled and generated files dist diff --git a/.storybook/CHANGELOG.md b/.storybook/CHANGELOG.md index 09c086cc78f..0c9c669830a 100644 --- a/.storybook/CHANGELOG.md +++ b/.storybook/CHANGELOG.md @@ -1,5 +1,184 @@ # Change Log +## 12.1.0-next.21 + +### Patch Changes + +Updated dependencies []: + +- @spectrum-css/bundle@2.0.0-next.17 + +## 12.1.0-next.20 + +### Patch Changes + +Updated dependencies []: + +- @spectrum-css/bundle@2.0.0-next.16 + +## 12.1.0-next.19 + +### Patch Changes + +Updated dependencies [[`ff1d0c8`](https://github.com/adobe/spectrum-css/commit/ff1d0c8d156305e2291b5519320d7069e0d7f68f)]: + +- @spectrum-css/tokens@16.1.0-next.10 +- @spectrum-css/bundle@2.0.0-next.15 + +## 12.1.0-next.18 + +### Patch Changes + +Updated dependencies [[`eb23c3b`](https://github.com/adobe/spectrum-css/commit/eb23c3b2acc5e39684319b2fd46990c2e76add0c)]: + +- @spectrum-css/tokens@16.1.0-next.9 +- @spectrum-css/bundle@2.0.0-next.14 + +## 12.1.0-next.17 + +### Patch Changes + +Updated dependencies []: + +- @spectrum-css/bundle@2.0.0-next.13 + +## 12.1.0-next.16 + +### Patch Changes + +Updated dependencies []: + +- @spectrum-css/bundle@2.0.0-next.12 + +## 12.1.0-next.15 + +### Minor Changes + +📝 [#4165](https://github.com/adobe/spectrum-css/pull/4165) [`fa7a1b4`](https://github.com/adobe/spectrum-css/commit/fa7a1b4fc3b9feca7a0568eb1fd998fcdcb905fa) Thanks [@castastrophe](https://github.com/castastrophe)! + +- _feature_: Add the `resetArgs` function to the argEvents decorator +- _fix_: Resolve minor lint warnings in the Storybook CSS assets + +## 12.0.5-next.14 + +### Patch Changes + +Updated dependencies []: + +- @spectrum-css/bundle@2.0.0-next.11 + +## 12.0.5-next.13 + +### Patch Changes + +Updated dependencies [[`5b694c5`](https://github.com/adobe/spectrum-css/commit/5b694c58be813fd82315252dab721e94bf769a71)]: + +- @spectrum-css/tokens@16.1.0-next.8 +- @spectrum-css/bundle@2.0.0-next.10 + +## 12.0.5-next.12 + +### Patch Changes + +Updated dependencies []: + +- @spectrum-css/bundle@2.0.0-next.9 + +## 12.0.5-next.11 + +### Patch Changes + +Updated dependencies []: + +- @spectrum-css/bundle@2.0.0-next.8 + +## 12.0.5-next.10 + +### Patch Changes + +Updated dependencies []: + +- @spectrum-css/bundle@2.0.0-next.7 + +## 12.0.5-next.9 + +### Patch Changes + +Updated dependencies [[`7f48b7c`](https://github.com/adobe/spectrum-css/commit/7f48b7c6384f8c7d598637226a17aff1c8e8b61c)]: + +- @spectrum-css/tokens@16.1.0-next.7 +- @spectrum-css/bundle@2.0.0-next.6 + +## 12.0.5-next.8 + +### Patch Changes + +Updated dependencies [[`86dd51d`](https://github.com/adobe/spectrum-css/commit/86dd51d884878a3090cb8463ca0bf44f21ee9f87), [`f6843c6`](https://github.com/adobe/spectrum-css/commit/f6843c698a2aac7c15ba949e28c56e4ff49c8c4a)]: + +- @spectrum-css/ui-icons@2.0.0-next.2 +- @spectrum-css/tokens@16.1.0-next.6 +- @spectrum-css/bundle@2.0.0-next.5 + +## 12.0.5-next.7 + +### Patch Changes + +- Updated dependencies [[`d952e0c`](https://github.com/adobe/spectrum-css/commit/d952e0c4d234f5e742432fe906965a52a50b228e)]: + - @spectrum-css/tokens@16.1.0-next.5 + - @spectrum-css/bundle@2.0.0-next.4 + +## 12.0.5-next.6 + +### Patch Changes + +- Updated dependencies [[`f20e1e7`](https://github.com/adobe/spectrum-css/commit/f20e1e7ff402b591706cc791d9207fdedb80cd1e)]: + - @spectrum-css/tokens@16.1.0-next.4 + - @spectrum-css/bundle@2.0.0-next.3 + +## 12.0.5-next.5 + +### Patch Changes + +- Updated dependencies []: + - @spectrum-css/bundle@2.0.0-next.2 + +## 12.0.5-next.4 + +### Patch Changes + +- Updated dependencies []: + - @spectrum-css/bundle@2.0.0-next.1 + +## 12.0.5-next.3 + +### Patch Changes + +- Updated dependencies [[`d47295a`](https://github.com/adobe/spectrum-css/commit/d47295a06cf974c347d794ae4f71bc4c8c498025), [`f0d187f`](https://github.com/adobe/spectrum-css/commit/f0d187ff016d49c46ac125cb37ae274644608505), [`1cdfcbf`](https://github.com/adobe/spectrum-css/commit/1cdfcbff6cb3369d710cec78733536d5dd72e7d4), [`1b33315`](https://github.com/adobe/spectrum-css/commit/1b33315fa1b65d65fe940d3be4ea4395d5394655)]: + - @spectrum-css/bundle@2.0.0-next.0 + - @spectrum-css/tokens@16.1.0-next.3 + - @spectrum-css/ui-icons@2.0.0-next.1 + +## 12.0.5-next.2 + +### Patch Changes + +- Updated dependencies [[`87d7d99`](https://github.com/adobe/spectrum-css/commit/87d7d99260e758e697668cc17962b0b36d075c65)]: + - @spectrum-css/tokens@16.1.0-next.2 + +## 12.0.5-next.1 + +### Patch Changes + +- Updated dependencies [[`89a3f2b`](https://github.com/adobe/spectrum-css/commit/89a3f2bfeed257a5eefeef229efaa3cc7555980c)]: + - @spectrum-css/tokens@16.1.0-next.1 + +## 12.0.5-next.0 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + ## 12.0.5 ### Patch Changes @@ -110,7 +289,6 @@ This release also includes: 📝 [#3458](https://github.com/adobe/spectrum-css/pull/3458) [`e1b7102`](https://github.com/adobe/spectrum-css/commit/e1b71027f92ce18feb3a63c100d2b4871fc73b9f) Thanks [@castastrophe](https://github.com/castastrophe)! - Update the Chromatic add-on to the currently maintained package: - - from "@chromaui/addon-visual-tests": "^1.0.0" - to "@chromatic-com/storybook": "^3.2.3" @@ -336,7 +514,6 @@ This release also includes: 📝 [#2820](https://github.com/adobe/spectrum-css/pull/2820) [`1711ef8`](https://github.com/adobe/spectrum-css/commit/1711ef8a7aa8da1858019b77ed52e1dd1b86d3bf) Thanks [@castastrophe](https://github.com/castastrophe)! - Fixes for Storybook instance - - Bring back testing preview global toggle to toolbar after it was accidentally removed in a previous release - Chromatic disable snapshot syntax corrected in multiple stories - Update when token assets are loaded to correct snapshot inconsistencies @@ -510,7 +687,6 @@ This component has been deprecated. Use an action bar to allow users to perform ### 🛑 BREAKING CHANGE - @spectrum-css/icon will no longer contain SVG assets; it will be a purely CSS package with all SVG assets migrated to the new @spectrum-css/ui-icons package. - - NEW: @spectrum-css/ui-icons package for all SVG icons in the UI set. ## 6.0.1 diff --git a/.storybook/assets/base.css b/.storybook/assets/base.css index 98841f09954..1644b455fb6 100644 --- a/.storybook/assets/base.css +++ b/.storybook/assets/base.css @@ -1,5 +1,3 @@ -/* stylelint-disable selector-class-pattern -- Targeting pre-defined Storybook classes */ - /*! * Copyright 2024 Adobe. All rights reserved. * @@ -29,23 +27,11 @@ body { } .spectrum { - /* Gradient that changes with the color theme. */ - --spectrum-examples-gradient: linear-gradient(45deg, var(--spectrum-magenta-1500), var(--spectrum-blue-1500)); - - /* Gradients that do not change with the color theme, for use in static color backgrounds. */ - --spectrum-examples-gradient-static-black: linear-gradient(45deg, rgb(255 241 246), rgb(238 245 255)); - --spectrum-examples-gradient-static-white: linear-gradient(45deg, rgb(64 0 22), rgb(14 24 67)); - color: var(--spectrum-neutral-content-color-default); background-color: var(--spectrum-background-base-color); -webkit-tap-highlight-color: rgb(0, 0, 0, 0%); } -.spectrum.spectrum--legacy { - color: var(--spectrum-neutral-content-color-default); - background-color: var(--spectrum-background-layer-1-color); -} - .spectrum .spectrum-examples-static-black { background: var(--spectrum-examples-gradient-static-black); } @@ -89,4 +75,14 @@ svg:has(symbol):not(:has(use)) { overflow: visible !important; } -/* stylelint-enable selector-class-pattern */ +#panel-tab-content tr th:nth-child(1), +#panel-tab-content tr th:nth-child(3), +#panel-tab-content tr td:nth-child(1), +#panel-tab-content tr td:nth-child(3) { + min-inline-size: 100px !important; +} + +#panel-tab-content tr th:nth-child(2), +#panel-tab-content tr td:nth-child(2) { + max-inline-size: 500px !important; +} diff --git a/.storybook/assets/images/dropzone-illustration.png b/.storybook/assets/images/dropzone-illustration.png new file mode 100644 index 00000000000..dcc34b9f97b Binary files /dev/null and b/.storybook/assets/images/dropzone-illustration.png differ diff --git a/.storybook/assets/images/sparkline-informative.svg b/.storybook/assets/images/sparkline-informative.svg new file mode 100644 index 00000000000..5998b3e03b0 --- /dev/null +++ b/.storybook/assets/images/sparkline-informative.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/.storybook/assets/images/sparkline-negative.svg b/.storybook/assets/images/sparkline-negative.svg new file mode 100644 index 00000000000..d31715827f7 --- /dev/null +++ b/.storybook/assets/images/sparkline-negative.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/.storybook/assets/images/sparkline-notice.svg b/.storybook/assets/images/sparkline-notice.svg new file mode 100644 index 00000000000..80d18bc0e30 --- /dev/null +++ b/.storybook/assets/images/sparkline-notice.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/.storybook/assets/images/sparkline-positive.svg b/.storybook/assets/images/sparkline-positive.svg new file mode 100644 index 00000000000..f5a80fa6ec7 --- /dev/null +++ b/.storybook/assets/images/sparkline-positive.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/.storybook/assets/index.css b/.storybook/assets/index.css index 95b4d83897d..1836e9c950b 100644 --- a/.storybook/assets/index.css +++ b/.storybook/assets/index.css @@ -1,5 +1,3 @@ -/* stylelint-disable selector-class-pattern -- Targeting pre-defined Storybook classes */ - /*! * Copyright 2024 Adobe. All rights reserved. * @@ -72,6 +70,13 @@ div.sb-bar > div > div > span:first-child { .docblock-argstable-body tr td { letter-spacing: unset; font-size: 11px; + max-inline-size: 400px; + overflow-x: auto; +} + +.docblock-argstable-body tr td code { + white-space: pre-wrap; + line-height: inherit; } .docblock-argstable-body td > span:has(select), @@ -119,4 +124,9 @@ select:focus, border-color: rgb(2, 101, 220) !important; box-shadow: rgb(2, 101, 220) 0 0 0 1px inset !important; } -/* stylelint-enable selector-class-pattern */ + +nav.sidebar-container, +div.sb-bar { + color: var(--spectrum-neutral-content-color-default) !important; + background-color: var(--spectrum-background-layer-2-color) !important; +} diff --git a/.storybook/blocks/utilities.js b/.storybook/blocks/utilities.js index b5ba302ccd7..a9b733423d2 100644 --- a/.storybook/blocks/utilities.js +++ b/.storybook/blocks/utilities.js @@ -1,4 +1,3 @@ -import legacy from "@spectrum-css/tokens-legacy/dist/json/tokens.json"; import spectrum from "@spectrum-css/tokens/dist/json/tokens.json"; import { useTheme } from "@storybook/theming"; @@ -50,15 +49,10 @@ function parseData(data, { key, color, platform }) { * @param {string} context.context - The theme context set globally for the page * @returns {{ color: string, scale: string, context: string, platform: "desktop"|"mobile" }} - An object containing the calculated theme context */ -function fetchTheme({ color, scale, context } = {}) { +function fetchTheme({ color, scale } = {}) { // Fetch the theme if it exists; this data exists if wrapped in a ThemeProvider const theme = useTheme() ?? {}; - // If the context is not provided, use the theme value or a fallback - if (typeof context !== "string" && typeof theme.context == "string") - context = theme.context; - else if (!context) context = "spectrum"; - // If the color or scale is not provided, use the theme values or a fallback if (typeof color !== "string" && typeof theme.color == "string") color = theme.color; @@ -70,9 +64,8 @@ function fetchTheme({ color, scale, context } = {}) { // Create a platform context based on the scale (platform used in the token data) const platform = scale === "medium" ? "desktop" : "mobile"; - const tokens = context === "spectrum" ? spectrum : legacy; - return { color, scale, context, platform, tokens }; + return { color, scale, platform, tokens: (spectrum ?? {}) }; } /** diff --git a/.storybook/decorators/context.js b/.storybook/decorators/context.js index 0ad4bb758aa..cc147ee10cd 100644 --- a/.storybook/decorators/context.js +++ b/.storybook/decorators/context.js @@ -1,7 +1,6 @@ import { makeDecorator, useEffect } from "@storybook/preview-api"; import { fetchContainers, toggleStyles } from "./helpers.js"; -import legacyTokens from "@spectrum-css/tokens-legacy/dist/index.css?inline"; import tokens from "@spectrum-css/tokens/dist/css/index.css?inline"; /** @@ -19,7 +18,6 @@ export const withContextWrapper = makeDecorator({ } = {}, globals: { color = "light", - context = "spectrum", scale = "medium", } = {}, parameters: { @@ -31,35 +29,26 @@ export const withContextWrapper = makeDecorator({ const staticColorSettings = { "black": { - background: "var(--spectrum-docs-static-black-background-color)", + background: "var(--spectrum-examples-gradient-static-black)", color: "light" }, "white": { - background: "var(--spectrum-docs-static-white-background-color)", + background: "var(--spectrum-examples-gradient-static-white)", color: "dark" }, }; - const original = { - color, - context, - scale, - }; + const original = { color, scale }; useEffect(() => { const isDocs = viewMode === "docs"; const isTesting = showTestingGrid; - const isRaw = Boolean(context === "raw"); - const isModern = Boolean(context === "spectrum"); - const isExpress = Boolean(context === "express"); - - if (!isRaw) { - // add the default classes to the body to ensure labels, headings, and borders are styled correctly - document.body.classList.add("spectrum", "spectrum--light", "spectrum--medium"); - } // Start by attaching the appropriate tokens to the container - toggleStyles(document.body, "tokens", isModern ? tokens : legacyTokens, !isRaw, context); + toggleStyles(document.body, "tokens", tokens, true); + + // add the default classes to the body to ensure labels, headings, and borders are styled correctly + document.body.classList.add("spectrum", "spectrum--light", "spectrum--medium"); for (const container of fetchContainers(id, isDocs, isTesting)) { // Check if the container is a testing wrapper to prevent applying colors around the testing grid @@ -69,7 +58,6 @@ export const withContextWrapper = makeDecorator({ // Reset the context to the original values color = original.color; - context = original.context; scale = original.scale; let staticKey = staticColor; @@ -84,20 +72,7 @@ export const withContextWrapper = makeDecorator({ if (!staticKey) hasStaticElement = false; // Every container gets the spectrum class - container.classList.toggle("spectrum", !isRaw); - - // S1 and S1 Express get the legacy class - container.classList.toggle("spectrum--legacy", !isModern && !isRaw); - - // Express only gets the express class - container.classList.toggle("spectrum--express", isExpress && !isRaw); - - // Darkest is deprecated in Spectrum 2 - if (isModern && color === "darkest") { - /* eslint-disable no-console -- notify that darkest was deprecated in S2 */ - console.warn("The 'darkest' color is deprecated in Spectrum 2. Please use 'dark' instead."); - color = "dark"; - } + container.classList.toggle("spectrum", true); // Let the static color override the color if it's set if (!isTestingWrapper && hasStaticElement && staticColorSettings[staticKey]?.color) { @@ -110,12 +85,12 @@ export const withContextWrapper = makeDecorator({ color = "light"; } - for (let c of ["light", "dark", "darkest"]) { - container.classList.toggle(`spectrum--${c}`, c === color && !isRaw); + for (let c of ["light", "dark"]) { + container.classList.toggle(`spectrum--${c}`, c === color); } for (const s of ["medium", "large"]) { - container.classList.toggle(`spectrum--${s}`, s === scale && !isRaw); + container.classList.toggle(`spectrum--${s}`, s === scale); } if (!isTestingWrapper) { @@ -129,7 +104,7 @@ export const withContextWrapper = makeDecorator({ } } - }, [context, color, scale, viewMode, original, staticColor, rootClass, tokens, legacyTokens, staticColorSettings, showTestingGrid]); + }, [viewMode, original, staticColor, color, scale, rootClass, tokens, staticColorSettings, showTestingGrid]); return StoryFn(data); }, diff --git a/.storybook/decorators/down-state.js b/.storybook/decorators/down-state.js new file mode 100644 index 00000000000..31ba5ed5133 --- /dev/null +++ b/.storybook/decorators/down-state.js @@ -0,0 +1,40 @@ +import { makeDecorator, useEffect } from "@storybook/preview-api"; +import { fetchContainers } from "./helpers.js"; + +export const withDownStateDimensionCapture = makeDecorator({ + name: "withDownStateDimensionCapture", + parameterName: "downState", + wrapper: (StoryFn, context) => { + const { args = {}, parameters = {}, viewMode, id } = context; + + /* Selectors are defined in the downState parameter */ + const { + // Fall back to the rootClass if no selectors are provided + selectors = args.rootClass ? [ args.rootClass ] : [] + } = parameters.downState ?? {}; + + /** + * This effect will run after the component is rendered and will capture the dimensions of the + * components that are specified in the selectors array. It will then set the custom properties + * --spectrum-downstate-width and --spectrum-downstate-height on the component to the width and + * height of the component respectively. This will allow the downstate to be calculated correctly + * in the CSS. + */ + useEffect(() => { + if (selectors.length === 0) return; + + for (const container of fetchContainers(id, viewMode === "docs")) { + for (const selector of selectors) { + const components = [...container.querySelectorAll(selector)]; + for (const component of components) { + const { width, height } = component.getBoundingClientRect(); + component.style.setProperty("--spectrum-downstate-width", `${width}px`); + component.style.setProperty("--spectrum-downstate-height", `${height}px`); + } + } + } + }, [selectors]); + + return StoryFn(context); + }, +}); diff --git a/.storybook/decorators/icon-sprites.js b/.storybook/decorators/icon-sprites.js index 48f045eea8a..b576632bcab 100644 --- a/.storybook/decorators/icon-sprites.js +++ b/.storybook/decorators/icon-sprites.js @@ -1,5 +1,5 @@ // Used in the icon sprite decorator to inject the sprite sheets into the document -import workflowSprite from "@adobe/spectrum-css-workflow-icons/dist/spectrum-icons.svg?raw"; +import workflowSprite from "@adobe/spectrum-css-workflow-icons/dist/assets/svg-spriteSheet/icons.svg?raw"; import uiSprite from "@spectrum-css/ui-icons/dist/spectrum-css-icons.svg?raw"; import { makeDecorator, useEffect } from "@storybook/preview-api"; @@ -14,9 +14,6 @@ export const withIconSpriteSheet = makeDecorator({ loaded = {}, } = context; - // Load the icons into the window object - if (loaded.icons) window.icons = loaded.icons; - useEffect(() => { // Inject the sprite sheets into the document let sprite = document.getElementById("spritesheets"); diff --git a/.storybook/decorators/index.js b/.storybook/decorators/index.js index 059919173ba..f44d173b22a 100644 --- a/.storybook/decorators/index.js +++ b/.storybook/decorators/index.js @@ -13,6 +13,7 @@ export { withArgEvents } from "./arg-events.js"; export { withContextWrapper } from "./context.js"; +export { withDownStateDimensionCapture } from "./down-state.js"; export { withIconSpriteSheet } from "./icon-sprites.js"; export { withLanguageWrapper } from "./language.js"; export { withReducedMotionWrapper } from "./reduce-motion.js"; diff --git a/.storybook/decorators/utilities.js b/.storybook/decorators/utilities.js index f6722ae79ea..bd22ac68401 100644 --- a/.storybook/decorators/utilities.js +++ b/.storybook/decorators/utilities.js @@ -556,12 +556,12 @@ export const renderContent = (content = [], { if (content.length === 0) return nothing; return html` - ${content.map((c) => { + ${content.map((c, idx) => { if (typeof c === "undefined") return nothing; /* If the content is an object (but not a lit object), we need to merge the object with the template */ if (typeof c !== "string" && (typeof c === "object" && !c._$litType$)) { - return callback({ ...args, ...c }, context); + return callback({ ...args, ...c, idx }, context); } if (typeof c === "function") { diff --git a/.storybook/foundations/backgroundlayers/backgroundlayers.stories.js b/.storybook/foundations/backgroundlayers/backgroundlayers.stories.js new file mode 100644 index 00000000000..6fe00400e4f --- /dev/null +++ b/.storybook/foundations/backgroundlayers/backgroundlayers.stories.js @@ -0,0 +1,127 @@ +import { html } from "lit"; +import { Template } from "./template"; + +/** + * The Spectrum CSS background layers is a set of utility classes used to apply Spectrum 2 app framing. Consult [design documentation](https://s2.spectrum.corp.adobe.com/page/background-layers/) for further usage and infomation. + * Make note of the context when determing the correct class to use. + * + * To use these classes: + * + * - add background layers as a dependency + * - Use appropriate class on the element which should display the background layer + */ +export default { + title: "Background layers", + description: "The background layers is a series of classes used to style background layers.", + component: "BackgroundLayers", + argTypes: { + environment: { + name: "Context", + description: "The context of the background layer", + control: "select", + options: ["edit", "browse"], + }, + layer: { + name: "Layer", + description: "The layer of the background layer", + control: "select", + options: ["elevated", "layer1", "layer2", "pasteboard"], + if: { + arg: "environment", + equals: "browse", + options: ["elevated", "layer1", "base"], + }, + }, + }, + args: { + rootClass: "spectrum-BackgroundLayers", + environment: "edit", + layer: "layer1", + }, + parameters: { + design: { + type: "figma", + url: "https://www.figma.com/design/Mngz9H7WZLbrCvGQf3GnsY/S2-%2F-Desktop?node-id=36806-6551", + }, + status: { + type: "migrated", + }, + }, + tags: ["migrated", "!dev"] +}; + +/** + * Editing context classes: + * + * - `spectrum-BackgroundLayers-edit-elevated` + * - `spectrum-BackgroundLayers-edit-layer2` + * - `spectrum-BackgroundLayers-edit-layer1` + * - `spectrum-BackgroundLayers-edit-pasteboard` + */ +export const EditingContext = (args = {}, context = {}) => { + const spacing = 28; + const size = 120; + const minSize = size + spacing * 2; + return html` +
+ ${Template({ + ...args, + customStyles: { zIndex: 4 }, + layer: "elevated", + }, context)} + ${Template({ + ...args, + customStyles: { zIndex: 3, insetInlineStart: `${spacing}px`, insetBlockStart: `${spacing}px` }, + layer: "layer2", + }, context)} + ${Template({ + ...args, + customStyles: { zIndex: 2, insetInlineStart: `${spacing * 2}px`, insetBlockStart: `${spacing * 2}px` }, + layer: "layer1", + }, context)} + ${Template({ + ...args, + customStyles: { zIndex: 1, insetInlineStart: `${spacing * 3}px`, insetBlockStart: `${spacing * 3}px` }, + layer: "pasteboard", + }, context)} +
+ `; +}; +EditingContext.args = { + environment: "edit", +}; + +/** + * Browsing context classes: + * + * - `spectrum-BackgroundLayers-browse-elevated` + * - `spectrum-BackgroundLayers-browse-layer1` + * - `spectrum-BackgroundLayers-browse-base` + */ +export const BrowsingContext = (args = {}, context = {}) => { + const spacing = 28; + const size = 120; + const minSize = size + spacing * 2; + return html` +
+ ${Template({ + ...args, + customStyles: { zIndex: 3 }, + layer: "elevated", + }, context)} + ${Template({ + ...args, + customStyles: { zIndex: 2, insetInlineStart: `${spacing}px`, insetBlockStart: `${spacing}px` }, + layer: "layer1", + }, context)} + ${Template({ + ...args, + customStyles: { zIndex: 1, insetInlineStart: `${spacing * 2}px`, insetBlockStart: `${spacing * 2}px` }, + layer: "base", + }, context)} +
+ `; +}; +BrowsingContext.args = { + environment: "browse", +}; diff --git a/.storybook/foundations/backgroundlayers/index.css b/.storybook/foundations/backgroundlayers/index.css new file mode 100644 index 00000000000..e795fb23d4a --- /dev/null +++ b/.storybook/foundations/backgroundlayers/index.css @@ -0,0 +1,56 @@ +/*! + * Copyright 2024 Adobe. All rights reserved. + * + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ + +/* for use only in editing contexts */ +.spectrum-BackgroundLayers-edit-elevated { + --spectrum-backgroundlayers-shadow-horizontal: 0; + --spectrum-backgroundlayers-shadow-vertical: 0; + --spectrum-backgroundlayers-shadow-blur: 5px; + --spectrum-backgroundlayers-shadow-color: light-dark(var(--spectrum-gray-600), var(--spectrum-gray-100)); + + background-color: var(--spectrum-background-elevated-color); + box-shadow: var(--spectrum-backgroundlayers-shadow-horizontal) var(--spectrum-backgroundlayers-shadow-vertical) var(--spectrum-backgroundlayers-shadow-blur) var(--spectrum-backgroundlayers-shadow-color); +} + +.spectrum-BackgroundLayers-edit-layer2 { + background-color: var(--spectrum-background-layer-2-color); + border: 2px solid rgb(180 180 180 / 25%); +} + +.spectrum-BackgroundLayers-edit-layer1 { + background-color: var(--spectrum-background-layer-1-color); +} + +.spectrum-BackgroundLayers-edit-pasteboard { + background-color: var(--spectrum-background-pasteboard-color); +} + +/* only used in browsing contexts */ +.spectrum-BackgroundLayers-browse-elevated { + --spectrum-backgroundlayers-shadow-horizontal: 0; + --spectrum-backgroundlayers-shadow-vertical: 0; + --spectrum-backgroundlayers-shadow-blur: 5px; + --spectrum-backgroundlayers-shadow-color: light-dark(var(--spectrum-gray-600), var(--spectrum-gray-100)); + + background-color: var(--spectrum-background-elevated-color); + box-shadow: var(--spectrum-backgroundlayers-shadow-horizontal) var(--spectrum-backgroundlayers-shadow-vertical) var(--spectrum-backgroundlayers-shadow-blur) var(--spectrum-backgroundlayers-shadow-color); +} + +.spectrum-BackgroundLayers-browse-layer1 { + background-color: var(--spectrum-background-layer-1-color); +} + +.spectrum-BackgroundLayers-browse-base { + border: 2px solid rgb(180 180 180 / 25%); + background-color: var(--spectrum-background-base-color); +} diff --git a/.storybook/foundations/backgroundlayers/template.js b/.storybook/foundations/backgroundlayers/template.js new file mode 100644 index 00000000000..7519ecfece2 --- /dev/null +++ b/.storybook/foundations/backgroundlayers/template.js @@ -0,0 +1,44 @@ +import { getRandomId } from "@spectrum-css/preview/decorators"; +import { html } from "lit"; +import { classMap } from "lit/directives/class-map.js"; +import { ifDefined } from "lit/directives/if-defined.js"; +import { styleMap } from "lit/directives/style-map.js"; + +import "./index.css"; + +export const Template = ({ + rootClass = "spectrum-BackgroundLayers", + environment = "edit", + layer = "layer1", + size = 120, + customStyles = {}, + customClasses = [], + id = getRandomId("background-layers"), +}) => { + let previousZIndex = 0; + + return html` +
({ ...a, [c]: true }), {}), + })} + id=${ifDefined(id)} + style=${styleMap({ + inlineSize: `${size}px`, + blockSize: `${size}px`, + borderRadius: "10px", + position: "absolute", + ...customStyles, + display: "grid", + placeItems: "center", + })} @mouseover=${(event) => { + previousZIndex = event.target.style.zIndex; + event.target.style.zIndex = "100"; + }} @mouseout=${(event) => { + event.target.style.zIndex = previousZIndex; + }}> + ${layer} +
+ `; +}; diff --git a/.storybook/foundations/corner-rounding/action-button-corner-rounding.stories.js b/.storybook/foundations/corner-rounding/action-button-corner-rounding.stories.js new file mode 100644 index 00000000000..a3a50e1a905 --- /dev/null +++ b/.storybook/foundations/corner-rounding/action-button-corner-rounding.stories.js @@ -0,0 +1,101 @@ +import { Template } from "@spectrum-css/actionbutton/stories/template.js"; +import { html } from "lit"; + +export default { + title: "Corner rounding", + description: + "The action button component represents an action a user can take.", + component: "ActionButton", + args: { + rootClass: "spectrum-ActionButton", + }, + parameters: { + actions: { + handles: ["click .spectrum-ActionButton:not([disabled])"], + }, + }, + tags: ['!dev', 'migrated'], +}; + +const ActionButton = (args, context) => html` +
+ ${Template({ ...args, iconName: undefined }, context)} +
+`; + +const ActionButtonTable = (args, context) => { + return html` + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TokenValueMedium example
--spectrum-corner-radius-medium-size-extra-small6px + ${ActionButton({ + ...args, + label: "Extra Small", + size: "xs" + }, context)} +
--spectrum-corner-radius-medium-size-small7px + ${ActionButton({ + ...args, + label: "Small", + size: "s" + }, context)} +
--spectrum-corner-radius-medium-size-medium8px + ${ActionButton({ + ...args, + label: "Medium", + size: "m" + }, context)} +
--spectrum-corner-radius-medium-size-large9px + ${ActionButton({ + ...args, + label: "Large", + size: "l" + }, context)} +
--spectrum-corner-radius-medium-size-extra-large10px + ${ActionButton({ + ...args, + label: "Extra Large", + size: "xl" + }, context)} +
+ `; +}; + +export const ActionButtonExamples = ActionButtonTable.bind({}); +ActionButtonExamples.args = {}; +ActionButtonExamples.parameters = { + chromatic: { disableSnapshot: true }, +}; diff --git a/.storybook/foundations/corner-rounding/checkbox-corner-rounding.stories.js b/.storybook/foundations/corner-rounding/checkbox-corner-rounding.stories.js new file mode 100644 index 00000000000..baf059bebb9 --- /dev/null +++ b/.storybook/foundations/corner-rounding/checkbox-corner-rounding.stories.js @@ -0,0 +1,91 @@ +// Import the component markup template +import { Template } from "@spectrum-css/checkbox/stories/template.js"; +import { html } from "lit"; + +export default { + title: "Corner rounding", + description: + "Checkboxes allow users to select multiple items from a list of individual items, or mark one individual item as selected.", + component: "Checkbox", + args: { + rootClass: "spectrum-Checkbox", + }, + parameters: { + actions: { + handles: ['click input[type="checkbox"]'], + }, + }, + tags: ['!dev', 'migrated'], +}; + +const Checkbox = (args = {}, context = {}) => html` +
+ ${Template({ ...args, iconName: undefined }, context)} +
+`; + +const CheckboxTable = (args, context) => { + return html` + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TokenValueSmall example
--spectrum-corner-radius-small-size-small3px + ${Checkbox({ + ...args, + label: "Small", + size: "s" + }, context)} +
--spectrum-corner-radius-small-size-medium4px + ${Checkbox({ + ...args, + label: "Medium", + size: "m" + }, context)} +
--spectrum-corner-radius-small-size-large5px + ${Checkbox({ + ...args, + label: "Large", + size: "l" + }, context)} +
--spectrum-corner-radius-small-size-extra-large6px + ${Checkbox({ + ...args, + label: "Extra Large", + size: "xl" + }, context)} +
+ `; +} + +export const CheckboxExamples = CheckboxTable.bind({}); +CheckboxExamples.args = {}; +CheckboxExamples.parameters = { + chromatic: { disableSnapshot: true }, +}; diff --git a/.storybook/foundations/corner-rounding/component-size-tokens-medium.md b/.storybook/foundations/corner-rounding/component-size-tokens-medium.md new file mode 100644 index 00000000000..f2201667866 --- /dev/null +++ b/.storybook/foundations/corner-rounding/component-size-tokens-medium.md @@ -0,0 +1,7 @@ +| Component size token | Alias token (if available) | Global token | Value | +| ------------------------------------------------ | --------------------------------------- | ---------------------------- | ----- | +| --spectrum-corner-radius-medium-size-extra-small | | --spectrum-corner-radius-300 | 6px | +| --spectrum-corner-radius-medium-size-small | | --spectrum-corner-radius-400 | 7px | +| --spectrum-corner-radius-medium-size-medium | --spectrum-corner-radius-medium-default | --spectrum-corner-radius-500 | 8px | +| --spectrum-corner-radius-medium-size-large | | --spectrum-corner-radius-600 | 9px | +| --spectrum-corner-radius-medium-size-extra-large | --spectrum-corner-radius-large-default | --spectrum-corner-radius-700 | 10px | diff --git a/.storybook/foundations/corner-rounding/component-size-tokens-small.md b/.storybook/foundations/corner-rounding/component-size-tokens-small.md new file mode 100644 index 00000000000..1fdcae6ad6d --- /dev/null +++ b/.storybook/foundations/corner-rounding/component-size-tokens-small.md @@ -0,0 +1,6 @@ +| Component size token | Alias token (if available) | Global token | Value | +|---------------------------------------------------|-------------------------------|------------------------------|-------| +| --spectrum-corner-radius-small-size-small | | --spectrum-corner-radius-75 | 3px | +| --spectrum-corner-radius-small-size-medium | --spectrum-corner-radius-small-default | --spectrum-corner-radius-100 | 4px | +| --spectrum-corner-radius-small-size-large | | --spectrum-corner-radius-200 | 5px | +| --spectrum-corner-radius-small-size-extra-large | | --spectrum-corner-radius-300 | 6px | diff --git a/.storybook/foundations/corner-rounding/corner-rounding.mdx b/.storybook/foundations/corner-rounding/corner-rounding.mdx new file mode 100644 index 00000000000..0af56f6e446 --- /dev/null +++ b/.storybook/foundations/corner-rounding/corner-rounding.mdx @@ -0,0 +1,26 @@ +import { Meta, Canvas, Story, Title, Unstyled } from '@storybook/blocks'; +import * as CornerRoundingStories from './corner-rounding.stories.js'; +import * as CheckboxStories from './checkbox-corner-rounding.stories.js'; +import * as ActionButtonStories from './action-button-corner-rounding.stories.js'; + + + + + +## Default values + +<Story of={CornerRoundingStories.CornerRounding} /> + +## Component examples + +### Small tokens + +Checkbox includes small component size tokens to scale corner rounding. + +<Story of={CheckboxStories.CheckboxExamples} /> + +### Medium tokens + +Action button includes medium component size tokens to scale corner rounding. + +<Story of={ActionButtonStories.ActionButtonExamples} /> diff --git a/.storybook/foundations/corner-rounding/corner-rounding.stories.js b/.storybook/foundations/corner-rounding/corner-rounding.stories.js new file mode 100644 index 00000000000..c867a7d5de2 --- /dev/null +++ b/.storybook/foundations/corner-rounding/corner-rounding.stories.js @@ -0,0 +1,91 @@ +// Import the component markup template +import { html } from "lit"; +import { Template } from "./template.js"; + +export default { + title: "Corner rounding", + description: + "Corner rounding is a foundation that shows the different border-radius tokens that can be applied to a component.", + component: "Corner rounding", + args: { + rootClass: "spectrum-Foundations-Example-CornerRounding", + }, + tags: ["!dev", "migrated"], +}; + +const CornerRadiusGroup = (args = {}, context = {}) => html` + <div> + <table class="spectrum-Foundations-Example-CornerRounding-table"> + <thead> + <tr> + <th scope="col">Token</th> + <th scope="col" style="padding: 0 2rem;">Value</th> + <th scope="col">Example<br />(No Border)</th> + <th scope="col">Example<br />(Border)</th> + </tr> + </thead> + <tbody> + ${Template( + { + ...args, + label: "--spectrum-corner-radius-none", + size: "none", + value: "0px", + }, + context, + )} + ${Template( + { + ...args, + label: "--spectrum-corner-radius-small-default", + size: "s", + value: "4px", + }, + context, + )} + ${Template( + { + ...args, + label: "--spectrum-corner-radius-medium-default", + size: "m", + value: "8px", + }, + context, + )} + ${Template( + { + ...args, + label: "--spectrum-corner-radius-large-default", + size: "l", + value: "10px", + }, + context, + )} + ${Template( + { + ...args, + label: "--spectrum-corner-radius-extra-large-default", + size: "xl", + value: "16px", + }, + context, + )} + ${Template( + { + ...args, + label: "--spectrum-corner-radius-full", + size: "full", + value: "9999px", + }, + context, + )} + </tbody> + </table> + </div> +`; + +export const CornerRounding = CornerRadiusGroup.bind({}); +CornerRounding.args = {}; +CornerRounding.parameters = { + chromatic: { disableSnapshot: true }, +}; diff --git a/.storybook/foundations/corner-rounding/index.css b/.storybook/foundations/corner-rounding/index.css new file mode 100644 index 00000000000..d11cbe7823d --- /dev/null +++ b/.storybook/foundations/corner-rounding/index.css @@ -0,0 +1,57 @@ +/*! + * Copyright 2024 Adobe. All rights reserved. + * + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at <http://www.apache.org/licenses/LICENSE-2.0> + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ + +.spectrum-Foundations-Example-CornerRounding-table { + border-spacing: 1rem 0; + margin-inline-start: -1rem; +} + +.spectrum-Foundations-Example-CornerRounding-table th { + text-align: start; +} + +.spectrum-Foundations-Example-CornerRounding { + inline-size: 3rem; + block-size: 3rem; + margin: 0.5rem; + background-color: var(--spectrum-gray-500); +} + +.spectrum-Foundations-Example-CornerRounding--border { + background-color: var(--spectrum-gray-25); + border: var(--spectrum-border-width-200) solid var(--spectrum-gray-700); +} + +.spectrum-Foundations-Example-CornerRounding--none { + border-radius: var(--spectrum-corner-radius-none); +} + +.spectrum-Foundations-Example-CornerRounding--sizeS { + border-radius: var(--spectrum-corner-radius-small-default); +} + +.spectrum-Foundations-Example-CornerRounding--sizeM { + border-radius: var(--spectrum-corner-radius-medium-default); +} + +.spectrum-Foundations-Example-CornerRounding--sizeL { + border-radius: var(--spectrum-corner-radius-large-default); +} + +.spectrum-Foundations-Example-CornerRounding--sizeXL { + border-radius: var(--spectrum-corner-radius-extra-large-default); +} + +.spectrum-Foundations-Example-CornerRounding--full { + border-radius: var(--spectrum-corner-radius-full); +} diff --git a/.storybook/foundations/corner-rounding/template.js b/.storybook/foundations/corner-rounding/template.js new file mode 100644 index 00000000000..bd000575982 --- /dev/null +++ b/.storybook/foundations/corner-rounding/template.js @@ -0,0 +1,40 @@ +import { html } from "lit"; +import { classMap } from "lit/directives/class-map.js"; + +import "./index.css"; + +const getSizeModifier = (size) => { + if (size === "none" || size === "full") return size; + return `size${size.toUpperCase()}`; +}; + +export const Template = ({ + rootClass = "spectrum-Foundations-Example-CornerRounding", + size = "none", + label, + value, +}) => html` + <tr> + <td>${label}</td> + <td style="padding: 0 2rem;">${value}</td> + <td> + <div + class=${classMap({ + [rootClass]: true, + [`${rootClass}--${getSizeModifier(size)}`]: + typeof size !== "undefined", + })} + ></div> + </td> + <td> + <div + class=${classMap({ + [rootClass]: true, + [`${rootClass}--${getSizeModifier(size)}`]: + typeof size !== "undefined", + [`${rootClass}--border`]: true, + })} + ></div> + </td> + </tr> +`; diff --git a/.storybook/foundations/down-state/button-down-state.stories.js b/.storybook/foundations/down-state/button-down-state.stories.js new file mode 100644 index 00000000000..9af1aae2e4b --- /dev/null +++ b/.storybook/foundations/down-state/button-down-state.stories.js @@ -0,0 +1,30 @@ +import { Template } from "@spectrum-css/button/stories/template.js"; + +export default { + title: "Down state", + description: + "Buttons allow users to perform an action or to navigate to another page. They have multiple styles for various needs, and are ideal for calling attention to where a user needs to do something in order to move forward in a flow.", + component: "Button", + args: { + rootClass: "spectrum-Button", + }, + parameters: { + actions: { + handles: ["click .spectrum-Button"], + }, + }, + tags: ["!dev"], +}; + +export const ButtonDownState = Template.bind({}); +ButtonDownState.args = { + label: "Edit", + variant: "accent", + customStyles: { + "--spectrum-downstate-width": "72px", + "--spectrum-downstate-height": "32px" + } +}; +ButtonDownState.parameters = { + chromatic: { disableSnapshot: true }, +}; diff --git a/.storybook/foundations/down-state/checkbox-down-state.stories.js b/.storybook/foundations/down-state/checkbox-down-state.stories.js new file mode 100644 index 00000000000..0fee6f315d8 --- /dev/null +++ b/.storybook/foundations/down-state/checkbox-down-state.stories.js @@ -0,0 +1,25 @@ +import { Template } from "@spectrum-css/checkbox/stories/template.js"; + +export default { + title: "Down state", + description: + "Checkboxes allow users to select multiple items from a list of individual items, or mark one individual item as selected.", + component: "Checkbox", + args: { + rootClass: "spectrum-Checkbox", + }, + parameters: { + actions: { + handles: ["click input[type=\"checkbox\"]"], + }, + }, + tags: ["!dev"], +}; + +export const CheckboxDownState = Template.bind({}); +CheckboxDownState.args = { + label: "Checkbox", +}; +CheckboxDownState.parameters = { + chromatic: { disableSnapshot: true }, +}; diff --git a/.storybook/foundations/down-state/down-state.mdx b/.storybook/foundations/down-state/down-state.mdx new file mode 100644 index 00000000000..5933bff7604 --- /dev/null +++ b/.storybook/foundations/down-state/down-state.mdx @@ -0,0 +1,44 @@ +import { Meta, Story } from '@storybook/blocks'; +import * as Checkbox from './checkbox-down-state.stories.js'; +import * as Button from './button-down-state.stories.js'; + +<Meta title="Down state" /> + +# Down state + +Down state is a Spectrum 2 feature that creates the illusion of components being pressed-in when active. This functionality is already included in Spectrum 2 components that require down state in this project. It is implemented with a CSS transform. The implementation depends on the size of the interactable element, as shown in the examples below. + +## Examples + +### Minimum perspective + +For elements that have a width of 24px or less, the minimum perspective token is used to apply the down state. One example of a component that uses this token is the checkbox: + +<Story of={Checkbox.CheckboxDownState} /> + +In this case, we use the minimum perspective token: + +``` +transform: + perspective(var(--spectrum-component-size-minimum-perspective-down)) + translateZ(var(--spectrum-component-size-difference-down)); +``` + +### Calculated perspective + +For elements that have a width of greater than 24px, we need to use the component's width and height to apply the down state. One example of a component that uses this logic is the button: + +<Story of={Button.ButtonDownState} /> + +In this case, we use a max formula to calculate the perspective based on component width and height (this helps us account for components that may be very wide): + +``` +transform: + perspective(max( + var(--spectrum-downstate-height), + var(--spectrum-downstate-width) * var(--spectrum-component-size-width-ratio-down) + )) + translateZ(var(--spectrum-component-size-difference-down)); +``` + +*Note that in this case, users are required to develop an implementation to determine the width and height of the component. Assign these values to the `--spectrum-downstate-width` and `--spectrum-downstate-height` custom properties in a `style` attribute on the HTML element to expose them for use in the CSS.* diff --git a/.storybook/foundations/drop-shadow/drop-shadow.mdx b/.storybook/foundations/drop-shadow/drop-shadow.mdx new file mode 100644 index 00000000000..a8d6f298632 --- /dev/null +++ b/.storybook/foundations/drop-shadow/drop-shadow.mdx @@ -0,0 +1,86 @@ +import { Meta, Title, Story, Description } from '@storybook/blocks'; +import * as DropShadowStories from './drop-shadow.stories.js'; + + +<Meta of={DropShadowStories} /> + +<Title /> +<Description of={DropShadowStories} /> + +Drop shadow tokens may be used for box shadows or drop shadows in CSS. Using `box-shadow` is often preferable to using `filter: drop-shadow()`, but in situations where the shadow must be applied to the alpha channel of the content rather than the border box, or if `box-shadow` is already being used for a different purpose, such as a focus outline, `filter: drop-shadow()` may be used. Note that in cases where `filter: drop-shadow()` is used, the shadow may be more blurred than the design spec due to a difference in how the blur parameter is calculated, and an adjustment by half may be needed. + +The opacity values in dark shadow colors are 3x the light values. + +These single-layer shadows are an interim solution for shadows until complex tokens (additional design data for the Spectrum Tokens system) are available to support multi-layer shadows. + +## Emphasized Default +This shadow is used to provide emphasis to containers within a page. + +### `box-shadow` +<Story of={DropShadowStories.BoxShadowEmphasizedDefault} /> +``` +box-shadow: + var(--spectrum-drop-shadow-emphasized-default-x) + var(--spectrum-drop-shadow-emphasized-default-y) + var(--spectrum-drop-shadow-emphasized-default-blur) + var(--spectrum-drop-shadow-emphasized-default-color); +``` + +### `filter: drop-shadow()` +<Story of={DropShadowStories.DropShadowEmphasizedDefault} /> +``` +filter: drop-shadow( + var(--spectrum-drop-shadow-emphasized-default-x) + var(--spectrum-drop-shadow-emphasized-default-y) + calc(var(--spectrum-drop-shadow-emphasized-default-blur) / 2) + var(--spectrum-drop-shadow-emphasized-default-color) +); +``` + +## Emphasized Hover +If the whole container is interactive, such as in a select box, the shadow becomes elevated on hover. + +### `box-shadow` +<Story of={DropShadowStories.BoxShadowEmphasizedHover} /> +``` +box-shadow: + var(--spectrum-drop-shadow-emphasized-hover-x) + var(--spectrum-drop-shadow-emphasized-hover-y) + var(--spectrum-drop-shadow-emphasized-hover-blur) + var(--spectrum-drop-shadow-emphasized-hover-color); +``` + +### `filter: drop-shadow()` +<Story of={DropShadowStories.DropShadowEmphasizedHover} /> +``` +filter: drop-shadow( + var(--spectrum-drop-shadow-emphasized-hover-x) + var(--spectrum-drop-shadow-emphasized-hover-y) + calc(var(--spectrum-drop-shadow-emphasized-hover-blur) / 2) + var(--spectrum-drop-shadow-emphasized-hover-color) +); +``` + +## Elevated +Elevated shadows can be used on containers that appear on top of content, such as menus, coach marks, popovers, and floating bar panels. + +### `box-shadow` +<Story of={DropShadowStories.BoxShadowElevated} /> +``` +box-shadow: + var(--spectrum-drop-shadow-elevated-x) + var(--spectrum-drop-shadow-elevated-y) + var(--spectrum-drop-shadow-elevated-blur) + var(--spectrum-drop-shadow-elevated-color); +``` + +### `filter: drop-shadow()` +<Story of={DropShadowStories.DropShadowElevated} /> +``` +filter: drop-shadow( + var(--spectrum-drop-shadow-elevated-x) + var(--spectrum-drop-shadow-elevated-y) + calc(var(--spectrum-drop-shadow-elevated-blur) / 2) + var(--spectrum-drop-shadow-elevated-color) +); +``` diff --git a/.storybook/foundations/drop-shadow/drop-shadow.stories.js b/.storybook/foundations/drop-shadow/drop-shadow.stories.js new file mode 100644 index 00000000000..391031de906 --- /dev/null +++ b/.storybook/foundations/drop-shadow/drop-shadow.stories.js @@ -0,0 +1,107 @@ +import { html } from "lit"; +import { classMap } from "lit/directives/class-map.js"; +import "./index.css"; + +export default { + title: "Drop shadow", + description: + "Drop shadows draw attention and give the appearance of depth. By default, this style is used to show elevation, when content appears on top of other content.", + component: "Drop shadow", + tags: ["!dev"], +}; + +const DropShadowSwatch = ({ + rootClass = "spectrum-Foundations-Example-DropShadow-swatch", + variant, + isDropShadow, +}) => html` + <div + class=${classMap({ + [rootClass]: true, + [`${rootClass}--${variant}-drop-shadow`]: + typeof variant !== "undefined" && !!isDropShadow, + [`${rootClass}--${variant}-box-shadow`]: + typeof variant !== "undefined" && !isDropShadow, + })} + ></div> +`; + +const DropShadowBackground = ( + { + rootClass = "spectrum-Foundations-Example-swatch-container", + color, + ...args + }, + context, +) => html` + <div + class=${classMap({ + [rootClass]: true, + "spectrum--light": color === "light", + "spectrum--dark": color === "dark", + })} + > + ${DropShadowSwatch(args, context)} + </div> +`; + +const DropShadowVariant = (args, context) => html` + <div class="spectrum-Foundations-Example-variant-container"> + ${DropShadowBackground({ ...args, color: "light" }, context)} + ${DropShadowBackground({ ...args, color: "dark" }, context)} + </div> +`; + +export const DropShadowEmphasizedDefault = DropShadowVariant.bind({}); +DropShadowEmphasizedDefault.args = { + variant: "emphasized-default", + isDropShadow: true, +}; +DropShadowEmphasizedDefault.parameters = { + chromatic: { disableSnapshot: true }, +}; + +export const DropShadowEmphasizedHover = DropShadowVariant.bind({}); +DropShadowEmphasizedHover.args = { + variant: "emphasized-hover", + isDropShadow: true, +}; +DropShadowEmphasizedHover.parameters = { + chromatic: { disableSnapshot: true }, +}; + +export const DropShadowElevated = DropShadowVariant.bind({}); +DropShadowElevated.args = { + variant: "elevated", + isDropShadow: true, +}; +DropShadowElevated.parameters = { + chromatic: { disableSnapshot: true }, +}; + +export const BoxShadowEmphasizedDefault = DropShadowVariant.bind({}); +BoxShadowEmphasizedDefault.args = { + variant: "emphasized-default", + isDropShadow: false, +}; +BoxShadowEmphasizedDefault.parameters = { + chromatic: { disableSnapshot: true }, +}; + +export const BoxShadowEmphasizedHover = DropShadowVariant.bind({}); +BoxShadowEmphasizedHover.args = { + variant: "emphasized-hover", + isDropShadow: false, +}; +BoxShadowEmphasizedHover.parameters = { + chromatic: { disableSnapshot: true }, +}; + +export const BoxShadowElevated = DropShadowVariant.bind({}); +BoxShadowElevated.args = { + variant: "elevated", + isDropShadow: false, +}; +BoxShadowElevated.parameters = { + chromatic: { disableSnapshot: true }, +}; diff --git a/.storybook/foundations/drop-shadow/index.css b/.storybook/foundations/drop-shadow/index.css new file mode 100644 index 00000000000..bf54a5ddce9 --- /dev/null +++ b/.storybook/foundations/drop-shadow/index.css @@ -0,0 +1,115 @@ +/*! +Copyright 2024 Adobe. All rights reserved. +This file is licensed to you under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. You may obtain a copy +of the License at http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under +the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS +OF ANY KIND, either express or implied. See the License for the specific language +governing permissions and limitations under the License. +*/ + +/* stylelint-disable spectrum-tools/no-unknown-custom-properties */ + +.spectrum-Foundations-Example-DropShadow-swatch { + block-size: 150px; + inline-size: 150px; + background-color: var(--spectrum-gray-25); + border-radius: var(--spectrum-corner-radius-large-default); + border: transparent; +} + +.spectrum--dark .spectrum-Foundations-Example-DropShadow-swatch { + background-color: var(--spectrum-gray-75); /* matches dark mode design spec rgb(34, 34, 34) */ +} + +.spectrum-Foundations-Example-DropShadow-swatch--emphasized-default-box-shadow { + box-shadow: + var(--spectrum-drop-shadow-emphasized-default-x) + var(--spectrum-drop-shadow-emphasized-default-y) + var(--spectrum-drop-shadow-emphasized-default-blur) + var(--mod-drop-shadow-emphasized-default-color, var(--spectrum-drop-shadow-emphasized-default-color)); +} + +.spectrum-Foundations-Example-DropShadow-swatch--emphasized-default-drop-shadow { + filter: drop-shadow( + var(--spectrum-drop-shadow-emphasized-default-x) + var(--spectrum-drop-shadow-emphasized-default-y) + calc(var(--spectrum-drop-shadow-emphasized-default-blur) / 2) /* adjust blur by half of box-shadow */ + var(--mod-drop-shadow-emphasized-default-color, var(--spectrum-drop-shadow-emphasized-default-color)) + ); +} + +.spectrum--light .spectrum-Foundations-Example-DropShadow-swatch--emphasized-default-box-shadow, +.spectrum--dark .spectrum-Foundations-Example-DropShadow-swatch--emphasized-default-box-shadow, +.spectrum--light .spectrum-Foundations-Example-DropShadow-swatch--emphasized-default-drop-shadow, +.spectrum--dark .spectrum-Foundations-Example-DropShadow-swatch--emphasized-default-drop-shadow { +/* adjustment because color tokens do not work properly on foundations pages */ + --mod-drop-shadow-emphasized-default-color: var(--spectrum-drop-shadow-color-100); +} + +.spectrum-Foundations-Example-DropShadow-swatch--emphasized-hover-box-shadow { + box-shadow: + var(--spectrum-drop-shadow-emphasized-hover-x) + var(--spectrum-drop-shadow-emphasized-hover-y) + var(--spectrum-drop-shadow-emphasized-hover-blur) + var(--mod-drop-shadow-emphasized-hover-color, var(--spectrum-drop-shadow-emphasized-hover-color)); +} + +.spectrum-Foundations-Example-DropShadow-swatch--emphasized-hover-drop-shadow { + filter: drop-shadow( + var(--spectrum-drop-shadow-emphasized-hover-x) + var(--spectrum-drop-shadow-emphasized-hover-y) + calc(var(--spectrum-drop-shadow-emphasized-hover-blur) / 2) /* adjust blur by half of box-shadow */ + var(--mod-drop-shadow-emphasized-hover-color, var(--spectrum-drop-shadow-emphasized-hover-color)) + ); +} + +.spectrum--light .spectrum-Foundations-Example-DropShadow-swatch--emphasized-hover-drop-shadow, +.spectrum--dark .spectrum-Foundations-Example-DropShadow-swatch--emphasized-hover-drop-shadow, +.spectrum--light .spectrum-Foundations-Example-DropShadow-swatch--emphasized-hover-box-shadow, +.spectrum--dark .spectrum-Foundations-Example-DropShadow-swatch--emphasized-hover-box-shadow { +/* adjustment because color tokens do not work properly on foundations pages */ + --mod-drop-shadow-emphasized-hover-color: var(--spectrum-drop-shadow-color-200); +} + +.spectrum-Foundations-Example-DropShadow-swatch--elevated-box-shadow { + box-shadow: + var(--spectrum-drop-shadow-elevated-x) + var(--spectrum-drop-shadow-elevated-y) + var(--spectrum-drop-shadow-elevated-blur) + var(--mod-drop-shadow-elevated-color, var(--spectrum-drop-shadow-elevated-color)); +} + +.spectrum-Foundations-Example-DropShadow-swatch--elevated-drop-shadow { + filter: drop-shadow( + var(--spectrum-drop-shadow-elevated-x) + var(--spectrum-drop-shadow-elevated-y) + calc(var(--spectrum-drop-shadow-elevated-blur) / 2) /* adjust blur by half of box-shadow */ + var(--mod-drop-shadow-elevated-color, var(--spectrum-drop-shadow-elevated-color)) + ); +} + +.spectrum--light .spectrum-Foundations-Example-DropShadow-swatch--elevated-drop-shadow, +.spectrum--dark .spectrum-Foundations-Example-DropShadow-swatch--elevated-drop-shadow, +.spectrum--light .spectrum-Foundations-Example-DropShadow-swatch--elevated-box-shadow, +.spectrum--dark .spectrum-Foundations-Example-DropShadow-swatch--elevated-box-shadow { +/* adjustment because color tokens do not work properly on foundations pages */ + --mod-drop-shadow-elevated-color: var(--spectrum-drop-shadow-color-200); +} + +.spectrum-Foundations-Example-swatch-container { + background-color: var(--spectrum-gray-25); + block-size: 200px; + inline-size: 300px; + display: flex; + align-items: center; + justify-content: center; +} + +.spectrum-Foundations-Example-variant-container { + background-color: var(--spectrum-gray-25); + display: flex; + flex-direction: row; +} diff --git a/.storybook/guides/chromatic-testing.mdx b/.storybook/guides/chromatic-testing.mdx new file mode 100644 index 00000000000..881f9144cd1 --- /dev/null +++ b/.storybook/guides/chromatic-testing.mdx @@ -0,0 +1,79 @@ +import { Meta, Title } from "@storybook/blocks"; + +<Meta title="Visual regression testing" /> +<Title>Visual regression testing + +This guide explains how to run visual regression tests using Chromatic for the `spectrum-two` branch. + +## Prerequisites + +Before running tests in Chromatic, you must have: + +- Access to the Spectrum CSS project in Chromatic (request access from project maintainers) +- A valid `CHROMATIC_PROJECT_TOKEN` in your local `.env` file, do not commit this file to version control as it contains sensitive information + +## Set up your environment + +### Install dependencies + +From the project root, install all dependencies if you have not already done so: + +```bash +yarn install +``` + +### Configure Chromatic access + +Run `yarn refresh` to create or update your `.env` file with the necessary environment variables. Ensure the `CHROMATIC_PROJECT_TOKEN` is set correctly. + +```bash +CHROMATIC_PROJECT_TOKEN=your_project_token_here +``` + +**Note:** Never commit the `.env` file to version control as it contains sensitive information. + +Any global environment updates should be added to `.env.example`, which is used as a template. Tooling will always prefer your settings from `~/.env` if a variable exists there, but will fall back to the `.env.example` value otherwise. No other values from your local `.env` will be used unless it is explicitly set in `.env.example`. + +## Running manual tests + +### Basic test execution + +Because the base branch is not `main`, VRT builds are kicked off locally. This makes the build available in the Chromatic UI in order to create a manual review. To get an up-to-date comparison of your branch against the base branch, run the following command on the branch you are testing. + +```bash +yarn test +``` + +## Manual UI review + +Chromatic's [Manual UI review](https://www.chromatic.com/docs/manual-ui-review/) feature allows you to compare visual differences between any pair of branches. This is particularly useful for feature branches based off of `spectrum-two`. + +### Creating manual reviews + +1. **Create a review**: Navigate to the Reviews page and click "Create review" +2. **Select branches**: + - **Base branch**: The branch we are comparing against (`spectrum-two`) + - **Head branch**: The branch with changes (e.g., feature branch) +3. **Generate review**: Enter a title (be sure to include the Jira ticket number if available) and click "Compare branches" +4. **Post to the PR for review**: Copy the review URL and post it to the PR for validation + +## Getting help + +If you encounter issues not covered in this guide: + +1. **Chromatic documentation**: + - [Main documentation](https://www.chromatic.com/docs/) + - [Manual UI review](https://www.chromatic.com/docs/manual-ui-review/) for branch comparisons + - [Visual testing guide](https://www.chromatic.com/docs/visual/) for best practices +2. **Project resources**: + - Review existing test files in the project for examples + - Check the GitHub issues for known problems + - Contact the project maintainers for access and support +3. **Community support**: + - Chromatic's [Discord community](https://discord.gg/chromatic) + - [GitHub discussions](https://github.com/chromaui/chromatic/discussions) + +## Additional resources + +- [Chromatic CLI documentation](https://www.chromatic.com/docs/cli) +- [Storybook testing guide](https://storybook.js.org/docs/writing-tests) diff --git a/.storybook/guides/develop.mdx b/.storybook/guides/develop.mdx index d36ba09a9a7..24287b9f371 100644 --- a/.storybook/guides/develop.mdx +++ b/.storybook/guides/develop.mdx @@ -31,35 +31,24 @@ For more general information about how to contribute to the Spectrum CSS project Each component has the following files: -- `index.css` - The source file for all styles related to the component. This contains all selectors and css properties for the component but specifically lacks any custom properties or variables. These values are sourced from the `themes` directory. -- `themes/*.css` - The theme-specific, component-level custom properties used to style the component. These files are meant to be loaded with the source styles. +- `index.css` - The source file for all styles related to the component. This contains all selectors and css properties for the component. - `stories/*.stories.js` - The storybook file that defines the component's stories and the available knobs for the component. - `stories/template.js` - The template function that generates the component's mark-up based on the provided settings. - `stories/*.test.js` - The testing grid for visual regression testing in Chromatic. -- `stories/*.mdx` - This asset generates the component-specific documentation and is rendered in Storybook as the Docs page. Each component outputs the following assets to `dist`: -- `index.css`: This asset includes the base CSS and the `themes/spectrum.css` definitions (without the system mapping layer). This asset is meant to be used in a environment where only the current Spectrum theme is supported. -- `index-base.css`: This asset includes only the base CSS; that is, the CSS without any custom property definitions. This can be used in conjunction with `index-theme.css` and the desired `themes/*.css` file to render a themed component. -- `index-theme.css`: This asset includes only the custom property definitions for the component as mapped to the system variables. This can be used in conjunction with `index-base.css` and the desired `themes/*.css` file to render a themed component. - -Each component outputs theme-specific assets to `dist/themes`. These assets include the system variables mapped to their global token counterparts. This file is meant to be loaded in conjunction with the `index-base.css` and `index-theme.css` files to render a themed component. - -- `themes/spectrum-two.css`: Represents the current Spectrum theme, aka Spectrum 2. -- `themes/spectrum.css`: Represents the legacy Spectrum theme, aka Spectrum 1. **deprecated** -- `themes/express.css`: Represents the Express theme. **deprecated** +- `index.css`: This asset includes the CSS for the component and is meant to be loaded in conjunction with the tokens for your desired color context and scales. ## Adding a new component 1. Generate a new component using the `yarn new component` command. The generator will prompt you to answer questions about your component. 2. Edit the `dependencies` within the `package.json` file to use only the dependencies your component needs. All components rely on `@spectrum-css/tokens`, and most rely on `@spectrum-css/icon`. 3. Once your folder has been generated, you can run `yarn start` in the root of the project to begin developing. -4. The `index.css` file is where most of your styles will be added. Add any custom property mappings to the global token library in the `themes/spectrum.css` asset. -5. Inside the `stories` directory you will find a `template.js`, `*.stories.js`, and `*.mdx` file. +4. The `index.css` file is where all of your styles should be added. +5. Inside the `stories` directory you will find a `template.js` and `*.stories.js` file. - In the `*.stories.js` file, define the available knobs and properties for your component, as well as any standard variations you want to surface in [Storybook](https://storybook.js.org/docs/react/writing-stories/introduction). - Update the `template.js` file with the markup, using [lit-html syntax](https://lit.dev/docs/templates/overview/) to adjust results based on the provided settings from the Storybook knobs. - - Update the `*.mdx` file with the documentation for your component. _Note_: Because we use scoped packages, before it can be published, you must manually publish the new component as public: @@ -116,8 +105,6 @@ CSS assets will be run through their respective postcss configurations. This mea ```js import "../index.css"; -import "../themes/express.css"; -import "../themes/spectrum.css"; ``` We are leaning on Storybook's `@storybook/web-components-vite` framework configuration as our stories rely on lit for dynamic attribute assignment. @@ -345,8 +332,6 @@ import { ifDefined } from "lit/directives/if-defined.js"; import { when } from "lit/directives/when.js"; import "../index.css"; -import "../themes/express.css"; -import "../themes/spectrum.css"; export const Template = ( { diff --git a/.storybook/guides/s2_migration.mdx b/.storybook/guides/s2_migration.mdx index c94a30bf8ad..b8160320df2 100644 --- a/.storybook/guides/s2_migration.mdx +++ b/.storybook/guides/s2_migration.mdx @@ -13,6 +13,10 @@ import GrayMigrationGuide from "../assets/images/gray_migration-guide.png"; - Search within: Use a search field with a separate control to filter the search instead. - Split button: Use a button group to show any additional actions related to the most critical action. Reference [Spectrum documentation](https://spectrum.corp.adobe.com/page/button-group/#Use-a-button-group-to-show-additional-actions) for more information. +## Migrated components + +You can find a list of components that have been fully migrated to Spectrum 2 by filtering the components by the `migrated` tag. In the Storybook search field, click the filter button and select the `migrated` checkbox. The list of components should update to display only components that have been tagged as migrated. + ## Grays ({ - icons: { - workflow: { - medium: await import.meta.glob( - "/node_modules/@adobe/spectrum-css-workflow-icons/dist/18/*.svg", +import { cleanUiIconName, cleanWorkflowIconName } from "@spectrum-css/icon/stories/utilities.js"; + +/** + * Loads all SVG files from both icon sets, and stores a string with the SVG markup. + * + * Excludes "22x20" workflow icons as they are not yet used within the design system. + * + * @see https://storybook.js.org/docs/writing-stories/loaders + * @see https://vite.dev/guide/features#glob-import + */ +export const IconLoader = async () => { + let iconData = { + icons: { + workflow: await import.meta.glob( + [ + "/node_modules/@adobe/spectrum-css-workflow-icons/dist/assets/svg/*.svg", + "!/node_modules/@adobe/spectrum-css-workflow-icons/dist/assets/svg/*_22x20*.svg", + ], { eager: true, query: "?raw", import: "default", } ), - large: await import.meta.glob( - "/node_modules/@adobe/spectrum-css-workflow-icons/dist/24/*.svg", + ui: await import.meta.glob( + "/node_modules/@spectrum-css/ui-icons/dist/svg/*.svg", { eager: true, query: "?raw", @@ -18,23 +31,25 @@ export const IconLoader = async () => ({ } ), }, - ui: { - medium: await import.meta.glob( - "/node_modules/@spectrum-css/ui-icons/dist/medium/*.svg", - { - eager: true, - query: "?raw", - import: "default", - } - ), - large: await import.meta.glob( - "/node_modules/@spectrum-css/ui-icons/dist/large/*.svg", - { - eager: true, - query: "?raw", - import: "default", - } - ), - }, - }, -}); + }; + + /** + * Changes all keys in the IconLoader object to be just the cleaned icon name used within our Storybook's Icon component, + * instead of the full file name and directory that was loaded. + * + * E.g. "/node_modules/@adobe/spectrum-css-workflow-icons/dist/assets/svg/S2_Icon_3DAsset_20_N.svg" would become just "3DAsset". + */ + iconData.icons.workflow = Object.fromEntries( + Object.entries(iconData.icons.workflow).map( + ([key, value]) => [cleanWorkflowIconName(key.split("/").pop()), value] + ) + ); + + iconData.icons.ui = Object.fromEntries( + Object.entries(iconData.icons.ui).map( + ([key, value]) => [cleanUiIconName(key.split("/").pop()), value] + ) + ); + + return iconData; +}; diff --git a/.storybook/main.js b/.storybook/main.js index ccd00e2f45e..5914dd5b083 100644 --- a/.storybook/main.js +++ b/.storybook/main.js @@ -20,6 +20,11 @@ export default { files: "*.@(stories.js|mdx)", titlePrefix: "Guides", }, + { + directory: "./foundations", + files: "**/*.@(stories.js|mdx)", + titlePrefix: "Foundations", + }, { directory: "./deprecated", files: "**/*.@(stories.js|mdx)", @@ -85,6 +90,7 @@ export default { const { mergeConfig } = await import("vite"); return mergeConfig(config, { + base: process.env.BASE_PATH || config.base, publicDir: "./assets", // Add dependencies to pre-optimization optimizeDeps: { @@ -138,8 +144,6 @@ export default { check: false, }, features: { - /* Code splitting flag; load stories on-demand */ - storyStoreV7: true, /* Builds stories.json to help with on-demand loading */ buildStoriesJson: true, }, diff --git a/.storybook/manager.js b/.storybook/manager.js index 53b86a56602..1e1fe3ef8d1 100644 --- a/.storybook/manager.js +++ b/.storybook/manager.js @@ -1,5 +1,6 @@ import { addons } from "@storybook/manager-api"; import { create } from "@storybook/theming"; +import { startCase } from "lodash"; import "./assets/index.css"; @@ -64,5 +65,6 @@ addons.setConfig({ }), sidebar: { showRoots: false, + renderLabel: ({ name, type }) => (type === 'story' ? name : startCase(name)) + " 📚", }, }); diff --git a/.storybook/modes/index.js b/.storybook/modes/index.js index c3b991e5bd7..b4df304251d 100644 --- a/.storybook/modes/index.js +++ b/.storybook/modes/index.js @@ -20,16 +20,6 @@ const modes = { color: "dark", textDirection: "rtl", }, - "S1 | Light | LTR": { - context: "legacy", - color: "light", - textDirection: "ltr", - }, - "Express | Light | LTR": { - context: "express", - color: "light", - textDirection: "ltr", - }, }; export default modes; diff --git a/.storybook/package.json b/.storybook/package.json index 19e6ccd6220..7241855e3b4 100644 --- a/.storybook/package.json +++ b/.storybook/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/preview", - "version": "12.0.5", + "version": "12.1.0-next.21", "description": "A Spectrum CSS preview", "license": "Apache-2.0", "author": "Adobe", @@ -39,14 +39,13 @@ "build": "yarn docs:report && cross-env NODE_ENV=development storybook build --stats-json --config-dir ." }, "dependencies": { - "@adobe/spectrum-css-workflow-icons": "1.7.0", - "@spectrum-css/bundle": "1.0.1", - "@spectrum-css/tokens": "16.0.2", - "@spectrum-css/tokens-legacy": "npm:@spectrum-css/tokens@^15.2.0", - "@spectrum-css/ui-icons": "1.1.2" + "@adobe/spectrum-css-workflow-icons": "5.0.0", + "@spectrum-css/bundle": "2.0.0-next.17", + "@spectrum-css/tokens": "16.1.0-next.10", + "@spectrum-css/ui-icons": "2.0.0-next.2" }, "devDependencies": { - "@babel/core": "7.28.4", + "@babel/core": "7.28.5", "@chromatic-com/storybook": "3.2.7", "@etchteam/storybook-addon-status": "5.0.0", "@storybook/addon-a11y": "8.4.7", @@ -61,22 +60,21 @@ "@storybook/core-events": "8.4.7", "@storybook/manager-api": "8.4.7", "@storybook/preview-api": "8.4.7", - "@storybook/test-runner": "0.22.0", "@storybook/theming": "8.4.7", "@storybook/web-components-vite": "8.4.7", - "@whitespace/storybook-addon-html": "7.0.0", - "chromatic": "13.2.0", + "@whitespace/storybook-addon-html": "8.0.2", + "chromatic": "13.3.1", "lit": "3.3.1", "lodash-es": "4.17.21", "npm-registry-fetch": "19.0.0", "postcss": "8.5.6", "prettier": "3.6.2", - "react": "18.3.1", - "react-dom": "18.3.1", + "react": "19.2.0", + "react-dom": "19.2.0", "react-syntax-highlighter": "15.6.6", "remark-gfm": "4.0.1", - "storybook": "8.4.7", - "vite": "5.4.20" + "storybook": "8.6.14", + "vite": "7.1.12" }, "keywords": [ "design-system", diff --git a/.storybook/preview.js b/.storybook/preview.js index ff243044967..e9be0e5c367 100644 --- a/.storybook/preview.js +++ b/.storybook/preview.js @@ -32,6 +32,8 @@ export const parameters = { order: [ "Guides", ["Contributing", "*", "Adobe Code of Conduct", "Changelog"], + "Foundations", + ["*"], "Components", ["*", ["Docs", "Default", "*"]], "Deprecated", @@ -83,12 +85,17 @@ export const parameters = { color: "#fff", description: "Should not be used and will not receive updates.", }, + migrated: { + background: "rgb(84, 36, 219)", + color: "#fff", + description: "Migrated to Spectrum 2.", + }, }, }, // Set an empty object to avoid the "undefined" value in the ComponentDetails doc block packageJson: {}, // A list of published npm tags that should not appear in the ComponentDetails doc block - ignoredTags: ["beta", "next"], + ignoredTags: ["beta"], }; export default { diff --git a/.storybook/types/global.js b/.storybook/types/global.js index 60a369079e5..55f8c760e4d 100644 --- a/.storybook/types/global.js +++ b/.storybook/types/global.js @@ -4,22 +4,6 @@ /** @type import('@storybook/types').GlobalTypes */ export default { - context: { - title: "Design context", - description: "The variation of Spectrum to use in the component", - defaultValue: "spectrum", - type: "string", - showName: true, - toolbar: { - items: [ - { value: "spectrum", title: "Spectrum 2", right: "default" }, - { value: "legacy", title: "Spectrum 1", right: "legacy" }, - { value: "express", title: "Express", right: "legacy" }, - { value: "raw", title: "Token-free", right: "raw" }, - ], - dynamicTitle: true, - }, - }, color: { title: "Color", description: "Controls the color context of the component", @@ -30,7 +14,6 @@ export default { items: [ { value: "light", title: "Light", right: "default" }, { value: "dark", title: "Dark" }, - { value: "darkest", title: "Darkest", right: "deprecated" }, ], dynamicTitle: true, }, diff --git a/.stylelintignore b/.stylelintignore index 5956478781e..e9f7e6552c2 100644 --- a/.stylelintignore +++ b/.stylelintignore @@ -6,7 +6,7 @@ generator dist .storybook/storybook-static *-generated.css -tools/bundle/src/*.css +bundle/src/*.css node_modules/**/*.css diff --git a/.vscode/extensions.json b/.vscode/extensions.json index c2e4659a232..a31c90a2101 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -20,6 +20,7 @@ "rajdeepchandra.spectrum-design-tokens-for-vscode", "stylelint.vscode-stylelint", "vunguyentuan.vscode-css-variables", - "vunguyentuan.vscode-postcss" + "vunguyentuan.vscode-postcss", + "davidanson.vscode-markdownlint" ] } diff --git a/.vscode/settings.json b/.vscode/settings.json index 3fbd617ce55..b37a89b532f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -101,10 +101,8 @@ } ], "cssVariables.lookupFiles": [ - "${workspaceFolder}/tokens/dist/css/index.css", - "${workspaceFolder}/tokens/dist/css/*.css", - "${workspaceFolder}/components/*/index.css", - "${workspaceFolder}/components/*/themes/*.css" + "${workspaceFolder}/tokens/**/*.css", + "${workspaceFolder}/components/*/index.css" ], "docthis.includeDescriptionTag": true, "docthis.inferTypesFromNames": true, diff --git a/README.md b/README.md index 460f5d39631..e48f2231038 100644 --- a/README.md +++ b/README.md @@ -52,17 +52,6 @@ Spectrum CSS components have build output that is designed to be used in a varie - `index.css` - _Preferred and most commonly used to incorporate Spectrum CSS into a project_. This file includes the component's styles and variable definitions. In this version, token-driven CSS properties[1](#token-footnote) are mapped to empty `--mod` prefixed variables (for customization) with a fallback to variables prefixed with `--spectrum` (sourced from the design tokens). - - This file loads the `.spectrum`, `.spectrum--legacy`, and `.spectrum--express` contexts which are used to toggle components between different [visual styles](https://github.com/adobe/spectrum-css?tab=readme-ov-file#visual-language). The `.spectrum` context is the default. - -- `index-base.css`: This file mimics the `index.css` output, but does not include the `.spectrum` or `.spectrum--express` contexts. - - - If your product only requires the `.spectrum` context, you can use `index-base.css` plus `themes/spectrum-two.css` from the `themes` directory to render the default Spectrum visual language. - - The `.spectrum--legacy` context represents the previous version of Spectrum (also known as Spectrum 1). This means if you only want to use the legacy context, you should load `themes/spectrum.css`. **deprecated** - - The `.spectrum--express` context represents the subtheme of Spectrum 1 called Express . This means if you only want to use the Express context, you should load `themes/express.css`. **deprecated** - - This approach can also be used when you have defined and written your own visual language and only need the base component styles from Spectrum CSS. To wire up your own visual language, you would need to define your own custom properties that match those defined in the `themes/spectrum-two.css` assets. - -- `index-theme.css`: This file provides only the visual language for a component. It is used in conjunction with `index-base.css` and when loaded together, provides the same result as using `index.css` by itself. - 1: Token-driven CSS properties are properties whose values are mapped to a value in the `@spectrum-css/tokens` package. These values represent design-language and are meant to be used across platforms. In contrast, properties specific to web-based implementations will not have a token value assigned, so not all CSS properties will use custom properties. #### Including assets @@ -73,29 +62,10 @@ Start by including the base set of variables: /* Include tokens */ @import "node_modules/@spectrum-css/tokens/dist/index.css"; -/* - For components with no other contexts available, load the - index.css file from the component's package. These are components - that do not have a spectrum or express context available. -*/ @import "node_modules/@spectrum-css/page/dist/index.css"; @import "node_modules/@spectrum-css/typography/dist/index.css"; @import "node_modules/@spectrum-css/icon/dist/index.css"; - -/* - Recommended: For components with multiple contexts available, if you - want access to all contexts, load the index.css file, which includes - all contexts and component variables. -*/ @import "node_modules/@spectrum-css/button/dist/index.css"; - -/* - If you only need the spectrum visual context: For components with - multiple contexts available, load only the spectrum context by sourcing - index-base.css and the spectrum theme from the themes directory. -*/ -@import "node_modules/@spectrum-css/button/dist/index-base.css"; -@import "node_modules/@spectrum-css/button/dist/themes/spectrum.css"; ``` Tokens values are mapped to context-specific classes which can be applied to the `` element or any place in your DOM where you wish to encapsulate or alter the visual language of your Spectrum components. @@ -106,9 +76,7 @@ All contexts you want to use must be defined in order to load all the appropriat ##### Visual language -- `.spectrum` - The default visual language for Spectrum CSS; represents the Spectrum 2 foundations visual language. -- `.spectrum--legacy` - The legacy Spectrum 1 visual language. _This visual language will be deprecated in Spectrum 2_. -- `.spectrum--express` - A variant of the standard visual language. _This visual language will be deprecated in Spectrum 2_. +- `.spectrum` - The default visual language for Spectrum CSS; represents the Spectrum 2 visual language. ##### Scales @@ -134,16 +102,6 @@ Put together, we would define the context for our application in the following w ``` -To switch to Express, **add** the `.spectrum--express` class to the `` element: - -```html - -``` - -Note the `spectrum--legacy` or `spectrum--express` class is added to the existing classes; `spectrum` should always be present to ensure the correct visual language is loaded. - Because CSS custom properties honor the cascading nature of CSS, you can infinitely nest different contexts. For example, you could have a `.spectrum--dark` context inside of a `.spectrum--light` context, and components will honor the innermost context. ### Modifying components diff --git a/bundle/CHANGELOG.md b/bundle/CHANGELOG.md new file mode 100644 index 00000000000..699e77f08f7 --- /dev/null +++ b/bundle/CHANGELOG.md @@ -0,0 +1,217 @@ +# Change Log + +## 2.0.0-next.17 + +### Patch Changes + +Updated dependencies [[`082862e`](https://github.com/adobe/spectrum-css/commit/082862eb80c6e0ac1c801b1d538e4d2f2bb919b4)]: + +- @spectrum-css/actionmenu@8.0.0-next.2 +- @spectrum-css/actionbutton@8.0.0-next.4 +- @spectrum-css/menu@10.0.0-next.6 +- @spectrum-css/actiongroup@7.0.0-next.3 + +## 2.0.0-next.16 + +### Patch Changes + +Updated dependencies [[`9629fe3`](https://github.com/adobe/spectrum-css/commit/9629fe37cad996d47c827a3eabcdf39092a27b0d)]: + +- @spectrum-css/accordion@8.0.0-next.5 +- @spectrum-css/actionbar@11.0.0-next.3 +- @spectrum-css/actiongroup@7.0.0-next.2 + +## 2.0.0-next.15 + +### Patch Changes + +Updated dependencies [[`ff1d0c8`](https://github.com/adobe/spectrum-css/commit/ff1d0c8d156305e2291b5519320d7069e0d7f68f)]: + +- @spectrum-css/tokens@16.1.0-next.10 + +## 2.0.0-next.14 + +### Patch Changes + +Updated dependencies [[`eb23c3b`](https://github.com/adobe/spectrum-css/commit/eb23c3b2acc5e39684319b2fd46990c2e76add0c)]: + +- @spectrum-css/tokens@16.1.0-next.9 + +## 2.0.0-next.13 + +### Patch Changes + +Updated dependencies [[`1895ddb`](https://github.com/adobe/spectrum-css/commit/1895ddbe962989c8813cb1bf41f8bb0425b67e76)]: + +- @spectrum-css/popover@9.0.0-next.5 + +## 2.0.0-next.12 + +### Patch Changes + +Updated dependencies [[`6d835ff`](https://github.com/adobe/spectrum-css/commit/6d835ffeb77bc27bd5b2e4ddf48e2f5aa157a56b)]: + +- @spectrum-css/accordion@8.0.0-next.4 + +## 2.0.0-next.11 + +### Patch Changes + +Updated dependencies [[`7061eee`](https://github.com/adobe/spectrum-css/commit/7061eee2ada0b64bb68e37f93329c57e8dba4586), [`7061eee`](https://github.com/adobe/spectrum-css/commit/7061eee2ada0b64bb68e37f93329c57e8dba4586), [`7ac2952`](https://github.com/adobe/spectrum-css/commit/7ac2952d16e9760121e3a33390d14f6e336d587d), [`e467fe0`](https://github.com/adobe/spectrum-css/commit/e467fe00cfef00311b77ec4b32c6ab1791b6923a)]: + +- @spectrum-css/pickerbutton@7.0.0-next.2 +- @spectrum-css/infieldbutton@7.0.0-next.3 +- @spectrum-css/picker@10.0.0-next.4 +- @spectrum-css/search@9.0.0-next.3 + +## 2.0.0-next.10 + +### Patch Changes + +Updated dependencies [[`5b694c5`](https://github.com/adobe/spectrum-css/commit/5b694c58be813fd82315252dab721e94bf769a71)]: + +- @spectrum-css/tokens@16.1.0-next.8 + +## 2.0.0-next.9 + +### Patch Changes + +Updated dependencies [[`cf4fc1a`](https://github.com/adobe/spectrum-css/commit/cf4fc1a01d23ba810f45a903ecc29a5c8aae33d1)]: + +- @spectrum-css/coachindicator@5.0.0-next.1 +- @spectrum-css/alertbanner@4.0.0-next.3 +- @spectrum-css/colorhandle@11.0.0-next.2 +- @spectrum-css/colorslider@9.0.0-next.3 +- @spectrum-css/inlinealert@11.0.0-next.3 +- @spectrum-css/breadcrumb@12.0.0-next.3 +- @spectrum-css/colorwheel@7.0.0-next.4 +- @spectrum-css/datepicker@5.0.0-next.2 +- @spectrum-css/assetcard@6.0.0-next.2 +- @spectrum-css/thumbnail@9.0.0-next.1 +- @spectrum-css/calendar@8.0.0-next.3 +- @spectrum-css/combobox@5.0.0-next.4 +- @spectrum-css/dropzone@9.0.0-next.4 +- @spectrum-css/treeview@13.0.0-next.3 +- @spectrum-css/underlay@7.0.0-next.1 +- @spectrum-css/sidenav@8.0.0-next.3 +- @spectrum-css/stepper@8.0.0-next.3 +- @spectrum-css/card@12.0.0-next.3 +- @spectrum-css/dial@6.0.0-next.1 +- @spectrum-css/page@10.0.0-next.1 +- @spectrum-css/well@8.0.0-next.1 + +## 2.0.0-next.8 + +### Patch Changes + +Updated dependencies [[`d831bd0`](https://github.com/adobe/spectrum-css/commit/d831bd09e3a32cb0245692d73a4272101d5a0b88)]: + +- @spectrum-css/menu@10.0.0-next.5 + +## 2.0.0-next.7 + +### Patch Changes + +Updated dependencies [[`8a39697`](https://github.com/adobe/spectrum-css/commit/8a3969751718d45ff1a4a0656e842cf490a8da94)]: + +- @spectrum-css/slider@7.0.0-next.4 + +## 2.0.0-next.6 + +### Patch Changes + +Updated dependencies [[`7f48b7c`](https://github.com/adobe/spectrum-css/commit/7f48b7c6384f8c7d598637226a17aff1c8e8b61c), [`7f48b7c`](https://github.com/adobe/spectrum-css/commit/7f48b7c6384f8c7d598637226a17aff1c8e8b61c), [`35c066b`](https://github.com/adobe/spectrum-css/commit/35c066b29c311b1bfcf4507075f13b41222ffc84), [`dc5f820`](https://github.com/adobe/spectrum-css/commit/dc5f8202a330910c0af51b7c172aca35ec99a1e7)]: + +- @spectrum-css/tabs@7.0.0-next.2 +- @spectrum-css/tokens@16.1.0-next.7 +- @spectrum-css/actionbutton@8.0.0-next.3 +- @spectrum-css/colorslider@9.0.0-next.2 +- @spectrum-css/progressbar@7.0.0-next.4 +- @spectrum-css/breadcrumb@12.0.0-next.2 +- @spectrum-css/colorloupe@8.0.0-next.1 +- @spectrum-css/colorwheel@7.0.0-next.3 +- @spectrum-css/pagination@11.0.0-next.2 +- @spectrum-css/accordion@8.0.0-next.3 +- @spectrum-css/assetlist@9.0.0-next.2 +- @spectrum-css/colorarea@8.0.0-next.2 +- @spectrum-css/calendar@8.0.0-next.2 +- @spectrum-css/combobox@5.0.0-next.3 +- @spectrum-css/steplist@8.0.0-next.2 +- @spectrum-css/treeview@13.0.0-next.2 +- @spectrum-css/popover@9.0.0-next.4 +- @spectrum-css/tooltip@8.0.0-next.4 +- @spectrum-css/slider@7.0.0-next.3 +- @spectrum-css/switch@7.0.0-next.2 +- @spectrum-css/radio@11.0.0-next.3 +- @spectrum-css/table@9.0.0-next.4 +- @spectrum-css/menu@10.0.0-next.4 + +## 2.0.0-next.5 + +### Patch Changes + +Updated dependencies [[`b1166bd`](https://github.com/adobe/spectrum-css/commit/b1166bd9e4542b3a665cc95498011a633c56e72a), [`86dd51d`](https://github.com/adobe/spectrum-css/commit/86dd51d884878a3090cb8463ca0bf44f21ee9f87), [`f6843c6`](https://github.com/adobe/spectrum-css/commit/f6843c698a2aac7c15ba949e28c56e4ff49c8c4a), [`61f3c04`](https://github.com/adobe/spectrum-css/commit/61f3c04a4211f19be2c5db883653fb25309a39ea), [`08b3345`](https://github.com/adobe/spectrum-css/commit/08b33457975293c07b5c7d2f60a305f5fd8be77e), [`0242f7f`](https://github.com/adobe/spectrum-css/commit/0242f7f69ec24ef6c6f000324a7b44106e4603fa), [`f654c8d`](https://github.com/adobe/spectrum-css/commit/f654c8d950e6a1f0a77ce0f2413cb205a3b5e276), [`88948bf`](https://github.com/adobe/spectrum-css/commit/88948bf722acde7176716879968cb2f1f0fdb5e1), [`18c69aa`](https://github.com/adobe/spectrum-css/commit/18c69aa52f6e598aecd67d2b5e7dd945473402e6), [`75e847f`](https://github.com/adobe/spectrum-css/commit/75e847f1ae38a889b43888b3ac19505aadb4e24d)]: + +- @spectrum-css/sidenav@8.0.0-next.2 +- @spectrum-css/tooltip@8.0.0-next.3 +- @spectrum-css/icon@10.0.0-next.3 +- @spectrum-css/tokens@16.1.0-next.6 +- @spectrum-css/popover@9.0.0-next.3 +- @spectrum-css/contextualhelp@6.0.0-next.3 +- @spectrum-css/clearbutton@8.0.0-next.2 +- @spectrum-css/dialog@13.0.0-next.4 +- @spectrum-css/taggroup@8.0.0-next.2 +- @spectrum-css/meter@2.0.0-next.3 +- @spectrum-css/progressbar@7.0.0-next.3 + +## 2.0.0-next.4 + +### Patch Changes + +- Updated dependencies [[`d952e0c`](https://github.com/adobe/spectrum-css/commit/d952e0c4d234f5e742432fe906965a52a50b228e)]: + - @spectrum-css/tokens@16.1.0-next.5 + +## 2.0.0-next.3 + +### Patch Changes + +- Updated dependencies [[`f0c6273`](https://github.com/adobe/spectrum-css/commit/f0c6273310a8a7d8f392d6113919a3982ab07b2e), [`f20e1e7`](https://github.com/adobe/spectrum-css/commit/f20e1e7ff402b591706cc791d9207fdedb80cd1e), [`f20e1e7`](https://github.com/adobe/spectrum-css/commit/f20e1e7ff402b591706cc791d9207fdedb80cd1e)]: + - @spectrum-css/accordion@8.0.0-next.2 + - @spectrum-css/tokens@16.1.0-next.4 + - @spectrum-css/table@9.0.0-next.3 + +## 2.0.0-next.2 + +### Patch Changes + +- Updated dependencies [[`7971c77`](https://github.com/adobe/spectrum-css/commit/7971c7728b88e5e539b9d0974ab805d9ef6338fd)]: + - @spectrum-css/progressbar@7.0.0-next.2 + - @spectrum-css/meter@2.0.0-next.2 + +## 2.0.0-next.1 + +### Major Changes + +- Updated picker and table changes brought into the released bundle. + +## 2.0.0-next.0 + +### Major Changes + +- Release bundle with the latest styles on the S2 feature branch. + +## 1.0.1 + +### Patch Changes + +📝 [#3527](https://github.com/adobe/spectrum-css/pull/3527) [`5f1751c`](https://github.com/adobe/spectrum-css/commit/5f1751c82a5fe55ae0d999f5f50cfeca4c8a5c75) Thanks [@castastrophe](https://github.com/castastrophe)! + +- Minor dependency updates to align with the larger project. + +## 1.0.0 + +### Major Changes + +📝 [#3477](https://github.com/adobe/spectrum-css/pull/3477) [`d52c701`](https://github.com/adobe/spectrum-css/commit/d52c70196bf2d17433c239313a82f00f75d77e79) Thanks [@castastrophe](https://github.com/castastrophe)! + +- Resurrecting the CSS bundle for development use. Excellent resource for generating quick demo pages by loading all the CSS components in the library in a pre-bundled package with tokens pre-loaded and minified to remove unused tokens. diff --git a/tools/bundle/README.md b/bundle/README.md similarity index 100% rename from tools/bundle/README.md rename to bundle/README.md diff --git a/bundle/package.json b/bundle/package.json new file mode 100644 index 00000000000..8b07d2985a2 --- /dev/null +++ b/bundle/package.json @@ -0,0 +1,131 @@ +{ + "name": "@spectrum-css/bundle", + "version": "2.0.0-next.17", + "description": "A demo-ready bundle of the components in the Spectrum CSS library.", + "license": "Apache-2.0", + "author": "Adobe", + "contributors": [ + "Larry Davis ", + "Garth Braithwaite (https://garthdb.com)", + "Steve Gill ", + "Cassondra Roberts (https://allons-y.llc)" + ], + "homepage": "https://opensource.adobe.com/spectrum-css/", + "repository": { + "type": "git", + "url": "https://github.com/adobe/spectrum-css.git", + "directory": "bundle" + }, + "bugs": { + "url": "https://github.com/adobe/spectrum-css/issues" + }, + "type": "module", + "exports": { + ".": "./dist/index.css", + "./*.md": "./*.md", + "./dist/*": "./dist/*", + "./index.css": "./dist/index.css", + "./package.json": "./package.json", + "./src/*": "./src/*" + }, + "main": "dist/index.css", + "dependencies": { + "@spectrum-css/accordion": "8.0.0-next.5", + "@spectrum-css/actionbar": "11.0.0-next.3", + "@spectrum-css/actionbutton": "8.0.0-next.4", + "@spectrum-css/actiongroup": "7.0.0-next.3", + "@spectrum-css/actionmenu": "8.0.0-next.2", + "@spectrum-css/alertbanner": "4.0.0-next.3", + "@spectrum-css/alertdialog": "5.0.0-next.4", + "@spectrum-css/asset": "8.0.0-next.0", + "@spectrum-css/assetcard": "6.0.0-next.2", + "@spectrum-css/assetlist": "9.0.0-next.2", + "@spectrum-css/avatar": "10.0.0-next.0", + "@spectrum-css/badge": "7.0.0-next.2", + "@spectrum-css/breadcrumb": "12.0.0-next.3", + "@spectrum-css/button": "15.0.0-next.2", + "@spectrum-css/buttongroup": "10.0.0-next.1", + "@spectrum-css/calendar": "8.0.0-next.3", + "@spectrum-css/card": "12.0.0-next.3", + "@spectrum-css/checkbox": "11.0.0-next.2", + "@spectrum-css/clearbutton": "8.0.0-next.2", + "@spectrum-css/closebutton": "7.0.0-next.1", + "@spectrum-css/coachindicator": "5.0.0-next.1", + "@spectrum-css/coachmark": "10.0.0-next.1", + "@spectrum-css/colorarea": "8.0.0-next.2", + "@spectrum-css/colorhandle": "11.0.0-next.2", + "@spectrum-css/colorloupe": "8.0.0-next.1", + "@spectrum-css/colorslider": "9.0.0-next.3", + "@spectrum-css/colorwheel": "7.0.0-next.4", + "@spectrum-css/combobox": "5.0.0-next.4", + "@spectrum-css/contextualhelp": "6.0.0-next.3", + "@spectrum-css/datepicker": "5.0.0-next.2", + "@spectrum-css/dial": "6.0.0-next.1", + "@spectrum-css/dialog": "13.0.0-next.4", + "@spectrum-css/divider": "6.0.0-next.1", + "@spectrum-css/dropindicator": "8.0.0-next.1", + "@spectrum-css/dropzone": "9.0.0-next.4", + "@spectrum-css/fieldgroup": "8.0.0-next.1", + "@spectrum-css/fieldlabel": "11.0.0-next.2", + "@spectrum-css/floatingactionbutton": "5.0.0-next.1", + "@spectrum-css/form": "2.0.0-next.0", + "@spectrum-css/helptext": "8.0.0-next.2", + "@spectrum-css/icon": "10.0.0-next.3", + "@spectrum-css/illustratedmessage": "10.0.0-next.0", + "@spectrum-css/infieldbutton": "7.0.0-next.3", + "@spectrum-css/inlinealert": "11.0.0-next.3", + "@spectrum-css/link": "8.0.0-next.2", + "@spectrum-css/logicbutton": "7.0.0-next.1", + "@spectrum-css/menu": "10.0.0-next.6", + "@spectrum-css/meter": "2.0.0-next.3", + "@spectrum-css/miller": "9.0.0-next.1", + "@spectrum-css/modal": "8.0.0-next.1", + "@spectrum-css/opacitycheckerboard": "5.0.0-next.0", + "@spectrum-css/page": "10.0.0-next.1", + "@spectrum-css/pagination": "11.0.0-next.2", + "@spectrum-css/picker": "10.0.0-next.4", + "@spectrum-css/pickerbutton": "7.0.0-next.2", + "@spectrum-css/popover": "9.0.0-next.5", + "@spectrum-css/progressbar": "7.0.0-next.4", + "@spectrum-css/progresscircle": "6.0.0-next.0", + "@spectrum-css/radio": "11.0.0-next.3", + "@spectrum-css/rating": "7.0.0-next.2", + "@spectrum-css/search": "9.0.0-next.3", + "@spectrum-css/sidenav": "8.0.0-next.3", + "@spectrum-css/slider": "7.0.0-next.4", + "@spectrum-css/splitview": "8.0.0-next.0", + "@spectrum-css/statuslight": "10.0.0-next.2", + "@spectrum-css/steplist": "8.0.0-next.2", + "@spectrum-css/stepper": "8.0.0-next.3", + "@spectrum-css/swatch": "9.0.0-next.1", + "@spectrum-css/swatchgroup": "6.0.0-next.1", + "@spectrum-css/switch": "7.0.0-next.2", + "@spectrum-css/table": "9.0.0-next.4", + "@spectrum-css/tabs": "7.0.0-next.2", + "@spectrum-css/tag": "11.0.0-next.2", + "@spectrum-css/taggroup": "8.0.0-next.2", + "@spectrum-css/textfield": "9.0.0-next.1", + "@spectrum-css/thumbnail": "9.0.0-next.1", + "@spectrum-css/toast": "12.0.0-next.2", + "@spectrum-css/tokens": "16.1.0-next.10", + "@spectrum-css/tooltip": "8.0.0-next.4", + "@spectrum-css/tray": "6.0.0-next.3", + "@spectrum-css/treeview": "13.0.0-next.3", + "@spectrum-css/typography": "9.0.0-next.0", + "@spectrum-css/underlay": "7.0.0-next.1", + "@spectrum-css/well": "8.0.0-next.1", + "colors": "1.4.0", + "postcss": "8.5.6", + "postcss-licensing": "3.0.0" + }, + "keywords": [ + "design-system", + "spectrum", + "spectrum-css", + "adobe", + "adobe-spectrum" + ], + "publishConfig": { + "access": "public" + } +} diff --git a/tools/bundle/postcss.config.js b/bundle/postcss.config.js similarity index 95% rename from tools/bundle/postcss.config.js rename to bundle/postcss.config.js index 6e61f640c88..a7b4402e3bb 100644 --- a/tools/bundle/postcss.config.js +++ b/bundle/postcss.config.js @@ -11,7 +11,7 @@ * governing permissions and limitations under the License. */ -import { dirs } from "../../tasks/utilities.js"; +import { dirs } from "../tasks/utilities.js"; /** * This config is used only to process the source files when created; diff --git a/tools/bundle/project.json b/bundle/project.json similarity index 57% rename from tools/bundle/project.json rename to bundle/project.json index 204cf06390d..05dd3aed18d 100644 --- a/tools/bundle/project.json +++ b/bundle/project.json @@ -3,7 +3,7 @@ "tag": ["tooling"], "targets": { "build": { - "dependsOn": ["clean", "^build", "refresh"], + "dependsOn": ["clean", "^build"], "executor": "nx:run-commands", "inputs": [ "{projectRoot}/src/index.css", @@ -31,25 +31,6 @@ } }, "format": {}, - "lint": {}, - "refresh": { - "cache": false, - "dependsOn": [], - "executor": "nx:run-commands", - "inputs": [ - "{projectRoot}/tasks/bundler.js", - "builder", - "postcss", - "stylelint", - { "env": "NODE_ENV" } - ], - "options": { - "commands": [ - "cross-env NODE_OPTIONS=\"--no-warnings\" node -e 'import(\"./tasks/bundler.js\").then(module => module.refresh() )'" - ], - "cwd": "{projectRoot}" - }, - "outputs": ["{projectRoot}/src/index.css"] - } + "lint": {} } } diff --git a/tools/bundle/src/index.css b/bundle/src/index.css similarity index 98% rename from tools/bundle/src/index.css rename to bundle/src/index.css index 28c0201ff7f..c358dc52117 100644 --- a/tools/bundle/src/index.css +++ b/bundle/src/index.css @@ -45,7 +45,6 @@ @import "@spectrum-css/colorslider"; @import "@spectrum-css/colorwheel"; @import "@spectrum-css/combobox"; -/* skip @spectrum-css/commons -- does not ship CSS */ @import "@spectrum-css/contextualhelp"; @import "@spectrum-css/datepicker"; @import "@spectrum-css/dial"; @@ -61,6 +60,7 @@ @import "@spectrum-css/icon"; @import "@spectrum-css/illustratedmessage"; @import "@spectrum-css/infieldbutton"; +@import "@spectrum-css/infieldprogresscircle"; @import "@spectrum-css/inlinealert"; @import "@spectrum-css/link"; @import "@spectrum-css/logicbutton"; diff --git a/tools/bundle/tasks/bundler.js b/bundle/tasks/bundler.js similarity index 58% rename from tools/bundle/tasks/bundler.js rename to bundle/tasks/bundler.js index 613cd008df1..f251167468e 100644 --- a/tools/bundle/tasks/bundler.js +++ b/bundle/tasks/bundler.js @@ -15,65 +15,12 @@ import fs from "node:fs"; import path from "node:path"; -import { processCSS } from "../../../tasks/component-builder.js"; -import { dirs, getAllComponentNames } from "../../../tasks/utilities.js"; +import { processCSS } from "../../tasks/component-builder.js"; +import { dirs } from "../../tasks/utilities.js"; import "colors"; -const bundleRoot = path.resolve(dirs.root, "tools", "bundle"); - -/** - * Refresh the list of component imports - * @returns {Promise} - */ -export async function refresh() { - const components = getAllComponentNames(false); - - // Refresh the src/index.css file with the latest component imports - const imports = ` -/** This file is machine generated. */ - -/* --- CORE TOKENS --- */ -@import "@spectrum-css/tokens/dist/css/index.css"; - -/* --- COMPONENTS --- */ -${components.map((component) => { - // Check if the package has an index.css file - if ( - fs.existsSync(path.join(dirs.components, component, "index.css")) && - !["commons"].includes(component) - ) { - return `@import "@spectrum-css/${component}";`; - } - return `/* skip @spectrum-css/${component} -- does not ship CSS */`; -}).join("\n")} -`; - - const reports = await processCSS(imports, undefined, path.join(bundleRoot, "src", "index.css"), { - cwd: bundleRoot, - env: "development", - configPath: bundleRoot, - }).catch((err) => { - console.log("\n\n🔄 refresh bundle"); - console.log(`${"".padStart(30, "-")}`); - - console.trace(err); - - console.log(`${"".padStart(30, "-")}`); - console.log(""); - - process.exit(1); - }); - - const logs = reports.flat(Infinity).filter(Boolean); - console.log("\n\n🔄 refresh bundle"); - console.log(`${"".padStart(30, "-")}`); - if (logs && logs.length > 0) { - logs.forEach(log => console.log(log)); - console.log(`${"".padStart(30, "-")}`); - console.log(""); - } -} +const bundleRoot = path.resolve(dirs.root, "bundle"); /** * Bundle all the components into a single CSS file diff --git a/components/accordion/CHANGELOG.md b/components/accordion/CHANGELOG.md index aa97c85661d..c1010bc9eed 100644 --- a/components/accordion/CHANGELOG.md +++ b/components/accordion/CHANGELOG.md @@ -1,5 +1,117 @@ # Change log +## 8.0.0-next.5 + +### Major Changes + +📝 [#4249](https://github.com/adobe/spectrum-css/pull/4249) [`9629fe3`](https://github.com/adobe/spectrum-css/commit/9629fe37cad996d47c827a3eabcdf39092a27b0d) Thanks [@castastrophe](https://github.com/castastrophe)! + +This update removes `--mod-*` custom property hooks per SWC-1264, see also the RFC for extensible styling. + +- Remove all `--mod-*` custom property hooks. +- Keep existing class selectors and variants unchanged. +- Update stories to reflect the removal of the `--mod-*` override layer. + +Breaking change: the `--mod-*` override layer is removed. Consumers should set `--spectrum-*` variables directly where customization is needed. + +## 8.0.0-next.4 + +### Minor Changes + +📝 [#4139](https://github.com/adobe/spectrum-css/pull/4139) [`6d835ff`](https://github.com/adobe/spectrum-css/commit/6d835ffeb77bc27bd5b2e4ddf48e2f5aa157a56b) Thanks [@rise-erpelding](https://github.com/rise-erpelding)! + +Changes values of `--spectrum-accordion-item-minimum-height` to align more closely with design spec, this affects the minimum height of accordion items for some combinations of size/density by giving them more space. + +New accordion minimum heights will use the heights/tokens: + +| Size | Compact | Regular | Spacious | +| ---- | --------------------------- | --------------------------- | --------------------------- | +| S | 24px/`component-height-75` | 32px/`component-height-100` | 40px/`component-height-200` | +| M | 32px/`component-height-100` | 40px/`component-height-200` | 48px/`component-height-300` | +| L | 40px/`component-height-200` | 48px/`component-height-300` | 56px/`component-height-400` | +| XL | 48px/`component-height-300` | 56px/`component-height-400` | 64px/`component-height-500` | + +## 8.0.0-next.3 + +### Major Changes + +📝 [#4014](https://github.com/adobe/spectrum-css/pull/4014) [`35c066b`](https://github.com/adobe/spectrum-css/commit/35c066b29c311b1bfcf4507075f13b41222ffc84) Thanks [@castastrophe](https://github.com/castastrophe)! + +This update removes the `dir` attribute polyfill (served via a PostCSS transform to compiled assets) as the fallback is no longer necessary. The`dir` attribute support is available in all supported browsers and has been tested to correctly inherit inside web component shadow DOMs. This is a breaking change **only** to those relying on the `dir` attribute being present for styling, however, the `:dir` pseudo will correctly inherit values from their containers. To correctly determine the `dir` value of a node using JavaScript, you can use `getComputedStyle(node).direction`. + +### Minor Changes + +📝 [#4020](https://github.com/adobe/spectrum-css/pull/4020) [`dc5f820`](https://github.com/adobe/spectrum-css/commit/dc5f8202a330910c0af51b7c172aca35ec99a1e7) Thanks [@rise-erpelding](https://github.com/rise-erpelding)! + +Accordion now supports direct actions. Direct actions, which may consist of a quiet action button or a switch, or both, may be added to each accordion item's heading. Direct action items are vertically centered within the heading's first line of text for all sizes and densities, and maintain their own individual key focus states. + +To allow the same level of customizability found in other elements within this component, the following --mod custom properties have been added: + +- `--mod-accordion-item-direct-actions-height` +- `--mod-accordion-item-direct-actions-spacing` +- `--mod-accordion-item-direct-actions-vertical-spacing` + +## 8.0.0-next.2 + +### Major Changes + +📝 [#3684](https://github.com/adobe/spectrum-css/pull/3684) [`f0c6273`](https://github.com/adobe/spectrum-css/commit/f0c6273310a8a7d8f392d6113919a3982ab07b2e) Thanks [@jawinn](https://github.com/jawinn)! + +#### Spectrum 2 migration + +Accordion now uses Spectrum 2 tokens and specifications. + +New sized tokens are used for corner rounding, the spacing around the disclosure icon, and +the spacing around the content area. + +##### New features + +- Adds the optional "quiet" style, which does not show dividers between accordion items. +- Adds CSS transition to animate the rotation of the disclosure indicator when expanding and + collapsing the accordion item. +- Adds no inline padding variant (`.spectrum-Accordion--noInlinePadding`) in which the item + header does not have padding. +- Per design spec, accordion items have a min-width and default width. Default width can be + overridden with `--mod-accordion-item-width` but should not be smaller than + `--spectrum-accordion-item-minimum-width`. + +##### Markup changes + +The HTML markup has changed slightly for the accordion header. The disclosure icon has been moved +from outside the button (`spectrum-Accordion-itemHeader`), to within the button. The extra +element with class `spectrum-Accordion-itemIconContainer`, previously wrapping the icon, has +been removed. A span with class `spectrum-Accordion-itemTitle` has been added around the heading +text. + +##### Modifier changes + +The following `--mod` custom properties have been renamed to better reflect how they are used: + +- `--mod-accordion-item-height` has been renamed to `--mod-accordion-item-minimum-height` +- `--mod-accordion-min-block-size` has been renamed to `--mod-accordion-item-min-block-size` +- `--mod-accordion-component-edge-to-text` has been renamed to `--mod-accordion-content-padding-inline` + +New modifiers: + +- `--mod-accordion-animation-duration` +- `--mod-accordion-edge-to-content-area` +- `--mod-accordion-item-minimum-width` +- `--mod-accordion-top-to-disclosure-indicator` + +## 8.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + +## 8.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`a25e0a9`](https://github.com/adobe/spectrum-css/commit/a25e0a99e5a4736ab4e607e00739343101a2633b)]: + - @spectrum-css/icon@10.0.0-next.0 + ## 7.2.0 ### Minor Changes diff --git a/components/accordion/dist/metadata.json b/components/accordion/dist/metadata.json index 3f3e89fbf15..149c2ecc5c8 100644 --- a/components/accordion/dist/metadata.json +++ b/components/accordion/dist/metadata.json @@ -6,6 +6,9 @@ ".spectrum-Accordion--compact.spectrum-Accordion--sizeL", ".spectrum-Accordion--compact.spectrum-Accordion--sizeS", ".spectrum-Accordion--compact.spectrum-Accordion--sizeXL", + ".spectrum-Accordion--quiet", + ".spectrum-Accordion--quiet .spectrum-Accordion-itemHeader:active", + ".spectrum-Accordion--quiet .spectrum-Accordion-itemHeader:hover", ".spectrum-Accordion--sizeL", ".spectrum-Accordion--sizeS", ".spectrum-Accordion--sizeXL", @@ -14,77 +17,29 @@ ".spectrum-Accordion--spacious.spectrum-Accordion--sizeS", ".spectrum-Accordion--spacious.spectrum-Accordion--sizeXL", ".spectrum-Accordion-item", - ".spectrum-Accordion-item.is-disabled .spectrum-Accordion-itemContent", - ".spectrum-Accordion-item.is-disabled .spectrum-Accordion-itemHeader", - ".spectrum-Accordion-item.is-disabled .spectrum-Accordion-itemHeader + .spectrum-Accordion-itemIconContainer", - ".spectrum-Accordion-item.is-disabled .spectrum-Accordion-itemHeader:focus-visible", - ".spectrum-Accordion-item.is-disabled .spectrum-Accordion-itemHeader:hover", - ".spectrum-Accordion-item.is-open .spectrum-Accordion-itemHeader:hover", + ".spectrum-Accordion-item.is-disabled", ".spectrum-Accordion-item.is-open > .spectrum-Accordion-itemContent", - ".spectrum-Accordion-item.is-open > .spectrum-Accordion-itemHeading > .spectrum-Accordion-itemIconContainer > .spectrum-Accordion-itemIndicator", - ".spectrum-Accordion-item.is-open > .spectrum-Accordion-itemIconContainer > .spectrum-Accordion-itemIndicator", + ".spectrum-Accordion-item.is-open > .spectrum-Accordion-itemHeading .spectrum-Accordion-itemIndicator", ".spectrum-Accordion-item:first-child", ".spectrum-Accordion-itemContent", + ".spectrum-Accordion-itemDirectActions", ".spectrum-Accordion-itemHeader", - ".spectrum-Accordion-itemHeader:active", - ".spectrum-Accordion-itemHeader:after", - ".spectrum-Accordion-itemHeader:focus", + ".spectrum-Accordion-itemHeader.spectrum-Accordion-itemHeader:active", ".spectrum-Accordion-itemHeader:focus-visible", - ".spectrum-Accordion-itemHeader:focus:after", + ".spectrum-Accordion-itemHeader:has(+ .spectrum-Accordion-itemDirectActions)", ".spectrum-Accordion-itemHeader:hover", - ".spectrum-Accordion-itemHeader:hover + .spectrum-Accordion-itemIconContainer", ".spectrum-Accordion-itemHeading", - ".spectrum-Accordion-itemIconContainer", - ".spectrum-Accordion-itemIconContainer:dir(rtl)", + ".spectrum-Accordion-itemIndicator", + ".spectrum-Accordion-itemTitle", + ".spectrum-Accordion.spectrum-Accordion--noInlinePadding", ".spectrum-Accordion:dir(rtl)", ".spectrum-Accordion:lang(ja)", ".spectrum-Accordion:lang(ko)", - ".spectrum-Accordion:lang(zh)", - "[dir=\"rtl\"] .spectrum-Accordion", - "[dir=\"rtl\"] .spectrum-Accordion-itemIconContainer" - ], - "modifiers": [ - "--mod-accordion-background-color-default", - "--mod-accordion-background-color-down", - "--mod-accordion-background-color-hover", - "--mod-accordion-background-color-key-focus", - "--mod-accordion-component-edge-to-text", - "--mod-accordion-corner-radius", - "--mod-accordion-disclosure-indicator-height", - "--mod-accordion-disclosure-indicator-to-text-space", - "--mod-accordion-divider-color", - "--mod-accordion-divider-thickness", - "--mod-accordion-edge-to-disclosure-indicator-space", - "--mod-accordion-edge-to-text-space", - "--mod-accordion-focus-indicator-color", - "--mod-accordion-focus-indicator-gap", - "--mod-accordion-focus-indicator-thickness", - "--mod-accordion-item-content-area-bottom-to-content", - "--mod-accordion-item-content-area-top-to-content", - "--mod-accordion-item-content-color", - "--mod-accordion-item-content-disabled-color", - "--mod-accordion-item-content-font", - "--mod-accordion-item-content-font-size", - "--mod-accordion-item-content-font-style", - "--mod-accordion-item-content-font-weight", - "--mod-accordion-item-content-line-height", - "--mod-accordion-item-header-bottom-to-text-space", - "--mod-accordion-item-header-color-default", - "--mod-accordion-item-header-color-down", - "--mod-accordion-item-header-color-hover", - "--mod-accordion-item-header-color-key-focus", - "--mod-accordion-item-header-disabled-color", - "--mod-accordion-item-header-font", - "--mod-accordion-item-header-font-size", - "--mod-accordion-item-header-font-style", - "--mod-accordion-item-header-font-weight", - "--mod-accordion-item-header-line-height", - "--mod-accordion-item-header-top-to-text-space", - "--mod-accordion-item-height", - "--mod-accordion-item-width", - "--mod-accordion-min-block-size" + ".spectrum-Accordion:lang(zh)" ], + "modifiers": [], "component": [ + "--spectrum-accordion-animation-duration", "--spectrum-accordion-background-color-default", "--spectrum-accordion-background-color-down", "--spectrum-accordion-background-color-hover", @@ -93,72 +48,86 @@ "--spectrum-accordion-bottom-to-text-compact-large", "--spectrum-accordion-bottom-to-text-compact-medium", "--spectrum-accordion-bottom-to-text-compact-small", - "--spectrum-accordion-bottom-to-text-regular-extra-large", - "--spectrum-accordion-bottom-to-text-regular-large", - "--spectrum-accordion-bottom-to-text-regular-medium", - "--spectrum-accordion-bottom-to-text-regular-small", + "--spectrum-accordion-bottom-to-text-extra-large", + "--spectrum-accordion-bottom-to-text-large", + "--spectrum-accordion-bottom-to-text-medium", + "--spectrum-accordion-bottom-to-text-small", "--spectrum-accordion-bottom-to-text-spacious-extra-large", "--spectrum-accordion-bottom-to-text-spacious-large", "--spectrum-accordion-bottom-to-text-spacious-medium", "--spectrum-accordion-bottom-to-text-spacious-small", - "--spectrum-accordion-component-edge-to-text", "--spectrum-accordion-content-area-bottom-to-content", + "--spectrum-accordion-content-area-edge-to-content-extra-large", + "--spectrum-accordion-content-area-edge-to-content-large", + "--spectrum-accordion-content-area-edge-to-content-medium", + "--spectrum-accordion-content-area-edge-to-content-small", "--spectrum-accordion-content-area-top-to-content", + "--spectrum-accordion-content-padding-inline", "--spectrum-accordion-corner-radius", "--spectrum-accordion-disclosure-indicator-height", - "--spectrum-accordion-disclosure-indicator-to-text", + "--spectrum-accordion-disclosure-indicator-to-text-extra-large", + "--spectrum-accordion-disclosure-indicator-to-text-large", + "--spectrum-accordion-disclosure-indicator-to-text-medium", + "--spectrum-accordion-disclosure-indicator-to-text-small", "--spectrum-accordion-disclosure-indicator-to-text-space", "--spectrum-accordion-divider-color", - "--spectrum-accordion-edge-to-disclosure-indicator", + "--spectrum-accordion-divider-thickness", + "--spectrum-accordion-edge-to-content-area", + "--spectrum-accordion-edge-to-content-area-extra-large", + "--spectrum-accordion-edge-to-content-area-large", + "--spectrum-accordion-edge-to-content-area-medium", + "--spectrum-accordion-edge-to-content-area-small", "--spectrum-accordion-edge-to-disclosure-indicator-space", "--spectrum-accordion-edge-to-text", "--spectrum-accordion-edge-to-text-space", - "--spectrum-accordion-focus-indicator-color", - "--spectrum-accordion-focus-indicator-gap", - "--spectrum-accordion-focus-indicator-thickness", "--spectrum-accordion-item-content-area-bottom-to-content", "--spectrum-accordion-item-content-area-top-to-content", "--spectrum-accordion-item-content-color", - "--spectrum-accordion-item-content-disabled-color", "--spectrum-accordion-item-content-font", "--spectrum-accordion-item-content-font-size", "--spectrum-accordion-item-content-font-style", "--spectrum-accordion-item-content-font-weight", "--spectrum-accordion-item-content-line-height", + "--spectrum-accordion-item-direct-actions-height", + "--spectrum-accordion-item-direct-actions-spacing", + "--spectrum-accordion-item-direct-actions-vertical-spacing", + "--spectrum-accordion-item-focus-indicator-color", + "--spectrum-accordion-item-focus-indicator-gap", + "--spectrum-accordion-item-focus-indicator-thickness", "--spectrum-accordion-item-header-bottom-to-text-space", "--spectrum-accordion-item-header-color-default", "--spectrum-accordion-item-header-color-down", "--spectrum-accordion-item-header-color-hover", "--spectrum-accordion-item-header-color-key-focus", - "--spectrum-accordion-item-header-disabled-color", + "--spectrum-accordion-item-header-cursor", "--spectrum-accordion-item-header-font", "--spectrum-accordion-item-header-font-size", "--spectrum-accordion-item-header-font-style", "--spectrum-accordion-item-header-font-weight", "--spectrum-accordion-item-header-line-height", + "--spectrum-accordion-item-header-to-direct-actions-space", "--spectrum-accordion-item-header-top-to-text-space", - "--spectrum-accordion-item-height", + "--spectrum-accordion-item-min-block-size", + "--spectrum-accordion-item-minimum-height", + "--spectrum-accordion-item-minimum-width", "--spectrum-accordion-item-width", - "--spectrum-accordion-min-block-size", "--spectrum-accordion-minimum-width", - "--spectrum-accordion-small-top-to-text-spacious", + "--spectrum-accordion-top-to-disclosure-indicator", "--spectrum-accordion-top-to-text-compact-extra-large", "--spectrum-accordion-top-to-text-compact-large", "--spectrum-accordion-top-to-text-compact-medium", "--spectrum-accordion-top-to-text-compact-small", - "--spectrum-accordion-top-to-text-regular-extra-large", - "--spectrum-accordion-top-to-text-regular-large", - "--spectrum-accordion-top-to-text-regular-medium", - "--spectrum-accordion-top-to-text-regular-small", + "--spectrum-accordion-top-to-text-extra-large", + "--spectrum-accordion-top-to-text-large", + "--spectrum-accordion-top-to-text-medium", + "--spectrum-accordion-top-to-text-small", "--spectrum-accordion-top-to-text-spacious-extra-large", "--spectrum-accordion-top-to-text-spacious-large", - "--spectrum-accordion-top-to-text-spacious-medium" + "--spectrum-accordion-top-to-text-spacious-medium", + "--spectrum-accordion-top-to-text-spacious-small" ], "global": [ - "--spectrum-background-opacity-default", - "--spectrum-background-opacity-down", - "--spectrum-background-opacity-hover", - "--spectrum-background-opacity-key-focus", + "--spectrum-animation-duration-100", "--spectrum-body-color", "--spectrum-body-sans-serif-font-style", "--spectrum-body-sans-serif-font-weight", @@ -167,41 +136,62 @@ "--spectrum-body-size-s", "--spectrum-body-size-xs", "--spectrum-bold-font-weight", + "--spectrum-chevron-icon-size-100", + "--spectrum-chevron-icon-size-200", + "--spectrum-chevron-icon-size-300", + "--spectrum-chevron-icon-size-75", "--spectrum-cjk-line-height-100", - "--spectrum-component-edge-to-text-100", - "--spectrum-component-edge-to-text-200", - "--spectrum-component-edge-to-text-50", - "--spectrum-component-edge-to-text-75", "--spectrum-component-height-100", "--spectrum-component-height-200", "--spectrum-component-height-300", "--spectrum-component-height-400", + "--spectrum-component-height-500", "--spectrum-component-height-75", - "--spectrum-corner-radius-100", + "--spectrum-corner-radius-medium-size-extra-large", + "--spectrum-corner-radius-medium-size-large", + "--spectrum-corner-radius-medium-size-medium", + "--spectrum-corner-radius-medium-size-small", "--spectrum-default-font-style", "--spectrum-disabled-content-color", "--spectrum-divider-thickness-small", + "--spectrum-field-default-width-extra-large", + "--spectrum-field-default-width-large", + "--spectrum-field-default-width-medium", + "--spectrum-field-edge-to-disclosure-icon-100", + "--spectrum-field-edge-to-disclosure-icon-200", + "--spectrum-field-edge-to-disclosure-icon-300", + "--spectrum-field-edge-to-disclosure-icon-75", + "--spectrum-field-top-to-disclosure-icon-compact-extra-large", + "--spectrum-field-top-to-disclosure-icon-compact-large", + "--spectrum-field-top-to-disclosure-icon-compact-medium", + "--spectrum-field-top-to-disclosure-icon-compact-small", + "--spectrum-field-top-to-disclosure-icon-extra-large", + "--spectrum-field-top-to-disclosure-icon-large", + "--spectrum-field-top-to-disclosure-icon-medium", + "--spectrum-field-top-to-disclosure-icon-small", + "--spectrum-field-top-to-disclosure-icon-spacious-extra-large", + "--spectrum-field-top-to-disclosure-icon-spacious-large", + "--spectrum-field-top-to-disclosure-icon-spacious-medium", + "--spectrum-field-top-to-disclosure-icon-spacious-small", "--spectrum-focus-indicator-color", "--spectrum-focus-indicator-gap", "--spectrum-focus-indicator-thickness", + "--spectrum-font-size-100", "--spectrum-font-size-200", "--spectrum-font-size-300", - "--spectrum-font-size-500", - "--spectrum-font-size-700", + "--spectrum-font-size-400", "--spectrum-gray-200", - "--spectrum-gray-900-rgb", "--spectrum-line-height-100", "--spectrum-logical-rotation", "--spectrum-neutral-content-color-default", "--spectrum-neutral-content-color-down", "--spectrum-neutral-content-color-hover", "--spectrum-neutral-content-color-key-focus", - "--spectrum-sans-font-family-stack" - ], - "system-theme": [ - "--system-accordion-divider-color", - "--system-accordion-item-content-color", - "--system-accordion-item-content-disabled-color" + "--spectrum-sans-font-family-stack", + "--spectrum-spacing-100", + "--spectrum-transparent-black-100", + "--spectrum-transparent-black-25", + "--spectrum-transparent-black-300" ], "passthroughs": [], "high-contrast": [] diff --git a/components/accordion/index.css b/components/accordion/index.css index 942f421e901..2c2bc4e8c15 100644 --- a/components/accordion/index.css +++ b/components/accordion/index.css @@ -11,30 +11,39 @@ * governing permissions and limitations under the License. */ -@import "./themes/spectrum-two.css"; - .spectrum-Accordion { - --spectrum-accordion-item-height: var(--spectrum-component-height-200); - --spectrum-accordion-item-width: var(--spectrum-accordion-minimum-width); - --spectrum-accordion-disclosure-indicator-height: var(--spectrum-component-height-100); - --spectrum-accordion-disclosure-indicator-to-text-space: var(--spectrum-accordion-disclosure-indicator-to-text); - --spectrum-accordion-edge-to-disclosure-indicator-space: var(--spectrum-accordion-edge-to-disclosure-indicator); + /* Layout and spacing */ + --spectrum-accordion-item-minimum-height: var(--spectrum-component-height-200); + --spectrum-accordion-item-minimum-width: var(--spectrum-accordion-minimum-width); + --spectrum-accordion-item-width: var(--spectrum-field-default-width-medium); + --spectrum-accordion-disclosure-indicator-height: var(--spectrum-chevron-icon-size-100); + --spectrum-accordion-disclosure-indicator-to-text-space: var(--spectrum-accordion-disclosure-indicator-to-text-medium); + --spectrum-accordion-edge-to-disclosure-indicator-space: var(--spectrum-field-edge-to-disclosure-icon-100); + --spectrum-accordion-content-padding-inline: var(--spectrum-accordion-content-area-edge-to-content-medium); + --spectrum-accordion-edge-to-content-area: var(--spectrum-accordion-edge-to-content-area-medium); --spectrum-accordion-edge-to-text-space: var(--spectrum-accordion-edge-to-text); - --spectrum-accordion-item-header-top-to-text-space: var(--spectrum-accordion-top-to-text-regular-medium); - --spectrum-accordion-item-header-bottom-to-text-space: var(--spectrum-accordion-bottom-to-text-regular-medium); - --spectrum-accordion-focus-indicator-gap: var(--spectrum-focus-indicator-gap); - --spectrum-accordion-focus-indicator-thickness: var(--spectrum-focus-indicator-thickness); - --spectrum-accordion-corner-radius: var(--spectrum-corner-radius-100); + --spectrum-accordion-item-header-top-to-text-space: var(--spectrum-accordion-top-to-text-medium); + --spectrum-accordion-item-header-bottom-to-text-space: var(--spectrum-accordion-bottom-to-text-medium); + --spectrum-accordion-top-to-disclosure-indicator: var(--spectrum-field-top-to-disclosure-icon-medium); + --spectrum-accordion-item-focus-indicator-thickness: var(--spectrum-focus-indicator-thickness); + --spectrum-accordion-item-focus-indicator-gap: var(--spectrum-focus-indicator-gap); + --spectrum-accordion-corner-radius: var(--spectrum-corner-radius-medium-size-medium); --spectrum-accordion-item-content-area-top-to-content: var(--spectrum-accordion-content-area-top-to-content); --spectrum-accordion-item-content-area-bottom-to-content: var(--spectrum-accordion-content-area-bottom-to-content); - --spectrum-accordion-component-edge-to-text: var(--spectrum-component-edge-to-text-75); + --spectrum-accordion-divider-thickness: var(--spectrum-divider-thickness-small); + --spectrum-accordion-item-direct-actions-height: var(--spectrum-component-height-100); + --spectrum-accordion-item-header-to-direct-actions-space: var(--spectrum-spacing-100); /* same for all sizes */ /* Text header */ --spectrum-accordion-item-header-font: var(--spectrum-sans-font-family-stack); --spectrum-accordion-item-header-font-weight: var(--spectrum-bold-font-weight); --spectrum-accordion-item-header-font-style: var(--spectrum-default-font-style); - --spectrum-accordion-item-header-font-size: var(--spectrum-font-size-300); - --spectrum-accordion-item-header-line-height: 1.25; + --spectrum-accordion-item-header-font-size: var(--spectrum-font-size-200); + --spectrum-accordion-item-header-line-height: var(--spectrum-line-height-100); + + --spectrum-accordion-item-header-cursor: pointer; + --spectrum-accordion-item-direct-actions-spacing: var(--spectrum-spacing-100); + --spectrum-accordion-animation-duration: var(--spectrum-animation-duration-100); /* Text body */ --spectrum-accordion-item-content-font: var(--spectrum-sans-font-family-stack); @@ -44,31 +53,34 @@ --spectrum-accordion-item-content-line-height: var(--spectrum-line-height-100); /* Colors */ - --spectrum-accordion-background-color-default: rgb(var(--spectrum-gray-900-rgb), var(--spectrum-background-opacity-default)); - --spectrum-accordion-background-color-hover: rgb(var(--spectrum-gray-900-rgb), var(--spectrum-background-opacity-hover)); - --spectrum-accordion-background-color-down: rgb(var(--spectrum-gray-900-rgb), var(--spectrum-background-opacity-down)); - --spectrum-accordion-background-color-key-focus: rgb(var(--spectrum-gray-900-rgb), var(--spectrum-background-opacity-key-focus)); + /* @TODO: use opacity tokens when available */ + --spectrum-accordion-background-color-default: var(--spectrum-transparent-black-25); + --spectrum-accordion-background-color-hover: var(--spectrum-transparent-black-100); + --spectrum-accordion-background-color-down: var(--spectrum-transparent-black-300); + --spectrum-accordion-background-color-key-focus: var(--spectrum-transparent-black-100); + + --spectrum-accordion-item-content-color: var(--spectrum-body-color); + --spectrum-accordion-divider-color: var(--spectrum-gray-200); + --spectrum-accordion-item-focus-indicator-color: var(--spectrum-focus-indicator-color); - /* Label */ --spectrum-accordion-item-header-color-default: var(--spectrum-neutral-content-color-default); --spectrum-accordion-item-header-color-hover: var(--spectrum-neutral-content-color-hover); --spectrum-accordion-item-header-color-down: var(--spectrum-neutral-content-color-down); --spectrum-accordion-item-header-color-key-focus: var(--spectrum-neutral-content-color-key-focus); - --spectrum-accordion-item-header-disabled-color: var(--spectrum-disabled-content-color); - - /* Focus indicator */ - --spectrum-accordion-focus-indicator-color: var(--spectrum-focus-indicator-color); + /* Calculated minimum block-size that accounts for density spacing changes and/or increases in font size and line-height. + This gives us the block-size of the header with a single line of text. */ + --spectrum-accordion-item-min-block-size: max(var(--spectrum-accordion-item-minimum-height), var(--spectrum-accordion-item-header-top-to-text-space) + var(--spectrum-accordion-item-header-bottom-to-text-space) + (var(--spectrum-accordion-item-header-font-size) * var(--spectrum-accordion-item-header-line-height))); - --spectrum-accordion-min-block-size: max( - var(--mod-accordion-item-height, var(--spectrum-accordion-item-height)), - calc(var(--mod-accordion-item-header-top-to-text-space, var(--spectrum-accordion-item-header-top-to-text-space)) + var(--mod-accordion-item-header-bottom-to-text-space, var(--spectrum-accordion-item-header-bottom-to-text-space)) + (var(--mod-accordion-item-header-font-size, var(--spectrum-accordion-item-header-font-size)) * var(--mod-accordion-item-header-line-height, var(--spectrum-accordion-item-header-line-height)))) - ); + /* Calculated vertical spacing for action button and switch to center them within the accordion item */ + --spectrum-accordion-item-direct-actions-vertical-spacing: calc((var(--spectrum-accordion-item-min-block-size) - var(--spectrum-accordion-item-direct-actions-height)) / 2); + /* Right-to-left adjustments for transforms */ &:dir(rtl) { --spectrum-logical-rotation: matrix(-1, 0, 0, 1, 0, 0); } + /* CJK (Chinese, Japanese, and Korean) language support */ &:lang(ja), &:lang(zh), &:lang(ko) { @@ -77,82 +89,133 @@ } } +.spectrum-Accordion--sizeS { + --spectrum-accordion-item-minimum-height: var(--spectrum-component-height-100); + --spectrum-accordion-item-width: var(--spectrum-accordion-minimum-width); /* small size default width uses this min-width token */ + --spectrum-accordion-disclosure-indicator-height: var(--spectrum-chevron-icon-size-75); + --spectrum-accordion-disclosure-indicator-to-text-space: var(--spectrum-accordion-disclosure-indicator-to-text-small); + --spectrum-accordion-edge-to-disclosure-indicator-space: var(--spectrum-field-edge-to-disclosure-icon-75); + --spectrum-accordion-content-padding-inline: var(--spectrum-accordion-content-area-edge-to-content-small); + --spectrum-accordion-edge-to-content-area: var(--spectrum-accordion-edge-to-content-area-small); + --spectrum-accordion-corner-radius: var(--spectrum-corner-radius-medium-size-small); + --spectrum-accordion-item-header-font-size: var(--spectrum-font-size-100); + --spectrum-accordion-item-content-font-size: var(--spectrum-body-size-xs); + --spectrum-accordion-item-header-top-to-text-space: var(--spectrum-accordion-top-to-text-small); + --spectrum-accordion-item-header-bottom-to-text-space: var(--spectrum-accordion-bottom-to-text-small); + --spectrum-accordion-top-to-disclosure-indicator: var(--spectrum-field-top-to-disclosure-icon-small); + --spectrum-accordion-item-direct-actions-height: var(--spectrum-component-height-75); /* component height for switch and action button */ +} + +.spectrum-Accordion--sizeL { + --spectrum-accordion-item-minimum-height: var(--spectrum-component-height-300); + --spectrum-accordion-item-width: var(--spectrum-field-default-width-large); + --spectrum-accordion-disclosure-indicator-height: var(--spectrum-chevron-icon-size-200); + --spectrum-accordion-disclosure-indicator-to-text-space: var(--spectrum-accordion-disclosure-indicator-to-text-large); + --spectrum-accordion-edge-to-disclosure-indicator-space: var(--spectrum-field-edge-to-disclosure-icon-200); + --spectrum-accordion-content-padding-inline: var(--spectrum-accordion-content-area-edge-to-content-large); + --spectrum-accordion-edge-to-content-area: var(--spectrum-accordion-edge-to-content-area-large); + --spectrum-accordion-corner-radius: var(--spectrum-corner-radius-medium-size-large); + --spectrum-accordion-item-header-font-size: var(--spectrum-font-size-300); + --spectrum-accordion-item-content-font-size: var(--spectrum-body-size-m); + --spectrum-accordion-item-header-top-to-text-space: var(--spectrum-accordion-top-to-text-large); + --spectrum-accordion-item-header-bottom-to-text-space: var(--spectrum-accordion-bottom-to-text-large); + --spectrum-accordion-top-to-disclosure-indicator: var(--spectrum-field-top-to-disclosure-icon-large); + --spectrum-accordion-item-direct-actions-height: var(--spectrum-component-height-200); +} + +.spectrum-Accordion--sizeXL { + --spectrum-accordion-item-minimum-height: var(--spectrum-component-height-400); + --spectrum-accordion-item-width: var(--spectrum-field-default-width-extra-large); + --spectrum-accordion-disclosure-indicator-height: var(--spectrum-chevron-icon-size-300); + --spectrum-accordion-disclosure-indicator-to-text-space: var(--spectrum-accordion-disclosure-indicator-to-text-extra-large); + --spectrum-accordion-edge-to-disclosure-indicator-space: var(--spectrum-field-edge-to-disclosure-icon-300); + --spectrum-accordion-content-padding-inline: var(--spectrum-accordion-content-area-edge-to-content-extra-large); + --spectrum-accordion-edge-to-content-area: var(--spectrum-accordion-edge-to-content-area-extra-large); + --spectrum-accordion-corner-radius: var(--spectrum-corner-radius-medium-size-extra-large); + --spectrum-accordion-item-header-font-size: var(--spectrum-font-size-400); + --spectrum-accordion-item-content-font-size: var(--spectrum-body-size-l); + --spectrum-accordion-item-header-top-to-text-space: var(--spectrum-accordion-top-to-text-extra-large); + --spectrum-accordion-item-header-bottom-to-text-space: var(--spectrum-accordion-bottom-to-text-extra-large); + --spectrum-accordion-top-to-disclosure-indicator: var(--spectrum-field-top-to-disclosure-icon-extra-large); + --spectrum-accordion-item-direct-actions-height: var(--spectrum-component-height-300); +} + .spectrum-Accordion--compact { - --spectrum-accordion-item-height: var(--spectrum-component-height-100); + --spectrum-accordion-item-minimum-height: var(--spectrum-component-height-100); --spectrum-accordion-item-header-top-to-text-space: var(--spectrum-accordion-top-to-text-compact-medium); --spectrum-accordion-item-header-bottom-to-text-space: var(--spectrum-accordion-bottom-to-text-compact-medium); + --spectrum-accordion-top-to-disclosure-indicator: var(--spectrum-field-top-to-disclosure-icon-compact-medium); &.spectrum-Accordion--sizeS { - --spectrum-accordion-item-height: var(--spectrum-component-height-75); + --spectrum-accordion-item-minimum-height: var(--spectrum-component-height-75); --spectrum-accordion-item-header-top-to-text-space: var(--spectrum-accordion-top-to-text-compact-small); --spectrum-accordion-item-header-bottom-to-text-space: var(--spectrum-accordion-bottom-to-text-compact-small); + --spectrum-accordion-top-to-disclosure-indicator: var(--spectrum-field-top-to-disclosure-icon-compact-small); } &.spectrum-Accordion--sizeL { - --spectrum-accordion-item-height: var(--spectrum-component-height-200); + --spectrum-accordion-item-minimum-height: var(--spectrum-component-height-200); --spectrum-accordion-item-header-top-to-text-space: var(--spectrum-accordion-top-to-text-compact-large); --spectrum-accordion-item-header-bottom-to-text-space: var(--spectrum-accordion-bottom-to-text-compact-large); + --spectrum-accordion-top-to-disclosure-indicator: var(--spectrum-field-top-to-disclosure-icon-compact-large); } &.spectrum-Accordion--sizeXL { - --spectrum-accordion-item-height: var(--spectrum-component-height-300); + --spectrum-accordion-item-minimum-height: var(--spectrum-component-height-300); --spectrum-accordion-item-header-top-to-text-space: var(--spectrum-accordion-top-to-text-compact-extra-large); --spectrum-accordion-item-header-bottom-to-text-space: var(--spectrum-accordion-bottom-to-text-compact-extra-large); + --spectrum-accordion-top-to-disclosure-indicator: var(--spectrum-field-top-to-disclosure-icon-compact-extra-large); } } .spectrum-Accordion--spacious { - --spectrum-accordion-item-header-line-height: 1.278; + --spectrum-accordion-item-minimum-height: var(--spectrum-component-height-300); --spectrum-accordion-item-header-top-to-text-space: var(--spectrum-accordion-top-to-text-spacious-medium); --spectrum-accordion-item-header-bottom-to-text-space: var(--spectrum-accordion-bottom-to-text-spacious-medium); + --spectrum-accordion-top-to-disclosure-indicator: var(--spectrum-field-top-to-disclosure-icon-spacious-medium); &.spectrum-Accordion--sizeS { - --spectrum-accordion-item-header-line-height: 1.25; - --spectrum-accordion-item-header-top-to-text-space: var(--spectrum-accordion-small-top-to-text-spacious); + --spectrum-accordion-item-minimum-height: var(--spectrum-component-height-200); + --spectrum-accordion-item-header-top-to-text-space: var(--spectrum-accordion-top-to-text-spacious-small); --spectrum-accordion-item-header-bottom-to-text-space: var(--spectrum-accordion-bottom-to-text-spacious-small); + --spectrum-accordion-top-to-disclosure-indicator: var(--spectrum-field-top-to-disclosure-icon-spacious-small); } &.spectrum-Accordion--sizeL { - --spectrum-accordion-item-header-line-height: 1.273; + --spectrum-accordion-item-minimum-height: var(--spectrum-component-height-400); --spectrum-accordion-item-header-top-to-text-space: var(--spectrum-accordion-top-to-text-spacious-large); --spectrum-accordion-item-header-bottom-to-text-space: var(--spectrum-accordion-bottom-to-text-spacious-large); + --spectrum-accordion-top-to-disclosure-indicator: var(--spectrum-field-top-to-disclosure-icon-spacious-large); } &.spectrum-Accordion--sizeXL { - --spectrum-accordion-item-header-line-height: 1.25; + --spectrum-accordion-item-minimum-height: var(--spectrum-component-height-500); --spectrum-accordion-item-header-top-to-text-space: var(--spectrum-accordion-top-to-text-spacious-extra-large); --spectrum-accordion-item-header-bottom-to-text-space: var(--spectrum-accordion-bottom-to-text-spacious-extra-large); + --spectrum-accordion-top-to-disclosure-indicator: var(--spectrum-field-top-to-disclosure-icon-spacious-extra-large); } } -.spectrum-Accordion--sizeS { - --spectrum-accordion-item-height: var(--spectrum-component-height-100); - --spectrum-accordion-disclosure-indicator-height: var(--spectrum-component-height-75); - --spectrum-accordion-component-edge-to-text: var(--spectrum-component-edge-to-text-50); - --spectrum-accordion-item-header-font-size: var(--spectrum-font-size-200); - --spectrum-accordion-item-content-font-size: var(--spectrum-body-size-xs); - --spectrum-accordion-item-header-top-to-text-space: var(--spectrum-accordion-top-to-text-regular-small); - --spectrum-accordion-item-header-bottom-to-text-space: var(--spectrum-accordion-bottom-to-text-regular-small); +.spectrum-Accordion--quiet { + --spectrum-accordion-divider-thickness: 0px; } -.spectrum-Accordion--sizeL { - --spectrum-accordion-item-height: var(--spectrum-component-height-300); - --spectrum-accordion-disclosure-indicator-height: var(--spectrum-component-height-200); - --spectrum-accordion-component-edge-to-text: var(--spectrum-component-edge-to-text-100); - --spectrum-accordion-item-header-font-size: var(--spectrum-font-size-500); - --spectrum-accordion-item-content-font-size: var(--spectrum-body-size-m); - --spectrum-accordion-item-header-top-to-text-space: var(--spectrum-accordion-top-to-text-regular-large); - --spectrum-accordion-item-header-bottom-to-text-space: var(--spectrum-accordion-bottom-to-text-regular-large); +.spectrum-Accordion-item.is-disabled { + --spectrum-accordion-item-header-cursor: default; + --spectrum-accordion-background-color-default: transparent; + --spectrum-accordion-background-color-hover: transparent; + --spectrum-accordion-background-color-down: transparent; + --spectrum-accordion-background-color-key-focus: transparent; + --spectrum-accordion-item-content-color: var(--spectrum-disabled-content-color); + --spectrum-accordion-item-header-color-default: var(--spectrum-disabled-content-color); + --spectrum-accordion-item-header-color-hover: var(--spectrum-disabled-content-color); + --spectrum-accordion-item-header-color-down: var(--spectrum-disabled-content-color); + --spectrum-accordion-item-header-color-key-focus: var(--spectrum-disabled-content-color); } -.spectrum-Accordion--sizeXL { - --spectrum-accordion-item-height: var(--spectrum-component-height-400); - --spectrum-accordion-disclosure-indicator-height: var(--spectrum-component-height-300); - --spectrum-accordion-component-edge-to-text: var(--spectrum-component-edge-to-text-200); - --spectrum-accordion-item-header-font-size: var(--spectrum-font-size-700); - --spectrum-accordion-item-content-font-size: var(--spectrum-body-size-l); - --spectrum-accordion-item-header-top-to-text-space: var(--spectrum-accordion-top-to-text-regular-extra-large); - --spectrum-accordion-item-header-bottom-to-text-space: var(--spectrum-accordion-bottom-to-text-regular-extra-large); +.spectrum-Accordion.spectrum-Accordion--noInlinePadding { + --spectrum-accordion-edge-to-disclosure-indicator-space: 0px; + --spectrum-accordion-edge-to-content-area: 0px; } .spectrum-Accordion { @@ -165,175 +228,141 @@ .spectrum-Accordion-item { z-index: inherit; position: relative; - margin: 0; - - min-block-size: var(--mod-accordion-item-height, var(--spectrum-accordion-item-height)); - min-inline-size: var(--mod-accordion-item-width, var(--spectrum-accordion-item-width)); + min-block-size: var(--spectrum-accordion-item-min-block-size); + min-inline-size: var(--spectrum-accordion-item-minimum-width); + inline-size: var(--spectrum-accordion-item-width); + border-block-end: var(--spectrum-accordion-divider-thickness) solid var(--spectrum-accordion-divider-color); &:first-child { - border-block-start: 1px solid transparent; - border-color: var(--mod-accordion-divider-color, var(--spectrum-accordion-divider-color)); - border-width: var(--mod-accordion-divider-thickness, var(--spectrum-divider-thickness-small)); + border-block-start: var(--spectrum-accordion-divider-thickness) solid var(--spectrum-accordion-divider-color); } - - border-block-end: 1px solid transparent; - border-color: var(--mod-accordion-divider-color, var(--spectrum-accordion-divider-color)); - border-width: var(--mod-accordion-divider-thickness, var(--spectrum-divider-thickness-small)); } .spectrum-Accordion-itemHeading { margin: 0; position: relative; box-sizing: border-box; -} - -.spectrum-Accordion-itemIconContainer { - padding-inline-start: var(--mod-accordion-edge-to-disclosure-indicator-space, var(--spectrum-accordion-edge-to-disclosure-indicator-space)); - inline-size: var(--mod-accordion-disclosure-indicator-height, var(--spectrum-accordion-disclosure-indicator-height)); - block-size: var(--mod-accordion-disclosure-indicator-height, var(--spectrum-accordion-disclosure-indicator-height)); display: flex; - justify-content: center; - align-items: center; - color: var(--mod-accordion-item-header-color-default, var(--spectrum-accordion-item-header-color-default)); - position: absolute; - inset-block-start: max(0px, calc((var(--mod-accordion-min-block-size, var(--spectrum-accordion-min-block-size)) - var(--mod-accordion-disclosure-indicator-height, var(--spectrum-accordion-disclosure-indicator-height))) / 2)); +} - &:dir(rtl) { - transform: scaleX(-1); - } +.spectrum-Accordion-itemIndicator { + inline-size: var(--spectrum-accordion-disclosure-indicator-height); + block-size: var(--spectrum-accordion-disclosure-indicator-height); + transform: var(--spectrum-logical-rotation); + transition: transform ease var(--spectrum-accordion-animation-duration); + flex-shrink: 0; + margin-block-start: var(--spectrum-accordion-top-to-disclosure-indicator); + margin-inline: var(--spectrum-accordion-edge-to-disclosure-indicator-space) var(--spectrum-accordion-disclosure-indicator-to-text-space); } .spectrum-Accordion-itemContent { - padding-block: var(--mod-accordion-item-content-area-top-to-content, var(--spectrum-accordion-item-content-area-top-to-content)) var(--mod-accordion-item-content-area-bottom-to-content, var(--spectrum-accordion-item-content-area-bottom-to-content)); - padding-inline: var(--mod-accordion-component-edge-to-text, var(--spectrum-accordion-component-edge-to-text)) var(--mod-accordion-component-edge-to-text, var(--spectrum-accordion-component-edge-to-text)); display: none; - color: var(--mod-accordion-item-content-color, var(--spectrum-accordion-item-content-color)); - font-weight: var(--mod-accordion-item-content-font-weight, var(--spectrum-accordion-item-content-font-weight)); - font-style: var(--mod-accordion-item-content-font-style, var(--spectrum-accordion-item-content-font-style)); - font-size: var(--mod-accordion-item-content-font-size, var(--spectrum-accordion-item-content-font-size)); - font-family: var(--mod-accordion-item-content-font, var(--spectrum-accordion-item-content-font)); - line-height: var(--mod-accordion-item-content-line-height, var(--spectrum-accordion-item-content-line-height)); + padding-block: var(--spectrum-accordion-item-content-area-top-to-content) var(--spectrum-accordion-item-content-area-bottom-to-content); + padding-inline: var(--spectrum-accordion-content-padding-inline); + color: var(--spectrum-accordion-item-content-color); + font-weight: var(--spectrum-accordion-item-content-font-weight); + font-style: var(--spectrum-accordion-item-content-font-style); + font-size: var(--spectrum-accordion-item-content-font-size); + font-family: var(--spectrum-accordion-item-content-font); + line-height: var(--spectrum-accordion-item-content-line-height); } -.spectrum-Accordion-itemHeader { - position: relative; +.spectrum-Accordion-itemTitle { + /* if we use min-height token, sometimes we'll have extra space so we'll need to center the text vertically */ display: flex; align-items: center; - justify-content: flex-start; - box-sizing: border-box; - padding-block: var(--mod-accordion-item-header-top-to-text-space, var(--spectrum-accordion-item-header-top-to-text-space)) var(--mod-accordion-item-header-bottom-to-text-space, var(--spectrum-accordion-item-header-bottom-to-text-space)); + min-block-size: var(--spectrum-accordion-item-min-block-size); + box-sizing: border-box; /* respect min-block-size but include padding */ + padding-block: var(--spectrum-accordion-item-header-top-to-text-space) var(--spectrum-accordion-item-header-bottom-to-text-space); + padding-inline-end: var(--spectrum-accordion-edge-to-text-space); +} - padding-inline-start: calc(var(--mod-accordion-disclosure-indicator-to-text-space, var(--spectrum-accordion-disclosure-indicator-to-text-space)) + var(--mod-accordion-disclosure-indicator-height, var(--spectrum-accordion-disclosure-indicator-height))); - padding-inline-end: var(--mod-accordion-edge-to-text-space, var(--spectrum-accordion-edge-to-text-space)); +/* Focusable button that expands/collapses the accordion item. */ +.spectrum-Accordion-itemHeader { + overflow-wrap: anywhere; + word-break: normal; + box-sizing: border-box; + position: relative; + display: flex; + align-items: flex-start; + justify-content: flex-start; - min-block-size: var(--mod-accordion-min-block-size, var(--spectrum-accordion-min-block-size)); - line-height: var(--mod-accordion-item-header-line-height, var(--spectrum-accordion-item-header-line-height)); + /* start spacing controlled by edge to disclosure icon spacing */ + padding-inline: 0 var(--spectrum-accordion-edge-to-content-area); + padding-block: 0; /* reset user-agent styles */ + line-height: var(--spectrum-accordion-item-header-line-height); text-overflow: ellipsis; - cursor: pointer; - font-size: var(--mod-accordion-item-header-font-size, var(--spectrum-accordion-item-header-font-size)); - font-weight: var(--mod-accordion-item-header-font-weight, var(--spectrum-accordion-item-header-font-weight)); - font-style: var(--mod-accordion-item-header-font-style, var(--spectrum-accordion-item-header-font-style)); - font-family: var(--mod-accordion-item-header-font, var(--spectrum-accordion-item-header-font)); + cursor: var(--spectrum-accordion-item-header-cursor); + font-size: var(--spectrum-accordion-item-header-font-size); + font-weight: var(--spectrum-accordion-item-header-font-weight); + font-style: var(--spectrum-accordion-item-header-font-style); + font-family: var(--spectrum-accordion-item-header-font); - /* reset styling if button element is used */ + /* Reset styling of button element */ appearance: none; border: 0; text-align: start; inline-size: 100%; - &:focus { - outline: none; - - &::after { - content: ""; - position: absolute; - inset-inline-start: 0; - } - } - color: var(--mod-accordion-item-header-color-default, var(--spectrum-accordion-item-header-color-default)); - background-color: var(--mod-accordion-background-color-default, var(--spectrum-accordion-background-color-default)); + color: var(--spectrum-accordion-item-header-color-default); + background-color: var(--spectrum-accordion-background-color-default); &:hover { - color: var(--mod-accordion-item-header-color-hover, var(--spectrum-accordion-item-header-color-hover)); - background-color: var(--mod-accordion-background-color-hover, var(--spectrum-accordion-background-color-hover)); - - + .spectrum-Accordion-itemIconContainer { - color: var(--mod-accordion-item-header-color-hover, var(--spectrum-accordion-item-header-color-hover)); - } + color: var(--spectrum-accordion-item-header-color-hover); + background-color: var(--spectrum-accordion-background-color-hover); } &:focus-visible { - border-radius: var(--mod-accordion-corner-radius, var(--spectrum-accordion-corner-radius)); + border-radius: var(--spectrum-accordion-corner-radius); + background-color: var(--spectrum-accordion-background-color-key-focus); + color: var(--spectrum-accordion-item-header-color-key-focus); + outline: var(--spectrum-accordion-item-focus-indicator-thickness) solid var(--spectrum-accordion-item-focus-indicator-color); + outline-offset: var(--spectrum-accordion-item-focus-indicator-gap); + } - outline: var(--mod-accordion-focus-indicator-thickness, var(--spectrum-accordion-focus-indicator-thickness)) solid var(--mod-accordion-focus-indicator-color, var(--spectrum-accordion-focus-indicator-color)); - background-color: var(--mod-accordion-background-color-key-focus, var(--spectrum-accordion-background-color-key-focus)); - color: var(--mod-accordion-item-header-color-key-focus, var(--spectrum-accordion-item-header-color-key-focus)); - outline-offset: calc(var(--mod-accordion-focus-indicator-gap, var(--spectrum-accordion-focus-indicator-gap)) * -1); + /* higher specificity to maintain active styles over @media hover styles */ + &.spectrum-Accordion-itemHeader:active { + background-color: var(--spectrum-accordion-background-color-down); + color: var(--spectrum-accordion-item-header-color-down); } - &:active { - background-color: var(--mod-accordion-background-color-down, var(--spectrum-accordion-background-color-down)); - color: var(--mod-accordion-item-header-color-down, var(--spectrum-accordion-item-header-color-down)); + &:has(+ .spectrum-Accordion-itemDirectActions) { + /* set spacing between header and direct actions, whether or not noInlinePadding variant is used */ + margin-inline-end: var(--spectrum-accordion-item-header-to-direct-actions-space); } } -.spectrum-Accordion-item { - &.is-open { - .spectrum-Accordion-itemHeader:hover { - background-color: var(--mod-accordion-background-color-hover, var(--spectrum-accordion-background-color-hover)); - } - } +.spectrum-Accordion-itemDirectActions { + margin-inline-end: var(--spectrum-accordion-edge-to-content-area); + display: inline-flex; + gap: var(--spectrum-accordion-item-direct-actions-spacing); + + /* margin needs to be set on top and bottom to keep compact XL items vertically centered and prevent them from growing vertically */ + margin-block: var(--spectrum-accordion-item-direct-actions-vertical-spacing); } -.spectrum-Accordion-item.is-disabled { - .spectrum-Accordion-itemHeader { - &, - &:hover, - &:focus-visible { - color: var(--mod-accordion-item-header-disabled-color, var(--spectrum-accordion-item-header-disabled-color)); - background-color: transparent; - } - - + .spectrum-Accordion-itemIconContainer { - color: var(--mod-accordion-item-header-disabled-color, var(--spectrum-accordion-item-header-disabled-color)); - } +.spectrum-Accordion-item.is-open { + > .spectrum-Accordion-itemHeading .spectrum-Accordion-itemIndicator { + transform: var(--spectrum-logical-rotation,) rotate(90deg); } - .spectrum-Accordion-itemContent { - color: var(--mod-accordion-item-content-disabled-color, var(--spectrum-accordion-item-content-disabled-color)); + > .spectrum-Accordion-itemContent { + display: block; } } -@media (forced-colors: active) { - .spectrum-Accordion-itemHeader { - &::after { - /* make sure focus ring renders */ - forced-color-adjust: none; - content: ""; - position: absolute; - inset-inline-start: 0; - } +.spectrum-Accordion--quiet .spectrum-Accordion-itemHeader { + &:hover, + &:active { + border-radius: var(--spectrum-accordion-corner-radius); } } -.spectrum-Accordion-item { - &.is-open { - > .spectrum-Accordion-itemHeading > .spectrum-Accordion-itemIconContainer > .spectrum-Accordion-itemIndicator, - > .spectrum-Accordion-itemIconContainer > .spectrum-Accordion-itemIndicator { - transform: var(--spectrum-logical-rotation,) rotate(90deg); - } - - > .spectrum-Accordion-itemContent { - display: block; - } - } - - &.is-disabled { - .spectrum-Accordion-itemHeader { - cursor: default; - } +@media (forced-colors: active) { + .spectrum-Accordion { + --spectrum-accordion-item-focus-indicator-color: Highlight; } } diff --git a/components/accordion/package.json b/components/accordion/package.json index 8827aa16b7e..151a1fd4114 100644 --- a/components/accordion/package.json +++ b/components/accordion/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/accordion", - "version": "7.2.0", + "version": "8.0.0-next.5", "description": "The Spectrum CSS accordion component", "license": "Apache-2.0", "author": "Adobe", @@ -19,15 +19,13 @@ "./package.json": "./package.json", "./dist/*": "./dist/*", "./index.css": "./dist/index.css", - "./index-*.css": "./dist/index-*.css", "./metadata.json": "./dist/metadata.json", - "./themes/*": "./dist/themes/*", "./stories/*": "./stories/*" }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/icon": ">=9.0.0 <10.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/icon": ">=10.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/icon": { @@ -38,8 +36,8 @@ } }, "devDependencies": { - "@spectrum-css/icon": "9.2.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/icon": "10.0.0-next.3", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/accordion/stories/accordion.stories.js b/components/accordion/stories/accordion.stories.js index 3709e75871f..1b19feee243 100644 --- a/components/accordion/stories/accordion.stories.js +++ b/components/accordion/stories/accordion.stories.js @@ -1,19 +1,21 @@ -import { Template as Link } from "@spectrum-css/link/stories/template.js"; +import { default as IconStories } from "@spectrum-css/icon/stories/icon.stories.js"; import { Sizes } from "@spectrum-css/preview/decorators"; import { disableDefaultModes } from "@spectrum-css/preview/modes"; -import { size } from "@spectrum-css/preview/types"; -import { Template as Typography } from "@spectrum-css/typography/stories/template.js"; +import { isQuiet, size } from "@spectrum-css/preview/types"; import metadata from "../dist/metadata.json"; import packageJson from "../package.json"; -import { AccordionGroup } from "./accordion.test.js"; +import { AccordionGroup, testsContent as accordionContent, directActionsContent, longerContent } from "./accordion.test.js"; import { Template } from "./template.js"; /** - * The accordion element contains a list of items that can be expanded or collapsed to reveal additional content or information associated with each item. There can be zero expanded items, exactly one expanded item, or more than one item expanded at a time, depending on the configuration. This list of items is defined by child accordion item elements. + * The accordion element contains a list of items that can be expanded or collapsed to reveal + * additional content or information associated with each item. There can be zero expanded items, + * exactly one expanded item, or more than one item expanded at a time, depending on the + * configuration. This list of items is defined by child accordion item elements. * - * ## Density options - * - * Accordion has three density options and requires that you specify one of the density types: compact, regular, or spacious. + * Accordion has three density options: regular (default), compact, or spacious. While all the + * densities maintain the same font size, compact density reduces vertical spacing between rows, + * while spacious density increases it. */ export default { title: "Accordion", @@ -49,6 +51,46 @@ export default { options: ["compact", "regular", "spacious"], control: "select", }, + hasNoInlinePadding: { + name: "No inline padding styling", + description: "Displays accordion item headers without default inline padding.", + type: { name: "boolean" }, + table: { + type: { summary: "boolean" }, + category: "Component", + }, + control: { type: "boolean" }, + }, + isQuiet, + hasActionButtons: { + name: "Has action buttons", + description: "Adds an action button to each accordion item header, in the direct actions section.", + type: { name: "boolean" }, + table: { + type: { summary: "boolean" }, + category: "Direct actions", + }, + control: { type: "boolean" }, + }, + actionButtonIconName: { + name: "Action button icon", + ...(IconStories?.argTypes?.iconName ?? {}), + if: { arg: "hasActionButtons", truthy: true }, + table: { + type: { summary: "string" }, + category: "Direct actions", + }, + }, + hasSwitches: { + name: "Has switches", + description: "Adds a switch to each accordion item header, in the direct actions section.", + type: { name: "boolean" }, + table: { + type: { summary: "boolean" }, + category: "Direct actions", + }, + control: { type: "boolean" }, + }, }, args: { rootClass: "spectrum-Accordion", @@ -56,6 +98,11 @@ export default { density: "regular", collapseAll: false, disableAll: false, + isQuiet: false, + hasNoInlinePadding: false, + hasActionButtons: false, + actionButtonIconName: "Circle", + hasSwitches: false, }, parameters: { actions: { @@ -68,101 +115,19 @@ export default { }, packageJson, metadata, + status: { + type: "migrated", + }, }, + tags: ["migrated"], }; -/* Content sourced from: https://www.adobe.com/products/catalog.html#:~:text=Frequently%20asked%20questions. */ -const content = new Map([ - [ - "Are any Adobe products free?", - { - content: - "Yes, Adobe offers free products like Acrobat Reader, Aero, Fill & Sign, Photoshop Express, and Adobe Scan. You can also use Creative Cloud Express, Fresco, and Lightroom Mobile for free, with the option of making in-app purchases.", - isDisabled: true, - }, - ], - [ - "Are Adobe products worth it?", - { - content: Typography({ - semantics: "body", - content: [ - "Adobe makes some of the most widely used software applications in the world, many of which are industry standard. Get started with free apps like Adobe Acrobat Reader, Aero, Fill & Sign, Photoshop Express, and Adobe Scan. Or consider Creative Cloud, with plans starting at just US$9.99/mo. Every Adobe Creative Cloud plan includes perks like free stock images and fonts, collaboration tools, and cloud storage as well as regular feature updates to deliver the latest technology.", - Link({ - url: "https://www.adobe.com/creativecloud/plans.html", - text: "Learn more about Adobe Creative Cloud plans and pricing.", - }), - ], - }), - isOpen: true, - }, - ], - [ - "Which Adobe product is best for editing PDFs?", - { - content: Typography({ - semantics: "body", - content: [ - "You can edit PDFs with Adobe Acrobat, which is available in two editions: Standard and Pro. Acrobat Standard provides basic tools to create, edit, and sign PDFs on Windows devices. Acrobat Pro is the complete PDF solution with tools to edit, convert, and sign PDFs across web, mobile, and tablet, as well as on Windows and macOS computers. If you'd like to try before you buy, you can get a free 7-day trial of Acrobat Pro.", - Link({ - url: "https://www.adobe.com/acrobat.html", - text: "Learn more about Acrobat.", - }), - ], - }), - }, - ], - [ - "How many products does Adobe have?", - { - content: - "Adobe offers nearly 100 products. Get creative with industry-standard apps like Adobe Photoshop, Illustrator InDesign, and Lightroom. Create, edit, and sign PDFs with Adobe Acrobat and Acrobat Sign. And deliver exceptional customer experiences with our marketing and commerce apps such as Adobe Experience Manager, Campaign, and Target.", - isOpen: true, - }, - ], - [ - "How much do Adobe products cost?", - { - content: Typography({ - semantics: "body", - content: [ - "Creative Cloud plans start at US$9.99/mo. You can subscribe to specific Single App plans or get 20+ creative apps and services in the Creative Cloud All Apps plan.", - Link({ - url: "https://www.adobe.com/creativecloud/plans.html", - text: "Explore Creative Cloud plans.", - }), - ], - }), - }, - ], - [ - "What are the most popular Adobe products?", - { - content: - "Adobe makes some of the most widely used software in the world, including popular apps like Acrobat Pro, Photoshop, Illustrator, InDesign, Lightroom, and Premiere Pro.", - }, - ], - [ - "How can I get a student discount on Adobe products?", - { - content: Typography({ - semantics: "body", - content: [ - `Students who provide a valid school-issued email address at purchase are eligible to save over 60% on Creative Cloud All Apps, which includes 20+ apps such as Photoshop, Illustrator, InDesign, Acrobat Pro, and more. ${Link( - { - url: "https://www.adobe.com/creativecloud/buy/students.html", - text: "Learn more about Creative Cloud for students.", - } - )}`, - ], - }), - }, - ] -]); - +/** + * The default accordion displays at medium size with a regular density. + */ export const Default = AccordionGroup.bind({}); Default.args = { - items: content, + items: accordionContent, }; Default.parameters = { chromatic: { disableSnapshot: false }, @@ -180,33 +145,129 @@ WithForcedColors.parameters = { }; // ********* DOCS ONLY ********* // + +/** + * Accordion items have a default width for each size, but a custom width can also be set to any + * width that meets or exceeds the minimum width. + * + * This example also uses the body typography element with class `.spectrum-Body` for the + * accordion item's content. If using typography, the t-shirt size of the typography element + * may need to be adjusted to match the accordion item's font size. The body typography component + * shown here is a size "S," in contrast with the the accordion's "M" size. + */ +export const CustomWidth = AccordionGroup.bind({}); +CustomWidth.tags = ["!dev"]; +CustomWidth.storyName = "Custom width"; +CustomWidth.args = { + items: longerContent, + customStyles: { + "--spectrum-accordion-item-width": "auto", + }, +}; +CustomWidth.parameters = { + chromatic: { disableSnapshot: true }, +}; + +/** + * The compact density has less vertical spacing between rows. + */ export const Compact = Template.bind({}); Compact.tags = ["!dev"]; Compact.args = { - items: content, + items: accordionContent, density: "compact", }; Compact.parameters = { chromatic: { disableSnapshot: true }, }; -Compact.storyName = "Density - Compact"; +Compact.storyName = "Density: Compact"; +/** + * The spacious density has more vertical spacing between rows. + */ export const Spacious = Template.bind({}); Spacious.tags = ["!dev"]; Spacious.args = { - items: content, + items: accordionContent, density: "spacious", }; Spacious.parameters = { chromatic: { disableSnapshot: true }, }; -Spacious.storyName = "Density - Spacious"; +Spacious.storyName = "Density: Spacious"; +/** + * Direct actions within accordion items are supported. A quiet + * [action button](/?path=/docs/actionbutton--default), a + * [switch](/?path=/docs/switch--default), or both can be added to + * each accordion item header. + */ +export const DirectActions = Template.bind({}); +DirectActions.tags = ["!dev"]; +DirectActions.args = { + items: directActionsContent +}; +DirectActions.parameters = { + chromatic: { disableSnapshot: true }, +}; + +/** + * Individual accordion items can be disabled by applying the `.is-disabled` class to the + * `.spectrum-Accordion-item` element. This example also demonstrates the use of the disabled + * attribute on the heading button. + */ +export const Disabled = Template.bind({}); +Disabled.tags = ["!dev"]; +Disabled.args = { + items: accordionContent, + disableAll: true, +}; +Disabled.parameters = { + chromatic: { disableSnapshot: true }, +}; + +/** + * The optional quiet style for accordion has no dividers between sections. This style works best + * when a clear layout (vertical stack, table, grid) makes it easy to see and understand because + * too many quiet components in a small space can be hard to differentiate. This can be applied by + * adding the `.spectrum-Accordion--quiet` class alongside the parent `.spectrum-Accordion` class. + */ +export const Quiet = Template.bind({}); +Quiet.tags = ["!dev"]; +Quiet.args = { + items: accordionContent, + isQuiet: true, +}; +Quiet.parameters = { + chromatic: { disableSnapshot: true }, +}; + +/** + * Implementations may choose to remove inline padding from the accordion item headers by adding + * the `.spectrum-Accordion--noInlinePadding` class alongside the parent `.spectrum-Accordion` + * class. Accordion item header padding will be removed, but the body text content will keep its + * own padding from the edge. + */ +export const NoInlinePadding = Template.bind({}); +NoInlinePadding.storyName = "No inline padding"; +NoInlinePadding.tags = ["!dev"]; +NoInlinePadding.args = { + items: accordionContent, + hasNoInlinePadding: true, +}; +NoInlinePadding.parameters = { + chromatic: { disableSnapshot: true }, +}; + +/** + * Each of the different sizes has varying font sizes, and varying vertical spacing between the + * rows. Medium is the default size. + */ export const Sizing = (args, context) => Sizes({ Template, withBorder: false, withHeading: false, - items: content, + items: accordionContent, ...args, }, context); Sizing.tags = ["!dev"]; diff --git a/components/accordion/stories/accordion.test.js b/components/accordion/stories/accordion.test.js index 192400fe3fb..6ded894342c 100644 --- a/components/accordion/stories/accordion.test.js +++ b/components/accordion/stories/accordion.test.js @@ -1,17 +1,257 @@ -import { Variants } from "@spectrum-css/preview/decorators"; +import { Template as Link } from "@spectrum-css/link/stories/template.js"; +import { Sizes, Variants } from "@spectrum-css/preview/decorators"; +import { Template as Typography } from "@spectrum-css/typography/stories/template.js"; import { Template } from "./template.js"; +/** + * General accordion item content for tests. + */ +export const testsContent = new Map([ + [ + "Abstract", + { + content: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec eleifend est mollis ligula lobortis, tempus ultricies sapien lacinia. Nulla ut turpis velit. Sed finibus dapibus diam et sollicitudin. Phasellus in ipsum nec ante elementum congue eget in leo. Morbi eleifend justo non rutrum venenatis. Fusce cursus et lectus eu facilisis. Ut laoreet felis in magna dignissim feugiat.", + }, + ], + [ + "Architecture", + { + content: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec eleifend est mollis ligula lobortis, tempus ultricies sapien lacinia. Nulla ut turpis velit. Sed finibus dapibus diam et sollicitudin. Phasellus in ipsum nec ante elementum congue eget in leo. Morbi eleifend justo non rutrum venenatis. Fusce cursus et lectus eu facilisis. Ut laoreet felis in magna dignissim feugiat.", + isOpen: true, + }, + ], + [ + "Nature", + { + content: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec eleifend est mollis ligula lobortis, tempus ultricies sapien lacinia. Nulla ut turpis velit. Sed finibus dapibus diam et sollicitudin. Phasellus in ipsum nec ante elementum congue eget in leo. Morbi eleifend justo non rutrum venenatis. Fusce cursus et lectus eu facilisis. Ut laoreet felis in magna dignissim feugiat.", + }, + ], + [ + "Illustrations", + { + content: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec eleifend est mollis ligula lobortis, tempus ultricies sapien lacinia. Nulla ut turpis velit. Sed finibus dapibus diam et sollicitudin. Phasellus in ipsum nec ante elementum congue eget in leo. Morbi eleifend justo non rutrum venenatis. Fusce cursus et lectus eu facilisis. Ut laoreet felis in magna dignissim feugiat.", + }, + ], + [ + "Business", + { + content: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec eleifend est mollis ligula lobortis, tempus ultricies sapien lacinia. Nulla ut turpis velit. Sed finibus dapibus diam et sollicitudin. Phasellus in ipsum nec ante elementum congue eget in leo. Morbi eleifend justo non rutrum venenatis. Fusce cursus et lectus eu facilisis. Ut laoreet felis in magna dignissim feugiat.", + }, + ], + [ + "Landscape and longer text that wraps", + { + content: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec eleifend est mollis ligula lobortis, tempus ultricies sapien lacinia. Nulla ut turpis velit. Sed finibus dapibus diam et sollicitudin. Phasellus in ipsum nec ante elementum congue eget in leo. Morbi eleifend justo non rutrum venenatis. Fusce cursus et lectus eu facilisis. Ut laoreet felis in magna dignissim feugiat.", + }, + ], +]); + +/** + * Longer content for a custom width accordion. + * Content sourced from: https://www.adobe.com/products/catalog.html#:~:text=Frequently%20asked%20questions. + */ +export const longerContent = new Map([ + [ + "Are any Adobe products free?", + { + content: "Yes, Adobe offers free products like Acrobat Reader, Aero, Fill & Sign, Photoshop Express, and Adobe Scan. You can also use Creative Cloud Express, Fresco, and Lightroom Mobile for free, with the option of making in-app purchases.", + }, + ], + [ + "Are Adobe products worth it?", + { + content: Typography({ + size: "s", + semantics: "body", + content: [ + "Adobe makes some of the most widely used software applications in the world, many of which are industry standard. Get started with free apps like Adobe Acrobat Reader, Aero, Fill & Sign, Photoshop Express, and Adobe Scan. Or consider Creative Cloud, with plans starting at just US$9.99/mo. Every Adobe Creative Cloud plan includes perks like free stock images and fonts, collaboration tools, and cloud storage as well as regular feature updates to deliver the latest technology.", + Link({ + url: "https://www.adobe.com/creativecloud/plans.html", + text: "Learn more about Adobe Creative Cloud plans and pricing.", + }), + ], + }), + isOpen: true, + }, + ], + [ + "Which Adobe product is best for editing PDFs?", + { + content: Typography({ + size: "s", + semantics: "body", + content: [ + "You can edit PDFs with Adobe Acrobat, which is available in two editions: Standard and Pro. Acrobat Standard provides basic tools to create, edit, and sign PDFs on Windows devices. Acrobat Pro is the complete PDF solution with tools to edit, convert, and sign PDFs across web, mobile, and tablet, as well as on Windows and macOS computers. If you'd like to try before you buy, you can get a free 7-day trial of Acrobat Pro.", + Link({ + url: "https://www.adobe.com/acrobat.html", + text: "Learn more about Acrobat.", + }), + ], + }), + }, + ], + [ + "How many products does Adobe have?", + { + content: "Adobe offers nearly 100 products. Get creative with industry-standard apps like Adobe Photoshop, Illustrator, InDesign, and Lightroom. Create, edit, and sign PDFs with Adobe Acrobat and Acrobat Sign. And deliver exceptional customer experiences with our marketing and commerce apps such as adobe experience manager, Campaign, and Target.", + isOpen: true, + }, + ], + [ + "What are the most popular Adobe products?", + { + content: "Adobe makes some of the most widely used software in the world, including popular apps like Acrobat Pro, Photoshop, Illustrator, InDesign, Lightroom, and Premiere Pro.", + }, + ], +]); + +export const directActionsContent = new Map([ + [ + "Heading 1", + { + content: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", + hasActionButton: true, + }, + ], + [ + "Heading 2", + { + content: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.", + hasSwitch: true, + }, + ], + [ + "Heading 3", + { + content: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.", + hasActionButton: true, + hasSwitch: true, + isOpen: true, + }, + ], +]); + +const defaultContentText = "This is an example of text content within the content area that is not wrapped by any typography classes or elements."; + +/** + * Content for testing accordion item states. + */ +const statesTestContent = new Map([ + [ + "Hovered", + { + isHovered: true, + content: defaultContentText, + }, + ], + [ + "Disabled", + { + isDisabled: true, + content: defaultContentText, + }, + ], + [ + "Hovered + disabled", + { + isDisabled: true, + isHovered: true, + content: defaultContentText, + }, + ], + [ + "Focus-visible", + { + isFocused: true, + content: defaultContentText, + }, + ], + [ + "Active/down", + { + isActive: true, + content: defaultContentText, + }, + ], + [ + "Active/down + hovered", + { + isActive: true, + isHovered: true, + content: defaultContentText, + }, + ], + [ + "Focus-visible + hovered", + { + isFocused: true, + isHovered: true, + content: defaultContentText, + }, + ], +]); + export const AccordionGroup = Variants({ + withSizes: false, Template, testData: [ { testHeading: "Standard", + items: testsContent, + customStyles: { + maxInlineSize: "500px", + }, + }, + { + testHeading: "Quiet", + items: testsContent, + isQuiet: true, + customStyles: { + maxInlineSize: "500px", + }, + }, + { + testHeading: "No Inline Padding", + items: testsContent, + hasNoInlinePadding: true, customStyles: { maxInlineSize: "500px", }, }, { - testHeading: "Compact", + testHeading: "Heading text wrapping", + items: new Map([ + [ + "This example has a heading that wraps to two lines.", + { + content: defaultContentText, + isOpen: false, + }, + ], + [ + "This example has a heading that wraps to more than two lines. What are the most popular Adobe products?", + { + content: defaultContentText, + isOpen: false, + }, + ], + [ + "This example has a heading that wraps to more than two lines. It also shows the text in its content area.", + { + content: defaultContentText, + isOpen: true, + }, + ], + ]), + customStyles: { + maxInlineSize: "300px", + }, + withStates: false, + }, + { + testHeading: "Compact density", + items: new Map([...testsContent, ...directActionsContent]), + Template: (args, context) => { return Sizes({Template: Template, ...args}, context); }, density: "compact", collapseAll: true, customStyles: { @@ -20,8 +260,10 @@ export const AccordionGroup = Variants({ withStates: false, }, { - testHeading: "Spacious", - density: "spacious", + testHeading: "Regular density", + items: new Map([...testsContent, ...directActionsContent]), + Template: (args, context) => { return Sizes({Template: Template, ...args}, context); }, + density: "regular", collapseAll: true, customStyles: { maxInlineSize: "500px", @@ -29,18 +271,21 @@ export const AccordionGroup = Variants({ withStates: false, }, { - testHeading: "Text wrapping", + testHeading: "Spacious density", + items: new Map([...testsContent, ...directActionsContent]), + Template: (args, context) => { return Sizes({Template: Template, ...args}, context); }, + density: "spacious", collapseAll: true, customStyles: { - maxInlineSize: "300px", + maxInlineSize: "500px", }, withStates: false, }, ], stateData: [ { - testHeading: "Disabled", - disableAll: true, + testHeading: "Accordion item states", + items: statesTestContent, }, ], }); diff --git a/components/accordion/stories/template.js b/components/accordion/stories/template.js index 8294f3a4027..e12314a460f 100644 --- a/components/accordion/stories/template.js +++ b/components/accordion/stories/template.js @@ -1,15 +1,15 @@ +import { Template as ActionButton } from "@spectrum-css/actionbutton/stories/template.js"; import { Template as Icon } from "@spectrum-css/icon/stories/template.js"; import { getRandomId } from "@spectrum-css/preview/decorators"; +import { Template as Switch } from "@spectrum-css/switch/stories/template.js"; import { html } from "lit"; import { classMap } from "lit/directives/class-map.js"; import { ifDefined } from "lit/directives/if-defined.js"; import { repeat } from "lit/directives/repeat.js"; import { styleMap } from "lit/directives/style-map.js"; +import { when } from "lit/directives/when.js"; import "../index.css"; -import "../themes/spectrum.css"; -/* Must be imported last */ -import "../themes/express.css"; export const AccordionItem = ({ heading, @@ -19,6 +19,13 @@ export const AccordionItem = ({ idx = 0, isDisabled = false, isOpen = false, + isHovered = false, + isActive = false, + isFocused = false, + hasActionButton = false, + hasSwitch = false, + actionButtonIconName = "", + size = "m", iconSize = "m", customStyles = {}, customClasses = [], @@ -41,25 +48,57 @@ export const AccordionItem = ({

- ${Icon({ - iconName: !isOpen ? "ChevronRight" : "ChevronDown", + iconName: (!isOpen ? "ChevronRight" : "ChevronDown") + ({ + s: "75", + m: "100", + l: "200", + xl: "300", + }[iconSize] || "100"), setName: "ui", size: iconSize, customClasses: [`${rootClass}Indicator`], }, context)} - + ${heading} + + ${when( + hasActionButton || hasSwitch, + () => + html` +
+ ${when(hasActionButton, () => + ActionButton({ + label: "", // icon-only + isQuiet: true, + customClasses: [`${rootClass}ActionButton`], + iconName: actionButtonIconName || "Circle", + isDisabled, + size, + }, context) + )} + ${when(hasSwitch, () => + Switch({ + label: "", + customClasses: [`${rootClass}Switch`], + isDisabled, + size + }, context))} +
+ `)}

- +
{ @@ -90,9 +134,11 @@ export const Template = ({ class="${classMap({ [rootClass]: true, [`${rootClass}--size${size?.toUpperCase()}`]: - typeof size !== "undefined", + typeof size !== "undefined" && size !== "m", [`${rootClass}--${density}`]: typeof density !== "undefined" && density !== "regular", + [`${rootClass}--quiet`]: isQuiet, + [`${rootClass}--noInlinePadding`]: hasNoInlinePadding, ...customClasses.reduce((a, c) => ({ ...a, [c]: true }), {}), })}" id=${ifDefined(id)} @@ -106,6 +152,10 @@ export const Template = ({ rootClass: `${rootClass}-item`, heading, idx, + size, + hasActionButton: item.hasActionButton || hasActionButtons, + actionButtonIconName: item.actionButtonIconName || actionButtonIconName, + hasSwitch: item.hasSwitch || hasSwitches, iconSize: `${size}`, isDisabled: item.isDisabled || disableAll, isOpen: collapseAll === true ? false : item.isOpen, diff --git a/components/accordion/themes/express.css b/components/accordion/themes/express.css deleted file mode 100644 index 9fd550418f2..00000000000 --- a/components/accordion/themes/express.css +++ /dev/null @@ -1,16 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--express */ - -@import "./spectrum.css"; diff --git a/components/accordion/themes/spectrum-two.css b/components/accordion/themes/spectrum-two.css deleted file mode 100644 index 7097b1adc62..00000000000 --- a/components/accordion/themes/spectrum-two.css +++ /dev/null @@ -1,20 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -@container style(--system: spectrum) { - .spectrum-Accordion { - --spectrum-accordion-divider-color: var(--spectrum-gray-200); - --spectrum-accordion-item-content-disabled-color: var(--spectrum-disabled-content-color); - --spectrum-accordion-item-content-color: var(--spectrum-body-color); - } -} diff --git a/components/accordion/themes/spectrum.css b/components/accordion/themes/spectrum.css deleted file mode 100644 index 572d3f1db1b..00000000000 --- a/components/accordion/themes/spectrum.css +++ /dev/null @@ -1,24 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--legacy */ - -@import "./spectrum-two.css"; - -@container style(--system: legacy) { - .spectrum-Accordion { - --spectrum-accordion-divider-color: var(--spectrum-gray-300); - --spectrum-accordion-item-content-disabled-color: var(--spectrum-gray-400); - --spectrum-accordion-item-content-color: var(--spectrum-gray-800); - } -} diff --git a/components/actionbar/CHANGELOG.md b/components/actionbar/CHANGELOG.md index 110b9315bcc..4aa1e2e4c58 100644 --- a/components/actionbar/CHANGELOG.md +++ b/components/actionbar/CHANGELOG.md @@ -1,5 +1,63 @@ # Change log +## 11.0.0-next.3 + +### Major Changes + +📝 [#4249](https://github.com/adobe/spectrum-css/pull/4249) [`9629fe3`](https://github.com/adobe/spectrum-css/commit/9629fe37cad996d47c827a3eabcdf39092a27b0d) Thanks [@castastrophe](https://github.com/castastrophe)! + +This update removes `--mod-*` custom property hooks per SWC-1264, see also the RFC for extensible styling. + +- Remove all `--mod-*` custom property hooks. +- Keep existing class selectors and variants unchanged. +- Update stories to reflect the removal of the `--mod-*` override layer. + +Breaking change: the `--mod-*` override layer is removed. Consumers should set `--spectrum-*` variables directly where customization is needed. + +## 11.0.0-next.2 + +### Major Changes + +- [#3657](https://github.com/adobe/spectrum-css/pull/3657) [`c06e995`](https://github.com/adobe/spectrum-css/commit/c06e9953caaaafa3c3f1841057e26c6212754ae5) Thanks [@aramos-adobe](https://github.com/aramos-adobe)! + +#### Action bar S2 migration + +Action bar now has some updated colors, corner radius, and icons. There's a new look to the default and emphasized variants. + +The emphasized has changed from an `accent` background color to a `neutral` background color. In light mode, the clear button and action buttons are `staticWhite` and in dark mode they are `staticBlack`. + +##### New tokens + +`--spectrum-actionbar-emphasized-actionbutton-label-color` +`--spectrum-actionbar-emphasized-icon-color` +`--spectrum-actionbar-minimum-width` +`--spectrum-actionbar-spacing-label-to-action-group` +`--spectrum-actionbar-spacing-action-group-edge` +`--spectrum-actionbar-close-button-to-counter` + +##### New modifiers + +`--mod-actionbar-minimum-width` +`--mod-actionbar-spacing-action-group-edge` +`--mod-actionbar-spacing-label-to-action-group` + +## 11.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + +## 11.0.0-next.0 + +### Patch Changes + +- Updated dependencies []: + - @spectrum-css/closebutton@7.0.0-next.0 + - @spectrum-css/fieldlabel@11.0.0-next.0 + - @spectrum-css/actiongroup@7.0.0-next.0 + - @spectrum-css/popover@9.0.0-next.0 + ## 10.2.0 ### Minor Changes diff --git a/components/actionbar/dist/metadata.json b/components/actionbar/dist/metadata.json index 3632db90bf7..b0d9b4df5f2 100644 --- a/components/actionbar/dist/metadata.json +++ b/components/actionbar/dist/metadata.json @@ -2,96 +2,44 @@ "sourceFile": "index.css", "selectors": [ ".spectrum-ActionBar", - ".spectrum-ActionBar .spectrum-ActionBar-popover", ".spectrum-ActionBar .spectrum-ActionGroup", - ".spectrum-ActionBar .spectrum-CloseButton", ".spectrum-ActionBar .spectrum-FieldLabel", ".spectrum-ActionBar .spectrum-FieldLabel:lang(ja)", ".spectrum-ActionBar .spectrum-FieldLabel:lang(ko)", ".spectrum-ActionBar .spectrum-FieldLabel:lang(zh)", - ".spectrum-ActionBar--emphasized .spectrum-ActionBar-popover", + ".spectrum-ActionBar .spectrum-Popover", ".spectrum-ActionBar--emphasized .spectrum-FieldLabel", + ".spectrum-ActionBar--emphasized .spectrum-Popover", ".spectrum-ActionBar--fixed", ".spectrum-ActionBar--flexible .spectrum-ActionBar-popover", ".spectrum-ActionBar--sticky", - ".spectrum-ActionBar.is-open", - ".spectrum-ActionBar:lang(ja)", - ".spectrum-ActionBar:lang(ko)", - ".spectrum-ActionBar:lang(zh)" - ], - "modifiers": [ - "--mod-actionbar-corner-radius", - "--mod-actionbar-emphasized-background-color", - "--mod-actionbar-emphasized-item-counter-color", - "--mod-actionbar-height", - "--mod-actionbar-item-counter-color", - "--mod-actionbar-item-counter-font-size", - "--mod-actionbar-item-counter-line-height", - "--mod-actionbar-item-counter-line-height-cjk", - "--mod-actionbar-popover-background-color", - "--mod-actionbar-popover-border-color", - "--mod-actionbar-shadow-blur", - "--mod-actionbar-shadow-color", - "--mod-actionbar-shadow-horizontal", - "--mod-actionbar-shadow-vertical", - "--mod-actionbar-spacing-action-group-end", - "--mod-actionbar-spacing-action-group-top", - "--mod-actionbar-spacing-close-button-end", - "--mod-actionbar-spacing-close-button-start", - "--mod-actionbar-spacing-close-button-top", - "--mod-actionbar-spacing-item-counter-end", - "--mod-actionbar-spacing-item-counter-top", - "--mod-actionbar-spacing-outer-edge" + ".spectrum-ActionBar.is-open" ], + "modifiers": [], "component": [ + "--spectrum-action-bar-border-color", + "--spectrum-action-bar-bottom-to-content-area", + "--spectrum-action-bar-close-button-to-counter", + "--spectrum-action-bar-counter-font-size", + "--spectrum-action-bar-edge-to-content-area", "--spectrum-action-bar-height", - "--spectrum-action-bar-top-to-item-counter", - "--spectrum-actionbar-corner-radius", - "--spectrum-actionbar-emphasized-background-color", - "--spectrum-actionbar-emphasized-item-counter-color", - "--spectrum-actionbar-height", - "--spectrum-actionbar-item-counter-color", - "--spectrum-actionbar-item-counter-font-size", - "--spectrum-actionbar-item-counter-line-height", - "--spectrum-actionbar-item-counter-line-height-cjk", - "--spectrum-actionbar-popover-background-color", - "--spectrum-actionbar-popover-border-color", - "--spectrum-actionbar-shadow-blur", - "--spectrum-actionbar-shadow-color", - "--spectrum-actionbar-shadow-horizontal", - "--spectrum-actionbar-shadow-vertical", - "--spectrum-actionbar-spacing-action-group-end", - "--spectrum-actionbar-spacing-action-group-top", - "--spectrum-actionbar-spacing-close-button-end", - "--spectrum-actionbar-spacing-close-button-start", - "--spectrum-actionbar-spacing-close-button-top", - "--spectrum-actionbar-spacing-item-counter-end", - "--spectrum-actionbar-spacing-item-counter-top", - "--spectrum-actionbar-spacing-outer-edge" + "--spectrum-action-bar-label-to-action-group-area", + "--spectrum-action-bar-minimum-width", + "--spectrum-action-bar-top-to-content-area" ], "global": [ + "--spectrum-background-elevated-color", "--spectrum-cjk-line-height-100", - "--spectrum-corner-radius-100", - "--spectrum-drop-shadow-blur", - "--spectrum-drop-shadow-color", - "--spectrum-drop-shadow-x", - "--spectrum-drop-shadow-y", - "--spectrum-font-size-100", + "--spectrum-corner-radius-medium-size-extra-large", + "--spectrum-drop-shadow-elevated-blur", + "--spectrum-drop-shadow-elevated-color", + "--spectrum-drop-shadow-elevated-x", + "--spectrum-drop-shadow-elevated-y", "--spectrum-gray-25", - "--spectrum-gray-400", - "--spectrum-informative-background-color-default", "--spectrum-line-height-100", "--spectrum-neutral-content-color-default", - "--spectrum-spacing-100", - "--spectrum-spacing-300", - "--spectrum-spacing-400", - "--spectrum-spacing-75", - "--spectrum-white" - ], - "system-theme": [ - "--system-action-bar-popover-background-color", - "--system-action-bar-popover-border-color" + "--spectrum-spacing-300" ], "passthroughs": [], - "high-contrast": ["--highcontrast-actionbar-popover-border-color"] + "high-contrast": [] } diff --git a/components/actionbar/index.css b/components/actionbar/index.css index 474499e462f..fcb1554fcd3 100644 --- a/components/actionbar/index.css +++ b/components/actionbar/index.css @@ -11,66 +11,10 @@ * governing permissions and limitations under the License. */ -@import "./themes/spectrum-two.css"; - -.spectrum-ActionBar { - --spectrum-actionbar-height: var(--spectrum-action-bar-height); - --spectrum-actionbar-corner-radius: var(--spectrum-corner-radius-100); - - /* item counter field label */ - --spectrum-actionbar-item-counter-font-size: var(--spectrum-font-size-100); - --spectrum-actionbar-item-counter-line-height: var(--spectrum-line-height-100); - --spectrum-actionbar-item-counter-color: var(--spectrum-neutral-content-color-default); - - /* emphasized variation colors */ - --spectrum-actionbar-emphasized-background-color: var(--spectrum-informative-background-color-default); - --spectrum-actionbar-emphasized-item-counter-color: var(--spectrum-white); - - /* spacing of action bar bottom and horizontal outer edge */ - --spectrum-actionbar-spacing-outer-edge: var(--spectrum-spacing-300); - - /* spacing of close button */ - --spectrum-actionbar-spacing-close-button-top: var(--spectrum-spacing-100); - --spectrum-actionbar-spacing-close-button-start: var(--spectrum-spacing-100); - --spectrum-actionbar-spacing-close-button-end: var(--spectrum-spacing-75); - - /* spacing of item counter field label */ - --spectrum-actionbar-spacing-item-counter-top: var(--spectrum-action-bar-top-to-item-counter); - --spectrum-actionbar-spacing-item-counter-end: var(--spectrum-spacing-400); - - /* spacing of action group */ - --spectrum-actionbar-spacing-action-group-top: var(--spectrum-spacing-100); - --spectrum-actionbar-spacing-action-group-end: var(--spectrum-spacing-100); - - /* drop shadow */ - --spectrum-actionbar-shadow-horizontal: var(--spectrum-drop-shadow-x); - --spectrum-actionbar-shadow-vertical: var(--spectrum-drop-shadow-y); - --spectrum-actionbar-shadow-blur: var(--spectrum-drop-shadow-blur); - --spectrum-actionbar-shadow-color: var(--spectrum-drop-shadow-color); - - /* cjk language support for item counter */ - &:lang(ja), - &:lang(zh), - &:lang(ko) { - --spectrum-actionbar-item-counter-line-height-cjk: var(--spectrum-cjk-line-height-100); - } -} - -/* windows high contrast mode */ -@media (forced-colors: active) { - .spectrum-ActionBar { - --highcontrast-actionbar-popover-border-color: CanvasText; - } - - .spectrum-ActionBar--emphasized .spectrum-ActionBar-popover { - --highcontrast-actionbar-popover-border-color: CanvasText; - } -} - /* ActionBar is outer wrapper with nested popover component within */ .spectrum-ActionBar { /* creates horizontal spacing to edge */ - padding: 0 var(--mod-actionbar-spacing-outer-edge, var(--spectrum-actionbar-spacing-outer-edge)); + padding: 0 var(--spectrum-spacing-300); inset-block-end: 0; z-index: 1; @@ -86,27 +30,28 @@ &.is-open { /* add ActionBar bottom margin to height for correct spacing even when sticky */ - block-size: calc(var(--mod-actionbar-spacing-outer-edge, var(--spectrum-actionbar-spacing-outer-edge)) + var(--mod-actionbar-height, var(--spectrum-actionbar-height))); + block-size: calc(var(--spectrum-spacing-300) + var(--spectrum-action-bar-height)); opacity: 1; } - .spectrum-ActionBar-popover { + .spectrum-Popover { /* popover is ActionBar height */ - block-size: var(--mod-actionbar-height, var(--spectrum-actionbar-height)); + block-size: var(--spectrum-action-bar-height); + min-inline-size: var(--spectrum-action-bar-minimum-width); box-sizing: border-box; inline-size: 100%; margin: auto; - padding-block-start: 0; - padding-block-end: 0; + padding-inline: var(--spectrum-action-bar-edge-to-content-area); + padding-block: var(--spectrum-action-bar-top-to-content-area) var(--spectrum-action-bar-bottom-to-content-area); /* Be relative so our width can be restricted */ position: relative; - border-radius: var(--mod-actionbar-corner-radius, var(--spectrum-actionbar-corner-radius)); - border-color: var(--highcontrast-actionbar-popover-border-color, var(--mod-actionbar-popover-border-color, var(--spectrum-actionbar-popover-border-color))); - background-color: var(--mod-actionbar-popover-background-color, var(--spectrum-actionbar-popover-background-color)); + border-radius: var(--spectrum-corner-radius-medium-size-extra-large); + border-color: var(--spectrum-action-bar-border-color); + background-color: var(--spectrum-background-elevated-color); - filter: drop-shadow(var(--mod-actionbar-shadow-horizontal, var(--spectrum-actionbar-shadow-horizontal)) var(--mod-actionbar-shadow-vertical, var(--spectrum-actionbar-shadow-vertical)) var(--mod-actionbar-shadow-blur, var(--spectrum-actionbar-shadow-blur)) var(--mod-actionbar-shadow-color, var(--spectrum-actionbar-shadow-color))); + filter: drop-shadow(var(--spectrum-drop-shadow-elevated-x) var(--spectrum-drop-shadow-elevated-y) var(--spectrum-drop-shadow-elevated-blur) var(--spectrum-drop-shadow-elevated-color)); /* Let clicks do their thing */ pointer-events: auto; @@ -114,58 +59,40 @@ /* inner layout of content items */ display: flex; flex-direction: row; - } - - /* close button */ - .spectrum-CloseButton { - margin-inline-start: var(--mod-actionbar-spacing-close-button-start, var(--spectrum-actionbar-spacing-close-button-start)); - margin-inline-end: var(--mod-actionbar-spacing-close-button-end, var(--spectrum-actionbar-spacing-close-button-end)); - margin-block-start: var(--mod-actionbar-spacing-close-button-top, var(--spectrum-actionbar-spacing-close-button-top)); - flex-shrink: 0; + align-items: center; } /* item counter */ .spectrum-FieldLabel { - margin-inline-end: var(--mod-actionbar-spacing-item-counter-end, var(--spectrum-actionbar-spacing-item-counter-end)); - margin-block-start: var(--mod-actionbar-spacing-item-counter-top, var(--spectrum-actionbar-spacing-item-counter-top)); - - /* neutralize padding for correct spacing within ActionBar */ - padding: 0; + font-size: var(--spectrum-action-bar-counter-font-size); + line-height: var(--spectrum-line-height-100); - font-size: var(--mod-actionbar-item-counter-font-size, var(--spectrum-actionbar-item-counter-font-size)); - color: var(--mod-actionbar-item-counter-color, var(--spectrum-actionbar-item-counter-color)); - line-height: var(--mod-actionbar-item-counter-line-height, var(--spectrum-actionbar-item-counter-line-height)); + color: var(--spectrum-neutral-content-color-default); + padding-inline-start: var(--spectrum-action-bar-close-button-to-counter); /* cjk language support */ &:lang(ja), &:lang(zh), &:lang(ko) { - line-height: var(--mod-actionbar-item-counter-line-height-cjk, var(--spectrum-actionbar-item-counter-line-height-cjk)); + line-height: var(--spectrum-cjk-line-height-100); } } /* action group */ .spectrum-ActionGroup { - margin-inline-end: var(--mod-actionbar-spacing-action-group-end, var(--spectrum-actionbar-spacing-action-group-end)); - margin-block-start: var(--mod-actionbar-spacing-action-group-top, var(--spectrum-actionbar-spacing-action-group-top)); - /* align to end by default */ margin-inline-start: auto; + padding-inline-start: var(--spectrum-action-bar-label-to-action-group-area); } } .spectrum-ActionBar--emphasized { - .spectrum-ActionBar-popover { - filter: none; - background-color: var(--mod-actionbar-emphasized-background-color, var(--spectrum-actionbar-emphasized-background-color)); - - /* border transparent instead of none so WHCM will have visible border */ - border-color: transparent; + .spectrum-FieldLabel { + color: var(--spectrum-gray-25); } - /* ensure text is legible on emphasized background */ - .spectrum-FieldLabel { - color: var(--mod-actionbar-emphasized-item-counter-color, var(--spectrum-actionbar-emphasized-item-counter-color)); + .spectrum-Popover { + background-color: var(--spectrum-neutral-content-color-default); } } diff --git a/components/actionbar/package.json b/components/actionbar/package.json index 8ea6fdde28d..639f40ab571 100644 --- a/components/actionbar/package.json +++ b/components/actionbar/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/actionbar", - "version": "10.2.0", + "version": "11.0.0-next.3", "description": "The Spectrum CSS actionbar component", "license": "Apache-2.0", "author": "Adobe", @@ -19,18 +19,16 @@ "./package.json": "./package.json", "./dist/*": "./dist/*", "./index.css": "./dist/index.css", - "./index-*.css": "./dist/index-*.css", "./metadata.json": "./dist/metadata.json", - "./themes/*": "./dist/themes/*", "./stories/*": "./stories/*" }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/actiongroup": ">=6.0.0 <7.0.0", - "@spectrum-css/closebutton": ">=6.0.0 <7.0.0", - "@spectrum-css/fieldlabel": ">=10.0.0 <11.0.0", - "@spectrum-css/popover": ">=8.0.0 <9.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/actiongroup": ">=7.0.0-next.0", + "@spectrum-css/closebutton": ">=7.0.0-next.0", + "@spectrum-css/fieldlabel": ">=11.0.0-next.0", + "@spectrum-css/popover": ">=9.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/actiongroup": { @@ -50,11 +48,11 @@ } }, "devDependencies": { - "@spectrum-css/actiongroup": "6.2.0", - "@spectrum-css/closebutton": "6.2.0", - "@spectrum-css/fieldlabel": "10.2.0", - "@spectrum-css/popover": "8.3.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/actiongroup": "7.0.0-next.3", + "@spectrum-css/closebutton": "7.0.0-next.1", + "@spectrum-css/fieldlabel": "11.0.0-next.2", + "@spectrum-css/popover": "9.0.0-next.5", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/actionbar/stories/actionbar.stories.js b/components/actionbar/stories/actionbar.stories.js index aa2e867ea09..e3410ba3953 100644 --- a/components/actionbar/stories/actionbar.stories.js +++ b/components/actionbar/stories/actionbar.stories.js @@ -12,7 +12,7 @@ import { BehavioralTemplate } from "./template.js"; * The action bar component is a floating full width bar that appears upon selection. Action bars are used for single and bulk selection patterns, when a user needs to perform actions on either a single or multiple items at the same time. * * ## Popover dependency - * Action bar requires popover, which is nested within the action bar. Action bar background, border, and corner radius are applied to the nested popover component and can be overridden by using action bar's `--mod-*` prefixed custom properties. A [list of the properties](#modifiable-properties) can be found below. + * Action bar requires popover, which is nested within the action bar. Action bar background, border, and corner radius are applied to the nested popover component. */ export default { title: "Action bar", @@ -72,7 +72,11 @@ export default { }, packageJson, metadata, + status: { + type: "migrated", + }, }, + tags: ["migrated"], }; export const Default = ActionBarGroup.bind({}); @@ -92,7 +96,7 @@ WithForcedColors.parameters = { // ********* DOCS ONLY ********* // /** - * The emphasized action bar has a blue background that adds visual emphasis on the actions and selection. Use this for when the bar should call attention (e.g., floating in a table). + * The emphasized action bar has a neutral background that adds visual emphasis on the actions and selection. Use this for when the bar should call attention (e.g., floating in a table). */ export const Emphasized = BehavioralTemplate.bind({}); Emphasized.tags = ["!dev"]; diff --git a/components/actionbar/stories/template.js b/components/actionbar/stories/template.js index 8b134157bd2..865aee288c4 100644 --- a/components/actionbar/stories/template.js +++ b/components/actionbar/stories/template.js @@ -1,20 +1,16 @@ -import { Container } from "@spectrum-css/preview/decorators"; import { Template as ActionGroup } from "@spectrum-css/actiongroup/stories/template.js"; import { Template as CloseButton } from "@spectrum-css/closebutton/stories/template.js"; import { Template as FieldLabel } from "@spectrum-css/fieldlabel/stories/template.js"; import { Template as Popover } from "@spectrum-css/popover/stories/template.js"; +import { Container } from "@spectrum-css/preview/decorators"; import { html } from "lit"; import { classMap } from "lit/directives/class-map.js"; import { styleMap } from "lit/directives/style-map.js"; import "../index.css"; -import "../themes/spectrum.css"; -/* Must be imported last */ -import "../themes/express.css"; export const Template = ({ rootClass = "spectrum-ActionBar", - size = "m", isOpen = true, isEmphasized = false, isSticky = false, @@ -28,7 +24,6 @@ export const Template = ({
`; diff --git a/components/actionbar/themes/express.css b/components/actionbar/themes/express.css deleted file mode 100644 index 9fd550418f2..00000000000 --- a/components/actionbar/themes/express.css +++ /dev/null @@ -1,16 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--express */ - -@import "./spectrum.css"; diff --git a/components/actionbar/themes/spectrum-two.css b/components/actionbar/themes/spectrum-two.css deleted file mode 100644 index 157c2dc9294..00000000000 --- a/components/actionbar/themes/spectrum-two.css +++ /dev/null @@ -1,20 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -@container style(--system: spectrum) { - .spectrum-ActionBar { - /* colors - applied to popover */ - --spectrum-actionbar-popover-background-color: var(--spectrum-gray-25); - --spectrum-actionbar-popover-border-color: var(--spectrum-gray-400); - } -} diff --git a/components/actionbar/themes/spectrum.css b/components/actionbar/themes/spectrum.css deleted file mode 100644 index 27971810d3d..00000000000 --- a/components/actionbar/themes/spectrum.css +++ /dev/null @@ -1,23 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--legacy */ - -@import "./spectrum-two.css"; - -@container style(--system: legacy) { - .spectrum-ActionBar { - --spectrum-actionbar-popover-background-color: var(--spectrum-gray-50); - --spectrum-actionbar-popover-border-color: var(--spectrum-gray-400); - } -} diff --git a/components/actionbutton/CHANGELOG.md b/components/actionbutton/CHANGELOG.md index 63d6a7a16c5..ef41b956272 100644 --- a/components/actionbutton/CHANGELOG.md +++ b/components/actionbutton/CHANGELOG.md @@ -1,5 +1,118 @@ # Change log +## 8.0.0-next.4 + +### Minor Changes + +📝 [#4085](https://github.com/adobe/spectrum-css/pull/4085) [`082862e`](https://github.com/adobe/spectrum-css/commit/082862eb80c6e0ac1c801b1d538e4d2f2bb919b4) Thanks [@castastrophe](https://github.com/castastrophe)! + +### Action menu component (now with custom styles!) + +Introduces `@spectrum-css/actionmenu`, a composition of `ActionButton`, `Popover`, and `Menu` to present action lists from a trigger. Now with custom styles! + +- Adds wrapper classes: `spectrum-ActionMenu`, `spectrum-ActionMenu-trigger`, `spectrum-ActionMenu-popover`, and `spectrum-ActionMenu-menu`. +- Supports long press triggers and four placements (start/end, top/bottom) via the underlying popover API. +- Design reference: [Figma S2 token specs](https://www.figma.com/design/eoZHKJH9a3LJkHYCGt60Vb/S2-token-specs?node-id=20959-21513&node-type=frame&t=jbePQKK1yLdrHG2M-11). + +#### Migration notes + +- If you previously composed an action menu manually (action button + popover + menu), you can adopt the new wrapper classes without changing the underlying markup semantics. Ensure the trigger has `aria-haspopup="menu"` and manages `aria-expanded` according to your application logic. +- For spacing customizations previously done with ad‑hoc margins, switch to the new `--spectrum-actionmenu-button-to-menu-gap` custom property. + +Example markup: + +```html +
+ +
+
    + +
+
+ + + +
+``` + +### Menu refinements + +Updates `@spectrum-css/menu` styles to align with latest Spectrum 2 design specifications and improve accessibility. + +- Updated `.is-selectableMultiple .spectrum-Menu-itemCheckbox` to `.is-selectableMultiple:not(:has(.is-selectable)) .spectrum-Menu-itemCheckbox` to prevent clash with the `.is-selectable` placement. +- Non-breaking; no class or DOM changes required. + +### Action button refinements + +- Selection styling now applies when components use ARIA pressed/expanded semantics, not just `.is-selected`. +- Implemented with `:where()` to keep selector specificity low and prevent downstream specificity battles. +- Non-breaking; no class changes required. + +### Action group refinements + +Aligns selection behavior of grouped items with action button updates. + +- Adds `:where([aria-pressed="true"], [aria-expanded="true"])` alongside `.is-selected` on items to cover more accessibility use-cases while keeping specificity low. +- Non-breaking; no class changes required. + +## 8.0.0-next.3 + +### Major Changes + +📝 [#4014](https://github.com/adobe/spectrum-css/pull/4014) [`35c066b`](https://github.com/adobe/spectrum-css/commit/35c066b29c311b1bfcf4507075f13b41222ffc84) Thanks [@castastrophe](https://github.com/castastrophe)! + +This update removes the `dir` attribute polyfill (served via a PostCSS transform to compiled assets) as the fallback is no longer necessary. The`dir` attribute support is available in all supported browsers and has been tested to correctly inherit inside web component shadow DOMs. This is a breaking change **only** to those relying on the `dir` attribute being present for styling, however, the `:dir` pseudo will correctly inherit values from their containers. To correctly determine the `dir` value of a node using JavaScript, you can use `getComputedStyle(node).direction`. + +## 8.0.0-next.2 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + +## 8.0.0-next.1 + +### Major Changes + +📝 [#2669](https://github.com/adobe/spectrum-css/pull/2669) [`b2c6357`](https://github.com/adobe/spectrum-css/commit/b2c6357c542737fb996cf8378354f525adde1fc2) Thanks [@mdt2](https://github.com/mdt2)! + +Action button now uses Spectrum 2 tokens and design specifications. A few notable changes: + +- Medium is now the default size and `.spectrum-ActionButton--sizeM` has been removed. +- Includes the Spectrum 2 down state transform. +- The component border was not removed and its color was changed to `transparent` in order to continue support for Windows High Contrast / forced colors, which still shows a border. The mod custom properties for border were removed to avoid interference with Windows High Contrast / forced colors accessibility. +- Some selectors to target the icon + text button and the icon-only button have been simplified using `:has`. This removes some overly complex `calc()` functions used for inline spacing, uses the design tokens more directly, and removes the previously documented need for the component's child elements to use a specific source order. +- Background and content colors were updated. +- Mod custom properties have been adjusted: + - Renamed: + - `--mod-line-height-100` renamed to `--mod-actionbutton-line-height`. + - `--mod-sans-font-family-stack` renamed to `--mod-button-font-family`. + - `--mod-animation-duration-100` renamed to `--mod-button-animation-duration`. + - Removed: + - `--mod-actionbutton-border-color-default` + - `--mod-actionbutton-border-color-disabled` + - `--mod-actionbutton-border-color-down` + - `--mod-actionbutton-border-color-focus` + - `--mod-actionbutton-border-color-hover` + - `--mod-actionbutton-border-width` + - `--mod-actionbutton-static-content-color` + - New: + - `--mod-actionbutton-font-weight` + - `--mod-actionbutton-font-style` + +## 8.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`a25e0a9`](https://github.com/adobe/spectrum-css/commit/a25e0a99e5a4736ab4e607e00739343101a2633b)]: + - @spectrum-css/icon@10.0.0-next.0 + ## 7.2.0 ### Minor Changes @@ -20,7 +133,9 @@ Minor linting fix of replacing `rgba` to the `rgb` shorthand syntax. ### Patch Changes -- [#3644](https://github.com/adobe/spectrum-css/pull/3644) [`5adef1d`](https://github.com/adobe/spectrum-css/commit/5adef1d15d07516dc9c1aac7bbcf9ac5bdeb9e97) Thanks [@marissahuysentruyt](https://github.com/marissahuysentruyt)! - Fix support for `--mod-actionbutton-border-radius` to make sure it is surfaced to consumers, and properly overwrites the default border radius setting. +📝 [#3644](https://github.com/adobe/spectrum-css/pull/3644) [`5adef1d`](https://github.com/adobe/spectrum-css/commit/5adef1d15d07516dc9c1aac7bbcf9ac5bdeb9e97) Thanks [@marissahuysentruyt](https://github.com/marissahuysentruyt)! + +Fix support for `--mod-actionbutton-border-radius` to make sure it is surfaced to consumers, and properly overwrites the default border radius setting. ## 7.1.2 diff --git a/components/actionbutton/dist/metadata.json b/components/actionbutton/dist/metadata.json index 08d99aab279..8a5fd1c4424 100644 --- a/components/actionbutton/dist/metadata.json +++ b/components/actionbutton/dist/metadata.json @@ -2,33 +2,28 @@ "sourceFile": "index.css", "selectors": [ ".spectrum-ActionButton", + ".spectrum-ActionButton .spectrum-ActionButton-hold", + ".spectrum-ActionButton .spectrum-ActionButton-icon", + ".spectrum-ActionButton .spectrum-ActionButton-label", ".spectrum-ActionButton--sizeL", - ".spectrum-ActionButton--sizeM", ".spectrum-ActionButton--sizeS", ".spectrum-ActionButton--sizeXL", ".spectrum-ActionButton--sizeXS", ".spectrum-ActionButton-hold", - ".spectrum-ActionButton-hold + .spectrum-ActionButton-icon", ".spectrum-ActionButton-icon", - ".spectrum-ActionButton-icon:only-child", ".spectrum-ActionButton-label", ".spectrum-ActionButton-label:empty", ".spectrum-ActionButton.is-disabled", - ".spectrum-ActionButton.is-selected", - ".spectrum-ActionButton.is-selected .spectrum-ActionButton-hold", - ".spectrum-ActionButton.is-selected .spectrum-ActionButton-icon", - ".spectrum-ActionButton.is-selected .spectrum-ActionButton-label", - ".spectrum-ActionButton.spectrum-ActionButton--emphasized:not(.spectrum-ActionButton--staticBlack, .spectrum-ActionButton--staticWhite)", + ".spectrum-ActionButton.spectrum-ActionButton--emphasized:is(.is-selected, [aria-pressed=\"true\"], [aria-expanded=\"true\"])", ".spectrum-ActionButton.spectrum-ActionButton--quiet", - ".spectrum-ActionButton.spectrum-ActionButton--sizeL", - ".spectrum-ActionButton.spectrum-ActionButton--sizeM", - ".spectrum-ActionButton.spectrum-ActionButton--sizeS", - ".spectrum-ActionButton.spectrum-ActionButton--sizeXL", - ".spectrum-ActionButton.spectrum-ActionButton--sizeXS", + ".spectrum-ActionButton.spectrum-ActionButton--quiet:is(.is-selected, [aria-pressed=\"true\"], [aria-expanded=\"true\"])", + ".spectrum-ActionButton.spectrum-ActionButton--quiet:is(:disabled, .is-disabled, [aria-disabled=\"true\"]):not(:where(.is-selected, [aria-pressed=\"true\"], [aria-expanded=\"true\"]))", ".spectrum-ActionButton.spectrum-ActionButton--staticBlack", ".spectrum-ActionButton.spectrum-ActionButton--staticBlack.spectrum-ActionButton--quiet", + ".spectrum-ActionButton.spectrum-ActionButton--staticBlack:is(.is-selected, [aria-pressed=\"true\"], [aria-expanded=\"true\"])", ".spectrum-ActionButton.spectrum-ActionButton--staticWhite", ".spectrum-ActionButton.spectrum-ActionButton--staticWhite.spectrum-ActionButton--quiet", + ".spectrum-ActionButton.spectrum-ActionButton--staticWhite:is(.is-selected, [aria-pressed=\"true\"], [aria-expanded=\"true\"])", ".spectrum-ActionButton::-moz-focus-inner", ".spectrum-ActionButton:active", ".spectrum-ActionButton:after", @@ -37,12 +32,14 @@ ".spectrum-ActionButton:focus", ".spectrum-ActionButton:focus-visible", ".spectrum-ActionButton:focus-visible:after", + ".spectrum-ActionButton:has(.spectrum-ActionButton-icon)", ".spectrum-ActionButton:hover", - "[dir=\"rtl\"] .spectrum-ActionButton", + ".spectrum-ActionButton:is(.is-selected, [aria-pressed=\"true\"], [aria-expanded=\"true\"])", + ".spectrum-ActionButton:is(:disabled, .is-disabled, [aria-disabled=\"true\"])", + ".spectrum-ActionButton:not(:has(.spectrum-ActionButton-label))", "a.spectrum-ActionButton" ], "modifiers": [ - "--mod-actionbutton-animation-duration", "--mod-actionbutton-background-color-default", "--mod-actionbutton-background-color-default-selected", "--mod-actionbutton-background-color-default-selected-emphasized", @@ -56,13 +53,7 @@ "--mod-actionbutton-background-color-hover", "--mod-actionbutton-background-color-hover-selected", "--mod-actionbutton-background-color-hover-selected-emphasized", - "--mod-actionbutton-border-color-default", - "--mod-actionbutton-border-color-disabled", - "--mod-actionbutton-border-color-down", - "--mod-actionbutton-border-color-focus", - "--mod-actionbutton-border-color-hover", "--mod-actionbutton-border-radius", - "--mod-actionbutton-border-width", "--mod-actionbutton-content-color-default", "--mod-actionbutton-content-color-default-selected", "--mod-actionbutton-content-color-default-selected-emphasized", @@ -80,20 +71,15 @@ "--mod-actionbutton-edge-to-text", "--mod-actionbutton-edge-to-visual", "--mod-actionbutton-edge-to-visual-only", - "--mod-actionbutton-focus-indicator-border-radius", - "--mod-actionbutton-focus-indicator-color", - "--mod-actionbutton-focus-indicator-gap", - "--mod-actionbutton-focus-indicator-thickness", "--mod-actionbutton-font-size", + "--mod-actionbutton-font-style", + "--mod-actionbutton-font-weight", "--mod-actionbutton-height", "--mod-actionbutton-icon-size", "--mod-actionbutton-label-color", + "--mod-actionbutton-line-height", "--mod-actionbutton-min-width", - "--mod-actionbutton-static-content-color", - "--mod-actionbutton-text-to-visual", - "--mod-animation-duration-100", - "--mod-line-height-100", - "--mod-sans-font-family-stack" + "--mod-actionbutton-text-to-visual" ], "component": [ "--spectrum-action-button-edge-to-hold-icon-extra-large", @@ -101,46 +87,36 @@ "--spectrum-action-button-edge-to-hold-icon-large", "--spectrum-action-button-edge-to-hold-icon-medium", "--spectrum-action-button-edge-to-hold-icon-small", - "--spectrum-actionbutton-background-color", + "--spectrum-actionbutton-animation-duration", "--spectrum-actionbutton-background-color-default", "--spectrum-actionbutton-background-color-disabled", "--spectrum-actionbutton-background-color-down", "--spectrum-actionbutton-background-color-focus", "--spectrum-actionbutton-background-color-hover", - "--spectrum-actionbutton-background-color-selected", - "--spectrum-actionbutton-background-color-selected-disabled", - "--spectrum-actionbutton-background-color-selected-down", - "--spectrum-actionbutton-background-color-selected-focus", - "--spectrum-actionbutton-background-color-selected-hover", "--spectrum-actionbutton-border-color", - "--spectrum-actionbutton-border-color-default", - "--spectrum-actionbutton-border-color-disabled", - "--spectrum-actionbutton-border-color-down", - "--spectrum-actionbutton-border-color-focus", - "--spectrum-actionbutton-border-color-hover", "--spectrum-actionbutton-border-radius", - "--spectrum-actionbutton-border-radius-default", "--spectrum-actionbutton-border-width", - "--spectrum-actionbutton-content-color", - "--spectrum-actionbutton-content-color-selected", + "--spectrum-actionbutton-content-color-default", + "--spectrum-actionbutton-content-color-disabled", + "--spectrum-actionbutton-content-color-down", + "--spectrum-actionbutton-content-color-focus", + "--spectrum-actionbutton-content-color-hover", + "--spectrum-actionbutton-downstate-perspective", "--spectrum-actionbutton-edge-to-hold-icon", "--spectrum-actionbutton-edge-to-text", "--spectrum-actionbutton-edge-to-visual", "--spectrum-actionbutton-edge-to-visual-only", + "--spectrum-actionbutton-focus-indicator-border-radius", "--spectrum-actionbutton-focus-indicator-color", "--spectrum-actionbutton-focus-indicator-gap", "--spectrum-actionbutton-focus-indicator-thickness", "--spectrum-actionbutton-font-size", + "--spectrum-actionbutton-font-style", + "--spectrum-actionbutton-font-weight", "--spectrum-actionbutton-height", "--spectrum-actionbutton-icon-size", - "--spectrum-actionbutton-sized-edge-to-hold-icon", - "--spectrum-actionbutton-sized-edge-to-text", - "--spectrum-actionbutton-sized-edge-to-visual", - "--spectrum-actionbutton-sized-edge-to-visual-only", - "--spectrum-actionbutton-sized-font-size", - "--spectrum-actionbutton-sized-height", - "--spectrum-actionbutton-sized-icon-size", - "--spectrum-actionbutton-sized-text-to-visual", + "--spectrum-actionbutton-line-height", + "--spectrum-actionbutton-min-width", "--spectrum-actionbutton-text-to-visual" ], "global": [ @@ -171,17 +147,23 @@ "--spectrum-component-height-300", "--spectrum-component-height-50", "--spectrum-component-height-75", + "--spectrum-component-size-difference-down", + "--spectrum-component-size-minimum-perspective-down", + "--spectrum-component-size-width-ratio-down", "--spectrum-corner-radius-medium-size-extra-large", "--spectrum-corner-radius-medium-size-extra-small", "--spectrum-corner-radius-medium-size-large", "--spectrum-corner-radius-medium-size-medium", "--spectrum-corner-radius-medium-size-small", + "--spectrum-default-font-style", "--spectrum-disabled-background-color", "--spectrum-disabled-content-color", "--spectrum-disabled-static-black-background-color", "--spectrum-disabled-static-black-content-color", "--spectrum-disabled-static-white-background-color", "--spectrum-disabled-static-white-content-color", + "--spectrum-downstate-height", + "--spectrum-downstate-width", "--spectrum-focus-indicator-color", "--spectrum-focus-indicator-gap", "--spectrum-focus-indicator-thickness", @@ -192,9 +174,9 @@ "--spectrum-font-size-75", "--spectrum-gray-100", "--spectrum-gray-200", - "--spectrum-gray-50", - "--spectrum-line-height-100", + "--spectrum-gray-25", "--spectrum-logical-rotation", + "--spectrum-medium-font-weight", "--spectrum-neutral-background-color-selected-default", "--spectrum-neutral-background-color-selected-down", "--spectrum-neutral-background-color-selected-hover", @@ -213,10 +195,12 @@ "--spectrum-text-to-visual-75", "--spectrum-transparent-black-100", "--spectrum-transparent-black-200", + "--spectrum-transparent-black-25", "--spectrum-transparent-black-800", "--spectrum-transparent-black-900", "--spectrum-transparent-white-100", "--spectrum-transparent-white-200", + "--spectrum-transparent-white-25", "--spectrum-transparent-white-800", "--spectrum-transparent-white-900", "--spectrum-white", @@ -226,75 +210,17 @@ "--spectrum-workflow-icon-size-50", "--spectrum-workflow-icon-size-75" ], - "system-theme": [ - "--system-action-button-background-color-default", - "--system-action-button-background-color-disabled", - "--system-action-button-background-color-down", - "--system-action-button-background-color-focus", - "--system-action-button-background-color-hover", - "--system-action-button-background-color-selected", - "--system-action-button-background-color-selected-down", - "--system-action-button-background-color-selected-focus", - "--system-action-button-background-color-selected-hover", - "--system-action-button-border-color-default", - "--system-action-button-border-color-disabled", - "--system-action-button-border-color-down", - "--system-action-button-border-color-focus", - "--system-action-button-border-color-hover", - "--system-action-button-content-color-selected", - "--system-action-button-quiet-background-color-default", - "--system-action-button-quiet-background-color-disabled", - "--system-action-button-quiet-background-color-down", - "--system-action-button-quiet-background-color-focus", - "--system-action-button-quiet-background-color-hover", - "--system-action-button-quiet-background-color-selected-disabled", - "--system-action-button-size-l-border-radius-default", - "--system-action-button-size-m-border-radius-default", - "--system-action-button-size-s-border-radius-default", - "--system-action-button-size-xl-border-radius-default", - "--system-action-button-size-xs-border-radius-default", - "--system-action-button-static-black-background-color-default", - "--system-action-button-static-black-background-color-disabled", - "--system-action-button-static-black-background-color-down", - "--system-action-button-static-black-background-color-focus", - "--system-action-button-static-black-background-color-hover", - "--system-action-button-static-black-background-color-selected-disabled", - "--system-action-button-static-black-border-color-default", - "--system-action-button-static-black-border-color-disabled", - "--system-action-button-static-black-border-color-down", - "--system-action-button-static-black-border-color-focus", - "--system-action-button-static-black-border-color-hover", - "--system-action-button-static-black-quiet-background-color-default", - "--system-action-button-static-black-quiet-background-color-disabled", - "--system-action-button-static-black-quiet-background-color-down", - "--system-action-button-static-black-quiet-background-color-focus", - "--system-action-button-static-black-quiet-background-color-hover", - "--system-action-button-static-white-background-color-default", - "--system-action-button-static-white-background-color-disabled", - "--system-action-button-static-white-background-color-down", - "--system-action-button-static-white-background-color-focus", - "--system-action-button-static-white-background-color-hover", - "--system-action-button-static-white-background-color-selected-disabled", - "--system-action-button-static-white-border-color-default", - "--system-action-button-static-white-border-color-disabled", - "--system-action-button-static-white-border-color-down", - "--system-action-button-static-white-border-color-focus", - "--system-action-button-static-white-border-color-hover", - "--system-action-button-static-white-quiet-background-color-default", - "--system-action-button-static-white-quiet-background-color-disabled", - "--system-action-button-static-white-quiet-background-color-down", - "--system-action-button-static-white-quiet-background-color-focus", - "--system-action-button-static-white-quiet-background-color-hover" - ], "passthroughs": [ "--mod-button-animation-duration", - "--mod-button-font-family", - "--mod-button-line-height" + "--mod-button-font-family" ], "high-contrast": [ - "--highcontrast-actionbutton-background-color", + "--highcontrast-actionbutton-animation-duration", + "--highcontrast-actionbutton-background-color-default", + "--highcontrast-actionbutton-background-color-disabled", "--highcontrast-actionbutton-border-color", - "--highcontrast-actionbutton-content-color", + "--highcontrast-actionbutton-content-color-default", + "--highcontrast-actionbutton-content-color-disabled", "--highcontrast-actionbutton-focus-indicator-color" ] } diff --git a/components/actionbutton/index.css b/components/actionbutton/index.css index ac4f410471e..c9f7c7899a2 100644 --- a/components/actionbutton/index.css +++ b/components/actionbutton/index.css @@ -1,329 +1,478 @@ /*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -@import "@spectrum-css/commons/basebutton.css"; -@import "./themes/spectrum-two.css"; +Copyright 2025 Adobe. All rights reserved. +This file is licensed to you under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. You may obtain a copy +of the License at http://www.apache.org/licenses/LICENSE-2.0 -@media (forced-colors: active) { - .spectrum-ActionButton { - /* force a more visible focus indicator color */ - --highcontrast-actionbutton-focus-indicator-color: ButtonText; - --highcontrast-actionbutton-content-color: ButtonText; - - &::after { - /* make sure focus indicator renders */ - forced-color-adjust: none; - } - - &.is-selected { - --highcontrast-actionbutton-background-color: Highlight; - --highcontrast-actionbutton-border-color: HighlightText; - --highcontrast-actionbutton-content-color: HighlightText; - - .spectrum-ActionButton-icon, - .spectrum-ActionButton-hold, - .spectrum-ActionButton-label { - /* ensure custom text colors from above get applied */ - /* it seems like this shouldn't have to be done, but colors are wrong without it */ - forced-color-adjust: none; - } - } - - &:disabled, - &.is-disabled { - --highcontrast-actionbutton-content-color: GrayText; - --highcontrast-actionbutton-border-color: GrayText; - --highcontrast-actionbutton-background-color: ButtonFace; - } - } -} +Unless required by applicable law or agreed to in writing, software distributed under +the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS +OF ANY KIND, either express or implied. See the License for the specific language +governing permissions and limitations under the License. +*/ .spectrum-ActionButton { - --spectrum-actionbutton-background-color: var(--highcontrast-actionbutton-background-color, var(--mod-actionbutton-background-color-default, var(--spectrum-actionbutton-background-color-default))); - --spectrum-actionbutton-border-color: var(--highcontrast-actionbutton-border-color, var(--mod-actionbutton-border-color-default, var(--spectrum-actionbutton-border-color-default))); - --spectrum-actionbutton-content-color: var(--highcontrast-actionbutton-content-color, var(--mod-actionbutton-content-color-default, var(--spectrum-neutral-content-color-default))); - - --spectrum-actionbutton-border-radius: var(--mod-actionbutton-border-radius, var(--spectrum-actionbutton-border-radius-default)); - --spectrum-actionbutton-border-width: var(--mod-actionbutton-border-width, var(--spectrum-border-width-100)); - - --spectrum-actionbutton-focus-indicator-gap: var(--mod-actionbutton-focus-indicator-gap, var(--spectrum-focus-indicator-gap)); - --spectrum-actionbutton-focus-indicator-thickness: var(--mod-actionbutton-focus-indicator-thickness, var(--spectrum-focus-indicator-thickness)); - --spectrum-actionbutton-focus-indicator-color: var(--highcontrast-actionbutton-focus-indicator-color, var(--mod-actionbutton-focus-indicator-color, var(--spectrum-focus-indicator-color))); + --spectrum-actionbutton-animation-duration: var(--spectrum-animation-duration-100); + --spectrum-actionbutton-border-radius: var(--spectrum-corner-radius-medium-size-medium); + --spectrum-actionbutton-border-width: var(--spectrum-border-width-100); + --spectrum-actionbutton-border-color: transparent; + + --spectrum-actionbutton-content-color-default: var(--spectrum-neutral-content-color-default); + --spectrum-actionbutton-content-color-hover: var(--spectrum-neutral-content-color-hover); + --spectrum-actionbutton-content-color-down: var(--spectrum-neutral-content-color-down); + --spectrum-actionbutton-content-color-focus: var(--spectrum-neutral-content-color-key-focus); + --spectrum-actionbutton-content-color-disabled: var(--spectrum-disabled-content-color); + + --spectrum-actionbutton-background-color-default: var(--spectrum-gray-100); + --spectrum-actionbutton-background-color-hover: var(--spectrum-gray-200); + --spectrum-actionbutton-background-color-down: var(--spectrum-gray-200); + --spectrum-actionbutton-background-color-focus: var(--spectrum-gray-200); + --spectrum-actionbutton-background-color-disabled: var(--spectrum-disabled-background-color); + + --spectrum-actionbutton-focus-indicator-gap: var(--spectrum-focus-indicator-gap); + --spectrum-actionbutton-focus-indicator-thickness: var(--spectrum-focus-indicator-thickness); + --spectrum-actionbutton-focus-indicator-color: var(--spectrum-focus-indicator-color); + --spectrum-actionbutton-focus-indicator-border-radius: calc(var(--spectrum-actionbutton-border-radius) + var(--spectrum-actionbutton-focus-indicator-gap)); + + --spectrum-actionbutton-min-width: calc((var(--spectrum-component-edge-to-visual-only-100) * 2) + var(--spectrum-workflow-icon-size-100)); + --spectrum-actionbutton-height: var(--spectrum-component-height-100); + + --spectrum-actionbutton-icon-size: var(--spectrum-workflow-icon-size-100); + --spectrum-actionbutton-font-size: var(--spectrum-font-size-100); + --spectrum-actionbutton-font-weight: var(--spectrum-medium-font-weight); + --spectrum-actionbutton-font-style: var(--spectrum-default-font-style); + + /* Take up full component height for line-height, in order to help prevent characters from being cut off in some languages (e.g. Thai). */ + --spectrum-actionbutton-line-height: var(--spectrum-actionbutton-height); + + --spectrum-actionbutton-text-to-visual: var(--spectrum-text-to-visual-100); + --spectrum-actionbutton-edge-to-hold-icon: var(--spectrum-action-button-edge-to-hold-icon-medium); + --spectrum-actionbutton-edge-to-visual: var(--spectrum-component-edge-to-visual-100); + --spectrum-actionbutton-edge-to-text: var(--spectrum-component-edge-to-text-100); + --spectrum-actionbutton-edge-to-visual-only: var(--spectrum-component-edge-to-visual-only-100); + + --spectrum-actionbutton-downstate-perspective: max(var(--spectrum-downstate-height), var(--spectrum-downstate-width) * var(--spectrum-component-size-width-ratio-down)); &:dir(rtl) { --spectrum-logical-rotation: matrix(-1, 0, 0, 1, 0, 0); } &.spectrum-ActionButton--quiet { - --spectrum-actionbutton-border-color: transparent; - } - - /* Emphasized styles are only applied to the "selected" state of the button and are not applied in static color modes */ - &.spectrum-ActionButton--emphasized:not(.spectrum-ActionButton--staticBlack, .spectrum-ActionButton--staticWhite) { - --mod-actionbutton-background-color-default-selected: var(--mod-actionbutton-background-color-default-selected-emphasized, var(--spectrum-accent-background-color-default)); - --mod-actionbutton-background-color-hover-selected: var(--mod-actionbutton-background-color-hover-selected-emphasized, var(--spectrum-accent-background-color-hover)); - --mod-actionbutton-background-color-down-selected: var(--mod-actionbutton-background-color-down-selected-emphasized, var(--spectrum-accent-background-color-down)); - --mod-actionbutton-background-color-focus-selected: var(--mod-actionbutton-background-color-focus-selected-emphasized, var(--spectrum-accent-background-color-key-focus)); - - --mod-actionbutton-content-color-default-selected: var(--mod-actionbutton-content-color-default-selected-emphasized, var(--spectrum-white)); - --mod-actionbutton-content-color-hover-selected: var(--mod-actionbutton-content-color-hover-selected-emphasized, var(--spectrum-white)); - --mod-actionbutton-content-color-down-selected: var(--mod-actionbutton-content-color-down-selected-emphasized, var(--spectrum-white)); - --mod-actionbutton-content-color-focus-selected: var(--mod-actionbutton-content-color-focus-selected-emphasized, var(--spectrum-white)); + --spectrum-actionbutton-background-color-default: transparent; + --spectrum-actionbutton-background-color-hover: var(--spectrum-gray-200); + --spectrum-actionbutton-background-color-down: var(--spectrum-gray-200); + --spectrum-actionbutton-background-color-focus: var(--spectrum-gray-200); + --spectrum-actionbutton-background-color-disabled: transparent; + + &:is(.is-selected, [aria-pressed="true"], [aria-expanded="true"]) { + --spectrum-actionbutton-background-color-disabled: var(--spectrum-disabled-background-color); + } } &.spectrum-ActionButton--staticBlack { - --mod-actionbutton-background-color-default-selected: var(--spectrum-transparent-black-800); - --mod-actionbutton-background-color-hover-selected: var(--spectrum-transparent-black-900); - --mod-actionbutton-background-color-down-selected: var(--spectrum-transparent-black-900); - --mod-actionbutton-background-color-focus-selected: var(--spectrum-transparent-black-900); - - --mod-actionbutton-content-color-default: var(--spectrum-black); - --mod-actionbutton-content-color-hover: var(--spectrum-black); - --mod-actionbutton-content-color-down: var(--spectrum-black); - --mod-actionbutton-content-color-focus: var(--spectrum-black); - --mod-actionbutton-content-color-disabled: var(--spectrum-disabled-static-black-content-color); - - --mod-actionbutton-content-color-default-selected: var(--mod-actionbutton-static-content-color, var(--spectrum-white)); - --mod-actionbutton-content-color-hover-selected: var(--mod-actionbutton-static-content-color, var(--spectrum-white)); - --mod-actionbutton-content-color-down-selected: var(--mod-actionbutton-static-content-color, var(--spectrum-white)); - --mod-actionbutton-content-color-focus-selected: var(--mod-actionbutton-static-content-color, var(--spectrum-white)); - - --mod-actionbutton-focus-indicator-color: var(--spectrum-static-black-focus-indicator-color); + --spectrum-actionbutton-background-color-default: var(--spectrum-transparent-black-100); + --spectrum-actionbutton-background-color-hover: var(--spectrum-transparent-black-200); + --spectrum-actionbutton-background-color-down: var(--spectrum-transparent-black-200); + --spectrum-actionbutton-background-color-focus: var(--spectrum-transparent-black-200); + --spectrum-actionbutton-background-color-disabled: var(--spectrum-disabled-static-black-background-color); + + --spectrum-actionbutton-content-color-default: var(--spectrum-transparent-black-800); + --spectrum-actionbutton-content-color-hover: var(--spectrum-transparent-black-900); + --spectrum-actionbutton-content-color-down: var(--spectrum-transparent-black-900); + --spectrum-actionbutton-content-color-focus: var(--spectrum-transparent-black-900); + --spectrum-actionbutton-content-color-disabled: var(--spectrum-disabled-static-black-content-color); + + --spectrum-actionbutton-focus-indicator-color: var(--spectrum-static-black-focus-indicator-color); + + &.spectrum-ActionButton--quiet { + --spectrum-actionbutton-background-color-default: transparent; + --spectrum-actionbutton-background-color-hover: var(--spectrum-transparent-black-200); + --spectrum-actionbutton-background-color-down: var(--spectrum-transparent-black-200); + --spectrum-actionbutton-background-color-focus: var(--spectrum-transparent-black-200); + --spectrum-actionbutton-background-color-disabled: var(--spectrum-transparent-black-25); + } } &.spectrum-ActionButton--staticWhite { - /* background color _not_ selected is coming from the system theme layer */ - --mod-actionbutton-background-color-default-selected: var(--spectrum-transparent-white-800); - --mod-actionbutton-background-color-hover-selected: var(--spectrum-transparent-white-900); - --mod-actionbutton-background-color-down-selected: var(--spectrum-transparent-white-900); - --mod-actionbutton-background-color-focus-selected: var(--spectrum-transparent-white-900); - - --mod-actionbutton-content-color-default: var(--spectrum-white); - --mod-actionbutton-content-color-hover: var(--spectrum-white); - --mod-actionbutton-content-color-down: var(--spectrum-white); - --mod-actionbutton-content-color-focus: var(--spectrum-white); - --mod-actionbutton-content-color-disabled: var(--spectrum-disabled-static-white-content-color); - - --mod-actionbutton-content-color-default-selected: var(--mod-actionbutton-static-content-color, var(--spectrum-black)); - --mod-actionbutton-content-color-hover-selected: var(--mod-actionbutton-static-content-color, var(--spectrum-black)); - --mod-actionbutton-content-color-down-selected: var(--mod-actionbutton-static-content-color, var(--spectrum-black)); - --mod-actionbutton-content-color-focus-selected: var(--mod-actionbutton-static-content-color, var(--spectrum-black)); - - --mod-actionbutton-focus-indicator-color: var(--spectrum-static-white-focus-indicator-color); + --spectrum-actionbutton-background-color-default: var(--spectrum-transparent-white-100); + --spectrum-actionbutton-background-color-hover: var(--spectrum-transparent-white-200); + --spectrum-actionbutton-background-color-down: var(--spectrum-transparent-white-200); + --spectrum-actionbutton-background-color-focus: var(--spectrum-transparent-white-200); + --spectrum-actionbutton-background-color-disabled: var(--spectrum-disabled-static-white-background-color); + + --spectrum-actionbutton-content-color-default: var(--spectrum-transparent-white-800); + --spectrum-actionbutton-content-color-hover: var(--spectrum-transparent-white-900); + --spectrum-actionbutton-content-color-down: var(--spectrum-transparent-white-900); + --spectrum-actionbutton-content-color-focus: var(--spectrum-transparent-white-900); + --spectrum-actionbutton-content-color-disabled: var(--spectrum-disabled-static-white-content-color); + + --spectrum-actionbutton-focus-indicator-color: var(--spectrum-static-white-focus-indicator-color); + + &.spectrum-ActionButton--quiet { + --spectrum-actionbutton-background-color-default: transparent; + --spectrum-actionbutton-background-color-hover: var(--spectrum-transparent-white-200); + --spectrum-actionbutton-background-color-down: var(--spectrum-transparent-white-200); + --spectrum-actionbutton-background-color-focus: var(--spectrum-transparent-white-200); + --spectrum-actionbutton-background-color-disabled: var(--spectrum-transparent-white-25); + } } - &.is-selected { - --mod-actionbutton-background-color-default: var(--mod-actionbutton-background-color-default-selected, var(--spectrum-actionbutton-background-color-selected)); - --mod-actionbutton-background-color-hover: var(--mod-actionbutton-background-color-hover-selected, var(--spectrum-actionbutton-background-color-selected-hover)); - --mod-actionbutton-background-color-down: var(--mod-actionbutton-background-color-down-selected, var(--spectrum-actionbutton-background-color-selected-down)); - --mod-actionbutton-background-color-focus: var(--mod-actionbutton-background-color-focus-selected, var(--spectrum-actionbutton-background-color-selected-focus)); - --mod-actionbutton-background-color-disabled: var(--spectrum-actionbutton-background-color-selected-disabled); - - --mod-actionbutton-border-color-default: transparent; - --mod-actionbutton-border-color-hover: transparent; - --mod-actionbutton-border-color-down: transparent; - --mod-actionbutton-border-color-focus: transparent; - --mod-actionbutton-border-color-disabled: transparent; - - --mod-actionbutton-content-color-default: var(--mod-actionbutton-content-color-default-selected, var(--spectrum-actionbutton-content-color-selected)); - --mod-actionbutton-content-color-hover: var(--mod-actionbutton-content-color-hover-selected, var(--spectrum-actionbutton-content-color-selected)); - --mod-actionbutton-content-color-down: var(--mod-actionbutton-content-color-down-selected, var(--spectrum-actionbutton-content-color-selected)); - --mod-actionbutton-content-color-focus: var(--mod-actionbutton-content-color-focus-selected, var(--spectrum-actionbutton-content-color-selected)); - } + /* expanded is specific to action menu when the menu is open */ + &:is(.is-selected, [aria-pressed="true"], [aria-expanded="true"]) { + --mod-actionbutton-background-color-default: var(--mod-actionbutton-background-color-default-selected, var(--spectrum-neutral-background-color-selected-default)); + --mod-actionbutton-background-color-hover: var(--mod-actionbutton-background-color-hover-selected, var(--spectrum-neutral-background-color-selected-hover)); + --mod-actionbutton-background-color-down: var(--mod-actionbutton-background-color-down-selected, var(--spectrum-neutral-background-color-selected-down)); + --mod-actionbutton-background-color-focus: var(--mod-actionbutton-background-color-focus-selected, var(--spectrum-neutral-background-color-selected-key-focus)); + + --mod-actionbutton-content-color-default: var(--mod-actionbutton-content-color-default-selected, var(--spectrum-gray-25)); + --mod-actionbutton-content-color-hover: var(--mod-actionbutton-content-color-hover-selected, var(--spectrum-gray-25)); + --mod-actionbutton-content-color-down: var(--mod-actionbutton-content-color-down-selected, var(--spectrum-gray-25)); + --mod-actionbutton-content-color-focus: var(--mod-actionbutton-content-color-focus-selected, var(--spectrum-gray-25)); + + &.spectrum-ActionButton--emphasized { + --mod-actionbutton-background-color-default: var(--mod-actionbutton-background-color-default-selected-emphasized, var(--spectrum-accent-background-color-default)); + --mod-actionbutton-background-color-hover: var(--mod-actionbutton-background-color-hover-selected-emphasized, var(--spectrum-accent-background-color-hover)); + --mod-actionbutton-background-color-down: var(--mod-actionbutton-background-color-down-selected-emphasized, var(--spectrum-accent-background-color-down)); + --mod-actionbutton-background-color-focus: var(--mod-actionbutton-background-color-focus-selected-emphasized, var(--spectrum-accent-background-color-key-focus)); + + --mod-actionbutton-content-color-default: var(--mod-actionbutton-content-color-default-selected-emphasized, var(--spectrum-white)); + --mod-actionbutton-content-color-hover: var(--mod-actionbutton-content-color-hover-selected-emphasized, var(--spectrum-white)); + --mod-actionbutton-content-color-down: var(--mod-actionbutton-content-color-down-selected-emphasized, var(--spectrum-white)); + --mod-actionbutton-content-color-focus: var(--mod-actionbutton-content-color-focus-selected-emphasized, var(--spectrum-white)); + } - &:hover { - --mod-actionbutton-background-color-default: var(--mod-actionbutton-background-color-hover, var(--spectrum-actionbutton-background-color-hover)); - --mod-actionbutton-border-color-default: var(--mod-actionbutton-border-color-hover, var(--spectrum-actionbutton-border-color-hover)); - --mod-actionbutton-content-color-default: var(--mod-actionbutton-content-color-hover, var(--spectrum-neutral-content-color-hover)); - } + &.spectrum-ActionButton--staticWhite { + --spectrum-actionbutton-background-color-default: var(--spectrum-transparent-white-800); + --spectrum-actionbutton-background-color-hover: var(--spectrum-transparent-white-900); + --spectrum-actionbutton-background-color-down: var(--spectrum-transparent-white-900); + --spectrum-actionbutton-background-color-focus: var(--spectrum-transparent-white-900); + --spectrum-actionbutton-background-color-disabled: var(--spectrum-disabled-static-white-background-color); + + --spectrum-actionbutton-content-color-default: var(--spectrum-black); + --spectrum-actionbutton-content-color-hover: var(--spectrum-black); + --spectrum-actionbutton-content-color-down: var(--spectrum-black); + --spectrum-actionbutton-content-color-focus: var(--spectrum-black); + } - &:focus-visible { - --mod-actionbutton-background-color-default: var(--mod-actionbutton-background-color-focus, var(--spectrum-actionbutton-background-color-focus)); - --mod-actionbutton-border-color-default: var(--mod-actionbutton-border-color-focus, var(--spectrum-actionbutton-border-color-focus)); - --mod-actionbutton-content-color-default: var(--mod-actionbutton-content-color-focus, var(--spectrum-neutral-content-color-key-focus)); + &.spectrum-ActionButton--staticBlack { + --spectrum-actionbutton-background-color-default: var(--spectrum-transparent-black-800); + --spectrum-actionbutton-background-color-hover: var(--spectrum-transparent-black-900); + --spectrum-actionbutton-background-color-down: var(--spectrum-transparent-black-900); + --spectrum-actionbutton-background-color-focus: var(--spectrum-transparent-black-900); + --spectrum-actionbutton-background-color-disabled: var(--spectrum-disabled-static-black-background-color); + + --spectrum-actionbutton-content-color-default: var(--spectrum-white); + --spectrum-actionbutton-content-color-hover: var(--spectrum-white); + --spectrum-actionbutton-content-color-down: var(--spectrum-white); + --spectrum-actionbutton-content-color-focus: var(--spectrum-white); + } } +} - &:active { - --mod-actionbutton-background-color-default: var(--mod-actionbutton-background-color-down, var(--spectrum-actionbutton-background-color-down)); - --mod-actionbutton-border-color-default: var(--mod-actionbutton-border-color-down, var(--spectrum-actionbutton-border-color-down)); - --mod-actionbutton-content-color-default: var(--mod-actionbutton-content-color-down, var(--spectrum-neutral-content-color-down)); - } +.spectrum-ActionButton--sizeXS { + --spectrum-actionbutton-border-radius: var(--spectrum-corner-radius-medium-size-extra-small); - &:disabled, - &.is-disabled { - --mod-actionbutton-background-color-default: var(--mod-actionbutton-background-color-disabled, var(--spectrum-actionbutton-background-color-disabled)); - --mod-actionbutton-border-color-default: var(--mod-actionbutton-border-color-disabled, var(--spectrum-actionbutton-border-color-disabled)); - --mod-actionbutton-content-color-default: var(--mod-actionbutton-content-color-disabled, var(--spectrum-disabled-content-color)); - } -} + --spectrum-actionbutton-min-width: calc((var(--spectrum-component-edge-to-visual-only-50) * 2) + var(--spectrum-workflow-icon-size-50)); + --spectrum-actionbutton-height: var(--spectrum-component-height-50); -.spectrum-ActionButton, -.spectrum-ActionButton--sizeM { - --spectrum-actionbutton-sized-height: var(--spectrum-component-height-100); - --spectrum-actionbutton-sized-icon-size: var(--spectrum-workflow-icon-size-100); - --spectrum-actionbutton-sized-font-size: var(--spectrum-font-size-100); - --spectrum-actionbutton-sized-text-to-visual: var(--spectrum-text-to-visual-100); - --spectrum-actionbutton-sized-edge-to-hold-icon: var(--spectrum-action-button-edge-to-hold-icon-medium); - --spectrum-actionbutton-sized-edge-to-visual: var(--spectrum-component-edge-to-visual-100); - --spectrum-actionbutton-sized-edge-to-text: var(--spectrum-component-edge-to-text-100); - --spectrum-actionbutton-sized-edge-to-visual-only: var(--spectrum-component-edge-to-visual-only-100); -} + --spectrum-actionbutton-icon-size: var(--spectrum-workflow-icon-size-50); + --spectrum-actionbutton-font-size: var(--spectrum-font-size-50); + --spectrum-actionbutton-text-to-visual: var(--spectrum-text-to-visual-50); + --spectrum-actionbutton-edge-to-hold-icon: var(--spectrum-action-button-edge-to-hold-icon-extra-small); + --spectrum-actionbutton-edge-to-visual: var(--spectrum-component-edge-to-visual-50); + --spectrum-actionbutton-edge-to-text: var(--spectrum-component-edge-to-text-50); + --spectrum-actionbutton-edge-to-visual-only: var(--spectrum-component-edge-to-visual-only-50); -.spectrum-ActionButton--sizeXS { - --spectrum-actionbutton-sized-height: var(--spectrum-component-height-50); - --spectrum-actionbutton-sized-icon-size: var(--spectrum-workflow-icon-size-50); - --spectrum-actionbutton-sized-font-size: var(--spectrum-font-size-50); - --spectrum-actionbutton-sized-text-to-visual: var(--spectrum-text-to-visual-50); - --spectrum-actionbutton-sized-edge-to-hold-icon: var(--spectrum-action-button-edge-to-hold-icon-extra-small); - --spectrum-actionbutton-sized-edge-to-visual: var(--spectrum-component-edge-to-visual-50); - --spectrum-actionbutton-sized-edge-to-text: var(--spectrum-component-edge-to-text-50); - --spectrum-actionbutton-sized-edge-to-visual-only: var(--spectrum-component-edge-to-visual-only-50); + --spectrum-actionbutton-downstate-perspective: var(--spectrum-component-size-minimum-perspective-down); } .spectrum-ActionButton--sizeS { - --spectrum-actionbutton-sized-height: var(--spectrum-component-height-75); - --spectrum-actionbutton-sized-icon-size: var(--spectrum-workflow-icon-size-75); - --spectrum-actionbutton-sized-font-size: var(--spectrum-font-size-75); - --spectrum-actionbutton-sized-text-to-visual: var(--spectrum-text-to-visual-75); - --spectrum-actionbutton-sized-edge-to-hold-icon: var(--spectrum-action-button-edge-to-hold-icon-small); - --spectrum-actionbutton-sized-edge-to-visual: var(--spectrum-component-edge-to-visual-75); - --spectrum-actionbutton-sized-edge-to-text: var(--spectrum-component-edge-to-text-75); - --spectrum-actionbutton-sized-edge-to-visual-only: var(--spectrum-component-edge-to-visual-only-75); + --spectrum-actionbutton-border-radius: var(--spectrum-corner-radius-medium-size-small); + + --spectrum-actionbutton-min-width: calc((var(--spectrum-component-edge-to-visual-only-75) * 2) + var(--spectrum-workflow-icon-size-75)); + --spectrum-actionbutton-height: var(--spectrum-component-height-75); + + --spectrum-actionbutton-icon-size: var(--spectrum-workflow-icon-size-75); + --spectrum-actionbutton-font-size: var(--spectrum-font-size-75); + --spectrum-actionbutton-text-to-visual: var(--spectrum-text-to-visual-75); + --spectrum-actionbutton-edge-to-hold-icon: var(--spectrum-action-button-edge-to-hold-icon-small); + --spectrum-actionbutton-edge-to-visual: var(--spectrum-component-edge-to-visual-75); + --spectrum-actionbutton-edge-to-text: var(--spectrum-component-edge-to-text-75); + --spectrum-actionbutton-edge-to-visual-only: var(--spectrum-component-edge-to-visual-only-75); + + --spectrum-actionbutton-downstate-perspective: var(--spectrum-component-size-minimum-perspective-down); } .spectrum-ActionButton--sizeL { - --spectrum-actionbutton-sized-height: var(--spectrum-component-height-200); - --spectrum-actionbutton-sized-icon-size: var(--spectrum-workflow-icon-size-200); - --spectrum-actionbutton-sized-font-size: var(--spectrum-font-size-200); - --spectrum-actionbutton-sized-text-to-visual: var(--spectrum-text-to-visual-200); - --spectrum-actionbutton-sized-edge-to-hold-icon: var(--spectrum-action-button-edge-to-hold-icon-large); - --spectrum-actionbutton-sized-edge-to-visual: var(--spectrum-component-edge-to-visual-200); - --spectrum-actionbutton-sized-edge-to-text: var(--spectrum-component-edge-to-text-200); - --spectrum-actionbutton-sized-edge-to-visual-only: var(--spectrum-component-edge-to-visual-only-200); + --spectrum-actionbutton-border-radius: var(--spectrum-corner-radius-medium-size-large); + + --spectrum-actionbutton-min-width: calc((var(--spectrum-component-edge-to-visual-only-200) * 2) + var(--spectrum-workflow-icon-size-200)); + --spectrum-actionbutton-height: var(--spectrum-component-height-200); + + --spectrum-actionbutton-icon-size: var(--spectrum-workflow-icon-size-200); + --spectrum-actionbutton-font-size: var(--spectrum-font-size-200); + --spectrum-actionbutton-text-to-visual: var(--spectrum-text-to-visual-200); + --spectrum-actionbutton-edge-to-hold-icon: var(--spectrum-action-button-edge-to-hold-icon-large); + --spectrum-actionbutton-edge-to-visual: var(--spectrum-component-edge-to-visual-200); + --spectrum-actionbutton-edge-to-text: var(--spectrum-component-edge-to-text-200); + --spectrum-actionbutton-edge-to-visual-only: var(--spectrum-component-edge-to-visual-only-200); } .spectrum-ActionButton--sizeXL { - --spectrum-actionbutton-sized-height: var(--spectrum-component-height-300); - --spectrum-actionbutton-sized-icon-size: var(--spectrum-workflow-icon-size-300); - --spectrum-actionbutton-sized-font-size: var(--spectrum-font-size-300); - --spectrum-actionbutton-sized-text-to-visual: var(--spectrum-text-to-visual-300); - --spectrum-actionbutton-sized-edge-to-hold-icon: var(--spectrum-action-button-edge-to-hold-icon-extra-large); - --spectrum-actionbutton-sized-edge-to-visual: var(--spectrum-component-edge-to-visual-300); - --spectrum-actionbutton-sized-edge-to-text: var(--spectrum-component-edge-to-text-300); - --spectrum-actionbutton-sized-edge-to-visual-only: var(--spectrum-component-edge-to-visual-only-300); + --spectrum-actionbutton-border-radius: var(--spectrum-corner-radius-medium-size-extra-large); + + --spectrum-actionbutton-min-width: calc((var(--spectrum-component-edge-to-visual-only-300) * 2) + var(--spectrum-workflow-icon-size-300)); + --spectrum-actionbutton-height: var(--spectrum-component-height-300); + + --spectrum-actionbutton-icon-size: var(--spectrum-workflow-icon-size-300); + --spectrum-actionbutton-font-size: var(--spectrum-font-size-300); + --spectrum-actionbutton-text-to-visual: var(--spectrum-text-to-visual-300); + --spectrum-actionbutton-edge-to-hold-icon: var(--spectrum-action-button-edge-to-hold-icon-extra-large); + --spectrum-actionbutton-edge-to-visual: var(--spectrum-component-edge-to-visual-300); + --spectrum-actionbutton-edge-to-text: var(--spectrum-component-edge-to-text-300); + --spectrum-actionbutton-edge-to-visual-only: var(--spectrum-component-edge-to-visual-only-300); } .spectrum-ActionButton { - /* Variables leveraging t-shirt sizing */ - --spectrum-actionbutton-height: var(--mod-actionbutton-height, var(--spectrum-actionbutton-sized-height)); - --spectrum-actionbutton-icon-size: var(--mod-actionbutton-icon-size, var(--spectrum-actionbutton-sized-icon-size)); - --spectrum-actionbutton-font-size: var(--mod-actionbutton-font-size, var(--spectrum-actionbutton-sized-font-size)); - --spectrum-actionbutton-text-to-visual: var(--mod-actionbutton-text-to-visual, var(--spectrum-actionbutton-sized-text-to-visual)); - --spectrum-actionbutton-edge-to-hold-icon: var(--mod-actionbutton-edge-to-hold-icon, var(--spectrum-actionbutton-sized-edge-to-hold-icon)); + cursor: pointer; + user-select: none; - --spectrum-actionbutton-edge-to-visual: var(--mod-actionbutton-edge-to-visual, calc(var(--spectrum-actionbutton-sized-edge-to-visual) - var(--spectrum-actionbutton-border-width))); - --spectrum-actionbutton-edge-to-text: var(--mod-actionbutton-edge-to-text, calc(var(--spectrum-actionbutton-sized-edge-to-text) - var(--spectrum-actionbutton-border-width))); - --spectrum-actionbutton-edge-to-visual-only: var(--mod-actionbutton-edge-to-visual-only, calc(var(--spectrum-actionbutton-sized-edge-to-visual-only) - var(--spectrum-actionbutton-border-width))); + /* Contain halo */ + position: relative; - @extend %spectrum-BaseButton; + /* Show the button overflow in Edge. */ + overflow: visible; + display: inline-flex; + align-items: center; + justify-content: center; - position: relative; + box-sizing: border-box; + + /* Remove button the margin in Firefox and Safari. */ + margin: 0; + + font-family: var(--mod-button-font-family, var(--spectrum-sans-font-family-stack)); + + /* Adjacent buttons should be aligned correctly */ + vertical-align: top; - min-inline-size: var(--mod-actionbutton-min-width, calc(var(--mod-actionbutton-edge-to-visual-only, var(--spectrum-actionbutton-sized-edge-to-visual-only)) * 2 + var(--spectrum-actionbutton-icon-size))); - block-size: var(--spectrum-actionbutton-height); + -webkit-font-smoothing: antialiased; - border-radius: var(--spectrum-actionbutton-border-radius); + /* Font smoothing for Firefox */ + -moz-osx-font-smoothing: grayscale; + text-decoration: none; + + /* Remove the inheritance of text transform on button in Edge, Firefox, and IE. */ + text-transform: none; + + /* stylelint-disable-next-line property-no-vendor-prefix -- Correct the inability to style clickable types in iOS and Safari (normalize). */ + -webkit-appearance: button; + + transition: + background var(--mod-button-animation-duration, var(--spectrum-animation-duration-100)) ease-out, + border-color var(--mod-button-animation-duration, var(--spectrum-animation-duration-100)) ease-out, + color var(--mod-button-animation-duration, var(--spectrum-animation-duration-100)) ease-out, + box-shadow var(--mod-button-animation-duration, var(--spectrum-animation-duration-100)) ease-out; + + min-inline-size: var(--mod-actionbutton-min-width, var(--spectrum-actionbutton-min-width)); + block-size: var(--mod-actionbutton-height, var(--spectrum-actionbutton-height)); + line-height: var(--mod-actionbutton-line-height, var(--spectrum-actionbutton-line-height)); + + border-radius: var(--mod-actionbutton-border-radius, var(--spectrum-actionbutton-border-radius)); border-width: var(--spectrum-actionbutton-border-width); + border-color: var(--highcontrast-actionbutton-border-color, var(--spectrum-actionbutton-border-color)); + border-style: solid; - gap: calc(var(--spectrum-actionbutton-text-to-visual) + var(--spectrum-actionbutton-edge-to-text) - var(--spectrum-actionbutton-edge-to-visual-only)); + gap: var(--mod-actionbutton-text-to-visual, var(--spectrum-actionbutton-text-to-visual)); + padding-inline: calc(var(--mod-actionbutton-edge-to-text, var(--spectrum-actionbutton-edge-to-text)) - var(--spectrum-actionbutton-border-width)); - /* Start with text-only padding */ - padding-inline: var(--spectrum-actionbutton-edge-to-text); + background-color: var(--highcontrast-actionbutton-background-color-default, var(--mod-actionbutton-background-color-default, var(--spectrum-actionbutton-background-color-default))); + color: var(--highcontrast-actionbutton-content-color-default, var(--mod-actionbutton-content-color-default, var(--spectrum-actionbutton-content-color-default))); - background-color: var(--spectrum-actionbutton-background-color); - border-color: var(--spectrum-actionbutton-border-color); - color: var(--spectrum-actionbutton-content-color); + /* Fix Firefox */ + &::-moz-focus-inner { + margin-block-start: -2px; + margin-block-end: -2px; + padding: 0; + border: 0; - transition: border-color var(--mod-actionbutton-animation-duration, var(--spectrum-animation-duration-100)) ease-in-out; + /* Remove the inner border and padding for button in Firefox. */ + border-style: none; + } &::after { position: absolute; inset: 0; - margin: calc((var(--spectrum-actionbutton-focus-indicator-gap) + var(--spectrum-actionbutton-border-width)) * -1); + border-radius: var(--spectrum-actionbutton-focus-indicator-border-radius); + transition: box-shadow var(--highcontrast-actionbutton-animation-duration, var(--spectrum-actionbutton-animation-duration)) ease-in-out; + pointer-events: none; + content: ""; + } - border-radius: var(--mod-actionbutton-focus-indicator-border-radius, calc(var(--spectrum-actionbutton-border-radius) + var(--spectrum-actionbutton-focus-indicator-gap))); + &:focus { + outline: none; + } - transition: box-shadow var(--mod-actionbutton-animation-duration, var(--spectrum-animation-duration-100)) ease-in-out; + &:disabled, + &.is-disabled { + cursor: default; + } - pointer-events: none; - content: ""; + &:hover { + background-color: var(--highcontrast-actionbutton-background-color-default, var(--mod-actionbutton-background-color-hover, var(--spectrum-actionbutton-background-color-hover))); + color: var(--highcontrast-actionbutton-content-color-default, var(--mod-actionbutton-content-color-hover, var(--spectrum-actionbutton-content-color-hover))); } &:focus-visible { - /* kill the default ring */ + background-color: var(--highcontrast-actionbutton-background-color-default, var(--mod-actionbutton-background-color-focus, var(--spectrum-actionbutton-background-color-focus))); + color: var(--highcontrast-actionbutton-content-color-default, var(--mod-actionbutton-content-color-focus, var(--spectrum-actionbutton-content-color-focus))); + box-shadow: none; outline: none; &::after { - box-shadow: 0 0 0 var(--spectrum-actionbutton-focus-indicator-thickness) var(--spectrum-actionbutton-focus-indicator-color); + box-shadow: 0 0 0 var(--spectrum-actionbutton-focus-indicator-thickness) var(--highcontrast-actionbutton-focus-indicator-color, var(--spectrum-actionbutton-focus-indicator-color)); } } + + &:active { + background-color: var(--highcontrast-actionbutton-background-color-default, var(--mod-actionbutton-background-color-down, var(--spectrum-actionbutton-background-color-down))); + color: var(--highcontrast-actionbutton-content-color-default, var(--mod-actionbutton-content-color-down, var(--spectrum-actionbutton-content-color-down))); + transform: perspective(var(--spectrum-actionbutton-downstate-perspective)) translateZ(var(--spectrum-component-size-difference-down)); + } + + /* ideal when we want to disable the button but still allow its content to be focused */ + &:is(:disabled, .is-disabled, [aria-disabled="true"]) { + background-color: var(--highcontrast-actionbutton-background-color-disabled, var(--mod-actionbutton-background-color-disabled, var(--spectrum-actionbutton-background-color-disabled))); + color: var(--highcontrast-actionbutton-content-color-disabled, var(--mod-actionbutton-content-color-disabled, var(--spectrum-actionbutton-content-color-disabled))); + } } a.spectrum-ActionButton { - @extend %spectrum-AnchorButton; + /* Make link text not selectable */ + user-select: none; + + /* stylelint-disable-next-line property-no-vendor-prefix -- Remove appearance for clickable types in iOS and Safari. */ + -webkit-appearance: none; } -/* Nested sub-component: Icon */ .spectrum-ActionButton-icon { - @extend %spectrum-ButtonIcon; - - inline-size: var(--spectrum-actionbutton-icon-size); - block-size: var(--spectrum-actionbutton-icon-size); - - /* adjust icon positioning to match UI kit */ - margin-inline-start: calc(var(--spectrum-actionbutton-edge-to-visual) - var(--spectrum-actionbutton-edge-to-text)); - margin-inline-end: calc(var(--spectrum-actionbutton-edge-to-visual-only) - var(--spectrum-actionbutton-edge-to-text)); + flex-shrink: 0; + max-block-size: 100%; + inline-size: var(--mod-actionbutton-icon-size, var(--spectrum-actionbutton-icon-size)); + block-size: var(--mod-actionbutton-icon-size, var(--spectrum-actionbutton-icon-size)); color: inherit; +} - /* Augment the margin correction for the icon only scenario */ - .spectrum-ActionButton-hold + &, - &:only-child { - margin-inline-start: calc(var(--spectrum-actionbutton-edge-to-visual-only) - var(--spectrum-actionbutton-edge-to-text)); - } +/* Icon and label text */ +.spectrum-ActionButton:has(.spectrum-ActionButton-icon) { + padding-inline-start: calc(var(--mod-actionbutton-edge-to-visual, var(--spectrum-actionbutton-edge-to-visual)) - var(--spectrum-actionbutton-border-width)); +} + +/* Icon only */ +.spectrum-ActionButton:not(:has(.spectrum-ActionButton-label)) { + padding-inline: calc(var(--mod-actionbutton-edge-to-visual-only, var(--spectrum-actionbutton-edge-to-visual-only)) - var(--spectrum-actionbutton-border-width)); } .spectrum-ActionButton-label { - @extend %spectrum-ButtonLabel; + align-self: center; + justify-self: center; + + /* Fixes horizontal alignment of text in anchor buttons */ + text-align: center; + pointer-events: none; - line-height: var(--spectrum-actionbutton-height); - font-size: var(--spectrum-actionbutton-font-size); + font-size: var(--mod-actionbutton-font-size, var(--spectrum-actionbutton-font-size)); + font-weight: var(--mod-actionbutton-font-weight, var(--spectrum-actionbutton-font-weight)); + font-style: var(--mod-actionbutton-font-style, var(--spectrum-actionbutton-font-style)); white-space: nowrap; color: var(--mod-actionbutton-label-color, inherit); text-overflow: ellipsis; overflow: hidden; + + &:empty { + display: none; + } } .spectrum-ActionButton-hold { position: absolute; - inset-inline-end: calc(var(--spectrum-actionbutton-edge-to-hold-icon) - var(--spectrum-actionbutton-border-width)); - inset-block-end: calc(var(--spectrum-actionbutton-edge-to-hold-icon) - var(--spectrum-actionbutton-border-width)); - + inset-inline-end: calc(var(--mod-actionbutton-edge-to-hold-icon, var(--spectrum-actionbutton-edge-to-hold-icon)) - var(--spectrum-actionbutton-border-width)); + inset-block-end: calc(var(--mod-actionbutton-edge-to-hold-icon, var(--spectrum-actionbutton-edge-to-hold-icon)) - var(--spectrum-actionbutton-border-width)); + display: block; color: inherit; + transform: var(--spectrum-logical-rotation); +} - transform: var(--spectrum-logical-rotation,); +@media (forced-colors: active) { + .spectrum-ActionButton { + /** + * Default + * - Uses "Button*" system color pairings. + * - Focus indicator is outside the element and should contrast with its background (default of Canvas). + */ + --highcontrast-actionbutton-border-color: ButtonBorder; + --highcontrast-actionbutton-background-color-default: ButtonFace; + --highcontrast-actionbutton-content-color-default: ButtonText; + + --highcontrast-actionbutton-background-color-disabled: ButtonFace; + --highcontrast-actionbutton-content-color-disabled: GrayText; + + --highcontrast-actionbutton-focus-indicator-color: CanvasText; + + /** + * Avoid performance and rendering issues with transitions between system colors. + * Fixes bug in Windows High Contrast where border flashes the wrong color after hover (quiet). + */ + --highcontrast-actionbutton-animation-duration: 0; + + &::after { + /* Make sure the box-shadow for the focus indicator renders. */ + forced-color-adjust: none; + } + + .spectrum-ActionButton-icon, + .spectrum-ActionButton-hold, + .spectrum-ActionButton-label { + /* Removes the extra unwanted background on label ("readability backplate") that can cause text to be unreadable. */ + forced-color-adjust: none; + } + + /** + * Quiet + * - Default blends in with background and has no border. + * - Quiet + disabled does not show border unless selected. + */ + &.spectrum-ActionButton--quiet { + --highcontrast-actionbutton-border-color: Canvas; + --highcontrast-actionbutton-background-color-default: Canvas; + --highcontrast-actionbutton-background-color-disabled: Canvas; + --highcontrast-actionbutton-content-color-default: CanvasText; + + &:is(:disabled, .is-disabled, [aria-disabled="true"]):not(:where(.is-selected, [aria-pressed="true"], [aria-expanded="true"])) { + --highcontrast-actionbutton-border-color: Canvas; + } + } + + /* Interaction shows a change in border color. */ + &:hover, + &:active, + &:focus-visible { + --highcontrast-actionbutton-border-color: Highlight; + } + + &:is(.is-selected, [aria-pressed="true"], [aria-expanded="true"]) { + --highcontrast-actionbutton-border-color: Highlight; + --highcontrast-actionbutton-background-color-default: Highlight; + --highcontrast-actionbutton-content-color-default: HighlightText; + } + + /* Disabled has a GrayText border and content color. */ + &:disabled { + --highcontrast-actionbutton-border-color: GrayText; + } + } } diff --git a/components/actionbutton/package.json b/components/actionbutton/package.json index 400dfbfcaa8..09f5a7dfafd 100644 --- a/components/actionbutton/package.json +++ b/components/actionbutton/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/actionbutton", - "version": "7.2.0", + "version": "8.0.0-next.4", "description": "The Spectrum CSS action button component", "license": "Apache-2.0", "author": "Adobe", @@ -19,15 +19,13 @@ "./package.json": "./package.json", "./dist/*": "./dist/*", "./index.css": "./dist/index.css", - "./index-*.css": "./dist/index-*.css", "./metadata.json": "./dist/metadata.json", - "./themes/*": "./dist/themes/*", "./stories/*": "./stories/*" }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/icon": ">=9.0.0 <10.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/icon": ">=10.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/icon": { @@ -38,9 +36,8 @@ } }, "devDependencies": { - "@spectrum-css/commons": "11.1.0", - "@spectrum-css/icon": "9.2.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/icon": "10.0.0-next.3", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/actionbutton/stories/actionbutton.stories.js b/components/actionbutton/stories/actionbutton.stories.js index a08f0f7bbfc..fb5fc92084b 100644 --- a/components/actionbutton/stories/actionbutton.stories.js +++ b/components/actionbutton/stories/actionbutton.stories.js @@ -1,22 +1,20 @@ import { default as IconStories } from "@spectrum-css/icon/stories/icon.stories.js"; -import { Sizes } from "@spectrum-css/preview/decorators"; +import { Sizes, withDownStateDimensionCapture } from "@spectrum-css/preview/decorators"; import { disableDefaultModes } from "@spectrum-css/preview/modes"; -import { isActive, isDisabled, isEmphasized, isFocused, isHovered, isQuiet, isSelected, size, staticColor } from "@spectrum-css/preview/types"; +import { isActive, isDisabled, isEmphasized, isFocused, isHovered, isOpen, isQuiet, isSelected, size, staticColor } from "@spectrum-css/preview/types"; +import { ActionButtonGroup } from "./actionbutton.test.js"; +import { ActionButtonsWithIconOptions, IconOnlyOption, Template, TreatmentTemplate } from "./template.js"; + +// Local assets to render the component styles and structure import metadata from "../dist/metadata.json"; import packageJson from "../package.json"; -import { ActionButtonGroup } from "./actionbutton.test.js"; -import { ActionButtonsWithIconOptions, IconOnlyOption, TreatmentTemplate } from "./template.js"; /** * The action button component represents an action a user can take. * * ## Usage notes * - * For action buttons that only contain an icon with no label, do not include the element with the `.spectrum-ActionButton-label` class in the markup. If an icon and a label are both used, ensure that the element with the `.spectrum-ActionButton-label` class comes after the `.spectrum-Icon` element. - * - * If the hold icon is used, ensure that the element with the `.spectrum-ActionButton-hold` class comes before the `.spectrum-Icon` element. - * - * When using `.spectrum-ActionButton--staticWhite` or `.spectrum-ActionButton--staticBlack`, use the `--mod-actionbutton-content-color-default` custom property to set the text color when selected. + * For action buttons that only contain an icon with no label, do not include the element with the `.spectrum-ActionButton-label` class in the markup. */ export default { title: "Action button", @@ -25,6 +23,7 @@ export default { size: size(["xs", "s", "m", "l", "xl"]), iconName: { ...(IconStories?.argTypes?.iconName ?? {}), + name: "Workflow icon", if: false, }, label: { @@ -37,9 +36,15 @@ export default { control: { type: "text" }, }, isQuiet, - isEmphasized, + isEmphasized: { + ...isEmphasized, + if: { arg: "staticColor", truthy: false }, + }, isDisabled, - isSelected, + isSelected: { + ...isSelected, + description: "An optional state used when treating the action button as a toggle.", + }, isHovered, isFocused, isActive, @@ -53,8 +58,8 @@ export default { control: "boolean", }, hasPopup: { - name: "Has popup", - description: "If the button triggers a popup action, this should be set to reflect the type of element that pops-up.", + name: "Has pop-up", + description: "If the button triggers a popover element to open, this should be set to reflect the semantic type of that element.", type: { name: "string" }, table: { type: { summary: "string" }, @@ -63,7 +68,26 @@ export default { control: "select", options: ["true", "menu", "listbox", "tree", "grid", "dialog", "false"], }, - staticColor, + hasLongPress: { + name: "Long press", + description: "If the trigger supports a long-press action which triggers the menu, this should be set to true.", + type: { name: "boolean" }, + table: { + type: { summary: "boolean" }, + category: "Accessibility", + }, + control: "boolean", + }, + isOpen: { + ...isOpen, + name: "Popover open", + description: "This should be true when the popover element is open.", + if: { arg: "hasPopup", truthy: true }, + }, + staticColor: { + ...staticColor, + if: { arg: "isEmphasized", truthy: false }, + }, }, args: { rootClass: "spectrum-ActionButton", @@ -71,6 +95,7 @@ export default { isQuiet: false, isEmphasized: false, hasPopup: "false", + hasLongPress: false, isActive: false, isFocused: false, isHovered: false, @@ -82,20 +107,30 @@ export default { }, parameters: { actions: { - handles: ["click .spectrum-ActionButton:not([disabled])"], + handles: ["click .spectrum-ActionButton:not([disabled])", "mousedown .spectrum-ActionButton:not([disabled])", "mouseup .spectrum-ActionButton:not([disabled])", "touchstart .spectrum-ActionButton:not([disabled])", "touchend .spectrum-ActionButton:not([disabled])"], }, design: { type: "figma", url: "https://www.figma.com/design/Mngz9H7WZLbrCvGQf3GnsY/S2-%2F-Desktop?node-id=702-2877", }, + downState: { + selectors: [".spectrum-ActionButton:not(:disabled)"], + }, packageJson, metadata, docs: { story: { height: "auto", }, - } + }, + status: { + type: "migrated", + }, }, + decorators: [ + withDownStateDimensionCapture, + ], + tags: ["migrated"], }; export const Default = ActionButtonGroup.bind({}); @@ -106,7 +141,9 @@ Default.tags = ["!autodocs"]; /** * Action buttons should always have a label, unless they are only using an icon that is universally understood and accessible. They can have an optional icon, but it should not be used for decoration. Use an icon only when necessary and when it has a strong association with the label text. * - * The label can be hidden to create an icon-only action button. If the label is hidden, an icon is required, and the label will appear in a tooltip on hover. + * The label can be hidden to create an icon-only action button. If the label is hidden, an icon is required, and the implementation should show the label with a tooltip on hover. + * + * Action buttons can be used as toggles instead of for taking direct action. The optional "selected" state displayed below is used for when the action button is toggleable. */ export const Standard = TreatmentTemplate.bind({}); Standard.args = Default.args; @@ -117,7 +154,9 @@ Standard.parameters = { Standard.storyName = "Default"; /** - * The emphasized action button has a blue background for its selected state in order to provide a visual prominence. This is optimal for when the selection should call attention, such as within a tool bar. + * The emphasized action button has a blue background for its selected state in order to provide a visual prominence. + * This is optimal for when the selection should call attention, such as within a tool bar. + * For this variant, the `.spectrum-ActionButton--emphasized` class is applied to `.spectrum-ActionButton`. */ export const Emphasized = TreatmentTemplate.bind({}); Emphasized.tags = ["!dev"]; @@ -130,9 +169,6 @@ Emphasized.parameters = { }, }; -/** - * Adding the `.spectrum-ActionButton--emphasized` class to a quiet action button can be effective in calling attention. - */ export const EmphasizedQuiet = TreatmentTemplate.bind({}); EmphasizedQuiet.tags = ["!dev"]; EmphasizedQuiet.args = { @@ -144,7 +180,7 @@ EmphasizedQuiet.parameters = { disableSnapshot: true, }, }; -EmphasizedQuiet.storyName = "Emphasized (quiet)"; +EmphasizedQuiet.storyName = "Quiet, emphasized"; /** * Quiet action buttons have no visible background until they’re interacted with. This style works best when a clear layout (vertical stack, table, grid) makes it easy to parse the buttons. Too many quiet components in a small space can be hard to read. @@ -161,7 +197,10 @@ Quiet.parameters = { }; /** - * An action button can have a hold icon (a small corner triangle). This icon indicates that holding down the action button for a short amount of time can reveal a popover menu, which can be used, for example, to switch between related actions. Because of the way padding is calculated, the hold icon must be placed before the workflow icon in the markup. + * An action button can have a hold icon (a small corner triangle). This icon indicates that holding down the action button for a + * short amount of time (currently the standard is 300ms) can reveal a [popover](/docs/components-popover--docs) menu, which can be used, for example, to switch + * between related actions. Note that this popover menu is not demonstrated here; this would be handled by the implementation. + * Because of the way padding is calculated, the hold icon must be placed before the workflow icon in the markup. */ export const HoldIcon = IconOnlyOption.bind({}); HoldIcon.tags = ["!dev"]; @@ -190,6 +229,14 @@ StaticWhiteQuiet.parameters = { chromatic: { disableSnapshot: true } }; +/** + * When an action button needs to be placed on top of a color background or a visual, use the static color + * option. Use static black on light color or image backgrounds, and static white on dark color or image + * backgrounds, regardless of the color theme. For more info, see the + * [design guidelines](https://spectrum.adobe.com/page/action-button/#Static-color). + * + * Emphasized is not supported for the static black and static white variants. + */ export const StaticBlackDocs = TreatmentTemplate.bind({}); StaticBlackDocs.tags = ["!dev"]; StaticBlackDocs.args = { @@ -226,6 +273,28 @@ Sizing.parameters = { chromatic: { disableSnapshot: true }, }; +/** + * When the action button text is too long for the available horizontal space, it truncates at the end. + * To demonstrate what this looks like, this example sets a maximum width on the button. + * + * Implementations should also reveal the full text on hover, per this component's + * [design guidelines on text overflow](https://spectrum.adobe.com/page/action-button/#Text-overflow). + * This is not demonstrated here. + */ +export const TextOverflowBehavior = Template.bind({}); +TextOverflowBehavior.tags = ["!dev"]; +TextOverflowBehavior.args = { + label: "This is extra long text that will cause text truncation", + customStyles: { + "max-inline-size": "120px", + }, +}; +TextOverflowBehavior.parameters = { + chromatic: { + disableSnapshot: true, + }, +}; + // ********* VRT ONLY ********* // export const WithForcedColors = ActionButtonGroup.bind({}); WithForcedColors.args = Default.args; diff --git a/components/actionbutton/stories/actionbutton.test.js b/components/actionbutton/stories/actionbutton.test.js index fb37fdc910f..7e65e449655 100644 --- a/components/actionbutton/stories/actionbutton.test.js +++ b/components/actionbutton/stories/actionbutton.test.js @@ -17,12 +17,14 @@ export const ActionButtons = (args, context) => { ${Template({ ...args, hasPopup: "true", + hasLongPress: true, hideLabel: true, }, context)} ${Template({ ...args, iconName: undefined, hasPopup: "true", + hasLongPress: true, }, context)}
`; @@ -62,11 +64,6 @@ export const ActionButtonGroup = Variants({ testHeading: "Static black", staticColor: "black", }, - { - testHeading: "Static black - emphasized", - staticColor: "black", - isEmphasized: true, - }, { testHeading: "Static black - quiet", staticColor: "black", @@ -76,11 +73,6 @@ export const ActionButtonGroup = Variants({ testHeading: "Static white", staticColor: "white", }, - { - testHeading: "Static white - emphasized", - staticColor: "white", - isEmphasized: true, - }, { testHeading: "Static white - quiet", staticColor: "white", diff --git a/components/actionbutton/stories/template.js b/components/actionbutton/stories/template.js index 425b7e4115c..a45b497b476 100644 --- a/components/actionbutton/stories/template.js +++ b/components/actionbutton/stories/template.js @@ -7,9 +7,6 @@ import { when } from "lit/directives/when.js"; import { capitalize } from "lodash-es"; import "../index.css"; -import "../themes/spectrum.css"; -/* Must be imported last */ -import "../themes/express.css"; /** * @todo load order should not influence the icon size but it is; fix this @@ -57,7 +54,9 @@ export const Template = ({ isFocused = false, isActive = false, isDisabled = false, + isOpen = false, hasPopup = "false", + hasLongPress = false, popupId, hideLabel = false, staticColor, @@ -76,7 +75,8 @@ export const Template = ({ aria-label=${ifDefined(hideLabel ? label : undefined)} aria-haspopup=${ifDefined(hasPopup && hasPopup !== "false" ? hasPopup : undefined)} aria-controls=${hasPopup && hasPopup !== "false" ? popupId : undefined} - aria-pressed=${isSelected ? "true" : "false"} + aria-pressed=${ifDefined(isSelected ? "true" : undefined)} + aria-expanded=${ifDefined(hasPopup && hasPopup !== "false" ? isOpen ? "true" : "false" : undefined)} class=${classMap({ [rootClass]: true, [`${rootClass}--size${size?.toUpperCase()}`]: @@ -86,7 +86,6 @@ export const Template = ({ [`${rootClass}--static${capitalize(staticColor)}`]: typeof staticColor !== "undefined", ["is-disabled"]: isDisabled, - ["is-selected"]: isSelected, ["is-hover"]: isHovered, ["is-focus-visible"]: isFocused, ["is-active"]: isActive, @@ -94,25 +93,37 @@ export const Template = ({ })} id=${id} data-testid=${testId ?? id} + popovertarget=${ifDefined(hasPopup && hasPopup !== "false" ? popupId : undefined)} role=${ifDefined(role)} style=${styleMap(customStyles)} ?disabled=${isDisabled} - @click=${onclick ?? function() { - updateArgs({ - isSelected: !isSelected - }); + @click=${function () { + if (isDisabled) return; + if (typeof onclick === "function") onclick(); + else { + updateArgs({ + isSelected: !isSelected, + isOpen: !isOpen, + }); + } }} - @focusin=${function() { + @focusin=${function () { updateArgs({ isFocused: true }); }} @focusout=${function() { updateArgs({ isFocused: false }); }} > - ${when(hasPopup && hasPopup !== "false", () => + ${when(hasLongPress && hasPopup && hasPopup !== "false", () => Icon({ size, - iconName: "CornerTriangle", + iconName: "CornerTriangle" + ({ + xs: "75", + s: "75", + m: "100", + l: "200", + xl: "300", + }[size] || "100"), setName: "ui", customClasses: [`${rootClass}-hold`], }, context) @@ -134,64 +145,78 @@ export const Template = ({ `; }; +/** + * Displays multiple action buttons in a row, with different combinations of + * label, icon, and hold button (has pop-up). + */ export const ActionButtonsWithIconOptions = (args, context) => Container({ withBorder: false, direction: "row", wrapperStyles: { columnGap: "12px", }, - content: html` - ${Template({ + content: [ + Template({ ...args, iconName: undefined, - }, context)} - ${Template({ + }, context), + Template({ ...args, - }, context)} - ${Template({ + }, context), + Template({ ...args, hideLabel: true, - }, context)} - ${Template({ + }, context), + Template({ ...args, hideLabel: true, hasPopup: "true", - }, context)} - ${Template({ + hasLongPress: true, + }, context), + Template({ ...args, iconName: undefined, hasPopup: "true", - }, context)} - ` + hasLongPress: true, + }, context) + ], }, context); +/** + * Displays two action buttons in a row: + * - icon only action button + * - icon only action button with hold button (has pop-up) + */ export const IconOnlyOption = (args, context) => Container({ withBorder: false, direction: "row", wrapperStyles: { columnGap: "12px", }, - content: html` - ${Template({ + content: [ + Template({ ...args, hideLabel: true, hasPopup: "true", - }, context)} - ${Template({ + hasLongPress: true, + }, context), + Template({ ...args, hideLabel: true, isQuiet: true, hasPopup: "true", - }, context)} - ` + hasLongPress: true, + }, context), + ], }, context); +/** + * Displays multiple groups of action buttons for: + * default, selected, disabled, and selected + disabled + */ export const TreatmentTemplate = (args, context) => Container({ withBorder: false, direction: "row", - wrapperStyles: { - rowGap: "12px", - }, content: html`${[ { isSelected: false, isDisabled: false, heading: "Default" }, { isSelected: true, isDisabled: false, heading: "Selected" }, @@ -200,10 +225,13 @@ export const TreatmentTemplate = (args, context) => Container({ ].map(({ isSelected, isDisabled, heading }) => Container({ withBorder: false, heading: heading, + containerStyles: { + rowGap: "8px", + }, content: ActionButtonsWithIconOptions({ ...args, isSelected, isDisabled, - }) + }, context) }, context))}`, }, context); diff --git a/components/actionbutton/themes/express.css b/components/actionbutton/themes/express.css deleted file mode 100644 index be6353eb9cd..00000000000 --- a/components/actionbutton/themes/express.css +++ /dev/null @@ -1,77 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--express */ - -@import "./spectrum.css"; - -@container style(--system: express) { - .spectrum-ActionButton { - --spectrum-actionbutton-background-color-default: var(--spectrum-gray-200); - --spectrum-actionbutton-background-color-hover: var(--spectrum-gray-300); - --spectrum-actionbutton-background-color-down: var(--spectrum-gray-400); - --spectrum-actionbutton-background-color-focus: var(--spectrum-gray-300); - --spectrum-actionbutton-background-color-disabled: var(--spectrum-gray-200); - - --spectrum-actionbutton-border-color-default: transparent; - --spectrum-actionbutton-border-color-hover: transparent; - --spectrum-actionbutton-border-color-down: transparent; - --spectrum-actionbutton-border-color-focus: transparent; - --spectrum-actionbutton-border-color-disabled: transparent; - - &.spectrum-ActionButton--quiet { - --spectrum-actionbutton-background-color-default: transparent; - --spectrum-actionbutton-background-color-hover: var(--spectrum-gray-300); - --spectrum-actionbutton-background-color-down: var(--spectrum-gray-400); - --spectrum-actionbutton-background-color-focus: var(--spectrum-gray-300); - } - - &.spectrum-ActionButton--staticBlack, - &.spectrum-ActionButton--staticWhite { - --spectrum-actionbutton-border-color-default: transparent; - --spectrum-actionbutton-border-color-hover: transparent; - --spectrum-actionbutton-border-color-down: transparent; - --spectrum-actionbutton-border-color-focus: transparent; - } - - &.spectrum-ActionButton--staticBlack { - --spectrum-actionbutton-background-color-disabled: transparent; - --spectrum-actionbutton-background-color-default: var(--spectrum-transparent-black-200); - --spectrum-actionbutton-background-color-hover: var(--spectrum-transparent-black-300); - --spectrum-actionbutton-background-color-down: var(--spectrum-transparent-black-400); - --spectrum-actionbutton-background-color-focus: var(--spectrum-transparent-black-300); - - &.spectrum-ActionButton--quiet { - --spectrum-actionbutton-background-color-default: var(--spectrum-transparent-black-200); - --spectrum-actionbutton-background-color-hover: var(--spectrum-transparent-black-300); - --spectrum-actionbutton-background-color-down: var(--spectrum-transparent-black-400); - --spectrum-actionbutton-background-color-focus: var(--spectrum-transparent-black-300); - } - } - - &.spectrum-ActionButton--staticWhite { - --spectrum-actionbutton-background-color-disabled: transparent; - --spectrum-actionbutton-background-color-default: var(--spectrum-transparent-white-200); - --spectrum-actionbutton-background-color-hover: var(--spectrum-transparent-white-300); - --spectrum-actionbutton-background-color-down: var(--spectrum-transparent-white-400); - --spectrum-actionbutton-background-color-focus: var(--spectrum-transparent-white-300); - - &.spectrum-ActionButton--quiet { - --spectrum-actionbutton-background-color-default: var(--spectrum-transparent-white-200); - --spectrum-actionbutton-background-color-hover: var(--spectrum-transparent-white-300); - --spectrum-actionbutton-background-color-down: var(--spectrum-transparent-white-400); - --spectrum-actionbutton-background-color-focus: var(--spectrum-transparent-white-300); - } - } - } -} diff --git a/components/actionbutton/themes/spectrum-two.css b/components/actionbutton/themes/spectrum-two.css deleted file mode 100644 index b436e9a77b5..00000000000 --- a/components/actionbutton/themes/spectrum-two.css +++ /dev/null @@ -1,112 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -@container style(--system: spectrum) { - .spectrum-ActionButton { - --spectrum-actionbutton-background-color-default: var(--spectrum-gray-100); - --spectrum-actionbutton-background-color-hover: var(--spectrum-gray-200); - --spectrum-actionbutton-background-color-down: var(--spectrum-gray-200); - --spectrum-actionbutton-background-color-focus: var(--spectrum-gray-200); - --spectrum-actionbutton-background-color-disabled: var(--spectrum-disabled-background-color); - - --spectrum-actionbutton-background-color-selected: var(--spectrum-neutral-background-color-selected-default); - --spectrum-actionbutton-background-color-selected-hover: var(--spectrum-neutral-background-color-selected-hover); - --spectrum-actionbutton-background-color-selected-down: var(--spectrum-neutral-background-color-selected-down); - --spectrum-actionbutton-background-color-selected-focus: var(--spectrum-neutral-background-color-selected-key-focus); - - --spectrum-actionbutton-border-color-default: transparent; - --spectrum-actionbutton-border-color-hover: transparent; - --spectrum-actionbutton-border-color-down: transparent; - --spectrum-actionbutton-border-color-focus: transparent; - --spectrum-actionbutton-border-color-disabled: transparent; - - --spectrum-actionbutton-content-color-selected: var(--spectrum-gray-50); - - &.spectrum-ActionButton--sizeM { - --spectrum-actionbutton-border-radius-default: var(--spectrum-corner-radius-medium-size-medium); - } - - &.spectrum-ActionButton--sizeXS { - --spectrum-actionbutton-border-radius-default: var(--spectrum-corner-radius-medium-size-extra-small); - } - - &.spectrum-ActionButton--sizeS { - --spectrum-actionbutton-border-radius-default: var(--spectrum-corner-radius-medium-size-small); - } - - &.spectrum-ActionButton--sizeL { - --spectrum-actionbutton-border-radius-default: var(--spectrum-corner-radius-medium-size-large); - } - - &.spectrum-ActionButton--sizeXL { - --spectrum-actionbutton-border-radius-default: var(--spectrum-corner-radius-medium-size-extra-large); - } - - &.spectrum-ActionButton--quiet { - --spectrum-actionbutton-background-color-default: transparent; - --spectrum-actionbutton-background-color-hover: var(--spectrum-gray-200); - --spectrum-actionbutton-background-color-down: var(--spectrum-gray-200); - --spectrum-actionbutton-background-color-focus: var(--spectrum-gray-200); - --spectrum-actionbutton-background-color-disabled: transparent; - --spectrum-actionbutton-background-color-selected-disabled: var(--spectrum-disabled-background-color); - } - - &.spectrum-ActionButton--staticBlack { - --spectrum-actionbutton-border-color-default: transparent; - --spectrum-actionbutton-border-color-hover: transparent; - --spectrum-actionbutton-border-color-down: transparent; - --spectrum-actionbutton-border-color-focus: transparent; - --spectrum-actionbutton-border-color-disabled: transparent; - - --spectrum-actionbutton-background-color-disabled: var(--spectrum-disabled-static-black-background-color); - --spectrum-actionbutton-background-color-selected-disabled: var(--spectrum-disabled-static-black-background-color); - - --spectrum-actionbutton-background-color-default: var(--spectrum-transparent-black-100); - --spectrum-actionbutton-background-color-hover: var(--spectrum-transparent-black-200); - --spectrum-actionbutton-background-color-down: var(--spectrum-transparent-black-200); - --spectrum-actionbutton-background-color-focus: var(--spectrum-transparent-black-200); - - &.spectrum-ActionButton--quiet { - --spectrum-actionbutton-background-color-default: transparent; - --spectrum-actionbutton-background-color-hover: var(--spectrum-transparent-black-200); - --spectrum-actionbutton-background-color-down: var(--spectrum-transparent-black-200); - --spectrum-actionbutton-background-color-focus: var(--spectrum-transparent-black-200); - --spectrum-actionbutton-background-color-disabled: transparent; - } - } - - &.spectrum-ActionButton--staticWhite { - --spectrum-actionbutton-border-color-default: transparent; - --spectrum-actionbutton-border-color-hover: transparent; - --spectrum-actionbutton-border-color-down: transparent; - --spectrum-actionbutton-border-color-focus: transparent; - --spectrum-actionbutton-border-color-disabled: transparent; - - --spectrum-actionbutton-background-color-disabled: var(--spectrum-disabled-static-white-background-color); - --spectrum-actionbutton-background-color-selected-disabled: var(--spectrum-disabled-static-white-background-color); - - --spectrum-actionbutton-background-color-default: var(--spectrum-transparent-white-100); - --spectrum-actionbutton-background-color-hover: var(--spectrum-transparent-white-200); - --spectrum-actionbutton-background-color-down: var(--spectrum-transparent-white-200); - --spectrum-actionbutton-background-color-focus: var(--spectrum-transparent-white-200); - - &.spectrum-ActionButton--quiet { - --spectrum-actionbutton-background-color-default: transparent; - --spectrum-actionbutton-background-color-hover: var(--spectrum-transparent-white-200); - --spectrum-actionbutton-background-color-down: var(--spectrum-transparent-white-200); - --spectrum-actionbutton-background-color-focus: var(--spectrum-transparent-white-200); - --spectrum-actionbutton-background-color-disabled: transparent; - } - } - } -} diff --git a/components/actionbutton/themes/spectrum.css b/components/actionbutton/themes/spectrum.css deleted file mode 100644 index 0c07028cf58..00000000000 --- a/components/actionbutton/themes/spectrum.css +++ /dev/null @@ -1,93 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--legacy */ - -@import "./spectrum-two.css"; - -@container style(--system: legacy) { - .spectrum-ActionButton { - --spectrum-actionbutton-background-color-default: var(--spectrum-gray-75); - --spectrum-actionbutton-background-color-hover: var(--spectrum-gray-200); - --spectrum-actionbutton-background-color-down: var(--spectrum-gray-300); - --spectrum-actionbutton-background-color-focus: var(--spectrum-gray-200); - --spectrum-actionbutton-background-color-disabled: transparent; - --spectrum-actionbutton-background-color-selected-disabled: var(--spectrum-disabled-background-color); - - --spectrum-actionbutton-border-color-default: var(--spectrum-gray-400); - --spectrum-actionbutton-border-color-hover: var(--spectrum-gray-500); - --spectrum-actionbutton-border-color-down: var(--spectrum-gray-600); - --spectrum-actionbutton-border-color-focus: var(--spectrum-gray-500); - --spectrum-actionbutton-border-color-disabled: var(--spectrum-disabled-border-color); - - --spectrum-actionbutton-content-color-selected: var(--spectrum-gray-75); - - &.spectrum-ActionButton--sizeXS, - &.spectrum-ActionButton--sizeS, - &.spectrum-ActionButton--sizeM, - &.spectrum-ActionButton--sizeL, - &.spectrum-ActionButton--sizeXL { - --spectrum-actionbutton-border-radius-default: var(--spectrum-corner-radius-100); - } - - &.spectrum-ActionButton--quiet { - --spectrum-actionbutton-background-color-hover: var(--spectrum-gray-200); - --spectrum-actionbutton-background-color-down: var(--spectrum-gray-300); - --spectrum-actionbutton-background-color-focus: var(--spectrum-gray-200); - } - - &.spectrum-ActionButton--staticBlack { - --spectrum-actionbutton-border-color-default: var(--spectrum-transparent-black-400); - --spectrum-actionbutton-border-color-hover: var(--spectrum-transparent-black-500); - --spectrum-actionbutton-border-color-down: var(--spectrum-transparent-black-600); - --spectrum-actionbutton-border-color-focus: var(--spectrum-transparent-black-500); - --spectrum-actionbutton-border-color-disabled: var(--spectrum-disabled-static-black-border-color); - - --spectrum-actionbutton-background-color-default: transparent; - --spectrum-actionbutton-background-color-hover: var(--spectrum-transparent-black-300); - --spectrum-actionbutton-background-color-down: var(--spectrum-transparent-black-400); - --spectrum-actionbutton-background-color-focus: var(--spectrum-transparent-black-300); - --spectrum-actionbutton-background-color-disabled: transparent; - - &.spectrum-ActionButton--quiet { - --spectrum-actionbutton-background-color-default: transparent; - --spectrum-actionbutton-background-color-hover: var(--spectrum-transparent-black-300); - --spectrum-actionbutton-background-color-down: var(--spectrum-transparent-black-400); - --spectrum-actionbutton-background-color-focus: var(--spectrum-transparent-black-300); - --spectrum-actionbutton-background-color-disabled: transparent; - } - } - - &.spectrum-ActionButton--staticWhite { - --spectrum-actionbutton-border-color-default: var(--spectrum-transparent-white-400); - --spectrum-actionbutton-border-color-hover: var(--spectrum-transparent-white-500); - --spectrum-actionbutton-border-color-down: var(--spectrum-transparent-white-600); - --spectrum-actionbutton-border-color-focus: var(--spectrum-transparent-white-500); - --spectrum-actionbutton-border-color-disabled: var(--spectrum-disabled-static-white-border-color); - - --spectrum-actionbutton-background-color-default: transparent; - --spectrum-actionbutton-background-color-hover: var(--spectrum-transparent-white-300); - --spectrum-actionbutton-background-color-down: var(--spectrum-transparent-white-400); - --spectrum-actionbutton-background-color-focus: var(--spectrum-transparent-white-300); - --spectrum-actionbutton-background-color-disabled: transparent; - - &.spectrum-ActionButton--quiet { - --spectrum-actionbutton-background-color-default: transparent; - --spectrum-actionbutton-background-color-hover: var(--spectrum-transparent-white-300); - --spectrum-actionbutton-background-color-down: var(--spectrum-transparent-white-400); - --spectrum-actionbutton-background-color-focus: var(--spectrum-transparent-white-300); - --spectrum-actionbutton-background-color-disabled: transparent; - } - } - } -} diff --git a/components/actiongroup/CHANGELOG.md b/components/actiongroup/CHANGELOG.md index a4b3acd322f..fee0ec2c2c5 100644 --- a/components/actiongroup/CHANGELOG.md +++ b/components/actiongroup/CHANGELOG.md @@ -1,12 +1,93 @@ # Change log -## 6.2.0 +## 7.0.0-next.3 -### Minor Changes +### Patch Changes + +📝 [#4085](https://github.com/adobe/spectrum-css/pull/4085) [`082862e`](https://github.com/adobe/spectrum-css/commit/082862eb80c6e0ac1c801b1d538e4d2f2bb919b4) Thanks [@castastrophe](https://github.com/castastrophe)! + +### Action menu component (now with custom styles!) + +Introduces `@spectrum-css/actionmenu`, a composition of `ActionButton`, `Popover`, and `Menu` to present action lists from a trigger. Now with custom styles! + +- Adds wrapper classes: `spectrum-ActionMenu`, `spectrum-ActionMenu-trigger`, `spectrum-ActionMenu-popover`, and `spectrum-ActionMenu-menu`. +- Supports long press triggers and four placements (start/end, top/bottom) via the underlying popover API. +- Design reference: [Figma S2 token specs](https://www.figma.com/design/eoZHKJH9a3LJkHYCGt60Vb/S2-token-specs?node-id=20959-21513&node-type=frame&t=jbePQKK1yLdrHG2M-11). + +#### Migration notes + +- If you previously composed an action menu manually (action button + popover + menu), you can adopt the new wrapper classes without changing the underlying markup semantics. Ensure the trigger has `aria-haspopup="menu"` and manages `aria-expanded` according to your application logic. +- For spacing customizations previously done with ad‑hoc margins, switch to the new `--spectrum-actionmenu-button-to-menu-gap` custom property. + +Example markup: + +```html +
+ +
+
    + +
+
+ + + +
+``` + +### Menu refinements + +Updates `@spectrum-css/menu` styles to align with latest Spectrum 2 design specifications and improve accessibility. + +- Updated `.is-selectableMultiple .spectrum-Menu-itemCheckbox` to `.is-selectableMultiple:not(:has(.is-selectable)) .spectrum-Menu-itemCheckbox` to prevent clash with the `.is-selectable` placement. +- Non-breaking; no class or DOM changes required. -📝 [#4218](https://github.com/adobe/spectrum-css/pull/4218) [`2df53f8`](https://github.com/adobe/spectrum-css/commit/2df53f8b9ef6d6a031ca99726aa7f0475443ca03) Thanks [@castastrophe](https://github.com/castastrophe)! +### Action button refinements + +- Selection styling now applies when components use ARIA pressed/expanded semantics, not just `.is-selected`. +- Implemented with `:where()` to keep selector specificity low and prevent downstream specificity battles. +- Non-breaking; no class changes required. + +### Action group refinements + +Aligns selection behavior of grouped items with action button updates. + +- Adds `:where([aria-pressed="true"], [aria-expanded="true"])` alongside `.is-selected` on items to cover more accessibility use-cases while keeping specificity low. +- Non-breaking; no class changes required. + +## 7.0.0-next.2 + +### Major Changes -Ensure accurate exports are present for each component. Specifically, adding `themes/*` assets where present and removing`index-*.css` exports where those assets do not exist. +📝 [#4249](https://github.com/adobe/spectrum-css/pull/4249) [`9629fe3`](https://github.com/adobe/spectrum-css/commit/9629fe37cad996d47c827a3eabcdf39092a27b0d) Thanks [@castastrophe](https://github.com/castastrophe)! + +This update removes `--mod-*` custom property hooks per SWC-1264, see also the RFC for extensible styling. + +- Remove all `--mod-*` custom property hooks. +- Keep existing class selectors and variants unchanged. +- Update stories to reflect the removal of the `--mod-*` override layer. + +Breaking change: the `--mod-*` override layer is removed. Consumers should set `--spectrum-*` variables directly where customization is needed. + +## 7.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + +## 7.0.0-next.0 + +### Patch Changes + +- Updated dependencies []: + - @spectrum-css/actionbutton@8.0.0-next.0 ## 7.0.0 @@ -226,7 +307,7 @@ Output for all component CSS files is now being run through a lightweight optimi ## 4.1.10 -📝 [Commits](https://github.com/adobe/spectrum-css/compare/@spectrum-css/actiongroup@4.1.9...@spectrum-css/actiongroup@4.1.10) +🗓 2024-01-16 • 📝 [Commits](https://github.com/adobe/spectrum-css/compare/@spectrum-css/actiongroup@4.1.9...@spectrum-css/actiongroup@4.1.10) **Note:** Version bump only for package @spectrum-css/actiongroup @@ -342,7 +423,7 @@ Output for all component CSS files is now being run through a lightweight optimi - refactor(actiongroup)!: replace focus-ring with focus-visible([d792847](https://github.com/adobe/spectrum-css/commit/d792847)) -### 🛑 BREAKING CHANGE +### 🛑 BREAKING CHANGES - use native focus-visible pseudo class for focus styling @@ -378,7 +459,7 @@ Output for all component CSS files is now being run through a lightweight optimi ## 3.0.56 -📝 [Commits](https://github.com/adobe/spectrum-css/compare/@spectrum-css/actiongroup@3.0.55...@spectrum-css/actiongroup@3.0.56) +🗓 2023-07-14 • 📝 [Commits](https://github.com/adobe/spectrum-css/compare/@spectrum-css/actiongroup@3.0.55...@spectrum-css/actiongroup@3.0.56) **Note:** Version bump only for package @spectrum-css/actiongroup @@ -431,6 +512,7 @@ Output for all component CSS files is now being run through a lightweight optimi ## 3.0.48 🗓 2023-06-01 • 📝 [Commits](https://github.com/adobe/spectrum-css/compare/@spectrum-css/actiongroup@3.0.47...@spectrum-css/actiongroup@3.0.48) + **Note:** Version bump only for package @spectrum-css/actiongroup ## 3.0.47 diff --git a/components/actiongroup/dist/metadata.json b/components/actiongroup/dist/metadata.json index c78e7d30965..aee1c9d6b00 100644 --- a/components/actiongroup/dist/metadata.json +++ b/components/actiongroup/dist/metadata.json @@ -2,62 +2,36 @@ "sourceFile": "index.css", "selectors": [ ".spectrum-ActionGroup", - ".spectrum-ActionGroup .spectrum-ActionGroup-item", - ".spectrum-ActionGroup .spectrum-ActionGroup-item:focus-visible", - ".spectrum-ActionGroup--compact", - ".spectrum-ActionGroup--compact.spectrum-ActionGroup--vertical:not(.spectrum-ActionGroup--quiet)", ".spectrum-ActionGroup--compact.spectrum-ActionGroup--vertical:not(.spectrum-ActionGroup--quiet) .spectrum-ActionGroup-item", ".spectrum-ActionGroup--compact.spectrum-ActionGroup--vertical:not(.spectrum-ActionGroup--quiet) .spectrum-ActionGroup-item + .spectrum-ActionGroup-item", ".spectrum-ActionGroup--compact.spectrum-ActionGroup--vertical:not(.spectrum-ActionGroup--quiet) .spectrum-ActionGroup-item:first-child", ".spectrum-ActionGroup--compact.spectrum-ActionGroup--vertical:not(.spectrum-ActionGroup--quiet) .spectrum-ActionGroup-item:last-child", - ".spectrum-ActionGroup--compact:not(.spectrum-ActionGroup--quiet)", ".spectrum-ActionGroup--compact:not(.spectrum-ActionGroup--quiet) .spectrum-ActionGroup-item", ".spectrum-ActionGroup--compact:not(.spectrum-ActionGroup--quiet) .spectrum-ActionGroup-item + .spectrum-ActionGroup-item", ".spectrum-ActionGroup--compact:not(.spectrum-ActionGroup--quiet) .spectrum-ActionGroup-item .spectrum-ActionButton-label", - ".spectrum-ActionGroup--compact:not(.spectrum-ActionGroup--quiet) .spectrum-ActionGroup-item.is-selected", ".spectrum-ActionGroup--compact:not(.spectrum-ActionGroup--quiet) .spectrum-ActionGroup-item:first-child", ".spectrum-ActionGroup--compact:not(.spectrum-ActionGroup--quiet) .spectrum-ActionGroup-item:focus-visible", ".spectrum-ActionGroup--compact:not(.spectrum-ActionGroup--quiet) .spectrum-ActionGroup-item:hover", ".spectrum-ActionGroup--compact:not(.spectrum-ActionGroup--quiet) .spectrum-ActionGroup-item:last-child", + ".spectrum-ActionGroup--compact:not(.spectrum-ActionGroup--quiet) .spectrum-ActionGroup-item:where(.is-selected, [aria-pressed=\"true\"], [aria-expanded=\"true\"])", ".spectrum-ActionGroup--justified .spectrum-ActionGroup-item", - ".spectrum-ActionGroup--sizeL", - ".spectrum-ActionGroup--sizeM", - ".spectrum-ActionGroup--sizeS", - ".spectrum-ActionGroup--sizeXL", - ".spectrum-ActionGroup--sizeXS", - ".spectrum-ActionGroup--vertical", + ".spectrum-ActionGroup-item", + ".spectrum-ActionGroup-item:focus-visible", + ".spectrum-ActionGroup.spectrum-ActionGroup--compact", + ".spectrum-ActionGroup.spectrum-ActionGroup--compact:not(.spectrum-ActionGroup--quiet)", + ".spectrum-ActionGroup.spectrum-ActionGroup--sizeS", + ".spectrum-ActionGroup.spectrum-ActionGroup--sizeXS", + ".spectrum-ActionGroup.spectrum-ActionGroup--vertical", ".spectrum-ActionGroup:not(.spectrum-ActionGroup--vertical, .spectrum-ActionGroup--compact) .spectrum-ActionGroup-item" ], - "modifiers": [ - "--mod-actiongroup-border-radius", - "--mod-actiongroup-border-radius-reset", - "--mod-actiongroup-button-spacing-reset", - "--mod-actiongroup-gap-size-compact", - "--mod-actiongroup-horizontal-spacing-compact", - "--mod-actiongroup-horizontal-spacing-regular", - "--mod-actiongroup-vertical-spacing-compact", - "--mod-actiongroup-vertical-spacing-regular" - ], - "component": [ - "--spectrum-actiongroup-border-radius", - "--spectrum-actiongroup-border-radius-reset", - "--spectrum-actiongroup-button-spacing-reset", - "--spectrum-actiongroup-gap-size-compact", - "--spectrum-actiongroup-horizontal-spacing-compact", - "--spectrum-actiongroup-horizontal-spacing-regular", - "--spectrum-actiongroup-vertical-spacing-compact", - "--spectrum-actiongroup-vertical-spacing-regular" - ], + "modifiers": [], + "component": ["--spectrum-actiongroup-spacing"], "global": [ + "--spectrum-actionbutton-focus-indicator-border-radius", "--spectrum-corner-radius-100", "--spectrum-spacing-100", "--spectrum-spacing-75" ], - "system-theme": [ - "--system-action-group-gap-size-compact", - "--system-action-group-horizontal-spacing-compact", - "--system-action-group-vertical-spacing-compact" - ], - "passthroughs": ["--mod-actionbutton-focus-indicator-border-radius"], + "passthroughs": [], "high-contrast": [] } diff --git a/components/actiongroup/index.css b/components/actiongroup/index.css index bbd26cb0f65..56a619c4c23 100644 --- a/components/actiongroup/index.css +++ b/components/actiongroup/index.css @@ -11,94 +11,82 @@ * governing permissions and limitations under the License. */ -@import "./themes/spectrum-two.css"; - .spectrum-ActionGroup { - --spectrum-actiongroup-button-spacing-reset: 0; - --spectrum-actiongroup-border-radius-reset: 0; - --spectrum-actiongroup-border-radius: var(--spectrum-corner-radius-100); -} + --spectrum-actiongroup-spacing: var(--spectrum-spacing-100); -.spectrum-ActionGroup--sizeXS, -.spectrum-ActionGroup--sizeS { - --spectrum-actiongroup-horizontal-spacing-regular: var(--spectrum-spacing-75); - --spectrum-actiongroup-vertical-spacing-regular: var(--spectrum-spacing-75); -} + &.spectrum-ActionGroup--sizeXS, + &.spectrum-ActionGroup--sizeS { + --spectrum-actiongroup-spacing: var(--spectrum-spacing-75); + } -.spectrum-ActionGroup--sizeM, -.spectrum-ActionGroup--sizeL, -.spectrum-ActionGroup--sizeXL { - --spectrum-actiongroup-horizontal-spacing-regular: var(--spectrum-spacing-100); - --spectrum-actiongroup-vertical-spacing-regular: var(--spectrum-spacing-100); -} + &.spectrum-ActionGroup--compact { + /* account for button border */ + --spectrum-actiongroup-spacing: -1px; + } -.spectrum-ActionGroup { display: flex; flex-wrap: wrap; - gap: var(--mod-actiongroup-horizontal-spacing-regular, var(--spectrum-actiongroup-horizontal-spacing-regular)); - - .spectrum-ActionGroup-item { - flex-shrink: 0; + gap: var(--spectrum-actiongroup-spacing); - /* Focus indicator should appear above hovered and selected borders */ - &:focus-visible { - z-index: 3; - } + &.spectrum-ActionGroup--vertical { + display: inline-flex; + flex-direction: column; } - &:not(.spectrum-ActionGroup--vertical, .spectrum-ActionGroup--compact) { - .spectrum-ActionGroup-item { - flex-shrink: 0; + &.spectrum-ActionGroup--compact { + gap: 0; + + &:not(.spectrum-ActionGroup--quiet) { + flex-wrap: nowrap; } } } -.spectrum-ActionGroup--vertical { - gap: var(--mod-actiongroup-vertical-spacing-regular, var(--spectrum-actiongroup-vertical-spacing-regular)); - display: inline-flex; - flex-direction: column; -} +.spectrum-ActionGroup-item { + flex-shrink: 0; -.spectrum-ActionGroup--compact { - gap: var(--mod-actiongroup-gap-size-compact, var(--spectrum-actiongroup-gap-size-compact)); -} + /* Focus indicator should appear above hovered and selected borders */ + &:focus-visible { + z-index: 3; + } -.spectrum-ActionGroup--compact:not(.spectrum-ActionGroup--quiet) { - flex-wrap: nowrap; + .spectrum-ActionGroup:not(.spectrum-ActionGroup--vertical, .spectrum-ActionGroup--compact) & { + flex-shrink: 0; + } - .spectrum-ActionGroup-item { + .spectrum-ActionGroup--compact:not(.spectrum-ActionGroup--quiet) & { position: relative; - border-radius: var(--mod-actiongroup-border-radius-reset, var(--spectrum-actiongroup-border-radius-reset)); + border-radius: 0; z-index: 0; &:first-child { /* @passthrough -- Action button styling */ - --mod-actionbutton-focus-indicator-border-radius: var(--mod-actiongroup-border-radius, var(--spectrum-actiongroup-border-radius)) 0px 0px var(--mod-actiongroup-border-radius, var(--spectrum-actiongroup-border-radius)); + --spectrum-actionbutton-focus-indicator-border-radius: var(--spectrum-corner-radius-100) 0px 0px var(--spectrum-corner-radius-100); - border-start-start-radius: var(--mod-actiongroup-border-radius, var(--spectrum-actiongroup-border-radius)); - border-end-start-radius: var(--mod-actiongroup-border-radius, var(--spectrum-actiongroup-border-radius)); - margin-inline-start: var(--mod-actiongroup-button-spacing-reset, var(--spectrum-actiongroup-button-spacing-reset)); + border-start-start-radius: var(--spectrum-corner-radius-100); + border-end-start-radius: var(--spectrum-corner-radius-100); + margin-inline-start: 0; } & + .spectrum-ActionGroup-item { /* @passthrough -- Action button styling */ - --mod-actionbutton-focus-indicator-border-radius: 0px; + --spectrum-actionbutton-focus-indicator-border-radius: 0px; - margin-inline-start: var(--mod-actiongroup-horizontal-spacing-compact, var(--spectrum-actiongroup-horizontal-spacing-compact)); - margin-inline-end: var(--mod-actiongroup-horizontal-spacing-compact, var(--spectrum-actiongroup-horizontal-spacing-compact)); + margin-inline-start: var(--spectrum-actiongroup-spacing); + margin-inline-end: var(--spectrum-actiongroup-spacing); } &:last-child { /* @passthrough -- Action button styling */ - --mod-actionbutton-focus-indicator-border-radius: 0px var(--mod-actiongroup-border-radius, var(--spectrum-actiongroup-border-radius)) var(--mod-actiongroup-border-radius, var(--spectrum-actiongroup-border-radius)) 0px; + --spectrum-actionbutton-focus-indicator-border-radius: 0px var(--spectrum-corner-radius-100) var(--spectrum-corner-radius-100) 0px; - border-start-end-radius: var(--mod-actiongroup-border-radius, var(--spectrum-actiongroup-border-radius)); - border-end-end-radius: var(--mod-actiongroup-border-radius, var(--spectrum-actiongroup-border-radius)); - margin-inline-start: var(--mod-actiongroup-horizontal-spacing-compact, var(--spectrum-actiongroup-horizontal-spacing-compact)); - margin-inline-end: var(--mod-actiongroup-border-radius-reset, var(--spectrum-actiongroup-border-radius-reset)); + border-start-end-radius: var(--spectrum-corner-radius-100); + border-end-end-radius: var(--spectrum-corner-radius-100); + margin-inline-start: var(--spectrum-actiongroup-spacing); + margin-inline-end: 0; } - &.is-selected { + &:where(.is-selected, [aria-pressed="true"], [aria-expanded="true"]) { z-index: 1; } @@ -115,44 +103,40 @@ inline-size: auto; } } -} - -.spectrum-ActionGroup--compact.spectrum-ActionGroup--vertical:not(.spectrum-ActionGroup--quiet) { - gap: var(--mod-actiongroup-gap-size-compact, var(--spectrum-actiongroup-gap-size-compact)); - .spectrum-ActionGroup-item { - border-radius: var(--mod-actiongroup-border-radius-reset, var(--spectrum-actiongroup-border-radius-reset)); + .spectrum-ActionGroup--compact.spectrum-ActionGroup--vertical:not(.spectrum-ActionGroup--quiet) & { + border-radius: 0; &:first-child { /* @passthrough -- Action button styling */ - --mod-actionbutton-focus-indicator-border-radius: var(--mod-actiongroup-border-radius, var(--spectrum-actiongroup-border-radius)) var(--mod-actiongroup-border-radius, var(--spectrum-actiongroup-border-radius)) 0px 0px; + --spectrum-actionbutton-focus-indicator-border-radius: var(--spectrum-corner-radius-100) var(--spectrum-corner-radius-100) 0px 0px; - border-start-start-radius: var(--mod-actiongroup-border-radius, var(--spectrum-actiongroup-border-radius)); - border-start-end-radius: var(--mod-actiongroup-border-radius, var(--spectrum-actiongroup-border-radius)); - margin-inline-end: var(--mod-actiongroup-button-spacing-reset, var(--spectrum-actiongroup-button-spacing-reset)); - margin-block-start: var(--mod-actiongroup-vertical-spacing-compact, var(--spectrum-actiongroup-vertical-spacing-compact)); - margin-block-end: var(--mod-actiongroup-vertical-spacing-compact, var(--spectrum-actiongroup-vertical-spacing-compact)); + border-start-start-radius: var(--spectrum-corner-radius-100); + border-start-end-radius: var(--spectrum-corner-radius-100); + margin-inline-end: 0; + margin-block-start: var(--spectrum-actiongroup-spacing); + margin-block-end: var(--spectrum-actiongroup-spacing); } & + .spectrum-ActionGroup-item { - margin-inline-start: var(--mod-actiongroup-button-spacing-reset, var(--spectrum-actiongroup-button-spacing-reset)); - margin-inline-end: var(--mod-actiongroup-button-spacing-reset, var(--spectrum-actiongroup-button-spacing-reset)); - margin-block-start: var(--mod-actiongroup-button-spacing-reset, var(--spectrum-actiongroup-button-spacing-reset)); - margin-block-end: var(--mod-actiongroup-vertical-spacing-compact, var(--spectrum-actiongroup-vertical-spacing-compact)); + margin-inline-start: 0; + margin-inline-end: 0; + margin-block-start: 0; + margin-block-end: var(--spectrum-actiongroup-spacing); } &:last-child { /* @passthrough -- Action button styling */ - --mod-actionbutton-focus-indicator-border-radius: 0px 0px var(--mod-actiongroup-border-radius, var(--spectrum-actiongroup-border-radius)) var(--mod-actiongroup-border-radius, var(--spectrum-actiongroup-border-radius)); + --spectrum-actionbutton-focus-indicator-border-radius: 0px 0px var(--spectrum-corner-radius-100) var(--spectrum-corner-radius-100); - border-end-start-radius: var(--mod-actiongroup-border-radius, var(--spectrum-actiongroup-border-radius)); - border-end-end-radius: var(--mod-actiongroup-border-radius, var(--spectrum-actiongroup-border-radius)); - margin-block-start: var(--mod-actiongroup-vertical-spacing-compact, var(--spectrum-actiongroup-vertical-spacing-compact)); - margin-block-end: var(--mod-actiongroup-button-spacing-reset, var(--spectrum-actiongroup-button-spacing-reset)); + border-end-start-radius: var(--spectrum-corner-radius-100); + border-end-end-radius: var(--spectrum-corner-radius-100); + margin-block-start: var(--spectrum-actiongroup-spacing); + margin-block-end: 0; } } -} -.spectrum-ActionGroup--justified .spectrum-ActionGroup-item { - flex-grow: 1; + .spectrum-ActionGroup--justified & { + flex-grow: 1; + } } diff --git a/components/actiongroup/package.json b/components/actiongroup/package.json index f4e5f9ef555..4ac00486f74 100644 --- a/components/actiongroup/package.json +++ b/components/actiongroup/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/actiongroup", - "version": "6.2.0", + "version": "7.0.0-next.3", "description": "The Spectrum CSS actiongroup component", "license": "Apache-2.0", "author": "Adobe", @@ -19,15 +19,13 @@ "./package.json": "./package.json", "./dist/*": "./dist/*", "./index.css": "./dist/index.css", - "./index-*.css": "./dist/index-*.css", "./metadata.json": "./dist/metadata.json", - "./themes/*": "./dist/themes/*", "./stories/*": "./stories/*" }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/actionbutton": ">=7.0.0 <8.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/actionbutton": ">=8.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/actionbutton": { @@ -38,8 +36,8 @@ } }, "devDependencies": { - "@spectrum-css/actionbutton": "7.2.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/actionbutton": "8.0.0-next.4", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/actiongroup/stories/actiongroup.stories.js b/components/actiongroup/stories/actiongroup.stories.js index a83857b9e54..0fd9731f55b 100644 --- a/components/actiongroup/stories/actiongroup.stories.js +++ b/components/actiongroup/stories/actiongroup.stories.js @@ -5,7 +5,7 @@ import { size } from "@spectrum-css/preview/types"; import metadata from "../dist/metadata.json"; import packageJson from "../package.json"; import { ActionGroups } from "./actiongroup.test.js"; -import { OverflowOption, TreatmentTemplate } from "./template.js"; +import { OverflowOption, Template, TreatmentTemplate } from "./template.js"; /** * An action group is a grouping of [action buttons](/docs/components-action-button--docs) that are related to each other. @@ -99,7 +99,11 @@ export default { }, packageJson, metadata, + status: { + type: "migrated", + }, }, + tags: ["migrated"], }; export const Default = ActionGroups.bind({}); @@ -279,6 +283,15 @@ JustifiedIconOnlyCompact.parameters = { chromatic: { disableSnapshot: true }, }; +export const Quiet = Template.bind({}); +Quiet.tags = ["!dev"]; +Quiet.args = { + areQuiet: true, +}; +Quiet.parameters = { + chromatic: { disableSnapshot: true }, +}; + /** * When space is limited in an action group, there are 2 options for the group's overflow behavior: wrap or collapse. By default, an action group is set to wrap, meaning that the action buttons inside the group wrap to form another line. Alternatively, an action group can be set to collapse inside a **More (...)** action button. */ diff --git a/components/actiongroup/stories/template.js b/components/actiongroup/stories/template.js index d13cdac64aa..25d8f25f4e0 100644 --- a/components/actiongroup/stories/template.js +++ b/components/actiongroup/stories/template.js @@ -6,9 +6,6 @@ import { styleMap } from "lit/directives/style-map.js"; import { capitalize } from "lodash-es"; import "../index.css"; -import "../themes/spectrum.css"; -/* Must be imported last */ -import "../themes/express.css"; export const Template = ({ rootClass = "spectrum-ActionGroup", diff --git a/components/actiongroup/themes/express.css b/components/actiongroup/themes/express.css deleted file mode 100644 index 3fd8de9cdbb..00000000000 --- a/components/actiongroup/themes/express.css +++ /dev/null @@ -1,26 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--express */ - -@import "./spectrum.css"; - -@container style(--system: express) { - .spectrum-ActionGroup { - --spectrum-actiongroup-gap-size-compact: var(--spectrum-spacing-50); - - /* account for button border */ - --spectrum-actiongroup-horizontal-spacing-compact: calc(-1px * var(--spectrum-spacing-50)); - --spectrum-actiongroup-vertical-spacing-compact: calc(-1px * var(--spectrum-spacing-50)); - } -} diff --git a/components/actiongroup/themes/spectrum-two.css b/components/actiongroup/themes/spectrum-two.css deleted file mode 100644 index b25c0f945b2..00000000000 --- a/components/actiongroup/themes/spectrum-two.css +++ /dev/null @@ -1,22 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -@container style(--system: spectrum) { - .spectrum-ActionGroup { - --spectrum-actiongroup-gap-size-compact: 0; - - /* account for button border */ - --spectrum-actiongroup-horizontal-spacing-compact: -1px; - --spectrum-actiongroup-vertical-spacing-compact: -1px; - } -} diff --git a/components/actiongroup/themes/spectrum.css b/components/actiongroup/themes/spectrum.css deleted file mode 100644 index 3d81bc564b5..00000000000 --- a/components/actiongroup/themes/spectrum.css +++ /dev/null @@ -1,16 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--legacy */ - -@import "./spectrum-two.css"; diff --git a/components/actionmenu/CHANGELOG.md b/components/actionmenu/CHANGELOG.md index be9a81e3903..275ba440829 100644 --- a/components/actionmenu/CHANGELOG.md +++ b/components/actionmenu/CHANGELOG.md @@ -1,5 +1,83 @@ # Change log +## 8.0.0-next.2 + +### Major Changes + +📝 [#4085](https://github.com/adobe/spectrum-css/pull/4085) [`082862e`](https://github.com/adobe/spectrum-css/commit/082862eb80c6e0ac1c801b1d538e4d2f2bb919b4) Thanks [@castastrophe](https://github.com/castastrophe)! + +### Action menu component (now with custom styles!) + +Introduces `@spectrum-css/actionmenu`, a composition of `ActionButton`, `Popover`, and `Menu` to present action lists from a trigger. Now with custom styles! + +- Adds wrapper classes: `spectrum-ActionMenu`, `spectrum-ActionMenu-trigger`, `spectrum-ActionMenu-popover`, and `spectrum-ActionMenu-menu`. +- Supports long press triggers and four placements (start/end, top/bottom) via the underlying popover API. +- Design reference: [Figma S2 token specs](https://www.figma.com/design/eoZHKJH9a3LJkHYCGt60Vb/S2-token-specs?node-id=20959-21513&node-type=frame&t=jbePQKK1yLdrHG2M-11). + +#### Migration notes + +- If you previously composed an action menu manually (action button + popover + menu), you can adopt the new wrapper classes without changing the underlying markup semantics. Ensure the trigger has `aria-haspopup="menu"` and manages `aria-expanded` according to your application logic. +- For spacing customizations previously done with ad‑hoc margins, switch to the new `--spectrum-actionmenu-button-to-menu-gap` custom property. + +Example markup: + +```html +
+ +
+
    + +
+
+ + + +
+``` + +### Menu refinements + +Updates `@spectrum-css/menu` styles to align with latest Spectrum 2 design specifications and improve accessibility. + +- Updated `.is-selectableMultiple .spectrum-Menu-itemCheckbox` to `.is-selectableMultiple:not(:has(.is-selectable)) .spectrum-Menu-itemCheckbox` to prevent clash with the `.is-selectable` placement. +- Non-breaking; no class or DOM changes required. + +### Action button refinements + +- Selection styling now applies when components use ARIA pressed/expanded semantics, not just `.is-selected`. +- Implemented with `:where()` to keep selector specificity low and prevent downstream specificity battles. +- Non-breaking; no class changes required. + +### Action group refinements + +Aligns selection behavior of grouped items with action button updates. + +- Adds `:where([aria-pressed="true"], [aria-expanded="true"])` alongside `.is-selected` on items to cover more accessibility use-cases while keeping specificity low. +- Non-breaking; no class changes required. + +## 8.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + +## 8.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`a25e0a9`](https://github.com/adobe/spectrum-css/commit/a25e0a99e5a4736ab4e607e00739343101a2633b)]: + - @spectrum-css/icon@10.0.0-next.0 + - @spectrum-css/actionbutton@8.0.0-next.0 + - @spectrum-css/menu@10.0.0-next.0 + - @spectrum-css/popover@9.0.0-next.0 + ## 7.2.0 ### Minor Changes @@ -174,6 +252,7 @@ Output for all component CSS files is now being run through a lightweight optimi ### 🛑 BREAKING CHANGE - Removes component-builder & component-builder-simple for script leveraging postcss + - Imports added to index.css and themes/express.css ## 5.1.3 diff --git a/components/actionmenu/dist/metadata.json b/components/actionmenu/dist/metadata.json new file mode 100644 index 00000000000..530a08aae34 --- /dev/null +++ b/components/actionmenu/dist/metadata.json @@ -0,0 +1,9 @@ +{ + "sourceFile": "index.css", + "selectors": [".spectrum-ActionMenu", ".spectrum-ActionMenu-popover"], + "modifiers": [], + "component": ["--spectrum-actionmenu-button-to-menu-gap"], + "global": ["--spectrum-popover-animation-distance", "--spectrum-spacing-100"], + "passthroughs": [], + "high-contrast": [] +} diff --git a/components/actionmenu/index.css b/components/actionmenu/index.css new file mode 100644 index 00000000000..3d7598380aa --- /dev/null +++ b/components/actionmenu/index.css @@ -0,0 +1,32 @@ +/*! + * Copyright 2025 Adobe. All rights reserved. + * + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ + +/* + * @spectrum-css/actionmenu + * This component is a combination of a menu, popover, and action button. + * It is used to display a list of actions in a popover menu when the user clicks on an action button. + * The markup has the following structure: + *
+ * + *
+ *
    + */ + +.spectrum-ActionMenu { + --spectrum-actionmenu-button-to-menu-gap: var(--spectrum-spacing-100); +} + +.spectrum-ActionMenu-popover { + /* @passthrough */ + --spectrum-popover-animation-distance: var(--spectrum-actionmenu-button-to-menu-gap); +} diff --git a/components/actionmenu/package.json b/components/actionmenu/package.json index 10f8d6f2106..8412a69b1d4 100644 --- a/components/actionmenu/package.json +++ b/components/actionmenu/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/actionmenu", - "version": "7.2.0", + "version": "8.0.0-next.2", "description": "The Spectrum CSS actionmenu component", "license": "Apache-2.0", "author": "Adobe", @@ -14,17 +14,21 @@ "url": "https://github.com/adobe/spectrum-css/issues" }, "exports": { + ".": "./dist/index.css", "./*.md": "./*.md", "./package.json": "./package.json", + "./dist/*": "./dist/*", + "./index.css": "./dist/index.css", + "./metadata.json": "./dist/metadata.json", "./stories/*": "./stories/*" }, - "main": "README.md", + "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/actionbutton": ">=7.0.0 <8.0.0", - "@spectrum-css/icon": ">=9.0.0 <10.0.0", - "@spectrum-css/menu": ">=9.0.0 <10.0.0", - "@spectrum-css/popover": ">=8.0.0 <9.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/actionbutton": ">=8.0.0-next.0", + "@spectrum-css/icon": ">=10.0.0-next.0", + "@spectrum-css/menu": ">=10.0.0-next.0", + "@spectrum-css/popover": ">=9.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/actionbutton": { @@ -44,18 +48,20 @@ } }, "devDependencies": { - "@spectrum-css/actionbutton": "7.2.0", - "@spectrum-css/icon": "9.2.0", - "@spectrum-css/menu": "9.3.0", - "@spectrum-css/popover": "8.3.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/actionbutton": "8.0.0-next.4", + "@spectrum-css/icon": "10.0.0-next.3", + "@spectrum-css/menu": "10.0.0-next.6", + "@spectrum-css/popover": "9.0.0-next.5", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", "spectrum", "spectrum-css", "adobe", - "adobe-spectrum" + "adobe-spectrum", + "component", + "css" ], "publishConfig": { "access": "public" diff --git a/tools/generator/templates/project.json.hbs b/components/actionmenu/project.json similarity index 90% rename from tools/generator/templates/project.json.hbs rename to components/actionmenu/project.json index 6f68b7e48f7..5b51f022edd 100644 --- a/tools/generator/templates/project.json.hbs +++ b/components/actionmenu/project.json @@ -1,6 +1,6 @@ { "$schema": "../../node_modules/nx/schemas/project-schema.json", - "name": "{{ folderName }}", + "name": "actionmenu", "tags": ["component"], "targets": { "build": {}, diff --git a/components/actionmenu/stories/actionmenu.stories.js b/components/actionmenu/stories/actionmenu.stories.js index 04000663c59..4ca19fc6807 100644 --- a/components/actionmenu/stories/actionmenu.stories.js +++ b/components/actionmenu/stories/actionmenu.stories.js @@ -1,44 +1,58 @@ +import { ArgGrid, Container } from "@spectrum-css/preview/decorators/utilities.js"; +import { disableDefaultModes } from "@spectrum-css/preview/modes"; +import { isOpen } from "@spectrum-css/preview/types"; + import { default as ActionButton } from "@spectrum-css/actionbutton/stories/actionbutton.stories.js"; -import { default as IconStories } from "@spectrum-css/icon/stories/icon.stories.js"; import { default as Menu } from "@spectrum-css/menu/stories/menu.stories.js"; import { default as Popover } from "@spectrum-css/popover/stories/popover.stories.js"; -import { disableDefaultModes } from "@spectrum-css/preview/modes"; -import { isOpen } from "@spectrum-css/preview/types"; -import packageJson from "../package.json"; + +import { Template as IconTemplate } from "@spectrum-css/icon/stories/template.js"; import { ActionMenuGroup } from "./actionmenu.test.js"; +import { Template } from "./template.js"; + +import metadata from "../dist/metadata.json"; +import packageJson from "../package.json"; /** - * The action menu component is an action button with a popover. The `is-selected` class should be applied to the button when the menu is open. Note that the accessibility roles are different for an action menu compared to a normal menu. + * Action menu allows users to access and execute various commands or tasks related to their current workflow. It's typically triggered from an action button by user interaction. + * + * Note that the accessibility roles are different for an action menu compared to a normal menu. The action menu is a combination of a menu, popover, and action button. */ export default { title: "Action menu", component: "ActionMenu", argTypes: { - withTip: Popover.argTypes.withTip, - position: Popover.argTypes.position, - isOpen, - iconName: { - ...(IconStories?.argTypes?.iconName ?? {}), - if: false, + position: { + ...Popover.argTypes.position, + options: [ + "bottom-start", + "bottom-end", + "start-top", + "end-top", + ] }, - label: { - name: "Label", - type: { name: "string" }, + isOpen, + hasLongPress: { + name: "Long press", + description: "If the trigger supports a long-press action which triggers the menu, this should be set to true.", + type: { name: "boolean" }, table: { - type: { summary: "string" }, - category: "Content", + type: { summary: "boolean" }, + category: "Accessibility", }, - control: { type: "text" }, + control: "boolean", }, - items: { table: { disable: true } }, - id: { table: { disable: true } }, - testId: { table: { disable: true } }, - triggerId: { table: { disable: true } }, + menuArgs: { table: { disable: true } }, + triggerArgs: { table: { disable: true } }, }, args: { - isOpen: false, - withTip: Popover.args.withTip, - position: Popover.args.position, + isOpen: true, + position: "bottom-start", + hasLongPress: false, + triggerArgs: { + iconName: "More", + iconSet: "workflow", + }, }, parameters: { actions: { @@ -53,36 +67,227 @@ export default { url: "https://www.figma.com/design/eoZHKJH9a3LJkHYCGt60Vb/S2-token-specs?node-id=20959-21513&node-type=frame&t=jbePQKK1yLdrHG2M-11", }, packageJson, - docs: { - story: { - height: "200px", - } - } + metadata, + status: { + type: "migrated", + }, }, + tags: ["migrated"], }; export const Default = ActionMenuGroup.bind({}); Default.args = { + triggerArgs: { + iconName: "AddCircle", + label: "Add", + }, + menuArgs: { + hasActions: true, + selectionMode: "multiple", + items: [{ + heading: "Menu section header", + description: "Menu section description", + items: [{ + label: "Menu item", + iconName: "Circle", + }, + { + label: "Menu item", + iconName: "Circle", + }, + { + label: "Menu item", + iconName: "Circle", + }], + }, { + heading: "Menu section header", + description: "Menu section description", + selectionMode: "none", + hasActions: false, + items: [{ + label: "Menu item", + iconName: "Circle", + }, + { + label: "Menu item", + iconName: "Circle", + }, + { + label: "Menu item", + iconName: "Circle", + },], + }], + }, +}; + +// ********* DOCS ONLY ********* // +/** + * By default, the menu is opened by pressing the trigger element or activating it via the Space or Enter keys. However, there may be cases where the trigger should perform a separate action on press such as selection, and should only display the menu when long pressed. For this use-case, the menu will only be opened when pressing and holding the trigger or by using the Option (Alt on Windows) + Down arrow/Up arrow keys while focusing the trigger. + * + * This example illustrates the expected visuals and states of the action menu for a trigger with both long press and short press behaviors. + * + * Please note that the long press functionality is not implemented in this documentation and the example serves only as a visual reference. + */ +export const LongPress = Template.bind({}); +LongPress.args = { + position: "end-top", + hasLongPress: true, isOpen: true, - position: "bottom", - label: "More actions", - iconName: "More", - items: [ - { - label: "Action 1", - }, - { - label: "Action 2", - }, - { - label: "Action 3", + triggerArgs: { + iconName: "CropRotate", + }, + menuArgs: { + customStyles: { + "--mod-menu-inline-size": "max-content", }, - { - label: "Action 4", + selectionMode: "single", + items: [{ + label: "Crop rotate", + iconName: "CropRotate", + isSelected: true, + }, { + label: "Slice", + iconName: "VectorDraw", + }, { + label: "Clone stamp", + iconName: "StampClone", + }], + }, +}; +LongPress.tags = ["!dev"]; +LongPress.parameters = { + chromatic: { + disableSnapshot: true, + }, +}; + +/** + * Action menus can be positioned in four locales relative to the trigger but only one menu can be triggered at a single time. + */ +export const PlacementOptions = (args, context) => ArgGrid({ + Template, + argKey: "position", + withBorder: false, + ...args, +}, context); +PlacementOptions.args = { + triggerArgs: { + iconName: "More", + }, + menuArgs: { + customStyles: { + "--mod-menu-inline-size": "max-content", }, + items: [{ + label: "Details", + iconName: "FileText" + }, { + label: "Share", + iconName: "Share" + }, { + label: "Remove", + iconName: "Delete" + }], + }, +}; +PlacementOptions.tags = ["!dev"]; +PlacementOptions.parameters = { + chromatic: { + disableSnapshot: true, + }, +}; + +/** + * Icon used is a placeholder and can be swapped with any other from icon set along with corresponding label. + */ +export const PlaceholderIcon = (args, context) => Container({ + withBorder: false, + content: [ + Template(args, context), + IconTemplate({ + iconName: "ArrowRight400", + setName: "ui", + fill: "var(--spectrum-gray-400)", + customStyles: { + "margin-block-start": "var(--spectrum-spacing-200)", + }, + }, context), + Template({ + ...args, + isOpen: true, + triggerArgs: { + iconName: "AddCircle", + label: "Add", + }, + menuArgs: { + items: [{ + heading: "Add new page", + items: [ + { + label: "Same size", + iconName: "Copy" + }, + { + label: "Custom size", + iconName: "Properties" + }, + { + label: "Duplicate", + iconName: "Duplicate" + } + ] + }, { + heading: "Edit page", + items: [{ + label: "Edit timeline", + iconName: "Clock", + description: "Add time to this page" + }], + }] + }, + }, context), ], +}); +PlaceholderIcon.args = { + triggerArgs: { + iconName: "More", + label: "", + }, + isOpen: true, + menuArgs: { + customStyles: { + "--mod-menu-inline-size": "max-content", + }, + items: [{ + heading: "Menu section header", + customStyles: { + "--mod-menu-inline-size": "100%", + }, + items: [ + { + label: "Menu item", + iconName: "Circle" + }, + { + label: "Menu item", + iconName: "Circle" + }, + { + label: "Menu item", + iconName: "Circle" + } + ] + }], + }, +}; +PlaceholderIcon.tags = ["!dev"]; +PlaceholderIcon.parameters = { + chromatic: { + disableSnapshot: true, + }, }; + // ********* VRT ONLY ********* // export const WithForcedColors = ActionMenuGroup.bind({}); WithForcedColors.args = Default.args; diff --git a/components/actionmenu/stories/actionmenu.test.js b/components/actionmenu/stories/actionmenu.test.js index 159a70c756b..e91cf61b34a 100644 --- a/components/actionmenu/stories/actionmenu.test.js +++ b/components/actionmenu/stories/actionmenu.test.js @@ -1,26 +1,25 @@ -import { Variants } from "@spectrum-css/preview/decorators"; +import { ArgGrid, Variants } from "@spectrum-css/preview/decorators"; import { Template } from "./template.js"; export const ActionMenuGroup = Variants({ Template, - testData: [{ - wrapperStyles: { - "min-block-size": "200px", - "align-items": "flex-start", - }, - }, { - testHeading: "Closed menu", + withSizes: false, + testData: [{}, { + testHeading: "Positioning", + withStates: false, + Template: (args, context) => ArgGrid({ + Template, + argKey: "position", + withBorder: false, + ...args, + }, context), + }], + stateData: [{ + testHeading: "Closed", isOpen: false, - wrapperStyles: { - "min-block-size": "50px", - }, }, { - testHeading: "Custom icon", + testHeading: "Has long press", + hasLongPress: true, isOpen: false, - iconName: "Add", - iconSet: "workflow", - wrapperStyles: { - "min-block-size": "50px", - }, - }], + }] }); diff --git a/components/actionmenu/stories/template.js b/components/actionmenu/stories/template.js index c4bc29768d9..574d7fcdf45 100644 --- a/components/actionmenu/stories/template.js +++ b/components/actionmenu/stories/template.js @@ -3,48 +3,75 @@ import { Template as Menu } from "@spectrum-css/menu/stories/template.js"; import { Template as Popover } from "@spectrum-css/popover/stories/template.js"; import { getRandomId } from "@spectrum-css/preview/decorators"; -export const Template = ({ - id = getRandomId("actionmenu"), - testId, - triggerId = getRandomId("actionmenu-trigger"), - customClasses = [], - customStyles = {}, - items = [], - isOpen = false, - label, - iconName = "More", - iconSet = "workflow", - size = "m", - ...popoverArgs -} = {}, context = {}) => { - return Popover({ - size, - isOpen, - withTip: false, - id, - testId: testId ?? id, - triggerId, - trigger: (passthroughs) => - ActionButton({ - ...passthroughs, - size, - label, - hasPopup: "menu", - iconName, - iconSet, - id: triggerId, - customClasses, - }, context), - position: "bottom-start", - customStyles, - content: [ - (passthroughs) => Menu({ - ...passthroughs, - items, - isOpen, - size - }, context) - ], - ...popoverArgs, - }, context); +import "../index.css"; + +export const Template = ( + { + rootClass = "spectrum-ActionMenu", + id = getRandomId("actionmenu"), + testId, + triggerId = getRandomId("actionmenu-trigger"), + customClasses = [], + customStyles = {}, + isOpen = false, + hasLongPress = false, + position = "bottom-start", + // Object should match the schema of the Menu component + menuArgs = {}, + // Object should match the schema of the ActionButton component (or whatever component is used for the trigger) + triggerArgs = {}, + ...popoverArgs + } = {}, + context = {}, +) => { + return Popover( + { + ...popoverArgs, + isOpen, + withTip: false, + id, + testId: testId ?? id, + triggerId, + trigger: (passthroughs) => + ActionButton( + { + ...passthroughs, + ...triggerArgs, + hasPopup: "menu", + hasLongPress, + id: triggerId, + isOpen, + isSelected: isOpen, + customClasses: [`${rootClass}-trigger`], + }, + context, + ), + position, + customClasses: [`${rootClass}-popover`], + customWrapperClasses: [rootClass, ...customClasses], + customWrapperStyles: customStyles, + content: [ + (passthroughs) => + Menu( + { + ...passthroughs, + ...menuArgs, + customClasses: [ + `${rootClass}-menu`, + ...(passthroughs?.customClasses ?? []), + ...(menuArgs?.customClasses ?? []), + ], + customStyles: { + "--mod-menu-inline-size": "100%", + ...(passthroughs?.customStyles ?? {}), + ...(menuArgs?.customStyles ?? {}), + }, + isOpen, + }, + context, + ), + ], + }, + context, + ); }; diff --git a/components/alertbanner/CHANGELOG.md b/components/alertbanner/CHANGELOG.md index 30059766fb8..cb32cbfa901 100644 --- a/components/alertbanner/CHANGELOG.md +++ b/components/alertbanner/CHANGELOG.md @@ -1,5 +1,44 @@ # Change log +## 4.0.0-next.3 + +### Patch Changes + +📝 [#4113](https://github.com/adobe/spectrum-css/pull/4113) [`cf4fc1a`](https://github.com/adobe/spectrum-css/commit/cf4fc1a01d23ba810f45a903ecc29a5c8aae33d1) Thanks [@castastrophe](https://github.com/castastrophe)! + +## Minor linting fixes + +- Removed unused custom properties across multiple components +- Fixed color function notation by converting `rgba()` to `rgb()` where appropriate +- Removed duplicate custom property declarations +- Fixed deprecated CSS properties (e.g., `word-wrap` → `overflow-wrap`) +- Removed unnecessary stylelint-disable comments + +_No visual or functional changes to components._ + +## 4.0.0-next.2 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + +## 4.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`c6836fb`](https://github.com/adobe/spectrum-css/commit/c6836fb132effcfb09e4ca6d0d8923564bfe2914)]: + - @spectrum-css/divider@6.0.0-next.0 + +## 4.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`a25e0a9`](https://github.com/adobe/spectrum-css/commit/a25e0a99e5a4736ab4e607e00739343101a2633b)]: + - @spectrum-css/icon@10.0.0-next.0 + - @spectrum-css/button@15.0.0-next.0 + - @spectrum-css/closebutton@7.0.0-next.0 + ## 3.2.0 ### Minor Changes @@ -20,7 +59,9 @@ Minor linting fix of replacing `rgba` to the `rgb` shorthand syntax. ### Patch Changes -- [#3624](https://github.com/adobe/spectrum-css/pull/3624) [`754f99a`](https://github.com/adobe/spectrum-css/commit/754f99afc3c1918cdc0d173150989bcc1e6a7d2f) Thanks [@marissahuysentruyt](https://github.com/marissahuysentruyt)! - In the alert banner spectrum.css (the S1 stylesheet), --system: legacy was corrected in the container query. +📝 [#3624](https://github.com/adobe/spectrum-css/pull/3624) [`754f99a`](https://github.com/adobe/spectrum-css/commit/754f99afc3c1918cdc0d173150989bcc1e6a7d2f) Thanks [@marissahuysentruyt](https://github.com/marissahuysentruyt)! + +In the alert banner `spectrum.css` (the S1 stylesheet), `--system: legacy` was corrected in the container query. ## 3.1.0 diff --git a/components/alertbanner/dist/metadata.json b/components/alertbanner/dist/metadata.json index 15b6983e631..deed56dd2c9 100644 --- a/components/alertbanner/dist/metadata.json +++ b/components/alertbanner/dist/metadata.json @@ -6,82 +6,89 @@ ".spectrum-AlertBanner--negative", ".spectrum-AlertBanner-body", ".spectrum-AlertBanner-content", - ".spectrum-AlertBanner-end", ".spectrum-AlertBanner-icon", ".spectrum-AlertBanner-text", - ".spectrum-AlertBanner.is-open" + ".spectrum-AlertBanner.is-open", + ".spectrum-AlertBanner:has(.spectrum-CloseButton) .spectrum-AlertBanner-body", + ".spectrum-AlertBanner:lang(ja)", + ".spectrum-AlertBanner:lang(ko)", + ".spectrum-AlertBanner:lang(zh)" ], "modifiers": [ - "--mod-alert-banner-bottom-text", - "--mod-alert-banner-close-button-spacing", - "--mod-alert-banner-edge-to-button", - "--mod-alert-banner-edge-to-divider", + "--mod-alert-banner-background", + "--mod-alert-banner-block-edge-to-button", + "--mod-alert-banner-bottom-to-text", + "--mod-alert-banner-close-button-to-content", + "--mod-alert-banner-close-button-to-inline-end", "--mod-alert-banner-font-color", + "--mod-alert-banner-font-family", "--mod-alert-banner-font-size", "--mod-alert-banner-icon-size", "--mod-alert-banner-icon-to-text", "--mod-alert-banner-informative-background", + "--mod-alert-banner-inline-end-to-content", + "--mod-alert-banner-inline-size", + "--mod-alert-banner-inline-start-to-content", + "--mod-alert-banner-line-height", "--mod-alert-banner-max-inline-size", "--mod-alert-banner-min-height", "--mod-alert-banner-negative-background", "--mod-alert-banner-neutral-background", - "--mod-alert-banner-size", - "--mod-alert-banner-start-edge", + "--mod-alert-banner-text-margin-block-end", + "--mod-alert-banner-text-margin-block-start", "--mod-alert-banner-text-to-button-horizontal", "--mod-alert-banner-text-to-button-vertical", - "--mod-alert-banner-text-to-divider", - "--mod-alert-banner-top-icon", - "--mod-alert-banner-top-text" + "--mod-alert-banner-top-to-close-button", + "--mod-alert-banner-top-to-icon", + "--mod-alert-banner-top-to-text" ], "component": [ - "--spectrum-alert-banner-bottom-text", + "--spectrum-alert-banner-background", + "--spectrum-alert-banner-block-edge-to-button", "--spectrum-alert-banner-bottom-to-text", "--spectrum-alert-banner-close-button-spacing", - "--spectrum-alert-banner-edge-to-button", - "--spectrum-alert-banner-edge-to-divider", + "--spectrum-alert-banner-close-button-to-content", + "--spectrum-alert-banner-close-button-to-inline-end", "--spectrum-alert-banner-font-color", + "--spectrum-alert-banner-font-family", "--spectrum-alert-banner-font-size", "--spectrum-alert-banner-icon-size", "--spectrum-alert-banner-icon-to-text", - "--spectrum-alert-banner-informative-background", + "--spectrum-alert-banner-inline-end-to-content", + "--spectrum-alert-banner-inline-size", + "--spectrum-alert-banner-inline-start-to-content", + "--spectrum-alert-banner-line-height", "--spectrum-alert-banner-max-inline-size", "--spectrum-alert-banner-min-height", "--spectrum-alert-banner-minimum-height", - "--spectrum-alert-banner-negative-background", - "--spectrum-alert-banner-neutral-background", - "--spectrum-alert-banner-size", - "--spectrum-alert-banner-start-edge", + "--spectrum-alert-banner-text-margin-block-end", + "--spectrum-alert-banner-text-margin-block-start", "--spectrum-alert-banner-text-to-button-horizontal", "--spectrum-alert-banner-text-to-button-vertical", - "--spectrum-alert-banner-text-to-divider", - "--spectrum-alert-banner-top-icon", - "--spectrum-alert-banner-top-text", "--spectrum-alert-banner-top-to-text", "--spectrum-alert-banner-top-to-workflow-icon", "--spectrum-alert-banner-width" ], "global": [ "--spectrum-border-width-100", + "--spectrum-cjk-line-height-100", "--spectrum-font-size-100", "--spectrum-informative-background-color-default", + "--spectrum-line-height-100", "--spectrum-negative-background-color-default", "--spectrum-neutral-subdued-background-color-default", + "--spectrum-sans-font-family-stack", + "--spectrum-spacing-200", "--spectrum-spacing-300", "--spectrum-text-to-visual-300", "--spectrum-white", "--spectrum-workflow-icon-size-100" ], - "system-theme": ["--system-alert-banner-neutral-background"], "passthroughs": [ - "--mod-button-margin-block", - "--mod-button-margin-left", - "--mod-button-margin-right", "--mod-closebutton-align-self", "--mod-closebutton-margin-inline", "--mod-closebutton-margin-top", - "--mod-divider-vertical-align", - "--mod-divider-vertical-height", - "--mod-divider-vertical-margin" + "--mod-icon-size" ], "high-contrast": [ "--highcontrast-alert-banner-border-color", diff --git a/components/alertbanner/index.css b/components/alertbanner/index.css index 7044f73c610..d3000e6d243 100644 --- a/components/alertbanner/index.css +++ b/components/alertbanner/index.css @@ -11,54 +11,65 @@ * governing permissions and limitations under the License. */ -@import "./themes/spectrum-two.css"; - .spectrum-AlertBanner { --spectrum-alert-banner-min-height: var(--spectrum-alert-banner-minimum-height); --spectrum-alert-banner-max-inline-size: var(--spectrum-alert-banner-width); - --spectrum-alert-banner-size: auto; + --spectrum-alert-banner-inline-size: auto; + --spectrum-alert-banner-font-size: var(--spectrum-font-size-100); + --spectrum-alert-banner-line-height: var(--spectrum-line-height-100); + --spectrum-alert-banner-font-family: var(--spectrum-sans-font-family-stack); --spectrum-alert-banner-icon-size: var(--spectrum-workflow-icon-size-100); /* spacing */ --spectrum-alert-banner-icon-to-text: var(--spectrum-text-to-visual-300); - --spectrum-alert-banner-start-edge: var(--spectrum-spacing-300); + --spectrum-alert-banner-inline-start-to-content: var(--spectrum-spacing-300); + --spectrum-alert-banner-inline-end-to-content: var(--spectrum-spacing-300); --spectrum-alert-banner-text-to-button-horizontal: var(--spectrum-spacing-300); - --spectrum-alert-banner-text-to-divider: var(--spectrum-spacing-300); - --spectrum-alert-banner-top-icon: var(--spectrum-alert-banner-top-to-workflow-icon); - --spectrum-alert-banner-top-text: var(--spectrum-alert-banner-top-to-text); - --spectrum-alert-banner-bottom-text: var(--spectrum-alert-banner-bottom-to-text); + --spectrum-alert-banner-block-edge-to-button: var(--spectrum-spacing-200); + --spectrum-alert-banner-close-button-to-content: var(--spectrum-spacing-300); + --spectrum-alert-banner-close-button-to-inline-end: var(--spectrum-alert-banner-close-button-spacing); + + /* Top and bottom margins for AlertBanner-text. Subtracts the vertical spacing that is already included in the + padding-block of its parent AlertBanner-body element. */ + --spectrum-alert-banner-text-margin-block-start: max(0px, var(--mod-alert-banner-top-to-text, var(--spectrum-alert-banner-top-to-text)) - var(--mod-alert-banner-block-edge-to-button, var(--spectrum-alert-banner-block-edge-to-button))); + --spectrum-alert-banner-text-margin-block-end: max(0px, var(--mod-alert-banner-bottom-to-text, var(--spectrum-alert-banner-bottom-to-text)) - var(--mod-alert-banner-block-edge-to-button, var(--spectrum-alert-banner-block-edge-to-button))); /* colors */ - --spectrum-alert-banner-informative-background: var(--spectrum-informative-background-color-default); - --spectrum-alert-banner-negative-background: var(--spectrum-negative-background-color-default); + --spectrum-alert-banner-background: var(--mod-alert-banner-neutral-background, var(--spectrum-neutral-subdued-background-color-default)); --spectrum-alert-banner-font-color: var(--spectrum-white); - /* @passthrough start */ - /* settings for nested Divider */ - --mod-divider-vertical-margin: var(--mod-alert-banner-edge-to-divider, var(--spectrum-alert-banner-edge-to-divider)); - --mod-divider-vertical-height: auto; - --mod-divider-vertical-align: stretch; + /* @passthrough -- settings for nested Close button */ + --mod-closebutton-margin-inline: var(--mod-alert-banner-close-button-to-content, var(--spectrum-alert-banner-close-button-to-content)) var(--mod-alert-banner-close-button-to-inline-end, var(--spectrum-alert-banner-close-button-to-inline-end)); + --mod-closebutton-margin-top: var(--mod-alert-banner-top-to-close-button, var(--spectrum-alert-banner-block-edge-to-button)); + --mod-closebutton-align-self: flex-start; - /* settings for nested Button */ - --mod-button-margin-block: var(--mod-alert-banner-edge-to-button, var(--spectrum-alert-banner-edge-to-button)); - --mod-button-margin-right: var(--mod-alert-banner-text-to-divider, var(--spectrum-alert-banner-text-to-divider)); - --mod-button-margin-left: auto; + &:lang(ja), + &:lang(zh), + &:lang(ko) { + --spectrum-alert-banner-line-height: var(--spectrum-cjk-line-height-100); + } +} - /* settings for nested CloseButton */ - --mod-closebutton-margin-inline: var(--mod-alert-banner-close-button-spacing, var(--spectrum-alert-banner-close-button-spacing)); - --mod-closebutton-margin-top: var(--mod-alert-banner-close-button-spacing, var(--spectrum-alert-banner-close-button-spacing)); - --mod-closebutton-align-self: flex-start; - /* @passthrough end */ +.spectrum-AlertBanner--info { + --spectrum-alert-banner-background: var(--mod-alert-banner-informative-background, var(--spectrum-informative-background-color-default)); +} + +.spectrum-AlertBanner--negative { + --spectrum-alert-banner-background: var(--mod-alert-banner-negative-background, var(--spectrum-negative-background-color-default)); +} +.spectrum-AlertBanner { display: none; justify-content: space-between; - inline-size: var(--mod-alert-banner-size, var(--spectrum-alert-banner-size)); + inline-size: var(--mod-alert-banner-inline-size, var(--spectrum-alert-banner-inline-size)); max-inline-size: var(--mod-alert-banner-max-inline-size, var(--spectrum-alert-banner-max-inline-size)); min-block-size: var(--mod-alert-banner-min-height, var(--spectrum-alert-banner-min-height)); font-size: var(--mod-alert-banner-font-size, var(--spectrum-alert-banner-font-size)); + font-family: var(--mod-alert-banner-font-family, var(--spectrum-alert-banner-font-family)); + line-height: var(--mod-alert-banner-line-height, var(--spectrum-alert-banner-line-height)); color: var(--mod-alert-banner-font-color, var(--spectrum-alert-banner-font-color)); - background-color: var(--mod-alert-banner-neutral-background, var(--spectrum-alert-banner-neutral-background)); + background: var(--mod-alert-banner-background, var(--spectrum-alert-banner-background)); border: var(--highcontrast-alert-banner-border-width, 0) solid var(--highcontrast-alert-banner-border-color, transparent); &.is-open { @@ -66,46 +77,47 @@ } } -.spectrum-AlertBanner--info { - background-color: var(--mod-alert-banner-informative-background, var(--spectrum-alert-banner-informative-background)); -} - -.spectrum-AlertBanner--negative { - background-color: var(--mod-alert-banner-negative-background, var(--spectrum-alert-banner-negative-background)); -} - .spectrum-AlertBanner-body { inline-size: 100%; display: flex; - - /* --mod-* for alert-banner-text-to-button-vertical will only accept values larger than alert-banner-edge-to-bottom, as gap only recognizes positive values */ - gap: max(calc(var(--mod-alert-banner-text-to-button-vertical, var(--spectrum-alert-banner-text-to-button-vertical)) - var(--mod-alert-banner-edge-to-button, var(--spectrum-alert-banner-edge-to-button))), 0px); flex-wrap: wrap; align-items: center; - margin-inline-start: var(--mod-alert-banner-start-edge, var(--spectrum-alert-banner-start-edge)); -} + justify-content: flex-end; -.spectrum-AlertBanner-content { - display: flex; + /* Inline spacing between text and button, only when the button has not wrapped to the next line. */ + column-gap: var(--mod-alert-banner-text-to-button-horizontal, var(--spectrum-alert-banner-text-to-button-horizontal)); + + /* Block spacing between text and button, when the button has wrapped to the next line. Takes into + account the existing margins on the text. */ + row-gap: max(var(--mod-alert-banner-text-to-button-vertical, 0px), var(--spectrum-alert-banner-text-to-button-vertical) - var(--spectrum-alert-banner-text-margin-block-end)); + + padding-block: var(--mod-alert-banner-block-edge-to-button, var(--spectrum-alert-banner-block-edge-to-button)); + margin-inline-start: var(--mod-alert-banner-inline-start-to-content, var(--spectrum-alert-banner-inline-start-to-content)); + margin-inline-end: var(--mod-alert-banner-inline-end-to-content, var(--spectrum-alert-banner-inline-end-to-content)); + + /* When dismissible, this spacing is handled by the margin-inline-start on the close button instead. */ + .spectrum-AlertBanner:has(.spectrum-CloseButton) & { + margin-inline-end: 0; + } } -.spectrum-AlertBanner-end { +.spectrum-AlertBanner-content { display: flex; - align-items: center; + flex-grow: 1; } .spectrum-AlertBanner-icon { - inline-size: var(--mod-alert-banner-icon-size, var(--spectrum-alert-banner-icon-size)); - block-size: var(--mod-alert-banner-icon-size, var(--spectrum-alert-banner-icon-size)); - margin-block-start: var(--mod-alert-banner-top-icon, var(--spectrum-alert-banner-top-icon)); + /* @passthrough -- icon-size */ + --mod-icon-size: var(--mod-alert-banner-icon-size, var(--spectrum-alert-banner-icon-size)); + + margin-block-start: calc(var(--mod-alert-banner-top-to-icon, var(--spectrum-alert-banner-top-to-workflow-icon)) - var(--mod-alert-banner-block-edge-to-button, var(--spectrum-alert-banner-block-edge-to-button))); margin-inline-end: var(--mod-alert-banner-icon-to-text, var(--spectrum-alert-banner-icon-to-text)); flex-shrink: 0; } .spectrum-AlertBanner-text { - margin-block-start: var(--mod-alert-banner-top-text, var(--spectrum-alert-banner-top-text)); - margin-block-end: var(--mod-alert-banner-bottom-text, var(--spectrum-alert-banner-bottom-text)); - margin-inline-end: var(--mod-alert-banner-text-to-button-horizontal, var(--spectrum-alert-banner-text-to-button-horizontal)); + margin-block-start: var(--mod-alert-banner-text-margin-block-start, var(--spectrum-alert-banner-text-margin-block-start)); + margin-block-end: var(--mod-alert-banner-text-margin-block-end, var(--spectrum-alert-banner-text-margin-block-end)); } @media (forced-colors: active) { diff --git a/components/alertbanner/package.json b/components/alertbanner/package.json index 8e89148a391..38b3e7f082f 100644 --- a/components/alertbanner/package.json +++ b/components/alertbanner/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/alertbanner", - "version": "3.2.0", + "version": "4.0.0-next.3", "description": "The Spectrum CSS alertbanner component", "license": "Apache-2.0", "author": "Adobe", @@ -19,18 +19,16 @@ "./package.json": "./package.json", "./dist/*": "./dist/*", "./index.css": "./dist/index.css", - "./index-*.css": "./dist/index-*.css", "./metadata.json": "./dist/metadata.json", - "./themes/*": "./dist/themes/*", "./stories/*": "./stories/*" }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/button": ">=14.0.0 <15.0.0", - "@spectrum-css/closebutton": ">=6.0.0 <7.0.0", - "@spectrum-css/divider": ">=5.0.0 <6.0.0", - "@spectrum-css/icon": ">=9.0.0 <10.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/button": ">=15.0.0-next.0", + "@spectrum-css/closebutton": ">=7.0.0-next.0", + "@spectrum-css/divider": ">=6.0.0-next.0", + "@spectrum-css/icon": ">=10.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/button": { @@ -50,11 +48,11 @@ } }, "devDependencies": { - "@spectrum-css/button": "14.2.0", - "@spectrum-css/closebutton": "6.2.0", - "@spectrum-css/divider": "5.2.0", - "@spectrum-css/icon": "9.2.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/button": "15.0.0-next.2", + "@spectrum-css/closebutton": "7.0.0-next.1", + "@spectrum-css/divider": "6.0.0-next.1", + "@spectrum-css/icon": "10.0.0-next.3", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/alertbanner/stories/alertbanner.stories.js b/components/alertbanner/stories/alertbanner.stories.js index cd49c21a70e..c6d638008c2 100644 --- a/components/alertbanner/stories/alertbanner.stories.js +++ b/components/alertbanner/stories/alertbanner.stories.js @@ -75,7 +75,11 @@ export default { }, packageJson, metadata, + status: { + type: "migrated", + }, }, + tags: ["migrated"], }; export const Default = AlertBannerGroup.bind({}); diff --git a/components/alertbanner/stories/alertbanner.test.js b/components/alertbanner/stories/alertbanner.test.js index dee63d20c8d..0b86e7fbfaa 100644 --- a/components/alertbanner/stories/alertbanner.test.js +++ b/components/alertbanner/stories/alertbanner.test.js @@ -3,6 +3,7 @@ import { Template } from "./template.js"; export const AlertBannerGroup = Variants({ Template, + TestTemplate: Template, stateDirection: "column", wrapperStyles: { "inline-size": "100%", diff --git a/components/alertbanner/stories/template.js b/components/alertbanner/stories/template.js index 3eb719c0612..ec0278583fd 100644 --- a/components/alertbanner/stories/template.js +++ b/components/alertbanner/stories/template.js @@ -1,6 +1,5 @@ import { Template as Button } from "@spectrum-css/button/stories/template.js"; import { Template as CloseButton } from "@spectrum-css/closebutton/stories/template.js"; -import { Template as Divider } from "@spectrum-css/divider/stories/template.js"; import { Template as Icon } from "@spectrum-css/icon/stories/template.js"; import { Container, getRandomId } from "@spectrum-css/preview/decorators"; import { html } from "lit"; @@ -10,9 +9,6 @@ import { styleMap } from "lit/directives/style-map.js"; import { when } from "lit/directives/when.js"; import "../index.css"; -import "../themes/spectrum.css"; -/* Must be imported last */ -import "../themes/express.css"; export const Template = ({ rootClass = "spectrum-AlertBanner", @@ -26,6 +22,12 @@ export const Template = ({ customClasses = [], customStyles = {}, } = {}, context = {}) => { + const { updateArgs } = context; + + const onclick = () => { + updateArgs({ isOpen: false }); + }; + return html`
    - ${Divider({ - vertical: true, - size: "s", - tag: "div", - }, context)} ${CloseButton({ size: "m", staticColor: "white", @@ -118,62 +115,62 @@ export const TextOverflowTemplate = (args) => html` export const ActionableOptionsTemplate = (args, context) => Container({ withBorder: false, direction: "column", - containerStyles: { alignItems: "stretch" }, - wrapperStyles: { alignItems: "stretch" }, - content: html` - ${Container({ + containerStyles: { "align-items": "stretch" }, + wrapperStyles: { "align-items": "stretch" }, + content: [ + Container({ withBorder: false, direction: "column", heading: "Action button and close button", - containerStyles: { alignItems: "stretch" }, - wrapperStyles: { alignItems: "stretch" }, + containerStyles: { "align-items": "stretch" }, + wrapperStyles: { "align-items": "stretch" }, content: Template({ - ...args, - variant: "neutral", - text: "Your trial has expired", - actionButtonText: "Buy now", + ...args, + variant: "neutral", + text: "Your trial has expired", + actionButtonText: "Buy now", }, context), - }, context)} - ${Container({ + }, context), + Container({ withBorder: false, direction: "column", heading: "Action button only", - containerStyles: { alignItems: "stretch" }, - wrapperStyles: { alignItems: "stretch" }, + containerStyles: { "align-items": "stretch" }, + wrapperStyles: { "align-items": "stretch" }, content: Template({ - ...args, - variant: "neutral", - text: "Your trial has expired", - actionButtonText: "Buy now", - showCloseButton: false, + ...args, + variant: "neutral", + text: "Your trial has expired", + actionButtonText: "Buy now", + showCloseButton: false, }, context), - }, context)} - ${Container({ + }, context), + Container({ withBorder: false, direction: "column", heading: "Close button only", - containerStyles: { alignItems: "stretch" }, - wrapperStyles: { alignItems: "stretch" }, + containerStyles: { "align-items": "stretch" }, + wrapperStyles: { "align-items": "stretch" }, content: Template({ ...args, variant: "neutral", text: "Your trial has expired", actionButtonText: "", }), - }, context)} - ${Container({ + }, context), + Container({ withBorder: false, direction: "column", heading: "Text only", - containerStyles: { alignItems: "stretch" }, - wrapperStyles: { alignItems: "stretch" }, + containerStyles: { "align-items": "stretch" }, + wrapperStyles: { "align-items": "stretch" }, content: Template({ - ...args, - variant: "neutral", - text: "Your trial has expired", - actionButtonText: "", - showCloseButton: false, + ...args, + variant: "neutral", + text: "Your trial has expired", + actionButtonText: "", + showCloseButton: false, }, context), - }, context)} - `, + }, context), + ], }, context); diff --git a/components/alertbanner/themes/express.css b/components/alertbanner/themes/express.css deleted file mode 100644 index a86424d5e4b..00000000000 --- a/components/alertbanner/themes/express.css +++ /dev/null @@ -1,22 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--express */ - -@import "./spectrum.css"; - -@container style(--system: express) { - .spectrum-AlertBanner { - --spectrum-alert-banner-neutral-background: var(--spectrum-neutral-background-color-default); - } -} diff --git a/components/alertbanner/themes/spectrum-two.css b/components/alertbanner/themes/spectrum-two.css deleted file mode 100644 index 3e038dbd7a4..00000000000 --- a/components/alertbanner/themes/spectrum-two.css +++ /dev/null @@ -1,18 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -@container style(--system: spectrum) { - .spectrum-AlertBanner { - --spectrum-alert-banner-neutral-background: var(--spectrum-neutral-subdued-background-color-default); - } -} diff --git a/components/alertbanner/themes/spectrum.css b/components/alertbanner/themes/spectrum.css deleted file mode 100644 index 4dd42f109fe..00000000000 --- a/components/alertbanner/themes/spectrum.css +++ /dev/null @@ -1,22 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--legacy */ - -@import "./spectrum-two.css"; - -@container style(--system: legacy) { - .spectrum-AlertBanner { - --spectrum-alert-banner-neutral-background: var(--spectrum-neutral-subdued-background-color-default); - } -} diff --git a/components/alertdialog/CHANGELOG.md b/components/alertdialog/CHANGELOG.md index 6acbf0cf9ad..c052ad9c35e 100644 --- a/components/alertdialog/CHANGELOG.md +++ b/components/alertdialog/CHANGELOG.md @@ -1,5 +1,101 @@ # Change log +## 5.0.0-next.4 + +### Major Changes + +- [#3725](https://github.com/adobe/spectrum-css/pull/3725) [`f977e60`](https://github.com/adobe/spectrum-css/commit/f977e60a7f32eb7147bd1546d04a02557011e7d9) Thanks [@cdransf](https://github.com/cdransf)! + +#### S2 migration + +This migrates the `alert dialog` component to the latest Spectrum 2 designs. Custom properties have been remapped and added per the design specification. + +The icon in the dialog header has been moved from the right side to the left. + +The dialog divider has been removed. + +Primary button style has been updated to filled. + +The following variants remain supported: + +- Confirmation +- Information +- Destructive +- Warning (with `AlertDiamond` icon) +- Error (with `AlertTriangle` icon) + +Dialog buttons may be displayed either horizontally or vertically. + +##### Removed custom properties + +`--spectrum-alert-dialog-description-to-buttons` +`--spectrum-alert-dialog-divider-to-description` +`--spectrum-alert-dialog-padding` +`--spectrum-alert-dialog-title-size` +`--spectrum-alert-dialog-title-to-divider` +`--spectrum-alert-dialog-title-to-icon` + +##### New custom properties + +`--spectrum-alert-dialog-background-color` +`--spectrum-alert-dialog-corner-radius` +`--spectrum-alert-dialog-description-font-size` +`--spectrum-alert-dialog-description-to-button-group` +`--spectrum-alert-dialog-edge-to-content` +`--spectrum-alert-dialog-heading-size` +`--spectrum-alert-dialog-title-to-description` + +##### Removed mods + +`--mod-alert-dialog-body-font-size` +`--mod-alert-dialog-description-to-buttons` +`--mod-alert-dialog-divider-to-description` +`--mod-alert-dialog-padding` +`--mod-alert-dialog-title-to-divider` +`--mod-alert-dialog-title-to-icon` + +##### New mods + +`--mod-alert-dialog-background-color` +`--mod-alert-dialog-corner-radius` +`--mod-alert-dialog-description-content-size` +`--mod-alert-dialog-description-to-button-group` +`--mod-alert-dialog-edge-to-content` +`--mod-alert-dialog-heading-size` +`--mod-alert-dialog-minimum-title-to-icon` +`--mod-alert-dialog-title-to-description` + +## 5.0.0-next.3 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + - @spectrum-css/modal@8.0.0-next.1 + - @spectrum-css/underlay@7.0.0-next.0 + +## 5.0.0-next.2 + +### Patch Changes + +- Updated dependencies [[`cb1b957`](https://github.com/adobe/spectrum-css/commit/cb1b957c05ecf02d3f473de09a8bfd5f2b5d42bf)]: + - @spectrum-css/modal@7.1.1-next.0 + +## 5.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`c6836fb`](https://github.com/adobe/spectrum-css/commit/c6836fb132effcfb09e4ca6d0d8923564bfe2914)]: + - @spectrum-css/divider@6.0.0-next.0 + +## 5.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`a25e0a9`](https://github.com/adobe/spectrum-css/commit/a25e0a99e5a4736ab4e607e00739343101a2633b)]: + - @spectrum-css/icon@10.0.0-next.0 + - @spectrum-css/buttongroup@10.0.0-next.0 + ## 4.2.0 ### Minor Changes diff --git a/components/alertdialog/dist/metadata.json b/components/alertdialog/dist/metadata.json index 03bf62123f2..bc28f998bbc 100644 --- a/components/alertdialog/dist/metadata.json +++ b/components/alertdialog/dist/metadata.json @@ -3,82 +3,42 @@ "selectors": [ ".spectrum-AlertDialog", ".spectrum-AlertDialog .spectrum-Icon", - ".spectrum-AlertDialog--error", - ".spectrum-AlertDialog--warning", + ".spectrum-AlertDialog-buttongroup", ".spectrum-AlertDialog-content", ".spectrum-AlertDialog-grid", ".spectrum-AlertDialog-header", - ".spectrum-AlertDialog-heading" - ], - "modifiers": [ - "--mod-alert-dialog-body-color", - "--mod-alert-dialog-body-font-family", - "--mod-alert-dialog-body-font-size", - "--mod-alert-dialog-body-font-style", - "--mod-alert-dialog-body-font-weight", - "--mod-alert-dialog-body-line-height", - "--mod-alert-dialog-description-to-buttons", - "--mod-alert-dialog-divider-to-description", - "--mod-alert-dialog-error-icon-color", - "--mod-alert-dialog-icon-size", - "--mod-alert-dialog-max-width", - "--mod-alert-dialog-min-width", - "--mod-alert-dialog-padding", - "--mod-alert-dialog-title-color", - "--mod-alert-dialog-title-font-family", - "--mod-alert-dialog-title-font-size", - "--mod-alert-dialog-title-font-style", - "--mod-alert-dialog-title-font-weight", - "--mod-alert-dialog-title-line-height", - "--mod-alert-dialog-title-to-divider", - "--mod-alert-dialog-title-to-icon", - "--mod-alert-dialog-warning-icon-color" + ".spectrum-AlertDialog-heading", + ".spectrum-AlertDialog:where(.spectrum-AlertDialog--error) .spectrum-AlertDialog-icon", + ".spectrum-AlertDialog:where(.spectrum-AlertDialog--warning) .spectrum-AlertDialog-icon" ], + "modifiers": [], "component": [ - "--spectrum-alert-dialog-body-color", - "--spectrum-alert-dialog-body-font-family", - "--spectrum-alert-dialog-body-font-size", - "--spectrum-alert-dialog-body-font-style", - "--spectrum-alert-dialog-body-font-weight", - "--spectrum-alert-dialog-body-line-height", - "--spectrum-alert-dialog-description-size", - "--spectrum-alert-dialog-description-to-buttons", - "--spectrum-alert-dialog-divider-to-description", - "--spectrum-alert-dialog-error-icon-color", - "--spectrum-alert-dialog-icon-size", - "--spectrum-alert-dialog-max-width", + "--spectrum-alert-dialog-description-font-size", + "--spectrum-alert-dialog-edge-to-content", "--spectrum-alert-dialog-maximum-width", - "--spectrum-alert-dialog-min-width", "--spectrum-alert-dialog-minimum-width", - "--spectrum-alert-dialog-padding", - "--spectrum-alert-dialog-title-color", - "--spectrum-alert-dialog-title-font-family", - "--spectrum-alert-dialog-title-font-size", - "--spectrum-alert-dialog-title-font-style", - "--spectrum-alert-dialog-title-font-weight", - "--spectrum-alert-dialog-title-line-height", - "--spectrum-alert-dialog-title-size", - "--spectrum-alert-dialog-title-to-divider", - "--spectrum-alert-dialog-title-to-icon", - "--spectrum-alert-dialog-warning-icon-color" + "--spectrum-alert-dialog-title-font-size" ], "global": [ + "--spectrum-background-layer-2-color", "--spectrum-body-color", "--spectrum-body-sans-serif-font-style", "--spectrum-body-sans-serif-font-weight", + "--spectrum-border-width-100", + "--spectrum-corner-radius-extra-large-default", "--spectrum-heading-color", "--spectrum-heading-line-height", "--spectrum-heading-sans-serif-font-style", "--spectrum-heading-sans-serif-font-weight", - "--spectrum-line-height-100", + "--spectrum-line-height-200", "--spectrum-negative-visual-color", "--spectrum-notice-visual-color", "--spectrum-sans-font-family-stack", - "--spectrum-spacing-200", + "--spectrum-spacing-100", "--spectrum-spacing-300", + "--spectrum-spacing-500", "--spectrum-workflow-icon-size-100" ], - "system-theme": [], - "passthroughs": ["--mod-buttongroup-justify-content", "--mod-icon-color"], + "passthroughs": [], "high-contrast": [] } diff --git a/components/alertdialog/index.css b/components/alertdialog/index.css index 14e6e555f2c..8bd7f7d3586 100644 --- a/components/alertdialog/index.css +++ b/components/alertdialog/index.css @@ -1,5 +1,5 @@ /*! - * Copyright 2024 Adobe. All rights reserved. + * Copyright 2025 Adobe. All rights reserved. * * This file is licensed to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. You may obtain a copy @@ -11,105 +11,73 @@ * governing permissions and limitations under the License. */ -.spectrum-AlertDialog { - --spectrum-alert-dialog-min-width: var(--spectrum-alert-dialog-minimum-width); - --spectrum-alert-dialog-max-width: var(--spectrum-alert-dialog-maximum-width); - --spectrum-alert-dialog-icon-size: var(--spectrum-workflow-icon-size-100); - - /* color */ - --spectrum-alert-dialog-warning-icon-color: var(--spectrum-notice-visual-color); - --spectrum-alert-dialog-error-icon-color: var(--spectrum-negative-visual-color); - - /* typography */ - --spectrum-alert-dialog-title-font-family: var(--spectrum-sans-font-family-stack); - --spectrum-alert-dialog-title-font-weight: var(--spectrum-heading-sans-serif-font-weight); - --spectrum-alert-dialog-title-font-style: var(--spectrum-heading-sans-serif-font-style); - --spectrum-alert-dialog-title-font-size: var(--spectrum-alert-dialog-title-size); - --spectrum-alert-dialog-title-line-height: var(--spectrum-heading-line-height); - --spectrum-alert-dialog-title-color: var(--spectrum-heading-color); - - --spectrum-alert-dialog-body-font-family: var(--spectrum-sans-font-family-stack); - --spectrum-alert-dialog-body-font-weight: var(--spectrum-body-sans-serif-font-weight); - --spectrum-alert-dialog-body-font-style: var(--spectrum-body-sans-serif-font-style); - --spectrum-alert-dialog-body-font-size: var(--spectrum-alert-dialog-description-size); - --spectrum-alert-dialog-body-line-height: var(--spectrum-line-height-100); - --spectrum-alert-dialog-body-color: var(--spectrum-body-color); - - /* spacing */ - --spectrum-alert-dialog-title-to-divider: var(--spectrum-spacing-200); - --spectrum-alert-dialog-divider-to-description: var(--spectrum-spacing-300); - --spectrum-alert-dialog-title-to-icon: var(--spectrum-spacing-300); - - /* mods for nested component */ - --mod-buttongroup-justify-content: flex-end; -} - .spectrum-AlertDialog { display: flex; box-sizing: border-box; inline-size: fit-content; - min-inline-size: var(--mod-alert-dialog-min-width, var(--spectrum-alert-dialog-min-width)); - max-inline-size: var(--mod-alert-dialog-max-width, var(--spectrum-alert-dialog-max-width)); + min-inline-size: var(--spectrum-alert-dialog-minimum-width); + max-inline-size: var(--spectrum-alert-dialog-maximum-width); max-block-size: inherit; + background-color: var(--spectrum-background-layer-2-color); outline: none; - padding: var(--mod-alert-dialog-padding, var(--spectrum-alert-dialog-padding)); + padding: var(--spectrum-alert-dialog-edge-to-content); + + /* Adding a transparent border here allows the forced colors mode to default appropriately */ + border: var(--spectrum-border-width-100) solid transparent; + border-radius: var(--spectrum-corner-radius-extra-large-default); .spectrum-Icon { - inline-size: var(--mod-alert-dialog-icon-size, var(--spectrum-alert-dialog-icon-size)); - block-size: var(--mod-alert-dialog-icon-size, var(--spectrum-alert-dialog-icon-size)); - margin-inline-start: var(--mod-alert-dialog-title-to-icon, var(--spectrum-alert-dialog-title-to-icon)); + inline-size: var(--spectrum-workflow-icon-size-100); + block-size: var(--spectrum-workflow-icon-size-100); flex-shrink: 0; } -} -.spectrum-AlertDialog--warning { - /* @passthrough */ - --mod-icon-color: var(--mod-alert-dialog-warning-icon-color, var(--spectrum-alert-dialog-warning-icon-color)); -} + &:where(.spectrum-AlertDialog--warning) .spectrum-AlertDialog-icon { + color: var(--spectrum-notice-visual-color); + } -.spectrum-AlertDialog--error { - /* @passthrough */ - --mod-icon-color: var(--mod-alert-dialog-error-icon-color, var(--spectrum-alert-dialog-error-icon-color)); + &:where(.spectrum-AlertDialog--error) .spectrum-AlertDialog-icon { + color: var(--spectrum-negative-visual-color); + } } .spectrum-AlertDialog-grid { display: grid; + inline-size: 100%; } .spectrum-AlertDialog-header { display: flex; - justify-content: space-between; - align-items: baseline; + gap: var(--spectrum-spacing-100); + align-items: center; + margin-block-end: var(--spectrum-spacing-300); } .spectrum-AlertDialog-heading { - font-family: var(--mod-alert-dialog-title-font-family, var(--spectrum-alert-dialog-title-font-family)); - font-weight: var(--mod-alert-dialog-title-font-weight, var(--spectrum-alert-dialog-title-font-weight)); - font-style: var(--mod-alert-dialog-title-font-style, var(--spectrum-alert-dialog-title-font-style)); - font-size: var(--mod-alert-dialog-title-font-size, var(--spectrum-alert-dialog-title-font-size)); - line-height: var(--mod-alert-dialog-title-line-height, var(--spectrum-alert-dialog-title-line-height)); - color: var(--mod-alert-dialog-title-color, var(--spectrum-alert-dialog-title-color)); + font-family: var(--spectrum-sans-font-family-stack); + font-weight: var(--spectrum-heading-sans-serif-font-weight); + font-style: var(--spectrum-heading-sans-serif-font-style); + font-size: var(--spectrum-alert-dialog-title-font-size); + line-height: var(--spectrum-heading-line-height); + color: var(--spectrum-heading-color); margin: 0; - margin-block-end: var(--mod-alert-dialog-title-to-divider, var(--spectrum-alert-dialog-title-to-divider)); } .spectrum-AlertDialog-content { - font-family: var(--mod-alert-dialog-body-font-family, var(--spectrum-alert-dialog-body-font-family)); - font-weight: var(--mod-alert-dialog-body-font-weight, var(--spectrum-alert-dialog-body-font-weight)); - font-style: var(--mod-alert-dialog-body-font-style, var(--spectrum-alert-dialog-body-font-style)); - font-size: var(--mod-alert-dialog-body-font-size, var(--spectrum-alert-dialog-body-font-size)); - line-height: var(--mod-alert-dialog-body-line-height, var(--spectrum-alert-dialog-body-line-height)); - color: var(--mod-alert-dialog-body-color, var(--spectrum-alert-dialog-body-color)); + font-family: var(--spectrum-sans-font-family-stack); + font-weight: var(--spectrum-body-sans-serif-font-weight); + font-style: var(--spectrum-body-sans-serif-font-style); + font-size: var(--spectrum-alert-dialog-description-font-size); + line-height: var(--spectrum-line-height-200); + color: var(--spectrum-body-color); margin: 0; - margin-block-start: var(--mod-alert-dialog-divider-to-description, var(--spectrum-alert-dialog-divider-to-description)); - margin-block-end: var(--mod-alert-dialog-description-to-buttons, var(--spectrum-alert-dialog-description-to-buttons)); + margin-block-end: var(--spectrum-spacing-500); overflow-y: auto; -webkit-overflow-scrolling: touch; } -@media (forced-colors: active) { - .spectrum-AlertDialog { - border: solid; - } +.spectrum-AlertDialog-buttongroup { + display: flex; + justify-content: flex-end; } diff --git a/components/alertdialog/package.json b/components/alertdialog/package.json index 99e0cc134a2..596bc4c7ee9 100644 --- a/components/alertdialog/package.json +++ b/components/alertdialog/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/alertdialog", - "version": "4.2.0", + "version": "5.0.0-next.4", "description": "The Spectrum CSS alertdialog component", "license": "Apache-2.0", "author": "Adobe", @@ -24,12 +24,12 @@ }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/buttongroup": ">=9.0.0 <10.0.0", - "@spectrum-css/divider": ">=5.0.0 <6.0.0", - "@spectrum-css/icon": ">=9.0.0 <10.0.0", - "@spectrum-css/modal": ">=7.0.0 <8.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0", - "@spectrum-css/underlay": ">=6.0.0 <7.0.0" + "@spectrum-css/buttongroup": ">=10.0.0-next.0", + "@spectrum-css/divider": ">=6.0.0-next.0", + "@spectrum-css/icon": ">=10.0.0-next.0", + "@spectrum-css/modal": ">=8.0.0-next.1", + "@spectrum-css/tokens": ">=16.1.0-next.0", + "@spectrum-css/underlay": ">=7.0.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/buttongroup": { @@ -52,12 +52,12 @@ } }, "devDependencies": { - "@spectrum-css/buttongroup": "9.2.0", - "@spectrum-css/divider": "5.2.0", - "@spectrum-css/icon": "9.2.0", - "@spectrum-css/modal": "7.2.0", - "@spectrum-css/tokens": "16.0.2", - "@spectrum-css/underlay": "6.2.0" + "@spectrum-css/buttongroup": "10.0.0-next.1", + "@spectrum-css/divider": "6.0.0-next.1", + "@spectrum-css/icon": "10.0.0-next.3", + "@spectrum-css/modal": "8.0.0-next.1", + "@spectrum-css/tokens": "16.1.0-next.10", + "@spectrum-css/underlay": "7.0.0-next.1" }, "keywords": [ "design-system", diff --git a/components/alertdialog/stories/alertdialog.stories.js b/components/alertdialog/stories/alertdialog.stories.js index 87c83d18ff9..48594e7a80e 100644 --- a/components/alertdialog/stories/alertdialog.stories.js +++ b/components/alertdialog/stories/alertdialog.stories.js @@ -32,12 +32,31 @@ export default { control: { type: "text" }, }, isOpen, - variant: { table: { disable: true } }, - buttons: { table: { disable: true } }, + variant: { + name: "Variant", + type: { name: "string" }, + table: { + type: { summary: "string" }, + category: "Component", + }, + options: ["confirmation", "information", "destructive", "warning", "error"], + control: "select", + }, + hasVerticalButtons: { + name: "Vertical buttons", + description: "In limited horizontal space, the button group may stack vertically.", + type: { name: "boolean" }, + table: { + type: { summary: "boolean" }, + category: "Component", + }, + control: "boolean", + } }, args: { rootClass: "spectrum-AlertDialog", - isOpen: false, + isOpen: true, + hasVerticalButtons: false, variant: "confirmation", }, parameters: { @@ -47,34 +66,25 @@ export default { }, design: { type: "figma", - url: "https://www.figma.com/design/Mngz9H7WZLbrCvGQf3GnsY/S2-%2F-Desktop?node-id=21917-157", - }, - docs: { - story: { - height: "300px", - } + url: "https://www.figma.com/design/Mngz9H7WZLbrCvGQf3GnsY/S2---Desktop?node-id=21917-157", }, packageJson, metadata, + status: { + type: "migrated", + } }, + tags: ["migrated"], decorators: [ withUnderlayWrapper, ], }; export const Default = AlertDialogGroup.bind({}); +Default.storyName = "Default (confirmation)"; Default.args = { isOpen: true, heading: "Enable smart filters?", - buttons: [{ - variant: "secondary", - treatment: "outline", - label: "Remind me later" - }, { - treatment: "fill", - label: "Enable", - variant: "accent" - }], content: "Smart filters are nondestructive and will preserve your original images.", }; @@ -101,19 +111,6 @@ Information.args = { isOpen: true, variant: "information", heading: "Informative Dialog with a wrapping title text because the text is longer than the width of the alert dialog", - buttons: [{ - variant: "secondary", - treatment: "outline", - label: "No, thanks" - },{ - variant: "secondary", - treatment: "outline", - label: "Remind me later" - }, { - variant: "primary", - treatment: "outline", - label: "Rate now", - }], content: "If you enjoy our app, would you mind taking a moment to rate it?", }; Information.parameters = { @@ -129,16 +126,7 @@ Warning.args = { isOpen: true, variant: "warning", heading: "Unverified format", - icon: true, - buttons: [{ - variant: "secondary", - treatment: "outline", - label: "Cancel" - }, { - treatment: "outline", - label: "Continue", - variant: "primary" - }], + icon: "Warning", content: "This format has not been verified and may not be viewable for some users. Do you want to continue publishing?", }; Warning.parameters = { @@ -154,17 +142,8 @@ Error.args = { isOpen: true, variant: "error", heading: "Unable to share", - icon: true, - buttons: [{ - variant: "secondary", - treatment: "outline", - label: "Cancel" - }, { - treatment: "outline", - label: "Continue", - variant: "primary" - }], - content: "An error occured while sharing your project. Please verify the email address and try again.", + icon: "AlertTriangle", + content: "An error occurred while sharing your project. Please verify the email address and try again.", }; Error.parameters = { chromatic: { disableSnapshot: true }, @@ -179,36 +158,36 @@ Destructive.args = { isOpen: true, variant: "destructive", heading: "Delete 3 documents?", - buttons: [{ - variant: "secondary", - treatment: "outline", - label: "Cancel" - }, { - treatment: "fill", - label: "Delete", - variant: "negative" - }], content: "Are you sure you want to delete the 3 selected documents?", }; Destructive.parameters = { chromatic: { disableSnapshot: true }, }; +/** + * When the title and description text are too long for the available horizontal space, they wrap to form another line. + */ +export const Overflow = Template.bind({}); +Overflow.tags = ["!dev"]; +Overflow.args = { + isOpen: true, + variant: "confirmation", + heading: "Alert dialogs allow for text overflow by wrapping when the description and dialog are too long", + content: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse ultrices est eu lacus interdum, vitae volutpat tortor laoreet. Phasellus consectetur erat quis massa congue, vel placerat ipsum hendrerit. Aenean eleifend augue quam, quis blandit lacus pretium eget. Aliquam aliquam fermentum nunc, sed dictum metus varius in. Suspendisse in nisl libero. Nulla egestas massa eget lectus ullamcorper placerat. Vivamus cursus, nunc quis pharetra auctor, eros mi tempus elit, sit amet placerat ipsum velit ut dolor. Nam sit amet eleifend erat. Duis sollicitudin orci sit amet tellus tincidunt, vel lobortis risus pellentesque. Integer viverra urna elementum metus dignissim placerat. Nulla posuere eros ipsum." +}; +Overflow.parameters = { + chromatic: { disableSnapshot: true }, +}; + +/** + * The dialog description may also scroll if the height of the dialog is constrained. + */ export const Scroll = Template.bind({}); Scroll.tags = ["!dev"]; Scroll.args = { isOpen: true, variant: "confirmation", heading: "Enable Smart Filters?", - buttons: [{ - variant: "secondary", - treatment: "outline", - label: "Remind me later" - }, { - treatment: "fill", - label: "Enable", - variant: "accent" - }], content: "Smart filters are nondestructive and will preserve your original images. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse ultrices est eu lacus interdum, vitae volutpat tortor laoreet. Phasellus consectetur erat quis massa congue, vel placerat ipsum hendrerit. Aenean eleifend augue quam, quis blandit lacus pretium eget. Aliquam aliquam fermentum nunc, sed dictum metus varius in. Suspendisse in nisl libero. Nulla egestas massa eget lectus ullamcorper placerat. Vivamus cursus, nunc quis pharetra auctor, eros mi tempus elit, sit amet placerat ipsum velit ut dolor. Nam sit amet eleifend erat. Duis sollicitudin orci sit amet tellus tincidunt, vel lobortis risus pellentesque. Integer viverra urna elementum metus dignissim placerat. Nulla posuere eros ipsum. Pellentesque viverra urna justo, eu ultricies nisl fermentum et. Vivamus tristique porttitor dictum.", customStyles: { "max-block-size": "275px", @@ -217,3 +196,16 @@ Scroll.args = { Scroll.parameters = { chromatic: { disableSnapshot: true }, }; + +/** + * Buttons are stacked by the importance of the action, with the most critical or primary action at the bottom. + */ +export const VerticalButtons = Template.bind({}); +VerticalButtons.storyName = "Vertical buttons"; +VerticalButtons.tags = ["!dev"]; +VerticalButtons.args = { + hasVerticalButtons: true, + isOpen: true, + heading: "Vertical button group", + content: "This is what an alert dialog looks like with buttons arranged vertically.", +}; diff --git a/components/alertdialog/stories/alertdialog.test.js b/components/alertdialog/stories/alertdialog.test.js index a74e2092864..c2c850cb58c 100644 --- a/components/alertdialog/stories/alertdialog.test.js +++ b/components/alertdialog/stories/alertdialog.test.js @@ -2,72 +2,39 @@ import { Variants } from "@spectrum-css/preview/decorators"; import { Dialog, Template } from "./template.js"; export const AlertDialogGroup = Variants({ - // Test this without Modal to focus on the dialog solo Template, TestTemplate: Dialog, wrapperStyles: { "z-index": "1", "inline-size": "fit-content", - "background-color": "var(--spectrum-gray-50, white)", + "background-color": "transparent", + "border": "none", "min-block-size": "auto", }, testData: [{}, { + testHeading: "Vertical button display", + heading: "Vertical button group", + content: "This is what an alert dialog looks like with buttons arranged vertically.", + hasVerticalButtons: true, + }, { + testHeading: "Warning", variant: "warning", heading: "Unverified format", - icon: true, - buttons: [{ - variant: "secondary", - treatment: "outline", - label: "Cancel" - }, { - treatment: "outline", - label: "Continue", - variant: "primary" - }], content: "This format has not been verified and may not be viewable for some users. Do you want to continue publishing?", }, { + testHeading: "Error", variant: "error", heading: "Unable to share", - icon: true, - buttons: [{ - variant: "secondary", - treatment: "outline", - label: "Cancel" - }, { - treatment: "outline", - label: "Continue", - variant: "primary" - }], content: "An error occured while sharing your project. Please verify the email address and try again.", }, { + testHeading: "Destructive", variant: "destructive", heading: "Delete 3 documents?", - buttons: [{ - variant: "secondary", - treatment: "outline", - label: "Cancel" - }, { - treatment: "fill", - label: "Delete", - variant: "negative" - }], content: "Are you sure you want to delete the 3 selected documents?", }, { + testHeading: "Informative", variant: "information", - heading: "Informative Dialog with a wrapping title text because the text is longer than the width of the alert dialog", - buttons: [{ - variant: "secondary", - treatment: "outline", - label: "No, thanks" - },{ - variant: "secondary", - treatment: "outline", - label: "Remind me later" - }, { - variant: "primary", - treatment: "outline", - label: "Rate now", - }], + heading: "Informative dialog with a wrapping title text because the text is longer than the width of the alert dialog", content: "If you enjoy our app, would you mind taking a moment to rate it?", }], }); diff --git a/components/alertdialog/stories/template.js b/components/alertdialog/stories/template.js index 5de1e37972c..8d72b3a68c2 100644 --- a/components/alertdialog/stories/template.js +++ b/components/alertdialog/stories/template.js @@ -1,5 +1,4 @@ import { Template as ButtonGroup } from "@spectrum-css/buttongroup/stories/template.js"; -import { Template as Divider } from "@spectrum-css/divider/stories/template.js"; import { Template as Icon } from "@spectrum-css/icon/stories/template.js"; import { Template as Modal } from "@spectrum-css/modal/stories/template.js"; import { getRandomId } from "@spectrum-css/preview/decorators"; @@ -11,14 +10,70 @@ import { when } from "lit/directives/when.js"; import "../index.css"; +const iconMap = { + warning: "AlertDiamond", + error: "AlertTriangle" +}; + +const buttonMap = { + confirmation: [{ + variant: "secondary", + treatment: "outline", + label: "Remind me later" + }, { + variant: "accent", + treatment: "fill", + label: "Enable" + }], + information: [{ + variant: "secondary", + treatment: "outline", + label: "No, thanks" + },{ + variant: "secondary", + treatment: "outline", + label: "Remind me later" + }, { + variant: "primary", + treatment: "fill", + label: "Rate now" + }], + destructive: [{ + variant: "secondary", + treatment: "outline", + label: "Cancel" + }, { + variant: "negative", + treatment: "fill", + label: "Delete" + }], + warning: [{ + variant: "secondary", + treatment: "outline", + label: "Cancel" + }, { + variant: "primary", + treatment: "fill", + label: "Continue" + }], + error: [{ + variant: "secondary", + treatment: "outline", + label: "Cancel" + }, { + variant: "primary", + treatment: "fill", + label: "Continue" + }], +}; + export const Dialog = ({ rootClass = "spectrum-AlertDialog", heading, content, customClasses = [], - buttons, variant, - icon = false, + hasVerticalButtons, id = getRandomId("alertdialog"), customStyles = {}, } = {}, context = {}) => { @@ -26,7 +81,7 @@ export const Dialog = ({
    ({ ...a, [c]: true }), {}), })} id=${ifDefined(id)} @@ -38,20 +93,21 @@ export const Dialog = ({ >
    -

    ${heading}

    - ${when(icon, () => Icon({ + ${when(iconMap[variant], () => Icon({ size: "m", - iconName: "Alert", + iconName: iconMap[variant], setName: "workflow", customClasses: [`${rootClass}-icon`], }, context))} +

    ${heading}

    - ${Divider({ - horizontal: true, - customClasses: [`${rootClass}-divider`], - }, context)}
    ${content}
    - ${ButtonGroup({ items: buttons }, context)} +
    + ${ButtonGroup({ + items: buttonMap[variant], + vertical: hasVerticalButtons, + }, context)} +
    `; @@ -59,7 +115,6 @@ export const Dialog = ({ export const Template = ({ isOpen = true, - customModalStyles = {}, skipWrapper = false, ...args } = {}, context = {}) => { @@ -68,7 +123,6 @@ export const Template = ({ content: [ Dialog(args, context) ], - customStyles: customModalStyles, skipWrapper, }, context); }; diff --git a/components/asset/CHANGELOG.md b/components/asset/CHANGELOG.md index aacdb69b1a7..b68e82c60ef 100644 --- a/components/asset/CHANGELOG.md +++ b/components/asset/CHANGELOG.md @@ -1,5 +1,12 @@ # Change log +## 8.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + ## 7.2.0 ### Minor Changes diff --git a/components/asset/dist/metadata.json b/components/asset/dist/metadata.json index 306c123b1b6..fd0baac95cd 100644 --- a/components/asset/dist/metadata.json +++ b/components/asset/dist/metadata.json @@ -10,34 +10,13 @@ ".spectrum-Asset-folderOutline", ".spectrum-Asset-image" ], - "modifiers": [ - "--mod-asset-file-background-color", - "--mod-asset-folder-background-color", - "--mod-asset-icon-margin", - "--mod-asset-icon-max-width", - "--mod-asset-icon-min-width", - "--mod-asset-icon-outline-color" - ], - "component": [ - "--spectrum-asset-file-background", - "--spectrum-asset-file-background-color", - "--spectrum-asset-file-outline", - "--spectrum-asset-folder-background", - "--spectrum-asset-folder-background-color", - "--spectrum-asset-folder-outline", - "--spectrum-asset-icon-outline-color" - ], + "modifiers": [], + "component": [], "global": [ - "--spectrum-animation-duration-100", "--spectrum-gray-200", "--spectrum-gray-25", "--spectrum-gray-500" ], - "system-theme": [ - "--system-asset-file-background-color", - "--system-asset-folder-background-color", - "--system-asset-icon-outline-color" - ], "passthroughs": [], - "high-contrast": ["--highcontrast-asset-icon-background-color"] + "high-contrast": [] } diff --git a/components/asset/index.css b/components/asset/index.css index abf5d42572f..b283a1c58b0 100644 --- a/components/asset/index.css +++ b/components/asset/index.css @@ -11,14 +11,7 @@ * governing permissions and limitations under the License. */ -@import "./themes/spectrum-two.css"; - .spectrum-Asset { - --spectrum-asset-folder-background: var(--highcontrast-asset-icon-background-color, var(--mod-asset-folder-background-color, var(--spectrum-asset-folder-background-color))); - --spectrum-asset-file-background: var(--highcontrast-asset-icon-background-color, var(--mod-asset-file-background-color, var(--spectrum-asset-file-background-color))); - --spectrum-asset-folder-outline: var(--mod-asset-icon-outline-color, var(--spectrum-asset-icon-outline-color)); - --spectrum-asset-file-outline: var(--mod-asset-icon-outline-color, var(--spectrum-asset-icon-outline-color)); - display: flex; align-items: center; justify-content: center; @@ -31,34 +24,27 @@ max-inline-size: 100%; max-block-size: 100%; object-fit: contain; - transition: opacity var(--spectrum-animation-duration-100); } .spectrum-Asset-folder, .spectrum-Asset-file { - inline-size: clamp(var(--mod-asset-icon-min-width, 48px), 100%, var(--mod-asset-icon-max-width, 80px)); + inline-size: clamp(48px, 100%, 80px); block-size: 100%; - margin: var(--mod-asset-icon-margin, 20px); + margin: 20px; } .spectrum-Asset-folderBackground { - fill: var(--spectrum-asset-folder-background); + fill: var(--spectrum-gray-200); } .spectrum-Asset-fileBackground { - fill: var(--spectrum-asset-file-background); + fill: var(--spectrum-gray-25); } .spectrum-Asset-folderOutline { - fill: var(--spectrum-asset-folder-outline); + fill: var(--spectrum-gray-500); } .spectrum-Asset-fileOutline { - fill: var(--spectrum-asset-file-outline); -} - -@media (forced-colors: active) { - .spectrum-Asset { - --highcontrast-asset-icon-background-color: currentColor; - } + fill: var(--spectrum-gray-500); } diff --git a/components/asset/package.json b/components/asset/package.json index 3a0a81666ec..d1e54ab6159 100644 --- a/components/asset/package.json +++ b/components/asset/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/asset", - "version": "7.2.0", + "version": "8.0.0-next.0", "description": "The Spectrum CSS asset component", "license": "Apache-2.0", "author": "Adobe", @@ -19,14 +19,12 @@ "./package.json": "./package.json", "./dist/*": "./dist/*", "./index.css": "./dist/index.css", - "./index-*.css": "./dist/index-*.css", "./metadata.json": "./dist/metadata.json", - "./themes/*": "./dist/themes/*", "./stories/*": "./stories/*" }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/tokens": ">=16.0.1" + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/tokens": { @@ -34,7 +32,7 @@ } }, "devDependencies": { - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/asset/stories/asset.stories.js b/components/asset/stories/asset.stories.js index 927c1009aad..01bbe81fad3 100644 --- a/components/asset/stories/asset.stories.js +++ b/components/asset/stories/asset.stories.js @@ -38,7 +38,11 @@ export default { parameters: { packageJson, metadata, + status: { + type: "migrated", + }, }, + tags: ["migrated"], }; export const Default = AssetGroup.bind({}); diff --git a/components/asset/stories/template.js b/components/asset/stories/template.js index c32f792cd49..795c346c508 100644 --- a/components/asset/stories/template.js +++ b/components/asset/stories/template.js @@ -5,9 +5,6 @@ import { ifDefined } from "lit/directives/if-defined.js"; import { styleMap } from "lit/directives/style-map.js"; import "../index.css"; -import "../themes/spectrum.css"; -/* Must be imported last */ -import "../themes/express.css"; export const Template = ({ rootClass = "spectrum-Asset", diff --git a/components/asset/themes/express.css b/components/asset/themes/express.css deleted file mode 100644 index 9fd550418f2..00000000000 --- a/components/asset/themes/express.css +++ /dev/null @@ -1,16 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--express */ - -@import "./spectrum.css"; diff --git a/components/asset/themes/spectrum-two.css b/components/asset/themes/spectrum-two.css deleted file mode 100644 index 5eda732011b..00000000000 --- a/components/asset/themes/spectrum-two.css +++ /dev/null @@ -1,20 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -@container style(--system: spectrum) { - .spectrum-Asset { - --spectrum-asset-folder-background-color: var(--spectrum-gray-200); - --spectrum-asset-file-background-color: var(--spectrum-gray-25); - --spectrum-asset-icon-outline-color: var(--spectrum-gray-500); - } -} diff --git a/components/asset/themes/spectrum.css b/components/asset/themes/spectrum.css deleted file mode 100644 index 8b2b12ee379..00000000000 --- a/components/asset/themes/spectrum.css +++ /dev/null @@ -1,24 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--legacy */ - -@import "./spectrum-two.css"; - -@container style(--system: legacy) { - .spectrum-Asset { - --spectrum-asset-folder-background-color: var(--spectrum-gray-300); - --spectrum-asset-file-background-color: var(--spectrum-gray-50); - --spectrum-asset-icon-outline-color: var(--spectrum-gray-500); - } -} diff --git a/components/assetcard/CHANGELOG.md b/components/assetcard/CHANGELOG.md index 20009d901d0..273b735f02b 100644 --- a/components/assetcard/CHANGELOG.md +++ b/components/assetcard/CHANGELOG.md @@ -1,5 +1,35 @@ # Change log +## 6.0.0-next.2 + +### Patch Changes + +📝 [#4113](https://github.com/adobe/spectrum-css/pull/4113) [`cf4fc1a`](https://github.com/adobe/spectrum-css/commit/cf4fc1a01d23ba810f45a903ecc29a5c8aae33d1) Thanks [@castastrophe](https://github.com/castastrophe)! + +## Minor linting fixes + +- Removed unused custom properties across multiple components +- Fixed color function notation by converting `rgba()` to `rgb()` where appropriate +- Removed duplicate custom property declarations +- Fixed deprecated CSS properties (e.g., `word-wrap` → `overflow-wrap`) +- Removed unnecessary stylelint-disable comments + +_No visual or functional changes to components._ + +## 6.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + +## 6.0.0-next.0 + +### Patch Changes + +- Updated dependencies []: + - @spectrum-css/checkbox@11.0.0-next.0 + ## 5.2.0 ### Minor Changes diff --git a/components/assetcard/dist/metadata.json b/components/assetcard/dist/metadata.json index 1c86dc47523..6e7fe700c4b 100644 --- a/components/assetcard/dist/metadata.json +++ b/components/assetcard/dist/metadata.json @@ -2,13 +2,15 @@ "sourceFile": "index.css", "selectors": [ ".spectrum-AssetCard", + ".spectrum-AssetCard .spectrum-AssetCard-selectionIndicator", ".spectrum-AssetCard .spectrum-AssetCard-selectionOrder", + ".spectrum-AssetCard .spectrum-Checkbox-box:before", ".spectrum-AssetCard--checkboxSelection .spectrum-AssetCard-selectionIndicator", ".spectrum-AssetCard--checkboxSelection .spectrum-AssetCard-selectionIndicator .spectrum-AssetCard-selectionOrder", ".spectrum-AssetCard--checkboxSelection.is-selected .spectrum-AssetCard-selectionIndicator", ".spectrum-AssetCard--checkboxSelection:focus-visible .spectrum-AssetCard-selectionIndicator", ".spectrum-AssetCard--checkboxSelection:hover .spectrum-AssetCard-selectionIndicator", - ".spectrum-AssetCard--highlightSelection.is-selected .spectrum-AssetCard-asset", + ".spectrum-AssetCard--highlightSelection:where(.is-selected) .spectrum-AssetCard-asset", ".spectrum-AssetCard--orderedSelection .spectrum-AssetCard-selectionIndicator", ".spectrum-AssetCard--orderedSelection .spectrum-AssetCard-selectionIndicator .spectrum-AssetCard-checkbox", ".spectrum-AssetCard--orderedSelection.is-selected .spectrum-AssetCard-selectionIndicator", @@ -23,172 +25,77 @@ ".spectrum-AssetCard-selectionOrder", ".spectrum-AssetCard-selectionOverlay", ".spectrum-AssetCard-title", - ".spectrum-AssetCard.is-drop-target .spectrum-AssetCard-assetContainer:after", + ".spectrum-AssetCard.is-drop-target", ".spectrum-AssetCard.is-drop-target .spectrum-AssetCard-selectionOverlay", - ".spectrum-AssetCard.is-drop-target:active .spectrum-AssetCard-assetContainer:after", - ".spectrum-AssetCard.is-drop-target:hover .spectrum-AssetCard-assetContainer:after", - ".spectrum-AssetCard.is-selected .spectrum-AssetCard-assetContainer:after", + ".spectrum-AssetCard.is-drop-target:active", + ".spectrum-AssetCard.is-drop-target:hover", + ".spectrum-AssetCard.is-selected", ".spectrum-AssetCard.is-selected .spectrum-AssetCard-selectionOverlay", - ".spectrum-AssetCard.is-selected .spectrum-Checkbox-box:before", - ".spectrum-AssetCard.is-selected:active .spectrum-AssetCard-assetContainer:after", - ".spectrum-AssetCard.is-selected:hover .spectrum-AssetCard-assetContainer:after", - ".spectrum-AssetCard:active .spectrum-AssetCard-assetContainer:after", - ".spectrum-AssetCard:focus-visible .spectrum-AssetCard-assetContainer:after", + ".spectrum-AssetCard.is-selected:active", + ".spectrum-AssetCard.is-selected:hover", + ".spectrum-AssetCard:active", + ".spectrum-AssetCard:focus-visible", ".spectrum-AssetCard:focus-visible .spectrum-AssetCard-assetContainer:before", - ".spectrum-AssetCard:focus-visible .spectrum-Checkbox-box:before", - ".spectrum-AssetCard:hover .spectrum-AssetCard-assetContainer:after", - ".spectrum-AssetCard:hover .spectrum-Checkbox-box:before", + ".spectrum-AssetCard:hover", ".spectrum-AssetCard:lang(ja)", ".spectrum-AssetCard:lang(ko)", - ".spectrum-AssetCard:lang(zh)" - ], - "modifiers": [ - "--mod-assectcard-border-color-selected-down", - "--mod-assectcard-focus-indicator-color", - "--mod-assetcard-asset-animation-duration", - "--mod-assetcard-asset-container-border-size", - "--mod-assetcard-asset-size", - "--mod-assetcard-background-color", - "--mod-assetcard-border-color", - "--mod-assetcard-border-color-down", - "--mod-assetcard-border-color-hover", - "--mod-assetcard-border-color-selected", - "--mod-assetcard-border-color-selected-hover", - "--mod-assetcard-border-radius", - "--mod-assetcard-content-font-family", - "--mod-assetcard-content-font-size", - "--mod-assetcard-content-font-style", - "--mod-assetcard-content-font-weight", - "--mod-assetcard-content-letter-spacing", - "--mod-assetcard-content-line-height", - "--mod-assetcard-content-margin-block-start", - "--mod-assetcard-content-text-color", - "--mod-assetcard-focus-indicator-thickness", - "--mod-assetcard-focus-ring-border-radius", - "--mod-assetcard-focus-ring-gap", - "--mod-assetcard-header-content-font-family", - "--mod-assetcard-header-content-font-size", - "--mod-assetcard-header-content-font-stlye", - "--mod-assetcard-header-content-font-weight", - "--mod-assetcard-header-content-letter-spacing", - "--mod-assetcard-header-content-line-height", - "--mod-assetcard-header-content-text-color", - "--mod-assetcard-header-margin-block-start", - "--mod-assetcard-overlay-background-color", - "--mod-assetcard-selectionindicator-background-color-default", - "--mod-assetcard-selectionindicator-background-color-ordered", - "--mod-assetcard-selectionindicator-border-radius", - "--mod-assetcard-selectionindicator-color", - "--mod-assetcard-selectionindicator-font-size", - "--mod-assetcard-selectionindicator-font-weight", - "--mod-assetcard-selectionindicator-margin", - "--mod-assetcard-selectionindicator-size", - "--mod-assetcard-title-font-family", - "--mod-assetcard-title-font-size", - "--mod-assetcard-title-font-style", - "--mod-assetcard-title-font-weight", - "--mod-assetcard-title-letter-spacing", - "--mod-assetcard-title-line-height", - "--mod-assetcard-title-text-color" + ".spectrum-AssetCard:lang(zh)", + ".spectrum-AssetCard:where(.spectrum-AssetCard--orderedSelection) .spectrum-AssetCard-selectionIndicator" ], + "modifiers": [], "component": [ - "--spectrum-assetcard-asset-animation-duration", - "--spectrum-assetcard-asset-container-border-size", "--spectrum-assetcard-asset-size", - "--spectrum-assetcard-background-color", "--spectrum-assetcard-border-color", - "--spectrum-assetcard-border-color-down", - "--spectrum-assetcard-border-color-hover", "--spectrum-assetcard-border-color-selected", "--spectrum-assetcard-border-color-selected-down", "--spectrum-assetcard-border-color-selected-hover", - "--spectrum-assetcard-border-radius", - "--spectrum-assetcard-content-font-family", - "--spectrum-assetcard-content-font-size", - "--spectrum-assetcard-content-font-style", - "--spectrum-assetcard-content-font-weight", - "--spectrum-assetcard-content-letter-spacing", - "--spectrum-assetcard-content-line-height", - "--spectrum-assetcard-content-margin-block-start", - "--spectrum-assetcard-content-text-color", - "--spectrum-assetcard-focus-indicator-thickness", "--spectrum-assetcard-focus-ring-border-radius", - "--spectrum-assetcard-focus-ring-gap", - "--spectrum-assetcard-header-content-font-family", "--spectrum-assetcard-header-content-font-size", - "--spectrum-assetcard-header-content-font-style", - "--spectrum-assetcard-header-content-font-weight", - "--spectrum-assetcard-header-content-letter-spacing", - "--spectrum-assetcard-header-content-line-height", - "--spectrum-assetcard-header-content-text-color", - "--spectrum-assetcard-header-margin-block-start", - "--spectrum-assetcard-overlay-background-color", - "--spectrum-assetcard-selectionindicator-background-color-default", "--spectrum-assetcard-selectionindicator-background-color-ordered", - "--spectrum-assetcard-selectionindicator-blur", - "--spectrum-assetcard-selectionindicator-border-radius", - "--spectrum-assetcard-selectionindicator-box-shadow-color", - "--spectrum-assetcard-selectionindicator-color", - "--spectrum-assetcard-selectionindicator-font-size", - "--spectrum-assetcard-selectionindicator-font-weight", "--spectrum-assetcard-selectionindicator-margin", - "--spectrum-assetcard-selectionindicator-offset-y", - "--spectrum-assetcard-selectionindicator-size", - "--spectrum-assetcard-title-font-family", - "--spectrum-assetcard-title-font-size", - "--spectrum-assetcard-title-font-style", - "--spectrum-assetcard-title-font-weight", - "--spectrum-assetcard-title-letter-spacing", - "--spectrum-assetcard-title-line-height", - "--spectrum-assetcard-title-text-color" + "--spectrum-assetcard-title-font-size" ], "global": [ "--spectrum-animation-duration-100", "--spectrum-assestcard-focus-indicator-color", + "--spectrum-blue-1000", + "--spectrum-blue-900", "--spectrum-body-cjk-font-style", "--spectrum-body-cjk-font-weight", "--spectrum-body-cjk-line-height", + "--spectrum-body-line-height", "--spectrum-body-sans-serif-font-weight", - "--spectrum-bold-font-weight", + "--spectrum-border-width-100", "--spectrum-card-selection-background-size", "--spectrum-cjk-font-family-stack", "--spectrum-cjk-letter-spacing", "--spectrum-corner-radius-100", "--spectrum-default-font-style", + "--spectrum-drop-shadow-blur", + "--spectrum-drop-shadow-color-200", + "--spectrum-drop-shadow-y-200", + "--spectrum-focus-indicator-gap", "--spectrum-focus-indicator-thickness", - "--spectrum-font-size-400", "--spectrum-gray-500", "--spectrum-gray-600", "--spectrum-gray-700", "--spectrum-gray-75", - "--spectrum-gray-75-rgb", "--spectrum-gray-900", - "--spectrum-heading-cjk-font-style", "--spectrum-heading-cjk-font-weight", "--spectrum-heading-cjk-line-height", "--spectrum-heading-cjk-size-xs", + "--spectrum-heading-line-height", "--spectrum-heading-sans-serif-font-weight", - "--spectrum-line-height-100", - "--spectrum-line-height-200", + "--spectrum-heading-size-s", + "--spectrum-heading-size-xs", + "--spectrum-heading-size-xxs", "--spectrum-sans-font-family-stack", "--spectrum-spacing-300", "--spectrum-spacing-75", - "--spectrum-transparent-black-300", + "--spectrum-stack-item-selected-background-color-emphasized", + "--spectrum-transparent-black-25", "--spectrum-white" ], - "system-theme": [ - "--system-asset-card-background-color", - "--system-asset-card-overlay-background-color", - "--system-asset-card-selectionindicator-background-color-default", - "--system-asset-card-selectionindicator-box-shadow-color" - ], "passthroughs": [], - "high-contrast": [ - "--highcontrast-assectcard-border-color-selected-down", - "--highcontrast-assetcard-border-color-hover", - "--highcontrast-assetcard-border-color-selected", - "--highcontrast-assetcard-border-color-selected-hover", - "--highcontrast-assetcard-selectionindicator-background-color-ordered", - "--highcontrast-assetcard-selectionindicator-color" - ] + "high-contrast": [] } diff --git a/components/assetcard/index.css b/components/assetcard/index.css index 26881a3f45f..7c698cb0302 100644 --- a/components/assetcard/index.css +++ b/components/assetcard/index.css @@ -11,117 +11,77 @@ * governing permissions and limitations under the License. */ -@import "./themes/spectrum-two.css"; - /* outer container, unstyled */ .spectrum-AssetCard { /* todo: this isn't quite the size from the XD file as 232px is not a size token, so we use 224px */ --spectrum-assetcard-asset-size: 224px; - --spectrum-assetcard-asset-animation-duration: var(--spectrum-animation-duration-100); - --spectrum-assetcard-asset-container-border-size: 1px; - --spectrum-assetcard-header-margin-block-start: var(--spectrum-spacing-300); - - --spectrum-assetcard-border-radius: var(--spectrum-corner-radius-100); - --spectrum-assetcard-border-color: transparent; - --spectrum-assetcard-border-color-hover: var(--spectrum-gray-500); - --spectrum-assetcard-border-color-down: var(--spectrum-gray-600); - - --spectrum-assetcard-focus-ring-gap: 5px; - --spectrum-assetcard-focus-indicator-thickness: var(--spectrum-focus-indicator-thickness); - - /* selection indicator - checkbox or number */ - --spectrum-assetcard-selectionindicator-size: var(--spectrum-card-selection-background-size); - --spectrum-assetcard-selectionindicator-border-radius: var(--spectrum-corner-radius-100); - --spectrum-assetcard-selectionindicator-offset-y: 4px; - --spectrum-assetcard-selectionindicator-blur: 6px; - --spectrum-assetcard-selectionindicator-color: var(--spectrum-white); - --spectrum-assetcard-selectionindicator-font-weight: var(--spectrum-bold-font-weight); - --spectrum-assetcard-selectionindicator-font-size: var(--spectrum-font-size-400); - - /* title */ - --spectrum-assetcard-title-text-color: var(--spectrum-gray-900); - --spectrum-assetcard-title-font-family: var(--spectrum-sans-font-family-stack); - --spectrum-assetcard-title-font-weight: var(--spectrum-heading-sans-serif-font-weight); - --spectrum-assetcard-title-font-style: var(--spectrum-default-font-style); - --spectrum-assetcard-title-line-height: var(--spectrum-line-height-100); - --spectrum-assetcard-title-letter-spacing: 0; - - /* header content */ - --spectrum-assetcard-header-content-text-color: var(--spectrum-gray-900); - --spectrum-assetcard-header-content-font-family: var(--spectrum-sans-font-family-stack); - --spectrum-assetcard-header-content-font-weight: var(--spectrum-body-sans-serif-font-weight); - --spectrum-assetcard-header-content-font-style: var(--spectrum-default-font-style); - --spectrum-assetcard-header-content-line-height: var(--spectrum-line-height-200); - --spectrum-assetcard-header-content-letter-spacing: 0; - - /* content */ - --spectrum-assetcard-content-text-color: var(--spectrum-gray-700); - --spectrum-assetcard-content-font-family: var(--spectrum-sans-font-family-stack); - --spectrum-assetcard-content-font-weight: var(--spectrum-body-sans-serif-font-weight); - --spectrum-assetcard-content-font-style: var(--spectrum-default-font-style); - --spectrum-assetcard-content-line-height: var(--spectrum-line-height-200); - --spectrum-assetcard-content-letter-spacing: 0; - - --spectrum-assetcard-content-margin-block-start: var(--spectrum-spacing-75); + + --spectrum-assetcard-border-color: var(--spectrum-transparent-black-25); /* contain selection indicator */ position: relative; - display: flex; flex-direction: column; - - inline-size: var(--mod-assetcard-asset-size, var(--spectrum-assetcard-asset-size)); - + inline-size: var(--spectrum-assetcard-asset-size); + font-family: var(--spectrum-sans-font-family-stack); + font-style: var(--spectrum-default-font-style); + font-weight: var(--spectrum-body-sans-serif-font-weight); + outline: none; cursor: pointer; &:lang(zh), &:lang(ja), &:lang(ko) { - --spectrum-assetcard-title-font-family: var(--spectrum-cjk-font-family-stack); - --spectrum-assetcard-title-font-style: var(--spectrum-heading-cjk-font-style); - --spectrum-assetcard-title-font-weight: var(--spectrum-heading-cjk-font-weight); - --spectrum-assetcard-title-font-size: var(--spectrum-heading-cjk-size-xs); - --spectrum-assetcard-title-line-height: var(--spectrum-heading-cjk-line-height); - --spectrum-assetcard-title-letter-spacing: var(--spectrum-cjk-letter-spacing); - - --spectrum-assetcard-header-content-font-family: var(--spectrum-cjk-font-family-stack); - --spectrum-assetcard-header-content-font-weight: var(--spectrum-body-cjk-font-weight); - --spectrum-assetcard-header-content-line-height: var(--spectrum-body-cjk-line-height); - --spectrum-assetcard-header-content-font-style: var(--spectrum-body-cjk-font-style); - --spectrum-assetcard-header-content-letter-spacing: var(--spectrum-cjk-letter-spacing); - - --spectrum-assetcard-content-font-family: var(--spectrum-cjk-font-family-stack); - --spectrum-assetcard-content-font-weight: var(--spectrum-body-cjk-font-weight); - --spectrum-assetcard-content-line-height: var(--spectrum-body-cjk-line-height); - --spectrum-assetcard-content-font-style: var(--spectrum-body-cjk-font-style); - --spectrum-assetcard-content-letter-spacing: var(--spectrum-cjk-letter-spacing); + --spectrum-sans-font-family-stack: var(--spectrum-cjk-font-family-stack); + --spectrum-default-font-style: var(--spectrum-body-cjk-font-style); + + --spectrum-heading-sans-serif-font-weight: var(--spectrum-heading-cjk-font-weight); + --spectrum-heading-size-xs: var(--spectrum-heading-cjk-size-xs); + --spectrum-heading-line-height: var(--spectrum-heading-cjk-line-height); + + --spectrum-body-sans-serif-font-weight: var(--spectrum-body-cjk-font-weight); + --spectrum-body-line-height: var(--spectrum-body-cjk-line-height); + + letter-spacing: var(--spectrum-cjk-letter-spacing); } &.is-selected, &:hover, &:focus-visible { - .spectrum-AssetCard-assetContainer::after { - border-color: var(--highcontrast-assetcard-border-color-hover, var(--mod-assetcard-border-color-hover, var(--spectrum-assetcard-border-color-hover))); - } - - /* adds hover to checkbox when spectrum-AssetCard card receives hover */ - .spectrum-Checkbox-box::before { - border-color: var(--highcontrast-assetcard-border-color-hover, var(--mod-assetcard-border-color-hover, var(--spectrum-assetcard-border-color-hover))); - } + --spectrum-assetcard-border-color: var(--spectrum-gray-500); } &:active { - .spectrum-AssetCard-assetContainer::after { - border-color: var(--mod-assetcard-border-color-down, var(--spectrum-assetcard-border-color-down)); - } + --spectrum-assetcard-border-color: var(--spectrum-gray-600); } - outline: none; + &:focus-visible .spectrum-AssetCard-assetContainer::before { + opacity: 1; + } - &:focus-visible { - .spectrum-AssetCard-assetContainer::before { - opacity: 1; + /* base selection styles shared by every selection mode */ + /* drop target looks identical to selected */ + &.is-drop-target, + &.is-selected { + --spectrum-assetcard-border-color: var(--spectrum-assetcard-border-color-selected, var(--spectrum-blue-900)); + + .spectrum-AssetCard-selectionOverlay { + /* was: rgb(27 127 245 / 10%); */ + background-color: color-mix(in sRGB, var(--spectrum-stack-item-selected-background-color-emphasized) 10%, transparent); + } + + &:hover { + --spectrum-assetcard-border-color: var(--spectrum-assetcard-border-color-selected-hover, var(--spectrum-blue-900)); } + + &:active { + --spectrum-assetcard-border-color: var(--spectrum-assetcard-border-color-selected-down, var(--spectrum-blue-1000)); + } + } + + /* Aligns checkbox color indicator with the border when spectrum-AssetCard card receives state */ + .spectrum-Checkbox-box::before { + border-color: var(--spectrum-assetcard-border-color); } } @@ -134,29 +94,29 @@ align-items: center; justify-content: center; - inline-size: var(--mod-assetcard-asset-size, var(--spectrum-assetcard-asset-size)); - block-size: var(--mod-assetcard-asset-size, var(--spectrum-assetcard-asset-size)); + inline-size: var(--spectrum-assetcard-asset-size); + block-size: var(--spectrum-assetcard-asset-size); - border-radius: var(--mod-assetcard-border-radius, var(--spectrum-assetcard-border-radius)); + border-radius: var(--spectrum-corner-radius-100); - background-color: var(--mod-assetcard-background-color, var(--spectrum-assetcard-background-color)); + background-color: var(--spectrum-gray-75); - transition: border var(--mod-assetcard-asset-animation-duration, var(--spectrum-assetcard-asset-animation-duration)) ease-in-out; + transition: border var(--spectrum-animation-duration-100) ease-in-out; /* focus indicator */ &::before { content: ""; position: absolute; - inset: calc(-1 * var(--mod-assetcard-focus-ring-gap, var(--spectrum-assetcard-focus-ring-gap))); + inset: calc(-1 * var(--spectrum-focus-indicator-gap)); - border: var(--mod-assetcard-focus-indicator-thickness, var(--spectrum-assetcard-focus-indicator-thickness)) solid var(--mod-assectcard-focus-indicator-color, var(--spectrum-assestcard-focus-indicator-color)); + border: var(--spectrum-focus-indicator-thickness) solid var(--spectrum-assestcard-focus-indicator-color); - border-radius: var(--mod-assetcard-focus-ring-border-radius, var(--spectrum-assetcard-focus-ring-border-radius)); + border-radius: var(--spectrum-assetcard-focus-ring-border-radius); opacity: 0; pointer-events: none; - transition: opacity var(--mod-assetcard-asset-animation-duration, var(--spectrum-assetcard-asset-animation-duration)) ease-in-out; + transition: opacity var(--spectrum-animation-duration-100) ease-in-out; } /* border */ @@ -166,8 +126,8 @@ inset: 0; z-index: 3; - border: var(--mod-assetcard-asset-container-border-size, var(--spectrum-assetcard-asset-container-border-size)) solid var(--mod-assetcard-border-color, var(--spectrum-assetcard-border-color)); - border-radius: calc(var(--mod-assetcard-border-radius, var(--spectrum-assetcard-border-radius)) - 1px); + border: var(--spectrum-border-width-100) solid var(--spectrum-assetcard-border-color); + border-radius: calc(var(--spectrum-corner-radius-100) - var(--spectrum-border-width-100)); } } @@ -179,10 +139,19 @@ block-size: 100%; transition: - inline-size var(--mod-assetcard-asset-animation-duration, var(--spectrum-assetcard-asset-animation-duration)) ease-in-out, - block-size var(--mod-assetcard-asset-animation-duration, var(--spectrum-assetcard-asset-animation-duration)) ease-in-out; + inline-size var(--spectrum-animation-duration-100) ease-in-out, + block-size var(--spectrum-animation-duration-100) ease-in-out; - border-radius: calc(var(--mod-assetcard-border-radius, var(--spectrum-assetcard-border-radius)) - 1px); + border-radius: calc(var(--spectrum-corner-radius-100) - var(--spectrum-border-width-100)); +} + +/* highlight */ +.spectrum-AssetCard--highlightSelection:where(.is-selected) .spectrum-AssetCard-asset { + inline-size: 90%; + block-size: 90%; + + /* no radius, otherwise square assets get rounded */ + border-radius: 0; } /* header area, contains the header and optional content */ @@ -192,33 +161,27 @@ align-items: center; /* space between the asset and the header, place it on the header so header can be optional */ - margin-block-start: var(--mod-assetcard-header-margin-block-start, var(--spectrum-assetcard-header-margin-block-start)); + margin-block-start: var(--spectrum-spacing-300); } /* bold title */ .spectrum-AssetCard-title { flex-grow: 1; - color: var(--mod-assetcard-title-text-color, var(--spectrum-assetcard-title-text-color)); + color: var(--spectrum-gray-900); - font-family: var(--mod-assetcard-title-font-family, var(--spectrum-assetcard-title-font-family)); - font-weight: var(--mod-assetcard-title-font-weight, var(--spectrum-assetcard-title-font-weight)); - font-size: var(--mod-assetcard-title-font-size, var(--spectrum-assetcard-title-font-size)); - line-height: var(--mod-assetcard-title-line-height, var(--spectrum-assetcard-title-line-height)); - font-style: var(--mod-assetcard-title-font-style, var(--spectrum-assetcard-title-font-style)); - letter-spacing: var(--mod-assetcard-title-letter-spacing, var(--spectrum-assetcard-title-letter-spacing)); + font-weight: var(--spectrum-heading-sans-serif-font-weight); + font-size: var(--spectrum-assetcard-title-font-size, var(--spectrum-heading-size-xs)); + line-height: var(--spectrum-heading-line-height); } /* optional content placed to the right of the title */ .spectrum-AssetCard-headerContent { - color: var(--mod-assetcard-header-content-text-color, var(--spectrum-assetcard-header-content-text-color)); - - font-family: var(--mod-assetcard-header-content-font-family, var(--spectrum-assetcard-header-content-font-family)); - font-size: var(--mod-assetcard-header-content-font-size, var(--spectrum-assetcard-header-content-font-size)); - font-weight: var(--mod-assetcard-header-content-font-weight, var(--spectrum-assetcard-header-content-font-weight)); - line-height: var(--mod-assetcard-header-content-line-height, var(--spectrum-assetcard-header-content-line-height)); - font-style: var(--mod-assetcard-header-content-font-stlye, var(--spectrum-assetcard-header-content-font-style)); - letter-spacing: var(--mod-assetcard-header-content-letter-spacing, var(--spectrum-assetcard-header-content-letter-spacing)); + color: var(--spectrum-gray-900); + + font-size: var(--spectrum-assetcard-header-content-font-size, var(--spectrum-heading-size-xxs)); + font-weight: var(--spectrum-body-sans-serif-font-weight); + line-height: var(--spectrum-body-line-height); } /* content area, the last thing in the card */ @@ -226,16 +189,9 @@ flex-grow: 1; /* space between the content and the header, place it on the content so content can be optional */ - margin-block-start: var(--mod-assetcard-content-margin-block-start, var(--spectrum-assetcard-content-margin-block-start)); - - color: var(--mod-assetcard-content-text-color, var(--spectrum-assetcard-content-text-color)); + margin-block-start: var(--spectrum-spacing-75); - font-family: var(--mod-assetcard-content-font-family, var(--spectrum-assetcard-content-font-family)); - font-size: var(--mod-assetcard-content-font-size, var(--spectrum-assetcard-content-font-size)); - font-weight: var(--mod-assetcard-content-font-weight, var(--spectrum-assetcard-content-font-weight)); - line-height: var(--mod-assetcard-content-line-height, var(--spectrum-assetcard-content-line-height)); - font-style: var(--mod-assetcard-content-font-style, var(--spectrum-assetcard-content-font-style)); - letter-spacing: var(--mod-assetcard-content-letter-spacing, var(--spectrum-assetcard-content-letter-spacing)); + color: var(--spectrum-gray-700); } /* Selection styles */ @@ -247,34 +203,34 @@ background-color: transparent; pointer-events: none; - transition: background-color var(--mod-assetcard-asset-animation-duration, var(--spectrum-assetcard-asset-animation-duration)) ease-in-out; + transition: background-color var(--spectrum-animation-duration-100) ease-in-out; - border-radius: calc(var(--mod-assetcard-border-radius, var(--spectrum-assetcard-border-radius)) - 1px); + border-radius: calc(var(--spectrum-corner-radius-100) - 1px); } /* the checkbox or selection order indicator */ .spectrum-AssetCard-selectionIndicator { position: absolute; z-index: 2; - inset-inline-start: var(--mod-assetcard-selectionindicator-margin, var(--spectrum-assetcard-selectionindicator-margin)); - inset-block-start: var(--mod-assetcard-selectionindicator-margin, var(--spectrum-assetcard-selectionindicator-margin)); + inset-inline-start: var(--spectrum-assetcard-selectionindicator-margin); + inset-block-start: var(--spectrum-assetcard-selectionindicator-margin); display: none; align-items: center; justify-content: center; - inline-size: var(--mod-assetcard-selectionindicator-size, var(--spectrum-assetcard-selectionindicator-size)); - block-size: var(--mod-assetcard-selectionindicator-size, var(--spectrum-assetcard-selectionindicator-size)); + inline-size: var(--spectrum-card-selection-background-size); + block-size: var(--spectrum-card-selection-background-size); - border-radius: var(--mod-assetcard-selectionindicator-border-radius, var(--spectrum-assetcard-selectionindicator-border-radius)); + border-radius: var(--spectrum-corner-radius-100); - box-shadow: 0 var(--spectrum-assetcard-selectionindicator-offset-y) var(--spectrum-assetcard-selectionindicator-blur) var(--spectrum-assetcard-selectionindicator-box-shadow-color); + box-shadow: 0 var(--spectrum-drop-shadow-y-200) var(--spectrum-drop-shadow-blur) var(--spectrum-drop-shadow-color-200); - color: var(--highcontrast-assetcard-selectionindicator-color, var(--mod-assetcard-selectionindicator-color, var(--spectrum-assetcard-selectionindicator-color))); - font-weight: var(--mod-assetcard-selectionindicator-font-weight, var(--spectrum-assetcard-selectionindicator-font-weight)); - font-size: var(--mod-assetcard-selectionindicator-font-size, var(--spectrum-assetcard-selectionindicator-font-size)); + color: var(--spectrum-white); + font-weight: var(--spectrum-heading-sans-serif-font-weight); + font-size: var(--spectrum-heading-size-s); - transition: opacity var(--mod-assetcard-asset-animation-duration, var(--spectrum-assetcard-asset-animation-duration)) ease-in-out; + transition: opacity var(--spectrum-animation-duration-100) ease-in-out; background-color: transparent; } @@ -282,48 +238,10 @@ line-height: 0; } -/* base selection styles shared by every selection mode */ -/* drop target looks identical to selected */ -.spectrum-AssetCard.is-drop-target, -.spectrum-AssetCard.is-selected { - .spectrum-AssetCard-assetContainer::after { - border-color: var(--highcontrast-assetcard-border-color-selected, var(--mod-assetcard-border-color-selected, var(--spectrum-assetcard-border-color-selected))); - } - - .spectrum-AssetCard-selectionOverlay { - background-color: var(--mod-assetcard-overlay-background-color, var(--spectrum-assetcard-overlay-background-color)); - } - - &:hover { - .spectrum-AssetCard-assetContainer::after { - border-color: var(--highcontrast-assetcard-border-color-selected-hover, var(--mod-assetcard-border-color-selected-hover, var(--spectrum-assetcard-border-color-selected-hover))); - } - } - - &:active { - .spectrum-AssetCard-assetContainer::after { - border-color: var(--highcontrast-assectcard-border-color-selected-down, var(--mod-assectcard-border-color-selected-down, var(--spectrum-assetcard-border-color-selected-down))); - } - } -} - -/* highlight */ -.spectrum-AssetCard--highlightSelection { - &.is-selected { - .spectrum-AssetCard-asset { - inline-size: 90%; - block-size: 90%; - - /* no radius, otherwise square assets get rounded */ - border-radius: 0; - } - } -} - /* with a checkbox */ .spectrum-AssetCard--checkboxSelection { .spectrum-AssetCard-selectionIndicator { - background-color: var(--mod-assetcard-selectionindicator-background-color-default, var(--spectrum-assetcard-selectionindicator-background-color-default)); + background-color: color-mix(in sRGB, var(--spectrum-gray-75) 90%, transparent); .spectrum-AssetCard-selectionOrder { display: none; @@ -343,29 +261,38 @@ /* with the little order flag that shows the selection order */ .spectrum-AssetCard--orderedSelection { .spectrum-AssetCard-selectionIndicator { - background-color: var(--highcontrast-assetcard-selectionindicator-background-color-ordered, var(--mod-assetcard-selectionindicator-background-color-ordered, var(--spectrum-assetcard-selectionindicator-background-color-ordered))); + background-color: var(--spectrum-assetcard-selectionindicator-background-color-ordered, var(--spectrum-blue-900)); .spectrum-AssetCard-checkbox { display: none; } } - &.is-selected { - .spectrum-AssetCard-selectionIndicator { - display: flex; - pointer-events: all; - } + &.is-selected .spectrum-AssetCard-selectionIndicator { + display: flex; + pointer-events: all; } } @media (forced-colors: active) { .spectrum-AssetCard { - --highcontrast-assetcard-border-color-hover: Highlight; - --highcontrast-assetcard-border-color-selected: Highlight; - --highcontrast-assetcard-border-color-selected-hover: Highlight; - --highcontrast-assectcard-border-color-selected-down: Highlight; - --highcontrast-assetcard-selectionindicator-background-color-ordered: Highlight; - --highcontrast-assetcard-selectionindicator-color: SelectedItemText; + --spectrum-assetcard-border-color-selected: Highlight; + --spectrum-assetcard-border-color-selected-hover: Highlight; + --spectrum-assetcard-border-color-selected-down: Highlight; + + &.is-selected, + &:hover, + &:focus-visible { + --spectrum-assetcard-border-color: Highlight; + } + + .spectrum-AssetCard-selectionIndicator { + color: SelectedItemText; + } + + &:where(.spectrum-AssetCard--orderedSelection) .spectrum-AssetCard-selectionIndicator { + background-color: Highlight; + } .spectrum-AssetCard-selectionOrder { /* prevents text backplate on displayed order number */ diff --git a/components/assetcard/package.json b/components/assetcard/package.json index 68f8df5a7a9..40f0fac63b9 100644 --- a/components/assetcard/package.json +++ b/components/assetcard/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/assetcard", - "version": "5.2.0", + "version": "6.0.0-next.2", "description": "The Spectrum CSS asset card component", "license": "Apache-2.0", "author": "Adobe", @@ -19,15 +19,13 @@ "./package.json": "./package.json", "./dist/*": "./dist/*", "./index.css": "./dist/index.css", - "./index-*.css": "./dist/index-*.css", "./metadata.json": "./dist/metadata.json", - "./themes/*": "./dist/themes/*", "./stories/*": "./stories/*" }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/checkbox": ">=10.0.0 <11.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/checkbox": ">=11.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/checkbox": { @@ -38,8 +36,8 @@ } }, "devDependencies": { - "@spectrum-css/checkbox": "10.2.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/checkbox": "11.0.0-next.2", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/assetcard/stories/assetcard.stories.js b/components/assetcard/stories/assetcard.stories.js index da97f55a889..4e876cb2f6f 100644 --- a/components/assetcard/stories/assetcard.stories.js +++ b/components/assetcard/stories/assetcard.stories.js @@ -96,7 +96,11 @@ export default { }, packageJson, metadata, + status: { + type: "unmigrated", + }, }, + tags: ["unmigrated"], }; export const Default = AssetCardGroup.bind({}); diff --git a/components/assetcard/stories/template.js b/components/assetcard/stories/template.js index 864fcd951b7..1b44be4e568 100644 --- a/components/assetcard/stories/template.js +++ b/components/assetcard/stories/template.js @@ -8,9 +8,6 @@ import { when } from "lit/directives/when.js"; import { camelCase } from "lodash-es"; import "../index.css"; -import "../themes/spectrum.css"; -/* Must be imported last */ -import "../themes/express.css"; export const Template = ({ rootClass = "spectrum-AssetCard", diff --git a/components/assetcard/themes/express.css b/components/assetcard/themes/express.css deleted file mode 100644 index 0b95b3a3110..00000000000 --- a/components/assetcard/themes/express.css +++ /dev/null @@ -1,22 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--express */ - -@import "./spectrum.css"; - -@container style(--system: express) { - .spectrum-AssetCard { - --spectrum-assetcard-overlay-background-color: rgb(109 115 246 / 20%); - } -} diff --git a/components/assetcard/themes/spectrum-two.css b/components/assetcard/themes/spectrum-two.css deleted file mode 100644 index 392a0a25751..00000000000 --- a/components/assetcard/themes/spectrum-two.css +++ /dev/null @@ -1,21 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -@container style(--system: spectrum) { - .spectrum-AssetCard { - --spectrum-assetcard-overlay-background-color: rgb(27 127 245 / 10%); - --spectrum-assetcard-background-color: var(--spectrum-gray-75); - --spectrum-assetcard-selectionindicator-background-color-default: rgb(var(--spectrum-gray-75-rgb), 0.9); - --spectrum-assetcard-selectionindicator-box-shadow-color: var(--spectrum-transparent-black-300); - } -} diff --git a/components/assetcard/themes/spectrum.css b/components/assetcard/themes/spectrum.css deleted file mode 100644 index 7c27603a92c..00000000000 --- a/components/assetcard/themes/spectrum.css +++ /dev/null @@ -1,25 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--legacy */ - -@import "./spectrum-two.css"; - -@container style(--system: legacy) { - .spectrum-AssetCard { - --spectrum-assetcard-overlay-background-color: rgb(27 127 245 / 10%); - --spectrum-assetcard-background-color: var(--spectrum-gray-200); - --spectrum-assetcard-selectionindicator-background-color-default: rgb(var(--spectrum-gray-100-rgb), 0.9); - --spectrum-assetcard-selectionindicator-box-shadow-color: var(--spectrum-transparent-black-200); - } -} diff --git a/components/assetlist/CHANGELOG.md b/components/assetlist/CHANGELOG.md index c0ed9590802..bcfdb831ffc 100644 --- a/components/assetlist/CHANGELOG.md +++ b/components/assetlist/CHANGELOG.md @@ -1,5 +1,28 @@ # Change log +## 9.0.0-next.2 + +### Major Changes + +📝 [#4014](https://github.com/adobe/spectrum-css/pull/4014) [`35c066b`](https://github.com/adobe/spectrum-css/commit/35c066b29c311b1bfcf4507075f13b41222ffc84) Thanks [@castastrophe](https://github.com/castastrophe)! + +This update removes the `dir` attribute polyfill (served via a PostCSS transform to compiled assets) as the fallback is no longer necessary. The`dir` attribute support is available in all supported browsers and has been tested to correctly inherit inside web component shadow DOMs. This is a breaking change **only** to those relying on the `dir` attribute being present for styling, however, the `:dir` pseudo will correctly inherit values from their containers. To correctly determine the `dir` value of a node using JavaScript, you can use `getComputedStyle(node).direction`. + +## 9.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + +## 9.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`a25e0a9`](https://github.com/adobe/spectrum-css/commit/a25e0a99e5a4736ab4e607e00739343101a2633b)]: + - @spectrum-css/icon@10.0.0-next.0 + - @spectrum-css/checkbox@11.0.0-next.0 + ## 8.3.0 ### Minor Changes @@ -12,7 +35,9 @@ Ensure accurate exports are present for each component. Specifically, adding `th ### Minor Changes -- [#3527](https://github.com/adobe/spectrum-css/pull/3527) [`5f1751c`](https://github.com/adobe/spectrum-css/commit/5f1751c82a5fe55ae0d999f5f50cfeca4c8a5c75) Thanks [@castastrophe](https://github.com/castastrophe)! - By updating the postcss-preset-env to the latest breaking change version, output for this component no longer injects the `.js-focus-within` and '[focus-within]` selectors for the focus-within polyfill. As this feature is not used in the SWC consumption, risk to the end user for this removal is low. +📝 [#3527](https://github.com/adobe/spectrum-css/pull/3527) [`5f1751c`](https://github.com/adobe/spectrum-css/commit/5f1751c82a5fe55ae0d999f5f50cfeca4c8a5c75) Thanks [@castastrophe](https://github.com/castastrophe)! + +By updating the postcss-preset-env to the latest breaking change version, output for this component no longer injects the `.js-focus-within` and '[focus-within]` selectors for the focus-within polyfill. As this feature is not used in the SWC consumption, risk to the end user for this removal is low. ## 8.1.0 diff --git a/components/assetlist/dist/metadata.json b/components/assetlist/dist/metadata.json index 011c28ee314..57d1970ac18 100644 --- a/components/assetlist/dist/metadata.json +++ b/components/assetlist/dist/metadata.json @@ -15,7 +15,6 @@ ".spectrum-AssetList-item.is-selected .spectrum-Checkbox", ".spectrum-AssetList-item.is-selected:focus", ".spectrum-AssetList-item.is-selected:hover", - ".spectrum-AssetList-item:before", ".spectrum-AssetList-item:focus .spectrum-Checkbox", ".spectrum-AssetList-item:focus-within:focus-visible", ".spectrum-AssetList-item:focus-within:focus-visible:before", @@ -24,55 +23,20 @@ ".spectrum-AssetList-itemChildIndicator", ".spectrum-AssetList-itemLabel", ".spectrum-AssetList-itemSelector", - ".spectrum-AssetList:dir(rtl)", - "[dir=\"rtl\"] .spectrum-AssetList" - ], - "modifiers": [ - "--mod-assetlist-border-color-key-focus", - "--mod-assetlist-child-indicator-animation", - "--mod-assetlist-item-animation", - "--mod-assetlist-item-background-color-down", - "--mod-assetlist-item-background-color-hover", - "--mod-assetlist-item-background-color-selected", - "--mod-assetlist-item-background-color-selected-hover", - "--mod-assetlist-item-border-radius", - "--mod-assetlist-item-font-size", - "--mod-assetlist-item-font-weight", - "--mod-assetlist-item-height", - "--mod-assetlist-item-label-padding-inline-start", - "--mod-assetlist-item-margin-bottom", - "--mod-assetlist-item-padding-inline-end", - "--mod-assetlist-item-padding-inline-start", - "--mod-assetlist-label-color", - "--mod-assetlist-thumbnail-margin-left", - "--mod-assetlist-thumbnail-width", - "--mod-assetlist-thumnail-height", - "--mod-assetlist-width" + ".spectrum-AssetList:dir(rtl)" ], + "modifiers": [], "component": [ - "--spectrum-assetlist-border-color-key-focus", - "--spectrum-assetlist-child-indicator-animation", - "--spectrum-assetlist-item-animation", - "--spectrum-assetlist-item-background-color-down", - "--spectrum-assetlist-item-background-color-hover", "--spectrum-assetlist-item-background-color-selected", - "--spectrum-assetlist-item-background-color-selected-hover", - "--spectrum-assetlist-item-border-radius", - "--spectrum-assetlist-item-font-size", - "--spectrum-assetlist-item-font-weight", - "--spectrum-assetlist-item-height", - "--spectrum-assetlist-item-label-padding-inline-start", - "--spectrum-assetlist-item-margin-block-end", - "--spectrum-assetlist-item-padding-inline-end", - "--spectrum-assetlist-item-padding-inline-start", - "--spectrum-assetlist-label-color", - "--spectrum-assetlist-thumbnail-height", - "--spectrum-assetlist-thumbnail-margin-inline-start", - "--spectrum-assetlist-thumbnail-width", - "--spectrum-assetlist-width" + "--spectrum-assetlist-item-background-color-selected-hover" ], "global": [ "--spectrum-animation-duration-100", + "--spectrum-component-height-200", + "--spectrum-corner-radius-100", + "--spectrum-field-default-width-large", + "--spectrum-focus-indicator-color", + "--spectrum-focus-indicator-thickness", "--spectrum-font-size-100", "--spectrum-gray-100", "--spectrum-gray-200", @@ -81,20 +45,9 @@ "--spectrum-regular-font-weight", "--spectrum-spacing-100", "--spectrum-spacing-300", - "--spectrum-spacing-400", - "--spectrum-spacing-600", - "--spectrum-spacing-75" - ], - "system-theme": [ - "--system-asset-list-item-background-color-down", - "--system-asset-list-item-background-color-hover" + "--spectrum-spacing-75", + "--spectrum-thumbnail-size-100" ], "passthroughs": [], - "high-contrast": [ - "--highcontrast-assetlist-border-color-key-focus", - "--highcontrast-assetlist-item-background-color-hover", - "--highcontrast-assetlist-item-background-color-selected", - "--highcontrast-assetlist-item-background-color-selected-hover", - "--highcontrast-assetlist-label-color" - ] + "high-contrast": [] } diff --git a/components/assetlist/index.css b/components/assetlist/index.css index 742070edbd4..42b2e96a58b 100644 --- a/components/assetlist/index.css +++ b/components/assetlist/index.css @@ -11,31 +11,8 @@ * governing permissions and limitations under the License. */ -@import "./themes/spectrum-two.css"; - +/* Container */ .spectrum-AssetList { - --spectrum-assetlist-width: 272px; - --spectrum-assetlist-child-indicator-animation: var(--spectrum-animation-duration-100); - - /* item */ - --spectrum-assetlist-item-height: var(--spectrum-spacing-600); - --spectrum-assetlist-item-padding-inline-start: var(--spectrum-spacing-300); - --spectrum-assetlist-item-padding-inline-end: var(--spectrum-spacing-300); - --spectrum-assetlist-item-margin-block-end: var(--spectrum-spacing-75); - --spectrum-assetlist-item-border-radius: var(--spectrum-spacing-75); - --spectrum-assetlist-item-animation: var(--spectrum-animation-duration-100); - --spectrum-assetlist-item-font-size: var(--spectrum-font-size-100); - --spectrum-assetlist-item-font-weight: var(--spectrum-regular-font-weight); - - /* thumbnail */ - --spectrum-assetlist-thumbnail-width: var(--spectrum-spacing-400); - --spectrum-assetlist-thumbnail-height: var(--spectrum-spacing-400); - --spectrum-assetlist-thumbnail-margin-inline-start: var(--spectrum-spacing-100); - - /* label */ - --spectrum-assetlist-item-label-padding-inline-start: var(--spectrum-spacing-100); - --spectrum-assetlist-label-color: var(--spectrum-neutral-content-color-default); - margin-block-start: 0; margin-block-end: 0; padding: 0; @@ -45,48 +22,27 @@ } } +/* Iterable children */ .spectrum-AssetList-item { position: relative; - color: var(--highcontrast-assetlist-label-color, var(--mod-assetlist-label-color, var(--spectrum-assetlist-label-color))); - display: flex; box-sizing: border-box; align-items: center; - - inline-size: var(--mod-assetlist-width, var(--spectrum-assetlist-width)); - block-size: var(--mod-assetlist-item-height, var(--spectrum-assetlist-item-height)); - + inline-size: var(--spectrum-field-default-width-large); + block-size: var(--spectrum-component-height-200); padding-block: 0; - padding-inline: var(--mod-assetlist-item-padding-inline-start, var(--spectrum-assetlist-item-padding-inline-start)) var(--mod-assetlist-item-padding-inline-end, var(--spectrum-assetlist-item-padding-inline-end)); - margin-block: 0 var(--mod-assetlist-item-margin-bottom, var(--spectrum-assetlist-item-margin-block-end)); + padding-inline: var(--spectrum-spacing-300); + margin-block: 0 var(--spectrum-spacing-75); margin-inline: 0; - - border-radius: var(--mod-assetlist-item-border-radius, var(--spectrum-assetlist-item-border-radius)); - - transition: background-color var(--mod-assetlist-item-animation, var(--spectrum-assetlist-item-animation)) ease-in-out; - - font-size: var(--mod-assetlist-item-font-size, var(--spectrum-assetlist-item-font-size)); - font-weight: var(--mod-assetlist-item-font-weight, var(--spectrum-assetlist-item-font-weight)); + border-radius: var(--spectrum-corner-radius-100); + transition: background-color var(--spectrum-animation-duration-100) ease-in-out; + color: var(--spectrum-neutral-content-color-default); + font-size: var(--spectrum-font-size-100); + font-weight: var(--spectrum-regular-font-weight); font-style: normal; - cursor: pointer; - outline: none; - &::before { - content: ""; - - position: absolute; - inset-inline-start: 0; - inset-inline-end: 0; - - block-size: var(--mod-assetlist-item-height, var(--spectrum-assetlist-item-height)); - - background-color: transparent; - - border-radius: var(--mod-assetlist-item-border-radius, var(--spectrum-assetlist-item-border-radius)); - } - &.is-selectable, &.is-selected, &:hover, @@ -97,55 +53,81 @@ } } - &.is-branch { - /* show chevron */ - .spectrum-AssetList-itemChildIndicator { - display: block; - } + /* show chevron */ + &.is-branch .spectrum-AssetList-itemChildIndicator { + display: block; } .spectrum-AssetList-itemThumbnail { /* Remove the border on images inside links in IE 10-. */ border-style: none; - - inline-size: var(--mod-assetlist-thumbnail-width, var(--spectrum-assetlist-thumbnail-width)); - block-size: var(--mod-assetlist-thumnail-height, var(--spectrum-assetlist-thumbnail-height)); - margin-inline-start: var(--mod-assetlist-thumbnail-margin-left, var(--spectrum-assetlist-thumbnail-margin-inline-start)); + inline-size: var(--spectrum-thumbnail-size-100); + block-size: var(--spectrum-thumbnail-size-100); + margin-inline-start: var(--spectrum-spacing-100); vertical-align: middle; } &:hover { - background-color: var(--highcontrast-assetlist-item-background-color-hover, var(--mod-assetlist-item-background-color-hover, var(--spectrum-assetlist-item-background-color-hover))); + background-color: var(--spectrum-gray-100); + + @media (forced-colors: active) { + forced-color-adjust: none; + background-color: Highlight; + color: HighlightText; + } } &:focus-within { &:focus-visible, &.is-focused { - background-color: var(--highcontrast-assetlist-item-background-color-hover, var(--mod-assetlist-item-background-color-hover, var(--spectrum-assetlist-item-background-color-hover))); + background-color: var(--spectrum-gray-100); + + @media (forced-colors: active) { + forced-color-adjust: none; + background-color: Highlight; + color: HighlightText; + } &::before { - /* we cannot achieve rounded corners with outline so we use box-shadow instead */ - box-shadow: 0 0 0 2px var(--highcontrast-assetlist-border-color-key-focus, var(--mod-assetlist-border-color-key-focus, var(--spectrum-assetlist-border-color-key-focus))) inset; + content: ""; + position: absolute; + inset-inline-start: 0; + inset-inline-end: 0; + block-size: 100%; + border-radius: var(--spectrum-corner-radius-100); + + /* outline clips so we use box-shadow instead */ + box-shadow: 0 0 0 var(--spectrum-focus-indicator-thickness) var(--spectrum-focus-indicator-color) inset; } } } &.is-navigated { - /* gray background */ - background-color: var(--mod-assetlist-item-background-color-down, var(--spectrum-assetlist-item-background-color-down)); - + &, &:hover, &:focus { - background-color: var(--mod-assetlist-item-background-color-down, var(--spectrum-assetlist-item-background-color-down)); + background-color: var(--spectrum-gray-200); } } &.is-selected { - background-color: var(--highcontrast-assetlist-item-background-color-selected, var(--mod-assetlist-item-background-color-selected, var(--spectrum-assetlist-item-background-color-selected))); + background-color: var(--spectrum-assetlist-item-background-color-selected); + + @media (forced-colors: active) { + forced-color-adjust: none; + background-color: SelectedItem; + color: SelectedItemText; + } &:hover, &:focus { - background-color: var(--highcontrast-assetlist-item-background-color-selected-hover, var(--mod-assetlist-item-background-color-selected-hover, var(--spectrum-assetlist-item-background-color-selected-hover))); + background-color: var(--spectrum-assetlist-item-background-color-selected-hover); + + @media (forced-colors: active) { + forced-color-adjust: none; + background-color: SelectedItem; + color: SelectedItemText; + } } } } @@ -156,33 +138,14 @@ .spectrum-AssetList-itemChildIndicator { display: none; - transition: transform ease var(--mod-assetlist-child-indicator-animation, var(--spectrum-assetlist-child-indicator-animation)); + transition: transform ease var(--spectrum-animation-duration-100); transform: var(--spectrum-logical-rotation,); } .spectrum-AssetList-itemLabel { flex: 1; - padding-inline-start: var(--mod-assetlist-item-label-padding-inline-start, var(--spectrum-assetlist-item-label-padding-inline-start)); - + padding-inline-start: var(--spectrum-spacing-100); text-overflow: ellipsis; overflow: hidden; white-space: nowrap; } - -@media (forced-colors: active) { - .spectrum-AssetList-item { - --highcontrast-assetlist-border-color-key-focus: Highlight; - --highcontrast-assetlist-item-background-color-hover: Highlight; - --highcontrast-assetlist-item-background-color-selected-hover: Highlight; - --highcontrast-assetlist-label-color: ButtonText; - --highcontrast-assetlist-item-background-color-selected: SelectedItem; - - forced-color-adjust: none; - - &:hover, - &.is-selected, - &.is-navigated { - --highcontrast-assetlist-label-color: HighlightText; - } - } -} diff --git a/components/assetlist/package.json b/components/assetlist/package.json index 40a1e2ee1b9..4dd940cc5d4 100644 --- a/components/assetlist/package.json +++ b/components/assetlist/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/assetlist", - "version": "8.3.0", + "version": "9.0.0-next.2", "description": "The Spectrum CSS assetlist component", "license": "Apache-2.0", "author": "Adobe", @@ -19,16 +19,14 @@ "./package.json": "./package.json", "./dist/*": "./dist/*", "./index.css": "./dist/index.css", - "./index-*.css": "./dist/index-*.css", "./metadata.json": "./dist/metadata.json", - "./themes/*": "./dist/themes/*", "./stories/*": "./stories/*" }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/checkbox": ">=10.0.0 <11.0.0", - "@spectrum-css/icon": ">=9.0.0 <10.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/checkbox": ">=11.0.0-next.0", + "@spectrum-css/icon": ">=10.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/checkbox": { @@ -42,9 +40,9 @@ } }, "devDependencies": { - "@spectrum-css/checkbox": "10.2.0", - "@spectrum-css/icon": "9.2.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/checkbox": "11.0.0-next.2", + "@spectrum-css/icon": "10.0.0-next.3", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/assetlist/stories/assetlist.stories.js b/components/assetlist/stories/assetlist.stories.js index d421267b95d..23936f901da 100644 --- a/components/assetlist/stories/assetlist.stories.js +++ b/components/assetlist/stories/assetlist.stories.js @@ -1,8 +1,9 @@ import { default as Checkbox } from "@spectrum-css/checkbox/stories/checkbox.stories.js"; import { disableDefaultModes } from "@spectrum-css/preview/modes"; +import { AssetListGroup } from "./assetlist.test.js"; + import metadata from "../dist/metadata.json"; import packageJson from "../package.json"; -import { AssetListGroup } from "./assetlist.test.js"; /** * A selectable list of assets, often used inside of miller columns. @@ -12,9 +13,56 @@ export default { component: "AssetList", argTypes: { items: { table: { disable: true } }, + isSelectable: { + name: "Selectable", + type: { name: "boolean" }, + table: { + type: { summary: "boolean" }, + category: "Component", + }, + control: "boolean", + }, }, args: { rootClass: "spectrum-AssetList", + isSelectable: false, + items: [ + { + image: "example-ava.png", + label: "Shantanu.jpg", + isSelectable: true, + ariaLabelledBy: "assetitemlabel-1", + checkboxId: "checkbox-1" + }, + { + iconName: "Document", + iconSet: "workflow", + label: "Resource allocation documentation should truncate", + isSelectable: true, + ariaLabelledby: "assetitemlabel-2", + checkboxId: "checkbox-2", + }, + { + iconName: "Folder", + iconSet: "workflow", + label: "Front-end Projects", + isSelectable: true, + isBranch: true, + isSelected: true, + ariaLabelledby: "assetitemlabel-3", + checkboxId: "checkbox-3", + }, + { + iconName: "Folder", + iconSet: "workflow", + label: "Downloads", + isSelectable: true, + isBranch: true, + isNavigated: true, + ariaLabelledby: "assetitemlabel-4", + checkboxId: "checkbox-4", + }, + ], }, parameters: { actions: { @@ -22,50 +70,15 @@ export default { }, packageJson, metadata, + status: { + type: "migrated", + }, }, + tags: ["migrated"], }; export const Default = AssetListGroup.bind({}); -Default.args = { - items: [ - { - image: "example-ava.png", - label: "Shantanu.jpg", - isSelectable: true, - ariaLabelledBy: "assetitemlabel-1", - checkboxId: "checkbox-1" - }, - { - iconName: "Document", - iconSet: "workflow", - label: "Resource allocation documentation should truncate", - isSelectable: true, - ariaLabelledby: "assetitemlabel-2", - checkboxId: "checkbox-2", - }, - { - iconName: "Folder", - iconSet: "workflow", - label: "Front-end Projects", - isSelectable: true, - isBranch: true, - isSelected: true, - ariaLabelledby: "assetitemlabel-3", - checkboxId: "checkbox-3", - }, - { - iconName: "Folder", - iconSet: "workflow", - label: "Downloads", - isSelectable: true, - isBranch: true, - isSelected: false, - isNavigated: true, - ariaLabelledby: "assetitemlabel-4", - checkboxId: "checkbox-4", - }, - ], -}; +Default.args = {}; // ********* VRT ONLY ********* // export const WithForcedColors = AssetListGroup.bind({}); diff --git a/components/assetlist/stories/assetlist.test.js b/components/assetlist/stories/assetlist.test.js index 24f14f7971e..d92fc29aa2a 100644 --- a/components/assetlist/stories/assetlist.test.js +++ b/components/assetlist/stories/assetlist.test.js @@ -1,4 +1,73 @@ import { Variants } from "@spectrum-css/preview/decorators"; import { Template } from "./template.js"; -export const AssetListGroup = Variants({ Template }); +const items = [ + { + image: "example-ava.png", + label: "Shantanu.jpg", + ariaLabelledBy: "assetitemlabel-1", + checkboxId: "checkbox-1" + }, + { + iconName: "Document", + iconSet: "workflow", + label: "Resource allocation documentation should truncate", + ariaLabelledby: "assetitemlabel-2", + checkboxId: "checkbox-2", + }, + { + iconName: "Folder", + iconSet: "workflow", + label: "Front-end projects", + ariaLabelledby: "assetitemlabel-3", + checkboxId: "checkbox-3", + isBranch: true, + }, + { + iconName: "Folder", + iconSet: "workflow", + label: "Downloads", + ariaLabelledby: "assetitemlabel-4", + checkboxId: "checkbox-4", + isBranch: true, + }, +]; +export const AssetListGroup = Variants({ + Template, + testData: [ + { + testHeading: "Default", + items, + }, + { + testHeading: "Selectable", + isSelectable: true, + } + ], + stateData: [{ + testHeading: "Navigated", + items: items.map((item, idx) => ({ ...item, isNavigated: idx === 2 })), + }, { + testHeading: "Selected", + items: items.map((item, idx) => ({ ...item, isSelected: idx < 2 })), + }, { + testHeading: "Focused", + items: items.map((item, idx) => ({ + ...item, + isFocused: idx % 2 + })), + }, { + testHeading: "Hovered", + items: items.map((item) => ({ + ...item, + isHovered: true + })), + }, { + testHeading: "Hovered + selected", + items: items.map((item) => ({ + ...item, + isSelected: true, + isHovered: true + })), + }] +}); diff --git a/components/assetlist/stories/template.js b/components/assetlist/stories/template.js index 96d8f75a80c..d0b5bf0620e 100644 --- a/components/assetlist/stories/template.js +++ b/components/assetlist/stories/template.js @@ -7,9 +7,6 @@ import { ifDefined } from "lit/directives/if-defined.js"; import { when } from "lit/directives/when.js"; import "../index.css"; -import "../themes/spectrum.css"; -/* Must be imported last */ -import "../themes/express.css"; export const AssetListItem = ({ rootClass = "spectrum-AssetList-item", @@ -23,6 +20,8 @@ export const AssetListItem = ({ isSelectable = false, isSelected = false, isBranch = false, + isFocused = false, + isHovered = false, onclick = () => {}, } = {}, context = {}) => html`
  • + ${when(image, () => html`asset image thumbnail` )} - ${when(iconName, () => + ${when(iconName, () => Icon({ iconName, setName: iconSet, @@ -76,6 +79,7 @@ export const AssetListItem = ({ export const Template = ({ rootClass = "spectrum-AssetList", + isSelectable = false, items = [], customClasses = [], id = getRandomId("assetlist"), @@ -92,6 +96,7 @@ export const Template = ({ callback: AssetListItem, args: { rootClass: `${rootClass}-item`, + isSelectable, }, context })} diff --git a/components/assetlist/themes/express.css b/components/assetlist/themes/express.css deleted file mode 100644 index 9fd550418f2..00000000000 --- a/components/assetlist/themes/express.css +++ /dev/null @@ -1,16 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--express */ - -@import "./spectrum.css"; diff --git a/components/assetlist/themes/spectrum-two.css b/components/assetlist/themes/spectrum-two.css deleted file mode 100644 index 0624623caf5..00000000000 --- a/components/assetlist/themes/spectrum-two.css +++ /dev/null @@ -1,19 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -@container style(--system: spectrum) { - .spectrum-AssetList { - --spectrum-assetlist-item-background-color-down: var(--spectrum-gray-200); - --spectrum-assetlist-item-background-color-hover: var(--spectrum-gray-100); - } -} diff --git a/components/assetlist/themes/spectrum.css b/components/assetlist/themes/spectrum.css deleted file mode 100644 index 30f67757c2e..00000000000 --- a/components/assetlist/themes/spectrum.css +++ /dev/null @@ -1,23 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--legacy */ - -@import "./spectrum-two.css"; - -@container style(--system: legacy) { - .spectrum-AssetList { - --spectrum-assetlist-item-background-color-down: var(--spectrum-gray-300); - --spectrum-assetlist-item-background-color-hover: var(--spectrum-gray-200); - } -} diff --git a/components/avatar/CHANGELOG.md b/components/avatar/CHANGELOG.md index 0de54d69f54..f67615d2ace 100644 --- a/components/avatar/CHANGELOG.md +++ b/components/avatar/CHANGELOG.md @@ -1,5 +1,12 @@ # Change log +## 10.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + ## 9.2.0 ### Minor Changes diff --git a/components/avatar/dist/metadata.json b/components/avatar/dist/metadata.json index 47df733191c..b5d4c95f96d 100644 --- a/components/avatar/dist/metadata.json +++ b/components/avatar/dist/metadata.json @@ -3,6 +3,12 @@ "selectors": [ ".spectrum-Avatar", ".spectrum-Avatar--size100", + ".spectrum-Avatar--size1000", + ".spectrum-Avatar--size1100", + ".spectrum-Avatar--size1200", + ".spectrum-Avatar--size1300", + ".spectrum-Avatar--size1400", + ".spectrum-Avatar--size1500", ".spectrum-Avatar--size200", ".spectrum-Avatar--size300", ".spectrum-Avatar--size400", @@ -11,33 +17,28 @@ ".spectrum-Avatar--size600", ".spectrum-Avatar--size700", ".spectrum-Avatar--size75", + ".spectrum-Avatar--size800", + ".spectrum-Avatar--size900", ".spectrum-Avatar-image", ".spectrum-Avatar-link", ".spectrum-Avatar.is-disabled", ".spectrum-Avatar.is-focused:not(.is-disabled):after", ".spectrum-Avatar:not(.is-disabled) .spectrum-Avatar-link:focus-visible:after" ], - "modifiers": [ - "--mod-avatar-block-size", - "--mod-avatar-border-radius", - "--mod-avatar-color-opacity", - "--mod-avatar-color-opacity-disabled", - "--mod-avatar-focus-indicator-color", - "--mod-avatar-focus-indicator-gap", - "--mod-avatar-focus-indicator-thickness", - "--mod-avatar-inline-size" - ], + "modifiers": [], "component": [ "--spectrum-avatar-block-size", - "--spectrum-avatar-border-radius", - "--spectrum-avatar-color-opacity", - "--spectrum-avatar-color-opacity-disabled", - "--spectrum-avatar-focus-indicator-color", - "--spectrum-avatar-focus-indicator-gap", - "--spectrum-avatar-focus-indicator-thickness", + "--spectrum-avatar-border-color", + "--spectrum-avatar-border-width", "--spectrum-avatar-inline-size", "--spectrum-avatar-opacity-disabled", "--spectrum-avatar-size-100", + "--spectrum-avatar-size-1000", + "--spectrum-avatar-size-1100", + "--spectrum-avatar-size-1200", + "--spectrum-avatar-size-1300", + "--spectrum-avatar-size-1400", + "--spectrum-avatar-size-1500", "--spectrum-avatar-size-200", "--spectrum-avatar-size-300", "--spectrum-avatar-size-400", @@ -45,14 +46,15 @@ "--spectrum-avatar-size-500", "--spectrum-avatar-size-600", "--spectrum-avatar-size-700", - "--spectrum-avatar-size-75" + "--spectrum-avatar-size-75", + "--spectrum-avatar-size-800", + "--spectrum-avatar-size-900" ], "global": [ "--spectrum-focus-indicator-color", "--spectrum-focus-indicator-gap", "--spectrum-focus-indicator-thickness" ], - "system-theme": [], "passthroughs": [], - "high-contrast": ["--highcontrast-avatar-focus-indicator-color"] + "high-contrast": [] } diff --git a/components/avatar/index.css b/components/avatar/index.css index 4f165dbf364..2b2bd5afe1d 100644 --- a/components/avatar/index.css +++ b/components/avatar/index.css @@ -12,18 +12,8 @@ */ .spectrum-Avatar { - --spectrum-avatar-color-opacity: 1; - --spectrum-avatar-inline-size: var(--spectrum-avatar-size-100); --spectrum-avatar-block-size: var(--spectrum-avatar-size-100); - - --spectrum-avatar-border-radius: var(--spectrum-avatar-block-size); - - --spectrum-avatar-focus-indicator-thickness: var(--spectrum-focus-indicator-thickness); - --spectrum-avatar-focus-indicator-gap: var(--spectrum-focus-indicator-gap); - --spectrum-avatar-focus-indicator-color: var(--spectrum-focus-indicator-color); - - --spectrum-avatar-color-opacity-disabled: var(--spectrum-avatar-opacity-disabled); } .spectrum-Avatar--size50 { @@ -71,20 +61,56 @@ --spectrum-avatar-block-size: var(--spectrum-avatar-size-700); } -@media (forced-colors: active) { - .spectrum-Avatar { - --highcontrast-avatar-focus-indicator-color: CanvasText; - } +.spectrum-Avatar--size800 { + --spectrum-avatar-inline-size: var(--spectrum-avatar-size-800); + --spectrum-avatar-block-size: var(--spectrum-avatar-size-800); +} + +.spectrum-Avatar--size900 { + --spectrum-avatar-inline-size: var(--spectrum-avatar-size-900); + --spectrum-avatar-block-size: var(--spectrum-avatar-size-900); +} + +.spectrum-Avatar--size1000 { + --spectrum-avatar-inline-size: var(--spectrum-avatar-size-1000); + --spectrum-avatar-block-size: var(--spectrum-avatar-size-1000); +} + +.spectrum-Avatar--size1100 { + --spectrum-avatar-inline-size: var(--spectrum-avatar-size-1100); + --spectrum-avatar-block-size: var(--spectrum-avatar-size-1100); +} + +.spectrum-Avatar--size1200 { + --spectrum-avatar-inline-size: var(--spectrum-avatar-size-1200); + --spectrum-avatar-block-size: var(--spectrum-avatar-size-1200); +} + +.spectrum-Avatar--size1300 { + --spectrum-avatar-inline-size: var(--spectrum-avatar-size-1300); + --spectrum-avatar-block-size: var(--spectrum-avatar-size-1300); +} + +.spectrum-Avatar--size1400 { + --spectrum-avatar-inline-size: var(--spectrum-avatar-size-1400); + --spectrum-avatar-block-size: var(--spectrum-avatar-size-1400); +} + +.spectrum-Avatar--size1500 { + --spectrum-avatar-inline-size: var(--spectrum-avatar-size-1500); + --spectrum-avatar-block-size: var(--spectrum-avatar-size-1500); } .spectrum-Avatar { display: inline-block; position: relative; - inline-size: var(--mod-avatar-inline-size, var(--spectrum-avatar-inline-size)); - block-size: var(--mod-avatar-block-size, var(--spectrum-avatar-block-size)); + inline-size: var(--spectrum-avatar-inline-size); + block-size: var(--spectrum-avatar-block-size); - border-radius: var(--mod-avatar-border-radius, var(--spectrum-avatar-border-radius)); - border-width: 0; + border-style: solid; + border-radius: var(--spectrum-avatar-block-size); + border-width: var(--spectrum-avatar-border-width); + border-color: var(--spectrum-avatar-border-color); outline: none; @@ -93,10 +119,10 @@ overflow: visible; - opacity: var(--mod-avatar-color-opacity, var(--spectrum-avatar-color-opacity)); + opacity: 1; &.is-disabled { - opacity: var(--mod-avatar-color-opacity-disabled, var(--spectrum-avatar-color-opacity-disabled)); + opacity: var(--spectrum-avatar-opacity-disabled); } } @@ -106,26 +132,27 @@ pointer-events: none; content: ""; position: absolute; - inset-block-start: calc((var(--mod-avatar-focus-indicator-gap, var(--spectrum-avatar-focus-indicator-gap)) + var(--mod-avatar-focus-indicator-thickness, var(--spectrum-avatar-focus-indicator-thickness))) * -1); - inset-inline-start: calc((var(--mod-avatar-focus-indicator-gap, var(--spectrum-avatar-focus-indicator-gap)) + var(--mod-avatar-focus-indicator-thickness, var(--spectrum-avatar-focus-indicator-thickness))) * -1); + inset-block-start: calc((var(--spectrum-focus-indicator-gap) + var(--spectrum-focus-indicator-thickness)) * -1); + inset-inline-start: calc((var(--spectrum-focus-indicator-gap) + var(--spectrum-focus-indicator-thickness)) * -1); - inline-size: calc(var(--mod-avatar-inline-size, var(--spectrum-avatar-inline-size)) + (var(--mod-avatar-focus-indicator-gap, var(--spectrum-avatar-focus-indicator-gap)) * 2)); - block-size: calc(var(--mod-avatar-inline-size, var(--spectrum-avatar-inline-size)) + (var(--mod-avatar-focus-indicator-gap, var(--spectrum-avatar-focus-indicator-gap)) * 2)); + inline-size: calc(var(--spectrum-avatar-inline-size) + (var(--spectrum-focus-indicator-gap) * 2)); + block-size: calc(var(--spectrum-avatar-inline-size) + (var(--spectrum-focus-indicator-gap) * 2)); border-style: solid; - border-width: var(--mod-avatar-focus-indicator-thickness, var(--spectrum-avatar-focus-indicator-thickness)); - border-color: var(--highcontrast-avatar-focus-indicator-color, var(--mod-avatar-focus-indicator-color, var(--spectrum-avatar-focus-indicator-color))); - border-radius: var(--mod-avatar-border-radius, var(--spectrum-avatar-border-radius)); + border-width: var(--spectrum-focus-indicator-thickness); + border-color: var(--spectrum-focus-indicator-color); + border-radius: var(--spectrum-avatar-block-size); } } .spectrum-Avatar-link { - outline: 0; + outline: none; + outline-color: transparent; + outline-style: solid; } .spectrum-Avatar-image { - inline-size: var(--mod-avatar-inline-size, var(--spectrum-avatar-inline-size)); - block-size: var(--mod-avatar-block-size, var(--spectrum-avatar-block-size)); - - border-radius: var(--mod-avatar-border-radius, var(--spectrum-avatar-border-radius)); + inline-size: var(--spectrum-avatar-inline-size); + block-size: var(--spectrum-avatar-block-size); + border-radius: var(--spectrum-avatar-block-size); } diff --git a/components/avatar/package.json b/components/avatar/package.json index 794ed1e1050..1b1326b7a23 100644 --- a/components/avatar/package.json +++ b/components/avatar/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/avatar", - "version": "9.2.0", + "version": "10.0.0-next.0", "description": "The Spectrum CSS avatar component", "license": "Apache-2.0", "author": "Adobe", @@ -24,7 +24,7 @@ }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/tokens": ">=16.0.1" + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/tokens": { @@ -32,7 +32,7 @@ } }, "devDependencies": { - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/avatar/stories/avatar.stories.js b/components/avatar/stories/avatar.stories.js index 3ef54b07b71..b3f4d56aea8 100644 --- a/components/avatar/stories/avatar.stories.js +++ b/components/avatar/stories/avatar.stories.js @@ -13,7 +13,7 @@ export default { title: "Avatar", component: "Avatar", argTypes: { - size: size([50, 75, 100, 200, 300, 400, 500, 600, 700], false), + size: size([50, 75, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500], false), image: { name: "Image", type: { name: "string" }, @@ -59,7 +59,11 @@ export default { }, packageJson, metadata, + status: { + type: "migrated", + }, }, + tags: ["migrated"], }; /** @@ -74,19 +78,7 @@ export const Default = AvatarGroup.bind({}); Default.args = {}; // ********* DOCS ONLY ********* // -/** Avatar sizes scale exponentially, based on the Spectrum type scale. These range from size-50 to size-700, with the default size for an avatar being `100`. An avatar can also be customized to fit appropriately for your context. - * - * Avatar is available in many sizes using the required `.spectrum-Avatar--size` class. The available size classes are: - -- `spectrum-Avatar--size50` -- `spectrum-Avatar--size75` -- `spectrum-Avatar--size100` -- `spectrum-Avatar--size200` -- `spectrum-Avatar--size300` -- `spectrum-Avatar--size400` -- `spectrum-Avatar--size500` -- `spectrum-Avatar--size600` -- `spectrum-Avatar--size700` +/** Avatar is available in many sizes and scales exponentially, based on the Spectrum type scale. These sizes range from size-50 to size-1500, using the required `.spectrum-Avatar--size` class. The default size for an avatar is `100`. An avatar can also be customized to fit appropriately for your context. */ export const Sizing = (args, context) => Sizes({ Template, diff --git a/components/badge/CHANGELOG.md b/components/badge/CHANGELOG.md index e583f5f25ff..716193c8466 100644 --- a/components/badge/CHANGELOG.md +++ b/components/badge/CHANGELOG.md @@ -1,5 +1,45 @@ # Change log +## 7.0.0-next.2 + +### Major Changes + +- [#3740](https://github.com/adobe/spectrum-css/pull/3740) [`075fc91`](https://github.com/adobe/spectrum-css/commit/075fc91dd2be332cc8d3005e14bd361bf5630d0a) Thanks [@5t3ph](https://github.com/5t3ph)! - This migrates the base Badge component to S2 designs, but does not include the "Notification" or "Highlight" types. + - New semantic color: "notice" + - Updated/expanded non-semantic colors + - **New colors**: + - pink + - turquoise + - brown + - cinnamon + - silver + - New "styles" to be used alongside a color choice, such as `spectrum-Badge--accent spectrum-Badge--style-subtle` + - subtle (lighter version of bg color) + - outline (border color, only semantic colors) + - Updated border-radius per size + - Updated border-width + - updated related padding/margin definitions to account for border-width + + ## New mods + + New mods added for each new color, as well as for the style-related application of each valid color, ex. `--mod-badge-subtle-background-color-accent` and `--mod-badge-outline-border-color-informative`. See the full [diff of updates](https://github.com/adobe/spectrum-css/pull/3740/files#diff-d1bfd5593c10aaa98222e6c01ca001131fcde194e824b096673ab02a9ef3874f). + + Also added for the default `--mod-badge-border-color` and `--mod-badge-border-width` + +## 7.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + +## 7.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`a25e0a9`](https://github.com/adobe/spectrum-css/commit/a25e0a99e5a4736ab4e607e00739343101a2633b)]: + - @spectrum-css/icon@10.0.0-next.0 + ## 6.2.0 ### Minor Changes diff --git a/components/badge/dist/metadata.json b/components/badge/dist/metadata.json index c8be859d830..5f4c783c596 100644 --- a/components/badge/dist/metadata.json +++ b/components/badge/dist/metadata.json @@ -2,98 +2,82 @@ "sourceFile": "index.css", "selectors": [ ".spectrum-Badge", - ".spectrum-Badge--accent", - ".spectrum-Badge--blue", - ".spectrum-Badge--celery", - ".spectrum-Badge--chartreuse", - ".spectrum-Badge--cyan", ".spectrum-Badge--fixed-block-end", ".spectrum-Badge--fixed-block-start", ".spectrum-Badge--fixed-inline-end", ".spectrum-Badge--fixed-inline-start", - ".spectrum-Badge--fuchsia", - ".spectrum-Badge--gray", - ".spectrum-Badge--green", - ".spectrum-Badge--indigo", - ".spectrum-Badge--informative", - ".spectrum-Badge--magenta", - ".spectrum-Badge--negative", - ".spectrum-Badge--neutral", - ".spectrum-Badge--notice", - ".spectrum-Badge--orange", - ".spectrum-Badge--positive", - ".spectrum-Badge--purple", - ".spectrum-Badge--red", - ".spectrum-Badge--seafoam", + ".spectrum-Badge--outline:where(.spectrum-Badge--accent)", + ".spectrum-Badge--outline:where(.spectrum-Badge--informative)", + ".spectrum-Badge--outline:where(.spectrum-Badge--negative)", + ".spectrum-Badge--outline:where(.spectrum-Badge--neutral)", + ".spectrum-Badge--outline:where(.spectrum-Badge--neutral, .spectrum-Badge--accent, .spectrum-Badge--informative, .spectrum-Badge--negative, .spectrum-Badge--positive, .spectrum-Badge--notice)", + ".spectrum-Badge--outline:where(.spectrum-Badge--notice)", + ".spectrum-Badge--outline:where(.spectrum-Badge--positive)", ".spectrum-Badge--sizeL", ".spectrum-Badge--sizeS", ".spectrum-Badge--sizeXL", - ".spectrum-Badge--yellow", + ".spectrum-Badge--subtle", + ".spectrum-Badge--subtle:where(.spectrum-Badge--accent)", + ".spectrum-Badge--subtle:where(.spectrum-Badge--blue)", + ".spectrum-Badge--subtle:where(.spectrum-Badge--brown)", + ".spectrum-Badge--subtle:where(.spectrum-Badge--celery)", + ".spectrum-Badge--subtle:where(.spectrum-Badge--chartreuse)", + ".spectrum-Badge--subtle:where(.spectrum-Badge--cinnamon)", + ".spectrum-Badge--subtle:where(.spectrum-Badge--cyan)", + ".spectrum-Badge--subtle:where(.spectrum-Badge--fuchsia)", + ".spectrum-Badge--subtle:where(.spectrum-Badge--gray)", + ".spectrum-Badge--subtle:where(.spectrum-Badge--green)", + ".spectrum-Badge--subtle:where(.spectrum-Badge--indigo)", + ".spectrum-Badge--subtle:where(.spectrum-Badge--informative)", + ".spectrum-Badge--subtle:where(.spectrum-Badge--magenta)", + ".spectrum-Badge--subtle:where(.spectrum-Badge--negative)", + ".spectrum-Badge--subtle:where(.spectrum-Badge--neutral)", + ".spectrum-Badge--subtle:where(.spectrum-Badge--notice)", + ".spectrum-Badge--subtle:where(.spectrum-Badge--orange)", + ".spectrum-Badge--subtle:where(.spectrum-Badge--pink)", + ".spectrum-Badge--subtle:where(.spectrum-Badge--positive)", + ".spectrum-Badge--subtle:where(.spectrum-Badge--purple)", + ".spectrum-Badge--subtle:where(.spectrum-Badge--red)", + ".spectrum-Badge--subtle:where(.spectrum-Badge--seafoam)", + ".spectrum-Badge--subtle:where(.spectrum-Badge--silver)", + ".spectrum-Badge--subtle:where(.spectrum-Badge--turquoise)", + ".spectrum-Badge--subtle:where(.spectrum-Badge--yellow)", ".spectrum-Badge-icon", ".spectrum-Badge-icon + .spectrum-Badge-label", ".spectrum-Badge-icon--no-label", ".spectrum-Badge-label", ".spectrum-Badge-label:lang(ja)", ".spectrum-Badge-label:lang(ko)", - ".spectrum-Badge-label:lang(zh)" - ], - "modifiers": [ - "--mod-badge-background-color-accent", - "--mod-badge-background-color-blue", - "--mod-badge-background-color-celery", - "--mod-badge-background-color-chartreuse", - "--mod-badge-background-color-cyan", - "--mod-badge-background-color-default", - "--mod-badge-background-color-fuchsia", - "--mod-badge-background-color-gray", - "--mod-badge-background-color-green", - "--mod-badge-background-color-indigo", - "--mod-badge-background-color-informative", - "--mod-badge-background-color-magenta", - "--mod-badge-background-color-negative", - "--mod-badge-background-color-notice", - "--mod-badge-background-color-orange", - "--mod-badge-background-color-positive", - "--mod-badge-background-color-purple", - "--mod-badge-background-color-red", - "--mod-badge-background-color-seafoam", - "--mod-badge-background-color-yellow", - "--mod-badge-corner-radius", - "--mod-badge-font-size", - "--mod-badge-height", - "--mod-badge-icon-only-spacing-horizontal", - "--mod-badge-icon-spacing-horizontal", - "--mod-badge-icon-spacing-vertical-top", - "--mod-badge-icon-text-spacing", - "--mod-badge-label-icon-color", - "--mod-badge-label-spacing-horizontal", - "--mod-badge-label-spacing-vertical-bottom", - "--mod-badge-label-spacing-vertical-top", - "--mod-badge-line-height", - "--mod-badge-line-height-cjk", - "--mod-badge-workflow-icon-size" + ".spectrum-Badge-label:lang(zh)", + ".spectrum-Badge:where(.spectrum-Badge--accent)", + ".spectrum-Badge:where(.spectrum-Badge--blue)", + ".spectrum-Badge:where(.spectrum-Badge--brown)", + ".spectrum-Badge:where(.spectrum-Badge--celery)", + ".spectrum-Badge:where(.spectrum-Badge--chartreuse)", + ".spectrum-Badge:where(.spectrum-Badge--cinnamon)", + ".spectrum-Badge:where(.spectrum-Badge--cyan)", + ".spectrum-Badge:where(.spectrum-Badge--fuchsia)", + ".spectrum-Badge:where(.spectrum-Badge--gray)", + ".spectrum-Badge:where(.spectrum-Badge--green)", + ".spectrum-Badge:where(.spectrum-Badge--indigo)", + ".spectrum-Badge:where(.spectrum-Badge--informative)", + ".spectrum-Badge:where(.spectrum-Badge--magenta)", + ".spectrum-Badge:where(.spectrum-Badge--negative)", + ".spectrum-Badge:where(.spectrum-Badge--neutral)", + ".spectrum-Badge:where(.spectrum-Badge--notice)", + ".spectrum-Badge:where(.spectrum-Badge--notice, .spectrum-Badge--orange, .spectrum-Badge--yellow, .spectrum-Badge--chartreuse, .spectrum-Badge--celery)", + ".spectrum-Badge:where(.spectrum-Badge--orange)", + ".spectrum-Badge:where(.spectrum-Badge--pink)", + ".spectrum-Badge:where(.spectrum-Badge--positive)", + ".spectrum-Badge:where(.spectrum-Badge--purple)", + ".spectrum-Badge:where(.spectrum-Badge--red)", + ".spectrum-Badge:where(.spectrum-Badge--seafoam)", + ".spectrum-Badge:where(.spectrum-Badge--silver)", + ".spectrum-Badge:where(.spectrum-Badge--turquoise)", + ".spectrum-Badge:where(.spectrum-Badge--yellow)" ], + "modifiers": [], "component": [ - "--spectrum-badge-background-color-accent", - "--spectrum-badge-background-color-blue", - "--spectrum-badge-background-color-celery", - "--spectrum-badge-background-color-chartreuse", - "--spectrum-badge-background-color-cyan", - "--spectrum-badge-background-color-default", - "--spectrum-badge-background-color-fuchsia", - "--spectrum-badge-background-color-gray", - "--spectrum-badge-background-color-green", - "--spectrum-badge-background-color-indigo", - "--spectrum-badge-background-color-informative", - "--spectrum-badge-background-color-magenta", - "--spectrum-badge-background-color-negative", - "--spectrum-badge-background-color-notice", - "--spectrum-badge-background-color-orange", - "--spectrum-badge-background-color-positive", - "--spectrum-badge-background-color-purple", - "--spectrum-badge-background-color-red", - "--spectrum-badge-background-color-seafoam", - "--spectrum-badge-background-color-yellow", "--spectrum-badge-corner-radius", "--spectrum-badge-font-size", "--spectrum-badge-height", @@ -101,21 +85,28 @@ "--spectrum-badge-icon-spacing-horizontal", "--spectrum-badge-icon-spacing-vertical-top", "--spectrum-badge-icon-text-spacing", - "--spectrum-badge-label-icon-color", - "--spectrum-badge-label-icon-color-primary", "--spectrum-badge-label-spacing-horizontal", "--spectrum-badge-label-spacing-vertical-bottom", "--spectrum-badge-label-spacing-vertical-top", - "--spectrum-badge-line-height", - "--spectrum-badge-line-height-cjk", "--spectrum-badge-workflow-icon-size" ], "global": [ "--spectrum-accent-background-color-default", + "--spectrum-accent-subtle-background-color-default", + "--spectrum-accent-visual-color", + "--spectrum-background-layer-2-color", "--spectrum-black", "--spectrum-blue-background-color-default", + "--spectrum-blue-subtle-background-color-default", + "--spectrum-border-width-200", + "--spectrum-brown-background-color-default", + "--spectrum-brown-subtle-background-color-default", "--spectrum-celery-background-color-default", + "--spectrum-celery-subtle-background-color-default", "--spectrum-chartreuse-background-color-default", + "--spectrum-chartreuse-subtle-background-color-default", + "--spectrum-cinnamon-background-color-default", + "--spectrum-cinnamon-subtle-background-color-default", "--spectrum-cjk-line-height-100", "--spectrum-component-bottom-to-text-100", "--spectrum-component-bottom-to-text-200", @@ -143,39 +134,70 @@ "--spectrum-component-top-to-workflow-icon-200", "--spectrum-component-top-to-workflow-icon-300", "--spectrum-component-top-to-workflow-icon-75", - "--spectrum-corner-radius-100", + "--spectrum-corner-radius-medium-size-extra-large", + "--spectrum-corner-radius-medium-size-large", + "--spectrum-corner-radius-medium-size-medium", + "--spectrum-corner-radius-medium-size-small", "--spectrum-cyan-background-color-default", + "--spectrum-cyan-subtle-background-color-default", "--spectrum-font-size-100", "--spectrum-font-size-200", "--spectrum-font-size-300", "--spectrum-font-size-75", "--spectrum-fuchsia-background-color-default", + "--spectrum-fuchsia-subtle-background-color-default", + "--spectrum-gray-1000", "--spectrum-gray-background-color-default", + "--spectrum-gray-subtle-background-color-default", "--spectrum-green-background-color-default", + "--spectrum-green-subtle-background-color-default", "--spectrum-indigo-background-color-default", + "--spectrum-indigo-subtle-background-color-default", "--spectrum-informative-background-color-default", + "--spectrum-informative-subtle-background-color-default", + "--spectrum-informative-visual-color", "--spectrum-line-height-100", "--spectrum-magenta-background-color-default", + "--spectrum-magenta-subtle-background-color-default", + "--spectrum-medium-font-weight", "--spectrum-negative-background-color-default", + "--spectrum-negative-subtle-background-color-default", + "--spectrum-negative-visual-color", "--spectrum-neutral-subdued-background-color-default", + "--spectrum-neutral-subtle-background-color-default", + "--spectrum-neutral-visual-color", "--spectrum-notice-background-color-default", + "--spectrum-notice-subtle-background-color-default", + "--spectrum-notice-visual-color", "--spectrum-orange-background-color-default", + "--spectrum-orange-subtle-background-color-default", + "--spectrum-pink-background-color-default", + "--spectrum-pink-subtle-background-color-default", "--spectrum-positive-background-color-default", + "--spectrum-positive-subtle-background-color-default", + "--spectrum-positive-visual-color", "--spectrum-purple-background-color-default", + "--spectrum-purple-subtle-background-color-default", "--spectrum-red-background-color-default", + "--spectrum-red-subtle-background-color-default", "--spectrum-seafoam-background-color-default", + "--spectrum-seafoam-subtle-background-color-default", + "--spectrum-silver-background-color-default", + "--spectrum-silver-subtle-background-color-default", "--spectrum-text-to-visual-100", "--spectrum-text-to-visual-200", "--spectrum-text-to-visual-300", "--spectrum-text-to-visual-75", + "--spectrum-turquoise-background-color-default", + "--spectrum-turquoise-subtle-background-color-default", "--spectrum-white", "--spectrum-workflow-icon-size-100", "--spectrum-workflow-icon-size-200", "--spectrum-workflow-icon-size-300", "--spectrum-workflow-icon-size-75", - "--spectrum-yellow-background-color-default" + "--spectrum-yellow-background-color-default", + "--spectrum-yellow-subtle-background-color-default" ], - "system-theme": [], "passthroughs": [], - "high-contrast": ["--highcontrast-badge-border-color"] + "high-contrast": [] } diff --git a/components/badge/index.css b/components/badge/index.css index bf4e458aca8..647593d6906 100644 --- a/components/badge/index.css +++ b/components/badge/index.css @@ -1,5 +1,5 @@ /*! - * Copyright 2024 Adobe. All rights reserved. + * Copyright 2025 Adobe. All rights reserved. * * This file is licensed to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. You may obtain a copy @@ -12,89 +12,26 @@ */ .spectrum-Badge { - /* badge styling for all t-shirt sizes and all themes */ - --spectrum-badge-corner-radius: var(--spectrum-corner-radius-100); - - /* label text styles for all t-shirt sizes and all themes */ - --spectrum-badge-line-height: var(--spectrum-line-height-100); - --spectrum-badge-line-height-cjk: var(--spectrum-cjk-line-height-100); - - /* text and icon color default white for all t-shirt sizes and all themes */ - --spectrum-badge-label-icon-color: var(--spectrum-white); - - /* background color default for all t-shirt sizes and all themes */ - --spectrum-badge-background-color-default: var(--spectrum-neutral-subdued-background-color-default); - - /* semantic background colors for all t-shirt sizes and all themes */ - --spectrum-badge-background-color-accent: var(--spectrum-accent-background-color-default); - --spectrum-badge-background-color-informative: var(--spectrum-informative-background-color-default); - --spectrum-badge-background-color-negative: var(--spectrum-negative-background-color-default); - --spectrum-badge-background-color-positive: var(--spectrum-positive-background-color-default); - --spectrum-badge-background-color-notice: var(--spectrum-notice-background-color-default); - - /* non-semantic background colors */ - --spectrum-badge-background-color-gray: var(--spectrum-gray-background-color-default); - --spectrum-badge-background-color-red: var(--spectrum-red-background-color-default); - --spectrum-badge-background-color-orange: var(--spectrum-orange-background-color-default); - --spectrum-badge-background-color-yellow: var(--spectrum-yellow-background-color-default); - --spectrum-badge-background-color-chartreuse: var(--spectrum-chartreuse-background-color-default); - --spectrum-badge-background-color-celery: var(--spectrum-celery-background-color-default); - --spectrum-badge-background-color-green: var(--spectrum-green-background-color-default); - --spectrum-badge-background-color-seafoam: var(--spectrum-seafoam-background-color-default); - --spectrum-badge-background-color-cyan: var(--spectrum-cyan-background-color-default); - --spectrum-badge-background-color-blue: var(--spectrum-blue-background-color-default); - --spectrum-badge-background-color-indigo: var(--spectrum-indigo-background-color-default); - --spectrum-badge-background-color-purple: var(--spectrum-purple-background-color-default); - --spectrum-badge-background-color-fuchsia: var(--spectrum-fuchsia-background-color-default); - --spectrum-badge-background-color-magenta: var(--spectrum-magenta-background-color-default); - /*** DEFAULT STYLE fallbacks if no t-shirt size - uses Medium t-shirt styles ***/ - /* badge height - fallback if no t-shirt size */ + --spectrum-badge-corner-radius: var(--spectrum-corner-radius-medium-size-medium); --spectrum-badge-height: var(--spectrum-component-height-100); - /* label font size - fallback if no t-shirt size */ + /* label */ --spectrum-badge-font-size: var(--spectrum-font-size-100); - - /* label spacing - fallback if no t-shirt size */ --spectrum-badge-label-spacing-vertical-top: var(--spectrum-component-top-to-text-100); --spectrum-badge-label-spacing-vertical-bottom: var(--spectrum-component-bottom-to-text-100); --spectrum-badge-label-spacing-horizontal: var(--spectrum-component-edge-to-text-100); - /* icon size - fallback if no t-shirt size */ + /* icon */ --spectrum-badge-workflow-icon-size: var(--spectrum-workflow-icon-size-100); - - /* icon spacing - fallback if no t-shirt size */ --spectrum-badge-icon-text-spacing: var(--spectrum-text-to-visual-100); --spectrum-badge-icon-spacing-horizontal: var(--spectrum-component-edge-to-visual-100); --spectrum-badge-icon-spacing-vertical-top: var(--spectrum-component-top-to-workflow-icon-100); --spectrum-badge-icon-only-spacing-horizontal: var(--spectrum-component-edge-to-visual-only-100); - - --highcontrast-badge-border-color: CanvasText; -} - -/* text and icon color is black for these background colors */ -.spectrum-Badge--orange, -.spectrum-Badge--yellow, -.spectrum-Badge--chartreuse, -.spectrum-Badge--celery { - --spectrum-badge-label-icon-color: var(--spectrum-black); -} - -/* dark theme all non-semantic colors are black */ -.spectrum-Badge--gray, -.spectrum-Badge--red, -.spectrum-Badge--green, -.spectrum-Badge--seafoam, -.spectrum-Badge--cyan, -.spectrum-Badge--blue, -.spectrum-Badge--indigo, -.spectrum-Badge--purple, -.spectrum-Badge--fuchsia, -.spectrum-Badge--magenta { - --spectrum-badge-label-icon-color: var(--spectrum-badge-label-icon-color-primary); } .spectrum-Badge--sizeS { + --spectrum-badge-corner-radius: var(--spectrum-corner-radius-medium-size-small); --spectrum-badge-height: var(--spectrum-component-height-75); /* label */ @@ -112,6 +49,7 @@ } .spectrum-Badge--sizeL { + --spectrum-badge-corner-radius: var(--spectrum-corner-radius-medium-size-large); --spectrum-badge-height: var(--spectrum-component-height-100); /* label */ @@ -129,6 +67,7 @@ } .spectrum-Badge--sizeXL { + --spectrum-badge-corner-radius: var(--spectrum-corner-radius-medium-size-extra-large); --spectrum-badge-height: var(--spectrum-component-height-100); /* label */ @@ -145,114 +84,271 @@ --spectrum-badge-icon-only-spacing-horizontal: var(--spectrum-component-edge-to-visual-only-300); } -/* windows high contrast mode */ -@media (forced-colors: active) { - .spectrum-Badge { - border-color: var(--highcontrast-badge-border-color); - } -} - .spectrum-Badge { - min-block-size: var(--mod-badge-height, var(--spectrum-badge-height)); + box-sizing: border-box; + min-block-size: var(--spectrum-badge-height); inline-size: auto; - display: inline-flex; vertical-align: middle; position: relative; - cursor: default; + border: var(--spectrum-border-width-200) solid transparent; + border-radius: var(--spectrum-badge-corner-radius); - -webkit-font-smoothing: subpixel-antialiased; - -moz-osx-font-smoothing: auto; + background: var(--spectrum-neutral-subdued-background-color-default); + color: var(--spectrum-white); - border-radius: var(--mod-badge-corner-radius, var(--spectrum-badge-corner-radius)); - border: 1px solid transparent; + /* Show background color under transparent border to correct visual height */ + background-origin: border-box; - background: var(--mod-badge-background-color-default, var(--spectrum-badge-background-color-default)); - color: var(--mod-badge-label-icon-color, var(--spectrum-badge-label-icon-color)); -} + /* Prevent stretch height behavior next to other flex/grid children */ + align-self: start; -/* background color variants */ -.spectrum-Badge--neutral { - background: var(--mod-badge-background-color-default, var(--spectrum-badge-background-color-default)); -} + /* text and icon color is black for these background colors */ + &:where(.spectrum-Badge--notice, .spectrum-Badge--orange, .spectrum-Badge--yellow, .spectrum-Badge--chartreuse, .spectrum-Badge--celery) { + color: var(--spectrum-black); + } -.spectrum-Badge--accent { - background: var(--mod-badge-background-color-accent, var(--spectrum-badge-background-color-accent)); -} + /* background color variants */ + &:where(.spectrum-Badge--neutral) { + background: var(--spectrum-neutral-subdued-background-color-default); + } -.spectrum-Badge--informative { - background: var(--mod-badge-background-color-informative, var(--spectrum-badge-background-color-informative)); -} + &:where(.spectrum-Badge--accent) { + background: var(--spectrum-accent-background-color-default); + } -.spectrum-Badge--negative { - background: var(--mod-badge-background-color-negative, var(--spectrum-badge-background-color-negative)); -} + &:where(.spectrum-Badge--informative) { + background: var(--spectrum-informative-background-color-default); + } -.spectrum-Badge--positive { - background: var(--mod-badge-background-color-positive, var(--spectrum-badge-background-color-positive)); -} + &:where(.spectrum-Badge--negative) { + background: var(--spectrum-negative-background-color-default); + } -/* New in S2, not supporting in Foundations yet! */ -.spectrum-Badge--notice { - background: var(--mod-badge-background-color-notice, var(--spectrum-badge-background-color-notice)); -} + &:where(.spectrum-Badge--positive) { + background: var(--spectrum-positive-background-color-default); + } -/* non-semantic colors */ -.spectrum-Badge--gray { - background: var(--mod-badge-background-color-gray, var(--spectrum-badge-background-color-gray)); -} + &:where(.spectrum-Badge--notice) { + background: var(--spectrum-notice-background-color-default); + } -.spectrum-Badge--red { - background: var(--mod-badge-background-color-red, var(--spectrum-badge-background-color-red)); -} + /* non-semantic colors */ + &:where(.spectrum-Badge--gray) { + background: var(--spectrum-gray-background-color-default); + } -.spectrum-Badge--orange { - background: var(--mod-badge-background-color-orange, var(--spectrum-badge-background-color-orange)); -} + &:where(.spectrum-Badge--red) { + background: var(--spectrum-red-background-color-default); + } -.spectrum-Badge--yellow { - background: var(--mod-badge-background-color-yellow, var(--spectrum-badge-background-color-yellow)); -} + &:where(.spectrum-Badge--orange) { + background: var(--spectrum-orange-background-color-default); + } -.spectrum-Badge--chartreuse { - background: var(--mod-badge-background-color-chartreuse, var(--spectrum-badge-background-color-chartreuse)); -} + &:where(.spectrum-Badge--yellow) { + background: var(--spectrum-yellow-background-color-default); + } -.spectrum-Badge--celery { - background: var(--mod-badge-background-color-celery, var(--spectrum-badge-background-color-celery)); -} + &:where(.spectrum-Badge--chartreuse) { + background: var(--spectrum-chartreuse-background-color-default); + } -.spectrum-Badge--green { - background: var(--mod-badge-background-color-green, var(--spectrum-badge-background-color-green)); -} + &:where(.spectrum-Badge--celery) { + background: var(--spectrum-celery-background-color-default); + } -.spectrum-Badge--seafoam { - background: var(--mod-badge-background-color-seafoam, var(--spectrum-badge-background-color-seafoam)); -} + &:where(.spectrum-Badge--green) { + background: var(--spectrum-green-background-color-default); + } -.spectrum-Badge--cyan { - background: var(--mod-badge-background-color-cyan, var(--spectrum-badge-background-color-cyan)); -} + &:where(.spectrum-Badge--seafoam) { + background: var(--spectrum-seafoam-background-color-default); + } -.spectrum-Badge--blue { - background: var(--mod-badge-background-color-blue, var(--spectrum-badge-background-color-blue)); -} + &:where(.spectrum-Badge--cyan) { + background: var(--spectrum-cyan-background-color-default); + } -.spectrum-Badge--indigo { - background: var(--mod-badge-background-color-indigo, var(--spectrum-badge-background-color-indigo)); -} + &:where(.spectrum-Badge--blue) { + background: var(--spectrum-blue-background-color-default); + } + + &:where(.spectrum-Badge--indigo) { + background: var(--spectrum-indigo-background-color-default); + } + + &:where(.spectrum-Badge--purple) { + background: var(--spectrum-purple-background-color-default); + } + + &:where(.spectrum-Badge--fuchsia) { + background: var(--spectrum-fuchsia-background-color-default); + } + + &:where(.spectrum-Badge--magenta) { + background: var(--spectrum-magenta-background-color-default); + } + + &:where(.spectrum-Badge--pink) { + background: var(--spectrum-pink-background-color-default); + } + + &:where(.spectrum-Badge--turquoise) { + background: var(--spectrum-turquoise-background-color-default); + } + + &:where(.spectrum-Badge--brown) { + background: var(--spectrum-brown-background-color-default); + } + + &:where(.spectrum-Badge--cinnamon) { + background: var(--spectrum-cinnamon-background-color-default); + } -.spectrum-Badge--purple { - background: var(--mod-badge-background-color-purple, var(--spectrum-badge-background-color-purple)); + &:where(.spectrum-Badge--silver) { + background: var(--spectrum-silver-background-color-default); + } } -.spectrum-Badge--fuchsia { - background: var(--mod-badge-background-color-fuchsia, var(--spectrum-badge-background-color-fuchsia)); +/* Style = subtle */ +.spectrum-Badge--subtle { + color: var(--spectrum-gray-1000); + + /* background color variants */ + &:where(.spectrum-Badge--neutral) { + background: var(--spectrum-neutral-subtle-background-color-default); + } + + &:where(.spectrum-Badge--accent) { + background: var(--spectrum-accent-subtle-background-color-default); + } + + &:where(.spectrum-Badge--informative) { + background: var(--spectrum-informative-subtle-background-color-default); + } + + &:where(.spectrum-Badge--negative) { + background: var(--spectrum-negative-subtle-background-color-default); + } + + &:where(.spectrum-Badge--positive) { + background: var(--spectrum-positive-subtle-background-color-default); + } + + &:where(.spectrum-Badge--notice) { + background: var(--spectrum-notice-subtle-background-color-default); + } + + /* non-semantic colors */ + &:where(.spectrum-Badge--gray) { + background: var(--spectrum-gray-subtle-background-color-default); + } + + &:where(.spectrum-Badge--red) { + background: var(--spectrum-red-subtle-background-color-default); + } + + &:where(.spectrum-Badge--orange) { + background: var(--spectrum-orange-subtle-background-color-default); + } + + &:where(.spectrum-Badge--yellow) { + background: var(--spectrum-yellow-subtle-background-color-default); + } + + &:where(.spectrum-Badge--chartreuse) { + background: var(--spectrum-chartreuse-subtle-background-color-default); + } + + &:where(.spectrum-Badge--celery) { + background: var(--spectrum-celery-subtle-background-color-default); + } + + &:where(.spectrum-Badge--green) { + background: var(--spectrum-green-subtle-background-color-default); + } + + &:where(.spectrum-Badge--seafoam) { + background: var(--spectrum-seafoam-subtle-background-color-default); + } + + &:where(.spectrum-Badge--cyan) { + background: var(--spectrum-cyan-subtle-background-color-default); + } + + &:where(.spectrum-Badge--blue) { + background: var(--spectrum-blue-subtle-background-color-default); + } + + &:where(.spectrum-Badge--indigo) { + background: var(--spectrum-indigo-subtle-background-color-default); + } + + &:where(.spectrum-Badge--purple) { + background: var(--spectrum-purple-subtle-background-color-default); + } + + &:where(.spectrum-Badge--fuchsia) { + background: var(--spectrum-fuchsia-subtle-background-color-default); + } + + &:where(.spectrum-Badge--magenta) { + background: var(--spectrum-magenta-subtle-background-color-default); + } + + &:where(.spectrum-Badge--pink) { + background: var(--spectrum-pink-subtle-background-color-default); + } + + &:where(.spectrum-Badge--turquoise) { + background: var(--spectrum-turquoise-subtle-background-color-default); + } + + &:where(.spectrum-Badge--brown) { + background: var(--spectrum-brown-subtle-background-color-default); + } + + &:where(.spectrum-Badge--cinnamon) { + background: var(--spectrum-cinnamon-subtle-background-color-default); + } + + &:where(.spectrum-Badge--silver) { + background: var(--spectrum-silver-subtle-background-color-default); + } } -.spectrum-Badge--magenta { - background: var(--mod-badge-background-color-magenta, var(--spectrum-badge-background-color-magenta)); +/* Style = outline - only valid for semantic colors */ +.spectrum-Badge--outline { + &:where(.spectrum-Badge--neutral, .spectrum-Badge--accent, .spectrum-Badge--informative, .spectrum-Badge--negative, .spectrum-Badge--positive, .spectrum-Badge--notice) { + background: var(--spectrum-background-layer-2-color); + color: var(--spectrum-gray-1000); + } + + &:where(.spectrum-Badge--neutral) { + border-color: var(--spectrum-neutral-visual-color); + } + + &:where(.spectrum-Badge--accent) { + border-color: var(--spectrum-accent-visual-color); + } + + &:where(.spectrum-Badge--informative) { + border-color: var(--spectrum-informative-visual-color); + } + + &:where(.spectrum-Badge--negative) { + border-color: var(--spectrum-negative-visual-color); + } + + &:where(.spectrum-Badge--positive) { + border-color: var(--spectrum-positive-visual-color); + } + + &:where(.spectrum-Badge--notice) { + border-color: var(--spectrum-notice-visual-color); + } } /* fixed position variants with border radius 0 on the fixed edge of the component */ @@ -278,21 +374,21 @@ /* label */ .spectrum-Badge-label { - font-size: var(--mod-badge-font-size, var(--spectrum-badge-font-size)); - line-height: var(--mod-badge-line-height, var(--spectrum-badge-line-height)); + box-sizing: border-box; + font-size: var(--spectrum-badge-font-size); + font-weight: var(--spectrum-medium-font-weight); + line-height: var(--spectrum-line-height-100); - padding-inline-end: var(--mod-badge-label-spacing-horizontal, var(--spectrum-badge-label-spacing-horizontal)); - padding-inline-start: var(--mod-badge-label-spacing-horizontal, var(--spectrum-badge-label-spacing-horizontal)); - padding-block-start: var(--mod-badge-label-spacing-vertical-top, var(--spectrum-badge-label-spacing-vertical-top)); - padding-block-end: var(--mod-badge-label-spacing-vertical-bottom, var(--spectrum-badge-label-spacing-vertical-bottom)); - - color: var(--mod-badge-label-icon-color, var(--spectrum-badge-label-icon-color)); + padding-inline-end: calc(var(--spectrum-badge-label-spacing-horizontal) - var(--spectrum-border-width-200)); + padding-inline-start: var(--spectrum-badge-label-spacing-horizontal); + padding-block-start: calc(var(--spectrum-badge-label-spacing-vertical-top) - var(--spectrum-border-width-200)); + padding-block-end: calc(var(--spectrum-badge-label-spacing-vertical-bottom) - var(--spectrum-border-width-200)); /* cjk language support */ &:lang(ja), &:lang(zh), &:lang(ko) { - line-height: var(--mod-badge-line-height-cjk, var(--spectrum-badge-line-height-cjk)); + line-height: var(--spectrum-cjk-line-height-100); } /* remove left padding from label if preceded by an icon */ @@ -303,24 +399,21 @@ /* optional icon */ .spectrum-Badge-icon { - block-size: var(--mod-badge-workflow-icon-size, var(--spectrum-badge-workflow-icon-size)); - inline-size: var(--mod-badge-workflow-icon-size, var(--spectrum-badge-workflow-icon-size)); + box-sizing: border-box; + block-size: var(--spectrum-badge-workflow-icon-size); + inline-size: var(--spectrum-badge-workflow-icon-size); /* ensures icon does not shrink when badge width is limited */ - flex: 0 0 var(--mod-badge-workflow-icon-size, var(--spectrum-badge-workflow-icon-size)); + flex: 0 0 var(--spectrum-badge-workflow-icon-size); - padding-inline-start: var(--mod-badge-icon-spacing-horizontal, var(--spectrum-badge-icon-spacing-horizontal)); + margin-inline-start: calc(var(--spectrum-badge-icon-spacing-horizontal) - var(--spectrum-border-width-200)); /* icon with label has reduced padding between icon and text */ - padding-inline-end: var(--mod-badge-icon-text-spacing, var(--spectrum-badge-icon-text-spacing)); - padding-block-start: var(--mod-badge-icon-spacing-vertical-top, var(--spectrum-badge-icon-spacing-vertical-top)); - padding-block-end: var(--mod-badge-icon-spacing-vertical-top, var(--spectrum-badge-icon-spacing-vertical-top)); - - color: var(--mod-badge-label-icon-color, var(--spectrum-badge-label-icon-color)); + margin-inline-end: var(--spectrum-badge-icon-text-spacing); + margin-block: calc(var(--spectrum-badge-icon-spacing-vertical-top) - var(--spectrum-border-width-200)); } .spectrum-Badge-icon--no-label { /* icon without label has identical padding left and right */ - padding-inline-start: var(--mod-badge-icon-only-spacing-horizontal, var(--spectrum-badge-icon-only-spacing-horizontal)); - padding-inline-end: var(--mod-badge-icon-only-spacing-horizontal, var(--spectrum-badge-icon-only-spacing-horizontal)); + margin-inline: calc(var(--spectrum-badge-icon-only-spacing-horizontal) - var(--spectrum-border-width-200)); } diff --git a/components/badge/package.json b/components/badge/package.json index 2514dac1820..d0bf88e2846 100644 --- a/components/badge/package.json +++ b/components/badge/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/badge", - "version": "6.2.0", + "version": "7.0.0-next.2", "description": "The Spectrum CSS badge component", "license": "Apache-2.0", "author": "Adobe", @@ -24,8 +24,8 @@ }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/icon": ">=9.0.0 <10.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/icon": ">=10.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/icon": { @@ -36,8 +36,8 @@ } }, "devDependencies": { - "@spectrum-css/icon": "9.2.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/icon": "10.0.0-next.3", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/badge/stories/badge.stories.js b/components/badge/stories/badge.stories.js index fb9961227a2..104a0d6e1ca 100644 --- a/components/badge/stories/badge.stories.js +++ b/components/badge/stories/badge.stories.js @@ -9,9 +9,9 @@ import { BadgeGroup } from "./badge.test.js"; import { ContentOptions, Template } from "./template.js"; /** - * A badge element displays a small amount of color-categorized metadata; ideal for getting a user's attention. Some notes about badge: - * - Label and icon elements must be nested inside a parent container of class `.spectrum-Badge` in order to achieve the correct layout and wrapping behavior. - * - The layout of badge is achieved by applying a display of `inline-flex`, allowing badge to display as inline, while the label and/or icon child elements can utilize flexbox for layout. + * Badges are for showing a small amount of color-categorized metadata. They're ideal for getting a user's attention. There are two additional styles - subtle fill and outline - in addition to the default, bold fill style. + * + * Because outline and subtle fill styles draw a similar level of attention, choose only one to use consistently within a single product. Bold fill can be paired with either style, and is reserved for high-attention badging only. */ export default { title: "Badge", @@ -32,6 +32,17 @@ export default { if: false, }, iconSet: { table: { disable: true } }, + style: { + name: "Style", + description: "Changes the visual appearance", + type: { name: "string" }, + table: { + type: { summary: "string" }, + category: "Component", + }, + options: ["subtle", "outline"], + control: "select", + }, variant: { name: "Variants", description: "Changes the badge's background color. The variant list includes both semantic and non-semantic options.", @@ -40,7 +51,7 @@ export default { type: { summary: "string" }, category: "Component", }, - options: ["neutral", "accent", "informative", "positive", "negative", "gray", "red", "orange", "yellow", "chartreuse", "celery", "green", "seafoam", "cyan", "blue", "indigo", "purple", "fuchsia", "magenta"], + options: ["neutral", "accent", "informative", "positive", "negative", "notice", "gray", "red", "orange", "yellow", "chartreuse", "celery", "green", "seafoam", "cyan", "blue", "indigo", "purple", "fuchsia", "magenta"], control: "select", }, fixed: { @@ -50,7 +61,7 @@ export default { type: { summary: "string" }, category: "Advanced", }, - options: ["none", "fixed-inline-start", "fixed-inline-end", "fixed-block-start", "fixed-block-end"], + options: ["fixed-inline-start", "fixed-inline-end", "fixed-block-start", "fixed-block-end"], control: "select", }, }, @@ -58,8 +69,7 @@ export default { rootClass: "spectrum-Badge", size: "m", variant: "neutral", - iconSet: "workflow", - fixed: "none" + iconSet: "workflow" }, parameters: { design: { @@ -68,7 +78,11 @@ export default { }, packageJson, metadata, + status: { + type: "migrated", + }, }, + tags: ["migrated"] }; /** @@ -76,7 +90,7 @@ export default { */ export const Default = BadgeGroup.bind({}); Default.args = { - iconName: "Info", + iconName: "InfoCircle", label: "Badge", }; @@ -84,7 +98,7 @@ Default.args = { export const SemanticVariants = (args, context) => ArgGrid({ Template, argKey: "variant", - options: ["neutral", "accent", "informative", "positive", "negative"], + options: ["neutral", "accent", "informative", "positive", "negative", "notice"], withBorder: false, ...args, }, context); @@ -109,6 +123,41 @@ NonSemanticVariants.parameters = { }; NonSemanticVariants.storyName = "Non-semantic"; +/** + * The "outline" style is only valid for semantic color variants. + */ +export const StyleOutline = (args, context) => ArgGrid({ + Template, + argKey: "variant", + options: ["neutral", "accent", "informative", "positive", "negative", "notice"], + withBorder: false, + ...args, +}, context); +StyleOutline.args = {...Default.args, style: "outline"}; +StyleOutline.tags = ["!dev"]; +StyleOutline.parameters = { + chromatic: { disableSnapshot: true }, +}; +StyleOutline.storyName = "Style: Outline"; + + +/** + * The "subtle" style is available for all color variants. + */ +export const StyleSubtle = (args, context) => ArgGrid({ + Template, + argKey: "variant", + options: ["neutral", "accent", "informative", "positive", "negative", "notice", "gray", "red", "orange", "yellow", "chartreuse", "celery", "green", "seafoam", "cyan", "blue", "indigo", "purple", "fuchsia", "magenta"], + withBorder: false, + ...args, +}, context); +StyleSubtle.args = {...Default.args, style: "subtle"}; +StyleSubtle.tags = ["!dev"]; +StyleSubtle.parameters = { + chromatic: { disableSnapshot: true }, +}; +StyleSubtle.storyName = "Style: Subtle"; + /** * Fixed positioning impacts the border radius of the badge component. The border radius is 0 along the fixed edge of the component. The actual component position is not represented on this page. */ diff --git a/components/badge/stories/badge.test.js b/components/badge/stories/badge.test.js index d1068ec340a..541e4d8c3c5 100644 --- a/components/badge/stories/badge.test.js +++ b/components/badge/stories/badge.test.js @@ -17,7 +17,7 @@ export const BadgeGroup = Variants({ Template: Badges, sizeDirection: "row", testData: [ - ...["neutral", "accent", "informative", "positive", "negative"].map((variant) => + ...["neutral", "accent", "informative", "positive", "negative", "notice"].map((variant) => ({ testHeading: capitalize(variant), wrapperStyles: { @@ -35,6 +35,26 @@ export const BadgeGroup = Variants({ variant, }) ), + ...["neutral", "accent", "informative", "positive", "negative", "notice"].map((variant) => + ({ + testHeading: capitalize(variant), + wrapperStyles: { + "column-gap": "10px", + }, + variant, + style: "outline" + }) + ), + ...["neutral", "accent", "informative", "positive", "negative", "notice", "gray", "red", "orange", "yellow", "chartreuse", "celery", "green", "seafoam", "cyan", "blue", "indigo", "purple", "fuchsia", "magenta"].map((variant) => + ({ + testHeading: capitalize(variant), + wrapperStyles: { + "column-gap": "10px", + }, + variant, + style: "subtle" + }) + ), ...["none", "fixed-inline-start", "fixed-inline-end", "fixed-block-start", "fixed-block-end"].map((fixed) => ({ testHeading: `Layout ${fixed}`, @@ -47,7 +67,7 @@ export const BadgeGroup = Variants({ }) ), { - testHeading: "Truncation", + testHeading: "Text Wrap", wrapperStyles: { "column-gap": "10px", }, diff --git a/components/badge/stories/template.js b/components/badge/stories/template.js index ee071e455fe..9b2a21bd4be 100644 --- a/components/badge/stories/template.js +++ b/components/badge/stories/template.js @@ -15,6 +15,7 @@ export const Template = ({ iconName, iconSet = "workflow", variant = "neutral", + style, fixed, customStyles = {}, customClasses = [], @@ -27,6 +28,7 @@ export const Template = ({ [`${rootClass}--size${size?.toUpperCase()}`]: typeof size !== "undefined", [`${rootClass}--${variant}`]: typeof variant !== "undefined", + [`${rootClass}--${style}`]: typeof style !== "undefined", [`${rootClass}--${fixed}`]: typeof fixed !== "undefined", ...customClasses.reduce((a, c) => ({ ...a, [c]: true }), {}), })} diff --git a/components/breadcrumb/CHANGELOG.md b/components/breadcrumb/CHANGELOG.md index c97613159bc..c7deeb5318d 100644 --- a/components/breadcrumb/CHANGELOG.md +++ b/components/breadcrumb/CHANGELOG.md @@ -1,5 +1,44 @@ # Change log +## 12.0.0-next.3 + +### Patch Changes + +📝 [#4113](https://github.com/adobe/spectrum-css/pull/4113) [`cf4fc1a`](https://github.com/adobe/spectrum-css/commit/cf4fc1a01d23ba810f45a903ecc29a5c8aae33d1) Thanks [@castastrophe](https://github.com/castastrophe)! + +## Minor linting fixes + +- Removed unused custom properties across multiple components +- Fixed color function notation by converting `rgba()` to `rgb()` where appropriate +- Removed duplicate custom property declarations +- Fixed deprecated CSS properties (e.g., `word-wrap` → `overflow-wrap`) +- Removed unnecessary stylelint-disable comments + +_No visual or functional changes to components._ + +## 12.0.0-next.2 + +### Major Changes + +📝 [#4014](https://github.com/adobe/spectrum-css/pull/4014) [`35c066b`](https://github.com/adobe/spectrum-css/commit/35c066b29c311b1bfcf4507075f13b41222ffc84) Thanks [@castastrophe](https://github.com/castastrophe)! + +This update removes the `dir` attribute polyfill (served via a PostCSS transform to compiled assets) as the fallback is no longer necessary. The`dir` attribute support is available in all supported browsers and has been tested to correctly inherit inside web component shadow DOMs. This is a breaking change **only** to those relying on the `dir` attribute being present for styling, however, the `:dir` pseudo will correctly inherit values from their containers. To correctly determine the `dir` value of a node using JavaScript, you can use `getComputedStyle(node).direction`. + +## 12.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + +## 12.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`a25e0a9`](https://github.com/adobe/spectrum-css/commit/a25e0a99e5a4736ab4e607e00739343101a2633b)]: + - @spectrum-css/icon@10.0.0-next.0 + - @spectrum-css/actionbutton@8.0.0-next.0 + ## 11.2.0 ### Minor Changes @@ -214,6 +253,7 @@ Output for all component CSS files is now being run through a lightweight optimi ### 🛑 BREAKING CHANGE - Removes component-builder & component-builder-simple for script leveraging postcss + - Imports added to index.css and themes/express.css ## 8.2.5 diff --git a/components/breadcrumb/dist/metadata.json b/components/breadcrumb/dist/metadata.json index 561253d9efa..01ed6639e32 100644 --- a/components/breadcrumb/dist/metadata.json +++ b/components/breadcrumb/dist/metadata.json @@ -2,80 +2,56 @@ "sourceFile": "index.css", "selectors": [ ".spectrum-Breadcrumbs", - ".spectrum-Breadcrumbs--compact", - ".spectrum-Breadcrumbs--compact .spectrum-Breadcrumbs-item", - ".spectrum-Breadcrumbs--compact .spectrum-Breadcrumbs-item > .spectrum-ActionButton", - ".spectrum-Breadcrumbs--compact .spectrum-Breadcrumbs-item:last-of-type", - ".spectrum-Breadcrumbs--compact .spectrum-Breadcrumbs-itemLink", - ".spectrum-Breadcrumbs--compact .spectrum-Breadcrumbs-itemSeparator", ".spectrum-Breadcrumbs--multiline", - ".spectrum-Breadcrumbs--multiline .spectrum-Breadcrumbs-item", - ".spectrum-Breadcrumbs--multiline .spectrum-Breadcrumbs-item > .spectrum-ActionButton", ".spectrum-Breadcrumbs--multiline .spectrum-Breadcrumbs-item:last-of-type", - ".spectrum-Breadcrumbs--multiline .spectrum-Breadcrumbs-item:last-of-type .spectrum-Breadcrumbs-itemLink", - ".spectrum-Breadcrumbs--multiline .spectrum-Breadcrumbs-itemLink", - ".spectrum-Breadcrumbs--multiline .spectrum-Breadcrumbs-itemSeparator", + ".spectrum-Breadcrumbs--multiline .spectrum-Breadcrumbs-item:last-of-type > .spectrum-Breadcrumbs-itemLink", + ".spectrum-Breadcrumbs--sizeL", ".spectrum-Breadcrumbs-item", ".spectrum-Breadcrumbs-item > .spectrum-ActionButton", ".spectrum-Breadcrumbs-item > .spectrum-ActionButton:disabled", ".spectrum-Breadcrumbs-item.is-dragged .spectrum-Breadcrumbs-itemLink:before", ".spectrum-Breadcrumbs-item:first-of-type > .spectrum-ActionButton", + ".spectrum-Breadcrumbs-item:first-of-type > .spectrum-Breadcrumbs-itemLink", ".spectrum-Breadcrumbs-item:last-of-type", ".spectrum-Breadcrumbs-item:last-of-type .spectrum-Breadcrumbs-itemLink", ".spectrum-Breadcrumbs-item:last-of-type .spectrum-Breadcrumbs-itemSeparator", ".spectrum-Breadcrumbs-itemLink", + ".spectrum-Breadcrumbs-itemLink + .spectrum-Breadcrumbs-itemSeparator", ".spectrum-Breadcrumbs-itemLink.is-disabled", ".spectrum-Breadcrumbs-itemLink:focus-visible:before", ".spectrum-Breadcrumbs-itemLink[aria-disabled=\"true\"]", ".spectrum-Breadcrumbs-itemLink[href]", + ".spectrum-Breadcrumbs-itemLink[href]:active", ".spectrum-Breadcrumbs-itemLink[href]:focus-visible", ".spectrum-Breadcrumbs-itemLink[href]:hover", ".spectrum-Breadcrumbs-itemLink[tabindex=\"0\"]", + ".spectrum-Breadcrumbs-itemLink[tabindex=\"0\"]:active", ".spectrum-Breadcrumbs-itemLink[tabindex=\"0\"]:focus-visible", ".spectrum-Breadcrumbs-itemLink[tabindex=\"0\"]:hover", ".spectrum-Breadcrumbs-itemSeparator", - ".spectrum-Breadcrumbs-itemSeparator:dir(rtl)", - "[dir=\"rtl\"] .spectrum-Breadcrumbs-itemSeparator" + ".spectrum-Breadcrumbs-itemSeparator:dir(rtl)" ], "modifiers": [ "--mod-breadcrumbs-action-button-color", "--mod-breadcrumbs-action-button-color-disabled", "--mod-breadcrumbs-action-button-spacing-block", - "--mod-breadcrumbs-action-button-spacing-block-between-multiline", - "--mod-breadcrumbs-action-button-spacing-block-compact", - "--mod-breadcrumbs-action-button-spacing-block-multiline", "--mod-breadcrumbs-action-button-spacing-inline", - "--mod-breadcrumbs-action-button-spacing-inline-start", "--mod-breadcrumbs-block-size", - "--mod-breadcrumbs-block-size-compact", - "--mod-breadcrumbs-block-size-multiline", "--mod-breadcrumbs-focus-indicator-color", "--mod-breadcrumbs-focus-indicator-gap", "--mod-breadcrumbs-focus-indicator-thickness", "--mod-breadcrumbs-font-family", - "--mod-breadcrumbs-font-family-compact", - "--mod-breadcrumbs-font-family-compact-current", "--mod-breadcrumbs-font-family-current", - "--mod-breadcrumbs-font-family-multiline", - "--mod-breadcrumbs-font-family-multiline-current", "--mod-breadcrumbs-font-size", - "--mod-breadcrumbs-font-size-compact", - "--mod-breadcrumbs-font-size-compact-current", "--mod-breadcrumbs-font-size-current", - "--mod-breadcrumbs-font-size-multiline", - "--mod-breadcrumbs-font-size-multiline-current", + "--mod-breadcrumbs-font-style", "--mod-breadcrumbs-font-weight", - "--mod-breadcrumbs-font-weight-compact", - "--mod-breadcrumbs-font-weight-compact-current", "--mod-breadcrumbs-font-weight-current", - "--mod-breadcrumbs-font-weight-multiline", - "--mod-breadcrumbs-font-weight-multiline-current", "--mod-breadcrumbs-icon-spacing-block", - "--mod-breadcrumbs-icon-spacing-block-between-multiline", - "--mod-breadcrumbs-icon-spacing-block-compact", - "--mod-breadcrumbs-icon-spacing-block-start-multiline", "--mod-breadcrumbs-inline-end", "--mod-breadcrumbs-inline-start", + "--mod-breadcrumbs-inline-start-to-truncated-menu", + "--mod-breadcrumbs-item-dragged-background", "--mod-breadcrumbs-item-link-border-radius", "--mod-breadcrumbs-line-height", "--mod-breadcrumbs-separator-color", @@ -85,112 +61,96 @@ "--mod-breadcrumbs-text-color-disabled", "--mod-breadcrumbs-text-decoration-gap", "--mod-breadcrumbs-text-decoration-thickness", - "--mod-breadcrumbs-text-spacing-block-between-multiline", "--mod-breadcrumbs-text-spacing-block-end", - "--mod-breadcrumbs-text-spacing-block-end-compact", - "--mod-breadcrumbs-text-spacing-block-end-multiline", "--mod-breadcrumbs-text-spacing-block-start", - "--mod-breadcrumbs-text-spacing-block-start-compact", - "--mod-breadcrumbs-text-spacing-block-start-multiline" + "--mod-breadcrumbs-title-spacing-block-end", + "--mod-breadcrumbs-title-spacing-block-start", + "--mod-heading-margin-end", + "--mod-heading-margin-start" ], "component": [ "--spectrum-breadcrumbs-action-button-color", "--spectrum-breadcrumbs-action-button-color-disabled", "--spectrum-breadcrumbs-action-button-spacing-block", - "--spectrum-breadcrumbs-action-button-spacing-block-between-multiline", - "--spectrum-breadcrumbs-action-button-spacing-block-compact", - "--spectrum-breadcrumbs-action-button-spacing-block-multiline", "--spectrum-breadcrumbs-action-button-spacing-inline", - "--spectrum-breadcrumbs-action-button-spacing-inline-start", "--spectrum-breadcrumbs-block-size", - "--spectrum-breadcrumbs-block-size-compact", - "--spectrum-breadcrumbs-block-size-multiline", - "--spectrum-breadcrumbs-bottom-to-text", - "--spectrum-breadcrumbs-bottom-to-text-compact", "--spectrum-breadcrumbs-bottom-to-text-multiline", "--spectrum-breadcrumbs-end-edge-to-text", "--spectrum-breadcrumbs-focus-indicator-color", "--spectrum-breadcrumbs-focus-indicator-gap", "--spectrum-breadcrumbs-focus-indicator-thickness", "--spectrum-breadcrumbs-font-family", - "--spectrum-breadcrumbs-font-family-compact", - "--spectrum-breadcrumbs-font-family-compact-current", "--spectrum-breadcrumbs-font-family-current", - "--spectrum-breadcrumbs-font-family-multiline", - "--spectrum-breadcrumbs-font-family-multiline-current", "--spectrum-breadcrumbs-font-size", - "--spectrum-breadcrumbs-font-size-compact", - "--spectrum-breadcrumbs-font-size-compact-current", "--spectrum-breadcrumbs-font-size-current", - "--spectrum-breadcrumbs-font-size-multiline", - "--spectrum-breadcrumbs-font-size-multiline-current", + "--spectrum-breadcrumbs-font-style", "--spectrum-breadcrumbs-font-weight", - "--spectrum-breadcrumbs-font-weight-compact", - "--spectrum-breadcrumbs-font-weight-compact-current", "--spectrum-breadcrumbs-font-weight-current", - "--spectrum-breadcrumbs-font-weight-multiline", - "--spectrum-breadcrumbs-font-weight-multiline-current", - "--spectrum-breadcrumbs-height", - "--spectrum-breadcrumbs-height-compact", "--spectrum-breadcrumbs-height-multiline", "--spectrum-breadcrumbs-icon-spacing-block", - "--spectrum-breadcrumbs-icon-spacing-block-between-multiline", - "--spectrum-breadcrumbs-icon-spacing-block-compact", - "--spectrum-breadcrumbs-icon-spacing-block-start-multiline", "--spectrum-breadcrumbs-inline-end", "--spectrum-breadcrumbs-inline-start", + "--spectrum-breadcrumbs-inline-start-to-truncated-menu", + "--spectrum-breadcrumbs-item-dragged-background", "--spectrum-breadcrumbs-item-link-border-radius", "--spectrum-breadcrumbs-line-height", "--spectrum-breadcrumbs-separator-color", - "--spectrum-breadcrumbs-separator-icon-to-bottom-text-multiline", "--spectrum-breadcrumbs-separator-spacing-inline", - "--spectrum-breadcrumbs-start-edge-to-text", + "--spectrum-breadcrumbs-separator-to-bottom-text-multiline", + "--spectrum-breadcrumbs-start-edge-to-text-large", + "--spectrum-breadcrumbs-start-edge-to-text-medium", + "--spectrum-breadcrumbs-start-edge-to-text-multiline", "--spectrum-breadcrumbs-start-edge-to-truncated-menu", "--spectrum-breadcrumbs-text-color", "--spectrum-breadcrumbs-text-color-current", "--spectrum-breadcrumbs-text-color-disabled", "--spectrum-breadcrumbs-text-decoration-gap", "--spectrum-breadcrumbs-text-decoration-thickness", - "--spectrum-breadcrumbs-text-spacing-block-between-multiline", "--spectrum-breadcrumbs-text-spacing-block-end", - "--spectrum-breadcrumbs-text-spacing-block-end-compact", - "--spectrum-breadcrumbs-text-spacing-block-end-multiline", "--spectrum-breadcrumbs-text-spacing-block-start", - "--spectrum-breadcrumbs-text-spacing-block-start-compact", - "--spectrum-breadcrumbs-text-spacing-block-start-multiline", + "--spectrum-breadcrumbs-text-to-separator-large", + "--spectrum-breadcrumbs-text-to-separator-medium", + "--spectrum-breadcrumbs-text-to-separator-multiline", + "--spectrum-breadcrumbs-title-spacing-block-end", + "--spectrum-breadcrumbs-title-spacing-block-start", "--spectrum-breadcrumbs-top-text-to-bottom-text", - "--spectrum-breadcrumbs-top-to-separator-icon", - "--spectrum-breadcrumbs-top-to-separator-icon-compact", - "--spectrum-breadcrumbs-top-to-separator-icon-multiline", - "--spectrum-breadcrumbs-top-to-text", - "--spectrum-breadcrumbs-top-to-text-compact", + "--spectrum-breadcrumbs-top-to-separator-large", + "--spectrum-breadcrumbs-top-to-separator-medium", + "--spectrum-breadcrumbs-top-to-separator-multiline", "--spectrum-breadcrumbs-top-to-text-multiline", "--spectrum-breadcrumbs-top-to-truncated-menu", - "--spectrum-breadcrumbs-top-to-truncated-menu-compact", "--spectrum-breadcrumbs-truncated-menu-to-bottom-text", - "--spectrum-breadcrumbs-truncated-menu-to-separator-icon" + "--spectrum-breadcrumbs-truncated-menu-to-separator" ], "global": [ "--spectrum-bold-font-weight", - "--spectrum-corner-radius-100", + "--spectrum-component-bottom-to-text-100", + "--spectrum-component-bottom-to-text-200", + "--spectrum-component-height-100", + "--spectrum-component-height-200", + "--spectrum-component-top-to-text-100", + "--spectrum-component-top-to-text-200", + "--spectrum-corner-radius-small-default", + "--spectrum-default-font-style", "--spectrum-disabled-content-color", + "--spectrum-drop-zone-background-color-opacity", + "--spectrum-drop-zone-background-color-rgb", + "--spectrum-extra-bold-font-weight", "--spectrum-focus-indicator-color", "--spectrum-focus-indicator-gap", "--spectrum-focus-indicator-thickness", "--spectrum-font-size-100", "--spectrum-font-size-200", - "--spectrum-font-size-300", "--spectrum-font-size-75", + "--spectrum-heading-size-l", "--spectrum-line-height-100", "--spectrum-neutral-content-color-default", "--spectrum-neutral-subdued-content-color-default", "--spectrum-regular-font-weight", "--spectrum-sans-font-family-stack", - "--spectrum-text-to-visual-100", "--spectrum-text-underline-gap", "--spectrum-text-underline-thickness" ], - "system-theme": [], "passthroughs": [], "high-contrast": [ "--highcontrast-breadcrumbs-action-button-color", diff --git a/components/breadcrumb/index.css b/components/breadcrumb/index.css index 11e5a68e03b..bc62aafbc57 100644 --- a/components/breadcrumb/index.css +++ b/components/breadcrumb/index.css @@ -12,88 +12,46 @@ */ .spectrum-Breadcrumbs { - /* block size */ - --spectrum-breadcrumbs-block-size: var(--spectrum-breadcrumbs-height); - --spectrum-breadcrumbs-block-size-compact: var(--spectrum-breadcrumbs-height-compact); - --spectrum-breadcrumbs-block-size-multiline: var(--spectrum-breadcrumbs-height-multiline); + --spectrum-breadcrumbs-block-size: var(--spectrum-component-height-100); - /* text regular */ + /* Text - medium / default */ --spectrum-breadcrumbs-line-height: var(--spectrum-line-height-100); - --spectrum-breadcrumbs-font-size: var(--spectrum-font-size-200); + --spectrum-breadcrumbs-font-size: var(--spectrum-font-size-100); --spectrum-breadcrumbs-font-family: var(--spectrum-sans-font-family-stack); --spectrum-breadcrumbs-font-weight: var(--spectrum-regular-font-weight); + --spectrum-breadcrumbs-font-style: var(--spectrum-default-font-style); - /* text regular active item */ - --spectrum-breadcrumbs-font-size-current: var(--spectrum-font-size-200); + --spectrum-breadcrumbs-font-size-current: var(--spectrum-font-size-100); --spectrum-breadcrumbs-font-family-current: var(--spectrum-sans-font-family-stack); --spectrum-breadcrumbs-font-weight-current: var(--spectrum-bold-font-weight); - /* text compact */ - --spectrum-breadcrumbs-font-size-compact: var(--spectrum-font-size-100); - --spectrum-breadcrumbs-font-family-compact: var(--spectrum-sans-font-family-stack); - --spectrum-breadcrumbs-font-weight-compact: var(--spectrum-regular-font-weight); - - /* text compact active item */ - --spectrum-breadcrumbs-font-size-compact-current: var(--spectrum-font-size-100); - --spectrum-breadcrumbs-font-family-compact-current: var(--spectrum-sans-font-family-stack); - --spectrum-breadcrumbs-font-weight-compact-current: var(--spectrum-bold-font-weight); - - /* text multiline */ - --spectrum-breadcrumbs-font-size-multiline: var(--spectrum-font-size-75); - --spectrum-breadcrumbs-font-family-multiline: var(--spectrum-sans-font-family-stack); - --spectrum-breadcrumbs-font-weight-multiline: var(--spectrum-regular-font-weight); - - /* text multiline active item */ - --spectrum-breadcrumbs-font-size-multiline-current: var(--spectrum-font-size-300); - --spectrum-breadcrumbs-font-family-multiline-current: var(--spectrum-sans-font-family-stack); - --spectrum-breadcrumbs-font-weight-multiline-current: var(--spectrum-bold-font-weight); - - /* hover, active, focus underline */ + /* Hover, active, focus underline */ --spectrum-breadcrumbs-text-decoration-thickness: var(--spectrum-text-underline-thickness); --spectrum-breadcrumbs-text-decoration-gap: var(--spectrum-text-underline-gap); - /* space between items */ - --spectrum-breadcrumbs-separator-spacing-inline: var(--spectrum-text-to-visual-100); - - /* vertical spacing */ - --spectrum-breadcrumbs-text-spacing-block-start: var(--spectrum-breadcrumbs-top-to-text); - --spectrum-breadcrumbs-text-spacing-block-end: var(--spectrum-breadcrumbs-bottom-to-text); - --spectrum-breadcrumbs-icon-spacing-block: var(--spectrum-breadcrumbs-top-to-separator-icon); + /* Space between separator chevron and items */ + --spectrum-breadcrumbs-separator-spacing-inline: var(--spectrum-breadcrumbs-text-to-separator-medium); - /* compact vertical spacing */ - --spectrum-breadcrumbs-text-spacing-block-start-compact: var(--spectrum-breadcrumbs-top-to-text-compact); - --spectrum-breadcrumbs-text-spacing-block-end-compact: var(--spectrum-breadcrumbs-bottom-to-text-compact); - --spectrum-breadcrumbs-icon-spacing-block-compact: var(--spectrum-breadcrumbs-top-to-separator-icon-compact); + /* Vertical spacing for text and separator icon */ + --spectrum-breadcrumbs-text-spacing-block-start: var(--spectrum-component-top-to-text-100); + --spectrum-breadcrumbs-text-spacing-block-end: var(--spectrum-component-bottom-to-text-100); + --spectrum-breadcrumbs-icon-spacing-block: var(--spectrum-breadcrumbs-top-to-separator-medium); + --spectrum-breadcrumbs-title-spacing-block-start: var(--spectrum-breadcrumbs-text-spacing-block-start); + --spectrum-breadcrumbs-title-spacing-block-end: var(--spectrum-breadcrumbs-text-spacing-block-end); - /* multiline vertical spacing */ - --spectrum-breadcrumbs-text-spacing-block-start-multiline: var(--spectrum-breadcrumbs-top-to-text-multiline); - --spectrum-breadcrumbs-text-spacing-block-end-multiline: var(--spectrum-breadcrumbs-bottom-to-text-multiline); - --spectrum-breadcrumbs-text-spacing-block-between-multiline: var(--spectrum-breadcrumbs-top-text-to-bottom-text); /* vertical between lines */ - --spectrum-breadcrumbs-icon-spacing-block-start-multiline: var(--spectrum-breadcrumbs-top-to-separator-icon-multiline); - --spectrum-breadcrumbs-icon-spacing-block-between-multiline: var(--spectrum-breadcrumbs-separator-icon-to-bottom-text-multiline); /* vertical between lines */ - - /* horizontal outer spacing of list */ - --spectrum-breadcrumbs-inline-start: var(--spectrum-breadcrumbs-start-edge-to-text); + /* Horizontal outer spacing of list */ + --spectrum-breadcrumbs-inline-start: var(--spectrum-breadcrumbs-start-edge-to-text-medium); --spectrum-breadcrumbs-inline-end: var(--spectrum-breadcrumbs-end-edge-to-text); + --spectrum-breadcrumbs-inline-start-to-truncated-menu: var(--spectrum-breadcrumbs-start-edge-to-truncated-menu); - /* menu action button icon spacing */ - --spectrum-breadcrumbs-action-button-spacing-inline: var(--spectrum-breadcrumbs-truncated-menu-to-separator-icon); - - /* action button spacing */ + /* Action button (truncated menu) spacing */ + --spectrum-breadcrumbs-action-button-spacing-inline: var(--spectrum-breadcrumbs-truncated-menu-to-separator); --spectrum-breadcrumbs-action-button-spacing-block: var(--spectrum-breadcrumbs-top-to-truncated-menu); - --spectrum-breadcrumbs-action-button-spacing-block-compact: var(--spectrum-breadcrumbs-top-to-truncated-menu-compact); /* compact */ - - --spectrum-breadcrumbs-action-button-spacing-inline-start: var(--spectrum-breadcrumbs-start-edge-to-truncated-menu); /* if icon is first item */ - --spectrum-breadcrumbs-action-button-spacing-block-multiline: var(--spectrum-breadcrumbs-top-to-truncated-menu-compact); /* multiline */ - --spectrum-breadcrumbs-action-button-spacing-block-between-multiline: var(--spectrum-breadcrumbs-truncated-menu-to-bottom-text); /* multiline */ - - /* Focus Indicator */ + /* Focus indicator */ --spectrum-breadcrumbs-focus-indicator-thickness: var(--spectrum-focus-indicator-thickness); --spectrum-breadcrumbs-focus-indicator-gap: var(--spectrum-focus-indicator-gap); - - /* placeholder for border radius for focus indicator */ - --spectrum-breadcrumbs-item-link-border-radius: var(--spectrum-corner-radius-100); + --spectrum-breadcrumbs-item-link-border-radius: var(--spectrum-corner-radius-small-default); /* Colors */ --spectrum-breadcrumbs-text-color: var(--spectrum-neutral-subdued-content-color-default); @@ -102,72 +60,63 @@ --spectrum-breadcrumbs-separator-color: var(--spectrum-neutral-content-color-default); --spectrum-breadcrumbs-action-button-color: var(--spectrum-neutral-subdued-content-color-default); --spectrum-breadcrumbs-action-button-color-disabled: var(--spectrum-disabled-content-color); - --spectrum-breadcrumbs-focus-indicator-color: var(--spectrum-focus-indicator-color); + --spectrum-breadcrumbs-item-dragged-background: rgb(var(--spectrum-drop-zone-background-color-rgb), var(--spectrum-drop-zone-background-color-opacity)); + + /* Sub-component: heading */ + --mod-heading-margin-end: 0px; + --mod-heading-margin-start: 0px; } -/* windows high contrast mode */ -@media (forced-colors: active) { - .spectrum-Breadcrumbs { - --highcontrast-breadcrumbs-text-color: LinkText; - --highcontrast-breadcrumbs-text-color-current: CanvasText; - --highcontrast-breadcrumbs-text-color-disabled: GrayText; - --highcontrast-breadcrumbs-separator-color: CanvasText; - --highcontrast-breadcrumbs-action-button-color: LinkText; - --highcontrast-breadcrumbs-action-button-color-disabled: GrayText; +.spectrum-Breadcrumbs--sizeL { + --spectrum-breadcrumbs-block-size: var(--spectrum-component-height-200); + --spectrum-breadcrumbs-font-size: var(--spectrum-font-size-200); + --spectrum-breadcrumbs-font-size-current: var(--spectrum-font-size-200); - --highcontrast-breadcrumbs-focus-indicator-color: CanvasText; - } + --spectrum-breadcrumbs-separator-spacing-inline: var(--spectrum-breadcrumbs-text-to-separator-large); + --spectrum-breadcrumbs-text-spacing-block-start: var(--spectrum-component-top-to-text-200); + --spectrum-breadcrumbs-text-spacing-block-end: var(--spectrum-component-bottom-to-text-200); + --spectrum-breadcrumbs-icon-spacing-block: var(--spectrum-breadcrumbs-top-to-separator-large); + --spectrum-breadcrumbs-inline-start: var(--spectrum-breadcrumbs-start-edge-to-text-large); +} + +.spectrum-Breadcrumbs--multiline { + --spectrum-breadcrumbs-block-size: var(--spectrum-breadcrumbs-height-multiline); + --spectrum-breadcrumbs-font-size: var(--spectrum-font-size-75); + --spectrum-breadcrumbs-font-size-current: var(--spectrum-heading-size-l); + --spectrum-breadcrumbs-font-weight-current: var(--spectrum-extra-bold-font-weight); + + --spectrum-breadcrumbs-separator-spacing-inline: var(--spectrum-breadcrumbs-text-to-separator-multiline); + --spectrum-breadcrumbs-text-spacing-block-start: var(--spectrum-breadcrumbs-top-to-text-multiline); + --spectrum-breadcrumbs-text-spacing-block-end: var(--spectrum-breadcrumbs-top-text-to-bottom-text); + --spectrum-breadcrumbs-icon-spacing-block: var(--spectrum-breadcrumbs-top-to-separator-multiline) var(--spectrum-breadcrumbs-separator-to-bottom-text-multiline); + --spectrum-breadcrumbs-title-spacing-block-start: 0; + --spectrum-breadcrumbs-title-spacing-block-end: var(--spectrum-breadcrumbs-bottom-to-text-multiline); + --spectrum-breadcrumbs-inline-start: var(--spectrum-breadcrumbs-start-edge-to-text-multiline); + --spectrum-breadcrumbs-action-button-spacing-block: var(--spectrum-breadcrumbs-top-to-truncated-menu) var(--spectrum-breadcrumbs-truncated-menu-to-bottom-text); } .spectrum-Breadcrumbs { list-style-type: none; - margin: 0; - padding-inline-start: var(--mod-breadcrumbs-inline-start, var(--spectrum-breadcrumbs-inline-start)); - padding-inline-end: var(--mod-breadcrumbs-inline-end, var(--spectrum-breadcrumbs-inline-end)); + padding-inline: 0 var(--mod-breadcrumbs-inline-end, var(--spectrum-breadcrumbs-inline-end)); + block-size: var(--mod-breadcrumbs-block-size, var(--spectrum-breadcrumbs-block-size)); display: flex; flex-flow: row nowrap; align-items: center; justify-content: flex-start; - flex: 1 0 0%; - - block-size: var(--mod-breadcrumbs-block-size, var(--spectrum-breadcrumbs-block-size)); -} - -.spectrum-Breadcrumbs--compact { - block-size: var(--mod-breadcrumbs-block-size-compact, var(--spectrum-breadcrumbs-block-size-compact)); -} - -.spectrum-Breadcrumbs--multiline { - block-size: var(--mod-breadcrumbs-block-size-multiline, var(--spectrum-breadcrumbs-block-size-multiline)); - - flex-wrap: wrap; - align-content: center; } .spectrum-Breadcrumbs-itemSeparator { position: relative; - margin-block: var(--mod-breadcrumbs-icon-spacing-block, var(--spectrum-breadcrumbs-icon-spacing-block)); - margin-inline: var(--mod-breadcrumbs-separator-spacing-inline, var(--spectrum-breadcrumbs-separator-spacing-inline)); - opacity: 1; color: var(--highcontrast-breadcrumbs-separator-color, var(--mod-breadcrumbs-separator-color, var(--spectrum-breadcrumbs-separator-color))); &:dir(rtl) { transform: scaleX(-1); } - - .spectrum-Breadcrumbs--compact & { - margin-block: var(--mod-breadcrumbs-icon-spacing-block-compact, var(--spectrum-breadcrumbs-icon-spacing-block-compact)); - } - - .spectrum-Breadcrumbs--multiline & { - margin-block-start: var(--mod-breadcrumbs-icon-spacing-block-start-multiline, var(--spectrum-breadcrumbs-icon-spacing-block-start-multiline)); - margin-block-end: var(--mod-breadcrumbs-icon-spacing-block-between-multiline, var(--spectrum-breadcrumbs-icon-spacing-block-between-multiline)); - } } .spectrum-Breadcrumbs-item { @@ -175,40 +124,15 @@ position: relative; display: inline-flex; white-space: nowrap; - align-items: center; font-family: var(--mod-breadcrumbs-font-family, var(--spectrum-breadcrumbs-font-family)); font-size: var(--mod-breadcrumbs-font-size, var(--spectrum-breadcrumbs-font-size)); font-weight: var(--mod-breadcrumbs-font-weight, var(--spectrum-breadcrumbs-font-weight)); + font-style: var(--mod-breadcrumbs-font-style, var(--spectrum-breadcrumbs-font-style)); line-height: var(--mod-breadcrumbs-line-height, var(--spectrum-breadcrumbs-line-height)); - .spectrum-Breadcrumbs--compact & { - font-family: var(--mod-breadcrumbs-font-family-compact, var(--spectrum-breadcrumbs-font-family-compact)); - font-size: var(--mod-breadcrumbs-font-size-compact, var(--spectrum-breadcrumbs-font-size-compact)); - font-weight: var(--mod-breadcrumbs-font-weight-compact, var(--spectrum-breadcrumbs-font-weight-compact)); - - > .spectrum-ActionButton { - margin-block: var(--mod-breadcrumbs-action-button-spacing-block-compact, var(--spectrum-breadcrumbs-action-button-spacing-block-compact)); - } - } - - .spectrum-Breadcrumbs--multiline & { - font-family: var(--mod-breadcrumbs-font-family-multiline, var(--spectrum-breadcrumbs-font-family-multiline)); - font-size: var(--mod-breadcrumbs-font-size-multiline, var(--spectrum-breadcrumbs-font-size-multiline)); - font-weight: var(--mod-breadcrumbs-font-weight-multiline, var(--spectrum-breadcrumbs-font-weight-multiline)); - - &:last-of-type { - block-size: auto; - inline-size: 100%; - } - - > .spectrum-ActionButton { - margin-block-start: var(--mod-breadcrumbs-action-button-spacing-block-multiline, var(--spectrum-breadcrumbs-action-button-spacing-block-multiline)); - margin-block-end: var(--mod-breadcrumbs-action-button-spacing-block-between-multiline, var(--spectrum-breadcrumbs-action-button-spacing-block-between-multiline)); - } - } - + /* Breadcrumbs title (current item) */ &:last-of-type { font-family: var(--mod-breadcrumbs-font-family-current, var(--spectrum-breadcrumbs-font-family-current)); font-size: var(--mod-breadcrumbs-font-size-current, var(--spectrum-breadcrumbs-font-size-current)); @@ -219,27 +143,10 @@ } } - .spectrum-Breadcrumbs--compact &:last-of-type { - font-family: var(--mod-breadcrumbs-font-family-compact-current, var(--spectrum-breadcrumbs-font-family-compact-current)); - font-size: var(--mod-breadcrumbs-font-size-compact-current, var(--spectrum-breadcrumbs-font-size-compact-current)); - font-weight: var(--mod-breadcrumbs-font-weight-compact-current, var(--spectrum-breadcrumbs-font-weight-compact-current)); - } - - .spectrum-Breadcrumbs--multiline &:last-of-type { - font-family: var(--mod-breadcrumbs-font-family-multiline-current, var(--spectrum-breadcrumbs-font-family-multiline-current)); - font-size: var(--mod-breadcrumbs-font-size-multiline-current, var(--spectrum-breadcrumbs-font-size-multiline-current)); - font-weight: var(--mod-breadcrumbs-font-weight-multiline-current, var(--spectrum-breadcrumbs-font-weight-multiline-current)); - - .spectrum-Breadcrumbs-itemLink { - margin-block-start: 0; - margin-block-end: var(--mod-breadcrumbs-text-spacing-block-end-multiline, var(--spectrum-breadcrumbs-text-spacing-block-end-multiline)); - } - } - + /* Truncated menu */ > .spectrum-ActionButton { margin-inline: var(--mod-breadcrumbs-action-button-spacing-inline, var(--spectrum-breadcrumbs-action-button-spacing-inline)); margin-block: var(--mod-breadcrumbs-action-button-spacing-block, var(--spectrum-breadcrumbs-action-button-spacing-block)); - color: var(--highcontrast-breadcrumbs-action-button-color, var(--mod-breadcrumbs-action-button-color, var(--spectrum-breadcrumbs-action-button-color))); &:disabled { @@ -247,10 +154,14 @@ } } + /* Start edge to text or truncated menu */ &:first-of-type { - /* if folder icon is first item */ + > .spectrum-Breadcrumbs-itemLink { + margin-inline-start: var(--mod-breadcrumbs-inline-start, var(--spectrum-breadcrumbs-inline-start)); + } + > .spectrum-ActionButton { - margin-inline-start: var(--mod-breadcrumbs-action-button-spacing-inline-start, var(--spectrum-breadcrumbs-action-button-spacing-inline-start)); + margin-inline-start: var(--mod-breadcrumbs-inline-start-to-truncated-menu, var(--spectrum-breadcrumbs-inline-start-to-truncated-menu)); } } } @@ -258,46 +169,43 @@ .spectrum-Breadcrumbs-itemLink { cursor: default; position: relative; - box-sizing: border-box; - display: block; - border-radius: var(--mod-breadcrumbs-item-link-border-radius, var(--spectrum-breadcrumbs-item-link-border-radius)); /* placeholder for token */ outline: none; - text-decoration: none; color: var(--highcontrast-breadcrumbs-text-color, var(--mod-breadcrumbs-text-color, var(--spectrum-breadcrumbs-text-color))); + /* Create new stacking context for negative z-index dragged pseudo element. */ + isolation: isolate; + margin-block-start: var(--mod-breadcrumbs-text-spacing-block-start, var(--spectrum-breadcrumbs-text-spacing-block-start)); margin-block-end: var(--mod-breadcrumbs-text-spacing-block-end, var(--spectrum-breadcrumbs-text-spacing-block-end)); + margin-inline-start: var(--mod-breadcrumbs-separator-spacing-inline, var(--spectrum-breadcrumbs-separator-spacing-inline)); &.is-disabled, &[aria-disabled="true"] { color: var(--highcontrast-breadcrumbs-text-color-disabled, var(--mod-breadcrumbs-text-color-disabled, var(--spectrum-breadcrumbs-text-color-disabled))); } + /* Breadcrumbs title (current item) */ .spectrum-Breadcrumbs-item:last-of-type & { color: var(--highcontrast-breadcrumbs-text-color-current, var(--mod-breadcrumbs-text-color-current, var(--spectrum-breadcrumbs-text-color-current))); + margin-block-start: var(--mod-breadcrumbs-title-spacing-block-start, var(--spectrum-breadcrumbs-title-spacing-block-start)); + margin-block-end: var(--mod-breadcrumbs-title-spacing-block-end, var(--spectrum-breadcrumbs-title-spacing-block-end)); } - .spectrum-Breadcrumbs--compact & { - /* compact vertical spacing */ - margin-block-start: var(--mod-breadcrumbs-text-spacing-block-start-compact, var(--spectrum-breadcrumbs-text-spacing-block-start-compact)); - margin-block-end: var(--mod-breadcrumbs-text-spacing-block-end-compact, var(--spectrum-breadcrumbs-text-spacing-block-end-compact)); - } - - .spectrum-Breadcrumbs--multiline & { - /* multiline vertical spacing */ - margin-block-start: var(--mod-breadcrumbs-text-spacing-block-start-multiline, var(--spectrum-breadcrumbs-text-spacing-block-start-multiline)); - margin-block-end: var(--mod-breadcrumbs-text-spacing-block-between-multiline, var(--spectrum-breadcrumbs-text-spacing-block-between-multiline)); /* vertical between lines */ + + .spectrum-Breadcrumbs-itemSeparator { + margin-inline-start: var(--mod-breadcrumbs-separator-spacing-inline, var(--spectrum-breadcrumbs-separator-spacing-inline)); } + /* Link is focusable */ &[href], &[tabindex="0"] { cursor: pointer; &:hover, + &:active, &:focus-visible { text-decoration: underline; text-decoration-thickness: var(--mod-breadcrumbs-text-decoration-thickness, var(--spectrum-breadcrumbs-text-decoration-thickness)); @@ -306,10 +214,12 @@ } } -/* focus indicator */ +/* Focus indicator */ .spectrum-Breadcrumbs-item.is-dragged .spectrum-Breadcrumbs-itemLink::before, .spectrum-Breadcrumbs-itemLink:focus-visible::before { position: absolute; + content: ""; + pointer-events: none; margin-inline-start: calc((var(--mod-breadcrumbs-focus-indicator-gap, var(--spectrum-breadcrumbs-focus-indicator-gap)) + var(--mod-breadcrumbs-focus-indicator-thickness, var(--spectrum-breadcrumbs-focus-indicator-thickness))) * -1); margin-block-start: calc((var(--mod-breadcrumbs-focus-indicator-gap, var(--spectrum-breadcrumbs-focus-indicator-gap)) + var(--mod-breadcrumbs-focus-indicator-thickness, var(--spectrum-breadcrumbs-focus-indicator-thickness))) * -1); @@ -322,9 +232,40 @@ border-width: var(--mod-breadcrumbs-focus-indicator-thickness, var(--spectrum-breadcrumbs-focus-indicator-thickness)); border-style: solid; border-radius: var(--mod-breadcrumbs-item-link-border-radius, var(--spectrum-breadcrumbs-item-link-border-radius)); + border-color: var(--highcontrast-breadcrumbs-focus-indicator-color, var(--mod-breadcrumbs-focus-indicator-color, var(--spectrum-breadcrumbs-focus-indicator-color))); +} - content: ""; - pointer-events: none; +.spectrum-Breadcrumbs-item.is-dragged .spectrum-Breadcrumbs-itemLink::before { + background: var(--mod-breadcrumbs-item-dragged-background, var(--spectrum-breadcrumbs-item-dragged-background)); - border-color: var(--highcontrast-breadcrumbs-focus-indicator-color, var(--mod-breadcrumbs-focus-indicator-color, var(--spectrum-breadcrumbs-focus-indicator-color))); + /* Make sure the background color does not appear on top of the text. */ + z-index: -1; +} + +/* Multiline */ +.spectrum-Breadcrumbs--multiline { + flex-wrap: wrap; + align-content: center; + + /* The multiline title takes up the full width and appears below the other breadcrumb items. */ + .spectrum-Breadcrumbs-item:last-of-type { + block-size: auto; + inline-size: 100%; + + > .spectrum-Breadcrumbs-itemLink { + margin-inline-start: var(--mod-breadcrumbs-inline-start, var(--spectrum-breadcrumbs-inline-start)); + } + } +} + +@media (forced-colors: active) { + .spectrum-Breadcrumbs { + --highcontrast-breadcrumbs-text-color: LinkText; + --highcontrast-breadcrumbs-text-color-current: CanvasText; + --highcontrast-breadcrumbs-text-color-disabled: GrayText; + --highcontrast-breadcrumbs-separator-color: CanvasText; + --highcontrast-breadcrumbs-action-button-color: LinkText; + --highcontrast-breadcrumbs-action-button-color-disabled: GrayText; + --highcontrast-breadcrumbs-focus-indicator-color: CanvasText; + } } diff --git a/components/breadcrumb/package.json b/components/breadcrumb/package.json index d45d2f9ef4a..5fee7b38c67 100644 --- a/components/breadcrumb/package.json +++ b/components/breadcrumb/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/breadcrumb", - "version": "11.2.0", + "version": "12.0.0-next.3", "description": "The Spectrum CSS breadcrumb component", "license": "Apache-2.0", "author": "Adobe", @@ -24,9 +24,9 @@ }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/actionbutton": ">=7.0.0 <8.0.0", - "@spectrum-css/icon": ">=9.0.0 <10.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/actionbutton": ">=8.0.0-next.0", + "@spectrum-css/icon": ">=10.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/actionbutton": { @@ -40,9 +40,9 @@ } }, "devDependencies": { - "@spectrum-css/actionbutton": "7.2.0", - "@spectrum-css/icon": "9.2.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/actionbutton": "8.0.0-next.4", + "@spectrum-css/icon": "10.0.0-next.3", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/breadcrumb/stories/breadcrumb.stories.js b/components/breadcrumb/stories/breadcrumb.stories.js index a25c76c285c..33faf477ad0 100644 --- a/components/breadcrumb/stories/breadcrumb.stories.js +++ b/components/breadcrumb/stories/breadcrumb.stories.js @@ -1,44 +1,136 @@ import { disableDefaultModes } from "@spectrum-css/preview/modes"; -import { isDragged } from "@spectrum-css/preview/types"; +import { isDragged, size } from "@spectrum-css/preview/types"; import metadata from "../dist/metadata.json"; import packageJson from "../package.json"; import { BreadcrumbGroup } from "./breadcrumb.test.js"; -import { Template } from "./template.js"; +import { BreadcrumbTitleHeadings, Template } from "./template.js"; /** * Breadcrumbs show hierarchy and navigational context for a user's location within an app. - * - * ## Nesting - * Breadcrumbs truncate when there is not enough room to display all levels of the breadcrumb list, or as a way of managing relevance of the visible breadcrumb items in a deeply nested hierarchy. The truncation of breadcrumb items begins when either there is not enough room to display all items, or if there are 5 or more breadcrumbs to display. They are typically indicated by the truncated menu folder icon. - * - * The nested variants below are non-functional. Implementations can add their own overflow menus to display all options within a breadcrumb. - * - * ## Root Context - * Some applications find that displaying the root directory is useful for user orientation. This variation keeps the root visible when other folders are truncated into a menu. For example, when users can navigate file directories on their device as well as in the cloud, exposing a root directory called “On this device” is very helpful. */ export default { title: "Breadcrumbs", component: "Breadcrumbs", argTypes: { - items: { table: { disable: true } }, + items: { + name: "Breadcrumb items", + description: "Additional breadcrumb items after the nav root item, including their label text.
    Advanced:
    • To show an item as disabled, add a key named `isDisabled` with a value of `true`.
    • The \"Show dragged item\" control will affect the item with `isDragged` set to `true`.
    ", + control: "array", + table: { + category: "Content", + }, + }, + size: { + ...size(["m", "l"]), + if: { arg: "variant", neq: "multiline" }, + }, variant: { - name: "Variants", + name: "Variant", type: { name: "string" }, defaultValue: "Default", table: { type: { summary: "string" }, category: "Component", - defaultValue: { summary: "Default" }, }, - options: ["default", "compact", "multiline"], - control: "select", + options: [undefined, "multiline"], + control: { + type: "select", + labels: { + undefined: "Default", + multiline: "Multiline", + }, + }, + }, + isDragged: { + ...isDragged, + name: "Show dragged item", + description: "Breadcrumbs can have optional behavior to allow for drag and drop functionality. Setting this to true will style a breadcrumb item as if something is currently being dragged on top of it.", + }, + titleHeadingSize: { + name: "Breadcrumb title heading size", + description: "The breadcrumb title can be customized in the multiline variant using an additional element that uses the typography component's heading classes. The preferred heading sizes are small, medium, large, and extra-large. When no heading classes are used, the text will be sized the same as a large heading by default.", + type: { name: "string" }, + table: { + type: { summary: "string" }, + category: "Content", + }, + control: { + type: "select", + labels: { + undefined: "Default", + s: "Small", + m: "Medium", + l: "Large", + xl: "Extra-large", + }, + }, + defaultValue: undefined, + options: [undefined, "s", "m", "l", "xl"], + if: { arg: "variant", eq: "multiline" }, + }, + showTruncatedMenu: { + name: "Show truncated menu", + description: "Displays a breadcrumb item with a folder icon, that would house truncated breadcrumb items.", + type: { name: "boolean" }, + table: { + type: { summary: "boolean" }, + category: "State", + }, + control: "boolean", + }, + showRootContext: { + name: "Show with root context", + description: "Includes a visible breadcrumb item before the truncated menu, for displaying a root directory.", + type: { name: "boolean" }, + table: { + type: { summary: "boolean" }, + category: "State", + }, + control: "boolean", + if: { arg: "showTruncatedMenu" }, + }, + truncatedMenuIsDisabled: { + name: "Show truncated menu as disabled", + type: { name: "boolean" }, + table: { + type: { summary: "boolean" }, + category: "State", + }, + control: "boolean", + if: { arg: "showTruncatedMenu" }, + }, + rootItemText: { + name: "Root breadcrumb item label", + type: { name: "string" }, + defaultValue: "Nav root", + table: { + type: { summary: "string" }, + category: "Content", + }, + control: "text", }, - isDragged, }, args: { rootClass: "spectrum-Breadcrumbs", isDragged: false, - variant: "default", + variant: undefined, + size: "m", + showTruncatedMenu: false, + showRootContext: false, + truncatedMenuIsDisabled: false, + rootItemText: "Nav root", + items: [ + { + label: "Sub item", + isDragged: true, + }, + { + label: "Trend", + }, + { + label: "January 2019 assets", + }, + ], }, parameters: { design: { @@ -47,38 +139,30 @@ export default { }, packageJson, metadata, + status: { + type: "migrated", + } }, + tags: ["migrated"], }; /** * By default, breadcrumbs are displayed inline with the hierarchy shown in reading order. + * The medium size is used by default, and it should display the medium truncated menu action button. + * The separator UI icon displayed should be `Chevron100`. */ export const Default = BreadcrumbGroup.bind({}); -Default.args = { - items: [ - { - label: "Nav root", - }, - { - label: "Trend", - isDragged: true, - }, - { - label: "January 2019 assets", - }, - ], -}; +Default.args = {}; +/** + * Breadcrumbs truncate when there is not enough room to display all levels of the breadcrumb list, or as a way of managing relevance of the visible breadcrumb items in a deeply nested hierarchy. The truncation of breadcrumb items begins when either there is not enough room to display all items, or if there are 5 or more breadcrumbs to display. This truncated menu is an icon only action button that typically displays a folder icon. + * + * The nested variants below are non-functional. Implementations should make sure to follow the design guidelines for overflow behavior and displaying all options within the truncated menu. + */ export const DefaultNested = Template.bind({}); DefaultNested.args = { + showTruncatedMenu: true, items: [ - { - iconName: "FolderOpen", - iconSet: "workflow", - }, - { - label: "Sub item", - }, { label: "Trend", }, @@ -91,18 +175,18 @@ DefaultNested.tags = ["!dev"]; DefaultNested.parameters = { chromatic: { disableSnapshot: true }, }; -DefaultNested.storyName = "Default, nested"; +DefaultNested.storyName = "Default, nested (truncated menu)"; +/** + * Some applications find that displaying the root directory is useful for user orientation. This variation keeps the root visible when other folders are + * truncated into a menu. For example, when users can navigate file directories on their device as well as in the cloud, exposing a root directory + * called “On this device” is very helpful. + */ export const DefaultNestedRootVisible = Template.bind({}); DefaultNestedRootVisible.args = { + showTruncatedMenu: true, + showRootContext: true, items: [ - { - label: "Nav root", - }, - { - iconName: "FolderOpen", - iconSet: "workflow", - }, { label: "Trend", }, @@ -115,7 +199,7 @@ DefaultNestedRootVisible.tags = ["!dev"]; DefaultNestedRootVisible.parameters = { chromatic: { disableSnapshot: true }, }; -DefaultNestedRootVisible.storyName = "Default, nested (root visible)"; +DefaultNestedRootVisible.storyName = "Default, nested with root context"; /** * The multiline variation places emphasis on the selected breadcrumb item as a page title, helping a user to more clearly identify their current location. @@ -135,7 +219,7 @@ MultilineNested.args = { ...DefaultNested.args, variant: "multiline", }; -MultilineNested.storyName = "Multiline, nested"; +MultilineNested.storyName = "Multiline, nested (truncated menu)"; MultilineNested.tags= ["!dev"]; MultilineNested.parameters = { chromatic: { disableSnapshot: true }, @@ -150,45 +234,47 @@ MultilineNestedRootVisible.tags = ["!dev"]; MultilineNestedRootVisible.parameters = { chromatic: { disableSnapshot: true }, }; -MultilineNestedRootVisible.storyName = "Multiline, nested (root visible)"; +MultilineNestedRootVisible.storyName = "Multiline, nested with root context"; /** - * When needing to optimize for functional space, the compact option is useful for reducing the height of the breadcrumbs while still maintaining the proper user context. + * When using the large size, the truncated menu action button should also use the large size. The separator UI icon displayed should be `Chevron100`. */ -export const Compact = Template.bind({}); -Compact.args = { +export const Large = Template.bind({}); +Large.args = { ...Default.args, - variant: "compact", + size: "l", }; -Compact.tags = ["!dev"]; -Compact.parameters = { +Large.tags = ["!dev"]; +Large.parameters = { chromatic: { disableSnapshot: true }, }; -export const CompactNested = Template.bind({}); -CompactNested.args = { +export const LargeNested = Template.bind({}); +LargeNested.args = { ...DefaultNested.args, - variant: "compact", + size: "l", }; -CompactNested.tags = ["!dev"]; -CompactNested.parameters = { +LargeNested.tags = ["!dev"]; +LargeNested.parameters = { chromatic: { disableSnapshot: true }, }; -CompactNested.storyName = "Compact, nested"; +LargeNested.storyName = "Large, nested (truncated menu)"; -export const CompactNestedRootVisible = Template.bind({}); -CompactNestedRootVisible.args = { +export const LargeNestedRootVisible = Template.bind({}); +LargeNestedRootVisible.args = { ...DefaultNestedRootVisible.args, - variant: "compact", + size: "l", }; -CompactNestedRootVisible.tags = ["!dev"]; -CompactNestedRootVisible.parameters = { +LargeNestedRootVisible.tags = ["!dev"]; +LargeNestedRootVisible.parameters = { chromatic: { disableSnapshot: true }, }; -CompactNestedRootVisible.storyName = "Compact, nested (root visible)"; +LargeNestedRootVisible.storyName = "Large, nested with root context"; /** * Breadcrumbs can have optional behavior to allow for drag and drop functionality. + * When a breadcrumb item has something being dragged on top of it, the class `is-dragged` is added to it. + * This example adds that class to the second breadcrumb item. */ export const Dragged = Template.bind({}); Dragged.args = { @@ -201,21 +287,16 @@ Dragged.parameters = { }; /** - * The example below has two disabled breadcrumb items. When disabling the text link, the `is-disabled` class gets added to `.spectrum-Breadcrumbs-itemLink`. When disabling the Action button, the `[disabled]` attribute is applied. + * The example below has two disabled breadcrumb items. When disabling the text link, the `is-disabled` class + * gets added to `.spectrum-Breadcrumbs-itemLink`. When disabling the truncated menu action button, the `[disabled]` attribute is applied. */ export const Disabled = Template.bind({}); Disabled.args = { + showTruncatedMenu: true, + truncatedMenuIsDisabled: true, items: [ { - label: "Nav root", - }, - { - iconName: "FolderOpen", - iconSet: "workflow", - isDisabled: true, - }, - { - label: "Trendy", + label: "Trend", isDisabled: true, }, { @@ -228,6 +309,23 @@ Disabled.parameters = { chromatic: { disableSnapshot: true }, }; +/** + * For the multiline variant, the breadcrumb title can be customized using an additional element that uses the heading classes from + * the [typography component](/docs/components-typography--docs). The preferred heading sizes are `.spectrum-Heading--sizeS`, + * `.spectrum-Heading--sizeM`, `.spectrum-Heading--sizeL` (default), and `.spectrum-Heading--sizeXL`. If no heading element or classes are + * used, the text will be sized the same as a large heading by default. + */ +export const MultilineTitleSizes = BreadcrumbTitleHeadings.bind({}); +MultilineTitleSizes.args = { + ...Multiline.args, + showTruncatedMenu: true, +}; +MultilineTitleSizes.storyName = "Multiline, title heading sizes"; +MultilineTitleSizes.tags = ["!dev"]; +MultilineTitleSizes.parameters = { + chromatic: { disableSnapshot: true }, +}; + // ********* VRT ONLY ********* // export const WithForcedColors = BreadcrumbGroup.bind({}); WithForcedColors.args = Default.args; diff --git a/components/breadcrumb/stories/breadcrumb.test.js b/components/breadcrumb/stories/breadcrumb.test.js index f5e33d71c58..ef56e21e722 100644 --- a/components/breadcrumb/stories/breadcrumb.test.js +++ b/components/breadcrumb/stories/breadcrumb.test.js @@ -1,109 +1,94 @@ import { Variants } from "@spectrum-css/preview/decorators"; -import { Template } from "./template.js"; - -const DefaultItems = [ - { - label: "Nav root", - }, - { - label: "Dragged", - isDragged: true, - }, - { - label: "Disabled sub item", - isDisabled: true, - }, - { - label: "January 2019 assets", - }, -]; - -const NestedItems = [ - { - iconName: "FolderOpen", - iconSet: "workflow", - }, - { - label: "Dragged", - isDragged: true, - }, - { - label: "Disabled", - isDisabled: true, - }, - { - label: "January 2019 assets", - }, -]; - -const NestedRootVisibleItems = [ - { - label: "Nav root", - }, - { - iconName: "FolderOpen", - iconSet: "workflow", - isDisabled: true, - }, - { - label: "Dragged sub item", - isDragged: true, - }, - { - label: "January 2019 assets", - }, -]; +import { BreadcrumbTitleHeadings, Template } from "./template.js"; export const BreadcrumbGroup = Variants({ Template, + withSizes: false, testData: [ { testHeading: "Default", - items: DefaultItems, - }, - { - testHeading: "Default (nested)", - items: NestedItems, }, { - testHeading: "Default (nested, root visible)", - items: NestedRootVisibleItems, + testHeading: "Large", + size: "l", }, { - testHeading: "Compact", - variant: "compact", - items: DefaultItems, + testHeading: "Multiline", + variant: "multiline", }, { - testHeading: "Compact (nested)", - variant: "compact", - items: NestedItems, + testHeading: "Multiline with typography headings", + variant: "multiline", + withStates: false, + Template: BreadcrumbTitleHeadings, + showTruncatedMenu: true, + showRootContext: true, + isDragged: true, }, + ], + stateData: [ { - testHeading: "Compact (nested, root visible)", - variant: "compact", - items: NestedRootVisibleItems, + testHeading: "Nested", + showTruncatedMenu: true, }, { - testHeading: "Multiline", - variant: "multiline", - items: DefaultItems, + testHeading: "Nested with root context", + showTruncatedMenu: true, + showRootContext: true, }, { - testHeading: "Multiline (nested)", - variant: "multiline", - items: NestedItems, + testHeading: "Disabled items and dragged item", + isDragged: true, + showTruncatedMenu: true, + truncatedMenuIsDisabled: true, + items: [ + { + label: "Dragged item", + isDragged: true, + }, + { + label: "Disabled sub item", + isDisabled: true, + }, + { + label: "January 2019 assets", + }, + ] }, { - testHeading: "Multiline (nested, root visible)", - variant: "multiline", - items: NestedRootVisibleItems, + testHeading: "Hover", + isDragged: true, + showTruncatedMenu: true, + items: [ + { + label: "Sub item", + isHovered: true, + }, + { + label: "Disabled sub item", + isDisabled: true, + isHovered: true, + }, + { + label: "January 2019 assets", + isHovered: true, + }, + ] }, - ], - stateData: [ { - testHeading: "Dragged, disabled", + testHeading: "Focus-visible", isDragged: true, - } + showTruncatedMenu: true, + items: [ + { + label: "Sub item", + isFocused: true, + }, + { + label: "January 2019 assets", + isFocused: true, + }, + ] + }, ] }); diff --git a/components/breadcrumb/stories/template.js b/components/breadcrumb/stories/template.js index 3f0db2ad30b..0a0ad48c0d9 100644 --- a/components/breadcrumb/stories/template.js +++ b/components/breadcrumb/stories/template.js @@ -1,5 +1,7 @@ import { Template as ActionButton } from "@spectrum-css/actionbutton/stories/template.js"; import { Template as Icon } from "@spectrum-css/icon/stories/template.js"; +import { Container } from "@spectrum-css/preview/decorators"; +import { Template as Typography } from "@spectrum-css/typography/stories/template.js"; import { html } from "lit"; import { classMap } from "lit/directives/class-map.js"; import { ifDefined } from "lit/directives/if-defined.js"; @@ -11,19 +13,43 @@ export const Template = ({ rootClass = "spectrum-Breadcrumbs", customClasses = [], items = [], + size = "m", variant, isDragged = false, + titleHeadingSize, + showTruncatedMenu = false, + showRootContext = false, + truncatedMenuIsDisabled = false, + rootItemText = "Nav root", } = {}, context = {}) => { + /** + * Build array of breadcrumb items. + * - The presence of the root item and truncated menu are dependent upon controls. + * - The rest of the items, including the current item, come from the `items` array. + */ + const breadcrumbItems = [ + ...(showTruncatedMenu == false || showRootContext == true) ? [{ + label: rootItemText, + }] : [], + ...(showTruncatedMenu == true) ? [{ + iconName: "FolderOpen", + iconSet: "workflow", + isDragged: true, + }] : [], + ...items, + ]; + return html` `; }; + +/** + * Displays all preferred sizes for breadcrumb title headings used with the multiline variant. + */ +export const BreadcrumbTitleHeadings = (args, context) => Container({ + withBorder: false, + direction: "column", + wrapperStyles: { + rowGap: "12px", + }, + content: html`${[undefined, "s", "m", "l", "xl"].map((titleHeadingSize) => Container({ + withBorder: true, + heading: typeof titleHeadingSize != "undefined" + ? `Heading size: ${titleHeadingSize}` + : "Default - no heading element or classes", + content: Template({ + ...args, + titleHeadingSize, + }) + }, context))}`, +}, context); diff --git a/components/button/CHANGELOG.md b/components/button/CHANGELOG.md index 30080a3da0d..1b7a5e8d464 100644 --- a/components/button/CHANGELOG.md +++ b/components/button/CHANGELOG.md @@ -1,5 +1,35 @@ # Change log +## 15.0.0-next.2 + +### Patch Changes + +- [#3687](https://github.com/adobe/spectrum-css/pull/3687) [`53d1e5e`](https://github.com/adobe/spectrum-css/commit/53d1e5e7eb7817c37be3cfe5a253363dea744046) Thanks [@marissahuysentruyt](https://github.com/marissahuysentruyt)! - ### S2 button fixes + + This work addresses some regressions noticed in the migrated S2 button. Mainly, the borders were gray where they were not supposed to be. Most of the changes are to ensure that the correct S2 tokens are being used appropriately in the styles and button follows the S2 design specs. + + Additionally, there was some missing style support for the `.spectrum-Button--noWrap` option, so this work reimplements a "no wrapping" option for button components, and removes some of the repetitiveness in the no wrap test cases and story. + + PRs used as reference: + - [S2 button migration](https://github.com/adobe/spectrum-css/pull/2600) + - [Add text wrapping option](https://github.com/adobe/spectrum-css/pull/3086) + - [PostCSS plugin updates/fixes](https://github.com/adobe/spectrum-css/pull/3502) + +## 15.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + - @spectrum-css/progresscircle@6.0.0-next.0 + +## 15.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`a25e0a9`](https://github.com/adobe/spectrum-css/commit/a25e0a99e5a4736ab4e607e00739343101a2633b)]: + - @spectrum-css/icon@10.0.0-next.0 + ## 14.2.0 ### Minor Changes diff --git a/components/button/dist/metadata.json b/components/button/dist/metadata.json index be9fdd8fe84..67e48aa9bd3 100644 --- a/components/button/dist/metadata.json +++ b/components/button/dist/metadata.json @@ -9,42 +9,33 @@ ".spectrum-Button--noWrap .spectrum-Button-label", ".spectrum-Button--sizeL", ".spectrum-Button--sizeS", + ".spectrum-Button--sizeS.spectrum-Button--iconOnly", ".spectrum-Button--sizeXL", ".spectrum-Button-label", ".spectrum-Button-label:empty", ".spectrum-Button.is-disabled", + ".spectrum-Button.is-focused", ".spectrum-Button.is-focused:after", ".spectrum-Button.is-pending", ".spectrum-Button.is-pending .spectrum-Button-label", ".spectrum-Button.is-pending .spectrum-Icon", ".spectrum-Button.is-pending .spectrum-ProgressCircle", - ".spectrum-Button.is-selected", - ".spectrum-Button.is-selected.spectrum-Button--emphasized", ".spectrum-Button.spectrum-Button--accent", - ".spectrum-Button.spectrum-Button--accent.spectrum-Button--fill", - ".spectrum-Button.spectrum-Button--accent.spectrum-Button--outline", + ".spectrum-Button.spectrum-Button--accent .spectrum-Button-label", ".spectrum-Button.spectrum-Button--iconOnly", ".spectrum-Button.spectrum-Button--iconOnly .spectrum-Icon", - ".spectrum-Button.spectrum-Button--iconOnly:after", ".spectrum-Button.spectrum-Button--negative", - ".spectrum-Button.spectrum-Button--negative.spectrum-Button--outline", ".spectrum-Button.spectrum-Button--outline", ".spectrum-Button.spectrum-Button--primary", ".spectrum-Button.spectrum-Button--primary.spectrum-Button--outline", - ".spectrum-Button.spectrum-Button--quiet", ".spectrum-Button.spectrum-Button--secondary", ".spectrum-Button.spectrum-Button--secondary.spectrum-Button--outline", ".spectrum-Button.spectrum-Button--staticBlack", - ".spectrum-Button.spectrum-Button--staticBlack.is-selected", ".spectrum-Button.spectrum-Button--staticBlack.spectrum-Button--outline", - ".spectrum-Button.spectrum-Button--staticBlack.spectrum-Button--quiet", ".spectrum-Button.spectrum-Button--staticBlack.spectrum-Button--secondary", ".spectrum-Button.spectrum-Button--staticBlack.spectrum-Button--secondary.spectrum-Button--outline", ".spectrum-Button.spectrum-Button--staticWhite", - ".spectrum-Button.spectrum-Button--staticWhite.is-selected", - ".spectrum-Button.spectrum-Button--staticWhite.spectrum-Button--accent", ".spectrum-Button.spectrum-Button--staticWhite.spectrum-Button--outline", - ".spectrum-Button.spectrum-Button--staticWhite.spectrum-Button--quiet", ".spectrum-Button.spectrum-Button--staticWhite.spectrum-Button--secondary", ".spectrum-Button.spectrum-Button--staticWhite.spectrum-Button--secondary.spectrum-Button--outline", ".spectrum-Button::-moz-focus-inner", @@ -55,6 +46,8 @@ ".spectrum-Button:focus-visible", ".spectrum-Button:focus-visible:after", ".spectrum-Button:hover", + ".spectrum-Button:not(.spectrum-Button--primary, .spectrum-Button--negative, .spectrum-Button--secondary, .spectrum-Button--staticBlack, .spectrum-Button--staticWhite)", + ".spectrum-Button:not(.spectrum-Button--primary, .spectrum-Button--negative, .spectrum-Button--secondary, .spectrum-Button--staticBlack, .spectrum-Button--staticWhite) .spectrum-Button-label", ".spectrum-Button[pending]", ".spectrum-Button[pending] .spectrum-Button-label", ".spectrum-Button[pending] .spectrum-Icon", @@ -62,8 +55,6 @@ "a.spectrum-Button" ], "modifiers": [ - "--mod-animation-duration-100", - "--mod-bold-font-weight", "--mod-button-animation-duration", "--mod-button-background-color-default", "--mod-button-background-color-disabled", @@ -86,13 +77,13 @@ "--mod-button-edge-to-text", "--mod-button-edge-to-visual", "--mod-button-edge-to-visual-only", - "--mod-button-focus-indicator-gap", "--mod-button-focus-ring-border-radius", "--mod-button-focus-ring-color", "--mod-button-focus-ring-gap", "--mod-button-focus-ring-thickness", "--mod-button-font-family", "--mod-button-font-size", + "--mod-button-font-weight", "--mod-button-height", "--mod-button-icon-margin-block-start", "--mod-button-line-height", @@ -102,15 +93,8 @@ "--mod-button-max-inline-size", "--mod-button-min-width", "--mod-button-padding-label-to-icon", - "--mod-button-static-content-color", - "--mod-button-text-align", - "--mod-button-text-align-with-icon", "--mod-button-top-to-icon", - "--mod-button-top-to-text", - "--mod-focus-indicator-gap", - "--mod-line-height-100", - "--mod-sans-font-family-stack", - "--mod-static-black-focus-indicator-color" + "--mod-button-top-to-text" ], "component": [ "--spectrum-button-animation-duration", @@ -143,21 +127,13 @@ "--spectrum-button-focus-ring-gap", "--spectrum-button-focus-ring-thickness", "--spectrum-button-font-size", + "--spectrum-button-font-weight", "--spectrum-button-height", "--spectrum-button-intended-icon-size", "--spectrum-button-line-height", "--spectrum-button-min-width", "--spectrum-button-minimum-width-multiplier", "--spectrum-button-padding-label-to-icon", - "--spectrum-button-sized-bottom-to-text", - "--spectrum-button-sized-edge-to-text", - "--spectrum-button-sized-edge-to-visual", - "--spectrum-button-sized-edge-to-visual-only", - "--spectrum-button-sized-font-size", - "--spectrum-button-sized-height", - "--spectrum-button-sized-padding-label-to-icon", - "--spectrum-button-sized-top-to-icon", - "--spectrum-button-sized-top-to-text", "--spectrum-button-top-to-icon", "--spectrum-button-top-to-text", "--spectrum-button-top-to-text-extra-large", @@ -170,15 +146,6 @@ "--spectrum-accent-background-color-down", "--spectrum-accent-background-color-hover", "--spectrum-accent-background-color-key-focus", - "--spectrum-accent-color-1000", - "--spectrum-accent-color-1100", - "--spectrum-accent-color-200", - "--spectrum-accent-color-300", - "--spectrum-accent-color-900", - "--spectrum-accent-content-color-default", - "--spectrum-accent-content-color-down", - "--spectrum-accent-content-color-hover", - "--spectrum-accent-content-color-key-focus", "--spectrum-animation-duration-100", "--spectrum-black", "--spectrum-bold-font-weight", @@ -199,10 +166,14 @@ "--spectrum-component-pill-edge-to-visual-only-200", "--spectrum-component-pill-edge-to-visual-only-300", "--spectrum-component-pill-edge-to-visual-only-75", + "--spectrum-component-size-difference-down", + "--spectrum-component-size-minimum-perspective-down", + "--spectrum-component-size-width-ratio-down", "--spectrum-component-top-to-workflow-icon-100", "--spectrum-component-top-to-workflow-icon-200", "--spectrum-component-top-to-workflow-icon-300", "--spectrum-component-top-to-workflow-icon-75", + "--spectrum-corner-radius-full", "--spectrum-disabled-background-color", "--spectrum-disabled-border-color", "--spectrum-disabled-content-color", @@ -212,6 +183,9 @@ "--spectrum-disabled-static-white-background-color", "--spectrum-disabled-static-white-border-color", "--spectrum-disabled-static-white-content-color", + "--spectrum-downstate-height", + "--spectrum-downstate-perspective", + "--spectrum-downstate-width", "--spectrum-focus-indicator-color", "--spectrum-focus-indicator-gap", "--spectrum-focus-indicator-thickness", @@ -224,9 +198,6 @@ "--spectrum-gray-25", "--spectrum-gray-300", "--spectrum-gray-400", - "--spectrum-gray-50", - "--spectrum-gray-500", - "--spectrum-gray-600", "--spectrum-gray-800", "--spectrum-gray-900", "--spectrum-icon-block-size", @@ -235,15 +206,6 @@ "--spectrum-negative-background-color-down", "--spectrum-negative-background-color-hover", "--spectrum-negative-background-color-key-focus", - "--spectrum-negative-color-1000", - "--spectrum-negative-color-1100", - "--spectrum-negative-color-200", - "--spectrum-negative-color-300", - "--spectrum-negative-color-900", - "--spectrum-negative-content-color-default", - "--spectrum-negative-content-color-down", - "--spectrum-negative-content-color-hover", - "--spectrum-negative-content-color-key-focus", "--spectrum-neutral-background-color-default", "--spectrum-neutral-background-color-down", "--spectrum-neutral-background-color-hover", @@ -252,10 +214,6 @@ "--spectrum-neutral-content-color-down", "--spectrum-neutral-content-color-hover", "--spectrum-neutral-content-color-key-focus", - "--spectrum-neutral-subdued-background-color-default", - "--spectrum-neutral-subdued-background-color-down", - "--spectrum-neutral-subdued-background-color-hover", - "--spectrum-neutral-subdued-background-color-key-focus", "--spectrum-progress-circle-thickness-medium", "--spectrum-sans-font-family-stack", "--spectrum-static-black-focus-indicator-color", @@ -284,110 +242,6 @@ "--spectrum-workflow-icon-size-300", "--spectrum-workflow-icon-size-75" ], - "system-theme": [ - "--system-button-background-color-default", - "--system-button-background-color-disabled", - "--system-button-background-color-down", - "--system-button-background-color-focus", - "--system-button-background-color-hover", - "--system-button-border-color-default", - "--system-button-border-color-disabled", - "--system-button-border-color-down", - "--system-button-border-color-focus", - "--system-button-border-color-hover", - "--system-button-primary-content-color-default", - "--system-button-primary-content-color-down", - "--system-button-primary-content-color-focus", - "--system-button-primary-content-color-hover", - "--system-button-primary-outline-background-color-down", - "--system-button-primary-outline-background-color-focus", - "--system-button-primary-outline-background-color-hover", - "--system-button-secondary-background-color-default", - "--system-button-secondary-background-color-down", - "--system-button-secondary-background-color-focus", - "--system-button-secondary-background-color-hover", - "--system-button-secondary-outline-background-color-down", - "--system-button-secondary-outline-background-color-focus", - "--system-button-secondary-outline-background-color-hover", - "--system-button-secondary-outline-border-color-default", - "--system-button-secondary-outline-border-color-down", - "--system-button-selected-background-color-default", - "--system-button-selected-background-color-down", - "--system-button-selected-background-color-focus", - "--system-button-selected-background-color-hover", - "--system-button-static-black-background-color-default", - "--system-button-static-black-background-color-down", - "--system-button-static-black-background-color-focus", - "--system-button-static-black-background-color-hover", - "--system-button-static-black-content-color-default", - "--system-button-static-black-content-color-down", - "--system-button-static-black-content-color-focus", - "--system-button-static-black-content-color-hover", - "--system-button-static-black-outline-background-color-default", - "--system-button-static-black-outline-background-color-down", - "--system-button-static-black-outline-background-color-focus", - "--system-button-static-black-outline-background-color-hover", - "--system-button-static-black-outline-border-color-default", - "--system-button-static-black-outline-border-color-down", - "--system-button-static-black-outline-border-color-focus", - "--system-button-static-black-outline-border-color-hover", - "--system-button-static-black-outline-content-color-default", - "--system-button-static-black-outline-content-color-down", - "--system-button-static-black-outline-content-color-focus", - "--system-button-static-black-outline-content-color-hover", - "--system-button-static-black-secondary-background-color-default", - "--system-button-static-black-secondary-background-color-down", - "--system-button-static-black-secondary-background-color-focus", - "--system-button-static-black-secondary-background-color-hover", - "--system-button-static-black-secondary-content-color-default", - "--system-button-static-black-secondary-content-color-down", - "--system-button-static-black-secondary-content-color-focus", - "--system-button-static-black-secondary-content-color-hover", - "--system-button-static-black-secondary-outline-background-color-default", - "--system-button-static-black-secondary-outline-background-color-down", - "--system-button-static-black-secondary-outline-background-color-focus", - "--system-button-static-black-secondary-outline-background-color-hover", - "--system-button-static-black-secondary-outline-border-color-default", - "--system-button-static-black-secondary-outline-border-color-down", - "--system-button-static-black-secondary-outline-border-color-focus", - "--system-button-static-black-secondary-outline-border-color-hover", - "--system-button-static-white-background-color-default", - "--system-button-static-white-background-color-down", - "--system-button-static-white-background-color-focus", - "--system-button-static-white-background-color-hover", - "--system-button-static-white-content-color-default", - "--system-button-static-white-content-color-down", - "--system-button-static-white-content-color-focus", - "--system-button-static-white-content-color-hover", - "--system-button-static-white-outline-background-color-default", - "--system-button-static-white-outline-background-color-down", - "--system-button-static-white-outline-background-color-focus", - "--system-button-static-white-outline-background-color-hover", - "--system-button-static-white-outline-border-color-default", - "--system-button-static-white-outline-border-color-down", - "--system-button-static-white-outline-border-color-focus", - "--system-button-static-white-outline-border-color-hover", - "--system-button-static-white-outline-content-color-default", - "--system-button-static-white-outline-content-color-down", - "--system-button-static-white-outline-content-color-focus", - "--system-button-static-white-outline-content-color-hover", - "--system-button-static-white-secondary-background-color-default", - "--system-button-static-white-secondary-background-color-down", - "--system-button-static-white-secondary-background-color-focus", - "--system-button-static-white-secondary-background-color-hover", - "--system-button-static-white-secondary-content-color-default", - "--system-button-static-white-secondary-content-color-down", - "--system-button-static-white-secondary-content-color-focus", - "--system-button-static-white-secondary-content-color-hover", - "--system-button-static-white-secondary-outline-background-color-default", - "--system-button-static-white-secondary-outline-background-color-down", - "--system-button-static-white-secondary-outline-background-color-focus", - "--system-button-static-white-secondary-outline-background-color-hover", - "--system-button-static-white-secondary-outline-border-color-default", - "--system-button-static-white-secondary-outline-border-color-down", - "--system-button-static-white-secondary-outline-border-color-focus", - "--system-button-static-white-secondary-outline-border-color-hover" - ], "passthroughs": [ "--mod-progress-circle-position", "--mod-progress-circle-thickness", @@ -409,6 +263,7 @@ "--highcontrast-button-content-color-disabled", "--highcontrast-button-content-color-down", "--highcontrast-button-content-color-focus", - "--highcontrast-button-content-color-hover" + "--highcontrast-button-content-color-hover", + "--highcontrast-button-focus-ring-color" ] } diff --git a/components/button/index.css b/components/button/index.css index cbddb4e2ec1..cc40ddb5227 100644 --- a/components/button/index.css +++ b/components/button/index.css @@ -1,5 +1,5 @@ /*! - * Copyright 2024 Adobe. All rights reserved. + * Copyright 2025 Adobe. All rights reserved. * * This file is licensed to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. You may obtain a copy @@ -11,185 +11,151 @@ * governing permissions and limitations under the License. */ -@import "@spectrum-css/commons/basebutton.css"; -@import "./themes/spectrum-two.css"; - .spectrum-Button { - --spectrum-button-sized-height: var(--spectrum-component-height-100); - --spectrum-button-sized-font-size: var(--spectrum-font-size-100); - - --spectrum-button-sized-edge-to-visual: calc(var(--spectrum-component-pill-edge-to-visual-100) - var(--spectrum-button-border-width)); - --spectrum-button-sized-edge-to-visual-only: var(--spectrum-component-pill-edge-to-visual-only-100); - --spectrum-button-sized-edge-to-text: calc(var(--spectrum-component-pill-edge-to-text-100) - var(--spectrum-button-border-width)); - --spectrum-button-sized-padding-label-to-icon: var(--spectrum-text-to-visual-100); - --spectrum-button-sized-top-to-text: var(--spectrum-button-top-to-text-medium); - --spectrum-button-sized-bottom-to-text: var(--spectrum-button-bottom-to-text-medium); - --spectrum-button-sized-top-to-icon: var(--spectrum-component-top-to-workflow-icon-100); + --spectrum-button-animation-duration: var(--spectrum-animation-duration-100); + + --spectrum-button-focus-ring-gap: var(--spectrum-focus-indicator-gap); + --spectrum-button-focus-ring-thickness: var(--spectrum-focus-indicator-thickness); + --spectrum-button-focus-indicator-color: var(--spectrum-focus-indicator-color); + + --spectrum-button-min-width: calc(var(--spectrum-component-height-100) * var(--spectrum-button-minimum-width-multiplier)); + --spectrum-button-height: var(--spectrum-component-height-100); + + --spectrum-button-border-radius: calc(var(--spectrum-button-height) / 2); + --spectrum-button-border-width: var(--spectrum-border-width-200); + + /* @todo set line-height using font size specific line-height tokens when they are finalized along with the new variable font. */ + --spectrum-button-line-height: 1.2; + --spectrum-button-font-weight: var(--spectrum-bold-font-weight); + --spectrum-button-font-size: var(--spectrum-font-size-100); + + --spectrum-button-edge-to-visual: calc(var(--spectrum-component-pill-edge-to-visual-100) - var(--mod-button-border-width, var(--spectrum-button-border-width))); + --spectrum-button-edge-to-visual-only: calc(var(--spectrum-component-pill-edge-to-visual-only-100) - var(--mod-button-border-width, var(--spectrum-button-border-width))); + --spectrum-button-edge-to-text: calc(var(--spectrum-component-pill-edge-to-text-100) - var(--mod-button-border-width, var(--spectrum-button-border-width))); + --spectrum-button-padding-label-to-icon: var(--spectrum-text-to-visual-100); + --spectrum-button-top-to-text: var(--spectrum-button-top-to-text-medium); + --spectrum-button-bottom-to-text: var(--spectrum-button-bottom-to-text-medium); + --spectrum-button-top-to-icon: var(--spectrum-component-top-to-workflow-icon-100); --spectrum-button-intended-icon-size: var(--spectrum-workflow-icon-size-100); + + --mod-progress-circle-position: absolute; + --spectrum-downstate-perspective: max(var(--spectrum-downstate-height), var(--spectrum-downstate-width) * var(--spectrum-component-size-width-ratio-down)); + + &.spectrum-Button--iconOnly { + --spectrum-button-border-radius: var(--spectrum-corner-radius-full); + } } .spectrum-Button--sizeS { - --spectrum-button-sized-height: var(--spectrum-component-height-75); - --spectrum-button-sized-font-size: var(--spectrum-font-size-75); - - --spectrum-button-sized-edge-to-visual: calc(var(--spectrum-component-pill-edge-to-visual-75) - var(--spectrum-button-border-width)); - --spectrum-button-sized-edge-to-visual-only: var(--spectrum-component-pill-edge-to-visual-only-75); - --spectrum-button-sized-edge-to-text: calc(var(--spectrum-component-pill-edge-to-text-75) - var(--spectrum-button-border-width)); - --spectrum-button-sized-padding-label-to-icon: var(--spectrum-text-to-visual-75); - --spectrum-button-sized-top-to-text: var(--spectrum-button-top-to-text-small); - --spectrum-button-sized-bottom-to-text: var(--spectrum-button-bottom-to-text-small); - --spectrum-button-sized-top-to-icon: var(--spectrum-component-top-to-workflow-icon-75); + --spectrum-button-min-width: calc(var(--spectrum-component-height-75) * var(--spectrum-button-minimum-width-multiplier)); + --spectrum-button-height: var(--spectrum-component-height-75); + + --spectrum-button-font-size: var(--spectrum-font-size-75); + + --spectrum-button-edge-to-visual: calc(var(--spectrum-component-pill-edge-to-visual-75) - var(--mod-button-border-width, var(--spectrum-button-border-width))); + --spectrum-button-edge-to-visual-only: calc(var(--spectrum-component-pill-edge-to-visual-only-75) - var(--mod-button-border-width, var(--spectrum-button-border-width))); + --spectrum-button-edge-to-text: calc(var(--spectrum-component-pill-edge-to-text-75) - var(--mod-button-border-width, var(--spectrum-button-border-width))); + --spectrum-button-padding-label-to-icon: var(--spectrum-text-to-visual-75); + --spectrum-button-top-to-text: var(--spectrum-button-top-to-text-small); + --spectrum-button-bottom-to-text: var(--spectrum-button-bottom-to-text-small); + --spectrum-button-top-to-icon: var(--spectrum-component-top-to-workflow-icon-75); --spectrum-button-intended-icon-size: var(--spectrum-workflow-icon-size-75); + + &.spectrum-Button--iconOnly { + --spectrum-downstate-perspective: var(--spectrum-component-size-minimum-perspective-down); + } } .spectrum-Button--sizeL { - --spectrum-button-sized-height: var(--spectrum-component-height-200); - --spectrum-button-sized-font-size: var(--spectrum-font-size-200); - - --spectrum-button-sized-edge-to-visual: calc(var(--spectrum-component-pill-edge-to-visual-200) - var(--spectrum-button-border-width)); - --spectrum-button-sized-edge-to-visual-only: var(--spectrum-component-pill-edge-to-visual-only-200); - --spectrum-button-sized-edge-to-text: calc(var(--spectrum-component-pill-edge-to-text-200) - var(--spectrum-button-border-width)); - --spectrum-button-sized-padding-label-to-icon: var(--spectrum-text-to-visual-200); - --spectrum-button-sized-top-to-text: var(--spectrum-button-top-to-text-large); - --spectrum-button-sized-bottom-to-text: var(--spectrum-button-bottom-to-text-large); - --spectrum-button-sized-top-to-icon: var(--spectrum-component-top-to-workflow-icon-200); + --spectrum-button-min-width: calc(var(--spectrum-component-height-200) * var(--spectrum-button-minimum-width-multiplier)); + --spectrum-button-height: var(--spectrum-component-height-200); + + --spectrum-button-font-size: var(--spectrum-font-size-200); + + --spectrum-button-edge-to-visual: calc(var(--spectrum-component-pill-edge-to-visual-200) - var(--mod-button-border-width, var(--spectrum-button-border-width))); + --spectrum-button-edge-to-visual-only: calc(var(--spectrum-component-pill-edge-to-visual-only-200) - var(--mod-button-border-width, var(--spectrum-button-border-width))); + --spectrum-button-edge-to-text: calc(var(--spectrum-component-pill-edge-to-text-200) - var(--mod-button-border-width, var(--spectrum-button-border-width))); + --spectrum-button-padding-label-to-icon: var(--spectrum-text-to-visual-200); + --spectrum-button-top-to-text: var(--spectrum-button-top-to-text-large); + --spectrum-button-bottom-to-text: var(--spectrum-button-bottom-to-text-large); + --spectrum-button-top-to-icon: var(--spectrum-component-top-to-workflow-icon-200); --spectrum-button-intended-icon-size: var(--spectrum-workflow-icon-size-200); } .spectrum-Button--sizeXL { - --spectrum-button-sized-height: var(--spectrum-component-height-300); - --spectrum-button-sized-font-size: var(--spectrum-font-size-300); - - --spectrum-button-sized-edge-to-visual: calc(var(--spectrum-component-pill-edge-to-visual-300) - var(--spectrum-button-border-width)); - --spectrum-button-sized-edge-to-visual-only: var(--spectrum-component-pill-edge-to-visual-only-300); - --spectrum-button-sized-edge-to-text: calc(var(--spectrum-component-pill-edge-to-text-300) - var(--spectrum-button-border-width)); - --spectrum-button-sized-padding-label-to-icon: var(--spectrum-text-to-visual-300); - --spectrum-button-sized-top-to-text: var(--spectrum-button-top-to-text-extra-large); - --spectrum-button-sized-bottom-to-text: var(--spectrum-button-bottom-to-text-extra-large); - --spectrum-button-sized-top-to-icon: var(--spectrum-component-top-to-workflow-icon-300); + --spectrum-button-min-width: calc(var(--spectrum-component-height-300) * var(--spectrum-button-minimum-width-multiplier)); + --spectrum-button-height: var(--spectrum-component-height-300); + + --spectrum-button-font-size: var(--spectrum-font-size-300); + + --spectrum-button-edge-to-visual: calc(var(--spectrum-component-pill-edge-to-visual-300) - var(--mod-button-border-width, var(--spectrum-button-border-width))); + --spectrum-button-edge-to-visual-only: calc(var(--spectrum-component-pill-edge-to-visual-only-300) - var(--mod-button-border-width, var(--spectrum-button-border-width))); + --spectrum-button-edge-to-text: calc(var(--spectrum-component-pill-edge-to-text-300) - var(--mod-button-border-width, var(--spectrum-button-border-width))); + --spectrum-button-padding-label-to-icon: var(--spectrum-text-to-visual-300); + --spectrum-button-top-to-text: var(--spectrum-button-top-to-text-extra-large); + --spectrum-button-bottom-to-text: var(--spectrum-button-bottom-to-text-extra-large); + --spectrum-button-top-to-icon: var(--spectrum-component-top-to-workflow-icon-300); --spectrum-button-intended-icon-size: var(--spectrum-workflow-icon-size-300); } -/* default for all buttons */ +/* Variants and colors */ .spectrum-Button { - --spectrum-button-content-color-default: var(--spectrum-neutral-content-color-default); - --spectrum-button-content-color-hover: var(--spectrum-neutral-content-color-hover); - --spectrum-button-content-color-down: var(--spectrum-neutral-content-color-down); - --spectrum-button-content-color-focus: var(--spectrum-neutral-content-color-key-focus); + --spectrum-button-border-color-default: transparent; + --spectrum-button-border-color-hover: transparent; + --spectrum-button-border-color-down: transparent; + --spectrum-button-border-color-focus: transparent; + + --spectrum-button-content-color-default: var(--spectrum-white); + --spectrum-button-content-color-hover: var(--spectrum-white); + --spectrum-button-content-color-down: var(--spectrum-white); + --spectrum-button-content-color-focus: var(--spectrum-white); + + --spectrum-button-background-color-disabled: var(--spectrum-disabled-background-color); + --spectrum-button-border-color-disabled: transparent; --spectrum-button-content-color-disabled: var(--spectrum-disabled-content-color); - &.is-selected { - --spectrum-button-border-color-default: transparent; - --spectrum-button-border-color-hover: transparent; - --spectrum-button-border-color-down: transparent; - --spectrum-button-border-color-focus: transparent; - - --spectrum-button-content-color-default: var(--spectrum-white); - --spectrum-button-content-color-hover: var(--spectrum-white); - --spectrum-button-content-color-down: var(--spectrum-white); - --spectrum-button-content-color-focus: var(--spectrum-white); - - --spectrum-button-background-color-disabled: var(--spectrum-disabled-background-color); - --spectrum-button-border-color-disabled: transparent; - - &.spectrum-Button--emphasized { - --spectrum-button-background-color-default: var(--spectrum-accent-background-color-default); - --spectrum-button-background-color-hover: var(--spectrum-accent-background-color-hover); - --spectrum-button-background-color-down: var(--spectrum-accent-background-color-down); - --spectrum-button-background-color-focus: var(--spectrum-accent-background-color-key-focus); - } + &.spectrum-Button--outline { + --spectrum-button-background-color-disabled: transparent; + --spectrum-button-border-color-disabled: var(--spectrum-disabled-border-color); + --spectrum-button-content-color-disabled: var(--spectrum-disabled-content-color); } + /* ---- Accent ---- */ + /* Also shows as the default when a variant class is not used. */ + &, &.spectrum-Button--accent { --spectrum-button-background-color-default: var(--spectrum-accent-background-color-default); --spectrum-button-background-color-hover: var(--spectrum-accent-background-color-hover); --spectrum-button-background-color-down: var(--spectrum-accent-background-color-down); --spectrum-button-background-color-focus: var(--spectrum-accent-background-color-key-focus); - --spectrum-button-background-color-disabled: var(--spectrum-disabled-background-color); - - --spectrum-button-border-color-default: transparent; - --spectrum-button-border-color-hover: transparent; - --spectrum-button-border-color-down: transparent; - --spectrum-button-border-color-focus: transparent; - --spectrum-button-border-color-disabled: transparent; - - --spectrum-button-content-color-default: var(--spectrum-white); - --spectrum-button-content-color-hover: var(--spectrum-white); - --spectrum-button-content-color-down: var(--spectrum-white); - --spectrum-button-content-color-focus: var(--spectrum-white); - - &.spectrum-Button--outline { - --spectrum-button-background-color-hover: var(--spectrum-accent-color-200); - --spectrum-button-background-color-down: var(--spectrum-accent-color-300); - --spectrum-button-background-color-focus: var(--spectrum-accent-color-200); - - --spectrum-button-border-color-default: var(--spectrum-accent-color-900); - --spectrum-button-border-color-hover: var(--spectrum-accent-color-1000); - --spectrum-button-border-color-down: var(--spectrum-accent-color-1100); - --spectrum-button-border-color-focus: var(--spectrum-accent-color-1000); - --spectrum-button-border-color-disabled: var(--spectrum-disabled-border-color); - - --spectrum-button-content-color-default: var(--spectrum-accent-content-color-default); - --spectrum-button-content-color-hover: var(--spectrum-accent-content-color-hover); - --spectrum-button-content-color-down: var(--spectrum-accent-content-color-down); - --spectrum-button-content-color-focus: var(--spectrum-accent-content-color-key-focus); - --spectrum-button-content-color-disabled: var(--spectrum-disabled-content-color); - } } + /* ---- Negative ---- */ &.spectrum-Button--negative { --spectrum-button-background-color-default: var(--spectrum-negative-background-color-default); --spectrum-button-background-color-hover: var(--spectrum-negative-background-color-hover); --spectrum-button-background-color-down: var(--spectrum-negative-background-color-down); --spectrum-button-background-color-focus: var(--spectrum-negative-background-color-key-focus); - - --spectrum-button-border-color-default: transparent; - --spectrum-button-border-color-hover: transparent; - --spectrum-button-border-color-down: transparent; - --spectrum-button-border-color-focus: transparent; - - --spectrum-button-content-color-default: var(--spectrum-white); - --spectrum-button-content-color-hover: var(--spectrum-white); - --spectrum-button-content-color-down: var(--spectrum-white); - --spectrum-button-content-color-focus: var(--spectrum-white); - - --spectrum-button-background-color-disabled: var(--spectrum-disabled-background-color); - --spectrum-button-border-color-disabled: transparent; - --spectrum-button-content-color-disabled: var(--spectrum-disabled-content-color); - - &.spectrum-Button--outline { - --spectrum-button-background-color-hover: var(--spectrum-negative-color-200); - --spectrum-button-background-color-down: var(--spectrum-negative-color-300); - --spectrum-button-background-color-focus: var(--spectrum-negative-color-200); - - --spectrum-button-border-color-default: var(--spectrum-negative-color-900); - --spectrum-button-border-color-hover: var(--spectrum-negative-color-1000); - --spectrum-button-border-color-down: var(--spectrum-negative-color-1100); - --spectrum-button-border-color-focus: var(--spectrum-negative-color-1000); - --spectrum-button-border-color-disabled: var(--spectrum-disabled-border-color); - - --spectrum-button-content-color-default: var(--spectrum-negative-content-color-default); - --spectrum-button-content-color-hover: var(--spectrum-negative-content-color-hover); - --spectrum-button-content-color-down: var(--spectrum-negative-content-color-down); - --spectrum-button-content-color-focus: var(--spectrum-negative-content-color-key-focus); - --spectrum-button-content-color-disabled: var(--spectrum-disabled-content-color); - } } + /* ---- Primary ---- */ &.spectrum-Button--primary { + --spectrum-button-content-color-default: var(--spectrum-gray-25); + --spectrum-button-content-color-hover: var(--spectrum-gray-25); + --spectrum-button-content-color-down: var(--spectrum-gray-25); + --spectrum-button-content-color-focus: var(--spectrum-gray-25); + --spectrum-button-background-color-default: var(--spectrum-neutral-background-color-default); --spectrum-button-background-color-hover: var(--spectrum-neutral-background-color-hover); --spectrum-button-background-color-down: var(--spectrum-neutral-background-color-down); --spectrum-button-background-color-focus: var(--spectrum-neutral-background-color-key-focus); - --spectrum-button-background-color-disabled: var(--spectrum-disabled-background-color); - - --spectrum-button-border-color-default: transparent; - --spectrum-button-border-color-hover: transparent; - --spectrum-button-border-color-down: transparent; - --spectrum-button-border-color-focus: transparent; - --spectrum-button-border-color-disabled: transparent; &.spectrum-Button--outline { + --spectrum-button-background-color-default: transparent; + --spectrum-button-background-color-hover: var(--spectrum-gray-100); + --spectrum-button-background-color-down: var(--spectrum-gray-100); + --spectrum-button-background-color-focus: var(--spectrum-gray-100); + --spectrum-button-border-color-default: var(--spectrum-gray-800); --spectrum-button-border-color-hover: var(--spectrum-gray-900); --spectrum-button-border-color-down: var(--spectrum-gray-900); @@ -199,246 +165,302 @@ --spectrum-button-content-color-hover: var(--spectrum-neutral-content-color-hover); --spectrum-button-content-color-down: var(--spectrum-neutral-content-color-down); --spectrum-button-content-color-focus: var(--spectrum-neutral-content-color-key-focus); - - --spectrum-button-border-color-disabled: var(--spectrum-disabled-border-color); - --spectrum-button-content-color-disabled: var(--spectrum-disabled-content-color); } } + /* ---- Secondary ---- */ &.spectrum-Button--secondary { - --spectrum-button-background-color-disabled: var(--spectrum-disabled-background-color); - - --spectrum-button-border-color-default: transparent; - --spectrum-button-border-color-hover: transparent; - --spectrum-button-border-color-down: transparent; - --spectrum-button-border-color-focus: transparent; - --spectrum-button-border-color-disabled: transparent; + --spectrum-button-background-color-default: var(--spectrum-gray-100); + --spectrum-button-background-color-hover: var(--spectrum-gray-200); + --spectrum-button-background-color-down: var(--spectrum-gray-200); + --spectrum-button-background-color-focus: var(--spectrum-gray-200); --spectrum-button-content-color-default: var(--spectrum-neutral-content-color-default); --spectrum-button-content-color-hover: var(--spectrum-neutral-content-color-hover); --spectrum-button-content-color-down: var(--spectrum-neutral-content-color-down); --spectrum-button-content-color-focus: var(--spectrum-neutral-content-color-key-focus); - --spectrum-button-content-color-disabled: var(--spectrum-disabled-content-color); &.spectrum-Button--outline { - --spectrum-button-background-color-down: var(--spectrum-gray-400); + --spectrum-button-background-color-default: transparent; + --spectrum-button-background-color-hover: var(--spectrum-gray-100); + --spectrum-button-background-color-down: var(--spectrum-gray-100); + --spectrum-button-background-color-focus: var(--spectrum-gray-100); --spectrum-button-border-color-default: var(--spectrum-gray-300); --spectrum-button-border-color-hover: var(--spectrum-gray-400); + --spectrum-button-border-color-down: var(--spectrum-gray-400); --spectrum-button-border-color-focus: var(--spectrum-gray-400); - --spectrum-button-border-color-disabled: var(--spectrum-disabled-border-color); - - --spectrum-button-content-color-default: var(--spectrum-neutral-content-color-default); - --spectrum-button-content-color-hover: var(--spectrum-neutral-content-color-hover); - --spectrum-button-content-color-down: var(--spectrum-neutral-content-color-down); - --spectrum-button-content-color-focus: var(--spectrum-neutral-content-color-key-focus); - --spectrum-button-content-color-disabled: var(--spectrum-disabled-content-color); } } - &.spectrum-Button--quiet { - --spectrum-button-background-color-hover: var(--spectrum-gray-200); - --spectrum-button-background-color-down: var(--spectrum-gray-300); - --spectrum-button-background-color-focus: var(--spectrum-gray-200); + /* ---- Static White ---- */ + &.spectrum-Button--staticWhite { + --spectrum-button-background-color-default: var(--spectrum-transparent-white-800); + --spectrum-button-background-color-hover: var(--spectrum-transparent-white-900); + --spectrum-button-background-color-down: var(--spectrum-transparent-white-900); + --spectrum-button-background-color-focus: var(--spectrum-transparent-white-900); - --spectrum-button-border-color-default: transparent; - --spectrum-button-border-color-hover: transparent; - --spectrum-button-border-color-down: transparent; - --spectrum-button-border-color-focus: transparent; - --spectrum-button-border-color-disabled: transparent; - } + --spectrum-button-content-color-default: var(--spectrum-black); + --spectrum-button-content-color-hover: var(--spectrum-black); + --spectrum-button-content-color-down: var(--spectrum-black); + --spectrum-button-content-color-focus: var(--spectrum-black); - &.spectrum-Button--staticBlack, - &.spectrum-Button--staticWhite { - --spectrum-button-border-color-default: transparent; - --spectrum-button-border-color-hover: transparent; - --spectrum-button-border-color-down: transparent; - --spectrum-button-border-color-focus: transparent; - --spectrum-button-border-color-disabled: transparent; + --spectrum-button-focus-indicator-color: var(--spectrum-static-white-focus-indicator-color); - &.is-selected { - /* @deprecated previous mapping for --mod-button-static-content-color was applied to the is-selected state */ - --mod-button-content-color-default: var(--mod-button-static-content-color); - --mod-button-content-color-hover: var(--mod-button-static-content-color); - --mod-button-content-color-down: var(--mod-button-static-content-color); - --mod-button-content-color-focus: var(--mod-button-static-content-color); + --spectrum-button-background-color-disabled: var(--spectrum-disabled-static-white-background-color); + --spectrum-button-border-color-disabled: transparent; + --spectrum-button-content-color-disabled: var(--spectrum-disabled-static-white-content-color); - --spectrum-button-border-color-disabled: transparent; + &.spectrum-Button--outline { + --spectrum-button-background-color-default: var(--spectrum-transparent-white-25); + --spectrum-button-background-color-hover: var(--spectrum-transparent-white-100); + --spectrum-button-background-color-down: var(--spectrum-transparent-white-100); + --spectrum-button-background-color-focus: var(--spectrum-transparent-white-100); + + --spectrum-button-border-color-default: var(--spectrum-transparent-white-800); + --spectrum-button-border-color-hover: var(--spectrum-transparent-white-900); + --spectrum-button-border-color-down: var(--spectrum-transparent-white-900); + --spectrum-button-border-color-focus: var(--spectrum-transparent-white-900); + + --spectrum-button-content-color-default: var(--spectrum-transparent-white-800); + --spectrum-button-content-color-hover: var(--spectrum-transparent-white-900); + --spectrum-button-content-color-down: var(--spectrum-transparent-white-900); + --spectrum-button-content-color-focus: var(--spectrum-transparent-white-900); + + --spectrum-button-background-color-disabled: var(--spectrum-transparent-white-25); + --spectrum-button-border-color-disabled: var(--spectrum-disabled-static-white-border-color); + --spectrum-button-content-color-disabled: var(--spectrum-disabled-static-white-content-color); } &.spectrum-Button--secondary { - --spectrum-button-border-color-default: transparent; - --spectrum-button-border-color-hover: transparent; - --spectrum-button-border-color-down: transparent; - --spectrum-button-border-color-focus: transparent; - --spectrum-button-border-color-disabled: transparent; + --spectrum-button-background-color-default: var(--spectrum-transparent-white-100); + --spectrum-button-background-color-hover: var(--spectrum-transparent-white-200); + --spectrum-button-background-color-down: var(--spectrum-transparent-white-200); + --spectrum-button-background-color-focus: var(--spectrum-transparent-white-200); + + --spectrum-button-content-color-default: var(--spectrum-transparent-white-800); + --spectrum-button-content-color-hover: var(--spectrum-transparent-white-900); + --spectrum-button-content-color-down: var(--spectrum-transparent-white-900); + --spectrum-button-content-color-focus: var(--spectrum-transparent-white-900); &.spectrum-Button--outline { - --spectrum-button-background-color-disabled: transparent; + --spectrum-button-background-color-default: var(--spectrum-transparent-white-25); + --spectrum-button-background-color-hover: var(--spectrum-transparent-white-100); + --spectrum-button-background-color-down: var(--spectrum-transparent-white-100); + --spectrum-button-background-color-focus: var(--spectrum-transparent-white-100); + + --spectrum-button-border-color-default: var(--spectrum-transparent-white-300); + --spectrum-button-border-color-hover: var(--spectrum-transparent-white-400); + --spectrum-button-border-color-down: var(--spectrum-transparent-white-400); + --spectrum-button-border-color-focus: var(--spectrum-transparent-white-400); } } - - &.spectrum-Button--quiet { - --spectrum-button-border-color-default: transparent; - --spectrum-button-border-color-hover: transparent; - --spectrum-button-border-color-down: transparent; - --spectrum-button-border-color-focus: transparent; - - --spectrum-button-border-color-disabled: transparent; - } } - &.spectrum-Button--staticWhite { - --spectrum-button-content-color-disabled: var(--spectrum-disabled-static-white-content-color); - --spectrum-button-background-color-disabled: var(--spectrum-disabled-static-white-background-color); - --spectrum-button-focus-indicator-color: var(--spectrum-static-white-focus-indicator-color); + /* ---- Static Black ---- */ + &.spectrum-Button--staticBlack { + --spectrum-button-background-color-default: var(--spectrum-transparent-black-800); + --spectrum-button-background-color-hover: var(--spectrum-transparent-black-900); + --spectrum-button-background-color-down: var(--spectrum-transparent-black-900); + --spectrum-button-background-color-focus: var(--spectrum-transparent-black-900); - &.spectrum-Button--outline { - --spectrum-button-content-color-disabled: var(--spectrum-disabled-static-white-content-color); - --spectrum-button-border-color-disabled: var(--spectrum-disabled-static-white-border-color); - } + --spectrum-button-content-color-default: var(--spectrum-white); + --spectrum-button-content-color-hover: var(--spectrum-white); + --spectrum-button-content-color-down: var(--spectrum-white); + --spectrum-button-content-color-focus: var(--spectrum-white); - &.spectrum-Button--secondary { - --spectrum-button-background-color-disabled: var(--spectrum-disabled-static-white-background-color); - } - } + --spectrum-button-focus-indicator-color: var(--spectrum-static-black-focus-indicator-color); - &.spectrum-Button--staticBlack { - --spectrum-button-content-color-disabled: var(--spectrum-disabled-static-black-content-color); --spectrum-button-background-color-disabled: var(--spectrum-disabled-static-black-background-color); - --spectrum-button-focus-indicator-color: var(--mod-static-black-focus-indicator-color, var(--spectrum-static-black-focus-indicator-color)); + --spectrum-button-border-color-disabled: transparent; + --spectrum-button-content-color-disabled: var(--spectrum-disabled-static-black-content-color); &.spectrum-Button--outline { - --spectrum-button-content-color-disabled: var(--spectrum-disabled-static-black-content-color); + --spectrum-button-background-color-default: var(--spectrum-transparent-black-25); + --spectrum-button-background-color-hover: var(--spectrum-transparent-black-100); + --spectrum-button-background-color-down: var(--spectrum-transparent-black-100); + --spectrum-button-background-color-focus: var(--spectrum-transparent-black-100); + + --spectrum-button-border-color-default: var(--spectrum-transparent-black-800); + --spectrum-button-border-color-hover: var(--spectrum-transparent-black-900); + --spectrum-button-border-color-down: var(--spectrum-transparent-black-900); + --spectrum-button-border-color-focus: var(--spectrum-transparent-black-900); + + --spectrum-button-content-color-default: var(--spectrum-transparent-black-800); + --spectrum-button-content-color-hover: var(--spectrum-transparent-black-900); + --spectrum-button-content-color-down: var(--spectrum-transparent-black-900); + --spectrum-button-content-color-focus: var(--spectrum-transparent-black-900); + + --spectrum-button-background-color-disabled: var(--spectrum-transparent-black-25); --spectrum-button-border-color-disabled: var(--spectrum-disabled-static-black-border-color); + --spectrum-button-content-color-disabled: var(--spectrum-disabled-static-black-content-color); } &.spectrum-Button--secondary { - --spectrum-button-background-color-disabled: var(--spectrum-disabled-static-black-background-color); - } - } + --spectrum-button-background-color-default: var(--spectrum-transparent-black-100); + --spectrum-button-background-color-hover: var(--spectrum-transparent-black-200); + --spectrum-button-background-color-down: var(--spectrum-transparent-black-200); + --spectrum-button-background-color-focus: var(--spectrum-transparent-black-200); - &.spectrum-Button--quiet, - &.spectrum-Button--outline { - --spectrum-button-background-color-default: transparent; - --spectrum-button-background-color-disabled: transparent; + --spectrum-button-content-color-default: var(--spectrum-transparent-black-800); + --spectrum-button-content-color-hover: var(--spectrum-transparent-black-900); + --spectrum-button-content-color-down: var(--spectrum-transparent-black-900); + --spectrum-button-content-color-focus: var(--spectrum-transparent-black-900); + + &.spectrum-Button--outline { + --spectrum-button-background-color-default: var(--spectrum-transparent-black-25); + --spectrum-button-background-color-hover: var(--spectrum-transparent-black-100); + --spectrum-button-background-color-down: var(--spectrum-transparent-black-100); + --spectrum-button-background-color-focus: var(--spectrum-transparent-black-100); + + --spectrum-button-border-color-default: var(--spectrum-transparent-black-300); + --spectrum-button-border-color-hover: var(--spectrum-transparent-black-400); + --spectrum-button-border-color-down: var(--spectrum-transparent-black-400); + --spectrum-button-border-color-focus: var(--spectrum-transparent-black-400); + } + } } } .spectrum-Button { - --spectrum-button-height: var(--mod-button-height, var(--spectrum-button-sized-height)); - --spectrum-button-min-width: var(--mod-button-min-width, calc(var(--spectrum-button-height) * var(--spectrum-button-minimum-width-multiplier))); + cursor: pointer; + user-select: none; + + /* Contain halo */ + position: relative; - --spectrum-button-line-height: var(--mod-button-line-height, 1.2); /* Hack to keep buttons at 32px */ - --spectrum-button-font-size: var(--mod-button-font-size, var(--spectrum-button-sized-font-size)); - --spectrum-button-padding-label-to-icon: var(--mod-button-padding-label-to-icon, var(--spectrum-button-sized-padding-label-to-icon)); + /* Show the button overflow in Edge. */ + overflow: visible; + display: inline-flex; + align-items: center; + justify-content: center; - --spectrum-button-edge-to-visual: var(--mod-button-edge-to-visual, var(--spectrum-button-sized-edge-to-visual)); - --spectrum-button-edge-to-visual-only: var(--mod-button-edge-to-visual-only, var(--spectrum-button-sized-edge-to-visual-only)); - --spectrum-button-edge-to-text: var(--mod-button-edge-to-text, var(--spectrum-button-sized-edge-to-text)); + box-sizing: border-box; - --spectrum-button-top-to-text: var(--mod-button-top-to-text, var(--spectrum-button-sized-top-to-text)); - --spectrum-button-bottom-to-text: var(--mod-button-bottom-to-text, var(--spectrum-button-sized-bottom-to-text)); - --spectrum-button-top-to-icon: var(--mod-button-top-to-icon, var(--spectrum-button-sized-top-to-icon)); + /* Remove button the margin in Firefox and Safari. */ + margin: 0; - --spectrum-button-focus-ring-thickness: var(--mod-button-focus-ring-thickness, var(--spectrum-focus-indicator-thickness)); - --spectrum-button-focus-indicator-color: var(--mod-button-focus-ring-color, var(--spectrum-focus-indicator-color)); + font-family: var(--mod-button-font-family, var(--spectrum-sans-font-family-stack)); - --spectrum-button-animation-duration: var(--mod-button-animation-duration, var(--spectrum-animation-duration-100)); - --spectrum-button-border-width: var(--mod-button-border-width, var(--spectrum-border-width-200)); + /* Adjacent buttons should be aligned correctly */ + vertical-align: top; - --spectrum-button-focus-ring-gap: var(--mod-focus-indicator-gap, var(--mod-button-focus-ring-gap, var(--spectrum-focus-indicator-gap))); - --spectrum-button-border-radius: var(--mod-button-border-radius, calc(var(--spectrum-button-height) / 2)); + -webkit-font-smoothing: antialiased; - /* @passthrough -- align the progress circle in the button */ - --mod-progress-circle-position: absolute; + /* Font smoothing for Firefox */ + -moz-osx-font-smoothing: grayscale; - @extend %spectrum-BaseButton; - @extend %spectrum-ButtonWithFocusRing; + line-height: var(--mod-button-line-height, var(--spectrum-line-height-100)); + text-decoration: none; - border-radius: var(--spectrum-button-border-radius); - border-width: var(--spectrum-button-border-width); + /* Remove the inheritance of text transform on button in Edge, Firefox, and IE. */ + text-transform: none; + + /* stylelint-disable-next-line property-no-vendor-prefix -- Correct the inability to style clickable types in iOS and Safari (normalize). */ + -webkit-appearance: button; + + border-radius: var(--mod-button-border-radius, var(--spectrum-button-border-radius)); + border-width: var(--mod-button-border-width, var(--spectrum-button-border-width)); border-style: solid; - font-size: var(--spectrum-button-font-size); - font-weight: var(--mod-bold-font-weight, var(--spectrum-bold-font-weight)); - gap: var(--spectrum-button-padding-label-to-icon); + font-size: var(--mod-button-font-size, var(--spectrum-button-font-size)); + font-weight: var(--mod-button-font-weight, var(--spectrum-button-font-weight)); + gap: var(--mod-button-padding-label-to-icon, var(--spectrum-button-padding-label-to-icon)); max-inline-size: var(--mod-button-max-inline-size, none); - min-inline-size: var(--spectrum-button-min-width); - min-block-size: var(--spectrum-button-height); + min-inline-size: var(--mod-button-min-width, var(--spectrum-button-min-width)); + min-block-size: var(--mod-button-height, var(--spectrum-button-height)); - /* Start with text-only padding */ padding-block: 0; - padding-inline: var(--spectrum-button-edge-to-text); - position: relative; + padding-inline: var(--mod-button-edge-to-text, var(--spectrum-button-edge-to-text)); + + background-color: var(--highcontrast-button-background-color-default, var(--mod-button-background-color-default, var(--spectrum-button-background-color-default))); + border-color: var(--highcontrast-button-border-color-default, var(--mod-button-border-color-default, var(--spectrum-button-border-color-default))); + color: var(--highcontrast-button-content-color-default, var(--mod-button-content-color-default, var(--spectrum-button-content-color-default))); + transition: + border-color var(--mod-button-animation-duration, var(--spectrum-button-animation-duration, 130ms)) linear, + color var(--mod-button-animation-duration, var(--spectrum-button-animation-duration, 130ms)) linear, + background var(--mod-button-animation-duration, var(--spectrum-button-animation-duration, 130ms)) linear; margin-block: var(--mod-button-margin-block); margin-inline-end: var(--mod-button-margin-right); margin-inline-start: var(--mod-button-margin-left); - background-color: var(--highcontrast-button-background-color-default, var(--mod-button-background-color-default, var(--spectrum-button-background-color-default))); - border-color: var(--highcontrast-button-border-color-default, var(--mod-button-border-color-default, var(--spectrum-button-border-color-default))); + .spectrum-Icon { + /* Any block-size difference between the intended workflow icon size and actual icon used. Helps support any existing use of smaller UI icons instead of intended Workflow icons. */ + --_icon-size-difference: max(0px, var(--spectrum-button-intended-icon-size) - var(--spectrum-icon-block-size, var(--spectrum-button-intended-icon-size))); - /* let staticColor variants inherit their color */ - color: var(--highcontrast-button-content-color-default, var(--mod-button-content-color-default, var(--spectrum-button-content-color-default, inherit))); - transition: - border var(--spectrum-button-animation-duration, 130ms) linear, - color var(--spectrum-button-animation-duration, 130ms) linear, - background-color var(--spectrum-button-animation-duration, 130ms) linear; + margin-block-start: var(--mod-button-icon-margin-block-start, max(0px, var(--mod-button-top-to-icon, var(--spectrum-button-top-to-icon)) - var(--mod-button-border-width, var(--spectrum-button-border-width)) + (var(--_icon-size-difference, 0px) / 2))); - &.spectrum-Button--outline { - background-color: transparent; + margin-inline-start: calc(var(--mod-button-edge-to-visual, var(--spectrum-button-edge-to-visual)) - var(--mod-button-edge-to-text, var(--spectrum-button-edge-to-text))); + color: inherit; + flex-shrink: 0; + align-self: flex-start; } + &:disabled, + &.is-disabled { + cursor: default; + } + + /* Focus indicator */ &::after { + content: ""; + display: block; position: absolute; inset: 0; - margin: var(--mod-button-focus-ring-border-radius, calc((var(--spectrum-button-focus-ring-gap) + var(--spectrum-button-border-width)) * -1)); - transition: box-shadow var(--spectrum-button-animation-duration) ease-in-out; + margin: calc((var(--mod-button-focus-ring-gap, var(--spectrum-button-focus-ring-gap)) + var(--mod-button-border-width, var(--spectrum-button-border-width))) * -1); + border-radius: var(--mod-button-focus-ring-border-radius, calc(var(--mod-button-border-radius, var(--spectrum-button-border-radius)) + var(--mod-button-focus-ring-gap, var(--spectrum-button-focus-ring-gap)))); + transition: box-shadow var(--mod-button-animation-duration, var(--spectrum-button-animation-duration)) ease-in-out; pointer-events: none; - content: ""; + } + + /* Fix Firefox */ + &::-moz-focus-inner { + margin-block-start: -2px; + margin-block-end: -2px; + padding: 0; + border: 0; + + /* Remove the inner border and padding for button in Firefox. */ + border-style: none; + } + + &:focus { + outline: none; + } + + &:focus-visible, + &.is-focused { + box-shadow: none; + outline: none; + + &::after { + box-shadow: 0 0 0 var(--mod-button-focus-ring-thickness, var(--spectrum-button-focus-ring-thickness)) var(--highcontrast-button-focus-ring-color, var(--mod-button-focus-ring-color, var(--spectrum-button-focus-indicator-color))); + } + } - /* correct focus indicator radius for t-shirt sizing */ - border-radius: calc(var(--spectrum-button-border-radius) + var(--spectrum-focus-indicator-gap)); + /* States and interaction */ + &:hover, + &:active { + box-shadow: none; } &:hover { background-color: var(--highcontrast-button-background-color-hover, var(--mod-button-background-color-hover, var(--spectrum-button-background-color-hover))); border-color: var(--highcontrast-button-border-color-hover, var(--mod-button-border-color-hover, var(--spectrum-button-border-color-hover))); color: var(--highcontrast-button-content-color-hover, var(--mod-button-content-color-hover, var(--spectrum-button-content-color-hover))); - box-shadow: none; } &:focus-visible { background-color: var(--highcontrast-button-background-color-focus, var(--mod-button-background-color-focus, var(--spectrum-button-background-color-focus))); border-color: var(--highcontrast-button-border-color-focus, var(--mod-button-border-color-focus, var(--spectrum-button-border-color-focus))); color: var(--highcontrast-button-content-color-focus, var(--mod-button-content-color-focus, var(--spectrum-button-content-color-focus))); - - /* Remove the default focus outline */ - box-shadow: none; - outline: none; - - &::after { - box-shadow: 0 0 0 var(--spectrum-button-focus-ring-thickness) var(--spectrum-button-focus-indicator-color); - } - } - - &:focus-visible, - &.is-focused { - &::after { - box-shadow: 0 0 0 var(--spectrum-button-focus-ring-thickness) var(--spectrum-button-focus-indicator-color); - } } &:active { background-color: var(--highcontrast-button-background-color-down, var(--mod-button-background-color-down, var(--spectrum-button-background-color-down))); border-color: var(--highcontrast-button-border-color-down, var(--mod-button-border-color-down, var(--spectrum-button-border-color-down))); color: var(--highcontrast-button-content-color-down, var(--mod-button-content-color-down, var(--spectrum-button-content-color-down))); - box-shadow: none; - } - - &:hover, - &:active { - box-shadow: none; + transform: perspective(var(--spectrum-downstate-perspective)) translateZ(var(--spectrum-component-size-difference-down)); } &:disabled, @@ -450,51 +472,19 @@ color: var(--highcontrast-button-content-color-disabled, var(--mod-button-content-color-disabled, var(--spectrum-button-content-color-disabled))); } - .spectrum-Icon { - /* Any block-size difference between the intended workflow icon size and actual icon used. Helps support any existing use of smaller UI icons instead of intended Workflow icons. */ - --_icon-size-difference: max(0px, var(--spectrum-button-intended-icon-size) - var(--spectrum-icon-block-size, var(--spectrum-button-intended-icon-size))); - - margin-block-start: var(--mod-button-icon-margin-block-start, max(0px, var(--mod-button-top-to-icon, var(--spectrum-button-top-to-icon)) - var(--mod-button-border-width, var(--spectrum-button-border-width)) + (var(--_icon-size-difference, 0px) / 2))); - - margin-inline-start: calc(var(--mod-button-edge-to-visual, var(--spectrum-button-edge-to-visual)) - var(--mod-button-edge-to-text, var(--spectrum-button-edge-to-text))); - color: inherit; - flex-shrink: 0; - align-self: flex-start; - } - - .spectrum-Icon + .spectrum-Button-label { - text-align: var(--mod-button-text-align-with-icon, start); - } - - &.spectrum-Button--iconOnly { - min-inline-size: unset; - padding: calc(var(--mod-button-edge-to-visual-only, var(--spectrum-button-edge-to-visual-only)) - var(--mod-button-border-width, var(--spectrum-button-border-width))); - border-radius: 50%; - - .spectrum-Icon { - align-self: center; - margin-inline-start: 0; - margin-block-start: 0; - } - - &::after { - border-radius: 50%; - } - } - .spectrum-Icon, .spectrum-Button-label { visibility: visible; opacity: 1; - transition: opacity var(--spectrum-button-animation-duration, 130ms) ease-in-out; + transition: opacity var(--mod-button-animation-duration, var(--spectrum-button-animation-duration, 130ms)) ease-in-out; } .spectrum-ProgressCircle { visibility: hidden; opacity: 0; transition: - opacity var(--spectrum-button-animation-duration, 130ms) ease-in-out, - visibility 0ms linear var(--spectrum-button-animation-duration, 130ms); + opacity var(--mod-button-animation-duration, var(--spectrum-button-animation-duration, 130ms)) ease-in-out, + visibility 0ms linear var(--mod-button-animation-duration, var(--spectrum-button-animation-duration, 130ms)); } &[pending], @@ -506,132 +496,107 @@ visibility: hidden; opacity: 0; transition: - opacity var(--spectrum-button-animation-duration, 130ms) ease-in-out, - visibility 0ms linear var(--spectrum-button-animation-duration, 130ms); + opacity var(--mod-button-animation-duration, var(--spectrum-button-animation-duration, 130ms)) ease-in-out, + visibility 0ms linear var(--mod-button-animation-duration, var(--spectrum-button-animation-duration, 130ms)); } .spectrum-ProgressCircle { visibility: visible; opacity: 1; - transition: opacity var(--spectrum-button-animation-duration, 130ms) ease-in-out; + transition: opacity var(--mod-button-animation-duration, var(--spectrum-button-animation-duration, 130ms)) ease-in-out; } } +} - .spectrum-Icon { - /* Any block-size difference between the intended workflow icon size and actual icon used. - Helps support any existing use of smaller UI icons instead of intended Workflow icons. */ - --_icon-size-difference: max(0px, calc(var(--spectrum-button-intended-icon-size) - var(--spectrum-icon-block-size, var(--spectrum-button-intended-icon-size)))); +a.spectrum-Button { + /* Make link text not selectable */ + user-select: none; - margin-block-start: var(--mod-button-icon-margin-block-start, max(0px, calc(var(--spectrum-button-top-to-icon) - var(--spectrum-button-border-width) + (var(--_icon-size-difference, 0px) / 2)))); + /* stylelint-disable-next-line property-no-vendor-prefix -- Remove appearance for clickable types in iOS and Safari. */ + -webkit-appearance: none; +} - margin-inline-start: calc(var(--spectrum-button-edge-to-visual) - var(--spectrum-button-edge-to-text)); - color: inherit; - flex-shrink: 0; - align-self: flex-start; - } +.spectrum-Button-label { + align-self: start; + justify-self: center; - &.spectrum-Button--iconOnly { - min-inline-size: unset; - padding: calc(var(--spectrum-button-edge-to-visual-only) - var(--spectrum-button-border-width)); - border-radius: 50%; - - .spectrum-Icon { - align-self: center; - margin-inline-start: 0; - margin-block-start: 0; - } + /* Fixes horizontal alignment of text in anchor buttons */ + text-align: center; - &::after { - border-radius: 50%; - } - } + padding-block-start: calc(var(--mod-button-top-to-text, var(--spectrum-button-top-to-text)) - var(--mod-button-border-width, var(--spectrum-button-border-width))); + padding-block-end: calc(var(--mod-button-bottom-to-text, var(--spectrum-button-bottom-to-text)) - var(--mod-button-border-width, var(--spectrum-button-border-width))); + line-height: var(--mod-button-line-height, var(--spectrum-button-line-height)); - .spectrum-Icon + .spectrum-Button-label { - text-align: var(--mod-button-text-align-with-icon, start); + &:empty { + display: none; } } -a.spectrum-Button { - @extend %spectrum-AnchorButton; +/* Disable button label wrap */ +.spectrum-Button--noWrap .spectrum-Button-label { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; } -.spectrum-Button-label { - @extend %spectrum-ButtonLabel; - padding-block-start: calc(var(--spectrum-button-top-to-text) - var(--spectrum-button-border-width)); - padding-block-end: calc(var(--spectrum-button-bottom-to-text) - var(--spectrum-button-border-width)); - line-height: var(--spectrum-button-line-height); - align-self: start; - text-align: var(--mod-button-text-align, center); +.spectrum-Button .spectrum-Icon + .spectrum-Button-label { + text-align: start; +} - /* Disable button label wrap */ - .spectrum-Button--noWrap & { - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; +/* Icon only variant */ +.spectrum-Button.spectrum-Button--iconOnly { + min-inline-size: unset; + padding: var(--mod-button-edge-to-visual-only, var(--spectrum-button-edge-to-visual-only)); + + .spectrum-Icon { + align-self: center; + margin-inline-start: 0; + margin-block-start: 0; } } -/* Windows High Contrast Mode */ +/* Forced colors / high contrast mode */ @media (forced-colors: active) { .spectrum-Button { - --highcontrast-button-content-color-default: ButtonText; - --highcontrast-button-content-color-hover: ButtonText; - --highcontrast-button-content-color-focus: ButtonText; - --highcontrast-button-content-color-down: ButtonText; - --highcontrast-button-content-color-disabled: GrayText; - --highcontrast-button-border-color-default: ButtonBorder; --highcontrast-button-border-color-hover: ButtonBorder; --highcontrast-button-border-color-focus: ButtonBorder; --highcontrast-button-border-color-down: ButtonBorder; + --highcontrast-button-content-color-disabled: GrayText; --highcontrast-button-border-color-disabled: GrayText; - - --highcontrast-button-background-color-default: ButtonFace; - --highcontrast-button-background-color-hover: ButtonFace; - --highcontrast-button-background-color-down: ButtonFace; - --highcontrast-button-background-color-focus: ButtonFace; --highcontrast-button-background-color-disabled: ButtonFace; /* @passthrough start -- progress circle highcontrast overrides */ --mod-progress-circle-track-border-color: ButtonText; --mod-progress-circle-track-border-color-over-background: ButtonText; --mod-progress-circle-thickness: var(--spectrum-progress-circle-thickness-medium); - /* @passthrough end */ - --spectrum-button-animation-duration: 0s; + --highcontrast-button-focus-ring-color: ButtonText; - .spectrum-Button-label { - forced-color-adjust: none; + &:focus-visible { + &::after { + /* Make sure the box-shadow used for the focus indicator is displayed. */ + forced-color-adjust: none; + } } - &:focus-visible::after { - forced-color-adjust: none; - box-shadow: 0 0 0 var(--spectrum-button-focus-ring-thickness) ButtonText; - } + &.spectrum-Button--accent, + &:not(.spectrum-Button--primary, .spectrum-Button--negative, .spectrum-Button--secondary, .spectrum-Button--staticBlack, .spectrum-Button--staticWhite) { + /* The accent fill variant looks different than the other buttons. + It inverts the background and content colors. */ + --highcontrast-button-background-color-default: ButtonText; + --highcontrast-button-content-color-default: ButtonFace; - &.spectrum-Button--accent { - &.spectrum-Button--fill { - --highcontrast-button-background-color-default: ButtonText; - --highcontrast-button-background-color-hover: Highlight; - --highcontrast-button-background-color-down: Highlight; - --highcontrast-button-background-color-focus: Highlight; - --highcontrast-button-background-color-disabled: ButtonFace; - - --highcontrast-button-content-color-default: ButtonFace; - --highcontrast-button-content-color-hover: HighlightText; - --highcontrast-button-content-color-down: HighlightText; - --highcontrast-button-content-color-focus: HighlightText; - - --highcontrast-button-border-color-default: ButtonText; - --highcontrast-button-border-color-hover: Highlight; - --highcontrast-button-border-color-focus: Highlight; - --highcontrast-button-border-color-down: Highlight; - } - } + --highcontrast-button-background-color-hover: Highlight; + --highcontrast-button-background-color-down: Highlight; + --highcontrast-button-background-color-focus: Highlight; + + --highcontrast-button-content-color-hover: HighlightText; + --highcontrast-button-content-color-down: HighlightText; + --highcontrast-button-content-color-focus: HighlightText; - &.spectrum-Button--staticWhite { - &.spectrum-Button--accent { - --highcontrast-button-content-color-disabled: GrayText; + .spectrum-Button-label { + forced-color-adjust: none; } } } diff --git a/components/button/package.json b/components/button/package.json index a43e858d64d..c16bee13017 100644 --- a/components/button/package.json +++ b/components/button/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/button", - "version": "14.2.0", + "version": "15.0.0-next.2", "description": "The Spectrum CSS button component", "license": "Apache-2.0", "author": "Adobe", @@ -19,16 +19,14 @@ "./package.json": "./package.json", "./dist/*": "./dist/*", "./index.css": "./dist/index.css", - "./index-*.css": "./dist/index-*.css", "./metadata.json": "./dist/metadata.json", - "./themes/*": "./dist/themes/*", "./stories/*": "./stories/*" }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/icon": ">=9.0.0 <10.0.0", - "@spectrum-css/progresscircle": ">=5.0.0 <6.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/icon": ">=10.0.0-next.0", + "@spectrum-css/progresscircle": ">=6.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/icon": { @@ -42,10 +40,9 @@ } }, "devDependencies": { - "@spectrum-css/commons": "11.1.0", - "@spectrum-css/icon": "9.2.0", - "@spectrum-css/progresscircle": "5.2.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/icon": "10.0.0-next.3", + "@spectrum-css/progresscircle": "6.0.0-next.0", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/button/stories/button.stories.js b/components/button/stories/button.stories.js index 2de4d54053b..525d230e91a 100644 --- a/components/button/stories/button.stories.js +++ b/components/button/stories/button.stories.js @@ -1,5 +1,5 @@ import { default as IconStories } from "@spectrum-css/icon/stories/icon.stories.js"; -import { Sizes } from "@spectrum-css/preview/decorators"; +import { Sizes, withDownStateDimensionCapture } from "@spectrum-css/preview/decorators"; import { disableDefaultModes } from "@spectrum-css/preview/modes"; import { isActive, isDisabled, isFocused, isHovered, isPending, size, staticColor } from "@spectrum-css/preview/types"; import metadata from "../dist/metadata.json"; @@ -93,9 +93,19 @@ export default { type: "figma", url: "https://www.figma.com/design/Mngz9H7WZLbrCvGQf3GnsY/S2-%2F-Desktop?node-id=707-2774", }, + downState: { + selectors: [".spectrum-Button:not(:disabled)"], + }, packageJson, metadata, + status: { + type: "migrated", + }, }, + decorators: [ + withDownStateDimensionCapture, + ], + tags: ["migrated"], }; export const Default = ButtonGroups.bind({}); @@ -307,6 +317,8 @@ DisableWrapping.tags = ["!dev"]; DisableWrapping.storyName = "Text overflow - disabled text wrap"; DisableWrapping.args = { variant: "primary", + label: "Be a premium member", + noWrap: true, }; DisableWrapping.parameters = { diff --git a/components/button/stories/button.test.js b/components/button/stories/button.test.js index bdc6ee37996..16af7a2fe3a 100644 --- a/components/button/stories/button.test.js +++ b/components/button/stories/button.test.js @@ -60,8 +60,8 @@ const ButtonIconGroup = (args, context) => Container({ testHeading: "UI icon (larger)", content: Template({ ...args, - // UI icon that is larger than workflow sizing: - iconName: "ArrowDown600", + // Largest UI icon from UI icon set: + iconName: "Cross600", iconSet: "ui", }, context), }, @@ -109,8 +109,6 @@ export const ButtonGroups = Variants({ customStyles: { "max-inline-size": "480px", }, - iconName: "Edit", - iconSet: "workflow", label: "An example of text overflow behavior within the button component. When the button text is too long for the horizontal space available, it wraps to form another line.", withStates: false, }, @@ -120,8 +118,6 @@ export const ButtonGroups = Variants({ customStyles: { "max-inline-size": "120px", }, - iconName: "Edit", - iconSet: "workflow", label: "Be a premium member", noWrap: true, withStates: false, diff --git a/components/button/stories/template.js b/components/button/stories/template.js index 16e259bd86f..a910cc0ac37 100644 --- a/components/button/stories/template.js +++ b/components/button/stories/template.js @@ -1,6 +1,6 @@ import { Template as Icon } from "@spectrum-css/icon/stories/template.js"; +import { Template as InfieldProgressCircle } from "@spectrum-css/infieldprogresscircle/stories/template.js"; import { Container, getRandomId } from "@spectrum-css/preview/decorators"; -import { Template as ProgressCircle } from "@spectrum-css/progresscircle/stories/template.js"; import { html } from "lit"; import { classMap } from "lit/directives/class-map.js"; import { ifDefined } from "lit/directives/if-defined.js"; @@ -9,9 +9,6 @@ import { when } from "lit/directives/when.js"; import { capitalize } from "lodash-es"; import "../index.css"; -import "../themes/spectrum.css"; -/* Must be imported last */ -import "../themes/express.css"; export const Template = ({ rootClass = "spectrum-Button", @@ -92,15 +89,12 @@ export const Template = ({ Icon({ iconName, setName: iconSet, size }, context) )} ${when(isPending, () => - ProgressCircle( - { - size: "s", - testId: "progress-circle", - staticColor, - isIndeterminate: true, - }, - context - ) + InfieldProgressCircle({ + size: size, + staticColor, + isIndeterminate: true, + testId: "infield-progress-circle" + }, context) )} `; @@ -187,16 +181,12 @@ export const TextWrapTemplate = (args, context = {}) => Container({ ${Template({ ...args, customStyles: {}, - label: "Be a premium member", - noWrap: true, }, context)} ${Template({ ...args, customStyles: { "max-inline-size": "100%", }, - label: "Be a premium member", - noWrap: true, }, context)} ${Template({ ...args, @@ -205,8 +195,6 @@ export const TextWrapTemplate = (args, context = {}) => Container({ }, iconName: "Star", iconSet: "workflow", - label: "Be a premium member", - noWrap: true, }, context)} `, }, context); diff --git a/components/button/themes/express.css b/components/button/themes/express.css deleted file mode 100644 index 1b4b5618ed8..00000000000 --- a/components/button/themes/express.css +++ /dev/null @@ -1,37 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--express */ - -@import "./spectrum.css"; - -@container style(--system: express) { - .spectrum-Button { - --spectrum-button-background-color-default: var(--spectrum-gray-200); - --spectrum-button-background-color-hover: var(--spectrum-gray-300); - --spectrum-button-background-color-down: var(--spectrum-gray-400); - --spectrum-button-background-color-focus: var(--spectrum-gray-300); - - --spectrum-button-border-color-default: transparent; - --spectrum-button-border-color-hover: transparent; - --spectrum-button-border-color-down: transparent; - --spectrum-button-border-color-focus: transparent; - - &.is-selected { - --spectrum-button-background-color-default: var(--spectrum-neutral-background-color-default); - --spectrum-button-background-color-hover: var(--spectrum-neutral-background-color-hover); - --spectrum-button-background-color-down: var(--spectrum-neutral-background-color-down); - --spectrum-button-background-color-focus: var(--spectrum-neutral-background-color-key-focus); - } - } -} diff --git a/components/button/themes/spectrum-two.css b/components/button/themes/spectrum-two.css deleted file mode 100644 index 1275f3fd45b..00000000000 --- a/components/button/themes/spectrum-two.css +++ /dev/null @@ -1,173 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -@container style(--system: spectrum) { - .spectrum-Button { - --spectrum-button-background-color-default: var(--spectrum-gray-50); - --spectrum-button-background-color-hover: var(--spectrum-gray-100); - --spectrum-button-background-color-down: var(--spectrum-gray-200); - --spectrum-button-background-color-focus: var(--spectrum-gray-100); - - --spectrum-button-border-color-default: var(--spectrum-gray-400); - --spectrum-button-border-color-hover: var(--spectrum-gray-500); - --spectrum-button-border-color-down: var(--spectrum-gray-600); - --spectrum-button-border-color-focus: var(--spectrum-gray-500); - - --spectrum-button-background-color-disabled: transparent; - --spectrum-button-border-color-disabled: var(--spectrum-disabled-border-color); - - &.is-selected { - --spectrum-button-background-color-default: var(--spectrum-neutral-subdued-background-color-default); - --spectrum-button-background-color-hover: var(--spectrum-neutral-subdued-background-color-hover); - --spectrum-button-background-color-down: var(--spectrum-neutral-subdued-background-color-down); - --spectrum-button-background-color-focus: var(--spectrum-neutral-subdued-background-color-key-focus); - } - - &.spectrum-Button--primary { - --spectrum-button-content-color-default: var(--spectrum-gray-25); - --spectrum-button-content-color-hover: var(--spectrum-gray-25); - --spectrum-button-content-color-down: var(--spectrum-gray-25); - --spectrum-button-content-color-focus: var(--spectrum-gray-25); - - &.spectrum-Button--outline { - --spectrum-button-background-color-hover: var(--spectrum-gray-100); - --spectrum-button-background-color-down: var(--spectrum-gray-100); - --spectrum-button-background-color-focus: var(--spectrum-gray-100); - } - } - - &.spectrum-Button--secondary { - --spectrum-button-background-color-default: var(--spectrum-gray-100); - --spectrum-button-background-color-hover: var(--spectrum-gray-200); - --spectrum-button-background-color-down: var(--spectrum-gray-200); - --spectrum-button-background-color-focus: var(--spectrum-gray-200); - - &.spectrum-Button--outline { - --spectrum-button-background-color-hover: var(--spectrum-gray-100); - --spectrum-button-background-color-down: var(--spectrum-gray-100); - --spectrum-button-background-color-focus: var(--spectrum-gray-100); - - --spectrum-button-border-color-default: var(--spectrum-gray-300); - --spectrum-button-border-color-down: var(--spectrum-gray-400); - } - } - - /* static white: double the selector, double the fun (specificity...) */ - &.spectrum-Button--staticWhite { - --spectrum-button-background-color-default: var(--spectrum-transparent-white-800); - --spectrum-button-background-color-hover: var(--spectrum-transparent-white-900); - --spectrum-button-background-color-down: var(--spectrum-transparent-white-900); - --spectrum-button-background-color-focus: var(--spectrum-transparent-white-900); - - --spectrum-button-content-color-default: var(--spectrum-black); - --spectrum-button-content-color-hover: var(--spectrum-black); - --spectrum-button-content-color-down: var(--spectrum-black); - --spectrum-button-content-color-focus: var(--spectrum-black); - - &.spectrum-Button--outline { - --spectrum-button-background-color-default: var(--spectrum-transparent-white-25); - --spectrum-button-background-color-hover: var(--spectrum-transparent-white-100); - --spectrum-button-background-color-down: var(--spectrum-transparent-white-100); - --spectrum-button-background-color-focus: var(--spectrum-transparent-white-100); - - --spectrum-button-content-color-default: var(--spectrum-transparent-white-800); - --spectrum-button-content-color-hover: var(--spectrum-transparent-white-900); - --spectrum-button-content-color-down: var(--spectrum-transparent-white-900); - --spectrum-button-content-color-focus: var(--spectrum-transparent-white-900); - - --spectrum-button-border-color-default: var(--spectrum-transparent-white-800); - --spectrum-button-border-color-hover: var(--spectrum-transparent-white-900); - --spectrum-button-border-color-down: var(--spectrum-transparent-white-900); - --spectrum-button-border-color-focus: var(--spectrum-transparent-white-900); - } - - &.spectrum-Button--secondary { - --spectrum-button-background-color-default: var(--spectrum-transparent-white-100); - --spectrum-button-background-color-hover: var(--spectrum-transparent-white-200); - --spectrum-button-background-color-down: var(--spectrum-transparent-white-200); - --spectrum-button-background-color-focus: var(--spectrum-transparent-white-200); - - --spectrum-button-content-color-default: var(--spectrum-transparent-white-800); - --spectrum-button-content-color-hover: var(--spectrum-transparent-white-900); - --spectrum-button-content-color-down: var(--spectrum-transparent-white-900); - --spectrum-button-content-color-focus: var(--spectrum-transparent-white-900); - - &.spectrum-Button--outline { - --spectrum-button-border-color-default: var(--spectrum-transparent-white-300); - --spectrum-button-border-color-hover: var(--spectrum-transparent-white-400); - --spectrum-button-border-color-down: var(--spectrum-transparent-white-400); - --spectrum-button-border-color-focus: var(--spectrum-transparent-white-400); - - --spectrum-button-background-color-default: var(--spectrum-transparent-white-25); - --spectrum-button-background-color-hover: var(--spectrum-transparent-white-100); - --spectrum-button-background-color-down: var(--spectrum-transparent-white-100); - --spectrum-button-background-color-focus: var(--spectrum-transparent-white-100); - } - } - } - - /* static black */ - &.spectrum-Button--staticBlack { - --spectrum-button-background-color-default: var(--spectrum-transparent-black-800); - --spectrum-button-background-color-hover: var(--spectrum-transparent-black-900); - --spectrum-button-background-color-down: var(--spectrum-transparent-black-900); - --spectrum-button-background-color-focus: var(--spectrum-transparent-black-900); - - --spectrum-button-content-color-default: var(--spectrum-white); - --spectrum-button-content-color-hover: var(--spectrum-white); - --spectrum-button-content-color-down: var(--spectrum-white); - --spectrum-button-content-color-focus: var(--spectrum-white); - - &.spectrum-Button--outline { - --spectrum-button-background-color-default: var(--spectrum-transparent-black-25); - --spectrum-button-background-color-hover: var(--spectrum-transparent-black-100); - --spectrum-button-background-color-down: var(--spectrum-transparent-black-100); - --spectrum-button-background-color-focus: var(--spectrum-transparent-black-100); - - --spectrum-button-content-color-default: var(--spectrum-transparent-black-800); - --spectrum-button-content-color-hover: var(--spectrum-transparent-black-900); - --spectrum-button-content-color-down: var(--spectrum-transparent-black-900); - --spectrum-button-content-color-focus: var(--spectrum-transparent-black-900); - - --spectrum-button-border-color-default: var(--spectrum-transparent-black-800); - --spectrum-button-border-color-hover: var(--spectrum-transparent-black-900); - --spectrum-button-border-color-down: var(--spectrum-transparent-black-900); - --spectrum-button-border-color-focus: var(--spectrum-transparent-black-900); - } - - &.spectrum-Button--secondary { - --spectrum-button-background-color-default: var(--spectrum-transparent-black-100); - --spectrum-button-background-color-hover: var(--spectrum-transparent-black-200); - --spectrum-button-background-color-down: var(--spectrum-transparent-black-200); - --spectrum-button-background-color-focus: var(--spectrum-transparent-black-200); - - --spectrum-button-content-color-default: var(--spectrum-transparent-black-800); - --spectrum-button-content-color-hover: var(--spectrum-transparent-black-900); - --spectrum-button-content-color-down: var(--spectrum-transparent-black-900); - --spectrum-button-content-color-focus: var(--spectrum-transparent-black-900); - - &.spectrum-Button--outline { - --spectrum-button-border-color-default: var(--spectrum-transparent-black-300); - --spectrum-button-border-color-hover: var(--spectrum-transparent-black-400); - --spectrum-button-border-color-down: var(--spectrum-transparent-black-400); - --spectrum-button-border-color-focus: var(--spectrum-transparent-black-400); - - --spectrum-button-background-color-default: var(--spectrum-transparent-black-25); - --spectrum-button-background-color-hover: var(--spectrum-transparent-black-100); - --spectrum-button-background-color-down: var(--spectrum-transparent-black-100); - --spectrum-button-background-color-focus: var(--spectrum-transparent-black-100); - } - } - } - } -} diff --git a/components/button/themes/spectrum.css b/components/button/themes/spectrum.css deleted file mode 100644 index 9f9dc03cd92..00000000000 --- a/components/button/themes/spectrum.css +++ /dev/null @@ -1,148 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--legacy */ - -@import "./spectrum-two.css"; - -@container style(--system: legacy) { - .spectrum-Button { - --spectrum-button-background-color-default: var(--spectrum-gray-75); - --spectrum-button-background-color-hover: var(--spectrum-gray-200); - --spectrum-button-background-color-down: var(--spectrum-gray-300); - --spectrum-button-background-color-focus: var(--spectrum-gray-200); - - &.spectrum-Button--primary { - --spectrum-button-content-color-default: var(--spectrum-white); - --spectrum-button-content-color-hover: var(--spectrum-white); - --spectrum-button-content-color-down: var(--spectrum-white); - --spectrum-button-content-color-focus: var(--spectrum-white); - - &.spectrum-Button--outline { - --spectrum-button-background-color-hover: var(--spectrum-gray-300); - --spectrum-button-background-color-down: var(--spectrum-gray-400); - --spectrum-button-background-color-focus: var(--spectrum-gray-300); - } - } - - &.spectrum-Button--secondary { - --spectrum-button-background-color-default: var(--spectrum-gray-200); - --spectrum-button-background-color-hover: var(--spectrum-gray-300); - --spectrum-button-background-color-down: var(--spectrum-gray-400); - --spectrum-button-background-color-focus: var(--spectrum-gray-300); - - &.spectrum-Button--outline { - --spectrum-button-background-color-hover: var(--spectrum-gray-300); - --spectrum-button-background-color-down: var(--spectrum-gray-400); - --spectrum-button-background-color-focus: var(--spectrum-gray-300); - - --spectrum-button-border-color-default: var(--spectrum-gray-300); - --spectrum-button-border-color-down: var(--spectrum-gray-500); - } - } - - &.spectrum-Button--staticWhite { - --spectrum-button-background-color-default: var(--spectrum-transparent-white-800); - --spectrum-button-background-color-hover: var(--spectrum-transparent-white-900); - --spectrum-button-background-color-down: var(--spectrum-transparent-white-900); - --spectrum-button-background-color-focus: var(--spectrum-transparent-white-900); - - &.spectrum-Button--outline { - --spectrum-button-background-color-hover: var(--spectrum-transparent-white-300); - --spectrum-button-background-color-down: var(--spectrum-transparent-white-400); - --spectrum-button-background-color-focus: var(--spectrum-transparent-white-300); - - --spectrum-button-content-color-default: var(--spectrum-white); - --spectrum-button-content-color-hover: var(--spectrum-white); - --spectrum-button-content-color-down: var(--spectrum-white); - --spectrum-button-content-color-focus: var(--spectrum-white); - - --spectrum-button-border-color-default: var(--spectrum-transparent-white-800); - --spectrum-button-border-color-hover: var(--spectrum-transparent-white-900); - --spectrum-button-border-color-down: var(--spectrum-transparent-white-900); - --spectrum-button-border-color-focus: var(--spectrum-transparent-white-900); - } - - &.spectrum-Button--secondary { - --spectrum-button-background-color-default: var(--spectrum-transparent-white-200); - --spectrum-button-background-color-hover: var(--spectrum-transparent-white-300); - --spectrum-button-background-color-down: var(--spectrum-transparent-white-400); - --spectrum-button-background-color-focus: var(--spectrum-transparent-white-300); - - --spectrum-button-content-color-default: var(--spectrum-white); - --spectrum-button-content-color-hover: var(--spectrum-white); - --spectrum-button-content-color-down: var(--spectrum-white); - --spectrum-button-content-color-focus: var(--spectrum-white); - - &.spectrum-Button--outline { - --spectrum-button-border-color-default: var(--spectrum-transparent-white-300); - --spectrum-button-border-color-hover: var(--spectrum-transparent-white-400); - --spectrum-button-border-color-down: var(--spectrum-transparent-white-500); - --spectrum-button-border-color-focus: var(--spectrum-transparent-white-400); - - --spectrum-button-background-color-default: var(--spectrum-transparent-white-800); - --spectrum-button-background-color-hover: var(--spectrum-transparent-white-300); - --spectrum-button-background-color-down: var(--spectrum-transparent-white-400); - --spectrum-button-background-color-focus: var(--spectrum-transparent-white-300); - } - } - } - - &.spectrum-Button--staticBlack { - --spectrum-button-background-color-default: var(--spectrum-transparent-black-800); - --spectrum-button-background-color-hover: var(--spectrum-transparent-black-900); - --spectrum-button-background-color-down: var(--spectrum-transparent-black-900); - --spectrum-button-background-color-focus: var(--spectrum-transparent-black-900); - - &.spectrum-Button--outline { - --spectrum-button-background-color-hover: var(--spectrum-transparent-black-300); - --spectrum-button-background-color-down: var(--spectrum-transparent-black-400); - --spectrum-button-background-color-focus: var(--spectrum-transparent-black-300); - - --spectrum-button-content-color-default: var(--spectrum-black); - --spectrum-button-content-color-hover: var(--spectrum-black); - --spectrum-button-content-color-down: var(--spectrum-black); - --spectrum-button-content-color-focus: var(--spectrum-black); - - --spectrum-button-border-color-default: var(--spectrum-transparent-black-400); - --spectrum-button-border-color-hover: var(--spectrum-transparent-black-500); - --spectrum-button-border-color-down: var(--spectrum-transparent-black-600); - --spectrum-button-border-color-focus: var(--spectrum-transparent-black-500); - } - - &.spectrum-Button--secondary { - --spectrum-button-background-color-default: var(--spectrum-transparent-black-200); - --spectrum-button-background-color-hover: var(--spectrum-transparent-black-300); - --spectrum-button-background-color-down: var(--spectrum-transparent-black-400); - --spectrum-button-background-color-focus: var(--spectrum-transparent-black-300); - - --spectrum-button-content-color-default: var(--spectrum-black); - --spectrum-button-content-color-hover: var(--spectrum-black); - --spectrum-button-content-color-down: var(--spectrum-black); - --spectrum-button-content-color-focus: var(--spectrum-black); - - &.spectrum-Button--outline { - --spectrum-button-border-color-default: var(--spectrum-transparent-black-300); - --spectrum-button-border-color-hover: var(--spectrum-transparent-black-400); - --spectrum-button-border-color-down: var(--spectrum-transparent-black-500); - --spectrum-button-border-color-focus: var(--spectrum-transparent-black-400); - - --spectrum-button-background-color-default: var(--spectrum-transparent-black-800); - --spectrum-button-background-color-hover: var(--spectrum-transparent-black-300); - --spectrum-button-background-color-down: var(--spectrum-transparent-black-400); - --spectrum-button-background-color-focus: var(--spectrum-transparent-black-300); - } - } - } - } -} diff --git a/components/buttongroup/CHANGELOG.md b/components/buttongroup/CHANGELOG.md index 7b1893b315a..6f85fd05b98 100644 --- a/components/buttongroup/CHANGELOG.md +++ b/components/buttongroup/CHANGELOG.md @@ -1,5 +1,19 @@ # Change log +## 10.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + +## 10.0.0-next.0 + +### Patch Changes + +- Updated dependencies []: + - @spectrum-css/button@15.0.0-next.0 + ## 9.2.0 ### Minor Changes @@ -193,6 +207,7 @@ Output for all component CSS files is now being run through a lightweight optimi ## 6.2.5 🗓 2024-03-07 • 📝 [Commits](https://github.com/adobe/spectrum-css/compare/@spectrum-css/buttongroup@6.2.4...@spectrum-css/buttongroup@6.2.5) + **Note:** Version bump only for package @spectrum-css/buttongroup ## 6.2.4 @@ -248,6 +263,7 @@ Output for all component CSS files is now being run through a lightweight optimi ## 6.1.13 🗓 2023-11-13 • 📝 [Commits](https://github.com/adobe/spectrum-css/compare/@spectrum-css/buttongroup@6.1.12...@spectrum-css/buttongroup@6.1.13) + **Note:** Version bump only for package @spectrum-css/buttongroup ## 6.1.12 @@ -301,6 +317,7 @@ Output for all component CSS files is now being run through a lightweight optimi ## 6.1.4 🗓 2023-08-31 • 📝 [Commits](https://github.com/adobe/spectrum-css/compare/@spectrum-css/buttongroup@6.1.3...@spectrum-css/buttongroup@6.1.4) + **Note:** Version bump only for package @spectrum-css/buttongroup ## 6.1.3 @@ -358,6 +375,7 @@ Output for all component CSS files is now being run through a lightweight optimi ## 6.0.59 🗓 2023-08-03 • 📝 [Commits](https://github.com/adobe/spectrum-css/compare/@spectrum-css/buttongroup@6.0.58...@spectrum-css/buttongroup@6.0.59) + **Note:** Version bump only for package @spectrum-css/buttongroup ## 6.0.58 diff --git a/components/buttongroup/dist/metadata.json b/components/buttongroup/dist/metadata.json index 38d29f26e39..04dc22bce0f 100644 --- a/components/buttongroup/dist/metadata.json +++ b/components/buttongroup/dist/metadata.json @@ -7,6 +7,7 @@ ".spectrum-ButtonGroup.spectrum-ButtonGroup--vertical" ], "modifiers": [ + "--mod-buttongroup-flex-wrap", "--mod-buttongroup-justify-content", "--mod-buttongroup-spacing", "--mod-buttongroup-spacing-horizontal", @@ -19,7 +20,6 @@ "--spectrum-buttongroup-spacing" ], "global": ["--spectrum-spacing-200", "--spectrum-spacing-300"], - "system-theme": [], "passthroughs": [], "high-contrast": [] } diff --git a/components/buttongroup/index.css b/components/buttongroup/index.css index 05019824787..0d65d39c0f2 100644 --- a/components/buttongroup/index.css +++ b/components/buttongroup/index.css @@ -35,7 +35,7 @@ .spectrum-ButtonGroup { display: var(--spectrum-buttongroup-display); flex-direction: var(--spectrum-buttongroup-flex-direction); - flex-wrap: wrap; + flex-wrap: var(--mod-buttongroup-flex-wrap, wrap); gap: var(--spectrum-buttongroup-spacing); justify-content: var(--spectrum-buttongroup-justify-content); diff --git a/components/buttongroup/package.json b/components/buttongroup/package.json index b6bafc5280d..f4e0d27c514 100644 --- a/components/buttongroup/package.json +++ b/components/buttongroup/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/buttongroup", - "version": "9.2.0", + "version": "10.0.0-next.1", "description": "The Spectrum CSS buttongroup component", "license": "Apache-2.0", "author": "Adobe", @@ -24,8 +24,8 @@ }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/button": ">=14.0.0 <15.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/button": ">=15.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/button": { @@ -36,8 +36,8 @@ } }, "devDependencies": { - "@spectrum-css/button": "14.2.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/button": "15.0.0-next.2", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/buttongroup/stories/buttongroup.stories.js b/components/buttongroup/stories/buttongroup.stories.js index ba7e125de76..ae0cab736cb 100644 --- a/components/buttongroup/stories/buttongroup.stories.js +++ b/components/buttongroup/stories/buttongroup.stories.js @@ -64,7 +64,11 @@ export default { }, packageJson, metadata, + status: { + type: "migrated", + }, }, + tags: ["migrated"], }; export const Default = ButtonGroup.bind({}); @@ -74,7 +78,7 @@ Default.tags = ["!autodocs"]; // ********* DOCS ONLY ********* // /** - * Default spacing for Medium, Large, and Extra Large t-shirt sizes. + * Default horizontal spacing for when using medium, large, and extra large buttons. */ export const Horizontal = Template.bind({}); Horizontal.tags = ["!dev"]; @@ -87,7 +91,7 @@ Horizontal.parameters = { }; /** - * Spacing for the Small t-shirt size. + * Horizontal spacing for the small t-shirt size. Should be used with small buttons. */ export const HorizontalSmall = Template.bind({}); HorizontalSmall.tags = ["!dev"]; @@ -102,7 +106,7 @@ HorizontalSmall.parameters = { }; /** - * Default spacing for Medium, Large, and Extra Large t-shirt sizes + * Default vertical spacing for when using medium, large, and extra large buttons. */ export const Vertical = ButtonGroup.bind({}); Vertical.tags = ["!dev"]; @@ -117,7 +121,7 @@ Vertical.parameters = { }; /** - * Spacing for the Small t-shirt size. + * Vertical spacing for the small t-shirt size. Should be used with small buttons. */ export const VerticalSmall = Template.bind({}); VerticalSmall.tags = ["!dev"]; diff --git a/components/calendar/CHANGELOG.md b/components/calendar/CHANGELOG.md index c9b56c906b5..0d36bf42912 100644 --- a/components/calendar/CHANGELOG.md +++ b/components/calendar/CHANGELOG.md @@ -1,5 +1,43 @@ # Change log +## 8.0.0-next.3 + +### Patch Changes + +📝 [#4113](https://github.com/adobe/spectrum-css/pull/4113) [`cf4fc1a`](https://github.com/adobe/spectrum-css/commit/cf4fc1a01d23ba810f45a903ecc29a5c8aae33d1) Thanks [@castastrophe](https://github.com/castastrophe)! + +## Minor linting fixes + +- Removed unused custom properties across multiple components +- Fixed color function notation by converting `rgba()` to `rgb()` where appropriate +- Removed duplicate custom property declarations +- Fixed deprecated CSS properties (e.g., `word-wrap` → `overflow-wrap`) +- Removed unnecessary stylelint-disable comments + +_No visual or functional changes to components._ + +## 8.0.0-next.2 + +### Major Changes + +📝 [#4014](https://github.com/adobe/spectrum-css/pull/4014) [`35c066b`](https://github.com/adobe/spectrum-css/commit/35c066b29c311b1bfcf4507075f13b41222ffc84) Thanks [@castastrophe](https://github.com/castastrophe)! + +This update removes the `dir` attribute polyfill (served via a PostCSS transform to compiled assets) as the fallback is no longer necessary. The`dir` attribute support is available in all supported browsers and has been tested to correctly inherit inside web component shadow DOMs. This is a breaking change **only** to those relying on the `dir` attribute being present for styling, however, the `:dir` pseudo will correctly inherit values from their containers. To correctly determine the `dir` value of a node using JavaScript, you can use `getComputedStyle(node).direction`. + +## 8.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + +## 8.0.0-next.0 + +### Patch Changes + +- Updated dependencies []: + - @spectrum-css/actionbutton@8.0.0-next.0 + ## 7.2.0 ### Minor Changes diff --git a/components/calendar/dist/metadata.json b/components/calendar/dist/metadata.json index 676c81a041f..cc1fb80035c 100644 --- a/components/calendar/dist/metadata.json +++ b/components/calendar/dist/metadata.json @@ -54,8 +54,7 @@ ".spectrum-Calendar-tableCell", ".spectrum-Calendar-tableCell:focus", ".spectrum-Calendar-title", - ".spectrum-Calendar:dir(rtl)", - "[dir=\"rtl\"] .spectrum-Calendar" + ".spectrum-Calendar:dir(rtl)" ], "modifiers": [ "--mod-calendar-border-radius-reset", @@ -176,7 +175,6 @@ "--spectrum-neutral-subdued-content-color-default", "--spectrum-regular-font-weight" ], - "system-theme": ["--system-calendar-day-background-color-selected-disabled"], "passthroughs": [ "--mod-actionbutton-content-color-default", "--mod-actionbutton-edge-to-text", diff --git a/components/calendar/index.css b/components/calendar/index.css index 2ca1bc289aa..352a388d74f 100644 --- a/components/calendar/index.css +++ b/components/calendar/index.css @@ -11,9 +11,9 @@ * governing permissions and limitations under the License. */ -@import "./themes/spectrum-two.css"; - .spectrum-Calendar { + --spectrum-calendar-day-background-color-selected-disabled: rgb(var(--spectrum-gray-100-rgb), 0.4); + --spectrum-calendar-day-width: var(--mod-calendar-day-width, var(--spectrum-component-height-100)); --spectrum-calendar-day-height: var(--mod-calendar-day-height, var(--spectrum-component-height-100)); --spectrum-calendar-day-border-size: var(--mod-calendar-day-border-size, var(--spectrum-border-width-200)); @@ -48,6 +48,7 @@ --spectrum-calendar-day-background: var(--mod-calendar-day-background-color, transparent); --spectrum-calendar-day-background-selected: var(--highcontrast-calendar-day-background-selected, var(--mod-calendar-day-background-color-selected, var(--spectrum-calendar-day-background-color-selected))); --spectrum-calendar-day-background-selected-hover: var(--highcontrast-calendar-day-background-selected-hover, var(--mod-calendar-day-background-color-selected-hover, var(--spectrum-calendar-day-background-color-selected-hover))); + --spectrum-calendar-day-background-color-selected-disabled: rgb(var(--spectrum-gray-100-rgb), 0.4); --spectrum-calendar-day-background-cap-selected: var(--highcontrast-calendar-day-background-cap-selected, var(--mod-calendar-day-background-color-cap-selected, var(--spectrum-calendar-day-background-color-cap-selected))); --spectrum-calendar-day-background-hover: var(--highcontrast-calendar-day-background-hover, var(--mod-calendar-day-background-color-hover, var(--spectrum-calendar-day-background-color-hover))); --spectrum-calendar-day-background-focus: var(--highcontrast-calendar-day-background-focus, var(--mod-calendar-day-background-color-key-focus, var(--spectrum-calendar-day-background-color-key-focus))); @@ -170,8 +171,7 @@ .spectrum-Calendar-prevMonth, .spectrum-Calendar-nextMonth { - /* @passthrough start */ - /* Mimic the placement and sizing of the dates in the grid below */ + /* @passthrough start -- mimic the placement and sizing of the dates in the grid below */ --mod-actionbutton-edge-to-text: var(--spectrum-calendar-day-padding); --mod-actionbutton-min-width: var(--spectrum-calendar-day-width); --mod-actionbutton-content-color-default: var(--spectrum-calendar-button-icon-color); diff --git a/components/calendar/package.json b/components/calendar/package.json index 65bf6775d6a..7c025d0998a 100644 --- a/components/calendar/package.json +++ b/components/calendar/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/calendar", - "version": "7.2.0", + "version": "8.0.0-next.3", "description": "The Spectrum CSS calendar component", "license": "Apache-2.0", "author": "Adobe", @@ -19,15 +19,13 @@ "./package.json": "./package.json", "./dist/*": "./dist/*", "./index.css": "./dist/index.css", - "./index-*.css": "./dist/index-*.css", "./metadata.json": "./dist/metadata.json", - "./themes/*": "./dist/themes/*", "./stories/*": "./stories/*" }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/actionbutton": ">=7.0.0 <8.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/actionbutton": ">=8.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/actionbutton": { @@ -38,8 +36,8 @@ } }, "devDependencies": { - "@spectrum-css/actionbutton": "7.2.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/actionbutton": "8.0.0-next.4", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/calendar/stories/calendar.stories.js b/components/calendar/stories/calendar.stories.js index f461d8fff20..d74c9f1ee31 100644 --- a/components/calendar/stories/calendar.stories.js +++ b/components/calendar/stories/calendar.stories.js @@ -121,7 +121,11 @@ export default { }, packageJson, metadata, + status: { + type: "unmigrated", + }, }, + tags: ["unmigrated"], }; export const Default = CalendarGroup.bind({}); diff --git a/components/calendar/stories/template.js b/components/calendar/stories/template.js index 19c70fe9395..863f5e8d113 100644 --- a/components/calendar/stories/template.js +++ b/components/calendar/stories/template.js @@ -8,9 +8,6 @@ import { repeat } from "lit/directives/repeat.js"; import { styleMap } from "lit/directives/style-map.js"; import "../index.css"; -import "../themes/spectrum.css"; -/* Must be imported last */ -import "../themes/express.css"; export const Template = ({ rootClass = "spectrum-Calendar", diff --git a/components/calendar/themes/express.css b/components/calendar/themes/express.css deleted file mode 100644 index 9fd550418f2..00000000000 --- a/components/calendar/themes/express.css +++ /dev/null @@ -1,16 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--express */ - -@import "./spectrum.css"; diff --git a/components/calendar/themes/spectrum-two.css b/components/calendar/themes/spectrum-two.css deleted file mode 100644 index 3633f5d7c80..00000000000 --- a/components/calendar/themes/spectrum-two.css +++ /dev/null @@ -1,18 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -@container style(--system: spectrum) { - .spectrum-Calendar { - --spectrum-calendar-day-background-color-selected-disabled: rgb(var(--spectrum-gray-100-rgb), 0.4); - } -} diff --git a/components/calendar/themes/spectrum.css b/components/calendar/themes/spectrum.css deleted file mode 100644 index 062c7f2ff54..00000000000 --- a/components/calendar/themes/spectrum.css +++ /dev/null @@ -1,22 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--legacy */ - -@import "./spectrum-two.css"; - -@container style(--system: legacy) { - .spectrum-Calendar { - --spectrum-calendar-day-background-color-selected-disabled: rgb(var(--spectrum-gray-200-rgb), 0.4); - } -} diff --git a/components/card/CHANGELOG.md b/components/card/CHANGELOG.md index 510120b995a..427bdb908f4 100644 --- a/components/card/CHANGELOG.md +++ b/components/card/CHANGELOG.md @@ -1,5 +1,84 @@ # Change log +## 12.0.0-next.3 + +### Patch Changes + +📝 [#4113](https://github.com/adobe/spectrum-css/pull/4113) [`cf4fc1a`](https://github.com/adobe/spectrum-css/commit/cf4fc1a01d23ba810f45a903ecc29a5c8aae33d1) Thanks [@castastrophe](https://github.com/castastrophe)! + +## Minor linting fixes + +- Removed unused custom properties across multiple components +- Fixed color function notation by converting `rgba()` to `rgb()` where appropriate +- Removed duplicate custom property declarations +- Fixed deprecated CSS properties (e.g., `word-wrap` → `overflow-wrap`) +- Removed unnecessary stylelint-disable comments + +_No visual or functional changes to components._ + +## 12.0.0-next.2 + +### Major Changes + +- [#3669](https://github.com/adobe/spectrum-css/pull/3669) [`87d7d99`](https://github.com/adobe/spectrum-css/commit/87d7d99260e758e697668cc17962b0b36d075c65) Thanks [@castastrophe](https://github.com/castastrophe)! + +Previously: + +```css +.spectrum-Card.is-selected::before { + background-color: rgba( + var( + --mod-card-selected-background-color-rgb, + var(--spectrum-card-selected-background-color-rgb) + ), + var(--spectrum-card-selected-background-opacity) + ); +} +``` + +Styles now use `--spectrum-card-selection-background-color` which maps to a transparent global property of `--spectrum-transparent-(black|white)-600` depending on color context. + +Updated: + +```css +.spectrum-Card.is-selected::before { + background-color: var( + --mod-card-background-color-selected, + var(--spectrum-card-selection-background-color) + ); +} +``` + +#### Removed variants + +Removed the quiet variant which is no longer supported in Spectrum 2. + +#### Removed/replaced properties + +- `--mod-card-selected-background-color-rgb`. Use `--mod-card-background-color-selected` to override the selected background color. +- `--mod-card-content-margin-top-quiet`. Use `--mod-card-content-margin-top` with appropriate selectors to override. +- `--mod-card-minimum-width-quiet`. Use `--mod-card-minimum-width` with appropriate selectors to override. +- `--mod-card-actions-background-color-rgb`. No replacement, using token value `--spectrum-card-selection-background-color` directly. +- `--mod-card-actions-background-color-opacity`. No replacement, using token value `--spectrum-card-selection-background-color` directly. + +## 12.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + - @spectrum-css/asset@8.0.0-next.0 + - @spectrum-css/typography@9.0.0-next.0 + +## 12.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`a25e0a9`](https://github.com/adobe/spectrum-css/commit/a25e0a99e5a4736ab4e607e00739343101a2633b)]: + - @spectrum-css/icon@10.0.0-next.0 + - @spectrum-css/actionbutton@8.0.0-next.0 + - @spectrum-css/checkbox@11.0.0-next.0 + ## 11.2.0 ### Minor Changes diff --git a/components/card/dist/metadata.json b/components/card/dist/metadata.json index 54eb899211d..d1d22100c30 100644 --- a/components/card/dist/metadata.json +++ b/components/card/dist/metadata.json @@ -22,23 +22,6 @@ ".spectrum-Card--horizontal .spectrum-Card-preview", ".spectrum-Card--horizontal .spectrum-Card-title", ".spectrum-Card--horizontal:hover .spectrum-Card-preview", - ".spectrum-Card--quiet", - ".spectrum-Card--quiet .spectrum-Card-body", - ".spectrum-Card--quiet .spectrum-Card-footer", - ".spectrum-Card--quiet .spectrum-Card-preview", - ".spectrum-Card--quiet .spectrum-Card-preview:after", - ".spectrum-Card--quiet .spectrum-Card-preview:before", - ".spectrum-Card--quiet.is-drop-target", - ".spectrum-Card--quiet.is-drop-target .spectrum-Card-preview", - ".spectrum-Card--quiet.is-drop-target .spectrum-Card-preview:before", - ".spectrum-Card--quiet.is-focused .spectrum-Card-preview:after", - ".spectrum-Card--quiet.is-focused:after", - ".spectrum-Card--quiet.is-selected .spectrum-Card-preview", - ".spectrum-Card--quiet.is-selected .spectrum-Card-preview:before", - ".spectrum-Card--quiet:before", - ".spectrum-Card--quiet:focus .spectrum-Card-preview:after", - ".spectrum-Card--quiet:focus:after", - ".spectrum-Card--quiet:hover .spectrum-Card-preview", ".spectrum-Card-actionButton", ".spectrum-Card-actions", ".spectrum-Card-body", @@ -60,7 +43,6 @@ ".spectrum-Card.is-selected .spectrum-Card-quickActions", ".spectrum-Card.is-selected:before", ".spectrum-Card.spectrum-Card--gallery", - ".spectrum-Card.spectrum-Card--quiet", ".spectrum-Card:after", ".spectrum-Card:before", ".spectrum-Card:focus .spectrum-Card-actions", @@ -75,8 +57,6 @@ ], "modifiers": [ "--mod-animation-duration-100", - "--mod-card-actions-background-color-opacity", - "--mod-card-actions-background-color-rgb", "--mod-card-actions-border-radius", "--mod-card-actions-drop-shadow-blur", "--mod-card-actions-drop-shadow-color", @@ -87,6 +67,7 @@ "--mod-card-animation-duration", "--mod-card-background-color", "--mod-card-background-color-hover", + "--mod-card-background-color-selected", "--mod-card-body-font-color", "--mod-card-body-font-family", "--mod-card-body-font-size", @@ -104,7 +85,6 @@ "--mod-card-border-width", "--mod-card-content-margin-bottom", "--mod-card-content-margin-top", - "--mod-card-content-margin-top-quiet", "--mod-card-corner-radius", "--mod-card-divider-color", "--mod-card-focus-indicator-color", @@ -117,10 +97,8 @@ "--mod-card-horizontal-body-padding", "--mod-card-horizontal-preview-padding", "--mod-card-minimum-width", - "--mod-card-minimum-width-quiet", "--mod-card-preview-background-color", "--mod-card-preview-background-color-hover", - "--mod-card-preview-border-width-selected", "--mod-card-preview-minimum-height", "--mod-card-selected-background-color-rgb", "--mod-card-selected-background-opacity", @@ -135,8 +113,6 @@ "--mod-overlay-animation-duration" ], "component": [ - "--spectrum-card-actions-background-color-opacity", - "--spectrum-card-actions-background-color-rgb", "--spectrum-card-actions-border-radius", "--spectrum-card-actions-drop-shadow-blur", "--spectrum-card-actions-drop-shadow-color", @@ -155,6 +131,7 @@ "--spectrum-card-body-spacing", "--spectrum-card-border-color", "--spectrum-card-border-color-hover", + "--spectrum-card-border-color-selected", "--spectrum-card-border-width", "--spectrum-card-content-margin-bottom", "--spectrum-card-content-margin-top", @@ -168,11 +145,10 @@ "--spectrum-card-minimum-width", "--spectrum-card-preview-background-color", "--spectrum-card-preview-background-color-hover", - "--spectrum-card-preview-border-width-selected", "--spectrum-card-preview-minimum-height", "--spectrum-card-selected-background-color-rgb", "--spectrum-card-selected-background-opacity", - "--spectrum-card-selection-background-color-opacity", + "--spectrum-card-selection-background-color", "--spectrum-card-selection-background-size", "--spectrum-card-subtitle-padding-right", "--spectrum-card-title-font-color", @@ -202,7 +178,6 @@ "--spectrum-focus-indicator-color", "--spectrum-focus-indicator-thickness", "--spectrum-gray-100", - "--spectrum-gray-100-rgb", "--spectrum-gray-200", "--spectrum-heading-color", "--spectrum-heading-line-height", @@ -215,13 +190,6 @@ "--spectrum-spacing-300", "--spectrum-spacing-400" ], - "system-theme": [ - "--system-card-border-color", - "--system-card-border-color-hover", - "--system-card-divider-color", - "--system-card-preview-background-color", - "--system-card-preview-background-color-hover" - ], "passthroughs": [], "high-contrast": [] } diff --git a/components/card/index.css b/components/card/index.css index f540ebbea38..472e79504f2 100644 --- a/components/card/index.css +++ b/components/card/index.css @@ -11,9 +11,15 @@ * governing permissions and limitations under the License. */ -@import "./themes/spectrum-two.css"; - .spectrum-Card { + --spectrum-card-border-color: var(--mod-card-border-color, var(--spectrum-gray-100)); + --spectrum-card-border-color-hover: var(--mod-card-border-color-hover, var(--spectrum-gray-200)); + --spectrum-card-border-color-selected: var(--mod-card-border-color-selected, var(--spectrum-blue-700)); + + --spectrum-card-divider-color: var(--mod-card-divider-color, var(--spectrum-gray-200)); + --spectrum-card-preview-background-color: var(--mod-card-preview-background-color, var(--mod-card-background-color, var(--spectrum-gray-100))); + --spectrum-card-preview-background-color-hover: var(--mod-card-preview-background-color-hover, var(--mod-card-background-color-hover, var(--spectrum-gray-200))); + /* Default Layout */ --spectrum-card-background-color: var(--mod-card-background-color, var(--spectrum-background-layer-2-color)); --spectrum-card-body-spacing: var(--mod-card-body-spacing, var(--spectrum-spacing-400)); @@ -47,9 +53,6 @@ --spectrum-card-actions-size: var(--mod-card-actions-size, var(--spectrum-card-selection-background-size)); --spectrum-card-actions-border-radius: var(--mod-card-actions-border-radius, var(--spectrum-corner-radius-100)); - /* TODO update to --spectrum-card-selection-background-color token once an RGB stripped value is available */ - --spectrum-card-actions-background-color-rgb: var(--mod-card-actions-background-color-rgb, var(--spectrum-gray-100-rgb)); - --spectrum-card-actions-background-color-opacity: var(--mod-card-actions-background-color-opacity, var(--spectrum-card-selection-background-color-opacity)); --spectrum-card-actions-drop-shadow-color: var(--mod-card-actions-drop-shadow-color, var(--spectrum-drop-shadow-color)); --spectrum-card-actions-drop-shadow-x: var(--mod-card-actions-drop-shadow-x, var(--spectrum-drop-shadow-x)); --spectrum-card-actions-drop-shadow-y: var(--mod-card-actions-drop-shadow-y, var(--spectrum-drop-shadow-y)); @@ -62,28 +65,14 @@ /* Selected */ --spectrum-card-selected-background-opacity: var(--mod-card-selected-background-opacity, 0.1); /* table-selected-row-background-opacity does not exist in tokens yet */ - --spectrum-card-preview-border-width-selected: var(--mod-card-preview-border-width-selected, var(--spectrum-border-width-100)); - /* Horizontal */ --spectrum-card-horizontal-body-padding: var(--mod-card-horizontal-body-padding, var(--spectrum-spacing-300)); --spectrum-card-horizontal-preview-padding: var(--mod-card-horizontal-preview-padding, var(--spectrum-spacing-200)); - &.spectrum-Card--quiet { - --mod-card-minimum-width: var(--mod-card-minimum-width-quiet); - --mod-card-content-margin-top: var(--mod-card-content-margin-top-quiet, var(--spectrum-spacing-100)); - } - &.spectrum-Card--gallery { --spectrum-card-content-margin-top: var(--spectrum-spacing-100); } - &.is-selected, - &.is-drop-target { - --spectrum-card-border-color: var(--mod-card-border-color-selected, var(--spectrum-blue-700)); - } -} - -.spectrum-Card { position: relative; display: inline-flex; flex-direction: column; @@ -91,10 +80,11 @@ text-decoration: none; min-inline-size: var(--mod-card-minimum-width, var(--spectrum-card-minimum-width)); + block-size: 100%; border: var(--spectrum-card-border-width) solid transparent; border-radius: var(--spectrum-card-corner-radius); - border-color: var(--mod-card-border-color, var(--spectrum-card-border-color)); + border-color: var(--spectrum-card-border-color); background-color: var(--spectrum-card-background-color); @@ -144,11 +134,16 @@ } &:hover { - --mod-card-border-color: var(--mod-card-border-color-hover, var(--spectrum-card-border-color-hover)); + --mod-card-border-color: var(--spectrum-card-border-color-hover); } - &.is-selected::before { - background-color: rgb(var(--mod-card-selected-background-color-rgb, var(--spectrum-card-selected-background-color-rgb)), var(--spectrum-card-selected-background-opacity)); + &.is-selected { + --mod-card-border-color: var(--spectrum-card-border-color-selected); + + &::before { + /* @deprecated --mod-card-selected-background-color-rgb. Use --mod-card-background-color-selected instead. */ + background-color: var(--mod-card-background-color-selected, var(--spectrum-card-selection-background-color)); + } } &.is-drop-target { @@ -178,7 +173,7 @@ inline-size: var(--spectrum-card-actions-size); block-size: var(--spectrum-card-actions-size); border-radius: var(--spectrum-card-actions-border-radius); - background-color: rgb(var(--spectrum-card-actions-background-color-rgb), var(--spectrum-card-actions-background-color-opacity)); + background-color: var(--spectrum-card-selection-background-color); inset-inline-start: calc(var(--spectrum-card-actions-spacing) - var(--spectrum-card-border-width)); inset-block-start: calc(var(--spectrum-card-actions-spacing) - var(--spectrum-card-border-width)); @@ -219,8 +214,8 @@ background-size: cover; background-position: center center; - background-color: var(--mod-card-preview-background-color, var(--spectrum-card-preview-background-color)); - border-block-end-color: var(--mod-card-border-color, var(--spectrum-card-border-color)); + background-color: var(--spectrum-card-preview-background-color); + border-block-end-color: var(--spectrum-card-border-color); } .spectrum-Card .spectrum-Divider { @@ -291,7 +286,7 @@ color: var(--spectrum-card-body-font-color); line-height: var(--spectrum-card-body-line-height); - border-block-start: var(--spectrum-card-border-width) solid var(--mod-card-divider-color, var(--spectrum-card-divider-color)); + border-block-start: var(--spectrum-card-border-width) solid var(--spectrum-card-divider-color); } .spectrum-Card-header { @@ -304,30 +299,6 @@ z-index: 1; } -.spectrum-Card--quiet { - .spectrum-Card-preview { - border: var(--spectrum-card-focus-indicator-width) solid transparent; - } - - &:focus, - &.is-focused { - /* Quiet cards only have the focus indicator around the preview */ - &::after { - border-width: 0; - } - - .spectrum-Card-preview::after { - border-color: var(--spectrum-card-focus-indicator-color); - } - } - - &.is-selected .spectrum-Card-preview { - border: var(--spectrum-card-preview-border-width-selected) solid; - border-color: var(--spectrum-card-border-color); - } -} - -.spectrum-Card--quiet, .spectrum-Card--gallery { --mod-card-border-color-hover: transparent; @@ -336,7 +307,6 @@ overflow: visible; border-color: transparent; background-color: transparent; - block-size: 100%; &::before { display: none; @@ -344,7 +314,7 @@ .spectrum-Card-preview { border-radius: var(--spectrum-card-corner-radius); - background-color: var(--mod-card-preview-background-color, var(--mod-card-background-color, var(--spectrum-card-preview-background-color))); + background-color: var(--spectrum-card-preview-background-color); min-block-size: var(--mod-card-preview-minimum-height, var(--spectrum-card-preview-minimum-height)); inline-size: 100%; flex: 1; @@ -386,7 +356,7 @@ } &:hover .spectrum-Card-preview { - background-color: var(--mod-card-preview-background-color-hover, var(--mod-card-background-color-hover, var(--spectrum-card-preview-background-color-hover))); + background-color: var(--spectrum-card-preview-background-color-hover); } &.is-drop-target { @@ -396,7 +366,7 @@ .spectrum-Card-preview { transition: none; - background-color: var(--mod-card-preview-background-color, var(--mod-card-background-color, var(--spectrum-card-preview-background-color))); + background-color: var(--spectrum-card-preview-background-color); } .spectrum-Card-preview::before { @@ -424,7 +394,7 @@ flex-direction: row; &:hover .spectrum-Card-preview { - border-color: var(--mod-card-border-color-hover, var(--spectrum-card-border-color-hover)); + --mod-card-border-color: var(--spectrum-card-border-color-hover); } .spectrum-Card-preview { @@ -440,8 +410,8 @@ border-end-end-radius: 0; padding: var(--spectrum-card-horizontal-preview-padding); - background-color: var(--mod-card-preview-background-color, var(--spectrum-card-preview-background-color)); - border-color: var(--mod-card-border-color, var(--spectrum-card-border-color)); + background-color: var(--spectrum-card-preview-background-color); + border-color: var(--spectrum-card-border-color); } .spectrum-Card-header, diff --git a/components/card/package.json b/components/card/package.json index 28b29cf2993..90c6910a0f8 100644 --- a/components/card/package.json +++ b/components/card/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/card", - "version": "11.2.0", + "version": "12.0.0-next.3", "description": "The Spectrum CSS card component", "license": "Apache-2.0", "author": "Adobe", @@ -19,20 +19,18 @@ "./package.json": "./package.json", "./dist/*": "./dist/*", "./index.css": "./dist/index.css", - "./index-*.css": "./dist/index-*.css", "./metadata.json": "./dist/metadata.json", - "./themes/*": "./dist/themes/*", "./stories/*": "./stories/*" }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/actionbutton": ">=7.0.0 <8.0.0", - "@spectrum-css/asset": ">=7.0.0 <8.0.0", - "@spectrum-css/checkbox": ">=10.0.0 <11.0.0", - "@spectrum-css/icon": ">=9.0.0 <10.0.0", + "@spectrum-css/actionbutton": ">=8.0.0-next.0", + "@spectrum-css/asset": ">=8.0.0-next.0", + "@spectrum-css/checkbox": ">=11.0.0-next.0", + "@spectrum-css/icon": ">=10.0.0-next.0", "@spectrum-css/quickaction": ">=3", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0", - "@spectrum-css/typography": ">=8.0.0 <9.0.0" + "@spectrum-css/tokens": ">=16.1.0-next.0", + "@spectrum-css/typography": ">=9.0.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/actionbutton": { @@ -58,12 +56,12 @@ } }, "devDependencies": { - "@spectrum-css/actionbutton": "7.2.0", - "@spectrum-css/asset": "7.2.0", - "@spectrum-css/checkbox": "10.2.0", - "@spectrum-css/icon": "9.2.0", - "@spectrum-css/tokens": "16.0.2", - "@spectrum-css/typography": "8.2.0" + "@spectrum-css/actionbutton": "8.0.0-next.4", + "@spectrum-css/asset": "8.0.0-next.0", + "@spectrum-css/checkbox": "11.0.0-next.2", + "@spectrum-css/icon": "10.0.0-next.3", + "@spectrum-css/tokens": "16.1.0-next.10", + "@spectrum-css/typography": "9.0.0-next.0" }, "keywords": [ "design-system", diff --git a/components/card/stories/card.stories.js b/components/card/stories/card.stories.js index 07acb513957..4920f53bd2b 100644 --- a/components/card/stories/card.stories.js +++ b/components/card/stories/card.stories.js @@ -1,7 +1,7 @@ import { default as ActionButton } from "@spectrum-css/actionbutton/stories/actionbutton.stories.js"; import { default as Checkbox } from "@spectrum-css/checkbox/stories/checkbox.stories.js"; import { disableDefaultModes } from "@spectrum-css/preview/modes"; -import { isFocused, isQuiet, isSelected } from "@spectrum-css/preview/types"; +import { isFocused, isSelected } from "@spectrum-css/preview/types"; import metadata from "../dist/metadata.json"; import packageJson from "../package.json"; import { CardGroup } from "./card.test.js"; @@ -23,7 +23,6 @@ export default { }, control: { type: "file", accept: ".svg,.png,.jpg,.jpeg,.webc" }, }, - isQuiet, isSelected, isFocused, hasActions: { @@ -109,7 +108,6 @@ export default { rootClass: "spectrum-Card", isSelected: false, isFocused: false, - isQuiet: false, isGrid: false, isGallery: false, isDropTarget: false, @@ -131,11 +129,15 @@ export default { }, packageJson, metadata, + status: { + type: "unmigrated", + }, }, + tags: ["unmigrated"], }; /** - * Cards can either be standard or quiet style. A standard card includes a cover photo and footer, with buttons and more information. A vertical layout is default for cards, and the recommended default preview size is 2:1. + * A standard card includes a cover photo and footer, with buttons and more information. A vertical layout is default for cards, and the recommended default preview size is 2:1. */ export const Default = CardGroup.bind({}); Default.args = { @@ -180,35 +182,6 @@ Focused.parameters = { }; Focused.storyName = "Default - focused"; -/** - * Quiet card styling is reserved for very simple cards with little metadata. The border of the `.spectrum-Card` element is removed, and additional rounded corners are added to the `.spectrum-Card-preview` container. - */ -export const Quiet = Template.bind({}); -Quiet.args = { - ...Default.args, - showAsset: "image", - image: "example-ava@2x.png", - isQuiet: true, -}; -Quiet.tags = ["!dev"]; -Quiet.parameters = { - chromatic: { disableSnapshot: true }, -}; - -/** A quiet card for a file asset. */ -export const QuietFile = Template.bind({}); -QuietFile.storyName = "Quiet - file"; -QuietFile.args = { - ...Quiet.args, - title: "FileName", - description: "PDF", - showAsset: "file", -}; -QuietFile.tags = ["!dev"]; -QuietFile.parameters = { - chromatic: { disableSnapshot: true }, -}; - /** * A card with a horizontal layout. Horizontal cards always have a square preview, and the image is cropped to fit inside the square. These can only be laid out in a tile grid where every card is the same size. * */ @@ -237,44 +210,6 @@ NoImage.parameters = { chromatic: { disableSnapshot: true }, }; -/** - * A quiet card for a folder asset. - * */ -export const QuietFolder = Quiet.bind({}); -QuietFolder.args = { - title: "Name", - showAsset: "folder", - description: "10/15/18", - isQuiet: true, -}; -QuietFolder.tags = ["!dev"]; -QuietFolder.parameters = { - chromatic: { disableSnapshot: true }, -}; -QuietFolder.storyName = "Quiet - folder"; - -export const QuietFocused = Quiet.bind({}); -QuietFocused.args = { - ...Quiet.args, - isFocused: true, -}; -QuietFocused.tags = ["!dev"]; -QuietFocused.parameters = { - chromatic: { disableSnapshot: true }, -}; -QuietFocused.storyName = "Quiet - focused"; - -export const QuietSelected = Quiet.bind({}); -QuietSelected.args = { - ...Quiet.args, - isSelected: true, -}; -QuietSelected.tags = ["!dev"]; -QuietSelected.parameters = { - chromatic: { disableSnapshot: true }, -}; -QuietSelected.storyName = "Quiet - selected"; - /** * Card preview areas can have any aspect ratio between 4:1 (shortest) and 3:4 (tallest). */ diff --git a/components/card/stories/card.test.js b/components/card/stories/card.test.js index 143d1ad8009..37883aaf287 100644 --- a/components/card/stories/card.test.js +++ b/components/card/stories/card.test.js @@ -21,30 +21,6 @@ export const CardGroup = Variants({ hasQuickAction: false, footer: undefined, }, - { - testHeading: "Quiet", - showAsset: "image", - image: "example-ava@2x.png", - isQuiet: true, - footer: undefined, - }, - { - testHeading: "Quiet file", - title: "FileName", - description: "PDF", - showAsset: "file", - isQuiet: true, - footer: undefined, - }, - { - testHeading: "Quiet folder", - title: "Name", - showAsset: "folder", - description: "10/15/18", - isQuiet: true, - image: undefined, - footer: undefined, - }, { testHeading: "Asset preview", showAsset: "image", diff --git a/components/card/stories/template.js b/components/card/stories/template.js index d1d226c7b0e..0911e3a78d7 100644 --- a/components/card/stories/template.js +++ b/components/card/stories/template.js @@ -11,9 +11,6 @@ import { styleMap } from "lit/directives/style-map.js"; import { when } from "lit/directives/when.js"; import "../index.css"; -import "../themes/spectrum.css"; -/* Must be imported last */ -import "../themes/express.css"; export const Template = ({ rootClass = "spectrum-Card", @@ -25,7 +22,6 @@ export const Template = ({ isFocused = false, isSelected = false, isHorizontal = false, - isQuiet = false, isGallery = false, isImageFill = false, isGrid = false, @@ -45,7 +41,6 @@ export const Template = ({ [rootClass]: true, "is-selected": isSelected, "is-focused": isFocused, - [`${rootClass}--quiet`]: isQuiet, [`${rootClass}--gallery`]: isGallery, [`${rootClass}--horizontal`]: isHorizontal, ...customClasses.reduce((a, c) => ({ ...a, [c]: true }), {}), @@ -65,7 +60,7 @@ export const Template = ({ > ${when(image || showAsset, () => when( - showAsset || (isGallery && image) || isQuiet, + showAsset || (isGallery && image), () => html`
    ` )} ${when( - footer && !isQuiet && !isHorizontal && !isGallery, + footer && !isHorizontal && !isGallery, () => html`
    - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--express */ - -@import "./spectrum.css"; diff --git a/components/card/themes/spectrum-two.css b/components/card/themes/spectrum-two.css deleted file mode 100644 index 2ef275418ee..00000000000 --- a/components/card/themes/spectrum-two.css +++ /dev/null @@ -1,22 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -@container style(--system: spectrum) { - .spectrum-Card { - --spectrum-card-border-color: var(--spectrum-gray-100); - --spectrum-card-border-color-hover: var(--spectrum-gray-200); - --spectrum-card-divider-color: var(--spectrum-gray-200); - --spectrum-card-preview-background-color: var(--spectrum-gray-100); - --spectrum-card-preview-background-color-hover: var(--spectrum-gray-200); - } -} diff --git a/components/card/themes/spectrum.css b/components/card/themes/spectrum.css deleted file mode 100644 index a1906d601bd..00000000000 --- a/components/card/themes/spectrum.css +++ /dev/null @@ -1,26 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--legacy */ - -@import "./spectrum-two.css"; - -@container style(--system: legacy) { - .spectrum-Card { - --spectrum-card-border-color: var(--spectrum-gray-200); - --spectrum-card-border-color-hover: var(--spectrum-gray-300); - --spectrum-card-divider-color: var(--spectrum-gray-300); - --spectrum-card-preview-background-color: var(--spectrum-background-base-color); - --spectrum-card-preview-background-color-hover: var(--spectrum-gray-300); - } -} diff --git a/components/checkbox/CHANGELOG.md b/components/checkbox/CHANGELOG.md index fdd1c9665d0..722f67603ec 100644 --- a/components/checkbox/CHANGELOG.md +++ b/components/checkbox/CHANGELOG.md @@ -1,5 +1,58 @@ # Change log +## 11.0.0-next.2 + +### Major Changes + +- [#3531](https://github.com/adobe/spectrum-css/pull/3531) [`e4556f1`](https://github.com/adobe/spectrum-css/commit/e4556f1ad7443a5ee191b1e79721413e7ba5a83e) Thanks [@aramos-adobe](https://github.com/aramos-adobe)! + +#### Spectrum 2 migration + +Checkbox's control and color tokens have been updated by the latest S2 tokens: + +##### Updates + +- Checkbox has a background color token: `--spectrum-checkbox-background-color` +- New typography additions: line-height, font-weight, and font style +- `spectrum-Checkbox--sizeM` is now the default style settings of the component. +- Fixed typo in `--mod-focus-indicator-thickness` +- Removed interactive state selectors in `--emphasized` variant that was overriding other variants +- Refactored WHCM settings for read-only and disabled states +- `--mod-checkbox-spacing` has been renamed to `--mod-checkbox-margin-block` + +##### New tokens + +`--spectrum-component-size-width-ratio-down` +`--spectrum-checkbox-bottom-to-text` +`--spectrum-checkbox-top-to-control` +`--spectrum-accent-content-color-default` +`--spectrum-accent-content-color-hover` +`--spectrum-accent-content-color-down` +`--spectrum-accent-content-color-key-focus` + +##### Modified tokens + +`--spectrum-checkbox-checkmark-color` +`--spectrum-checkbox-invalid-color-down` +`--spectrum-checkbox-control-color-default` +`--spectrum-checkbox-control-color-hover` +`--spectrum-checkbox-control-color-down` +`--spectrum-checkbox-control-color-focus` + +## 11.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + +## 11.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`a25e0a9`](https://github.com/adobe/spectrum-css/commit/a25e0a99e5a4736ab4e607e00739343101a2633b)]: + - @spectrum-css/icon@10.0.0-next.0 + ## 10.2.0 ### Minor Changes @@ -30,8 +83,6 @@ Adds a `::before` pseudo element to properly target the `.spectrum-Checkbox-inpu 📝 [`205182b`](https://github.com/adobe/spectrum-css/commit/205182bebcbe82813457aa098d8799b0a23423ee) Thanks [@castastrophe](https://github.com/castastrophe)! -## New feature - Minified and gzipped outputs available for all compiled CSS assets. ### Patch Changes @@ -219,6 +270,7 @@ Output for all component CSS files is now being run through a lightweight optimi ### 🛑 BREAKING CHANGE - Removes component-builder & component-builder-simple for script leveraging postcss + - Imports added to index.css and themes/express.css ## 8.1.5 diff --git a/components/checkbox/dist/metadata.json b/components/checkbox/dist/metadata.json index 695a4df09f6..daf35c48fa3 100644 --- a/components/checkbox/dist/metadata.json +++ b/components/checkbox/dist/metadata.json @@ -2,86 +2,64 @@ "sourceFile": "index.css", "selectors": [ ".spectrum-Checkbox", + ".spectrum-Checkbox .spectrum-Checkbox-box", + ".spectrum-Checkbox .spectrum-Checkbox-box:after", + ".spectrum-Checkbox .spectrum-Checkbox-box:before", ".spectrum-Checkbox .spectrum-Checkbox-checkmark", + ".spectrum-Checkbox .spectrum-Checkbox-input", + ".spectrum-Checkbox .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box .spectrum-Checkbox-checkmark", + ".spectrum-Checkbox .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box:before", ".spectrum-Checkbox .spectrum-Checkbox-input:checked:disabled + .spectrum-Checkbox-box:before", ".spectrum-Checkbox .spectrum-Checkbox-input:checked:disabled ~ .spectrum-Checkbox-label", + ".spectrum-Checkbox .spectrum-Checkbox-input:checked:hover:disabled + .spectrum-Checkbox-box:before", + ".spectrum-Checkbox .spectrum-Checkbox-input:disabled", ".spectrum-Checkbox .spectrum-Checkbox-input:disabled + .spectrum-Checkbox-box:before", ".spectrum-Checkbox .spectrum-Checkbox-input:disabled ~ .spectrum-Checkbox-label", + ".spectrum-Checkbox .spectrum-Checkbox-input:focus-visible + .spectrum-Checkbox-box:after", + ".spectrum-Checkbox .spectrum-Checkbox-input:focus-visible + .spectrum-Checkbox-box:before", + ".spectrum-Checkbox .spectrum-Checkbox-input:focus-visible + .spectrum-Checkbox-label", + ".spectrum-Checkbox .spectrum-Checkbox-input:hover:disabled + .spectrum-Checkbox-box:before", + ".spectrum-Checkbox .spectrum-Checkbox-label", ".spectrum-Checkbox .spectrum-Checkbox-partialCheckmark", - ".spectrum-Checkbox--emphasized .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box:before", - ".spectrum-Checkbox--emphasized .spectrum-Checkbox-input:focus-visible:checked + .spectrum-Checkbox-box:before", ".spectrum-Checkbox--emphasized.is-indeterminate .spectrum-Checkbox-box:before", ".spectrum-Checkbox--emphasized.is-indeterminate .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box:before", - ".spectrum-Checkbox--emphasized.is-indeterminate .spectrum-Checkbox-input:focus-visible + .spectrum-Checkbox-box:before", - ".spectrum-Checkbox--emphasized.is-indeterminate:active .spectrum-Checkbox-box:before", - ".spectrum-Checkbox--emphasized.is-indeterminate:active .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box:before", ".spectrum-Checkbox--emphasized.is-indeterminate:hover .spectrum-Checkbox-box:before", ".spectrum-Checkbox--emphasized.is-indeterminate:hover .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box:before", - ".spectrum-Checkbox--emphasized.is-invalid .spectrum-Checkbox-input:focus-visible:checked + .spectrum-Checkbox-box:before", - ".spectrum-Checkbox--emphasized.is-invalid.is-indeterminate:hover .spectrum-Checkbox-box:before", - ".spectrum-Checkbox--emphasized.is-invalid.is-indeterminate:hover .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box:before", - ".spectrum-Checkbox--emphasized.is-invalid:active .spectrum-Checkbox-box:before", - ".spectrum-Checkbox--emphasized.is-invalid:active .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box:before", - ".spectrum-Checkbox--emphasized.is-invalid:hover .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box:before", - ".spectrum-Checkbox--emphasized:active .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box:before", - ".spectrum-Checkbox--emphasized:focus-visible .spectrum-Checkbox-box:before", - ".spectrum-Checkbox--emphasized:focus-visible .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box:before", - ".spectrum-Checkbox--emphasized:hover .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box:before", - ".spectrum-Checkbox--sizeL", - ".spectrum-Checkbox--sizeM", - ".spectrum-Checkbox--sizeS", - ".spectrum-Checkbox--sizeXL", - ".spectrum-Checkbox-box", - ".spectrum-Checkbox-box:after", - ".spectrum-Checkbox-box:before", - ".spectrum-Checkbox-input", - ".spectrum-Checkbox-input:checked + .spectrum-Checkbox-box .spectrum-Checkbox-checkmark", - ".spectrum-Checkbox-input:checked + .spectrum-Checkbox-box:before", - ".spectrum-Checkbox-input:disabled", + ".spectrum-Checkbox--emphasized.is-indeterminate:not(.is-invalid) .spectrum-Checkbox-input:focus-visible + .spectrum-Checkbox-box:before", + ".spectrum-Checkbox--emphasized:not(.is-invalid) .spectrum-Checkbox-input:focus-visible:checked + .spectrum-Checkbox-box:before", ".spectrum-Checkbox-input:focus-visible + .spectrum-Checkbox-box", - ".spectrum-Checkbox-input:focus-visible + .spectrum-Checkbox-box:after", - ".spectrum-Checkbox-input:focus-visible + .spectrum-Checkbox-box:before", - ".spectrum-Checkbox-input:focus-visible + .spectrum-Checkbox-label", - ".spectrum-Checkbox-input:focus-visible:checked + .spectrum-Checkbox-box:before", - ".spectrum-Checkbox-label", - ".spectrum-Checkbox-label:lang(ja)", - ".spectrum-Checkbox-label:lang(ko)", - ".spectrum-Checkbox-label:lang(zh)", ".spectrum-Checkbox.is-indeterminate .spectrum-Checkbox-box .spectrum-Checkbox-checkmark", ".spectrum-Checkbox.is-indeterminate .spectrum-Checkbox-box .spectrum-Checkbox-partialCheckmark", ".spectrum-Checkbox.is-indeterminate .spectrum-Checkbox-box:before", ".spectrum-Checkbox.is-indeterminate .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box .spectrum-Checkbox-checkmark", ".spectrum-Checkbox.is-indeterminate .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box .spectrum-Checkbox-partialCheckmark", ".spectrum-Checkbox.is-indeterminate .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box:before", - ".spectrum-Checkbox.is-indeterminate .spectrum-Checkbox-input:focus-visible + .spectrum-Checkbox-box:before", - ".spectrum-Checkbox.is-indeterminate:hover .spectrum-Checkbox-box:before", - ".spectrum-Checkbox.is-indeterminate:hover .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box:before", - ".spectrum-Checkbox.is-invalid .spectrum-Checkbox-box:before", - ".spectrum-Checkbox.is-invalid .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box:before", - ".spectrum-Checkbox.is-invalid .spectrum-Checkbox-input:focus-visible + .spectrum-Checkbox-box:before", + ".spectrum-Checkbox.is-invalid", ".spectrum-Checkbox.is-invalid.is-indeterminate .spectrum-Checkbox-box:before", - ".spectrum-Checkbox.is-invalid.is-indeterminate .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box:before", + ".spectrum-Checkbox.is-invalid.is-indeterminate .spectrum-Checkbox-input:checked:not(:disabled) + .spectrum-Checkbox-box:before", ".spectrum-Checkbox.is-invalid.is-indeterminate .spectrum-Checkbox-input:focus-visible + .spectrum-Checkbox-box:before", ".spectrum-Checkbox.is-invalid.is-indeterminate:hover .spectrum-Checkbox-box:before", - ".spectrum-Checkbox.is-invalid.is-indeterminate:hover .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box:before", - ".spectrum-Checkbox.is-invalid.is-indeterminate:hover .spectrum-Checkbox-label", - ".spectrum-Checkbox.is-invalid:hover .spectrum-Checkbox-box:before", - ".spectrum-Checkbox.is-invalid:hover .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box:before", - ".spectrum-Checkbox.is-readOnly .spectrum-Checkbox-input", - ".spectrum-Checkbox.is-readOnly .spectrum-Checkbox-input:checked:disabled + .spectrum-Checkbox-box:before", - ".spectrum-Checkbox.is-readOnly .spectrum-Checkbox-input:checked:disabled ~ .spectrum-Checkbox-label", - ".spectrum-Checkbox.is-readOnly .spectrum-Checkbox-input:disabled + .spectrum-Checkbox-box:before", - ".spectrum-Checkbox.is-readOnly .spectrum-Checkbox-input:disabled ~ .spectrum-Checkbox-label", + ".spectrum-Checkbox.is-invalid.is-indeterminate:hover .spectrum-Checkbox-input:checked:not(:disabled) + .spectrum-Checkbox-box:before", + ".spectrum-Checkbox.spectrum-Checkbox--emphasized", + ".spectrum-Checkbox.spectrum-Checkbox--sizeL", + ".spectrum-Checkbox.spectrum-Checkbox--sizeS", + ".spectrum-Checkbox.spectrum-Checkbox--sizeXL", ".spectrum-Checkbox:active .spectrum-Checkbox-box:before", ".spectrum-Checkbox:active .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box:before", ".spectrum-Checkbox:active .spectrum-Checkbox-label", ".spectrum-Checkbox:hover .spectrum-Checkbox-box:before", ".spectrum-Checkbox:hover .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box:before", - ".spectrum-Checkbox:hover .spectrum-Checkbox-label" + ".spectrum-Checkbox:hover .spectrum-Checkbox-label", + ".spectrum-Checkbox:lang(ja)", + ".spectrum-Checkbox:lang(ko)", + ".spectrum-Checkbox:lang(zh)", + ".spectrum-Checkbox:not(.is-readOnly) .spectrum-Checkbox-input:active:not(:disabled) + .spectrum-Checkbox-box", + ".spectrum-Checkbox:not(.is-readOnly):active .spectrum-Checkbox-input:not(:disabled) + .spectrum-Checkbox-box" ], "modifiers": [ "--mod-checkbox-animation-duration", "--mod-checkbox-border-width", + "--mod-checkbox-bottom-to-text", "--mod-checkbox-checkmark-color", "--mod-checkbox-content-color-default", "--mod-checkbox-content-color-disabled", @@ -94,38 +72,30 @@ "--mod-checkbox-control-color-focus", "--mod-checkbox-control-color-hover", "--mod-checkbox-control-corner-radius", - "--mod-checkbox-control-invalid-color-down", "--mod-checkbox-control-selected-color-default", "--mod-checkbox-control-selected-color-down", - "--mod-checkbox-control-selected-color-focus", "--mod-checkbox-control-selected-color-hover", "--mod-checkbox-control-size", - "--mod-checkbox-emphasized-color-default", - "--mod-checkbox-emphasized-color-down", - "--mod-checkbox-emphasized-color-focus", - "--mod-checkbox-emphasized-color-hover", "--mod-checkbox-focus-indicator-color", "--mod-checkbox-focus-indicator-gap", - "--mod-checkbox-focus-indicator-thinkness", + "--mod-checkbox-focus-indicator-thickness", "--mod-checkbox-font-size", "--mod-checkbox-height", - "--mod-checkbox-invalid-color-default", - "--mod-checkbox-invalid-color-focus", - "--mod-checkbox-invalid-color-hover", "--mod-checkbox-line-height", "--mod-checkbox-line-height-cjk", + "--mod-checkbox-margin-block", "--mod-checkbox-selected-border-width", - "--mod-checkbox-spacing", "--mod-checkbox-text-to-control", "--mod-checkbox-top-to-text", "--mod-focus-indicator-thickness" ], "component": [ "--spectrum-checkbox-animation-duration", + "--spectrum-checkbox-background-color", "--spectrum-checkbox-border-width", + "--spectrum-checkbox-bottom-to-text", "--spectrum-checkbox-checkmark-color", "--spectrum-checkbox-content-color-default", - "--spectrum-checkbox-content-color-disabled", "--spectrum-checkbox-content-color-down", "--spectrum-checkbox-content-color-focus", "--spectrum-checkbox-content-color-hover", @@ -137,7 +107,6 @@ "--spectrum-checkbox-control-corner-radius", "--spectrum-checkbox-control-selected-color-default", "--spectrum-checkbox-control-selected-color-down", - "--spectrum-checkbox-control-selected-color-focus", "--spectrum-checkbox-control-selected-color-hover", "--spectrum-checkbox-control-size", "--spectrum-checkbox-control-size-extra-large", @@ -160,25 +129,43 @@ "--spectrum-checkbox-line-height", "--spectrum-checkbox-line-height-cjk", "--spectrum-checkbox-selected-border-width", - "--spectrum-checkbox-spacing", + "--spectrum-checkbox-text-font-style", + "--spectrum-checkbox-text-font-weight", "--spectrum-checkbox-text-to-control", + "--spectrum-checkbox-top-to-control", + "--spectrum-checkbox-top-to-control-extra-large", + "--spectrum-checkbox-top-to-control-large", + "--spectrum-checkbox-top-to-control-medium", + "--spectrum-checkbox-top-to-control-small", "--spectrum-checkbox-top-to-text" ], "global": [ - "--spectrum-accent-color-1000", - "--spectrum-accent-color-1100", - "--spectrum-accent-color-900", + "--spectrum-accent-content-color-default", + "--spectrum-accent-content-color-down", + "--spectrum-accent-content-color-hover", + "--spectrum-accent-content-color-key-focus", "--spectrum-animation-duration-100", "--spectrum-border-width-200", "--spectrum-cjk-line-height-100", + "--spectrum-component-bottom-to-text-100", + "--spectrum-component-bottom-to-text-200", + "--spectrum-component-bottom-to-text-300", + "--spectrum-component-bottom-to-text-75", "--spectrum-component-height-100", "--spectrum-component-height-200", "--spectrum-component-height-300", "--spectrum-component-height-75", + "--spectrum-component-size-difference-down", + "--spectrum-component-size-minimum-perspective-down", "--spectrum-component-top-to-text-100", "--spectrum-component-top-to-text-200", "--spectrum-component-top-to-text-300", "--spectrum-component-top-to-text-75", + "--spectrum-corner-radius-small-size-extra-large", + "--spectrum-corner-radius-small-size-large", + "--spectrum-corner-radius-small-size-medium", + "--spectrum-corner-radius-small-size-small", + "--spectrum-default-font-style", "--spectrum-disabled-content-color", "--spectrum-focus-indicator-color", "--spectrum-focus-indicator-gap", @@ -187,40 +174,25 @@ "--spectrum-font-size-200", "--spectrum-font-size-300", "--spectrum-font-size-75", - "--spectrum-gray-50", - "--spectrum-gray-700", - "--spectrum-gray-800", + "--spectrum-gray-25", "--spectrum-line-height-100", "--spectrum-negative-color-1000", - "--spectrum-negative-color-1100", "--spectrum-negative-color-900", - "--spectrum-neutral-background-color-selected-default", - "--spectrum-neutral-background-color-selected-down", - "--spectrum-neutral-background-color-selected-hover", - "--spectrum-neutral-background-color-selected-key-focus", "--spectrum-neutral-content-color-default", "--spectrum-neutral-content-color-down", "--spectrum-neutral-content-color-hover", "--spectrum-neutral-content-color-key-focus", + "--spectrum-regular-font-weight", "--spectrum-text-to-control-100", "--spectrum-text-to-control-200", "--spectrum-text-to-control-300", "--spectrum-text-to-control-75" ], - "system-theme": [ - "--system-checkbox-checkmark-color", - "--system-checkbox-control-color-default", - "--system-checkbox-control-color-down", - "--system-checkbox-control-color-focus", - "--system-checkbox-control-color-hover", - "--system-checkbox-control-corner-radius" - ], "passthroughs": [], "high-contrast": [ "--highcontrast-checkbox-background-color-default", "--highcontrast-checkbox-color-default", "--highcontrast-checkbox-color-focus", - "--highcontrast-checkbox-color-hover", "--highcontrast-checkbox-content-color-default", "--highcontrast-checkbox-content-color-down", "--highcontrast-checkbox-content-color-focus", @@ -229,7 +201,6 @@ "--highcontrast-checkbox-focus-indicator-color", "--highcontrast-checkbox-highlight-color-default", "--highcontrast-checkbox-highlight-color-down", - "--highcontrast-checkbox-highlight-color-focus", "--highcontrast-checkbox-highlight-color-hover" ] } diff --git a/components/checkbox/index.css b/components/checkbox/index.css index 3c1a7782398..140581616e8 100644 --- a/components/checkbox/index.css +++ b/components/checkbox/index.css @@ -11,8 +11,6 @@ * governing permissions and limitations under the License. */ -@import "./themes/spectrum-two.css"; - /* * .spectrum-Checkbox-box::before is the Checkbox "box" * .spectrum-Checkbox-box::after is the focus indicator @@ -20,97 +18,125 @@ .spectrum-Checkbox { /* Color */ + --spectrum-checkbox-checkmark-color: var(--spectrum-gray-25); + --spectrum-checkbox-background-color: var(--spectrum-gray-25); --spectrum-checkbox-content-color-default: var(--spectrum-neutral-content-color-default); --spectrum-checkbox-content-color-hover: var(--spectrum-neutral-content-color-hover); --spectrum-checkbox-content-color-down: var(--spectrum-neutral-content-color-down); --spectrum-checkbox-content-color-focus: var(--spectrum-neutral-content-color-key-focus); - --spectrum-checkbox-focus-indicator-color: var(--spectrum-focus-indicator-color); + --spectrum-checkbox-control-color-default: var(--spectrum-neutral-content-color-default); + --spectrum-checkbox-control-color-hover: var(--spectrum-neutral-content-color-hover); + --spectrum-checkbox-control-color-down: var(--spectrum-neutral-content-color-down); + --spectrum-checkbox-control-color-focus: var(--spectrum-neutral-content-color-key-focus); - --spectrum-checkbox-content-color-disabled: var(--spectrum-disabled-content-color); + --spectrum-checkbox-focus-indicator-color: var(--spectrum-focus-indicator-color); --spectrum-checkbox-control-color-disabled: var(--spectrum-disabled-content-color); --spectrum-checkbox-invalid-color-default: var(--spectrum-negative-color-900); --spectrum-checkbox-invalid-color-hover: var(--spectrum-negative-color-1000); - --spectrum-checkbox-invalid-color-down: var(--spectrum-negative-color-1100); + --spectrum-checkbox-invalid-color-down: var(--spectrum-negative-color-1000); --spectrum-checkbox-invalid-color-focus: var(--spectrum-negative-color-1000); - --spectrum-checkbox-emphasized-color-default: var(--spectrum-accent-color-900); - --spectrum-checkbox-emphasized-color-hover: var(--spectrum-accent-color-1000); - --spectrum-checkbox-emphasized-color-down: var(--spectrum-accent-color-1100); - --spectrum-checkbox-emphasized-color-focus: var(--spectrum-accent-color-1000); + --spectrum-checkbox-emphasized-color-default: var(--spectrum-accent-content-color-default); + --spectrum-checkbox-emphasized-color-hover: var(--spectrum-accent-content-color-hover); + --spectrum-checkbox-emphasized-color-down: var(--spectrum-accent-content-color-down); + --spectrum-checkbox-emphasized-color-focus: var(--spectrum-accent-content-color-key-focus); - --spectrum-checkbox-control-selected-color-default: var(--spectrum-neutral-background-color-selected-default); - --spectrum-checkbox-control-selected-color-hover: var(--spectrum-neutral-background-color-selected-hover); - --spectrum-checkbox-control-selected-color-down: var(--spectrum-neutral-background-color-selected-down); - --spectrum-checkbox-control-selected-color-focus: var(--spectrum-neutral-background-color-selected-key-focus); + --spectrum-checkbox-control-selected-color-default: var(--spectrum-neutral-content-color-default); + --spectrum-checkbox-control-selected-color-hover: var(--spectrum-neutral-content-color-hover); + --spectrum-checkbox-control-selected-color-down: var(--spectrum-neutral-content-color-down); /* Font */ + --spectrum-checkbox-font-size: var(--spectrum-font-size-100); --spectrum-checkbox-line-height: var(--spectrum-line-height-100); --spectrum-checkbox-line-height-cjk: var(--spectrum-cjk-line-height-100); + --spectrum-checkbox-text-font-weight: var(--spectrum-regular-font-weight); + --spectrum-checkbox-text-font-style: var(--spectrum-default-font-style); + /* Size */ + --spectrum-checkbox-height: var(--spectrum-component-height-100); + --spectrum-checkbox-control-size: var(--spectrum-checkbox-control-size-medium); + --spectrum-checkbox-control-corner-radius: var(--spectrum-corner-radius-small-size-medium); --spectrum-checkbox-focus-indicator-gap: var(--spectrum-focus-indicator-gap); --spectrum-checkbox-focus-indicator-thickness: var(--spectrum-focus-indicator-thickness); --spectrum-checkbox-border-width: var(--spectrum-border-width-200); - --spectrum-checkbox-selected-border-width: calc(var(--spectrum-checkbox-control-size) / 2); --spectrum-checkbox-animation-duration: var(--spectrum-animation-duration-100); -} - -.spectrum-Checkbox, -.spectrum-Checkbox--sizeM { - --spectrum-checkbox-font-size: var(--spectrum-font-size-100); - - --spectrum-checkbox-height: var(--spectrum-component-height-100); - --spectrum-checkbox-control-size: var(--spectrum-checkbox-control-size-medium); --spectrum-checkbox-top-to-text: var(--spectrum-component-top-to-text-100); + --spectrum-checkbox-bottom-to-text: var(--spectrum-component-bottom-to-text-100); --spectrum-checkbox-text-to-control: var(--spectrum-text-to-control-100); -} - -.spectrum-Checkbox--sizeS { - --spectrum-checkbox-font-size: var(--spectrum-font-size-75); + --spectrum-checkbox-top-to-control: var(--spectrum-checkbox-top-to-control-medium); - --spectrum-checkbox-height: var(--spectrum-component-height-75); - --spectrum-checkbox-control-size: var(--spectrum-checkbox-control-size-small); - - --spectrum-checkbox-top-to-text: var(--spectrum-component-top-to-text-75); - --spectrum-checkbox-text-to-control: var(--spectrum-text-to-control-75); -} + --spectrum-checkbox-selected-border-width: calc(var(--spectrum-checkbox-control-size) / 2); -.spectrum-Checkbox--sizeL { - --spectrum-checkbox-font-size: var(--spectrum-font-size-200); + /* CJK (Chinese, Japanese, and Korean) language support */ + &:lang(ja), + &:lang(zh), + &:lang(ko) { + --mod-checkbox-line-height: var(--mod-checkbox-line-height-cjk, var(--spectrum-checkbox-line-height-cjk)); + } - --spectrum-checkbox-height: var(--spectrum-component-height-200); - --spectrum-checkbox-control-size: var(--spectrum-checkbox-control-size-large); + &.spectrum-Checkbox--sizeS { + --spectrum-checkbox-control-corner-radius: var(--spectrum-corner-radius-small-size-small); + --spectrum-checkbox-font-size: var(--spectrum-font-size-75); + --spectrum-checkbox-height: var(--spectrum-component-height-75); + --spectrum-checkbox-control-size: var(--spectrum-checkbox-control-size-small); + --spectrum-checkbox-top-to-text: var(--spectrum-component-top-to-text-75); + --spectrum-checkbox-bottom-to-text: var(--spectrum-component-bottom-to-text-75); + --spectrum-checkbox-text-to-control: var(--spectrum-text-to-control-75); + --spectrum-checkbox-top-to-control: var(--spectrum-checkbox-top-to-control-small); + } - --spectrum-checkbox-top-to-text: var(--spectrum-component-top-to-text-200); - --spectrum-checkbox-text-to-control: var(--spectrum-text-to-control-200); -} + &.spectrum-Checkbox--sizeL { + --spectrum-checkbox-control-corner-radius: var(--spectrum-corner-radius-small-size-large); + --spectrum-checkbox-font-size: var(--spectrum-font-size-200); + --spectrum-checkbox-height: var(--spectrum-component-height-200); + --spectrum-checkbox-control-size: var(--spectrum-checkbox-control-size-large); + --spectrum-checkbox-top-to-text: var(--spectrum-component-top-to-text-200); + --spectrum-checkbox-bottom-to-text: var(--spectrum-component-bottom-to-text-200); + --spectrum-checkbox-text-to-control: var(--spectrum-text-to-control-200); + --spectrum-checkbox-top-to-control: var(--spectrum-checkbox-top-to-control-large); + } -.spectrum-Checkbox--sizeXL { - --spectrum-checkbox-font-size: var(--spectrum-font-size-300); + &.spectrum-Checkbox--sizeXL { + --spectrum-checkbox-control-corner-radius: var(--spectrum-corner-radius-small-size-extra-large); + --spectrum-checkbox-font-size: var(--spectrum-font-size-300); + --spectrum-checkbox-height: var(--spectrum-component-height-300); + --spectrum-checkbox-control-size: var(--spectrum-checkbox-control-size-extra-large); + --spectrum-checkbox-top-to-text: var(--spectrum-component-top-to-text-300); + --spectrum-checkbox-bottom-to-text: var(--spectrum-component-bottom-to-text-300); + --spectrum-checkbox-text-to-control: var(--spectrum-text-to-control-300); + --spectrum-checkbox-top-to-control: var(--spectrum-checkbox-top-to-control-extra-large); + } - --spectrum-checkbox-height: var(--spectrum-component-height-300); - --spectrum-checkbox-control-size: var(--spectrum-checkbox-control-size-extra-large); + &.spectrum-Checkbox--emphasized { + --spectrum-checkbox-control-selected-color-default: var(--spectrum-checkbox-emphasized-color-default); + --spectrum-checkbox-control-selected-color-hover: var(--spectrum-checkbox-emphasized-color-hover); + --spectrum-checkbox-control-selected-color-down: var(--spectrum-checkbox-emphasized-color-down); + } - --spectrum-checkbox-top-to-text: var(--spectrum-component-top-to-text-300); - --spectrum-checkbox-text-to-control: var(--spectrum-text-to-control-300); + &.is-invalid { + --spectrum-checkbox-control-color-default: var(--spectrum-checkbox-invalid-color-default); + --spectrum-checkbox-control-color-hover: var(--spectrum-checkbox-invalid-color-hover); + --spectrum-checkbox-control-color-down: var(--spectrum-checkbox-invalid-color-down); + --spectrum-checkbox-control-color-focus: var(--spectrum-checkbox-invalid-color-focus); + + --spectrum-checkbox-control-selected-color-default: var(--spectrum-checkbox-invalid-color-default); + --spectrum-checkbox-control-selected-color-hover: var(--spectrum-checkbox-invalid-color-hover); + --spectrum-checkbox-control-selected-color-down: var(--spectrum-checkbox-invalid-color-down); + } } -/* Default Unchecked */ .spectrum-Checkbox { color: var(--highcontrast-checkbox-content-color-default, var(--mod-checkbox-content-color-default, var(--spectrum-checkbox-content-color-default))); - display: inline-flex; align-items: flex-start; - position: relative; - min-block-size: var(--mod-checkbox-height, var(--spectrum-checkbox-height)); max-inline-size: 100%; - vertical-align: top; &:hover { @@ -141,389 +167,260 @@ } } - /* Selected Invalid */ - &.is-invalid { - .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box, - .spectrum-Checkbox-box { - &::before { - border-color: var(--highcontrast-checkbox-color-default, var(--mod-checkbox-invalid-color-default, var(--spectrum-checkbox-invalid-color-default))); - } + &:not(.is-readOnly) { + .spectrum-Checkbox-input:active:not(:disabled) + .spectrum-Checkbox-box, + &:active .spectrum-Checkbox-input:not(:disabled) + .spectrum-Checkbox-box { + transform: perspective(var(--spectrum-component-size-minimum-perspective-down)) translateZ(var(--spectrum-component-size-difference-down)); } + } - &.is-indeterminate .spectrum-Checkbox-input:focus-visible, - .spectrum-Checkbox-input:focus-visible { - & + .spectrum-Checkbox-box::before { - border-color: var(--highcontrast-checkbox-color-hover, var(--mod-checkbox-invalid-color-hover, var(--spectrum-checkbox-invalid-color-hover))); - } - } + .spectrum-Checkbox-checkmark, + .spectrum-Checkbox-partialCheckmark { + color: var(--highcontrast-checkbox-background-color-default, var(--spectrum-checkbox-checkmark-color)); + opacity: 0; + transform: scale(0); - &:hover { - .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box::before, - .spectrum-Checkbox-box::before { - border-color: var(--highcontrast-checkbox-color-hover, var(--mod-checkbox-invalid-color-hover, var(--spectrum-checkbox-invalid-color-hover))); - } - } + transition: + opacity var(--mod-checkbox-animation-duration, var(--spectrum-checkbox-animation-duration)) ease-in-out, + transform var(--mod-checkbox-animation-duration, var(--spectrum-checkbox-animation-duration)) ease-in-out; } - /* Read-only */ - &.is-readOnly { - .spectrum-Checkbox-input { - cursor: default; - } + .spectrum-Checkbox-partialCheckmark { + display: none; + } - /* Overrides disabled styles */ - .spectrum-Checkbox-input, - .spectrum-Checkbox-input:checked { - &:disabled + .spectrum-Checkbox-box::before { - border-color: var(--highcontrast-checkbox-color-default, var(--mod-checkbox-control-selected-color-default, var(--spectrum-checkbox-control-selected-color-default))); - background-color: var(--highcontrast-checkbox-background-color-default, var(--mod-checkbox-checkmark-color, var(--spectrum-checkbox-checkmark-color))); - } + .spectrum-Checkbox-label { + text-align: start; + margin-inline-start: var(--mod-checkbox-text-to-control, var(--spectrum-checkbox-text-to-control)); + margin-block-start: var(--mod-checkbox-top-to-text, var(--spectrum-checkbox-top-to-text)); + margin-block-end: var(--mod-checkbox-bottom-to-text, var(--spectrum-checkbox-bottom-to-text)); - &:disabled ~ .spectrum-Checkbox-label { - color: var(--highcontrast-checkbox-color-default, var(--mod-checkbox-content-color-default, var(--spectrum-checkbox-content-color-default))); - } - } + font-size: var(--mod-checkbox-font-size, var(--spectrum-checkbox-font-size)); + font-weight: var(--spectrum-checkbox-text-font-weight); + font-style: var(--spectrum-checkbox-text-font-style); + + transition: color var(--mod-checkbox-animation-duration, var(--spectrum-checkbox-animation-duration)) ease-in-out; + + line-height: var(--mod-checkbox-line-height, var(--spectrum-checkbox-line-height)); } - /* Indeterminate */ - &.is-indeterminate { - .spectrum-Checkbox-box, - .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box { + /** + * The input is visually hidden (with opacity), and remains accessible using assistive tech. + * It is still sized and positioned where it would naturally be present so that touch users can find it with haptics. + */ + .spectrum-Checkbox-input { + color: var(--mod-checkbox-control-color-default, var(--spectrum-checkbox-control-color-default)); + + /* Remove the margin for input in Firefox and Safari. */ + margin: 0; + + /* Show the overflow for input in Edge. */ + overflow: visible; + + /* Add the correct box sizing for [type="checkbox"] in IE 10-. */ + box-sizing: border-box; + + /* Remove the padding for [type="checkbox"] in IE 10-. */ + padding: 0; + + position: absolute; + inline-size: 100%; + block-size: 100%; + + opacity: 0; + z-index: 1; + + cursor: pointer; + + &:disabled { + cursor: default; + } + + /* Selected */ + &:checked + .spectrum-Checkbox-box { &::before { border-color: var(--highcontrast-checkbox-highlight-color-default, var(--mod-checkbox-control-selected-color-default, var(--spectrum-checkbox-control-selected-color-default))); + background-color: var(--highcontrast-checkbox-background-color-default, var(--mod-checkbox-checkmark-color, var(--spectrum-checkbox-checkmark-color))); border-width: var(--mod-checkbox-selected-border-width, var(--spectrum-checkbox-selected-border-width)); } .spectrum-Checkbox-checkmark { - display: none; - } - - .spectrum-Checkbox-partialCheckmark { - display: block; - transform: scale(1); opacity: 1; } } - .spectrum-Checkbox-input:focus-visible + .spectrum-Checkbox-box { + /* Focus */ + &:focus-visible + .spectrum-Checkbox-box { &::before { - border-color: var(--highcontrast-checkbox-highlight-color-focus, var(--mod-checkbox-control-selected-color-focus, var(--spectrum-checkbox-control-selected-color-focus))); + border-color: var(--highcontrast-checkbox-color-focus, var(--mod-checkbox-control-color-focus, var(--spectrum-checkbox-control-color-focus))); } - } - &:hover { - .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box::before, - .spectrum-Checkbox-box::before { - border-color: var(--highcontrast-checkbox-highlight-color-hover, var(--mod-checkbox-control-selected-color-hover, var(--spectrum-checkbox-control-selected-color-hover))); + &::after { + box-shadow: 0 0 0 var(--mod-checkbox-focus-indicator-thickness, var(--spectrum-checkbox-focus-indicator-thickness)) var(--highcontrast-checkbox-focus-indicator-color, var(--mod-checkbox-focus-indicator-color, var(--spectrum-checkbox-focus-indicator-color))); + margin: calc(var(--mod-checkbox-focus-indicator-gap, var(--spectrum-checkbox-focus-indicator-gap)) * -1); } } - } - /* Invalid Indeterminate */ - &.is-invalid.is-indeterminate { - .spectrum-Checkbox-box, - .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box { - &::before { - border-color: var(--highcontrast-checkbox-color-default, var(--mod-checkbox-invalid-color-default, var(--spectrum-checkbox-invalid-color-default))); - border-width: var(--mod-checkbox-selected-border-width, var(--spectrum-checkbox-selected-border-width)); - } + &:focus-visible + .spectrum-Checkbox-label { + color: var(--highcontrast-checkbox-content-color-focus, var(--mod-checkbox-content-color-focus, var(--spectrum-checkbox-content-color-focus))); } + } - &:hover { - .spectrum-Checkbox-box::before, - .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box::before { - border-color: var(--highcontrast-checkbox-color-default, var(--mod-checkbox-invalid-color-hover, var(--spectrum-checkbox-invalid-color-hover))); - } + .spectrum-Checkbox-box { + display: flex; + align-items: center; + justify-content: center; - .spectrum-Checkbox-label { - color: var(--highcontrast-checkbox-content-color-hover, var(--mod-checkbox-content-color-hover, var(--spectrum-checkbox-content-color-hover))); - } - } - } -} + position: relative; + box-sizing: border-box; + inline-size: var(--mod-checkbox-control-size, var(--spectrum-checkbox-control-size)); + block-size: var(--mod-checkbox-control-size, var(--spectrum-checkbox-control-size)); + + /* Fix vertical alignment when not wrapping since we're flex-start */ + margin: var(--mod-checkbox-margin-block, var(--spectrum-checkbox-top-to-control)) 0; + flex-grow: 0; + flex-shrink: 0; -/* Emphasized */ -.spectrum-Checkbox--emphasized { - /* Checked and Indeterminate Default States */ - .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box, - &.is-indeterminate .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box, - &.is-indeterminate .spectrum-Checkbox-box { &::before { - border-color: var(--highcontrast-checkbox-highlight-color-default, var(--mod-checkbox-emphasized-color-default, var(--spectrum-checkbox-emphasized-color-default))); - } - } + border-color: var(--highcontrast-checkbox-color-default, var(--mod-checkbox-control-color-default, var(--spectrum-checkbox-control-color-default))); + background-color: var(--highcontrast-checkbox-background-color-default, var(--spectrum-checkbox-background-color)); + display: block; + z-index: 0; + content: ""; + box-sizing: border-box; + position: absolute; - /* Hover for Checked and Indeterminate States */ - &:hover { - .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box, - &.is-indeterminate .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box, - &.is-indeterminate .spectrum-Checkbox-box { - &::before { - border-color: var(--highcontrast-checkbox-color-hover, var(--mod-checkbox-emphasized-color-hover, var(--spectrum-checkbox-emphasized-color-hover))); - } - } - } + inline-size: var(--mod-checkbox-control-size, var(--spectrum-checkbox-control-size)); + block-size: var(--mod-checkbox-control-size, var(--spectrum-checkbox-control-size)); - /* Selected and Indeterminate Focus States */ - .spectrum-Checkbox-input:focus-visible:checked + .spectrum-Checkbox-box, - &.is-indeterminate .spectrum-Checkbox-input:focus-visible + .spectrum-Checkbox-box { - &::before { - border-color: var(--highcontrast-checkbox-highlight-color-focus, var(--mod-checkbox-emphasized-color-focus, var(--spectrum-checkbox-emphasized-color-focus))); + border-radius: var(--mod-checkbox-control-corner-radius, var(--spectrum-checkbox-control-corner-radius)); + border-width: var(--mod-checkbox-border-width, var(--spectrum-checkbox-border-width)); + border-style: solid; + + transition: + border var(--mod-checkbox-animation-duration, var(--spectrum-checkbox-animation-duration)) ease-in-out, + box-shadow var(--mod-checkbox-animation-duration, var(--spectrum-checkbox-animation-duration)) ease-in-out; } - } - /* Selected Invalid Focus State */ - &.is-invalid .spectrum-Checkbox-input:focus-visible:checked + .spectrum-Checkbox-box { - &::before { - border-color: var(--highcontrast-checkbox-color-default, var(--mod-checkbox-invalid-color-focus, var(--spectrum-checkbox-invalid-color-focus))); + &::after { + border-radius: calc(var(--mod-checkbox-control-corner-radius, var(--spectrum-checkbox-control-corner-radius)) + var(--mod-checkbox-focus-indicator-gap, var(--spectrum-checkbox-focus-indicator-gap))); + content: ""; + display: block; + position: absolute; + inset-inline-start: 0; + inset-inline-end: 0; + inset-block-end: 0; + inset-block-start: 0; + margin: var(--mod-checkbox-focus-indicator-gap, var(--spectrum-checkbox-focus-indicator-gap)); + + transition: + box-shadow var(--mod-checkbox-animation-duration, var(--spectrum-checkbox-animation-duration)) ease-out, + margin var(--mod-checkbox-animation-duration, var(--spectrum-checkbox-animation-duration)) ease-out; + + /* force ff to render on the pixel grid */ + transform: translate(0, 0); } } - /* TODO: Because this selector was moved to the default variant's styles, this selector block can be deleted when it is safe to make changes to selectors. */ - /* Invalid Hover States */ - &.is-invalid:hover { - &.is-indeterminate .spectrum-Checkbox-box, - &.is-indeterminate .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box, + /* Indeterminate */ + &.is-indeterminate { + .spectrum-Checkbox-box, .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box { &::before { - border-color: var(--highcontrast-checkbox-color-hover, var(--mod-checkbox-invalid-color-hover, var(--spectrum-checkbox-invalid-color-hover))); + border-color: var(--highcontrast-checkbox-highlight-color-default); + border-width: var(--mod-checkbox-selected-border-width, var(--spectrum-checkbox-selected-border-width)); } - } - } - /* Selected and Indeterminate Hover States */ - &:hover { - &.is-indeterminate .spectrum-Checkbox-box, - &.is-indeterminate .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box, - .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box { - &::before { - border-color: var(--highcontrast-checkbox-highlight-color-hover, var(--mod-checkbox-emphasized-color-hover, var(--spectrum-checkbox-emphasized-color-hover))); + .spectrum-Checkbox-checkmark { + display: none; + } + + .spectrum-Checkbox-partialCheckmark { + display: block; + transform: scale(1); + opacity: 1; } } } +} - /* Selected and Indeterminate Active States */ - &:active { - &.is-indeterminate .spectrum-Checkbox-box, - &.is-indeterminate .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box, - .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box { - &::before { - border-color: var(--highcontrast-checkbox-highlight-color-default, var(--mod-checkbox-emphasized-color-down, var(--spectrum-checkbox-emphasized-color-down))); - } +/* Invalid state indeterminate override - for default state */ +.spectrum-Checkbox.is-invalid.is-indeterminate { + .spectrum-Checkbox-box, + .spectrum-Checkbox-input:checked:not(:disabled) + .spectrum-Checkbox-box { + &::before { + border-color: var(--highcontrast-checkbox-highlight-color-default, var(--spectrum-checkbox-control-selected-color-default)); } } - /* Invalid Active State */ - &.is-invalid:active { - .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box, - .spectrum-Checkbox-box { - &::before { - border-color: var(--highcontrast-checkbox-highlight-color-default, var(--mod-checkbox-control-invalid-color-down, var(--spectrum-checkbox-invalid-color-down))); - } + .spectrum-Checkbox-input:focus-visible + .spectrum-Checkbox-box { + &::before { + border-color: var(--highcontrast-checkbox-color-focus, var(--spectrum-checkbox-control-color-focus)); } } - /* Focus State */ - &:focus-visible { - .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box, - .spectrum-Checkbox-box { + &:hover { + .spectrum-Checkbox-box, + .spectrum-Checkbox-input:checked:not(:disabled) + .spectrum-Checkbox-box { &::before { - border-color: var(--highcontrast-checkbox-color-focus, var(--mod-checkbox-control-color-focus, var(--spectrum-checkbox-control-color-focus))); + border-color: var(--highcontrast-checkbox-highlight-color-hover, var(--spectrum-checkbox-control-selected-color-hover)); } } } } -.spectrum-Checkbox-label { - text-align: start; - margin-inline-start: var(--mod-checkbox-text-to-control, var(--spectrum-checkbox-text-to-control)); - margin-block-start: var(--mod-checkbox-top-to-text, var(--spectrum-checkbox-top-to-text)); - - font-size: var(--mod-checkbox-font-size, var(--spectrum-checkbox-font-size)); - - /* TODO Use font-weight and font-style tokens */ - /* font-weight: var(--spectrum-checkbox-text-font-weight); */ - /* font-style: var(--spectrum-checkbox-text-font-style); */ - - transition: color var(--mod-checkbox-animation-duration, var(--spectrum-checkbox-animation-duration)) ease-in-out; - - line-height: var(--mod-checkbox-line-height, var(--spectrum-checkbox-line-height)); - - &:lang(ja), - &:lang(zh), - &:lang(ko) { - line-height: var(--mod-checkbox-line-height-cjk, var(--spectrum-checkbox-line-height-cjk)); - } -} - -/** - * The input is visually hidden (with opacity), and remains accessible using assistive tech. - * It is still sized and positioned where it would naturally be present so that touch users can find it with haptics. - */ -.spectrum-Checkbox-input { - color: var(--mod-checkbox-control-color-default, var(--spectrum-checkbox-control-color-default)); - - /* Change the font styles in all browsers for input. */ - font-family: inherit; - font-size: 100%; - line-height: 1.15; - - /* Remove the margin for input in Firefox and Safari. */ - margin: 0; - - /* Show the overflow for input in Edge. */ - overflow: visible; - - /* Add the correct box sizing for [type="checkbox"] in IE 10-. */ - box-sizing: border-box; - - /* Remove the padding for [type="checkbox"] in IE 10-. */ - padding: 0; - - position: absolute; - inline-size: 100%; - block-size: 100%; - - opacity: 0; - z-index: 1; - - cursor: pointer; - - &:disabled { - cursor: default; - } - - /* Selected */ - &:checked + .spectrum-Checkbox-box { +/* Emphasized state overrides - all configurations at the top apply except for the ones below: indeterminate, indeterminate focused, focused + checked */ +.spectrum-Checkbox--emphasized.is-indeterminate { + .spectrum-Checkbox-box, + .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box { &::before { - border-color: var(--highcontrast-checkbox-highlight-color-default, var(--mod-checkbox-control-selected-color-default, var(--spectrum-checkbox-control-selected-color-default))); - background-color: var(--mod-checkbox-checkmark-color, var(--spectrum-checkbox-checkmark-color)); - border-width: var(--mod-checkbox-selected-border-width, var(--spectrum-checkbox-selected-border-width)); - } - - .spectrum-Checkbox-checkmark { - transform: scale(1); - opacity: 1; + border-color: var(--highcontrast-checkbox-highlight-color-default, var(--spectrum-checkbox-control-selected-color-default)); } } - /* Focus */ - &:focus-visible + .spectrum-Checkbox-box { + &:not(.is-invalid) .spectrum-Checkbox-input:focus-visible + .spectrum-Checkbox-box { &::before { - border-color: var(--highcontrast-checkbox-color-focus, var(--mod-checkbox-control-color-focus, var(--spectrum-checkbox-control-color-focus))); + border-color: var(--highcontrast-checkbox-color-focus, var(--spectrum-checkbox-emphasized-color-focus)); } - - &::after { - forced-color-adjust: none; - box-shadow: 0 0 0 var(--mod-checkbox-focus-indicator-thinkness, var(--spectrum-checkbox-focus-indicator-thickness)) var(--highcontrast-checkbox-focus-indicator-color, var(--mod-checkbox-focus-indicator-color, var(--spectrum-checkbox-focus-indicator-color))); - margin: calc(var(--mod-checkbox-focus-indicator-gap, var(--spectrum-checkbox-focus-indicator-gap)) * -1); - } - } - - &:focus-visible + .spectrum-Checkbox-label { - color: var(--highcontrast-checkbox-content-color-focus, var(--mod-checkbox-content-color-focus, var(--spectrum-checkbox-content-color-focus))); } - /* Selected and Focus */ - &:focus-visible:checked + .spectrum-Checkbox-box { - &::before { - border-color: var(--highcontrast-checkbox-highlight-color-focus, var(--mod-checkbox-control-selected-color-focus, var(--spectrum-checkbox-control-selected-color-focus))); + &:hover { + .spectrum-Checkbox-box, + .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box { + &::before { + border-color: var(--highcontrast-checkbox-highlight-color-hover, var(--spectrum-checkbox-control-selected-color-hover)); + } } } } -.spectrum-Checkbox-box { - --spectrum-checkbox-spacing: calc(var(--mod-checkbox-height, var(--spectrum-checkbox-height)) - var(--mod-checkbox-control-size, var(--spectrum-checkbox-control-size))); - - display: flex; - align-items: center; - justify-content: center; - - position: relative; - box-sizing: border-box; - inline-size: var(--mod-checkbox-control-size, var(--spectrum-checkbox-control-size)); - block-size: var(--mod-checkbox-control-size, var(--spectrum-checkbox-control-size)); - - /* Fix vertical alignment when not wrapping since we're flex-start */ - margin: calc(var(--mod-checkbox-spacing, var(--spectrum-checkbox-spacing)) / 2) 0; - - flex-grow: 0; - flex-shrink: 0; - - &::before { - forced-color-adjust: none; - border-color: var(--highcontrast-checkbox-color-default, var(--mod-checkbox-control-color-default, var(--spectrum-checkbox-control-color-default))); - - display: block; - z-index: 0; - content: ""; - box-sizing: border-box; - position: absolute; - - inline-size: var(--mod-checkbox-control-size, var(--spectrum-checkbox-control-size)); - block-size: var(--mod-checkbox-control-size, var(--spectrum-checkbox-control-size)); - - border-radius: var(--mod-checkbox-control-corner-radius, var(--spectrum-checkbox-control-corner-radius)); - border-width: var(--mod-checkbox-border-width, var(--spectrum-checkbox-border-width)); - border-style: solid; - - transition: - border var(--mod-checkbox-animation-duration, var(--spectrum-checkbox-animation-duration)) ease-in-out, - box-shadow var(--mod-checkbox-animation-duration, var(--spectrum-checkbox-animation-duration)) ease-in-out; - } - - &::after { - border-radius: calc(var(--mod-checkbox-control-corner-radius, var(--spectrum-checkbox-control-corner-radius)) + var(--mod-checkbox-focus-indicator-gap, var(--spectrum-checkbox-focus-indicator-gap))); - content: ""; - display: block; - position: absolute; - inset-inline-start: 0; - inset-inline-end: 0; - inset-block-end: 0; - inset-block-start: 0; - margin: var(--mod-checkbox-focus-indicator-gap, var(--spectrum-checkbox-focus-indicator-gap)); - - transition: - box-shadow var(--mod-checkbox-animation-duration, var(--spectrum-checkbox-animation-duration)) ease-out, - margin var(--mod-checkbox-animation-duration, var(--spectrum-checkbox-animation-duration)) ease-out; - - /* force ff to render on the pixel grid */ - transform: translate(0, 0); - } -} - -.spectrum-Checkbox { - .spectrum-Checkbox-checkmark, - .spectrum-Checkbox-partialCheckmark { - color: var(--highcontrast-checkbox-background-color-default, var(--mod-checkbox-checkmark-color, var(--spectrum-checkbox-checkmark-color))); - opacity: 0; - transform: scale(0); - - transition: - opacity var(--mod-checkbox-animation-duration, var(--spectrum-checkbox-animation-duration)) ease-in-out, - transform var(--mod-checkbox-animation-duration, var(--spectrum-checkbox-animation-duration)) ease-in-out; - } - - .spectrum-Checkbox-partialCheckmark { - display: none; +.spectrum-Checkbox--emphasized { + &:not(.is-invalid) .spectrum-Checkbox-input:focus-visible:checked + .spectrum-Checkbox-box { + &::before { + --mod-checkbox-control-color-focus: var(--highcontrast-checkbox-color-focus, var(--spectrum-checkbox-emphasized-color-focus)); + } } } -/* Disabled */ +/* Disabled state for all variants - default, invalid, emphasized */ .spectrum-Checkbox .spectrum-Checkbox-input, .spectrum-Checkbox .spectrum-Checkbox-input:checked { &:disabled + .spectrum-Checkbox-box { &::before { border-color: var(--highcontrast-checkbox-disabled-color-default, var(--mod-checkbox-control-color-disabled, var(--spectrum-checkbox-control-color-disabled))); + background-color: var(--highcontrast-checkbox-background-color-default, var(--spectrum-checkbox-background-color)); + } + } - background-color: var(--highcontrast-checkbox-background-color-default, var(--mod-checkbox-checkmark-color, var(--spectrum-checkbox-checkmark-color))); + &:hover:disabled + .spectrum-Checkbox-box { + &::before { + border-color: var(--highcontrast-checkbox-disabled-color-default, var(--mod-checkbox-control-color-disabled, var(--spectrum-checkbox-control-color-disabled))); } } &:disabled ~ .spectrum-Checkbox-label { - forced-color-adjust: none; - color: var(--highcontrast-checkbox-disabled-color-default, var(--mod-checkbox-content-color-disabled, var(--spectrum-checkbox-content-color-disabled))); + color: var(--highcontrast-checkbox-disabled-color-default, var(--mod-checkbox-content-color-disabled, var(--spectrum-checkbox-control-color-disabled))); } } @@ -533,13 +430,8 @@ &:focus-visible + .spectrum-Checkbox-box { forced-color-adjust: none; outline-color: var(--highcontrast-checkbox-focus-indicator-color, var(--mod-checkbox-focus-indicator-color, var(--spectrum-checkbox-focus-indicator-color))); - outline-style: auto; outline-offset: var(--mod-checkbox-focus-indicator-gap, var(--spectrum-checkbox-focus-indicator-gap)); outline-width: var(--mod-focus-indicator-thickness, var(--spectrum-focus-indicator-thickness)); - - &::after { - box-shadow: 0 0 0 0 var(--highcontrast-checkbox-focus-indicator-color, var(--mod-checkbox-focus-indicator-color, var(--spectrum-checkbox-focus-indicator-color))); - } } } @@ -554,13 +446,11 @@ --highcontrast-checkbox-background-color-default: Canvas; --highcontrast-checkbox-color-default: ButtonText; - --highcontrast-checkbox-color-hover: ButtonText; --highcontrast-checkbox-color-focus: Highlight; --highcontrast-checkbox-highlight-color-default: Highlight; --highcontrast-checkbox-highlight-color-hover: Highlight; --highcontrast-checkbox-highlight-color-down: Highlight; - --highcontrast-checkbox-highlight-color-focus: Highlight; --highcontrast-checkbox-disabled-color-default: GrayText; --highcontrast-checkbox-focus-indicator-color: CanvasText; diff --git a/components/checkbox/package.json b/components/checkbox/package.json index f62db8c7af7..cbaf62bd538 100644 --- a/components/checkbox/package.json +++ b/components/checkbox/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/checkbox", - "version": "10.2.0", + "version": "11.0.0-next.2", "description": "The Spectrum CSS checkbox component", "license": "Apache-2.0", "author": "Adobe", @@ -19,15 +19,13 @@ "./package.json": "./package.json", "./dist/*": "./dist/*", "./index.css": "./dist/index.css", - "./index-*.css": "./dist/index-*.css", "./metadata.json": "./dist/metadata.json", - "./themes/*": "./dist/themes/*", "./stories/*": "./stories/*" }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/icon": ">=9.0.0 <10.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/icon": ">=10.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/icon": { @@ -38,8 +36,8 @@ } }, "devDependencies": { - "@spectrum-css/icon": "9.2.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/icon": "10.0.0-next.3", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/checkbox/stories/checkbox.stories.js b/components/checkbox/stories/checkbox.stories.js index cbcad99494f..1941061d619 100644 --- a/components/checkbox/stories/checkbox.stories.js +++ b/components/checkbox/stories/checkbox.stories.js @@ -1,6 +1,6 @@ import { Sizes } from "@spectrum-css/preview/decorators"; import { disableDefaultModes } from "@spectrum-css/preview/modes"; -import { isChecked, isDisabled, isEmphasized, isHovered, isIndeterminate, isInvalid, isReadOnly, size } from "@spectrum-css/preview/types"; +import { isActive, isChecked, isDisabled, isEmphasized, isHovered, isIndeterminate, isInvalid, isReadOnly, size } from "@spectrum-css/preview/types"; import metadata from "../dist/metadata.json"; import packageJson from "../package.json"; import { CheckboxGroup } from "./checkbox.test.js"; @@ -36,6 +36,7 @@ export default { isChecked, isIndeterminate, isReadOnly, + isActive, }, args: { rootClass: "spectrum-Checkbox", @@ -48,6 +49,7 @@ export default { isIndeterminate: false, isInvalid: false, isReadOnly: false, + isActive: false, }, parameters: { actions: { @@ -59,7 +61,11 @@ export default { }, packageJson, metadata, + status: { + type: "migrated", + }, }, + tags: ["migrated"], }; export const Default = CheckboxGroup.bind({}); diff --git a/components/checkbox/stories/checkbox.test.js b/components/checkbox/stories/checkbox.test.js index a7c3efcaaf3..b1eef5f51d6 100644 --- a/components/checkbox/stories/checkbox.test.js +++ b/components/checkbox/stories/checkbox.test.js @@ -23,37 +23,184 @@ export const CheckboxGroup = Variants({ } ], stateData: [ + { + testHeading: "Default", + }, { testHeading: "Checked", isChecked: true, }, { - testHeading: "Checked, hovered", - isChecked: true, + testHeading: "Hovered", isHovered: true, }, + { + testHeading: "Focused", + isFocused: true, + }, + { + testHeading: "Active", + isActive: true, + }, { testHeading: "Indeterminate", isIndeterminate: true, }, + { + testHeading: "Checked + Hovered", + isChecked: true, + isHovered: true, + }, + { + testHeading: "Checked + Focused", + isChecked: true, + isFocused: true, + }, + { + testHeading: "Checked + Indeterminate", + isChecked: true, + isIndeterminate: true, + }, + { + testHeading: "Hovered + Focused", + isHovered: true, + isFocused: true, + }, + { + testHeading: "Hovered + Indeterminate", + isHovered: true, + isIndeterminate: true, + }, + { + testHeading: "Focused + Indeterminate", + isFocused: true, + isIndeterminate: true, + }, + { + testHeading: "Checked + Hovered + Focused", + isChecked: true, + isHovered: true, + isFocused: true, + }, + { + testHeading: "Checked + Hovered + Indeterminate", + isChecked: true, + isHovered: true, + isIndeterminate: true, + }, + { + testHeading: "Checked + Focused + Indeterminate", + isChecked: true, + isFocused: true, + isIndeterminate: true, + }, + { + testHeading: "Checked + Hovered + Focused + Indeterminate", + isChecked: true, + isHovered: true, + isFocused: true, + isIndeterminate: true, + }, + { + testHeading: "Hovered + Focused + Indeterminate", + isHovered: true, + isFocused: true, + isIndeterminate: true, + }, { testHeading: "Invalid", isInvalid: true, }, { - testHeading: "Invalid, checked", + testHeading: "Invalid + Checked", isInvalid: true, isChecked: true, }, { - testHeading: "Invalid, checked, hovered", + testHeading: "Invalid + Hovered", + isInvalid: true, + isHovered: true, + }, + { + testHeading: "Invalid + Focused", + isInvalid: true, + isFocused: true, + }, + { + testHeading: "Invalid + Indeterminate", + isInvalid: true, + isIndeterminate: true, + }, + { + testHeading: "Invalid + Checked + Hovered", + isInvalid: true, + isChecked: true, + isHovered: true, + }, + { + testHeading: "Invalid + Checked + Focused", + isInvalid: true, + isChecked: true, + isFocused: true, + }, + { + testHeading: "Invalid + Checked + Indeterminate", + isInvalid: true, + isChecked: true, + isIndeterminate: true, + }, + { + testHeading: "Invalid + Hovered + Focused", + isInvalid: true, + isHovered: true, + isFocused: true, + }, + { + testHeading: "Invalid + Hovered + Indeterminate", + isInvalid: true, + isHovered: true, + isIndeterminate: true, + }, + { + testHeading: "Invalid + Focused + Indeterminate", + isInvalid: true, + isFocused: true, + isIndeterminate: true, + }, + { + testHeading: "Invalid + Checked + Hovered + Focused", + isInvalid: true, + isChecked: true, + isHovered: true, + isFocused: true, + }, + { + testHeading: "Invalid + Checked + Hovered + Indeterminate", isInvalid: true, isChecked: true, isHovered: true, + isIndeterminate: true, }, { - testHeading: "Invalid, indeterminate", + testHeading: "Invalid + Checked + Focused + Indeterminate", isInvalid: true, + isChecked: true, + isFocused: true, + isIndeterminate: true, + }, + { + testHeading: "Invalid + Hovered + Focused + Indeterminate", + isInvalid: true, + isHovered: true, + isFocused: true, + isIndeterminate: true, + }, + { + testHeading: "Invalid + Checked + Hovered + Focused + Indeterminate", + isInvalid: true, + isChecked: true, + isHovered: true, + isFocused: true, isIndeterminate: true, }, { @@ -61,44 +208,523 @@ export const CheckboxGroup = Variants({ isDisabled: true, }, { - testHeading: "Disabled, checked", + testHeading: "Invalid + Disabled", + isInvalid: true, isDisabled: true, + }, + { + testHeading: "Checked + Disabled", isChecked: true, + isDisabled: true, }, { - testHeading: "Disabled, checked, hovered", + testHeading: "Hovered + Disabled", + isHovered: true, isDisabled: true, + }, + { + testHeading: "Focused + Disabled", + isFocused: true, + isDisabled: true, + }, + { + testHeading: "Indeterminate + Disabled", + isIndeterminate: true, + isDisabled: true, + }, + { + testHeading: "Invalid + Checked + Disabled", + isInvalid: true, + isChecked: true, + isDisabled: true, + }, + { + testHeading: "Invalid + Hovered + Disabled", + isInvalid: true, + isHovered: true, + isDisabled: true, + }, + { + testHeading: "Invalid + Focused + Disabled", + isInvalid: true, + isFocused: true, + isDisabled: true, + }, + { + testHeading: "Invalid + Indeterminate + Disabled", + isInvalid: true, + isIndeterminate: true, + isDisabled: true, + }, + { + testHeading: "Checked + Hovered + Disabled", + isChecked: true, + isHovered: true, + isDisabled: true, + }, + { + testHeading: "Checked + Focused + Disabled", + isChecked: true, + isFocused: true, + isDisabled: true, + }, + { + testHeading: "Checked + Indeterminate + Disabled", + isChecked: true, + isIndeterminate: true, + isDisabled: true, + }, + { + testHeading: "Hovered + Focused + Disabled", + isHovered: true, + isFocused: true, + isDisabled: true, + }, + { + testHeading: "Hovered + Indeterminate + Disabled", + isHovered: true, + isIndeterminate: true, + isDisabled: true, + }, + { + testHeading: "Focused + Indeterminate + Disabled", + isFocused: true, + isIndeterminate: true, + isDisabled: true, + }, + { + testHeading: "Invalid + Checked + Hovered + Disabled", + isInvalid: true, + isChecked: true, + isHovered: true, + isDisabled: true, + }, + { + testHeading: "Invalid + Checked + Focused + Disabled", + isInvalid: true, + isChecked: true, + isFocused: true, + isDisabled: true, + }, + { + testHeading: "Invalid + Hovered + Indeterminate + Disabled", + isInvalid: true, + isHovered: true, + isIndeterminate: true, + isDisabled: true, + }, + { + testHeading: "Invalid + Focused + Indeterminate + Disabled", + isInvalid: true, + isFocused: true, + isIndeterminate: true, + isDisabled: true, + }, + { + testHeading: "Checked + Hovered + Indeterminate + Disabled", + isChecked: true, + isHovered: true, + isIndeterminate: true, + isDisabled: true, + }, + { + testHeading: "Checked + Focused + Indeterminate + Disabled", + isChecked: true, + isFocused: true, + isIndeterminate: true, + isDisabled: true, + }, + { + testHeading: "Hovered + Focused + Indeterminate + Disabled", + isHovered: true, + isFocused: true, + isIndeterminate: true, + isDisabled: true, + }, + { + testHeading: "Invalid + Checked + Hovered + Focused + Disabled", + isInvalid: true, + isChecked: true, + isHovered: true, + isFocused: true, + isDisabled: true, + }, + { + testHeading: "Invalid + Checked + Hovered + Indeterminate + Disabled", + isInvalid: true, + isChecked: true, + isHovered: true, + isIndeterminate: true, + isDisabled: true, + }, + { + testHeading: "Invalid + Checked + Focused + Indeterminate + Disabled", + isInvalid: true, isChecked: true, + isFocused: true, + isIndeterminate: true, + isDisabled: true, + }, + { + testHeading: "Invalid + Hovered + Focused + Indeterminate + Disabled", + isInvalid: true, + isHovered: true, + isFocused: true, + isIndeterminate: true, + isDisabled: true, }, { - testHeading: "Disabled, indeterminate", + testHeading: "Checked + Hovered + Focused + Indeterminate + Disabled", + isChecked: true, + isHovered: true, + isFocused: true, + isIndeterminate: true, isDisabled: true, + }, + { + testHeading: "Invalid + Checked + Hovered + Focused + Indeterminate + Disabled", + isInvalid: true, + isChecked: true, + isHovered: true, + isFocused: true, isIndeterminate: true, + isDisabled: true, }, { testHeading: "Read-only", isReadOnly: true, }, { - testHeading: "Read-only, checked", + testHeading: "Checked + Read-only", + isChecked: true, + isReadOnly: true, + }, + { + testHeading: "Hovered + Read-only", + isHovered: true, isReadOnly: true, + }, + { + testHeading: "Focused + Read-only", + isFocused: true, + isReadOnly: true, + }, + { + testHeading: "Indeterminate + Read-only", + isIndeterminate: true, + isReadOnly: true, + }, + { + testHeading: "Invalid + Read-only", + isInvalid: true, + isReadOnly: true, + }, + { + testHeading: "Invalid + Checked + Read-only", + isInvalid: true, + isChecked: true, + isReadOnly: true, + }, + { + testHeading: "Invalid + Hovered + Read-only", + isInvalid: true, + isHovered: true, + isReadOnly: true, + }, + { + testHeading: "Invalid + Focused + Read-only", + isInvalid: true, + isFocused: true, + isReadOnly: true, + }, + { + testHeading: "Invalid + Indeterminate + Read-only", + isInvalid: true, + isIndeterminate: true, + isReadOnly: true, + }, + { + testHeading: "Checked + Hovered + Read-only", + isChecked: true, + isHovered: true, + isReadOnly: true, + }, + { + testHeading: "Checked + Focused + Read-only", + isChecked: true, + isFocused: true, + isReadOnly: true, + }, + { + testHeading: "Checked + Indeterminate + Read-only", + isChecked: true, + isIndeterminate: true, + isReadOnly: true, + }, + { + testHeading: "Hovered + Focused + Read-only", + isHovered: true, + isFocused: true, + isReadOnly: true, + }, + { + testHeading: "Hovered + Indeterminate + Read-only", + isHovered: true, + isIndeterminate: true, + isReadOnly: true, + }, + { + testHeading: "Focused + Indeterminate + Read-only", + isFocused: true, + isIndeterminate: true, + isReadOnly: true, + }, + { + testHeading: "Invalid + Checked + Hovered + Read-only", + isInvalid: true, + isChecked: true, + isHovered: true, + isReadOnly: true, + }, + { + testHeading: "Invalid + Checked + Focused + Read-only", + isInvalid: true, + isChecked: true, + isFocused: true, + isReadOnly: true, + }, + { + testHeading: "Invalid + Hovered + Indeterminate + Read-only", + isInvalid: true, + isHovered: true, + isIndeterminate: true, + isReadOnly: true, + }, + { + testHeading: "Invalid + Focused + Indeterminate + Read-only", + isInvalid: true, + isFocused: true, + isIndeterminate: true, + isReadOnly: true, + }, + { + testHeading: "Checked + Hovered + Indeterminate + Read-only", + isChecked: true, + isHovered: true, + isIndeterminate: true, + isReadOnly: true, + }, + { + testHeading: "Checked + Focused + Indeterminate + Read-only", + isChecked: true, + isFocused: true, + isIndeterminate: true, + isReadOnly: true, + }, + { + testHeading: "Hovered + Focused + Indeterminate + Read-only", + isHovered: true, + isFocused: true, + isIndeterminate: true, + isReadOnly: true, + }, + { + testHeading: "Invalid + Checked + Hovered + Focused + Read-only", + isInvalid: true, + isChecked: true, + isHovered: true, + isFocused: true, + isReadOnly: true, + }, + { + testHeading: "Invalid + Checked + Hovered + Indeterminate + Read-only", + isInvalid: true, + isChecked: true, + isHovered: true, + isIndeterminate: true, + isReadOnly: true, + }, + { + testHeading: "Invalid + Checked + Focused + Indeterminate + Read-only", + isInvalid: true, + isChecked: true, + isFocused: true, + isIndeterminate: true, + isReadOnly: true, + }, + { + testHeading: "Invalid + Hovered + Focused + Indeterminate + Read-only", + isInvalid: true, + isHovered: true, + isFocused: true, + isIndeterminate: true, + isReadOnly: true, + }, + { + testHeading: "Checked + Hovered + Focused + Indeterminate + Read-only", + isChecked: true, + isHovered: true, + isFocused: true, + isIndeterminate: true, + isReadOnly: true, + }, + { + testHeading: "Invalid + Checked + Hovered + Focused + Indeterminate + Read-only", + isInvalid: true, + isChecked: true, + isHovered: true, + isFocused: true, + isIndeterminate: true, + isReadOnly: true, + }, + { + testHeading: "Disabled + Read-only", + isDisabled: true, + isReadOnly: true, + }, + { + testHeading: "Invalid + Disabled + Read-only", + isInvalid: true, + isDisabled: true, + isReadOnly: true, + }, + { + testHeading: "Checked + Disabled + Read-only", + isChecked: true, + isDisabled: true, + isReadOnly: true, + }, + { + testHeading: "Hovered + Disabled + Read-only", + isHovered: true, + isDisabled: true, + isReadOnly: true, + }, + { + testHeading: "Focused + Disabled + Read-only", + isFocused: true, + isDisabled: true, + isReadOnly: true, + }, + { + testHeading: "Indeterminate + Disabled + Read-only", + isIndeterminate: true, + isDisabled: true, + isReadOnly: true, + }, + { + testHeading: "Invalid + Checked + Disabled + Read-only", + isInvalid: true, + isChecked: true, + isDisabled: true, + isReadOnly: true, + }, + { + testHeading: "Invalid + Hovered + Disabled + Read-only", + isInvalid: true, + isHovered: true, + isDisabled: true, + isReadOnly: true, + }, + { + testHeading: "Invalid + Focused + Disabled + Read-only", + isInvalid: true, + isFocused: true, + isDisabled: true, + isReadOnly: true, + }, + { + testHeading: "Invalid + Indeterminate + Disabled + Read-only", + isInvalid: true, + isIndeterminate: true, + isDisabled: true, + isReadOnly: true, + }, + { + testHeading: "Checked + Hovered + Disabled + Read-only", + isChecked: true, + isHovered: true, + isDisabled: true, + isReadOnly: true, + }, + { + testHeading: "Checked + Focused + Disabled + Read-only", + isChecked: true, + isFocused: true, + isDisabled: true, + isReadOnly: true, + }, + { + testHeading: "Checked + Indeterminate + Disabled + Read-only", isChecked: true, + isIndeterminate: true, + isDisabled: true, + isReadOnly: true, }, { - testHeading: "Read-only, checked, hovered", + testHeading: "Hovered + Indeterminate + Disabled + Read-only", + isHovered: true, + isIndeterminate: true, + isDisabled: true, isReadOnly: true, + }, + { + testHeading: "Focused + Indeterminate + Disabled + Read-only", + isFocused: true, + isIndeterminate: true, + isDisabled: true, + isReadOnly: true, + }, + { + testHeading: "Invalid + Checked + Hovered + Disabled + Read-only", + isInvalid: true, isChecked: true, isHovered: true, + isDisabled: true, + isReadOnly: true, }, { - testHeading: "Read-only, indeterminate", + testHeading: "Invalid + Checked + Focused + Disabled + Read-only", + isInvalid: true, + isChecked: true, + isFocused: true, + isDisabled: true, isReadOnly: true, + }, + { + testHeading: "Invalid + Hovered + Indeterminate + Disabled + Read-only", + isInvalid: true, + isHovered: true, + isIndeterminate: true, + isDisabled: true, + isReadOnly: true, + }, + { + testHeading: "Invalid + Focused + Indeterminate + Disabled + Read-only", + isInvalid: true, + isFocused: true, isIndeterminate: true, + isDisabled: true, + isReadOnly: true, }, { - testHeading: "Read-only, checked, disabled", + testHeading: "Checked + Hovered + Focused + Indeterminate + Disabled + Read-only", + isChecked: true, + isHovered: true, + isFocused: true, + isIndeterminate: true, + isDisabled: true, isReadOnly: true, + }, + { + testHeading: "Invalid + Checked + Hovered + Focused + Indeterminate + Disabled + Read-only", + isInvalid: true, isChecked: true, + isHovered: true, + isFocused: true, + isIndeterminate: true, + isDisabled: true, + isReadOnly: true, }, - ] + ], }); diff --git a/components/checkbox/stories/template.js b/components/checkbox/stories/template.js index ebeaba0e276..0c7c42b6272 100644 --- a/components/checkbox/stories/template.js +++ b/components/checkbox/stories/template.js @@ -7,9 +7,6 @@ import { styleMap } from "lit/directives/style-map.js"; import { when } from "lit/directives/when.js"; import "../index.css"; -import "../themes/spectrum.css"; -/* Must be imported last */ -import "../themes/express.css"; export const Template = ({ rootClass = "spectrum-Checkbox", @@ -22,6 +19,8 @@ export const Template = ({ isDisabled = false, isInvalid = false, isReadOnly = false, + isFocused = false, + isActive = false, title, value, id = getRandomId("checkbox"), @@ -58,6 +57,7 @@ export const Template = ({ ["is-invalid"]: isInvalid, ["is-hover"]: isHovered && !isDisabled, ["is-readOnly"]: isReadOnly, + ["is-active"]: isActive, ...customClasses.reduce((a, c) => ({ ...a, [c]: true }), {}), })} id=${ifDefined(id)} @@ -65,7 +65,10 @@ export const Template = ({ > - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--express */ - -@import "./spectrum.css"; - -@container style(--system: express) { - .spectrum-Checkbox { - --spectrum-checkbox-control-color-default: var(--spectrum-gray-800); - --spectrum-checkbox-control-color-hover: var(--spectrum-gray-900); - --spectrum-checkbox-control-color-down: var(--spectrum-gray-900); - --spectrum-checkbox-control-color-focus: var(--spectrum-gray-900); - } -} diff --git a/components/checkbox/themes/spectrum-two.css b/components/checkbox/themes/spectrum-two.css deleted file mode 100644 index 4b7d8a675f8..00000000000 --- a/components/checkbox/themes/spectrum-two.css +++ /dev/null @@ -1,24 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -@container style(--system: spectrum) { - .spectrum-Checkbox { - --spectrum-checkbox-control-color-default: var(--spectrum-neutral-content-color-default); - --spectrum-checkbox-control-color-hover: var(--spectrum-gray-700); - --spectrum-checkbox-control-color-down: var(--spectrum-gray-800); - --spectrum-checkbox-control-color-focus: var(--spectrum-gray-700); - - --spectrum-checkbox-checkmark-color: var(--spectrum-gray-50); - --spectrum-checkbox-control-corner-radius: 2px; - } -} diff --git a/components/checkbox/themes/spectrum.css b/components/checkbox/themes/spectrum.css deleted file mode 100644 index 698c531cc51..00000000000 --- a/components/checkbox/themes/spectrum.css +++ /dev/null @@ -1,24 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--legacy */ - -@import "./spectrum-two.css"; - -@container style(--system: legacy) { - .spectrum-Checkbox { - --spectrum-checkbox-control-color-default: var(--spectrum-gray-600); - --spectrum-checkbox-checkmark-color: var(--spectrum-gray-75); - --spectrum-checkbox-control-corner-radius: var(--spectrum-corner-radius-75); - } -} diff --git a/components/clearbutton/CHANGELOG.md b/components/clearbutton/CHANGELOG.md index 54b7794a74e..5e08ea21d55 100644 --- a/components/clearbutton/CHANGELOG.md +++ b/components/clearbutton/CHANGELOG.md @@ -1,5 +1,34 @@ # Change log +## 8.0.0-next.2 + +### Major Changes + +📝 [#4043](https://github.com/adobe/spectrum-css/pull/4043) [`0242f7f`](https://github.com/adobe/spectrum-css/commit/0242f7f69ec24ef6c6f000324a7b44106e4603fa) Thanks [@cdransf](https://github.com/cdransf)! + +#### S2 migration for clear button + +This migrates the clear button component to the latest Spectrum 2 designs. Custom properties have been remapped and added per the design specification. + +- The quiet variant has been remove as all clear buttons have a transparent background. +- The over-background and static color variants have been removed. +- Test and stories for deprecated variants have been removed. +- The down state has been added, corresponding controls and tests have been added. + +## 8.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + +## 8.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`a25e0a9`](https://github.com/adobe/spectrum-css/commit/a25e0a99e5a4736ab4e607e00739343101a2633b)]: + - @spectrum-css/icon@10.0.0-next.0 + ## 7.3.0 ### Minor Changes @@ -12,7 +41,9 @@ Ensure accurate exports are present for each component. Specifically, adding `th ### Minor Changes -- [#3527](https://github.com/adobe/spectrum-css/pull/3527) [`5f1751c`](https://github.com/adobe/spectrum-css/commit/5f1751c82a5fe55ae0d999f5f50cfeca4c8a5c75) Thanks [@castastrophe](https://github.com/castastrophe)! - By updating the postcss-preset-env to the latest breaking change version, output for this component no longer injects the `.js-focus-within` and '[focus-within]` selectors for the focus-within polyfill. As this feature is not used in the SWC consumption, risk to the end user for this removal is low. +📝 [#3527](https://github.com/adobe/spectrum-css/pull/3527) [`5f1751c`](https://github.com/adobe/spectrum-css/commit/5f1751c82a5fe55ae0d999f5f50cfeca4c8a5c75) Thanks [@castastrophe](https://github.com/castastrophe)! + +By updating the postcss-preset-env to the latest breaking change version, output for this component no longer injects the `.js-focus-within` and '[focus-within]` selectors for the focus-within polyfill. As this feature is not used in the SWC consumption, risk to the end user for this removal is low. ## 7.1.0 diff --git a/components/clearbutton/dist/metadata.json b/components/clearbutton/dist/metadata.json index 7702979183f..dd50b142662 100644 --- a/components/clearbutton/dist/metadata.json +++ b/components/clearbutton/dist/metadata.json @@ -3,17 +3,14 @@ "selectors": [ ".spectrum-ClearButton", ".spectrum-ClearButton > .spectrum-Icon", - ".spectrum-ClearButton--overBackground:focus-visible", - ".spectrum-ClearButton--staticWhite:focus-visible", ".spectrum-ClearButton-fill", ".spectrum-ClearButton-icon", ".spectrum-ClearButton.is-disabled", - ".spectrum-ClearButton.spectrum-ClearButton--quiet", ".spectrum-ClearButton.spectrum-ClearButton--sizeL", ".spectrum-ClearButton.spectrum-ClearButton--sizeS", ".spectrum-ClearButton.spectrum-ClearButton--sizeXL", - ".spectrum-ClearButton.spectrum-ClearButton--staticWhite", ".spectrum-ClearButton:disabled", + ".spectrum-ClearButton:focus-visible", ".spectrum-ClearButton:not(:disabled)", ".spectrum-ClearButton:not(:disabled):active", ".spectrum-ClearButton:not(:disabled):active .spectrum-ClearButton-fill", @@ -57,25 +54,17 @@ "--spectrum-component-height-200", "--spectrum-component-height-300", "--spectrum-component-height-75", + "--spectrum-component-size-difference-down", + "--spectrum-component-size-minimum-perspective-down", "--spectrum-disabled-content-color", - "--spectrum-disabled-static-white-content-color", - "--spectrum-in-field-button-edge-to-fill", + "--spectrum-in-field-button-edge-to-fill-extra-large", + "--spectrum-in-field-button-edge-to-fill-large", + "--spectrum-in-field-button-edge-to-fill-medium", + "--spectrum-in-field-button-edge-to-fill-small", "--spectrum-neutral-content-color-default", "--spectrum-neutral-content-color-down", "--spectrum-neutral-content-color-hover", - "--spectrum-neutral-content-color-key-focus", - "--spectrum-transparent-white-400", - "--spectrum-transparent-white-500", - "--spectrum-white" - ], - "system-theme": [ - "--system-clear-button-background-color", - "--system-clear-button-background-color-down", - "--system-clear-button-background-color-hover", - "--system-clear-button-background-color-key-focus", - "--system-clear-button-static-white-background-color-down", - "--system-clear-button-static-white-background-color-hover", - "--system-clear-button-static-white-background-color-key-focus" + "--spectrum-neutral-content-color-key-focus" ], "passthroughs": [], "high-contrast": ["--highcontrast-clear-button-icon-color-hover"] diff --git a/components/clearbutton/index.css b/components/clearbutton/index.css index edee47004ee..8289c77e0de 100644 --- a/components/clearbutton/index.css +++ b/components/clearbutton/index.css @@ -1,5 +1,5 @@ /*! -* Copyright 2024 Adobe. All rights reserved. +* Copyright 2025 Adobe. All rights reserved. * * This file is licensed to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. You may obtain a copy @@ -11,59 +11,40 @@ * governing permissions and limitations under the License. */ -@import "./themes/spectrum-two.css"; - .spectrum-ClearButton { --spectrum-clear-button-height: var(--spectrum-component-height-100); --spectrum-clear-button-width: var(--spectrum-component-height-100); - --spectrum-clear-button-padding: var(--spectrum-in-field-button-edge-to-fill); + --spectrum-clear-button-padding: var(--spectrum-in-field-button-edge-to-fill-medium); --spectrum-clear-button-icon-color: var(--spectrum-neutral-content-color-default); --spectrum-clear-button-icon-color-hover: var(--spectrum-neutral-content-color-hover); --spectrum-clear-button-icon-color-down: var(--spectrum-neutral-content-color-down); --spectrum-clear-button-icon-color-key-focus: var(--spectrum-neutral-content-color-key-focus); - block-size: var(--mod-clear-button-height, var(--spectrum-clear-button-height)); - inline-size: var(--mod-clear-button-width, var(--spectrum-clear-button-width)); - border-radius: 100%; - - background-color: var(--mod-clear-button-background-color, transparent); - margin: 0; - padding: var(--mod-clear-button-padding, var(--spectrum-clear-button-padding)); - - border: none; - color: var(--mod-clear-button-icon-color, var(--spectrum-clear-button-icon-color)); + --spectrum-clear-button-background-color: transparent; + --spectrum-clear-button-background-color-hover: transparent; + --spectrum-clear-button-background-color-down: transparent; + --spectrum-clear-button-background-color-key-focus: transparent; &.spectrum-ClearButton--sizeS { --spectrum-clear-button-height: var(--spectrum-component-height-75); --spectrum-clear-button-width: var(--spectrum-component-height-75); + + --spectrum-clear-button-padding: var(--spectrum-in-field-button-edge-to-fill-small); } &.spectrum-ClearButton--sizeL { --spectrum-clear-button-height: var(--spectrum-component-height-200); --spectrum-clear-button-width: var(--spectrum-component-height-200); + + --spectrum-clear-button-padding: var(--spectrum-in-field-button-edge-to-fill-large); } &.spectrum-ClearButton--sizeXL { --spectrum-clear-button-height: var(--spectrum-component-height-300); --spectrum-clear-button-width: var(--spectrum-component-height-300); - } - &.spectrum-ClearButton--quiet { - --mod-clear-button-background-color: transparent; - --mod-clear-button-background-color-hover: transparent; - --mod-clear-button-background-color-down: transparent; - --mod-clear-button-background-color-key-focus: transparent; - } - - &.spectrum-ClearButton--staticWhite { - --mod-clear-button-icon-color: var(--spectrum-white); - --mod-clear-button-icon-color-hover: var(--spectrum-white); - --mod-clear-button-icon-color-down: var(--spectrum-white); - --mod-clear-button-icon-color-key-focus: var(--spectrum-white); - --mod-clear-button-icon-color-disabled: var(--spectrum-disabled-static-white-content-color); - - --mod-clear-button-background-color: transparent; + --spectrum-clear-button-padding: var(--spectrum-in-field-button-edge-to-fill-extra-large); } &:disabled, @@ -73,11 +54,27 @@ --mod-clear-button-icon-color-down: var(--spectrum-disabled-content-color); --mod-clear-button-background-color: var(--mod-clear-button-background-color-disabled, transparent); } +} + +.spectrum-ClearButton { + block-size: var(--mod-clear-button-height, var(--spectrum-clear-button-height)); + inline-size: var(--mod-clear-button-width, var(--spectrum-clear-button-width)); + + background-color: transparent; + margin: 0; + padding: var(--mod-clear-button-padding, var(--spectrum-clear-button-padding)); + + border: none; + color: var(--mod-clear-button-icon-color, var(--spectrum-clear-button-icon-color)); &:not(:disabled) { cursor: pointer; } + &:focus-visible { + outline: none; + } + > .spectrum-Icon { /* @safari10 Workaround for https://bugs.webkit.org/show_bug.cgi?id=169700 */ margin-block: 0; @@ -94,6 +91,7 @@ &:not(:disabled):active { color: var(--mod-clear-button-icon-color-down, var(--spectrum-clear-button-icon-color-down)); + transform: perspective(var(--spectrum-component-size-minimum-perspective-down)) translateZ(var(--spectrum-component-size-difference-down)); .spectrum-ClearButton-fill { background-color: var(--mod-clear-button-background-color-down, var(--spectrum-clear-button-background-color-down)); @@ -119,21 +117,12 @@ inline-size: 100%; block-size: 100%; - border-radius: 100%; display: flex; align-items: center; justify-content: center; } -/* @deprecated .spectrum-ClearButton--overBackground */ -.spectrum-ClearButton--staticWhite, -.spectrum-ClearButton--overBackground { - &:focus-visible { - outline: none; - } -} - @media (forced-colors: active) { .spectrum-ClearButton { &:not(:disabled) { diff --git a/components/clearbutton/package.json b/components/clearbutton/package.json index 1884d2dd096..fa44122d6e9 100644 --- a/components/clearbutton/package.json +++ b/components/clearbutton/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/clearbutton", - "version": "7.3.0", + "version": "8.0.0-next.2", "description": "The Spectrum CSS clearbutton component", "license": "Apache-2.0", "author": "Adobe", @@ -19,15 +19,13 @@ "./package.json": "./package.json", "./dist/*": "./dist/*", "./index.css": "./dist/index.css", - "./index-*.css": "./dist/index-*.css", "./metadata.json": "./dist/metadata.json", - "./themes/*": "./dist/themes/*", "./stories/*": "./stories/*" }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/icon": ">=9.0.0 <10.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/icon": ">=10.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/icon": { @@ -38,8 +36,8 @@ } }, "devDependencies": { - "@spectrum-css/icon": "9.2.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/icon": "10.0.0-next.3", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/clearbutton/stories/clearbutton.stories.js b/components/clearbutton/stories/clearbutton.stories.js index 311f370c833..6c6e3877789 100644 --- a/components/clearbutton/stories/clearbutton.stories.js +++ b/components/clearbutton/stories/clearbutton.stories.js @@ -1,44 +1,13 @@ import { Sizes } from "@spectrum-css/preview/decorators"; import { disableDefaultModes } from "@spectrum-css/preview/modes"; -import { isDisabled, isQuiet, size, staticColor } from "@spectrum-css/preview/types"; +import { isActive, isDisabled, isHovered, size } from "@spectrum-css/preview/types"; import metadata from "../dist/metadata.json"; import packageJson from "../package.json"; import { ClearButtonGroup } from "./clearbutton.test.js"; import { Template } from "./template.js"; /** - * The clear button component is an in-field button used in search and tags. - * - * ## Usage Notes - - Use the correct cross icon size that corresponds to the t-shirt size you require for the clear button. - - - - - - - - - - - - - - - - - - - - - - - - - - -
    **T-Shirt Size****Icon Size**
    spectrum-ClearButton--sizeSspectrum-css-icon-Cross75
    spectrum-ClearButton--sizeMspectrum-css-icon-Cross100
    spectrum-ClearButton--sizeLspectrum-css-icon-Cross200
    spectrum-ClearButton--sizeXLspectrum-css-icon-Cross300
    + * The clear button component is an in-field button used in [search](/docs/components-search-field--docs) and [tags](/docs/components-tag--docs). */ export default { title: "Clear button", @@ -46,17 +15,19 @@ export default { argTypes: { size: size(["s", "m", "l", "xl"]), isDisabled, - isQuiet, - staticColor: { - ...staticColor, - options: ["white"], + isHovered, + isActive, + isFocusable: { + table: { disable: true }, + type: { name: "boolean" }, }, }, args: { rootClass: "spectrum-ClearButton", size: "m", isDisabled: false, - isQuiet: false, + isHovered: false, + isActive: false, }, parameters: { design: { @@ -65,16 +36,19 @@ export default { }, packageJson, metadata, + status: { + type: "migrated", + }, }, + tags: ["migrated"], }; -/** - * The default size for clear button is medium. - */ - export const Default = ClearButtonGroup.bind({}); Default.args = {}; +/** + * When disabled, the clear button color changes to `--spectrum-disabled-content-color` and is not interactive. + */ export const Disabled = Template.bind({}); Disabled.args = { isDisabled: true, @@ -85,17 +59,36 @@ Disabled.parameters = { }; /** - * The `.spectrum-ClearButton--quiet` class will use a transparent background (including when the Express theme is active). - */ -export const Quiet = Template.bind({}); -Quiet.args = { - isQuiet: true, -}; -Quiet.tags = ["!dev"]; -Quiet.parameters = { - chromatic: { disableSnapshot: true }, -}; + * Use the correct cross icon size that corresponds to the t-shirt size you require for the clear button. The default size is medium. + + + + + + + + + + + + + + + + + + + + + + + + + +
    **T-Shirt Size****Icon Size**
    spectrum-ClearButton--sizeSspectrum-css-icon-Cross75
    spectrum-ClearButton--sizeMspectrum-css-icon-Cross100
    spectrum-ClearButton--sizeLspectrum-css-icon-Cross200
    spectrum-ClearButton--sizeXLspectrum-css-icon-Cross300
    + * + */ export const Sizing = (args, context) => Sizes({ Template, withHeading: false, @@ -109,15 +102,6 @@ Sizing.parameters = { }; -export const OverBackground = ClearButtonGroup.bind({}); -OverBackground.tags = ["!dev"]; -OverBackground.args = { - staticColor: "white", -}; -OverBackground.parameters = { - chromatic: { disableSnapshot: true }, -}; - // ********* VRT ONLY ********* // export const WithForcedColors = ClearButtonGroup.bind({}); WithForcedColors.tags = ["!autodocs", "!dev"]; diff --git a/components/clearbutton/stories/clearbutton.test.js b/components/clearbutton/stories/clearbutton.test.js index 6db9bf89dd4..3421b6cc114 100644 --- a/components/clearbutton/stories/clearbutton.test.js +++ b/components/clearbutton/stories/clearbutton.test.js @@ -9,24 +9,19 @@ export const ClearButtonGroup = Variants({ { testHeading: "Default", }, - { - testHeading: "Quiet", - isQuiet: true, - }, - { - testHeading: "Static white", - staticColor: "white", - }, - { - testHeading: "Static white - quiet", - staticColor: "white", - isQuiet: true, - }, ], stateData: [ { testHeading: "Disabled", isDisabled: true, }, + { + testHeading: "Hover", + isHovered: true, + }, + { + testHeading: "Down", + isActive: true, + }, ] }); diff --git a/components/clearbutton/stories/template.js b/components/clearbutton/stories/template.js index 58e90007c04..a8321f114f9 100644 --- a/components/clearbutton/stories/template.js +++ b/components/clearbutton/stories/template.js @@ -6,17 +6,16 @@ import { ifDefined } from "lit/directives/if-defined.js"; import { styleMap } from "lit/directives/style-map.js"; import "../index.css"; -import "../themes/spectrum.css"; -/* Must be imported last */ -import "../themes/express.css"; export const Template = ({ rootClass = "spectrum-ClearButton", isDisabled = false, + isHovered = false, + isActive = false, size = "m", - isQuiet = false, - staticColor, + isFocusable = true, id = getRandomId("clearbutton"), + onclick = () => {}, customClasses = [], customStyles = {}, }, context) => html` @@ -25,19 +24,17 @@ export const Template = ({ class=${classMap({ [rootClass]: true, [`${rootClass}--size${size?.toUpperCase()}`]: typeof size !== "undefined", - [`${rootClass}--quiet`]: isQuiet, - [`${rootClass}--overBackground`]: staticColor === "white", - /** - * There aren't styles for `--staticWhite` in clear button (yet) - * but this makes it easier to support in the testing grid - */ - [`${rootClass}--staticWhite`]: staticColor === "white", "is-disabled": isDisabled, + "is-hover": isHovered, + "is-active": isActive, ...customClasses.reduce((a, c) => ({ ...a, [c]: true }), {}), })} id=${ifDefined(id)} style=${styleMap(customStyles)} ?disabled=${isDisabled} + tabindex=${isFocusable ? 0 : -1} + aria-hidden=${isFocusable} + @click=${onclick} >
    ${Icon({ diff --git a/components/clearbutton/themes/express.css b/components/clearbutton/themes/express.css deleted file mode 100644 index e13724e2883..00000000000 --- a/components/clearbutton/themes/express.css +++ /dev/null @@ -1,25 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--express */ - -@import "./spectrum.css"; - -@container style(--system: express) { - .spectrum-ClearButton { - --spectrum-clear-button-background-color: var(--spectrum-gray-200); - --spectrum-clear-button-background-color-hover: var(--spectrum-gray-300); - --spectrum-clear-button-background-color-down: var(--spectrum-gray-400); - --spectrum-clear-button-background-color-key-focus: var(--spectrum-gray-300); - } -} diff --git a/components/clearbutton/themes/spectrum-two.css b/components/clearbutton/themes/spectrum-two.css deleted file mode 100644 index abba1f78556..00000000000 --- a/components/clearbutton/themes/spectrum-two.css +++ /dev/null @@ -1,27 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -@container style(--system: spectrum) { - .spectrum-ClearButton { - --spectrum-clear-button-background-color: transparent; - --spectrum-clear-button-background-color-hover: transparent; - --spectrum-clear-button-background-color-down: transparent; - --spectrum-clear-button-background-color-key-focus: transparent; - - &.spectrum-ClearButton--staticWhite { - --spectrum-clear-button-background-color-hover: var(--spectrum-transparent-white-400); - --spectrum-clear-button-background-color-down: var(--spectrum-transparent-white-500); - --spectrum-clear-button-background-color-key-focus: var(--spectrum-transparent-white-400); - } - } -} diff --git a/components/clearbutton/themes/spectrum.css b/components/clearbutton/themes/spectrum.css deleted file mode 100644 index e4235fb3dff..00000000000 --- a/components/clearbutton/themes/spectrum.css +++ /dev/null @@ -1,26 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--legacy */ - -@import "./spectrum-two.css"; - -@container style(--system: legacy) { - .spectrum-ClearButton { - &.spectrum-ClearButton--staticWhite { - --spectrum-clear-button-background-color-hover: var(--spectrum-transparent-white-300); - --spectrum-clear-button-background-color-down: var(--spectrum-transparent-white-400); - --spectrum-clear-button-background-color-key-focus: var(--spectrum-transparent-white-300); - } - } -} diff --git a/components/closebutton/CHANGELOG.md b/components/closebutton/CHANGELOG.md index 779740844c4..5bb5a1dd773 100644 --- a/components/closebutton/CHANGELOG.md +++ b/components/closebutton/CHANGELOG.md @@ -1,5 +1,19 @@ # Change log +## 7.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + +## 7.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`a25e0a9`](https://github.com/adobe/spectrum-css/commit/a25e0a99e5a4736ab4e607e00739343101a2633b)]: + - @spectrum-css/icon@10.0.0-next.0 + ## 6.2.0 ### Minor Changes diff --git a/components/closebutton/dist/metadata.json b/components/closebutton/dist/metadata.json index 756fc3d7e62..28efda498a3 100644 --- a/components/closebutton/dist/metadata.json +++ b/components/closebutton/dist/metadata.json @@ -2,45 +2,15 @@ "sourceFile": "index.css", "selectors": [ ".spectrum-CloseButton", + ".spectrum-CloseButton--sizeL", + ".spectrum-CloseButton--sizeS", + ".spectrum-CloseButton--sizeXL", ".spectrum-CloseButton--staticBlack", - ".spectrum-CloseButton--staticBlack.is-focused:not(:disabled) .spectrum-CloseButton-UIIcon", - ".spectrum-CloseButton--staticBlack.is-keyboardFocused:not(:disabled)", - ".spectrum-CloseButton--staticBlack.is-keyboardFocused:not(:disabled) .spectrum-CloseButton-UIIcon", - ".spectrum-CloseButton--staticBlack:disabled .spectrum-CloseButton-UIIcon", - ".spectrum-CloseButton--staticBlack:not(:disabled)", - ".spectrum-CloseButton--staticBlack:not(:disabled) .spectrum-CloseButton-UIIcon", - ".spectrum-CloseButton--staticBlack:not(:disabled):active", - ".spectrum-CloseButton--staticBlack:not(:disabled):active .spectrum-CloseButton-UIIcon", - ".spectrum-CloseButton--staticBlack:not(:disabled):focus .spectrum-CloseButton-UIIcon", - ".spectrum-CloseButton--staticBlack:not(:disabled):focus-visible", - ".spectrum-CloseButton--staticBlack:not(:disabled):focus-visible .spectrum-CloseButton-UIIcon", - ".spectrum-CloseButton--staticBlack:not(:disabled):hover", - ".spectrum-CloseButton--staticBlack:not(:disabled):hover .spectrum-CloseButton-UIIcon", ".spectrum-CloseButton--staticWhite", - ".spectrum-CloseButton--staticWhite.is-focused:not(:disabled) .spectrum-CloseButton-UIIcon", - ".spectrum-CloseButton--staticWhite.is-keyboardFocused:not(:disabled)", - ".spectrum-CloseButton--staticWhite.is-keyboardFocused:not(:disabled) .spectrum-CloseButton-UIIcon", - ".spectrum-CloseButton--staticWhite:disabled .spectrum-CloseButton-UIIcon", - ".spectrum-CloseButton--staticWhite:not(:disabled)", - ".spectrum-CloseButton--staticWhite:not(:disabled) .spectrum-CloseButton-UIIcon", - ".spectrum-CloseButton--staticWhite:not(:disabled):active", - ".spectrum-CloseButton--staticWhite:not(:disabled):active .spectrum-CloseButton-UIIcon", - ".spectrum-CloseButton--staticWhite:not(:disabled):focus .spectrum-CloseButton-UIIcon", - ".spectrum-CloseButton--staticWhite:not(:disabled):focus-visible", - ".spectrum-CloseButton--staticWhite:not(:disabled):focus-visible .spectrum-CloseButton-UIIcon", - ".spectrum-CloseButton--staticWhite:not(:disabled):hover", - ".spectrum-CloseButton--staticWhite:not(:disabled):hover .spectrum-CloseButton-UIIcon", ".spectrum-CloseButton-UIIcon", - ".spectrum-CloseButton.is-disabled", ".spectrum-CloseButton.is-focused:not(:disabled) .spectrum-CloseButton-UIIcon", ".spectrum-CloseButton.is-keyboardFocused:not(:disabled)", ".spectrum-CloseButton.is-keyboardFocused:not(:disabled) .spectrum-CloseButton-UIIcon", - ".spectrum-CloseButton.spectrum-CloseButton--sizeL", - ".spectrum-CloseButton.spectrum-CloseButton--sizeM", - ".spectrum-CloseButton.spectrum-CloseButton--sizeS", - ".spectrum-CloseButton.spectrum-CloseButton--sizeXL", - ".spectrum-CloseButton.spectrum-CloseButton--staticBlack", - ".spectrum-CloseButton.spectrum-CloseButton--staticWhite", ".spectrum-CloseButton::-moz-focus-inner", ".spectrum-CloseButton:after", ".spectrum-CloseButton:disabled", @@ -60,7 +30,6 @@ "a.spectrum-CloseButton" ], "modifiers": [ - "--mod-animation-duration-100", "--mod-closebutton-align-self", "--mod-closebutton-animation-duraction", "--mod-closebutton-animation-duration", @@ -72,7 +41,6 @@ "--mod-closebutton-focus-indicator-color", "--mod-closebutton-focus-indicator-gap", "--mod-closebutton-focus-indicator-thickness", - "--mod-closebutton-height", "--mod-closebutton-icon-color-default", "--mod-closebutton-icon-color-disabled", "--mod-closebutton-icon-color-down", @@ -80,14 +48,7 @@ "--mod-closebutton-icon-color-hover", "--mod-closebutton-margin-inline", "--mod-closebutton-margin-top", - "--mod-closebutton-size", - "--mod-closebutton-static-background-color-default", - "--mod-closebutton-static-background-color-down", - "--mod-closebutton-static-background-color-focus", - "--mod-closebutton-static-background-color-hover", - "--mod-closebutton-width", - "--mod-line-height-100", - "--mod-sans-font-family-stack" + "--mod-closebutton-size" ], "component": [ "--spectrum-closebutton-animation-duration", @@ -104,27 +65,22 @@ "--spectrum-closebutton-icon-color-down", "--spectrum-closebutton-icon-color-focus", "--spectrum-closebutton-icon-color-hover", - "--spectrum-closebutton-size", - "--spectrum-closebutton-static-background-color-default", - "--spectrum-closebutton-static-background-color-down", - "--spectrum-closebutton-static-background-color-focus", - "--spectrum-closebutton-static-background-color-hover" + "--spectrum-closebutton-size" ], "global": [ "--spectrum-animation-duration-100", - "--spectrum-black", "--spectrum-component-height-100", "--spectrum-component-height-200", "--spectrum-component-height-300", "--spectrum-component-height-75", + "--spectrum-corner-radius-full", "--spectrum-disabled-content-color", - "--spectrum-disabled-static-black-content-color", - "--spectrum-disabled-static-white-content-color", + "--spectrum-disabled-static-black-background-color", + "--spectrum-disabled-static-white-background-color", "--spectrum-focus-indicator-color", "--spectrum-focus-indicator-gap", "--spectrum-focus-indicator-thickness", "--spectrum-gray-100", - "--spectrum-gray-200", "--spectrum-line-height-100", "--spectrum-neutral-content-color-default", "--spectrum-neutral-content-color-down", @@ -133,37 +89,20 @@ "--spectrum-sans-font-family-stack", "--spectrum-static-black-focus-indicator-color", "--spectrum-static-white-focus-indicator-color", - "--spectrum-transparent-black-400", - "--spectrum-transparent-black-500", - "--spectrum-transparent-white-400", - "--spectrum-transparent-white-500", - "--spectrum-white" - ], - "system-theme": [ - "--system-close-button-background-color-default", - "--system-close-button-background-color-down", - "--system-close-button-background-color-focus", - "--system-close-button-background-color-hover", - "--system-close-button-static-black-static-background-color-down", - "--system-close-button-static-black-static-background-color-focus", - "--system-close-button-static-black-static-background-color-hover", - "--system-close-button-static-white-static-background-color-down", - "--system-close-button-static-white-static-background-color-focus", - "--system-close-button-static-white-static-background-color-hover" - ], - "passthroughs": [ - "--mod-button-animation-duration", - "--mod-button-font-family", - "--mod-button-line-height" + "--spectrum-transparent-black-100", + "--spectrum-transparent-black-800", + "--spectrum-transparent-black-900", + "--spectrum-transparent-white-100", + "--spectrum-transparent-white-800", + "--spectrum-transparent-white-900" ], + "passthroughs": ["--mod-button-font-family", "--mod-button-line-height"], "high-contrast": [ "--highcontrast-closebutton-background-color-default", "--highcontrast-closebutton-focus-indicator-color", - "--highcontrast-closebutton-icon-color-default", "--highcontrast-closebutton-icon-color-disabled", "--highcontrast-closebutton-icon-color-down", "--highcontrast-closebutton-icon-color-focus", - "--highcontrast-closebutton-icon-color-hover", - "--highcontrast-closebutton-static-background-color-default" + "--highcontrast-closebutton-icon-color-hover" ] } diff --git a/components/closebutton/index.css b/components/closebutton/index.css index 14880d3ee6e..5bc33779eb1 100644 --- a/components/closebutton/index.css +++ b/components/closebutton/index.css @@ -11,8 +11,80 @@ * governing permissions and limitations under the License. */ -@import "./themes/spectrum-two.css"; -@import "@spectrum-css/commons/basebutton.css"; +.spectrum-CloseButton { + --spectrum-closebutton-border-radius: var(--spectrum-corner-radius-full); + + /* Cross icon */ + --spectrum-closebutton-icon-color-default: var(--spectrum-neutral-content-color-default); + --spectrum-closebutton-icon-color-hover: var(--spectrum-neutral-content-color-hover); + --spectrum-closebutton-icon-color-down: var(--spectrum-neutral-content-color-down); + --spectrum-closebutton-icon-color-focus: var(--spectrum-neutral-content-color-key-focus); + --spectrum-closebutton-icon-color-disabled: var(--spectrum-disabled-content-color); + + /* Focus indicator */ + --spectrum-closebutton-focus-indicator-thickness: var(--spectrum-focus-indicator-thickness); + --spectrum-closebutton-focus-indicator-gap: var(--spectrum-focus-indicator-gap); + --spectrum-closebutton-focus-indicator-color: var(--spectrum-focus-indicator-color); + + /* Size */ + --spectrum-closebutton-size: var(--spectrum-component-height-100); + + --spectrum-closebutton-animation-duration: var(--spectrum-animation-duration-100); + + /* Background color */ + --spectrum-closebutton-background-color-default: transparent; + --spectrum-closebutton-background-color-hover: var(--spectrum-gray-100); + --spectrum-closebutton-background-color-down: var(--spectrum-gray-100); + --spectrum-closebutton-background-color-focus: var(--spectrum-gray-100); +} + +.spectrum-CloseButton--sizeS { + --spectrum-closebutton-size: var(--spectrum-component-height-75); +} + +.spectrum-CloseButton--sizeL { + --spectrum-closebutton-size: var(--spectrum-component-height-200); +} + +.spectrum-CloseButton--sizeXL { + --spectrum-closebutton-size: var(--spectrum-component-height-300); +} + +.spectrum-CloseButton--staticWhite { + /* Cross icon */ + --spectrum-closebutton-icon-color-default: var(--spectrum-transparent-white-800); + --spectrum-closebutton-icon-color-hover: var(--spectrum-transparent-white-900); + --spectrum-closebutton-icon-color-down: var(--spectrum-transparent-white-900); + --spectrum-closebutton-icon-color-focus: var(--spectrum-transparent-white-900); + --spectrum-closebutton-icon-color-disabled: var(--spectrum-disabled-static-white-background-color); + + /* Background color */ + --spectrum-closebutton-background-color-default: transparent; + --spectrum-closebutton-background-color-hover: var(--spectrum-transparent-white-100); + --spectrum-closebutton-background-color-down: var(--spectrum-transparent-white-100); + --spectrum-closebutton-background-color-focus: var(--spectrum-transparent-white-100); + + /* Focus indicator */ + --spectrum-closebutton-focus-indicator-color: var(--spectrum-static-white-focus-indicator-color); +} + +.spectrum-CloseButton--staticBlack { + /* Cross icon */ + --spectrum-closebutton-icon-color-default: var(--spectrum-transparent-black-800); + --spectrum-closebutton-icon-color-hover: var(--spectrum-transparent-black-900); + --spectrum-closebutton-icon-color-down: var(--spectrum-transparent-black-900); + --spectrum-closebutton-icon-color-focus: var(--spectrum-transparent-black-900); + --spectrum-closebutton-icon-color-disabled: var(--spectrum-disabled-static-black-background-color); + + /* Background color */ + --spectrum-closebutton-background-color-default: transparent; + --spectrum-closebutton-background-color-hover: var(--spectrum-transparent-black-100); + --spectrum-closebutton-background-color-down: var(--spectrum-transparent-black-100); + --spectrum-closebutton-background-color-focus: var(--spectrum-transparent-black-100); + + /* Focus indicator */ + --spectrum-closebutton-focus-indicator-color: var(--spectrum-static-black-focus-indicator-color); +} /* Windows high contrast mode */ @media (forced-colors: active) { @@ -24,99 +96,74 @@ --highcontrast-closebutton-background-color-default: ButtonFace; --highcontrast-closebutton-focus-indicator-color: ButtonText; - &:focus-visible { - &::after { - forced-color-adjust: none; - margin: var(--mod-closebutton-focus-indicator-gap, var(--spectrum-closebutton-focus-indicator-gap)); - transition: - opacity var(--mod-closebutton-animation-duration, var(--spectrum-closebutton-animation-duration)) ease-out, - margin var(--mod-closebutton-animation-duraction, var(--spectrum-closebutton-animation-duration)) ease-out; - } + &:focus-visible::after { + forced-color-adjust: none; + margin: var(--mod-closebutton-focus-indicator-gap, var(--spectrum-closebutton-focus-indicator-gap)); + transition: + opacity var(--mod-closebutton-animation-duration, var(--spectrum-closebutton-animation-duration)) ease-out, + margin var(--mod-closebutton-animation-duraction, var(--spectrum-closebutton-animation-duration)) ease-out; } } - .spectrum-CloseButton--staticBlack { - --highcontrast-closebutton-static-background-color-default: ButtonFace; - --highcontrast-closebutton-icon-color-default: Highlight; - --highcontrast-closebutton-icon-color-disabled: GrayText; - } - .spectrum-CloseButton--staticWhite { - --highcontrast-closebutton-static-background-color-default: ButtonFace; - --highcontrast-closebutton-icon-color-default: Highlight; --highcontrast-closebutton-icon-color-disabled: Highlight; } } -.spectrum-CloseButton { - /* Cross icon */ - --spectrum-closebutton-icon-color-default: var(--spectrum-neutral-content-color-default); - --spectrum-closebutton-icon-color-hover: var(--spectrum-neutral-content-color-hover); - --spectrum-closebutton-icon-color-down: var(--spectrum-neutral-content-color-down); - --spectrum-closebutton-icon-color-focus: var(--spectrum-neutral-content-color-key-focus); - --spectrum-closebutton-icon-color-disabled: var(--spectrum-disabled-content-color); +a.spectrum-CloseButton { + /* Make link text not selectable */ + user-select: none; - /* Focus ring */ - --spectrum-closebutton-focus-indicator-thickness: var(--spectrum-focus-indicator-thickness); - --spectrum-closebutton-focus-indicator-gap: var(--spectrum-focus-indicator-gap); - --spectrum-closebutton-focus-indicator-color: var(--spectrum-focus-indicator-color); + /* stylelint-disable-next-line property-no-vendor-prefix -- Remove appearance for clickable types in iOS and Safari. */ + -webkit-appearance: none; +} - --spectrum-closebutton-animation-duration: var(--spectrum-animation-duration-100); +.spectrum-CloseButton { + cursor: pointer; + user-select: none; - &.spectrum-CloseButton--sizeS { - --spectrum-closebutton-size: var(--spectrum-component-height-75); - --spectrum-closebutton-border-radius: var(--spectrum-component-height-75); - } + /* Contain halo */ + position: relative; - &, - &.spectrum-CloseButton--sizeM { - --spectrum-closebutton-size: var(--spectrum-component-height-100); - --spectrum-closebutton-border-radius: var(--spectrum-component-height-100); - } + /* Show the button overflow in Edge. */ + overflow: visible; + display: inline-flex; + align-items: center; + justify-content: center; + flex-direction: row; - &.spectrum-CloseButton--sizeL { - --spectrum-closebutton-size: var(--spectrum-component-height-200); - --spectrum-closebutton-border-radius: var(--spectrum-component-height-200); - } + box-sizing: border-box; - &.spectrum-CloseButton--sizeXL { - --spectrum-closebutton-size: var(--spectrum-component-height-300); - --spectrum-closebutton-border-radius: var(--spectrum-component-height-300); - } + /* Remove button the margin in Firefox and Safari. */ + margin: 0; - &.spectrum-CloseButton--staticWhite { - --spectrum-closebutton-static-background-color-default: transparent; + font-family: var(--mod-button-font-family, var(--spectrum-sans-font-family-stack)); - --spectrum-closebutton-icon-color-default: var(--spectrum-white); - --spectrum-closebutton-icon-color-disabled: var(--spectrum-disabled-static-white-content-color); - --spectrum-closebutton-focus-indicator-color: var(--spectrum-static-white-focus-indicator-color); - } + /* Adjacent buttons should be aligned correctly */ + vertical-align: top; - &.spectrum-CloseButton--staticBlack { - --spectrum-closebutton-static-background-color-default: transparent; + -webkit-font-smoothing: antialiased; - --spectrum-closebutton-icon-color-default: var(--spectrum-black); - --spectrum-closebutton-icon-color-disabled: var(--spectrum-disabled-static-black-content-color); - --spectrum-closebutton-focus-indicator-color: var(--spectrum-static-black-focus-indicator-color); - } + /* Font smoothing for Firefox */ + -moz-osx-font-smoothing: grayscale; - @extend %spectrum-BaseButton; + line-height: var(--mod-button-line-height, var(--spectrum-line-height-100)); + text-decoration: none; - block-size: var(--mod-closebutton-height, var(--spectrum-closebutton-size)); - inline-size: var(--mod-closebutton-width, var(--mod-closebutton-height, var(--spectrum-closebutton-size))); + /* Remove the inheritance of text transform on button in Edge, Firefox, and IE. */ + text-transform: none; - position: relative; + /* stylelint-disable-next-line property-no-vendor-prefix -- Correct the inability to style clickable types in iOS and Safari (normalize). */ + -webkit-appearance: button; + + block-size: var(--mod-closebutton-size, var(--spectrum-closebutton-size)); + inline-size: var(--mod-closebutton-size, var(--spectrum-closebutton-size)); color: inherit; border-color: transparent; border-radius: var(--mod-closebutton-border-radius, var(--spectrum-closebutton-border-radius)); border-width: 0; - - justify-content: center; - align-items: center; - flex-direction: row; - display: inline-flex; padding: 0; transition: border-color var(--mod-closebutton-animation-duration, var(--spectrum-closebutton-animation-duration)) ease-in-out; @@ -125,7 +172,21 @@ margin-block-start: var(--mod-closebutton-margin-top); align-self: var(--mod-closebutton-align-self); - /* Represents focus ring */ + /* Fix Firefox */ + &::-moz-focus-inner { + margin-block-start: -2px; + margin-block-end: -2px; + padding: 0; + border: 0; + + /* Remove the inner border and padding for button in Firefox. */ + border-style: none; + } + + &:focus { + outline: none; + } + &::after { pointer-events: none; content: ""; @@ -135,7 +196,7 @@ inset-block-end: 0; inset-block-start: 0; margin: calc(var(--mod-closebutton-focus-indicator-gap, var(--spectrum-closebutton-focus-indicator-gap)) * -1); - border-radius: calc(var(--mod-closebutton-size, var(--spectrum-closebutton-size)) + var(--mod-closebutton-focus-indicator-gap, var(--spectrum-closebutton-focus-indicator-gap))); + border-radius: calc(var(--mod-closebutton-border-radius, var(--spectrum-closebutton-border-radius)) + var(--mod-closebutton-focus-indicator-gap, var(--spectrum-closebutton-focus-indicator-gap))); transition: box-shadow var(--mod-closebutton-animation-duration, var(--spectrum-closebutton-animation-duration)) ease-in-out; } @@ -148,6 +209,7 @@ } } + /* COLORS */ &:not(:disabled) { background-color: var(--highcontrast-closebutton-background-color-default, var(--mod-closebutton-background-color-default, var(--spectrum-closebutton-background-color-default))); @@ -189,6 +251,7 @@ } &:disabled { + cursor: default; background-color: var(--mod-closebutton-background-color-default, var(--spectrum-closebutton-background-color-default)); .spectrum-CloseButton-UIIcon { @@ -197,59 +260,6 @@ } } -a.spectrum-CloseButton { - @extend %spectrum-AnchorButton; -} - -/* Modifier Classes */ -.spectrum-CloseButton--staticBlack:not(:disabled), -.spectrum-CloseButton--staticWhite:not(:disabled) { - background-color: var(--highcontrast-closebutton-static-background-color-default, var(--mod-closebutton-static-background-color-default, var(--spectrum-closebutton-static-background-color-default))); - - &:hover { - background-color: var(--mod-closebutton-static-background-color-hover, var(--spectrum-closebutton-static-background-color-hover)); - - .spectrum-CloseButton-UIIcon { - color: var(--highcontrast-closebutton-icon-color-default, var(--mod-closebutton-icon-color-default, var(--spectrum-closebutton-icon-color-default))); - } - } - - &:active { - background-color: var(--mod-closebutton-static-background-color-down, var(--spectrum-closebutton-static-background-color-down)); - - .spectrum-CloseButton-UIIcon { - color: var(--highcontrast-closebutton-icon-color-default, var(--mod-closebutton-icon-color-default, var(--spectrum-closebutton-icon-color-default))); - } - } - - &:focus-visible, - &.is-keyboardFocused { - background-color: var(--mod-closebutton-static-background-color-focus, var(--spectrum-closebutton-static-background-color-focus)); - - .spectrum-CloseButton-UIIcon { - color: var(--highcontrast-closebutton-icon-color-default, var(--mod-closebutton-icon-color-default, var(--spectrum-closebutton-icon-color-default))); - } - } - - &:focus, - &.is-focused { - .spectrum-CloseButton-UIIcon { - color: var(--highcontrast-closebutton-icon-color-default, var(--mod-closebutton-icon-color-default, var(--spectrum-closebutton-icon-color-default))); - } - } - - .spectrum-CloseButton-UIIcon { - color: var(--mod-closebutton-icon-color-default, var(--spectrum-closebutton-icon-color-default)); - } -} - -.spectrum-CloseButton--staticBlack:disabled, -.spectrum-CloseButton--staticWhite:disabled { - .spectrum-CloseButton-UIIcon { - color: var(--mod-closebutton-icon-color-disabled, var(--spectrum-closebutton-icon-color-disabled)); - } -} - .spectrum-CloseButton-UIIcon { margin: 0; } diff --git a/components/closebutton/package.json b/components/closebutton/package.json index 32ba71135ac..146ff08a57b 100644 --- a/components/closebutton/package.json +++ b/components/closebutton/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/closebutton", - "version": "6.2.0", + "version": "7.0.0-next.1", "description": "The Spectrum CSS close button component", "license": "Apache-2.0", "author": "Adobe", @@ -19,15 +19,13 @@ "./package.json": "./package.json", "./dist/*": "./dist/*", "./index.css": "./dist/index.css", - "./index-*.css": "./dist/index-*.css", "./metadata.json": "./dist/metadata.json", - "./themes/*": "./dist/themes/*", "./stories/*": "./stories/*" }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/icon": ">=9.0.0 <10.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/icon": ">=10.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/icon": { @@ -38,9 +36,8 @@ } }, "devDependencies": { - "@spectrum-css/commons": "11.1.0", - "@spectrum-css/icon": "9.2.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/icon": "10.0.0-next.3", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/closebutton/stories/closebutton.stories.js b/components/closebutton/stories/closebutton.stories.js index f048e3e23b0..a991b559cb3 100644 --- a/components/closebutton/stories/closebutton.stories.js +++ b/components/closebutton/stories/closebutton.stories.js @@ -52,7 +52,11 @@ export default { }, packageJson, metadata, + status: { + type: "migrated", + }, }, + tags: ["migrated"], }; export const Default = CloseButtonGroup.bind({}); diff --git a/components/closebutton/stories/template.js b/components/closebutton/stories/template.js index 644ce705f62..4f6c5d8c00e 100644 --- a/components/closebutton/stories/template.js +++ b/components/closebutton/stories/template.js @@ -6,9 +6,6 @@ import { ifDefined } from "lit/directives/if-defined.js"; import { capitalize, upperCase } from "lodash-es"; import "../index.css"; -import "../themes/spectrum.css"; -/* Must be imported last */ -import "../themes/express.css"; export const Template = ({ rootClass = "spectrum-CloseButton", @@ -46,6 +43,7 @@ export const Template = ({ size, iconName: getCloseButtonIconName(size, iconSize), setName: "ui", + useRef: false, customClasses: [`${rootClass}-UIIcon`], }, context)} @@ -69,6 +67,7 @@ const getCloseButtonIconName = (size = "m", iconSize = "regular", iconName = "Cr return `${iconName}300`; } } + // Default, "regular" icon size. switch (size) { case "s": @@ -88,14 +87,14 @@ const getCloseButtonIconName = (size = "m", iconSize = "regular", iconName = "Cr */ export const CloseButtonExample = (args, context) => Container({ withBorder: false, - content: html` - ${Container({ + content: [ + Container({ withBorder: false, direction: "column", heading: "Default", content: Template(args, context), - }, context)} - ${Container({ + }, context), + Container({ withBorder: false, direction: "column", heading: "Disabled", @@ -103,6 +102,6 @@ export const CloseButtonExample = (args, context) => Container({ ...args, isDisabled: true, }, context), - }, context)} - `, + }, context), + ], }, context); diff --git a/components/closebutton/themes/express.css b/components/closebutton/themes/express.css deleted file mode 100644 index 06a90e4fee9..00000000000 --- a/components/closebutton/themes/express.css +++ /dev/null @@ -1,25 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--express */ - -@import "./spectrum.css"; - -@container style(--system: express) { - .spectrum-CloseButton { - --spectrum-closebutton-background-color-default: transparent; - --spectrum-closebutton-background-color-hover: var(--spectrum-gray-300); - --spectrum-closebutton-background-color-down: var(--spectrum-gray-400); - --spectrum-closebutton-background-color-focus: var(--spectrum-gray-300); - } -} diff --git a/components/closebutton/themes/spectrum-two.css b/components/closebutton/themes/spectrum-two.css deleted file mode 100644 index 01479c42fd4..00000000000 --- a/components/closebutton/themes/spectrum-two.css +++ /dev/null @@ -1,33 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -@container style(--system: spectrum) { - .spectrum-CloseButton { - --spectrum-closebutton-background-color-default: transparent; - --spectrum-closebutton-background-color-hover: var(--spectrum-gray-100); - --spectrum-closebutton-background-color-down: var(--spectrum-gray-200); - --spectrum-closebutton-background-color-focus: var(--spectrum-gray-100); - - &.spectrum-CloseButton--staticWhite { - --spectrum-closebutton-static-background-color-hover: var(--spectrum-transparent-white-400); - --spectrum-closebutton-static-background-color-down: var(--spectrum-transparent-white-500); - --spectrum-closebutton-static-background-color-focus: var(--spectrum-transparent-white-400); - } - - &.spectrum-CloseButton--staticBlack { - --spectrum-closebutton-static-background-color-hover: var(--spectrum-transparent-black-400); - --spectrum-closebutton-static-background-color-down: var(--spectrum-transparent-black-500); - --spectrum-closebutton-static-background-color-focus: var(--spectrum-transparent-black-400); - } - } -} diff --git a/components/closebutton/themes/spectrum.css b/components/closebutton/themes/spectrum.css deleted file mode 100644 index 62e907bae8a..00000000000 --- a/components/closebutton/themes/spectrum.css +++ /dev/null @@ -1,36 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--legacy */ - -@import "./spectrum-two.css"; - -@container style(--system: legacy) { - .spectrum-CloseButton { - --spectrum-closebutton-background-color-hover: var(--spectrum-gray-200); - --spectrum-closebutton-background-color-down: var(--spectrum-gray-300); - --spectrum-closebutton-background-color-focus: var(--spectrum-gray-200); - - &.spectrum-CloseButton--staticWhite { - --spectrum-closebutton-static-background-color-hover: var(--spectrum-transparent-white-300); - --spectrum-closebutton-static-background-color-down: var(--spectrum-transparent-white-400); - --spectrum-closebutton-static-background-color-focus: var(--spectrum-transparent-white-300); - } - - &.spectrum-CloseButton--staticBlack { - --spectrum-closebutton-static-background-color-hover: var(--spectrum-transparent-black-300); - --spectrum-closebutton-static-background-color-down: var(--spectrum-transparent-black-400); - --spectrum-closebutton-static-background-color-focus: var(--spectrum-transparent-black-300); - } - } -} diff --git a/components/coachindicator/CHANGELOG.md b/components/coachindicator/CHANGELOG.md index 46ae1095e17..6b13a673c46 100644 --- a/components/coachindicator/CHANGELOG.md +++ b/components/coachindicator/CHANGELOG.md @@ -1,5 +1,28 @@ # Change log +## 5.0.0-next.1 + +### Patch Changes + +📝 [#4113](https://github.com/adobe/spectrum-css/pull/4113) [`cf4fc1a`](https://github.com/adobe/spectrum-css/commit/cf4fc1a01d23ba810f45a903ecc29a5c8aae33d1) Thanks [@castastrophe](https://github.com/castastrophe)! + +## Minor linting fixes + +- Removed unused custom properties across multiple components +- Fixed color function notation by converting `rgba()` to `rgb()` where appropriate +- Removed duplicate custom property declarations +- Fixed deprecated CSS properties (e.g., `word-wrap` → `overflow-wrap`) +- Removed unnecessary stylelint-disable comments + +_No visual or functional changes to components._ + +## 5.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + ## 4.2.0 ### Minor Changes diff --git a/components/coachindicator/dist/metadata.json b/components/coachindicator/dist/metadata.json index 9714f9f1ed1..0bed4172eef 100644 --- a/components/coachindicator/dist/metadata.json +++ b/components/coachindicator/dist/metadata.json @@ -6,14 +6,9 @@ ".spectrum-CoachIndicator-ring:first-child", ".spectrum-CoachIndicator-ring:nth-child(2)", ".spectrum-CoachIndicator-ring:nth-child(3)", - ".spectrum-CoachIndicator.spectrum-CoachIndicator--dark", - ".spectrum-CoachIndicator.spectrum-CoachIndicator--light", ".spectrum-CoachIndicator.spectrum-CoachIndicator--quiet", ".spectrum-CoachIndicator.spectrum-CoachIndicator--staticBlack", - ".spectrum-CoachIndicator.spectrum-CoachIndicator--staticWhite", - "0%", - "50%", - "to" + ".spectrum-CoachIndicator.spectrum-CoachIndicator--staticWhite" ], "modifiers": [ "--mod-coach-animation-indicator-ring-center-delay-multiple", @@ -31,11 +26,9 @@ "--mod-coach-indicator-quiet-ring-diameter", "--mod-coach-indicator-ring-block-size", "--mod-coach-indicator-ring-border-size", - "--mod-coach-indicator-ring-dark-color", "--mod-coach-indicator-ring-default-color", "--mod-coach-indicator-ring-diameter", "--mod-coach-indicator-ring-inline-size", - "--mod-coach-indicator-ring-light-color", "--mod-coach-indicator-top" ], "component": [ @@ -60,7 +53,6 @@ "--spectrum-coach-animation-indicator-ring-duration", "--spectrum-white" ], - "system-theme": [], "passthroughs": [], "high-contrast": [] } diff --git a/components/coachindicator/index.css b/components/coachindicator/index.css index 8cc7bdb8eda..c3bb2754d30 100644 --- a/components/coachindicator/index.css +++ b/components/coachindicator/index.css @@ -33,18 +33,6 @@ --spectrum-coach-indicator-animation-ring-inner-delay-multiple: var(--mod-coach-indicator-quiet-animation-ring-inner-delay-multiple, -0.33); } - /* @deprecated .spectrum-CoachIndicator--light */ - &.spectrum-CoachIndicator--light { - /* @deprecated --mod-coach-indicator-ring-light-color, use --mod-coach-indicator-ring-default-color instead */ - --spectrum-coach-indicator-ring-default-color: var(--mod-coach-indicator-ring-light-color, var(--spectrum-white)); - } - - /* @deprecated .spectrum-CoachIndicator--dark */ - &.spectrum-CoachIndicator--dark { - /* @deprecated --mod-coach-indicator-ring-dark-color, use --mod-coach-indicator-ring-default-color instead */ - --spectrum-coach-indicator-ring-default-color: var(--mod-coach-indicator-ring-dark-color, var(--spectrum-black)); - } - &.spectrum-CoachIndicator--staticWhite { --spectrum-coach-indicator-ring-default-color: var(--spectrum-white); } diff --git a/components/coachindicator/package.json b/components/coachindicator/package.json index 1b92f263882..778523998b4 100644 --- a/components/coachindicator/package.json +++ b/components/coachindicator/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/coachindicator", - "version": "4.2.0", + "version": "5.0.0-next.1", "description": "The Spectrum CSS Coach Indicator component ", "license": "Apache-2.0", "author": "Adobe", @@ -24,7 +24,7 @@ }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/tokens": ">=16.0.1" + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/tokens": { @@ -32,7 +32,7 @@ } }, "devDependencies": { - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/coachindicator/stories/coachindicator.stories.js b/components/coachindicator/stories/coachindicator.stories.js index f206b3bef9a..342a3293333 100644 --- a/components/coachindicator/stories/coachindicator.stories.js +++ b/components/coachindicator/stories/coachindicator.stories.js @@ -30,7 +30,11 @@ export default { }, packageJson, metadata, + status: { + type: "unmigrated", + }, }, + tags: ["unmigrated"], }; export const Default = CoachIndicatorGroup.bind({}); diff --git a/components/coachindicator/stories/template.js b/components/coachindicator/stories/template.js index f407dc51444..5a532caf2ca 100644 --- a/components/coachindicator/stories/template.js +++ b/components/coachindicator/stories/template.js @@ -1,5 +1,7 @@ +import { getRandomId } from "@spectrum-css/preview/decorators"; import { html } from "lit-html"; import { classMap } from "lit-html/directives/class-map.js"; +import { ifDefined } from "lit-html/directives/if-defined.js"; import { styleMap } from "lit-html/directives/style-map.js"; import "../index.css"; @@ -10,6 +12,7 @@ export const Template = ({ staticColor, customClasses = [], customStyles = {}, + id = getRandomId("coach-indicator"), } = {}) => { return html`
    ({ ...a, [c]: true }), {}), })} style=${styleMap(customStyles)} + id=${ifDefined(id)} > ${Array.from({ length: 3 }).map(() => html`
    diff --git a/components/coachmark/CHANGELOG.md b/components/coachmark/CHANGELOG.md index 2e57713408f..0c673855a47 100644 --- a/components/coachmark/CHANGELOG.md +++ b/components/coachmark/CHANGELOG.md @@ -1,5 +1,87 @@ # Change log +## 10.0.0-next.1 + +### Major Changes + +📝 [#3412](https://github.com/adobe/spectrum-css/pull/3412) [`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b) Thanks [@cdransf](https://github.com/cdransf)! + +#### S2 coachmark migration + +This migrates the `coachmark` component to S2. Custom properties have been remapped per the design spec. + +| Before | After | +| ------------------------------------------ | ----------------------------------------------- | +| --spectrum-heading-sans-serif-font-weight | --spectrum-title-sans-serif-font-weight | +| --spectrum-coach-mark-title-size | --spectrum-coach-mark-title-font-size | +| --spectrum-heading-line-height | --spectrum-title-line-height | +| --spectrum-heading-serif-font-style | --spectrum-title-serif-font-style | +| --spectrum-coach-mark-body-size | --spectrum-coach-mark-body-font-size | +| --spectrum-body-sans-serif-font-style | --spectrum-body-serif-font-style | +| --spectrum-coach-mark-pagination-body-size | --spectrum-coach-mark-pagination-body-font-size | + +### New properties + +```css +--spectrum-coach-mark-edge-to-content +--spectrum-coach-mark-maximum-width +--spectrum-coach-mark-media-height +--spectrum-coach-mark-media-minimum-height +--spectrum-coach-mark-minimum-width +--spectrum-coach-mark-pagination-color +--spectrum-coach-mark-pagination-text-to-bottom-edge +--spectrum-coach-mark-width +--spectrum-coachmark-body-to-footer +--spectrum-coachmark-border-radius +--spectrum-coachmark-border-size +--spectrum-coachmark-buttongroup-display +--spectrum-coachmark-buttongroup-mobile-display +--spectrum-coachmark-content-font-size +--spectrum-coachmark-content-font-weight +--spectrum-coachmark-header-to-body +--spectrum-coachmark-heading-to-action-button +--spectrum-coachmark-max-width +--spectrum-coachmark-media-fixed-height +--spectrum-coachmark-media-min-height +--spectrum-coachmark-menu-display +--spectrum-coachmark-menu-mobile-display +--spectrum-coachmark-min-width +--spectrum-coachmark-padding +--spectrum-coachmark-step-color +--spectrum-coachmark-step-font-size +--spectrum-coachmark-step-font-style +--spectrum-coachmark-step-text-font-weight +--spectrum-coachmark-step-text-line-height +--spectrum-coachmark-step-to-bottom +--spectrum-coachmark-title-color +--spectrum-coachmark-title-font-family +--spectrum-coachmark-title-font-size +--spectrum-coachmark-title-font-style +--spectrum-coachmark-title-text-font-weight +--spectrum-coachmark-title-text-line-height +``` + +#### Additions + +Adds `--spectrum-coachmark-media-fixed-height` for fixed `4:3` image variant and an accompanying `--mod-coachmark-media-fixed-height` mod. This variation has been added to the `coachmark` component story as a boolean control labeled as `Fixed image height`. The class is conditionally added within the `hasImage` block and, as such, will only impact rendering when `hasImage` is also `true`. + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + +## 10.0.0-next.0 + +### Patch Changes + +- Updated dependencies []: + - @spectrum-css/actionbutton@8.0.0-next.0 + - @spectrum-css/actionmenu@8.0.0-next.0 + - @spectrum-css/button@15.0.0-next.0 + - @spectrum-css/menu@10.0.0-next.0 + - @spectrum-css/popover@9.0.0-next.0 + - @spectrum-css/buttongroup@10.0.0-next.0 + ## 9.2.0 ### Minor Changes diff --git a/components/coachmark/dist/metadata.json b/components/coachmark/dist/metadata.json index 8bc036d5fca..9286c817c5f 100644 --- a/components/coachmark/dist/metadata.json +++ b/components/coachmark/dist/metadata.json @@ -10,12 +10,14 @@ ".spectrum-CoachMark-header", ".spectrum-CoachMark-image", ".spectrum-CoachMark-image-wrapper", + ".spectrum-CoachMark-image-wrapper--fixedHeight", ".spectrum-CoachMark-menu", ".spectrum-CoachMark-menu--mobile", ".spectrum-CoachMark-step", ".spectrum-CoachMark-title" ], "modifiers": [ + "--mod-coachmark-action-menu-vertical-offset", "--mod-coachmark-body-to-footer", "--mod-coachmark-border-radius", "--mod-coachmark-border-size", @@ -27,8 +29,9 @@ "--mod-coachmark-content-line-height", "--mod-coachmark-header-to-body", "--mod-coachmark-heading-to-action-button", + "--mod-coachmark-image-to-heading", "--mod-coachmark-max-width", - "--mod-coachmark-media-height", + "--mod-coachmark-media-fixed-height", "--mod-coachmark-media-min-height", "--mod-coachmark-min-width", "--mod-coachmark-padding", @@ -47,47 +50,74 @@ "--mod-coachmark-width" ], "component": [ - "--spectrum-coach-mark-body-size", + "--spectrum-coach-mark-body-font-size", "--spectrum-coach-mark-edge-to-content", "--spectrum-coach-mark-maximum-width", "--spectrum-coach-mark-media-height", "--spectrum-coach-mark-media-minimum-height", "--spectrum-coach-mark-minimum-width", - "--spectrum-coach-mark-pagination-body-size", + "--spectrum-coach-mark-pagination-body-font-size", "--spectrum-coach-mark-pagination-color", "--spectrum-coach-mark-pagination-text-to-bottom-edge", - "--spectrum-coach-mark-title-size", + "--spectrum-coach-mark-title-font-size", "--spectrum-coach-mark-width", + "--spectrum-coachmark-action-menu-vertical-offset", + "--spectrum-coachmark-body-to-footer", "--spectrum-coachmark-border-radius", "--spectrum-coachmark-border-size", "--spectrum-coachmark-buttongroup-display", "--spectrum-coachmark-buttongroup-mobile-display", + "--spectrum-coachmark-content-font-size", + "--spectrum-coachmark-content-font-weight", + "--spectrum-coachmark-header-to-body", + "--spectrum-coachmark-image-to-heading", + "--spectrum-coachmark-max-width", + "--spectrum-coachmark-media-fixed-height", + "--spectrum-coachmark-media-min-height", "--spectrum-coachmark-menu-display", - "--spectrum-coachmark-menu-mobile-display" + "--spectrum-coachmark-menu-mobile-display", + "--spectrum-coachmark-min-width", + "--spectrum-coachmark-padding", + "--spectrum-coachmark-step-color", + "--spectrum-coachmark-step-font-size", + "--spectrum-coachmark-step-font-style", + "--spectrum-coachmark-step-text-font-weight", + "--spectrum-coachmark-step-text-line-height", + "--spectrum-coachmark-step-to-bottom", + "--spectrum-coachmark-title-color", + "--spectrum-coachmark-title-font-family", + "--spectrum-coachmark-title-font-size", + "--spectrum-coachmark-title-font-style", + "--spectrum-coachmark-title-text-font-weight", + "--spectrum-coachmark-title-text-line-height", + "--spectrum-coachmark-width" ], "global": [ "--spectrum-body-color", "--spectrum-body-line-height", "--spectrum-body-sans-serif-font-style", "--spectrum-body-sans-serif-font-weight", + "--spectrum-body-serif-font-style", "--spectrum-border-width-100", - "--spectrum-corner-radius-100", + "--spectrum-corner-radius-large-default", "--spectrum-heading-color", - "--spectrum-heading-line-height", - "--spectrum-heading-sans-serif-font-weight", - "--spectrum-heading-serif-font-style", + "--spectrum-line-height-200", + "--spectrum-medium-font-weight", + "--spectrum-popover-edge-to-content-area", "--spectrum-sans-serif-font", "--spectrum-spacing-100", "--spectrum-spacing-200", - "--spectrum-spacing-300" + "--spectrum-spacing-300", + "--spectrum-title-line-height", + "--spectrum-title-sans-serif-font-weight", + "--spectrum-title-serif-font-style" ], - "system-theme": [], "passthroughs": [ "--mod-button-edge-to-visual-only", "--mod-buttongroup-justify-content", "--mod-buttongroup-spacing", "--mod-popover-border-width", - "--mod-popover-content-area-spacing-vertical", + "--mod-popover-content-area-spacing", "--mod-popover-corner-radius" ], "high-contrast": [] diff --git a/components/coachmark/index.css b/components/coachmark/index.css index bd8821b3bb1..3d78766e888 100644 --- a/components/coachmark/index.css +++ b/components/coachmark/index.css @@ -1,5 +1,5 @@ /*! - * Copyright 2024 Adobe. All rights reserved. + * Copyright 2025 Adobe. All rights reserved. * * This file is licensed to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. You may obtain a copy @@ -12,27 +12,59 @@ */ .spectrum-CoachMark { + --spectrum-coachmark-width: var(--spectrum-coach-mark-width); + --spectrum-coachmark-min-width: var(--spectrum-coach-mark-minimum-width); + --spectrum-coachmark-max-width: var(--spectrum-coach-mark-maximum-width); + --spectrum-coachmark-media-min-height: var(--spectrum-coach-mark-media-minimum-height); + --spectrum-coachmark-border-size: var(--mod-coachmark-border-size, var(--mod-popover-border-width)); --spectrum-coachmark-border-radius: var(--mod-coachmark-border-radius, var(--mod-popover-corner-radius)); + --spectrum-coachmark-media-fixed-height: var(--spectrum-coach-mark-media-height); + + /* layout */ + --spectrum-coachmark-padding: var(--spectrum-coach-mark-edge-to-content); + --spectrum-coachmark-image-to-heading: var(--spectrum-coach-mark-edge-to-content); + --spectrum-coachmark-header-to-body: var(--spectrum-spacing-200); + --spectrum-coachmark-body-to-footer: var(--spectrum-spacing-300); + + /* font */ + --spectrum-coachmark-title-color: var(--spectrum-heading-color); + --spectrum-coachmark-title-font-family: var(--spectrum-sans-serif-font); + --spectrum-coachmark-title-font-size: var(--spectrum-coach-mark-title-font-size); + --spectrum-coachmark-title-font-style: var(--spectrum-title-serif-font-style); + --spectrum-coachmark-title-text-font-weight: var(--spectrum-title-sans-serif-font-weight); + --spectrum-coachmark-title-text-line-height: var(--spectrum-title-line-height); + + --spectrum-coachmark-content-font-size: var(--spectrum-coach-mark-body-font-size); + --spectrum-coachmark-content-font-weight: var(--spectrum-body-sans-serif-font-weight); + + --spectrum-coachmark-step-color: var(--spectrum-coach-mark-pagination-color); + --spectrum-coachmark-step-font-style: var(--spectrum-body-serif-font-style); + --spectrum-coachmark-step-font-size: var(--spectrum-coach-mark-pagination-body-font-size); + --spectrum-coachmark-step-text-font-weight: var(--spectrum-medium-font-weight); + --spectrum-coachmark-step-text-line-height: var(--spectrum-line-height-200); + --spectrum-coachmark-step-to-bottom: var(--spectrum-coach-mark-pagination-text-to-bottom-edge); + /* @passthrough start */ --mod-buttongroup-justify-content: flex-end; --mod-popover-border-width: var(--spectrum-border-width-100); - --mod-popover-corner-radius: var(--spectrum-corner-radius-100); - --mod-popover-content-area-spacing-vertical: 0; + --mod-popover-corner-radius: var(--spectrum-corner-radius-large-default); + --mod-popover-content-area-spacing: 0; --mod-button-edge-to-visual-only: 9px; /* @passthrough end */ +} +.spectrum-CoachMark { position: relative; - min-inline-size: var(--mod-coachmark-min-width, var(--spectrum-coach-mark-minimum-width)); - max-inline-size: var(--mod-coachmark-max-width, var(--spectrum-coach-mark-maximum-width)); - inline-size: var(--mod-coachmark-width, var(--spectrum-coach-mark-width)); + min-inline-size: var(--mod-coachmark-min-width, var(--spectrum-coachmark-min-width)); + max-inline-size: var(--mod-coachmark-max-width, var(--spectrum-coachmark-max-width)); + inline-size: var(--mod-coachmark-width, var(--spectrum-coachmark-width)); } /* Used when the coachmark has an image */ .spectrum-CoachMark-image-wrapper { - block-size: var(--mod-coachmark-media-height, var(--spectrum-coach-mark-media-height)); - min-block-size: var(--mod-coachmark-media-min-height, var(--spectrum-coach-mark-media-minimum-height)); + min-block-size: var(--mod-coachmark-media-min-height, var(--spectrum-coachmark-media-min-height)); inline-size: calc(var(--mod-coachmark-width, var(--spectrum-coach-mark-width)) - (var(--spectrum-coachmark-border-size) * 2)); object-fit: cover; @@ -42,11 +74,16 @@ border-start-end-radius: inherit; } +.spectrum-CoachMark-image-wrapper--fixedHeight { + block-size: var(--mod-coachmark-media-fixed-height, var(--spectrum-coachmark-media-fixed-height)); +} + /* Class for the image; nested inside image-wrapper */ .spectrum-CoachMark-image { display: block; inline-size: 100%; block-size: 100%; + min-block-size: var(--mod-coachmark-media-min-height, var(--spectrum-coachmark-media-min-height)); object-fit: cover; border-start-start-radius: calc(var(--spectrum-coachmark-border-radius) - var(--spectrum-coachmark-border-size)); border-start-end-radius: calc(var(--spectrum-coachmark-border-radius) - var(--spectrum-coachmark-border-size)); @@ -57,34 +94,37 @@ .spectrum-CoachMark-content, .spectrum-CoachMark-footer { padding-block: 0; - padding-inline: var(--mod-coachmark-padding, var(--spectrum-coach-mark-edge-to-content)); + padding-inline: var(--mod-coachmark-padding, var(--spectrum-coachmark-padding)); } /* Wrapper contains title, action-menu */ .spectrum-CoachMark-header { - padding-block-start: var(--mod-coachmark-padding, var(--spectrum-coach-mark-edge-to-content)); + padding-block-start: var(--mod-coachmark-image-to-heading, var(--spectrum-coachmark-image-to-heading)); display: flex; justify-content: space-between; - align-items: center; - margin-block-end: var(--mod-coachmark-header-to-body, var(--spectrum-spacing-200)); + align-items: flex-start; + margin-block-end: var(--mod-coachmark-header-to-body, var(--spectrum-coachmark-header-to-body)); } /* Text wrapper for the title content; sides besdie action menu if present */ .spectrum-CoachMark-title { - color: var(--mod-coachmark-title-color, var(--spectrum-heading-color)); - font-size: var(--mod-coachmark-title-font-size, var(--spectrum-coach-mark-title-size)); - font-weight: var(--mod-coachmark-title-text-font-weight, var(--spectrum-heading-sans-serif-font-weight)); - font-family: var(--mod-coachmark-title-font-family, var(--spectrum-sans-serif-font)); - font-style: var(--mod-coachmark-title-font-style, var(--spectrum-heading-serif-font-style)); - line-height: var(--mod-coachmark-title-text-line-height, var(--spectrum-heading-line-height)); + color: var(--mod-coachmark-title-color, var(--spectrum-coachmark-title-color)); + font-size: var(--mod-coachmark-title-font-size, var(--spectrum-coachmark-title-font-size)); + font-weight: var(--mod-coachmark-title-text-font-weight, var(--spectrum-coachmark-title-text-font-weight)); + font-family: var(--mod-coachmark-title-font-family, var(--spectrum-coachmark-title-font-family)); + font-style: var(--mod-coachmark-title-font-style, var(--spectrum-coachmark-title-font-style)); + line-height: var(--mod-coachmark-title-text-line-height, var(--spectrum-coachmark-title-text-line-height)); margin-block-end: 0; } /* Wrapper element around the nested action menu sub-component */ .spectrum-CoachMark-action-menu { + --mod-popover-content-area-spacing: var(--spectrum-popover-edge-to-content-area); + white-space: nowrap; z-index: 1; margin-inline-start: var(--mod-coachmark-heading-to-action-button, var(--spectrum-spacing-300)); + margin-block: var(--mod-coachmark-action-menu-vertical-offset, var(--spectrum-coachmark-action-menu-vertical-offset)); } /* @deprecated not used currently in demos or by SWC */ @@ -99,10 +139,10 @@ /* Text wrapper for the content */ .spectrum-CoachMark-content { - margin-block-end: var(--mod-coachmark-body-to-footer, var(--spectrum-spacing-300)); + margin-block-end: var(--mod-coachmark-body-to-footer, var(--spectrum-coachmark-body-to-footer)); color: var(--mod-coachmark-content-font-color, var(--spectrum-body-color)); - font-size: var(--mod-coachmark-content-font-size, var(--spectrum-coach-mark-body-size)); - font-weight: var(--mod-coachmark-content-font-weight, var(--spectrum-body-sans-serif-font-weight)); + font-size: var(--mod-coachmark-content-font-size, var(--spectrum-coachmark-content-font-size)); + font-weight: var(--mod-coachmark-content-font-weight, var(--spectrum-coachmark-content-font-weight)); font-family: var(--mod-coachmark-content-font-family, var(--spectrum-sans-serif-font)); font-style: var(--mod-coachmark-content-font-style, var(--spectrum-body-sans-serif-font-style)); line-height: var(--mod-coachmark-content-line-height, var(--spectrum-body-line-height)); @@ -113,20 +153,20 @@ display: grid; align-items: end; margin-block-start: 0; - padding-block-end: var(--mod-coachmark-padding, var(--spectrum-coach-mark-edge-to-content)); + padding-block-end: var(--mod-coachmark-padding, var(--spectrum-coachmark-padding)); } /* Text wrapper for the step count */ .spectrum-CoachMark-step { justify-self: start; - margin-block-end: calc(var(--mod-coachmark-step-to-bottom, var(--spectrum-coach-mark-pagination-text-to-bottom-edge)) - var(--mod-coachmark-padding, var(--spectrum-coach-mark-edge-to-content))); + margin-block-end: calc(var(--mod-coachmark-step-to-bottom, var(--spectrum-coachmark-step-to-bottom)) - var(--mod-coachmark-padding, var(--spectrum-coachmark-padding))); - color: var(--mod-coachmark-step-color, var(--spectrum-coach-mark-pagination-color)); - font-size: var(--mod-coachmark-step-font-size, var(--spectrum-coach-mark-pagination-body-size)); - font-weight: var(--mod-coachmark-step-text-font-weight, var(--spectrum-body-sans-serif-font-weight)); + color: var(--mod-coachmark-step-color, var(--spectrum-coachmark-step-color)); + font-size: var(--mod-coachmark-step-font-size, var(--spectrum-coachmark-step-font-size)); + font-weight: var(--mod-coachmark-step-text-font-weight, var(--spectrum-coachmark-step-text-font-weight)); font-family: var(--spectrum-sans-serif-font); - font-style: var(--mod-coachmark-step-font-style, var(--spectrum-body-sans-serif-font-style)); - line-height: var(--mod-coachmark-step-text-line-height, var(--spectrum-body-line-height)); + font-style: var(--mod-coachmark-step-font-style, var(--spectrum-coachmark-step-font-style)); + line-height: var(--mod-coachmark-step-text-line-height, var(--spectrum-coachmark-step-text-line-height)); white-space: nowrap; } diff --git a/components/coachmark/package.json b/components/coachmark/package.json index 09e0e78d122..af849a2eda6 100644 --- a/components/coachmark/package.json +++ b/components/coachmark/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/coachmark", - "version": "9.2.0", + "version": "10.0.0-next.1", "description": "The Spectrum CSS coachmark component", "license": "Apache-2.0", "author": "Adobe", @@ -24,13 +24,13 @@ }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/actionbutton": ">=7.0.0 <8.0.0", - "@spectrum-css/actionmenu": ">=7.0.0 <8.0.0", - "@spectrum-css/button": ">=14.0.0 <15.0.0", - "@spectrum-css/buttongroup": ">=9.0.0 <10.0.0", - "@spectrum-css/menu": ">=9.0.0 <10.0.0", - "@spectrum-css/popover": ">=8.0.0 <9.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/actionbutton": ">=8.0.0-next.0", + "@spectrum-css/actionmenu": ">=8.0.0-next.0", + "@spectrum-css/button": ">=15.0.0-next.0", + "@spectrum-css/buttongroup": ">=10.0.0-next.0", + "@spectrum-css/menu": ">=10.0.0-next.0", + "@spectrum-css/popover": ">=9.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/actionbutton": { @@ -56,13 +56,13 @@ } }, "devDependencies": { - "@spectrum-css/actionbutton": "7.2.0", - "@spectrum-css/actionmenu": "7.2.0", - "@spectrum-css/button": "14.2.0", - "@spectrum-css/buttongroup": "9.2.0", - "@spectrum-css/menu": "9.3.0", - "@spectrum-css/popover": "8.3.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/actionbutton": "8.0.0-next.4", + "@spectrum-css/actionmenu": "8.0.0-next.2", + "@spectrum-css/button": "15.0.0-next.2", + "@spectrum-css/buttongroup": "10.0.0-next.1", + "@spectrum-css/menu": "10.0.0-next.6", + "@spectrum-css/popover": "9.0.0-next.5", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/coachmark/stories/coachmark.stories.js b/components/coachmark/stories/coachmark.stories.js index e13b70fce24..a0fe9e0416c 100644 --- a/components/coachmark/stories/coachmark.stories.js +++ b/components/coachmark/stories/coachmark.stories.js @@ -4,7 +4,11 @@ import { disableDefaultModes } from "@spectrum-css/preview/modes"; import metadata from "../dist/metadata.json"; import packageJson from "../package.json"; import { CoachMarkGroup } from "./coachmark.test.js"; -import { CoachmarkMenuStatesTemplate, Template } from "./template.js"; +import { + CoachMarkMediaOptionsTemplate, + CoachmarkMenuStatesTemplate, + Template, +} from "./template.js"; /** * The coach mark component can be used to bring added attention to specific parts of a page, like during a tour. It is a separate component from [the coach indicator](/docs/components-coach-indicator--docs) and similar to [a popover](/docs/components-purpose--docs). @@ -14,7 +18,7 @@ export default { component: "CoachMark", argTypes: { hasActionMenu: { - name: "ActionMenu", + name: "Has action menu", type: { name: "boolean" }, table: { type: { summary: "boolean" }, @@ -32,7 +36,7 @@ export default { control: "boolean", }, hasImage: { - name: "Image", + name: "Has image", type: { name: "boolean" }, table: { type: { summary: "boolean" }, @@ -40,12 +44,42 @@ export default { }, control: "boolean", }, + imageIsFixedHeight: { + name: "Fixed image height", + description: "By default this displays an image with a 4:3 aspect ratio.", + type: { name: "boolean" }, + table: { + type: { summary: "boolean" }, + category: "Component", + }, + if: { arg: "hasImage", truthy: true }, + }, + imageSource: { + name: "Image source", + type: { name: "string" }, + table: { + type: { summary: "string" }, + category: "Content", + }, + control: { type: "file", accept: ".svg,.png,.jpg,.jpeg,.webc" }, + if: { arg: "hasImage", truthy: true }, + }, + title: { + name: "Title text", + type: { name: "string" }, + table: { + type: { summary: "string" }, + category: "Content", + }, + }, }, args: { + title: "Coach mark title", rootClass: "spectrum-CoachMark", - hasActionMenu: true, + hasActionMenu: false, hasPagination: true, - hasImage: false, + hasImage: true, + imageIsFixedHeight: false, }, parameters: { actions: { @@ -60,22 +94,22 @@ export default { }, packageJson, metadata, - docs: { - story: { - height: "300px", - } - } + status: { + type: "migrated", + }, }, + tags: ["migrated"], }; export const Default = CoachMarkGroup.bind({}); +Default.title = "Standard"; Default.tags = ["!autodocs"]; -Default.args = {}; +Default.parameters = {}; /** - * Coach marks are temporary messages that educate users through new or unfamiliar product experiences. They can be chained into a sequence to form a tour. + * Coach marks are temporary messages that educate users through new or unfamiliar product experiences. They can be chained into a sequence to form a tour. They may contain images or media that relate to their content, such as demonstrations of gestures, the UI being used, or illustrations. All coach marks can have any combination of action menu and media. */ -export const Standard = CoachmarkMenuStatesTemplate.bind({}); +export const Standard = Template.bind({}); Standard.storyName = "Default"; Standard.tags = ["!dev"]; Standard.parameters = { @@ -83,21 +117,45 @@ Standard.parameters = { disableSnapshot: true, }, }; +Standard.args = { + imageSource: "example-card-landscape.png", +}; -/** Coach marks can contain images or media that relate to their content, such as demonstrations of gestures, the UI being used, or illustrations. */ -export const WithMedia = Template.bind({}); -WithMedia.tags = ["!dev"]; -WithMedia.args = { - hasImage: true, +export const StandardNoMedia = Template.bind({}); +StandardNoMedia.storyName = "Default, no media"; +StandardNoMedia.tags = ["!dev"]; +StandardNoMedia.args = { + hasImage: false, }; -WithMedia.parameters = { +StandardNoMedia.parameters = { chromatic: { disableSnapshot: true, }, - docs: { - story: { - height: "500px", - }, +}; + +/** Images and media have a minimum height and can grow with the parent component. Fixed height media is constrained to a 4:3 aspect ratio by applying the `spectrum-CoachMark-image-wrapper--fixedHeight` class. When this fixed height class is used, the height can be customized using the modifiable custom property `--mod-coachmark-media-fixed-height`. */ +export const MediaOptions = CoachMarkMediaOptionsTemplate.bind({}); +MediaOptions.tags = ["!dev"]; +MediaOptions.args = { + imageSource: "example-card-portrait.png", +}; +MediaOptions.parameters = { + chromatic: { + disableSnapshot: true, + }, +}; +MediaOptions.storyName = "Media options"; + +/** The action menu, if enabled, is shown in line with the title. */ +export const WithActionMenu = CoachmarkMenuStatesTemplate.bind({}); +WithActionMenu.storyName = "With action menu"; +WithActionMenu.tags = ["!dev"]; +WithActionMenu.args = { + hasActionMenu: true, +}; +WithActionMenu.parameters = { + chromatic: { + disableSnapshot: true, }, }; @@ -107,6 +165,6 @@ WithForcedColors.tags = ["!autodocs", "!dev"]; WithForcedColors.parameters = { chromatic: { forcedColors: "active", - modes: disableDefaultModes + modes: disableDefaultModes, }, }; diff --git a/components/coachmark/stories/coachmark.test.js b/components/coachmark/stories/coachmark.test.js index c699803e554..7189c7f0402 100644 --- a/components/coachmark/stories/coachmark.test.js +++ b/components/coachmark/stories/coachmark.test.js @@ -12,7 +12,9 @@ export const TestTemplate = (args, context) => { ...args.customClasses.reduce((a, c) => ({ ...a, [c]: true }), {}), })} style=${styleMap(args.customStyles)} - >${CoachContainer(args, context)}
    + > + ${CoachContainer(args, context)} +
    `; }; @@ -28,50 +30,44 @@ export const CoachMarkGroup = Variants({ testHeading: "Default", hasActionMenu: false, hasPagination: false, - wrapperStyles: { - "background-color": "var(--spectrum-gray-50, white)", - }, }, { testHeading: "With media", hasActionMenu: false, hasPagination: false, hasImage: true, - wrapperStyles: { - "background-color": "var(--spectrum-gray-50, white)" - }, + }, + { + testHeading: "With media + fixed height", + hasActionMenu: false, + hasPagination: false, + hasImage: true, + imageIsFixedHeight: true, }, { testHeading: "With action menu", hasPagination: false, - isOpen: true, - wrapperStyles: { - "background-color": "var(--spectrum-gray-50, white)" - }, + hasActionMenu: true, }, { testHeading: "With action menu + media", hasPagination: false, - isOpen: true, hasImage: true, - wrapperStyles: { - "background-color": "var(--spectrum-gray-50, white)" - }, + hasActionMenu: true, }, { testHeading: "With pagination", hasActionMenu: false, - wrapperStyles: { - "background-color": "var(--spectrum-gray-50, white)" - }, }, { testHeading: "With pagination + media", hasActionMenu: false, hasImage: true, - wrapperStyles: { - "background-color": "var(--spectrum-gray-50, white)" - }, + }, + { + testHeading: "With a long title", + title: "Coach mark title with longer text that wraps to see how icon should align", + hasActionMenu: true, }, ], stateData: [], diff --git a/components/coachmark/stories/template.js b/components/coachmark/stories/template.js index 5a3f967ce37..5852bca7f15 100644 --- a/components/coachmark/stories/template.js +++ b/components/coachmark/stories/template.js @@ -1,4 +1,4 @@ -import { Template as ActionMenu } from "@spectrum-css/actionmenu/stories/template.js"; +import { Template as ActionButton } from "@spectrum-css/actionbutton/stories/template.js"; import { Template as ButtonGroup } from "@spectrum-css/buttongroup/stories/template.js"; import { Template as CoachIndicator } from "@spectrum-css/coachindicator/stories/template.js"; import { Template as Popover } from "@spectrum-css/popover/stories/template.js"; @@ -10,60 +10,77 @@ import { when } from "lit/directives/when.js"; import "../index.css"; -export const CoachContainer = ({ - rootClass = "spectrum-CoachMark", - hasActionMenu = false, - hasPagination, - hasImage, - title = "Try playing with a pixel brush", - content = "Pixel brushes use pixels to create brush strokes, just like in other design and drawing tools. Start drawing, and zoom in to see the pixels in each stroke.", - currentStep = 2, - totalStepCount = 8, - isOpen = false, -} = {}, context = {}) => { +export const CoachContainer = ( + { + rootClass = "spectrum-CoachMark", + hasActionMenu = false, + hasPagination, + hasImage, + imageIsFixedHeight, + imageSource, + title = "Coach mark title", + content = "Pixel brushes use pixels to create brush strokes, just like in other design and drawing tools. Start drawing, and zoom in to see the pixels in each stroke.", + currentStep = 2, + totalStepCount = 8, + alt = "", + } = {}, + context = {}, +) => { const { globals = {} } = context; const scale = globals.scale ?? "medium"; return html` - ${when(hasImage, () => html` -
    - -
    - `)} -
    + ${when( + hasImage, + () => html` +
    + ${alt} +
    + `, + )} +
    ${title}
    - ${when(hasActionMenu, () => html` -
    - ${ActionMenu({ - isOpen, - position: "bottom-start", + + ${when( + hasActionMenu, + () => ActionButton( + { iconName: "More", size: scale === "large" ? "s" : "m", - items: [ - { - label: "Skip tour", - }, - { - label: "Reset tour", - }, - ], - popoverHeight: 68, - popoverWidth: 84, - }, context)} -
    ` + label: "More actions", + hideLabel: true, + customClasses: [`${rootClass}-action-menu`], + }, + context, + ), )}
    -
    ${content}
    +
    + ${content} +
    ${ColorHandle({ isDisabled, + isFocused, customClasses: [`${rootClass}-handle`], customStyles: { "--spectrum-picked-color": selectedColor, diff --git a/components/colorhandle/CHANGELOG.md b/components/colorhandle/CHANGELOG.md index 26edda6a0e0..b8a3a0d3606 100644 --- a/components/colorhandle/CHANGELOG.md +++ b/components/colorhandle/CHANGELOG.md @@ -1,5 +1,42 @@ # Change log +## 11.0.0-next.2 + +### Patch Changes + +📝 [#4113](https://github.com/adobe/spectrum-css/pull/4113) [`cf4fc1a`](https://github.com/adobe/spectrum-css/commit/cf4fc1a01d23ba810f45a903ecc29a5c8aae33d1) Thanks [@castastrophe](https://github.com/castastrophe)! + +## Minor linting fixes + +- Removed unused custom properties across multiple components +- Fixed color function notation by converting `rgba()` to `rgb()` where appropriate +- Removed duplicate custom property declarations +- Fixed deprecated CSS properties (e.g., `word-wrap` → `overflow-wrap`) +- Removed unnecessary stylelint-disable comments + +_No visual or functional changes to components._ + +## 11.0.0-next.1 + +### Minor Changes + +- [#3656](https://github.com/adobe/spectrum-css/pull/3656) [`911c390`](https://github.com/adobe/spectrum-css/commit/911c390b9fa0b43187e5ab535874f2ed1ffeb88d) Thanks [@aramos-adobe](https://github.com/aramos-adobe)! - #### Including the touch action rule for draggable content + + The slider, color slider, color area, color wheel, color handle all deserve to have their touch-action property managed so that trying to set the value of those interfaces doesn't cause page scrolling in touch context. + + Adding `touch-action: none` to a slider or any draggable component is necessary to prevent the browser's default touch behaviors—such as scrolling, pinch-zooming, or double-tap zooming from interfering with the component's intended interaction. + + These components also include `user-select: none` to prevent selection or highlighting of any text elements. + +## 11.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + - @spectrum-css/colorloupe@8.0.0-next.0 + - @spectrum-css/opacitycheckerboard@5.0.0-next.0 + ## 10.2.0 ### Minor Changes diff --git a/components/colorhandle/dist/metadata.json b/components/colorhandle/dist/metadata.json index 4d8589ac1c1..cbd2b5d599f 100644 --- a/components/colorhandle/dist/metadata.json +++ b/components/colorhandle/dist/metadata.json @@ -46,7 +46,6 @@ "--spectrum-picked-color", "--spectrum-white" ], - "system-theme": [], "passthroughs": ["--mod-opacity-checkerboard-position"], "high-contrast": [ "--highcontrast-colorhandle-border-color-disabled", diff --git a/components/colorhandle/index.css b/components/colorhandle/index.css index 6597cfe59df..4a44307da48 100644 --- a/components/colorhandle/index.css +++ b/components/colorhandle/index.css @@ -55,6 +55,9 @@ transition: all var(--mod-colorhandle-animation-duration, var(--spectrum-animation-duration-100)) var(--mod-colorhandle-animation-easing, ease-in-out); + touch-action: none; /* Disable touch scrolling on touch devices to allow for color picking */ + user-select: none; /* Prevent text selection when dragging the handle */ + &::after { content: ""; inset-inline: calc(50% - calc(var(--mod-colorhandle-hitarea-size, var(--spectrum-color-control-track-width)) / 2)); diff --git a/components/colorhandle/package.json b/components/colorhandle/package.json index dc89771d516..e472ef29c22 100644 --- a/components/colorhandle/package.json +++ b/components/colorhandle/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/colorhandle", - "version": "10.2.0", + "version": "11.0.0-next.2", "description": "The Spectrum CSS Color Handle component", "license": "Apache-2.0", "author": "Adobe", @@ -24,9 +24,9 @@ }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/colorloupe": ">=7.0.0 <8.0.0", - "@spectrum-css/opacitycheckerboard": ">=4.0.0 <5.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/colorloupe": ">=8.0.0-next.0", + "@spectrum-css/opacitycheckerboard": ">=5.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/colorloupe": { @@ -40,9 +40,9 @@ } }, "devDependencies": { - "@spectrum-css/colorloupe": "7.2.0", - "@spectrum-css/opacitycheckerboard": "4.2.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/colorloupe": "8.0.0-next.1", + "@spectrum-css/opacitycheckerboard": "5.0.0-next.0", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/colorhandle/stories/colorhandle.stories.js b/components/colorhandle/stories/colorhandle.stories.js index b3923e6d17e..ff525d51d6d 100644 --- a/components/colorhandle/stories/colorhandle.stories.js +++ b/components/colorhandle/stories/colorhandle.stories.js @@ -52,7 +52,11 @@ export default { }, packageJson, metadata, + status: { + type: "migrated", + }, }, + tags: ["migrated"], }; /** diff --git a/components/colorloupe/CHANGELOG.md b/components/colorloupe/CHANGELOG.md index e93f3015c43..9adf440c4bc 100644 --- a/components/colorloupe/CHANGELOG.md +++ b/components/colorloupe/CHANGELOG.md @@ -1,5 +1,20 @@ # Change log +## 8.0.0-next.1 + +### Major Changes + +📝 [#4014](https://github.com/adobe/spectrum-css/pull/4014) [`35c066b`](https://github.com/adobe/spectrum-css/commit/35c066b29c311b1bfcf4507075f13b41222ffc84) Thanks [@castastrophe](https://github.com/castastrophe)! + +This update removes the `dir` attribute polyfill (served via a PostCSS transform to compiled assets) as the fallback is no longer necessary. The`dir` attribute support is available in all supported browsers and has been tested to correctly inherit inside web component shadow DOMs. This is a breaking change **only** to those relying on the `dir` attribute being present for styling, however, the `:dir` pseudo will correctly inherit values from their containers. To correctly determine the `dir` value of a node using JavaScript, you can use `getComputedStyle(node).direction`. + +## 8.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + ## 7.2.0 ### Minor Changes diff --git a/components/colorloupe/dist/metadata.json b/components/colorloupe/dist/metadata.json index 245bb476b1f..8ec7836e2ed 100644 --- a/components/colorloupe/dist/metadata.json +++ b/components/colorloupe/dist/metadata.json @@ -9,8 +9,7 @@ ".spectrum-ColorLoupe-outer-border", ".spectrum-ColorLoupe.is-disabled", ".spectrum-ColorLoupe.is-open", - ".spectrum-ColorLoupe:dir(rtl)", - "[dir=\"rtl\"] .spectrum-ColorLoupe" + ".spectrum-ColorLoupe:dir(rtl)" ], "modifiers": [ "--mod-colorloupe-animation-distance", @@ -26,26 +25,39 @@ ], "component": [ "--spectrum-color-loupe-bottom-to-color-handle", - "--spectrum-color-loupe-drop-shadow-blur", - "--spectrum-color-loupe-drop-shadow-color", - "--spectrum-color-loupe-drop-shadow-y", "--spectrum-color-loupe-height", "--spectrum-color-loupe-inner-border", "--spectrum-color-loupe-inner-border-width", "--spectrum-color-loupe-outer-border", "--spectrum-color-loupe-outer-border-width", "--spectrum-color-loupe-width", - "--spectrum-colorloupe-checkerboard-fill" + "--spectrum-colorloupe-animation-distance", + "--spectrum-colorloupe-checkerboard-dark-color", + "--spectrum-colorloupe-checkerboard-fill", + "--spectrum-colorloupe-checkerboard-light-color", + "--spectrum-colorloupe-drop-shadow-blur", + "--spectrum-colorloupe-drop-shadow-color", + "--spectrum-colorloupe-drop-shadow-x", + "--spectrum-colorloupe-drop-shadow-y", + "--spectrum-colorloupe-height", + "--spectrum-colorloupe-inner-border-color", + "--spectrum-colorloupe-inner-border-width", + "--spectrum-colorloupe-offset", + "--spectrum-colorloupe-outer-border-color", + "--spectrum-colorloupe-outer-border-width", + "--spectrum-colorloupe-width" ], "global": [ "--spectrum-color-handle-outer-border-width", "--spectrum-color-handle-size", - "--spectrum-drop-shadow-x", + "--spectrum-drop-shadow-elevated-blur", + "--spectrum-drop-shadow-elevated-color", + "--spectrum-drop-shadow-elevated-x", + "--spectrum-drop-shadow-elevated-y", "--spectrum-opacity-checkerboard-square-dark", "--spectrum-opacity-checkerboard-square-light", "--spectrum-picked-color" ], - "system-theme": [], "passthroughs": [], "high-contrast": ["--highcontrast-colorloupe-outer-border-color"] } diff --git a/components/colorloupe/index.css b/components/colorloupe/index.css index f793d2fa6b0..adcd988e569 100644 --- a/components/colorloupe/index.css +++ b/components/colorloupe/index.css @@ -12,25 +12,44 @@ */ .spectrum-ColorLoupe { - inline-size: var(--spectrum-color-loupe-width); - block-size: var(--spectrum-color-loupe-height); + --spectrum-colorloupe-width: var(--spectrum-color-loupe-width); + --spectrum-colorloupe-height: var(--spectrum-color-loupe-height); + + --spectrum-colorloupe-offset: var(--spectrum-color-loupe-bottom-to-color-handle); + --spectrum-colorloupe-animation-distance: 8px; /* TODO: replace with forthcoming animation token */ + + --spectrum-colorloupe-drop-shadow-x: var(--spectrum-drop-shadow-elevated-x); + --spectrum-colorloupe-drop-shadow-y: var(--spectrum-drop-shadow-elevated-y); + --spectrum-colorloupe-drop-shadow-blur: var(--spectrum-drop-shadow-elevated-blur); + --spectrum-colorloupe-drop-shadow-color: var(--spectrum-drop-shadow-elevated-color); + + --spectrum-colorloupe-outer-border-width: var(--spectrum-color-loupe-outer-border-width); + --spectrum-colorloupe-inner-border-width: var(--spectrum-color-loupe-inner-border-width); + --spectrum-colorloupe-outer-border-color: var(--spectrum-color-loupe-outer-border); + --spectrum-colorloupe-inner-border-color: var(--spectrum-color-loupe-inner-border); + + --spectrum-colorloupe-checkerboard-dark-color: var(--spectrum-opacity-checkerboard-square-dark); + --spectrum-colorloupe-checkerboard-light-color: var(--spectrum-opacity-checkerboard-square-light); + + inline-size: var(--spectrum-colorloupe-width); + block-size: var(--spectrum-colorloupe-height); position: absolute; - transform: translate(0, var(--mod-colorloupe-animation-distance, 8px)); + transform: translate(0, var(--mod-colorloupe-animation-distance, var(--spectrum-colorloupe-animation-distance))); opacity: 0; transform-origin: bottom center; - inset-block-end: calc(var(--spectrum-color-handle-size) - var(--spectrum-color-handle-outer-border-width) + var(--mod-colorloupe-offset, var(--spectrum-color-loupe-bottom-to-color-handle))); - inset-inline-end: calc(50% - var(--spectrum-color-loupe-width) / 2); + inset-block-end: calc((var(--spectrum-color-handle-size) - var(--spectrum-color-handle-outer-border-width)) + var(--mod-colorloupe-offset, var(--spectrum-colorloupe-offset))); + inset-inline-end: calc(50% - (var(--spectrum-colorloupe-width) / 2)); transition: transform 100ms ease-in-out, opacity 125ms ease-in-out; pointer-events: none; - filter: drop-shadow(var(--mod-colorloupe-drop-shadow-x, var(--spectrum-drop-shadow-x)) var(--mod-colorloupe-drop-shadow-y, var(--spectrum-color-loupe-drop-shadow-y)) var(--mod-colorloupe-drop-shadow-blur, var(--spectrum-color-loupe-drop-shadow-blur)) var(--mod-colorloupe-drop-shadow-color, var(--spectrum-color-loupe-drop-shadow-color))); + filter: drop-shadow(var(--mod-colorloupe-drop-shadow-x, var(--spectrum-colorloupe-drop-shadow-x)) var(--mod-colorloupe-drop-shadow-y, var(--spectrum-colorloupe-drop-shadow-y)) var(--mod-colorloupe-drop-shadow-blur, var(--spectrum-colorloupe-drop-shadow-blur)) var(--mod-colorloupe-drop-shadow-color, var(--spectrum-colorloupe-drop-shadow-color))); &:dir(rtl) { - inset-inline-end: calc(50% - (var(--spectrum-color-loupe-width) / 2) - 1px); + inset-inline-end: calc(50% - (var(--spectrum-colorloupe-width) / 2) - 1px); } &.is-open { @@ -44,26 +63,27 @@ } .spectrum-ColorLoupe-inner-border { + /* Undefined variable allows custom stylesheet or JS to pass the value to this element */ fill: var(--spectrum-picked-color); - stroke: var(--mod-colorloupe-inner-border-color, var(--spectrum-color-loupe-inner-border)); - stroke-width: var(--mod-colorloupe-inner-border-width, var(--spectrum-color-loupe-inner-border-width)); + stroke: var(--mod-colorloupe-inner-border-color, var(--spectrum-colorloupe-inner-border-color)); + stroke-width: var(--mod-colorloupe-inner-border-width, var(--spectrum-colorloupe-inner-border-width)); } .spectrum-ColorLoupe-outer-border { fill: none; - stroke: var(--highcontrast-colorloupe-outer-border-color, var(--mod-colorloupe-outer-border-color, var(--spectrum-color-loupe-outer-border))); - stroke-width: calc(var(--mod-colorloupe-outer-border-width, var(--spectrum-color-loupe-outer-border-width)) + 2px); + stroke: var(--highcontrast-colorloupe-outer-border-color, var(--mod-colorloupe-outer-border-color, var(--spectrum-colorloupe-outer-border-color))); + stroke-width: calc(var(--mod-colorloupe-outer-border-width, var(--spectrum-colorloupe-outer-border-width)) + 2px); } /* The checkerboard classes use opacity checkerboard tokens for dark and light color. The opacity-checkerboard-square-size token is not able to be used witin the SVG pattern and instead colorloupe docs are using two different patterns toggled by --spectrum-colorloupe-checkerboard-fill */ .spectrum-ColorLoupe-checkerboard-pattern { - fill: var(--spectrum-opacity-checkerboard-square-dark); + fill: var(--spectrum-colorloupe-checkerboard-dark-color); } .spectrum-ColorLoupe-checkerboard-background { - fill: var(--spectrum-opacity-checkerboard-square-light); + fill: var(--spectrum-colorloupe-checkerboard-light-color); } .spectrum-ColorLoupe-checkerboard-fill { diff --git a/components/colorloupe/package.json b/components/colorloupe/package.json index 89d5b7b895f..8a5533c89a7 100644 --- a/components/colorloupe/package.json +++ b/components/colorloupe/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/colorloupe", - "version": "7.2.0", + "version": "8.0.0-next.1", "description": "The Spectrum CSS Color Loupe component", "license": "Apache-2.0", "author": "Adobe", @@ -24,7 +24,7 @@ }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/tokens": ">=16.0.1" + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/tokens": { @@ -32,7 +32,7 @@ } }, "devDependencies": { - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/colorloupe/stories/colorloupe.stories.js b/components/colorloupe/stories/colorloupe.stories.js index 33913ad09aa..663790bb246 100644 --- a/components/colorloupe/stories/colorloupe.stories.js +++ b/components/colorloupe/stories/colorloupe.stories.js @@ -49,7 +49,11 @@ export default { }, packageJson, metadata, + status: { + type: "migrated", + }, }, + tags: ["migrated"], }; export const Default = ColorLoupeGroup.bind({}); diff --git a/components/colorslider/CHANGELOG.md b/components/colorslider/CHANGELOG.md index 7df9a058794..324b5b405c2 100644 --- a/components/colorslider/CHANGELOG.md +++ b/components/colorslider/CHANGELOG.md @@ -1,5 +1,50 @@ # Change log +## 9.0.0-next.3 + +### Patch Changes + +📝 [#4113](https://github.com/adobe/spectrum-css/pull/4113) [`cf4fc1a`](https://github.com/adobe/spectrum-css/commit/cf4fc1a01d23ba810f45a903ecc29a5c8aae33d1) Thanks [@castastrophe](https://github.com/castastrophe)! + +## Minor linting fixes + +- Removed unused custom properties across multiple components +- Fixed color function notation by converting `rgba()` to `rgb()` where appropriate +- Removed duplicate custom property declarations +- Fixed deprecated CSS properties (e.g., `word-wrap` → `overflow-wrap`) +- Removed unnecessary stylelint-disable comments + +_No visual or functional changes to components._ + +## 9.0.0-next.2 + +### Major Changes + +📝 [#4014](https://github.com/adobe/spectrum-css/pull/4014) [`35c066b`](https://github.com/adobe/spectrum-css/commit/35c066b29c311b1bfcf4507075f13b41222ffc84) Thanks [@castastrophe](https://github.com/castastrophe)! + +This update removes the `dir` attribute polyfill (served via a PostCSS transform to compiled assets) as the fallback is no longer necessary. The`dir` attribute support is available in all supported browsers and has been tested to correctly inherit inside web component shadow DOMs. This is a breaking change **only** to those relying on the `dir` attribute being present for styling, however, the `:dir` pseudo will correctly inherit values from their containers. To correctly determine the `dir` value of a node using JavaScript, you can use `getComputedStyle(node).direction`. + +## 9.0.0-next.1 + +### Minor Changes + +- [#3656](https://github.com/adobe/spectrum-css/pull/3656) [`911c390`](https://github.com/adobe/spectrum-css/commit/911c390b9fa0b43187e5ab535874f2ed1ffeb88d) Thanks [@aramos-adobe](https://github.com/aramos-adobe)! - #### Including the touch action rule for draggable content + + The slider, color slider, color area, color wheel, color handle all deserve to have their touch-action property managed so that trying to set the value of those interfaces doesn't cause page scrolling in touch context. + + Adding `touch-action: none` to a slider or any draggable component is necessary to prevent the browser's default touch behaviors—such as scrolling, pinch-zooming, or double-tap zooming from interfering with the component's intended interaction. + + These components also include `user-select: none` to prevent selection or highlighting of any text elements. + +## 9.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + - @spectrum-css/colorhandle@11.0.0-next.0 + - @spectrum-css/opacitycheckerboard@5.0.0-next.0 + ## 8.2.0 ### Minor Changes diff --git a/components/colorslider/dist/metadata.json b/components/colorslider/dist/metadata.json index ea202a9f0a0..aad9494baf6 100644 --- a/components/colorslider/dist/metadata.json +++ b/components/colorslider/dist/metadata.json @@ -13,8 +13,7 @@ ".spectrum-ColorSlider.is-disabled", ".spectrum-ColorSlider.is-disabled .spectrum-ColorSlider-checkerboard", ".spectrum-ColorSlider.is-disabled .spectrum-ColorSlider-gradient", - ".spectrum-ColorSlider.is-focused", - "[dir=\"rtl\"] .spectrum-ColorSlider-gradient" + ".spectrum-ColorSlider.is-focused" ], "modifiers": [ "--mod-color-slider-background-color-disabled", @@ -37,15 +36,16 @@ "--spectrum-color-slider-border-opacity", "--spectrum-color-slider-border-rounding", "--spectrum-color-slider-border-width", + "--spectrum-color-slider-control-track-width", + "--spectrum-color-slider-fill-color-disabled", "--spectrum-color-slider-length", "--spectrum-color-slider-minimum-length" ], "global": [ "--spectrum-color-control-track-width", "--spectrum-disabled-background-color", - "--spectrum-gray-900-rgb" + "--spectrum-gray-1000-rgb" ], - "system-theme": [], "passthroughs": ["--mod-colorhandle-hitarea-border-radius"], "high-contrast": [ "--highcontrast-color-slider-background-color-disabled", diff --git a/components/colorslider/index.css b/components/colorslider/index.css index 73d9f3a7b9a..8c34d8aa396 100644 --- a/components/colorslider/index.css +++ b/components/colorslider/index.css @@ -11,28 +11,26 @@ * governing permissions and limitations under the License. */ -@media (forced-colors: active) { - .spectrum-ColorSlider { - --highcontrast-color-slider-border-color: CanvasText; - --highcontrast-color-slider-border-color-disabled: GrayText; - --highcontrast-color-slider-background-color-disabled: Canvas; - forced-color-adjust: none; - } -} - .spectrum-ColorSlider { + /* Size and Spacing */ + --spectrum-color-slider-control-track-width: var(--spectrum-color-control-track-width); + /* @todo Refactor with --spectrum-color-slider-border-color once gray rgb token is no longer necessary to workaround nested rgb color token value using rgba(). */ - --spectrum-color-slider-border-color-default: rgb(var(--spectrum-gray-900-rgb), var(--spectrum-color-slider-border-opacity)); + --spectrum-color-slider-border-color-default: rgb(var(--spectrum-gray-1000-rgb), var(--spectrum-color-slider-border-opacity)); /* @passthrough -- settings for nested color handle */ --mod-colorhandle-hitarea-border-radius: var(--mod-color-slider-handle-hitarea-border-radius, 0px); + --spectrum-color-slider-fill-color-disabled: var(--spectrum-disabled-background-color); + position: relative; display: block; min-inline-size: var(--mod-color-slider-minimum-length, var(--spectrum-color-slider-minimum-length)); inline-size: var(--mod-color-slider-length, var(--spectrum-color-slider-length)); - block-size: var(--mod-color-slider-control-track-width, var(--spectrum-color-control-track-width)); + block-size: var(--mod-color-slider-control-track-width, var(--spectrum-color-slider-control-track-width)); + + touch-action: none; /* Disable touch scrolling on touch devices to allow for color picking */ /* Otherwise we randomly drag a file icon */ user-select: none; @@ -58,7 +56,7 @@ min-block-size: var(--mod-color-slider-vertical-minimum-height, var(--mod-color-slider-minimum-length, var(--spectrum-color-slider-minimum-length))); block-size: var(--mod-color-slider-vertical-height, var(--mod-color-slider-length, var(--spectrum-color-slider-length))); min-inline-size: 0; - inline-size: var(--mod-color-slider-vertical-control-track-width, var(--mod-color-slider-control-track-height, var(--spectrum-color-control-track-width))); + inline-size: var(--mod-color-slider-vertical-control-track-width, var(--mod-color-slider-control-track-height, var(--spectrum-color-slider-control-track-width))); .spectrum-ColorSlider-handle { inset-inline-start: 50%; @@ -85,8 +83,8 @@ } .spectrum-ColorSlider.is-disabled & { - --spectrum-color-slider-border-color-local: var(--highcontrast-color-slider-border-color-disabled, var(--mod-color-slider-border-color-disabled, var(--spectrum-disabled-background-color))); - background: var(--highcontrast-color-slider-background-color-disabled, var(--mod-color-slider-background-color-disabled, var(--spectrum-disabled-background-color))); + --spectrum-color-slider-border-color-local: var(--highcontrast-color-slider-border-color-disabled, var(--mod-color-slider-border-color-disabled, var(--spectrum-color-slider-fill-color-disabled))); + background: var(--highcontrast-color-slider-background-color-disabled, var(--mod-color-slider-background-color-disabled, var(--spectrum-color-slider-fill-color-disabled))); } } @@ -114,3 +112,12 @@ margin: 0; pointer-events: none; } + +@media (forced-colors: active) { + .spectrum-ColorSlider { + --highcontrast-color-slider-border-color: CanvasText; + --highcontrast-color-slider-border-color-disabled: GrayText; + --highcontrast-color-slider-background-color-disabled: Canvas; + forced-color-adjust: none; + } +} diff --git a/components/colorslider/package.json b/components/colorslider/package.json index 11be7eebb65..8cc3fcf00e3 100644 --- a/components/colorslider/package.json +++ b/components/colorslider/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/colorslider", - "version": "8.2.0", + "version": "9.0.0-next.3", "description": "The Spectrum CSS Color slider component", "license": "Apache-2.0", "author": "Adobe", @@ -24,9 +24,9 @@ }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/colorhandle": ">=10.0.0 <11.0.0", - "@spectrum-css/opacitycheckerboard": ">=4.0.0 <5.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/colorhandle": ">=11.0.0-next.0", + "@spectrum-css/opacitycheckerboard": ">=5.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/colorhandle": { @@ -40,9 +40,9 @@ } }, "devDependencies": { - "@spectrum-css/colorhandle": "10.2.0", - "@spectrum-css/opacitycheckerboard": "4.2.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/colorhandle": "11.0.0-next.2", + "@spectrum-css/opacitycheckerboard": "5.0.0-next.0", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/colorslider/stories/colorslider.stories.js b/components/colorslider/stories/colorslider.stories.js index 633fa48b8be..d6aed7a33be 100644 --- a/components/colorslider/stories/colorslider.stories.js +++ b/components/colorslider/stories/colorslider.stories.js @@ -19,18 +19,20 @@ export default { component: "ColorSlider", argTypes: { colorHandleStyle: { table: { disable: true } }, - vertical: { table: { disable: true } }, isDisabled, isFocused: { ...isFocused, if: { arg: "isDisabled", truthy: false }, }, - gradientStops: { - name: "Gradient stops", + color: { + name: "Color", description: - "The value of the CSS linear-gradient. Can be multiple stops separated by commas.", - type: { name: "array" }, - table: { disable: true }, + "Supports standard color input or any valid input for the background property such as, linear-gradient(red, blue).", + type: { name: "string", required: true }, + table: { + type: { summary: "string" }, + }, + control: "color", }, selectedColor: { name: "Selected color", @@ -40,12 +42,19 @@ export default { control: "color", }, gradientType: { - name: "Gradient type", - description: "The gradient can be defined in the markup using CSS or with an image.", - options: ["gradient", "image"], + name: "Color type", + description: + "The color can be defined in the markup using CSS or with an image.", + options: ["color", "image"], control: { type: "select" }, table: { disable: true }, }, + vertical: { + name: "Vertical", + description: "The orientation of the component.", + type: { name: "boolean" }, + control: "boolean", + }, }, args: { rootClass: "spectrum-ColorSlider", @@ -62,7 +71,11 @@ export default { }, packageJson, metadata, + status: { + type: "migrated", + }, }, + tags: ["migrated"], }; /** @@ -70,8 +83,8 @@ export default { */ export const Default = ColorSliderGroup.bind({}); Default.args = { - gradientStops: - ["rgb(255, 0, 0) 0%", "rgb(255, 255, 0) 17%", "rgb(0, 255, 0) 33%", "rgb(0, 255, 255) 50%", "rgb(0, 0, 255) 67%", "rgb(255, 0, 255) 83%", "rgb(255, 0, 0) 100%"], + color: + "linear-gradient(to right, rgb(255, 0, 0) 0%, rgb(255, 255, 0) 17%, rgb(0, 255, 0) 33%, rgb(0, 255, 255) 50%, rgb(0, 0, 255) 67%, rgb(255, 0, 255) 83%, rgb(255, 0, 0) 100%)", }; // ********* VRT ONLY ********* // @@ -81,7 +94,7 @@ WithForcedColors.tags = ["!autodocs", "!dev"]; WithForcedColors.parameters = { chromatic: { forcedColors: "active", - modes: disableDefaultModes + modes: disableDefaultModes, }, }; @@ -92,6 +105,8 @@ WithForcedColors.parameters = { export const Vertical = Template.bind({}); Vertical.args = { vertical: true, + color: + "linear-gradient(to bottom, rgb(255, 0, 0) 0%, rgb(255, 255, 0) 17%, rgb(0, 255, 0) 33%, rgb(0, 255, 255) 50%, rgb(0, 0, 255) 67%, rgb(255, 0, 255) 83%, rgb(255, 0, 0) 100%)", }; Vertical.tags = ["!dev"]; Vertical.parameters = { @@ -100,7 +115,7 @@ Vertical.parameters = { export const Alpha = Template.bind({}); Alpha.args = { - gradientStops: ["rgba(0, 0, 0, 1) 0%", "rgba(0, 0, 0, 0) 100%"], + color: "linear-gradient(to right, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0) 100%)", selectedColor: "rgba(0, 0, 0, 1)", }; Alpha.tags = ["!dev"]; diff --git a/components/colorslider/stories/colorslider.test.js b/components/colorslider/stories/colorslider.test.js index 166960e9353..ceb4f5dac81 100644 --- a/components/colorslider/stories/colorslider.test.js +++ b/components/colorslider/stories/colorslider.test.js @@ -14,6 +14,7 @@ export const ColorSliderGroup = Variants({ { testHeading: "Vertical", vertical: true, + color: "linear-gradient(to bottom, rgb(255, 0, 0) 0%, rgb(255, 255, 0) 17%, rgb(0, 255, 0) 33%, rgb(0, 255, 255) 50%, rgb(0, 0, 255) 67%, rgb(255, 0, 255) 83%, rgb(255, 0, 0) 100%)", wrapperStyles: { // Adjust for the indicator "padding-block": "20px", @@ -21,7 +22,7 @@ export const ColorSliderGroup = Variants({ }, { testHeading: "Alpha", - gradientStops: ["rgba(0, 0, 0, 1) 0%", "rgba(0, 0, 0, 0) 100%"], + color: "linear-gradient(to right, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0) 100%)", selectedColor: "rgba(0, 0, 0, 1)", wrapperStyles: { // Adjust for the indicator diff --git a/components/colorslider/stories/template.js b/components/colorslider/stories/template.js index f4c15735012..73f7f123568 100644 --- a/components/colorslider/stories/template.js +++ b/components/colorslider/stories/template.js @@ -7,83 +7,83 @@ import { when } from "lit/directives/when.js"; import "../index.css"; -export const Template = ({ - rootClass = "spectrum-ColorSlider", - customClasses = [], - customStyles = {}, - isDisabled = false, - isFocused = false, - vertical = false, - gradientStops = [ - "rgb(255, 0, 0) 0%", - "rgb(255, 255, 0) 17%", - "rgb(0, 255, 0) 33%", - "rgb(0, 255, 255) 50%", - "rgb(0, 0, 255) 67%", - "rgb(255, 0, 255) 83%", - "rgb(255, 0, 0)", - ], - gradientType = "gradient", - selectedColor = "rgba(255, 0, 0, 1)", - colorHandleStyle = {}, -} = {}, context = {}) => { +export const Template = ( + { + rootClass = "spectrum-ColorSlider", + customClasses = [], + customStyles = {}, + isDisabled = false, + isFocused = false, + vertical = false, + color = "linear-gradient(to right, rgb(255, 0, 0) 0%, rgb(255, 255, 0) 17%, rgb(0, 255, 0) 33%, rgb(0, 255, 255) 50%, rgb(0, 0, 255) 67%, rgb(255, 0, 255) 83%, rgb(255, 0, 0) 100%)", + gradientType = "gradient", + selectedColor = "rgba(255, 0, 0, 1)", + colorHandleStyle = {}, + } = {}, + context = {}, +) => { const { updateArgs } = context; return html` -
    ({ ...a, [c]: true }), {}), - })} - style=${styleMap(customStyles)} - @focusin=${function() { - updateArgs({ isFocused: true }); - }} - @focusout=${function() { - updateArgs({ isFocused: false }); - }} - > - ${OpacityCheckerboard({ - customClasses: [`${rootClass}-checkerboard`], - content: [ - when( - gradientType === "image", - () => html``, - () => html`` - ), - ], - role: "presentation", - }, context)} - ${ColorHandle({ - isDisabled, - isFocused, - selectedColor, - customClasses: [`${rootClass}-handle`], - customStyles: colorHandleStyle, - }, context)} - -
    - `; +
    ({ ...a, [c]: true }), {}), + })} + style=${styleMap(customStyles)} + @focusin=${function () { + updateArgs({ isFocused: true }); + }} + @focusout=${function () { + updateArgs({ isFocused: false }); + }} + > + ${OpacityCheckerboard( + { + customClasses: [`${rootClass}-checkerboard`], + content: [ + when( + gradientType === "image", + () => + html``, + () => + html``, + ), + ], + role: "presentation", + }, + context, + )} + ${ColorHandle( + { + isDisabled, + isFocused, + selectedColor, + customClasses: [`${rootClass}-handle`], + customStyles: colorHandleStyle, + }, + context, + )} + +
    + `; }; diff --git a/components/colorwheel/CHANGELOG.md b/components/colorwheel/CHANGELOG.md index 758d6a19230..34bee3ff5fc 100644 --- a/components/colorwheel/CHANGELOG.md +++ b/components/colorwheel/CHANGELOG.md @@ -1,5 +1,78 @@ # Change log +## 7.0.0-next.4 + +### Patch Changes + +📝 [#4113](https://github.com/adobe/spectrum-css/pull/4113) [`cf4fc1a`](https://github.com/adobe/spectrum-css/commit/cf4fc1a01d23ba810f45a903ecc29a5c8aae33d1) Thanks [@castastrophe](https://github.com/castastrophe)! + +## Minor linting fixes + +- Removed unused custom properties across multiple components +- Fixed color function notation by converting `rgba()` to `rgb()` where appropriate +- Removed duplicate custom property declarations +- Fixed deprecated CSS properties (e.g., `word-wrap` → `overflow-wrap`) +- Removed unnecessary stylelint-disable comments + +_No visual or functional changes to components._ + +## 7.0.0-next.3 + +### Major Changes + +📝 [#4014](https://github.com/adobe/spectrum-css/pull/4014) [`35c066b`](https://github.com/adobe/spectrum-css/commit/35c066b29c311b1bfcf4507075f13b41222ffc84) Thanks [@castastrophe](https://github.com/castastrophe)! + +This update removes the `dir` attribute polyfill (served via a PostCSS transform to compiled assets) as the fallback is no longer necessary. The`dir` attribute support is available in all supported browsers and has been tested to correctly inherit inside web component shadow DOMs. This is a breaking change **only** to those relying on the `dir` attribute being present for styling, however, the `:dir` pseudo will correctly inherit values from their containers. To correctly determine the `dir` value of a node using JavaScript, you can use `getComputedStyle(node).direction`. + +## 7.0.0-next.2 + +### Minor Changes + +- [#3656](https://github.com/adobe/spectrum-css/pull/3656) [`911c390`](https://github.com/adobe/spectrum-css/commit/911c390b9fa0b43187e5ab535874f2ed1ffeb88d) Thanks [@aramos-adobe](https://github.com/aramos-adobe)! - #### Including the touch action rule for draggable content + + The slider, color slider, color area, color wheel, color handle all deserve to have their touch-action property managed so that trying to set the value of those interfaces doesn't cause page scrolling in touch context. + + Adding `touch-action: none` to a slider or any draggable component is necessary to prevent the browser's default touch behaviors—such as scrolling, pinch-zooming, or double-tap zooming from interfering with the component's intended interaction. + + These components also include `user-select: none` to prevent selection or highlighting of any text elements. + +## 7.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + - @spectrum-css/colorarea@8.0.0-next.0 + - @spectrum-css/colorhandle@11.0.0-next.0 + - @spectrum-css/colorloupe@8.0.0-next.0 + +## 7.0.0-next.0 + +### Major Changes + +- [#3390](https://github.com/adobe/spectrum-css/pull/3390) [`b9f61e4`](https://github.com/adobe/spectrum-css/commit/b9f61e42486c3619de95423e0575e10ccc9be167) Thanks [@cdransf](https://github.com/cdransf)! - # colorwheel S2 migration + + This change migrates the colorwheel component to S2. It adds the `--spectrum-colorwheel-border-color-rgb` and `--spectrum-colorwheel-border-opacity` custom properties. It updates `--spectrum-colorwheel-border-color` to leverage these tokens in an `rgba(...)` function. + + This removes the `spectrum-ColorWheel-border` and associated template DOM node as the outside/underlying border are no longer present in the S2 designs. `::before` and `::after` pseudo elements are now used to draw the exterior and interior borders that overlay the exterior and interior edges of the color wheel. + + Support is provided for the `240px` and `192px` sizes outlined in the design requirements. + + The `forced-colors` media query has been moved to the bottom of the file consistent with our other component implementations. + + Stories, tests and documentation have been updated to be consistent with these changes. + + The following mods have been removed: + + ```css + --mod-colorwheel-height + --mod-colorwheel-width + --mod-colorwheel-min-width + --mod-colorwheel-path-borders + --mod-colorwheel-colorarea-margin + --mod-colorwheel-border-width + ``` + ## 6.2.0 ### Minor Changes diff --git a/components/colorwheel/dist/metadata.json b/components/colorwheel/dist/metadata.json index c321e1aca27..1c087a7f50f 100644 --- a/components/colorwheel/dist/metadata.json +++ b/components/colorwheel/dist/metadata.json @@ -4,8 +4,6 @@ ".spectrum-ColorWheel", ".spectrum-ColorWheel-ColorArea-handle", ".spectrum-ColorWheel-ColorArea-handle:dir(rtl)", - ".spectrum-ColorWheel-border", - ".spectrum-ColorWheel-border.is-disabled", ".spectrum-ColorWheel-colorarea-container", ".spectrum-ColorWheel-handle", ".spectrum-ColorWheel-inner", @@ -13,44 +11,46 @@ ".spectrum-ColorWheel-wheel", ".spectrum-ColorWheel-wheel.is-disabled", ".spectrum-ColorWheel.is-disabled", + ".spectrum-ColorWheel.is-disabled .spectrum-ColorWheel-inner:before", + ".spectrum-ColorWheel.is-disabled:after", + ".spectrum-ColorWheel.is-disabled:before", ".spectrum-ColorWheel.is-dragged", ".spectrum-ColorWheel.is-focused", - "[dir=\"rtl\"] .spectrum-ColorWheel-ColorArea-handle" + ".spectrum-ColorWheel:after", + ".spectrum-ColorWheel:before" ], "modifiers": [ + "--mod-colorwheel-block-size", "--mod-colorwheel-border-color", - "--mod-colorwheel-border-width", "--mod-colorwheel-colorarea-container-size", - "--mod-colorwheel-colorarea-margin", "--mod-colorwheel-fill-color-disabled", - "--mod-colorwheel-height", - "--mod-colorwheel-min-width", + "--mod-colorwheel-inline-size", + "--mod-colorwheel-min-inline-size", "--mod-colorwheel-path", - "--mod-colorwheel-path-borders", - "--mod-colorwheel-track-width", - "--mod-colorwheel-width" + "--mod-colorwheel-track-width" ], "component": [ - "--spectrum-color-wheel-color-area-margin", + "--spectrum-color-wheel-border-opacity", "--spectrum-color-wheel-minimum-width", "--spectrum-color-wheel-width", + "--spectrum-colorwheel-block-size", "--spectrum-colorwheel-border-color", + "--spectrum-colorwheel-border-color-rgb", + "--spectrum-colorwheel-border-opacity", "--spectrum-colorwheel-border-width", "--spectrum-colorwheel-colorarea-container-size", "--spectrum-colorwheel-fill-color-disabled", - "--spectrum-colorwheel-height", + "--spectrum-colorwheel-inline-size", + "--spectrum-colorwheel-min-inline-size", "--spectrum-colorwheel-path", - "--spectrum-colorwheel-path-borders", - "--spectrum-colorwheel-track-width", - "--spectrum-colorwheel-width" + "--spectrum-colorwheel-track-width" ], "global": [ "--spectrum-border-width-100", "--spectrum-color-control-track-width", "--spectrum-disabled-background-color", - "--spectrum-transparent-black-300" + "--spectrum-gray-1000-rgb" ], - "system-theme": ["--system-color-wheel-border-color"], "passthroughs": [], "high-contrast": [ "--highcontrast-colorwheel-border-color-disabled", diff --git a/components/colorwheel/index.css b/components/colorwheel/index.css index e44d21045f0..d910165d5ac 100644 --- a/components/colorwheel/index.css +++ b/components/colorwheel/index.css @@ -1,5 +1,5 @@ /*! - * Copyright 2024 Adobe. All rights reserved. + * Copyright 2025 Adobe. All rights reserved. * * This file is licensed to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. You may obtain a copy @@ -11,45 +11,82 @@ * governing permissions and limitations under the License. */ -@import "./themes/spectrum-two.css"; +.spectrum-ColorWheel { + --spectrum-colorwheel-inline-size: var(--spectrum-color-wheel-width); + --spectrum-colorwheel-block-size: var(--spectrum-color-wheel-width); + --spectrum-colorwheel-min-inline-size: var(--spectrum-color-wheel-minimum-width); -/* Windows High Contrast Mode */ -@media (forced-colors: active) { - .spectrum-ColorWheel { - --highcontrast-colorwheel-border-color-disabled: GrayText; - --highcontrast-colorwheel-fill-color-disabled: Canvas; + /* @TODO: leveraging the rgb token in this case to achieve the desired border color implementation as rgb + opacity are required by the `rgba` function. */ + --spectrum-colorwheel-border-color-rgb: var(--spectrum-gray-1000-rgb); - forced-color-adjust: none; - } -} + --spectrum-colorwheel-border-opacity: var(--spectrum-color-wheel-border-opacity); + --spectrum-colorwheel-border-color: rgb(var(--spectrum-colorwheel-border-color-rgb), var(--spectrum-colorwheel-border-opacity)); -.spectrum-ColorWheel { - --spectrum-colorwheel-width: var(--mod-colorwheel-width, var(--spectrum-color-wheel-width)); - --spectrum-colorwheel-height: var(--mod-colorwheel-height, var(--spectrum-color-wheel-width)); - --spectrum-colorwheel-fill-color-disabled: var(--mod-colorwheel-fill-color-disabled, var(--spectrum-disabled-background-color)); + --spectrum-colorwheel-border-width: var(--spectrum-border-width-100); + --spectrum-colorwheel-track-width: var(--spectrum-color-control-track-width); - --spectrum-colorwheel-border-width: var(--mod-colorwheel-border-width, var(--spectrum-border-width-100)); - --spectrum-colorwheel-track-width: var(--mod-colorwheel-track-width, var(--spectrum-color-control-track-width)); + --spectrum-colorwheel-fill-color-disabled: var(--spectrum-disabled-background-color); /* stylelint-disable-next-line spectrum-tools/no-unused-custom-properties -- used with JS in calculating the clip-path paths and colorarea-container-size */ - --_track-width: var(--spectrum-colorwheel-track-width); + --_track-width: var(--mod-colorwheel-track-width, var(--spectrum-colorwheel-track-width)); /* stylelint-disable-next-line spectrum-tools/no-unused-custom-properties -- used with JS in calculating the clip-path paths and colorarea-container-size */ --_border-width: var(--spectrum-colorwheel-border-width); position: relative; display: block; - min-inline-size: var(--mod-colorwheel-min-width, var(--spectrum-color-wheel-minimum-width)); - inline-size: var(--spectrum-colorwheel-width); - block-size: var(--spectrum-colorwheel-height); + min-inline-size: var(--mod-colorwheel-min-inline-size, var(--spectrum-colorwheel-min-inline-size)); + inline-size: var(--mod-colorwheel-inline-size, var(--spectrum-colorwheel-inline-size)); + block-size: var(--mod-colorwheel-block-size, var(--spectrum-colorwheel-block-size)); + touch-action: none; /* Disable touch scrolling on touch devices to allow for color picking */ user-select: none; cursor: default; + /** + * Color wheel exterior border + * - Calcs for `inline-size` and `block-size` subtract 4 times the component's border width + * (to account for the inset width of the exterior border) from the component's width. + */ + &::before { + inline-size: calc(var(--mod-colorwheel-inline-size, var(--spectrum-colorwheel-inline-size)) - calc(4 * var(--spectrum-colorwheel-border-width))); + block-size: calc(var(--mod-colorwheel-inline-size, var(--spectrum-colorwheel-inline-size)) - calc(4 * var(--spectrum-colorwheel-border-width))); + inset: var(--spectrum-colorwheel-border-width); + content: ""; + position: absolute; + border-width: var(--spectrum-colorwheel-border-width); + border-style: solid; + border-color: var(--mod-colorwheel-border-color, var(--spectrum-colorwheel-border-color)); + border-radius: 100%; + z-index: 1; + } + + /** + * Color wheel interior border + * - Calcs for `inset` 2 times the component's border width from the + * track width (to account for the inset width of the interior border) + */ + &::after { + inset: calc(var(--mod-colorwheel-track-width, var(--spectrum-colorwheel-track-width)) - (calc(2 * var(--spectrum-colorwheel-border-width)))); + content: ""; + position: absolute; + border-width: var(--spectrum-colorwheel-border-width); + border-style: solid; + border-color: var(--mod-colorwheel-border-color, var(--spectrum-colorwheel-border-color)); + border-radius: 100%; + z-index: 1; + } + &.is-focused { z-index: 2; } &.is-disabled { pointer-events: none; + + &::before, + &::after, + .spectrum-ColorWheel-inner::before { + border-color: var(--highcontrast-colorwheel-border-color-disabled, transparent); + } } &.is-dragged { @@ -76,7 +113,6 @@ display: flex; align-items: center; justify-content: center; - margin: var(--mod-colorwheel-colorarea-margin, var(--spectrum-color-wheel-color-area-margin)); } .spectrum-ColorWheel-slider { @@ -92,7 +128,7 @@ } .spectrum-ColorWheel-handle { - transform: translate(calc(var(--spectrum-colorwheel-width) / 2 - var(--spectrum-colorwheel-track-width) / 2), 0); + transform: translate(calc(var(--mod-colorwheel-inline-size, var(--spectrum-colorwheel-inline-size)) / 2 - var(--mod-colorwheel-track-width, var(--mod-colorwheel-track-width, var(--spectrum-colorwheel-track-width))) / 2), 0); inset-block-start: 50%; inset-inline: 50%; } @@ -106,19 +142,6 @@ } } -/* a clip-path set border-width wider than than spectrum-colorwheel-wheel to create the appreance of a border */ -.spectrum-ColorWheel-border { - position: relative; - background-color: var(--mod-colorwheel-border-color, var(--spectrum-colorwheel-border-color)); - inline-size: var(--spectrum-colorwheel-width); - block-size: var(--spectrum-colorwheel-height); - clip-path: path(evenodd, var(--mod-colorwheel-path-borders, var(--spectrum-colorwheel-path-borders))); - - &.is-disabled { - background-color: var(--highcontrast-colorwheel-border-color-disabled, var(--spectrum-colorwheel-fill-color-disabled)); - } -} - .spectrum-ColorWheel-wheel { position: absolute; background: conic-gradient(from 90deg, red, rgb(255 128 0), rgb(255 255 0), rgb(128 255 0), rgb(0 255 0), rgb(0 255 128), rgb(0 255 255), rgb(0 128 255), rgb(0 0 255), rgb(128 0 255), rgb(255 0 255), rgb(255 0 128), red); @@ -128,6 +151,16 @@ &.is-disabled { pointer-events: none; - background: var(--highcontrast-colorwheel-fill-color-disabled, var(--spectrum-colorwheel-fill-color-disabled)); + background: var(--highcontrast-colorwheel-fill-color-disabled, var(--mod-colorwheel-fill-color-disabled, var(--spectrum-colorwheel-fill-color-disabled))); + } +} + +/* Windows High Contrast Mode */ +@media (forced-colors: active) { + .spectrum-ColorWheel { + --highcontrast-colorwheel-border-color-disabled: GrayText; + --highcontrast-colorwheel-fill-color-disabled: Canvas; + + forced-color-adjust: none; } } diff --git a/components/colorwheel/package.json b/components/colorwheel/package.json index 17c0532e998..d74a81b081c 100644 --- a/components/colorwheel/package.json +++ b/components/colorwheel/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/colorwheel", - "version": "6.2.0", + "version": "7.0.0-next.4", "description": "The Spectrum CSS Color Area component", "license": "Apache-2.0", "author": "Adobe", @@ -19,17 +19,15 @@ "./package.json": "./package.json", "./dist/*": "./dist/*", "./index.css": "./dist/index.css", - "./index-*.css": "./dist/index-*.css", "./metadata.json": "./dist/metadata.json", - "./themes/*": "./dist/themes/*", "./stories/*": "./stories/*" }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/colorarea": ">=7.0.0 <8.0.0", - "@spectrum-css/colorhandle": ">=10.0.0 <11.0.0", - "@spectrum-css/colorloupe": ">=7.0.0 <8.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/colorarea": ">=8.0.0-next.0", + "@spectrum-css/colorhandle": ">=11.0.0-next.0", + "@spectrum-css/colorloupe": ">=8.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/colorarea": { @@ -46,10 +44,10 @@ } }, "devDependencies": { - "@spectrum-css/colorarea": "7.2.0", - "@spectrum-css/colorhandle": "10.2.0", - "@spectrum-css/colorloupe": "7.2.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/colorarea": "8.0.0-next.2", + "@spectrum-css/colorhandle": "11.0.0-next.2", + "@spectrum-css/colorloupe": "8.0.0-next.1", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/colorwheel/stories/colorwheel.stories.js b/components/colorwheel/stories/colorwheel.stories.js index 15bba48a20a..f55a704ff03 100644 --- a/components/colorwheel/stories/colorwheel.stories.js +++ b/components/colorwheel/stories/colorwheel.stories.js @@ -23,7 +23,16 @@ export default { if: { arg: "isDisabled", truthy: false }, }, isWithColorArea: { - name: "With Color Area", + name: "With color area", + type: { name: "boolean" }, + table: { + type: { summary: "boolean" }, + category: "State", + }, + control: "boolean", + }, + isWithColorLoupe: { + name: "With color loupe", type: { name: "boolean" }, table: { type: { summary: "boolean" }, @@ -44,6 +53,7 @@ export default { isDisabled: false, isFocused: false, isWithColorArea: false, + isWithColorLoupe: true, selectedColor: "rgba(255, 0, 0, 50%)", }, parameters: { @@ -53,12 +63,40 @@ export default { }, packageJson, metadata, + status: { + type: "migrated", + }, }, + tags: ["migrated"], }; export const Default = ColorWheelGroup.bind({}); Default.args = {}; +/** + * By default, the color wheel has both a fixed size and a minimum size. The color wheel may be displayed at custom sizes by setting some of its modifiable custom properties. Below, the wheel is displayed at `300px` with the following mod values: + * ``` + * "--mod-colorwheel-inline-size": "300px", + * "--mod-colorwheel-block-size": "300px", + * "--mod-colorwheel-track-width": "30px", + * "--mod-colorwheel-path": '"M 149 149 m -149 0 a 149 149 0 1 0 298 0 a 149 149 0 1 0 -298 0 M 149 149 m -121 0 a 121 121 0 1 0 242 0 a 121 121 0 1 0 -242 0"', + * ``` + */ +export const CustomSizing = Template.bind({}); +CustomSizing.tags = ["!dev"]; +CustomSizing.args = { + customStyles: { + "--mod-colorwheel-inline-size": "300px", + "--mod-colorwheel-block-size": "300px", + "--mod-colorwheel-track-width": "30px", + "--mod-colorwheel-path": "\"M 149 149 m -149 0 a 149 149 0 1 0 298 0 a 149 149 0 1 0 -298 0 M 149 149 m -121 0 a 121 121 0 1 0 242 0 a 121 121 0 1 0 -242 0\"", + } +}; +CustomSizing.parameters = { + chromatic: { disableSnapshot: true }, +}; + + // ********* DOCS ONLY ********* // export const Disabled = Template.bind({}); Disabled.tags = ["!dev"]; @@ -76,7 +114,9 @@ Disabled.parameters = { * * The `.spectrum-colorwheel-colorarea-container-size` is hard coded to position the color area within the color wheel using `.spectrum-color-wheel-color-area-margin`. Implementations using JS can calculate the container size with `Math.sqrt(2 * R * R)`, where `R` is the inner radius as calculated for the clip paths. * - * `.spectrum-colorwheel-path`, `.spectrum-colorwheel-path-borders` and `.spectrum-colorwheel-colorarea-container` are hard coded in CSS, and include token values as custom CSS variables so they can be accessed with JS. To use and calculate these values, implementations should consider: +* Implementations should factor in the value of `--spectrum-color-wheel-color-area-margin`, as illustrated in the token specs, when calculating the size of the color area relative to the color wheel that contains it. + * + * `--spectrum-colorwheel-path` and `--spectrum-colorwheel-colorarea-container-size` are hard coded in CSS, and include token values as custom CSS variables so they can be accessed with JS. To use and calculate these values, implementations should consider: * ``` * const wheel = document.querySelector(".spectrum-ColorWheel-wheel") * getComputedStyle(wheel).getPropertyValue('--track-width') diff --git a/components/colorwheel/stories/colorwheel.test.js b/components/colorwheel/stories/colorwheel.test.js index 7271a8d0808..9bea3ef333c 100644 --- a/components/colorwheel/stories/colorwheel.test.js +++ b/components/colorwheel/stories/colorwheel.test.js @@ -11,6 +11,19 @@ export const ColorWheelGroup = Variants({ testHeading: "With color area", isWithColorArea: true, }, + { + testHeading: "Without color loupe", + isWithColorLoupe: false, + }, + { + testHeading: "Custom sizing", + customStyles: { + "--mod-colorwheel-inline-size": "300px", + "--mod-colorwheel-block-size": "300px", + "--mod-colorwheel-track-width": "30px", + "--mod-colorwheel-path": "\"M 149 149 m -149 0 a 149 149 0 1 0 298 0 a 149 149 0 1 0 -298 0 M 149 149 m -121 0 a 121 121 0 1 0 242 0 a 121 121 0 1 0 -242 0\"", + }, + } ], stateData: [ { diff --git a/components/colorwheel/stories/template.js b/components/colorwheel/stories/template.js index 851150ffd37..fe46f3ef157 100644 --- a/components/colorwheel/stories/template.js +++ b/components/colorwheel/stories/template.js @@ -2,12 +2,10 @@ import { Template as ColorArea } from "@spectrum-css/colorarea/stories/template. import { Template as ColorHandle } from "@spectrum-css/colorhandle/stories/template.js"; import { html } from "lit"; import { classMap } from "lit/directives/class-map.js"; +import { styleMap } from "lit/directives/style-map.js"; import { when } from "lit/directives/when.js"; import "../index.css"; -import "../themes/spectrum.css"; -/* Must be imported last */ -import "../themes/express.css"; export const Template = ({ rootClass = "spectrum-ColorWheel", @@ -15,16 +13,21 @@ export const Template = ({ isDisabled = false, isFocused = false, isWithColorArea = false, + isWithColorLoupe = true, colorHandleStyle = {}, selectedColor = "rgba(255, 0, 0, 50%)", + customStyles = {}, } = {}, context = {}) => { return html` -
    ({ ...a, [c]: true }), {}), - })}> +
    ({ ...a, [c]: true }), {}), + })} + style=${styleMap(customStyles)} + >
    ${when(isWithColorArea, () => html` @@ -40,20 +43,16 @@ export const Template = ({
    -
    -
    + })}>
    ${ColorHandle({ isDisabled, isFocused, customClasses: [`${rootClass}-handle`], selectedColor, customStyles: colorHandleStyle, + isWithColorLoupe, }, context)}
    diff --git a/components/colorwheel/themes/express.css b/components/colorwheel/themes/express.css deleted file mode 100644 index 9fd550418f2..00000000000 --- a/components/colorwheel/themes/express.css +++ /dev/null @@ -1,16 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--express */ - -@import "./spectrum.css"; diff --git a/components/colorwheel/themes/spectrum-two.css b/components/colorwheel/themes/spectrum-two.css deleted file mode 100644 index b80c228ebb8..00000000000 --- a/components/colorwheel/themes/spectrum-two.css +++ /dev/null @@ -1,18 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -@container style(--system: spectrum) { - .spectrum-ColorWheel { - --spectrum-colorwheel-border-color: var(--spectrum-transparent-black-300); - } -} diff --git a/components/colorwheel/themes/spectrum.css b/components/colorwheel/themes/spectrum.css deleted file mode 100644 index 9c47a280a66..00000000000 --- a/components/colorwheel/themes/spectrum.css +++ /dev/null @@ -1,22 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--legacy */ - -@import "./spectrum-two.css"; - -@container style(--system: legacy) { - .spectrum-ColorWheel { - --spectrum-colorwheel-border-color: var(--spectrum-transparent-black-200); - } -} diff --git a/components/combobox/CHANGELOG.md b/components/combobox/CHANGELOG.md index 0f945d32ef2..375c470e12c 100644 --- a/components/combobox/CHANGELOG.md +++ b/components/combobox/CHANGELOG.md @@ -1,5 +1,76 @@ # Change log +## 5.0.0-next.4 + +### Patch Changes + +📝 [#4113](https://github.com/adobe/spectrum-css/pull/4113) [`cf4fc1a`](https://github.com/adobe/spectrum-css/commit/cf4fc1a01d23ba810f45a903ecc29a5c8aae33d1) Thanks [@castastrophe](https://github.com/castastrophe)! + +## Minor linting fixes + +- Removed unused custom properties across multiple components +- Fixed color function notation by converting `rgba()` to `rgb()` where appropriate +- Removed duplicate custom property declarations +- Fixed deprecated CSS properties (e.g., `word-wrap` → `overflow-wrap`) +- Removed unnecessary stylelint-disable comments + +_No visual or functional changes to components._ + +## 5.0.0-next.3 + +### Major Changes + +📝 [#4014](https://github.com/adobe/spectrum-css/pull/4014) [`35c066b`](https://github.com/adobe/spectrum-css/commit/35c066b29c311b1bfcf4507075f13b41222ffc84) Thanks [@castastrophe](https://github.com/castastrophe)! + +This update removes the `dir` attribute polyfill (served via a PostCSS transform to compiled assets) as the fallback is no longer necessary. The`dir` attribute support is available in all supported browsers and has been tested to correctly inherit inside web component shadow DOMs. This is a breaking change **only** to those relying on the `dir` attribute being present for styling, however, the `:dir` pseudo will correctly inherit values from their containers. To correctly determine the `dir` value of a node using JavaScript, you can use `getComputedStyle(node).direction`. + +## 5.0.0-next.2 + +### Major Changes + +- [#3683](https://github.com/adobe/spectrum-css/pull/3683) [`e309613`](https://github.com/adobe/spectrum-css/commit/e309613c356ba5586b65cdcc26787d161a3b39e1) Thanks [@aramos-adobe](https://github.com/aramos-adobe)! - ### Combobox S2 Migration + + #### New Changes + - Removed quiet styling variant + - Updated corner radius to match S2 specifications + - Changed outline thickness for better visibility + - Replaced picker button with in-field button component + - Added help text along with invalid state + - Modified the WHCM invalid/error state in help text + + ### New tokens + + `--spectrum-combobox-font-weight` + `--spectrum-combobox-line-height-cjk` + `--spectrum-combobox-spacing-alert-icon-to-text` + `--spectrum-combobox-spacing-to-help-text` + + ### New mods + + `--mod-combobox-line-height-cjk` + `--mod-combobox-popover-animation-distance` + `--mod-combobox-spacing-alert-icon-to-text` + `--mod-combobox-spacing-to-help-text` + `--mod-combobox-textfield-background-color` + +## 5.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + - @spectrum-css/progresscircle@6.0.0-next.0 + +## 5.0.0-next.0 + +### Patch Changes + +- Updated dependencies: + - @spectrum-css/menu@10.0.0-next.0 + - @spectrum-css/pickerbutton@7.0.0-next.0 + - @spectrum-css/popover@9.0.0-next.0 + - @spectrum-css/textfield@9.0.0-next.0 + ## 4.2.0 ### Minor Changes @@ -12,10 +83,13 @@ Ensure accurate exports are present for each component. Specifically, adding `th ### Patch Changes -- [#3609](https://github.com/adobe/spectrum-css/pull/3609) [`851be13`](https://github.com/adobe/spectrum-css/commit/851be13295f9d42d548894fee6626009f053de61) Thanks [@marissahuysentruyt](https://github.com/marissahuysentruyt)! - Fast follow fixes for combobox - - corrects container query for the `--system` reference to "legacy" in the combobox/themes/spectrum.css file - - corrects the border colors for several combobox states including focus, keyboardFocus, focus+hover, disabled, read-only for all themes - - adds `--spectrum-combobox-readonly-input-border-color: var(--spectrum-gray-400);` to express.css theme so that the default border and read-only border colors are the same +📝 [#3609](https://github.com/adobe/spectrum-css/pull/3609) [`851be13`](https://github.com/adobe/spectrum-css/commit/851be13295f9d42d548894fee6626009f053de61) Thanks [@marissahuysentruyt](https://github.com/marissahuysentruyt)! + +#### Fast follow fixes for combobox + +- corrects container query for the `--system` reference to "legacy" in the combobox/themes/spectrum.css file +- corrects the border colors for several combobox states including focus, keyboardFocus, focus+hover, disabled, read-only for all themes +- adds `--spectrum-combobox-readonly-input-border-color: var(--spectrum-gray-400);` to express.css theme so that the default border and read-only border colors are the same ## 4.1.1 diff --git a/components/combobox/dist/metadata.json b/components/combobox/dist/metadata.json index bdf2685d75f..ee4f97630eb 100644 --- a/components/combobox/dist/metadata.json +++ b/components/combobox/dist/metadata.json @@ -4,21 +4,14 @@ ".spectrum-Combobox", ".spectrum-Combobox .spectrum-Combobox-button.spectrum-PickerButton--quiet .spectrum-PickerButton-fill", ".spectrum-Combobox .spectrum-Combobox-button.spectrum-PickerButton--quiet .spectrum-PickerButton-icon", - ".spectrum-Combobox .spectrum-Popover.is-open", - ".spectrum-Combobox--quiet", - ".spectrum-Combobox--quiet .spectrum-Combobox-input", - ".spectrum-Combobox--quiet .spectrum-Combobox-textfield.is-invalid .spectrum-Combobox-input", - ".spectrum-Combobox--quiet .spectrum-Combobox-textfield.is-invalid .spectrum-Textfield-validationIcon", - ".spectrum-Combobox--quiet .spectrum-Combobox-textfield.is-loading .spectrum-Combobox-input", - ".spectrum-Combobox--quiet .spectrum-Combobox-textfield.is-readOnly .spectrum-Combobox-input:read-only", - ".spectrum-Combobox--quiet .spectrum-Combobox-textfield.is-readOnly.is-disabled .spectrum-Combobox-input:read-only", - ".spectrum-Combobox--quiet .spectrum-Combobox-textfield.is-readOnly.is-invalid > .spectrum-Combobox-input:read-only", - ".spectrum-Combobox--quiet.spectrum-Combobox--sizeL", - ".spectrum-Combobox--quiet.spectrum-Combobox--sizeM", - ".spectrum-Combobox--quiet.spectrum-Combobox--sizeS", - ".spectrum-Combobox--quiet.spectrum-Combobox--sizeXL", + ".spectrum-Combobox .spectrum-Combobox-content", + ".spectrum-Combobox .spectrum-Combobox-label", + ".spectrum-Combobox .spectrum-Combobox-popover", + ".spectrum-Combobox--sideLabel .spectrum-Combobox-content", + ".spectrum-Combobox--sideLabel .spectrum-Combobox-helptext", + ".spectrum-Combobox--sideLabel .spectrum-Combobox-label", + ".spectrum-Combobox--sideLabel .spectrum-Combobox-textfield", ".spectrum-Combobox--sizeL", - ".spectrum-Combobox--sizeM", ".spectrum-Combobox--sizeS", ".spectrum-Combobox--sizeXL", ".spectrum-Combobox-button", @@ -40,15 +33,33 @@ ".spectrum-Combobox-button:not(:disabled, .is-invalid, .spectrum-PickerButton--quiet):focus-visible", ".spectrum-Combobox-button:not(:disabled, .is-invalid, .spectrum-PickerButton--quiet):focus:hover", ".spectrum-Combobox-button:not(:disabled, .is-invalid, .spectrum-PickerButton--quiet):hover", + ".spectrum-Combobox-content", + ".spectrum-Combobox-helptext", + ".spectrum-Combobox-helptext .spectrum-HelpText-text", ".spectrum-Combobox-input", + ".spectrum-Combobox-input.spectrum-Combobox-autocomplete", + ".spectrum-Combobox-input.spectrum-Combobox-autocomplete::selection", + ".spectrum-Combobox-input:-internal-autofill-selected", + ".spectrum-Combobox-input:-internal-autofill-selected::selection", + ".spectrum-Combobox-input:-webkit-autofill", + ".spectrum-Combobox-input:-webkit-autofill::selection", + ".spectrum-Combobox-input:-webkit-autofill:active", + ".spectrum-Combobox-input:-webkit-autofill:active::selection", + ".spectrum-Combobox-input:-webkit-autofill:focus", + ".spectrum-Combobox-input:-webkit-autofill:focus::selection", + ".spectrum-Combobox-input:-webkit-autofill:hover", + ".spectrum-Combobox-input:-webkit-autofill:hover::selection", ".spectrum-Combobox-input::placeholder", ".spectrum-Combobox-input:active", ".spectrum-Combobox-input:focus", ".spectrum-Combobox-input:focus:hover", ".spectrum-Combobox-input:hover", + ".spectrum-Combobox-input:lang(ja)", + ".spectrum-Combobox-input:lang(ko)", + ".spectrum-Combobox-input:lang(zh)", + ".spectrum-Combobox-label", ".spectrum-Combobox-progress-circle", ".spectrum-Combobox-progress-circle:dir(rtl)", - ".spectrum-Combobox-textfield", ".spectrum-Combobox-textfield.is-focused .spectrum-Combobox-input", ".spectrum-Combobox-textfield.is-focused .spectrum-Combobox-input:hover", ".spectrum-Combobox-textfield.is-invalid .spectrum-Combobox-input", @@ -62,12 +73,12 @@ ".spectrum-Combobox.is-focused:hover .spectrum-Combobox-button:not(:disabled, .is-invalid, .spectrum-PickerButton--quiet)", ".spectrum-Combobox.is-keyboardFocused .spectrum-Combobox-button.is-invalid:not(:disabled, .spectrum-PickerButton--quiet)", ".spectrum-Combobox.is-keyboardFocused .spectrum-Combobox-button:not(:disabled, .is-invalid, .spectrum-PickerButton--quiet)", - ".spectrum-Combobox.is-readOnly.is-disabled:not(.spectrum-Combobox--quiet) .spectrum-Combobox-input:read-only", - ".spectrum-Combobox.is-readOnly.is-disabled:not(.spectrum-Combobox--quiet) .spectrum-Combobox-input:read-only:hover", - ".spectrum-Combobox.is-readOnly.is-invalid:not(.spectrum-Combobox--quiet) .spectrum-Combobox-input:read-only", - ".spectrum-Combobox.is-readOnly:not(.spectrum-Combobox--quiet) .spectrum-Combobox-input:read-only", - ".spectrum-Combobox.is-readOnly:not(.spectrum-Combobox--quiet) .spectrum-Combobox-input:read-only:hover", - ".spectrum-Combobox.is-readOnly:not(.spectrum-Combobox--quiet) .spectrum-Combobox-textfield.is-keyboardFocused .spectrum-Combobox-input", + ".spectrum-Combobox.is-readOnly .spectrum-Combobox-input:read-only", + ".spectrum-Combobox.is-readOnly .spectrum-Combobox-input:read-only:hover", + ".spectrum-Combobox.is-readOnly .spectrum-Combobox-textfield.is-keyboardFocused .spectrum-Combobox-input", + ".spectrum-Combobox.is-readOnly.is-disabled .spectrum-Combobox-input:read-only", + ".spectrum-Combobox.is-readOnly.is-disabled .spectrum-Combobox-input:read-only:hover", + ".spectrum-Combobox.is-readOnly.is-invalid .spectrum-Combobox-input:read-only", ".spectrum-Combobox:has(:active) .spectrum-Combobox-button.is-invalid:not(:disabled, .spectrum-PickerButton--quiet)", ".spectrum-Combobox:has(:active) .spectrum-Combobox-button:not(:disabled, .is-invalid, .spectrum-PickerButton--quiet)", ".spectrum-Combobox:has(:focus) .spectrum-Combobox-button.is-invalid:not(:disabled, .spectrum-PickerButton--quiet)", @@ -78,8 +89,7 @@ ".spectrum-Combobox:hover:has(:focus) .spectrum-Combobox-button:not(:disabled, .is-invalid, .spectrum-PickerButton--quiet)", ".spectrum-Textfield.is-disabled .spectrum-Textfield-validationIcon", ".spectrum-Textfield.is-loading .spectrum-Textfield-validationIcon", - ".spectrum-Textfield.is-readOnly .spectrum-Textfield-validationIcon", - "[dir=\"rtl\"] .spectrum-Combobox-progress-circle" + ".spectrum-Textfield.is-readOnly .spectrum-Textfield-validationIcon" ], "modifiers": [ "--mod-combobox-alert-icon-color", @@ -90,7 +100,7 @@ "--mod-combobox-background-color-hover", "--mod-combobox-background-color-key-focus", "--mod-combobox-block-size", - "--mod-combobox-block-spacing-edge-to-alert", + "--mod-combobox-block-spacing-edge-to-icon", "--mod-combobox-block-spacing-edge-to-progress-circle", "--mod-combobox-border-color-default", "--mod-combobox-border-color-disabled", @@ -105,7 +115,6 @@ "--mod-combobox-border-color-key-focus", "--mod-combobox-border-radius", "--mod-combobox-border-width", - "--mod-combobox-button-inline-offset", "--mod-combobox-button-width", "--mod-combobox-focus-indicator-color", "--mod-combobox-focus-indicator-gap", @@ -118,34 +127,32 @@ "--mod-combobox-font-color-key-focus", "--mod-combobox-font-color-placeholder", "--mod-combobox-font-family", - "--mod-combobox-font-size", - "--mod-combobox-font-style", - "--mod-combobox-font-weight", "--mod-combobox-icon-size", "--mod-combobox-inline-size", "--mod-combobox-line-height", + "--mod-combobox-line-height-cjk", "--mod-combobox-min-inline-size", + "--mod-combobox-popover-animation-distance", "--mod-combobox-readonly-border-color-disabled", - "--mod-combobox-readonly-input-border-color", + "--mod-combobox-spacing-alert-icon-to-text", "--mod-combobox-spacing-block-end-edge-to-text", "--mod-combobox-spacing-block-start-edge-to-text", - "--mod-combobox-spacing-edge-to-menu", - "--mod-combobox-spacing-inline-end-edge-to-text", "--mod-combobox-spacing-inline-icon-to-button", + "--mod-combobox-spacing-inline-icon-to-text", "--mod-combobox-spacing-inline-start-edge-to-text", - "--mod-combobox-spacing-label-to-combobox" + "--mod-combobox-spacing-label-to-combobox", + "--mod-combobox-spacing-side-label-to-field", + "--mod-combobox-spacing-to-help-text", + "--mod-combobox-textfield-background-color" ], "component": [ "--spectrum-combo-box-minimum-width-multiplier", - "--spectrum-combo-box-quiet-minimum-width-multiplier", - "--spectrum-combo-box-visual-to-field-button-extra-large", - "--spectrum-combo-box-visual-to-field-button-large", - "--spectrum-combo-box-visual-to-field-button-medium", - "--spectrum-combo-box-visual-to-field-button-quiet", - "--spectrum-combo-box-visual-to-field-button-small", + "--spectrum-combo-box-visual-to-field-button", + "--spectrum-combobox-background-color-autofill", + "--spectrum-combobox-background-color-default", "--spectrum-combobox-background-color-disabled", "--spectrum-combobox-block-size", - "--spectrum-combobox-block-spacing-edge-to-alert", + "--spectrum-combobox-block-spacing-edge-to-icon", "--spectrum-combobox-block-spacing-edge-to-progress-circle", "--spectrum-combobox-border-color-default", "--spectrum-combobox-border-color-disabled", @@ -160,16 +167,17 @@ "--spectrum-combobox-border-color-key-focus", "--spectrum-combobox-border-radius", "--spectrum-combobox-border-width", - "--spectrum-combobox-button-inline-offset", "--spectrum-combobox-button-width", "--spectrum-combobox-focus-indicator-color", "--spectrum-combobox-focus-indicator-gap", "--spectrum-combobox-focus-indicator-thickness", "--spectrum-combobox-font-size", "--spectrum-combobox-font-style", + "--spectrum-combobox-font-weight", "--spectrum-combobox-icon-size", "--spectrum-combobox-inline-size", "--spectrum-combobox-line-height", + "--spectrum-combobox-line-height-cjk", "--spectrum-combobox-min-inline-size", "--spectrum-combobox-readonly-background-color-disabled", "--spectrum-combobox-readonly-border-color-disabled", @@ -179,14 +187,17 @@ "--spectrum-combobox-readonly-text-color-disabled", "--spectrum-combobox-spacing-block-end-edge-to-text", "--spectrum-combobox-spacing-block-start-edge-to-text", - "--spectrum-combobox-spacing-edge-to-menu", - "--spectrum-combobox-spacing-inline-end-edge-to-text", "--spectrum-combobox-spacing-inline-icon-to-button", + "--spectrum-combobox-spacing-inline-icon-to-text", "--spectrum-combobox-spacing-inline-start-edge-to-text", - "--spectrum-combobox-spacing-label-to-combobox" + "--spectrum-combobox-spacing-label-to-combobox", + "--spectrum-combobox-spacing-side-label-to-field", + "--spectrum-combobox-spacing-to-help-text" ], "global": [ - "--spectrum-border-width-100", + "--spectrum-blue-900-rgb", + "--spectrum-border-width-200", + "--spectrum-cjk-line-height-100", "--spectrum-component-bottom-to-text-100", "--spectrum-component-bottom-to-text-200", "--spectrum-component-bottom-to-text-300", @@ -207,26 +218,27 @@ "--spectrum-component-top-to-text-200", "--spectrum-component-top-to-text-300", "--spectrum-component-top-to-text-75", - "--spectrum-corner-radius-100", + "--spectrum-component-top-to-workflow-icon-100", + "--spectrum-component-top-to-workflow-icon-200", + "--spectrum-component-top-to-workflow-icon-300", + "--spectrum-component-top-to-workflow-icon-75", + "--spectrum-corner-radius-medium-size-extra-large", + "--spectrum-corner-radius-medium-size-large", + "--spectrum-corner-radius-medium-size-medium", + "--spectrum-corner-radius-medium-size-small", "--spectrum-default-font-style", "--spectrum-disabled-background-color", "--spectrum-disabled-border-color", "--spectrum-disabled-content-color", - "--spectrum-field-edge-to-text-quiet", "--spectrum-field-label-to-component", - "--spectrum-field-label-to-component-quiet-extra-large", - "--spectrum-field-label-to-component-quiet-large", - "--spectrum-field-label-to-component-quiet-medium", - "--spectrum-field-label-to-component-quiet-small", - "--spectrum-field-top-to-alert-icon-extra-large", - "--spectrum-field-top-to-alert-icon-large", - "--spectrum-field-top-to-alert-icon-medium", - "--spectrum-field-top-to-alert-icon-small", "--spectrum-field-top-to-progress-circle-extra-large", "--spectrum-field-top-to-progress-circle-large", "--spectrum-field-top-to-progress-circle-medium", "--spectrum-field-top-to-progress-circle-small", - "--spectrum-field-width", + "--spectrum-field-width-extra-large", + "--spectrum-field-width-large", + "--spectrum-field-width-medium", + "--spectrum-field-width-small", "--spectrum-focus-indicator-color", "--spectrum-focus-indicator-gap", "--spectrum-focus-indicator-thickness", @@ -235,41 +247,38 @@ "--spectrum-font-size-300", "--spectrum-font-size-75", "--spectrum-gray-25", - "--spectrum-gray-50", - "--spectrum-gray-500", - "--spectrum-gray-600", + "--spectrum-gray-300", + "--spectrum-gray-400", "--spectrum-gray-800", "--spectrum-gray-900", + "--spectrum-help-text-to-component", "--spectrum-line-height-100", "--spectrum-negative-border-color-default", "--spectrum-negative-border-color-focus", "--spectrum-negative-border-color-focus-hover", "--spectrum-negative-border-color-hover", "--spectrum-negative-border-color-key-focus", + "--spectrum-neutral-content-color-default", + "--spectrum-regular-font-weight", + "--spectrum-spacing-200", + "--spectrum-text-to-visual-100", + "--spectrum-text-to-visual-200", + "--spectrum-text-to-visual-300", + "--spectrum-text-to-visual-75", "--spectrum-workflow-icon-size-100", "--spectrum-workflow-icon-size-200", "--spectrum-workflow-icon-size-300", "--spectrum-workflow-icon-size-75" ], - "system-theme": [ - "--system-combobox-background-color-disabled", - "--system-combobox-border-color-default", - "--system-combobox-border-color-disabled", - "--system-combobox-border-color-focus", - "--system-combobox-border-color-focus-hover", - "--system-combobox-border-color-hover", - "--system-combobox-border-color-key-focus", - "--system-combobox-readonly-input-border-color" - ], "passthroughs": [ + "--mod-divider-inline-minimum-size", "--mod-picker-button-background-color", "--mod-picker-button-background-color-disabled", - "--mod-picker-button-background-color-quiet", "--mod-picker-button-border-color", "--mod-picker-button-border-color-disabled", - "--mod-picker-button-border-color-quiet", "--mod-picker-button-border-width", "--mod-picker-button-font-color-disabled", + "--mod-popover-animation-distance", "--mod-textfield-background-color", "--mod-textfield-background-color-disabled", "--mod-textfield-border-color", @@ -284,12 +293,17 @@ "--mod-textfield-border-color-invalid-keyboard-focus", "--mod-textfield-border-color-keyboard-focus", "--mod-textfield-border-width", + "--mod-textfield-corner-radius", "--mod-textfield-focus-indicator-color", "--mod-textfield-focus-indicator-gap", "--mod-textfield-focus-indicator-width", "--mod-textfield-font-family", + "--mod-textfield-font-size", + "--mod-textfield-font-style", "--mod-textfield-font-weight", "--mod-textfield-icon-color-invalid", + "--mod-textfield-spacing-block-end", + "--mod-textfield-spacing-block-start", "--mod-textfield-text-color-default", "--mod-textfield-text-color-disabled", "--mod-textfield-text-color-focus", @@ -298,9 +312,9 @@ "--mod-textfield-text-color-keyboard-focus" ], "high-contrast": [ + "--highcontrast-combobox-background-color-default", "--highcontrast-combobox-border-color-highlight", "--highcontrast-combobox-border-color-invalid", - "--highcontrast-textfield-border-color-invalid-default", - "--highcontrast-textfield-text-color-disabled" + "--highcontrast-combobox-readonly-border-color" ] } diff --git a/components/combobox/index.css b/components/combobox/index.css index 1718cb5d750..eab2bd4feb8 100644 --- a/components/combobox/index.css +++ b/components/combobox/index.css @@ -11,36 +11,49 @@ * governing permissions and limitations under the License. */ -@import "./themes/spectrum-two.css"; - .spectrum-Combobox { - --spectrum-combobox-inline-size: var(--spectrum-field-width); --spectrum-combobox-block-size: var(--spectrum-component-height-100); - --spectrum-combobox-min-inline-size: calc(var(--spectrum-combo-box-minimum-width-multiplier) * var(--spectrum-combobox-block-size)); - --spectrum-combobox-button-width: var(--spectrum-combobox-block-size); --spectrum-combobox-icon-size: var(--spectrum-workflow-icon-size-100); --spectrum-combobox-font-size: var(--spectrum-font-size-100); + --spectrum-combobox-line-height: var(--spectrum-line-height-100); - --spectrum-combobox-spacing-inline-icon-to-button: var(--spectrum-combo-box-visual-to-field-button-medium); + --spectrum-combobox-spacing-inline-icon-to-button: var(--spectrum-combo-box-visual-to-field-button); --spectrum-combobox-block-spacing-edge-to-progress-circle: var(--spectrum-field-top-to-progress-circle-medium); - --spectrum-combobox-block-spacing-edge-to-alert: var(--spectrum-field-top-to-alert-icon-medium); - --spectrum-combobox-spacing-edge-to-menu: var(--spectrum-component-to-menu-medium); + --spectrum-combobox-block-spacing-edge-to-icon: var(--spectrum-component-top-to-workflow-icon-100); --spectrum-combobox-spacing-block-start-edge-to-text: var(--spectrum-component-top-to-text-100); --spectrum-combobox-spacing-block-end-edge-to-text: var(--spectrum-component-bottom-to-text-100); --spectrum-combobox-spacing-inline-start-edge-to-text: var(--spectrum-component-edge-to-text-100); - --spectrum-combobox-spacing-inline-end-edge-to-text: var(--spectrum-component-edge-to-text-100); + --spectrum-combobox-spacing-inline-icon-to-text: var(--spectrum-text-to-visual-100); + + --spectrum-combobox-spacing-to-help-text: var(--spectrum-help-text-to-component); + + --spectrum-combobox-inline-size: var(--spectrum-field-width-medium); + --spectrum-combobox-min-inline-size: calc(var(--spectrum-combo-box-minimum-width-multiplier) * var(--spectrum-combobox-block-size)); + --spectrum-combobox-button-width: var(--spectrum-combobox-block-size); --spectrum-combobox-focus-indicator-thickness: var(--spectrum-focus-indicator-thickness); --spectrum-combobox-focus-indicator-gap: var(--spectrum-focus-indicator-gap); --spectrum-combobox-focus-indicator-color: var(--spectrum-focus-indicator-color); - --spectrum-combobox-border-radius: var(--spectrum-corner-radius-100); - --spectrum-combobox-border-width: var(--spectrum-border-width-100); + --spectrum-combobox-border-radius: var(--spectrum-corner-radius-medium-size-medium); + --spectrum-combobox-border-width: var(--spectrum-border-width-200); --spectrum-combobox-spacing-label-to-combobox: var(--spectrum-field-label-to-component); + --spectrum-combobox-spacing-side-label-to-field: var(--spectrum-spacing-200); --spectrum-combobox-font-style: var(--spectrum-default-font-style); - --spectrum-combobox-line-height: var(--spectrum-line-height-100); + --spectrum-combobox-font-weight: var(--spectrum-regular-font-weight); + --spectrum-combobox-line-height-cjk: var(--spectrum-cjk-line-height-100); + + --spectrum-combobox-background-color-disabled: var(--spectrum-gray-25); + + --spectrum-combobox-background-color-default: var(--spectrum-gray-25); + --spectrum-combobox-border-color-default: var(--spectrum-gray-300); + --spectrum-combobox-border-color-hover: var(--spectrum-gray-400); + --spectrum-combobox-border-color-focus: var(--spectrum-gray-800); + --spectrum-combobox-border-color-focus-hover: var(--spectrum-gray-900); + --spectrum-combobox-border-color-key-focus: var(--spectrum-gray-800); + --spectrum-combobox-border-color-disabled: var(--spectrum-disabled-border-color); --spectrum-combobox-border-color-invalid-default: var(--spectrum-negative-border-color-default); --spectrum-combobox-border-color-invalid-hover: var(--spectrum-negative-border-color-hover); @@ -48,6 +61,10 @@ --spectrum-combobox-border-color-invalid-focus-hover: var(--spectrum-negative-border-color-focus-hover); --spectrum-combobox-border-color-invalid-key-focus: var(--spectrum-negative-border-color-key-focus); + --spectrum-combobox-background-color-autofill: rgb(var(--spectrum-blue-900-rgb), 0.3); + + --mod-combobox-popover-animation-distance: var(--spectrum-component-to-menu-medium); + /* @passthroughs start -- settings for nested Textfield component */ --mod-textfield-focus-indicator-gap: var(--mod-combobox-focus-indicator-gap, var(--spectrum-combobox-focus-indicator-gap)); --mod-textfield-focus-indicator-width: var(--mod-combobox-focus-indicator-thickness, var(--spectrum-combobox-focus-indicator-thickness)); @@ -57,8 +74,11 @@ --mod-textfield-background-color-disabled: var(--mod-combobox-background-color-disabled, var(--spectrum-combobox-background-color-disabled)); --mod-textfield-font-family: var(--mod-combobox-font-family); - --mod-textfield-font-weight: var(--mod-combobox-font-weight); - + --mod-textfield-font-weight: var(--spectrum-combobox-font-weight); + --mod-textfield-font-size: var(--spectrum-combobox-font-size); + --mod-textfield-font-style: var(--spectrum-combobox-font-style); + --mod-textfield-spacing-block-start: var(--mod-combobox-spacing-block-start-edge-to-text, var(--spectrum-combobox-spacing-block-start-edge-to-text)); + --mod-textfield-spacing-block-end: var(--mod-combobox-spacing-block-end-edge-to-text, var(--spectrum-combobox-spacing-block-end-edge-to-text)); --mod-textfield-text-color-default: var(--mod-combobox-font-color-default); --mod-textfield-text-color-hover: var(--mod-combobox-font-color-hover); --mod-textfield-text-color-focus: var(--mod-combobox-font-color-focus); @@ -73,6 +93,7 @@ --mod-textfield-border-color-focus-hover: var(--mod-combobox-border-color-focus-hover, var(--spectrum-combobox-border-color-focus-hover)); --mod-textfield-border-color-hover: var(--mod-combobox-border-color-hover, var(--spectrum-combobox-border-color-hover)); --mod-textfield-border-color-keyboard-focus: var(--mod-combobox-border-color-key-focus, var(--spectrum-combobox-border-color-key-focus)); + --mod-textfield-corner-radius: var(--mod-combobox-border-radius, var(--spectrum-combobox-border-radius)); --mod-textfield-border-color-invalid-default: var(--mod-combobox-border-color-invalid-default, var(--spectrum-combobox-border-color-invalid-default)); --mod-textfield-border-color-invalid-hover: var(--mod-combobox-border-color-invalid-hover, var(--spectrum-combobox-border-color-invalid-hover)); @@ -93,27 +114,16 @@ /* @passthroughs end -- settings for nested Picker Button component */ /*** Read-only Colors ***/ - --spectrum-combobox-readonly-input-background-color: var(--spectrum-gray-50); + --spectrum-combobox-readonly-input-background-color: var(--spectrum-combobox-background-color-default); --spectrum-combobox-readonly-border-color-invalid-default: var(--spectrum-negative-border-color-default); --spectrum-combobox-readonly-background-color-disabled: var(--spectrum-disabled-background-color); --spectrum-combobox-readonly-text-color-disabled: var(--spectrum-disabled-content-color); --spectrum-combobox-readonly-border-color-disabled: var(--spectrum-disabled-border-color); -} - -.spectrum-Combobox, -.spectrum-Combobox--sizeM { - --spectrum-combobox-block-size: var(--spectrum-component-height-100); - --spectrum-combobox-icon-size: var(--spectrum-workflow-icon-size-100); - --spectrum-combobox-font-size: var(--spectrum-font-size-100); + --spectrum-combobox-readonly-input-border-color: var(--spectrum-combobox-border-color-default); - --spectrum-combobox-spacing-inline-icon-to-button: var(--spectrum-combo-box-visual-to-field-button-medium); - --spectrum-combobox-block-spacing-edge-to-progress-circle: var(--spectrum-field-top-to-progress-circle-medium); - --spectrum-combobox-block-spacing-edge-to-alert: var(--spectrum-field-top-to-alert-icon-medium); - --spectrum-combobox-spacing-edge-to-menu: var(--spectrum-component-to-menu-medium); - --spectrum-combobox-spacing-block-start-edge-to-text: var(--spectrum-component-top-to-text-100); - --spectrum-combobox-spacing-block-end-edge-to-text: var(--spectrum-component-bottom-to-text-100); - --spectrum-combobox-spacing-inline-start-edge-to-text: var(--spectrum-component-edge-to-text-100); - --spectrum-combobox-spacing-inline-end-edge-to-text: var(--spectrum-component-edge-to-text-100); + /* @passthroughs start -- settings for nested divider component */ + --mod-divider-inline-minimum-size: auto; + /* @passthroughs end -- settings for nested divider component */ } .spectrum-Combobox--sizeS { @@ -121,14 +131,15 @@ --spectrum-combobox-icon-size: var(--spectrum-workflow-icon-size-75); --spectrum-combobox-font-size: var(--spectrum-font-size-75); - --spectrum-combobox-spacing-inline-icon-to-button: var(--spectrum-combo-box-visual-to-field-button-small); --spectrum-combobox-block-spacing-edge-to-progress-circle: var(--spectrum-field-top-to-progress-circle-small); - --spectrum-combobox-block-spacing-edge-to-alert: var(--spectrum-field-top-to-alert-icon-small); - --spectrum-combobox-spacing-edge-to-menu: var(--spectrum-component-to-menu-small); + --spectrum-combobox-block-spacing-edge-to-icon: var(--spectrum-component-top-to-workflow-icon-75); --spectrum-combobox-spacing-block-start-edge-to-text: var(--spectrum-component-top-to-text-75); --spectrum-combobox-spacing-block-end-edge-to-text: var(--spectrum-component-bottom-to-text-75); --spectrum-combobox-spacing-inline-start-edge-to-text: var(--spectrum-component-edge-to-text-75); - --spectrum-combobox-spacing-inline-end-edge-to-text: var(--spectrum-component-edge-to-text-75); + --spectrum-combobox-spacing-inline-icon-to-text: var(--spectrum-text-to-visual-75); + --spectrum-combobox-inline-size: var(--spectrum-field-width-small); + --spectrum-combobox-border-radius: var(--spectrum-corner-radius-medium-size-small); + --mod-combobox-popover-animation-distance: var(--spectrum-component-to-menu-small); } .spectrum-Combobox--sizeL { @@ -136,14 +147,15 @@ --spectrum-combobox-icon-size: var(--spectrum-workflow-icon-size-200); --spectrum-combobox-font-size: var(--spectrum-font-size-200); - --spectrum-combobox-spacing-inline-icon-to-button: var(--spectrum-combo-box-visual-to-field-button-large); --spectrum-combobox-block-spacing-edge-to-progress-circle: var(--spectrum-field-top-to-progress-circle-large); - --spectrum-combobox-block-spacing-edge-to-alert: var(--spectrum-field-top-to-alert-icon-large); - --spectrum-combobox-spacing-edge-to-menu: var(--spectrum-component-to-menu-large); + --spectrum-combobox-block-spacing-edge-to-icon: var(--spectrum-component-top-to-workflow-icon-200); --spectrum-combobox-spacing-block-start-edge-to-text: var(--spectrum-component-top-to-text-200); --spectrum-combobox-spacing-block-end-edge-to-text: var(--spectrum-component-bottom-to-text-200); --spectrum-combobox-spacing-inline-start-edge-to-text: var(--spectrum-component-edge-to-text-200); - --spectrum-combobox-spacing-inline-end-edge-to-text: var(--spectrum-component-edge-to-text-200); + --spectrum-combobox-spacing-inline-icon-to-text: var(--spectrum-text-to-visual-200); + --spectrum-combobox-inline-size: var(--spectrum-field-width-large); + --spectrum-combobox-border-radius: var(--spectrum-corner-radius-medium-size-large); + --mod-combobox-popover-animation-distance: var(--spectrum-component-to-menu-large); } .spectrum-Combobox--sizeXL { @@ -151,80 +163,33 @@ --spectrum-combobox-icon-size: var(--spectrum-workflow-icon-size-300); --spectrum-combobox-font-size: var(--spectrum-font-size-300); - --spectrum-combobox-spacing-inline-icon-to-button: var(--spectrum-combo-box-visual-to-field-button-extra-large); --spectrum-combobox-block-spacing-edge-to-progress-circle: var(--spectrum-field-top-to-progress-circle-extra-large); - --spectrum-combobox-block-spacing-edge-to-alert: var(--spectrum-field-top-to-alert-icon-extra-large); - --spectrum-combobox-spacing-edge-to-menu: var(--spectrum-component-to-menu-extra-large); + --spectrum-combobox-block-spacing-edge-to-icon: var(--spectrum-component-top-to-workflow-icon-300); --spectrum-combobox-spacing-block-start-edge-to-text: var(--spectrum-component-top-to-text-300); --spectrum-combobox-spacing-block-end-edge-to-text: var(--spectrum-component-bottom-to-text-300); --spectrum-combobox-spacing-inline-start-edge-to-text: var(--spectrum-component-edge-to-text-300); - --spectrum-combobox-spacing-inline-end-edge-to-text: var(--spectrum-component-edge-to-text-300); -} - -.spectrum-Combobox--quiet { - --spectrum-combobox-min-inline-size: calc(var(--spectrum-combo-box-quiet-minimum-width-multiplier) * var(--spectrum-combobox-block-size)); - --spectrum-combobox-spacing-inline-icon-to-button: var(--spectrum-combo-box-visual-to-field-button-quiet); - --spectrum-combobox-spacing-inline-start-edge-to-text: var(--spectrum-field-edge-to-text-quiet); - --spectrum-combobox-spacing-label-to-combobox: var(--spectrum-field-label-to-component-quiet-medium); - --spectrum-combobox-button-inline-offset: calc((var(--mod-combobox-block-size, var(--spectrum-combobox-block-size)) / 2) - (var(--mod-combobox-icon-size, var(--spectrum-combobox-icon-size)) / 2)); - --mod-textfield-border-color-disabled: var(--mod-combobox-border-color-disabled, initial); - - &.spectrum-Combobox--sizeS { - --spectrum-combobox-spacing-label-to-combobox: var(--spectrum-field-label-to-component-quiet-small); - } - - &.spectrum-Combobox--sizeM { - --spectrum-combobox-spacing-label-to-combobox: var(--spectrum-field-label-to-component-quiet-medium); - } - - &.spectrum-Combobox--sizeL { - --spectrum-combobox-spacing-label-to-combobox: var(--spectrum-field-label-to-component-quiet-large); - } - - &.spectrum-Combobox--sizeXL { - --spectrum-combobox-spacing-label-to-combobox: var(--spectrum-field-label-to-component-quiet-extra-large); - } - - /* Settings for nested Picker Button component. */ - --mod-picker-button-background-color-quiet: transparent; - --mod-picker-button-border-color-quiet: transparent; -} - -@media (forced-colors: active) { - .spectrum-Combobox { - --highcontrast-combobox-border-color-highlight: Highlight; - --highcontrast-combobox-border-color-invalid: Highlight; - - .spectrum-Combobox-button.spectrum-PickerButton--quiet { - .spectrum-PickerButton-fill { - forced-color-adjust: none; - } - - .spectrum-PickerButton-icon { - /* Should match foreground color of the Textfield. */ - color: CanvasText; - } - } - } + --spectrum-combobox-spacing-inline-icon-to-text: var(--spectrum-text-to-visual-300); + --spectrum-combobox-inline-size: var(--spectrum-field-width-extra-large); + --spectrum-combobox-border-radius: var(--spectrum-corner-radius-medium-size-extra-large); + --mod-combobox-popover-animation-distance: var(--spectrum-component-to-menu-extra-large); } .spectrum-Combobox { position: relative; - display: inline-flex; - flex-flow: row nowrap; - + display: inline-grid; inline-size: var(--mod-combobox-inline-size, var(--spectrum-combobox-inline-size)); - min-inline-size: var(--mod-combobox-min-inline-size, var(--spectrum-combobox-min-inline-size)); - block-size: var(--mod-combobox-block-size, var(--spectrum-combobox-block-size)); margin-block-start: var(--mod-combobox-spacing-label-to-combobox, var(--spectrum-combobox-spacing-label-to-combobox)); - border-radius: var(--mod-combobox-border-radius, var(--spectrum-combobox-border-radius)); + .spectrum-Combobox-label, + .spectrum-Combobox-content { + min-inline-size: var(--mod-combobox-min-inline-size, var(--spectrum-combobox-min-inline-size)); + } - .spectrum-Popover.is-open { - transform: translateY(var(--mod-combobox-spacing-edge-to-menu, var(--spectrum-combobox-spacing-edge-to-menu))); + .spectrum-Combobox-popover { + --mod-popover-animation-distance: var(--mod-combobox-popover-animation-distance); } - &.is-readOnly:not(.spectrum-Combobox--quiet) { + &.is-readOnly { .spectrum-Combobox-textfield { &.is-keyboardFocused .spectrum-Combobox-input { outline-offset: var(--mod-textfield-focus-indicator-gap); @@ -234,8 +199,8 @@ } .spectrum-Combobox-input:read-only { - background-color: var(--spectrum-combobox-readonly-input-background-color); - border-color: var(--spectrum-combobox-readonly-input-border-color); + background-color: var(--highcontrast-combobox-background-color-default, var(--spectrum-combobox-readonly-input-background-color)); + border-color: var(--highcontrast-combobox-readonly-border-color, var(--spectrum-combobox-readonly-input-border-color)); &:hover { background-color: revert; @@ -243,13 +208,13 @@ } &.is-invalid .spectrum-Combobox-input:read-only { - border-color: var(--highcontrast-textfield-border-color-invalid-default, var(--mod-textfield-border-color-invalid-default, var(--spectrum-combobox-readonly-border-color-invalid-default))); + border-color: var(--highcontrast-combobox-border-color-invalid, var(--mod-textfield-border-color-invalid-default, var(--spectrum-combobox-readonly-border-color-invalid-default))); } &.is-disabled .spectrum-Combobox-input:read-only { background-color: var(--mod-textfield-background-color-disabled, var(--spectrum-combobox-readonly-background-color-disabled)); border-color: var(--mod-combobox-readonly-border-color-disabled, var(--spectrum-combobox-readonly-border-color-disabled, transparent)); - color: var(--highcontrast-textfield-text-color-disabled, var(--mod-textfield-text-color-disabled, var(--spectrum-combobox-readonly-text-color-disabled))); + color: var(--mod-textfield-text-color-disabled, var(--spectrum-combobox-readonly-text-color-disabled)); &:hover { background-color: var(--mod-textfield-background-color-disabled, var(--spectrum-combobox-readonly-background-color-disabled)); @@ -263,7 +228,8 @@ position: absolute; inset-inline-end: calc(var(--mod-combobox-spacing-inline-icon-to-button, var(--spectrum-combobox-spacing-inline-icon-to-button)) + var(--mod-combobox-button-width, var(--spectrum-combobox-button-width))); inset-block-start: var(--mod-combobox-block-spacing-edge-to-progress-circle, var(--spectrum-combobox-block-spacing-edge-to-progress-circle)); - inset-block-end: var(--mod-combobox-block-spacing-edge-to-alert, var(--spectrum-combobox-block-spacing-edge-to-alert)); + inset-block-end: var(--mod-combobox-block-spacing-edge-to-icon, var(--spectrum-combobox-block-spacing-edge-to-icon)); + padding-inline-start: var(--mod-combobox-spacing-inline-icon-to-text, var(--spectrum-combobox-spacing-inline-icon-to-text)); &:dir(rtl) { inset-inline-end: inherit; @@ -271,10 +237,16 @@ } } +.spectrum-Combobox-label { + display: flex; + align-items: center; + justify-content: space-between; +} + /* PICKER BUTTON */ .spectrum-Combobox-button { position: absolute; - inset-inline-end: calc(-1 * var(--mod-combobox-button-inline-offset, var(--spectrum-combobox-button-inline-offset, 0px))); + inset-inline-end: 0; /* Default */ &:not(:disabled, .is-invalid, .spectrum-PickerButton--quiet) { @@ -341,21 +313,19 @@ } } -/* TEXTFIELD (wrapper) */ -.spectrum-Combobox-textfield { - inline-size: 100%; +.spectrum-Combobox-content { + display: inline-grid; + block-size: var(--mod-combobox-block-size, var(--spectrum-combobox-block-size)); + position: relative; } /* TEXT INPUT */ .spectrum-Combobox-input { - padding-block-start: calc(var(--mod-combobox-spacing-block-start-edge-to-text, var(--spectrum-combobox-spacing-block-start-edge-to-text)) - var(--mod-combobox-border-width, var(--spectrum-combobox-border-width))); - padding-block-end: calc(var(--mod-combobox-spacing-block-end-edge-to-text, var(--spectrum-combobox-spacing-block-end-edge-to-text)) - var(--mod-combobox-border-width, var(--spectrum-combobox-border-width))); + background-color: var(--highcontrast-combobox-background-color-default, var(--mod-combobox-textfield-background-color, var(--spectrum-combobox-background-color-default))); padding-inline-start: calc(var(--mod-combobox-spacing-inline-start-edge-to-text, var(--spectrum-combobox-spacing-inline-start-edge-to-text)) - var(--mod-combobox-border-width, var(--spectrum-combobox-border-width))); - padding-inline-end: calc(var(--mod-combobox-button-width, var(--spectrum-combobox-button-width)) + var(--mod-combobox-spacing-inline-end-edge-to-text, var(--spectrum-combobox-spacing-inline-end-edge-to-text)) - (var(--mod-combobox-border-width, var(--spectrum-combobox-border-width)) * 2)); + padding-inline-end: calc(var(--mod-combobox-button-width, var(--spectrum-combobox-button-width)) + var(--mod-combobox-spacing-inline-icon-to-text, var(--spectrum-combobox-spacing-inline-icon-to-text)) - var(--mod-combobox-border-width, var(--spectrum-combobox-border-width))); backface-visibility: hidden; - line-height: var(--mod-combobox-line-height, var(--spectrum-combobox-line-height)); - font-size: var(--mod-combobox-font-size, var(--spectrum-combobox-font-size)); - font-style: var(--mod-combobox-font-style, var(--spectrum-combobox-font-style)); + line-height: var(--mod-combobox-line-height, var(--spectrum-combobox-block-size)); &::placeholder { --mod-textfield-text-color-default: var(--mod-combobox-font-color-placeholder); @@ -390,10 +360,63 @@ /* ****** Invalid & Loading ****** */ .spectrum-Combobox-textfield.is-invalid &, .spectrum-Combobox-textfield.is-loading & { - padding-inline-end: calc( - var(--mod-combobox-button-width, var(--spectrum-combobox-button-width)) + var(--mod-combobox-spacing-inline-icon-to-button, var(--spectrum-combobox-spacing-inline-icon-to-button)) + var(--mod-combobox-icon-size, var(--spectrum-combobox-icon-size)) + var(--mod-combobox-spacing-inline-end-edge-to-text, var(--spectrum-combobox-spacing-inline-end-edge-to-text)) - var(--mod-combobox-button-inline-offset, var(--spectrum-combobox-button-inline-offset, 0px)) - - (var(--mod-combobox-border-width, var(--spectrum-combobox-border-width)) * 2) - ); + padding-inline-end: calc(var(--mod-combobox-button-width, var(--spectrum-combobox-button-width)) + var(--mod-combobox-spacing-inline-icon-to-button, var(--spectrum-combobox-spacing-inline-icon-to-button)) + var(--mod-combobox-icon-size, var(--spectrum-combobox-icon-size)) + var(--mod-combobox-spacing-alert-icon-to-text, var(--spectrum-combobox-spacing-inline-icon-to-text)) - var(--mod-combobox-border-width, var(--spectrum-combobox-border-width))); + } + + &:lang(ja), + &:lang(zh), + &:lang(ko) { + --mod-combobox-line-height: var(--mod-combobox-line-height-cjk, var(--spectrum-combobox-line-height-cjk)); + } + + &:-webkit-autofill, + &:-webkit-autofill:hover, + &:-webkit-autofill:focus, + &:-webkit-autofill:active, + &:-internal-autofill-selected, + &.spectrum-Combobox-autocomplete { + border-color: var(--spectrum-combobox-border-color-default); + box-shadow: 0 0 0 30px var(--highcontrast-combobox-background-color-default, var(--spectrum-combobox-background-color-default)) inset !important; + transition: background-color 200ms ease-in-out 0s; + -webkit-text-fill-color: var(--spectrum-neutral-content-color-default) !important; + line-height: var(--spectrum-combobox-line-height); + + &::selection { + background-color: var(--spectrum-combobox-background-color-autofill); + } + } +} + +.spectrum-Combobox-helptext { + inset-block-start: var(--mod-combobox-spacing-to-help-text, var(--spectrum-combobox-spacing-to-help-text)); + + .spectrum-HelpText-text { + inline-size: 100%; + overflow-wrap: break-word; + text-wrap: wrap; + } +} + +.spectrum-Combobox--sideLabel { + .spectrum-Combobox-textfield { + inline-size: auto; + } + + .spectrum-Combobox-label { + grid-row: 1; + grid-column: 1 / span 1; + padding-inline-end: var(--mod-combobox-spacing-side-label-to-field, var(--spectrum-combobox-spacing-side-label-to-field)); + overflow-wrap: anywhere; + } + + .spectrum-Combobox-content { + grid-row: 1 / span 1; + grid-column: 2 / span 1; + } + + .spectrum-Combobox-helptext { + grid-row: 2 / span 2; + grid-column: 2 / span 1; } } @@ -403,9 +426,10 @@ inline-size: var(--mod-combobox-icon-size, var(--spectrum-combobox-icon-size)); block-size: var(--mod-combobox-icon-size, var(--spectrum-combobox-icon-size)); - inset-block-start: var(--mod-combobox-block-spacing-edge-to-alert, var(--spectrum-combobox-block-spacing-edge-to-alert)); - inset-block-end: var(--mod-combobox-block-spacing-edge-to-alert, var(--spectrum-combobox-block-spacing-edge-to-alert)); + inset-block-start: var(--mod-combobox-block-spacing-edge-to-icon, var(--spectrum-combobox-block-spacing-edge-to-icon)); + inset-block-end: var(--mod-combobox-block-spacing-edge-to-icon, var(--spectrum-combobox-block-spacing-edge-to-icon)); inset-inline-end: calc(var(--mod-combobox-spacing-inline-icon-to-button, var(--spectrum-combobox-spacing-inline-icon-to-button)) + var(--mod-combobox-button-width, var(--spectrum-combobox-button-width))); + padding-inline-start: var(--mod-combobox-spacing-inline-icon-to-text, var(--spectrum-combobox-spacing-inline-icon-to-text)); } .spectrum-Textfield.is-disabled &, @@ -415,43 +439,22 @@ } } -/* QUIET VARIATION (no visible background) */ -.spectrum-Combobox--quiet { - border-radius: 0; - - .spectrum-Combobox-textfield { - &.is-invalid .spectrum-Textfield-validationIcon { - inset-inline-end: var(--mod-combobox-button-width, var(--spectrum-combobox-button-width)); - } - - &.is-readOnly { - .spectrum-Combobox-input:read-only { - border-block-end: var(--mod-combobox-border-width, var(--spectrum-combobox-border-width)) solid var(--mod-combobox-readonly-input-border-color, var(--spectrum-combobox-readonly-input-border-color)); - } +@media (forced-colors: active) { + .spectrum-Combobox { + --highcontrast-combobox-border-color-highlight: Highlight; + --highcontrast-combobox-border-color-invalid: Highlight; + --highcontrast-combobox-background-color-default: Canvas; + --highcontrast-combobox-readonly-border-color: CanvasText; - &.is-invalid > .spectrum-Combobox-input:read-only { - border-color: var(--highcontrast-textfield-border-color-invalid-default, var(--mod-textfield-border-color-invalid-default, var(--spectrum-combobox-readonly-border-color-invalid-default))); + .spectrum-Combobox-button.spectrum-PickerButton--quiet { + .spectrum-PickerButton-fill { + forced-color-adjust: none; } - &.is-disabled .spectrum-Combobox-input:read-only { - color: var(--highcontrast-textfield-text-color-disabled, var(--mod-textfield-text-color-disabled, var(--spectrum-combobox-readonly-text-color-disabled))); - border-color: var(--mod-textfield-border-color-disabled, var(--spectrum-combobox-readonly-border-color-disabled)); + .spectrum-PickerButton-icon { + /* Should match foreground color of the Textfield. */ + color: CanvasText; } } } - - .spectrum-Combobox-input { - border-block-end-width: var(--mod-combobox-border-width, var(--spectrum-combobox-border-width)); - - padding-block-start: var(--mod-combobox-spacing-block-start-edge-to-text, var(--spectrum-combobox-spacing-block-start-edge-to-text)); - padding-block-end: calc(var(--mod-combobox-spacing-block-end-edge-to-text, var(--spectrum-combobox-spacing-block-end-edge-to-text)) - var(--mod-combobox-border-width, var(--spectrum-combobox-border-width))); - - padding-inline-start: var(--mod-combobox-spacing-inline-start-edge-to-text, var(--spectrum-combobox-spacing-inline-start-edge-to-text)); - padding-inline-end: calc(var(--mod-combobox-button-width, var(--spectrum-combobox-button-width)) + var(--mod-combobox-spacing-inline-end-edge-to-text, var(--spectrum-combobox-spacing-inline-end-edge-to-text)) - var(--mod-combobox-button-inline-offset, var(--spectrum-combobox-button-inline-offset, 0px))); - } - - .spectrum-Combobox-textfield.is-invalid .spectrum-Combobox-input, - .spectrum-Combobox-textfield.is-loading .spectrum-Combobox-input { - padding-inline-end: calc(var(--mod-combobox-button-width, var(--spectrum-combobox-button-width)) + var(--mod-combobox-spacing-inline-icon-to-button, var(--spectrum-combobox-spacing-inline-icon-to-button)) + var(--mod-combobox-icon-size, var(--spectrum-combobox-icon-size)) + var(--mod-combobox-spacing-inline-end-edge-to-text, var(--spectrum-combobox-spacing-inline-end-edge-to-text)) - var(--mod-combobox-button-inline-offset, var(--spectrum-combobox-button-inline-offset, 0px))); - } } diff --git a/components/combobox/package.json b/components/combobox/package.json index 342fc9c488a..4a59a586747 100644 --- a/components/combobox/package.json +++ b/components/combobox/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/combobox", - "version": "4.2.0", + "version": "5.0.0-next.4", "description": "The Spectrum CSS combobox component", "license": "Apache-2.0", "author": "Adobe", @@ -19,19 +19,17 @@ "./package.json": "./package.json", "./dist/*": "./dist/*", "./index.css": "./dist/index.css", - "./index-*.css": "./dist/index-*.css", "./metadata.json": "./dist/metadata.json", - "./themes/*": "./dist/themes/*", "./stories/*": "./stories/*" }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/menu": ">=9.0.0 <10.0.0", - "@spectrum-css/pickerbutton": ">=6.0.0 <7.0.0", - "@spectrum-css/popover": ">=8.0.0 <9.0.0", - "@spectrum-css/progresscircle": ">=5.0.0 <6.0.0", - "@spectrum-css/textfield": ">=8.0.0 <9.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/menu": ">=10.0.0-next.0", + "@spectrum-css/pickerbutton": ">=7.0.0-next.0", + "@spectrum-css/popover": ">=9.0.0-next.0", + "@spectrum-css/progresscircle": ">=6.0.0-next.0", + "@spectrum-css/textfield": ">=9.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/menu": { @@ -54,12 +52,12 @@ } }, "devDependencies": { - "@spectrum-css/menu": "9.3.0", - "@spectrum-css/pickerbutton": "6.2.0", - "@spectrum-css/popover": "8.3.0", - "@spectrum-css/progresscircle": "5.2.0", - "@spectrum-css/textfield": "8.2.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/menu": "10.0.0-next.6", + "@spectrum-css/pickerbutton": "7.0.0-next.2", + "@spectrum-css/popover": "9.0.0-next.5", + "@spectrum-css/progresscircle": "6.0.0-next.0", + "@spectrum-css/textfield": "9.0.0-next.1", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/combobox/stories/combobox.stories.js b/components/combobox/stories/combobox.stories.js index baea4599d01..524f54eca85 100644 --- a/components/combobox/stories/combobox.stories.js +++ b/components/combobox/stories/combobox.stories.js @@ -1,11 +1,12 @@ import { Template as Menu } from "@spectrum-css/menu/stories/template.js"; +import { Sizes, withDownStateDimensionCapture } from "@spectrum-css/preview/decorators"; import { disableDefaultModes } from "@spectrum-css/preview/modes"; -import { isDisabled, isFocused, isInvalid, isKeyboardFocused, isLoading, isOpen, isQuiet, isReadOnly, size } from "@spectrum-css/preview/types"; +import { isDisabled, isFocused, isHovered, isInvalid, isKeyboardFocused, isLoading, isOpen, isReadOnly, size } from "@spectrum-css/preview/types"; import { within } from "@storybook/test"; import metadata from "../dist/metadata.json"; import packageJson from "../package.json"; import { ComboBoxGroup } from "./combobox.test.js"; -import { Template, VariantGroup } from "./template.js"; +import { HelpTextTemplate, Template, VariantGroup } from "./template.js"; /** * Comboboxes combine a text entry with a picker menu, allowing users to filter longer lists to only the selections matching a query. @@ -14,11 +15,11 @@ import { Template, VariantGroup } from "./template.js"; * * ### General notes * - * - Combobox uses `.spectrum-PickerButton` instead of a `.spectrum-Picker` + * - Combobox uses `.spectrum-InfieldButton` as a menu trigger. * - The following classes must be added: * - `.spectrum-Combobox-textfield` is required on the Textfield outer element (`.spectrum-Textfield`) * - `.spectrum-Combobox-input` is required on the `` element inside of Textfields (`.spectrum-Textfield-input`) - * - `.spectrum-Combobox-button` is required on the FieldButton (`.spectrum-ActionButton spectrum-ActionButton--sizeM`) + * - `.spectrum-Combobox-button` is required on the InfieldButton (`.spectrum-InfieldButton`) * * ### Indicating validity and focus * @@ -26,8 +27,7 @@ import { Template, VariantGroup } from "./template.js"; * * - `.is-focused` - when the input or button is focused with the mouse * - `.is-keyboardFocused` - when the input or button is focused with the keyboard - * - `.is-valid` - when the input has an explicit valid state - * - `.is-invalid` - when the input has an explicit invalid state + * - `.is-invalid` - when the input has an explicit invalid state; should also show help text for error messaging * - `.is-disabled` - when the control is disabled; should also add to the `.spectrum-Combobox-textfield` and include a `[disabled]` attribute to the `.spectrum-Combobox-button` * - `.is-loading` - when the progress circle is being shown * @@ -45,13 +45,23 @@ export default { ...isOpen, if: { arg: "isReadOnly", truthy: false }, }, - isQuiet, isInvalid, + isHovered, isFocused, isKeyboardFocused, isLoading, isDisabled, isReadOnly, + isLabelRequired: { + name: "Label required", + type: { name: "boolean" }, + table: { + type: { summary: "boolean" }, + category: "Component", + }, + control: "boolean", + if: { arg: "showFieldLabel", truthy: true }, + }, showFieldLabel: { name: "Show field label", type: { name: "boolean" }, @@ -78,10 +88,28 @@ export default { type: { summary: "string" }, category: "Component", }, - options: ["top", "left"], + options: ["top", "side"], control: "select", if: { arg: "showFieldLabel", truthy: true }, }, + autocomplete: { + name: "Autocomplete", + type: { name: "boolean" }, + table: { + type: { summary: "boolean" }, + category: "Component", + }, + control: "boolean", + }, + helpText: { + name: "Help text", + type: { name: "text" }, + table: { + type: { summary: "text" }, + category: "Component", + }, + control: "text", + }, value: { name: "Value", description: "The value shows the option that a user has selected.", @@ -98,43 +126,51 @@ export default { rootClass: "spectrum-Combobox", size: "m", isOpen: false, - isQuiet: false, isInvalid: false, + isHovered: false, isFocused: false, isKeyboardFocused: false, isLoading: false, isDisabled: false, isReadOnly: false, + isLabelRequired: false, showFieldLabel: false, + autocomplete: false, testId: "combobox", + fieldLabelText: "Select location", + helpText: "", + value: "Ballard", content: [ - (passthroughs, context) => Menu({ - role: "listbox", - subrole: "option", - selectionMode: "single", - hasDividers: true, - items: [ + (passthroughs, context) => + Menu( { - label: "Ballard", - isSelected: true, - isChecked: true, + role: "listbox", + selectionMode: "single", + hasDividers: true, + items: [ + { + label: "Ballard", + isSelected: true, + isChecked: true, + }, + { + label: "Fremont", + }, + { + label: "Greenwood", + }, + { + type: "divider", + }, + { + label: "United States of America", + isDisabled: true, + }, + ], + ...passthroughs, }, - { - label: "Fremont", - }, - { - label: "Greenwood", - }, - { - type: "divider", - }, - { - label: "United States of America", - isDisabled: true, - }, - ], - ...passthroughs, - }, context), + context, + ), ], }, parameters: { @@ -142,9 +178,19 @@ export default { type: "figma", url: "https://www.figma.com/design/Mngz9H7WZLbrCvGQf3GnsY/S2-%2F-Desktop?node-id=727-2550", }, + downState: { + selectors: [".spectrum-InfieldButton:not(:disabled)"], + }, packageJson, metadata, + status: { + type: "migrated", + }, }, + tags: ["migrated"], + decorators: [ + withDownStateDimensionCapture, + ], play: async ({ canvasElement }) => { const canvas = within(canvasElement); @@ -155,11 +201,6 @@ export default { export const Default = ComboBoxGroup.bind({}); Default.tags = ["!autodocs"]; -Default.args = { - isOpen: true, - fieldLabelText: "Select location", - value: "Ballard", -}; Default.parameters = { chromatic: { delay: 1000 } }; @@ -167,38 +208,58 @@ Default.parameters = { // ********* DOCS ONLY ********* // export const DefaultGroup = VariantGroup.bind({}); DefaultGroup.storyName = "Default"; -DefaultGroup.args = Default.args; +DefaultGroup.args = { + isOpen: true, +}; DefaultGroup.tags = ["!dev"]; DefaultGroup.parameters = { chromatic: { disableSnapshot: true }, }; -export const QuietGroup = VariantGroup.bind({}); -QuietGroup.storyName = "Quiet"; -QuietGroup.args = { - ...Default.args, - isQuiet: true, -}; -QuietGroup.tags = ["!dev"]; -QuietGroup.parameters = { - chromatic: { disableSnapshot: true }, +/** + * Comboboxes can show help text to provide feedback to users. The description in the help text is flexible and encompasses a range of guidance. Sometimes this guidance is about what to input, and sometime it’s about how to input. This includes information such as: + * + * - An overall description of the input field + * - Hints for what kind of information needs to be input + * - Specific formatting examples or requirements + */ +export const HelpText = HelpTextTemplate.bind({}); +HelpText.tags = ["!dev"]; +HelpText.args = { + showHelpText: true, + helpText: "This is a help text. Select an option", }; /** - * Comboboxes have a read-only option for when content in the disabled state still needs to be shown. This allows for content to be copied, but not interacted with or changed. A combobox does not have a read-only option if no selection has been made. To enable this feature, add the `.isReadOnly` class to the combobox. To enable this feature, add the .isReadOnly class to the combobox. Then within the nested textfield component, add the .isReadOnly class and readonly attribute to the `` element. -*/ + * Comboboxes have a read-only option for when content in the disabled state still needs to be shown. This allows for content to be copied, but not interacted with or changed. A combobox does not have a read-only option if no selection has been made. To enable this feature, add the `.is-readOnly` class to the combobox. To enable this feature, add the `.is-readOnly` class to the combobox. Then within the nested textfield component, add the `.is-readOnly class and readonly attribute to the `input` element. + */ export const ReadOnly = Template.bind({}); ReadOnly.tags = ["!dev"]; ReadOnly.args = { isReadOnly: true, - value: "Ballard" + value: "Ballard", }; ReadOnly.parameters = { - chromatic: { disableSnapshot: true } + chromatic: { disableSnapshot: true }, }; ReadOnly.storyName = "Read-only"; +export const Sizing = (args, context) => + Sizes( + { + Template, + withBorder: false, + withHeading: false, + ...args, + }, + context, + ); +Sizing.tags = ["!dev"]; +Sizing.parameters = { + chromatic: { disableSnapshot: true }, +}; + // ********* VRT ONLY ********* // export const WithForcedColors = ComboBoxGroup.bind({}); WithForcedColors.tags = ["!autodocs", "!dev"]; diff --git a/components/combobox/stories/combobox.test.js b/components/combobox/stories/combobox.test.js index 5c7d94e7d44..bc15c691b08 100644 --- a/components/combobox/stories/combobox.test.js +++ b/components/combobox/stories/combobox.test.js @@ -4,64 +4,57 @@ import { Template } from "./template.js"; export const ComboBoxGroup = Variants({ Template, sizeDirection: "row", - wrapperStyles: { - "align-items": "flex-start", - }, testData: [ { testHeading: "Default", isOpen: false, }, { - testHeading: "Quiet", - isQuiet: true, - isOpen: false, + testHeading: "Invalid", + isInvalid: true, }, { testHeading: "Open", isOpen: true, }, { - testHeading: "Quiet + open", - isQuiet: true, - isOpen: true, + testHeading: "Help text with label", + showFieldLabel: true, + helpText: "Choose a location. Add a new location by typing it in the field, then selecting 'Enter.'", }, { - testHeading: "With field label top", + testHeading: "With field label on the side", showFieldLabel: true, - isOpen: false, - fieldLabelPosition: "top", + fieldLabelPosition: "side", }, { - testHeading: "With field label left", + testHeading: "Help text with label on the side", showFieldLabel: true, - isOpen: false, - fieldLabelPosition: "left", + helpText: "Choose a location. Add a new location by typing it in the field, then selecting 'Enter.'", + fieldLabelPosition: "side", }, { testHeading: "Truncation", - isOpen: false, value: "United States of America and to the republic", }, { - testHeading: "Quiet + truncation", - isOpen: false, - isQuiet: true, - value: "United States of America and to the republic", - }, + testHeading: "Autocomplete", + autocomplete: true, + } ], stateData: [ { - testHeading: "Disabled", - isDisabled: true, + testHeading: "Hovered", + isHovered: true, }, { - testHeading: "Invalid", - isInvalid: true, + testHeading: "Focused", + isFocused: true, }, { - testHeading: "Focused", + testHeading: "Focused + Hovered", isFocused: true, + isHovered: true, }, { testHeading: "Keyboard focused", @@ -75,5 +68,9 @@ export const ComboBoxGroup = Variants({ testHeading: "Read-only", isReadOnly: true }, + { + testHeading: "Disabled", + isDisabled: true, + }, ], }); diff --git a/components/combobox/stories/template.js b/components/combobox/stories/template.js index fe68d45cba9..07020446d7a 100644 --- a/components/combobox/stories/template.js +++ b/components/combobox/stories/template.js @@ -1,5 +1,6 @@ import { Template as FieldLabel } from "@spectrum-css/fieldlabel/stories/template.js"; -import { Template as PickerButton } from "@spectrum-css/pickerbutton/stories/template.js"; +import { Template as HelpText } from "@spectrum-css/helptext/stories/template.js"; +import { Template as InfieldButton } from "@spectrum-css/infieldbutton/stories/template.js"; import { Template as Popover } from "@spectrum-css/popover/stories/template.js"; import { Container, getRandomId } from "@spectrum-css/preview/decorators"; import { Template as TextField } from "@spectrum-css/textfield/stories/template.js"; @@ -10,11 +11,8 @@ import { styleMap } from "lit/directives/style-map.js"; import { when } from "lit/directives/when.js"; import "../index.css"; -import "../themes/spectrum.css"; -/* Must be imported last */ -import "../themes/express.css"; -const Combobox = ({ +export const Template = ({ rootClass = "spectrum-Combobox", id = getRandomId("combobox"), testId, @@ -23,15 +21,40 @@ const Combobox = ({ size = "m", isOpen = true, isInvalid = false, - isQuiet = false, isDisabled = false, + isHovered = false, isFocused = false, isKeyboardFocused = false, isLoading = false, isReadOnly = false, + helpText, + fieldLabelText = "Select location", + fieldLabelPosition = "top", + isLabelRequired = false, + showFieldLabel = false, value = "", + autocomplete = true, + content = [], } = {}, context = {}) => { const { updateArgs } = context; + const comboboxId = id || getRandomId("combobox"); + + // Handle click outside of the combobox to close it + if (typeof window !== "undefined" && isOpen) { + // Use setTimeout to allow DOM to render first + setTimeout(() => { + const comboboxEl = document.getElementById(comboboxId); + + const handleClickOutside = (event) => { + if (comboboxEl && !comboboxEl.contains(event.target)) { + updateArgs({ isOpen: false }); + document.removeEventListener("mousedown", handleClickOutside); + } + }; + + document.addEventListener("mousedown", handleClickOutside); + }, 0); + } return html`
    ({ ...a, [c]: true }), {}), })} id=${ifDefined(id)} data-testid=${ifDefined(testId ?? id)} style=${styleMap(customStyles)} + role="combobox" + aria-expanded=${isOpen} + aria-haspopup="listbox" + aria-controls=${`${comboboxId}-popover`} + aria-owns=${`${comboboxId}-popover`} + aria-autocomplete=${ifDefined(autocomplete ? "list" : undefined)} > - ${TextField({ - size, - isQuiet, - isDisabled, - isInvalid, - isFocused, - isKeyboardFocused, - customClasses: [ - `${rootClass}-textfield`, - ...(isLoading ? ["is-loading"] : []), - ], - customInputClasses: [`${rootClass}-input`], - isLoading, - customProgressCircleClasses: ["spectrum-Combobox-progress-circle"], - name: "field", - isReadOnly, - value, - onclick: function () { - if (!isOpen) updateArgs({ isOpen: true }); - }, - }, context)} - ${PickerButton({ - customClasses: [ - `${rootClass}-button`, - ... isInvalid ? ["is-invalid"] : [], - ], - size, - iconSet: "ui", - iconName: "ChevronDown", - isQuiet, - id: getRandomId("picker"), - isOpen, - isFocused, - isKeyboardFocused, - isDisabled, - position: "right", - onclick: function () { - updateArgs({ isOpen: !isOpen }); - }, - tabindex: "-1", - }, context)} -
    - `; -}; - -export const Template = ({ - size = "m", - isOpen = true, - isQuiet = false, - isDisabled = false, - showFieldLabel = false, - isReadOnly = false, - fieldLabelText = "Select location", - fieldLabelPosition = "top", - content = [], - value = "", - ...args -} = {}, context = {}) => { - const popoverHeight = size === "s" ? 106 : size === "l" ? 170 : size === "xl" ? 229 : 142; // default value is "m" - return html` -
    ${when(showFieldLabel, () => FieldLabel({ size, label: fieldLabelText, isDisabled, - customStyles: { "max-inline-size": "100px"}, - alignment: fieldLabelPosition === "left" && "left", + customClasses: [`${rootClass}-label`], + alignment: fieldLabelPosition === "side" && "side", + isRequired: isLabelRequired, }, context) )} - ${[ - Popover({ - isOpen: isOpen && !isDisabled && !isReadOnly, - withTip: false, - position: "bottom-start", - isQuiet, - trigger: (passthrough) => Combobox({ - size, - isOpen, - isQuiet, - isDisabled, - isReadOnly, - value, - ...args, - ...passthrough, - }, context), - content, - popoverWidth: size === "s" ? 140 : size === "l" ? 191 : size === "xl" ? 192 : 166, // default value is "m" - popoverHeight, - }, context), - ]} +
    + ${TextField({ + size, + isDisabled, + isInvalid, + isFocused, + isHovered, + isKeyboardFocused, + customClasses: [ + `${rootClass}-textfield`, + ...(isLoading ? ["is-loading"] : []), + ], + customInputClasses: [ + `${rootClass}-input`, + ...(autocomplete ? [`${rootClass}-autocomplete`] : []) + ], + isLoading, + customInfieldProgressCircleClasses: ["spectrum-Combobox-progress-circle"], + name: "field", + isReadOnly, + value, + autocomplete: autocomplete ? undefined : "off", + onclick: function () { + if (!isOpen) updateArgs({ isOpen: true }); + }, + }, context)} + ${InfieldButton({ + customClasses: [ + `${rootClass}-button`, + ...(!isDisabled && isOpen ? ["is-open"] : []), + ], + size, + id: getRandomId("infieldbutton"), + isDisabled: isDisabled || isReadOnly, + tabindex: "-1", + onclick: function () { + updateArgs({ + isOpen: !isOpen, + }); + }, + }, context)} +
    + ${Popover({ + isOpen: isOpen && !isDisabled && !isReadOnly, + withTip: false, + position: "bottom-start", + customClasses: [`${rootClass}-popover`], + customStyles: { + "inline-size": size === "s" ? "192px" : size === "l" ? "224px" : size === "xl" ? "240px" : "208px", + }, + content, + }, context)} + ${when(helpText, () => + HelpText({ + customClasses: [`${rootClass}-helptext`], + size, + isDisabled, + hideIcon: true, + text: helpText, + variant: isInvalid ? "negative" : "neutral", + }, context) + )} +
    `; }; +export const HelpTextTemplate = (args, context) => { + const variants = [ + { + heading: "Help text", + args: {...args, helpText: "Choose a topic. Add a new topic by typing it in the field, then selecting 'Enter.'"}, + }, + { + heading: "Help text with error", + args: {...args, helpText: "Choose or add at least one topic.", isInvalid: true}, + } + ]; + + return Container({ + direction: "row", + withHeading: false, + withBorder: false, + content: html`${variants.map(variant => Container({ + withBorder: false, + heading: variant.heading, + containerStyles: {"display": "inline"}, + content: Template({ + ...variant.args, + customStyles: {"margin-top": "8px"} + }, context)}, + context))}`, + }, context); +}; + export const VariantGroup = (args, context) => { const variants = [ { diff --git a/components/combobox/themes/express.css b/components/combobox/themes/express.css deleted file mode 100644 index dc19625a853..00000000000 --- a/components/combobox/themes/express.css +++ /dev/null @@ -1,28 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--express */ - -@import "./spectrum.css"; - -@container style(--system: express) { - .spectrum-Combobox { - --spectrum-combobox-border-color-default: var(--spectrum-gray-400); - --spectrum-combobox-border-color-hover: var(--spectrum-gray-500); - --spectrum-combobox-border-color-focus: var(--spectrum-gray-900); - --spectrum-combobox-border-color-focus-hover: var(--spectrum-gray-800); - --spectrum-combobox-border-color-key-focus: var(--spectrum-gray-900); - - --spectrum-combobox-readonly-input-border-color: var(--spectrum-gray-400); - } -} diff --git a/components/combobox/themes/spectrum-two.css b/components/combobox/themes/spectrum-two.css deleted file mode 100644 index 9d8502ebb3e..00000000000 --- a/components/combobox/themes/spectrum-two.css +++ /dev/null @@ -1,27 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -@container style(--system: spectrum) { - .spectrum-Combobox { - --spectrum-combobox-border-color-default: var(--spectrum-gray-500); - --spectrum-combobox-border-color-hover: var(--spectrum-gray-600); - --spectrum-combobox-border-color-focus: var(--spectrum-gray-800); - --spectrum-combobox-border-color-focus-hover: var(--spectrum-gray-900); - --spectrum-combobox-border-color-key-focus: var(--spectrum-gray-800); - - --spectrum-combobox-readonly-input-border-color: var(--spectrum-gray-500); - - --spectrum-combobox-background-color-disabled: var(--spectrum-gray-25); - --spectrum-combobox-border-color-disabled: var(--spectrum-disabled-border-color); - } -} diff --git a/components/combobox/themes/spectrum.css b/components/combobox/themes/spectrum.css deleted file mode 100644 index 5b0a3eea8bf..00000000000 --- a/components/combobox/themes/spectrum.css +++ /dev/null @@ -1,29 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--legacy */ - -@import "./spectrum-two.css"; - -@container style(--system: legacy) { - .spectrum-Combobox { - --spectrum-combobox-border-color-focus: var(--spectrum-gray-500); - --spectrum-combobox-border-color-focus-hover: var(--spectrum-gray-600); - --spectrum-combobox-border-color-key-focus: var(--spectrum-gray-600); - - --spectrum-combobox-readonly-input-border-color: var(--spectrum-gray-500); - - --spectrum-combobox-background-color-disabled: var(--spectrum-disabled-background-color); - --spectrum-combobox-border-color-disabled: transparent; - } -} diff --git a/components/commons/CHANGELOG.md b/components/commons/CHANGELOG.md deleted file mode 100644 index 801eb7a3fb6..00000000000 --- a/components/commons/CHANGELOG.md +++ /dev/null @@ -1,321 +0,0 @@ -# Change log - -## 11.1.0 - -### Minor Changes - -📝 [#4218](https://github.com/adobe/spectrum-css/pull/4218) [`2df53f8`](https://github.com/adobe/spectrum-css/commit/2df53f8b9ef6d6a031ca99726aa7f0475443ca03) Thanks [@castastrophe](https://github.com/castastrophe)! - -Ensure accurate exports are present for each component. Specifically, adding `themes/*` assets where present and removing`index-*.css` exports where those assets do not exist. - -## 11.0.0 - -### Major Changes - -📝 [#2786](https://github.com/adobe/spectrum-css/pull/2786) [`6c19fcf`](https://github.com/adobe/spectrum-css/commit/6c19fcf3f0eda76987f338981ae20f9999febce6) Thanks [@pfulton](https://github.com/pfulton)! - -## Breaking change - -This major update creates a bridge between the Spectrum 1 (S1) and Spectrum 2 (S2) designs, dubbed "Spectrum 2 Foundations". These do _NOT_ reflect a fully migrated S2 component. This approach allows consumers to swap the appearance of their components between S1, Express, and S2 by leveraging a "system" layer that remaps the necessary component-level tokens to the appropriate token dataset. - -For these components to appear S2, you must load the assets with the `@spectrum-css/tokens` at `v16` or higher. - -For S1 or Express, load assets with the `@spectrum-css/tokens` at `v14.x` or `v15.x`. - -If you are looking to implement a fully S2 design, please explore the `next` tag releases instead of using this foundations release. **This release is used in Spectrum Web Components 1.x**. - -### Deprecations - -The `metadata` folder containing the `mods.md` and `metadata.json` assets has been removed from source. To find information about the components including what selectors, modifiers, and passthroughs are used, please see the `dist/metadata.json` asset shipped with every component containing CSS. - -The `index-vars.css` asset has been removed in this release as it was previously deprecated and is no longer maintained. Please use the `index.css` or `index-base.css` - -### File usage - -If you are rendering components and need **only** the S2 Foundations styles, you can make use of the `index.css` asset which contains all the base styles plus the system mappings for S2 Foundations. - -If you are using this version to publish **only** an S1 or Express component, you can use the `index-base.css` plus the desired `themes/(spectrum|express).css` file. - -To render a component that can be easily swapped between the S2 Foundations, S1, or Express contexts, load `index-base.css` with the `index-theme.css` file and leverage the appropriate context classes (`.spectrum--legacy` for S1 and `.spectrum--express` for Express). - -### Patch Changes - -- Updated dependencies [[`6c19fcf`](https://github.com/adobe/spectrum-css/commit/6c19fcf3f0eda76987f338981ae20f9999febce6), [`3d08cea`](https://github.com/adobe/spectrum-css/commit/3d08cea0f590c8c2de7252677a6b81b8cc206b9a)]: - - @spectrum-css/tokens@16.0.0 - -## 10.1.1 - -### Patch Changes - -📝 [#3522](https://github.com/adobe/spectrum-css/pull/3522) [`7a47c22`](https://github.com/adobe/spectrum-css/commit/7a47c2266b6d0e8c99061fe85cba8d52684bae39) Thanks [@castastrophe](https://github.com/castastrophe)! - -- Peer dependency for @spectrum-css/tokens updated to include v15 as well as v14. - -- Updated dependencies [[`7a47c22`](https://github.com/adobe/spectrum-css/commit/7a47c2266b6d0e8c99061fe85cba8d52684bae39)]: - - @spectrum-css/tokens@15.2.0 - -## 10.1.0 - -### Minor Changes - -📝 [#2771](https://github.com/adobe/spectrum-css/pull/2771) [`81e86b1`](https://github.com/adobe/spectrum-css/commit/81e86b1adc442c891948281f1f66efea795c0447) Thanks [@jawinn](https://github.com/jawinn)! - -- Removes some legacy vendor prefixes that are no longer necessary, including some that were for older browsers that are no longer in browser support list for Spectrum CSS. Such as Microsoft Edge before version 79. Includes some cleanup around some of the related normalization styles in the Text field component and the Commons `%spectrum-BaseButton` (used for multiple button components). - -## 10.0.1 - -### Patch Changes - -📝 [#2677](https://github.com/adobe/spectrum-css/pull/2677) [`d83200c`](https://github.com/adobe/spectrum-css/commit/d83200ca70a959aa70329e71de0c4383de157855) Thanks [@castastrophe](https://github.com/castastrophe)! - -- Leverage local workspace versioning to prevent misalignment - -## 10.0.0 - -🗓 2024-04-18 • 📝 [Commits](https://github.com/adobe/spectrum-css/compare/@spectrum-css/commons@9.1.2...@spectrum-css/commons@10.0.0) - -- feat!: postcss config build and script; remove gulp (#2466)([b0f337b](https://github.com/adobe/spectrum-css/commit/b0f337b)), closes[#2466](https://github.com/adobe/spectrum-css/issues/2466) - -### 🛑 BREAKING CHANGE - -- Removes component-builder & component-builder-simple for script leveraging postcss -- Imports added to index.css and themes/express.css - -## 9.1.2 - -🗓 2024-02-15 • 📝 [Commits](https://github.com/adobe/spectrum-css/compare/@spectrum-css/commons@9.1.1...@spectrum-css/commons@9.1.2) - -**Note:** Version bump only for package @spectrum-css/commons - -## 9.1.1 - -🗓 2024-02-06 - -**Note:** Version bump only for package @spectrum-css/commons - -## 9.1.0 - -🗓 2024-01-29 • 📝 [Commits](https://github.com/adobe/spectrum-css/compare/@spectrum-css/commons@9.0.2...@spectrum-css/commons@9.1.0) - -### ✨ Features - -- **overlay,commons:**deprecate overlay; migrate references to commons ([#2429](https://github.com/adobe/spectrum-css/issues/2429))([7eecd96](https://github.com/adobe/spectrum-css/commit/7eecd96)) - -### 🐛 Bug fixes - -- **commons:** rename and deprecate mods referencing global tokens ([#2423](https://github.com/adobe/spectrum-css/issues/2423))([3a49432](https://github.com/adobe/spectrum-css/commit/3a49432)) - -## 9.0.2 - -🗓 2024-01-16 • 📝 [Commits](https://github.com/adobe/spectrum-css/compare/@spectrum-css/commons@9.0.1...@spectrum-css/commons@9.0.2) - -**Note:** Version bump only for package @spectrum-css/commons - -## 9.0.1 - -🗓 2023-12-12 • 📝 [Commits](https://github.com/adobe/spectrum-css/compare/@spectrum-css/commons@9.0.0...@spectrum-css/commons@9.0.1) - -**Note:** Version bump only for package @spectrum-css/commons - -## 9.0.0 - -🗓 2023-10-13 • 📝 [Commits](https://github.com/adobe/spectrum-css/compare/@spectrum-css/commons@8.0.1...@spectrum-css/commons@9.0.0) - -- feat(overlay)!: migrate to spectrum-tokens (#2165)([0331dae](https://github.com/adobe/spectrum-css/commit/0331dae)), closes[#2165](https://github.com/adobe/spectrum-css/issues/2165) - -### 🛑 BREAKING CHANGE - -- migrates Overlay to use `@adobe/spectrum-tokens` -- feat(overlay): migrate to use spectrum-tokens BREAKING CHANGE: migrate overlay to use spectrum tokens -- chore(tokens): add custom tokens to overlay component -- docs: regenerate mods - -## 8.0.1 - -🗓 2023-09-18 • 📝 [Commits](https://github.com/adobe/spectrum-css/compare/@spectrum-css/commons@8.0.0...@spectrum-css/commons@8.0.1) - -**Note:** Version bump only for package @spectrum-css/commons - -## 8.0.0 - -🗓 2023-08-16 • 📝 [Commits](https://github.com/adobe/spectrum-css/compare/@spectrum-css/commons@7.0.8...@spectrum-css/commons@8.0.0) - -- refactor(button)!: replace focus-ring with focus-visible([5ec4849](https://github.com/adobe/spectrum-css/commit/5ec4849)) - -### 🛑 BREAKING CHANGE - -- use native focus-visible pseudo class for focus styling on button and basebutton - -## 7.0.8 - -🗓 2023-06-12 • 📝 [Commits](https://github.com/adobe/spectrum-css/compare/@spectrum-css/commons@7.0.7...@spectrum-css/commons@7.0.8) - -### 🐛 Bug fixes - -- restore files to pre-formatted state([491dbcb](https://github.com/adobe/spectrum-css/commit/491dbcb)) - -## 7.0.7 - -🗓 2023-06-01 • 📝 [Commits](https://github.com/adobe/spectrum-css/compare/@spectrum-css/commons@7.0.6...@spectrum-css/commons@7.0.7) - -**Note:** Version bump only for package @spectrum-css/commons - -## 7.0.6 - -🗓 2023-05-10 • 📝 [Commits](https://github.com/adobe/spectrum-css/compare/@spectrum-css/commons@7.0.5...@spectrum-css/commons@7.0.6) - -**Note:** Version bump only for package @spectrum-css/commons - -## 7.0.5 - -🗓 2023-04-26 • 📝 [Commits](https://github.com/adobe/spectrum-css/compare/@spectrum-css/commons@7.0.4...@spectrum-css/commons@7.0.5) - -**Note:** Version bump only for package @spectrum-css/commons - -## 7.0.4 - -🗓 2023-04-25 • 📝 [Commits](https://github.com/adobe/spectrum-css/compare/@spectrum-css/commons@7.0.2...@spectrum-css/commons@7.0.4) - -**Note:** Version bump only for package @spectrum-css/commons - -## 7.0.3 - -🗓 2023-04-25 • 📝 [Commits](https://github.com/adobe/spectrum-css/compare/@spectrum-css/commons@7.0.2...@spectrum-css/commons@7.0.3) - -**Note:** Version bump only for package @spectrum-css/commons - -## 7.0.2 - -🗓 2023-03-13 • 📝 [Commits](https://github.com/adobe/spectrum-css/compare/@spectrum-css/commons@7.0.1...@spectrum-css/commons@7.0.2) - -**Note:** Version bump only for package @spectrum-css/commons - -## 7.0.1 - -🗓 2023-02-21 • 📝 [Commits](https://github.com/adobe/spectrum-css/compare/@spectrum-css/commons@7.0.0...@spectrum-css/commons@7.0.1) - -**Note:** Version bump only for package @spectrum-css/commons - -## 7.0.0 - -🗓 2023-02-01 • 📝 [Commits](https://github.com/adobe/spectrum-css/compare/@spectrum-css/commons@6.0.0...@spectrum-css/commons@7.0.0) - -- chore(tokens)!: use latest dependency & fix build error (#1591) ([f2532e7](https://github.com/adobe/spectrum-css/commit/f2532e7)), closes [#1591](https://github.com/adobe/spectrum-css/issues/1591) - -### 🛑 BREAKING CHANGE - -- uses latest `@adobe/spectrum-tokens` dependency which includes token renames - -## 6.0.0 - -🗓 2023-02-01 • 📝 [Commits](https://github.com/adobe/spectrum-css/compare/@spectrum-css/commons@4.0.2...@spectrum-css/commons@6.0.0) - -- feat(button)!: migrating button to core-tokens (CSS-97) (#1479) ([0640be0](https://github.com/adobe/spectrum-css/commit/0640be0)), closes [#1479](https://github.com/adobe/spectrum-css/issues/1479) - -### 🛑 BREAKING CHANGE - -- migrates the Button to core tokens - -## 5.0.0 - -🗓 2023-01-31 • 📝 [Commits](https://github.com/adobe/spectrum-css/compare/@spectrum-css/commons@4.0.2...@spectrum-css/commons@5.0.0) - -- feat(button)!: migrating button to core-tokens (CSS-97) (#1479) ([0640be0](https://github.com/adobe/spectrum-css/commit/0640be0)), closes [#1479](https://github.com/adobe/spectrum-css/issues/1479) - -### 🛑 BREAKING CHANGE - -- migrates the Button to core tokens v5.0.0 ([6e640ba](https://github.com/adobe/spectrum-css/commit/6e640ba)) - -## 4.0.2 - -🗓 2023-01-18 • 📝 [Commits](https://github.com/adobe/spectrum-css/compare/@spectrum-css/commons@4.0.0...@spectrum-css/commons@4.0.2) - -**Note:** Version bump only for package @spectrum-css/commons - -## 4.0.1 - -🗓 2023-01-13 • 📝 [Commits](https://github.com/adobe/spectrum-css/compare/@spectrum-css/commons@4.0.0...@spectrum-css/commons@4.0.1) - -**Note:** Version bump only for package @spectrum-css/commons - -## 4.0.0 - -🗓 2022-11-10 • 📝 [Commits](https://github.com/adobe/spectrum-css/compare/@spectrum-css/commons@3.0.6...@spectrum-css/commons@4.0.0) - -- refactor(popover)!: migrate to core tokens (#1509) ([011e486](https://github.com/adobe/spectrum-css/commit/011e486)), closes [#1509](https://github.com/adobe/spectrum-css/issues/1509) - -### 🛑 BREAKING CHANGE - -- migrates popover to core tokens - -Co-authored-by: Garth Braithwaite -Co-authored-by: Patrick Fulton - -## 3.0.6 - -🗓 2022-06-16 • 📝 [Commits](https://github.com/adobe/spectrum-css/compare/@spectrum-css/commons@3.0.5...@spectrum-css/commons@3.0.6) - -**Note:** Version bump only for package @spectrum-css/commons - -## 3.0.5 - -🗓 2022-01-05 • 📝 [Commits](https://github.com/adobe/spectrum-css/compare/@spectrum-css/commons@3.0.4...@spectrum-css/commons@3.0.5) - -### 🐛 Bug fixes - -- unbreak the build ([d595cad](https://github.com/adobe/spectrum-css/commit/d595cad)) - -## 3.0.4 - -🗓 2022-01-05 • 📝 [Commits](https://github.com/adobe/spectrum-css/compare/@spectrum-css/commons@3.0.3...@spectrum-css/commons@3.0.4) - -**Note:** Version bump only for package @spectrum-css/commons - -## 3.0.3 - -🗓 2021-09-29 • 📝 [Commits](https://github.com/adobe/spectrum-css/compare/@spectrum-css/commons@3.0.2...@spectrum-css/commons@3.0.3) - -**Note:** Version bump only for package @spectrum-css/commons - -## 3.0.2 - -🗓 2021-03-10 • 📝 [Commits](https://github.com/adobe/spectrum-css/compare/@spectrum-css/commons@3.0.1...@spectrum-css/commons@3.0.2) - -### 🐛 Bug fixes - -- re-enable touch scrolling for buttons. ([ad649f9](https://github.com/adobe/spectrum-css/commit/ad649f9)) - -## 3.0.1 - -🗓 2021-02-02 • 📝 [Commits](https://github.com/adobe/spectrum-css/compare/@spectrum-css/commons@3.0.0...@spectrum-css/commons@3.0.1) - -**Note:** Version bump only for package @spectrum-css/commons - -## 3.0.0 - -🗓 2020-12-04 • 📝 [Commits](https://github.com/adobe/spectrum-css/compare/@spectrum-css/commons@2.1.0...@spectrum-css/commons@3.0.0) - -### ✨ Features - -- fixup padding ([612dd0c](https://github.com/adobe/spectrum-css/commit/612dd0c)) -- implement t-shirt sizing for Action Button, closes [#936](https://github.com/adobe/spectrum-css/issues/936) ([1a9ecf6](https://github.com/adobe/spectrum-css/commit/1a9ecf6)) - -### 🛑 BREAKING CHANGE - -- .spectrum-ActionButton is no longer part of the button component, use the actionbutton component - -## 2.1.0 - -🗓 2020-02-10 • 📝 [Commits](https://github.com/adobe/spectrum-css/compare/@spectrum-css/commons@2.0.0...@spectrum-css/commons@2.1.0) - -### ✨ Features - -- adding t-shirt sized typography, fixes [#210](https://github.com/adobe/spectrum-css/issues/210), closes [#416](https://github.com/adobe/spectrum-css/issues/416) ([#408](https://github.com/adobe/spectrum-css/issues/408)) ([3921bcb](https://github.com/adobe/spectrum-css/commit/3921bcb)), closes [#523](https://github.com/adobe/spectrum-css/issues/523) - -## 2.0.0 - -🗓 2019-10-08 - -### ✨ Features - -- move to individually versioned packages with Lerna ([#265](https://github.com/adobe/spectrum-css/issues/265)) ([cb7fd4b](https://github.com/adobe/spectrum-css/commit/cb7fd4b)), closes [#231](https://github.com/adobe/spectrum-css/issues/231) [#214](https://github.com/adobe/spectrum-css/issues/214) [#229](https://github.com/adobe/spectrum-css/issues/229) [#240](https://github.com/adobe/spectrum-css/issues/240) [#239](https://github.com/adobe/spectrum-css/issues/239) [#161](https://github.com/adobe/spectrum-css/issues/161) [#242](https://github.com/adobe/spectrum-css/issues/242) [#246](https://github.com/adobe/spectrum-css/issues/246) [#219](https://github.com/adobe/spectrum-css/issues/219) [#235](https://github.com/adobe/spectrum-css/issues/235) [#189](https://github.com/adobe/spectrum-css/issues/189) [#248](https://github.com/adobe/spectrum-css/issues/248) [#232](https://github.com/adobe/spectrum-css/issues/232) [#248](https://github.com/adobe/spectrum-css/issues/248) [#218](https://github.com/adobe/spectrum-css/issues/218) [#237](https://github.com/adobe/spectrum-css/issues/237) [#255](https://github.com/adobe/spectrum-css/issues/255) [#256](https://github.com/adobe/spectrum-css/issues/256) [#258](https://github.com/adobe/spectrum-css/issues/258) [#257](https://github.com/adobe/spectrum-css/issues/257) [#259](https://github.com/adobe/spectrum-css/issues/259) diff --git a/components/commons/basebutton.css b/components/commons/basebutton.css deleted file mode 100644 index fa015bc145f..00000000000 --- a/components/commons/basebutton.css +++ /dev/null @@ -1,124 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -%spectrum-BaseButton { - cursor: pointer; - user-select: none; - - /* Contain halo */ - position: relative; - - /* Show the button overflow in Edge. */ - overflow: visible; - display: inline-flex; - align-items: center; - justify-content: center; - - box-sizing: border-box; - - /* Remove button the margin in Firefox and Safari. */ - margin: 0; - - /* @deprecation --mod-sans-font-family-stack has been renamed and will be removed in a future version. */ - font-family: var(--mod-button-font-family, var(--mod-sans-font-family-stack, var(--spectrum-sans-font-family-stack))); - - -webkit-font-smoothing: antialiased; - - /* Font smoothing for Firefox */ - -moz-osx-font-smoothing: grayscale; - - /* @deprecation --mod-line-height-100 has been renamed and will be removed in a future version. */ - line-height: var(--mod-button-line-height, var(--mod-line-height-100, var(--spectrum-line-height-100))); - text-decoration: none; - - /* Remove the inheritance of text transform on button in Edge, Firefox, and IE. */ - text-transform: none; - - /* Adjacent buttons should be aligned correctly */ - vertical-align: top; - - /* stylelint-disable-next-line property-no-vendor-prefix -- Correct the inability to style clickable types in iOS and Safari (normalize). */ - -webkit-appearance: button; - - border-style: solid; - - transition: - background var(--mod-button-animation-duration, var(--mod-animation-duration-100, var(--spectrum-animation-duration-100))) ease-out, - border-color var(--mod-button-animation-duration, var(--mod-animation-duration-100, var(--spectrum-animation-duration-100))) ease-out, - color var(--mod-button-animation-duration, var(--mod-animation-duration-100, var(--spectrum-animation-duration-100))) ease-out, - box-shadow var(--mod-button-animation-duration, var(--mod-animation-duration-100, var(--spectrum-animation-duration-100))) ease-out; - - /* Fix Firefox */ - &::-moz-focus-inner { - border-style: none; - padding: 0; - } - - &:focus { - outline: none; - } - - &:disabled, - &.is-disabled { - cursor: default; - } -} - -%spectrum-ButtonIcon { - flex-shrink: 0; - max-block-size: 100%; -} - -%spectrum-ButtonWithFocusRing { - &::after { - content: ""; - - position: absolute; - inset-block-start: 0; - inset-block-end: 0; - inset-inline-start: 0; - inset-inline-end: 0; - - display: block; - - margin: calc(-1 * var(--mod-button-focus-indicator-gap, var(--spectrum-focus-indicator-gap))); - - transition: - opacity var(--mod-button-animation-duration, var(--mod-button-animation-duration, var(--spectrum-animation-duration-100))) ease-out, - margin var(--mod-button-animation-duration, var(--mod-button-animation-duration, var(--spectrum-animation-duration-100))) ease-out; - } - - &:focus-visible::after { - margin: calc(-2 * var(--mod-focus-indicator-gap, var(--spectrum-focus-indicator-gap))); - } -} - -%spectrum-AnchorButton { - /* Make link text not selectable */ - user-select: none; - - /* stylelint-disable-next-line property-no-vendor-prefix -- Remove appearance for clickable types in iOS and Safari. */ - -webkit-appearance: none; -} - -%spectrum-ButtonLabel { - align-self: center; - justify-self: center; - - /* Fixes horizontal alignment of text in anchor buttons */ - text-align: center; - - &:empty { - display: none; - } -} diff --git a/components/commons/index.css b/components/commons/index.css deleted file mode 100644 index 90a509a509f..00000000000 --- a/components/commons/index.css +++ /dev/null @@ -1,15 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -@import "./basebutton.css"; -@import "./overlay.css"; diff --git a/components/commons/overlay.css b/components/commons/overlay.css deleted file mode 100644 index fc40b564b05..00000000000 --- a/components/commons/overlay.css +++ /dev/null @@ -1,33 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* TODO: replace legacy animation variables with core tokens when available */ - -/** @note used in modal, tooltip, underlay */ -%spectrum-overlay { - pointer-events: none; - visibility: hidden; - opacity: 0; - transition: - transform var(--mod-overlay-animation-duration, var(--spectrum-animation-duration-100, 130ms)) ease-in-out, - opacity var(--mod-overlay-animation-duration, var(--spectrum-animation-duration-100, 130ms)) ease-in-out, - visibility 0ms linear var(--mod-overlay-animation-duration, var(--spectrum-animation-duration-100, 130ms)); -} - -/** @note used in modal, tooltip, underlay */ -%spectrum-overlay--open { - pointer-events: auto; - visibility: visible; - opacity: 1; - transition-delay: var(--mod-overlay-animation-duration-opened, var(--spectrum-animation-duration-0, 0ms)); -} diff --git a/components/commons/package.json b/components/commons/package.json deleted file mode 100644 index 967498c72aa..00000000000 --- a/components/commons/package.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "name": "@spectrum-css/commons", - "version": "11.1.0", - "description": "Common mixins for Spectrum CSS components", - "license": "Apache-2.0", - "author": "Adobe", - "homepage": "https://opensource.adobe.com/spectrum-css/", - "repository": { - "type": "git", - "url": "https://github.com/adobe/spectrum-css.git", - "directory": "components/commons" - }, - "bugs": { - "url": "https://github.com/adobe/spectrum-css/issues" - }, - "exports": { - ".": "./index.css", - "./*.md": "./*.md", - "./package.json": "./package.json", - "./*.css": "./*.css", - "./stories/*": "./stories/*" - }, - "main": "index.css", - "files": [ - "*.md", - "package.json" - ], - "peerDependencies": { - "@spectrum-css/tokens": ">=16.0.1" - }, - "peerDependenciesMeta": { - "@spectrum-css/tokens": { - "optional": true - } - }, - "devDependencies": { - "@spectrum-css/tokens": "16.0.2" - }, - "keywords": [ - "design-system", - "spectrum", - "spectrum-css", - "adobe", - "adobe-spectrum", - "css" - ], - "publishConfig": { - "access": "public" - } -} diff --git a/components/commons/project.json b/components/commons/project.json deleted file mode 100644 index 1115b61271c..00000000000 --- a/components/commons/project.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "$schema": "../../node_modules/nx/schemas/project-schema.json", - "name": "commons", - "tags": ["utility"], - "targets": { - "build": { - "executor": "nx:noop" - }, - "clean": { - "executor": "nx:noop" - }, - "compare": { - "executor": "nx:noop" - }, - "format": {}, - "lint": {}, - "report": { - "executor": "nx:noop" - }, - "test": { - "executor": "nx:noop" - }, - "validate": {} - } -} diff --git a/components/contextualhelp/CHANGELOG.md b/components/contextualhelp/CHANGELOG.md index 7bef47843e4..665c06f245a 100644 --- a/components/contextualhelp/CHANGELOG.md +++ b/components/contextualhelp/CHANGELOG.md @@ -1,5 +1,84 @@ # Change log +## 6.0.0-next.3 + +### Major Changes + +📝 [#3909](https://github.com/adobe/spectrum-css/pull/3909) [`08b3345`](https://github.com/adobe/spectrum-css/commit/08b33457975293c07b5c7d2f60a305f5fd8be77e) Thanks [@cdransf](https://github.com/cdransf)! + +#### S2 migration for contextual help + +This migrates the contextual help component to the latest Spectrum 2 designs. Custom properties have been remapped and added per the design specification. + +Typographic and color tokens have been updated per design specifications. + +All existing popover positioning variations are supported. + +##### New custom properties + +`--spectrum-contextual-help-body-color` +`--spectrum-contextual-help-body-line-height` +`--spectrum-contextual-help-body-sans-serif-font-family` +`--spectrum-contextual-help-body-sans-serif-font-style` +`--spectrum-contextual-help-body-sans-serif-font-weight` +`--spectrum-contextual-help-title-color` +`--spectrum-contextual-help-title-font-style` +`--spectrum-contextual-help-title-font-weight` +`--spectrum-contextual-help-title-line-height` +`--spectrum-contextual-help-title-sans-serif-font-family` + +##### New mods + +`--mod-contextual-help-body-line-height` +`--mod-contextual-help-body-sans-serif-font-family` +`--mod-contextual-help-body-sans-serif-font-style` +`--mod-contextual-help-body-sans-serif-font-weight` +`--mod-contextual-help-body-size` +`--mod-contextual-help-title-color` +`--mod-contextual-help-title-font-style` +`--mod-contextual-help-title-font-weight` +`--mod-contextual-help-title-line-height` +`--mod-contextual-help-title-sans-serif-font-family` +`--mod-contextual-help-content-spacing` +`--mod-contextual-help-heading-size` +`--mod-contextual-help-link-spacing` +`--mod-contextual-help-min-inline-size` +`--mod-contextual-help-padding` +`--mod-contextual-help-popover-maximum-width` + +##### Removed mods + +`--mod-contextual-help-title-sans-serif-font-family` +`--mod-spectrum-contextual-help-body-size` +`--mod-spectrum-contextual-help-content-spacing` +`--mod-spectrum-contextual-help-heading-size` +`--mod-spectrum-contextual-help-link-spacing` +`--mod-spectrum-contextual-help-minimum-width` +`--mod-spectrum-contextual-help-padding` +`--mod-spectrum-contextual-help-popover-maximum-width` + +## 6.0.0-next.2 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + +## 6.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`c88fcdc`](https://github.com/adobe/spectrum-css/commit/c88fcdcfa4866f4b3ff7a1027e4253b8f2114351)]: + - @spectrum-css/link@8.0.0-next.0 + +## 6.0.0-next.0 + +### Patch Changes + +- Updated dependencies []: + - @spectrum-css/actionbutton@8.0.0-next.0 + - @spectrum-css/popover@9.0.0-next.0 + ## 5.2.0 ### Minor Changes diff --git a/components/contextualhelp/dist/metadata.json b/components/contextualhelp/dist/metadata.json index 4f7dbd58c5b..a64ded05750 100644 --- a/components/contextualhelp/dist/metadata.json +++ b/components/contextualhelp/dist/metadata.json @@ -10,31 +10,63 @@ ], "modifiers": [ "--mod-contextual-help-body-color", - "--mod-contextual-help-heading-color", - "--mod-spectrum-contextual-help-body-size", - "--mod-spectrum-contextual-help-content-spacing", - "--mod-spectrum-contextual-help-heading-size", - "--mod-spectrum-contextual-help-link-spacing", - "--mod-spectrum-contextual-help-minimum-width", - "--mod-spectrum-contextual-help-padding", - "--mod-spectrum-contextual-help-popover-maximum-width" + "--mod-contextual-help-body-line-height", + "--mod-contextual-help-body-sans-serif-font-family", + "--mod-contextual-help-body-sans-serif-font-style", + "--mod-contextual-help-body-sans-serif-font-weight", + "--mod-contextual-help-body-size", + "--mod-contextual-help-content-spacing", + "--mod-contextual-help-heading-size", + "--mod-contextual-help-link-spacing", + "--mod-contextual-help-min-inline-size", + "--mod-contextual-help-padding", + "--mod-contextual-help-popover-maximum-width", + "--mod-contextual-help-title-color", + "--mod-contextual-help-title-font-style", + "--mod-contextual-help-title-font-weight", + "--mod-contextual-help-title-line-height", + "--mod-contextual-help-title-sans-serif-font-family" ], "component": [ + "--spectrum-contextual-help-body-color", + "--spectrum-contextual-help-body-line-height", + "--spectrum-contextual-help-body-sans-serif-font-family", + "--spectrum-contextual-help-body-sans-serif-font-style", + "--spectrum-contextual-help-body-sans-serif-font-weight", "--spectrum-contextual-help-body-size", "--spectrum-contextual-help-content-spacing", + "--spectrum-contextual-help-link-spacing", + "--spectrum-contextual-help-min-inline-size", "--spectrum-contextual-help-minimum-width", + "--spectrum-contextual-help-padding", + "--spectrum-contextual-help-title-color", + "--spectrum-contextual-help-title-font-style", + "--spectrum-contextual-help-title-font-weight", + "--spectrum-contextual-help-title-line-height", + "--spectrum-contextual-help-title-sans-serif-font-family", "--spectrum-contextual-help-title-size" ], "global": [ "--spectrum-body-color", - "--spectrum-heading-color", + "--spectrum-body-sans-serif-font-style", + "--spectrum-body-sans-serif-font-weight", + "--spectrum-corner-radius-large-default", + "--spectrum-line-height-200", + "--spectrum-sans-font-family-stack", + "--spectrum-spacing-100", "--spectrum-spacing-300", - "--spectrum-spacing-400" + "--spectrum-spacing-400", + "--spectrum-title-color", + "--spectrum-title-line-height", + "--spectrum-title-sans-serif-font-style", + "--spectrum-title-sans-serif-font-weight" + ], + "passthroughs": [ + "--mod-popover-animation-distance", + "--mod-popover-corner-radius" ], - "system-theme": [], - "passthroughs": [], "high-contrast": [ "--highcontrast-contextual-help-body-color", - "--highcontrast-contextual-help-heading-color" + "--highcontrast-contextual-help-title-color" ] } diff --git a/components/contextualhelp/index.css b/components/contextualhelp/index.css index 68152fd353b..c416b8395c0 100644 --- a/components/contextualhelp/index.css +++ b/components/contextualhelp/index.css @@ -1,5 +1,5 @@ /*! - * Copyright 2024 Adobe. All rights reserved. + * Copyright 2025 Adobe. All rights reserved. * * This file is licensed to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. You may obtain a copy @@ -11,9 +11,34 @@ * governing permissions and limitations under the License. */ +.spectrum-ContextualHelp { + --spectrum-contextual-help-title-sans-serif-font-family: var(--spectrum-sans-font-family-stack); + --spectrum-contextual-help-title-font-weight: var(--spectrum-title-sans-serif-font-weight); + --spectrum-contextual-help-title-font-style: var(--spectrum-title-sans-serif-font-style); + --spectrum-contextual-help-title-line-height: var(--spectrum-title-line-height); + + --spectrum-contextual-help-title-color: var(--spectrum-title-color); + + --spectrum-contextual-help-body-sans-serif-font-family: var(--spectrum-sans-font-family-stack); + --spectrum-contextual-help-body-sans-serif-font-weight: var(--spectrum-body-sans-serif-font-weight); + --spectrum-contextual-help-body-sans-serif-font-style: var(--spectrum-body-sans-serif-font-style); + --spectrum-contextual-help-body-line-height: var(--spectrum-line-height-200); + + --spectrum-contextual-help-body-color: var(--spectrum-body-color); + + --spectrum-contextual-help-min-inline-size: var(--spectrum-contextual-help-minimum-width); + --spectrum-contextual-help-link-spacing: var(--spectrum-spacing-300); + --spectrum-contextual-help-padding: var(--spectrum-spacing-400); + + /* @passthrough start */ + --mod-popover-animation-distance: var(--spectrum-spacing-100); + --mod-popover-corner-radius: var(--spectrum-corner-radius-large-default); + /* @passthrough end */ +} + .spectrum-ContextualHelp { position: relative; - min-inline-size: var(--mod-spectrum-contextual-help-minimum-width, var(--spectrum-contextual-help-minimum-width)); + min-inline-size: var(--mod-contextual-help-min-inline-size, var(--spectrum-contextual-help-min-inline-size)); } .spectrum-ContextualHelp-button { @@ -21,12 +46,11 @@ } .spectrum-ContextualHelp-popover { - padding-block: var(--mod-spectrum-contextual-help-padding, var(--spectrum-spacing-400)); - padding-inline: var(--mod-spectrum-contextual-help-padding, var(--spectrum-spacing-400)); - font-size: var(--mod-spectrum-contextual-help-body-size, var(--spectrum-contextual-help-body-size)); + padding: var(--mod-contextual-help-padding, var(--spectrum-contextual-help-padding)); + font-size: var(--mod-contextual-help-body-size, var(--spectrum-contextual-help-body-size)); color: var(--highcontrast-contextual-help-body-color, var(--mod-contextual-help-body-color, var(--spectrum-body-color))); - max-inline-size: var(--mod-spectrum-contextual-help-popover-maximum-width); + max-inline-size: var(--mod-contextual-help-popover-maximum-width); .spectrum-ContextualHelp-heading, .spectrum-ContextualHelp-body { @@ -34,19 +58,32 @@ } .spectrum-ContextualHelp-heading { - margin-block-end: var(--mod-spectrum-contextual-help-content-spacing, var(--spectrum-contextual-help-content-spacing)); - font-size: var(--mod-spectrum-contextual-help-heading-size, var(--spectrum-contextual-help-title-size)); - color: var(--highcontrast-contextual-help-heading-color, var(--mod-contextual-help-heading-color, var(--spectrum-heading-color))); + font-family: var(--mod-contextual-help-title-sans-serif-font-family, var(--spectrum-contextual-help-title-sans-serif-font-family)); + font-weight: var(--mod-contextual-help-title-font-weight, var(--spectrum-contextual-help-title-font-weight)); + font-size: var(--mod-contextual-help-heading-size, var(--spectrum-contextual-help-title-size)); + font-style: var(--mod-contextual-help-title-font-style, var(--spectrum-contextual-help-title-font-style)); + line-height: var(--mod-contextual-help-title-line-height, var(--spectrum-contextual-help-title-line-height)); + color: var(--highcontrast-contextual-help-title-color, var(--mod-contextual-help-title-color, var(--spectrum-contextual-help-title-color))); + margin-block-end: var(--mod-contextual-help-content-spacing, var(--spectrum-contextual-help-content-spacing)); + } + + .spectrum-ContextualHelp-body { + font-size: var(--mod-contextual-help-body-size, var(--spectrum-contextual-help-body-size)); + font-family: var(--mod-contextual-help-body-sans-serif-font-family, var(--spectrum-contextual-help-body-sans-serif-font-family)); + font-weight: var(--mod-contextual-help-body-sans-serif-font-weight, var(--spectrum-contextual-help-body-sans-serif-font-weight)); + font-style: var(--mod-contextual-help-body-sans-serif-font-style, var(--spectrum-contextual-help-body-sans-serif-font-style)); + line-height: var(--mod-contextual-help-body-line-height, var(--spectrum-contextual-help-body-line-height)); + color: var(--mod-contextual-help-body-color, var(--spectrum-contextual-help-body-color)); } } .spectrum-ContextualHelp-link { - margin-block-start: var(--mod-spectrum-contextual-help-link-spacing, var(--spectrum-spacing-300)); + margin-block-start: var(--mod-contextual-help-link-spacing, var(--spectrum-contextual-help-link-spacing)); } @media (forced-colors: active) { .spectrum-ContextualHelp { - --highcontrast-contextual-help-heading-color: CanvasText; + --highcontrast-contextual-help-title-color: CanvasText; --highcontrast-contextual-help-body-color: CanvasText; } } diff --git a/components/contextualhelp/package.json b/components/contextualhelp/package.json index 3ec0c9eb959..58f21b859a4 100644 --- a/components/contextualhelp/package.json +++ b/components/contextualhelp/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/contextualhelp", - "version": "5.2.0", + "version": "6.0.0-next.3", "description": "The Spectrum CSS contextualhelp component", "license": "Apache-2.0", "author": "Adobe", @@ -24,10 +24,10 @@ }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/actionbutton": ">=7.0.0 <8.0.0", - "@spectrum-css/link": ">=7.0.0 <8.0.0", - "@spectrum-css/popover": ">=8.0.0 <9.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/actionbutton": ">=8.0.0-next.0", + "@spectrum-css/link": ">=8.0.0-next.0", + "@spectrum-css/popover": ">=9.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/actionbutton": { @@ -44,10 +44,10 @@ } }, "devDependencies": { - "@spectrum-css/actionbutton": "7.2.0", - "@spectrum-css/link": "7.2.0", - "@spectrum-css/popover": "8.3.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/actionbutton": "8.0.0-next.4", + "@spectrum-css/link": "8.0.0-next.2", + "@spectrum-css/popover": "9.0.0-next.5", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/contextualhelp/stories/contextualhelp.stories.js b/components/contextualhelp/stories/contextualhelp.stories.js index 4b7abd0296a..9c9715ab76b 100644 --- a/components/contextualhelp/stories/contextualhelp.stories.js +++ b/components/contextualhelp/stories/contextualhelp.stories.js @@ -1,10 +1,12 @@ import { default as ActionButtonStories } from "@spectrum-css/actionbutton/stories/actionbutton.stories.js"; +import { default as Popover } from "@spectrum-css/popover/stories/popover.stories.js"; import { disableDefaultModes } from "@spectrum-css/preview/modes"; -import metadata from "../dist/metadata.json"; -import packageJson from "../package.json"; import { ContextualHelpGroup } from "./contextualhelp.test.js"; import { Template } from "./template.js"; +import metadata from "../dist/metadata.json"; +import packageJson from "../package.json"; + /** * Contextual help shows a user extra information in relation to another component or view. */ @@ -31,61 +33,40 @@ export default { iconName: { name: "Icon", type: { name: "string", required: true }, - defaultValue: "Info", + defaultValue: "InfoCircle", table: { type: { summary: "string" }, category: "Component", defaultValue: { summary: "Info" }, }, - options: ["Info", "Help"], + options: ["InfoCircle", "HelpCircle"], control: "select", }, iconSet: { table: { disable: true } }, popoverPlacement: { - name: "Popover Placement", - type: { name: "string", required: true }, - defaultValue: "bottom-start", + ...Popover.argTypes.position, + name: "Popover placement", + }, + link: { + name: "Has link", + type: { name: "boolean", required: false }, + defaultValue: false, table: { - type: { summary: "string" }, + summary: "boolean", category: "Component", - defaultValue: { summary: "Info" }, - }, - options: [ - "top", - "top-left", - "top-right", - "top-start", - "top-end", - "bottom", - "bottom-left", - "bottom-right", - "bottom-start", - "bottom-end", - "left", - "left-top", - "left-bottom", - "start", - "start-top", - "start-bottom", - "right", - "right-top", - "right-bottom", - "end", - "end-top", - "end-bottom", - ], - control: "select", + defaultValue: { summary: false } + } }, - link: { table: { disable: true } }, }, args: { rootClass: "spectrum-ContextualHelp", - iconName: "Info", + iconName: "InfoCircle", iconSet: "workflow", popoverPlacement: "bottom-start", + link: false, title: "Permission required", body: "Your admin must grant you permission before you can create a new document. Please contact your admin for more information.", - customStyles: { "inline-size": "275px" }, + customStyles: { "inline-size": "var(--spectrum-contextual-help-min-inline-size)" }, }, parameters: { actions: { @@ -97,12 +78,11 @@ export default { }, packageJson, metadata, - docs: { - story: { - height: "200px", - }, + status: { + type: "migrated", }, }, + tags: ["migrated"] }; /** @@ -130,28 +110,6 @@ WithLink.parameters = { }; WithLink.storyName = "Default - info icon with link"; -/** - * In order to further customize the contextual help popover, implementations can set `--mod-spectrum-contextual-help-popover-maximum-width` to their desired max width. - */ -export const MaxWidthPopover = Template.bind({}); -MaxWidthPopover.tags = ["!dev"]; -MaxWidthPopover.args = { - customStyles: { - "inline-size": "275px", - "--mod-spectrum-contextual-help-popover-maximum-width": "180px", - "margin-bottom": "270px", - }, -}; -MaxWidthPopover.parameters = { - chromatic: { disableSnapshot: true }, - docs: { - story: { - height: "auto", - }, - }, -}; -MaxWidthPopover.storyName = "Default - max width popover"; - /** * This is an example of the contextual help component within a popover with a placement of `top`. Read more about the 22 available placement positions in the [popover documentation](/docs/components-popover--docs). */ @@ -159,28 +117,21 @@ export const TopPopover = Template.bind({}); TopPopover.tags = ["!dev"]; TopPopover.args = { popoverPlacement: "top", - customStyles: { - "inline-size": "275px", - "margin-top": "170px", - }, }; TopPopover.parameters = { chromatic: { disableSnapshot: true }, - docs: { - story: { - height: "auto", - }, - }, }; TopPopover.storyName = "Default - top popover"; /** * When displaying help or resources to learn more, the contextual help should use the help icon. The content in this variant provides more detailed, in-depth guidance about a task, UI element, tool or keyboard shortcuts. + * + * All variants and positions of the contextual help component can be configured with a help icon. */ export const HelpDefault = Template.bind({}); HelpDefault.tags = ["!dev"]; HelpDefault.args = { - iconName: "Help", + iconName: "HelpCircle", title: "Need help?", }; HelpDefault.parameters = { @@ -188,66 +139,6 @@ HelpDefault.parameters = { }; HelpDefault.storyName = "Help icon"; -export const HelpWithLink = Template.bind({}); -HelpWithLink.tags = ["!dev"]; -HelpWithLink.args = { - link: { - text: "Learn about permissions", - url: "#", - }, - iconName: "Help", - title: "Need help?", - body: "Reach out to your admin for help regarding the document you are trying to create.", -}; -HelpWithLink.parameters = { - chromatic: { disableSnapshot: true }, -}; -HelpWithLink.storyName = "Help icon - with link"; - -export const HelpTopPopover = Template.bind({}); -HelpTopPopover.tags = ["!dev"]; -HelpTopPopover.args = { - popoverPlacement: "top", - customStyles: { - "inline-size": "275px", - "margin-top": "170px", - }, - title: "Need help?", - body: "Reach out to your admin for help regarding the document you are trying to create.", - iconName: "Help", -}; -HelpTopPopover.parameters = { - chromatic: { disableSnapshot: true }, - docs: { - story: { - height: "auto", - }, - }, -}; -HelpTopPopover.storyName = "Help icon - top popover"; - -export const HelpMaxWidthPopover = Template.bind({}); -HelpMaxWidthPopover.tags = ["!dev"]; -HelpMaxWidthPopover.args = { - customStyles: { - "inline-size": "275px", - "--mod-spectrum-contextual-help-popover-maximum-width": "180px", - "margin-bottom": "270px", - }, - title: "Need help?", - body: "Reach out to your admin for help regarding the document you are trying to create.", - iconName: "Help", -}; -HelpMaxWidthPopover.parameters = { - chromatic: { disableSnapshot: true }, - docs: { - story: { - height: "auto", - }, - }, -}; -HelpMaxWidthPopover.storyName = "Help icon - max width popover"; - // ********* VRT ONLY ********* // export const WithForcedColors = ContextualHelpGroup.bind({}); WithForcedColors.args = Default.args; diff --git a/components/contextualhelp/stories/contextualhelp.test.js b/components/contextualhelp/stories/contextualhelp.test.js index 7fea0b99dc3..3bc35936298 100644 --- a/components/contextualhelp/stories/contextualhelp.test.js +++ b/components/contextualhelp/stories/contextualhelp.test.js @@ -6,37 +6,14 @@ export const ContextualHelpGroup = Variants({ testData: [ { testHeading: "Default", - customStyles: { - "inline-size": "275px", - "margin-bottom": "170px", - }, - }, - { - testHeading: "Max-width popover", - customStyles: { - "inline-size": "275px", - "margin-bottom": "275px", - "--mod-spectrum-contextual-help-popover-maximum-width": "150px", - }, }, { testHeading: "With link", - customStyles: { - "inline-size": "275px", - "margin-bottom": "200px", - }, - link: { - text: "Learn about permissions", - url: "#", - }, + link: true, }, { testHeading: "Help", - iconName: "Help", - customStyles: { - "inline-size": "275px", - "margin-bottom": "170px", - }, + iconName: "HelpCircle", }, ], }); diff --git a/components/contextualhelp/stories/template.js b/components/contextualhelp/stories/template.js index aaeac140d32..45a1ebd8ef0 100644 --- a/components/contextualhelp/stories/template.js +++ b/components/contextualhelp/stories/template.js @@ -21,6 +21,9 @@ export const Template = ({ customStyles = {}, customClasses = [], } = {}, context = {}) => { + const { globals = {} } = context; + const scale = globals.scale ?? "medium"; + return html`
    ActionButton({ ...passthrough, - size: "xs", + size: scale === "medium" ? "xs" : "s", iconName, iconSet, customClasses: [`${rootClass}-button`], }, context), content: [ - title ? html`

    ${title}

    ` : "", - body ? html`

    ${body}

    ` : "", + title ? html`

    ${title}

    ` : nothing, + body ? html`

    ${body}

    ` : nothing, link ? Link({ - text: link.text, - url: link.url, + text: "Link text", + url: "#", customClasses: [`${rootClass}-link`], }) : nothing, @@ -53,8 +56,6 @@ export const Template = ({ position: popoverPlacement, customClasses: [`${rootClass}-popover`], customStyles, - popoverWidth: 275, - popoverHeight: 150, }, context)}
    `; diff --git a/components/datepicker/CHANGELOG.md b/components/datepicker/CHANGELOG.md index 6d17c57139b..70646d572bf 100644 --- a/components/datepicker/CHANGELOG.md +++ b/components/datepicker/CHANGELOG.md @@ -1,5 +1,38 @@ # Change log +## 5.0.0-next.2 + +### Patch Changes + +📝 [#4113](https://github.com/adobe/spectrum-css/pull/4113) [`cf4fc1a`](https://github.com/adobe/spectrum-css/commit/cf4fc1a01d23ba810f45a903ecc29a5c8aae33d1) Thanks [@castastrophe](https://github.com/castastrophe)! + +## Minor linting fixes + +- Removed unused custom properties across multiple components +- Fixed color function notation by converting `rgba()` to `rgb()` where appropriate +- Removed duplicate custom property declarations +- Fixed deprecated CSS properties (e.g., `word-wrap` → `overflow-wrap`) +- Removed unnecessary stylelint-disable comments + +_No visual or functional changes to components._ + +## 5.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + +## 5.0.0-next.0 + +### Patch Changes + +- Updated dependencies []: + - @spectrum-css/pickerbutton@7.0.0-next.0 + - @spectrum-css/calendar@8.0.0-next.0 + - @spectrum-css/popover@9.0.0-next.0 + - @spectrum-css/textfield@9.0.0-next.0 + ## 4.2.0 ### Minor Changes @@ -258,6 +291,7 @@ Output for all component CSS files is now being run through a lightweight optimi ### 🛑 BREAKING CHANGE - Removes component-builder & component-builder-simple for script leveraging postcss + - Imports added to index.css and themes/express.css ## 2.1.4 diff --git a/components/datepicker/dist/metadata.json b/components/datepicker/dist/metadata.json index f52f1b93cd6..cf8fffe86db 100644 --- a/components/datepicker/dist/metadata.json +++ b/components/datepicker/dist/metadata.json @@ -140,7 +140,6 @@ "--spectrum-text-to-visual-100", "--spectrum-workflow-icon-size-100" ], - "system-theme": ["--system-date-picker-initial-height"], "passthroughs": [ "--mod-picker-button-background-color", "--mod-picker-button-background-color-hover-disabled", diff --git a/components/datepicker/index.css b/components/datepicker/index.css index 7b20a28ae6b..2890b5f54d1 100644 --- a/components/datepicker/index.css +++ b/components/datepicker/index.css @@ -11,13 +11,12 @@ * governing permissions and limitations under the License. */ -@import "./themes/spectrum-two.css"; - .spectrum-DatePicker { --spectrum-datepicker-border-radius: var(--mod-datepicker-border-radius, var(--spectrum-corner-radius-100)); --spectrum-datepicker-border-radius-quiet: var(--mod-datepicker-border-radius-quiet, 0); --spectrum-datepicker-border-width: var(--spectrum-border-width-100); --spectrum-datepicker-min-width: var(--mod-datepicker-min-width, var(--spectrum-field-width)); + --spectrum-datepicker-initial-height: var(--spectrum-component-height-100); --spectrum-datepicker-icon-size: var(--spectrum-workflow-icon-size-100); /* button */ @@ -85,8 +84,10 @@ } &.is-invalid { + /* @passthrough start */ --mod-textfield-icon-spacing-inline-end-invalid: calc(var(--spectrum-datepicker-pickerbutton-width) + var(--spectrum-datepicker-invalid-icon-to-button)); --mod-textfield-icon-spacing-inline-end-quiet-invalid: calc(var(--spectrum-datepicker-pickerbutton-width-quiet) + var(--spectrum-datepicker-invalid-icon-to-button-quiet)); + /* @passthrough end */ } &:not(.spectrum-DatePicker--quiet, .is-disabled) { diff --git a/components/datepicker/package.json b/components/datepicker/package.json index f8506c329c6..d4593a127e4 100644 --- a/components/datepicker/package.json +++ b/components/datepicker/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/datepicker", - "version": "4.2.0", + "version": "5.0.0-next.2", "description": "The Spectrum CSS datepicker component", "license": "Apache-2.0", "author": "Adobe", @@ -19,18 +19,16 @@ "./package.json": "./package.json", "./dist/*": "./dist/*", "./index.css": "./dist/index.css", - "./index-*.css": "./dist/index-*.css", "./metadata.json": "./dist/metadata.json", - "./themes/*": "./dist/themes/*", "./stories/*": "./stories/*" }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/calendar": ">=7.0.0 <8.0.0", - "@spectrum-css/pickerbutton": ">=6.0.0 <7.0.0", - "@spectrum-css/popover": ">=8.0.0 <9.0.0", - "@spectrum-css/textfield": ">=8.0.0 <9.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/calendar": ">=8.0.0-next.0", + "@spectrum-css/pickerbutton": ">=7.0.0-next.0", + "@spectrum-css/popover": ">=9.0.0-next.0", + "@spectrum-css/textfield": ">=9.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/calendar": { @@ -50,11 +48,11 @@ } }, "devDependencies": { - "@spectrum-css/calendar": "7.2.0", - "@spectrum-css/pickerbutton": "6.2.0", - "@spectrum-css/popover": "8.3.0", - "@spectrum-css/textfield": "8.2.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/calendar": "8.0.0-next.3", + "@spectrum-css/pickerbutton": "7.0.0-next.2", + "@spectrum-css/popover": "9.0.0-next.5", + "@spectrum-css/textfield": "9.0.0-next.1", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/datepicker/stories/datepicker.stories.js b/components/datepicker/stories/datepicker.stories.js index fa10174144c..1157597215d 100644 --- a/components/datepicker/stories/datepicker.stories.js +++ b/components/datepicker/stories/datepicker.stories.js @@ -74,14 +74,13 @@ export default { type: "figma", url: "https://www.figma.com/design/Mngz9H7WZLbrCvGQf3GnsY/S2---Desktop?node-id=112153-679", }, - docs: { - story: { - height: "50px" - } - }, packageJson, metadata, + status: { + type: "unmigrated", + }, }, + tags: ["unmigrated"], play: async ({ canvasElement }) => { const canvas = within(canvasElement); @@ -105,11 +104,6 @@ DefaultGroup.args = {}; DefaultGroup.tags = [ "!dev"]; DefaultGroup.storyName = "Default"; DefaultGroup.parameters = { - docs: { - story: { - height: "350px", - } - }, chromatic: { disableSnapshot: true }, }; @@ -123,11 +117,6 @@ Quiet.args = { }; Quiet.parameters = { chromatic: { disableSnapshot: true }, - docs: { - story: { - height: "350px", - } - }, }; /** diff --git a/components/datepicker/stories/template.js b/components/datepicker/stories/template.js index 2d56102d24e..9f653cb8c92 100644 --- a/components/datepicker/stories/template.js +++ b/components/datepicker/stories/template.js @@ -9,9 +9,6 @@ import { classMap } from "lit/directives/class-map.js"; import { ifDefined } from "lit/directives/if-defined.js"; import "../index.css"; -import "../themes/spectrum.css"; -/* Must be imported last */ -import "../themes/express.css"; export const DatePicker = ({ rootClass = "spectrum-DatePicker", @@ -88,12 +85,12 @@ export const DatePicker = ({ }, }, context))} ${PickerButton({ - customClasses: [`${rootClass}-button`], + customClasses: [`${rootClass}-button`, "spectrum-PickerButton--workflowicon"], size: "m", iconName: "Calendar", iconSet: "workflow", isQuiet, - customStyles: isReadOnly ? { "display": "none" } : undefined, + customStyles: isReadOnly ? { "display": "none" } : { "--mod-icon-size": "var(--spectrum-workflow-icon-size-50)" }, // @todo this is not added to the button on the website; need to make sure it's not a bug // isOpen, isInvalid, diff --git a/components/datepicker/themes/express.css b/components/datepicker/themes/express.css deleted file mode 100644 index ead071e6f18..00000000000 --- a/components/datepicker/themes/express.css +++ /dev/null @@ -1,22 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--express */ - -@import "./spectrum.css"; - -@container style(--system: express) { - .spectrum-DatePicker { - --spectrum-datepicker-initial-height: var(--spectrum-component-height-75); - } -} diff --git a/components/datepicker/themes/spectrum-two.css b/components/datepicker/themes/spectrum-two.css deleted file mode 100644 index 05b3ca88ae4..00000000000 --- a/components/datepicker/themes/spectrum-two.css +++ /dev/null @@ -1,18 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -@container style(--system: spectrum) { - .spectrum-DatePicker { - --spectrum-datepicker-initial-height: var(--spectrum-component-height-100); - } -} diff --git a/components/datepicker/themes/spectrum.css b/components/datepicker/themes/spectrum.css deleted file mode 100644 index 3d81bc564b5..00000000000 --- a/components/datepicker/themes/spectrum.css +++ /dev/null @@ -1,16 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--legacy */ - -@import "./spectrum-two.css"; diff --git a/components/dial/CHANGELOG.md b/components/dial/CHANGELOG.md index 8171762a07a..9fe9933764a 100644 --- a/components/dial/CHANGELOG.md +++ b/components/dial/CHANGELOG.md @@ -1,5 +1,28 @@ # Change log +## 6.0.0-next.1 + +### Patch Changes + +📝 [#4113](https://github.com/adobe/spectrum-css/pull/4113) [`cf4fc1a`](https://github.com/adobe/spectrum-css/commit/cf4fc1a01d23ba810f45a903ecc29a5c8aae33d1) Thanks [@castastrophe](https://github.com/castastrophe)! + +## Minor linting fixes + +- Removed unused custom properties across multiple components +- Fixed color function notation by converting `rgba()` to `rgb()` where appropriate +- Removed duplicate custom property declarations +- Fixed deprecated CSS properties (e.g., `word-wrap` → `overflow-wrap`) +- Removed unnecessary stylelint-disable comments + +_No visual or functional changes to components._ + +## 6.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + ## 5.3.0 ### Minor Changes @@ -12,7 +35,9 @@ Ensure accurate exports are present for each component. Specifically, adding `th ### Minor Changes -- [#3527](https://github.com/adobe/spectrum-css/pull/3527) [`5f1751c`](https://github.com/adobe/spectrum-css/commit/5f1751c82a5fe55ae0d999f5f50cfeca4c8a5c75) Thanks [@castastrophe](https://github.com/castastrophe)! - By updating the postcss-preset-env to the latest breaking change version, output for this component no longer injects the `.js-focus-within` and '[focus-within]` selectors for the focus-within polyfill. As this feature is not used in the SWC consumption, risk to the end user for this removal is low. +📝 [#3527](https://github.com/adobe/spectrum-css/pull/3527) [`5f1751c`](https://github.com/adobe/spectrum-css/commit/5f1751c82a5fe55ae0d999f5f50cfeca4c8a5c75) Thanks [@castastrophe](https://github.com/castastrophe)! + +By updating the postcss-preset-env to the latest breaking change version, output for this component no longer injects the `.js-focus-within` and '[focus-within]` selectors for the focus-within polyfill. As this feature is not used in the SWC consumption, risk to the end user for this removal is low. ## 5.1.0 diff --git a/components/dial/dist/metadata.json b/components/dial/dist/metadata.json index cf8d026a3b2..1d91c2bb539 100644 --- a/components/dial/dist/metadata.json +++ b/components/dial/dist/metadata.json @@ -112,10 +112,6 @@ "--spectrum-gray-800", "--spectrum-line-height-200" ], - "system-theme": [ - "--system-dial-background-color-default", - "--system-dial-handle-marker-color-key-focus" - ], "passthroughs": [], "high-contrast": [ "--highcontrast-dial-border-color", diff --git a/components/dial/index.css b/components/dial/index.css index 8aee8cef361..1db955a115f 100644 --- a/components/dial/index.css +++ b/components/dial/index.css @@ -11,9 +11,10 @@ * governing permissions and limitations under the License. */ -@import "./themes/spectrum-two.css"; - .spectrum-Dial { + --spectrum-dial-background-color-default: var(--spectrum-gray-75); + --spectrum-dial-handle-marker-color-key-focus: var(--spectrum-gray-25); + --spectrum-dial-handle-marker-color: var(--spectrum-gray-700); --spectrum-dial-border-color: var(--spectrum-gray-700); diff --git a/components/dial/package.json b/components/dial/package.json index 993c5ec2cd2..a12868872b6 100644 --- a/components/dial/package.json +++ b/components/dial/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/dial", - "version": "5.3.0", + "version": "6.0.0-next.1", "description": "The Spectrum CSS dial component", "license": "Apache-2.0", "author": "Adobe", @@ -19,14 +19,12 @@ "./package.json": "./package.json", "./dist/*": "./dist/*", "./index.css": "./dist/index.css", - "./index-*.css": "./dist/index-*.css", "./metadata.json": "./dist/metadata.json", - "./themes/*": "./dist/themes/*", "./stories/*": "./stories/*" }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/tokens": { @@ -34,7 +32,7 @@ } }, "devDependencies": { - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/dial/stories/dial.stories.js b/components/dial/stories/dial.stories.js index 9e9970e234b..4491aa2b861 100644 --- a/components/dial/stories/dial.stories.js +++ b/components/dial/stories/dial.stories.js @@ -35,7 +35,11 @@ export default { parameters: { packageJson, metadata, + status: { + type: "migrated", + }, }, + tags: ["migrated"], }; export const Default = DialGroup.bind(); diff --git a/components/dial/stories/template.js b/components/dial/stories/template.js index c8f25c2175b..547fb97f661 100644 --- a/components/dial/stories/template.js +++ b/components/dial/stories/template.js @@ -5,9 +5,6 @@ import { ifDefined } from "lit/directives/if-defined.js"; import { when } from "lit/directives/when.js"; import "../index.css"; -import "../themes/spectrum.css"; -/* Must be imported last */ -import "../themes/express.css"; export const Template = ({ rootClass = "spectrum-Dial", diff --git a/components/dial/themes/express.css b/components/dial/themes/express.css deleted file mode 100644 index 9fd550418f2..00000000000 --- a/components/dial/themes/express.css +++ /dev/null @@ -1,16 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--express */ - -@import "./spectrum.css"; diff --git a/components/dial/themes/spectrum-two.css b/components/dial/themes/spectrum-two.css deleted file mode 100644 index 410196c3916..00000000000 --- a/components/dial/themes/spectrum-two.css +++ /dev/null @@ -1,19 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -@container style(--system: spectrum) { - .spectrum-Dial { - --spectrum-dial-background-color-default: var(--spectrum-gray-75); - --spectrum-dial-handle-marker-color-key-focus: var(--spectrum-gray-25); - } -} diff --git a/components/dial/themes/spectrum.css b/components/dial/themes/spectrum.css deleted file mode 100644 index 24077607a8b..00000000000 --- a/components/dial/themes/spectrum.css +++ /dev/null @@ -1,23 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--legacy */ - -@import "./spectrum-two.css"; - -@container style(--system: legacy) { - .spectrum-Dial { - --spectrum-dial-background-color-default: var(--spectrum-gray-100); - --spectrum-dial-handle-marker-color-key-focus: var(--spectrum-gray-50); - } -} diff --git a/components/dialog/CHANGELOG.md b/components/dialog/CHANGELOG.md index aa164628f41..cffbeefbf90 100644 --- a/components/dialog/CHANGELOG.md +++ b/components/dialog/CHANGELOG.md @@ -1,5 +1,45 @@ # Change log +## 13.0.0-next.4 + +### Minor Changes + +📝 [#4000](https://github.com/adobe/spectrum-css/pull/4000) [`f654c8d`](https://github.com/adobe/spectrum-css/commit/f654c8d950e6a1f0a77ce0f2413cb205a3b5e276) Thanks [@marissahuysentruyt](https://github.com/marissahuysentruyt)! + +Increases flexibility and responsiveness of the dialog header. A container query for the `.spectrum-Dialog` was added, which now triggers the reflow of the `.spectrum-Dialog--fullscreen`/`.spectrum-Dialog--fullscreenTakeover` content grid. This is particularly useful when the component slot is utilized to add other components as additional content in fullscreen/fullscreenTakeover dialogs' header areas by allowing the content to reflow sooner. + +## 13.0.0-next.3 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + - @spectrum-css/modal@8.0.0-next.1 + - @spectrum-css/underlay@7.0.0-next.0 + +## 13.0.0-next.2 + +### Patch Changes + +- Updated dependencies [[`cb1b957`](https://github.com/adobe/spectrum-css/commit/cb1b957c05ecf02d3f473de09a8bfd5f2b5d42bf)]: + - @spectrum-css/modal@7.1.1-next.0 + +## 13.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`c6836fb`](https://github.com/adobe/spectrum-css/commit/c6836fb132effcfb09e4ca6d0d8923564bfe2914)]: + - @spectrum-css/divider@6.0.0-next.0 + +## 13.0.0-next.0 + +### Patch Changes + +- Updated dependencies []: + - @spectrum-css/button@15.0.0-next.0 + - @spectrum-css/closebutton@7.0.0-next.0 + - @spectrum-css/buttongroup@10.0.0-next.0 + ## 12.2.0 ### Minor Changes @@ -245,6 +285,7 @@ Output for all component CSS files is now being run through a lightweight optimi ### 🛑 BREAKING CHANGE - Removes component-builder & component-builder-simple for script leveraging postcss + - Imports added to index.css and themes/express.css ## 9.2.4 diff --git a/components/dialog/dist/metadata.json b/components/dialog/dist/metadata.json index 812542da227..738156392db 100644 --- a/components/dialog/dist/metadata.json +++ b/components/dialog/dist/metadata.json @@ -2,100 +2,140 @@ "sourceFile": "index.css", "selectors": [ ".spectrum-Dialog", - ".spectrum-Dialog .spectrum-Dialog-divider", - ".spectrum-Dialog .spectrum-Dialog-grid", ".spectrum-Dialog .spectrum-Dialog-header", + ".spectrum-Dialog--dismissible .spectrum-Dialog-grid", + ".spectrum-Dialog--dismissible .spectrum-Dialog-grid .spectrum-Dialog-footer", ".spectrum-Dialog--fullscreen", ".spectrum-Dialog--fullscreen .spectrum-Dialog-buttonGroup", + ".spectrum-Dialog--fullscreen .spectrum-Dialog-closeButton", ".spectrum-Dialog--fullscreen .spectrum-Dialog-content", ".spectrum-Dialog--fullscreen .spectrum-Dialog-footer", + ".spectrum-Dialog--fullscreen .spectrum-Dialog-grid", + ".spectrum-Dialog--fullscreen .spectrum-Dialog-header", + ".spectrum-Dialog--fullscreen .spectrum-Dialog-header > .spectrum-Dialog-headerContentWrapper", ".spectrum-Dialog--fullscreen .spectrum-Dialog-heading", - ".spectrum-Dialog--fullscreen .spectrum-Dialog-heading + .spectrum-Dialog-divider", ".spectrum-Dialog--fullscreen.spectrum-Dialog .spectrum-Dialog-grid", ".spectrum-Dialog--fullscreenTakeover", ".spectrum-Dialog--fullscreenTakeover .spectrum-Dialog-buttonGroup", + ".spectrum-Dialog--fullscreenTakeover .spectrum-Dialog-closeButton", ".spectrum-Dialog--fullscreenTakeover .spectrum-Dialog-content", ".spectrum-Dialog--fullscreenTakeover .spectrum-Dialog-footer", + ".spectrum-Dialog--fullscreenTakeover .spectrum-Dialog-grid", + ".spectrum-Dialog--fullscreenTakeover .spectrum-Dialog-header", + ".spectrum-Dialog--fullscreenTakeover .spectrum-Dialog-header > .spectrum-Dialog-headerContentWrapper", ".spectrum-Dialog--fullscreenTakeover .spectrum-Dialog-heading", ".spectrum-Dialog--fullscreenTakeover.spectrum-Dialog .spectrum-Dialog-grid", - ".spectrum-Dialog--noDivider .spectrum-Dialog-divider", - ".spectrum-Dialog--noDivider .spectrum-Dialog-heading", ".spectrum-Dialog--sizeL", ".spectrum-Dialog--sizeS", ".spectrum-Dialog-buttonGroup", - ".spectrum-Dialog-buttonGroup.spectrum-Dialog-buttonGroup--noFooter", + ".spectrum-Dialog-buttonGroup--noFooter", ".spectrum-Dialog-closeButton", ".spectrum-Dialog-content", ".spectrum-Dialog-footer", - ".spectrum-Dialog-footer > *", - ".spectrum-Dialog-footer > .spectrum-Button + .spectrum-Button", + ".spectrum-Dialog-footer .spectrum-Dialog-footerContent", + ".spectrum-Dialog-footer:has(.spectrum-Dialog-buttonGroup)", + ".spectrum-Dialog-footer:has(.spectrum-Dialog-footerContent)", + ".spectrum-Dialog-grid", ".spectrum-Dialog-header", + ".spectrum-Dialog-header > .spectrum-Dialog-headerContentWrapper", ".spectrum-Dialog-heading", - ".spectrum-Dialog-heading.spectrum-Dialog-heading--noHeader", - ".spectrum-Dialog-hero", - ".spectrum-Dialog.spectrum-Dialog--dismissable .spectrum-Dialog-grid", - ".spectrum-Dialog.spectrum-Dialog--dismissable .spectrum-Dialog-grid .spectrum-Dialog-buttonGroup", - ".spectrum-Dialog.spectrum-Dialog--dismissable .spectrum-Dialog-grid .spectrum-Dialog-footer" + ".spectrum-Dialog-hero" ], "modifiers": [ - "--mod-dialog-confirm-border-radius", - "--mod-dialog-confirm-buttongroup-padding-top", - "--mod-dialog-confirm-close-button-padding", - "--mod-dialog-confirm-close-button-size", - "--mod-dialog-confirm-description-font-weight", - "--mod-dialog-confirm-description-margin", - "--mod-dialog-confirm-description-padding", - "--mod-dialog-confirm-description-text-color", - "--mod-dialog-confirm-description-text-line-height", - "--mod-dialog-confirm-description-text-size", - "--mod-dialog-confirm-divider-block-spacing-end", - "--mod-dialog-confirm-divider-block-spacing-start", - "--mod-dialog-confirm-divider-height", - "--mod-dialog-confirm-footer-padding-top", - "--mod-dialog-confirm-gap-size", - "--mod-dialog-confirm-hero-height", - "--mod-dialog-confirm-large-width", - "--mod-dialog-confirm-medium-width", - "--mod-dialog-confirm-padding-grid", - "--mod-dialog-confirm-small-width", - "--mod-dialog-confirm-title-text-color", - "--mod-dialog-confirm-title-text-line-height", - "--mod-dialog-confirm-title-text-size", - "--mod-dialog-fullscreen-header-text-size", - "--mod-dialog-heading-font-weight", - "--mod-dialog-min-inline-size", - "--mod-dialog-width" - ], - "component": [ - "--spectrum-dialog-confirm-border-radius", - "--spectrum-dialog-confirm-buttongroup-padding-top", - "--spectrum-dialog-confirm-close-button-padding", - "--spectrum-dialog-confirm-close-button-size", - "--spectrum-dialog-confirm-description-padding", - "--spectrum-dialog-confirm-description-text-color", - "--spectrum-dialog-confirm-description-text-size", - "--spectrum-dialog-confirm-divider-block-spacing-end", - "--spectrum-dialog-confirm-divider-block-spacing-start", - "--spectrum-dialog-confirm-gap-size", - "--spectrum-dialog-confirm-hero-height", - "--spectrum-dialog-confirm-padding-grid", - "--spectrum-dialog-confirm-title-text-size" + "--mod-standard-dialog-background-color", + "--mod-standard-dialog-border-radius", + "--mod-standard-dialog-description-font-size", + "--mod-standard-dialog-description-font-weight", + "--mod-standard-dialog-description-line-height", + "--mod-standard-dialog-description-text-color", + "--mod-standard-dialog-header-content-font-size", + "--mod-standard-dialog-heading-font-size", + "--mod-standard-dialog-heading-font-weight", + "--mod-standard-dialog-heading-line-height", + "--mod-standard-dialog-heading-text-color", + "--mod-standard-dialog-hero-block-size", + "--mod-standard-dialog-max-width", + "--mod-standard-dialog-max-width-large", + "--mod-standard-dialog-max-width-small", + "--mod-standard-dialog-min-inline-size", + "--mod-standard-dialog-spacing-description-to-footer", + "--mod-standard-dialog-spacing-edge-to-close-button", + "--mod-standard-dialog-spacing-footer-to-button-group", + "--mod-standard-dialog-spacing-grid-padding", + "--mod-standard-dialog-spacing-title-to-description", + "--mod-standard-dialog-spacing-title-to-header-content", + "--mod-takeover-dialog-grid-spacing", + "--mod-takeover-dialog-spacing-header-content-gap", + "--mod-takeover-dialog-title-font-size" ], + "component": [], "global": [ - "--spectrum-component-bottom-to-text-300", - "--spectrum-component-height-100", - "--spectrum-component-pill-edge-to-text-100", - "--spectrum-gray-800", - "--spectrum-gray-900", - "--spectrum-heading-sans-serif-font-weight", - "--spectrum-line-height-100", - "--spectrum-regular-font-weight", + "--spectrum-background-layer-2-color", + "--spectrum-black-rgb", + "--spectrum-body-color", + "--spectrum-body-sans-serif-font-style", + "--spectrum-body-sans-serif-font-weight", + "--spectrum-corner-radius-extra-large-default", + "--spectrum-heading-color", + "--spectrum-line-height-200", + "--spectrum-overlay-opacity", + "--spectrum-sans-font-family-stack", "--spectrum-spacing-200", "--spectrum-spacing-300", - "--spectrum-spacing-50", - "--spectrum-spacing-600" + "--spectrum-spacing-400", + "--spectrum-spacing-500", + "--spectrum-standard-dialog-background-color", + "--spectrum-standard-dialog-body-font-size", + "--spectrum-standard-dialog-border-radius", + "--spectrum-standard-dialog-description-font-family", + "--spectrum-standard-dialog-description-font-size", + "--spectrum-standard-dialog-description-font-style", + "--spectrum-standard-dialog-description-font-weight", + "--spectrum-standard-dialog-description-line-height", + "--spectrum-standard-dialog-description-text-color", + "--spectrum-standard-dialog-header-content-font-size", + "--spectrum-standard-dialog-heading-font-family", + "--spectrum-standard-dialog-heading-font-size", + "--spectrum-standard-dialog-heading-font-style", + "--spectrum-standard-dialog-heading-font-weight", + "--spectrum-standard-dialog-heading-line-height", + "--spectrum-standard-dialog-heading-text-color", + "--spectrum-standard-dialog-hero-block-size", + "--spectrum-standard-dialog-max-width", + "--spectrum-standard-dialog-maximum-width-large", + "--spectrum-standard-dialog-maximum-width-medium", + "--spectrum-standard-dialog-maximum-width-small", + "--spectrum-standard-dialog-min-inline-size", + "--spectrum-standard-dialog-minimum-width", + "--spectrum-standard-dialog-padding", + "--spectrum-standard-dialog-spacing-description-to-footer", + "--spectrum-standard-dialog-spacing-edge-to-close-button", + "--spectrum-standard-dialog-spacing-edge-to-content", + "--spectrum-standard-dialog-spacing-edge-to-header-content-inline-end", + "--spectrum-standard-dialog-spacing-footer-to-button-group", + "--spectrum-standard-dialog-spacing-grid-padding", + "--spectrum-standard-dialog-spacing-title-to-description", + "--spectrum-standard-dialog-spacing-title-to-header-content", + "--spectrum-standard-dialog-title-font-size", + "--spectrum-takeover-dialog-block-size", + "--spectrum-takeover-dialog-grid-spacing", + "--spectrum-takeover-dialog-height", + "--spectrum-takeover-dialog-inline-size", + "--spectrum-takeover-dialog-spacing-grid-padding", + "--spectrum-takeover-dialog-spacing-header-content-gap", + "--spectrum-takeover-dialog-spacing-header-gap", + "--spectrum-takeover-dialog-spacing-title-to-body", + "--spectrum-takeover-dialog-spacing-title-to-content", + "--spectrum-takeover-dialog-title-font-size", + "--spectrum-takeover-dialog-width", + "--spectrum-title-line-height", + "--spectrum-title-sans-serif-font-style", + "--spectrum-title-sans-serif-font-weight", + "--spectrum-title-size-xxl" + ], + "passthroughs": [ + "--mod-buttongroup-flex-wrap", + "--mod-buttongroup-justify-content" ], - "system-theme": [], - "passthroughs": [], "high-contrast": [] } diff --git a/components/dialog/index.css b/components/dialog/index.css index 39ed5be57c7..357dbd6c68f 100644 --- a/components/dialog/index.css +++ b/components/dialog/index.css @@ -12,200 +12,233 @@ */ .spectrum-Dialog { - --spectrum-dialog-confirm-divider-block-spacing-start: var(--spectrum-spacing-300); - --spectrum-dialog-confirm-divider-block-spacing-end: var(--spectrum-spacing-200); - --spectrum-dialog-confirm-description-text-color: var(--spectrum-gray-800); - --spectrum-dialog-confirm-description-padding: var(--spectrum-spacing-50); - --spectrum-dialog-confirm-gap-size: var(--spectrum-component-pill-edge-to-text-100); - --spectrum-dialog-confirm-buttongroup-padding-top: var(--spectrum-spacing-600); - --spectrum-dialog-confirm-close-button-size: var(--spectrum-component-height-100); - --spectrum-dialog-confirm-close-button-padding: calc(26px - var(--spectrum-component-bottom-to-text-300)); + --spectrum-standard-dialog-max-width: var(--spectrum-standard-dialog-maximum-width-medium); + --spectrum-standard-dialog-min-inline-size: var(--spectrum-standard-dialog-minimum-width); + --spectrum-standard-dialog-border-radius: var(--spectrum-corner-radius-extra-large-default); + + /* Fonts */ + --spectrum-standard-dialog-heading-font-weight: var(--spectrum-title-sans-serif-font-weight); + --spectrum-standard-dialog-heading-font-size: var(--spectrum-standard-dialog-title-font-size); + --spectrum-standard-dialog-heading-font-style: var(--spectrum-title-sans-serif-font-style); + --spectrum-standard-dialog-heading-font-family: var(--spectrum-sans-font-family-stack); + --spectrum-standard-dialog-description-font-weight: var(--spectrum-body-sans-serif-font-weight); + --spectrum-standard-dialog-description-font-size: var(--spectrum-standard-dialog-body-font-size); + --spectrum-standard-dialog-description-font-style: var(--spectrum-body-sans-serif-font-style); + --spectrum-standard-dialog-description-font-family: var(--spectrum-sans-font-family-stack); + --spectrum-standard-dialog-header-content-font-size: var(--spectrum-standard-dialog-body-font-size); + + --spectrum-standard-dialog-heading-line-height: var(--spectrum-title-line-height); + --spectrum-standard-dialog-description-line-height: var(--spectrum-line-height-200); + + /* Colors */ + --spectrum-standard-dialog-heading-text-color: var(--spectrum-heading-color); + --spectrum-standard-dialog-description-text-color: var(--spectrum-body-color); + --spectrum-standard-dialog-background-color: var(--spectrum-background-layer-2-color); + + /* Spacing */ + --spectrum-standard-dialog-padding: var(--spectrum-standard-dialog-spacing-edge-to-content); + --spectrum-standard-dialog-spacing-title-to-description: var(--spectrum-spacing-300); + --spectrum-standard-dialog-spacing-description-to-footer: var(--spectrum-spacing-500); + --spectrum-standard-dialog-spacing-title-to-header-content: var(--spectrum-spacing-400); + --spectrum-standard-dialog-spacing-edge-to-header-content-inline-end: var(--spectrum-spacing-400); + --spectrum-standard-dialog-spacing-footer-to-button-group: var(--spectrum-spacing-400); + + /* Grid */ + --spectrum-standard-dialog-spacing-grid-padding: var(--spectrum-standard-dialog-padding); + --spectrum-standard-dialog-spacing-edge-to-close-button: var(--spectrum-spacing-200); + + /* Hero */ + --spectrum-standard-dialog-hero-block-size: 140px; + + /* Passthrough for nested component(s) */ + --mod-buttongroup-justify-content: flex-end; + --mod-buttongroup-flex-wrap: nowrap; + + /* Fullscreen/fullscreenTakeover */ + --spectrum-takeover-dialog-title-font-size: var(--spectrum-title-size-xxl); + --spectrum-takeover-dialog-grid-spacing: var(--spectrum-takeover-dialog-spacing-grid-padding); + --spectrum-takeover-dialog-spacing-header-content-gap: var(--spectrum-takeover-dialog-spacing-header-gap); + --spectrum-takeover-dialog-spacing-title-to-content: var(--spectrum-takeover-dialog-spacing-title-to-body); + --spectrum-takeover-dialog-inline-size: var(--spectrum-takeover-dialog-width); + --spectrum-takeover-dialog-block-size: var(--spectrum-takeover-dialog-height); +} + +.spectrum-Dialog--sizeS { + --spectrum-standard-dialog-max-width: var(--mod-standard-dialog-max-width-small, var(--spectrum-standard-dialog-maximum-width-small)); +} + +.spectrum-Dialog--sizeL { + --spectrum-standard-dialog-max-width: var(--mod-standard-dialog-max-width-large, var(--spectrum-standard-dialog-maximum-width-large)); +} +.spectrum-Dialog { /* Be a flexbox to allow a full sized content area that scrolls */ display: flex; /* Allow 100% width, taking into account padding */ box-sizing: border-box; - /* Be no bigger than max-width, but also be 90% if the viewport is smaller than max-width */ - inline-size: var(--mod-dialog-width, var(--mod-dialog-confirm-medium-width, 480px)); - min-inline-size: var(--mod-dialog-min-inline-size, 288px); + /* Be no bigger than max-width, but also be 90% if the viewport is smaller than max-width */ + inline-size: var(--mod-standard-dialog-max-width, var(--spectrum-standard-dialog-max-width)); + min-inline-size: var(--mod-standard-dialog-min-inline-size, var(--spectrum-standard-dialog-min-inline-size)); max-inline-size: 100%; - max-block-size: inherit; - + background-color: var(--mod-standard-dialog-background-color, var(--spectrum-standard-dialog-background-color)); outline: none; -} - -.spectrum-Dialog--sizeS { - --mod-dialog-width: var(--mod-dialog-confirm-small-width, 400px); -} - -.spectrum-Dialog--sizeL { - --mod-dialog-width: var(--mod-dialog-confirm-large-width, 640px); + border-radius: var(--mod-standard-dialog-border-radius, var(--spectrum-standard-dialog-border-radius)); + overflow: hidden; } .spectrum-Dialog-hero { grid-area: hero; - block-size: var(--mod-dialog-confirm-hero-height, var(--spectrum-dialog-confirm-hero-height)); - border-start-start-radius: var(--mod-dialog-confirm-border-radius, var(--spectrum-dialog-confirm-border-radius)); - border-start-end-radius: var(--mod-dialog-confirm-border-radius, var(--spectrum-dialog-confirm-border-radius)); + block-size: var(--mod-standard-dialog-hero-block-size, var(--spectrum-standard-dialog-hero-block-size)); background-size: cover; background-position: center center; - overflow: hidden; } -.spectrum-Dialog .spectrum-Dialog-grid { +/* Non-Dismissible Dialog (no close button) */ +.spectrum-Dialog-grid { display: grid; grid-template-columns: - var(--mod-dialog-confirm-padding-grid, var(--spectrum-dialog-confirm-padding-grid)) auto 1fr auto minmax(0, auto) - var(--mod-dialog-confirm-padding-grid, var(--spectrum-dialog-confirm-padding-grid)); + var(--mod-standard-dialog-spacing-grid-padding, var(--spectrum-standard-dialog-spacing-grid-padding)) + auto + 1fr + auto + var(--mod-standard-dialog-spacing-grid-padding, var(--spectrum-standard-dialog-spacing-grid-padding)) + minmax(0, auto) + var(--mod-standard-dialog-spacing-grid-padding, var(--spectrum-standard-dialog-spacing-grid-padding)); + grid-template-rows: + auto + var(--mod-standard-dialog-spacing-grid-padding, var(--spectrum-standard-dialog-spacing-grid-padding)) + auto + 1fr + auto + var(--mod-standard-dialog-spacing-grid-padding, var(--spectrum-standard-dialog-spacing-grid-padding)); grid-template-areas: - "hero hero hero hero hero hero" - ". . . . . ." - ". heading header header header ." - ". divider divider divider divider ." - ". content content content content ." - ". footer footer buttonGroup buttonGroup ." - ". . . . . ."; - grid-template-rows: auto var(--mod-dialog-confirm-padding-grid, var(--spectrum-dialog-confirm-padding-grid)) auto auto 1fr auto var(--mod-dialog-confirm-padding-grid, var(--spectrum-dialog-confirm-padding-grid)); + "hero hero hero hero hero hero hero" + ". . . . . . ." + ". heading header header header header ." + ". content content content content content ." + ". footer footer footer buttonGroup buttonGroup ." + ". . . . . . ."; inline-size: 100%; } +/* the dialog's heading/title */ .spectrum-Dialog-heading { grid-area: heading; - margin: 0; - - font-size: var(--mod-dialog-confirm-title-text-size, var(--spectrum-dialog-confirm-title-text-size)); - font-weight: var(--mod-dialog-heading-font-weight, var(--spectrum-heading-sans-serif-font-weight)); - line-height: var(--mod-dialog-confirm-title-text-line-height, var(--spectrum-line-height-100)); - color: var(--mod-dialog-confirm-title-text-color, var(--spectrum-gray-900)); + margin-block: 0; + font-size: var(--mod-standard-dialog-heading-font-size, var(--spectrum-standard-dialog-heading-font-size)); + font-weight: var(--mod-standard-dialog-heading-font-weight, var(--spectrum-standard-dialog-heading-font-weight)); + font-style: var(--spectrum-standard-dialog-heading-font-style); + font-family: var(--spectrum-standard-dialog-heading-font-family); + line-height: var(--mod-standard-dialog-heading-line-height, var(--spectrum-standard-dialog-heading-line-height)); + color: var(--mod-standard-dialog-heading-text-color, var(--spectrum-standard-dialog-heading-text-color)); outline: none; /* Hide focus outline */ - - padding-inline-end: var(--mod-dialog-confirm-gap-size, var(--spectrum-dialog-confirm-gap-size)); - - &.spectrum-Dialog-heading--noHeader { - grid-area: heading-start / heading-start / header-end / header-end; - padding-inline-end: 0; - } } +/* the container for the heading and any additional header content */ .spectrum-Dialog-header { grid-area: header; display: flex; + max-inline-size: 100%; + margin-block-end: var(--mod-standard-dialog-spacing-title-to-description, var(--spectrum-standard-dialog-spacing-title-to-description)); + gap: var(--mod-standard-dialog-spacing-title-to-header-content, var(--spectrum-standard-dialog-spacing-title-to-header-content)); - /* Without this, buttons will be stretched */ - align-items: center; - justify-content: flex-end; + /* Without this, buttons will be stretched */ + align-items: flex-start; + justify-content: space-between; box-sizing: border-box; outline: none; /* Hide focus outline around header */ -} - -.spectrum-Dialog .spectrum-Dialog-divider { - grid-area: divider; - inline-size: 100%; - margin-block-start: var(--mod-dialog-confirm-divider-block-spacing-end, var(--spectrum-dialog-confirm-divider-block-spacing-end)); - margin-block-end: var(--mod-dialog-confirm-divider-block-spacing-start, var(--spectrum-dialog-confirm-divider-block-spacing-start)); -} - -/* remove top vertical padding of spectrum-Dialog-content from bottom margin of first divider after heading */ -.spectrum-Dialog--fullscreen .spectrum-Dialog-heading + .spectrum-Dialog-divider { - margin-block-end: calc(var(--mod-dialog-confirm-divider-block-spacing-start, var(--spectrum-dialog-confirm-divider-block-spacing-start)) - (var(--mod-dialog-confirm-description-padding, var(--spectrum-dialog-confirm-description-padding)) * 2)); -} -.spectrum-Dialog--noDivider { - .spectrum-Dialog-divider { - display: none; - } - - .spectrum-Dialog-heading { - padding-block-end: calc(var(--mod-dialog-confirm-divider-block-spacing-end, var(--spectrum-dialog-confirm-divider-block-spacing-end)) + var(--mod-dialog-confirm-divider-block-spacing-start, var(--spectrum-dialog-confirm-divider-block-spacing-start)) + var(--mod-dialog-confirm-divider-height, var(--spectrum-spacing-50))); + /* additional header content should grow/shrink with the text, but only until it takes up half of the header */ + > .spectrum-Dialog-headerContentWrapper { + max-inline-size: fit-content; + flex: 1 1 100%; + font-size: var(--mod-standard-dialog-header-content-font-size, var(--spectrum-standard-dialog-header-content-font-size)); + text-wrap: pretty; } } .spectrum-Dialog-content { grid-area: content; box-sizing: border-box; - - /* - v2 is currently worse, inputs that get focus rings get a slight clipping unless overflow: visible replaces this line - we should think of a better way to handle this, see padding/margin below for fix - */ overflow-y: auto; -webkit-overflow-scrolling: touch; outline: none; /* Hide focus outline */ - - font-size: var(--mod-dialog-confirm-description-text-size, var(--spectrum-dialog-confirm-description-text-size)); - font-weight: var(--mod-dialog-confirm-description-font-weight, var(--spectrum-regular-font-weight)); - line-height: var(--mod-dialog-confirm-description-text-line-height, var(--spectrum-line-height-100)); - color: var(--mod-dialog-confirm-description-text-color, var(--spectrum-dialog-confirm-description-text-color)); - - /* this is kinda dumb, but needed for the keyboard focus rings so they don't get clipped. is there a better way to treat this */ - padding: calc(var(--mod-dialog-confirm-description-padding, var(--spectrum-dialog-confirm-description-padding)) * 2); - margin: 0 var(--mod-dialog-confirm-description-margin, calc(var(--spectrum-spacing-50) * -1)); + font-size: var(--mod-standard-dialog-description-font-size, var(--spectrum-standard-dialog-description-font-size)); + font-weight: var(--mod-standard-dialog-description-font-weight, var(--spectrum-standard-dialog-description-font-weight)); + font-family: var(--spectrum-standard-dialog-description-font-family); + font-style: var(--spectrum-standard-dialog-description-font-style); + line-height: var(--mod-standard-dialog-description-line-height, var(--spectrum-standard-dialog-description-line-height)); + color: var(--mod-standard-dialog-description-text-color, var(--spectrum-standard-dialog-description-text-color)); } .spectrum-Dialog-footer { - grid-area: footer; + grid-area: footer / footer / buttonGroup / buttonGroup; + max-inline-size: 100%; + display: flex; + align-items: flex-end; - /* this padding isn't built into the grid because it disappears with this footer */ - padding-block-start: var(--mod-dialog-confirm-footer-padding-top, var(--spectrum-spacing-600)); + /* this recreates padding between the footer content and button group. It should be safe as button group is always end aligned */ + gap: var(--mod-standard-dialog-spacing-footer-to-button-group, var(--spectrum-standard-dialog-spacing-footer-to-button-group)); - display: flex; - flex-wrap: wrap; + /* this padding isn't built into the grid because it disappears with this footer */ + padding-block-start: var(--mod-standard-dialog-spacing-description-to-footer, var(--spectrum-standard-dialog-spacing-description-to-footer)); outline: none; /* Hide focus outline */ - /* Both selectors are required to override the button + button rule */ - > *, - > .spectrum-Button + .spectrum-Button { - margin-block-end: 0; + .spectrum-Dialog-footerContent { + /* this attempts to give as much space as possible for the button group, particularly to avoid stacking on mobile. Some sizes still may have to stack. */ + flex: 1 1 100%; + } + + &:has(.spectrum-Dialog-footerContent), + &:has(.spectrum-Dialog-buttonGroup) { + justify-content: space-between; } } .spectrum-Dialog-buttonGroup { grid-area: buttonGroup; +} - /* this padding isn't built into the grid because it disappears with this buttonGroup */ - padding-block-start: var(--mod-dialog-confirm-buttongroup-padding-top, var(--spectrum-dialog-confirm-buttongroup-padding-top)); - display: flex; - justify-content: flex-end; - - /* this padding should be safe as button group is always end aligned */ - padding-inline-start: var(--mod-dialog-confirm-gap-size, var(--spectrum-dialog-confirm-gap-size)); - - &.spectrum-Dialog-buttonGroup--noFooter { - grid-area: footer-start / footer-start / buttonGroup-end / buttonGroup-end; - } +.spectrum-Dialog-buttonGroup--noFooter { + padding-block-start: var(--mod-standard-dialog-spacing-description-to-footer, var(--spectrum-standard-dialog-spacing-description-to-footer)); } -.spectrum-Dialog.spectrum-Dialog--dismissable .spectrum-Dialog-grid { +/* Dismissible Dialog (with close button) */ +.spectrum-Dialog--dismissible .spectrum-Dialog-grid { grid-template-columns: - var(--mod-dialog-confirm-padding-grid, var(--spectrum-dialog-confirm-padding-grid)) auto 1fr auto minmax(0, auto) - minmax(0, var(--mod-dialog-confirm-close-button-size, var(--spectrum-dialog-confirm-close-button-size))) var(--mod-dialog-confirm-padding-grid, var(--spectrum-dialog-confirm-padding-grid)); + var(--mod-standard-dialog-spacing-grid-padding, var(--spectrum-standard-dialog-spacing-grid-padding)) + auto + 1fr + auto + minmax(0, var(--spectrum-standard-dialog-spacing-edge-to-header-content-inline-end)) + var(--mod-standard-dialog-spacing-grid-padding, var(--spectrum-standard-dialog-spacing-grid-padding)); + grid-template-rows: + auto + var(--mod-standard-dialog-spacing-grid-padding, var(--spectrum-standard-dialog-spacing-grid-padding)) + auto + 1fr + auto + var(--mod-standard-dialog-spacing-grid-padding, var(--spectrum-standard-dialog-spacing-grid-padding)); grid-template-areas: - "hero hero hero hero hero hero hero" - ". . . . . closeButton closeButton" - ". heading header header typeIcon closeButton closeButton" - ". divider divider divider divider divider ." - ". content content content content content ." - ". footer footer buttonGroup buttonGroup buttonGroup ." - ". . . . . . ."; - grid-template-rows: auto var(--mod-dialog-confirm-padding-grid, var(--spectrum-dialog-confirm-padding-grid)) auto auto 1fr auto var(--mod-dialog-confirm-padding-grid, var(--spectrum-dialog-confirm-padding-grid)); - - .spectrum-Dialog-buttonGroup { - display: none; - } + "hero hero hero hero hero hero" + ". . . . closeButton closeButton" + ". heading header header closeButton closeButton" + ". content content content content ." + ". footer footer footer footer ." + ". . . . . ."; .spectrum-Dialog-footer { - grid-area: footer / footer/ buttonGroup / buttonGroup; - color: var(--mod-dialog-confirm-description-text-color, var(--spectrum-dialog-confirm-description-text-color)); + grid-area: footer; } } @@ -216,19 +249,18 @@ align-self: start; justify-self: end; - margin-inline-end: var(--mod-dialog-confirm-close-button-padding, var(--spectrum-dialog-confirm-close-button-padding)); - margin-block-start: var(--mod-dialog-confirm-close-button-padding, var(--spectrum-dialog-confirm-close-button-padding)); + margin-block-start: var(--mod-standard-dialog-spacing-edge-to-close-button, var(--spectrum-standard-dialog-spacing-edge-to-close-button)); + margin-inline-end: var(--mod-standard-dialog-spacing-edge-to-close-button, var(--spectrum-standard-dialog-spacing-edge-to-close-button)); } .spectrum-Dialog--fullscreen { - inline-size: 100%; - block-size: 100%; + inline-size: var(--spectrum-takeover-dialog-inline-size); + block-size: var(--spectrum-takeover-dialog-block-size); } .spectrum-Dialog--fullscreenTakeover { - inline-size: 100%; - block-size: 100%; - + inline-size: var(--spectrum-takeover-dialog-inline-size); + block-size: var(--spectrum-takeover-dialog-block-size); border-radius: 0; } @@ -237,29 +269,53 @@ max-block-size: none; max-inline-size: none; - &.spectrum-Dialog .spectrum-Dialog-grid { + /* Enable container queries for fullscreen/fullscreenTakeover dialogs */ + container: dialog-fullscreen / inline-size; + + .spectrum-Dialog-grid { display: grid; - grid-template-columns: var(--mod-dialog-confirm-padding-grid, var(--spectrum-dialog-confirm-padding-grid)) 1fr auto auto var(--mod-dialog-confirm-padding-grid, var(--spectrum-dialog-confirm-padding-grid)); - grid-template-rows: var(--mod-dialog-confirm-padding-grid, var(--spectrum-dialog-confirm-padding-grid)) auto auto 1fr var(--mod-dialog-confirm-padding-grid, var(--spectrum-dialog-confirm-padding-grid)); + grid-template-columns: + var(--mod-takeover-dialog-grid-spacing, var(--spectrum-takeover-dialog-grid-spacing)) + 1fr + auto + auto + var(--mod-takeover-dialog-grid-spacing, var(--spectrum-takeover-dialog-grid-spacing)); + grid-template-rows: + var(--mod-takeover-dialog-grid-spacing, var(--spectrum-takeover-dialog-grid-spacing)) + auto + 1fr + var(--mod-takeover-dialog-grid-spacing, var(--spectrum-takeover-dialog-grid-spacing)); grid-template-areas: ". . . . ." ". heading header buttonGroup ." - ". divider divider divider ." ". content content content ." ". . . . ."; } + .spectrum-Dialog-header { + grid-area: heading; + gap: var(--mod-takeover-dialog-spacing-header-content-gap, var(--spectrum-takeover-dialog-spacing-header-content-gap)); + margin-inline-end: var(--mod-takeover-dialog-spacing-header-content-gap, var(--spectrum-takeover-dialog-spacing-header-content-gap)); + margin-block-end: var(--spectrum-takeover-dialog-spacing-title-to-content); + + /* components in fullscreen/fullscreenTakeover dialogs are centered in the headerContentWrapper */ + > .spectrum-Dialog-headerContentWrapper { + max-inline-size: unset; + display: inline-flex; + justify-content: center; + } + } + .spectrum-Dialog-heading { - font-size: var(--mod-dialog-fullscreen-header-text-size, 28px); + font-size: var(--mod-takeover-dialog-title-font-size, var(--spectrum-takeover-dialog-title-font-size)); } - .spectrum-Dialog-content { - max-block-size: none; + .spectrum-Dialog-closeButton { + display: none; } - .spectrum-Dialog-footer, - .spectrum-Dialog-buttonGroup { - padding-block-start: 0; + .spectrum-Dialog-content { + max-block-size: none; } .spectrum-Dialog-footer { @@ -268,75 +324,126 @@ .spectrum-Dialog-buttonGroup { grid-area: buttonGroup; - align-self: start; } } @media screen and (width <= 700px) { - .spectrum-Dialog .spectrum-Dialog-grid { + .spectrum-Dialog-grid { grid-template-columns: - var(--mod-dialog-confirm-padding-grid, var(--spectrum-dialog-confirm-padding-grid)) auto 1fr auto minmax(0, auto) - var(--mod-dialog-confirm-padding-grid, var(--spectrum-dialog-confirm-padding-grid)); - grid-template-rows: auto var(--mod-dialog-confirm-padding-grid, var(--spectrum-dialog-confirm-padding-grid)) auto auto auto 1fr auto var(--mod-dialog-confirm-padding-grid, var(--spectrum-dialog-confirm-padding-grid)); + var(--mod-standard-dialog-spacing-grid-padding, var(--spectrum-standard-dialog-spacing-grid-padding)) + auto + 1fr + auto + minmax(0, auto) + var(--mod-standard-dialog-spacing-grid-padding, var(--spectrum-standard-dialog-spacing-grid-padding)); + grid-template-rows: + auto + var(--mod-standard-dialog-spacing-grid-padding, var(--spectrum-standard-dialog-spacing-grid-padding)) + auto + auto + 1fr + auto + var(--mod-standard-dialog-spacing-grid-padding, var(--spectrum-standard-dialog-spacing-grid-padding)); + grid-template-areas: "hero hero hero hero hero hero" ". . . . . ." - ". heading heading heading heading ." + ". heading heading heading heading ." ". header header header header ." - ". divider divider divider divider ." ". content content content content ." ". footer footer buttonGroup buttonGroup ." ". . . . . ."; } - .spectrum-Dialog.spectrum-Dialog--dismissable .spectrum-Dialog-grid { + .spectrum-Dialog-footer { + flex-direction: column; + } + + .spectrum-Dialog--dismissible .spectrum-Dialog-grid { grid-template-columns: - var(--mod-dialog-confirm-padding-grid, var(--spectrum-dialog-confirm-padding-grid)) auto 1fr auto minmax(0, auto) - minmax(0, var(--mod-dialog-confirm-close-button-size, var(--spectrum-dialog-confirm-close-button-size))) var(--mod-dialog-confirm-padding-grid, var(--spectrum-dialog-confirm-padding-grid)); - grid-template-rows: auto var(--mod-dialog-confirm-padding-grid, var(--spectrum-dialog-confirm-padding-grid)) auto auto auto 1fr auto var(--mod-dialog-confirm-padding-grid, var(--spectrum-dialog-confirm-padding-grid)); + var(--mod-standard-dialog-spacing-grid-padding, var(--spectrum-standard-dialog-spacing-grid-padding)) + auto + 1fr + auto + minmax(0, auto) + minmax(0, calc(var(--spectrum-standard-dialog-spacing-edge-to-content) - var(--spectrum-standard-dialog-spacing-edge-to-close-button))) + var(--mod-standard-dialog-spacing-grid-padding, var(--spectrum-standard-dialog-spacing-grid-padding)); + grid-template-rows: + auto + var(--mod-standard-dialog-spacing-grid-padding, var(--spectrum-standard-dialog-spacing-grid-padding)) + auto + auto + 1fr + auto + var(--mod-standard-dialog-spacing-grid-padding, var(--spectrum-standard-dialog-spacing-grid-padding)); grid-template-areas: "hero hero hero hero hero hero hero" ". . . . . closeButton closeButton" - ". heading heading heading heading closeButton closeButton" + ". heading heading heading heading closeButton closeButton" ". header header header header header ." - ". divider divider divider divider divider ." ". content content content content content ." - ". footer footer buttonGroup buttonGroup buttonGroup ." + ". footer footer footer footer footer ." ". . . . . . ."; } .spectrum-Dialog .spectrum-Dialog-header { + display: flex; + flex-direction: column; + align-items: flex-start; justify-content: flex-start; + gap: 0; } + .spectrum-Dialog-heading { + margin-block-end: var(--mod-standard-dialog-spacing-title-to-description, var(--spectrum-standard-dialog-spacing-title-to-description)); + } +} + +@container dialog-fullscreen (max-inline-size: 864px) { .spectrum-Dialog--fullscreen, .spectrum-Dialog--fullscreenTakeover { &.spectrum-Dialog .spectrum-Dialog-grid { display: grid; - grid-template-columns: var(--mod-dialog-confirm-padding-grid, var(--spectrum-dialog-confirm-padding-grid)) 1fr var(--mod-dialog-confirm-padding-grid, var(--spectrum-dialog-confirm-padding-grid)); - grid-template-rows: var(--mod-dialog-confirm-padding-grid, var(--spectrum-dialog-confirm-padding-grid)) auto auto auto 1fr auto var(--mod-dialog-confirm-padding-grid, var(--spectrum-dialog-confirm-padding-grid)); + grid-template-columns: + var(--mod-standard-dialog-spacing-grid-padding, var(--spectrum-standard-dialog-spacing-grid-padding)) + 1fr + var(--mod-standard-dialog-spacing-grid-padding, var(--spectrum-standard-dialog-spacing-grid-padding)); + grid-template-rows: + var(--mod-standard-dialog-spacing-grid-padding, var(--spectrum-standard-dialog-spacing-grid-padding)) + auto + auto + 1fr + var(--mod-standard-dialog-spacing-grid-padding, var(--spectrum-standard-dialog-spacing-grid-padding)) + auto + var(--mod-standard-dialog-spacing-grid-padding, var(--spectrum-standard-dialog-spacing-grid-padding)); grid-template-areas: ". . ." ". heading ." ". header ." - ". divider ." ". content ." + ". . ." ". buttonGroup ." ". . ."; } - .spectrum-Dialog-buttonGroup { - padding-block-start: var(--mod-dialog-confirm-buttongroup-padding-top, var(--spectrum-dialog-confirm-buttongroup-padding-top)); + .spectrum-Dialog-header { + margin-inline-end: 0; + + /* The header element is a flexbox, so that the title and headerContentWrapper can wrap sooner. */ + display: flex; + flex-direction: column; + gap: var(--mod-takeover-dialog-spacing-header-content-gap, var(--spectrum-takeover-dialog-spacing-header-content-gap)); } .spectrum-Dialog-heading { - font-size: var(--mod-dialog-confirm-title-text-size, var(--spectrum-dialog-confirm-title-text-size)); + margin-inline-end: 0; + margin-block-end: 0; } } } @media (forced-colors: active) { .spectrum-Dialog { - border: solid; + border: 1px solid rgb(var(--spectrum-black-rgb), var(--spectrum-overlay-opacity)); } } diff --git a/components/dialog/package.json b/components/dialog/package.json index 632f499f799..85f9d9b4912 100644 --- a/components/dialog/package.json +++ b/components/dialog/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/dialog", - "version": "12.2.0", + "version": "13.0.0-next.4", "description": "The Spectrum CSS dialog component", "license": "Apache-2.0", "author": "Adobe", @@ -24,13 +24,21 @@ }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/closebutton": ">=6.0.0 <7.0.0", - "@spectrum-css/divider": ">=5.0.0 <6.0.0", - "@spectrum-css/modal": ">=7.0.0 <8.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0", - "@spectrum-css/underlay": ">=6.0.0 <7.0.0" + "@spectrum-css/button": ">=15.0.0-next.0", + "@spectrum-css/buttongroup": ">=10.0.0-next.0", + "@spectrum-css/closebutton": ">=7.0.0-next.0", + "@spectrum-css/divider": ">=6.0.0-next.0", + "@spectrum-css/modal": ">=8.0.0-next.1", + "@spectrum-css/tokens": ">=16.1.0-next.0", + "@spectrum-css/underlay": ">=7.0.0-next.0" }, "peerDependenciesMeta": { + "@spectrum-css/button": { + "optional": true + }, + "@spectrum-css/buttongroup": { + "optional": true + }, "@spectrum-css/closebutton": { "optional": true }, @@ -48,12 +56,14 @@ } }, "devDependencies": { - "@spectrum-css/buttongroup": "9.2.0", - "@spectrum-css/closebutton": "6.2.0", - "@spectrum-css/divider": "5.2.0", - "@spectrum-css/modal": "7.2.0", - "@spectrum-css/tokens": "16.0.2", - "@spectrum-css/underlay": "6.2.0" + "@spectrum-css/button": "15.0.0-next.2", + "@spectrum-css/buttongroup": "10.0.0-next.1", + "@spectrum-css/closebutton": "7.0.0-next.1", + "@spectrum-css/divider": "6.0.0-next.1", + "@spectrum-css/modal": "8.0.0-next.1", + "@spectrum-css/tokens": "16.1.0-next.10", + "@spectrum-css/typography": "9.0.0-next.0", + "@spectrum-css/underlay": "7.0.0-next.1" }, "keywords": [ "design-system", diff --git a/components/dialog/stories/dialog.stories.js b/components/dialog/stories/dialog.stories.js index 45bec9bc1d1..b2fbb79e6fe 100644 --- a/components/dialog/stories/dialog.stories.js +++ b/components/dialog/stories/dialog.stories.js @@ -1,6 +1,8 @@ import { withUnderlayWrapper } from "@spectrum-css/preview/decorators"; import { disableDefaultModes } from "@spectrum-css/preview/modes"; import { isOpen, size } from "@spectrum-css/preview/types"; +import { Template as Steplist } from "@spectrum-css/steplist/stories/template.js"; +import { Template as Table } from "@spectrum-css/table/stories/template.js"; import { Template as Typography } from "@spectrum-css/typography/stories/template.js"; import metadata from "../dist/metadata.json"; import packageJson from "../package.json"; @@ -8,16 +10,32 @@ import { DialogFullscreen, DialogFullscreenTakeover, DialogGroup } from "./dialo import { Template } from "./template.js"; /** - * A dialog displays important information that users need to acknowledge. They appear over the interface and block further interactions. + * A dialog displays important information that users need to acknowledge. They appear over the interface and block further interactions. Standard dialogs are the most frequent type of dialogs. They appear in the center of the screen over the interface and should be used for moderately complex tasks. Takeover dialogs are large types of dialogs. They use the totality of the screen and should be used for modal experiences with complex workflows. + * + * The alert variants that were previously a part of Dialog were moved to their own component, [alert dialog](/docs/components-alert-dialog--docs). + * + * ## Usage with modal component + * When a dialog component is used in tandem with a [modal](/docs/components-modal--docs), implementations should set `--mod-modal-background-color` to `transparent`. This will prevent any background color used in the modal from peeking through from behind the dialog at the rounded corners, allowing the dialog's background color to take precedence. * - * The alert variants that were previously a part of Dialog were moved to their own component, [Alert Dialog](/docs/components-alert-dialog--docs). */ export default { title: "Dialog", component: "Dialog", argTypes: { + size: size(["s", "m", "l"]), heading: { name: "Heading", + description: "Title for the dialog.", + type: { name: "string" }, + table: { + type: { summary: "string" }, + category: "Content", + }, + control: { type: "text" }, + }, + header: { + name: "Additional header content", + description: "Controls header content.", type: { name: "string" }, table: { type: { summary: "string" }, @@ -28,6 +46,7 @@ export default { content: { table: { disable: true } }, hasFooter: { name: "Has footer", + description: "Adds a footer to the dialog, containing the button group, checkbox, and footer text. Currently only supported in the default layout.", type: { name: "boolean" }, table: { type: { summary: "boolean" }, @@ -35,8 +54,29 @@ export default { }, control: "boolean", }, - footer: { table: { disable: true } }, - size: size(["s", "m", "l"]), + isOpen, + footer: { + name: "Footer text", + description: "Text content of the dialog footer. Represents the checkbox label if a checkbox is present, or stands alone if there is no checkbox. Currently only supported in the default layout.", + type: { name: "string" }, + table: { + type: { summary: "string" }, + category: "Content", + }, + control: { type: "text" }, + if: { arg: "hasFooter", truthy: true, }, + }, + hasCheckbox: { + name: "Has checkbox", + description: "Adds a checkbox to the footer content. Currently only supported in the default layout.", + type: { name: "boolean" }, + table: { + type: { summary: "boolean" }, + category: "Content", + }, + control: { type: "boolean" }, + if: { arg: "hasFooter", truthy: true, }, + }, layout: { name: "Layout", type: { name: "string" }, @@ -45,6 +85,7 @@ export default { type: { summary: "string" }, category: "Component", defaultValue: { summary: "Default" }, + disable: true, }, options: ["default", "fullscreen", "fullscreenTakeover"], control: "select", @@ -59,8 +100,8 @@ export default { control: "boolean", if: { arg: "layout", eq: "default" }, }, - hasDivider: { - name: "Divider", + showModal: { + name: "Wrap the dialog in a modal", type: { name: "boolean" }, table: { type: { summary: "boolean" }, @@ -68,43 +109,45 @@ export default { }, control: "boolean", }, - showModal: { - name: "Wrap the dialog in a modal", + hasHeroImage: { + name: "Has hero image", type: { name: "boolean" }, + description: "Adds a cover image to the header of a dialog.", table: { type: { summary: "boolean" }, - category: "Component", + category: "Content", }, control: "boolean", + if: { arg: "layout", eq: "default" }, }, - isOpen, heroImageUrl: { name: "Hero Image", type: { name: "string" }, - description: "Adds a cover image to the header of a dialog.", + description: "Select a cover image for the hero section of a dialog.", + defaultValue: "example-card-portrait.png", table: { type: { summary: "string" }, category: "Content", + defaultValue: { summary: "example-card-portrait.png" }, }, control: { type: "file", accept: ".svg,.png,.jpg,.jpeg,.webc" }, - if: { arg: "layout", eq: "default" }, + if: { arg: "hasHeroImage", truthy: true }, }, }, args: { rootClass: "spectrum-Dialog", hasFooter: true, + footer: "Do not show this message again.", isDismissible: false, - hasDivider: true, isOpen: true, - showModal: true, + showModal: false, size: "m", layout: "default", + hasCheckbox: true, + hasHeroImage: false, }, parameters: { layout: "fullscreen", - actions: { - handles: ["click .spectrum-Dialog button"], - }, docs: { story: { // TODO: restore `inline: false,` @@ -117,22 +160,28 @@ export default { }, packageJson, metadata, + status: { + type: "migrated", + }, }, decorators: [ withUnderlayWrapper, ], + tags: ["migrated"], }; -const ExampleContent = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Auctor augue mauris augue neque gravida. Libero volutpat sed ornare arcu. Quisque egestas diam in arcu cursus euismod quis viverra. Posuere ac ut consequat semper viverra nam libero justo laoreet. Enim ut tellus elementum sagittis vitae et leo duis ut. Neque laoreet suspendisse interdum consectetur libero id faucibus nisl. Diam volutpat commodo sed egestas egestas. Dolor magna eget est lorem ipsum dolor. Vitae suscipit tellus mauris a diam maecenas sed. Turpis in eu mi bibendum neque egestas congue. Rhoncus est pellentesque elit ullamcorper dignissim cras lobortis."; +const ExampleContent = "Standard dialog description. This should briefly communicate any additional information or context about the standard dialog title, to help users make one of the decisions offered by the buttons. Make it no more than a few short sentences."; /** - * The default size for dialog is medium. + * The default size for dialog is medium. The default dialog also has a checkbox in the footer. */ export const Default = DialogGroup.bind({}); Default.args = { heading: "Lorem ipsum dolor sit amet, consectetur adipiscing elit", + header: "* Required", + showModal: true, content: [ - (passthroughs, context) => Typography({ + (passthroughs, context) => Typography({ semantics: "body", size: "m", content: [ ExampleContent ], @@ -165,7 +214,7 @@ DefaultLarge.args = { }; /** - * A dialog that can be dismissed without taking an action. Dismissible dialogs should never have buttons. + * A dialog that can be dismissed without taking an action. */ export const Dismissible = Template.bind({}); Dismissible.tags = ["!dev"]; @@ -177,38 +226,18 @@ Dismissible.args = { isDismissible: true, }; -/** - * Dialogs can forgo the divider if they have content that spans the entire width of the dialog. - */ -export const NoDivider = Template.bind({}); -NoDivider.tags = ["!dev"]; -NoDivider.parameters = { - chromatic: { disableSnapshot: true }, -}; -NoDivider.args = { - ...Default.args, - isDismissible: true, - hasDivider: false, -}; - /** * Dialogs can have a hero or cover image header. */ export const WithHero = Template.bind({}); WithHero.tags = ["!dev"]; +WithHero.storyName = "With hero image"; WithHero.parameters = { - docs: { - story: { - height: "650px", - }, - }, chromatic: { disableSnapshot: true }, }; WithHero.args = { ...Default.args, - isDismissible: true, hasHeroImage: true, - heroImageUrl: "example-card-portrait.png", }; /** @@ -217,54 +246,121 @@ WithHero.args = { export const WithScroll = Template.bind({}); WithScroll.args = { ...Default.args, + content: [ ExampleContent, ExampleContent, ExampleContent, ExampleContent ], customStyles: { "max-block-size": "400px", } }; +WithScroll.storyName = "Scrollable"; WithScroll.tags = ["!dev"]; WithScroll.parameters = { chromatic: { disableSnapshot: true }, }; /** - * A fullscreen dialog will automatically fill almost all of the available screen space. A margin is included around the outside of the dialog. + * The fullscreen variant shows a large dialog background, only revealing a small portion of the page around the outside of the dialog, behind an overlay. The size of the dialog varies with the size of the screen, in both width and height. + * + * Fullscreen dialogs do not support a close button, and are not dismissible. + * + * Implementations may swap out the extra header content and body content for other components, like the [steplist](/docs/components-steplist--docs) and [table](/docs/components-table--docs) seen in this example. Components in the extra header content area will be centered. */ export const Fullscreen = DialogFullscreen.bind({}); +Fullscreen.args = { + ...Default.args, + header:[ + (passthroughs, context) => Steplist({ + ...passthroughs, + items: [ + { + label: "Enter records", + isComplete: true, + }, + { + label: "Confirmation", + isComplete: true, + }, + { + label: "Summary", + isSelected: true, + }, + ], + }, context), + ], + content: [ + (passthroughs, context) => Table({ + ...passthroughs, + showThumbnails: true, + rowItems: [ + { + cellContent: ["Table Row Alpha", "Test", "2"], + }, + { + cellContent: ["Table Row Bravo", "Test", "28"], + }, + { + cellContent: [ + "Table Row Charlie. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt.", + "Test", + "23", + ], + }, + { + cellContent: ["Table Row Delta", "Test", "7"], + }, + { + cellContent: ["Summary Row", "", "60"], + isSummaryRow: true, + }, + ], + }, context), + ], + layout: "fullscreen", + hasFooter: false, +}; Fullscreen.parameters = { chromatic: { disableSnapshot: true }, design: { type: "figma", url: "https://www.figma.com/design/Mngz9H7WZLbrCvGQf3GnsY/S2-%2F-Desktop?node-id=61935-5399", - }, + } }; -Fullscreen.args = { - ...Default.args, - layout: "fullscreen", + +// TODO: Because storybook doesn't support for multiple conditionals, we've removed the hasFooter +// arg from the control table for the fullscreen and fullscreenTakeover stories only. Ideally, we +// could have some of our controls display when more than one arg is met to avoid custom argTypes. +// For instance, hasCheckbox would appear when layout: "default", AND footer is truthy. +// https://github.com/storybookjs/storybook/discussions/18542 +Fullscreen.argTypes = { + hasFooter: { table: { disable: true, } }, + header: { table: { disable: true, } }, }; /** - * A fullscreen takeover dialog will fill all of the available screen space. + * The fullscreen takeover variant is similar to the fullscreen variant except that the background covers the entire screen. The page behind the dialog is not visible. This variant should be reserved for workflows where displaying a second dialog on top of the first one is to be expected. + * + * Fullscreen takeover dialogs do not support a close button, and are not dismissible. */ export const FullscreenTakeover = DialogFullscreenTakeover.bind({}); +FullscreenTakeover.storyName = "Fullscreen takeover"; FullscreenTakeover.parameters = { chromatic: { disableSnapshot: true }, design: { type: "figma", url: "https://www.figma.com/design/Mngz9H7WZLbrCvGQf3GnsY/S2-%2F-Desktop?node-id=61935-5399", - }, + } }; FullscreenTakeover.args = { ...Default.args, layout: "fullscreenTakeover", - content: [ () => Typography({ - semantics: "body", - size: "m", - content: [ ExampleContent, ExampleContent, ExampleContent, ExampleContent ], - })], + hasFooter: false, + content: [ ExampleContent, ExampleContent, ExampleContent, ExampleContent, ExampleContent, ExampleContent, ExampleContent, ExampleContent ], +}; +FullscreenTakeover.argTypes = { + hasFooter: { table: { disable: true, } }, }; // ********* VRT ONLY ********* // -export const WithForcedColors = DialogGroup.bind({}); +export const WithForcedColors = Default.bind({}); WithForcedColors.args = Default.args; WithForcedColors.tags = ["!autodocs", "!dev"]; WithForcedColors.parameters = { diff --git a/components/dialog/stories/dialog.test.js b/components/dialog/stories/dialog.test.js index f9b5acb6b2e..c7805ee7472 100644 --- a/components/dialog/stories/dialog.test.js +++ b/components/dialog/stories/dialog.test.js @@ -16,10 +16,6 @@ export const DialogGroup = Variants({ // TODO: The dialog's heading arg is getting passed as the "Sizing" heading arg (instead of the // TODO: word "Sizing"). We should be able to remove this arg once that no longers happens. heading: showTestingGrid ? "Lorem ipsum dolor sit amet, consectetur adipiscing elit" : args.heading, - customStyles: { - ...(args.customStyles ?? {}), - "background-color": showTestingGrid ? "var(--spectrum-gray-100)" : undefined, - }, }, context); }, sizeDirection: "column", @@ -42,63 +38,69 @@ export const DialogGroup = Variants({ }, { testHeading: "With hero/cover image", + hasHeroImage: true, heroImageUrl: "example-card-portrait.png", }, { testHeading: "With hero/cover image, dismissible", + hasHeroImage: true, heroImageUrl: "example-card-portrait.png", isDismissible: true, hasFooter: false, }, - { - testHeading: "No divider", - hasDivider: false, - }, - { - testHeading: "No divider, dismissible", - hasDivider: false, - isDismissible: true, - hasFooter: false, - }, - { - testHeading: "With hero/cover image, no divider", - hasDivider: false, - heroImageUrl: "example-card-portrait.png", - }, - { - testHeading: "With hero/cover image, no divider, dismissible", - hasDivider: false, - isDismissible: true, - hasFooter: false, - heroImageUrl: "example-card-portrait.png", - }, ], }); -export const DialogFullscreen = Variants({ - Template, - withSizes: false, - wrapperStyles: { - "background-color": "var(--spectrum-gray-50)" - }, - testData: [ - { - showModal: false, - layout: "fullscreen", +export const DialogFullscreen = (args, context) => { + const { parameters: { showTestingGrid = false } = {} } = context; + + return Variants({ + Template: (args, context) => { + return Template({ + ...args, + /* + * Custom styles were added to make sure the VRTs catch the rounded corners + */ + customStyles: { + margin: showTestingGrid ? "16px" : undefined, + }, + }, context); }, - ], -}); + withSizes: false, + wrapperStyles: { + "background-color": "var(--spectrum-gray-50)", + ...(showTestingGrid && { "inline-size": "100%" }), // Applies conditional styles based on showTestingGrid- forces the data-inner-container to be full width so the container query doesn't break. + }, + containerStyles: { + ...(showTestingGrid && { "inline-size": "100%" }), // forces the data-outer-container to be full width so the container query doesn't break. + }, + testData: [ + { + showModal: false, + layout: "fullscreen", + }, + ], + })(args, context); +}; -export const DialogFullscreenTakeover = Variants({ - Template, - withSizes: false, - wrapperStyles: { - "background-color": "var(--spectrum-gray-50)" - }, - testData: [ - { - showModal: false, - layout: "fullscreenTakeover", +export const DialogFullscreenTakeover = (args, context) => { + const { parameters: { showTestingGrid = false } = {} } = context; + + return Variants({ + Template, + withSizes: false, + wrapperStyles: { + ...(showTestingGrid && { "inline-size": "100%" }), // Applies conditional styles based on showTestingGrid- forces the data-inner-container to be full width so the container query doesn't break. }, - ], -}); + // Apply conditional styles based on showTestingGrid + containerStyles: { + ...(showTestingGrid && { "inline-size": "100%" }), // forces the data-outer-container to be full width so the container query doesn't break. + }, + testData: [ + { + showModal: false, + layout: "fullscreenTakeover", + }, + ], + })(args, context); +}; diff --git a/components/dialog/stories/template.js b/components/dialog/stories/template.js index 86d2af5d050..b8c84b04a92 100644 --- a/components/dialog/stories/template.js +++ b/components/dialog/stories/template.js @@ -1,6 +1,6 @@ import { Template as ButtonGroup } from "@spectrum-css/buttongroup/stories/template.js"; +import { Template as Checkbox } from "@spectrum-css/checkbox/stories/template.js"; import { Template as CloseButton } from "@spectrum-css/closebutton/stories/template.js"; -import { Template as Divider } from "@spectrum-css/divider/stories/template.js"; import { Template as Modal } from "@spectrum-css/modal/stories/template.js"; import { getRandomId, renderContent } from "@spectrum-css/preview/decorators"; import { html } from "lit"; @@ -14,17 +14,19 @@ import "../index.css"; export const Template = ({ rootClass = "spectrum-Dialog", isDismissible = false, - hasDivider = true, isOpen = true, showModal = false, hasFooter = false, heading, + header = [], + hasCheckbox = false, content = [], footer = [], customClasses = [], id = getRandomId("dialog"), size = "m", layout, + hasHeroImage = false, heroImageUrl, customStyles = {}, } = {}, context = {}) => { @@ -38,10 +40,9 @@ export const Template = ({
    layout !== l), + [`${rootClass}--dismissible`]: isDismissible && ["fullscreen", "fullscreenTakeover"].every(l => layout !== l), [`${rootClass}--${layout}`]: typeof layout !== "undefined", [`${rootClass}--size${size?.toUpperCase()}`]: typeof size !== "undefined", - [`${rootClass}--noDivider`]: !hasDivider, ...customClasses.reduce((a, c) => ({ ...a, [c]: true }), {}), })} id=${ifDefined(id)} @@ -51,72 +52,126 @@ export const Template = ({ style=${ifDefined(styleMap(customStyles))} >
    - ${when(typeof heroImageUrl !== "undefined", () => + ${when(hasHeroImage, () => html`
    + style="background-image:url(${heroImageUrl ? heroImageUrl : "example-card-portrait.png"})">
    ` )} - ${when(heading, () => html` -

    ${heading}

    - `)} - ${when(hasDivider, () => - Divider({ - horizontal: true, - customClasses: [`${rootClass}-divider`], - }, context), +
    + ${when(heading, () => html` +

    ${heading}

    + `)} + ${when(header, () => html` +
    +
    + ${renderContent(header)} +
    +
    + `, )} -
    - ${renderContent(content)} -
    - ${when(hasFooter, () => { - return html` -
    - ${when(typeof footer !== "undefined" && Array.isArray(footer) && footer.length > 0, - () => renderContent(footer), - )} - ${when(!isDismissible, () => html ` - ${ButtonGroup({ - items: [ - { - label: "Cancel", - treatment: "outline", - variant: "secondary", - }, - { - label: "Save", - treatment: "fill", - variant: "accent" - }, - ], - }, context)} - ` - )} -
    - `; - })} - ${when(isDismissible && layout !== "fullscreen" && layout !== "fullscreenTakeover", () => +
    +
    ${renderContent(content)}
    + ${when(isDismissible, () => CloseButton({ customClasses: [`${rootClass}-closeButton`], onclick: toggleOpen, }, context) )} + ${when(layout === "fullscreen" || layout === "fullscreenTakeover", () => html` +
    + ${ButtonGroup({ + items: [ + { + label: "Cancel", + treatment: "outline", + variant: "secondary", + }, + { + label: "Save", + treatment: "fill", + variant: "accent" + }, + ], + onclick: () => { + updateArgs(toggleOpen); + }, + }, context)} +
    + `)} + ${when(hasFooter, () => html` +
    + ${when(typeof footer !== "undefined", () => html` +
    + ${when(hasCheckbox, () => html` + ${Checkbox({ + label: footer, + }, context)} + `, + () => + renderContent(footer) + )} +
    +
    + ${ButtonGroup({ + items: [ + { + label: "Cancel", + treatment: "outline", + variant: "secondary", + }, + { + label: "Save", + treatment: "fill", + variant: "accent" + }, + ], + onclick: () => { + updateArgs(toggleOpen); + }, + }, context)} +
    + `, + () => html` +
    +
    + ${ButtonGroup({ + items: [ + { + label: "Cancel", + treatment: "outline", + variant: "secondary", + }, + { + label: "Save", + treatment: "fill", + variant: "accent" + }, + ], + onclick: () => { + updateArgs(toggleOpen); + }, + }, context)} +
    + ` + )} +
    + `, + () => html` +
    + `)}
    `; if (showModal) { - return html` - ${Modal({ - isOpen, - content: [ () => Dialog], - variant: layout, - }, context)} - `; + return Modal({ + isOpen, + content: Dialog, + variant: layout, + }, context); } else { return Dialog; diff --git a/components/divider/CHANGELOG.md b/components/divider/CHANGELOG.md index 4d868c46086..a42904b1f61 100644 --- a/components/divider/CHANGELOG.md +++ b/components/divider/CHANGELOG.md @@ -1,5 +1,53 @@ # Change log +## 6.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + +## 6.0.0-next.0 + +### Major Changes + +- [#3557](https://github.com/adobe/spectrum-css/pull/3557) [`c6836fb`](https://github.com/adobe/spectrum-css/commit/c6836fb132effcfb09e4ca6d0d8923564bfe2914) Thanks [@cdransf](https://github.com/cdransf)! + +#### S2 divider migration + +This migrates the `divider` component to S2. Custom properties have been remapped and updated per the design specificiations. + +##### New properties + +```css +--spectrum-divider-horizontal-minimum-width +--spectrum-divider-vertical-minimum-height +``` + +##### New mods + +```css +--mod-divider-inline-minimum-size +--mod-divider-block-minimum-size +``` + +##### Removed mods + +```css +--mod-divider-background-color-large-static-black +--mod-divider-background-color-large-static-white +--mod-divider-background-color-medium-static-black +--mod-divider-background-color-medium-static-white +--mod-divider-background-color-small-static-black +--mod-divider-background-color-small-static-white +``` + +##### Additions + +This adds new minimum width and height tokens for the divider and the `minDimensionValues` arg has been removed in favor of these tokens and the rules with which they're applied. + +The default size for the Storybook control has been changed to `medium` (the new default size for the component). All sizes are now displayed for the static color variants in the docs. + ## 5.2.0 ### Minor Changes diff --git a/components/divider/dist/metadata.json b/components/divider/dist/metadata.json index a485bf25e3b..94ce19f83fd 100644 --- a/components/divider/dist/metadata.json +++ b/components/divider/dist/metadata.json @@ -6,20 +6,15 @@ ".spectrum-Divider--sizeS", ".spectrum-Divider--staticBlack", ".spectrum-Divider--staticBlack.spectrum-Divider--sizeL", - ".spectrum-Divider--staticBlack.spectrum-Divider--sizeS", ".spectrum-Divider--staticWhite", ".spectrum-Divider--staticWhite.spectrum-Divider--sizeL", - ".spectrum-Divider--staticWhite.spectrum-Divider--sizeS", - ".spectrum-Divider--vertical" + ".spectrum-Divider--vertical", + ".spectrum-Divider:not(.spectrum-Divider.spectrum-Divider--vertical)" ], "modifiers": [ "--mod-divider-background-color", - "--mod-divider-background-color-large-static-black", - "--mod-divider-background-color-large-static-white", - "--mod-divider-background-color-medium-static-black", - "--mod-divider-background-color-medium-static-white", - "--mod-divider-background-color-small-static-black", - "--mod-divider-background-color-small-static-white", + "--mod-divider-block-minimum-size", + "--mod-divider-inline-minimum-size", "--mod-divider-thickness", "--mod-divider-vertical-align", "--mod-divider-vertical-height", @@ -27,12 +22,14 @@ ], "component": [ "--spectrum-divider-background-color", - "--spectrum-divider-background-color-static-black", - "--spectrum-divider-background-color-static-white", + "--spectrum-divider-block-minimum-size", + "--spectrum-divider-horizontal-minimum-width", + "--spectrum-divider-inline-minimum-size", "--spectrum-divider-thickness", "--spectrum-divider-thickness-large", "--spectrum-divider-thickness-medium", - "--spectrum-divider-thickness-small" + "--spectrum-divider-thickness-small", + "--spectrum-divider-vertical-minimum-height" ], "global": [ "--spectrum-gray-200", @@ -42,11 +39,6 @@ "--spectrum-transparent-white-200", "--spectrum-transparent-white-800" ], - "system-theme": [ - "--system-divider-background-color", - "--system-divider-background-color-static-black", - "--system-divider-background-color-static-white" - ], "passthroughs": [], "high-contrast": ["--highcontrast-divider-background-color"] } diff --git a/components/divider/index.css b/components/divider/index.css index 188aeea7ecf..b793b6c86a1 100644 --- a/components/divider/index.css +++ b/components/divider/index.css @@ -1,5 +1,5 @@ /*! - * Copyright 2024 Adobe. All rights reserved. + * Copyright 2025 Adobe. All rights reserved. * * This file is licensed to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. You may obtain a copy @@ -11,17 +11,13 @@ * governing permissions and limitations under the License. */ -@import "./themes/spectrum-two.css"; - -/* windows high contrast mode */ -@media (forced-colors: active) { - .spectrum-Divider { - --highcontrast-divider-background-color: CanvasText; - } -} - .spectrum-Divider { + --spectrum-divider-background-color: var(--spectrum-gray-200); + --spectrum-divider-thickness: var(--spectrum-divider-thickness-medium); + + --spectrum-divider-inline-minimum-size: var(--spectrum-divider-horizontal-minimum-width); + --spectrum-divider-block-minimum-size: var(--spectrum-divider-vertical-minimum-height); } .spectrum-Divider--sizeS { @@ -35,33 +31,19 @@ /* static white variant colors */ .spectrum-Divider--staticWhite { - /** @deprecated --mod-divider-background-color-medium-static-white, use --mod-divider-background-color instead */ - --mod-divider-background-color: var(--mod-divider-background-color-medium-static-white, var(--spectrum-divider-background-color-static-white)); - - &.spectrum-Divider--sizeS { - /** @deprecated --mod-divider-background-color-small-static-white, use --mod-divider-background-color instead */ - --mod-divider-background-color: var(--mod-divider-background-color-small-static-white, var(--spectrum-divider-background-color-static-white)); - } + --spectrum-divider-background-color: var(--spectrum-transparent-white-200); &.spectrum-Divider--sizeL { - /** @deprecated --mod-divider-background-color-large-static-white, use --mod-divider-background-color instead */ - --mod-divider-background-color: var(--mod-divider-background-color-large-static-white, var(--spectrum-transparent-white-800)); + --spectrum-divider-background-color: var(--spectrum-transparent-white-800); } } /* static black variant colors */ .spectrum-Divider--staticBlack { - /** @deprecated --mod-divider-background-color-medium-static-black, use --mod-divider-background-color instead */ - --mod-divider-background-color: var(--mod-divider-background-color-medium-static-black, var(--spectrum-divider-background-color-static-black)); - - &.spectrum-Divider--sizeS { - /** @deprecated --mod-divider-background-color-small-static-black, use --mod-divider-background-color instead */ - --mod-divider-background-color: var(--mod-divider-background-color-small-static-black, var(--spectrum-divider-background-color-static-black)); - } + --spectrum-divider-background-color: var(--spectrum-transparent-black-200); &.spectrum-Divider--sizeL { - /** @deprecated --mod-divider-background-color-large-static-black, use --mod-divider-background-color instead */ - --mod-divider-background-color: var(--mod-divider-background-color-large-static-black, var(--spectrum-transparent-black-800)); + --spectrum-divider-background-color: var(--spectrum-transparent-black-800); } } @@ -77,13 +59,24 @@ border-radius: var(--mod-divider-thickness, var(--spectrum-divider-thickness)); background-color: var(--highcontrast-divider-background-color, var(--mod-divider-background-color, var(--spectrum-divider-background-color))); + + &:not(&.spectrum-Divider--vertical) { + min-inline-size: var(--mod-divider-inline-minimum-size, var(--spectrum-divider-inline-minimum-size)); + } } /* vertical dividers */ .spectrum-Divider--vertical { inline-size: var(--mod-divider-thickness, var(--spectrum-divider-thickness)); + min-block-size: var(--mod-divider-block-minimum-size, var(--spectrum-divider-block-minimum-size)); + margin-block: var(--mod-divider-vertical-margin, 0); block-size: var(--mod-divider-vertical-height, 100%); + align-self: var(--mod-divider-vertical-align, flex-start); +} - margin-block: var(--mod-divider-vertical-margin); - align-self: var(--mod-divider-vertical-align); +/* windows high contrast mode */ +@media (forced-colors: active) { + .spectrum-Divider { + --highcontrast-divider-background-color: CanvasText; + } } diff --git a/components/divider/package.json b/components/divider/package.json index 3a88573338c..94c41fb8f89 100644 --- a/components/divider/package.json +++ b/components/divider/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/divider", - "version": "5.2.0", + "version": "6.0.0-next.1", "description": "The Spectrum CSS divider component", "license": "Apache-2.0", "author": "Adobe", @@ -19,14 +19,12 @@ "./package.json": "./package.json", "./dist/*": "./dist/*", "./index.css": "./dist/index.css", - "./index-*.css": "./dist/index-*.css", "./metadata.json": "./dist/metadata.json", - "./themes/*": "./dist/themes/*", "./stories/*": "./stories/*" }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/tokens": ">=16.0.1" + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/tokens": { @@ -34,7 +32,7 @@ } }, "devDependencies": { - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/divider/stories/divider.stories.js b/components/divider/stories/divider.stories.js index 306e5c0c453..fe5696c1371 100644 --- a/components/divider/stories/divider.stories.js +++ b/components/divider/stories/divider.stories.js @@ -25,13 +25,11 @@ export default { control: "boolean", }, tag: { table: { disable: true } }, - minDimensionValues: {table: { disable: true }}, }, args: { rootClass: "spectrum-Divider", - size: "s", + size: "m", vertical: false, - minDimensionValues: true, }, parameters: { design: { @@ -40,20 +38,22 @@ export default { }, packageJson, metadata, + status: { + type: "migrated", + }, }, + tags: ["migrated"], }; /** - * By default, dividers are horizontal and should be used for separating content vertically. The small divider is the default size. + * By default, dividers are horizontal and should be used for separating content vertically. The medium divider is the default size. */ export const Default = DividerGroup.bind({}); Default.args = {}; // ********* DOCS ONLY ********* // /** - * To divide similar components such as table rows, action button groups, and components within a panel, use the default, small divider. - * - * The medium divider is used for dividing subsections on a page, or to separate different groupings of components such as panels, rails, etc. + * To divide similar components such as table rows, action button groups, and components within a panel, use the default, medium divider. * * Only use the large divider for page titles or section titles. */ @@ -63,9 +63,6 @@ export const Sizing = (args, context) => Sizes({ withBorder: false, ...args, }, context); -Sizing.args = { - minDimensionValues: true, -}; Sizing.tags = ["!dev"]; Sizing.parameters = { chromatic: { disableSnapshot: true }, @@ -84,13 +81,17 @@ VerticalSizing.storyName = "Vertical"; VerticalSizing.tags = ["!dev"]; VerticalSizing.args = { vertical: true, - minDimensionValues: true, }; VerticalSizing.parameters = { chromatic: { disableSnapshot: true }, }; -export const StaticWhiteGroup = Default.bind({}); +export const StaticWhiteGroup = (args, context) => Sizes({ + Template, + withHeading: false, + withBorder: false, + ...args, +}, context); StaticWhiteGroup.storyName = "Static white"; StaticWhiteGroup.tags = ["!dev"]; StaticWhiteGroup.args = { @@ -100,7 +101,12 @@ StaticWhiteGroup.parameters = { chromatic: { disableSnapshot: true }, }; -export const StaticBlackGroup = Default.bind({}); +export const StaticBlackGroup = (args, context) => Sizes({ + Template, + withHeading: false, + withBorder: false, + ...args, +}, context); StaticBlackGroup.storyName = "Static black"; StaticBlackGroup.tags = ["!dev"]; StaticBlackGroup.args = { diff --git a/components/divider/stories/divider.test.js b/components/divider/stories/divider.test.js index a670bfd6872..c4b708206db 100644 --- a/components/divider/stories/divider.test.js +++ b/components/divider/stories/divider.test.js @@ -7,18 +7,15 @@ export const DividerGroup = Variants({ { testHeading: "Default", vertical: false, - minDimensionValues: true, }, { testHeading: "Non-HR", tag: "div", vertical: false, - minDimensionValues: true, }, { testHeading: "Vertical", vertical: true, - minDimensionValues: true, }, { testHeading: "Static black", diff --git a/components/divider/stories/template.js b/components/divider/stories/template.js index ac2ffa2a4c1..149a9626674 100644 --- a/components/divider/stories/template.js +++ b/components/divider/stories/template.js @@ -4,9 +4,6 @@ import { styleMap } from "lit/directives/style-map.js"; import { capitalize, upperCase } from "lodash-es"; import "../index.css"; -import "../themes/spectrum.css"; -/* Must be imported last */ -import "../themes/express.css"; export const Template = ({ rootClass = "spectrum-Divider", @@ -14,7 +11,6 @@ export const Template = ({ tag = "hr", staticColor, vertical = false, - minDimensionValues, customClasses = [], customStyles = {}, } = {}) => { @@ -28,11 +24,7 @@ export const Template = ({ typeof staticColor !== "undefined", ...customClasses.reduce((a, c) => ({ ...a, [c]: true }), {}), })} - style=${styleMap({ - "min-inline-size": minDimensionValues && !vertical ? "200px": undefined, - "min-block-size": minDimensionValues && vertical ? "20px": undefined, - ...customStyles, - })} + style=${styleMap({...customStyles})} role="separator" />`; } @@ -46,11 +38,7 @@ export const Template = ({ typeof staticColor !== "undefined", ...customClasses.reduce((a, c) => ({ ...a, [c]: true }), {}), })} - style=${styleMap({ - "min-inline-size": minDimensionValues && !vertical ? "200px": undefined, - "min-block-size": minDimensionValues && vertical ? "20px": undefined, - ...customStyles, - })} + style=${styleMap({...customStyles})} role="separator" >
    `; }; diff --git a/components/divider/themes/express.css b/components/divider/themes/express.css deleted file mode 100644 index 9fd550418f2..00000000000 --- a/components/divider/themes/express.css +++ /dev/null @@ -1,16 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--express */ - -@import "./spectrum.css"; diff --git a/components/divider/themes/spectrum-two.css b/components/divider/themes/spectrum-two.css deleted file mode 100644 index 58f8de9a767..00000000000 --- a/components/divider/themes/spectrum-two.css +++ /dev/null @@ -1,25 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -@container style(--system: spectrum) { - .spectrum-Divider { - /* background colors */ - --spectrum-divider-background-color: var(--spectrum-gray-200); - - /* static white background colors */ - --spectrum-divider-background-color-static-white: var(--spectrum-transparent-white-200); - - /* static black background colors */ - --spectrum-divider-background-color-static-black: var(--spectrum-transparent-black-200); - } -} diff --git a/components/divider/themes/spectrum.css b/components/divider/themes/spectrum.css deleted file mode 100644 index ecfe3f3a46a..00000000000 --- a/components/divider/themes/spectrum.css +++ /dev/null @@ -1,29 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--legacy */ - -@import "./spectrum-two.css"; - -@container style(--system: legacy) { - .spectrum-Divider { - /* background colors */ - --spectrum-divider-background-color: var(--spectrum-gray-300); - - /* static white background colors */ - --spectrum-divider-background-color-static-white: var(--spectrum-transparent-white-300); - - /* static black background colors */ - --spectrum-divider-background-color-static-black: var(--spectrum-transparent-black-300); - } -} diff --git a/components/dropindicator/CHANGELOG.md b/components/dropindicator/CHANGELOG.md index 26febc7f00a..123431aa820 100644 --- a/components/dropindicator/CHANGELOG.md +++ b/components/dropindicator/CHANGELOG.md @@ -1,5 +1,19 @@ # Change log +## 8.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + +## 8.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`a25e0a9`](https://github.com/adobe/spectrum-css/commit/a25e0a99e5a4736ab4e607e00739343101a2633b)]: + - @spectrum-css/icon@10.0.0-next.0 + ## 7.2.0 ### Minor Changes diff --git a/components/dropindicator/dist/metadata.json b/components/dropindicator/dist/metadata.json index dd3a7a50810..294d6ad70bb 100644 --- a/components/dropindicator/dist/metadata.json +++ b/components/dropindicator/dist/metadata.json @@ -23,7 +23,6 @@ "--spectrum-dropindicator-color" ], "global": ["--spectrum-border-width-200"], - "system-theme": [], "passthroughs": [], "high-contrast": ["--highcontrast-dropindicator-color"] } diff --git a/components/dropindicator/package.json b/components/dropindicator/package.json index e20bad94d0d..692533282cf 100644 --- a/components/dropindicator/package.json +++ b/components/dropindicator/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/dropindicator", - "version": "7.2.0", + "version": "8.0.0-next.1", "description": "The Spectrum CSS dropindicator component", "license": "Apache-2.0", "author": "Adobe", @@ -24,8 +24,8 @@ }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/icon": ">=9.0.0 <10.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/icon": ">=10.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/icon": { @@ -36,8 +36,8 @@ } }, "devDependencies": { - "@spectrum-css/icon": "9.2.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/icon": "10.0.0-next.3", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/dropindicator/stories/dropindicator.stories.js b/components/dropindicator/stories/dropindicator.stories.js index ea28cb3b5f1..1333e0f2e83 100644 --- a/components/dropindicator/stories/dropindicator.stories.js +++ b/components/dropindicator/stories/dropindicator.stories.js @@ -41,7 +41,11 @@ export default { parameters: { packageJson, metadata, + status: { + type: "unmigrated", + }, }, + tags: ["unmigrated"], }; export const Default = DropIndicatorGroup.bind({}); diff --git a/components/dropzone/CHANGELOG.md b/components/dropzone/CHANGELOG.md index 8e3a4aa194d..077a0d4e36f 100644 --- a/components/dropzone/CHANGELOG.md +++ b/components/dropzone/CHANGELOG.md @@ -1,5 +1,85 @@ # Change log +## 9.0.0-next.4 + +### Patch Changes + +📝 [#4113](https://github.com/adobe/spectrum-css/pull/4113) [`cf4fc1a`](https://github.com/adobe/spectrum-css/commit/cf4fc1a01d23ba810f45a903ecc29a5c8aae33d1) Thanks [@castastrophe](https://github.com/castastrophe)! + +## Minor linting fixes + +- Removed unused custom properties across multiple components +- Fixed color function notation by converting `rgba()` to `rgb()` where appropriate +- Removed duplicate custom property declarations +- Fixed deprecated CSS properties (e.g., `word-wrap` → `overflow-wrap`) +- Removed unnecessary stylelint-disable comments + +_No visual or functional changes to components._ + +## 9.0.0-next.3 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + - @spectrum-css/illustratedmessage@10.0.0-next.0 + +## 9.0.0-next.2 + +### Patch Changes + +- Updated dependencies [[`c88fcdc`](https://github.com/adobe/spectrum-css/commit/c88fcdcfa4866f4b3ff7a1027e4253b8f2114351)]: + - @spectrum-css/link@8.0.0-next.0 + +## 9.0.0-next.1 + +### Major Changes + +- [#3429](https://github.com/adobe/spectrum-css/pull/3429) [`924fc7f`](https://github.com/adobe/spectrum-css/commit/924fc7f040b84731c06fd3c59dbb1aca9001b642) Thanks [@aramos-adobe](https://github.com/aramos-adobe)! + +#### Dropzone S2 Migration + +Since dropzone shares a lot of illustrated message's new content tokens (typography and spacing), tons of unused`--mods` were removed. + +The component reflects the [new design](https://www.figma.com/design/eoZHKJH9a3LJkHYCGt60Vb/S2-token-specs?node-id=10141-2822&m=dev) of the borders that includes dash length and dash gap. + +##### SVG Border + +To support the intention of the design, an SVG element is used. There are custom `--mod` tokens to adjust the length of dashed lines and the gap between them. It's understood it may be too much to consume an additional element so there's a fallback where the SVG element is not necessary - dropzone will use the standard `border` CSS property. + +##### New mods + +`--mod-drop-zone-content-height` +`--mod-drop-zone-edge-to-text` +`--mod-drop-zone-title-line-height` +`--mod-drop-zone-border-dash-length` +`--mod-drop-zone-border-dash-gap` + +##### Removed mods + +`--mod-drop-zone-body-color` +`--mod-drop-zone-body-font-family` +`--mod-drop-zone-body-font-style` +`--mod-drop-zone-body-font-weight` +`--mod-drop-zone-body-line-height` +`--mod-drop-zone-content-color` +`--mod-drop-zone-content-edge-to-text` +`--mod-drop-zone-content-font-size` +`--mod-drop-zone-heading-color` +`--mod-drop-zone-heading-font-family` +`--mod-drop-zone-heading-font-size` +`--mod-drop-zone-heading-font-style` +`--mod-drop-zone-heading-font-weight` +`--mod-drop-zone-heading-line-height` +`--mod-drop-zone-heading-to-body` `--mod-drop-zone-illustration-to-heading` `--mod-drop-zone-illustration-to-title` + +## 9.0.0-next.0 + +### Patch Changes + +- Updated dependencies []: + - @spectrum-css/actionbutton@8.0.0-next.0 + ## 8.2.0 ### Minor Changes diff --git a/components/dropzone/dist/metadata.json b/components/dropzone/dist/metadata.json index 3044ecfc906..e91812f2d27 100644 --- a/components/dropzone/dist/metadata.json +++ b/components/dropzone/dist/metadata.json @@ -2,133 +2,116 @@ "sourceFile": "index.css", "selectors": [ ".spectrum-DropZone", + ".spectrum-DropZone .spectrum-IllustratedMessage", + ".spectrum-DropZone-actions", ".spectrum-DropZone-button", + ".spectrum-DropZone-button .spectrum-Button-label", ".spectrum-DropZone-button:focus", ".spectrum-DropZone-button:hover", ".spectrum-DropZone-content", + ".spectrum-DropZone-stroke", + ".spectrum-DropZone-strokePath", ".spectrum-DropZone.is-dragged", + ".spectrum-DropZone.is-dragged .spectrum-DropZone-strokePath", ".spectrum-DropZone.is-filled", ".spectrum-DropZone.is-filled.is-dragged", + ".spectrum-DropZone.is-filled.is-dragged .spectrum-DropZone-actions", + ".spectrum-DropZone.is-filled.is-dragged .spectrum-DropZone-content", ".spectrum-DropZone:focus-visible", - ".spectrum-DropZone:lang(ja)", - ".spectrum-DropZone:lang(ko)", - ".spectrum-DropZone:lang(zh)" + ".spectrum-DropZone:has(.spectrum-DropZone-stroke)" ], "modifiers": [ "--mod-drop-zone-background-color", "--mod-drop-zone-background-color-opacity", "--mod-drop-zone-background-color-opacity-filled", - "--mod-drop-zone-body-color", - "--mod-drop-zone-body-font-family", "--mod-drop-zone-body-font-size", - "--mod-drop-zone-body-font-style", - "--mod-drop-zone-body-font-weight", - "--mod-drop-zone-body-line-height", + "--mod-drop-zone-body-to-action", "--mod-drop-zone-border-color", "--mod-drop-zone-border-color-hover", + "--mod-drop-zone-border-dash-gap", + "--mod-drop-zone-border-dash-length", "--mod-drop-zone-border-style", "--mod-drop-zone-border-style-dragged", "--mod-drop-zone-border-width", "--mod-drop-zone-content-background-color", "--mod-drop-zone-content-bottom-to-text", - "--mod-drop-zone-content-color", - "--mod-drop-zone-content-display", - "--mod-drop-zone-content-edge-to-text", "--mod-drop-zone-content-font-family", "--mod-drop-zone-content-font-size", - "--mod-drop-zone-content-font-style", "--mod-drop-zone-content-font-weight", "--mod-drop-zone-content-height", - "--mod-drop-zone-content-line-height", "--mod-drop-zone-content-max-width", "--mod-drop-zone-content-maximum-width", "--mod-drop-zone-content-top-to-text", "--mod-drop-zone-corner-radius", - "--mod-drop-zone-heading-color", - "--mod-drop-zone-heading-font-family", - "--mod-drop-zone-heading-font-size", - "--mod-drop-zone-heading-font-style", - "--mod-drop-zone-heading-font-weight", - "--mod-drop-zone-heading-line-height", - "--mod-drop-zone-heading-to-body", - "--mod-drop-zone-illustration-color", + "--mod-drop-zone-edge-to-text", "--mod-drop-zone-illustration-color-hover", - "--mod-drop-zone-illustration-to-heading", + "--mod-drop-zone-inline-size", "--mod-drop-zone-padding", - "--mod-drop-zone-width" + "--mod-drop-zone-title-line-height" ], "component": [ "--spectrum-drop-zone-background-color", "--spectrum-drop-zone-background-color-opacity", "--spectrum-drop-zone-background-color-opacity-filled", "--spectrum-drop-zone-background-color-rgb", - "--spectrum-drop-zone-body-size", + "--spectrum-drop-zone-body-font-size", + "--spectrum-drop-zone-body-to-action", "--spectrum-drop-zone-border-color", "--spectrum-drop-zone-border-color-hover", + "--spectrum-drop-zone-border-dash-gap", + "--spectrum-drop-zone-border-dash-length", "--spectrum-drop-zone-border-width", - "--spectrum-drop-zone-cjk-title-size", + "--spectrum-drop-zone-component-height", "--spectrum-drop-zone-content-background-color", + "--spectrum-drop-zone-content-bottom-to-text", + "--spectrum-drop-zone-content-font-family", + "--spectrum-drop-zone-content-font-size", + "--spectrum-drop-zone-content-font-weight", + "--spectrum-drop-zone-content-max-width", "--spectrum-drop-zone-content-maximum-width", - "--spectrum-drop-zone-illustration-color", - "--spectrum-drop-zone-title-size", + "--spectrum-drop-zone-content-top-to-text", + "--spectrum-drop-zone-corner-radius", + "--spectrum-drop-zone-dragged-background-color", + "--spectrum-drop-zone-edge-to-text", + "--spectrum-drop-zone-illustration-color-hover", + "--spectrum-drop-zone-inline-size", + "--spectrum-drop-zone-padding", + "--spectrum-drop-zone-stroke-dash-gap", + "--spectrum-drop-zone-stroke-dash-length", + "--spectrum-drop-zone-title-line-height", "--spectrum-drop-zone-width" ], "global": [ + "--spectrum-accent-content-color-default", "--spectrum-accent-visual-color", - "--spectrum-body-color", - "--spectrum-body-line-height", - "--spectrum-body-sans-serif-font-style", - "--spectrum-body-sans-serif-font-weight", "--spectrum-bold-font-weight", "--spectrum-border-width-200", "--spectrum-component-bottom-to-text-300", "--spectrum-component-edge-to-text-300", "--spectrum-component-height-300", "--spectrum-component-top-to-text-300", - "--spectrum-corner-radius-100", - "--spectrum-default-font-style", + "--spectrum-corner-radius-500", + "--spectrum-corner-radius-700", "--spectrum-font-size-300", - "--spectrum-gray-200", - "--spectrum-heading-color", - "--spectrum-heading-line-height", - "--spectrum-heading-sans-serif-font-style", - "--spectrum-heading-sans-serif-font-weight", + "--spectrum-gray-300", "--spectrum-line-height-100", - "--spectrum-neutral-visual-color", "--spectrum-sans-font-family-stack", - "--spectrum-spacing-400", - "--spectrum-spacing-75", - "--spectrum-white" + "--spectrum-spacing-300", + "--spectrum-spacing-400" ], - "system-theme": ["--system-drop-zone-border-color"], "passthroughs": [ - "--mod-actionbutton-edge-to-text", - "--mod-actionbutton-font-size", - "--mod-actionbutton-label-color", - "--mod-illustrated-message-content-maximum-width", - "--mod-illustrated-message-description-color", - "--mod-illustrated-message-description-font-family", + "--mod-button-border-radius", "--mod-illustrated-message-description-font-size", - "--mod-illustrated-message-description-font-style", - "--mod-illustrated-message-description-font-weight", - "--mod-illustrated-message-description-line-height", "--mod-illustrated-message-description-position", + "--mod-illustrated-message-description-to-action", "--mod-illustrated-message-description-z-index", "--mod-illustrated-message-display", - "--mod-illustrated-message-heading-to-body", - "--mod-illustrated-message-heading-to-description", "--mod-illustrated-message-illustration-color", - "--mod-illustrated-message-title-color", - "--mod-illustrated-message-title-font-family", - "--mod-illustrated-message-title-font-size", - "--mod-illustrated-message-title-font-style", - "--mod-illustrated-message-title-font-weight", - "--mod-illustrated-message-title-line-height", - "--mod-illustrated-message-title-to-heading" + "--mod-illustrated-message-vertical-maximum-width" ], "high-contrast": [ + "--highcontrast-drop-zone-border-color", "--highcontrast-drop-zone-border-color-hover", - "--highcontrast-drop-zone-illustration-color", - "--highcontrast-illustrated-message-illustration-color" + "--highcontrast-drop-zone-button-color" ] } diff --git a/components/dropzone/index.css b/components/dropzone/index.css index 28fa4491bb3..b495fc596e1 100644 --- a/components/dropzone/index.css +++ b/components/dropzone/index.css @@ -11,127 +11,188 @@ * governing permissions and limitations under the License. */ -@import "./themes/spectrum-two.css"; - .spectrum-DropZone { + /* Sizing */ + --spectrum-drop-zone-padding: var(--spectrum-spacing-400); --spectrum-drop-zone-border-width: var(--spectrum-border-width-200); + --spectrum-drop-zone-corner-radius: var(--spectrum-corner-radius-700); + --spectrum-drop-zone-border-color: var(--spectrum-gray-300); + --spectrum-drop-zone-inline-size: var(--spectrum-drop-zone-width); + + /* Color */ --spectrum-drop-zone-background-color: var(--spectrum-drop-zone-background-color-rgb); --spectrum-drop-zone-border-color-hover: var(--spectrum-accent-visual-color); - --spectrum-drop-zone-illustration-color: var(--spectrum-neutral-visual-color); + --spectrum-drop-zone-illustration-color-hover: var(--spectrum-accent-content-color-default); + --spectrum-drop-zone-body-to-action: var(--spectrum-spacing-300); + --spectrum-drop-zone-stroke-dash-gap: var(--spectrum-drop-zone-border-dash-gap); + --spectrum-drop-zone-stroke-dash-length: var(--spectrum-drop-zone-border-dash-length); + --spectrum-drop-zone-dragged-background-color: var(--spectrum-drop-zone-background-color-opacity); + + /* Filled styles */ + --spectrum-drop-zone-content-max-width: var(--spectrum-drop-zone-content-maximum-width); + --spectrum-drop-zone-content-top-to-text: var(--spectrum-component-top-to-text-300); + --spectrum-drop-zone-content-bottom-to-text: var(--spectrum-component-bottom-to-text-300); + --spectrum-drop-zone-component-height: var(--spectrum-component-height-300); + --spectrum-drop-zone-edge-to-text: var(--spectrum-component-edge-to-text-300); + + --spectrum-drop-zone-content-font-family: var(--spectrum-sans-font-family-stack); + --spectrum-drop-zone-content-font-weight: var(--spectrum-bold-font-weight); + --spectrum-drop-zone-content-font-size: var(--spectrum-font-size-300); + --spectrum-drop-zone-title-line-height: var(--spectrum-line-height-100); + --spectrum-drop-zone-content-background-color: var(--spectrum-accent-visual-color); - /* @passthrough start -- IllustratedMessage -- settings for a nested illustrated message */ - --mod-illustrated-message-content-maximum-width: var(--mod-drop-zone-content-maximum-width, var(--spectrum-drop-zone-content-maximum-width)); - --mod-illustrated-message-illustration-color: var(--mod-drop-zone-illustration-color, var(--spectrum-drop-zone-illustration-color)); - --mod-illustrated-message-title-to-heading: var(--mod-drop-zone-illustration-to-heading, var(--spectrum-spacing-400)); - --mod-illustrated-message-heading-to-body: var(--mod-drop-zone-heading-to-body, var(--spectrum-spacing-75)); - --mod-illustrated-message-title-font-family: var(--mod-drop-zone-heading-font-family, var(--spectrum-sans-font-family-stack)); - --mod-illustrated-message-title-font-weight: var(--mod-drop-zone-heading-font-weight, var(--spectrum-heading-sans-serif-font-weight)); - --mod-illustrated-message-title-font-style: var(--mod-drop-zone-heading-font-style, var(--spectrum-heading-sans-serif-font-style)); - --mod-illustrated-message-title-font-size: var(--mod-drop-zone-heading-font-size, var(--spectrum-drop-zone-title-size)); - --mod-illustrated-message-title-line-height: var(--mod-drop-zone-heading-line-height, var(--spectrum-heading-line-height)); - --mod-illustrated-message-title-color: var(--mod-drop-zone-heading-color, var(--spectrum-heading-color)); + /* Settings for a nested illustrated message */ + --mod-illustrated-message-vertical-maximum-width: var(--mod-drop-zone-content-maximum-width, var(--spectrum-drop-zone-content-maximum-width)); + --mod-illustrated-message-description-to-action: var(--mod-drop-zone-body-to-action, var(--spectrum-drop-zone-body-to-action)); --mod-illustrated-message-description-position: relative; --mod-illustrated-message-description-z-index: 10; - --mod-illustrated-message-heading-to-description: 0; - --mod-illustrated-message-description-font-family: var(--mod-drop-zone-body-font-family, var(--spectrum-sans-font-family-stack)); - --mod-illustrated-message-description-font-weight: var(--mod-drop-zone-body-font-weight, var(--spectrum-body-sans-serif-font-weight)); - --mod-illustrated-message-description-font-style: var(--mod-drop-zone-body-font-style, var(--spectrum-body-sans-serif-font-style)); - --mod-illustrated-message-description-font-size: var(--mod-drop-zone-body-font-size, var(--spectrum-drop-zone-body-size)); - --mod-illustrated-message-description-line-height: var(--mod-drop-zone-body-line-height, var(--spectrum-body-line-height)); - --mod-illustrated-message-description-color: var(--mod-drop-zone-body-color, var(--spectrum-body-color)); - /* @passthrough end */ - - /* @passthrough start -- ActionButton settings for a nested actionbutton */ - --mod-actionbutton-font-size: var(--mod-drop-zone-content-font-size, var(--spectrum-font-size-300)); - --mod-actionbutton-label-color: var(--mod-drop-zone-content-color, var(--spectrum-white)); - --mod-actionbutton-edge-to-text: var(--mod-drop-zone-content-edge-to-text, var(--spectrum-component-edge-to-text-300)); - /* @passthrough end */ + --mod-illustrated-message-description-font-size: var(--mod-drop-zone-body-font-size, var(--spectrum-drop-zone-body-font-size)); + + /* Adjusts height of filled & dragged dropzone state */ + --mod-drop-zone-content-height: 280px; +} +.spectrum-DropZone { + display: flex; + justify-content: center; + align-items: center; box-sizing: border-box; - inline-size: var(--mod-drop-zone-width, var(--spectrum-drop-zone-width)); - padding: calc(var(--mod-drop-zone-padding, var(--spectrum-spacing-400)) - var(--mod-drop-zone-border-width, var(--spectrum-drop-zone-border-width))); - text-align: center; - border-color: var(--mod-drop-zone-border-color, var(--spectrum-drop-zone-border-color)); - border-width: var(--mod-drop-zone-border-width, var(--spectrum-drop-zone-border-width)); - border-radius: var(--mod-drop-zone-corner-radius, var(--spectrum-corner-radius-100)); - border-style: var(--mod-drop-zone-border-style, dashed); - background-color: var(--mod-drop-zone-background-color, var(--spectrum-drop-zone-background-color)); + inline-size: var(--mod-drop-zone-inline-size, var(--spectrum-drop-zone-inline-size)); + padding: calc(var(--mod-drop-zone-padding, var(--spectrum-drop-zone-padding)) - var(--mod-drop-zone-border-width, var(--spectrum-drop-zone-border-width))); + border-radius: var(--mod-drop-zone-corner-radius, var(--spectrum-drop-zone-corner-radius)); background-size: cover; - - &:lang(ja), - &:lang(zh), - &:lang(ko) { - /* @passthrough -- updated value for cjk font size */ - --mod-illustrated-message-title-font-size: var(--spectrum-drop-zone-cjk-title-size); - } + background-color: var(--mod-drop-zone-background-color, var(--spectrum-drop-zone-background-color)); + position: relative; + border: var(--mod-drop-zone-border-width, var(--spectrum-drop-zone-border-width)) dashed var(--highcontrast-drop-zone-border-color, var(--mod-drop-zone-border-color, var(--spectrum-drop-zone-border-color))); &.is-dragged { --mod-drop-zone-border-style: var(--mod-drop-zone-border-style-dragged, solid); - --mod-drop-zone-background-color: rgb(var(--spectrum-drop-zone-background-color), var(--mod-drop-zone-background-color-opacity, var(--spectrum-drop-zone-background-color-opacity))); - --mod-drop-zone-border-color: var(--highcontrast-drop-zone-border-color-hover, var(--mod-drop-zone-border-color-hover, var(--spectrum-drop-zone-border-color-hover))); + --mod-drop-zone-background-color: rgb(var(--spectrum-drop-zone-background-color), var(--mod-drop-zone-background-color-opacity, var(--spectrum-drop-zone-dragged-background-color))); + --spectrum-drop-zone-border-color: var(--highcontrast-drop-zone-border-color-hover, var(--mod-drop-zone-border-color-hover, var(--spectrum-drop-zone-border-color-hover))); + + /* Updated values for a nested illustrated message when state changes */ + --mod-illustrated-message-illustration-color: var(--mod-drop-zone-illustration-color-hover, var(--spectrum-drop-zone-illustration-color-hover)); + color: var(--spectrum-drop-zone-illustration-color-hover); + border-style: solid; - /* @passthrough -- Updated values for a nested illustrated message when state changes */ - --mod-illustrated-message-illustration-color: var(--mod-drop-zone-illustration-color-hover, var(--spectrum-accent-visual-color)); + .spectrum-DropZone-strokePath { + stroke-dasharray: none; + } } &.is-filled { /* note: the below applies to .is-filled.is-dragged but works here b/c dragged is the only state applying background color */ --mod-drop-zone-background-color: rgb(var(--spectrum-drop-zone-background-color), var(--mod-drop-zone-background-color-opacity-filled, var(--spectrum-drop-zone-background-color-opacity-filled))); - /* @passthrough -- Updated values for a nested illustrated message when state changes */ + /* Updated values for a nested illustrated message when state changes */ --mod-illustrated-message-display: none; } &.is-filled.is-dragged { - --mod-drop-zone-content-display: flex; + background-position: center; + block-size: var(--mod-drop-zone-content-height); + background-blend-mode: multiply; + + .spectrum-DropZone-content { + block-size: 100%; + display: flex; + align-items: center; + justify-content: center; + } + + .spectrum-DropZone-actions { + margin-block-start: 0; + } } &:focus-visible { - --mod-drop-zone-border-style: solid; - --mod-drop-zone-border-color: var(--highcontrast-drop-zone-border-color-hover, var(--mod-drop-zone-border-color-hover, var(--spectrum-drop-zone-border-color-hover))); - + --spectrum-drop-zone-border-color: var(--highcontrast-drop-zone-border-color-hover, var(--mod-drop-zone-border-color-hover, var(--spectrum-drop-zone-border-color-hover))); outline: 0; } } -.spectrum-DropZone-content { - display: var(--mod-drop-zone-content-display, none); +.spectrum-DropZone:has(.spectrum-DropZone-stroke) { + border: none; +} + +.spectrum-DropZone-stroke { + position: absolute; + inset-block-start: 0; + inset-inline-start: 0; + inline-size: 100%; block-size: 100%; - align-items: center; - justify-content: center; - position: relative; - z-index: 10; + pointer-events: none; +} + +.spectrum-DropZone-strokePath { + stroke: var(--highcontrast-drop-zone-border-color, var(--mod-drop-zone-border-color, var(--spectrum-drop-zone-border-color))); + stroke-dasharray: var(--mod-drop-zone-border-dash-length, var(--spectrum-drop-zone-stroke-dash-length)) var(--mod-drop-zone-border-dash-gap, var(--spectrum-drop-zone-stroke-dash-gap)); + rx: var(--spectrum-drop-zone-corner-radius); + ry: var(--spectrum-drop-zone-corner-radius); + stroke-width: var(--mod-drop-zone-border-width, var(--spectrum-drop-zone-border-width)); + inline-size: calc(100% - var(--mod-drop-zone-border-width, var(--spectrum-drop-zone-border-width))); + block-size: calc(100% - var(--mod-drop-zone-border-width, var(--spectrum-drop-zone-border-width))); +} + +.spectrum-DropZone-content { + max-inline-size: var(--mod-illustrated-message-vertical-maximum-width); +} + +.spectrum-DropZone-actions { + margin-block-start: var(--spectrum-drop-zone-body-to-action); + text-align: center; } .spectrum-DropZone-button { + /* Adjust corner radius of button component is dragged & filled state */ + --mod-button-border-radius: var(--spectrum-corner-radius-500); box-sizing: border-box; border: none; - block-size: var(--mod-drop-zone-content-height, var(--spectrum-component-height-300)); - max-inline-size: var(--mod-drop-zone-content-max-width, var(--spectrum-drop-zone-content-maximum-width)); - padding-block-start: var(--mod-drop-zone-content-top-to-text, var(--spectrum-component-top-to-text-300)); - padding-block-end: var(--mod-drop-zone-content-bottom-to-text, var(--spectrum-component-bottom-to-text-300)); - background-color: var(--mod-drop-zone-content-background-color, var(--spectrum-drop-zone-content-background-color)); - - font-family: var(--mod-drop-zone-content-font-family, var(--spectrum-sans-font-family-stack)); - font-weight: var(--mod-drop-zone-content-font-weight, var(--spectrum-bold-font-weight)); - font-style: var(--mod-drop-zone-content-font-style, var(--spectrum-default-font-style)); - line-height: var(--mod-drop-zone-content-line-height, var(--spectrum-line-height-100)); + block-size: auto; + + max-inline-size: var(--mod-drop-zone-content-max-width, var(--spectrum-drop-zone-content-max-width)); + padding-block-start: var(--mod-drop-zone-content-top-to-text, var(--spectrum-drop-zone-content-top-to-text)); + padding-block-end: var(--mod-drop-zone-content-bottom-to-text, var(--spectrum-drop-zone-content-bottom-to-text)); + padding-inline: var(--mod-drop-zone-edge-to-text, var(--spectrum-drop-zone-edge-to-text)); + background-color: var(--highcontrast-drop-zone-button-color, var(--mod-drop-zone-content-background-color, var(--spectrum-drop-zone-content-background-color))); + max-block-size: var(--spectrum-drop-zone-component-height); + + font-family: var(--mod-drop-zone-content-font-family, var(--spectrum-drop-zone-content-font-family)); + font-weight: var(--mod-drop-zone-content-font-weight, var(--spectrum-drop-zone-content-font-weight)); + line-height: var(--mod-drop-zone-title-line-height, var(--spectrum-drop-zone-title-line-height)); + + .spectrum-Button-label { + font-size: var(--mod-drop-zone-content-font-size, var(--spectrum-drop-zone-content-font-size)); + padding: unset; + } &:hover, &:focus { - background-color: var(--mod-drop-zone-content-background-color, var(--spectrum-drop-zone-content-background-color)); + background-color: var(--highcontrast-drop-zone-button-color, var(--mod-drop-zone-content-background-color, var(--spectrum-drop-zone-content-background-color))); + } +} + +/********* Illustrated Message *********/ +.spectrum-DropZone { + .spectrum-IllustratedMessage { + justify-content: center; } } /********* WHCM *********/ @media (forced-colors: active) { .spectrum-DropZone { - --highcontrast-drop-zone-illustration-color: CanvasText; - --highcontrast-drop-zone-border-color-hover: Highlight; + --highcontrast-drop-zone-button-color: ButtonText; + --highcontrast-drop-zone-border-color: ButtonText; + + &.is-dragged { + border-color: var(--highcontrast-drop-zone-border-color-hover); - /* @passthrough -- updated values for a nested illustrated message when in a high contrast state */ - --highcontrast-illustrated-message-illustration-color: var(--highcontrast-drop-zone-illustration-color); + .spectrum-DropZone-strokePath { + stroke: var(--highcontrast-drop-zone-border-color-hover); + } + } } } diff --git a/components/dropzone/package.json b/components/dropzone/package.json index d2347705618..942565b2446 100644 --- a/components/dropzone/package.json +++ b/components/dropzone/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/dropzone", - "version": "8.2.0", + "version": "9.0.0-next.4", "description": "The Spectrum CSS dropzone component", "license": "Apache-2.0", "author": "Adobe", @@ -19,17 +19,15 @@ "./package.json": "./package.json", "./dist/*": "./dist/*", "./index.css": "./dist/index.css", - "./index-*.css": "./dist/index-*.css", "./metadata.json": "./dist/metadata.json", - "./themes/*": "./dist/themes/*", "./stories/*": "./stories/*" }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/actionbutton": ">=7.0.0 <8.0.0", - "@spectrum-css/illustratedmessage": ">=9.0.0 <10.0.0", - "@spectrum-css/link": ">=7.0.0 <8.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/actionbutton": ">=8.0.0-next.0", + "@spectrum-css/illustratedmessage": ">=10.0.0-next.0", + "@spectrum-css/link": ">=8.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/actionbutton": { @@ -46,10 +44,10 @@ } }, "devDependencies": { - "@spectrum-css/actionbutton": "7.2.0", - "@spectrum-css/illustratedmessage": "9.2.0", - "@spectrum-css/link": "7.2.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/actionbutton": "8.0.0-next.4", + "@spectrum-css/illustratedmessage": "10.0.0-next.0", + "@spectrum-css/link": "8.0.0-next.2", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/dropzone/stories/dropzone.stories.js b/components/dropzone/stories/dropzone.stories.js index 9d0d7e4c3d2..97e6bf7bd65 100644 --- a/components/dropzone/stories/dropzone.stories.js +++ b/components/dropzone/stories/dropzone.stories.js @@ -1,12 +1,12 @@ import { default as ActionButton } from "@spectrum-css/actionbutton/stories/actionbutton.stories.js"; import { default as IllustratedMessage } from "@spectrum-css/illustratedmessage/stories/illustratedmessage.stories.js"; -import { Template as Link } from "@spectrum-css/link/stories/template.js"; +import { Sizes } from "@spectrum-css/preview/decorators"; import { disableDefaultModes } from "@spectrum-css/preview/modes"; import { isDragged } from "@spectrum-css/preview/types"; -import { html } from "lit"; import metadata from "../dist/metadata.json"; import packageJson from "../package.json"; import { DropzoneGroup } from "./dropzone.test.js"; +import { Template } from "./template.js"; /** * A drop zone is an area on the screen into a which an object can be dragged and dropped to accomplish a task. It's a common interaction in uploading and file management workflows. For example, a drop zone might be used in an upload workflow to enable the user to simply drop a file from their operating system into the drop zone, which is a more efficient and intuitive action, rather than utilizing the standard "Choose file" dialog. @@ -27,12 +27,17 @@ export default { if: { arg: "isDragged", truthy: true }, }, ...IllustratedMessage.argTypes, + hasButtons: { table: { disable: true }}, + isHorizontal: { table: { disable: true }}, label: ActionButton.argTypes.label, }, args: { rootClass: "spectrum-DropZone", isDragged: false, isFilled: false, + title: "Drag and drop your file", + description: "Or, select a file from your computer.", + label: "Browse files", }, parameters: { design: { @@ -41,22 +46,36 @@ export default { }, packageJson, metadata, + status: { + type: "migrated", + }, }, + tags: ["migrated"], }; export const Default = DropzoneGroup.bind({}); -Default.args = { - heading: "Drag and drop your file", - description: [ - () => { - return html`${Link({ url: "#", text: "Select a file" })} from your computer.`; - }, - ], - label: "Drop file to replace", - useAccentColor: true, - customStyles: { - width: "300px", - }, +Default.args = {}; + +export const Dragged = Template.bind({}); +Dragged.args = { + isDragged: true, +}; +Dragged.tags = ["!dev"]; +Dragged.parameters = { + chromatic: { disableSnapshot: true }, +}; + +/** + * The filled state of a drop zone is used to indicate that a file has been dropped into the drop zone. Since the type size doesn't change in this state, the dropzone size would be identical in all size variants. +*/ +export const Filled = Template.bind({}); +Filled.args = { + isDragged: true, + isFilled: true, +}; +Filled.tags = ["!dev"]; +Filled.parameters = { + chromatic: { disableSnapshot: true }, }; // ********* VRT ONLY ********* // @@ -69,3 +88,15 @@ WithForcedColors.parameters = { modes: disableDefaultModes }, }; + +export const Sizing = (args, context) => Sizes({ + Template, + withBorder: false, + withHeader: false, + ...args +}, context); +Sizing.args = {}; +Sizing.tags = ["!dev"]; +Sizing.parameters = { + chromatic: { disableSnapshot: true }, +}; diff --git a/components/dropzone/stories/dropzone.test.js b/components/dropzone/stories/dropzone.test.js index 52303b56d69..258da1cd653 100644 --- a/components/dropzone/stories/dropzone.test.js +++ b/components/dropzone/stories/dropzone.test.js @@ -1,22 +1,10 @@ -import { Template as Link } from "@spectrum-css/link/stories/template.js"; import { Variants } from "@spectrum-css/preview/decorators"; -import { html } from "lit"; import { Template } from "./template.js"; export const DropzoneGroup = Variants({ Template, testData: [ {}, - { - testHeading: "Verbose example", - heading: "Drag and drop your file to upload", - description: [ - () => { - return html`You can also ${Link({ url: "#", text: "select a file" })} from your computer.`; - }, - ], - label: "Drag and drop to replace file upload", - }, ], stateData: [ { @@ -29,5 +17,4 @@ export const DropzoneGroup = Variants({ isDragged: true, }, ], - withSizes: false, }); diff --git a/components/dropzone/stories/template.js b/components/dropzone/stories/template.js index 9eb2dfface7..77e260501c2 100644 --- a/components/dropzone/stories/template.js +++ b/components/dropzone/stories/template.js @@ -1,4 +1,4 @@ -import { Template as ActionButton } from "@spectrum-css/actionbutton/stories/template.js"; +import { Template as Button } from "@spectrum-css/button/stories/template.js"; import { Template as IllustratedMessage } from "@spectrum-css/illustratedmessage/stories/template.js"; import { getRandomId } from "@spectrum-css/preview/decorators"; import { html } from "lit"; @@ -7,9 +7,6 @@ import { ifDefined } from "lit/directives/if-defined.js"; import { styleMap } from "lit/directives/style-map.js"; import "../index.css"; -import "../themes/spectrum.css"; -/* Must be imported last */ -import "../themes/express.css"; export const Template = ({ rootClass = "spectrum-DropZone", @@ -17,35 +14,70 @@ export const Template = ({ isFilled = false, customClasses = [], customStyles = {}, - heading, + title, description, label, id = getRandomId("dropzone"), + size = "m", + image = "dropzone-illustration.png", } = {}, context = {}) => { return html` -
    ({ ...a, [c]: true }), {}), - })} - id=${ifDefined(id)} - role="region" - tabindex="0" - style=${styleMap(customStyles)} - > - ${IllustratedMessage({ heading, description }, context)} - -
    - ${ActionButton( - { - label, - customClasses: [`${rootClass}-button`], - }, - context - )} + })} + id=${ifDefined(id)} + role="region" + tabindex="0" + style=${styleMap(customStyles), [isDragged && isFilled ? `background-image:url(${image});` : null].filter(Boolean).join(" ")} + > + + + +
    + ${IllustratedMessage({ + title: title, + description: description, + customIllustration: customSvg, + size: size + }, context )} +
    + ${isDragged && isFilled + ? Button({ + label: label, + customClasses: [`${rootClass}-button`], + variant: "accent", + }) + : Button({ + label: label, + size: size + })}
    - `; +
    `; }; + +const customSvg = () => html` + + + +`; diff --git a/components/dropzone/themes/express.css b/components/dropzone/themes/express.css deleted file mode 100644 index 9fd550418f2..00000000000 --- a/components/dropzone/themes/express.css +++ /dev/null @@ -1,16 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--express */ - -@import "./spectrum.css"; diff --git a/components/dropzone/themes/spectrum-two.css b/components/dropzone/themes/spectrum-two.css deleted file mode 100644 index cf71b766c33..00000000000 --- a/components/dropzone/themes/spectrum-two.css +++ /dev/null @@ -1,18 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -@container style(--system: spectrum) { - .spectrum-DropZone { - --spectrum-drop-zone-border-color: var(--spectrum-gray-200); - } -} diff --git a/components/dropzone/themes/spectrum.css b/components/dropzone/themes/spectrum.css deleted file mode 100644 index 0760508568f..00000000000 --- a/components/dropzone/themes/spectrum.css +++ /dev/null @@ -1,22 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--legacy */ - -@import "./spectrum-two.css"; - -@container style(--system: legacy) { - .spectrum-DropZone { - --spectrum-drop-zone-border-color: var(--spectrum-gray-300); - } -} diff --git a/components/fieldgroup/CHANGELOG.md b/components/fieldgroup/CHANGELOG.md index d3037774f6b..54edcc0147b 100644 --- a/components/fieldgroup/CHANGELOG.md +++ b/components/fieldgroup/CHANGELOG.md @@ -1,5 +1,21 @@ # Change log +## 8.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + +## 8.0.0-next.0 + +### Patch Changes + +- Updated dependencies []: + - @spectrum-css/checkbox@11.0.0-next.0 + - @spectrum-css/helptext@8.0.0-next.0 + - @spectrum-css/radio@11.0.0-next.0 + ## 7.2.0 ### Minor Changes diff --git a/components/fieldgroup/dist/metadata.json b/components/fieldgroup/dist/metadata.json index c8875b9d3a9..3c2343b1019 100644 --- a/components/fieldgroup/dist/metadata.json +++ b/components/fieldgroup/dist/metadata.json @@ -13,7 +13,6 @@ "modifiers": [], "component": [], "global": ["--spectrum-spacing-300"], - "system-theme": [], "passthroughs": [], "high-contrast": [] } diff --git a/components/fieldgroup/package.json b/components/fieldgroup/package.json index 4627cfd97e8..2aab6c035df 100644 --- a/components/fieldgroup/package.json +++ b/components/fieldgroup/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/fieldgroup", - "version": "7.2.0", + "version": "8.0.0-next.1", "description": "The Spectrum CSS fieldgroup component", "license": "Apache-2.0", "author": "Adobe", @@ -24,10 +24,10 @@ }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/checkbox": ">=10.0.0 <11.0.0", - "@spectrum-css/helptext": ">=7.0.0 <8.0.0", - "@spectrum-css/radio": ">=10.0.0 <11.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/checkbox": ">=11.0.0-next.0", + "@spectrum-css/helptext": ">=8.0.0-next.0", + "@spectrum-css/radio": ">=11.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/checkbox": { @@ -44,10 +44,10 @@ } }, "devDependencies": { - "@spectrum-css/checkbox": "10.2.0", - "@spectrum-css/helptext": "7.2.0", - "@spectrum-css/radio": "10.2.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/checkbox": "11.0.0-next.2", + "@spectrum-css/helptext": "8.0.0-next.2", + "@spectrum-css/radio": "11.0.0-next.3", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/fieldgroup/stories/fieldgroup.stories.js b/components/fieldgroup/stories/fieldgroup.stories.js index 18c06b181f5..c49e4990598 100644 --- a/components/fieldgroup/stories/fieldgroup.stories.js +++ b/components/fieldgroup/stories/fieldgroup.stories.js @@ -96,7 +96,11 @@ export default { }, packageJson, metadata, + status: { + type: "migrated", + }, }, + tags: ["migrated"], }; export const Default = FieldGroupSet.bind({}); diff --git a/components/fieldlabel/CHANGELOG.md b/components/fieldlabel/CHANGELOG.md index bde03f1643e..87770222686 100644 --- a/components/fieldlabel/CHANGELOG.md +++ b/components/fieldlabel/CHANGELOG.md @@ -1,5 +1,29 @@ # Change log +## 11.0.0-next.2 + +### Patch Changes + +📝 [#3652](https://github.com/adobe/spectrum-css/pull/3652) [`8b4511e`](https://github.com/adobe/spectrum-css/commit/8b4511eb14a8dc586c34719db2efd6f5c542e7b1) Thanks [@cdransf](https://github.com/cdransf)! + +#### Fix field label required icon wrapping + +Addresses case where fieldlabel required icon could appear on its own line when wrapping by applying text-wrap: pretty; to the parent label class and adding a non-breaking space character between the label content and required marker. + +## 11.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + +## 11.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`a25e0a9`](https://github.com/adobe/spectrum-css/commit/a25e0a99e5a4736ab4e607e00739343101a2633b)]: + - @spectrum-css/icon@10.0.0-next.0 + ## 10.2.0 ### Minor Changes diff --git a/components/fieldlabel/dist/metadata.json b/components/fieldlabel/dist/metadata.json index cc26c19a022..2a55dbd82f4 100644 --- a/components/fieldlabel/dist/metadata.json +++ b/components/fieldlabel/dist/metadata.json @@ -5,9 +5,10 @@ ".spectrum-FieldLabel--left", ".spectrum-FieldLabel--right", ".spectrum-FieldLabel--sizeL", - ".spectrum-FieldLabel--sizeM", ".spectrum-FieldLabel--sizeS", ".spectrum-FieldLabel--sizeXL", + ".spectrum-FieldLabel--staticBlack", + ".spectrum-FieldLabel--staticWhite", ".spectrum-FieldLabel-requiredIcon", ".spectrum-FieldLabel.is-disabled", ".spectrum-FieldLabel:lang(ja)", @@ -15,35 +16,20 @@ ".spectrum-FieldLabel:lang(zh)" ], "modifiers": [ - "--mod-disabled-content-color", - "--mod-field-label-asterisk-vertical-align", - "--mod-field-label-bottom-to-text", - "--mod-field-label-text-to-asterisk", - "--mod-field-label-top-to-text", - "--mod-fieldlabel-color", + "--mod-fieldlabel-asterisk-vertical-align", + "--mod-fieldlabel-bottom-to-text", "--mod-fieldlabel-font-size", "--mod-fieldlabel-font-weight", "--mod-fieldlabel-line-height", "--mod-fieldlabel-line-height-cjk", - "--mod-fieldlabel-margin-block", - "--mod-fieldlabel-margin-block-end", - "--mod-fieldlabel-margin-block-start", - "--mod-fieldlabel-margin-inline", - "--mod-fieldlabel-margin-inline-end", - "--mod-fieldlabel-margin-inline-start", "--mod-fieldlabel-min-height", - "--mod-fieldlabel-padding-block", "--mod-fieldlabel-padding-inline", "--mod-fieldlabel-side-margin-block-start", - "--mod-fieldlabel-side-padding-right" + "--mod-fieldlabel-side-padding-right", + "--mod-fieldlabel-text-to-asterisk", + "--mod-fieldlabel-top-to-text" ], "component": [ - "--spectrum-field-label-bottom-to-text", - "--spectrum-field-label-font-size", - "--spectrum-field-label-min-height", - "--spectrum-field-label-side-margin-block-start", - "--spectrum-field-label-side-padding-right", - "--spectrum-field-label-text-to-asterisk", "--spectrum-field-label-text-to-asterisk-extra-large", "--spectrum-field-label-text-to-asterisk-large", "--spectrum-field-label-text-to-asterisk-medium", @@ -52,30 +38,44 @@ "--spectrum-field-label-top-margin-large", "--spectrum-field-label-top-margin-medium", "--spectrum-field-label-top-margin-small", - "--spectrum-field-label-top-to-text" + "--spectrum-fieldlabel-bottom-to-text", + "--spectrum-fieldlabel-color", + "--spectrum-fieldlabel-font-size", + "--spectrum-fieldlabel-font-weight", + "--spectrum-fieldlabel-line-height", + "--spectrum-fieldlabel-min-height", + "--spectrum-fieldlabel-side-margin-block-start", + "--spectrum-fieldlabel-side-padding-right", + "--spectrum-fieldlabel-text-to-asterisk", + "--spectrum-fieldlabel-top-to-text" ], "global": [ + "--spectrum-black", "--spectrum-cjk-line-height-100", "--spectrum-component-bottom-to-text-100", "--spectrum-component-bottom-to-text-200", + "--spectrum-component-bottom-to-text-300", "--spectrum-component-bottom-to-text-75", "--spectrum-component-height-100", "--spectrum-component-height-200", + "--spectrum-component-height-300", "--spectrum-component-height-75", "--spectrum-component-top-to-text-100", "--spectrum-component-top-to-text-200", + "--spectrum-component-top-to-text-300", "--spectrum-component-top-to-text-75", "--spectrum-disabled-content-color", "--spectrum-font-size-100", "--spectrum-font-size-200", + "--spectrum-font-size-300", "--spectrum-font-size-75", "--spectrum-line-height-100", "--spectrum-neutral-subdued-content-color-default", "--spectrum-regular-font-weight", "--spectrum-spacing-100", - "--spectrum-spacing-200" + "--spectrum-spacing-200", + "--spectrum-white" ], - "system-theme": [], "passthroughs": [], - "high-contrast": ["--highcontrast-field-label-content-color"] + "high-contrast": ["--highcontrast-fieldlabel-disabled-content-color"] } diff --git a/components/fieldlabel/index.css b/components/fieldlabel/index.css index 4e5b4653efd..ba6692619ff 100644 --- a/components/fieldlabel/index.css +++ b/components/fieldlabel/index.css @@ -1,5 +1,5 @@ /*! - * Copyright 2024 Adobe. All rights reserved. + * Copyright 2025 Adobe. All rights reserved. * * This file is licensed to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. You may obtain a copy @@ -11,104 +11,112 @@ * governing permissions and limitations under the License. */ -/* @todo align modifiers to use field-label or fieldlabel but not both */ +.spectrum-FieldLabel { + --spectrum-fieldlabel-min-height: var(--spectrum-component-height-100); + --spectrum-fieldlabel-color: var(--spectrum-neutral-subdued-content-color-default); + + --spectrum-fieldlabel-top-to-text: var(--spectrum-component-top-to-text-100); + --spectrum-fieldlabel-bottom-to-text: var(--spectrum-component-bottom-to-text-100); + --spectrum-fieldlabel-text-to-asterisk: var(--spectrum-field-label-text-to-asterisk-medium); -.spectrum-FieldLabel, -.spectrum-FieldLabel--sizeM { - --spectrum-field-label-min-height: var(--spectrum-component-height-75); - --spectrum-field-label-top-to-text: var(--spectrum-component-top-to-text-75); - --spectrum-field-label-bottom-to-text: var(--spectrum-component-bottom-to-text-75); - --spectrum-field-label-font-size: var(--spectrum-font-size-75); + --spectrum-fieldlabel-font-size: var(--spectrum-font-size-100); + --spectrum-fieldlabel-font-weight: var(--spectrum-regular-font-weight); + --spectrum-fieldlabel-line-height: var(--spectrum-line-height-100); - --spectrum-field-label-side-margin-block-start: var(--spectrum-field-label-top-margin-medium); - --spectrum-field-label-side-padding-right: var(--spectrum-spacing-200); + --spectrum-fieldlabel-side-margin-block-start: var(--spectrum-field-label-top-margin-medium); + --spectrum-fieldlabel-side-padding-right: var(--spectrum-spacing-200); + + /* CJK (Chinese, Japanese, and Korean) language support */ + &:lang(ja), + &:lang(zh), + &:lang(ko) { + --mod-fieldlabel-line-height: var(--mod-fieldlabel-line-height-cjk, var(--spectrum-cjk-line-height-100)); + } - --spectrum-field-label-text-to-asterisk: var(--spectrum-field-label-text-to-asterisk-medium); + /********* Disabled state *********/ + &.is-disabled { + --spectrum-fieldlabel-color: var(--highcontrast-fieldlabel-disabled-content-color, var(--spectrum-disabled-content-color)); + } } .spectrum-FieldLabel--sizeS { - --spectrum-field-label-min-height: var(--spectrum-component-height-75); - --spectrum-field-label-top-to-text: var(--spectrum-component-top-to-text-75); - --spectrum-field-label-bottom-to-text: var(--spectrum-component-bottom-to-text-75); - --spectrum-field-label-font-size: var(--spectrum-font-size-75); + --spectrum-fieldlabel-min-height: var(--spectrum-component-height-75); + --spectrum-fieldlabel-top-to-text: var(--spectrum-component-top-to-text-75); + --spectrum-fieldlabel-bottom-to-text: var(--spectrum-component-bottom-to-text-75); + --spectrum-fieldlabel-text-to-asterisk: var(--spectrum-field-label-text-to-asterisk-small); - --spectrum-field-label-side-margin-block-start: var(--spectrum-field-label-top-margin-small); - --spectrum-field-label-side-padding-right: var(--spectrum-spacing-100); + --spectrum-fieldlabel-font-size: var(--spectrum-font-size-75); - --spectrum-field-label-text-to-asterisk: var(--spectrum-field-label-text-to-asterisk-small); + --spectrum-fieldlabel-side-margin-block-start: var(--spectrum-field-label-top-margin-small); + --spectrum-fieldlabel-side-padding-right: var(--spectrum-spacing-100); } .spectrum-FieldLabel--sizeL { - --spectrum-field-label-min-height: var(--spectrum-component-height-100); - --spectrum-field-label-top-to-text: var(--spectrum-component-top-to-text-100); - --spectrum-field-label-bottom-to-text: var(--spectrum-component-bottom-to-text-100); - --spectrum-field-label-font-size: var(--spectrum-font-size-100); + --spectrum-fieldlabel-min-height: var(--spectrum-component-height-200); + --spectrum-fieldlabel-top-to-text: var(--spectrum-component-top-to-text-200); + --spectrum-fieldlabel-bottom-to-text: var(--spectrum-component-bottom-to-text-200); + --spectrum-fieldlabel-text-to-asterisk: var(--spectrum-field-label-text-to-asterisk-large); - --spectrum-field-label-side-margin-block-start: var(--spectrum-field-label-top-margin-large); - --spectrum-field-label-side-padding-right: var(--spectrum-spacing-200); + --spectrum-fieldlabel-font-size: var(--spectrum-font-size-200); - --spectrum-field-label-text-to-asterisk: var(--spectrum-field-label-text-to-asterisk-large); + --spectrum-fieldlabel-side-margin-block-start: var(--spectrum-field-label-top-margin-large); + --spectrum-fieldlabel-side-padding-right: var(--spectrum-spacing-200); } .spectrum-FieldLabel--sizeXL { - --spectrum-field-label-min-height: var(--spectrum-component-height-200); - --spectrum-field-label-top-to-text: var(--spectrum-component-top-to-text-200); - --spectrum-field-label-bottom-to-text: var(--spectrum-component-bottom-to-text-200); - --spectrum-field-label-font-size: var(--spectrum-font-size-200); + --spectrum-fieldlabel-min-height: var(--spectrum-component-height-300); + --spectrum-fieldlabel-top-to-text: var(--spectrum-component-top-to-text-300); + --spectrum-fieldlabel-bottom-to-text: var(--spectrum-component-bottom-to-text-300); + --spectrum-fieldlabel-text-to-asterisk: var(--spectrum-field-label-text-to-asterisk-extra-large); + + --spectrum-fieldlabel-font-size: var(--spectrum-font-size-300); - --spectrum-field-label-side-margin-block-start: var(--spectrum-field-label-top-margin-extra-large); - --spectrum-field-label-side-padding-right: var(--spectrum-spacing-200); + --spectrum-fieldlabel-side-margin-block-start: var(--spectrum-field-label-top-margin-extra-large); + --spectrum-fieldlabel-side-padding-right: var(--spectrum-spacing-200); +} - --spectrum-field-label-text-to-asterisk: var(--spectrum-field-label-text-to-asterisk-extra-large); +.spectrum-FieldLabel--staticBlack { + --spectrum-fieldlabel-color: var(--spectrum-black); +} + +.spectrum-FieldLabel--staticWhite { + --spectrum-fieldlabel-color: var(--spectrum-white); } .spectrum-FieldLabel { display: block; + text-wrap: pretty; box-sizing: border-box; - min-block-size: var(--mod-fieldlabel-min-height, var(--spectrum-field-label-min-height)); + min-block-size: var(--mod-fieldlabel-min-height, var(--spectrum-fieldlabel-min-height)); - padding-block: var(--mod-fieldlabel-padding-block, var(--mod-field-label-top-to-text, var(--spectrum-field-label-top-to-text)) var(--mod-field-label-bottom-to-text, var(--spectrum-field-label-bottom-to-text))); + padding-block: var(--mod-fieldlabel-top-to-text, var(--spectrum-fieldlabel-top-to-text)) var(--mod-fieldlabel-bottom-to-text, var(--spectrum-fieldlabel-bottom-to-text)); padding-inline: var(--mod-fieldlabel-padding-inline, 0); - margin-block: var(--mod-fieldlabel-margin-block, var(--mod-fieldlabel-margin-block-start, 0) var(--mod-fieldlabel-margin-block-end, 0)); - margin-inline: var(--mod-fieldlabel-margin-inline, var(--mod-fieldlabel-margin-inline-start, 0) var(--mod-fieldlabel-margin-inline-end, 0)); - font-size: var(--mod-fieldlabel-font-size, var(--spectrum-field-label-font-size)); - font-weight: var(--mod-fieldlabel-font-weight, var(--spectrum-regular-font-weight)); + font-size: var(--mod-fieldlabel-font-size, var(--spectrum-fieldlabel-font-size)); + font-weight: var(--mod-fieldlabel-font-weight, var(--spectrum-fieldlabel-font-weight)); - line-height: var(--mod-fieldlabel-line-height, var(--spectrum-line-height-100)); + line-height: var(--mod-fieldlabel-line-height, var(--spectrum-fieldlabel-line-height)); -webkit-font-smoothing: subpixel-antialiased; -moz-osx-font-smoothing: auto; - color: var(--highcontrast-field-label-content-color, var(--mod-fieldlabel-color, var(--spectrum-neutral-subdued-content-color-default))); - - /* CJK (Chinese, Japanese, and Korean) language support */ - &:lang(ja), - &:lang(zh), - &:lang(ko) { - --mod-fieldlabel-line-height: var(--mod-fieldlabel-line-height-cjk, var(--spectrum-cjk-line-height-100)); - } - - /********* Disabled state *********/ - &.is-disabled { - --mod-fieldlabel-color: var(--mod-disabled-content-color, var(--spectrum-disabled-content-color)); - } + color: var(--spectrum-fieldlabel-color); } .spectrum-FieldLabel-requiredIcon { color: inherit; margin-block: 0; - margin-inline: var(--mod-field-label-text-to-asterisk, var(--spectrum-field-label-text-to-asterisk)) 0; - vertical-align: var(--mod-field-label-asterisk-vertical-align, baseline); + margin-inline: var(--mod-fieldlabel-text-to-asterisk, var(--spectrum-fieldlabel-text-to-asterisk)) 0; + vertical-align: var(--mod-fieldlabel-asterisk-vertical-align, baseline); } .spectrum-FieldLabel--left, .spectrum-FieldLabel--right { display: inline-block; - margin-block-start: var(--mod-fieldlabel-side-margin-block-start, var(--spectrum-field-label-side-margin-block-start)); + margin-block-start: var(--mod-fieldlabel-side-margin-block-start, var(--spectrum-fieldlabel-side-margin-block-start)); margin-block-end: 0; - margin-inline-end: var(--mod-fieldlabel-side-padding-right, var(--spectrum-field-label-side-padding-right)); + margin-inline-end: var(--mod-fieldlabel-side-padding-right, var(--spectrum-fieldlabel-side-padding-right)); vertical-align: top; } @@ -119,7 +127,7 @@ /********* WHCM *********/ @media (forced-colors: active) { - .spectrum-FieldLabel.is-disabled { - --highcontrast-field-label-content-color: GrayText; + .spectrum-FieldLabel { + --highcontrast-fieldlabel-disabled-content-color: GrayText; } } diff --git a/components/fieldlabel/package.json b/components/fieldlabel/package.json index 53c4ebc778c..87644b4ef6a 100644 --- a/components/fieldlabel/package.json +++ b/components/fieldlabel/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/fieldlabel", - "version": "10.2.0", + "version": "11.0.0-next.2", "description": "The Spectrum CSS fieldlabel component", "license": "Apache-2.0", "author": "Adobe", @@ -24,8 +24,8 @@ }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/icon": ">=9.0.0 <10.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/icon": ">=10.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/icon": { @@ -36,8 +36,8 @@ } }, "devDependencies": { - "@spectrum-css/icon": "9.2.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/icon": "10.0.0-next.3", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/fieldlabel/stories/fieldlabel.stories.js b/components/fieldlabel/stories/fieldlabel.stories.js index 1a268284d7f..426e0a699c2 100644 --- a/components/fieldlabel/stories/fieldlabel.stories.js +++ b/components/fieldlabel/stories/fieldlabel.stories.js @@ -1,6 +1,6 @@ import { Sizes } from "@spectrum-css/preview/decorators"; import { disableDefaultModes } from "@spectrum-css/preview/modes"; -import { isDisabled, isRequired, size } from "@spectrum-css/preview/types"; +import { isDisabled, isRequired, size, staticColor } from "@spectrum-css/preview/types"; import metadata from "../dist/metadata.json"; import packageJson from "../package.json"; import { FieldLabelGroup } from "./fieldlabel.test.js"; @@ -35,6 +35,7 @@ export default { }, isDisabled, isRequired, + staticColor, }, args: { rootClass: "spectrum-FieldLabel", @@ -51,7 +52,11 @@ export default { }, packageJson, metadata, + status: { + type: "migrated", + }, }, + tags: ["migrated"], }; /** @@ -102,6 +107,8 @@ RightAligned.storyName = "Right-aligned"; * Field labels for required inputs can be marked with an asterisk at the end of the label. Optional inputs would then be understood to not have the asterisk. If using the asterisk icon, do not leave any space between the label text and the start of the `` element in the markup. Extra space should not be added in addition to the inline margin. * * The field label for a required field can display either the text “(required)”, or an asterisk. + * + * When marking a field as required, a word-joiner character (e.g. `U+2060` or `⁠`) should be placed between the label text and the required marker to prevent the marker from appearing on its own line. */ export const Required = Template.bind({}); Required.args = { @@ -136,6 +143,32 @@ Disabled.parameters = { chromatic: { disableSnapshot: true }, }; +/** + * Use static white on dark color or image backgrounds, regardless of color theme. Make sure that the background and the link color meet the minimum color contrast ratio. + */ +export const StaticWhite = Default.bind({}); +StaticWhite.storyName = "Static white"; +StaticWhite.args = { + staticColor: "white", +}; +StaticWhite.tags = ["!dev"]; +StaticWhite.parameters = { + chromatic: { disableSnapshot: true }, +}; + +/** + * Use static black on light color or image backgrounds, regardless of color theme. Make sure that the background and the link color meet the minimum color contrast ratio. + */ +export const StaticBlack = Default.bind({}); +StaticBlack.storyName = "Static black"; +StaticBlack.args = { + staticColor: "black", +}; +StaticBlack.tags = ["!dev"]; +StaticBlack.parameters = { + chromatic: { disableSnapshot: true }, +}; + // ********* VRT ONLY ********* // export const WithForcedColors = FieldLabelGroup.bind({}); WithForcedColors.args = Default.args; diff --git a/components/fieldlabel/stories/template.js b/components/fieldlabel/stories/template.js index 7f5477e4d5f..3420504c4d7 100644 --- a/components/fieldlabel/stories/template.js +++ b/components/fieldlabel/stories/template.js @@ -5,6 +5,7 @@ import { classMap } from "lit/directives/class-map.js"; import { ifDefined } from "lit/directives/if-defined.js"; import { styleMap } from "lit/directives/style-map.js"; import { when } from "lit/directives/when.js"; +import { capitalize, lowerCase } from "lodash-es"; import "../index.css"; @@ -20,6 +21,7 @@ export const Template = ({ alignment, isDisabled, isRequired, + staticColor, } = {}, context = {}) => { if (!label) { console.warn("FieldLabel: please provide a label for the field label."); @@ -49,6 +51,7 @@ export const Template = ({ [`${rootClass}--size${size?.toUpperCase()}`]: typeof size !== "undefined", [`${rootClass}--${alignment}`]: typeof alignment !== "undefined", + [`${rootClass}--static${capitalize(lowerCase(staticColor))}`]: typeof staticColor !== "undefined", "is-disabled": isDisabled, ...customClasses.reduce((a, c) => ({ ...a, [c]: true }), {}), })} @@ -57,8 +60,7 @@ export const Template = ({ data-testid=${ifDefined(testId)} for=${ifDefined(forInput)} > - ${label} - ${when(isRequired, () => icon)} + ${label?.trim()}${when(isRequired, () => html`⁠${icon}`)} `; }; diff --git a/components/floatingactionbutton/CHANGELOG.md b/components/floatingactionbutton/CHANGELOG.md index 9c940cf76be..2b446ea00cb 100644 --- a/components/floatingactionbutton/CHANGELOG.md +++ b/components/floatingactionbutton/CHANGELOG.md @@ -1,5 +1,20 @@ # Change log +## 5.0.0-next.1 + +### Patch Changes + +- [#3687](https://github.com/adobe/spectrum-css/pull/3687) [`53d1e5e`](https://github.com/adobe/spectrum-css/commit/53d1e5e7eb7817c37be3cfe5a253363dea744046) Thanks [@marissahuysentruyt](https://github.com/marissahuysentruyt)! - ## S2 floating action button fix + + Opts to use the color property as opposed to fill for the icon. This correctly passes the floating action button icon colors to the component, to override the fill property style that is set on the embedded `.spectrum-Icon`. + +## 5.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + ## 4.2.0 ### Minor Changes diff --git a/components/floatingactionbutton/dist/metadata.json b/components/floatingactionbutton/dist/metadata.json index 7daf062a329..0ddd22d190a 100644 --- a/components/floatingactionbutton/dist/metadata.json +++ b/components/floatingactionbutton/dist/metadata.json @@ -72,7 +72,6 @@ "--spectrum-white", "--spectrum-workflow-icon-size-200" ], - "system-theme": [], "passthroughs": [], "high-contrast": [ "--highcontrast-floating-action-button-background-color", diff --git a/components/floatingactionbutton/index.css b/components/floatingactionbutton/index.css index fc4d7786fd7..bc695d6c109 100644 --- a/components/floatingactionbutton/index.css +++ b/components/floatingactionbutton/index.css @@ -79,7 +79,7 @@ background-color: var(--highcontrast-floating-action-button-background-color-hover, var(--mod-floating-action-button-background-color-hover, var(--spectrum-floating-action-button-background-color-hover))); .spectrum-FloatingActionButton-icon { - fill: var(--highcontrast-floating-action-button-icon-color-hover, var(--mod-floating-action-button-icon-color-hover, var(--spectrum-floating-action-button-icon-color-hover))); + color: var(--highcontrast-floating-action-button-icon-color-hover, var(--mod-floating-action-button-icon-color-hover, var(--spectrum-floating-action-button-icon-color-hover))); } } @@ -87,7 +87,7 @@ background-color: var(--highcontrast-floating-action-button-background-color-down, var(--mod-floating-action-button-background-color-down, var(--spectrum-floating-action-button-background-color-down))); .spectrum-FloatingActionButton-icon { - fill: var(--highcontrast-floating-action-button-icon-color-down, var(--mod-floating-action-button-icon-color-down, var(--spectrum-floating-action-button-icon-color-down))); + color: var(--highcontrast-floating-action-button-icon-color-down, var(--mod-floating-action-button-icon-color-down, var(--spectrum-floating-action-button-icon-color-down))); } } @@ -96,7 +96,7 @@ outline: 0; .spectrum-FloatingActionButton-icon { - fill: var(--highcontrast-floating-action-button-icon-color-key-focus, var(--mod-floating-action-button-icon-color-key-focus, var(--spectrum-floating-action-button-icon-color-key-focus))); + color: var(--highcontrast-floating-action-button-icon-color-key-focus, var(--mod-floating-action-button-icon-color-key-focus, var(--spectrum-floating-action-button-icon-color-key-focus))); } &::after { @@ -114,5 +114,5 @@ .spectrum-Icon.spectrum-FloatingActionButton-icon { block-size: var(--mod-floating-action-button-icon-size, var(--spectrum-floating-action-button-icon-size)); inline-size: var(--mod-floating-action-button-icon-size, var(--spectrum-floating-action-button-icon-size)); - fill: var(--highcontrast-floating-action-button-icon-color, var(--mod-floating-action-button-icon-color, var(--spectrum-floating-action-button-icon-color))); + color: var(--highcontrast-floating-action-button-icon-color, var(--mod-floating-action-button-icon-color, var(--spectrum-floating-action-button-icon-color))); } diff --git a/components/floatingactionbutton/package.json b/components/floatingactionbutton/package.json index 6bc1f478a03..fb967afe976 100644 --- a/components/floatingactionbutton/package.json +++ b/components/floatingactionbutton/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/floatingactionbutton", - "version": "4.2.0", + "version": "5.0.0-next.1", "description": "The Spectrum CSS floatingactionbutton component", "license": "Apache-2.0", "author": "Adobe", @@ -25,7 +25,7 @@ }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/tokens": ">=16.0.1" + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/tokens": { @@ -33,7 +33,7 @@ } }, "devDependencies": { - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/floatingactionbutton/stories/floatingactionbutton.stories.js b/components/floatingactionbutton/stories/floatingactionbutton.stories.js index 3d96790255d..133de04be8a 100644 --- a/components/floatingactionbutton/stories/floatingactionbutton.stories.js +++ b/components/floatingactionbutton/stories/floatingactionbutton.stories.js @@ -49,7 +49,11 @@ export default { parameters: { packageJson, metadata, + status: { + type: "unmigrated", + }, }, + tags: ["unmigrated"], }; export const Default = FloatingActionButtonGroup.bind({}); diff --git a/components/form/CHANGELOG.md b/components/form/CHANGELOG.md index eafa1da4e0e..e21aa320c7b 100644 --- a/components/form/CHANGELOG.md +++ b/components/form/CHANGELOG.md @@ -1,5 +1,12 @@ # Change Log +## 2.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + ## 1.2.0 ### Minor Changes diff --git a/components/form/dist/metadata.json b/components/form/dist/metadata.json index 88655f8edd3..c07dfdca8d9 100644 --- a/components/form/dist/metadata.json +++ b/components/form/dist/metadata.json @@ -31,7 +31,6 @@ "--spectrum-spacing-200", "--spectrum-spacing-300" ], - "system-theme": [], "passthroughs": [], "high-contrast": ["--highcontrast-form-item-disabled-content-color"] } diff --git a/components/form/package.json b/components/form/package.json index ffcf7fdaadc..3789068c867 100644 --- a/components/form/package.json +++ b/components/form/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/form", - "version": "1.2.0", + "version": "2.0.0-next.0", "description": "The Spectrum CSS form component", "license": "Apache-2.0", "author": "Adobe", @@ -24,7 +24,7 @@ }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/tokens": ">=16.0.1" + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/tokens": { @@ -32,7 +32,7 @@ } }, "devDependencies": { - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/form/stories/form.stories.js b/components/form/stories/form.stories.js index 233f18adb21..ab7af9d944b 100644 --- a/components/form/stories/form.stories.js +++ b/components/form/stories/form.stories.js @@ -1,7 +1,7 @@ import { Template as Fieldgroup } from "@spectrum-css/fieldgroup/stories/template.js"; import { Template as Picker } from "@spectrum-css/picker/stories/template.js"; import { disableDefaultModes } from "@spectrum-css/preview/modes"; -import { Template as Stepper } from "@spectrum-css/stepper/stories/template.js"; +import { Template as NumberField } from "@spectrum-css/stepper/stories/template.js"; import { Template as TextField } from "@spectrum-css/textfield/stories/template.js"; import metadata from "../dist/metadata.json"; import packageJson from "../package.json"; @@ -97,7 +97,7 @@ export default { label: "Age", id: "form-example-amount", content: [ - (passthroughs, context) => Stepper({ + (passthroughs, context) => NumberField({ ...passthroughs, }, context), ] @@ -107,7 +107,11 @@ export default { parameters: { packageJson, metadata, + status: { + type: "migrated", + }, }, + tags: ["migrated"], }; /** diff --git a/components/helptext/CHANGELOG.md b/components/helptext/CHANGELOG.md index 6bfee32895a..cffe2ab2d8a 100644 --- a/components/helptext/CHANGELOG.md +++ b/components/helptext/CHANGELOG.md @@ -1,5 +1,75 @@ # Change log +## 8.0.0-next.2 + +### Minor Changes + +- [#3683](https://github.com/adobe/spectrum-css/pull/3683) [`e309613`](https://github.com/adobe/spectrum-css/commit/e309613c356ba5586b65cdcc26787d161a3b39e1) Thanks [@aramos-adobe](https://github.com/aramos-adobe)! - ### Combobox S2 Migration + + #### New Changes + - Removed quiet styling variant + - Updated corner radius to match S2 specifications + - Changed outline thickness for better visibility + - Replaced picker button with in-field button component + - Added help text along with invalid state + - Modified the WHCM invalid/error state in help text + + ### New tokens + + `--spectrum-combobox-font-weight` + `--spectrum-combobox-line-height-cjk` + `--spectrum-combobox-spacing-alert-icon-to-text` + `--spectrum-combobox-spacing-to-help-text` + + ### New mods + + `--mod-combobox-line-height-cjk` + `--mod-combobox-popover-animation-distance` + `--mod-combobox-spacing-alert-icon-to-text` + `--mod-combobox-spacing-to-help-text` + `--mod-combobox-textfield-background-color` + +## 8.0.0-next.1 + +### Major Changes + +📝 [#3628](https://github.com/adobe/spectrum-css/pull/3628) [`beee947`](https://github.com/adobe/spectrum-css/commit/beee9473b66a4e10c2e4c100a64a3d05fd3f5d44) Thanks [@aramos-adobe](https://github.com/aramos-adobe)! + +#### Helptext S2 Migration + +The helptext S2 component has some updated spacing and typography tokens. The error message validation icon has also been updated. + +##### New mods + +`--mod-helptext-font-family` +`--mod-helptext-font-style` +`--mod-helptext-font-weight` +`--mod-helptext-top-edge-to-workflow-icon` +`--mod-helptext-bottom-edge-to-workflow-icon` + +##### Renamed mods + +`--mod-helptext-bottom-to-workflow-icon` >> `--mod-helptext-edge-to-workflow-icon` + +##### Deprecated tokens + +`--spectrum-help-text-top-to-workflow-icon-small` +`--spectrum-help-text-top-to-workflow-icon-medium` +`--spectrum-help-text-top-to-workflow-icon-large` +`--spectrum-help-text-top-to-workflow-icon-extra-large` + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + +## 8.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`a25e0a9`](https://github.com/adobe/spectrum-css/commit/a25e0a99e5a4736ab4e607e00739343101a2633b)]: + - @spectrum-css/icon@10.0.0-next.0 + ## 7.2.0 ### Minor Changes @@ -14,8 +84,6 @@ Ensure accurate exports are present for each component. Specifically, adding `th 📝 [`205182b`](https://github.com/adobe/spectrum-css/commit/205182bebcbe82813457aa098d8799b0a23423ee) Thanks [@castastrophe](https://github.com/castastrophe)! -## New feature - Minified and gzipped outputs available for all compiled CSS assets. ### Patch Changes diff --git a/components/helptext/dist/metadata.json b/components/helptext/dist/metadata.json index f730c33a671..4ed0075bb8c 100644 --- a/components/helptext/dist/metadata.json +++ b/components/helptext/dist/metadata.json @@ -14,7 +14,6 @@ ".spectrum-HelpText.spectrum-HelpText--neutral .spectrum-HelpText-text", ".spectrum-HelpText.spectrum-HelpText--neutral .spectrum-HelpText-validationIcon", ".spectrum-HelpText.spectrum-HelpText--sizeL", - ".spectrum-HelpText.spectrum-HelpText--sizeM", ".spectrum-HelpText.spectrum-HelpText--sizeS", ".spectrum-HelpText.spectrum-HelpText--sizeXL", ".spectrum-HelpText:lang(ja)", @@ -22,65 +21,80 @@ ".spectrum-HelpText:lang(zh)" ], "modifiers": [ + "--mod-helptext-bottom-edge-to-workflow-icon", "--mod-helptext-bottom-to-text", - "--mod-helptext-bottom-to-workflow-icon", "--mod-helptext-content-color-default", + "--mod-helptext-font-family", "--mod-helptext-font-size", + "--mod-helptext-font-style", + "--mod-helptext-font-weight", "--mod-helptext-icon-color-default", "--mod-helptext-icon-size", "--mod-helptext-line-height", "--mod-helptext-line-height-cjk", "--mod-helptext-min-height", "--mod-helptext-text-to-visual", - "--mod-helptext-top-to-text", - "--mod-helptext-top-to-workflow-icon" + "--mod-helptext-top-edge-to-workflow-icon", + "--mod-helptext-top-to-text" ], "component": [ - "--spectrum-help-text-top-to-workflow-icon-extra-large", - "--spectrum-help-text-top-to-workflow-icon-large", - "--spectrum-help-text-top-to-workflow-icon-medium", - "--spectrum-help-text-top-to-workflow-icon-small", "--spectrum-helptext-bottom-to-text", - "--spectrum-helptext-bottom-to-workflow-icon", "--spectrum-helptext-content-color-default", + "--spectrum-helptext-edge-to-workflow-icon", + "--spectrum-helptext-font-family", "--spectrum-helptext-font-size", + "--spectrum-helptext-font-style", + "--spectrum-helptext-font-weight", "--spectrum-helptext-icon-color-default", "--spectrum-helptext-icon-size", + "--spectrum-helptext-line-height", "--spectrum-helptext-min-height", "--spectrum-helptext-text-to-visual", - "--spectrum-helptext-top-to-text", - "--spectrum-helptext-top-to-workflow-icon" + "--spectrum-helptext-top-to-text" ], "global": [ "--spectrum-cjk-line-height-100", "--spectrum-component-bottom-to-text-100", "--spectrum-component-bottom-to-text-200", + "--spectrum-component-bottom-to-text-300", "--spectrum-component-bottom-to-text-75", "--spectrum-component-height-100", "--spectrum-component-height-200", + "--spectrum-component-height-300", "--spectrum-component-height-75", "--spectrum-component-top-to-text-100", "--spectrum-component-top-to-text-200", + "--spectrum-component-top-to-text-300", "--spectrum-component-top-to-text-75", + "--spectrum-component-top-to-workflow-icon-100", + "--spectrum-component-top-to-workflow-icon-200", + "--spectrum-component-top-to-workflow-icon-300", + "--spectrum-component-top-to-workflow-icon-75", + "--spectrum-default-font-style", "--spectrum-disabled-content-color", "--spectrum-font-size-100", "--spectrum-font-size-200", + "--spectrum-font-size-300", "--spectrum-font-size-75", "--spectrum-line-height-100", - "--spectrum-negative-color-900", + "--spectrum-negative-content-color-default", "--spectrum-neutral-subdued-content-color-default", + "--spectrum-regular-font-weight", + "--spectrum-sans-font-family-stack", "--spectrum-text-to-visual-100", "--spectrum-text-to-visual-200", + "--spectrum-text-to-visual-300", "--spectrum-text-to-visual-75", "--spectrum-workflow-icon-size-100", "--spectrum-workflow-icon-size-200", "--spectrum-workflow-icon-size-300", "--spectrum-workflow-icon-size-75" ], - "system-theme": [], "passthroughs": [], "high-contrast": [ "--highcontrast-helptext-content-color-default", - "--highcontrast-helptext-icon-color-default" + "--highcontrast-helptext-content-color-disabled", + "--highcontrast-helptext-icon-color-default", + "--highcontrast-helptext-icon-color-disabled" ] } diff --git a/components/helptext/index.css b/components/helptext/index.css index 607a81e01c8..3ef91377442 100644 --- a/components/helptext/index.css +++ b/components/helptext/index.css @@ -11,99 +11,85 @@ * governing permissions and limitations under the License. */ -@media (forced-colors: active) { - .spectrum-HelpText { - --highcontrast-helptext-content-color-default: CanvasText; - --highcontrast-helptext-icon-color-default: CanvasText; - - forced-color-adjust: none; +.spectrum-HelpText { + /* Spacing */ + --spectrum-helptext-min-height: var(--spectrum-component-height-100); + --spectrum-helptext-icon-size: var(--spectrum-workflow-icon-size-100); + --spectrum-helptext-text-to-visual: var(--spectrum-text-to-visual-100); + --spectrum-helptext-edge-to-workflow-icon: var(--spectrum-component-top-to-workflow-icon-100); + --spectrum-helptext-top-to-text: var(--spectrum-component-top-to-text-100); + --spectrum-helptext-bottom-to-text: var(--spectrum-component-bottom-to-text-100); + + /* Typpography */ + --spectrum-helptext-font-size: var(--spectrum-font-size-100); + --spectrum-helptext-font-family: var(--spectrum-sans-font-family-stack); + --spectrum-helptext-font-style: var(--spectrum-default-font-style); + --spectrum-helptext-line-height: var(--spectrum-line-height-100); + --spectrum-helptext-font-weight: var(--spectrum-regular-font-weight); - .spectrum-HelpText-validationIcon, - .spectrum-HelpText-text { - forced-color-adjust: none; - } + &:lang(ja), + &:lang(zh), + &:lang(ko) { + --mod-helptext-line-height: var(--mod-helptext-line-height-cjk, var(--spectrum-cjk-line-height-100)); } -} - -.spectrum-HelpText { - --spectrum-helptext-content-color-default: var(--spectrum-neutral-subdued-content-color-default); - --spectrum-helptext-icon-color-default: var(--spectrum-neutral-subdued-content-color-default); &.spectrum-HelpText--sizeS { --spectrum-helptext-min-height: var(--spectrum-component-height-75); --spectrum-helptext-icon-size: var(--spectrum-workflow-icon-size-75); --spectrum-helptext-font-size: var(--spectrum-font-size-75); --spectrum-helptext-text-to-visual: var(--spectrum-text-to-visual-75); - --spectrum-helptext-top-to-workflow-icon: var(--spectrum-help-text-top-to-workflow-icon-small); - --spectrum-helptext-bottom-to-workflow-icon: var(--spectrum-helptext-top-to-workflow-icon); - --spectrum-helptext-top-to-text: var(--spectrum-component-top-to-text-75); - --spectrum-helptext-bottom-to-text: var(--spectrum-component-bottom-to-text-75); - } - - &, - &.spectrum-HelpText--sizeM { - --spectrum-helptext-min-height: var(--spectrum-component-height-75); - --spectrum-helptext-icon-size: var(--spectrum-workflow-icon-size-100); - --spectrum-helptext-font-size: var(--spectrum-font-size-75); - --spectrum-helptext-text-to-visual: var(--spectrum-text-to-visual-75); - --spectrum-helptext-top-to-workflow-icon: var(--spectrum-help-text-top-to-workflow-icon-medium); - --spectrum-helptext-bottom-to-workflow-icon: var(--spectrum-helptext-top-to-workflow-icon); + --spectrum-helptext-edge-to-workflow-icon: var(--spectrum-component-top-to-workflow-icon-75); --spectrum-helptext-top-to-text: var(--spectrum-component-top-to-text-75); --spectrum-helptext-bottom-to-text: var(--spectrum-component-bottom-to-text-75); } &.spectrum-HelpText--sizeL { - --spectrum-helptext-min-height: var(--spectrum-component-height-100); - --spectrum-helptext-icon-size: var(--spectrum-workflow-icon-size-200); - --spectrum-helptext-font-size: var(--spectrum-font-size-100); - --spectrum-helptext-text-to-visual: var(--spectrum-text-to-visual-100); - --spectrum-helptext-top-to-workflow-icon: var(--spectrum-help-text-top-to-workflow-icon-large); - --spectrum-helptext-bottom-to-workflow-icon: var(--spectrum-helptext-top-to-workflow-icon); - --spectrum-helptext-top-to-text: var(--spectrum-component-top-to-text-100); - --spectrum-helptext-bottom-to-text: var(--spectrum-component-bottom-to-text-100); - } - - &.spectrum-HelpText--sizeXL { --spectrum-helptext-min-height: var(--spectrum-component-height-200); - --spectrum-helptext-icon-size: var(--spectrum-workflow-icon-size-300); + --spectrum-helptext-icon-size: var(--spectrum-workflow-icon-size-200); --spectrum-helptext-font-size: var(--spectrum-font-size-200); --spectrum-helptext-text-to-visual: var(--spectrum-text-to-visual-200); - --spectrum-helptext-top-to-workflow-icon: var(--spectrum-help-text-top-to-workflow-icon-extra-large); - --spectrum-helptext-bottom-to-workflow-icon: var(--spectrum-helptext-top-to-workflow-icon); + --spectrum-helptext-edge-to-workflow-icon: var(--spectrum-component-top-to-workflow-icon-200); --spectrum-helptext-top-to-text: var(--spectrum-component-top-to-text-200); --spectrum-helptext-bottom-to-text: var(--spectrum-component-bottom-to-text-200); } + &.spectrum-HelpText--sizeXL { + --spectrum-helptext-min-height: var(--spectrum-component-height-300); + --spectrum-helptext-icon-size: var(--spectrum-workflow-icon-size-300); + --spectrum-helptext-font-size: var(--spectrum-font-size-300); + --spectrum-helptext-text-to-visual: var(--spectrum-text-to-visual-300); + --spectrum-helptext-edge-to-workflow-icon: var(--spectrum-component-top-to-workflow-icon-300); + --spectrum-helptext-top-to-text: var(--spectrum-component-top-to-text-300); + --spectrum-helptext-bottom-to-text: var(--spectrum-component-bottom-to-text-300); + } + + &, &.spectrum-HelpText--neutral { --spectrum-helptext-content-color-default: var(--spectrum-neutral-subdued-content-color-default); --spectrum-helptext-icon-color-default: var(--spectrum-neutral-subdued-content-color-default); } &.spectrum-HelpText--negative { - --spectrum-helptext-content-color-default: var(--spectrum-negative-color-900); - --spectrum-helptext-icon-color-default: var(--spectrum-negative-color-900); + --spectrum-helptext-content-color-default: var(--spectrum-negative-content-color-default); + --spectrum-helptext-icon-color-default: var(--spectrum-negative-content-color-default); } &.is-disabled { --spectrum-helptext-content-color-default: var(--spectrum-disabled-content-color); --spectrum-helptext-icon-color-default: var(--spectrum-disabled-content-color); } +} +.spectrum-HelpText { color: var(--highcontrast-helptext-content-color-default, var(--mod-helptext-content-color-default, var(--spectrum-helptext-content-color-default))); display: flex; font-size: var(--mod-helptext-font-size, var(--spectrum-helptext-font-size)); min-block-size: var(--mod-helptext-min-height, var(--spectrum-helptext-min-height)); - &:lang(ja), - &:lang(zh), - &:lang(ko) { - --mod-helptext-line-height: var(--mod-helptext-line-height-cjk, var(--spectrum-cjk-line-height-100)); - } - .spectrum-HelpText-validationIcon { margin-inline-end: var(--mod-helptext-text-to-visual, var(--spectrum-helptext-text-to-visual)); - padding-block-start: var(--mod-helptext-top-to-workflow-icon, var(--spectrum-helptext-top-to-workflow-icon)); - padding-block-end: var(--mod-helptext-bottom-to-workflow-icon, var(--spectrum-helptext-bottom-to-workflow-icon)); + padding-block-start: var(--mod-helptext-top-edge-to-workflow-icon, var(--spectrum-helptext-edge-to-workflow-icon)); + padding-block-end: var(--mod-helptext-bottom-edge-to-workflow-icon, var(--spectrum-helptext-edge-to-workflow-icon)); flex-shrink: 0; block-size: var(--mod-helptext-icon-size, var(--spectrum-helptext-icon-size)); inline-size: var(--mod-helptext-icon-size, var(--spectrum-helptext-icon-size)); @@ -112,9 +98,13 @@ .spectrum-HelpText-text { padding-block-start: var(--mod-helptext-top-to-text, var(--spectrum-helptext-top-to-text)); padding-block-end: var(--mod-helptext-bottom-to-text, var(--spectrum-helptext-bottom-to-text)); - line-height: var(--mod-helptext-line-height, var(--spectrum-line-height-100)); + line-height: var(--mod-helptext-line-height, var(--spectrum-helptext-line-height)); + font-family: var(--mod-helptext-font-family, var(--spectrum-helptext-font-family)); + font-style: var(--mod-helptext-font-style, var(--spectrum-helptext-font-style)); + font-weight: var(--mod-helptext-font-weight, var(--spectrum-helptext-font-weight)); } + /* Variants -- Neutral, negative, disabled */ &.spectrum-HelpText--neutral { .spectrum-HelpText-text { color: var(--highcontrast-helptext-content-color-default, var(--mod-helptext-content-color-default, var(--spectrum-helptext-content-color-default))); @@ -137,11 +127,20 @@ &.is-disabled { .spectrum-HelpText-text { - color: var(--highcontrast-helptext-content-color-default, var(--mod-helptext-content-color-default, var(--spectrum-helptext-content-color-default))); + color: var(--highcontrast-helptext-content-color-disabled, var(--mod-helptext-content-color-default, var(--spectrum-helptext-content-color-default))); } .spectrum-HelpText-validationIcon { - color: var(--highcontrast-helptext-icon-color-default, var(--mod-helptext-icon-color-default, var(--spectrum-helptext-icon-color-default))); + color: var(--highcontrast-helptext-icon-color-disabled, var(--mod-helptext-icon-color-default, var(--spectrum-helptext-icon-color-default))); } } } + +@media (forced-colors: active) { + .spectrum-HelpText { + --highcontrast-helptext-content-color-default: CanvasText; + --highcontrast-helptext-icon-color-default: CanvasText; + --highcontrast-helptext-icon-color-disabled: GrayText; + --highcontrast-helptext-content-color-disabled: GrayText; + } +} diff --git a/components/helptext/package.json b/components/helptext/package.json index 8ef599b9e8b..0669bab6bd3 100644 --- a/components/helptext/package.json +++ b/components/helptext/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/helptext", - "version": "7.2.0", + "version": "8.0.0-next.2", "description": "The Spectrum CSS helptext component", "license": "Apache-2.0", "author": "Adobe", @@ -24,8 +24,8 @@ }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/icon": ">=9.0.0 <10.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/icon": ">=10.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/icon": { @@ -36,8 +36,8 @@ } }, "devDependencies": { - "@spectrum-css/icon": "9.2.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/icon": "10.0.0-next.3", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/helptext/stories/helptext.stories.js b/components/helptext/stories/helptext.stories.js index 5274cec9f78..01d56bd4f99 100644 --- a/components/helptext/stories/helptext.stories.js +++ b/components/helptext/stories/helptext.stories.js @@ -63,7 +63,11 @@ export default { }, packageJson, metadata, + status: { + type: "migrated", + }, }, + tags: ["migrated"], }; /** @@ -97,6 +101,9 @@ export const Sizing = (args, context) => Sizes({ Sizing.storyName = "Sizing"; Sizing.args = { variant: "negative", + customStyles: { + "--mod-helptext-align-text": "center", + }, }; Sizing.tags = ["!dev"]; Sizing.parameters = { diff --git a/components/helptext/stories/template.js b/components/helptext/stories/template.js index 74fa628ae2a..894c60745cb 100644 --- a/components/helptext/stories/template.js +++ b/components/helptext/stories/template.js @@ -34,7 +34,7 @@ export const Template = ({ ${when(!hideIcon && variant == "negative", () => Icon( { - iconName: "Alert", + iconName: "AlertTriangle", setName: "workflow", size, customClasses: [`${rootClass}-validationIcon`], @@ -85,7 +85,10 @@ export const NegativeTemplate = (args, context) => Container({ }, content: Template({ ...args, - hideIcon + hideIcon, + customStyles: { + "--mod-helptext-align-text": "center", + }, }, context), }, context) )}`, diff --git a/components/icon/CHANGELOG.md b/components/icon/CHANGELOG.md index c5d0b3b06eb..2314f2c2a4d 100644 --- a/components/icon/CHANGELOG.md +++ b/components/icon/CHANGELOG.md @@ -1,5 +1,34 @@ # Change log +## 10.0.0-next.3 + +### Minor Changes + +📝 [#3988](https://github.com/adobe/spectrum-css/pull/3988) [`86dd51d`](https://github.com/adobe/spectrum-css/commit/86dd51d884878a3090cb8463ca0bf44f21ee9f87) Thanks [@rise-erpelding](https://github.com/rise-erpelding)! + +Adds icon class for link out 75 icon + +## 10.0.0-next.2 + +### Minor Changes + +- [#3866](https://github.com/adobe/spectrum-css/pull/3866) [`1b33315`](https://github.com/adobe/spectrum-css/commit/1b33315fa1b65d65fe940d3be4ea4395d5394655) Thanks [@rise-erpelding](https://github.com/rise-erpelding)! - Updates the icon component to use size tokens for newly added ui icons. + +## 10.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + +## 10.0.0-next.0 + +### Major Changes + +📝 [#2352](https://github.com/adobe/spectrum-css/pull/2352) [`a25e0a9`](https://github.com/adobe/spectrum-css/commit/a25e0a99e5a4736ab4e607e00739343101a2633b) Thanks [@pfulton](https://github.com/pfulton)! + +Updates the icon component to use the new Spectrum 2 icon sets. The `.spectrum-UIIcon--medium` and `.spectrum-UIIcon--large` classes have been removed, as UI icons are now delivered with a single SVG. The color property also now makes use of the `--iconPrimary` custom property that is defined in some of the SVG files. Storybook has been updated to use and load the new SVGs, whose name format and directories have changed. + ## 9.2.0 ### Minor Changes @@ -175,6 +204,7 @@ Output for all component CSS files is now being run through a lightweight optimi ### 🛑 BREAKING CHANGE - Removes component-builder & component-builder-simple for script leveraging postcss + - Imports added to index.css and themes/express.css ## 6.0.5 diff --git a/components/icon/dist/metadata.json b/components/icon/dist/metadata.json index 7f5d27e3789..7fcad33c95b 100644 --- a/components/icon/dist/metadata.json +++ b/components/icon/dist/metadata.json @@ -11,8 +11,11 @@ ".spectrum-Icon--sizeXXL", ".spectrum-Icon--sizeXXS", ".spectrum-UIIcon", - ".spectrum-UIIcon--large", - ".spectrum-UIIcon--medium", + ".spectrum-UIIcon-Add100", + ".spectrum-UIIcon-Add200", + ".spectrum-UIIcon-Add300", + ".spectrum-UIIcon-Add50", + ".spectrum-UIIcon-Add75", ".spectrum-UIIcon-ArrowDown100", ".spectrum-UIIcon-ArrowDown200", ".spectrum-UIIcon-ArrowDown300", @@ -99,15 +102,23 @@ ".spectrum-UIIcon-Dash50", ".spectrum-UIIcon-Dash500", ".spectrum-UIIcon-Dash600", - ".spectrum-UIIcon-Dash75" + ".spectrum-UIIcon-Dash75", + ".spectrum-UIIcon-DragHandle100", + ".spectrum-UIIcon-DragHandle200", + ".spectrum-UIIcon-DragHandle300", + ".spectrum-UIIcon-DragHandle75", + ".spectrum-UIIcon-Gripper100", + ".spectrum-UIIcon-LinkOut100", + ".spectrum-UIIcon-LinkOut200", + ".spectrum-UIIcon-LinkOut300", + ".spectrum-UIIcon-LinkOut400", + ".spectrum-UIIcon-LinkOut75" ], "modifiers": [ "--mod-icon-block-size", "--mod-icon-color", "--mod-icon-inline-size", - "--mod-icon-size", - "--mod-ui-icon-large-display", - "--mod-ui-icon-medium-display" + "--mod-icon-size" ], "component": [ "--spectrum-icon-block-size", @@ -115,6 +126,11 @@ "--spectrum-icon-size" ], "global": [ + "--spectrum-add-icon-size-100", + "--spectrum-add-icon-size-200", + "--spectrum-add-icon-size-300", + "--spectrum-add-icon-size-50", + "--spectrum-add-icon-size-75", "--spectrum-arrow-icon-size-100", "--spectrum-arrow-icon-size-200", "--spectrum-arrow-icon-size-300", @@ -160,8 +176,16 @@ "--spectrum-dash-icon-size-500", "--spectrum-dash-icon-size-600", "--spectrum-dash-icon-size-75", - "--spectrum-ui-icon-large-display", - "--spectrum-ui-icon-medium-display", + "--spectrum-drag-handle-icon-size-100", + "--spectrum-drag-handle-icon-size-200", + "--spectrum-drag-handle-icon-size-300", + "--spectrum-drag-handle-icon-size-75", + "--spectrum-gripper-icon-size-100", + "--spectrum-link-out-icon-size-100", + "--spectrum-link-out-icon-size-200", + "--spectrum-link-out-icon-size-300", + "--spectrum-link-out-icon-size-400", + "--spectrum-link-out-icon-size-75", "--spectrum-workflow-icon-size-100", "--spectrum-workflow-icon-size-200", "--spectrum-workflow-icon-size-300", @@ -170,7 +194,6 @@ "--spectrum-workflow-icon-size-xxl", "--spectrum-workflow-icon-size-xxs" ], - "system-theme": [], "passthroughs": [], "high-contrast": [] } diff --git a/components/icon/icons.css b/components/icon/icons.css index e413ba95173..ff0a39b001d 100644 --- a/components/icon/icons.css +++ b/components/icon/icons.css @@ -13,6 +13,9 @@ .spectrum-Icon, .spectrum-UIIcon { + /* stylelint-disable-next-line custom-property-pattern -- variable name defined by A4U output */ + --iconPrimary: var(--mod-icon-color, currentColor); + --spectrum-icon-inline-size: var(--mod-icon-inline-size, var(--mod-icon-size, var(--spectrum-icon-size))); --spectrum-icon-block-size: var(--mod-icon-block-size, var(--mod-icon-size, var(--spectrum-icon-size))); @@ -24,7 +27,8 @@ color: var(--mod-icon-color, inherit); /* Fill should match the current text color. */ - fill: currentColor; + /* stylelint-disable-next-line custom-property-pattern -- map this to the same value as what's used by the icon's SVG code */ + fill: var(--iconPrimary); /* Don't catch clicks or hover, otherwise they may not escape the SVG. */ pointer-events: none; diff --git a/components/icon/package.json b/components/icon/package.json index fd44ec149bc..c5ca3b595e3 100644 --- a/components/icon/package.json +++ b/components/icon/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/icon", - "version": "9.2.0", + "version": "10.0.0-next.3", "description": "The Spectrum CSS icon component", "license": "Apache-2.0", "author": "Adobe", @@ -24,7 +24,7 @@ }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/tokens": { @@ -32,7 +32,7 @@ } }, "devDependencies": { - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/icon/stories/icon.stories.js b/components/icon/stories/icon.stories.js index da5fc2cda00..9287892c250 100644 --- a/components/icon/stories/icon.stories.js +++ b/components/icon/stories/icon.stories.js @@ -1,27 +1,11 @@ +import { Sizes } from "@spectrum-css/preview/decorators"; import { disableDefaultModes } from "@spectrum-css/preview/modes"; import { size } from "@spectrum-css/preview/types"; -import { Sizes } from "@spectrum-css/preview/decorators"; import metadata from "../dist/metadata.json"; import packageJson from "../package.json"; import { IconGroup } from "./icon.test.js"; -import { IconListTemplate, Template, UIDefaultTemplate } from "./template.js"; -import { uiIconSizes, uiIconsWithDirections, workflowIcons } from "./utilities.js"; - -/** - * Create a list of all UI Icons with their sizing numbers. - * - * The list is a little long until Storybook adds a way to use conditional options - * in controls, e.g. a "uiSize" control with options pulled from uiIconSizes: - * @see https://github.com/storybookjs/storybook/discussions/24235 - */ -const uiIconNameOptions = uiIconsWithDirections.map((iconName) => { - const baseIconName = iconName.replace(/(Left|Right|Up|Down)$/, ""); - // Icons like Gripper that don't have sizes yet, represented by any empty array. - if (uiIconSizes[baseIconName]?.length == 0) { - return [baseIconName]; - } - return uiIconSizes[baseIconName]?.map(sizeNum => iconName + sizeNum) ?? []; -}).flat(); +import { FullIconSetTemplate, Template, UIArrowsTemplate, UIDefaultTemplate, WorkflowDefaultTemplate } from "./template"; +import { uiIconsWithDirections, workflowIconsCleaned, workflowSizes } from "./utilities.js"; /** * The Icon component contains all of the CSS used for displaying both workflow and UI icons. @@ -44,7 +28,7 @@ export default { component: "Icon", argTypes: { size: { - ...size(["xs", "s", "m", "l", "xl", "xxl"]), + ...size(workflowSizes), if: { arg: "setName", eq: "workflow" }, }, setName: { @@ -64,7 +48,7 @@ export default { type: { summary: "string" }, category: "Content", }, - options: workflowIcons, + options: workflowIconsCleaned, control: "select", if: { arg: "setName", eq: "workflow" }, }, @@ -75,9 +59,7 @@ export default { type: { summary: "string" }, category: "Content", }, - options: [ - ...uiIconNameOptions, - ], + options: uiIconsWithDirections, control: "select", if: { arg: "setName", eq: "ui" }, }, @@ -90,25 +72,83 @@ export default { }, control: "color", }, - useRef: { table: { disable: true } }, + useRef: { + name: "Use sprite sheet reference", + description: "Storybook only: whether to display an SVG with a `` reference to the icon within a loaded sprite sheet. This improves Storybook performance, especially for multiple icons. When set to `false`, the icon file's full markup is used.", + type: { name: "boolean" }, + table: { + type: { summary: "boolean" }, + category: "Advanced", + }, + control: "boolean", + }, }, args: { rootClass: "spectrum-Icon", setName: "workflow", - iconName: "ABC", + iconName: "Color", + uiIconName: "Checkmark400", size: "xl", useRef: true, }, parameters: { packageJson, metadata, + design: { + type: "figma", + url: "https://www.figma.com/design/9qeVZSJ9t0kv6r7njzgHx7/S2-%2F-Styles-visualizer-(WIP)?node-id=295-24257&t=ZC7fyaQ0VQYQ5VYM-1", + }, + status: { + type: "migrated", + }, }, + tags: ["migrated"], }; export const Default = IconGroup.bind({}); Default.args = {}; Default.tags = ["!autodocs"]; +/** + * All icons in the Workflow icon set. + */ +export const Workflow = FullIconSetTemplate.bind({}); +Workflow.storyName = "Workflow icons"; +Workflow.tags = ["!autodocs"]; +Workflow.args = { + setName: "workflow", + useRef: true, +}; +Workflow.argTypes = { + setName: { table: { disable: true } }, + iconName: { table: { disable: true } }, +}; +Workflow.parameters = { + chromatic: { disableSnapshot: true }, + // Layout other than "centered" needed for dynamic grid columns CSS to work correctly. + layout: "padded", +}; + +/** + * All icons in the UI icon set. + */ +export const UI = FullIconSetTemplate.bind({}); +UI.storyName = "UI icons"; +UI.tags = ["!autodocs"]; +UI.args = { + setName: "ui", + useRef: true, +}; +UI.argTypes = { + setName: { table: { disable: true } }, + uiIconName: { table: { disable: true } }, +}; +UI.parameters = { + chromatic: { disableSnapshot: true }, + // Layout other than "centered" needed for dynamic grid columns CSS to work correctly. + layout: "padded", +}; + // ********* VRT ONLY ********* // export const WithForcedColors = IconGroup.bind({}); WithForcedColors.tags = ["!autodocs", "!dev"]; @@ -122,35 +162,16 @@ WithForcedColors.parameters = { }, }; -/* Stories for the MDX "Docs" only. */ +// ********* DOCS ONLY ********* // /** * The workflow icon set contains several hundred icons to choose from. + * For a full list of all icons within this set, see **[workflow icons](/story/components-icon--workflow)**. * These icons can be seen in use within [button](/docs/components-button--docs), [action button](/docs/components-action-button--docs), [menu](/docs/components-menu--docs), and many other components. * Here is an example of just a few of these icons: */ -export const WorkflowDefault = (args, context) => IconListTemplate( - { - ...args, - setName: "workflow", - size: "xl", - }, - [ - "Alert", - "Asset", - "Actions", - "ArrowDown", - "Camera", - "Copy", - "DeviceDesktop", - "Download", - "FilterAdd", - "Form", - "Light", - "Polygon", - ], - context -); +export const WorkflowDefault = WorkflowDefaultTemplate.bind({}); +WorkflowDefault.storyName = "Workflow icons"; WorkflowDefault.tags = ["!dev"]; WorkflowDefault.parameters = { chromatic: { disableSnapshot: true }, @@ -158,8 +179,8 @@ WorkflowDefault.parameters = { WorkflowDefault.storyName = "Workflow icons"; /** - * Below is an example of a workflow icon displayed at all its available sizes, from extra-small to extra-extra-large. - * Workflow icons use "t-shirt" sizes (e.g. small, medium), that are the same width and height for each icon in the set. + * An example of a Workflow icon displayed at all sizes, from small to extra-large. + * Note that the extra-extra-large size is currently *not* part of the design specifications and may be deprecated in the near future. */ export const WorkflowSizing = (args, context) => Sizes({ Template, @@ -167,6 +188,7 @@ export const WorkflowSizing = (args, context) => Sizes({ withHeading: false, ...args, }, context); +WorkflowSizing.tags = ["!dev"]; WorkflowSizing.args = { setName: "workflow", iconName: "Asset", @@ -175,11 +197,13 @@ WorkflowSizing.tags = ["!dev"]; WorkflowSizing.parameters = { chromatic: { disableSnapshot: true }, }; -WorkflowSizing.storyName = "Workflow sizing"; +WorkflowSizing.storyName = "Workflow icons - sizing"; /** * UI icons are atomic pieces (e.g., arrows, crosses, etc.) that are used as part of some components. * The chevron within the [combobox component](/docs/components-combobox--docs) is one example. + * For a full list of all icons within this set, see **[ui icons](/story/components-icon--ui)**. + * * Unlike workflow icons, each UI icon comes in specific numbered sizes. They do not use "t-shirt" sizing. They have unique classes applied that set their size in CSS. For example: * - `.spectrum-UIIcon-Asterisk300` * - `.spectrum-UIIcon-ChevronDown75` @@ -205,21 +229,26 @@ UIDefault.parameters = { * - `.spectrum-UIIcon-ArrowDown100` * - `.spectrum-UIIcon-ArrowUp100` */ -export const UIArrows = (args, context) => IconListTemplate( - { - ...args, - setName: "ui", - }, - [ - "ArrowRight100", - "ArrowLeft100", - "ArrowDown100", - "ArrowUp100", - ], - context -); +export const UIArrows = UIArrowsTemplate.bind({}); UIArrows.storyName = "UI icons - directional"; UIArrows.tags = ["!dev"]; UIArrows.parameters = { chromatic: { disableSnapshot: true }, }; + +/** + * In Storybook documentation, if a workflow icon name does not exist in the set, the + * placeholder "Circle" icon will be shown. Missing ui icons will render + * nothing. The following example purposefully uses an icon name that does + * not exist to demonstrate this behavior. + */ +export const MissingWorkflowIcon = Default.bind({}); +MissingWorkflowIcon.storyName = "Workflow icons - missing workflow icon placeholder"; +MissingWorkflowIcon.tags = ["!dev"]; +MissingWorkflowIcon.args = { + setName: "workflow", + iconName: "ThisIconNameDoesNotExist", +}; +MissingWorkflowIcon.parameters = { + chromatic: { disableSnapshot: true }, +}; diff --git a/components/icon/stories/icon.test.js b/components/icon/stories/icon.test.js index fc81d4cb922..34202826597 100644 --- a/components/icon/stories/icon.test.js +++ b/components/icon/stories/icon.test.js @@ -1,99 +1,127 @@ -import { Variants } from "@spectrum-css/preview/decorators"; +import { Container, Variants } from "@spectrum-css/preview/decorators"; +import { Template as Typography } from "@spectrum-css/typography/stories/template.js"; import { html } from "lit"; import { styleMap } from "lit/directives/style-map.js"; -import { when } from "lit/directives/when.js"; import { Template } from "./template.js"; -import { uiIconSizes, uiIconsWithDirections } from "./utilities.js"; +import { uiIconsWithDirections, uniqueUiIconBaseNames, workflowSizes } from "./utilities.js"; /** * Chromatic VRT template that displays multiple icons to cover various options. + * Includes Chromatic-only testing grid with: + * - Several workflow icons, at all sizes, with some set to a color + * - All UI icons, organized within a grid by sizing number and name */ -const TestTemplate = (args, context) => { - return html` -
    -
    - ${[ - { - setName: "workflow", - iconName: "Alert", - fill: "var(--spectrum-negative-content-color-default)", - }, - { - setName: "workflow", - iconName: "Hand", - }, - { - setName: "workflow", - iconName: "Help", - }, - { - setName: "workflow", - iconName: "ArrowLeft", - }, - { - setName: "workflow", - iconName: "ArrowRight", - }, - { - setName: "workflow", - iconName: "ChevronDown", - } - ].map((row_args) => html` -
    - ${["xs","s","m","l","xl","xxl"].map( - (size) => Template({ ...args, ...row_args, size }) - )} -
    ` - )} -
    -
    - ${uiIconsWithDirections.map(iconName => html` -
    - ${uiIconSizes[iconName.replace(/(Left|Right|Up|Down)$/, "")]?.map((iconSize) => - Template({ ...args, setName: "ui", iconName: iconName + iconSize }, context) - )} - ${when(uiIconSizes[iconName]?.length == 0, () => - Template({ ...args, setName: "ui", iconName }, context) - )} -
    ` - )} -
    -
    - `; -}; +export const TestTemplate = (args, context) => html` + ${Container({ + heading: "Workflow icon examples", + withBorder: false, + direction: "row", + wrapperStyles: { + columnGap: "12px", + }, + content: html` +
    + ${workflowSizes.map(scale => html` +
    + ${Typography({ + customClasses: ["chromatic-ignore"], + semantics: "detail", + size: "s", + content: [scale], + customStyles: { + "--mod-detail-font-color": "var(--spectrum-seafoam-900)", + } + })} +
    + `)} + ${[ + "Add", + "AlertTriangle", + "Edit", + "File", + "Folder", + "MenuHamburger", + "SelectRectangle", + "Redo", + "Star", + "StarFilled", + "User", + "ColorHarmony", + "CornerRadiusBottomLeft", + ].map((iconName, idx) => html` + ${workflowSizes.map((size) => Template({ + ...args, + useRef: true, + iconName, + setName: "workflow", + size, + fill: idx % 5 === 0 ? "var(--spectrum-negative-content-color-default)" : undefined + }, context))} + `)} +
    + `, + }, context)} + + ${Container({ + heading: "UI icon set", + withBorder: false, + direction: "row", + wrapperStyles: { + columnGap: "12px", + }, + content: html` +
    + ${["50", "75", "100", "200", "300", "400", "500", "600"].map(scale => html` +
    + ${Typography({ + customClasses: ["chromatic-ignore"], + semantics: "detail", + size: "s", + content: [scale], + customStyles: { + "--mod-detail-font-color": "var(--spectrum-seafoam-900)", + } + })} +
    + `)} + ${uniqueUiIconBaseNames.sort().reduce((print, iconName) => { + let output = Array(8).fill(html``); + ["50", "75", "100", "200", "300", "400", "500", "600"].forEach((scale, idx) => { + if (uiIconsWithDirections.includes(`${iconName}${scale}`)) { + output[idx] = Template({ + ...args, + setName: "ui", + useRef: false, + uiIconName: `${iconName}${scale}`, + }, context); + } + }); + print.push(...output); + return print; + }, [])} +
    + `, + }, context)} +`; export const IconGroup = Variants({ Template, diff --git a/components/icon/stories/template.js b/components/icon/stories/template.js index 2895ff1ef3e..fc0ef8d893e 100644 --- a/components/icon/stories/template.js +++ b/components/icon/stories/template.js @@ -1,9 +1,12 @@ import { getRandomId } from "@spectrum-css/preview/decorators"; +import { Template as Typography } from "@spectrum-css/typography/stories/template.js"; import { html } from "lit"; import { classMap } from "lit/directives/class-map.js"; import { ifDefined } from "lit/directives/if-defined.js"; import { styleMap } from "lit/directives/style-map.js"; import { unsafeSVG } from "lit/directives/unsafe-svg.js"; +import { when } from "lit/directives/when.js"; +import { appendUiIconDefaultSizing, getSpriteSheetName, uiIconsWithDirections, workflowIconsCleaned } from "./utilities.js"; import "../index.css"; @@ -12,78 +15,8 @@ import "../index.css"; * @typedef { IconArgs & { scale: string, setName: 'workflow' | 'ui' } } IconProps */ -const fetchIconDetails = ({ - icons, - workflowIcons = [], - uiIcons = [], - uiIconSizes = {}, -}) => { - if (!icons || Object.keys(icons).length == 0) { - // Fetch loaded data if not provided - if (window.icons) icons = window.icons; - else { - return { - workflowIcons: [], - uiIcons: [], - uiIconSizes: {}, - uiIconsWithDirections: [], - }; - } - } - - // clean up loaded icon data - icons = Object.entries(icons).reduce((acc, [setName, data]) => { - acc[setName] = Object.entries(data).reduce((acc, [size, data]) => { - acc[size] = Object.entries(data).reduce((acc, [iconName, svg]) => { - // simplify icon name - iconName = iconName.split("/").pop().replace(/\.svg$/, ""); - acc[iconName] = svg; - - // Add the icon name to the workflowIcons list if it's from the workflow set - if (setName === "workflow") { - workflowIcons.push(iconName); - } - else { - const iconNameRoot = iconName.replace(/\d{2,3}$/, "").replace(/(Right|Left|Down|Up)$/, ""); - const iconNameSize = iconName.match(/\d{2,3}/g)?.[0]; - uiIcons.push(iconNameRoot); - uiIconSizes[iconNameRoot] = [ - ...new Set([ - ...uiIconSizes[iconNameRoot] ?? [], - ...(iconNameSize ? [iconNameSize] : []), - ]) - ]; - } - return acc; - }, {}); - return acc; - }, {}); - return acc; - }, {}); - - return { - icons, - workflowIcons: [...new Set(workflowIcons)], - uiIcons: [...new Set(uiIcons)], - uiIconSizes, - uiIconsWithDirections: [ - ...new Set([ - ...(uiIcons.filter((c) => !["Chevron", "Arrow"].includes(c)) ?? []), - "ArrowRight", - "ArrowLeft", - "ArrowUp", - "ArrowDown", - "ChevronRight", - "ChevronLeft", - "ChevronUp", - "ChevronDown", - ]) - ], - }; -}; - /** - * Template for rendering an icon + * Template for rendering an icon. * @description Icon template that renders an icon based on the provided icon name and set name. * @param {IconProps} props * @param {string} props.rootClass @@ -94,146 +27,77 @@ const fetchIconDetails = ({ * @param {string} props.fill * @param {string} props.id * @param {string[]} props.customClasses + * @param {boolean} props.useRef [true] Whether to use an SVG with a reference to the icon within the sprite sheet. When false, returns the the individual SVG's entire markup. * @returns {import('lit').TemplateResult<1>} */ export const Template = ({ rootClass = "spectrum-Icon", size = "m", - setName, + setName = "workflow", iconName, uiIconName, fill, id = getRandomId("icon"), customClasses = [], - icons, + customStyles = {}, useRef = true, - workflowIcons, - uiIcons, - uiIconSizes, } = {}, context = {}) => { - const { globals = {}, loaded = {} } = context; - - const scale = globals.scale ?? "medium"; + // All icons SVG markup from the global IconLoader are in loaded.icons + const { loaded } = context; - if (!workflowIcons || !uiIcons || !uiIconSizes) { - const details = fetchIconDetails({ - icons: loaded.icons, - workflowIcons, - uiIcons, - uiIconSizes - }); - - if(details.icons) { - icons = details.icons; - } - - if (!workflowIcons && details.workflowIcons) { - workflowIcons = details.workflowIcons; - } - - if (!uiIcons && details.uiIcons) { - uiIcons = details.uiIcons; - } - - if (!uiIconSizes && details.uiIconSizes) { - uiIconSizes = details.uiIconSizes; - } - } - - // UI icons are selected from a different control. + // Treat "iconName" as the icon name regardless of the icon set. + // UI icons are selected from a different control and arg. if (setName === "ui" && uiIconName) { iconName = uiIconName; } - if (!iconName) { + // Make sure icon set is provided. + if (!["ui","workflow"].includes(setName)) { console.warn( - "Icon: Could not render a result because no icon name was provided to the icon template." + `Icon "${iconName}" is missing its icon set. Make sure you are explicitly setting either the workflow or ui icon set.` ); return html``; } - let idKey = iconName; - - // If icon set was not provided, try determine which icon set contains this icon. - // Note: icon sets can contain the same icon name, with different icons. - if (!["workflow","ui"].includes(setName)) { - if (workflowIcons.includes(idKey)) { - setName = "workflow"; - } - else if (uiIcons.includes(idKey.replace(/\d{2,3}$/, "").replace(/(Right|Left|Down|Up)$/, ""))) { - setName = "ui"; - } + // Make sure icon name is provided. + if (!iconName) { + console.warn("Icon: Could not render a result because no icon name was provided to the icon template."); + return html``; } - // Prefer full SVG for UI icons because sizing is more consistent. - if (setName === "ui" && uiIconName) { - useRef = false; + /** + * Append approximate sizing number to UI icons passed in without a sizing number. + * + * Note: It's preferred for components to provide the specific UI sizing numbers in the UI icon + * name, rather than relying on this approximation, as UI icons do not use t-shirt sizing. + */ + if (setName === "ui") { + iconName = appendUiIconDefaultSizing(iconName, size); } - if (!setName) { - console.warn( - `Icon: Could not determine the icon set for the provided icon name: ${idKey}.` - ); + // Make sure icon exists in the set. + if (setName == "ui" && !uiIconsWithDirections.includes(iconName)) { + console.warn(`Icon: Could not render an icon with the name "${iconName}" because it does not exist in the "ui" icon set.`); return html``; } - // If a descriptor like Right, Left, Down, or Up is present for the UI icons Chevron or - // Arrow, use that only for the class and not the icon fetch. - if ( - setName == "ui" && - uiIcons.some((c) => idKey.startsWith(c)) && - ["Right", "Left", "Down", "Up"].some((c) => idKey.includes(c)) - ) { - idKey = idKey.replace(/(Right|Left|Down|Up)/, ""); + if (setName == "workflow" && !workflowIconsCleaned.includes(iconName)) { + console.warn(`Icon: Could not render the correct icon with the name "${iconName}" because it does not exist in the "workflow" icon set. Rendering the placeholder icon instead.`); + iconName = "Circle"; } - /** - * Fallback UI Icon sizing number. - * - * If the icon name includes its scale, we want to leave that scale. This is preferred, - * as UI icons do not use workflow icon sizing. - * - * If the UI icon name does not include scale, reformat it to match the provided sizing. - * E.g. with a size of "s", the icon name "ChevronRight" would become "ChevronRight75". - */ + // Name of icon that corresponds with SVG file. This may differ from the icon name, such as with + // directional icons that use a single icon. + let iconNameToLoad = iconName; + + // If a descriptor like "Right", "Left", "Down", or "Up" is present for the UI icons Chevron or + // Arrow, use that only for the class name and not the icon fetch. This is because these use a + // single icon file that is rotated in CSS. if ( - setName == "ui" && - // Exists in the list of available UI icons. - uiIcons.includes(idKey.replace(/\d{2,3}$/, "")) && - // Does not already have size number at the end. - !idKey.match(/^(?!\d).*\d{2,3}$/) && - // Exclude some UI icons that do not (yet) have size numbers. - uiIconSizes[idKey]?.length != 0 + ["Right", "Left", "Down", "Up"].some((c) => iconNameToLoad.includes(c)) && + setName === "ui" ) { - let sizeVal; - switch (size) { - case "xs": - case "s": - sizeVal = "75"; - break; - case "l": - sizeVal = "200"; - break; - case "xl": - case "xxl": - sizeVal = "300"; - break; - default: - sizeVal = "100"; - break; - } - - idKey += sizeVal; - iconName += sizeVal; - } - - // Fetch SVG file markup, and set optional fill color. - let inlineStyle; - if (fill) inlineStyle = `color: ${fill}`; - - let svgString; - if (!useRef && icons && icons[setName]?.[scale]?.[idKey]) { - svgString = icons[setName][scale][idKey]; + iconNameToLoad = iconNameToLoad.replace(/(Right|Left|Down|Up)/, ""); } /** @@ -243,7 +107,6 @@ export const Template = ({ const classList = { [rootClass]: true, [`spectrum-UIIcon-${iconName}`]: !!(setName === "ui"), - [`${rootClass}--${scale}`]: !!(setName === "ui" && scale), [`${rootClass}--size${size?.toUpperCase()}`]: !!( (!setName || setName === "workflow") && size @@ -251,42 +114,122 @@ export const Template = ({ ...customClasses.reduce((a, c) => ({ ...a, [c]: true }), {}), }; - if (svgString) { - const classesAsString = Object.entries(classList).reduce((acc, [key, value]) => { - if (value) acc += `${key} `; - return acc; - }, ""); + const fillStyles = fill ? { + "--mod-icon-color": fill, + } : {}; + /** + * Display full SVG file markup from global IconLoader data, when not using a reference to the sprite sheet. + */ + if (!useRef) { + let svgString; + if (loaded?.icons && loaded?.icons[setName]?.[iconNameToLoad]) { + svgString = loaded.icons[setName][iconNameToLoad]; + } + + // Return the individual SVG's entire markup. + if (svgString) { + const classesAsString = Object.entries(classList).reduce((acc, [key, value]) => { + if (value) acc += `${key} `; + return acc; + }, ""); - return html`${unsafeSVG( - svgString.replace(/
    + ${when(args.setName === "workflow", () => { + return workflowIconsCleaned.map((iconName) => IconWithLabelTemplate({ ...args, iconName }, context)); + }, () => { + return uiIconsWithDirections.map((iconName) => IconWithLabelTemplate({ ...args, uiIconName: iconName }, context)); + })} +
    + `; +}; + +/** + * Display a single icon in the icon set with a label showing the icon name. + */ +export const IconWithLabelTemplate = (args, context) => html` +
    + ${Template({ + useRef: true, + size: "xxl", + setName: args.setName, + iconName: args?.iconName ?? undefined, + uiIconName: args?.uiIconName ?? undefined, + ...args, + }, context)} + ${Typography({ + customClasses: ["chromatic-ignore"], + semantics: "body", + size: "xxs", + content: [ + args.setName == "ui" ? args.uiIconName : args.iconName, + ], + })} +
    +`; + /** * Helper template function to display multiple icons using an array of icon names. */ -export const IconListTemplate = (args, iconsList = [], context) => html` +export const IconListTemplate = (args, context, iconsList = []) => html`
    html` })} > ${iconsList.map( - (iconName) => Template({ ...args, iconName }, context) + (iconName) => Template({ + ...args, + iconName: args?.setName === "workflow" ? iconName : undefined, + uiIconName: args?.setName === "ui" ? iconName : undefined, + }, context) )}
    `; /** - * A sampling of a few UI icons. + * Display examples of multiple workflow icons. */ -export const UIDefaultTemplate = (args, context) => html` -
    +export const WorkflowDefaultTemplate = (args, context) => html` ${IconListTemplate( { ...args, - setName: "ui", + setName: "workflow", + size: "xl", }, + context, [ - "Asterisk100", - "Asterisk200", - "Asterisk300", - ], - context + "AlertTriangle", + "Bell", + "Camera", + "Color", + "Copy", + "DeviceDesktop", + "Download", + "Draw", + "Files", + "Hand", + "Lightbulb", + "InfoCircle", + ] )} -
    -
    +`; + +/** + * Display examples of all directions of a single UI arrow. + */ +export const UIArrowsTemplate = (args, context) => html` ${IconListTemplate( { ...args, setName: "ui", }, + context, [ - "ChevronDown50", - "ChevronDown75", - "ChevronDown100", - "ChevronDown200", - "ChevronDown300", - "ChevronDown400", - ], - context + "ArrowRight100", + "ArrowLeft100", + "ArrowDown100", + "ArrowUp100", + ] )} -
    +`; + +/** + * Display examples of multiple UI icons. + */ +export const UIDefaultTemplate = (args, context) => html` +
    + ${IconListTemplate( + { + ...args, + setName: "ui", + }, + context, + [ + "Asterisk100", + "Asterisk200", + "Asterisk300", + ] + )} +
    +
    + ${IconListTemplate( + { + ...args, + setName: "ui", + }, + context, + [ + "ChevronDown50", + "ChevronDown75", + "ChevronDown100", + "ChevronDown200", + "ChevronDown300", + "ChevronDown400", + ] + )} +
    `; diff --git a/components/icon/stories/utilities.js b/components/icon/stories/utilities.js index d4219af7974..16faf30eaa3 100644 --- a/components/icon/stories/utilities.js +++ b/components/icon/stories/utilities.js @@ -1,44 +1,216 @@ -// Imports an array of all icon names in the workflow set -import iconOpts from "@adobe/spectrum-css-workflow-icons"; +// Import arrays containing data with all icon names in both icon sets. +import workflowIconOpts from "@adobe/spectrum-css-workflow-icons/dist/manifest.json"; +import uiIconOpts from "@spectrum-css/ui-icons/dist/icons.json"; -export const workflowIcons = (iconOpts || []).map((icon) => - icon.replace(/\.svg$/, "") +/** + * Clean workflow icon name to strip out unnecessary prefix and postfix text. + * Also removes file extension if present. + * Example: "S2_Icon_AlertCircle_20_N" becomes "AlertCircle" + * + * @param {string} iconName + * @returns {string} + */ +export const cleanWorkflowIconName = (iconName) => ( + iconName.replace(/\.svg$/, "").replace(/^S2_Icon_/, "").replace(/_N$/, "").replace(/_20$/, "") +); + +/** + * Clean UI icon name to remove file extension and any unnecessary text. + * + * @param {string} iconName + * @returns {string} + */ +export const cleanUiIconName = (iconName) => ( + iconName.replace(/\.svg$/, "") ); /** - * UI Icons have specific sizes represented by a number. - * Each size has its own individual file and a CSS class with defined dimensions. - */ -export const uiIconSizes = { - "Arrow": ["75","100","200","300","400","500","600"], - "Asterisk": ["75","100","200","300"], - "Checkmark": ["50","75","100","200","300","400","500","600"], - "Chevron": ["50","75","100","200","300","400","500"], - "CornerTriangle": ["75","100","200","300"], - "Cross": ["75","100","200","300","400","500","600"], - "Dash": ["50","75","100","200","300","400","500","600"], - "SingleGripper": [], - "DoubleGripper": [], - "TripleGripper": [], + * Get the ID of the icon within the sprite sheet. + * + * The sprite sheets are single SVG files containing all of the icons in the set, each with a + * unique ID. The ID can then be used to display the icon elsewhere by referencing the ID + * within an SVG element. + * + * Example of the format of IDs within the different sprite sheets: + * ui ID: #spectrum-css-icon-alert-triangle + * workflow ID: #icon-spectrum-css-icon-Arrow100 + * + * @param {string} iconName Icon name (original or cleaned). + * @param {string} setName Icon set. + * @returns {string} Icon name with original file name prefix and postfix added. + */ +export const getSpriteSheetName = (iconName, setName) => { + if (setName == "ui") { + return "spectrum-css-icon-" + iconName; + } + else if (setName == "workflow") { + // Use cleaned name, without file name prefix/postfix. + let iconID = cleanWorkflowIconName(iconName); + + // These regexes convert camel case or pascal case strings into kebab-case: + // ------- + // Matches a lowercase letter or digit followed by an uppercase letter and inserts a hyphen between them. + // E.g. "AddCircle" becomes "Add-Circle". + // Digits are included in the first grouping because of the exception of "3D" being "3-d" in the IDs. + iconID = iconID.replaceAll(/([a-z0-9])([A-Z])/g, "$1-$2"); + + // Matches an uppercase sequence followed by an uppercase letter with a lowercase letter. + // Replacing this separately helps prevent uppercase acronyms like CC and CCW from being split up by dashes. + iconID = iconID.replaceAll(/([A-Z]+)([A-Z][a-z])/g, "$1-$2"); + // ------- + + // Underscores become dashes. + iconID = iconID.replace("_", "-"); + + // All IDs begin with this prefix and are lowercase. + iconID = "icon-" + iconID.toLowerCase(); + + return iconID; + } + else { + console.error("setSpriteSheetName received an invalid setName and could not create the ID."); + return ""; + } }; /** - * List of UI icon names, corresponding to files. + * Sorted array with all the SVG workflow icon names, cleaned to remove file extension and + * unnecessary prefix and postfix text. These might look something like "3DAsset". + * + * Excludes 22x20 icons, which currently do not match workflow icon sizing. */ -export const uiIcons = Object.keys(uiIconSizes); +export const workflowIconsCleaned = (workflowIconOpts?.svg ?? []) + .filter(iconName => !iconName.includes("22x20")) + .map(iconName => cleanWorkflowIconName(iconName)) + .sort(alphaNumericSort); /** - * List of all UI icon names for CSS. Chevron and Arrow have directional suffixes + * Sorted array with all UI icon names, without the file extension. + */ +export const uiIconsCleaned = (uiIconOpts || []) + .map(iconName => cleanUiIconName(iconName)) + .sort(alphaNumericSort); + +/** + * @description A custom alpha-numeric sort that helps keep the order of the sizing numbers at the end of the string. + * @param {string} a + * @param {string} b + * @returns {number} + */ +function alphaNumericSort(a, b) { + const aSet = a.match(/^([a-zA-Z]+)([0-9]+)(\.svg)?$/i); + const bSet = b.match(/^([a-zA-Z]+)([0-9]+)(\.svg)?$/i); + + // Handle cases where match fails + if (!aSet || !bSet) return 0; + + // Compare characters at start of string (case-insensitive) + const aChar = aSet[1].toLowerCase(); + const bChar = bSet[1].toLowerCase(); + if (aChar !== bChar) return aChar > bChar ? 1 : -1; + + // Compare numbers at end of string + const aInt = parseInt(aSet[2]); + const bInt = parseInt(bSet[2]); + return aInt - bInt; +} + +/** + * Array of all UI icon names for CSS. Chevron and Arrow have directional suffixes * for rotating the same base icon, e.g. Arrow becomes ArrowRight, ArrowDown, etc. + * + * @param {string[]} uiIcons Array of icon names. + * @returns {string[]} + */ +export const getUiIconsWithDirections = (uiIcons) => [ + ...uiIcons.filter((c) => !["Chevron", "Arrow"].some(prefix => c.startsWith(prefix))), + ...uiIcons.filter((c) => ["Chevron", "Arrow"].some(prefix => c.startsWith(prefix))).map(i => i.replace(/(Chevron|Arrow)(\d{2,3})/, "$1Right$2")), + ...uiIcons.filter((c) => ["Chevron", "Arrow"].some(prefix => c.startsWith(prefix))).map(i => i.replace(/(Chevron|Arrow)(\d{2,3})/, "$1Left$2")), + ...uiIcons.filter((c) => ["Chevron", "Arrow"].some(prefix => c.startsWith(prefix))).map(i => i.replace(/(Chevron|Arrow)(\d{2,3})/, "$1Up$2")), + ...uiIcons.filter((c) => ["Chevron", "Arrow"].some(prefix => c.startsWith(prefix))).map(i => i.replace(/(Chevron|Arrow)(\d{2,3})/, "$1Down$2")), +].sort(alphaNumericSort); + +/** + * Array of all cleaned UI icon names for CSS. Including sizing numbers and directional suffixes. */ -export const uiIconsWithDirections = [ - ...uiIcons.filter((c) => !["Chevron", "Arrow"].includes(c)), - "ArrowRight", - "ArrowLeft", - "ArrowUp", - "ArrowDown", - "ChevronRight", - "ChevronLeft", - "ChevronUp", - "ChevronDown", +export const uiIconsWithDirections = getUiIconsWithDirections(uiIconsCleaned); + +/** + * Array of all unique base UI icon names without their sizing numbers. + */ +export const getUniqueUiIconBaseNames = (uiIcons) => [ + ...new Set(uiIcons.map(ui => ui.replace(/\d{2,3}$/, ""))) ]; + +/** + * Array of all base UI icon names (without sizing numbers) for CSS (including directional suffixes). + */ +export const uniqueUiIconBaseNames = getUniqueUiIconBaseNames(uiIconsWithDirections); + +/** + * Workflow icon sizes. Does not apply to UI icons. Note: XXL is not part of the design + * spec and may be deprecated in the future. + */ +export const workflowSizes = ["xs", "s", "m", "l", "xl", "xxl"]; + +/** + * Create an object where the key is the UI icon name, and the value is an array of + * strings with every sizing number available. + * + * Returns something like the following: + * { + * "Arrow": ['100', '400'], + * "Asterisk": ['100', '200', '300'], + * ... + * } + * + * @param {string[]} uiIcons Array of all UI icon names. + * @returns {object} + */ +export const getUiIconSizes = (uiIcons) => { + let uiIconSizes = {}; + + uiIcons.forEach(iconName => { + // UI icon name without the sizing number at the end. + const iconNameRoot = iconName.replace(/\d{2,3}$/, ""); + + // Sizing number at the end of the icon name (e.g. "100"). + const iconNameSize = iconName.match(/\d{2,3}/g)?.[0]; + + // Add to object (with no duplicates). + uiIconSizes[iconNameRoot] = [ + ...new Set([ + ...uiIconSizes[iconNameRoot] ?? [], + ...(iconNameSize ? [iconNameSize] : []), + ]) + ]; + }); + + return uiIconSizes; +}; + +export const uiIconSizes = getUiIconSizes(uiIconsWithDirections); + +/** + * If UI icon name does not have a sizing number appended, add one to approximate the provided + * t-shirt sizing for the component, based on the most common mapping. + * + * @param {string} uiIconName + * @param {string} size t-shirt sizing + * @returns {string} uiIconName with appended default sizing number, if one is not already present. + */ +export const appendUiIconDefaultSizing = (uiIconName, size = "m") => { + // If icon name already has a size number on the end, no change is needed. + if (uiIconName.match(/\d{2,3}$/)) { + return uiIconName; + } + + return uiIconName + ({ + xs: "50", + s: "75", + m: "100", + l: "200", + xl: "300", + xxl: "400", + }[size] || "100"); +}; diff --git a/components/icon/ui-icons.css b/components/icon/ui-icons.css index ce39d50ea8c..40ac2f7404f 100644 --- a/components/icon/ui-icons.css +++ b/components/icon/ui-icons.css @@ -11,22 +11,6 @@ * governing permissions and limitations under the License. */ -/* - * Medium/large scale - * ------------------ - * In the "combined" versiom of the UI Icon SVGs, the medium and the large icons are - * contained within the same SVG. The two separate elements are shown or hidden based - * on the current platform scale. - */ - -.spectrum-UIIcon--medium { - display: var(--mod-ui-icon-medium-display, var(--spectrum-ui-icon-medium-display, block)); -} - -.spectrum-UIIcon--large { - display: var(--mod-ui-icon-large-display, var(--spectrum-ui-icon-large-display, none)); -} - /* * UI icons list * ------------- @@ -430,3 +414,67 @@ .spectrum-UIIcon-Asterisk300 { --spectrum-icon-size: var(--spectrum-asterisk-icon-size-300); } + +/* Add */ +.spectrum-UIIcon-Add50 { + --spectrum-icon-size: var(--spectrum-add-icon-size-50); +} + +.spectrum-UIIcon-Add75 { + --spectrum-icon-size: var(--spectrum-add-icon-size-75); +} + +.spectrum-UIIcon-Add100 { + --spectrum-icon-size: var(--spectrum-add-icon-size-100); +} + +.spectrum-UIIcon-Add200 { + --spectrum-icon-size: var(--spectrum-add-icon-size-200); +} + +.spectrum-UIIcon-Add300 { + --spectrum-icon-size: var(--spectrum-add-icon-size-300); +} + +/* Drag handle */ +.spectrum-UIIcon-DragHandle75 { + --spectrum-icon-size: var(--spectrum-drag-handle-icon-size-75); +} + +.spectrum-UIIcon-DragHandle100 { + --spectrum-icon-size: var(--spectrum-drag-handle-icon-size-100); +} + +.spectrum-UIIcon-DragHandle200 { + --spectrum-icon-size: var(--spectrum-drag-handle-icon-size-200); +} + +.spectrum-UIIcon-DragHandle300 { + --spectrum-icon-size: var(--spectrum-drag-handle-icon-size-300); +} + +/* Gripper */ +.spectrum-UIIcon-Gripper100 { + --spectrum-icon-size: var(--spectrum-gripper-icon-size-100); +} + +/* Link out */ +.spectrum-UIIcon-LinkOut75 { + --spectrum-icon-size: var(--spectrum-link-out-icon-size-75); +} + +.spectrum-UIIcon-LinkOut100 { + --spectrum-icon-size: var(--spectrum-link-out-icon-size-100); +} + +.spectrum-UIIcon-LinkOut200 { + --spectrum-icon-size: var(--spectrum-link-out-icon-size-200); +} + +.spectrum-UIIcon-LinkOut300 { + --spectrum-icon-size: var(--spectrum-link-out-icon-size-300); +} + +.spectrum-UIIcon-LinkOut400 { + --spectrum-icon-size: var(--spectrum-link-out-icon-size-400); +} diff --git a/components/illustratedmessage/CHANGELOG.md b/components/illustratedmessage/CHANGELOG.md index bc4c87eca31..6a81047f762 100644 --- a/components/illustratedmessage/CHANGELOG.md +++ b/components/illustratedmessage/CHANGELOG.md @@ -1,5 +1,13 @@ # Change log +## 10.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + - @spectrum-css/typography@9.0.0-next.0 + ## 9.2.0 ### Minor Changes diff --git a/components/illustratedmessage/dist/metadata.json b/components/illustratedmessage/dist/metadata.json index 24de798ac33..12705f6822e 100644 --- a/components/illustratedmessage/dist/metadata.json +++ b/components/illustratedmessage/dist/metadata.json @@ -2,7 +2,18 @@ "sourceFile": "index.css", "selectors": [ ".spectrum-IllustratedMessage", - ".spectrum-IllustratedMessage-accent", + ".spectrum-IllustratedMessage--horizontal", + ".spectrum-IllustratedMessage--horizontal .spectrum-IllustratedMessage-illustration", + ".spectrum-IllustratedMessage--sizeL", + ".spectrum-IllustratedMessage--sizeL:lang(ja)", + ".spectrum-IllustratedMessage--sizeL:lang(ko)", + ".spectrum-IllustratedMessage--sizeL:lang(zh)", + ".spectrum-IllustratedMessage--sizeS", + ".spectrum-IllustratedMessage--sizeS:lang(ja)", + ".spectrum-IllustratedMessage--sizeS:lang(ko)", + ".spectrum-IllustratedMessage--sizeS:lang(zh)", + ".spectrum-IllustratedMessage-actions", + ".spectrum-IllustratedMessage-content", ".spectrum-IllustratedMessage-description", ".spectrum-IllustratedMessage-heading", ".spectrum-IllustratedMessage-illustration", @@ -11,23 +22,24 @@ ".spectrum-IllustratedMessage:lang(zh)" ], "modifiers": [ - "--mod-illustrated-message-content-maximum-width", "--mod-illustrated-message-description-color", "--mod-illustrated-message-description-font-family", "--mod-illustrated-message-description-font-size", "--mod-illustrated-message-description-font-style", "--mod-illustrated-message-description-font-weight", "--mod-illustrated-message-description-line-height", - "--mod-illustrated-message-description-max-inline-size", "--mod-illustrated-message-description-pointer-events", "--mod-illustrated-message-description-position", + "--mod-illustrated-message-description-to-action", "--mod-illustrated-message-description-z-index", "--mod-illustrated-message-display", - "--mod-illustrated-message-heading-max-inline-size", - "--mod-illustrated-message-heading-to-body", "--mod-illustrated-message-heading-to-description", - "--mod-illustrated-message-illustration-accent-color", + "--mod-illustrated-message-horizontal-maximum-width", + "--mod-illustrated-message-illustrated-inline-size", + "--mod-illustrated-message-illustration-block-size", "--mod-illustrated-message-illustration-color", + "--mod-illustrated-message-illustration-size", + "--mod-illustrated-message-illustration-to-heading", "--mod-illustrated-message-pointer-events", "--mod-illustrated-message-title-color", "--mod-illustrated-message-title-font-family", @@ -35,51 +47,55 @@ "--mod-illustrated-message-title-font-style", "--mod-illustrated-message-title-font-weight", "--mod-illustrated-message-title-line-height", - "--mod-illustrated-message-title-to-heading" + "--mod-illustrated-message-vertical-maximum-width" ], "component": [ - "--spectrum-illustrated-message-body-size", - "--spectrum-illustrated-message-cjk-title-size", "--spectrum-illustrated-message-description-color", "--spectrum-illustrated-message-description-font-family", "--spectrum-illustrated-message-description-font-size", "--spectrum-illustrated-message-description-font-style", "--spectrum-illustrated-message-description-font-weight", "--spectrum-illustrated-message-description-line-height", - "--spectrum-illustrated-message-description-max-inline-size", - "--spectrum-illustrated-message-heading-max-inline-size", + "--spectrum-illustrated-message-description-to-action", "--spectrum-illustrated-message-heading-to-description", - "--spectrum-illustrated-message-illustration-accent-color", + "--spectrum-illustrated-message-horizontal-maximum-width", "--spectrum-illustrated-message-illustration-color", - "--spectrum-illustrated-message-maximum-width", + "--spectrum-illustrated-message-illustration-size", + "--spectrum-illustrated-message-illustration-to-content", + "--spectrum-illustrated-message-illustration-to-heading", + "--spectrum-illustrated-message-large-body-font-size", + "--spectrum-illustrated-message-large-cjk-title-font-size", + "--spectrum-illustrated-message-large-title-font-size", + "--spectrum-illustrated-message-medium-body-font-size", + "--spectrum-illustrated-message-medium-cjk-title-font-size", + "--spectrum-illustrated-message-medium-title-font-size", + "--spectrum-illustrated-message-small-body-font-size", + "--spectrum-illustrated-message-small-cjk-title-font-size", + "--spectrum-illustrated-message-small-title-font-size", "--spectrum-illustrated-message-title-color", "--spectrum-illustrated-message-title-font-family", "--spectrum-illustrated-message-title-font-size", "--spectrum-illustrated-message-title-font-style", "--spectrum-illustrated-message-title-font-weight", "--spectrum-illustrated-message-title-line-height", - "--spectrum-illustrated-message-title-size", - "--spectrum-illustrated-message-title-to-heading" + "--spectrum-illustrated-message-vertical-maximum-width" ], "global": [ - "--spectrum-accent-visual-color", "--spectrum-body-color", - "--spectrum-body-line-height", "--spectrum-body-sans-serif-font-style", "--spectrum-body-sans-serif-font-weight", "--spectrum-heading-color", - "--spectrum-heading-line-height", - "--spectrum-heading-sans-serif-font-style", - "--spectrum-heading-sans-serif-font-weight", - "--spectrum-neutral-visual-color", + "--spectrum-line-height-200", + "--spectrum-neutral-content-color-default", "--spectrum-sans-font-family-stack", - "--spectrum-spacing-400", - "--spectrum-spacing-75" + "--spectrum-spacing-100", + "--spectrum-spacing-200", + "--spectrum-spacing-300", + "--spectrum-spacing-75", + "--spectrum-title-line-height", + "--spectrum-title-sans-serif-font-style", + "--spectrum-title-sans-serif-font-weight" ], - "system-theme": [], - "passthroughs": [], - "high-contrast": [ - "--highcontrast-illustrated-message-illustration-accent-color", - "--highcontrast-illustrated-message-illustration-color" - ] + "passthroughs": ["--mod-buttongroup-justify-content"], + "high-contrast": ["--highcontrast-illustrated-message-illustration-color"] } diff --git a/components/illustratedmessage/index.css b/components/illustratedmessage/index.css index 6b588504d11..39894c695a1 100644 --- a/components/illustratedmessage/index.css +++ b/components/illustratedmessage/index.css @@ -1,82 +1,96 @@ /*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ +Copyright 2024 Adobe. All rights reserved. +This file is licensed to you under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. You may obtain a copy +of the License at http://www.apache.org/licenses/LICENSE-2.0 -@media (forced-colors: active) { - .spectrum-IllustratedMessage { - --highcontrast-illustrated-message-illustration-color: CanvasText; - --highcontrast-illustrated-message-illustration-accent-color: Highlight; - } -} +Unless required by applicable law or agreed to in writing, software distributed under +the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS +OF ANY KIND, either express or implied. See the License for the specific language +governing permissions and limitations under the License. +*/ .spectrum-IllustratedMessage { /* Size & Spacing */ - --spectrum-illustrated-message-description-max-inline-size: var(--spectrum-illustrated-message-maximum-width); - --spectrum-illustrated-message-heading-max-inline-size: var(--spectrum-illustrated-message-maximum-width); - --spectrum-illustrated-message-title-to-heading: var(--spectrum-spacing-400); --spectrum-illustrated-message-heading-to-description: var(--spectrum-spacing-75); + --spectrum-illustrated-message-illustration-to-heading: var(--spectrum-spacing-200); + --spectrum-illustrated-message-illustration-to-content: var(--spectrum-spacing-200); + --spectrum-illustrated-message-description-to-action: var(--spectrum-spacing-300); + /* @passthrough -- settings for nested button group */ + --mod-buttongroup-justify-content: center; /* Illustration */ - --spectrum-illustrated-message-illustration-color: var(--spectrum-neutral-visual-color); - --spectrum-illustrated-message-illustration-accent-color: var(--spectrum-accent-visual-color); + --spectrum-illustrated-message-illustration-color: var(--spectrum-neutral-content-color-default); + --spectrum-illustrated-message-illustration-size: 96px; /* Title */ --spectrum-illustrated-message-title-font-family: var(--spectrum-sans-font-family-stack); - --spectrum-illustrated-message-title-font-weight: var(--spectrum-heading-sans-serif-font-weight); - --spectrum-illustrated-message-title-font-style: var(--spectrum-heading-sans-serif-font-style); - --spectrum-illustrated-message-title-font-size: var(--spectrum-illustrated-message-title-size); - --spectrum-illustrated-message-title-line-height: var(--spectrum-heading-line-height); + --spectrum-illustrated-message-title-font-weight: var(--spectrum-title-sans-serif-font-weight); + --spectrum-illustrated-message-title-font-style: var(--spectrum-title-sans-serif-font-style); + --spectrum-illustrated-message-title-font-size: var(--spectrum-illustrated-message-medium-title-font-size); + --spectrum-illustrated-message-title-line-height: var(--spectrum-title-line-height); --spectrum-illustrated-message-title-color: var(--spectrum-heading-color); /* Description */ --spectrum-illustrated-message-description-font-family: var(--spectrum-sans-font-family-stack); --spectrum-illustrated-message-description-font-weight: var(--spectrum-body-sans-serif-font-weight); --spectrum-illustrated-message-description-font-style: var(--spectrum-body-sans-serif-font-style); - --spectrum-illustrated-message-description-font-size: var(--spectrum-illustrated-message-body-size); - --spectrum-illustrated-message-description-line-height: var(--spectrum-body-line-height); + --spectrum-illustrated-message-description-font-size: var(--spectrum-illustrated-message-medium-body-font-size); + --spectrum-illustrated-message-description-line-height: var(--spectrum-line-height-200); --spectrum-illustrated-message-description-color: var(--spectrum-body-color); - block-size: 100%; - - display: var(--mod-illustrated-message-display, flex); - flex-direction: column; - align-items: center; - justify-content: center; + /* CJK (Chinese, Japanese, and Korean) language support */ + &:lang(ja), + &:lang(zh), + &:lang(ko) { + --spectrum-illustrated-message-title-font-size: var(--spectrum-illustrated-message-medium-cjk-title-font-size); + } +} - text-align: center; - pointer-events: var(--mod-illustrated-message-pointer-events, auto); - max-inline-size: var(--mod-illustrated-message-content-maximum-width); +.spectrum-IllustratedMessage--sizeS { + --spectrum-illustrated-message-title-font-size: var(--spectrum-illustrated-message-small-title-font-size); + --spectrum-illustrated-message-description-font-size: var(--spectrum-illustrated-message-small-body-font-size); - /* CJK (Chinese, Japanese, and Korean) language support */ &:lang(ja), &:lang(zh), &:lang(ko) { - --spectrum-illustrated-message-title-font-size: var(--spectrum-illustrated-message-cjk-title-size); + --spectrum-illustrated-message-title-font-size: var(--spectrum-illustrated-message-small-cjk-title-font-size); } } -.spectrum-IllustratedMessage-illustration { - margin-block-end: var(--mod-illustrated-message-title-to-heading, var(--spectrum-illustrated-message-title-to-heading)); - color: var(--highcontrast-illustrated-message-illustration-color, var(--mod-illustrated-message-illustration-color, var(--spectrum-illustrated-message-illustration-color))); - fill: currentColor; - stroke: currentColor; +.spectrum-IllustratedMessage--sizeL { + --spectrum-illustrated-message-illustration-size: 160px; + --spectrum-illustrated-message-illustration-to-heading: var(--spectrum-spacing-100); + --spectrum-illustrated-message-illustration-to-content: var(--spectrum-spacing-100); + --spectrum-illustrated-message-title-font-size: var(--spectrum-illustrated-message-large-title-font-size); + --spectrum-illustrated-message-description-font-size: var(--spectrum-illustrated-message-large-body-font-size); + + &:lang(ja), + &:lang(zh), + &:lang(ko) { + --spectrum-illustrated-message-title-font-size: var(--spectrum-illustrated-message-large-cjk-title-font-size); + } } -.spectrum-IllustratedMessage-accent { - color: var(--highcontrast-illustrated-message-illustration-accent-color, var(--mod-illustrated-message-illustration-accent-color, var(--spectrum-illustrated-message-illustration-accent-color))); +.spectrum-IllustratedMessage { + block-size: 100%; + display: var(--mod-illustrated-message-display, grid); + grid-template-areas: + ". illustration ." + "body body body"; + text-align: center; + pointer-events: var(--mod-illustrated-message-pointer-events, auto); + max-inline-size: var(--mod-illustrated-message-vertical-maximum-width, var(--spectrum-illustrated-message-vertical-maximum-width)); +} - /* Safari 16.3 🐛🛠️: Repeated stroke/fill properties is a workaround for a currentcolor bug that was fixed in 16.4. */ +.spectrum-IllustratedMessage-illustration { + margin-block-end: var(--mod-illustrated-message-illustration-to-heading, var(--spectrum-illustrated-message-illustration-to-heading)); + color: var(--highcontrast-illustrated-message-illustration-color, var(--mod-illustrated-message-illustration-color, var(--spectrum-illustrated-message-illustration-color))); fill: currentColor; stroke: currentColor; + block-size: var(--mod-illustrated-message-illustration-block-size, var(--mod-illustrated-message-illustration-size, var(--spectrum-illustrated-message-illustration-size))); + inline-size: var(--mod-illustrated-message-illustrated-inline-size, var(--mod-illustrated-message-illustration-size, var(--spectrum-illustrated-message-illustration-size))); + grid-area: illustration; } .spectrum-IllustratedMessage-heading { @@ -88,9 +102,8 @@ color: var(--mod-illustrated-message-title-color, var(--spectrum-illustrated-message-title-color)); - max-inline-size: var(--mod-illustrated-message-heading-max-inline-size, var(--spectrum-illustrated-message-heading-max-inline-size)); margin-block-start: 0; - margin-block-end: var(--mod-illustrated-message-heading-to-body, 0); + margin-block-end: var(--mod-illustrated-message-heading-to-description, var(--spectrum-illustrated-message-heading-to-description)); } .spectrum-IllustratedMessage-description { @@ -106,7 +119,32 @@ color: var(--mod-illustrated-message-description-color, var(--spectrum-illustrated-message-description-color)); - max-inline-size: var(--mod-illustrated-message-description-max-inline-size, var(--spectrum-illustrated-message-description-max-inline-size)); - margin-block-start: var(--mod-illustrated-message-heading-to-description, var(--spectrum-illustrated-message-heading-to-description)); - margin-block-end: 0; + margin-block: 0; +} + +.spectrum-IllustratedMessage--horizontal { + --mod-buttongroup-justify-content: flex-start; + max-inline-size: var(--mod-illustrated-message-horizontal-maximum-width, var(--spectrum-illustrated-message-horizontal-maximum-width)); + text-align: start; + gap: var(--spectrum-illustrated-message-illustration-to-content); + grid-template-areas: "illustration body"; + align-items: center; + + .spectrum-IllustratedMessage-illustration { + margin-block-end: 0; + } +} + +.spectrum-IllustratedMessage-actions { + margin-block-start: var(--mod-illustrated-message-description-to-action, var(--spectrum-illustrated-message-description-to-action)); +} + +.spectrum-IllustratedMessage-content { + grid-area: body; +} + +@media (forced-colors: active) { + .spectrum-IllustratedMessage { + --highcontrast-illustrated-message-illustration-color: CanvasText; + } } diff --git a/components/illustratedmessage/package.json b/components/illustratedmessage/package.json index 8fe6530be81..0bef8f134ae 100644 --- a/components/illustratedmessage/package.json +++ b/components/illustratedmessage/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/illustratedmessage", - "version": "9.2.0", + "version": "10.0.0-next.0", "description": "The Spectrum CSS illustratedmessage component", "license": "Apache-2.0", "author": "Adobe", @@ -24,8 +24,8 @@ }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/tokens": ">=16.0.0 <17.0.0", - "@spectrum-css/typography": ">=8.0.0 <9.0.0" + "@spectrum-css/tokens": ">=16.1.0-next.0", + "@spectrum-css/typography": ">=9.0.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/tokens": { @@ -36,8 +36,8 @@ } }, "devDependencies": { - "@spectrum-css/tokens": "16.0.2", - "@spectrum-css/typography": "8.2.0" + "@spectrum-css/tokens": "16.1.0-next.10", + "@spectrum-css/typography": "9.0.0-next.0" }, "keywords": [ "design-system", diff --git a/components/illustratedmessage/stories/illustratedmessage.stories.js b/components/illustratedmessage/stories/illustratedmessage.stories.js index 2b00b063d31..76510f582c9 100644 --- a/components/illustratedmessage/stories/illustratedmessage.stories.js +++ b/components/illustratedmessage/stories/illustratedmessage.stories.js @@ -1,20 +1,38 @@ -import { Template as Link } from "@spectrum-css/link/stories/template.js"; +import { Sizes } from "@spectrum-css/preview/decorators"; import { disableDefaultModes } from "@spectrum-css/preview/modes"; -import { html } from "lit"; import metadata from "../dist/metadata.json"; import packageJson from "../package.json"; import { IllustratedMessageGroup } from "./illustratedmessage.test.js"; import { Template } from "./template.js"; /** - * The Illustrated Message displays an illustration along with a heading and description. Optionally, part of the illustration can use an accent color. It can be used for status and errors, or as a call to action. For example, the Drop Zone component makes use of Illustrated Message as an area to drag and drop files. + * The Illustrated Message displays an illustration along with a heading, description and group of buttons. It can be used for status and errors, or as a call to action. For example, the Drop Zone component makes use of Illustrated Message as an area to drag and drop files. */ export default { title: "Illustrated message", component: "IllustratedMessage", argTypes: { - useAccentColor: { - name: "Illustration accent color", + title: { + name: "Title", + type: { name: "string" }, + table: { + type: { summary: "string" }, + category: "Content", + }, + control: "text", + }, + description: { + name: "Description", + type: { name: "string" }, + table: { + type: { summary: "string" }, + category: "Content", + }, + control: "text", + }, + isHorizontal: { + name: "Horizontal orientation", + description: "The default content orientation is vertical. Add the horizontal class to horizontally align the illustration with the content. The illustration will align left or right determined by the global direction of the text.", type: { name: "boolean" }, table: { type: { summary: "boolean" }, @@ -22,60 +40,61 @@ export default { }, control: "boolean", }, - heading: { - name: "Heading", - type: { name: "string" }, + size: { + name: "Size", + type: { name: "string", required: true }, table: { type: { summary: "string" }, - category: "Content", + category: "Component", }, - control: "text", + options: ["s", "m", "l"], + control: "select", }, - description: { - name: "Description", + hasButtons: { + name: "Show button group", + type: { name: "boolean" }, table: { - category: "Content", - disable: true, + type: { summary: "boolean" }, + category: "Component", }, + control: "boolean", }, }, args: { rootClass: "spectrum-IllustratedMessage", - useAccentColor: false, + isHorizontal: false, + size: "m", + hasButtons: true, + title: "Error 404: Page not found", + description: "This page isn't available. Try checking the URL or visit a different page.", }, parameters: { + layout: "centered", design: { type: "figma", url: "https://www.figma.com/design/Mngz9H7WZLbrCvGQf3GnsY/S2-%2F-Desktop?node-id=20032-601", }, packageJson, metadata, + status: { + type: "migrated", + }, }, + tags: ["migrated"], }; export const Default = IllustratedMessageGroup.bind({}); -Default.args = { - heading: "Error 404: Page not found", - description: [ - "This page isn't available. Try checking the URL or visit a different page.", - ], -}; +Default.args = {}; /** - * To use the accent color, the class `.spectrum-IllustratedMessage-accent` can be added to element(s) within the illustration SVG. - */ -export const AccentColor = Template.bind({}); -AccentColor.tags = ["!dev"]; -AccentColor.args = { - heading: "Drag and drop your file", - description: [ - () => { - return html`${Link({ url: "#", text: "Select a file" })} from your computer.`; - }, - ], - useAccentColor: true, + * Horizontal illustrated messages are displayed on extra large screen sizes or in a menu. +*/ +export const Horizontal = Template.bind({}); +Horizontal.tags = ["!dev"]; +Horizontal.args = { + isHorizontal: true }; -AccentColor.parameters = { +Horizontal.parameters = { chromatic: { disableSnapshot: true }, }; @@ -88,3 +107,21 @@ WithForcedColors.parameters = { modes: disableDefaultModes }, }; +/** + * Illustrated message comes in three sizes: small, medium, and large. + * - Small illustrated message is typically used in quick or in-line actions. + * - The medium size is the default, and often used in panels. + * - The large size illustrated message is generally used in full page layouts and dialogs. + */ +export const Sizing = (args, context) => Sizes({ + Template: Template, + withBorder: false, + withHeader: false, + ...args +}, context); + +Sizing.args = {}; +Sizing.tags = ["!dev"]; +Sizing.parameters = { + chromatic: { disableSnapshot: true }, +}; diff --git a/components/illustratedmessage/stories/illustratedmessage.test.js b/components/illustratedmessage/stories/illustratedmessage.test.js index 2b7b85946a1..a6da8059521 100644 --- a/components/illustratedmessage/stories/illustratedmessage.test.js +++ b/components/illustratedmessage/stories/illustratedmessage.test.js @@ -1,25 +1,17 @@ -import { Template as Link } from "@spectrum-css/link/stories/template.js"; import { Variants } from "@spectrum-css/preview/decorators"; -import { html } from "lit"; import { Template } from "./template.js"; export const IllustratedMessageGroup = Variants({ Template, testData: [{ - heading: "Error 404: Page not found", - description: [ - "This page isn't available. Try checking the URL or visit a different page.", - ], - useAccentColor: false, - }, { - testHeading: "With accent color", - heading: "Drag and drop your file", - description: [ - () => { - return html`${Link({ url: "#", text: "Select a file" })} from your computer.`; - }, - ], - useAccentColor: true, - } + }, + { + testHeading: "Horizontal layout", + isHorizontal: true + }, + { + testHeading: "W/o button group", + hasButtons: false + }, ], }); diff --git a/components/illustratedmessage/stories/template.js b/components/illustratedmessage/stories/template.js index ace824ddae9..8ee5daa77b0 100644 --- a/components/illustratedmessage/stories/template.js +++ b/components/illustratedmessage/stories/template.js @@ -1,4 +1,4 @@ -import { Template as Typography } from "@spectrum-css/typography/stories/template.js"; +import { Template as ButtonGroup } from "@spectrum-css/buttongroup/stories/template.js"; import { html } from "lit"; import { classMap } from "lit/directives/class-map.js"; import { when } from "lit/directives/when.js"; @@ -7,111 +7,76 @@ import "../index.css"; export const Template = ({ rootClass = "spectrum-IllustratedMessage", - heading, + title, description, customClasses = [], - useAccentColor = false, -} = {}, context = {}) => { + hasButtons = false, + isHorizontal = false, + size = "m", + customIllustration, +}) => { + const descriptionContent = Array.isArray(description) + ? description + : [() => html`${description}`]; return html` -
    ({ ...a, [c]: true }), {}), - })} - > - ${illustrationSvgMarkup(useAccentColor)} - ${when(heading, () => - Typography({ - semantics: "heading", - "size": "m", - customClasses: [`${rootClass}-heading`], - content: [heading], - }, context) +
    ({ ...a, [c]: true }), {}), + })} + > + ${customIllustration + ? customIllustration() + : illustrationSvgMarkup(size)} +
    + ${when( + title, + () => + html`

    + ${title} +

    ` )} - ${when(description, () => - Typography({ - semantics: "body", - "size": "s", - customClasses: [`${rootClass}-description`], - content: [ - ...description.map((c) => (typeof c === "function" ? c({}) : c)) - ], - }, context) + ${when( + descriptionContent, + () => + html`

    + ${descriptionContent.map((c) => + typeof c === "function" ? c({}) : c + )} +

    ` + )} + ${when(hasButtons, () => + ButtonGroup({ + size, + customClasses: ["spectrum-IllustratedMessage-actions"], + items: [ + { + variant: "secondary", + treatment: "outline", + label: "Remind me later", + }, + { + variant: "accent", + treatment: "fill", + label: "Rate now", + }, + ] + }) )}
    - `; +
    +`; }; -const illustrationSvgMarkup = (withAccentColorClass = false) => html` - - - - - - - - - - - - - - - -`; +const illustrationSvgMarkup = (size = "m") => { + const computedSize = size === "l" ? 160 : 96; + return html` + + + + `; +}; diff --git a/components/infieldbutton/CHANGELOG.md b/components/infieldbutton/CHANGELOG.md index 6184c265496..594201965e7 100644 --- a/components/infieldbutton/CHANGELOG.md +++ b/components/infieldbutton/CHANGELOG.md @@ -1,5 +1,68 @@ # Change log +## 7.0.0-next.3 + +### Patch Changes + +📝 [#4114](https://github.com/adobe/spectrum-css/pull/4114) [`7061eee`](https://github.com/adobe/spectrum-css/commit/7061eee2ada0b64bb68e37f93329c57e8dba4586) Thanks [@rise-erpelding](https://github.com/rise-erpelding)! + +Remove unused key-focus and border mods. Note that border and key focus styles were previously removed in the migration to Spectrum 2, and the mod removals here do not have any visual impact to the infield button. + +Also updates transition to use `background-color` instead of `border-color`. + +Also fixes a flash bug in WHCM: when hovered, the infield button was flashing/blinking before changing to the appropriate hover color. + +## 7.0.0-next.2 + +### Major Changes + +- [#3642](https://github.com/adobe/spectrum-css/pull/3642) [`646763a`](https://github.com/adobe/spectrum-css/commit/646763a9f7940b66def0329e3c4bae66e42d36b2) Thanks [@aramos-adobe](https://github.com/aramos-adobe)! + +#### Spectrum 2 migration + +In-field buttons are used to represent actions within input fields. They're currently used inside number field. This component has updated colors, corner radius, and icons compared to the Spectrum 1 version. The "Error" and "Key-focus" variants have been removed, since this now utilizes those states from the parent component. + +The position styles and controls have also been removed now that there's a consistent corner radius. + +##### Removed mods + +Due to deprecation of the position variants in the infield button, some spacing and border radius mods have been removed. + +`--mod-infield-button-inner-edge-to-fill` +`--mod-infield-button-stacked-border-radius-reset` +`--mod-infield-button-stacked-bottom-border-block-end-width` +`--mod-infield-button-stacked-bottom-border-radius-end-end` +`--mod-infield-button-stacked-bottom-border-radius-end-start` +`--mod-infield-button-stacked-fill-padding-inline` +`--mod-infield-button-stacked-fill-padding-inner` + +##### New tokens + +These new tokens are the inline variant & stepper (number field) use case. The padding changes here. + +`--spectrum-in-field-button-side-edge-to-fill-small` +`--spectrum-in-field-button-side-edge-to-fill-medium` +`--spectrum-in-field-button-side-edge-to-fill-large` +`--spectrum-in-field-button-side-edge-to-fill-extra-large` +`--spectrum-field-edge-to-icon-75` +`--spectrum-field-edge-to-icon-100` +`--spectrum-field-edge-to-icon-200` +`--spectrum-field-edge-to-icon-300` + +## 7.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + +## 7.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`a25e0a9`](https://github.com/adobe/spectrum-css/commit/a25e0a99e5a4736ab4e607e00739343101a2633b)]: + - @spectrum-css/icon@10.0.0-next.0 + ## 6.2.0 ### Minor Changes @@ -12,8 +75,11 @@ Ensure accurate exports are present for each component. Specifically, adding `th ### Patch Changes -- [#3615](https://github.com/adobe/spectrum-css/pull/3615) [`f09c84a`](https://github.com/adobe/spectrum-css/commit/f09c84ae9922d67b6fe237d693afee0fab53fa67) Thanks [@Rajdeepc](https://github.com/Rajdeepc)! - ### Infield button fast follows - - Updated infield button disabled border color to use `--spectrum-gray-300` for spectrum-two theme and `--spectrum-gray-200` for other themes. +- [#3615](https://github.com/adobe/spectrum-css/pull/3615) [`f09c84a`](https://github.com/adobe/spectrum-css/commit/f09c84ae9922d67b6fe237d693afee0fab53fa67) Thanks [@Rajdeepc](https://github.com/Rajdeepc)! + +#### Infield button fast follows + +Updated infield button disabled border color to use `--spectrum-gray-300` for spectrum-two theme and `--spectrum-gray-200` for other themes. ## 6.1.1 diff --git a/components/infieldbutton/dist/metadata.json b/components/infieldbutton/dist/metadata.json index 563089a4065..98a823a73c7 100644 --- a/components/infieldbutton/dist/metadata.json +++ b/components/infieldbutton/dist/metadata.json @@ -2,25 +2,21 @@ "sourceFile": "index.css", "selectors": [ ".spectrum-InfieldButton", - ".spectrum-InfieldButton--bottom .spectrum-InfieldButton-fill", - ".spectrum-InfieldButton--left .spectrum-InfieldButton-fill", - ".spectrum-InfieldButton--right .spectrum-InfieldButton-fill", - ".spectrum-InfieldButton--top .spectrum-InfieldButton-fill", + ".spectrum-InfieldButton--quiet", + ".spectrum-InfieldButton--quiet:disabled", + ".spectrum-InfieldButton--quiet:not(:disabled):active", + ".spectrum-InfieldButton--quiet:not(:disabled):focus-visible", + ".spectrum-InfieldButton--quiet:not(:disabled):hover", ".spectrum-InfieldButton-fill", ".spectrum-InfieldButton-icon", - ".spectrum-InfieldButton.spectrum-InfieldButton--bottom", - ".spectrum-InfieldButton.spectrum-InfieldButton--bottom.spectrum-InfieldButton--sizeL", - ".spectrum-InfieldButton.spectrum-InfieldButton--bottom.spectrum-InfieldButton--sizeS", - ".spectrum-InfieldButton.spectrum-InfieldButton--bottom.spectrum-InfieldButton--sizeXL", + ".spectrum-InfieldButton-inline", + ".spectrum-InfieldButton-inline .spectrum-InfieldButton", + ".spectrum-InfieldButton-inline > .spectrum-InfieldButton.spectrum-InfieldButton--sizeS", ".spectrum-InfieldButton.spectrum-InfieldButton--quiet", ".spectrum-InfieldButton.spectrum-InfieldButton--quiet:disabled", ".spectrum-InfieldButton.spectrum-InfieldButton--sizeL", ".spectrum-InfieldButton.spectrum-InfieldButton--sizeS", ".spectrum-InfieldButton.spectrum-InfieldButton--sizeXL", - ".spectrum-InfieldButton.spectrum-InfieldButton--top", - ".spectrum-InfieldButton.spectrum-InfieldButton--top.spectrum-InfieldButton--sizeL", - ".spectrum-InfieldButton.spectrum-InfieldButton--top.spectrum-InfieldButton--sizeS", - ".spectrum-InfieldButton.spectrum-InfieldButton--top.spectrum-InfieldButton--sizeXL", ".spectrum-InfieldButton:active", ".spectrum-InfieldButton:disabled", ".spectrum-InfieldButton:focus-visible", @@ -30,8 +26,6 @@ ".spectrum-InfieldButton:not(:disabled):hover" ], "modifiers": [ - "--mod-infield-border-color", - "--mod-infield-border-color-quiet", "--mod-infield-button-background-color", "--mod-infield-button-background-color-disabled", "--mod-infield-button-background-color-down", @@ -40,18 +34,11 @@ "--mod-infield-button-background-color-hover", "--mod-infield-button-background-color-hover-disabled", "--mod-infield-button-background-color-hover-quiet", - "--mod-infield-button-background-color-key-focus", - "--mod-infield-button-background-color-key-focus-quiet", "--mod-infield-button-background-color-quiet", "--mod-infield-button-background-color-quiet-disabled", - "--mod-infield-button-border-color", - "--mod-infield-button-border-color-disabled", - "--mod-infield-button-border-color-quiet-disabled", "--mod-infield-button-border-radius", - "--mod-infield-button-border-radius-reset", - "--mod-infield-button-border-width", - "--mod-infield-button-border-width-quiet", "--mod-infield-button-edge-to-fill", + "--mod-infield-button-field-edge-to-icon", "--mod-infield-button-fill-justify-content", "--mod-infield-button-fill-padding", "--mod-infield-button-height", @@ -61,99 +48,69 @@ "--mod-infield-button-icon-color-down-disabled", "--mod-infield-button-icon-color-hover", "--mod-infield-button-icon-color-hover-disabled", - "--mod-infield-button-icon-color-key-focus", - "--mod-infield-button-icon-color-key-focus-disabled", - "--mod-infield-button-inner-edge-to-fill", - "--mod-infield-button-stacked-border-radius-reset", - "--mod-infield-button-stacked-bottom-border-block-end-width", - "--mod-infield-button-stacked-bottom-border-radius-end-end", - "--mod-infield-button-stacked-bottom-border-radius-end-start", - "--mod-infield-button-stacked-fill-padding-inline", - "--mod-infield-button-stacked-fill-padding-inner", - "--mod-infield-button-stacked-fill-padding-outer", - "--mod-infield-button-stacked-top-border-radius-start-start", - "--mod-infield-button-width", - "--mod-infield-button-width-stacked" + "--mod-infield-button-side-edge-to-fill", + "--mod-infield-button-width" ], "component": [ - "--spectrum-in-field-button-edge-to-disclosure-icon-stacked-extra-large", - "--spectrum-in-field-button-edge-to-disclosure-icon-stacked-large", - "--spectrum-in-field-button-edge-to-disclosure-icon-stacked-medium", - "--spectrum-in-field-button-edge-to-disclosure-icon-stacked-small", - "--spectrum-in-field-button-edge-to-fill", - "--spectrum-in-field-button-fill-stacked-inner-border-rounding", - "--spectrum-in-field-button-inner-edge-to-disclosure-icon-stacked-extra-large", - "--spectrum-in-field-button-inner-edge-to-disclosure-icon-stacked-large", - "--spectrum-in-field-button-inner-edge-to-disclosure-icon-stacked-medium", - "--spectrum-in-field-button-inner-edge-to-disclosure-icon-stacked-small", - "--spectrum-in-field-button-outer-edge-to-disclosure-icon-stacked-extra-large", - "--spectrum-in-field-button-outer-edge-to-disclosure-icon-stacked-large", - "--spectrum-in-field-button-outer-edge-to-disclosure-icon-stacked-medium", - "--spectrum-in-field-button-outer-edge-to-disclosure-icon-stacked-small", - "--spectrum-in-field-button-stacked-inner-edge-to-fill", - "--spectrum-in-field-button-width-stacked-extra-large", - "--spectrum-in-field-button-width-stacked-large", - "--spectrum-in-field-button-width-stacked-medium", - "--spectrum-in-field-button-width-stacked-small", + "--spectrum-in-field-button-edge-to-fill-extra-large", + "--spectrum-in-field-button-edge-to-fill-large", + "--spectrum-in-field-button-edge-to-fill-medium", + "--spectrum-in-field-button-edge-to-fill-small", + "--spectrum-in-field-button-side-edge-to-fill-extra-large", + "--spectrum-in-field-button-side-edge-to-fill-large", + "--spectrum-in-field-button-side-edge-to-fill-medium", + "--spectrum-in-field-button-side-edge-to-fill-small", "--spectrum-infield-button-background-color", "--spectrum-infield-button-background-color-down", "--spectrum-infield-button-background-color-hover", - "--spectrum-infield-button-background-color-key-focus", - "--spectrum-infield-button-border-color", "--spectrum-infield-button-border-radius", - "--spectrum-infield-button-border-radius-reset", - "--spectrum-infield-button-border-width", + "--spectrum-infield-button-downstate-perspective", "--spectrum-infield-button-edge-to-fill", + "--spectrum-infield-button-field-edge-to-disclosure-icon", "--spectrum-infield-button-fill-justify-content", "--spectrum-infield-button-fill-padding", "--spectrum-infield-button-height", "--spectrum-infield-button-icon-color", "--spectrum-infield-button-icon-color-down", "--spectrum-infield-button-icon-color-hover", - "--spectrum-infield-button-icon-color-key-focus", - "--spectrum-infield-button-inner-edge-to-fill", - "--spectrum-infield-button-stacked-border-radius-reset", - "--spectrum-infield-button-stacked-bottom-border-radius-end-start", - "--spectrum-infield-button-stacked-fill-padding-inline", - "--spectrum-infield-button-stacked-fill-padding-inner", - "--spectrum-infield-button-stacked-fill-padding-outer", - "--spectrum-infield-button-stacked-top-border-radius-start-start", + "--spectrum-infield-button-inline-edge-to-fill", + "--spectrum-infield-button-inline-field-edge-to-icon", "--spectrum-infield-button-width" ], "global": [ "--spectrum-animation-duration-100", - "--spectrum-border-width-100", "--spectrum-component-height-100", "--spectrum-component-height-200", "--spectrum-component-height-300", "--spectrum-component-height-75", - "--spectrum-corner-radius-100", + "--spectrum-component-size-difference-down", + "--spectrum-component-size-minimum-perspective-down", + "--spectrum-component-size-width-ratio-down", + "--spectrum-corner-radius-small-size-extra-large", + "--spectrum-corner-radius-small-size-large", + "--spectrum-corner-radius-small-size-medium", + "--spectrum-corner-radius-small-size-small", "--spectrum-disabled-background-color", "--spectrum-disabled-content-color", + "--spectrum-downstate-height", + "--spectrum-downstate-width", + "--spectrum-field-edge-to-disclosure-icon-100", + "--spectrum-field-edge-to-disclosure-icon-200", + "--spectrum-field-edge-to-disclosure-icon-300", + "--spectrum-field-edge-to-disclosure-icon-75", + "--spectrum-field-edge-to-icon-100", + "--spectrum-field-edge-to-icon-200", + "--spectrum-field-edge-to-icon-300", + "--spectrum-field-edge-to-icon-75", "--spectrum-gray-100", "--spectrum-gray-200", - "--spectrum-gray-300", "--spectrum-neutral-content-color-default", "--spectrum-neutral-content-color-down", - "--spectrum-neutral-content-color-hover", - "--spectrum-neutral-content-color-key-focus" - ], - "system-theme": [ - "--system-infield-button-background-color", - "--system-infield-button-background-color-down", - "--system-infield-button-background-color-hover", - "--system-infield-button-background-color-key-focus", - "--system-infield-button-border-color", - "--system-infield-button-border-radius", - "--system-infield-button-border-radius-reset", - "--system-infield-button-border-width", - "--system-infield-button-disabled-border-color", - "--system-infield-button-stacked-bottom-border-radius-end-start", - "--system-infield-button-stacked-top-border-radius-start-start" + "--spectrum-neutral-content-color-hover" ], "passthroughs": [], "high-contrast": [ - "--highcontrast-infield-button-border-color", - "--highcontrast-infield-button-border-color-active" + "--highcontrast-infield-button-background-color", + "--highcontrast-infield-button-icon-color" ] } diff --git a/components/infieldbutton/index.css b/components/infieldbutton/index.css index cf9c6458cc1..a1e54ecb1de 100644 --- a/components/infieldbutton/index.css +++ b/components/infieldbutton/index.css @@ -11,94 +11,80 @@ * governing permissions and limitations under the License. */ -@import "./themes/spectrum-two.css"; - .spectrum-InfieldButton { - /* Medium size is the default */ - --spectrum-infield-button-height: var(--spectrum-component-height-100); - --spectrum-infield-button-width: var(--spectrum-component-height-100); - --spectrum-infield-button-stacked-border-radius-reset: var(--spectrum-in-field-button-fill-stacked-inner-border-rounding); - - --spectrum-infield-button-edge-to-fill: var(--spectrum-in-field-button-edge-to-fill); - --spectrum-infield-button-inner-edge-to-fill: var(--spectrum-in-field-button-stacked-inner-edge-to-fill); - --spectrum-infield-button-fill-padding: 0px; - --spectrum-infield-button-stacked-fill-padding-inline: var(--spectrum-in-field-button-edge-to-disclosure-icon-stacked-medium); - --spectrum-infield-button-stacked-fill-padding-outer: var(--spectrum-in-field-button-outer-edge-to-disclosure-icon-stacked-medium); - --spectrum-infield-button-stacked-fill-padding-inner: var(--spectrum-in-field-button-inner-edge-to-disclosure-icon-stacked-medium); + /* Color */ + --spectrum-infield-button-background-color: var(--spectrum-gray-100); + --spectrum-infield-button-background-color-hover: var(--spectrum-gray-200); + --spectrum-infield-button-background-color-down: var(--spectrum-gray-200); --spectrum-infield-button-icon-color: var(--spectrum-neutral-content-color-default); --spectrum-infield-button-icon-color-hover: var(--spectrum-neutral-content-color-hover); --spectrum-infield-button-icon-color-down: var(--spectrum-neutral-content-color-down); - --spectrum-infield-button-icon-color-key-focus: var(--spectrum-neutral-content-color-key-focus); + + /* Layout */ + --spectrum-infield-button-height: var(--spectrum-component-height-100); + --spectrum-infield-button-width: var(--spectrum-component-height-100); + --spectrum-infield-button-border-radius: var(--spectrum-corner-radius-small-size-medium); + + --spectrum-infield-button-edge-to-fill: var(--spectrum-in-field-button-edge-to-fill-medium); + --spectrum-infield-button-inline-field-edge-to-icon: var(--spectrum-field-edge-to-icon-100); + + /* TODO: using custom in-field-button-side-edge-to-fill-* while token is unavailable */ + --spectrum-infield-button-inline-edge-to-fill: var(--spectrum-in-field-button-side-edge-to-fill-medium); + --spectrum-infield-button-fill-padding: 0px; + --spectrum-infield-button-field-edge-to-disclosure-icon: var(--spectrum-field-edge-to-disclosure-icon-100); --spectrum-infield-button-fill-justify-content: center; + --spectrum-infield-button-downstate-perspective: max(var(--spectrum-downstate-height), var(--spectrum-downstate-width) * var(--spectrum-component-size-width-ratio-down)); &:disabled { --mod-infield-button-background-color: var(--mod-infield-button-background-color-disabled, var(--spectrum-disabled-background-color)); --mod-infield-button-background-color-hover: var(--mod-infield-button-background-color-hover-disabled, var(--spectrum-disabled-background-color)); --mod-infield-button-background-color-down: var(--mod-infield-button-background-color-down-disabled, var(--spectrum-disabled-background-color)); - --mod-infield-button-border-color: var(--mod-infield-button-border-color-disabled, var(--spectrum-infield-button-border-color)); - --mod-infield-button-icon-color: var(--mod-infield-button-icon-color-disabled, var(--spectrum-disabled-content-color)); --mod-infield-button-icon-color-hover: var(--mod-infield-button-icon-color-hover-disabled, var(--spectrum-disabled-content-color)); --mod-infield-button-icon-color-down: var(--mod-infield-button-icon-color-down-disabled, var(--spectrum-disabled-content-color)); - --mod-infield-button-icon-color-key-focus: var(--mod-infield-button-icon-color-key-focus-disabled, var(--spectrum-disabled-content-color)); } &.spectrum-InfieldButton--sizeS { --spectrum-infield-button-height: var(--spectrum-component-height-75); --spectrum-infield-button-width: var(--spectrum-component-height-75); - --spectrum-infield-button-stacked-fill-padding-inline: var(--spectrum-in-field-button-edge-to-disclosure-icon-stacked-small); - --spectrum-infield-button-stacked-fill-padding-outer: var(--spectrum-in-field-button-outer-edge-to-disclosure-icon-stacked-small); - --spectrum-infield-button-stacked-fill-padding-inner: var(--spectrum-in-field-button-inner-edge-to-disclosure-icon-stacked-small); + --spectrum-infield-button-edge-to-fill: var(--spectrum-in-field-button-edge-to-fill-small); + --spectrum-infield-button-border-radius: var(--spectrum-corner-radius-small-size-small); + --spectrum-infield-button-field-edge-to-disclosure-icon: var(--spectrum-field-edge-to-disclosure-icon-75); + --spectrum-infield-button-inline-edge-to-fill: var(--spectrum-in-field-button-side-edge-to-fill-small); + --spectrum-infield-button-inline-field-edge-to-icon: var(--spectrum-field-edge-to-icon-75); + --spectrum-infield-button-downstate-perspective: var(--spectrum-component-size-minimum-perspective-down); } &.spectrum-InfieldButton--sizeL { --spectrum-infield-button-height: var(--spectrum-component-height-200); --spectrum-infield-button-width: var(--spectrum-component-height-200); - --spectrum-infield-button-stacked-fill-padding-inline: var(--spectrum-in-field-button-edge-to-disclosure-icon-stacked-large); - --spectrum-infield-button-stacked-fill-padding-outer: var(--spectrum-in-field-button-outer-edge-to-disclosure-icon-stacked-large); - --spectrum-infield-button-stacked-fill-padding-inner: var(--spectrum-in-field-button-inner-edge-to-disclosure-icon-stacked-large); + --spectrum-infield-button-edge-to-fill: var(--spectrum-in-field-button-edge-to-fill-large); + --spectrum-infield-button-border-radius: var(--spectrum-corner-radius-small-size-large); + --spectrum-infield-button-field-edge-to-disclosure-icon: var(--spectrum-field-edge-to-disclosure-icon-200); + --spectrum-infield-button-inline-edge-to-fill: var(--spectrum-in-field-button-side-edge-to-fill-large); + --spectrum-infield-button-inline-field-edge-to-icon: var(--spectrum-field-edge-to-icon-200); } &.spectrum-InfieldButton--sizeXL { --spectrum-infield-button-height: var(--spectrum-component-height-300); --spectrum-infield-button-width: var(--spectrum-component-height-300); - --spectrum-infield-button-stacked-fill-padding-inline: var(--spectrum-in-field-button-edge-to-disclosure-icon-stacked-extra-large); - --spectrum-infield-button-stacked-fill-padding-outer: var(--spectrum-in-field-button-outer-edge-to-disclosure-icon-stacked-extra-large); - --spectrum-infield-button-stacked-fill-padding-inner: var(--spectrum-in-field-button-inner-edge-to-disclosure-icon-stacked-extra-large); - } - - &.spectrum-InfieldButton--top, - &.spectrum-InfieldButton--bottom { - --mod-infield-button-width: var(--mod-infield-button-width-stacked, var(--spectrum-in-field-button-width-stacked-medium)); - - &.spectrum-InfieldButton--sizeS { - --mod-infield-button-width: var(--mod-infield-button-width-stacked, var(--spectrum-in-field-button-width-stacked-small)); - } - - &.spectrum-InfieldButton--sizeL { - --mod-infield-button-width: var(--mod-infield-button-width-stacked, var(--spectrum-in-field-button-width-stacked-large)); - } - - &.spectrum-InfieldButton--sizeXL { - --mod-infield-button-width: var(--mod-infield-button-width-stacked, var(--spectrum-in-field-button-width-stacked-extra-large)); - } + --spectrum-infield-button-edge-to-fill: var(--spectrum-in-field-button-edge-to-fill-extra-large); + --spectrum-infield-button-border-radius: var(--spectrum-corner-radius-small-size-extra-large); + --spectrum-infield-button-field-edge-to-disclosure-icon: var(--spectrum-field-edge-to-disclosure-icon-300); + --spectrum-infield-button-inline-edge-to-fill: var(--spectrum-in-field-button-side-edge-to-fill-extra-large); + --spectrum-infield-button-inline-field-edge-to-icon: var(--spectrum-field-edge-to-icon-300); } &.spectrum-InfieldButton--quiet { --mod-infield-button-background-color: var(--mod-infield-button-background-color-quiet, transparent); --mod-infield-button-background-color-hover: var(--mod-infield-button-background-color-hover-quiet, transparent); --mod-infield-button-background-color-down: var(--mod-infield-button-background-color-down-quiet, transparent); - --mod-infield-button-background-color-key-focus: var(--mod-infield-button-background-color-key-focus-quiet, transparent); - - --mod-infield-border-color: var(--mod-infield-border-color-quiet, transparent); - --mod-infield-button-border-width: var(--mod-infield-button-border-width-quiet, 0); &:disabled { --mod-infield-button-background-color: var(--mod-infield-button-background-color-quiet-disabled, transparent); - --mod-infield-button-border-color: var(--mod-infield-button-border-color-quiet-disabled, transparent); } } @@ -111,28 +97,6 @@ --mod-infield-button-background-color: var(--mod-infield-button-background-color-down, var(--spectrum-infield-button-background-color-down)); --mod-infield-button-icon-color: var(--mod-infield-button-icon-color-down, var(--spectrum-infield-button-icon-color-down)); } - - &:focus-visible { - --mod-infield-button-background-color: var(--mod-infield-button-background-color-key-focus, var(--spectrum-infield-button-background-color-key-focus)); - --mod-infield-button-icon-color: var(--mod-infield-button-icon-color-key-focus, var(--spectrum-infield-button-icon-color-key-focus)); - } -} - -@media (forced-colors: active) { - .spectrum-InfieldButton { - --highcontrast-infield-button-border-color: ButtonText; - --highcontrast-infield-button-border-color-active: Highlight; - - &:disabled { - --highcontrast-infield-button-border-color: inherit; - } - - &:not(:disabled):hover, - &:not(:disabled):active, - &:not(:disabled):focus-visible { - --highcontrast-infield-button-border-color: var(--highcontrast-infield-button-border-color-active); - } - } } .spectrum-InfieldButton { @@ -153,23 +117,26 @@ cursor: auto; } + &:active { + transform: perspective(var(--spectrum-infield-button-downstate-perspective)) translateZ(var(--spectrum-component-size-difference-down)); + } + &:focus-visible { outline: none; } +} - /* Stacked in-field buttons */ - /* Not currently in use (stepper uses Action Buttons) but adding the CSS so the option is there */ - &.spectrum-InfieldButton--top, - &.spectrum-InfieldButton--bottom { - block-size: calc(var(--mod-infield-button-height, var(--spectrum-infield-button-height)) / 2); - } +.spectrum-InfieldButton-inline { + display: flex; - &.spectrum-InfieldButton--top { - padding-block-end: var(--mod-infield-button-inner-edge-to-fill, var(--spectrum-infield-button-inner-edge-to-fill)); + & .spectrum-InfieldButton { + --mod-infield-button-field-edge-to-icon: var(--spectrum-infield-button-inline-field-edge-to-icon); + inline-size: calc(var(--mod-infield-button-width, var(--spectrum-infield-button-width)) - var(--mod-infield-button-edge-to-fill, var(--spectrum-infield-button-edge-to-fill))); + padding-inline: var(--mod-infield-button-side-edge-to-fill, var(--spectrum-infield-button-inline-edge-to-fill)); } - &.spectrum-InfieldButton--bottom { - padding-block-start: var(--mod-infield-button-inner-edge-to-fill, var(--spectrum-infield-button-inner-edge-to-fill)); + & > .spectrum-InfieldButton.spectrum-InfieldButton--sizeS { + inline-size: var(--mod-infield-button-width, var(--spectrum-infield-button-width)); } } @@ -177,15 +144,8 @@ block-size: 100%; inline-size: 100%; - background-color: var(--mod-infield-button-background-color, var(--spectrum-infield-button-background-color)); - - border-width: var(--mod-infield-button-border-width, var(--spectrum-infield-button-border-width)); - border-style: solid; - border-color: var(--highcontrast-infield-button-border-color, var(--mod-infield-button-border-color, var(--spectrum-infield-button-border-color))); - border-end-end-radius: var(--mod-infield-button-border-radius, var(--spectrum-infield-button-border-radius)); - border-start-end-radius: var(--mod-infield-button-border-radius, var(--spectrum-infield-button-border-radius)); - border-end-start-radius: var(--mod-infield-button-border-radius, var(--spectrum-infield-button-border-radius)); - border-start-start-radius: var(--mod-infield-button-border-radius, var(--spectrum-infield-button-border-radius)); + background-color: var(--highcontrast-infield-button-background-color, var(--mod-infield-button-background-color, var(--spectrum-infield-button-background-color))); + border-radius: var(--mod-infield-button-border-radius, var(--spectrum-infield-button-border-radius)); padding: var(--mod-infield-button-fill-padding, var(--spectrum-infield-button-fill-padding)); @@ -194,43 +154,7 @@ align-items: center; justify-content: var(--mod-infield-button-fill-justify-content, var(--spectrum-infield-button-fill-justify-content)); - transition: border-color var(--spectrum-animation-duration-100) ease-in-out; - - .spectrum-InfieldButton--right & { - border-end-start-radius: var(--mod-infield-button-border-radius-reset, var(--spectrum-infield-button-border-radius-reset)); - border-start-start-radius: var(--mod-infield-button-border-radius-reset, var(--spectrum-infield-button-border-radius-reset)); - } - - .spectrum-InfieldButton--left & { - border-end-end-radius: var(--mod-infield-button-border-radius-reset, var(--spectrum-infield-button-border-radius-reset)); - border-start-end-radius: var(--mod-infield-button-border-radius-reset, var(--spectrum-infield-button-border-radius-reset)); - } - - .spectrum-InfieldButton--top &, - .spectrum-InfieldButton--bottom & { - box-sizing: border-box; - padding-inline-start: calc(var(--mod-infield-button-stacked-fill-padding-inline, var(--spectrum-infield-button-stacked-fill-padding-inline)) - var(--mod-infield-button-edge-to-fill, var(--spectrum-infield-button-edge-to-fill)) - var(--mod-infield-button-border-width, var(--spectrum-infield-button-border-width))); - padding-inline-end: calc(var(--mod-infield-button-stacked-fill-padding-inline, var(--spectrum-infield-button-stacked-fill-padding-inline)) - var(--mod-infield-button-edge-to-fill, var(--spectrum-infield-button-edge-to-fill)) - var(--mod-infield-button-border-width, var(--spectrum-infield-button-border-width))); - } - - .spectrum-InfieldButton--top & { - padding-block-start: calc(var(--mod-infield-button-stacked-fill-padding-outer, var(--spectrum-infield-button-stacked-fill-padding-outer)) - var(--mod-infield-button-edge-to-fill, var(--spectrum-infield-button-edge-to-fill)) - var(--mod-infield-button-border-width, var(--spectrum-infield-button-border-width))); - padding-block-end: calc(var(--mod-infield-button-stacked-fill-padding-inner, var(--spectrum-infield-button-stacked-fill-padding-inner)) - var(--mod-infield-button-inner-edge-to-fill, var(--spectrum-infield-button-inner-edge-to-fill))); - border-block-end: none; - border-start-start-radius: var(--mod-infield-button-stacked-top-border-radius-start-start, var(--spectrum-infield-button-stacked-top-border-radius-start-start)); - border-end-start-radius: var(--mod-infield-button-stacked-border-radius-reset, var(--spectrum-infield-button-stacked-border-radius-reset)); - border-end-end-radius: var(--mod-infield-button-stacked-border-radius-reset, var(--spectrum-infield-button-stacked-border-radius-reset)); - } - - .spectrum-InfieldButton--bottom & { - padding-block-start: calc(var(--mod-infield-button-stacked-fill-padding-inner, var(--spectrum-infield-button-stacked-fill-padding-inner)) - var(--mod-infield-button-edge-to-fill, var(--spectrum-infield-button-edge-to-fill)) - var(--mod-infield-button-border-width, var(--spectrum-infield-button-border-width))); - padding-block-end: calc(var(--mod-infield-button-stacked-fill-padding-outer, var(--spectrum-infield-button-stacked-fill-padding-outer)) - var(--mod-infield-button-inner-edge-to-fill, var(--spectrum-infield-button-inner-edge-to-fill)) - var(--mod-infield-button-border-width, var(--spectrum-infield-button-border-width))); - border-end-start-radius: var(--mod-infield-button-stacked-bottom-border-radius-end-start, var(--spectrum-infield-button-stacked-bottom-border-radius-end-start)); - border-start-start-radius: var(--mod-infield-button-stacked-border-radius-reset, var(--spectrum-infield-button-stacked-border-radius-reset)); - border-start-end-radius: var(--mod-infield-button-stacked-border-radius-reset, var(--spectrum-infield-button-stacked-border-radius-reset)); - border-end-end-radius: var(--mod-infield-button-stacked-bottom-border-radius-end-end, var(--mod-infield-button-border-radius, var(--spectrum-infield-button-border-radius))); - border-block-end-width: var(--mod-infield-button-stacked-bottom-border-block-end-width, var(--mod-infield-button-border-width, var(--spectrum-infield-button-border-width))); - } + transition: background-color var(--spectrum-animation-duration-100) ease-in-out; } .spectrum-InfieldButton-icon { @@ -242,5 +166,41 @@ /* remove margin used for centering */ margin: 0 !important; - color: var(--mod-infield-button-icon-color, var(--spectrum-infield-button-icon-color)); + color: var(--highcontrast-infield-button-icon-color, var(--mod-infield-button-icon-color, var(--spectrum-infield-button-icon-color))); + padding: var(--mod-infield-button-field-edge-to-icon, var(--spectrum-infield-button-field-edge-to-disclosure-icon)); +} + +@media (forced-colors: active) { + .spectrum-InfieldButton { + --highcontrast-infield-button-background-color: ButtonText; + --highcontrast-infield-button-icon-color: ButtonFace; + forced-color-adjust: none; /* keeps button from flashing when hovered */ + + &:disabled { + --highcontrast-infield-button-background-color: GrayText; + } + + &:not(:disabled):hover, + &:not(:disabled):active, + &:not(:disabled):focus-visible { + --highcontrast-infield-button-background-color: Highlight; + } + } + + .spectrum-InfieldButton--quiet { + --highcontrast-infield-button-background-color: Canvas; + --highcontrast-infield-button-icon-color: ButtonText; + + &:disabled { + --highcontrast-infield-button-background-color: Canvas; + --highcontrast-infield-button-icon-color: GrayText; + } + + &:not(:disabled):hover, + &:not(:disabled):active, + &:not(:disabled):focus-visible { + --highcontrast-infield-button-background-color: Canvas; + --highcontrast-infield-button-icon-color: Highlight; + } + } } diff --git a/components/infieldbutton/package.json b/components/infieldbutton/package.json index 5c382a79ed8..6c017cc9aad 100644 --- a/components/infieldbutton/package.json +++ b/components/infieldbutton/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/infieldbutton", - "version": "6.2.0", + "version": "7.0.0-next.3", "description": "The Spectrum CSS infield button component", "license": "Apache-2.0", "author": "Adobe", @@ -19,15 +19,13 @@ "./package.json": "./package.json", "./dist/*": "./dist/*", "./index.css": "./dist/index.css", - "./index-*.css": "./dist/index-*.css", "./metadata.json": "./dist/metadata.json", - "./themes/*": "./dist/themes/*", "./stories/*": "./stories/*" }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/icon": ">=9.0.0 <10.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/icon": ">=10.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/icon": { @@ -38,8 +36,8 @@ } }, "devDependencies": { - "@spectrum-css/icon": "9.2.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/icon": "10.0.0-next.3", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/infieldbutton/stories/infieldbutton.stories.js b/components/infieldbutton/stories/infieldbutton.stories.js index a49a676a441..2b3a91d6faa 100644 --- a/components/infieldbutton/stories/infieldbutton.stories.js +++ b/components/infieldbutton/stories/infieldbutton.stories.js @@ -1,13 +1,14 @@ import { default as IconStories } from "@spectrum-css/icon/stories/icon.stories.js"; +import { Sizes, withDownStateDimensionCapture } from "@spectrum-css/preview/decorators"; import { disableDefaultModes } from "@spectrum-css/preview/modes"; -import { isActive, isDisabled, isFocused, isHovered, isQuiet, size } from "@spectrum-css/preview/types"; +import { isActive, isDisabled, isHovered, isQuiet, size } from "@spectrum-css/preview/types"; import metadata from "../dist/metadata.json"; import packageJson from "../package.json"; import { InfieldButtonGroup } from "./infieldbutton.test.js"; -import { Template } from "./template.js"; +import { InfieldButtonGroupVariant, InfieldButtonIcons, Template } from "./template.js"; /** - * The in-field button component is a button used inside a text field. + * In-field buttons are used to represent actions within input fields. They’re currently used inside the [number field](/docs/components-stepper--docs). */ export default { title: "In-field button", @@ -15,70 +16,75 @@ export default { argTypes: { size: size(["s", "m", "l", "xl"]), isQuiet, - position: { - name: "Position", - type: { name: "string", required: true }, - table: { - type: { summary: "string" }, - category: "Component", - }, - options: ["left", "right", "top", "bottom"], - control: "select" - }, iconName: { - ...IconStories?.argTypes?.iconName ?? {}, - if: false, + ...IconStories?.argTypes?.uiIconName ?? {}, + options: ["ChevronDown", "Cross", "Dash", "Add"], + if: { arg: "isInline", neq: true }, + description: "These are icons to use within the in-field button - `ChevronDown`, `Add`, `Dash` and `Cross`", }, isDisabled, - isFocused, isActive, isHovered, - isStacked: { table: { disable: true } }, + isInline: { + name: "Side by side", + description: "Renders two in-field buttons side by side. This is typically used for number fields to add or subtract a number.", + type: { name: "boolean" }, + table: { + type: { summary: "boolean" }, + category: "Component", + }, + control: "boolean", + }, }, args: { rootClass: "spectrum-InfieldButton", size: "m", - position: "left", - iconName: "Add", + iconName: "ChevronDown", isQuiet: false, isDisabled: false, - isFocused: false, isHovered: false, isActive: false, - isStacked: false, + isInline: false, }, parameters: { + actions: { + handles: ["click .spectrum-InfieldButton"], + }, design: { type: "figma", - url: "https://www.figma.com/design/eoZHKJH9a3LJkHYCGt60Vb/S2-token-specs?node-id=814-8689", + url: "https://www.figma.com/design/Mngz9H7WZLbrCvGQf3GnsY/S2-%2F-Desktop?node-id=67509-808&m=dev" + }, + downState: { + selectors: [".spectrum-InfieldButton:not(:disabled)"], }, packageJson, metadata, + status: { + type: "migrated", + }, }, + decorators: [ + withDownStateDimensionCapture, + ], + tags: ["migrated"], }; export const Default = InfieldButtonGroup.bind({}); Default.args = {}; +Default.tags = ["!autodocs"]; -export const Start = Template.bind({}); -Start.tags = ["!dev"]; -Start.args = { - position: "left" -}; -Start.parameters = { - chromatic: { disableSnapshot: true }, -}; - -export const End = Template.bind({}); -End.tags = ["!dev"]; -End.args = { - position: "right" -}; -End.parameters = { +export const Primary = InfieldButtonGroupVariant.bind({}); +Primary.args = {}; +Primary.storyName = "Default"; +Primary.tags = ["!dev"]; +Primary.parameters = { chromatic: { disableSnapshot: true }, }; -export const Quiet = Template.bind({}); +/** + * The quiet variant is used when the in-field button needs to be less visually prominent since it is used in input fields. +*/ +export const Quiet = InfieldButtonGroupVariant.bind({}); Quiet.tags = ["!dev"]; Quiet.args = { isQuiet: true @@ -87,12 +93,78 @@ Quiet.parameters = { chromatic: { disableSnapshot: true }, }; -export const Disabled = Template.bind({}); -Disabled.tags = ["!dev"]; -Disabled.args = { - isDisabled: true +/** + * The inline variant is used when there are multiple in-field buttons that need to be displayed side by side. This is typically used for number fields to add or subtract a number. +*/ + +export const Inline = Template.bind({}); +Inline.tags = ["!dev"]; +Inline.args = { + isInline: true, +}; +Inline.parameters = { + chromatic: { disableSnapshot: true }, +}; + +export const Sizing = (args, context) => Sizes({ + Template, + withHeading: false, + withBorder: false, + ...args, +}, context); +Sizing.tags = ["!dev"]; +Sizing.parameters = { + chromatic: { disableSnapshot: true }, }; -Disabled.parameters = { + +/** + * The `ChevronDown`, `Add`, `Dash` and `Cross` icons should be used within the infield button to represent different actions. Use the correct icon size that corresponds to the t-shirt size you require for the infield button. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    **T-Shirt size****Cross icon size class****Disclosure (ChevronDown) icon size class****Dash (Minus) icon size class****Add icon size class**
    spectrum-InfieldButton--sizeSspectrum-UIIcon-Cross75spectrum-UIIcon-ChevronDown75spectrum-UIIcon-Dash75spectrum-Icon--sizeS
    spectrum-InfieldButton--sizeMspectrum-UIIcon-Cross100spectrum-UIIcon-ChevronDown100spectrum-UIIcon-Dash100spectrum-Icon--sizeM
    spectrum-InfieldButton--sizeLspectrum-UIIcon-Cross200spectrum-UIIcon-ChevronDown200spectrum-UIIcon-Dash200spectrum-Icon--sizeL
    spectrum-InfieldButton--sizeXLspectrum-UIIcon-Cross300spectrum-UIIcon-ChevronDown300spectrum-UIIcon-Dash300spectrum-Icon--sizeXL
    + */ +export const SupportedIcons = InfieldButtonIcons.bind({}); +SupportedIcons.tags = ["!dev"]; +SupportedIcons.parameters = { chromatic: { disableSnapshot: true }, }; @@ -105,12 +177,3 @@ WithForcedColors.parameters = { modes: disableDefaultModes }, }; - -export const Stacked = Template.bind({}); -Stacked.tags = ["!dev"]; -Stacked.args = { - isStacked: true, -}; -Stacked.parameters = { - chromatic: { disableSnapshot: true }, -}; diff --git a/components/infieldbutton/stories/infieldbutton.test.js b/components/infieldbutton/stories/infieldbutton.test.js index da3a06179ef..e5e80bf03bc 100644 --- a/components/infieldbutton/stories/infieldbutton.test.js +++ b/components/infieldbutton/stories/infieldbutton.test.js @@ -12,31 +12,11 @@ export const InfieldButtonGroup = Variants({ isQuiet: true, }, { - testHeading: "Position: top", - position: "top", - }, - { - testHeading: "Position: bottom", - position: "bottom", - }, - { - testHeading: "Position: left", - position: "left", - }, - { - testHeading: "Position: right", - position: "right", - }, - { - testHeading: "Stacked", - isStacked: true, + testHeading: "Side by side", + isInline: true, }, ], stateData: [ - { - testHeading: "Disabled", - isDisabled: true, - }, { testHeading: "Hovered", isHovered: true, @@ -46,12 +26,8 @@ export const InfieldButtonGroup = Variants({ isActive: true, }, { - testHeading: "Focused", - isFocused: true, - }, - { - testHeading: "Invalid", - isInvalid: true, + testHeading: "Disabled", + isDisabled: true, }, ], }); diff --git a/components/infieldbutton/stories/template.js b/components/infieldbutton/stories/template.js index 7f0b4ee8db1..06eca6f321f 100644 --- a/components/infieldbutton/stories/template.js +++ b/components/infieldbutton/stories/template.js @@ -3,56 +3,56 @@ import { html } from "lit"; import { classMap } from "lit/directives/class-map.js"; import { when } from "lit/directives/when.js"; +import { Container } from "@spectrum-css/preview/decorators"; import "../index.css"; -import "../themes/spectrum.css"; -/* Must be imported last */ -import "../themes/express.css"; export const Template = ( { rootClass = "spectrum-InfieldButton", customClasses = [], size = "m", - position, isQuiet, - iconName = "Add", - iconSet = "workflow", + iconName = "ChevronDown", + iconSet = "ui", isDisabled, - isInvalid, isHovered, isActive, - isFocused, - isStacked, + isInline, tabIndex = 0, + onSubtract, + onAdd, + onclick, } = {}, context = {}, ) => { - return isStacked + let iconSize = size === "s" ? "75" : size === "l" ? "200" : size === "xl" ? "300" : "100"; + let iconNameWithSize = `${iconName}${iconSize}`; + + return isInline ? html` - +
    ` : html` `; }; + +export const InfieldButtonGroupVariant = (args, context) => Container({ + withBorder: false, + direction: "row", + content: [ + Container({ + withBorder: false, + heading: "Default", + content: Template(args, context), + }), + Container({ + withBorder: false, + heading: "Disabled", + content: Template({ ...args, isDisabled: true }, context), + }), + ] +}, context); + +export const InfieldButtonIcons = (args, context) => Container({ + withBorder: false, + direction: "row", + content: [ + Template(args, context), + Template({...args, iconName: "Cross"}, context), + Template({...args, iconName: "Dash"}, context), + Template({...args, iconName: "Add"}, context), + ], +}, context); diff --git a/components/infieldbutton/themes/express.css b/components/infieldbutton/themes/express.css deleted file mode 100644 index 1d930d4cfee..00000000000 --- a/components/infieldbutton/themes/express.css +++ /dev/null @@ -1,34 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--express */ - -@import "./spectrum.css"; - -@container style(--system: express) { - .spectrum-InfieldButton { - --spectrum-infield-button-border-width: 0; - --spectrum-infield-button-border-color: transparent; - - --spectrum-infield-button-border-radius: var(--spectrum-corner-radius-75); - --spectrum-infield-button-border-radius-reset: var(--spectrum-corner-radius-75); - - --spectrum-infield-button-stacked-top-border-radius-start-start: var(--spectrum-corner-radius-75); - --spectrum-infield-button-stacked-bottom-border-radius-end-start: var(--spectrum-corner-radius-75); - - --spectrum-infield-button-background-color: var(--spectrum-gray-200); - --spectrum-infield-button-background-color-hover: var(--spectrum-gray-300); - --spectrum-infield-button-background-color-down: var(--spectrum-gray-400); - --spectrum-infield-button-background-color-key-focus: var(--spectrum-gray-300); - } -} diff --git a/components/infieldbutton/themes/spectrum-two.css b/components/infieldbutton/themes/spectrum-two.css deleted file mode 100644 index ec2307ef3a4..00000000000 --- a/components/infieldbutton/themes/spectrum-two.css +++ /dev/null @@ -1,35 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -@container style(--system: spectrum) { - .spectrum-InfieldButton { - --spectrum-infield-button-border-width: var(--spectrum-border-width-100); - --spectrum-infield-button-border-color: inherit; - - --spectrum-infield-button-border-radius: var(--spectrum-corner-radius-100); - --spectrum-infield-button-border-radius-reset: 0; - - /* Have to call these out specifically due to Express differences */ - --spectrum-infield-button-stacked-top-border-radius-start-start: var(--spectrum-infield-button-border-radius-reset); - --spectrum-infield-button-stacked-bottom-border-radius-end-start: var(--spectrum-infield-button-border-radius-reset); - - --spectrum-infield-button-background-color: var(--spectrum-gray-100); - --spectrum-infield-button-background-color-hover: var(--spectrum-gray-200); - --spectrum-infield-button-background-color-down: var(--spectrum-gray-200); - --spectrum-infield-button-background-color-key-focus: var(--spectrum-gray-200); - - &:disabled { - --spectrum-infield-button-border-color: var(--spectrum-gray-300); - } - } -} diff --git a/components/infieldbutton/themes/spectrum.css b/components/infieldbutton/themes/spectrum.css deleted file mode 100644 index 93ae76972e5..00000000000 --- a/components/infieldbutton/themes/spectrum.css +++ /dev/null @@ -1,29 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--legacy */ - -@import "./spectrum-two.css"; - -@container style(--system: legacy) { - .spectrum-InfieldButton { - --spectrum-infield-button-background-color: var(--spectrum-gray-75); - --spectrum-infield-button-background-color-hover: var(--spectrum-gray-200); - --spectrum-infield-button-background-color-down: var(--spectrum-gray-300); - --spectrum-infield-button-background-color-key-focus: var(--spectrum-gray-200); - - &:disabled { - --spectrum-infield-button-border-color: var(--spectrum-gray-200); - } - } -} diff --git a/components/infieldprogresscircle/CHANGELOG.md b/components/infieldprogresscircle/CHANGELOG.md new file mode 100644 index 00000000000..56ad4b72384 --- /dev/null +++ b/components/infieldprogresscircle/CHANGELOG.md @@ -0,0 +1,16 @@ +# @spectrum-css/infieldprogresscircle + +## 1.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + +## 1.0.0-next.0 + +### Major Changes + +- [#2352](https://github.com/adobe/spectrum-css/pull/2352) [`fb80825`](https://github.com/adobe/spectrum-css/commit/fb80825cc31d6b5eb46dc42e595bce253e7db805) Thanks [@pfulton](https://github.com/pfulton)! - ## Infield Progresscircle S2 Migration + + In-field progress circle is a new component created to replace progress circle (size S) in t-shirt size components. The button, textfield, combo box, and picker `template.js` files have all been updated to call for infield progress circles. This component comes in four sizes: (S, M, L, XL), has updated color variants (default, white, black), and has a unified track thickness. diff --git a/components/commons/README.md b/components/infieldprogresscircle/README.md similarity index 73% rename from components/commons/README.md rename to components/infieldprogresscircle/README.md index c7f2c8e095a..4d411cc9502 100644 --- a/components/commons/README.md +++ b/components/infieldprogresscircle/README.md @@ -1,6 +1,6 @@ -# @spectrum-css/commons +# @spectrum-css/infieldprogresscircle -> Common mixins and variables for Spectrum CSS components +> The Spectrum CSS infield progress circle component This package is part of the [Spectrum CSS project](https://github.com/adobe/spectrum-css). diff --git a/components/infieldprogresscircle/dist/metadata.json b/components/infieldprogresscircle/dist/metadata.json new file mode 100644 index 00000000000..ffc95f11390 --- /dev/null +++ b/components/infieldprogresscircle/dist/metadata.json @@ -0,0 +1,25 @@ +{ + "sourceFile": "index.css", + "selectors": [ + ".spectrum-InfieldProgressCircle", + ".spectrum-InfieldProgressCircle .spectrum-ProgressCircle-fill", + ".spectrum-InfieldProgressCircle--sizeL", + ".spectrum-InfieldProgressCircle--sizeS", + ".spectrum-InfieldProgressCircle--sizeXL" + ], + "modifiers": [], + "component": [ + "--spectrum-in-field-progress-circle-edge-to-fill", + "--spectrum-in-field-progress-circle-size-100", + "--spectrum-in-field-progress-circle-size-200", + "--spectrum-in-field-progress-circle-size-300", + "--spectrum-in-field-progress-circle-size-75", + "--spectrum-infieldprogresscircle-padding-block" + ], + "global": ["--spectrum-progress-circle-thickness-small"], + "passthroughs": [ + "--mod-progress-circle-size", + "--mod-progress-circle-thickness" + ], + "high-contrast": [] +} diff --git a/components/infieldprogresscircle/index.css b/components/infieldprogresscircle/index.css new file mode 100644 index 00000000000..e3525eccc40 --- /dev/null +++ b/components/infieldprogresscircle/index.css @@ -0,0 +1,37 @@ +/*! +Copyright 2025 Adobe. All rights reserved. +This file is licensed to you under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. You may obtain a copy +of the License at http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under +the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS +OF ANY KIND, either express or implied. See the License for the specific language +governing permissions and limitations under the License. +*/ + +.spectrum-InfieldProgressCircle { + --mod-progress-circle-thickness: var(--spectrum-progress-circle-thickness-small); + --mod-progress-circle-size: var(--spectrum-in-field-progress-circle-size-100); + --spectrum-infieldprogresscircle-padding-block: var(--spectrum-in-field-progress-circle-edge-to-fill); +} + +.spectrum-InfieldProgressCircle--sizeS { + --mod-progress-circle-size: var(--spectrum-in-field-progress-circle-size-75); +} + +.spectrum-InfieldProgressCircle--sizeL { + --mod-progress-circle-size: var(--spectrum-in-field-progress-circle-size-200); +} + +.spectrum-InfieldProgressCircle--sizeXL { + --mod-progress-circle-size: var(--spectrum-in-field-progress-circle-size-300); +} + +.spectrum-InfieldProgressCircle { + padding-block: var(--spectrum-infieldprogresscircle-padding-block); + + .spectrum-ProgressCircle-fill { + stroke-linecap: square; + } +} diff --git a/components/infieldprogresscircle/package.json b/components/infieldprogresscircle/package.json new file mode 100644 index 00000000000..02e5272e58a --- /dev/null +++ b/components/infieldprogresscircle/package.json @@ -0,0 +1,56 @@ +{ + "name": "@spectrum-css/infieldprogresscircle", + "version": "1.0.0-next.1", + "description": "The Spectrum CSS infieldprogresscircle component", + "license": "Apache-2.0", + "author": "Adobe", + "homepage": "https://opensource.adobe.com/spectrum-css/?path=/docs/components-in-field-progress-circle--docs", + "repository": { + "type": "git", + "url": "https://github.com/adobe/spectrum-css.git", + "directory": "components/infieldprogresscircle" + }, + "bugs": { + "url": "https://github.com/adobe/spectrum-css/issues" + }, + "exports": { + ".": "./dist/index.css", + "./*.md": "./*.md", + "./package.json": "./package.json", + "./dist/*": "./dist/*", + "./index.css": "./dist/index.css", + "./metadata.json": "./dist/metadata.json", + "./stories/*": "./stories/*" + }, + "main": "dist/index.css", + "peerDependencies": { + "@spectrum-css/tokens": ">=16.1.0-next.0" + }, + "peerDependenciesMeta": { + "@spectrum-css/tokens": { + "optional": true + } + }, + "devDependencies": { + "@spectrum-css/tokens": "16.1.0-next.10" + }, + "keywords": [ + "design-system", + "spectrum", + "spectrum-css", + "adobe", + "adobe-spectrum", + "component", + "css" + ], + "publishConfig": { + "access": "public" + }, + "spectrum": [ + { + "guidelines": "https://spectrum.adobe.com/page/progress-circle", + "rootClass": "spectrum-InfieldProgressCircle", + "swc": "https://opensource.adobe.com/spectrum-web-components/components/progress-circle/" + } + ] +} diff --git a/components/infieldprogresscircle/project.json b/components/infieldprogresscircle/project.json new file mode 100644 index 00000000000..ff11b0651fc --- /dev/null +++ b/components/infieldprogresscircle/project.json @@ -0,0 +1,17 @@ +{ + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "name": "infieldprogresscircle", + "tags": ["component"], + "targets": { + "build": {}, + "clean": {}, + "compare": {}, + "format": {}, + "lint": {}, + "report": {}, + "test": { + "defaultConfiguration": "scope" + }, + "validate": {} + } +} diff --git a/components/infieldprogresscircle/stories/infieldprogresscircle.stories.js b/components/infieldprogresscircle/stories/infieldprogresscircle.stories.js new file mode 100644 index 00000000000..bd05e261b83 --- /dev/null +++ b/components/infieldprogresscircle/stories/infieldprogresscircle.stories.js @@ -0,0 +1,125 @@ +import { Sizes } from "@spectrum-css/preview/decorators"; +import { disableDefaultModes } from "@spectrum-css/preview/modes"; +import { size } from "@spectrum-css/preview/types"; +import { default as ProgressCircle } from "@spectrum-css/progresscircle/stories/progresscircle.stories.js"; +import metadata from "../dist/metadata.json"; +import packageJson from "../package.json"; +import { InfieldProgressCircleGroup } from "./infieldprogresscircle.test.js"; +import { Template } from "./template.js"; + +/** + * In-field progress circles are used in t-shirt size components such as [buttons](/docs/components-button--docs), [combo boxes](/docs/components-combobox--docs), and [pickers](/docs/components-picker--docs). The in-field progress circle can be used in place of an icon or in tight spaces when space is limited both vertically and horizontally. +*/ + +export default { + title: "In-field progress circle", + component: "InfieldProgressCircle", + argTypes: { + ...ProgressCircle.argTypes, + size: size(["s", "m", "l", "xl"]), + }, + args: { + ...ProgressCircle.args, + rootClass: "spectrum-InfieldProgressCircle", + }, + parameters: { + ...ProgressCircle.parameters, + design: { + type: "figma", + url: "https://www.figma.com/design/eoZHKJH9a3LJkHYCGt60Vb/S2-token-specs?node-id=14970-6050", + }, + packageJson, + metadata, + status: { + type: "migrated", + }, + }, + tags: ["migrated"], +}; + +export const Default = InfieldProgressCircleGroup.bind({}); +Default.args = {}; + +// ********* VRT ONLY ********* // +export const WithForcedColors = InfieldProgressCircleGroup.bind({}); +WithForcedColors.args = Default.args; +WithForcedColors.tags = ["!autodocs", "!dev"]; +WithForcedColors.parameters = { + chromatic: { + forcedColors: "active", + modes: disableDefaultModes, + }, +}; + +// ********* DOCS ONLY ********* // + +export const Sizing = (args, context) => Sizes({ + Template, + withHeading: false, + withBorder: false, + ...args, +}, context); +Sizing.args = {}; +Sizing.tags = ["!dev"]; +Sizing.parameters = { + chromatic: { disableSnapshot: true }, +}; + +/** + * The indeterminate progress circle displays a repeating animation for the inner fill. + */ +export const Indeterminate = (args, context) => Sizes({ + Template, + withHeading: false, + withBorder: false, + ...args, +}, context); +Indeterminate.args = { + isIndeterminate: true, +}; +Indeterminate.tags = ["!dev"]; +Indeterminate.parameters = { + chromatic: { disableSnapshot: true }, +}; + +export const StaticWhiteDeterminate = Sizing.bind({}); +StaticWhiteDeterminate.tags = ["!dev"]; +StaticWhiteDeterminate.storyName = "Static white, default"; +StaticWhiteDeterminate.args = { + staticColor: "white", +}; +StaticWhiteDeterminate.parameters = { + chromatic: { disableSnapshot: true }, +}; + +export const StaticWhiteIndeterminate = Sizing.bind({}); +StaticWhiteIndeterminate.tags = ["!dev"]; +StaticWhiteIndeterminate.storyName = "Static white, indeterminate"; +StaticWhiteIndeterminate.args = { + staticColor: "white", + isIndeterminate: true, +}; +StaticWhiteIndeterminate.parameters = { + chromatic: { disableSnapshot: true }, +}; + +export const StaticBlackDeterminate = Sizing.bind({}); +StaticBlackDeterminate.tags = ["!dev"]; +StaticBlackDeterminate.storyName = "Static black, default"; +StaticBlackDeterminate.args = { + staticColor: "black", +}; +StaticBlackDeterminate.parameters = { + chromatic: { disableSnapshot: true }, +}; + +export const StaticBlackIndeterminate = Sizing.bind({}); +StaticBlackIndeterminate.tags = ["!dev"]; +StaticBlackIndeterminate.storyName = "Static black, indeterminate"; +StaticBlackIndeterminate.args = { + staticColor: "black", + isIndeterminate: true, +}; +StaticBlackIndeterminate.parameters = { + chromatic: { disableSnapshot: true }, +}; diff --git a/components/infieldprogresscircle/stories/infieldprogresscircle.test.js b/components/infieldprogresscircle/stories/infieldprogresscircle.test.js new file mode 100644 index 00000000000..2ef07f947ab --- /dev/null +++ b/components/infieldprogresscircle/stories/infieldprogresscircle.test.js @@ -0,0 +1,25 @@ +import { Variants } from "@spectrum-css/preview/decorators"; +import { Template } from "./template.js"; + +export const InfieldProgressCircleGroup = Variants({ + Template, + testData: [ + { + testHeading: "Default", + }, + { + testHeading: "Static white", + staticColor: "white", + }, + { + testHeading: "Static black", + staticColor: "black", + }, + ], + stateData: [ + { + testHeading: "Indeterminate", + isIndeterminate: true, + } + ] +}); diff --git a/components/infieldprogresscircle/stories/template.js b/components/infieldprogresscircle/stories/template.js new file mode 100644 index 00000000000..7f8fc1f8de1 --- /dev/null +++ b/components/infieldprogresscircle/stories/template.js @@ -0,0 +1,21 @@ +import { Template as ProgressCircle } from "@spectrum-css/progresscircle/stories/template.js"; +import { capitalize } from "lodash-es"; +import "../index.css"; + +export const Template = ({ + customClasses = [], + rootClass = "spectrum-InfieldProgressCircle", + size = "m", + staticColor, + ...item +} = {}, context = {}) => ProgressCircle({ + customClasses: [ + rootClass, + typeof size !== "undefined" ? `${rootClass}--size${size.toUpperCase()}` : null, + typeof staticColor !== "undefined" ? `${rootClass}--static${capitalize(staticColor)}` : null, + ...customClasses + ].filter(Boolean), + size, + staticColor, + ...item +}, context ); diff --git a/components/inlinealert/CHANGELOG.md b/components/inlinealert/CHANGELOG.md index 51c9a0ee013..26ab6e2ddfc 100644 --- a/components/inlinealert/CHANGELOG.md +++ b/components/inlinealert/CHANGELOG.md @@ -1,5 +1,121 @@ # Change log +## 11.0.0-next.3 + +### Patch Changes + +📝 [#4113](https://github.com/adobe/spectrum-css/pull/4113) [`cf4fc1a`](https://github.com/adobe/spectrum-css/commit/cf4fc1a01d23ba810f45a903ecc29a5c8aae33d1) Thanks [@castastrophe](https://github.com/castastrophe)! + +## Minor linting fixes + +- Removed unused custom properties across multiple components +- Fixed color function notation by converting `rgba()` to `rgb()` where appropriate +- Removed duplicate custom property declarations +- Fixed deprecated CSS properties (e.g., `word-wrap` → `overflow-wrap`) +- Removed unnecessary stylelint-disable comments + +_No visual or functional changes to components._ + +## 11.0.0-next.2 + +### Major Changes + +- [#3659](https://github.com/adobe/spectrum-css/pull/3659) [`83b2fe9`](https://github.com/adobe/spectrum-css/commit/83b2fe9a118936e68628ab02ccb9c03452eb1931) Thanks [@cdransf](https://github.com/cdransf)! + +#### Spectrum 2 migration + +This migrates the `in-line alert` component to Spectrum 2. Custom properties have been updated and added per the design specification. + +Subtle and bold treatments have been added for each badge variant. + +To use the subtle treatment, you will need to apply the `spectrum-InLineAlert--subtle` class: + +```html +
    +
    + Info variant with subtle fill + +
    +
    This is an alert.
    +
    +``` + +To use the bold treatment (which is reserved for high-attention alerts only), you will need to apply the `spectrum-InLineAlert--bold` class: + +```html +
    +
    + Info variant with bold fill + +
    +
    This is an alert.
    +
    +``` + +Because subtle and bold treatments draw a similar level of attention you should choose only one to use consistently within a single product. + +##### New mods + +`--mod-inlinealert-border-and-icon-color-neutral` +`--mod-inlinealert-min-spacing-header-to-icon` +`--mod-inlinealert-spacing-content-link-button` +`--mod-inlinealert-spacing-header-content` + +##### Removed mods + +`--mod-inlinealert-spacing-header-content-button` +`--mod-inlinealert-spacing-header-to-icon` + +##### New custom properties + +`--spectrum-inlinealert-min-spacing-header-to-icon` +`--spectrum-inlinealert-spacing-content-link-button` +`--spectrum-inlinealert-spacing-header-content` + +##### Removed custom properties + +`--spectrum-inlinealert-spacing-header-content-button` +`--spectrum-inlinealert-spacing-header-to-icon` + +## 11.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + +## 11.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`a25e0a9`](https://github.com/adobe/spectrum-css/commit/a25e0a99e5a4736ab4e607e00739343101a2633b)]: + - @spectrum-css/icon@10.0.0-next.0 + - @spectrum-css/button@15.0.0-next.0 + ## 10.2.0 ### Minor Changes @@ -22,8 +138,6 @@ Minor linting fix of replacing `rgba` to the `rgb` shorthand syntax. 📝 [`205182b`](https://github.com/adobe/spectrum-css/commit/205182bebcbe82813457aa098d8799b0a23423ee) Thanks [@castastrophe](https://github.com/castastrophe)! -## New feature - Minified and gzipped outputs available for all compiled CSS assets. ### Patch Changes diff --git a/components/inlinealert/dist/metadata.json b/components/inlinealert/dist/metadata.json index 935c89f08a3..81ebe4df638 100644 --- a/components/inlinealert/dist/metadata.json +++ b/components/inlinealert/dist/metadata.json @@ -2,27 +2,33 @@ "sourceFile": "index.css", "selectors": [ ".spectrum-InLineAlert", - ".spectrum-InLineAlert--info", - ".spectrum-InLineAlert--info .spectrum-InLineAlert-icon", - ".spectrum-InLineAlert--negative", - ".spectrum-InLineAlert--negative .spectrum-InLineAlert-icon", - ".spectrum-InLineAlert--notice", - ".spectrum-InLineAlert--notice .spectrum-InLineAlert-icon", - ".spectrum-InLineAlert--positive", - ".spectrum-InLineAlert--positive .spectrum-InLineAlert-icon", ".spectrum-InLineAlert-content", ".spectrum-InLineAlert-footer", ".spectrum-InLineAlert-footer:empty", ".spectrum-InLineAlert-header", - ".spectrum-InLineAlert-icon" + ".spectrum-InLineAlert-icon", + ".spectrum-InLineAlert.spectrum-InLineAlert--bold", + ".spectrum-InLineAlert.spectrum-InLineAlert--bold:not(.spectrum-InLineAlert--subtle, .spectrum-InLineAlert--notice)", + ".spectrum-InLineAlert.spectrum-InLineAlert--info", + ".spectrum-InLineAlert.spectrum-InLineAlert--info.spectrum-InLineAlert--bold", + ".spectrum-InLineAlert.spectrum-InLineAlert--info.spectrum-InLineAlert--subtle", + ".spectrum-InLineAlert.spectrum-InLineAlert--negative", + ".spectrum-InLineAlert.spectrum-InLineAlert--negative.spectrum-InLineAlert--bold", + ".spectrum-InLineAlert.spectrum-InLineAlert--negative.spectrum-InLineAlert--subtle", + ".spectrum-InLineAlert.spectrum-InLineAlert--neutral", + ".spectrum-InLineAlert.spectrum-InLineAlert--neutral.spectrum-InLineAlert--bold", + ".spectrum-InLineAlert.spectrum-InLineAlert--neutral.spectrum-InLineAlert--subtle", + ".spectrum-InLineAlert.spectrum-InLineAlert--notice", + ".spectrum-InLineAlert.spectrum-InLineAlert--notice.spectrum-InLineAlert--bold", + ".spectrum-InLineAlert.spectrum-InLineAlert--notice.spectrum-InLineAlert--subtle", + ".spectrum-InLineAlert.spectrum-InLineAlert--positive", + ".spectrum-InLineAlert.spectrum-InLineAlert--positive.spectrum-InLineAlert--bold", + ".spectrum-InLineAlert.spectrum-InLineAlert--positive.spectrum-InLineAlert--subtle", + ".spectrum-InLineAlert.spectrum-InLineAlert--subtle" ], "modifiers": [ "--mod-inlinealert-background-color", "--mod-inlinealert-border-and-icon-color", - "--mod-inlinealert-border-and-icon-color-info", - "--mod-inlinealert-border-and-icon-color-negative", - "--mod-inlinealert-border-and-icon-color-notice", - "--mod-inlinealert-border-and-icon-color-positive", "--mod-inlinealert-border-radius", "--mod-inlinealert-border-width", "--mod-inlinealert-content-color", @@ -40,18 +46,15 @@ "--mod-inlinealert-heading-line-height", "--mod-inlinealert-icon-size", "--mod-inlinealert-min-inline-size", + "--mod-inlinealert-min-spacing-header-to-icon", + "--mod-inlinealert-spacing-content-link-button", "--mod-inlinealert-spacing-edge-to-text", - "--mod-inlinealert-spacing-header-content-button", - "--mod-inlinealert-spacing-header-to-icon" + "--mod-inlinealert-spacing-header-content" ], "component": [ "--spectrum-in-line-alert-minimum-width", "--spectrum-inlinealert-background-color", "--spectrum-inlinealert-border-and-icon-color", - "--spectrum-inlinealert-border-and-icon-color-info", - "--spectrum-inlinealert-border-and-icon-color-negative", - "--spectrum-inlinealert-border-and-icon-color-notice", - "--spectrum-inlinealert-border-and-icon-color-positive", "--spectrum-inlinealert-border-radius", "--spectrum-inlinealert-border-width", "--spectrum-inlinealert-content-color", @@ -69,12 +72,14 @@ "--spectrum-inlinealert-heading-line-height", "--spectrum-inlinealert-icon-size", "--spectrum-inlinealert-min-inline-size", + "--spectrum-inlinealert-min-spacing-header-to-icon", + "--spectrum-inlinealert-spacing-content-link-button", "--spectrum-inlinealert-spacing-edge-to-text", - "--spectrum-inlinealert-spacing-header-content-button", - "--spectrum-inlinealert-spacing-header-to-icon" + "--spectrum-inlinealert-spacing-header-content" ], "global": [ "--spectrum-background-layer-2-color", + "--spectrum-black", "--spectrum-body-color", "--spectrum-body-line-height", "--spectrum-body-sans-serif-font-style", @@ -82,27 +87,39 @@ "--spectrum-body-size-s", "--spectrum-border-width-200", "--spectrum-component-height-50", - "--spectrum-corner-radius-100", + "--spectrum-corner-radius-700", "--spectrum-heading-color", "--spectrum-heading-line-height", "--spectrum-heading-sans-serif-font-style", "--spectrum-heading-sans-serif-font-weight", "--spectrum-heading-size-xxs", + "--spectrum-informative-background-color-default", + "--spectrum-informative-subtle-background-color-default", "--spectrum-informative-visual-color", + "--spectrum-negative-background-color-default", + "--spectrum-negative-subtle-background-color-default", "--spectrum-negative-visual-color", + "--spectrum-neutral-background-color-default", + "--spectrum-neutral-subtle-background-color-default", "--spectrum-neutral-visual-color", + "--spectrum-notice-background-color-default", + "--spectrum-notice-subtle-background-color-default", "--spectrum-notice-visual-color", + "--spectrum-positive-background-color-default", + "--spectrum-positive-subtle-background-color-default", "--spectrum-positive-visual-color", "--spectrum-sans-font-family-stack", + "--spectrum-spacing-100", + "--spectrum-spacing-200", "--spectrum-spacing-300", - "--spectrum-spacing-400", + "--spectrum-white", "--spectrum-workflow-icon-size-100" ], - "system-theme": [], "passthroughs": [], "high-contrast": [ "--highcontrast-inlinealert-background-color", "--highcontrast-inlinealert-border-and-icon-color", + "--highcontrast-inlinealert-border-width", "--highcontrast-inlinealert-content-color", "--highcontrast-inlinealert-header-color" ] diff --git a/components/inlinealert/index.css b/components/inlinealert/index.css index 50ca8f0cac4..62cf0bf3b97 100644 --- a/components/inlinealert/index.css +++ b/components/inlinealert/index.css @@ -1,5 +1,5 @@ /*! - * Copyright 2024 Adobe. All rights reserved. + * Copyright 2025 Adobe. All rights reserved. * * This file is licensed to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. You may obtain a copy @@ -27,26 +27,105 @@ /* Size */ --spectrum-inlinealert-border-width: var(--spectrum-border-width-200); - --spectrum-inlinealert-border-radius: var(--spectrum-corner-radius-100); + --spectrum-inlinealert-border-radius: var(--spectrum-corner-radius-700); --spectrum-inlinealert-icon-size: var(--spectrum-workflow-icon-size-100); --spectrum-inlinealert-min-inline-size: var(--spectrum-in-line-alert-minimum-width); --spectrum-inlinealert-header-min-block-size: var(--spectrum-component-height-50); /* Spacing */ - --spectrum-inlinealert-spacing-edge-to-text: var(--spectrum-spacing-400); - --spectrum-inlinealert-spacing-header-to-icon: var(--spectrum-spacing-400); - --spectrum-inlinealert-spacing-header-content-button: var(--spectrum-spacing-300); + --spectrum-inlinealert-spacing-edge-to-text: var(--spectrum-spacing-300); + --spectrum-inlinealert-min-spacing-header-to-icon: var(--spectrum-spacing-100); + --spectrum-inlinealert-spacing-header-content: var(--spectrum-spacing-100); + --spectrum-inlinealert-spacing-content-link-button: var(--spectrum-spacing-200); /* Color */ --spectrum-inlinealert-background-color: var(--spectrum-background-layer-2-color); --spectrum-inlinealert-border-and-icon-color: var(--spectrum-neutral-visual-color); --spectrum-inlinealert-header-color: var(--spectrum-heading-color); --spectrum-inlinealert-content-color: var(--spectrum-body-color); - --spectrum-inlinealert-border-and-icon-color-info: var(--spectrum-informative-visual-color); - --spectrum-inlinealert-border-and-icon-color-positive: var(--spectrum-positive-visual-color); - --spectrum-inlinealert-border-and-icon-color-notice: var(--spectrum-notice-visual-color); - --spectrum-inlinealert-border-and-icon-color-negative: var(--spectrum-negative-visual-color); + &.spectrum-InLineAlert--subtle { + --spectrum-inlinealert-border-width: 0px; + } + + &.spectrum-InLineAlert--bold { + --spectrum-inlinealert-border-width: 0px; + } + + &.spectrum-InLineAlert--bold:not(.spectrum-InLineAlert--subtle, .spectrum-InLineAlert--notice) { + --spectrum-inlinealert-header-color: var(--spectrum-white); + --spectrum-inlinealert-content-color: var(--spectrum-white); + --spectrum-inlinealert-border-and-icon-color: var(--spectrum-white); + } + + &.spectrum-InLineAlert--info { + --spectrum-inlinealert-border-and-icon-color: var(--spectrum-informative-visual-color); + + &.spectrum-InLineAlert--subtle { + --spectrum-inlinealert-background-color: var(--spectrum-informative-subtle-background-color-default); + --spectrum-inlinealert-border-and-icon-color: var(--spectrum-informative-visual-color); + } + + &.spectrum-InLineAlert--bold { + --spectrum-inlinealert-background-color: var(--spectrum-informative-background-color-default); + } + } + + &.spectrum-InLineAlert--notice { + --spectrum-inlinealert-border-and-icon-color: var(--spectrum-notice-visual-color); + + &.spectrum-InLineAlert--subtle { + --spectrum-inlinealert-background-color: var(--spectrum-notice-subtle-background-color-default); + --spectrum-inlinealert-border-and-icon-color: var(--spectrum-notice-visual-color); + } + + &.spectrum-InLineAlert--bold { + --spectrum-inlinealert-background-color: var(--spectrum-notice-background-color-default); + --spectrum-inlinealert-border-and-icon-color: var(--spectrum-black); + } + } + + &.spectrum-InLineAlert--positive { + --spectrum-inlinealert-border-and-icon-color: var(--spectrum-positive-visual-color); + + &.spectrum-InLineAlert--subtle { + --spectrum-inlinealert-background-color: var(--spectrum-positive-subtle-background-color-default); + --spectrum-inlinealert-border-and-icon-color: var(--spectrum-positive-visual-color); + } + + &.spectrum-InLineAlert--bold { + --spectrum-inlinealert-background-color: var(--spectrum-positive-background-color-default); + } + } + + &.spectrum-InLineAlert--negative { + --spectrum-inlinealert-border-and-icon-color: var(--spectrum-negative-visual-color); + + &.spectrum-InLineAlert--subtle { + --spectrum-inlinealert-background-color: var(--spectrum-negative-subtle-background-color-default); + --spectrum-inlinealert-border-and-icon-color: var(--spectrum-negative-visual-color); + } + + &.spectrum-InLineAlert--bold { + --spectrum-inlinealert-background-color: var(--spectrum-negative-background-color-default); + } + } + + &.spectrum-InLineAlert--neutral { + --spectrum-inlinealert-border-and-icon-color: var(--spectrum-neutral-visual-color); + + &.spectrum-InLineAlert--subtle { + --spectrum-inlinealert-background-color: var(--spectrum-neutral-subtle-background-color-default); + --spectrum-inlinealert-border-and-icon-color: var(--spectrum-neutral-visual-color); + } + + &.spectrum-InLineAlert--bold { + --spectrum-inlinealert-background-color: var(--spectrum-neutral-background-color-default); + } + } +} + +.spectrum-InLineAlert { position: relative; display: inline-block; @@ -56,8 +135,7 @@ padding-block: var(--mod-inlinealert-spacing-edge-to-text, var(--spectrum-inlinealert-spacing-edge-to-text)); padding-inline: var(--mod-inlinealert-spacing-edge-to-text, var(--spectrum-inlinealert-spacing-edge-to-text)); - border-block-width: var(--mod-inlinealert-border-width, var(--spectrum-inlinealert-border-width)); - border-inline-width: var(--mod-inlinealert-border-width, var(--spectrum-inlinealert-border-width)); + border-width: var(--highcontrast-inlinealert-border-width, var(--mod-inlinealert-border-width, var(--spectrum-inlinealert-border-width))); border-style: solid; border-radius: var(--mod-inlinealert-border-radius, var(--spectrum-inlinealert-border-radius)); @@ -65,27 +143,19 @@ border-color: var(--highcontrast-inlinealert-border-and-icon-color, var(--mod-inlinealert-border-and-icon-color, var(--spectrum-inlinealert-border-and-icon-color))); } -@media (forced-colors: active) { - .spectrum-InLineAlert { - --highcontrast-inlinealert-background-color: Background; - --highcontrast-inlinealert-header-color: CanvasText; - --highcontrast-inlinealert-content-color: CanvasText; - --highcontrast-inlinealert-border-and-icon-color: ButtonBorder; - } -} - .spectrum-InLineAlert-icon { inline-size: var(--mod-inlinealert-icon-size, var(--spectrum-inlinealert-icon-size)); block-size: var(--mod-inlinealert-icon-size, var(--spectrum-inlinealert-icon-size)); + flex-shrink: 0; + color: var(--highcontrast-inlinealert-border-and-icon-color, var(--spectrum-inlinealert-border-and-icon-color)); } .spectrum-InLineAlert-header { display: flex; - align-items: center; justify-content: space-between; - /* Minimum space between header and icon */ - gap: var(--mod-inlinealert-spacing-header-to-icon, var(--spectrum-inlinealert-spacing-header-to-icon)); + gap: var(--mod-inlinealert-min-spacing-header-to-icon, var(--spectrum-inlinealert-min-spacing-header-to-icon)); + margin-block-end: var(--mod-inlinealert-spacing-header-content, var(--spectrum-inlinealert-spacing-header-content)); font-weight: var(--mod-inlinealert-heading-font-weight, var(--spectrum-inlinealert-heading-font-weight)); font-family: var(--mod-inlinealert-heading-font-family, var(--spectrum-inlinealert-heading-font-family)); @@ -100,8 +170,10 @@ } .spectrum-InLineAlert-content { - display: block; - margin-block-start: var(--mod-inlinealert-spacing-header-content-button, var(--spectrum-inlinealert-spacing-header-content-button)); + display: flex; + justify-content: space-between; + gap: var(--mod-inlinealert-min-spacing-header-to-icon, var(--spectrum-inlinealert-min-spacing-header-to-icon)); + margin-block-end: 0; margin-inline-start: 0; margin-inline-end: 0; @@ -120,42 +192,25 @@ .spectrum-InLineAlert-footer { display: flex; - justify-content: flex-end; - margin-block-start: var(--mod-inlinealert-spacing-header-content-button, var(--spectrum-inlinealert-spacing-header-content-button)); + justify-content: flex-start; + margin-block-start: var(--mod-inlinealert-spacing-content-link-button, var(--spectrum-inlinealert-spacing-content-link-button)); &:empty { display: none; } } -.spectrum-InLineAlert--info { - border-color: var(--highcontrast-inlinealert-border-and-icon-color, var(--mod-inlinealert-border-and-icon-color-info, var(--spectrum-inlinealert-border-and-icon-color-info))); - - .spectrum-InLineAlert-icon { - color: var(--highcontrast-inlinealert-border-and-icon-color, var(--mod-inlinealert-border-and-icon-color-info, var(--spectrum-inlinealert-border-and-icon-color-info))); - } -} - -.spectrum-InLineAlert--notice { - border-color: var(--highcontrast-inlinealert-border-and-icon-color, var(--mod-inlinealert-border-and-icon-color-notice, var(--spectrum-inlinealert-border-and-icon-color-notice))); - - .spectrum-InLineAlert-icon { - color: var(--highcontrast-inlinealert-border-and-icon-color, var(--mod-inlinealert-border-and-icon-color-notice, var(--spectrum-inlinealert-border-and-icon-color-notice))); - } -} - -.spectrum-InLineAlert--positive { - border-color: var(--highcontrast-inlinealert-border-and-icon-color, var(--mod-inlinealert-border-and-icon-color-positive, var(--spectrum-inlinealert-border-and-icon-color-positive))); - - .spectrum-InLineAlert-icon { - color: var(--highcontrast-inlinealert-border-and-icon-color, var(--mod-inlinealert-border-and-icon-color-positive, var(--spectrum-inlinealert-border-and-icon-color-positive))); - } -} +@media (forced-colors: active) { + .spectrum-InLineAlert { + --highcontrast-inlinealert-header-color: CanvasText; + --highcontrast-inlinealert-content-color: CanvasText; + --highcontrast-inlinealert-border-and-icon-color: CanvasText; -.spectrum-InLineAlert--negative { - border-color: var(--highcontrast-inlinealert-border-and-icon-color, var(--mod-inlinealert-border-and-icon-color-negative, var(--spectrum-inlinealert-border-and-icon-color-negative))); + --highcontrast-inlinealert-background-color: Canvas; - .spectrum-InLineAlert-icon { - color: var(--highcontrast-inlinealert-border-and-icon-color, var(--mod-inlinealert-border-and-icon-color-negative, var(--spectrum-inlinealert-border-and-icon-color-negative))); + &.spectrum-InLineAlert--subtle, + &.spectrum-InLineAlert--bold { + --highcontrast-inlinealert-border-width: var(--spectrum-border-width-200); + } } } diff --git a/components/inlinealert/package.json b/components/inlinealert/package.json index ad2b390dfe5..09503b23ef1 100644 --- a/components/inlinealert/package.json +++ b/components/inlinealert/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/inlinealert", - "version": "10.2.0", + "version": "11.0.0-next.3", "description": "The Spectrum CSS in-line alert component", "license": "Apache-2.0", "author": "Adobe", @@ -24,9 +24,9 @@ }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/button": ">=14.0.0 <15.0.0", - "@spectrum-css/icon": ">=9.0.0 <10.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/button": ">=15.0.0-next.0", + "@spectrum-css/icon": ">=10.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/button": { @@ -40,9 +40,9 @@ } }, "devDependencies": { - "@spectrum-css/button": "14.2.0", - "@spectrum-css/icon": "9.2.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/button": "15.0.0-next.2", + "@spectrum-css/icon": "10.0.0-next.3", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/inlinealert/stories/inlinealert.stories.js b/components/inlinealert/stories/inlinealert.stories.js index 6ed4d7c5f18..31f6ac0414f 100644 --- a/components/inlinealert/stories/inlinealert.stories.js +++ b/components/inlinealert/stories/inlinealert.stories.js @@ -2,10 +2,12 @@ import { disableDefaultModes } from "@spectrum-css/preview/modes"; import metadata from "../dist/metadata.json"; import packageJson from "../package.json"; import { InlineAlertGroup } from "./inlinealert.test.js"; -import { Template } from "./template.js"; +import { AlertsWithStyleOptions } from "./template.js"; /** * In-line alerts display a non-modal message associated with objects in a view. These are often used in form validation, providing a place to aggregate feedback related to multiple fields. + * + * In-line alerts have five different variants: neutral (default), informative, positive, notice, and negative. Each variant is available with three fill styles (treatment): border (default), subtle, and bold. */ export default { title: "In-line alert", @@ -20,19 +22,29 @@ export default { category: "Content", }, control: { type: "text" }, + if: { arg: "withoutHeader", truthy: false }, }, text: { - name: "Text", + name: "Body text", type: { name: "string", required: true }, table: { type: { summary: "string" }, disable: false, - category: "Component", + category: "Content", }, control: { type: "text" }, }, + withoutHeader: { + name: "Without header", + type: { name: "boolean" }, + table: { + type: { summary: "boolean" }, + category: "Component", + }, + control: "boolean", + }, variant: { - name: "Variants", + name: "Variant", type: { name: "string" }, table: { type: { summary: "string" }, @@ -41,8 +53,29 @@ export default { options: ["neutral", "info", "positive", "notice", "negative"], control: "select", }, + treatment: { + name: "Treatment", + type: { name: "string" }, + table: { + type: { summary: "string" }, + category: "Component", + }, + options: ["border", "subtle", "bold"], + control: "select", + }, isClosable: { name: "Closable", + description: "An optional close button rendered below the alert text and link (if enabled).", + type: { name: "boolean" }, + table: { + type: { summary: "boolean" }, + category: "Advanced", + }, + control: "boolean", + }, + hasLink: { + name: "Link", + description: "An optional link rendered below the alert text.", type: { name: "boolean" }, table: { type: { summary: "boolean" }, @@ -53,10 +86,13 @@ export default { }, args: { rootClass: "spectrum-InLineAlert", - headerText: "Neutral in-line alert header", + headerText: "In-line alert header", text: "This is an alert.", + withoutHeader: false, variant: "neutral", + treatment: "border", isClosable: false, + hasLink: false, }, parameters: { design: { @@ -65,7 +101,11 @@ export default { }, packageJson, metadata, + status: { + type: "migrated", + }, }, + tags: ["migrated"], }; /** @@ -74,13 +114,23 @@ export default { export const Default = InlineAlertGroup.bind({}); Default.args = {}; +/** + * In-line alerts may be rendered without a header. Combine this strategy with any variant. + */ +export const WithoutHeader = InlineAlertGroup.bind({}); +WithoutHeader.args = { + withoutHeader: true, +}; +WithoutHeader.parameters = { + chromatic: { disableSnapshot: true }, +}; +WithoutHeader.tags = ["!dev"]; + // ********* DOCS ONLY ********* // /** * The informative variant uses the informative semantic color (blue) and has an "information" icon to help those with color vision deficiency discern the message tone. This should be used when the message needs to call extra attention, as compared to the neutral variant. - * - * _Spectrum for Adobe Express uses a different icon. Use the SX_Info_18_S.svg icon in the Express workflow icon set._ */ -export const Informative = Template.bind({}); +export const Informative = AlertsWithStyleOptions.bind({}); Informative.args = { variant: "info", headerText: "Info in-line alert header", @@ -92,10 +142,8 @@ Informative.tags = ["!dev"]; /** * A negative variant uses the negative semantic color (red) and has an "alert" icon to help those with color vision deficiency to discern the message tone. Negative variants are used to show an error or failure, or to convey something that needs to be immediately acknowledged or addressed. - * - * _Spectrum for Adobe Express uses a different icon. Use the SX_Alert_18_S.svg icon in the Express workflow icon set._ */ -export const Negative = Template.bind({}); +export const Negative = AlertsWithStyleOptions.bind({}); Negative.args = { variant: "negative", headerText: "Negative in-line alert header", @@ -105,12 +153,23 @@ Negative.parameters = { }; Negative.tags = ["!dev"]; +/** + * Neutral (default) variant alerts may also use the subtle and bold treatments available to other variants. + */ +export const Neutral = AlertsWithStyleOptions.bind({}); +Neutral.args = { + variant: "neutral", + headerText: "Neutral in-line alert header", +}; +Neutral.parameters = { + chromatic: { disableSnapshot: true }, +}; +Neutral.tags = ["!dev"]; + /** * The positive variant uses the positive semantic color (green) and has a "checkmark" icon to help those with color vision deficiency discern the message tone. This variant should be used to inform someone of a successful function or result of an action they took. - * - * _Spectrum for Adobe Express uses a different icon. Use the SX_CheckmarkCircle_18_S.svg icon in the Express workflow icon set._ */ -export const Positive = Template.bind({}); +export const Positive = AlertsWithStyleOptions.bind({}); Positive.args = { variant: "positive", headerText: "Positive in-line alert header", @@ -122,10 +181,8 @@ Positive.tags = ["!dev"]; /** * To warn about a situation that may need to be addressed soon, use the notice variant. It utilizes the notice semantic color (orange) and has an "alert" icon to help those with color vision deficiency to discern the message tone. - * - * _Spectrum for Adobe Express uses a different icon. Use the SX_Alert_18_S.svg icon in the Express workflow icon set._ */ -export const Notice = Template.bind({}); +export const Notice = AlertsWithStyleOptions.bind({}); Notice.args = { variant: "notice", headerText: "Notice in-line alert header", @@ -137,19 +194,44 @@ Notice.tags = ["!dev"]; /** * An in-line alert with a close button in the footer. Combine this strategy with any variant. - * - * _Spectrum for Adobe Express uses a different icon. Use the SX_Alert_18_S.svg icon in the Express workflow icon set._ */ -export const Closable = Template.bind({}); -Closable.args = { +export const WithFooterClosable = AlertsWithStyleOptions.bind({}); +WithFooterClosable.args = { variant: "negative", isClosable: true, - headerText: "Incorrect payment information - error", + text: "Incorrect payment information - error", +}; +WithFooterClosable.parameters = { + chromatic: { disableSnapshot: true }, +}; +WithFooterClosable.tags = ["!dev"]; + +/** + * An in-line alert with a link in the footer. Combine this strategy with any variant. + */ +export const WithFooterLink = AlertsWithStyleOptions.bind({}); +WithFooterLink.args = { + hasLink: true, + text: "Click the link", +}; +WithFooterLink.parameters = { + chromatic: { disableSnapshot: true }, +}; +WithFooterLink.tags = ["!dev"]; + +/** + * An in-line alert with a link and close button in the footer. Combine this strategy with any variant. + */ +export const WithFooterLinkAndClosable = AlertsWithStyleOptions.bind({}); +WithFooterLinkAndClosable.args = { + hasLink: true, + isClosable: true, + text: "Click the link or close the alert", }; -Closable.parameters = { +WithFooterLinkAndClosable.parameters = { chromatic: { disableSnapshot: true }, }; -Closable.tags = ["!dev"]; +WithFooterLinkAndClosable.tags = ["!dev"]; // ********* VRT ONLY ********* // export const WithForcedColors = InlineAlertGroup.bind({}); diff --git a/components/inlinealert/stories/inlinealert.test.js b/components/inlinealert/stories/inlinealert.test.js index 4f74e3bad08..4aa070b4a6f 100644 --- a/components/inlinealert/stories/inlinealert.test.js +++ b/components/inlinealert/stories/inlinealert.test.js @@ -12,6 +12,7 @@ export const InlineAlertGroup = Variants({ })), { testHeading: "Truncation", + variant: "info", headerText: "In-line alert header announcing something very long and in-line", text: "This is a very urgent alert with a lot of context, so the text has to wrap.", customStyles: {"max-width": "400px"} @@ -22,5 +23,58 @@ export const InlineAlertGroup = Variants({ testHeading: "Closable", isClosable: true, }, + { + testHeading: "Without header", + withoutHeader: true, + }, + { + testHeading: "Link", + hasLink: true, + }, + { + testHeading: "Link + closable", + isClosable: true, + hasLink: true, + }, + { + testHeading: "Subtle", + treatment: "subtle", + }, + { + testHeading: "Bold", + treatment: "bold", + }, + { + testHeading: "Subtle + closable", + treatment: "subtle", + isClosable: true, + }, + { + testHeading: "Subtle + link + closable", + treatment: "subtle", + isClosable: true, + hasLink: true, + }, + { + testHeading: "Bold + closable", + treatment: "bold", + isClosable: true, + }, + { + testHeading: "Subtle + link", + treatment: "subtle", + hasLink: true, + }, + { + testHeading: "Bold + link", + treatment: "bold", + hasLink: true, + }, + { + testHeading: "Bold + link + closable", + treatment: "bold", + isClosable: true, + hasLink: true, + }, ], }); diff --git a/components/inlinealert/stories/template.js b/components/inlinealert/stories/template.js index f5439cf8c4d..c2233414253 100644 --- a/components/inlinealert/stories/template.js +++ b/components/inlinealert/stories/template.js @@ -1,8 +1,10 @@ import { Template as Button } from "@spectrum-css/button/stories/template.js"; import { Template as Icon } from "@spectrum-css/icon/stories/template.js"; +import { Template as Link } from "@spectrum-css/link/stories/template.js"; import { html, nothing } from "lit"; import { classMap } from "lit/directives/class-map.js"; import { styleMap } from "lit/directives/style-map.js"; +import { Container } from "@spectrum-css/preview/decorators"; import "../index.css"; @@ -12,21 +14,26 @@ export const Template = ({ customStyles = {}, headerText, text, + withoutHeader = false, variant = "neutral", + treatment = "border", isClosable = false, + hasLink = false, } = {}, context = {}) => { let iconName; switch (variant) { case "info": - iconName = "Info"; + iconName = "InfoCircle"; break; case "positive": iconName = "CheckmarkCircle"; break; case "notice": + iconName = "AlertDiamond"; + break; case "negative": case "closable": - iconName = "Alert"; + iconName = "AlertTriangle"; break; default: iconName = undefined; @@ -40,6 +47,24 @@ export const Template = ({ customClasses: [`${rootClass}-icon`], }, context) : nothing; + + const titleMarkup = !withoutHeader ? html` +
    + ${headerText} + ${iconMarkup} +
    + ` : nothing; + + const linkMarkup = hasLink ? html` + + ` : nothing; + const closableMarkup = isClosable ? html` ` : nothing; @@ -57,17 +83,53 @@ export const Template = ({ class=${classMap({ [rootClass]: true, [`${rootClass}--${variant}`]: typeof variant !== "undefined", + [`${rootClass}--${treatment}`]: treatment !== "border", ...customClasses.reduce((a, c) => ({ ...a, [c]: true }), {}), })} style=${styleMap(customStyles)} > -
    - ${headerText} - ${iconMarkup} + ${titleMarkup} +
    + ${text} + ${withoutHeader ? iconMarkup : nothing}
    -
    ${text}
    + ${linkMarkup} ${closableMarkup}
    `; }; + +/** + * Convert provided string to title case + */ +const toTitleCase = (string) => string.replace(/\w\S*/g, text => text.charAt(0).toUpperCase() + text.substring(1).toLowerCase()); + +/** + * Set the appropriate treatment header text + */ +const setTreatmentHeaderText = (variant, treatment) => `${toTitleCase(variant)} variant with ${treatment !== "border" ? treatment : "outline"} fill`; + +export const AlertsWithStyleOptions = (args, context = {}) => Container({ + withBorder: false, + direction: "row", + wrapperStyles: { + columnGap: "12px", + }, + content: [ + Template({ + ...args, + headerText: setTreatmentHeaderText(args.variant, "border"), + }, context), + Template({ + ...args, + treatment: "subtle", + headerText: setTreatmentHeaderText(args.variant, "subtle"), + }, context), + Template({ + ...args, + treatment: "bold", + headerText: setTreatmentHeaderText(args.variant, "bold"), + }, context), + ], +}, context); diff --git a/components/link/CHANGELOG.md b/components/link/CHANGELOG.md index e45ac0f6125..0a7a2595893 100644 --- a/components/link/CHANGELOG.md +++ b/components/link/CHANGELOG.md @@ -1,5 +1,58 @@ # Change log +## 8.0.0-next.2 + +### Minor Changes + +- [#3861](https://github.com/adobe/spectrum-css/pull/3861) [`911a7cf`](https://github.com/adobe/spectrum-css/commit/911a7cf8b3a651f3e86d67b7b1c08ee1de540c17) Thanks [@cdransf](https://github.com/cdransf)! - Fixes keyboard focus shift by changing padding to outline-offset + +### Patch Changes + +- [#3687](https://github.com/adobe/spectrum-css/pull/3687) [`53d1e5e`](https://github.com/adobe/spectrum-css/commit/53d1e5e7eb7817c37be3cfe5a253363dea744046) Thanks [@marissahuysentruyt](https://github.com/marissahuysentruyt)! - ### S2 link fix + + This work adds the static color focus ring tokens to links (so that static white and static black links do _not_ have the usual blue focus ring). + +## 8.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + +## 8.0.0-next.0 + +### Major Changes + +📝 [#3570](https://github.com/adobe/spectrum-css/pull/3570) [`c88fcdc`](https://github.com/adobe/spectrum-css/commit/c88fcdcfa4866f4b3ff7a1027e4253b8f2114351) Thanks [@aramos-adobe](https://github.com/aramos-adobe)! + +#### Link S2 migration + +The link component is updated with S2 specifications, colors, and typography. There is a new inline variant which uses the `.spectrum-Link--inline` modifier class and the default is the standalone variant. + +##### Note + +- Quiet styling does not apply to the inline variant so that it is distinguishable from the surrounding text and the underline indicator is clear +- `--mod-spectrum-link-font-weight` can be used to adjust inline variant to match surrounding text. Apply font weights to this mod `inherit` does not apply. + +#### New tokens + +##### Color + +`spectrum-link-focus-indicator-color` +`spectrum-link-focus-indicator-thickness` +`spectrum-link-focus-indicator-gap` +`spectrum-link-corner-radius` + +##### Typography + +`spectrum-link-line-height` +`spectrum-link-line-height-cjk-100` +`spectrum-link-font-size` +`spectrum-link-font-style` +`spectrum-link-font-weight` +`spectrum-link-text-underline-thickness` +`spectrum-link-text-underline-gap` + ## 7.2.0 ### Minor Changes diff --git a/components/link/dist/metadata.json b/components/link/dist/metadata.json index 9befaceefc4..9c83915a752 100644 --- a/components/link/dist/metadata.json +++ b/components/link/dist/metadata.json @@ -2,6 +2,7 @@ "sourceFile": "index.css", "selectors": [ ".spectrum-Link", + ".spectrum-Link--inline", ".spectrum-Link--quiet", ".spectrum-Link--quiet:hover", ".spectrum-Link--secondary", @@ -9,26 +10,41 @@ ".spectrum-Link--staticWhite", ".spectrum-Link:active", ".spectrum-Link:focus-visible", - ".spectrum-Link:hover" + ".spectrum-Link:hover", + ".spectrum-Link:lang(ja)", + ".spectrum-Link:lang(ko)", + ".spectrum-Link:lang(zh)" ], "modifiers": [ "--mod-link-animation-duration", + "--mod-link-inline-font-weight", + "--mod-link-line-height-cjk", "--mod-link-text-color", "--mod-link-text-color-active", "--mod-link-text-color-black", "--mod-link-text-color-focus", "--mod-link-text-color-hover", - "--mod-link-text-color-primary-active", - "--mod-link-text-color-primary-default", - "--mod-link-text-color-primary-focus", - "--mod-link-text-color-primary-hover", "--mod-link-text-color-secondary-active", "--mod-link-text-color-secondary-default", "--mod-link-text-color-secondary-focus", "--mod-link-text-color-secondary-hover", "--mod-link-text-color-white" ], - "component": [], + "component": [ + "--spectrum-link-corner-radius", + "--spectrum-link-default-font-family", + "--spectrum-link-focus-indicator-color", + "--spectrum-link-focus-indicator-gap", + "--spectrum-link-focus-indicator-thickness", + "--spectrum-link-font-size", + "--spectrum-link-font-style", + "--spectrum-link-font-weight", + "--spectrum-link-inline-font-weight", + "--spectrum-link-line-height", + "--spectrum-link-line-height-cjk", + "--spectrum-link-text-underline-gap", + "--spectrum-link-text-underline-thickness" + ], "global": [ "--spectrum-accent-content-color-default", "--spectrum-accent-content-color-down", @@ -36,13 +52,30 @@ "--spectrum-accent-content-color-key-focus", "--spectrum-animation-duration-100", "--spectrum-black", + "--spectrum-cjk-line-height-100", + "--spectrum-corner-radius-100", + "--spectrum-default-font-style", + "--spectrum-focus-indicator-color", + "--spectrum-focus-indicator-gap", + "--spectrum-focus-indicator-thickness", + "--spectrum-font-size-100", + "--spectrum-line-height-100", + "--spectrum-medium-font-weight", "--spectrum-neutral-content-color-default", "--spectrum-neutral-content-color-down", "--spectrum-neutral-content-color-hover", "--spectrum-neutral-content-color-key-focus", + "--spectrum-regular-font-weight", + "--spectrum-sans-font-family-stack", + "--spectrum-static-black-focus-indicator-color", + "--spectrum-static-white-focus-indicator-color", + "--spectrum-text-underline-gap", + "--spectrum-text-underline-thickness", "--spectrum-white" ], - "system-theme": [], "passthroughs": [], - "high-contrast": ["--highcontrast-link-text-color"] + "high-contrast": [ + "--highcontrast-link-focus-indicator-color", + "--highcontrast-link-text-color" + ] } diff --git a/components/link/index.css b/components/link/index.css index 97a5f291228..9c49d650727 100644 --- a/components/link/index.css +++ b/components/link/index.css @@ -11,21 +11,28 @@ * governing permissions and limitations under the License. */ -/* Windows high contrast mode */ -@media (forced-colors: active) { - .spectrum-Link { - --highcontrast-link-text-color: LinkText; - } -} +.spectrum-Link { + /* Focus state */ + --spectrum-link-focus-indicator-color: var(--spectrum-focus-indicator-color); + --spectrum-link-focus-indicator-thickness: var(--spectrum-focus-indicator-thickness); + --spectrum-link-focus-indicator-gap: var(--spectrum-focus-indicator-gap); + --spectrum-link-corner-radius: var(--spectrum-corner-radius-100); -.spectrum-Link--secondary { - --mod-link-text-color: var(--mod-link-text-color-secondary-default, var(--spectrum-neutral-content-color-default)); - --mod-link-text-color-hover: var(--mod-link-text-color-secondary-hover, var(--spectrum-neutral-content-color-hover)); - --mod-link-text-color-active: var(--mod-link-text-color-secondary-active, var(--spectrum-neutral-content-color-down)); - --mod-link-text-color-focus: var(--mod-link-text-color-secondary-focus, var(--spectrum-neutral-content-color-key-focus)); -} + /* Typography */ + --spectrum-link-default-font-family: var(--spectrum-sans-font-family-stack); + + /* Standalone */ + --spectrum-link-line-height: var(--spectrum-line-height-100); + --spectrum-link-line-height-cjk: var(--spectrum-cjk-line-height-100); + --spectrum-link-font-size: var(--spectrum-font-size-100); + --spectrum-link-font-style: var(--spectrum-default-font-style); + --spectrum-link-font-weight: var(--spectrum-medium-font-weight); + --spectrum-link-text-underline-thickness: var(--spectrum-text-underline-thickness); + --spectrum-link-text-underline-gap: var(--spectrum-text-underline-gap); + + /* Inline */ + --spectrum-link-inline-font-weight: var(--spectrum-regular-font-weight); -.spectrum-Link { /* Remove the gray background on active links in IE 10. */ background-color: transparent; @@ -36,29 +43,45 @@ outline: none; cursor: pointer; - /* @deprecated --mod-link-text-color-primary-default in favor of --mod-link-text-color */ - color: var(--highcontrast-link-text-color, var(--mod-link-text-color, var(--mod-link-text-color-primary-default, var(--spectrum-accent-content-color-default)))); + color: var(--highcontrast-link-text-color, var(--mod-link-text-color, var(--spectrum-accent-content-color-default))); + font-family: var(--spectrum-link-default-font-family); + font-weight: var(--spectrum-link-font-weight); + font-size: var(--spectrum-link-font-size); + font-style: var(--spectrum-link-font-style); + line-height: var(--spectrum-link-line-height); + text-decoration-thickness: var(--spectrum-link-text-underline-thickness); + text-underline-offset: var(--spectrum-link-text-underline-gap); &:hover { - /* @deprecated --mod-link-text-color-primary-hover in favor of --mod-link-text-color-hover */ - --mod-link-text-color: var(--mod-link-text-color-hover, var(--mod-link-text-color-primary-hover, var(--spectrum-accent-content-color-hover))); + --mod-link-text-color: var(--mod-link-text-color-hover, var(--spectrum-accent-content-color-hover)); } &:active { - /* @deprecated --mod-link-text-color-primary-active in favor of --mod-link-text-color-active */ - --mod-link-text-color: var(--mod-link-text-color-active, var(--mod-link-text-color-primary-active, var(--spectrum-accent-content-color-down))); + --mod-link-text-color: var(--mod-link-text-color-active, var(--spectrum-accent-content-color-down)); } &:focus-visible { - /* @deprecated --mod-link-text-color-primary-focus in favor of --mod-link-text-color-focus */ - --mod-link-text-color: var(--mod-link-text-color-focus, var(--mod-link-text-color-primary-focus, var(--spectrum-accent-content-color-key-focus))); + --mod-link-text-color: var(--mod-link-text-color-focus, var(--spectrum-accent-content-color-key-focus)); - text-decoration: underline; - text-decoration-style: double; - text-decoration-color: inherit; + outline: var(--spectrum-link-focus-indicator-thickness) solid var(--highcontrast-link-focus-indicator-color, var(--spectrum-link-focus-indicator-color)); + outline-offset: var(--spectrum-link-focus-indicator-gap); + border-radius: var(--spectrum-link-corner-radius); + } + + &:lang(ja), + &:lang(zh), + &:lang(ko) { + line-height: var(--mod-link-line-height-cjk, var(--spectrum-link-line-height-cjk)); } } +.spectrum-Link--secondary { + --mod-link-text-color: var(--mod-link-text-color-secondary-default, var(--spectrum-neutral-content-color-default)); + --mod-link-text-color-hover: var(--mod-link-text-color-secondary-hover, var(--spectrum-neutral-content-color-hover)); + --mod-link-text-color-active: var(--mod-link-text-color-secondary-active, var(--spectrum-neutral-content-color-down)); + --mod-link-text-color-focus: var(--mod-link-text-color-secondary-focus, var(--spectrum-neutral-content-color-key-focus)); +} + .spectrum-Link--quiet { text-decoration: none; @@ -67,11 +90,17 @@ } } +.spectrum-Link--inline { + --spectrum-link-font-weight: var(--mod-link-inline-font-weight, var(--spectrum-link-inline-font-weight)); +} + .spectrum-Link--staticWhite { --mod-link-text-color: var(--mod-link-text-color-white, var(--spectrum-white)); --mod-link-text-color-hover: var(--mod-link-text-color-white, var(--spectrum-white)); --mod-link-text-color-active: var(--mod-link-text-color-white, var(--spectrum-white)); --mod-link-text-color-focus: var(--mod-link-text-color-white, var(--spectrum-white)); + + --spectrum-link-focus-indicator-color: var(--spectrum-static-white-focus-indicator-color); } .spectrum-Link--staticBlack { @@ -79,4 +108,14 @@ --mod-link-text-color-hover: var(--mod-link-text-color-black, var(--spectrum-black)); --mod-link-text-color-active: var(--mod-link-text-color-black, var(--spectrum-black)); --mod-link-text-color-focus: var(--mod-link-text-color-black, var(--spectrum-black)); + + --spectrum-link-focus-indicator-color: var(--spectrum-static-black-focus-indicator-color); +} + +/* Windows high contrast mode */ +@media (forced-colors: active) { + .spectrum-Link { + --highcontrast-link-text-color: LinkText; + --highcontrast-link-focus-indicator-color: LinkText; + } } diff --git a/components/link/package.json b/components/link/package.json index 4d823110cd5..2eefc3107a1 100644 --- a/components/link/package.json +++ b/components/link/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/link", - "version": "7.2.0", + "version": "8.0.0-next.2", "description": "The Spectrum CSS link component", "license": "Apache-2.0", "author": "Adobe", @@ -24,7 +24,7 @@ }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/tokens": ">=16.0.1" + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/tokens": { @@ -32,7 +32,7 @@ } }, "devDependencies": { - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/link/stories/link.stories.js b/components/link/stories/link.stories.js index 53c71bfacb2..e747752b695 100644 --- a/components/link/stories/link.stories.js +++ b/components/link/stories/link.stories.js @@ -3,7 +3,7 @@ import { isActive, isFocused, isHovered, isQuiet, staticColor } from "@spectrum- import metadata from "../dist/metadata.json"; import packageJson from "../package.json"; import { LinkGroup } from "./link.test.js"; -import { TemplateWithFillerText } from "./template.js"; +import { LinkGroupText, MultilineText, TemplateWithFillerText } from "./template.js"; /** * A link allows users to navigate to a different location. They can be presented in-line inside a paragraph or as standalone text. @@ -54,8 +54,20 @@ export default { }, control: "boolean", }, + isInline: { + name: "Inline", + type: { name: "boolean" }, + table: { + type: { summary: "boolean" }, + category: "Component", + }, + control: "boolean", + }, staticColor, - isQuiet, + isQuiet: { + ...isQuiet, + if: { arg: "isInline", neq: true }, + }, }, args: { rootClass: "spectrum-Link", @@ -65,6 +77,7 @@ export default { isActive: false, isFocused: false, isVisited: false, + isInline: false, }, parameters: { actions: { @@ -76,7 +89,11 @@ export default { }, packageJson, metadata, + status: { + type: "migrated", + }, }, + tags: ["migrated"], }; export const Default = LinkGroup.bind({}); @@ -88,106 +105,83 @@ Default.tags = ["!autodocs"]; // ********* DOCS ONLY ********* // /** - * The primary link is the default variant and is blue. This should be used to call attention to the link and for when the blue color won’t feel too overwhelming in the experience. + * The standalone link is the default variant with the primary style which appears blue. This should be used to call attention to the link and for when the blue color won’t feel too overwhelming in the experience. + * All links can have a quiet style, without an underline. This style should only be used when the placement and context of the link is explicit enough that a visible underline isn’t necessary. */ -export const Primary = TemplateWithFillerText.bind({}); -Primary.args = { - ...Default.args, - text: "link using spectrum-Link" -}; +export const Primary = LinkGroupText.bind({}); +Primary.args = {}; Primary.tags = ["!dev"]; Primary.parameters = { chromatic: { disableSnapshot: true }, }; +Primary.storyName = "Standalone, primary"; /** * The secondary variant is the same gray color as the paragraph text. Its subdued appearance is optimal for when the primary variant is too overwhelming, such as in blocks of text with several references linked throughout. + * Link is using the class `spectrum-Link--secondary`. */ -export const Secondary = TemplateWithFillerText.bind({}); +export const Secondary = LinkGroupText.bind({}); Secondary.args = { variant: "secondary", - text: "link using spectrum-Link--secondary", }; Secondary.parameters = { chromatic: { disableSnapshot: true }, }; Secondary.tags = ["!dev"]; - -/** - * All links can have a quiet style, without an underline. This style should only be used when the placement and context of the link is explicit enough that a visible underline isn’t necessary. - */ -export const QuietPrimary = TemplateWithFillerText.bind({}); -QuietPrimary.storyName = "Primary (quiet)"; -QuietPrimary.args = { - isQuiet: true, - text: "link using spectrum-Link--quiet", -}; -QuietPrimary.parameters = { - chromatic: { disableSnapshot: true }, -}; -QuietPrimary.tags = ["!dev"]; - -export const QuietSecondary = TemplateWithFillerText.bind({}); -QuietSecondary.storyName = "Secondary (quiet)"; -QuietSecondary.args = { - isQuiet: true, - variant: "secondary", - text: "link using spectrum-Link--quiet and spectrum-Link--secondary", -}; -QuietSecondary.parameters = { - chromatic: { disableSnapshot: true }, -}; -QuietSecondary.tags = ["!dev"]; +Secondary.storyName = "Standalone, secondary"; /** * Use static white on dark color or image backgrounds, regardless of color theme. Make sure that the background and the link color meet the minimum color contrast ratio. + * Link is using the class `spectrum-Link--staticWhite`. */ -export const StaticWhite = Default.bind({}); +export const StaticWhite = LinkGroupText.bind({}); StaticWhite.storyName = "Static white"; StaticWhite.args = { staticColor: "white", - text: "Link using spectrum-Link--staticWhite", }; StaticWhite.tags = ["!dev"]; StaticWhite.parameters = { chromatic: { disableSnapshot: true }, }; +StaticWhite.storyName = "Standalone, static white"; /** * Use static black on light color or image backgrounds, regardless of color theme. Make sure that the background and the link color meet the minimum color contrast ratio. + * Link using is the class `spectrum-Link--staticBlack`. */ -export const StaticBlack = Default.bind({}); +export const StaticBlack = LinkGroupText.bind({}); StaticBlack.storyName = "Static black"; StaticBlack.args = { staticColor: "black", - text: "Link using spectrum-Link--staticBlack", }; StaticBlack.tags = ["!dev"]; StaticBlack.parameters = { chromatic: { disableSnapshot: true }, }; +StaticBlack.storyName = "Standalone, static black"; -export const QuietStaticWhite = Default.bind({}); -QuietStaticWhite.storyName = "Static white (quiet)"; -QuietStaticWhite.args = { - isQuiet: true, - staticColor: "white", - text: "Link using spectrum-Link--staticWhite and spectrum-Link--quiet", -}; -QuietStaticWhite.tags = ["!dev"]; -QuietStaticWhite.parameters = { +/** + * The focus ring wraps when the link component breaks on multiple rows. + */ +export const Multiline = MultilineText.bind({}); +Multiline.args = {}; +Multiline.tags = ["!dev"]; +Multiline.parameters = { chromatic: { disableSnapshot: true }, }; +Multiline.storyName = "Multiline, focused"; -export const QuietStaticBlack = Default.bind({}); -QuietStaticBlack.storyName = "Static black (quiet)"; -QuietStaticBlack.args = { - isQuiet: true, - staticColor: "black", - text: "Link using spectrum-Link--staticBlack and spectrum-Link--quiet", +/** + * Inline links are used within a paragraph of text. They are styled differently from standalone links in which the font weight is lighter and can be adjusted to match the paragraph text. + * Inline links do not have a quiet variant style so that it is distinguishable from the surrounding text and the underline indicator is clear. + */ +export const Inline = TemplateWithFillerText.bind({}); +Inline.args = { + isInline: true, + text: "Inline link", }; -QuietStaticBlack.tags = ["!dev"]; -QuietStaticBlack.parameters = { +Inline.tags = ["!dev"]; +Inline.parameters = { chromatic: { disableSnapshot: true }, }; diff --git a/components/link/stories/link.test.js b/components/link/stories/link.test.js index 04b33e7abe7..3fdfa9576fe 100644 --- a/components/link/stories/link.test.js +++ b/components/link/stories/link.test.js @@ -11,6 +11,15 @@ export const LinkGroup = Variants({ testHeading: "Secondary", variant: "secondary", }, + { + testHeading: "Inline", + isInline: true, + }, + { + testHeading: "Inline - secondary", + isInline: true, + variant: "secondary", + }, { testHeading: "Quiet", isQuiet: true, @@ -47,7 +56,7 @@ export const LinkGroup = Variants({ testHeading: "Static white - quiet", staticColor: "white", isQuiet: true, - }, + } ], stateData: [ { diff --git a/components/link/stories/template.js b/components/link/stories/template.js index a4faba05967..798f0da7323 100644 --- a/components/link/stories/template.js +++ b/components/link/stories/template.js @@ -1,4 +1,4 @@ -import { getRandomId } from "@spectrum-css/preview/decorators"; +import { Container, getRandomId } from "@spectrum-css/preview/decorators"; import { html } from "lit"; import { classMap } from "lit/directives/class-map.js"; import { ifDefined } from "lit/directives/if-defined.js"; @@ -17,6 +17,7 @@ export const Template = ({ isActive = false, isFocused = false, isVisited = false, + isInline = false, id = getRandomId("link"), customClasses = [], } = {}) => { @@ -25,6 +26,7 @@ export const Template = ({ class=${classMap({ [rootClass]: true, [`${rootClass}--quiet`]: isQuiet, + [`${rootClass}--inline`]: isInline, [`${rootClass}--${variant}`]: typeof variant !== "undefined", [`${rootClass}--static${capitalize(staticColor)}`]: typeof staticColor !== "undefined", @@ -43,9 +45,48 @@ export const Template = ({ }; export const TemplateWithFillerText = (args, context) => html` -
    +

    Hello, this is a ${Template(args, context)} . This is just filler text, but if you keep reading maybe something good will happen. -

    +

    `; + +export const MultilineText = (args, context) => html` +

    + I like focus styles. They are very important for accessibility. They help users know where they are on the page. + ${Template({ + ...args, + text: "This is a link that spans multiple lines", + isFocused: true, + isInline: true, + }, context)} + They are also very pretty. +

    +`; + +export const LinkGroupText = (args, context) => Container({ + withBorder: false, + direction: "row", + content: [ + Container({ + withBorder: false, + direction: "column", + heading: "Default", + content: Template({ + ...args, + text: "Learn more", + }, context) + }, context), + Container({ + withBorder: false, + direction: "column", + heading: "Quiet", + content: Template({ + ...args, + text: "Learn more", + isQuiet: true, + }, context) + }, context) + ], +}, context); diff --git a/components/logicbutton/CHANGELOG.md b/components/logicbutton/CHANGELOG.md index 752ae9cd9b1..25e0c07c70f 100644 --- a/components/logicbutton/CHANGELOG.md +++ b/components/logicbutton/CHANGELOG.md @@ -1,5 +1,20 @@ # Change log +## 7.0.0-next.1 + +### Patch Changes + +- [#3687](https://github.com/adobe/spectrum-css/pull/3687) [`53d1e5e`](https://github.com/adobe/spectrum-css/commit/53d1e5e7eb7817c37be3cfe5a253363dea744046) Thanks [@marissahuysentruyt](https://github.com/marissahuysentruyt)! - ### S2 logic button fix + + Adds `border-style: solid` to the styles to avoid a 3D effect on the border. + +## 7.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + ## 6.2.0 ### Minor Changes diff --git a/components/logicbutton/dist/metadata.json b/components/logicbutton/dist/metadata.json index 6adfbf58b24..b61731b416a 100644 --- a/components/logicbutton/dist/metadata.json +++ b/components/logicbutton/dist/metadata.json @@ -15,9 +15,7 @@ ".spectrum-LogicButton:focus-visible:after" ], "modifiers": [ - "--mod-animation-duration-100", "--mod-focus-indicator-gap", - "--mod-line-height-100", "--mod-logic-button-and-background-color", "--mod-logic-button-and-background-color-disabled", "--mod-logic-button-and-background-color-hover", @@ -46,8 +44,7 @@ "--mod-logic-button-or-border-color-hover-disabled", "--mod-logic-button-or-text-color", "--mod-logic-button-or-text-color-disabled", - "--mod-logic-button-padding", - "--mod-sans-font-family-stack" + "--mod-logic-button-padding" ], "component": [ "--spectrum-logic-button-and-background-color", @@ -84,25 +81,13 @@ "--spectrum-font-size-100", "--spectrum-gray-100", "--spectrum-gray-500", - "--spectrum-line-height-100", "--spectrum-sans-font-family-stack", "--spectrum-white" ], - "system-theme": [ - "--system-logic-button-and-background-color-disabled", - "--system-logic-button-and-background-color-hover-disabled", - "--system-logic-button-and-border-color-disabled", - "--system-logic-button-and-border-color-hover-disabled", - "--system-logic-button-or-background-color-disabled", - "--system-logic-button-or-background-color-hover-disabled", - "--system-logic-button-or-border-color-disabled", - "--system-logic-button-or-border-color-hover-disabled" - ], "passthroughs": [ "--mod-button-animation-duration", "--mod-button-focus-indicator-gap", - "--mod-button-font-family", - "--mod-button-line-height" + "--mod-button-font-family" ], "high-contrast": [ "--highcontrast-logic-button-and-background-color", diff --git a/components/logicbutton/index.css b/components/logicbutton/index.css index 4429907705b..e54943f5bd6 100644 --- a/components/logicbutton/index.css +++ b/components/logicbutton/index.css @@ -11,10 +11,17 @@ * governing permissions and limitations under the License. */ -@import "@spectrum-css/commons/basebutton.css"; -@import "./themes/spectrum-two.css"; - .spectrum-LogicButton { + --spectrum-logic-button-and-background-color-disabled: var(--spectrum-gray-100); + --spectrum-logic-button-and-border-color-disabled: var(--spectrum-gray-100); + --spectrum-logic-button-and-background-color-hover-disabled: var(--spectrum-gray-100); + --spectrum-logic-button-and-border-color-hover-disabled: var(--spectrum-gray-100); + + --spectrum-logic-button-or-background-color-disabled: var(--spectrum-gray-100); + --spectrum-logic-button-or-border-color-disabled: var(--spectrum-gray-100); + --spectrum-logic-button-or-background-color-hover-disabled: var(--spectrum-gray-100); + --spectrum-logic-button-or-border-color-hover-disabled: var(--spectrum-gray-100); + --spectrum-logic-button-border-radius: var(--spectrum-corner-radius-100); --spectrum-logic-button-and-text-color: var(--spectrum-white); @@ -24,24 +31,100 @@ --spectrum-logic-button-or-text-color: var(--spectrum-white); --spectrum-logic-button-text-color-disabled: var(--spectrum-gray-500); - @extend %spectrum-BaseButton; - @extend %spectrum-ButtonWithFocusRing; + cursor: pointer; + user-select: none; + + /* Contain halo */ + position: relative; + + /* Show the button overflow in Edge. */ + overflow: visible; + display: inline-flex; + align-items: center; + justify-content: center; + + box-sizing: border-box; + + /* Remove button the margin in Firefox and Safari. */ + margin: 0; + + font-family: var(--mod-button-font-family, var(--spectrum-sans-font-family-stack)); + + /* Adjacent buttons should be aligned correctly */ + vertical-align: top; + + -webkit-font-smoothing: antialiased; + + /* Font smoothing for Firefox */ + -moz-osx-font-smoothing: grayscale; + text-decoration: none; + + /* Remove the inheritance of text transform on button in Edge, Firefox, and IE. */ + text-transform: none; + + /* stylelint-disable-next-line property-no-vendor-prefix -- Correct the inability to style clickable types in iOS and Safari (normalize). */ + -webkit-appearance: button; + + transition: + background var(--mod-button-animation-duration, var(--spectrum-animation-duration-100)) ease-out, + border-color var(--mod-button-animation-duration, var(--spectrum-animation-duration-100)) ease-out, + color var(--mod-button-animation-duration, var(--spectrum-animation-duration-100)) ease-out, + box-shadow var(--mod-button-animation-duration, var(--spectrum-animation-duration-100)) ease-out; block-size: var(--mod-logic-button-height, 24px); padding: var(--mod-logic-button-padding, var(--spectrum-component-edge-to-text-50)); border-width: var(--mod-logic-button-border-width, var(--spectrum-border-width-200)); + border-style: solid; border-radius: var(--mod-logic-button-border-radius, var(--spectrum-logic-button-border-radius)); font-size: var(--mod-logic-button-font-size, var(--spectrum-font-size-100)); font-weight: var(--mod-logic-button-font-weight, var(--spectrum-bold-font-weight)); line-height: 0; + /* Fix Firefox */ + &::-moz-focus-inner { + margin-block-start: -2px; + margin-block-end: -2px; + padding: 0; + border: 0; + + /* Remove the inner border and padding for button in Firefox. */ + border-style: none; + } + + &:focus { + outline: none; + } + + &:disabled, + &.is-disabled { + cursor: default; + } + &::after { - /* Override border-radius set in %spectrum-ButtonWithFocusRing since this is not a pill button */ + content: ""; + + position: absolute; + inset-block-start: 0; + inset-block-end: 0; + inset-inline-start: 0; + inset-inline-end: 0; + + display: block; + margin: calc(var(--mod-button-focus-indicator-gap, var(--spectrum-focus-indicator-gap)) * -1); + + transition: + opacity var(--mod-button-animation-duration, var(--spectrum-animation-duration-100)) ease-out, + margin var(--mod-button-animation-duration, var(--spectrum-animation-duration-100)) ease-out; + border-radius: calc(var(--mod-logic-button-border-radius, var(--spectrum-logic-button-border-radius)) + var(--mod-logic-button-focus-indicator-gap, var(--spectrum-focus-indicator-gap))); } + &:focus-visible::after { + margin: calc(-2 * var(--mod-focus-indicator-gap, var(--spectrum-focus-indicator-gap))); + } + &:focus-visible { outline: none; diff --git a/components/logicbutton/package.json b/components/logicbutton/package.json index e7958b6efb3..24f7e748ca7 100644 --- a/components/logicbutton/package.json +++ b/components/logicbutton/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/logicbutton", - "version": "6.2.0", + "version": "7.0.0-next.1", "description": "The Spectrum CSS logicbutton component", "license": "Apache-2.0", "author": "Adobe", @@ -19,14 +19,12 @@ "./package.json": "./package.json", "./dist/*": "./dist/*", "./index.css": "./dist/index.css", - "./index-*.css": "./dist/index-*.css", "./metadata.json": "./dist/metadata.json", - "./themes/*": "./dist/themes/*", "./stories/*": "./stories/*" }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/tokens": ">=16.0.1" + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/tokens": { @@ -34,8 +32,7 @@ } }, "devDependencies": { - "@spectrum-css/commons": "11.1.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/logicbutton/stories/logicbutton.stories.js b/components/logicbutton/stories/logicbutton.stories.js index 6b38a131275..c6e01749949 100644 --- a/components/logicbutton/stories/logicbutton.stories.js +++ b/components/logicbutton/stories/logicbutton.stories.js @@ -32,7 +32,11 @@ export default { parameters: { packageJson, metadata, + status: { + type: "unmigrated", + }, }, + tags: ["unmigrated"], }; /** diff --git a/components/logicbutton/stories/template.js b/components/logicbutton/stories/template.js index 5b0730616ef..02f5b3aa028 100644 --- a/components/logicbutton/stories/template.js +++ b/components/logicbutton/stories/template.js @@ -2,9 +2,6 @@ import { html } from "lit"; import { classMap } from "lit/directives/class-map.js"; import "../index.css"; -import "../themes/spectrum.css"; -/* Must be imported last */ -import "../themes/express.css"; export const Template = ({ rootClass = "spectrum-LogicButton", diff --git a/components/logicbutton/themes/express.css b/components/logicbutton/themes/express.css deleted file mode 100644 index 9fd550418f2..00000000000 --- a/components/logicbutton/themes/express.css +++ /dev/null @@ -1,16 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--express */ - -@import "./spectrum.css"; diff --git a/components/logicbutton/themes/spectrum-two.css b/components/logicbutton/themes/spectrum-two.css deleted file mode 100644 index c0bd0d1b3fb..00000000000 --- a/components/logicbutton/themes/spectrum-two.css +++ /dev/null @@ -1,26 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -@container style(--system: spectrum) { - .spectrum-LogicButton { - --spectrum-logic-button-and-background-color-disabled: var(--spectrum-gray-100); - --spectrum-logic-button-and-border-color-disabled: var(--spectrum-gray-100); - --spectrum-logic-button-and-background-color-hover-disabled: var(--spectrum-gray-100); - --spectrum-logic-button-and-border-color-hover-disabled: var(--spectrum-gray-100); - - --spectrum-logic-button-or-background-color-disabled: var(--spectrum-gray-100); - --spectrum-logic-button-or-border-color-disabled: var(--spectrum-gray-100); - --spectrum-logic-button-or-background-color-hover-disabled: var(--spectrum-gray-100); - --spectrum-logic-button-or-border-color-hover-disabled: var(--spectrum-gray-100); - } -} diff --git a/components/logicbutton/themes/spectrum.css b/components/logicbutton/themes/spectrum.css deleted file mode 100644 index 4aa43a01048..00000000000 --- a/components/logicbutton/themes/spectrum.css +++ /dev/null @@ -1,30 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--legacy */ - -@import "./spectrum-two.css"; - -@container style(--system: legacy) { - .spectrum-LogicButton { - --spectrum-logic-button-and-background-color-disabled: var(--spectrum-gray-200); - --spectrum-logic-button-and-border-color-disabled: var(--spectrum-gray-200); - --spectrum-logic-button-and-background-color-hover-disabled: var(--spectrum-gray-200); - --spectrum-logic-button-and-border-color-hover-disabled: var(--spectrum-gray-200); - - --spectrum-logic-button-or-background-color-disabled: var(--spectrum-gray-200); - --spectrum-logic-button-or-border-color-disabled: var(--spectrum-gray-200); - --spectrum-logic-button-or-background-color-hover-disabled: var(--spectrum-gray-200); - --spectrum-logic-button-or-border-color-hover-disabled: var(--spectrum-gray-200); - } -} diff --git a/components/menu/CHANGELOG.md b/components/menu/CHANGELOG.md index d1b02e1fb2a..5dab6e926f4 100644 --- a/components/menu/CHANGELOG.md +++ b/components/menu/CHANGELOG.md @@ -1,26 +1,148 @@ # Change log -## 9.3.0 +## 10.0.0-next.6 + +### Patch Changes + +📝 [#4085](https://github.com/adobe/spectrum-css/pull/4085) [`082862e`](https://github.com/adobe/spectrum-css/commit/082862eb80c6e0ac1c801b1d538e4d2f2bb919b4) Thanks [@castastrophe](https://github.com/castastrophe)! + +### Action menu component (now with custom styles!) + +Introduces `@spectrum-css/actionmenu`, a composition of `ActionButton`, `Popover`, and `Menu` to present action lists from a trigger. Now with custom styles! + +- Adds wrapper classes: `spectrum-ActionMenu`, `spectrum-ActionMenu-trigger`, `spectrum-ActionMenu-popover`, and `spectrum-ActionMenu-menu`. +- Supports long press triggers and four placements (start/end, top/bottom) via the underlying popover API. +- Design reference: [Figma S2 token specs](https://www.figma.com/design/eoZHKJH9a3LJkHYCGt60Vb/S2-token-specs?node-id=20959-21513&node-type=frame&t=jbePQKK1yLdrHG2M-11). + +#### Migration notes + +- If you previously composed an action menu manually (action button + popover + menu), you can adopt the new wrapper classes without changing the underlying markup semantics. Ensure the trigger has `aria-haspopup="menu"` and manages `aria-expanded` according to your application logic. +- For spacing customizations previously done with ad‑hoc margins, switch to the new `--spectrum-actionmenu-button-to-menu-gap` custom property. + +Example markup: + +```html +
    + +
    +
      + +
    +
    + + + +
    +``` + +### Menu refinements + +Updates `@spectrum-css/menu` styles to align with latest Spectrum 2 design specifications and improve accessibility. + +- Updated `.is-selectableMultiple .spectrum-Menu-itemCheckbox` to `.is-selectableMultiple:not(:has(.is-selectable)) .spectrum-Menu-itemCheckbox` to prevent clash with the `.is-selectable` placement. +- Non-breaking; no class or DOM changes required. + +### Action button refinements + +- Selection styling now applies when components use ARIA pressed/expanded semantics, not just `.is-selected`. +- Implemented with `:where()` to keep selector specificity low and prevent downstream specificity battles. +- Non-breaking; no class changes required. + +### Action group refinements + +Aligns selection behavior of grouped items with action button updates. + +- Adds `:where([aria-pressed="true"], [aria-expanded="true"])` alongside `.is-selected` on items to cover more accessibility use-cases while keeping specificity low. +- Non-breaking; no class changes required. + +## 10.0.0-next.5 ### Minor Changes -📝 [#4218](https://github.com/adobe/spectrum-css/pull/4218) [`2df53f8`](https://github.com/adobe/spectrum-css/commit/2df53f8b9ef6d6a031ca99726aa7f0475443ca03) Thanks [@castastrophe](https://github.com/castastrophe)! +📝 [#4058](https://github.com/adobe/spectrum-css/pull/4058) [`d831bd0`](https://github.com/adobe/spectrum-css/commit/d831bd09e3a32cb0245692d73a4272101d5a0b88) Thanks [@5t3ph](https://github.com/5t3ph)! -Ensure accurate exports are present for each component. Specifically, adding `themes/*` assets where present and removing`index-*.css` exports where those assets do not exist. +This handles a few remaining items from the initial S2 migration: -## 9.2.1 +- update to use the correct "LinkOut" icon (previously unavailable) +- add "Unavailable" icon + - the functionality in WC will be to open an explanatory popover + +Additionally, per design review, updates were made regarding valid feature combos: + +- **Not allowed:** + - external links with: thumbnails, drill-in, unavailable, or selection modes + - thumbnails with: drill-in, external links + - new "unavailable" with: selection modes, external links + +## 10.0.0-next.4 + +### Major Changes + +📝 [#4014](https://github.com/adobe/spectrum-css/pull/4014) [`35c066b`](https://github.com/adobe/spectrum-css/commit/35c066b29c311b1bfcf4507075f13b41222ffc84) Thanks [@castastrophe](https://github.com/castastrophe)! + +This update removes the `dir` attribute polyfill (served via a PostCSS transform to compiled assets) as the fallback is no longer necessary. The`dir` attribute support is available in all supported browsers and has been tested to correctly inherit inside web component shadow DOMs. This is a breaking change **only** to those relying on the `dir` attribute being present for styling, however, the `:dir` pseudo will correctly inherit values from their containers. To correctly determine the `dir` value of a node using JavaScript, you can use `getComputedStyle(node).direction`. + +## 10.0.0-next.3 + +### Major Changes + +- [#3686](https://github.com/adobe/spectrum-css/pull/3686) [`cda60f4`](https://github.com/adobe/spectrum-css/commit/cda60f4f68ea1863b605fe992682664379d51278) Thanks [@5t3ph](https://github.com/5t3ph)! - ### Spectrum 2 migration + + Menu now uses Spectrum 2 tokens and specifications. + + Removes custom menu item background color tokens: `@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. + + In addition to other small token and minor style changes, there were several new features that were added to this version of menu, including: + - A thumbnail can now be used in place of an icon + - A section description can now be included below the menu section heading + - The actions area previously held action switches for multi-select, and in this version, an external link action icon can be included in that area + + ### New mods + - `--mod-menu-item-corner-radius` + - `--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-item-top-to-workflow-icon` + - `--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` + +## 10.0.0-next.2 ### Patch Changes -📝 [#4088](https://github.com/adobe/spectrum-css/pull/4088) [`24d75bf`](https://github.com/adobe/spectrum-css/commit/24d75bfe4d8e627f9d8e019ae379bdd4787712dd) Thanks [@castastrophe](https://github.com/castastrophe)! +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + - @spectrum-css/switch@7.0.0-next.0 -Minor linting fix of replacing `rgba` to the `rgb` shorthand syntax. +## 10.0.0-next.1 -## 9.2.0 +### Patch Changes -### Minor Changes +- Updated dependencies [[`c6836fb`](https://github.com/adobe/spectrum-css/commit/c6836fb132effcfb09e4ca6d0d8923564bfe2914)]: + - @spectrum-css/divider@6.0.0-next.0 + +## 10.0.0-next.0 + +### Patch Changes -- [#3527](https://github.com/adobe/spectrum-css/pull/3527) [`5f1751c`](https://github.com/adobe/spectrum-css/commit/5f1751c82a5fe55ae0d999f5f50cfeca4c8a5c75) Thanks [@castastrophe](https://github.com/castastrophe)! - By updating the postcss-preset-env to the latest breaking change version, output for this component no longer injects the `.js-focus-within` and '[focus-within]` selectors for the focus-within polyfill. As this feature is not used in the SWC consumption, risk to the end user for this removal is low. +- Updated dependencies [[`a25e0a9`](https://github.com/adobe/spectrum-css/commit/a25e0a99e5a4736ab4e607e00739343101a2633b)]: + - @spectrum-css/icon@10.0.0-next.0 + - @spectrum-css/checkbox@11.0.0-next.0 + - @spectrum-css/tray@6.0.0-next.0 ## 10.0.0 @@ -28,8 +150,6 @@ Minor linting fix of replacing `rgba` to the `rgb` shorthand syntax. 📝 [`205182b`](https://github.com/adobe/spectrum-css/commit/205182bebcbe82813457aa098d8799b0a23423ee) Thanks [@castastrophe](https://github.com/castastrophe)! -## New feature - Minified and gzipped outputs available for all compiled CSS assets. ### Patch Changes @@ -48,6 +168,30 @@ Minified and gzipped outputs available for all compiled CSS assets. - @spectrum-css/tray@6.0.0 - @spectrum-css/tokens@16.0.1 +## 9.3.0 + +### Minor Changes + +📝 [#4218](https://github.com/adobe/spectrum-css/pull/4218) [`2df53f8`](https://github.com/adobe/spectrum-css/commit/2df53f8b9ef6d6a031ca99726aa7f0475443ca03) Thanks [@castastrophe](https://github.com/castastrophe)! + +Ensure accurate exports are present for each component. Specifically, adding `themes/*` assets where present and removing`index-*.css` exports where those assets do not exist. + +## 9.2.1 + +### Patch Changes + +📝 [#4088](https://github.com/adobe/spectrum-css/pull/4088) [`24d75bf`](https://github.com/adobe/spectrum-css/commit/24d75bfe4d8e627f9d8e019ae379bdd4787712dd) Thanks [@castastrophe](https://github.com/castastrophe)! + +Minor linting fix of replacing `rgba` to the `rgb` shorthand syntax. + +## 9.2.0 + +### Minor Changes + +📝 [#3527](https://github.com/adobe/spectrum-css/pull/3527) [`5f1751c`](https://github.com/adobe/spectrum-css/commit/5f1751c82a5fe55ae0d999f5f50cfeca4c8a5c75) Thanks [@castastrophe](https://github.com/castastrophe)! + +By updating the postcss-preset-env to the latest breaking change version, output for this component no longer injects the `.js-focus-within` and '[focus-within]` selectors for the focus-within polyfill. As this feature is not used in the SWC consumption, risk to the end user for this removal is low. + ## 9.1.1 ### Patch Changes diff --git a/components/menu/dist/metadata.json b/components/menu/dist/metadata.json index 5142e09aa66..6760b5701ba 100644 --- a/components/menu/dist/metadata.json +++ b/components/menu/dist/metadata.json @@ -12,7 +12,6 @@ ".spectrum-Menu .spectrum-Menu-item--collapsible.is-open.is-focused", ".spectrum-Menu .spectrum-Menu-item--collapsible.is-open:active", ".spectrum-Menu .spectrum-Menu-item--collapsible.is-open:focus", - ".spectrum-Menu .spectrum-Menu-item--collapsible.is-open:focus-within", ".spectrum-Menu .spectrum-Menu-item--collapsible.is-open:hover", ".spectrum-Menu .spectrum-Menu-item--drillIn.is-open", ".spectrum-Menu .spectrum-Menu-item:focus .spectrum-Menu-itemCheckbox", @@ -21,7 +20,8 @@ ".spectrum-Menu .spectrum-Menu-item:hover .spectrum-Menu-itemSwitch", ".spectrum-Menu .spectrum-Menu-itemIcon", ".spectrum-Menu .spectrum-Menu-itemIcon--workflowIcon", - ".spectrum-Menu .spectrum-Menu-itemIcon:not(.spectrum-Menu-chevron, .spectrum-Menu-checkmark)", + ".spectrum-Menu .spectrum-Menu-itemIcon:not(.spectrum-Menu-chevron, .spectrum-Menu-checkmark, .spectrum-Menu-linkout)", + ".spectrum-Menu .spectrum-Menu-linkout", ".spectrum-Menu li:not(.spectrum-Menu-item, .spectrum-Menu-divider)", ".spectrum-Menu-back", ".spectrum-Menu-back .spectrum-Menu-sectionHeading", @@ -60,27 +60,17 @@ ".spectrum-Menu-item--drillIn:active .spectrum-Menu-chevron", ".spectrum-Menu-item--drillIn:focus .spectrum-Menu-chevron", ".spectrum-Menu-item--drillIn:hover .spectrum-Menu-chevron", - ".spectrum-Menu-item.is-disabled", - ".spectrum-Menu-item.is-disabled .spectrum-Menu-itemDescription", - ".spectrum-Menu-item.is-disabled .spectrum-Menu-itemIcon", - ".spectrum-Menu-item.is-disabled .spectrum-Menu-itemLabel", - ".spectrum-Menu-item.is-disabled .spectrum-Menu-itemValue", - ".spectrum-Menu-item.is-disabled .spectrum-Menu-sectionHeading", - ".spectrum-Menu-item.is-disabled:hover", - ".spectrum-Menu-item.is-disabled:hover .spectrum-Menu-itemDescription", - ".spectrum-Menu-item.is-disabled:hover .spectrum-Menu-itemIcon", - ".spectrum-Menu-item.is-disabled:hover .spectrum-Menu-itemLabel", - ".spectrum-Menu-item.is-disabled:hover .spectrum-Menu-itemValue", - ".spectrum-Menu-item.is-disabled:hover .spectrum-Menu-sectionHeading", - ".spectrum-Menu-item.is-focused", - ".spectrum-Menu-item.is-focused > .spectrum-Menu-checkmark", - ".spectrum-Menu-item.is-focused > .spectrum-Menu-chevron", - ".spectrum-Menu-item.is-focused > .spectrum-Menu-itemDescription", - ".spectrum-Menu-item.is-focused > .spectrum-Menu-itemIcon:not(.spectrum-Menu-chevron, .spectrum-Menu-checkmark)", - ".spectrum-Menu-item.is-focused > .spectrum-Menu-itemLabel", - ".spectrum-Menu-item.is-focused > .spectrum-Menu-itemValue", - ".spectrum-Menu-item.is-focused > .spectrum-Menu-sectionHeading", + ".spectrum-Menu-item.is-focus-visible", + ".spectrum-Menu-item.is-focus-visible .spectrum-Menu-linkout", + ".spectrum-Menu-item.is-focus-visible > .spectrum-Menu-checkmark", + ".spectrum-Menu-item.is-focus-visible > .spectrum-Menu-chevron", + ".spectrum-Menu-item.is-focus-visible > .spectrum-Menu-itemDescription", + ".spectrum-Menu-item.is-focus-visible > .spectrum-Menu-itemIcon:not(.spectrum-Menu-chevron, .spectrum-Menu-checkmark)", + ".spectrum-Menu-item.is-focus-visible > .spectrum-Menu-itemLabel", + ".spectrum-Menu-item.is-focus-visible > .spectrum-Menu-itemValue", + ".spectrum-Menu-item.is-focus-visible > .spectrum-Menu-sectionHeading", ".spectrum-Menu-item:active", + ".spectrum-Menu-item:active .spectrum-Menu-linkout", ".spectrum-Menu-item:active > .spectrum-Menu-checkmark", ".spectrum-Menu-item:active > .spectrum-Menu-chevron", ".spectrum-Menu-item:active > .spectrum-Menu-itemDescription", @@ -88,16 +78,26 @@ ".spectrum-Menu-item:active > .spectrum-Menu-itemLabel", ".spectrum-Menu-item:active > .spectrum-Menu-itemValue", ".spectrum-Menu-item:active > .spectrum-Menu-sectionHeading", - ".spectrum-Menu-item:focus", - ".spectrum-Menu-item:focus > .spectrum-Menu-checkmark", - ".spectrum-Menu-item:focus > .spectrum-Menu-chevron", - ".spectrum-Menu-item:focus > .spectrum-Menu-itemDescription", - ".spectrum-Menu-item:focus > .spectrum-Menu-itemIcon:not(.spectrum-Menu-chevron, .spectrum-Menu-checkmark)", - ".spectrum-Menu-item:focus > .spectrum-Menu-itemLabel", - ".spectrum-Menu-item:focus > .spectrum-Menu-itemValue", - ".spectrum-Menu-item:focus > .spectrum-Menu-sectionHeading", ".spectrum-Menu-item:focus-visible", + ".spectrum-Menu-item:focus-visible .spectrum-Menu-linkout", + ".spectrum-Menu-item:focus-visible > .spectrum-Menu-checkmark", + ".spectrum-Menu-item:focus-visible > .spectrum-Menu-chevron", + ".spectrum-Menu-item:focus-visible > .spectrum-Menu-itemDescription", + ".spectrum-Menu-item:focus-visible > .spectrum-Menu-itemIcon:not(.spectrum-Menu-chevron, .spectrum-Menu-checkmark)", + ".spectrum-Menu-item:focus-visible > .spectrum-Menu-itemLabel", + ".spectrum-Menu-item:focus-visible > .spectrum-Menu-itemValue", + ".spectrum-Menu-item:focus-visible > .spectrum-Menu-sectionHeading", + ".spectrum-Menu-item:has(> .spectrum-Menu-itemThumbnail):has(> .spectrum-Menu-itemDescription) .spectrum-Menu-itemThumbnail", + ".spectrum-Menu-item:has(> .spectrum-Menu-itemThumbnail):not(:has(.spectrum-Menu-itemSwitch)) > .spectrum-Menu-checkmark", + ".spectrum-Menu-item:has(> .spectrum-Menu-itemThumbnail):not(:has(.spectrum-Menu-itemSwitch)) > .spectrum-Menu-itemActions", + ".spectrum-Menu-item:has(> .spectrum-Menu-itemThumbnail):not(:has(.spectrum-Menu-itemSwitch)) > .spectrum-Menu-itemCheckbox", + ".spectrum-Menu-item:has(> .spectrum-Menu-itemThumbnail):not(:has(.spectrum-Menu-itemSwitch)) > .spectrum-Menu-itemLabel", + ".spectrum-Menu-item:has(> .spectrum-Menu-itemThumbnail):not(:has(.spectrum-Menu-itemSwitch)) > .spectrum-Menu-itemValue", + ".spectrum-Menu-item:has(> .spectrum-Menu-itemThumbnail):not(:has(.spectrum-Menu-itemSwitch)):has(> .spectrum-Menu-itemDescription) > .spectrum-Menu-checkmark", + ".spectrum-Menu-item:has(> .spectrum-Menu-itemThumbnail):not(:has(.spectrum-Menu-itemSwitch)):has(> .spectrum-Menu-itemDescription) > .spectrum-Menu-itemCheckbox", + ".spectrum-Menu-item:has(> .spectrum-Menu-itemThumbnail):not(:has(.spectrum-Menu-itemSwitch)):has(> .spectrum-Menu-itemDescription) > .spectrum-Menu-itemDescription", ".spectrum-Menu-item:hover", + ".spectrum-Menu-item:hover .spectrum-Menu-linkout", ".spectrum-Menu-item:hover > .spectrum-Menu-checkmark", ".spectrum-Menu-item:hover > .spectrum-Menu-chevron", ".spectrum-Menu-item:hover > .spectrum-Menu-itemDescription", @@ -105,38 +105,37 @@ ".spectrum-Menu-item:hover > .spectrum-Menu-itemLabel", ".spectrum-Menu-item:hover > .spectrum-Menu-itemValue", ".spectrum-Menu-item:hover > .spectrum-Menu-sectionHeading", + ".spectrum-Menu-item:is(.is-disabled, [aria-disabled=\"true\"]) .spectrum-Menu-itemDescription", + ".spectrum-Menu-item:is(.is-disabled, [aria-disabled=\"true\"]) .spectrum-Menu-itemIcon", + ".spectrum-Menu-item:is(.is-disabled, [aria-disabled=\"true\"]) .spectrum-Menu-itemLabel", + ".spectrum-Menu-item:is(.is-disabled, [aria-disabled=\"true\"]) .spectrum-Menu-itemThumbnail", + ".spectrum-Menu-item:is(.is-disabled, [aria-disabled=\"true\"]) .spectrum-Menu-itemValue", + ".spectrum-Menu-item:is(.is-disabled, [aria-disabled=\"true\"]) .spectrum-Menu-sectionHeading", + ".spectrum-Menu-item:is(.is-disabled, [aria-disabled=\"true\"]):hover", + ".spectrum-Menu-item:is(.is-disabled, [aria-disabled=\"true\"]):hover .spectrum-Menu-itemDescription", + ".spectrum-Menu-item:is(.is-disabled, [aria-disabled=\"true\"]):hover .spectrum-Menu-itemIcon", + ".spectrum-Menu-item:is(.is-disabled, [aria-disabled=\"true\"]):hover .spectrum-Menu-itemLabel", + ".spectrum-Menu-item:is(.is-disabled, [aria-disabled=\"true\"]):hover .spectrum-Menu-itemValue", + ".spectrum-Menu-item:is(.is-disabled, [aria-disabled=\"true\"]):hover .spectrum-Menu-sectionHeading", ".spectrum-Menu-itemActions", ".spectrum-Menu-itemDescription", ".spectrum-Menu-itemLabel", ".spectrum-Menu-itemLabel--truncate", ".spectrum-Menu-itemSelection", + ".spectrum-Menu-itemThumbnail", ".spectrum-Menu-itemValue", - ".spectrum-Menu-item[aria-disabled=\"true\"]", - ".spectrum-Menu-item[aria-disabled=\"true\"] .spectrum-Menu-itemDescription", - ".spectrum-Menu-item[aria-disabled=\"true\"] .spectrum-Menu-itemIcon", - ".spectrum-Menu-item[aria-disabled=\"true\"] .spectrum-Menu-itemLabel", - ".spectrum-Menu-item[aria-disabled=\"true\"] .spectrum-Menu-itemValue", - ".spectrum-Menu-item[aria-disabled=\"true\"] .spectrum-Menu-sectionHeading", - ".spectrum-Menu-item[aria-disabled=\"true\"]:hover", - ".spectrum-Menu-item[aria-disabled=\"true\"]:hover .spectrum-Menu-itemDescription", - ".spectrum-Menu-item[aria-disabled=\"true\"]:hover .spectrum-Menu-itemIcon", - ".spectrum-Menu-item[aria-disabled=\"true\"]:hover .spectrum-Menu-itemLabel", - ".spectrum-Menu-item[aria-disabled=\"true\"]:hover .spectrum-Menu-itemValue", - ".spectrum-Menu-item[aria-disabled=\"true\"]:hover .spectrum-Menu-sectionHeading", + ".spectrum-Menu-sectionDescription", ".spectrum-Menu-sectionHeading", ".spectrum-Menu.is-selectable .spectrum-Menu-item", - ".spectrum-Menu.is-selectable .spectrum-Menu-item.is-selected", + ".spectrum-Menu.is-selectable .spectrum-Menu-item:where(.is-selected, [aria-selected=\"true\"])", ".spectrum-Menu.is-selectableMultiple .spectrum-Menu-item", - ".spectrum-Menu.is-selectableMultiple .spectrum-Menu-itemCheckbox", + ".spectrum-Menu.is-selectableMultiple:not(:has(.is-selectable)) .spectrum-Menu-itemCheckbox", ".spectrum-Menu.spectrum-Menu--sizeL", ".spectrum-Menu.spectrum-Menu--sizeS", ".spectrum-Menu.spectrum-Menu--sizeXL", - ".spectrum-Menu:dir(rtl)", ".spectrum-Menu:lang(ja)", ".spectrum-Menu:lang(ko)", - ".spectrum-Menu:lang(zh)", - "[dir=\"rtl\"] .spectrum-Menu", - "[dir=\"rtl\"] .spectrum-Menu .spectrum-Menu-chevron" + ".spectrum-Menu:lang(zh)" ], "modifiers": [ "--mod-menu-back-heading-color", @@ -166,6 +165,7 @@ "--mod-menu-item-checkmark-height", "--mod-menu-item-checkmark-width", "--mod-menu-item-collapsible-no-icon-submenu-item-padding-x-start", + "--mod-menu-item-corner-radius", "--mod-menu-item-description-color-default", "--mod-menu-item-description-color-disabled", "--mod-menu-item-description-color-down", @@ -195,17 +195,30 @@ "--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-linkout-icon-height", + "--mod-menu-item-linkout-icon-width", "--mod-menu-item-min-height", "--mod-menu-item-selectable-edge-to-text-not-selected", "--mod-menu-item-text-to-control", + "--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-edge-to-text", "--mod-menu-item-top-to-action", "--mod-menu-item-top-to-checkbox", "--mod-menu-item-top-to-checkmark", + "--mod-menu-item-top-to-thumbnail", + "--mod-menu-item-top-to-workflow-icon", "--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-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-divider-margin-block", "--mod-menu-section-header-bottom-edge-to-text", "--mod-menu-section-header-color", @@ -214,6 +227,7 @@ "--mod-menu-section-header-line-height", "--mod-menu-section-header-line-height-cjk", "--mod-menu-section-header-min-width", + "--mod-menu-section-header-to-description", "--mod-menu-section-header-top-edge-to-text" ], "component": [ @@ -234,18 +248,12 @@ "--spectrum-menu-item-background-color-default", "--spectrum-menu-item-background-color-down", "--spectrum-menu-item-background-color-hover", - "--spectrum-menu-item-background-color-key-focus", + "--spectrum-menu-item-background-color-keyboard-focus", "--spectrum-menu-item-bottom-edge-to-text", "--spectrum-menu-item-checkmark-height", - "--spectrum-menu-item-checkmark-height-extra-large", - "--spectrum-menu-item-checkmark-height-large", - "--spectrum-menu-item-checkmark-height-medium", - "--spectrum-menu-item-checkmark-height-small", "--spectrum-menu-item-checkmark-width", - "--spectrum-menu-item-checkmark-width-extra-large", - "--spectrum-menu-item-checkmark-width-large", - "--spectrum-menu-item-checkmark-width-medium", - "--spectrum-menu-item-checkmark-width-small", + "--spectrum-menu-item-chevron-height", + "--spectrum-menu-item-chevron-width", "--spectrum-menu-item-collapsible-no-icon-submenu-item-padding-x-start", "--spectrum-menu-item-corner-radius", "--spectrum-menu-item-description-color-default", @@ -256,14 +264,12 @@ "--spectrum-menu-item-description-font-size", "--spectrum-menu-item-description-line-height", "--spectrum-menu-item-description-line-height-cjk", - "--spectrum-menu-item-focus-indicator-border-width", "--spectrum-menu-item-focus-indicator-color", "--spectrum-menu-item-focus-indicator-color-default", - "--spectrum-menu-item-focus-indicator-direction-scalar", "--spectrum-menu-item-focus-indicator-offset", "--spectrum-menu-item-focus-indicator-outline-style", - "--spectrum-menu-item-focus-indicator-shadow", "--spectrum-menu-item-focus-indicator-width", + "--spectrum-menu-item-focus-margin", "--spectrum-menu-item-icon-height", "--spectrum-menu-item-icon-width", "--spectrum-menu-item-label-content-color-default", @@ -282,8 +288,13 @@ "--spectrum-menu-item-label-line-height-cjk", "--spectrum-menu-item-label-text-to-visual", "--spectrum-menu-item-label-to-description", - "--spectrum-menu-item-label-to-description-spacing", + "--spectrum-menu-item-label-to-description-extra-large", + "--spectrum-menu-item-label-to-description-large", + "--spectrum-menu-item-label-to-description-medium", + "--spectrum-menu-item-label-to-description-small", "--spectrum-menu-item-label-to-value-area-min-spacing", + "--spectrum-menu-item-linkout-icon-height", + "--spectrum-menu-item-linkout-icon-width", "--spectrum-menu-item-min-height", "--spectrum-menu-item-section-divider-height", "--spectrum-menu-item-selectable-edge-to-text-not-selected", @@ -291,8 +302,11 @@ "--spectrum-menu-item-selectable-edge-to-text-not-selected-large", "--spectrum-menu-item-selectable-edge-to-text-not-selected-medium", "--spectrum-menu-item-selectable-edge-to-text-not-selected-small", - "--spectrum-menu-item-spacing-multiplier", "--spectrum-menu-item-text-to-control", + "--spectrum-menu-item-thumbnail-height", + "--spectrum-menu-item-thumbnail-opacity-disabled", + "--spectrum-menu-item-thumbnail-to-label", + "--spectrum-menu-item-thumbnail-width", "--spectrum-menu-item-top-edge-to-text", "--spectrum-menu-item-top-to-action", "--spectrum-menu-item-top-to-checkbox", @@ -301,24 +315,46 @@ "--spectrum-menu-item-top-to-selected-icon-large", "--spectrum-menu-item-top-to-selected-icon-medium", "--spectrum-menu-item-top-to-selected-icon-small", + "--spectrum-menu-item-top-to-thumbnail", + "--spectrum-menu-item-top-to-thumbnail-extra-large", + "--spectrum-menu-item-top-to-thumbnail-large", + "--spectrum-menu-item-top-to-thumbnail-medium", + "--spectrum-menu-item-top-to-thumbnail-small", + "--spectrum-menu-item-top-to-workflow-icon", "--spectrum-menu-item-value-color-default", "--spectrum-menu-item-value-color-down", "--spectrum-menu-item-value-color-focus", "--spectrum-menu-item-value-color-hover", + "--spectrum-menu-section-description-color", + "--spectrum-menu-section-description-font-size", + "--spectrum-menu-section-description-font-weight", + "--spectrum-menu-section-description-line-height", + "--spectrum-menu-section-description-line-height-cjk", "--spectrum-menu-section-header-color", "--spectrum-menu-section-header-font-size", "--spectrum-menu-section-header-font-weight", "--spectrum-menu-section-header-line-height", "--spectrum-menu-section-header-line-height-cjk", - "--spectrum-menu-section-header-min-width" + "--spectrum-menu-section-header-min-width", + "--spectrum-menu-section-header-to-description", + "--spectrum-menu-section-header-to-description-extra-large", + "--spectrum-menu-section-header-to-description-large", + "--spectrum-menu-section-header-to-description-medium", + "--spectrum-menu-section-header-to-description-small" ], "global": [ "--spectrum-accent-color-1000", "--spectrum-accent-color-1100", "--spectrum-accent-color-900", - "--spectrum-blue-800", "--spectrum-bold-font-weight", - "--spectrum-border-width-200", + "--spectrum-checkmark-icon-size-100", + "--spectrum-checkmark-icon-size-200", + "--spectrum-checkmark-icon-size-300", + "--spectrum-checkmark-icon-size-75", + "--spectrum-chevron-icon-size-100", + "--spectrum-chevron-icon-size-200", + "--spectrum-chevron-icon-size-300", + "--spectrum-chevron-icon-size-75", "--spectrum-cjk-line-height-100", "--spectrum-component-bottom-to-text-100", "--spectrum-component-bottom-to-text-200", @@ -332,24 +368,38 @@ "--spectrum-component-height-200", "--spectrum-component-height-300", "--spectrum-component-height-75", + "--spectrum-component-size-difference-down", + "--spectrum-component-size-width-ratio-down", "--spectrum-component-top-to-text-100", "--spectrum-component-top-to-text-200", "--spectrum-component-top-to-text-300", "--spectrum-component-top-to-text-75", - "--spectrum-corner-radius-100", + "--spectrum-component-top-to-workflow-icon-100", + "--spectrum-component-top-to-workflow-icon-200", + "--spectrum-component-top-to-workflow-icon-300", + "--spectrum-component-top-to-workflow-icon-75", + "--spectrum-corner-radius-400", + "--spectrum-corner-radius-500", + "--spectrum-corner-radius-600", + "--spectrum-corner-radius-700", "--spectrum-disabled-content-color", "--spectrum-divider-thickness-medium", "--spectrum-divider-thickness-small", + "--spectrum-downstate-height", + "--spectrum-downstate-width", "--spectrum-focus-indicator-color", + "--spectrum-focus-indicator-gap", "--spectrum-focus-indicator-thickness", "--spectrum-font-size-100", "--spectrum-font-size-200", "--spectrum-font-size-300", "--spectrum-font-size-50", "--spectrum-font-size-75", - "--spectrum-gray-1000-rgb", "--spectrum-gray-900", "--spectrum-line-height-100", + "--spectrum-link-out-icon-size-100", + "--spectrum-link-out-icon-size-200", + "--spectrum-link-out-icon-size-75", "--spectrum-navigational-indicator-top-to-back-icon-extra-large", "--spectrum-navigational-indicator-top-to-back-icon-large", "--spectrum-navigational-indicator-top-to-back-icon-medium", @@ -362,6 +412,7 @@ "--spectrum-neutral-subdued-content-color-down", "--spectrum-neutral-subdued-content-color-hover", "--spectrum-neutral-subdued-content-color-key-focus", + "--spectrum-regular-font-weight", "--spectrum-spacing-100", "--spectrum-spacing-50", "--spectrum-text-to-control-100", @@ -371,23 +422,17 @@ "--spectrum-text-to-visual-100", "--spectrum-text-to-visual-200", "--spectrum-text-to-visual-300", + "--spectrum-text-to-visual-400", "--spectrum-text-to-visual-75", - "--spectrum-transparent-black-200-opacity", + "--spectrum-thumbnail-size-500", + "--spectrum-thumbnail-size-700", + "--spectrum-thumbnail-size-800", + "--spectrum-thumbnail-size-900", "--spectrum-workflow-icon-size-100", "--spectrum-workflow-icon-size-200", "--spectrum-workflow-icon-size-300", "--spectrum-workflow-icon-size-75" ], - "system-theme": [ - "--system-menu-item-background-color-down", - "--system-menu-item-background-color-hover", - "--system-menu-item-background-color-key-focus", - "--system-menu-item-corner-radius", - "--system-menu-item-focus-indicator-offset", - "--system-menu-item-focus-indicator-outline-style", - "--system-menu-item-focus-indicator-shadow", - "--system-menu-item-spacing-multiplier" - ], "passthroughs": [ "--mod-checkbox-text-to-control", "--mod-checkbox-top-to-text", diff --git a/components/menu/index.css b/components/menu/index.css index 3d48ce76499..a45537508a5 100644 --- a/components/menu/index.css +++ b/components/menu/index.css @@ -1,5 +1,5 @@ /*! - * Copyright 2024 Adobe. All rights reserved. + * Copyright 2025 Adobe. All rights reserved. * * This file is licensed to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. You may obtain a copy @@ -11,84 +11,12 @@ * governing permissions and limitations under the License. */ -@import "./themes/spectrum-two.css"; - -@media (forced-colors: active) { - .spectrum-Menu { - --highcontrast-menu-item-background-color-default: ButtonFace; - --highcontrast-menu-item-color-default: ButtonText; - - --highcontrast-menu-item-background-color-focus: Highlight; - --highcontrast-menu-item-color-focus: HighlightText; - - --highcontrast-menu-checkmark-icon-color-default: Highlight; - - --highcontrast-menu-item-color-disabled: GrayText; - --highcontrast-menu-item-focus-indicator-color: Highlight; - - --highcontrast-menu-item-selected-background-color: Highlight; - --highcontrast-menu-item-selected-color: HighlightText; - - @supports (color: SelectedItem) { - --highcontrast-menu-item-selected-background-color: SelectedItem; - --highcontrast-menu-item-selected-color: SelectedItemText; - } - - .spectrum-Menu-item { - /* Hide unstylable readability backplates. */ - forced-color-adjust: none; - } - - .spectrum-Menu-item:hover, - .spectrum-Menu-item:focus { - .spectrum-Menu-itemCheckbox { - /* @passthrough start */ - --highcontrast-checkbox-highlight-color-hover: ButtonText; - --highcontrast-checkbox-highlight-color-default: ButtonText; - /* @passthrough end */ - } - - .spectrum-Menu-itemSwitch { - /* @passthrough start */ - --highcontrast-switch-handle-border-color-hover: ButtonText; - --highcontrast-switch-handle-border-color-selected-default: ButtonText; - --highcontrast-switch-handle-border-color-selected-hover: ButtonText; - --highcontrast-switch-background-color-selected-default: ButtonText; - --highcontrast-switch-background-color-selected-hover: ButtonText; - /* @passthrough end */ - } - } - - .spectrum-Menu-item--drillIn.is-open { - --highcontrast-menu-item-background-color-default: var(--highcontrast-menu-item-selected-background-color); - --highcontrast-menu-item-color-default: var(--highcontrast-menu-item-selected-color); - } - - .spectrum-Menu-item--collapsible.is-open { - &:hover, - &:focus-within { - box-shadow: var(--spectrum-menu-item-focus-indicator-shadow) var(--spectrum-menu-item-focus-indicator-border-width) 0 0 0 var(--spectrum-menu-item-focus-indicator-color-default); - } - - &:hover, - &:active, - &:focus, - &.is-focused { - --highcontrast-menu-item-color-focus: var(--highcontrast-menu-item-color-default); - } - } - } -} - .spectrum-Menu { - --spectrum-menu-item-top-to-action: var(--spectrum-spacing-50); - --spectrum-menu-item-top-to-checkbox: var(--spectrum-spacing-50); + /* Simplified - spec'd for 0% opacity */ + --spectrum-menu-item-background-color-default: var(--highcontrast-menu-item-background-color-default, transparent); --spectrum-menu-item-label-line-height: var(--spectrum-line-height-100); --spectrum-menu-item-label-line-height-cjk: var(--spectrum-cjk-line-height-100); - --spectrum-menu-item-label-to-description-spacing: var(--spectrum-menu-item-label-to-description); - --spectrum-menu-item-focus-indicator-width: var(--mod-menu-item-focus-indicator-width, var(--spectrum-border-width-200)); - --spectrum-menu-item-focus-indicator-color: var(--spectrum-blue-800); --spectrum-menu-item-label-to-value-area-min-spacing: var(--spectrum-spacing-100); --spectrum-menu-item-label-content-color-default: var(--spectrum-neutral-content-color-default); @@ -116,7 +44,17 @@ --spectrum-menu-section-header-line-height: var(--spectrum-line-height-100); --spectrum-menu-section-header-line-height-cjk: var(--spectrum-cjk-line-height-100); --spectrum-menu-section-header-font-weight: var(--spectrum-bold-font-weight); - --spectrum-menu-section-header-color: var(--spectrum-gray-900); + --spectrum-menu-section-header-color: var(--spectrum-neutral-content-color-default); + --spectrum-menu-section-header-font-size: var(--spectrum-font-size-100); + --spectrum-menu-section-header-min-width: var(--spectrum-component-height-100); + + --spectrum-menu-section-description-line-height: var(--spectrum-line-height-100); + --spectrum-menu-section-description-line-height-cjk: var(--spectrum-cjk-line-height-100); + --spectrum-menu-section-description-font-weight: var(--spectrum-regular-font-weight); + --spectrum-menu-section-description-color: var(--spectrum-neutral-subdued-content-color-default); + --spectrum-menu-section-header-to-description: var(--spectrum-menu-section-header-to-description-medium); + --spectrum-menu-item-label-to-description: var(--spectrum-menu-item-label-to-description-medium); + --spectrum-menu-collapsible-icon-color: var(--spectrum-gray-900); --spectrum-menu-checkmark-icon-color-default: var(--spectrum-accent-color-900); @@ -141,33 +79,52 @@ --spectrum-menu-item-min-height: var(--spectrum-component-height-100); --spectrum-menu-item-icon-height: var(--spectrum-workflow-icon-size-100); --spectrum-menu-item-icon-width: var(--spectrum-workflow-icon-size-100); + + --spectrum-menu-item-linkout-icon-height: var(--spectrum-link-out-icon-size-100); + --spectrum-menu-item-linkout-icon-width: var(--spectrum-link-out-icon-size-100); + --spectrum-menu-item-label-font-size: var(--spectrum-font-size-100); --spectrum-menu-item-label-text-to-visual: var(--spectrum-text-to-visual-100); + --spectrum-menu-item-top-to-action: var(--spectrum-spacing-50); + --spectrum-menu-item-top-to-checkbox: var(--spectrum-spacing-50); + --spectrum-menu-item-top-to-workflow-icon: var(--spectrum-component-top-to-workflow-icon-100); + --spectrum-menu-item-label-inline-edge-to-content: var(--spectrum-component-edge-to-text-100); --spectrum-menu-item-top-edge-to-text: var(--spectrum-component-top-to-text-100); --spectrum-menu-item-bottom-edge-to-text: var(--spectrum-component-bottom-to-text-100); - --spectrum-menu-item-text-to-control: var(--spectrum-text-to-control-100); + --spectrum-menu-item-selectable-edge-to-text-not-selected: var(--spectrum-menu-item-selectable-edge-to-text-not-selected-medium); --spectrum-menu-item-description-font-size: var(--spectrum-font-size-75); - --spectrum-menu-section-header-font-size: var(--spectrum-font-size-100); - --spectrum-menu-section-header-min-width: var(--spectrum-component-height-100); + --spectrum-menu-item-corner-radius: var(--spectrum-corner-radius-500); - --spectrum-menu-item-selectable-edge-to-text-not-selected: var(--spectrum-menu-item-selectable-edge-to-text-not-selected-medium); - - --spectrum-menu-item-checkmark-height: var(--spectrum-menu-item-checkmark-height-medium); - --spectrum-menu-item-checkmark-width: var(--spectrum-menu-item-checkmark-width-medium); + --spectrum-menu-item-checkmark-height: var(--spectrum-checkmark-icon-size-100); + --spectrum-menu-item-checkmark-width: var(--spectrum-checkmark-icon-size-100); --spectrum-menu-item-top-to-checkmark: var(--spectrum-menu-item-top-to-selected-icon-medium); + --spectrum-menu-item-chevron-height: var(--spectrum-chevron-icon-size-100); + --spectrum-menu-item-chevron-width: var(--spectrum-chevron-icon-size-100); + + --spectrum-menu-item-top-to-thumbnail: var(--spectrum-menu-item-top-to-thumbnail-medium); + --spectrum-menu-item-thumbnail-to-label: var(--spectrum-text-to-visual-200); + --spectrum-menu-item-thumbnail-height: var(--spectrum-thumbnail-size-700); + --spectrum-menu-item-thumbnail-width: var(--spectrum-thumbnail-size-700); + --spectrum-menu-item-thumbnail-opacity-disabled: 0.3; + --spectrum-menu-back-icon-margin: var(--spectrum-navigational-indicator-top-to-back-icon-medium); /* "no" icon: just the chevron (we're not counting it because it HAS to be there for a collapsible) */ --spectrum-menu-item-collapsible-no-icon-submenu-item-padding-x-start: calc((var(--spectrum-menu-item-label-inline-edge-to-content) + var(--spectrum-menu-item-checkmark-width) + var(--spectrum-menu-item-label-text-to-visual) + var(--spectrum-menu-item-focus-indicator-width))); + /* Focus state styling */ + --spectrum-menu-item-focus-indicator-width: var(--mod-menu-item-focus-indicator-width, var(--spectrum-focus-indicator-thickness)); + --spectrum-menu-item-focus-indicator-color: var(--spectrum-focus-indicator-color); + --spectrum-menu-item-focus-indicator-offset: var(--spectrum-focus-indicator-gap); + --spectrum-menu-item-focus-indicator-outline-style: solid; --spectrum-menu-item-focus-indicator-color-default: var(--highcontrast-menu-item-focus-indicator-color, var(--mod-menu-item-focus-indicator-color, var(--spectrum-menu-item-focus-indicator-color))); - --spectrum-menu-item-focus-indicator-border-width: calc(var(--spectrum-menu-item-focus-indicator-width) * var(--spectrum-menu-item-focus-indicator-direction-scalar, 1)); + --spectrum-menu-item-focus-margin: calc(var(--spectrum-menu-item-focus-indicator-offset) + var(--spectrum-menu-item-focus-indicator-width)); &.spectrum-Menu--sizeS { --spectrum-menu-item-min-height: var(--spectrum-component-height-75); @@ -180,6 +137,8 @@ --spectrum-menu-item-top-edge-to-text: var(--spectrum-component-top-to-text-75); --spectrum-menu-item-bottom-edge-to-text: var(--spectrum-component-bottom-to-text-75); + --spectrum-menu-item-top-to-workflow-icon: var(--spectrum-component-top-to-workflow-icon-75); + --spectrum-menu-item-text-to-control: var(--spectrum-text-to-control-75); --spectrum-menu-item-description-font-size: var(--spectrum-font-size-50); @@ -187,12 +146,29 @@ --spectrum-menu-section-header-font-size: var(--spectrum-font-size-75); --spectrum-menu-section-header-min-width: var(--spectrum-component-height-75); + --spectrum-menu-section-description-font-size: var(--spectrum-font-size-50); + --spectrum-menu-section-header-to-description: var(--spectrum-menu-section-header-to-description-small); + --spectrum-menu-item-label-to-description: var(--spectrum-menu-item-label-to-description-small); + --spectrum-menu-item-selectable-edge-to-text-not-selected: var(--spectrum-menu-item-selectable-edge-to-text-not-selected-small); - --spectrum-menu-item-checkmark-height: var(--spectrum-menu-item-checkmark-height-small); - --spectrum-menu-item-checkmark-width: var(--spectrum-menu-item-checkmark-width-small); + --spectrum-menu-item-checkmark-height: var(--spectrum-checkmark-icon-size-75); + --spectrum-menu-item-checkmark-width: var(--spectrum-checkmark-icon-size-75); --spectrum-menu-item-top-to-checkmark: var(--spectrum-menu-item-top-to-selected-icon-small); + --spectrum-menu-item-chevron-height: var(--spectrum-chevron-icon-size-75); + --spectrum-menu-item-chevron-width: var(--spectrum-chevron-icon-size-75); + + --spectrum-menu-item-linkout-icon-height: var(--spectrum-link-out-icon-size-75); + --spectrum-menu-item-linkout-icon-width: var(--spectrum-link-out-icon-size-75); + + --spectrum-menu-item-corner-radius: var(--spectrum-corner-radius-400); + + --spectrum-menu-item-top-to-thumbnail: var(--spectrum-menu-item-top-to-thumbnail-small); + --spectrum-menu-item-thumbnail-to-label: var(--spectrum-text-to-visual-100); + --spectrum-menu-item-thumbnail-height: var(--spectrum-thumbnail-size-500); + --spectrum-menu-item-thumbnail-width: var(--spectrum-thumbnail-size-500); + --spectrum-menu-back-icon-margin: var(--spectrum-navigational-indicator-top-to-back-icon-small); } @@ -207,6 +183,8 @@ --spectrum-menu-item-top-edge-to-text: var(--spectrum-component-top-to-text-200); --spectrum-menu-item-bottom-edge-to-text: var(--spectrum-component-bottom-to-text-200); + --spectrum-menu-item-top-to-workflow-icon: var(--spectrum-component-top-to-workflow-icon-200); + --spectrum-menu-item-text-to-control: var(--spectrum-text-to-control-200); --spectrum-menu-item-description-font-size: var(--spectrum-font-size-100); @@ -214,12 +192,29 @@ --spectrum-menu-section-header-font-size: var(--spectrum-font-size-200); --spectrum-menu-section-header-min-width: var(--spectrum-component-height-200); + --spectrum-menu-section-description-font-size: var(--spectrum-font-size-100); + --spectrum-menu-section-header-to-description: var(--spectrum-menu-section-header-to-description-large); + --spectrum-menu-item-label-to-description: var(--spectrum-menu-item-label-to-description-large); + --spectrum-menu-item-selectable-edge-to-text-not-selected: var(--spectrum-menu-item-selectable-edge-to-text-not-selected-large); - --spectrum-menu-item-checkmark-height: var(--spectrum-menu-item-checkmark-height-large); - --spectrum-menu-item-checkmark-width: var(--spectrum-menu-item-checkmark-width-large); + --spectrum-menu-item-checkmark-height: var(--spectrum-checkmark-icon-size-200); + --spectrum-menu-item-checkmark-width: var(--spectrum-checkmark-icon-size-200); --spectrum-menu-item-top-to-checkmark: var(--spectrum-menu-item-top-to-selected-icon-large); + --spectrum-menu-item-chevron-height: var(--spectrum-chevron-icon-size-200); + --spectrum-menu-item-chevron-width: var(--spectrum-chevron-icon-size-200); + + --spectrum-menu-item-linkout-icon-height: var(--spectrum-link-out-icon-size-200); + --spectrum-menu-item-linkout-icon-width: var(--spectrum-link-out-icon-size-200); + + --spectrum-menu-item-corner-radius: var(--spectrum-corner-radius-600); + + --spectrum-menu-item-top-to-thumbnail: var(--spectrum-menu-item-top-to-thumbnail-large); + --spectrum-menu-item-thumbnail-to-label: var(--spectrum-text-to-visual-300); + --spectrum-menu-item-thumbnail-height: var(--spectrum-thumbnail-size-800); + --spectrum-menu-item-thumbnail-width: var(--spectrum-thumbnail-size-800); + --spectrum-menu-back-icon-margin: var(--spectrum-navigational-indicator-top-to-back-icon-large); } @@ -234,6 +229,8 @@ --spectrum-menu-item-top-edge-to-text: var(--spectrum-component-top-to-text-300); --spectrum-menu-item-bottom-edge-to-text: var(--spectrum-component-bottom-to-text-300); + --spectrum-menu-item-top-to-workflow-icon: var(--spectrum-component-top-to-workflow-icon-300); + --spectrum-menu-item-text-to-control: var(--spectrum-text-to-control-300); --spectrum-menu-item-description-font-size: var(--spectrum-font-size-200); @@ -241,17 +238,30 @@ --spectrum-menu-section-header-font-size: var(--spectrum-font-size-300); --spectrum-menu-section-header-min-width: var(--spectrum-component-height-300); + --spectrum-menu-section-description-font-size: var(--spectrum-font-size-200); + --spectrum-menu-section-header-to-description: var(--spectrum-menu-section-header-to-description-extra-large); + --spectrum-menu-item-label-to-description: var(--spectrum-menu-item-label-to-description-extra-large); + --spectrum-menu-item-selectable-edge-to-text-not-selected: var(--spectrum-menu-item-selectable-edge-to-text-not-selected-extra-large); - --spectrum-menu-item-checkmark-height: var(--spectrum-menu-item-checkmark-height-extra-large); - --spectrum-menu-item-checkmark-width: var(--spectrum-menu-item-checkmark-width-extra-large); + --spectrum-menu-item-checkmark-height: var(--spectrum-checkmark-icon-size-300); + --spectrum-menu-item-checkmark-width: var(--spectrum-checkmark-icon-size-300); --spectrum-menu-item-top-to-checkmark: var(--spectrum-menu-item-top-to-selected-icon-extra-large); - --spectrum-menu-back-icon-margin: var(--spectrum-navigational-indicator-top-to-back-icon-extra-large); - } + --spectrum-menu-item-chevron-height: var(--spectrum-chevron-icon-size-300); + --spectrum-menu-item-chevron-width: var(--spectrum-chevron-icon-size-300); + + --spectrum-menu-item-linkout-icon-height: var(--spectrum-link-out-icon-size-200); + --spectrum-menu-item-linkout-icon-width: var(--spectrum-link-out-icon-size-200); + + --spectrum-menu-item-corner-radius: var(--spectrum-corner-radius-700); + + --spectrum-menu-item-top-to-thumbnail: var(--spectrum-menu-item-top-to-thumbnail-extra-large); + --spectrum-menu-item-thumbnail-to-label: var(--spectrum-text-to-visual-400); + --spectrum-menu-item-thumbnail-height: var(--spectrum-thumbnail-size-900); + --spectrum-menu-item-thumbnail-width: var(--spectrum-thumbnail-size-900); - &:dir(rtl) { - --spectrum-menu-item-focus-indicator-direction-scalar: -1; + --spectrum-menu-back-icon-margin: var(--spectrum-navigational-indicator-top-to-back-icon-extra-large); } } @@ -270,6 +280,7 @@ --spectrum-menu-item-label-line-height: var(--mod-menu-item-label-line-height-cjk, var(--spectrum-menu-item-label-line-height-cjk)); --spectrum-menu-item-description-line-height: var(--mod-menu-item-description-line-height-cjk, var(--spectrum-menu-item-description-line-height-cjk)); --spectrum-menu-section-header-line-height: var(--mod-menu-section-header-line-height-cjk, var(--spectrum-menu-section-header-line-height-cjk)); + --spectrum-menu-section-description-line-height: var(--mod-menu-section-description-line-height-cjk, var(--spectrum-menu-section-description-line-height-cjk)); } /* Menus with "selectable" menu items. */ @@ -281,7 +292,7 @@ padding-inline-start: var(--mod-menu-item-selectable-edge-to-text-not-selected, var(--spectrum-menu-item-selectable-edge-to-text-not-selected)); /* Remove inline-start spacing once an item is selected and a checkmark appears. */ - &.is-selected { + &:where(.is-selected, [aria-selected="true"]) { --spectrum-menu-checkmark-display: var(--spectrum-menu-checkmark-display-shown); padding-inline-start: var(--mod-menu-item-label-inline-edge-to-content, var(--spectrum-menu-item-label-inline-edge-to-content)); @@ -289,14 +300,13 @@ } } - &.is-selectableMultiple { - .spectrum-Menu-item { - align-items: start; - } + &.is-selectable .spectrum-Menu-item, + &.is-selectableMultiple .spectrum-Menu-item { + align-items: start; + } - .spectrum-Menu-itemCheckbox { - grid-area: checkmarkArea; - } + &.is-selectableMultiple:not(:has(.is-selectable)) .spectrum-Menu-itemCheckbox { + grid-area: checkmarkArea; } .spectrum-Menu-divider { @@ -318,7 +328,6 @@ color: var(--highcontrast-menu-item-color-default, var(--mod-menu-item-label-icon-color-default, var(--spectrum-menu-item-label-icon-color-default))); grid-area: iconArea; - align-self: start; } .spectrum-Menu-checkmark { @@ -336,18 +345,16 @@ margin-inline-end: var(--mod-menu-item-text-to-control, var(--spectrum-menu-item-text-to-control)); grid-area: checkmarkArea; - align-self: start; } .spectrum-Menu-chevron { - block-size: var(--spectrum-menu-item-checkmark-height); - inline-size: var(--spectrum-menu-item-checkmark-width); + block-size: var(--spectrum-menu-item-chevron-height); + inline-size: var(--spectrum-menu-item-chevron-width); /* Chevrons (aka collapsibles) have text or an icon directly next to them. */ margin-inline-end: var(--mod-menu-item-text-to-control, var(--spectrum-menu-item-text-to-control)); grid-area: chevronArea; - align-self: center; &:dir(rtl) { transform: rotate(-180deg); @@ -364,13 +371,19 @@ .spectrum-Menu-itemIcon--workflowIcon { /* Always provide space at the end of a workflow icon. */ margin-inline-end: var(--mod-menu-item-label-text-to-visual, var(--spectrum-menu-item-label-text-to-visual)); + margin-block-start: calc(var(--mod-menu-item-top-to-workflow-icon, var(--spectrum-menu-item-top-to-workflow-icon)) - var(--mod-menu-item-top-edge-to-text, var(--spectrum-menu-item-top-edge-to-text))); } - .spectrum-Menu-itemIcon:not(.spectrum-Menu-chevron, .spectrum-Menu-checkmark) { + .spectrum-Menu-itemIcon:not(.spectrum-Menu-chevron, .spectrum-Menu-checkmark, .spectrum-Menu-linkout) { block-size: var(--mod-menu-item-icon-height, var(--spectrum-menu-item-icon-height)); inline-size: var(--mod-menu-item-icon-width, var(--spectrum-menu-item-icon-width)); } + .spectrum-Menu-linkout { + block-size: var(--mod-menu-item-linkout-icon-height, var(--spectrum-menu-item-linkout-icon-height)); + inline-size: var(--mod-menu-item-linkout-icon-width, var(--spectrum-menu-item-linkout-icon-width)); + } + /* Presentational list items for sections and dividers. */ li:not(.spectrum-Menu-item, .spectrum-Menu-divider) { display: block; @@ -386,7 +399,7 @@ position: relative; align-items: center; - border-radius: var(--spectrum-menu-item-corner-radius); + border-radius: var(--mod-menu-item-corner-radius, var(--spectrum-menu-item-corner-radius)); box-sizing: border-box; @@ -400,23 +413,50 @@ padding-block-end: var(--mod-menu-item-bottom-edge-to-text, var(--spectrum-menu-item-bottom-edge-to-text)); padding-inline: var(--mod-menu-item-label-inline-edge-to-content, var(--spectrum-menu-item-label-inline-edge-to-content)); - margin: calc((var(--spectrum-menu-item-focus-indicator-offset) + var(--spectrum-menu-item-focus-indicator-width)) * var(--spectrum-menu-item-spacing-multiplier)); + margin: var(--spectrum-menu-item-focus-margin); text-decoration: none; display: grid; grid-template-areas: - ". chevronAreaCollapsible . headingIconArea sectionHeadingArea . . . " - "selectedArea chevronAreaCollapsible checkmarkArea iconArea labelArea valueArea actionsArea chevronAreaDrillIn" - ". . . . descriptionArea . . . " - ". . . . submenuArea . . . "; + ". chevronAreaCollapsible . headingIconArea sectionHeadingArea . . . " + "selectedArea chevronAreaCollapsible checkmarkArea iconArea labelArea valueArea actionsArea chevronAreaDrillIn" + "selectedOverflow . . visualOverflow descriptionArea . . . " + ". . . . submenuArea . . . "; grid-template-columns: auto auto auto auto 1fr auto auto auto; grid-template-rows: 1fr auto; + /* Alignment adjustments if there's a thumbnail */ + &:has(> .spectrum-Menu-itemThumbnail):not(:has(.spectrum-Menu-itemSwitch)) { + > .spectrum-Menu-itemCheckbox, + > .spectrum-Menu-checkmark, + > .spectrum-Menu-itemActions, + > .spectrum-Menu-itemValue, + > .spectrum-Menu-itemLabel { + align-self: center; + margin-block-start: 0; + } + + &:has(> .spectrum-Menu-itemDescription) { + /* Reduces perceived visual margin between label and description */ + > .spectrum-Menu-itemDescription { + align-self: start; + } + + /* Allows visual centering against the thumbnail */ + > .spectrum-Menu-itemCheckbox, + > .spectrum-Menu-checkmark { + grid-row-end: selectedOverflow; + } + } + } + .spectrum-Menu-itemCheckbox { + /* @passthrough start */ --mod-checkbox-top-to-text: 0; --mod-checkbox-text-to-control: 0; + /* @passthrough end */ min-block-size: 0; @@ -451,10 +491,9 @@ } } - &:focus, - &.is-focused { - background-color: var(--highcontrast-menu-item-background-color-focus, var(--mod-menu-item-background-color-key-focus, var(--spectrum-menu-item-background-color-key-focus))); - outline: none; + &:focus-visible, + &.is-focus-visible { + background-color: var(--highcontrast-menu-item-background-color-focus, var(--mod-menu-item-background-color-key-focus, var(--spectrum-menu-item-background-color-keyboard-focus))); > .spectrum-Menu-itemLabel { color: var(--highcontrast-menu-item-color-focus, var(--mod-menu-item-label-content-color-focus, var(--spectrum-menu-item-label-content-color-focus))); @@ -472,7 +511,8 @@ color: var(--highcontrast-menu-item-color-focus, var(--mod-menu-item-value-color-focus, var(--spectrum-menu-item-value-color-focus))); } - > .spectrum-Menu-itemIcon:not(.spectrum-Menu-chevron, .spectrum-Menu-checkmark) { + > .spectrum-Menu-itemIcon:not(.spectrum-Menu-chevron, .spectrum-Menu-checkmark), + .spectrum-Menu-linkout { fill: var(--highcontrast-menu-item-color-focus, var(--mod-menu-item-label-icon-color-focus, var(--spectrum-menu-item-label-icon-color-focus))); color: var(--highcontrast-menu-item-color-focus, var(--mod-menu-item-label-icon-color-focus, var(--spectrum-menu-item-label-icon-color-focus))); } @@ -507,7 +547,8 @@ color: var(--highcontrast-menu-item-color-focus, var(--mod-menu-item-value-color-hover, var(--spectrum-menu-item-value-color-hover))); } - > .spectrum-Menu-itemIcon:not(.spectrum-Menu-chevron, .spectrum-Menu-checkmark) { + > .spectrum-Menu-itemIcon:not(.spectrum-Menu-chevron, .spectrum-Menu-checkmark), + .spectrum-Menu-linkout { fill: var(--highcontrast-menu-item-color-focus, var(--mod-menu-item-label-icon-color-hover, var(--spectrum-menu-item-label-icon-color-hover))); color: var(--highcontrast-menu-item-color-focus, var(--mod-menu-item-label-icon-color-hover, var(--spectrum-menu-item-label-icon-color-hover))); } @@ -526,6 +567,11 @@ &:active { background-color: var(--highcontrast-menu-item-background-color-focus, var(--mod-menu-item-background-color-down, var(--spectrum-menu-item-background-color-down))); + /* The perceived motion can be a bit jarring given the size/complexity of a menu item */ + @media (prefers-reduced-motion: no-preference) { + transform: perspective(max(var(--spectrum-downstate-height), var(--spectrum-downstate-width) * var(--spectrum-component-size-width-ratio-down))) translateZ(var(--spectrum-component-size-difference-down)); + } + > .spectrum-Menu-itemLabel { color: var(--highcontrast-menu-item-color-focus, var(--mod-menu-item-label-content-color-down, var(--spectrum-menu-item-label-content-color-down))); } @@ -542,7 +588,8 @@ color: var(--highcontrast-menu-item-color-focus, var(--mod-menu-item-value-color-down, var(--spectrum-menu-item-value-color-down))); } - > .spectrum-Menu-itemIcon:not(.spectrum-Menu-chevron, .spectrum-Menu-checkmark) { + > .spectrum-Menu-itemIcon:not(.spectrum-Menu-chevron, .spectrum-Menu-checkmark), + .spectrum-Menu-linkout { fill: var(--highcontrast-menu-item-color-focus, var(--mod-menu-item-label-icon-color-down, var(--spectrum-menu-item-label-icon-color-down))); color: var(--highcontrast-menu-item-color-focus, var(--mod-menu-item-label-icon-color-down, var(--spectrum-menu-item-label-icon-color-down))); } @@ -559,10 +606,7 @@ } /* Disabled menu items */ - &.is-disabled, - &[aria-disabled="true"] { - background-color: transparent; - + &:is(.is-disabled, [aria-disabled="true"]) { .spectrum-Menu-itemLabel, .spectrum-Menu-sectionHeading, .spectrum-Menu-itemValue { @@ -578,6 +622,10 @@ fill: var(--highcontrast-menu-item-color-disabled, var(--mod-menu-item-label-icon-color-disabled, var(--spectrum-menu-item-label-icon-color-disabled))); } + .spectrum-Menu-itemThumbnail { + opacity: var(--mod-menu-item-thumbnail-opacity-disabled, var(--spectrum-menu-item-thumbnail-opacity-disabled)); + } + &:hover { cursor: default; background-color: transparent; @@ -602,10 +650,8 @@ .spectrum-Menu-item:focus-visible, .spectrum-Menu-back:focus-visible { - box-shadow: var(--spectrum-menu-item-focus-indicator-shadow) var(--spectrum-menu-item-focus-indicator-border-width) 0 0 0 var(--spectrum-menu-item-focus-indicator-color-default); outline: var(--spectrum-menu-item-focus-indicator-width) var(--spectrum-menu-item-focus-indicator-outline-style) var(--spectrum-menu-item-focus-indicator-color-default); outline-offset: var(--spectrum-menu-item-focus-indicator-offset); - border-radius: var(--spectrum-menu-item-corner-radius); } .spectrum-Menu-itemSelection { @@ -631,13 +677,12 @@ color: var(--highcontrast-menu-item-color-default, var(--mod-menu-item-value-color-default, var(--spectrum-menu-item-value-color-default))); font-size: var(--mod-menu-item-label-font-size, var(--spectrum-menu-item-label-font-size)); justify-self: end; - align-self: start; margin-inline-start: var(--mod-menu-item-label-to-value-area-min-spacing, var(--spectrum-menu-item-label-to-value-area-min-spacing)); } .spectrum-Menu-itemActions { + display: grid; grid-area: actionsArea; - align-self: start; margin-inline-start: var(--mod-menu-item-label-to-value-area-min-spacing, var(--spectrum-menu-item-label-to-value-area-min-spacing)); } @@ -653,6 +698,18 @@ padding-block-start: var(--mod-menu-section-header-top-edge-to-text, var(--mod-menu-item-top-edge-to-text, var(--spectrum-menu-item-top-edge-to-text))); padding-block-end: var(--mod-menu-section-header-bottom-edge-to-text, var(--mod-menu-item-bottom-edge-to-text, var(--spectrum-menu-item-bottom-edge-to-text))); padding-inline: var(--mod-menu-item-label-inline-edge-to-content, var(--spectrum-menu-item-label-inline-edge-to-content)); + + /* Keep alignment with menu items */ + margin-inline: var(--spectrum-menu-item-focus-margin); +} + +.spectrum-Menu-sectionDescription { + display: block; + color: var(--mod-menu-section-description-color, var(--spectrum-menu-section-description-color)); + font-weight: var(--mod-menu-section-description-font-weight, var(--spectrum-menu-section-description-font-weight)); + line-height: var(--mod-menu-section-description-line-height, var(--spectrum-menu-section-description-line-height)); + font-size: var(--mod-menu-section-description-font-size, var(--spectrum-menu-section-description-font-size)); + margin-block-start: var(--mod-menu-section-header-to-description, var(--spectrum-menu-section-header-to-description)); } .spectrum-Menu-itemDescription { @@ -661,10 +718,24 @@ font-size: var(--mod-menu-item-description-font-size, var(--spectrum-menu-item-description-font-size)); hyphens: auto; overflow-wrap: break-word; - margin-block-start: var(--mod-menu-item-label-to-description-spacing, var(--spectrum-menu-item-label-to-description-spacing)); + margin-block-start: var(--mod-menu-item-label-to-description-spacing, var(--spectrum-menu-item-label-to-description)); line-height: var(--mod-menu-item-description-line-height, var(--spectrum-menu-item-description-line-height)); } +.spectrum-Menu-itemThumbnail { + grid-area: iconArea; + display: inline-block; + block-size: var(--mod-menu-item-thumbnail-height, var(--spectrum-menu-item-thumbnail-height)); + inline-size: var(--mod-menu-item-thumbnail-width, var(--spectrum-menu-item-thumbnail-width)); + margin-block-start: calc(var(--mod-menu-item-top-to-thumbnail, var(--spectrum-menu-item-top-to-thumbnail)) - var(--mod-menu-item-top-edge-to-text, var(--spectrum-menu-item-top-edge-to-text))); + margin-inline-end: var(--mod-menu-item-thumbnail-to-label, var(--spectrum-menu-item-thumbnail-to-label)); + + /* Span two rows to properly align to description when present */ + .spectrum-Menu-item:has(> &):has(> .spectrum-Menu-itemDescription) & { + grid-row-end: visualOverflow; + } +} + .spectrum-Menu-itemLabel--truncate { text-overflow: ellipsis; white-space: nowrap; @@ -696,7 +767,7 @@ &.is-open:active, &.is-open:focus, &.is-open.is-focused { - background-color: var(--highcontrast-menu-item-background-color-default, var(--mod-menu-item-background-color-default, var(--spectrum-menu-item-background-color-default))); + background-color: transparent; } .spectrum-Menu-itemIcon { @@ -821,3 +892,65 @@ font-weight: var(--mod-menu-section-header-font-weight, var(--spectrum-menu-section-header-font-weight)); line-height: var(--mod-menu-section-header-line-height, var(--spectrum-menu-section-header-line-height)); } + +@media (forced-colors: active) { + .spectrum-Menu { + --highcontrast-menu-item-background-color-default: ButtonFace; + --highcontrast-menu-item-color-default: ButtonText; + + --highcontrast-menu-item-background-color-focus: Highlight; + --highcontrast-menu-item-color-focus: HighlightText; + + --highcontrast-menu-checkmark-icon-color-default: Highlight; + + --highcontrast-menu-item-color-disabled: GrayText; + --highcontrast-menu-item-focus-indicator-color: Highlight; + + --highcontrast-menu-item-selected-background-color: Highlight; + --highcontrast-menu-item-selected-color: HighlightText; + + @supports (color: SelectedItem) { + --highcontrast-menu-item-selected-background-color: SelectedItem; + --highcontrast-menu-item-selected-color: SelectedItemText; + } + + .spectrum-Menu-item { + /* Hide unstylable readability backplates. */ + forced-color-adjust: none; + } + + .spectrum-Menu-item:hover, + .spectrum-Menu-item:focus { + .spectrum-Menu-itemCheckbox { + /* @passthrough start */ + --highcontrast-checkbox-highlight-color-hover: ButtonText; + --highcontrast-checkbox-highlight-color-default: ButtonText; + /* @passthrough end */ + } + + .spectrum-Menu-itemSwitch { + /* @passthrough start */ + --highcontrast-switch-handle-border-color-hover: ButtonText; + --highcontrast-switch-handle-border-color-selected-default: ButtonText; + --highcontrast-switch-handle-border-color-selected-hover: ButtonText; + --highcontrast-switch-background-color-selected-default: ButtonText; + --highcontrast-switch-background-color-selected-hover: ButtonText; + /* @passthrough end */ + } + } + + .spectrum-Menu-item--drillIn.is-open { + --highcontrast-menu-item-background-color-default: var(--highcontrast-menu-item-selected-background-color); + --highcontrast-menu-item-color-default: var(--highcontrast-menu-item-selected-color); + } + + .spectrum-Menu-item--collapsible.is-open { + &:hover, + &:active, + &:focus, + &.is-focused { + --highcontrast-menu-item-color-focus: var(--highcontrast-menu-item-color-default); + } + } + } +} diff --git a/components/menu/package.json b/components/menu/package.json index 6e22fc3f936..49adeaaa1e2 100644 --- a/components/menu/package.json +++ b/components/menu/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/menu", - "version": "9.3.0", + "version": "10.0.0-next.6", "description": "The Spectrum CSS menu component", "license": "Apache-2.0", "author": "Adobe", @@ -19,19 +19,17 @@ "./package.json": "./package.json", "./dist/*": "./dist/*", "./index.css": "./dist/index.css", - "./index-*.css": "./dist/index-*.css", "./metadata.json": "./dist/metadata.json", - "./themes/*": "./dist/themes/*", "./stories/*": "./stories/*" }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/checkbox": ">=10.0.0 <11.0.0", - "@spectrum-css/divider": ">=5.0.0 <6.0.0", - "@spectrum-css/icon": ">=9.0.0 <10.0.0", - "@spectrum-css/switch": ">=6.0.0 <7.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0", - "@spectrum-css/tray": ">=5.0.0 <6.0.0" + "@spectrum-css/checkbox": ">=11.0.0-next.0", + "@spectrum-css/divider": ">=6.0.0-next.0", + "@spectrum-css/icon": ">=10.0.0-next.0", + "@spectrum-css/switch": ">=7.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0", + "@spectrum-css/tray": ">=6.0.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/checkbox": { @@ -54,12 +52,12 @@ } }, "devDependencies": { - "@spectrum-css/checkbox": "10.2.0", - "@spectrum-css/divider": "5.2.0", - "@spectrum-css/icon": "9.2.0", - "@spectrum-css/switch": "6.2.0", - "@spectrum-css/tokens": "16.0.2", - "@spectrum-css/tray": "5.2.0" + "@spectrum-css/checkbox": "11.0.0-next.2", + "@spectrum-css/divider": "6.0.0-next.1", + "@spectrum-css/icon": "10.0.0-next.3", + "@spectrum-css/switch": "7.0.0-next.2", + "@spectrum-css/tokens": "16.1.0-next.10", + "@spectrum-css/tray": "6.0.0-next.3" }, "keywords": [ "design-system", diff --git a/components/menu/stories/menu.stories.js b/components/menu/stories/menu.stories.js index 23f82bfd300..b6c421d9773 100644 --- a/components/menu/stories/menu.stories.js +++ b/components/menu/stories/menu.stories.js @@ -1,23 +1,44 @@ import { default as IconStories } from "@spectrum-css/icon/stories/icon.stories.js"; -import { Sizes } from "@spectrum-css/preview/decorators"; +import { + Sizes, + withDownStateDimensionCapture, +} from "@spectrum-css/preview/decorators"; import { disableDefaultModes } from "@spectrum-css/preview/modes"; -import { isActive, isDisabled, isFocused, isHovered, isSelected, size } from "@spectrum-css/preview/types"; +import { + isActive, + isDisabled, + isFocused, + isHovered, + isSelected, + size, +} from "@spectrum-css/preview/types"; import metadata from "../dist/metadata.json"; import packageJson from "../package.json"; -import { MenuItemGroup, MenuTraySubmenu, MenuWithVariants } from "./menu.test.js"; -import { DisabledItemGroup, OverflowGroup, SelectionGroup, SubmenuInPopover, Template } from "./template.js"; +import { + MenuItemGroup, + MenuTraySubmenu, + MenuWithVariants, +} from "./menu.test.js"; +import { + DisabledItemGroup, + OverflowGroup, + SelectionGroup, + SubmenuInPopover, + Template, +} from "./template.js"; /** * A menu is used for creating a menu list. The various elements inside a menu can be: a menu group, a menu item, or a * menu divider. Often a menu will appear in a popover so that it displays as a toggling menu. -*/ + */ export default { title: "Menu", component: "Menu", argTypes: { selectionMode: { name: "Selection mode", - description: "Determines whether items in the menu can be selected, and how many", + description: + "Determines whether items in the menu can be selected, and how many", type: { name: "string", required: true }, table: { type: { summary: "string" }, @@ -57,15 +78,12 @@ export default { labelledby: { table: { disable: true } }, items: { table: { disable: true } }, role: { table: { disable: true } }, - subrole: { table: { disable: true } }, }, args: { rootClass: "spectrum-Menu", selectionMode: "none", size: "m", shouldTruncate: false, - role: "listbox", - subrole: "option", hasDividers: false, items: [ { label: "Edit" }, @@ -77,18 +95,21 @@ export default { actions: { handles: ["click .spectrum-Menu-item"], }, - docs: { - story: { - height: "300px" - } - }, design: { type: "figma", url: "https://www.figma.com/design/Mngz9H7WZLbrCvGQf3GnsY/S2-%2F-Desktop?node-id=37252-553", }, + downState: { + selectors: [".spectrum-Menu-item:not(.is-disabled)"], + }, packageJson, metadata, + status: { + type: "migrated", + }, }, + decorators: [withDownStateDimensionCapture], + tags: ["migrated"], }; export const Default = MenuWithVariants.bind({}); @@ -105,7 +126,7 @@ Default.args = { items: [ { label: "Default menu item", - iconName: "Export" + iconName: "Comment", }, { label: "Focused menu item", @@ -114,12 +135,29 @@ Default.args = { isActive: true, }, { - label: "A menu item with a longer label that causes the text to wrap to the next line", - iconName: "Send", + label: + "A menu item with a longer label that causes the text to wrap to the next line", }, { label: "Menu item with no icon", }, + { + label: "Menu item as unavailable", + isUnavailable: true, + }, + { + label: "Menu item as external link", + hasExternalLink: true, + }, + { + label: "Menu item as external link with icon", + hasExternalLink: true, + iconName: "Data", + }, + { + label: "Menu item with a thumbnail", + thumbnailUrl: "thumbnail.png", + }, { label: "Disabled menu item", iconName: "Share", @@ -127,10 +165,10 @@ Default.args = { }, ], }, - { type: "divider" }, { idx: 2, heading: "Menu header - With descriptions and icons", + sectionDescription: "This menu header also has a description", id: "menu-heading-short-desc", items: [ { @@ -139,45 +177,94 @@ Default.args = { }, { label: "Selected item", - description: "This item is checked if single-select or multi-select mode is turned on", + description: + "This item is checked if single-select or multi-select mode is turned on", + isSelected: true, + }, + { + label: "Selected item with thumbnail", + isSelected: true, + thumbnailUrl: "thumbnail.png", + }, + { + label: "Selected item with thumbnail", + description: + "This item is checked if single-select or multi-select mode is turned on", isSelected: true, + thumbnailUrl: "thumbnail.png", }, { label: "Selected item with icon", iconName: "Cloud", - description: "This item is checked if single-select or multi-select mode is turned on", + description: + "This item is checked if single-select or multi-select mode is turned on", isSelected: true, }, ], }, - { type: "divider" }, { idx: 3, - heading: "Menu header - With actions, icons, short descriptions, and values and longer header text that wraps", + heading: + "Menu header - With actions, icons, thumbnails, short descriptions, and values and longer header text that wraps", + sectionDescription: + "This menu header also has a description that is long enough to hopefully just maybe wrap if it's long enough", id: "menu-heading-desc-icon-value", hasActions: true, items: [ { - label: "Menu item with action and a longer label that truncates if it is long enough to truncate", + label: + "Menu item with action and a longer label that truncates if it is long enough to truncate", iconName: "Cut", - description: "This item has a switch if multi-select mode is turned on.", + description: + "This item has a switch if multi-select mode is turned on.", }, { label: "Menu item with action", iconName: "Copy", - description: "In multi-select mode, this item will be switched on. In single-select mode, this item will be checked.", + description: + "In multi-select mode, this item will be switched on. In single-select mode, this item will be checked.", isSelected: true, }, { label: "Menu item with action and value", iconName: "Paste", - description: "This item has a value. If multi-select mode is turned on, it also has a switch and the value can be used to label the switch.", + description: + "This item has a value. If multi-select mode is turned on, it also has a switch and the value can be used to label the switch.", + value: "⌘ C", + }, + { + label: "Disabled menu item with thumbnail", + description: "Disabled menu item with description and thumbnail", + isDisabled: true, + thumbnailUrl: "thumbnail.png", + }, + { + label: "Menu item with thumbnail and value", + value: "⌘ C", + thumbnailUrl: "thumbnail.png", + }, + { + label: "Menu item with thumbnail and value", + description: "And a description, too", value: "⌘ C", + thumbnailUrl: "thumbnail.png", + }, + { + label: "Menu item as unavailable", + description: "And a description, too", + isUnavailable: true, }, { - label: "Disabled menu item with action", - iconName: "Archive", - description: "Disabled menu item with description and icon", + label: "Menu item with external link action", + description: + "Menu item with external link action (does not work in multi-select mode)", + hasExternalLink: true, + }, + { + label: "Disabled menu item with external link action", + description: + "Menu item with external link action (does not work in multi-select mode)", + hasExternalLink: true, isDisabled: true, }, ], @@ -205,7 +292,7 @@ Default.args = { label: "Disabled menu item with drill-in", isDrillIn: true, isDisabled: true, - } + }, ], }, ], @@ -240,8 +327,8 @@ TraySubmenu.args = { { label: "Rulers", }, - ] - } + ], + }, ], }; TraySubmenu.parameters = { @@ -249,11 +336,10 @@ TraySubmenu.parameters = { docs: { story: { inline: false, - height: "300px", - } + }, }, viewport: { - defaultViewport: "mobile2" + defaultViewport: "mobile2", }, }; @@ -267,6 +353,11 @@ MenuItem.argTypes = { isSelected: { ...isSelected, description: "Used with single or multi-select mode turned on", + if: { arg: "selectionMode", neq: "none" }, + table: { + type: { summary: "boolean" }, + category: "Selection", + }, }, label: { name: "Label", @@ -296,11 +387,12 @@ MenuItem.argTypes = { }, iconName: { ...(IconStories?.argTypes?.iconName ?? {}), - if: false, + if: { arg: "exclusiveFeatures", neq: "hasThumbnail" }, }, hasActions: { name: "Has switches", - description: "If multiple selection is enabled, show switches instead of checkboxes to show which items have been selected", + description: + "If multiple selection is enabled, show switches instead of checkboxes to show which items have been selected", type: { name: "boolean" }, table: { type: { summary: "boolean" }, @@ -309,15 +401,40 @@ MenuItem.argTypes = { control: "boolean", if: { arg: "selectionMode", eq: "multiple" }, }, + exclusiveFeatures: { + name: "Mutually exclusive features", + description: + "These options are intended to never be used in combination with each other:\n- `hasExternalLink`: Displays external link icon\n- `hasThumbnail`: Displays a thumbnail, taking the place of an icon\n- `isDrillIn`: Displays submenu indicator", + options: ["none", "hasExternalLink", "hasThumbnail", "isDrillIn"], + control: "select", + table: { + type: { summary: "string" }, + category: "Content", + }, + }, + isUnavailable: { + name: "Is unavailable", + description: + "Displays unavailable icon intended to toggle explanatory popover.\n\nShould not be used with external links, drill-ins, or selectable items", + type: { name: "boolean" }, + table: { + type: { summary: "boolean" }, + category: "Content", + }, + control: "boolean", + if: { arg: "exclusiveFeatures", neq: "hasExternalLink" }, + }, // These settings are not used in the MenuItem story hasDividers: { table: { disable: true } }, isTraySubmenu: { table: { disable: true } }, }; MenuItem.args = { label: "Start a chat", - iconName: "Chat", description: "Menu item description", value: "⌘ N", + iconName: "Comment", + exclusiveFeatures: "none", + isUnavailable: false, isDisabled: false, isActive: false, isFocused: false, @@ -353,7 +470,7 @@ Collapsible.args = { items: [ { label: "Web Design", - iconName: "DesktopAndMobile", + iconName: "DeviceMultiscreen", isCollapsible: true, isOpen: true, items: [ @@ -394,25 +511,19 @@ Collapsible.args = { label: "Tablet", iconName: "DeviceTablet", isCollapsible: true, - items: [ - { label: "Defaults to not visible within closed item" }, - ], + items: [{ label: "Defaults to not visible within closed item" }], }, { label: "Social Media", iconName: "ShareAndroid", isCollapsible: true, - items: [ - { label: "Defaults to not visible within closed item" }, - ], + items: [{ label: "Defaults to not visible within closed item" }], }, { label: "Watches", - iconName: "Watch", + iconName: "Clock", isCollapsible: true, - items: [ - { label: "Defaults to not visible within closed item" }, - ], + items: [{ label: "Defaults to not visible within closed item" }], }, ], }; @@ -428,12 +539,16 @@ Collapsible.args = { * [action button](?path=/docs/components-action-button--docs)). Similarly, any components displayed inside a menu item * (such as a [switch](?path=/docs/components-switch--docs)) must also be of the same size. */ -export const Sizing = (args, context) => Sizes({ - Template, - withHeading: false, - withBorder: false, - ...args, -}, context); +export const Sizing = (args, context) => + Sizes( + { + Template, + withHeading: false, + withBorder: false, + ...args, + }, + context, + ); Sizing.storyName = "Default"; Sizing.tags = ["!dev"]; Sizing.args = { @@ -444,26 +559,48 @@ Sizing.args = { }, { idx: 2, - label: "Menu item with icon", - iconName: "Cloud", - }, - { - idx: 3, label: "Menu item with optional description", description: "Short description of menu item", }, { - idx: 4, + idx: 3, label: "Menu item with value", value: "Value", }, + { + idx: 4, + label: "Menu item with icon", + iconName: "Cloud", + }, { idx: 5, label: "Menu item with icon and description", description: "Short description of menu item", iconName: "Cloud", }, - ] + { + idx: 6, + label: "Menu item as external link", + hasExternalLink: true, + }, + { + idx: 7, + label: "Menu item as unavailable", + isUnavailable: true, + }, + { + idx: 8, + label: "Menu item with thumbnail", + value: "Value", + thumbnailUrl: "thumbnail.png", + }, + { + idx: 9, + label: "Menu item with thumbnail", + description: "and description", + thumbnailUrl: "thumbnail.png", + }, + ], }; Sizing.parameters = { chromatic: { disableSnapshot: true }, @@ -490,7 +627,7 @@ DrillInChevron.args = { }, { label: "Menu item", - } + }, ], }; @@ -520,6 +657,8 @@ MenuItemSelection.parameters = { * The last item in each of these menus is disabled. A menu item in a disabled state shows that an option exists, but * is not available in that circumstance. This state can be used to maintain layout continuity and to communicate that * an action may become available later. + * + * To explain why an option is not actionable and keep it navigable, instead use the [_unavailable_ menu item type](#unavailable%20items). */ export const DisabledItems = DisabledItemGroup.bind({}); DisabledItems.storyName = "Disabled items"; @@ -528,6 +667,72 @@ DisabledItems.parameters = { chromatic: { disableSnapshot: true }, }; +/** + * The "Unavailable" menu item type may be used when the item is inactive and requires further explanation. + * The menu item should toggle a popover containing the explanation of why the item is unavailable. + * In the example, the first item is marked as "unavailable" as noted by the icon. + * + * This is not the same as disabled, since the item can still be navigated to, but just has unavailable functionality. + * + * Items with drill-in submenus, external links, or that are selectable cannot be made unavailable. + */ +export const UnavailableItems = Template.bind({}); +UnavailableItems.storyName = "Unavailable items"; +UnavailableItems.tags = ["!dev"]; +UnavailableItems.parameters = { + chromatic: { disableSnapshot: true }, +}; +UnavailableItems.args = { + items: [ + { + label: "Marquee", + isSelected: true, + iconName: "SelectRectangle", + isUnavailable: true, + }, + { + label: "Add", + iconName: "SelectMulti", + }, + { + label: "Subtract", + iconName: "SelectNone", + }, + ], +}; + +/** + * If a menu item will navigate away from the application, it may use the external link icon. + * + * Menu item types not valid as external links include those with thumbnails, selection modes, + * drill-in submenus, or marked as "unavailable". + */ +export const ExternalLinks = Template.bind({}); +ExternalLinks.storyName = "External links"; +ExternalLinks.tags = ["!dev"]; +ExternalLinks.parameters = { + chromatic: { disableSnapshot: true }, +}; +ExternalLinks.args = { + items: [ + { + label: "An offsite link item", + hasExternalLink: true, + }, + { + label: "Link with item icon", + iconName: "Chat", + hasExternalLink: true, + }, + { + label: "An external link", + iconName: "Folder", + description: "And an additional description", + hasExternalLink: true, + }, + ], +}; + /** * When a menu item’s label or description exceed the available horizontal space, the default behavior is to wrap the * text to a new line. @@ -548,8 +753,8 @@ TextOverflow.parameters = { }; TextOverflow.args = { customStyles: { - "max-inline-size": "150px", - } + "max-inline-size": "175px", + }, }; // story used in Picker component as well as docs page @@ -578,7 +783,7 @@ WithDividers.args = { /** * Use a section header when a menu section requires a descriptor. Section headers are helpful when two or more - * sections differ in their functionality or relationships. + * sections differ in their functionality or relationships. Section headers can also include an optional description. */ export const WithDividersAndHeaders = Template.bind({}); WithDividersAndHeaders.storyName = "Sections with dividers and headers"; @@ -599,32 +804,32 @@ WithDividersAndHeaders.args = { { label: "Marquee", isSelected: true, - iconName: "Selection", + iconName: "SelectRectangle", }, { label: "Add", - iconName: "SelectAdd", + iconName: "SelectMulti", }, { label: "Subtract", - iconName: "SelectSubtract", + iconName: "SelectNone", }, - ] + ], }, - { type: "divider" }, { idx: 2, heading: "Actions", + sectionDescription: "With an optional description", id: "menu-actions", selectionMode: "single", items: [ { label: "Deselect", - iconName: "Deselect", + iconName: "SelectNo", isDisabled: true, - } - ] - } + }, + ], + }, ], }; @@ -634,6 +839,6 @@ WithForcedColors.tags = ["!autodocs", "!dev"]; WithForcedColors.parameters = { chromatic: { forcedColors: "active", - modes: disableDefaultModes + modes: disableDefaultModes, }, }; diff --git a/components/menu/stories/menu.test.js b/components/menu/stories/menu.test.js index 9c4cc39382c..e8e3af81487 100644 --- a/components/menu/stories/menu.test.js +++ b/components/menu/stories/menu.test.js @@ -1,7 +1,5 @@ import { Variants } from "@spectrum-css/preview/decorators"; -import { html } from "lit"; -import { classMap } from "lit/directives/class-map.js"; -import { MenuItem, Template } from "./template.js"; +import { Template } from "./template.js"; export const MenuWithVariants = Variants({ Template, @@ -35,7 +33,7 @@ export const MenuWithVariants = Variants({ items: [ { label: "Web Design", - iconName: "DesktopAndMobile", + iconName: "DeviceMultiscreen", iconSet: "workflow", isCollapsible: true, isOpen: true, @@ -89,7 +87,7 @@ export const MenuWithVariants = Variants({ }, { label: "Watches and longer truncated label that is really really much longer", - iconName: "Watch", + iconName: "Clock", iconSet: "workflow", isCollapsible: true, items: [{ label: "Defaults to not visible within closed item" }], @@ -101,26 +99,23 @@ export const MenuWithVariants = Variants({ }); export const MenuItemGroup = Variants({ - Template: (args, context) => html` -
      - ${MenuItem( - { - ...args, - rootClass: "spectrum-Menu-item", - }, - context, - )} -
    - `, + Template: ({ + customStyles, + hasActions, + hasThumbnail, + selectionMode, + shouldTruncate, + ...args + }, context) => Template({ + customStyles, + hasActions, + selectionMode, + shouldTruncate, + items: [{ + ...args, + thumbnailUrl: hasThumbnail && !args.thumbnailUrl ? "thumbnail.png" : args.thumbnailUrl, + }], + }, context), wrapperStyles: { "min-block-size": "auto", }, @@ -129,9 +124,18 @@ export const MenuItemGroup = Variants({ testHeading: "No selection", description: undefined, }, + { + testHeading: "No selection, with thumbnails", + description: undefined, + hasThumbnail: true, + }, { testHeading: "No selection, with description", }, + { + testHeading: "No selection, with thumbnails, description", + hasThumbnail: true, + }, { testHeading: "Single selection: selected", description: undefined, @@ -139,6 +143,14 @@ export const MenuItemGroup = Variants({ selectionMode: "single", isSelected: true, }, + { + testHeading: "Single selection with thumbnails: selected", + description: undefined, + value: undefined, + selectionMode: "single", + isSelected: true, + hasThumbnail: true, + }, { testHeading: "Single selection: unselected", description: undefined, @@ -148,6 +160,16 @@ export const MenuItemGroup = Variants({ iconName: "Share", iconSet: "workflow", }, + { + testHeading: "Single selection with thumbnails: unselected", + description: undefined, + value: undefined, + selectionMode: "single", + label: "Share", + iconName: "Share", + iconSet: "workflow", + hasThumbnail: true, + }, { testHeading: "Multi-selection: selected", description: undefined, @@ -155,12 +177,30 @@ export const MenuItemGroup = Variants({ selectionMode: "multiple", isSelected: true, }, + { + testHeading: "Multi-selection with thumbnails: selected", + description: undefined, + value: undefined, + selectionMode: "multiple", + isSelected: true, + hasThumbnail: true, + }, { testHeading: "Multi-selection: unselected", + description: undefined, + selectionMode: "multiple", + label: "Share", + iconName: "Share", + iconSet: "workflow", + }, + { + testHeading: "Multi-selection with thumbnails: unselected", + description: undefined, selectionMode: "multiple", label: "Share", iconName: "Share", iconSet: "workflow", + hasThumbnail: true, }, { testHeading: "Multi-selection: unselected switches", @@ -169,6 +209,14 @@ export const MenuItemGroup = Variants({ value: undefined, description: undefined, }, + { + testHeading: "Multi-selection with thumbnails: unselected switches", + selectionMode: "multiple", + hasActions: true, + value: undefined, + description: undefined, + hasThumbnail: true, + }, { testHeading: "Multi-selection: selected switches", selectionMode: "multiple", @@ -178,11 +226,27 @@ export const MenuItemGroup = Variants({ isSelected: true, }, { - testHeading: "Multi-selection: switches + labels", + testHeading: "Multi-selection with thumbnails: selected switches", + selectionMode: "multiple", + hasActions: true, + value: undefined, + description: undefined, + isSelected: true, + hasThumbnail: true, + }, + { + testHeading: "Multi-selection: switches + description", selectionMode: "multiple", hasActions: true, label: "Menu item", }, + { + testHeading: "Multi-selection with thumbnails: switches + description", + selectionMode: "multiple", + hasActions: true, + label: "Menu item", + hasThumbnail: true, + }, { testHeading: "Drill-in", isDrillIn: true, @@ -197,6 +261,17 @@ export const MenuItemGroup = Variants({ "inline-size": "150px", }, }, + { + testHeading: "Truncation with thumbnails", + description: "Description will wrap", + label: "Longer label will truncate", + shouldTruncate: true, + value: undefined, + customStyles: { + "inline-size": "175px", + }, + hasThumbnail: true, + }, { testHeading: "Text wrapping", description: "Description will wrap", @@ -205,6 +280,16 @@ export const MenuItemGroup = Variants({ customStyles: { "inline-size": "150px", }, + }, + { + testHeading: "Text wrapping with thumbnails", + description: "Description will wrap", + label: "Longer label will always wrap", + value: undefined, + customStyles: { + "inline-size": "175px", + }, + hasThumbnail: true, } ], stateData: [ @@ -232,28 +317,29 @@ export const MenuItemGroup = Variants({ { testHeading: "Without icon", iconName: undefined, + include: ["No selection", "No selection, with description", "Single selection: selected", "Single selection: unselected", "Multi-selection: selected", "Multi-selection: unselected", "Multi-selection: unselected switches", "Multi-selection: selected switches", "Multi-selection: switches + description", "Drill-in", "Truncation", "Text wrapping"], }, { testHeading: "Without value", value: undefined, - include: ["No selection", "No selection, with description", "Multi-selection: unselected", "Multi-selection: switches + labels", "Drill-in"], + include: ["No selection", "No selection, with thumbnails", "No selection, with description", "No selection, with thumbnails, description", "Multi-selection: unselected", "Multi-selection with thumbnails: unselected", "Multi-selection: switches + description", "Multi-selection with thumbnails: switches + description", "Drill-in", "Drill-in with thumbnails"], }, { testHeading: "Without value or icon", iconName: undefined, value: undefined, - include: ["No selection", "No selection, with description", "Multi-selection: unselected", "Multi-selection: switches + labels", "Drill-in"], + include: ["No selection", "No selection, with description", "Multi-selection: unselected", "Multi-selection: switches + description", "Drill-in"], }, { testHeading: "With value", value: "⌘ N", - include: ["Truncation", "Text wrapping"], + include: ["Single selection: selected", "Single selection: unselected", "Multi-selection: selected", "Multi-selection: unselected", "Multi-selection: unselected switches", "Multi-selection: selected switches", "Multi-selection: switches + description", "Truncation", "Truncation with thumbnails", "Text wrapping", "Text wrapping with thumbnails"], }, { testHeading: "With multi-select switch", selectionMode: "multiple", hasActions: true, - include: ["Truncation", "Text wrapping"], + include: ["Truncation", "Truncation with thumbnails", "Text wrapping", "Text wrapping with thumbnails"], }, { testHeading: "With value and multi-select switch", @@ -265,8 +351,45 @@ export const MenuItemGroup = Variants({ { testHeading: "Without description", description: undefined, - include: ["Drill-in", "Truncation", "Text wrapping"], + include: ["Drill-in", "Drill-in with thumbnails", "Truncation", "Truncation with thumbnails", "Text wrapping", "Text wrapping with thumbnails"], + }, + { + testHeading: "With description", + description: "Menu item description", + include: ["Single selection: selected", "Single selection with thumbnails: selected", "Single selection: unselected", "Single selection with thumbnails: unselected", "Multi-selection: selected","Multi-selection with thumbnails: selected","Multi-selection: unselected","Multi-selection with thumbnails: unselected","Multi-selection: unselected switches","Multi-selection with thumbnails: unselected switches","Multi-selection: selected switches","Multi-selection with thumbnails: selected switches",] + }, + { + testHeading: "Unavailable", + isUnavailable: true, + value: undefined, + include: ["No selection", "No selection, with thumbnails", "No selection, with description", "No selection, with thumbnails, description", "Truncation","Text wrapping"] + }, + { + testHeading: "Unavailable without icon", + isUnavailable: true, + value: undefined, + iconName: undefined, + include: ["No selection", "No selection, with description","Truncation","Text wrapping"] + }, + { + // Not allowed for use with thumbnails + testHeading: "External link", + hasExternalLink: true, + include: ["No selection", "No selection, with description", "Truncation", "Text wrapping"] }, + { + testHeading: "External link without value", + hasExternalLink: true, + value: undefined, + include: ["No selection", "No selection, with description"] + }, + { + testHeading: "External link without value, icon", + hasExternalLink: true, + value: undefined, + iconName: undefined, + include: ["No selection", "No selection, with description", "Truncation", "Text wrapping"] + } // { // testHeading: "Highlighted", // isHighlighted: true, diff --git a/components/menu/stories/template.js b/components/menu/stories/template.js index c50482cb696..02cb3f62728 100644 --- a/components/menu/stories/template.js +++ b/components/menu/stories/template.js @@ -3,48 +3,282 @@ import { Template as Checkbox } from "@spectrum-css/checkbox/stories/template.js import { Template as Divider } from "@spectrum-css/divider/stories/template.js"; import { Template as Icon } from "@spectrum-css/icon/stories/template.js"; import { Template as Popover } from "@spectrum-css/popover/stories/template.js"; -import { Container, getRandomId } from "@spectrum-css/preview/decorators"; import { Template as Switch } from "@spectrum-css/switch/stories/template.js"; +import { Template as Thumbnail } from "@spectrum-css/thumbnail/stories/template.js"; import { Template as Tray } from "@spectrum-css/tray/stories/template.js"; -import { html } from "lit"; + +import { + Container, + getRandomId, + renderContent, +} from "@spectrum-css/preview/decorators"; +import { html, nothing } from "lit"; import { classMap } from "lit/directives/class-map.js"; import { ifDefined } from "lit/directives/if-defined.js"; import { styleMap } from "lit/directives/style-map.js"; import { when } from "lit/directives/when.js"; import "../index.css"; -import "../themes/spectrum.css"; -/* Must be imported last */ -import "../themes/express.css"; /** - * Get the tray submenu back arrow name with scale number (defined in design spec). + * Get icon name with scale number (defined in design spec). */ const iconWithScale = (size = "m", iconName = "ArrowLeft") => { switch (size) { case "s": - return `${iconName}200`; + return `${iconName}75`; case "l": - return `${iconName}400`; + return `${iconName}200`; case "xl": - return `${iconName}500`; - default: return `${iconName}300`; + default: + return `${iconName}100`; + } +}; + +const Label = ({ + hasActions = false, + isCollapsible = false, + label, + rootClass, + role, + shouldTruncate = false, + id, +}) => { + if (isCollapsible) { + return html` + + ${label} + + `; + } + else { + return html` + + ${label} + + `; + } +}; + +const Visual = ({ + iconName, + iconSet, + rootClass, + size, + thumbnailUrl, + hasExternalLink, + isDrillIn, +}) => { + if (thumbnailUrl && !(hasExternalLink || isDrillIn)) { + return html` + ${Thumbnail({ + imageURL: thumbnailUrl, + altText: "Thumbnail alt text", + size, + customClasses: [`${rootClass}Thumbnail`], + })} + `; + } + else if (iconName) { + return html` + ${Icon({ + iconName, + setName: iconSet, + size, + customClasses: [`${rootClass}Icon`, `${rootClass}Icon--workflowIcon`], + })} + `; + } + return; +}; + +const StartAction = ( + { + hasActions = false, + idx = 0, + isCollapsible = false, + isDisabled = false, + isSelected = false, + isUnavailable = false, + rootClass, + selectionMode = "none", + size = "m", + } = {}, + context = {}, +) => { + if (isUnavailable) return nothing; + + if (isCollapsible || (selectionMode == "single" && isSelected)) { + return html` + ${Icon( + { + iconName: iconWithScale( + size, + isCollapsible ? "ChevronRight" : "Checkmark", + ), + setName: "ui", + useRef: false, + size, + customClasses: [ + `${rootClass}Icon`, + isCollapsible ? "spectrum-Menu-chevron" : "spectrum-Menu-checkmark", + ], + }, + context, + )} + `; + } + else if (selectionMode == "multiple" && !hasActions) { + return html` ${Checkbox( + { + size, + isChecked: isSelected, + isDisabled, + id: `menu-checkbox-${idx}`, + customClasses: [`${rootClass}Checkbox`], + }, + context, + )}`; } + return nothing; }; +const EndAction = ( + { + hasExternalLink = false, + hasActions = false, + idx, + isUnavailable, + isDisabled, + isDrillIn, + isSelected, + rootClass, + selectionMode, + labelId, + size, + value, + } = {}, + context = {}, +) => html` + ${when( + value, + () => html` + + ${value} + + `, + )} + ${when( + hasActions && selectionMode == "multiple", + () => + html`
    + ${Switch( + { + size, + isChecked: isSelected, + isDisabled, + label: "", + labelId, + id: `menu-switch-${idx}`, + customClasses: [`${rootClass}Switch`], + }, + context, + )} +
    `, + )} + ${when( + hasExternalLink && + !(isUnavailable || isDrillIn) && + !(hasActions && selectionMode === "multiple"), + () => + html`
    + ${Icon( + { + setName: "ui", + iconName: iconWithScale(size, "LinkOut"), + size, + customClasses: [`${rootClass}Icon`, "spectrum-Menu-linkout"], + }, + context, + )} +
    `, + )} + ${when( + isUnavailable && + !hasExternalLink && + !(hasActions && selectionMode === "multiple"), + () => + html`
    + ${Icon( + { + iconName: "InfoCircle", + size, + customClasses: [`${rootClass}Icon`, "spectrum-Menu-unavailable"], + }, + context, + )} +
    `, + )} + ${when(isDrillIn && !(isUnavailable || hasExternalLink), () => + Icon( + { + iconName: iconWithScale(size, "ChevronRight"), + setName: "ui", + useRef: false, + size, + customClasses: [`${rootClass}Icon`, "spectrum-Menu-chevron"], + }, + context, + ), + )} +`; + +const Description = ({ rootClass, content } = {}, context = {}) => + html`${renderContent(content, { context })}`; + export const MenuItem = ( { rootClass = "spectrum-Menu-item", label, description, + thumbnailUrl = "", iconName, iconSet = "workflow", + exclusiveFeatures = "none", + hasExternalLink = false, hasActions = false, id = getRandomId("menuitem"), + labelId = getRandomId("menuitem-label"), idx = 0, isActive = false, isCollapsible = false, + isUnavailable = false, isDisabled = false, isDrillIn = false, isFocused = false, @@ -62,165 +296,151 @@ export const MenuItem = ( customStyles = {}, } = {}, context = {}, -) => html` -
  • ({ ...a, [c]: true }), {}), - })} - style=${styleMap(customStyles)} - id=${ifDefined(id)} - role=${ifDefined(role)} - aria-selected=${isSelected ? "true" : "false"} - aria-disabled=${isDisabled ? "true" : "false"} - tabindex=${ifDefined(!isDisabled ? "0" : undefined)} - > - ${when(isCollapsible || (selectionMode == "single" && isSelected), () => - Icon( - { - iconName: iconWithScale( - size, - isCollapsible ? "ChevronRight" : "Checkmark", - ), - setName: "ui", - useRef: false, - size, - customClasses: [ - `${rootClass}Icon`, - isCollapsible ? "spectrum-Menu-chevron" : "spectrum-Menu-checkmark", - ], - }, - context, - ), - )} - ${when(selectionMode === "multiple" && !hasActions, () => - Checkbox( +) => { + const hasSubMenu = isCollapsible && items.length > 0; + + if (exclusiveFeatures !== "none") { + switch (exclusiveFeatures) { + case "hasExternalLink": + hasExternalLink = true; + break; + case "hasThumbnail": + thumbnailUrl = "thumbnail.png"; + break; + case "isDrillIn": + isDrillIn = true; + break; + default: + break; + } + } + + // Update menuitem role for single and multiple selection if no actions are present + if (!hasActions && role === "menuitem") { + // Force-update the role for multiple selection to menuitemcheckbox per WCAG guidelines + if (selectionMode == "multiple") role = "menuitemcheckbox"; + // Force-update the role for single selection to menuitemradio per WCAG guidelines + else role = "menuitemradio"; + } + + return html` +
  • ({ ...a, [c]: true }), {}), + })} + style=${styleMap(customStyles)} + id=${ifDefined(id)} + role=${ifDefined(role)} + aria-selected=${ifDefined( + !role.startsWith("menuitem") + ? isSelected + ? "true" + : "false" + : undefined, + )} + aria-checked=${ifDefined( + ["menuitemcheckbox", "menuitemradio"].includes(role) + ? isSelected + ? "true" + : "false" + : undefined, + )} + aria-disabled=${isDisabled ? "true" : "false"} + aria-expanded=${ifDefined( + !role.startsWith("menuitem") && role !== "option" && hasSubMenu + ? isOpen + ? "true" + : "false" + : undefined, + )} + aria-haspopup=${ifDefined(hasSubMenu ? "menu" : undefined)} + tabindex=${ifDefined( + ["menuitemradio", "menuitemcheckbox"].includes(role) && !isDisabled + ? "-1" + : undefined, + )} + > + ${StartAction( { - size, - isEmphasized: true, - isChecked: isSelected, + hasActions, + idx, + isCollapsible, isDisabled, - id: `menu-checkbox-${idx}`, - customClasses: [`${rootClass}Checkbox`], - }, - context, - ), - )} - ${when(iconName, () => - Icon( - { - iconName, - setName: iconSet, + isSelected, + isUnavailable, + rootClass, + selectionMode, size, - customClasses: [`${rootClass}Icon`, `${rootClass}Icon--workflowIcon`], }, context, - ), - )} - ${when( - isCollapsible, - () => html` - - ${label} - - `, - () => html` - - ${label} - - `, - )} - ${when( - description, - () => html` - - ${description} - - `, - )} - ${when( - value, - () => html` - - ${value} - - `, - )} - ${when( - hasActions && selectionMode == "multiple", - () => html` -
    - ${Switch( - { - size, - isChecked: isSelected, - isDisabled, - label: null, - id: `menu-switch-${idx}`, - customClasses: [`${rootClass}Switch`], - }, - context, - )} -
    - `, - )} - ${when(isDrillIn, () => - Icon( - { - iconName: iconWithScale(size, "ChevronRight"), - setName: "ui", - useRef: false, - size, - customClasses: [`${rootClass}Icon`, "spectrum-Menu-chevron"], - }, - context, - ), - )} - ${when(isCollapsible && items.length > 0, () => - Template( + )} + ${Visual({ + iconName, + iconSet, + rootClass, + size, + thumbnailUrl, + hasExternalLink, + isDrillIn, + })} + ${Label({ + hasActions, + isCollapsible, + label, + rootClass, + id: labelId, + shouldTruncate, + role: ["menuitemcheckbox", "menuitemradio"].includes(role) + ? "presentation" + : undefined, + })} + ${when(description, () => + Description( + { content: description, rootClass: `${rootClass}Description` }, + context, + ), + )} + ${EndAction( { - items, - isOpen, + hasExternalLink, + hasActions, + idx, + isUnavailable, + isDisabled, + isDrillIn, + isSelected, + rootClass, + selectionMode, size, - shouldTruncate, + value, + labelId, }, context, - ), - )} -
  • -`; + )} + ${when(hasSubMenu, () => + Template( + { + items, + isOpen, + size, + shouldTruncate, + }, + context, + ), + )} + + `; +}; export const MenuGroup = ( { @@ -233,7 +453,7 @@ export const MenuGroup = ( isSelectable = false, isTraySubmenu = false, shouldTruncate = false, - subrole = "menuitem", + sectionDescription, size = "m", selectionMode = "none", customStyles = {}, @@ -253,6 +473,15 @@ export const MenuGroup = ( aria-hidden="true" > ${heading} + `, () => html` @@ -269,7 +498,14 @@ export const MenuGroup = ( > ${Icon( { - iconName: iconWithScale(size), + iconName: + "ArrowRight" + + ({ + s: "100", + m: "100", + l: "400", + xl: "400", + }[size] || "100"), setName: "ui", size, customClasses: ["spectrum-Menu-backIcon"], @@ -285,11 +521,19 @@ export const MenuGroup = ( ["spectrum-Menu-sectionHeading"]: true, ["spectrum-Menu-itemLabel--truncate"]: shouldTruncate, })} - style=${styleMap(customStyles)} id=${id} aria-hidden="true" > ${heading} + `, )} @@ -299,15 +543,15 @@ export const MenuGroup = ( ${Template( { role: "group", - subrole, labelledby: id, hasActions, items, isDisabled, isSelectable, selectionMode, - shouldTruncate: true, + shouldTruncate, size, + customStyles, }, context, )} @@ -322,6 +566,7 @@ export const Template = ( id = getRandomId("menu"), hasActions = false, hasDividers = false, + hasThumbnail = false, isDisabled = false, isOpen = false, isTraySubmenu = false, @@ -330,9 +575,8 @@ export const Template = ( role = "menu", selectionMode = "none", singleItemValue, - shouldTruncate, + shouldTruncate = false, size = "m", - subrole = "menuitem", } = {}, context = {}, ) => { @@ -350,61 +594,79 @@ export const Template = ( id=${ifDefined(id)} role=${ifDefined(role)} aria-labelledby=${ifDefined(labelledby)} - aria-disabled=${isDisabled ? "true" : "false"} - style=${styleMap(customStyles)} + style=${styleMap({ + ...customStyles, + ...(shouldTruncate ? { "max-inline-size": "100%" } : {}), + })} > ${items.map((i, idx) => { - if (i.type === "divider") - return html`${hasDividers - ? Divider({ - tag: "li", - size: "s", - customClasses: [`${rootClass}-divider`], - }) - : ""}`; - else if (i.heading || i.isTraySubmenu) - return MenuGroup( - { - ...i, - subrole, - size, - selectionMode, - isTraySubmenu, - shouldTruncate, - }, - context, + const content = []; + if ( + (hasDividers && i.type === "divider") || + (items[idx - 1]?.heading && i?.heading) + ) + content.push( + Divider({ + tag: "li", + size: "s", + customClasses: [`${rootClass}-divider`], + }), + ); + + if (i.type === "divider") return content; + + if (i.heading || i.isTraySubmenu) + content.push( + MenuGroup( + { + size, + selectionMode, + isTraySubmenu, + shouldTruncate, + hasActions, + ...i, + }, + context, + ), ); else - return MenuItem( - { - ...i, - hasActions, - idx, - isDisabled: isDisabled || i.isDisabled, - role: subrole, - rootClass: `${rootClass}-item`, - selectionMode, - shouldTruncate, - size, - value: singleItemValue || i.value, - }, - context, + content.push( + MenuItem( + { + ...i, + hasActions, + idx, + isDisabled: isDisabled || i.isDisabled, + rootClass: `${rootClass}-item`, + selectionMode, + shouldTruncate, + size, + thumbnailUrl: + (hasThumbnail && "thumbnail.png") || i.thumbnailUrl, + value: singleItemValue || i.value, + role: role === "listbox" ? "option" : undefined, + }, + context, + ), ); + return content; })}
`; - if (isTraySubmenu) return Tray({ - isOpen: true, - content: [ - menuMarkup - ], - }, context); + if (isTraySubmenu) + return Tray( + { + isOpen: true, + content: [menuMarkup], + }, + context, + ); return menuMarkup; }; -export const DisabledItemGroup = (args, context) => { +export const DisabledItemGroup = (args = {}, context = {}) => { const groupData = [ { heading: "Menu with icons", @@ -421,7 +683,7 @@ export const DisabledItemGroup = (args, context) => { label: "Paste", iconName: "Paste", isDisabled: true, - } + }, ], }, { @@ -439,8 +701,8 @@ export const DisabledItemGroup = (args, context) => { label: "Share link", description: "Enable comments and download", isDisabled: true, - } - ] + }, + ], }, { heading: "Menu with icons & descriptions", @@ -448,7 +710,7 @@ export const DisabledItemGroup = (args, context) => { { label: "Quick export", description: "Share a snapshot", - iconName: "Export", + iconName: "ExportTo", }, { label: "Open a copy", @@ -460,37 +722,47 @@ export const DisabledItemGroup = (args, context) => { description: "Enable comments and download", iconName: "Share", isDisabled: true, - } - ] - } + }, + ], + }, ]; - return Container({ - withBorder: false, - content: groupData.map((group) => html` - ${Container({ - heading: group.heading, - content: html` - ${Template({ - ...args, + return Container( + { + withBorder: false, + content: groupData.map( + (group) => html` + ${Container( + { + heading: group.heading, + content: html` + ${Template( + { + ...args, + shouldTruncate: group.shouldTruncate || false, + items: group.items, + }, + context, + )} + `, + }, context, - shouldTruncate: group.shouldTruncate || false, - items: group.items, - })} - ` - }, context)} - `) - }, context); + )} + `, + ), + }, + context, + ); }; -export const OverflowGroup = (args, context) => { +export const OverflowGroup = (args = {}, context = {}) => { const groupData = [ { heading: "Text overflow without descriptions", items: [ { label: "Small (works best for mobile phones)" }, { label: "Medium (all purpose)" }, - { label: "Large (works best for printing)" } + { label: "Large (works best for printing)" }, ], }, { @@ -507,7 +779,7 @@ export const OverflowGroup = (args, context) => { { label: "Large (works best for printing)", description: "A large description about large is here", - } + }, ], }, { @@ -525,7 +797,7 @@ export const OverflowGroup = (args, context) => { { label: "Large (works best for printing)", description: "A large description about large is here", - } + }, ], }, { @@ -545,18 +817,18 @@ export const OverflowGroup = (args, context) => { }, { label: "Large (works best for printing)", - } - ] - } - ] + }, + ], + }, + ], }, { heading: "Text truncation with drill-ins and values", - shouldTruncate:true, + shouldTruncate: true, items: [ { label: "Quick export truncated text", - iconName: "Export", + iconName: "ExportTo", description: "Share a low-res snapshot", }, { @@ -567,40 +839,49 @@ export const OverflowGroup = (args, context) => { }, { label: "Preview timelapse truncated text", - iconName: "Pending", + iconName: "Preview", value: "Value", - } - ] - } + }, + ], + }, ]; - return Container({ - withBorder: false, - content: groupData.map((group) => html` - ${Container({ - heading: group.heading, - content: html` - ${Template({ - ...args, + return Container( + { + withBorder: false, + content: groupData.map( + (group) => html` + ${Container( + { + heading: group.heading, + content: html` + ${Template( + { + ...args, + shouldTruncate: group.shouldTruncate || false, + items: group.items, + }, + context, + )} + `, + wrapperStyles: { + "max-inline-size": "200px", + }, + }, context, - shouldTruncate: group.shouldTruncate || false, - items: group.items, - })} - ` - })} - `) - }); + )} + `, + ), + }, + context, + ); }; -export const SelectionGroup = (args, context) => { +export const SelectionGroup = (args = {}, context = {}) => { const groupData = [ { heading: "No selection", - items: [ - { label: "Cut" }, - { label: "Copy" }, - { label: "Paste" }, - ], + items: [{ label: "Cut" }, { label: "Copy" }, { label: "Paste" }], }, { heading: "Single selection", @@ -615,7 +896,26 @@ export const SelectionGroup = (args, context) => { }, { label: "Subtract", - } + }, + ], + }, + { + heading: "Single selection with thumbnails", + selectionMode: "single", + items: [ + { + label: "Preview 1", + isSelected: true, + thumbnailUrl: "thumbnail.png", + }, + { + label: "Preview 2", + thumbnailUrl: "flowers.png", + }, + { + label: "Preview 3", + thumbnailUrl: "example-ava.png", + }, ], }, { @@ -631,7 +931,7 @@ export const SelectionGroup = (args, context) => { }, { label: "Subtract", - } + }, ], }, { @@ -640,17 +940,36 @@ export const SelectionGroup = (args, context) => { items: [ { label: "Marquee", - iconName: "Selection", + iconName: "SelectRectangle", isSelected: true, }, { label: "Add", - iconName: "SelectAdd", + iconName: "SelectMulti", }, { label: "Subtract", - iconName: "SelectSubtract", - } + iconName: "SelectNone", + }, + ], + }, + { + heading: "Multiple selection with thumbnails", + selectionMode: "multiple", + items: [ + { + label: "Preview 1", + isSelected: true, + thumbnailUrl: "thumbnail.png", + }, + { + label: "Preview 2", + thumbnailUrl: "flowers.png", + }, + { + label: "Preview 3", + thumbnailUrl: "example-ava.png", + }, ], }, { @@ -668,7 +987,7 @@ export const SelectionGroup = (args, context) => { { label: "Rulers", isSelected: true, - } + }, ], }, { @@ -678,100 +997,144 @@ export const SelectionGroup = (args, context) => { items: [ { label: "Marquee", - iconName: "Selection", + iconName: "SelectRectangle", isSelected: true, }, { label: "Add", - iconName: "SelectAdd", + iconName: "SelectMulti", }, { label: "Subtract", - iconName: "SelectSubtract", - } + iconName: "SelectNone", + }, + ], + }, + { + heading: "Multiple selection with switches and thumbnails", + selectionMode: "multiple", + hasActions: true, + items: [ + { + label: "Preview 1", + isSelected: true, + thumbnailUrl: "thumbnail.png", + }, + { + label: "Preview 2", + thumbnailUrl: "flowers.png", + }, + { + label: "Preview 3", + thumbnailUrl: "example-ava.png", + }, ], }, ]; return Container({ withBorder: false, - content: groupData.map((group) => Container({ - heading: group.heading, - content: Template({ - ...args, + content: groupData.map((group) => + Container( + { + heading: group.heading, + content: Template( + { + ...args, + selectionMode: group.selectionMode || "none", + hasActions: group.hasActions || false, + items: group.items, + }, + context, + ), + }, context, - selectionMode: group.selectionMode || "none", - hasActions: group.hasActions || false, - items: group.items, - }) - }, context)) + ), + ), }); }; -export const SubmenuInPopover = (context) => Popover({ - isOpen: true, - position: "end-top", - customStyles: { - "inline-size": "200px", - }, - trigger: (args, context) => ActionButton({ - label: "Settings", - iconName: "Settings", - ...args, - }, context), - content: [ - (args, context) => Template({ - items: [ - { - label: "Language", - value: "English (US)", - isDrillIn: true, - isHovered: true, - }, - { - label: "Notifications", - }, - { - label: "Show grid", - } - ], - ...args - }, context), - (args, context) => Popover({ +export const SubmenuInPopover = (args = {}, context = {}) => + Popover( + { isOpen: true, position: "end-top", customStyles: { - top: "-120px", - "inline-size": "120px", + "inline-size": "202px", }, + trigger: (passthroughs) => + ActionButton( + { + label: "Settings", + iconName: "Settings", + ...passthroughs, + }, + context, + ), content: [ - (args, context) => Template({ - selectionMode: "single", - items: [ - { - label: "Deutsch", - }, - { - label: "English (US)", - isSelected: true, - }, - { - label: "Español", - }, - { - label: "Français", - }, - { - label: "Italiano", + Template( + { + ...args, + items: [ + { + label: "Language", + value: "English (US)", + isDrillIn: true, + isHovered: true, + }, + { + label: "Notifications", + }, + { + label: "Show grid", + }, + ], + }, + context, + ), + Popover( + { + isOpen: true, + position: "end-top", + customStyles: { + top: "-110px", + "inline-size": "120px", + "inset-inline-start": "calc(100% - 10px)", }, - { - label: "日本語", - } - ], - ...args, - }, context) + content: [ + Template( + { + ...args, + selectionMode: "single", + items: [ + { + label: "Deutsch", + }, + { + label: "English (US)", + isSelected: true, + }, + { + label: "Español", + }, + { + label: "Français", + }, + { + label: "Italiano", + }, + { + label: "日本語", + }, + ], + }, + context, + ), + ], + }, + context, + ), ], - ...args, - }, context) - ], -}, context); + }, + context, + ); diff --git a/components/menu/themes/express.css b/components/menu/themes/express.css deleted file mode 100644 index 9fd550418f2..00000000000 --- a/components/menu/themes/express.css +++ /dev/null @@ -1,16 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--express */ - -@import "./spectrum.css"; diff --git a/components/menu/themes/spectrum-two.css b/components/menu/themes/spectrum-two.css deleted file mode 100644 index 4f634efa2d7..00000000000 --- a/components/menu/themes/spectrum-two.css +++ /dev/null @@ -1,28 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -@container style(--system: spectrum) { - .spectrum-Menu { - --spectrum-menu-item-background-color-hover: rgb(var(--spectrum-gray-1000-rgb), var(--spectrum-transparent-black-200-opacity)); - --spectrum-menu-item-background-color-down: rgb(var(--spectrum-gray-1000-rgb), var(--spectrum-transparent-black-200-opacity)); - --spectrum-menu-item-background-color-key-focus: rgb(var(--spectrum-gray-1000-rgb), var(--spectrum-transparent-black-200-opacity)); - - --spectrum-menu-item-corner-radius: var(--spectrum-corner-radius-100); - - /* Focus state styling */ - --spectrum-menu-item-focus-indicator-shadow: none; - --spectrum-menu-item-focus-indicator-offset: var(--spectrum-spacing-50); - --spectrum-menu-item-spacing-multiplier: 1; - --spectrum-menu-item-focus-indicator-outline-style: solid; - } -} diff --git a/components/menu/themes/spectrum.css b/components/menu/themes/spectrum.css deleted file mode 100644 index c50b45ae73d..00000000000 --- a/components/menu/themes/spectrum.css +++ /dev/null @@ -1,32 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--legacy */ - -@import "./spectrum-two.css"; - -@container style(--system: legacy) { - .spectrum-Menu { - --spectrum-menu-item-background-color-hover: rgb(var(--spectrum-gray-900-rgb), var(--spectrum-transparent-black-200-opacity)); - --spectrum-menu-item-background-color-down: rgb(var(--spectrum-gray-900-rgb), var(--spectrum-transparent-black-200-opacity)); - --spectrum-menu-item-background-color-key-focus: rgb(var(--spectrum-gray-900-rgb), var(--spectrum-transparent-black-200-opacity)); - - --spectrum-menu-item-corner-radius: 0; - - /* Focus state styling */ - --spectrum-menu-item-focus-indicator-shadow: inset; - --spectrum-menu-item-focus-indicator-offset: 0; - --spectrum-menu-item-spacing-multiplier: 0; - --spectrum-menu-item-focus-indicator-outline-style: none; - } -} diff --git a/components/meter/CHANGELOG.md b/components/meter/CHANGELOG.md index 819db49dd85..a793e05c9b1 100644 --- a/components/meter/CHANGELOG.md +++ b/components/meter/CHANGELOG.md @@ -1,5 +1,68 @@ # Change Log +## 2.0.0-next.3 + +### Major Changes + +📝 [#3968](https://github.com/adobe/spectrum-css/pull/3968) [`75e847f`](https://github.com/adobe/spectrum-css/commit/75e847f1ae38a889b43888b3ac19505aadb4e24d) Thanks [@aramos-adobe](https://github.com/aramos-adobe)! + +### S2 meter migration with base progress bar updates + +This migration updates the meter component and the progress bar component. Both needed the track to have a full corner radius to make the rounded look. The progress bar's HTML template now includes the help text component but it is only used in the meter. Also includes a bug fix for progress bar in order to better support the side label variant. + +#### New updates + +- Includes `--sizeM` and `--sizeXL` (using progress bar's sizes) +- Includes help text component for more context +- Shares progress bar's field label typography +- Added help text visual test +- Added static black variant + +Since the progress bar and meter are now using the same tokens for track thickness in size variants, font size, and spacing, the following mods have been removed from meter but are still able to be used in progress bar: + +- `--mod-progressbar-thickness` +- `--mod-progressbar-font-size` +- `--mod-progressbar-spacing-top-to-text` + +These mods can continue to be used as before. + +#### New mods + +- `--mod-meter-help-text-to-progress-bar` + +## 2.0.0-next.2 + +### Minor Changes + +- [#3908](https://github.com/adobe/spectrum-css/pull/3908) [`7971c77`](https://github.com/adobe/spectrum-css/commit/7971c7728b88e5e539b9d0974ab805d9ef6338fd) Thanks [@cdransf](https://github.com/cdransf)! + +Adjust progressbar styles, story and template to support proper width token and sizes for medium (desktop) and large (mobile) platforms. + +- Progress bar and meter now use the same tokens to control their width. +- Progress bar and meter now have a set width regardless of t-shirt size. + +#### Removed modifiers + +`--mod-meter-inline-size` + +#### New modifiers + +`--mod-progressbar-inline-size` + +## 2.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + +## 2.0.0-next.0 + +### Patch Changes + +- Updated dependencies []: + - @spectrum-css/progressbar@7.0.0-next.0 + ## 1.2.0 ### Minor Changes diff --git a/components/meter/dist/metadata.json b/components/meter/dist/metadata.json index 9bfe3424ce7..53ce94ace9a 100644 --- a/components/meter/dist/metadata.json +++ b/components/meter/dist/metadata.json @@ -2,41 +2,38 @@ "sourceFile": "index.css", "selectors": [ ".spectrum-Meter", + ".spectrum-Meter .spectrum-ProgressBar-helptext", ".spectrum-Meter.is-negative", ".spectrum-Meter.is-notice", ".spectrum-Meter.is-positive", ".spectrum-Meter.spectrum-Meter--sizeL", - ".spectrum-Meter.spectrum-Meter--sizeS" + ".spectrum-Meter.spectrum-Meter--sizeS", + ".spectrum-Meter.spectrum-Meter--sizeXL" ], "modifiers": [ - "--mod-meter-inline-size", + "--mod-meter-help-text-to-progress-bar", "--mod-meter-max-width", "--mod-meter-min-width" ], "component": [ - "--spectrum-meter-default-width", + "--spectrum-meter-help-text-to-progress-bar", "--spectrum-meter-maximum-width", "--spectrum-meter-minimum-width", + "--spectrum-meter-thickness-extra-large", "--spectrum-meter-thickness-large", + "--spectrum-meter-thickness-medium", "--spectrum-meter-thickness-small" ], "global": [ - "--spectrum-component-top-to-text-200", - "--spectrum-component-top-to-text-75", - "--spectrum-font-size-100", - "--spectrum-font-size-75", "--spectrum-negative-visual-color", "--spectrum-notice-visual-color", - "--spectrum-positive-visual-color" + "--spectrum-positive-visual-color", + "--spectrum-spacing-75" ], - "system-theme": [], "passthroughs": [ "--mod-progressbar-fill-color", - "--mod-progressbar-font-size", "--mod-progressbar-max-size", "--mod-progressbar-min-size", - "--mod-progressbar-size-default", - "--mod-progressbar-spacing-top-to-text", "--mod-progressbar-thickness" ], "high-contrast": [] diff --git a/components/meter/index.css b/components/meter/index.css index b51a393aa73..fb552428a38 100644 --- a/components/meter/index.css +++ b/components/meter/index.css @@ -13,21 +13,21 @@ /* @passthrough start */ .spectrum-Meter { - --mod-progressbar-size-default: var(--mod-meter-inline-size, var(--spectrum-meter-default-width)); --mod-progressbar-max-size: var(--mod-meter-max-width, var(--spectrum-meter-maximum-width)); --mod-progressbar-min-size: var(--mod-meter-min-width, var(--spectrum-meter-minimum-width)); + --spectrum-meter-help-text-to-progress-bar: var(--spectrum-spacing-75); + --mod-progressbar-thickness: var(--spectrum-meter-thickness-medium); - &, &.spectrum-Meter--sizeS { --mod-progressbar-thickness: var(--spectrum-meter-thickness-small); - --mod-progressbar-font-size: var(--spectrum-font-size-75); - --mod-progressbar-spacing-top-to-text: var(--spectrum-component-top-to-text-75); } &.spectrum-Meter--sizeL { --mod-progressbar-thickness: var(--spectrum-meter-thickness-large); - --mod-progressbar-font-size: var(--spectrum-font-size-100); - --mod-progressbar-spacing-top-to-text: var(--spectrum-component-top-to-text-200); + } + + &.spectrum-Meter--sizeXL { + --mod-progressbar-thickness: var(--spectrum-meter-thickness-extra-large); } &.is-positive { @@ -41,5 +41,9 @@ &.is-negative { --mod-progressbar-fill-color: var(--spectrum-negative-visual-color); } + + .spectrum-ProgressBar-helptext { + margin-block-start: var(--mod-meter-help-text-to-progress-bar, var(--spectrum-meter-help-text-to-progress-bar)); + } } /* @passthrough end */ diff --git a/components/meter/package.json b/components/meter/package.json index a8e439fb83b..50c65a57474 100644 --- a/components/meter/package.json +++ b/components/meter/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/meter", - "version": "1.2.0", + "version": "2.0.0-next.3", "description": "The Spectrum CSS meter component", "license": "Apache-2.0", "author": "Adobe", @@ -24,8 +24,8 @@ }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/progressbar": ">=6.0.0 <7.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/progressbar": ">=7.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/progressbar": { @@ -36,8 +36,8 @@ } }, "devDependencies": { - "@spectrum-css/progressbar": "6.2.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/progressbar": "7.0.0-next.4", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/meter/stories/meter.stories.js b/components/meter/stories/meter.stories.js index 15603bc9d7c..f86cbad0dcd 100644 --- a/components/meter/stories/meter.stories.js +++ b/components/meter/stories/meter.stories.js @@ -1,6 +1,6 @@ import { Sizes } from "@spectrum-css/preview/decorators"; import { disableDefaultModes } from "@spectrum-css/preview/modes"; -import { size } from "@spectrum-css/preview/types"; +import { size, staticColor } from "@spectrum-css/preview/types"; import { default as ProgressBar } from "@spectrum-css/progressbar/stories/progressbar.stories.js"; import metadata from "../dist/metadata.json"; import packageJson from "../package.json"; @@ -8,7 +8,7 @@ import { MeterGroup } from "./meter.test.js"; import { FillGroup, Template } from "./template.js"; /** - * The meter component is a visual representations of a quantity or an achievement. The progress is determined by user actions, rather than system actions. + * The meter component is a visual representation of a quantity or an achievement. The progress is determined by user actions, rather than system actions. * * Meter is implemented using [the progress bar component](/docs/components-progress-bar--docs). Refer to the progress bar documentation for additional details. * @@ -19,7 +19,7 @@ export default { component: "Meter", argTypes: { ...ProgressBar.argTypes, - size: size(["s", "l"]), + size: size(["s", "m", "l", "xl"]), isIndeterminate: { table: { disable: true } }, fill: { name: "Fill color", @@ -33,12 +33,23 @@ export default { options: ["info", "notice", "positive", "negative"], control: "select", }, + helpText: { + name: "Help text", + type: { name: "text" }, + table: { + type: { summary: "text" }, + category: "Component", + }, + control: "text", + }, + staticColor, }, args: { ...ProgressBar.args, rootClass: "spectrum-Meter", - size: "l", + size: "m", label: "Storage space", + helpText: "", }, parameters: { design: { @@ -47,11 +58,15 @@ export default { }, packageJson, metadata, + status: { + type: "migrated", + }, }, + tags: ["migrated"], }; /** - * By default, meters have a blue fill and are the large sizes. + * By default, meters have a blue fill and are medium-sized. * * Meters should always have a label. In rare cases where context is sufficient and an accessibility expert has reviewed the design, the label could be undefined. These meters without a visible label should still include an “aria-label” or “aria-labelledby” in HTML, depending on the context. The label is always placed above the track. * @@ -63,7 +78,7 @@ Default.args = { }; /** - * Meters come in two sizes: large and small. By default, meters are large. Use the small size when there are multiple meters shown at the same time in a more confined space, such as in tables or cards. + * Meters come in four different sizes: small, medium, large, and extra-large. The medium size is the default and most frequently used option. Use the small size when there are multiple meters shown at the same time in a more confined space, such as in tables or cards. */ export const Sizing = (args, context) => Sizes({ Template, @@ -90,6 +105,39 @@ FillColors.parameters = { chromatic: { disableSnapshot: true }, }; +export const StaticWhite = Template.bind({}); +StaticWhite.args = { + staticColor: "white", + value: 50, +}; +StaticWhite.tags = ["!dev"]; +StaticWhite.parameters = { + chromatic: { disableSnapshot: true }, +}; + +export const StaticBlack = Template.bind({}); +StaticBlack.args = { + staticColor: "black", + value: 50, +}; +StaticBlack.tags = ["!dev"]; +StaticBlack.parameters = { + chromatic: { disableSnapshot: true }, +}; + +/** + * The help text is placed below the meter. This helps to provide additional context for the user. + */ +export const HelpText = Template.bind({}); +HelpText.args = { + helpText: "This is a help text", + value: 50, +}; +HelpText.tags = ["!dev"]; +HelpText.parameters = { + chromatic: { disableSnapshot: true }, +}; +HelpText.storyName = "Help text"; // ********* VRT ONLY ********* // export const WithForcedColors = MeterGroup.bind({}); WithForcedColors.args = Default.args; diff --git a/components/meter/stories/meter.test.js b/components/meter/stories/meter.test.js index 46f60024bf4..64d3ef98750 100644 --- a/components/meter/stories/meter.test.js +++ b/components/meter/stories/meter.test.js @@ -1,8 +1,19 @@ import { Variants } from "@spectrum-css/preview/decorators"; +import { html } from "lit"; import { Template } from "./template.js"; +export const MeterSizingTemplate = (args, context) => { + return html` + ${Template({ + ...args, + helpText: "Upgrade membership to get more storage space" + }, context)} + `; +}; + export const MeterGroup = Variants({ Template, + SizeTemplate: MeterSizingTemplate, testData: [ { testHeading: "Default", @@ -11,10 +22,6 @@ export const MeterGroup = Variants({ testHeading: `Fill: ${fill}`, fill, })), - { - testHeading: "Side label", - labelPosition: "side", - }, { testHeading: "Text overflow", label: "Storage space remaining for XYZ user" @@ -28,6 +35,10 @@ export const MeterGroup = Variants({ testHeading: "Without value label", showValueLabel: false, }, + { + testHeading: "Help text", + helpText: "Help text message to add more context", + }, /* The gradient story below supports linear-gradients used by Express. For use cases that require a custom linear-gradient for any --mod-*-{fill} properties, set those custom properties in CSS. */ @@ -40,5 +51,9 @@ export const MeterGroup = Variants({ testHeading: "Static white", staticColor: "white", }, + { + testHeading: "Static black", + staticColor: "black", + }, ], }); diff --git a/components/meter/stories/template.js b/components/meter/stories/template.js index 5741adc82a5..fb7629d0067 100644 --- a/components/meter/stories/template.js +++ b/components/meter/stories/template.js @@ -8,7 +8,8 @@ export const Template = ({ rootClass = "spectrum-Meter", customClasses = [], fill, - size = "s", + helpText, + size = "m", staticColor, ...item } = {}, context = {}) => { @@ -27,6 +28,8 @@ export const Template = ({ typeof staticColor !== "undefined" ? `${rootClass}--static${capitalize(staticColor)}` : null, ].filter(Boolean), staticColor, + helpText, + size, }, context); }; diff --git a/components/miller/CHANGELOG.md b/components/miller/CHANGELOG.md index 08866e8c37d..1a9d79d90c4 100644 --- a/components/miller/CHANGELOG.md +++ b/components/miller/CHANGELOG.md @@ -1,5 +1,21 @@ # Change log +## 9.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + +## 9.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`a25e0a9`](https://github.com/adobe/spectrum-css/commit/a25e0a99e5a4736ab4e607e00739343101a2633b)]: + - @spectrum-css/icon@10.0.0-next.0 + - @spectrum-css/assetlist@9.0.0-next.0 + - @spectrum-css/checkbox@11.0.0-next.0 + ## 8.2.0 ### Minor Changes @@ -208,6 +224,7 @@ Output for all component CSS files is now being run through a lightweight optimi ### 🛑 BREAKING CHANGE - Removes component-builder & component-builder-simple for script leveraging postcss + - Imports added to index.css and themes/express.css ## 5.1.4 diff --git a/components/miller/dist/metadata.json b/components/miller/dist/metadata.json index adb2109144c..b984a95bf94 100644 --- a/components/miller/dist/metadata.json +++ b/components/miller/dist/metadata.json @@ -5,15 +5,9 @@ ".spectrum-MillerColumns-item", ".spectrum-MillerColumns-item:first-child" ], - "modifiers": [ - "--mod-millercolumns-inline-size", - "--mod-millercolumns-margin-inline-end", - "--mod-millercolumns-margin-inline-start", - "--mod-millercolumns-padding" - ], + "modifiers": [], "component": [], - "global": ["--spectrum-spacing-100"], - "system-theme": [], + "global": ["--spectrum-field-default-width-large", "--spectrum-spacing-100"], "passthroughs": [], "high-contrast": [] } diff --git a/components/miller/index.css b/components/miller/index.css index 6c78ea3ac31..73f777612ed 100644 --- a/components/miller/index.css +++ b/components/miller/index.css @@ -15,21 +15,21 @@ overflow-x: auto; white-space: nowrap; user-select: none; - padding: var(--mod-millercolumns-padding, var(--spectrum-spacing-100)) 0; + padding: var(--spectrum-spacing-100) 0; } .spectrum-MillerColumns-item { display: inline-block; - inline-size: var(--mod-millercolumns-inline-size, 272px); + inline-size: var(--spectrum-field-default-width-large); vertical-align: top; outline: none; margin: 0; padding: 0; - margin-inline-end: var(--mod-millercolumns-margin-inline-end, var(--spectrum-spacing-100)); + margin-inline-end: var(--spectrum-spacing-100); overflow: auto; block-size: 100%; &:first-child { - margin-inline-start: var(--mod-millercolumns-margin-inline-start, var(--spectrum-spacing-100)); + margin-inline-start: var(--spectrum-spacing-100); } } diff --git a/components/miller/package.json b/components/miller/package.json index 8a8566e3618..5a7a10f5505 100644 --- a/components/miller/package.json +++ b/components/miller/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/miller", - "version": "8.2.0", + "version": "9.0.0-next.1", "description": "The Spectrum CSS miller component", "license": "Apache-2.0", "author": "Adobe", @@ -24,10 +24,10 @@ }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/assetlist": ">=8.0.0 <9.0.0", - "@spectrum-css/checkbox": ">=10.0.0 <11.0.0", - "@spectrum-css/icon": ">=9.0.0 <10.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/assetlist": ">=9.0.0-next.0", + "@spectrum-css/checkbox": ">=11.0.0-next.0", + "@spectrum-css/icon": ">=10.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/assetlist": { @@ -44,10 +44,10 @@ } }, "devDependencies": { - "@spectrum-css/assetlist": "8.3.0", - "@spectrum-css/checkbox": "10.2.0", - "@spectrum-css/icon": "9.2.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/assetlist": "9.0.0-next.2", + "@spectrum-css/checkbox": "11.0.0-next.2", + "@spectrum-css/icon": "10.0.0-next.3", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/miller/stories/miller.stories.js b/components/miller/stories/miller.stories.js index a255362e891..15847dea7d8 100644 --- a/components/miller/stories/miller.stories.js +++ b/components/miller/stories/miller.stories.js @@ -17,11 +17,11 @@ export default { rootClass: "spectrum-MillerColumns", columns: [ { + isSelectable: false, items: [ { label: "Folder 1", isBranch: true, - isSelectable: true, isSelected: false, ariaLabelledby: "assetitemlabel-1", checkboxId: "checkbox-1", @@ -29,7 +29,6 @@ export default { { label: "Folder 2", isBranch: true, - isSelectable: true, isSelected: true, ariaLabelledby: "assetitemlabel-2", checkboxId: "checkbox-2", @@ -37,7 +36,6 @@ export default { { label: "Folder 3", isBranch: true, - isSelectable: true, isSelected: false, image: "example-ava.png", ariaLabelledby: "assetitemlabel-3", @@ -46,11 +44,11 @@ export default { ], }, { + isSelectable: true, items: [ { label: "Folder 2.1", isBranch: true, - isSelectable: true, isSelected: false, ariaLabelledby: "assetitemlabel-4", checkboxId: "checkbox-4", @@ -58,7 +56,6 @@ export default { { label: "File 2.1", isBranch: true, - isSelectable: true, isSelected: true, ariaLabelledby: "assetitemlabel-5", checkboxId: "checkbox-5", @@ -66,7 +63,6 @@ export default { { label: "File 2.2", isBranch: true, - isSelectable: true, isSelected: true, image: "example-ava.png", ariaLabelledby: "assetitemlabel-6", @@ -79,7 +75,11 @@ export default { parameters: { packageJson, metadata, + status: { + type: "unmigrated", + }, }, + tags: ["unmigrated"], }; /** @@ -95,11 +95,11 @@ export const FilesSelectable = Template.bind({}); FilesSelectable.args = { columns: [ { + isSelectable: true, items: [ { label: "File 1", isBranch: true, - isSelectable: false, isSelected: false, ariaLabelledby: "assetitemlabel-7", checkboxId: "checkbox-7", @@ -107,7 +107,6 @@ FilesSelectable.args = { { label: "File 2", isBranch: false, - isSelectable: false, isSelected: false, ariaLabelledby: "assetitemlabel-8", checkboxId: "checkbox-8", @@ -115,7 +114,6 @@ FilesSelectable.args = { { label: "File 3", isBranch: true, - isSelectable: false, isSelected: false, isNavigated: true, image: "example-ava.png", @@ -125,17 +123,16 @@ FilesSelectable.args = { ], }, { + isSelectable: true, items: [ { label: "File 2.1", isBranch: true, - isSelectable: false, isSelected: false, }, { - label: "File 2.2 Shows Text Truncation For Long Names", + label: "File 2.2 Shows text truncation for long names", isBranch: false, - isSelectable: false, isSelected: false, ariaLabelledby: "assetitemlabel-10", checkboxId: "checkbox-10", @@ -143,7 +140,6 @@ FilesSelectable.args = { { label: "File 2.3", isBranch: false, - isSelectable: false, isSelected: true, image: "example-ava.png", ariaLabelledby: "assetitemlabel-11", diff --git a/components/miller/stories/miller.test.js b/components/miller/stories/miller.test.js index c2f9be0eb43..48eaf6160e5 100644 --- a/components/miller/stories/miller.test.js +++ b/components/miller/stories/miller.test.js @@ -11,11 +11,11 @@ export const MillerGroup = Variants({ testHeading: "Selectable files", columns: [ { + isSelectable: false, items: [ { label: "File 1", isBranch: true, - isSelectable: false, isSelected: false, ariaLabelledby: "assetitemlabel-7", checkboxId: "checkbox-7", @@ -23,7 +23,6 @@ export const MillerGroup = Variants({ { label: "File 2", isBranch: false, - isSelectable: false, isSelected: false, ariaLabelledby: "assetitemlabel-8", checkboxId: "checkbox-8", @@ -31,7 +30,6 @@ export const MillerGroup = Variants({ { label: "File 3", isBranch: true, - isSelectable: false, isSelected: false, isNavigated: true, image: "example-ava.png", @@ -41,17 +39,16 @@ export const MillerGroup = Variants({ ], }, { + isSelectable: true, items: [ { label: "File 2.1", isBranch: true, - isSelectable: false, isSelected: false, }, { - label: "File 2.2 Shows Text Truncation For Long Names", + label: "File 2.2 Shows text truncation for long names", isBranch: false, - isSelectable: false, isSelected: false, ariaLabelledby: "assetitemlabel-10", checkboxId: "checkbox-10", @@ -59,7 +56,6 @@ export const MillerGroup = Variants({ { label: "File 2.3", isBranch: false, - isSelectable: false, isSelected: true, image: "example-ava.png", ariaLabelledby: "assetitemlabel-11", diff --git a/components/miller/stories/template.js b/components/miller/stories/template.js index 66caafe96fe..ed1cc6d6ab3 100644 --- a/components/miller/stories/template.js +++ b/components/miller/stories/template.js @@ -20,10 +20,10 @@ export const Template = ({ ...customClasses.reduce((a, c) => ({ ...a, [c]: true }), {}), })} > - ${columns.map(({ items }) => { + ${columns.map(({ items, ...args } = { items: [] }) => { return html`
- ${AssetList({ items }, context)} + ${AssetList({ ...args, items }, context)}
`; })} diff --git a/components/modal/CHANGELOG.md b/components/modal/CHANGELOG.md index aee9166e8ae..55b2275b04b 100644 --- a/components/modal/CHANGELOG.md +++ b/components/modal/CHANGELOG.md @@ -1,5 +1,20 @@ # Change log +## 8.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + +## 7.1.1-next.0 + +### Patch Changes + +📝 [#3604](https://github.com/adobe/spectrum-css/pull/3604) [`cb1b957`](https://github.com/adobe/spectrum-css/commit/cb1b957c05ecf02d3f473de09a8bfd5f2b5d42bf) Thanks [@marissahuysentruyt](https://github.com/marissahuysentruyt)! + +In Spectrum 2, elements that would typically be children of a modal (like dialogs, alert dialogs, and tray) have background-color token specs defined. Because modal _also_ had a defined background color, there was some antialiasing bleed-through happening on the corners, since both the modal and its child now had background colors on top of each other. `--spectrum-modal-background-color` is now redefined as `transparent` to avoid these conflicts in S2. `--mod-modal-background-color` is still available to consumers. + ## 7.2.0 ### Minor Changes @@ -14,8 +29,6 @@ Ensure accurate exports are present for each component. Specifically, adding `th 📝 [`205182b`](https://github.com/adobe/spectrum-css/commit/205182bebcbe82813457aa098d8799b0a23423ee) Thanks [@castastrophe](https://github.com/castastrophe)! -## New feature - Minified and gzipped outputs available for all compiled CSS assets. ### Patch Changes diff --git a/components/modal/dist/metadata.json b/components/modal/dist/metadata.json index 950d9fca3c6..c27c44872d7 100644 --- a/components/modal/dist/metadata.json +++ b/components/modal/dist/metadata.json @@ -15,24 +15,26 @@ "--mod-modal-background-color", "--mod-modal-confirm-border-radius", "--mod-modal-confirm-entry-animation-delay", - "--mod-modal-confirm-entry-animation-distance", "--mod-modal-confirm-entry-animation-duration", "--mod-modal-confirm-exit-animation-delay", "--mod-modal-confirm-exit-animation-duration", "--mod-modal-fullscreen-margin", "--mod-modal-max-height", "--mod-modal-max-width", - "--mod-modal-transition-animation-duration", - "--mod-overlay-animation-duration", - "--mod-overlay-animation-duration-opened" + "--mod-modal-transition-animation-duration" ], "component": [ "--spectrum-modal-background-color", + "--spectrum-modal-confirm-border-radius", "--spectrum-modal-confirm-entry-animation-delay", "--spectrum-modal-confirm-entry-animation-duration", "--spectrum-modal-confirm-exit-animation-delay", "--spectrum-modal-confirm-exit-animation-duration", - "--spectrum-modal-fullscreen-margin" + "--spectrum-modal-fullscreen-margin", + "--spectrum-modal-max-height", + "--spectrum-modal-max-width", + "--spectrum-modal-takeover-window-to-edge", + "--spectrum-modal-transition-animation-duration" ], "global": [ "--spectrum-animation-duration-0", @@ -41,12 +43,10 @@ "--spectrum-animation-duration-500", "--spectrum-animation-ease-in", "--spectrum-animation-ease-out", - "--spectrum-animation-linear", - "--spectrum-background-layer-2-color", - "--spectrum-corner-radius-100", - "--spectrum-dialog-confirm-entry-animation-distance" + "--spectrum-corner-radius-extra-large-default", + "--spectrum-dialog-confirm-entry-animation-distance", + "--spectrum-window-to-edge" ], - "system-theme": ["--system-modal-background-color"], "passthroughs": [], "high-contrast": [] } diff --git a/components/modal/index.css b/components/modal/index.css index 8a5e2e9ad95..312c204caea 100644 --- a/components/modal/index.css +++ b/components/modal/index.css @@ -11,20 +11,23 @@ * governing permissions and limitations under the License. */ -@import "@spectrum-css/commons/overlay.css"; -@import "./themes/spectrum-two.css"; - .spectrum-Modal { --spectrum-modal-confirm-entry-animation-duration: var(--mod-modal-confirm-entry-animation-duration, var(--spectrum-animation-duration-500)); - /* @deprecated --mod-overlay-animation-duration-opened in favor of --mod-modal-confirm-entry-animation-delay */ - --spectrum-modal-confirm-entry-animation-delay: var(--mod-overlay-animation-duration-opened, var(--mod-modal-confirm-entry-animation-delay, var(--spectrum-animation-duration-200))); + --spectrum-modal-confirm-entry-animation-delay: var(--mod-modal-confirm-entry-animation-delay, var(--spectrum-animation-duration-200)); - /* @deprecated --mod-overlay-animation-duration in favor of --mod-modal-confirm-exit-animation-duration */ - --spectrum-modal-confirm-exit-animation-duration: var(--mod-overlay-animation-duration, var(--mod-modal-confirm-exit-animation-duration, var(--spectrum-animation-duration-100))); + --spectrum-modal-confirm-exit-animation-duration: var(--mod-modal-confirm-exit-animation-duration, var(--spectrum-animation-duration-100)); --spectrum-modal-confirm-exit-animation-delay: var(--mod-modal-confirm-exit-animation-delay, var(--spectrum-animation-duration-0)); /* Distance between top and bottom of modal and edge of window for fullscreen modal */ - --spectrum-modal-fullscreen-margin: var(--mod-modal-fullscreen-margin, 32px); + --spectrum-modal-fullscreen-margin: var(--spectrum-window-to-edge); + --spectrum-modal-takeover-window-to-edge: 0; + --spectrum-modal-max-height: 90vh; + --spectrum-modal-max-width: 90%; + + --spectrum-modal-background-color: var(--mod-modal-background-color, transparent); + --spectrum-modal-confirm-border-radius: var(--mod-modal-confirm-border-radius, var(--spectrum-corner-radius-extra-large-default)); + + --spectrum-modal-transition-animation-duration: var(--mod-modal-transition-animation-duration, var(--spectrum-animation-duration-100)); } /* Used to position the modal */ @@ -46,6 +49,7 @@ * We use the stretch value to counteract this where supported. */ block-size: 100vh; + block-size: -moz-available; block-size: -webkit-fill-available; /* autoprefixer: ignore next -- -moz-available providing inconsistent results; want to fall FF back to 100vh */ @@ -60,7 +64,7 @@ z-index: 2; /* Be invisible by default */ - transition: visibility 0ms linear var(--mod-modal-transition-animation-duration, var(--spectrum-animation-duration-100)); + transition: visibility 0ms linear var(--spectrum-modal-transition-animation-duration); &.is-open { visibility: visible; @@ -72,17 +76,17 @@ opacity: 0; /* Start offset by the animation distance -- @note this is using the global dialog token */ - transform: translateY(var(--mod-modal-confirm-entry-animation-distance, var(--spectrum-dialog-confirm-entry-animation-distance))); + transform: translateY(var(--spectrum-dialog-confirm-entry-animation-distance)); /* Appear above underlay */ z-index: 2; /* Don't be bigger than the screen */ - max-block-size: var(--mod-modal-max-height, 90vh); - max-inline-size: var(--mod-modal-max-width, 90%); + max-block-size: var(--mod-modal-max-height, var(--spectrum-modal-max-height)); + max-inline-size: var(--mod-modal-max-width, var(--spectrum-modal-max-width)); - background: var(--mod-modal-background-color, var(--spectrum-modal-background-color)); - border-radius: var(--mod-modal-confirm-border-radius, var(--spectrum-corner-radius-100)); + background: var(--spectrum-modal-background-color); + border-radius: var(--spectrum-modal-confirm-border-radius); overflow: hidden; outline: none; /* Firefox shows outline */ pointer-events: auto; @@ -90,8 +94,8 @@ /* Exit animations */ transition: opacity var(--spectrum-modal-confirm-exit-animation-duration) var(--spectrum-animation-ease-in) var(--spectrum-modal-confirm-exit-animation-delay), - visibility var(--spectrum-animation-duration-0) var(--spectrum-animation-linear) calc(var(--spectrum-modal-confirm-exit-animation-delay) + var(--spectrum-modal-confirm-exit-animation-duration)), - transform var(--spectrum-animation-duration-0) var(--spectrum-animation-linear) calc(var(--spectrum-modal-confirm-exit-animation-delay) + var(--spectrum-modal-confirm-exit-animation-duration)); + visibility 0ms linear calc(var(--spectrum-modal-confirm-exit-animation-delay) + var(--spectrum-modal-confirm-exit-animation-duration)), + transform 0ms linear calc(var(--spectrum-modal-confirm-exit-animation-delay) + var(--spectrum-modal-confirm-exit-animation-duration)); &.is-open { pointer-events: auto; @@ -125,17 +129,15 @@ /** @unofficial */ .spectrum-Modal--fullscreen { position: fixed; - inset-inline-start: var(--spectrum-modal-fullscreen-margin); - inset-block-start: var(--spectrum-modal-fullscreen-margin); - inset-inline-end: var(--spectrum-modal-fullscreen-margin); - inset-block-end: var(--spectrum-modal-fullscreen-margin); + inset-block: var(--mod-modal-fullscreen-margin, var(--spectrum-modal-fullscreen-margin)); + inset-inline: var(--mod-modal-fullscreen-margin, var(--spectrum-modal-fullscreen-margin)); max-inline-size: none; max-block-size: none; } .spectrum-Modal--fullscreenTakeover { position: fixed; - inset: 0; + inset: var(--spectrum-modal-takeover-window-to-edge); max-inline-size: none; max-block-size: none; diff --git a/components/modal/package.json b/components/modal/package.json index a09702464f9..6997cd5ed06 100644 --- a/components/modal/package.json +++ b/components/modal/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/modal", - "version": "7.2.0", + "version": "8.0.0-next.1", "description": "The Spectrum CSS modal component", "license": "Apache-2.0", "author": "Adobe", @@ -19,14 +19,12 @@ "./package.json": "./package.json", "./dist/*": "./dist/*", "./index.css": "./dist/index.css", - "./index-*.css": "./dist/index-*.css", "./metadata.json": "./dist/metadata.json", - "./themes/*": "./dist/themes/*", "./stories/*": "./stories/*" }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/tokens": ">=16.0.1" + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/tokens": { @@ -34,8 +32,7 @@ } }, "devDependencies": { - "@spectrum-css/commons": "11.1.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/modal/stories/modal.stories.js b/components/modal/stories/modal.stories.js index a4ce483de5f..23901ba9aaf 100644 --- a/components/modal/stories/modal.stories.js +++ b/components/modal/stories/modal.stories.js @@ -51,12 +51,19 @@ export default { }, packageJson, metadata, + status: { + type: "unmigrated", + }, }, decorators: [ withUnderlayWrapper, ], + tags: ["unmigrated"], }; +/** + * The default modal does not include a background color itself, other than `transparent`. If implementations are in need of a background color, and one is not supported within the modal's child component (for example, the dialog defines its own background color), `--mod-modal-background-color` may be set on the `.spectrum-Modal` class. + */ export const Default = ModalGroup.bind({}); Default.args = { content: [ diff --git a/components/modal/stories/template.js b/components/modal/stories/template.js index 07a52b89131..9abbf49ebea 100644 --- a/components/modal/stories/template.js +++ b/components/modal/stories/template.js @@ -5,9 +5,6 @@ import { styleMap } from "lit/directives/style-map.js"; import { when } from "lit/directives/when.js"; import "../index.css"; -import "../themes/spectrum.css"; -/* Must be imported last */ -import "../themes/express.css"; /** * Just the modal markup. diff --git a/components/modal/themes/express.css b/components/modal/themes/express.css deleted file mode 100644 index 9fd550418f2..00000000000 --- a/components/modal/themes/express.css +++ /dev/null @@ -1,16 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--express */ - -@import "./spectrum.css"; diff --git a/components/modal/themes/spectrum-two.css b/components/modal/themes/spectrum-two.css deleted file mode 100644 index c31756dcdae..00000000000 --- a/components/modal/themes/spectrum-two.css +++ /dev/null @@ -1,18 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -@container style(--system: spectrum) { - .spectrum-Modal { - --spectrum-modal-background-color: var(--spectrum-background-layer-2-color); - } -} diff --git a/components/modal/themes/spectrum.css b/components/modal/themes/spectrum.css deleted file mode 100644 index f637e6f343e..00000000000 --- a/components/modal/themes/spectrum.css +++ /dev/null @@ -1,22 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--legacy */ - -@import "./spectrum-two.css"; - -@container style(--system: legacy) { - .spectrum-Modal { - --spectrum-modal-background-color: var(--spectrum-gray-100); - } -} diff --git a/components/opacitycheckerboard/CHANGELOG.md b/components/opacitycheckerboard/CHANGELOG.md index 76561edd26e..7d3a5e344b7 100644 --- a/components/opacitycheckerboard/CHANGELOG.md +++ b/components/opacitycheckerboard/CHANGELOG.md @@ -1,5 +1,12 @@ # Change log +## 5.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + ## 4.2.0 ### Minor Changes diff --git a/components/opacitycheckerboard/dist/metadata.json b/components/opacitycheckerboard/dist/metadata.json index 51c1a155873..31fd76317b9 100644 --- a/components/opacitycheckerboard/dist/metadata.json +++ b/components/opacitycheckerboard/dist/metadata.json @@ -1,6 +1,9 @@ { "sourceFile": "index.css", - "selectors": [".spectrum-OpacityCheckerboard"], + "selectors": [ + ".spectrum-OpacityCheckerboard", + ".spectrum-OpacityCheckerboard--sizeS" + ], "modifiers": [ "--mod-opacity-checkerboard-dark", "--mod-opacity-checkerboard-light", @@ -8,12 +11,16 @@ "--mod-opacity-checkerboard-size" ], "component": [ + "--spectrum-opacity-checkerboard-dark", + "--spectrum-opacity-checkerboard-light", + "--spectrum-opacity-checkerboard-position", + "--spectrum-opacity-checkerboard-size", "--spectrum-opacity-checkerboard-square-dark", "--spectrum-opacity-checkerboard-square-light", - "--spectrum-opacity-checkerboard-square-size" + "--spectrum-opacity-checkerboard-square-size-medium", + "--spectrum-opacity-checkerboard-square-size-small" ], "global": [], - "system-theme": [], "passthroughs": [], "high-contrast": [] } diff --git a/components/opacitycheckerboard/index.css b/components/opacitycheckerboard/index.css index 675449dd8dd..8f1700294f0 100644 --- a/components/opacitycheckerboard/index.css +++ b/components/opacitycheckerboard/index.css @@ -12,7 +12,19 @@ */ .spectrum-OpacityCheckerboard { - background: repeating-conic-gradient(var(--mod-opacity-checkerboard-light, var(--spectrum-opacity-checkerboard-square-light)) 0% 25%, var(--mod-opacity-checkerboard-dark, var(--spectrum-opacity-checkerboard-square-dark)) 0% 50%) var(--mod-opacity-checkerboard-position, left top) / calc(var(--mod-opacity-checkerboard-size, var(--spectrum-opacity-checkerboard-square-size)) * 2) calc(var(--mod-opacity-checkerboard-size, var(--spectrum-opacity-checkerboard-square-size)) * 2); + --spectrum-opacity-checkerboard-dark: var(--mod-opacity-checkerboard-dark, var(--spectrum-opacity-checkerboard-square-dark)); + --spectrum-opacity-checkerboard-light: var(--mod-opacity-checkerboard-light, var(--spectrum-opacity-checkerboard-square-light)); + --spectrum-opacity-checkerboard-size: var(--mod-opacity-checkerboard-size, var(--spectrum-opacity-checkerboard-square-size-medium)); + + --spectrum-opacity-checkerboard-position: var(--mod-opacity-checkerboard-position, left top); +} + +.spectrum-OpacityCheckerboard--sizeS { + --spectrum-opacity-checkerboard-size: var(--mod-opacity-checkerboard-size, var(--spectrum-opacity-checkerboard-square-size-small)); +} + +.spectrum-OpacityCheckerboard { + background: repeating-conic-gradient(var(--spectrum-opacity-checkerboard-light) 0% 25%, var(--spectrum-opacity-checkerboard-dark) 0% 50%) var(--spectrum-opacity-checkerboard-position) / calc(var(--spectrum-opacity-checkerboard-size) * 2) calc(var(--spectrum-opacity-checkerboard-size) * 2); } @media (forced-colors: active) { diff --git a/components/opacitycheckerboard/package.json b/components/opacitycheckerboard/package.json index 5fb63099772..60b8e0f0245 100644 --- a/components/opacitycheckerboard/package.json +++ b/components/opacitycheckerboard/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/opacitycheckerboard", - "version": "4.2.0", + "version": "5.0.0-next.0", "description": "The Spectrum CSS opacitycheckerboard component", "license": "Apache-2.0", "author": "Adobe", @@ -24,7 +24,7 @@ }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/tokens": ">=16.0.1" + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/tokens": { @@ -32,7 +32,7 @@ } }, "devDependencies": { - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/opacitycheckerboard/stories/opacitycheckerboard.stories.js b/components/opacitycheckerboard/stories/opacitycheckerboard.stories.js index 971f2ef2285..c56f424b990 100644 --- a/components/opacitycheckerboard/stories/opacitycheckerboard.stories.js +++ b/components/opacitycheckerboard/stories/opacitycheckerboard.stories.js @@ -20,6 +20,16 @@ export default { control: "text", description: "Value for --mod-opacity-checkerboard-position. Accepts any valid CSS background-position property value.", }, + size: { + name: "Size", + type: { name: "string", required: true }, + table: { + type: { summary: "string" }, + category: "Component", + }, + options: ["s", "m"], + control: "select", + }, }, args: { rootClass: "spectrum-OpacityCheckerboard", @@ -36,7 +46,11 @@ export default { }, packageJson, metadata, + status: { + type: "migrated", + }, }, + tags: ["migrated"], }; export const Default = OpacityCheckboardGroup.bind({}); diff --git a/components/page/CHANGELOG.md b/components/page/CHANGELOG.md index 864eca7c06f..7af4ad7e79d 100644 --- a/components/page/CHANGELOG.md +++ b/components/page/CHANGELOG.md @@ -1,5 +1,28 @@ # Change log +## 10.0.0-next.1 + +### Patch Changes + +📝 [#4113](https://github.com/adobe/spectrum-css/pull/4113) [`cf4fc1a`](https://github.com/adobe/spectrum-css/commit/cf4fc1a01d23ba810f45a903ecc29a5c8aae33d1) Thanks [@castastrophe](https://github.com/castastrophe)! + +## Minor linting fixes + +- Removed unused custom properties across multiple components +- Fixed color function notation by converting `rgba()` to `rgb()` where appropriate +- Removed duplicate custom property declarations +- Fixed deprecated CSS properties (e.g., `word-wrap` → `overflow-wrap`) +- Removed unnecessary stylelint-disable comments + +_No visual or functional changes to components._ + +## 10.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + ## 9.2.0 ### Minor Changes diff --git a/components/page/dist/metadata.json b/components/page/dist/metadata.json index cb8c8163de8..77cb792b3bb 100644 --- a/components/page/dist/metadata.json +++ b/components/page/dist/metadata.json @@ -1,16 +1,9 @@ { "sourceFile": "index.css", "selectors": [":root"], - "modifiers": ["--mod-page-background", "--mod-page-content-tap-highlight"], - "component": [ - "--spectrum-page-background-color", - "--spectrum-page-content-tap-highlight" - ], + "modifiers": [], + "component": [], "global": ["--spectrum-gray-75", "--spectrum-transparent-black-25"], - "system-theme": [ - "--system-root-page-background-color", - "--system-root-page-content-tap-highlight" - ], "passthroughs": [], "high-contrast": [] } diff --git a/components/page/index.css b/components/page/index.css index 7a29f49a2e2..ac6ce8e1e76 100644 --- a/components/page/index.css +++ b/components/page/index.css @@ -11,11 +11,9 @@ * governing permissions and limitations under the License. */ -@import "./themes/spectrum-two.css"; - :root { - background: var(--mod-page-background, var(--spectrum-page-background-color)); + background: var(--spectrum-gray-75); /* The highlight that appears over a link while it's being tapped */ - -webkit-tap-highlight-color: var(--mod-page-content-tap-highlight, var(--spectrum-page-content-tap-highlight)); + -webkit-tap-highlight-color: var(--spectrum-transparent-black-25); } diff --git a/components/page/package.json b/components/page/package.json index 962b887b2fb..357c5eff26f 100644 --- a/components/page/package.json +++ b/components/page/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/page", - "version": "9.2.0", + "version": "10.0.0-next.1", "description": "The Spectrum CSS page component", "license": "Apache-2.0", "author": "Adobe", @@ -19,14 +19,12 @@ "./package.json": "./package.json", "./dist/*": "./dist/*", "./index.css": "./dist/index.css", - "./index-*.css": "./dist/index-*.css", "./metadata.json": "./dist/metadata.json", - "./themes/*": "./dist/themes/*", "./stories/*": "./stories/*" }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/tokens": ">=16.0.1" + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/tokens": { @@ -34,7 +32,7 @@ } }, "devDependencies": { - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/page/stories/page.stories.js b/components/page/stories/page.stories.js index 7327742970b..edb81d5d664 100644 --- a/components/page/stories/page.stories.js +++ b/components/page/stories/page.stories.js @@ -25,8 +25,11 @@ export default { }, packageJson, metadata, + status: { + type: "unmigrated", + }, }, - tags: ["!autodocs", "!dev"] + tags: ["unmigrated", "!autodocs", "!dev"] }; export const Default = PageGroup.bind({}); diff --git a/components/page/stories/template.js b/components/page/stories/template.js index 570ca98b244..395f6d48390 100644 --- a/components/page/stories/template.js +++ b/components/page/stories/template.js @@ -2,9 +2,6 @@ import { renderContent } from "@spectrum-css/preview/decorators"; import { html } from "lit"; import "../index.css"; -import "../themes/spectrum.css"; -/* Must be imported last */ -import "../themes/express.css"; export const Template = ({ content = [] } = {}, context = {}) => { return html`${renderContent(content, { context })}`; diff --git a/components/page/themes/express.css b/components/page/themes/express.css deleted file mode 100644 index 9fd550418f2..00000000000 --- a/components/page/themes/express.css +++ /dev/null @@ -1,16 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--express */ - -@import "./spectrum.css"; diff --git a/components/page/themes/spectrum-two.css b/components/page/themes/spectrum-two.css deleted file mode 100644 index 896ecf506cc..00000000000 --- a/components/page/themes/spectrum-two.css +++ /dev/null @@ -1,19 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -@container style(--system: spectrum) { - :root { - --spectrum-page-background-color: var(--spectrum-gray-75); - --spectrum-page-content-tap-highlight: var(--spectrum-transparent-black-25); - } -} diff --git a/components/page/themes/spectrum.css b/components/page/themes/spectrum.css deleted file mode 100644 index f6c120c2d43..00000000000 --- a/components/page/themes/spectrum.css +++ /dev/null @@ -1,23 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--legacy */ - -@import "./spectrum-two.css"; - -@container style(--system: legacy) { - :root { - --spectrum-page-background-color: var(--spectrum-gray-100); - --spectrum-page-content-tap-highlight: var(--spectrum-transparent-black-100); - } -} diff --git a/components/pagination/CHANGELOG.md b/components/pagination/CHANGELOG.md index d39b4a07cf0..f9ca596a914 100644 --- a/components/pagination/CHANGELOG.md +++ b/components/pagination/CHANGELOG.md @@ -1,5 +1,30 @@ # Change log +## 11.0.0-next.2 + +### Major Changes + +📝 [#4014](https://github.com/adobe/spectrum-css/pull/4014) [`35c066b`](https://github.com/adobe/spectrum-css/commit/35c066b29c311b1bfcf4507075f13b41222ffc84) Thanks [@castastrophe](https://github.com/castastrophe)! + +This update removes the `dir` attribute polyfill (served via a PostCSS transform to compiled assets) as the fallback is no longer necessary. The`dir` attribute support is available in all supported browsers and has been tested to correctly inherit inside web component shadow DOMs. This is a breaking change **only** to those relying on the `dir` attribute being present for styling, however, the `:dir` pseudo will correctly inherit values from their containers. To correctly determine the `dir` value of a node using JavaScript, you can use `getComputedStyle(node).direction`. + +## 11.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + +## 11.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`a25e0a9`](https://github.com/adobe/spectrum-css/commit/a25e0a99e5a4736ab4e607e00739343101a2633b)]: + - @spectrum-css/icon@10.0.0-next.0 + - @spectrum-css/actionbutton@8.0.0-next.0 + - @spectrum-css/button@15.0.0-next.0 + - @spectrum-css/textfield@9.0.0-next.0 + ## 10.2.0 ### Minor Changes diff --git a/components/pagination/dist/metadata.json b/components/pagination/dist/metadata.json index 7a0b21fe8dd..6c52ad62e8c 100644 --- a/components/pagination/dist/metadata.json +++ b/components/pagination/dist/metadata.json @@ -10,8 +10,7 @@ ".spectrum-Pagination-prevButton", ".spectrum-Pagination-prevButton .spectrum-Icon", ".spectrum-Pagination-textfield", - ".spectrum-Pagination:dir(rtl)", - "[dir=\"rtl\"] .spectrum-Pagination" + ".spectrum-Pagination:dir(rtl)" ], "modifiers": [ "--mod-pagination-counter-color", @@ -34,7 +33,6 @@ "--spectrum-logical-rotation", "--spectrum-neutral-subdued-content-color-default" ], - "system-theme": [], "passthroughs": ["--mod-textfield-min-width", "--mod-textfield-width"], "high-contrast": [] } diff --git a/components/pagination/package.json b/components/pagination/package.json index 64ea153d0f8..7d651e582de 100644 --- a/components/pagination/package.json +++ b/components/pagination/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/pagination", - "version": "10.2.0", + "version": "11.0.0-next.2", "description": "The Spectrum CSS Pagination component", "license": "Apache-2.0", "author": "Adobe", @@ -24,11 +24,11 @@ }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/actionbutton": ">=7.0.0 <8.0.0", - "@spectrum-css/button": ">=14.0.0 <15.0.0", - "@spectrum-css/icon": ">=9.0.0 <10.0.0", - "@spectrum-css/textfield": ">=8.0.0 <9.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/actionbutton": ">=8.0.0-next.0", + "@spectrum-css/button": ">=15.0.0-next.0", + "@spectrum-css/icon": ">=10.0.0-next.0", + "@spectrum-css/textfield": ">=9.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/actionbutton": { @@ -48,11 +48,11 @@ } }, "devDependencies": { - "@spectrum-css/actionbutton": "7.2.0", - "@spectrum-css/button": "14.2.0", - "@spectrum-css/icon": "9.2.0", - "@spectrum-css/textfield": "8.2.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/actionbutton": "8.0.0-next.4", + "@spectrum-css/button": "15.0.0-next.2", + "@spectrum-css/icon": "10.0.0-next.3", + "@spectrum-css/textfield": "9.0.0-next.1", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/pagination/stories/pagination.stories.js b/components/pagination/stories/pagination.stories.js index 7fa6fa909e1..1ce2bc1f1bc 100644 --- a/components/pagination/stories/pagination.stories.js +++ b/components/pagination/stories/pagination.stories.js @@ -70,7 +70,11 @@ export default { }, packageJson, metadata, + status: { + type: "migrated", + }, }, + tags: ["migrated"], }; /** diff --git a/components/picker/CHANGELOG.md b/components/picker/CHANGELOG.md index d5d0233db7e..8be2a52acb0 100644 --- a/components/picker/CHANGELOG.md +++ b/components/picker/CHANGELOG.md @@ -1,5 +1,80 @@ # Change log +## 10.0.0-next.4 + +### Major Changes + +📝 [#2352](https://github.com/adobe/spectrum-css/pull/2352) [`7ac2952`](https://github.com/adobe/spectrum-css/commit/7ac2952d16e9760121e3a33390d14f6e336d587d) Thanks [@pfulton](https://github.com/pfulton)! + +#### Picker: remove quiet variant + +This removes the quiet variant for the picker component based on design feedback. Prior to this change, there was an odd state where the quiet picker scaled with the foundations down state applied. + +##### Removed mods + +`--mod-picker-background-color-disabled` + +**Additionally:** all of the quiet variant mods have been removed. + +`--mod-picker-inline-size-quiet` +`--mod-picker-min-inline-size-quiet` +`--mod-picker-spacing-edge-to-disclosure-icon-quiet` +`--mod-picker-spacing-edge-to-text-quiet` +`--mod-picker-spacing-label-to-picker-quiet` + +## 10.0.0-next.3 + +### Major Changes + +- [#3792](https://github.com/adobe/spectrum-css/pull/3792) [`032001b`](https://github.com/adobe/spectrum-css/commit/032001b4eb1e6f15bb30fcc18b42cd001f790024) Thanks [@aramos-adobe](https://github.com/aramos-adobe)! + +#### Component refactor + +- Refactors Picker component to use proper custom property naming conventions +- Adds size-specific animation distances for Popover component +- Improves component structure with proper class by renaming `spectrum-Picker` to `spectrum-Picker-button` +- `spectrum-Picker` now encapsulates help text, label, and popover components +- Adds `flex-shrink` to progress circle for better layout control when truncation and loading is visible +- Updates Popover animation distance to use `spectrum-Picker` custom properties + +##### New token + +`--spectrum-picker-popover-animation-distance` + +##### Renamed tokens + +`spectrum-picker-spacing-picker-to-popover` --> `--spectrum-picker-popover-animation-distance` + +## 10.0.0-next.2 + +### Patch Changes + +- [#3687](https://github.com/adobe/spectrum-css/pull/3687) [`53d1e5e`](https://github.com/adobe/spectrum-css/commit/53d1e5e7eb7817c37be3cfe5a253363dea744046) Thanks [@marissahuysentruyt](https://github.com/marissahuysentruyt)! - ### S2 picker fixes + + This work addresses some regressions noticed in the migrated S2 picker component. Mainly, S2 border colors were fixed (most of them are transparent, including disabled). + + PRs used as reference: + - [Picker docs to storybook migration](https://github.com/adobe/spectrum-css/pull/3200) + - [S2 picker migration](https://github.com/adobe/spectrum-css/pull/2697) + +## 10.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + - @spectrum-css/progresscircle@6.0.0-next.0 + +## 10.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`a25e0a9`](https://github.com/adobe/spectrum-css/commit/a25e0a99e5a4736ab4e607e00739343101a2633b)]: + - @spectrum-css/icon@10.0.0-next.0 + - @spectrum-css/helptext@8.0.0-next.0 + - @spectrum-css/menu@10.0.0-next.0 + - @spectrum-css/popover@9.0.0-next.0 + ## 9.2.0 ### Minor Changes @@ -12,7 +87,9 @@ Ensure accurate exports are present for each component. Specifically, adding `th ### Patch Changes -- [#3607](https://github.com/adobe/spectrum-css/pull/3607) [`7797847`](https://github.com/adobe/spectrum-css/commit/7797847c723d530f34d610516e04150092557af1) Thanks [@blunteshwar](https://github.com/blunteshwar)! - Updated border-color for Open not hover state of picker from --spectrum-gray-900 to --spectrum-gray-800 as specified in the spec +- [#3607](https://github.com/adobe/spectrum-css/pull/3607) [`7797847`](https://github.com/adobe/spectrum-css/commit/7797847c723d530f34d610516e04150092557af1) Thanks [@blunteshwar](https://github.com/blunteshwar)! + +Updated border-color for open state of picker from `--spectrum-gray-900` to `--spectrum-gray-800`. ## 9.1.3 diff --git a/components/picker/dist/metadata.json b/components/picker/dist/metadata.json index e2c3b4e5c0a..09740dc9174 100644 --- a/components/picker/dist/metadata.json +++ b/components/picker/dist/metadata.json @@ -2,88 +2,72 @@ "sourceFile": "index.css", "selectors": [ ".spectrum-Picker", - ".spectrum-Picker + .spectrum-Popover--bottom.is-open", ".spectrum-Picker .spectrum-Picker-icon", ".spectrum-Picker .spectrum-Picker-label", ".spectrum-Picker .spectrum-ProgressCircle", - ".spectrum-Picker--quiet", - ".spectrum-Picker--quiet .spectrum-Picker-menuIcon", - ".spectrum-Picker--quiet.is-keyboardFocused", - ".spectrum-Picker--quiet.is-keyboardFocused:after", - ".spectrum-Picker--quiet.is-open", - ".spectrum-Picker--quiet.spectrum-Picker--sideLabel", - ".spectrum-Picker--quiet.spectrum-Picker.is-disabled", - ".spectrum-Picker--quiet.spectrum-Picker:disabled", - ".spectrum-Picker--quiet:active", - ".spectrum-Picker--quiet:after", - ".spectrum-Picker--quiet:focus-visible", - ".spectrum-Picker--quiet:focus-visible:after", - ".spectrum-Picker--quiet:hover", ".spectrum-Picker--sideLabel", ".spectrum-Picker--sizeL", - ".spectrum-Picker--sizeL + .spectrum-Popover--bottom.is-open", ".spectrum-Picker--sizeS", - ".spectrum-Picker--sizeS + .spectrum-Popover--bottom.is-open", ".spectrum-Picker--sizeXL", - ".spectrum-Picker--sizeXL + .spectrum-Popover--bottom.is-open", + ".spectrum-Picker-button", + ".spectrum-Picker-button.is-disabled", + ".spectrum-Picker-button.is-disabled .spectrum-Picker-icon", + ".spectrum-Picker-button.is-disabled .spectrum-Picker-label.is-placeholder", + ".spectrum-Picker-button.is-disabled .spectrum-Picker-menuIcon", + ".spectrum-Picker-button.is-disabled .spectrum-Picker-validationIcon", + ".spectrum-Picker-button.is-invalid.is-keyboardFocused:not(:disabled, .is-disabled)", + ".spectrum-Picker-button.is-invalid.is-open:not(:disabled, .is-disabled)", + ".spectrum-Picker-button.is-invalid.is-open:not(:disabled, .is-disabled):hover", + ".spectrum-Picker-button.is-invalid:not(:disabled, .is-disabled)", + ".spectrum-Picker-button.is-invalid:not(:disabled, .is-disabled) .spectrum-Picker-validationIcon", + ".spectrum-Picker-button.is-invalid:not(:disabled, .is-disabled):active", + ".spectrum-Picker-button.is-invalid:not(:disabled, .is-disabled):focus-visible", + ".spectrum-Picker-button.is-invalid:not(:disabled, .is-disabled):hover", + ".spectrum-Picker-button.is-keyboardFocused", + ".spectrum-Picker-button.is-keyboardFocused .spectrum-Picker-label.is-placeholder", + ".spectrum-Picker-button.is-keyboardFocused .spectrum-Picker-menuIcon", + ".spectrum-Picker-button.is-keyboardFocused:after", + ".spectrum-Picker-button.is-open:not(:disabled, .is-disabled, .is-loading)", + ".spectrum-Picker-button.is-open:not(:disabled, .is-disabled, .is-loading) .spectrum-Picker-menuIcon", + ".spectrum-Picker-button.is-open:not(:disabled, .is-disabled, .is-loading):hover", + ".spectrum-Picker-button.is-open:not(:disabled, .is-disabled, .is-loading):hover .spectrum-Picker-menuIcon", + ".spectrum-Picker-button::-moz-focus-inner", + ".spectrum-Picker-button:active", + ".spectrum-Picker-button:active .spectrum-Picker-label.is-placeholder", + ".spectrum-Picker-button:active:after", + ".spectrum-Picker-button:disabled", + ".spectrum-Picker-button:disabled .spectrum-Picker-icon", + ".spectrum-Picker-button:disabled .spectrum-Picker-label.is-placeholder", + ".spectrum-Picker-button:disabled .spectrum-Picker-menuIcon", + ".spectrum-Picker-button:disabled .spectrum-Picker-validationIcon", + ".spectrum-Picker-button:focus", + ".spectrum-Picker-button:focus-visible", + ".spectrum-Picker-button:focus-visible .spectrum-Picker-label.is-placeholder", + ".spectrum-Picker-button:focus-visible .spectrum-Picker-menuIcon", + ".spectrum-Picker-button:focus-visible:after", + ".spectrum-Picker-button:hover", + ".spectrum-Picker-button:hover .spectrum-Picker-menuIcon", ".spectrum-Picker-label", - ".spectrum-Picker-label ~ .spectrum-Picker-menuIcon", ".spectrum-Picker-label.is-placeholder", ".spectrum-Picker-label.is-placeholder:active", ".spectrum-Picker-label.is-placeholder:hover", ".spectrum-Picker-menuIcon", ".spectrum-Picker-menuIcon:active", ".spectrum-Picker-validationIcon", - ".spectrum-Picker.is-disabled", - ".spectrum-Picker.is-disabled .spectrum-Picker-icon", - ".spectrum-Picker.is-disabled .spectrum-Picker-label.is-placeholder", - ".spectrum-Picker.is-disabled .spectrum-Picker-menuIcon", - ".spectrum-Picker.is-disabled .spectrum-Picker-validationIcon", - ".spectrum-Picker.is-invalid .spectrum-Picker-label", - ".spectrum-Picker.is-invalid.is-keyboardFocused:not(:disabled, .is-disabled)", - ".spectrum-Picker.is-invalid.is-open:not(:disabled, .is-disabled)", - ".spectrum-Picker.is-invalid.is-open:not(:disabled, .is-disabled):hover", - ".spectrum-Picker.is-invalid:not(:disabled, .is-disabled)", - ".spectrum-Picker.is-invalid:not(:disabled, .is-disabled) .spectrum-Picker-validationIcon", - ".spectrum-Picker.is-invalid:not(:disabled, .is-disabled):active", - ".spectrum-Picker.is-invalid:not(:disabled, .is-disabled):focus-visible", - ".spectrum-Picker.is-invalid:not(:disabled, .is-disabled):hover", ".spectrum-Picker.is-keyboardFocused", - ".spectrum-Picker.is-keyboardFocused .spectrum-Picker-label.is-placeholder", - ".spectrum-Picker.is-keyboardFocused .spectrum-Picker-menuIcon", - ".spectrum-Picker.is-keyboardFocused:after", - ".spectrum-Picker.is-loading .spectrum-Picker-label", + ".spectrum-Picker.is-loading", ".spectrum-Picker.is-loading .spectrum-Picker-menuIcon", - ".spectrum-Picker.is-open:not(.spectrum-Picker--quiet, :disabled, .is-disabled)", - ".spectrum-Picker.is-open:not(.spectrum-Picker--quiet, :disabled, .is-disabled) .spectrum-Picker-menuIcon", - ".spectrum-Picker.is-open:not(.spectrum-Picker--quiet, :disabled, .is-disabled):hover", - ".spectrum-Picker.is-open:not(.spectrum-Picker--quiet, :disabled, .is-disabled):hover .spectrum-Picker-menuIcon", - ".spectrum-Picker.is-placeholder:active .spectrum-Picker-label", - ".spectrum-Picker::-moz-focus-inner", - ".spectrum-Picker:active", - ".spectrum-Picker:active:after", ".spectrum-Picker:after", - ".spectrum-Picker:disabled", - ".spectrum-Picker:disabled .spectrum-Picker-icon", - ".spectrum-Picker:disabled .spectrum-Picker-label.is-placeholder", - ".spectrum-Picker:disabled .spectrum-Picker-menuIcon", - ".spectrum-Picker:disabled .spectrum-Picker-validationIcon", - ".spectrum-Picker:focus", ".spectrum-Picker:focus-visible", - ".spectrum-Picker:focus-visible .spectrum-Picker-label.is-placeholder", - ".spectrum-Picker:focus-visible .spectrum-Picker-menuIcon", - ".spectrum-Picker:focus-visible:after", - ".spectrum-Picker:hover", - ".spectrum-Picker:hover .spectrum-Picker-menuIcon" + ".spectrum-Picker:lang(ja) .spectrum-Picker-label", + ".spectrum-Picker:lang(ko) .spectrum-Picker-label", + ".spectrum-Picker:lang(zh) .spectrum-Picker-label" ], "modifiers": [ - "--mod-animation-duration-100", - "--mod-line-height-100", "--mod-picker-animation-duration", "--mod-picker-background-color-active", "--mod-picker-background-color-default", "--mod-picker-background-color-default-open", - "--mod-picker-background-color-disabled", "--mod-picker-background-color-hover", "--mod-picker-background-color-hover-open", "--mod-picker-background-color-key-focus", @@ -124,32 +108,27 @@ "--mod-picker-icon-color-key-focus", "--mod-picker-inline-size", "--mod-picker-line-height", + "--mod-picker-line-height-cjk", + "--mod-picker-min-inline-size", "--mod-picker-placeholder-font-style", "--mod-picker-placeholder-font-weight", "--mod-picker-spacing-bottom-to-text", "--mod-picker-spacing-edge-to-disclosure-icon", - "--mod-picker-spacing-edge-to-disclosure-icon-quiet", "--mod-picker-spacing-edge-to-text", - "--mod-picker-spacing-edge-to-text-quiet", "--mod-picker-spacing-icon-to-disclosure-icon", "--mod-picker-spacing-label-to-picker", - "--mod-picker-spacing-label-to-picker-quiet", - "--mod-picker-spacing-picker-to-popover", - "--mod-picker-spacing-text-to-alert-icon-inline-start", - "--mod-picker-spacing-text-to-icon", + "--mod-picker-spacing-starting-icon-to-text", "--mod-picker-spacing-text-to-icon-inline-end", "--mod-picker-spacing-top-to-alert-icon", "--mod-picker-spacing-top-to-disclosure-icon", "--mod-picker-spacing-top-to-progress-circle", - "--mod-picker-spacing-top-to-text", - "--mod-sans-font-family-stack" + "--mod-picker-spacing-top-to-text" ], "component": [ "--spectrum-picker-animation-duration", "--spectrum-picker-background-color-active", "--spectrum-picker-background-color-default", "--spectrum-picker-background-color-default-open", - "--spectrum-picker-background-color-disabled", "--spectrum-picker-background-color-hover", "--spectrum-picker-background-color-hover-open", "--spectrum-picker-background-color-key-focus", @@ -157,7 +136,6 @@ "--spectrum-picker-border-color-active", "--spectrum-picker-border-color-default", "--spectrum-picker-border-color-default-open", - "--spectrum-picker-border-color-disabled", "--spectrum-picker-border-color-error-active", "--spectrum-picker-border-color-error-default", "--spectrum-picker-border-color-error-default-open", @@ -169,7 +147,6 @@ "--spectrum-picker-border-color-key-focus", "--spectrum-picker-border-radius", "--spectrum-picker-border-width", - "--spectrum-picker-end-edge-to-disclousure-icon-quiet", "--spectrum-picker-focus-indicator-color", "--spectrum-picker-focus-indicator-gap", "--spectrum-picker-focus-indicator-thickness", @@ -192,18 +169,17 @@ "--spectrum-picker-icon-color-key-focus", "--spectrum-picker-inline-size", "--spectrum-picker-line-height", + "--spectrum-picker-line-height-cjk", + "--spectrum-picker-min-inline-size", "--spectrum-picker-minimum-width-multiplier", "--spectrum-picker-placeholder-font-style", + "--spectrum-picker-popover-animation-distance", "--spectrum-picker-spacing-bottom-to-text", "--spectrum-picker-spacing-edge-to-disclosure-icon", - "--spectrum-picker-spacing-edge-to-disclosure-icon-quiet", "--spectrum-picker-spacing-edge-to-text", - "--spectrum-picker-spacing-edge-to-text-quiet", "--spectrum-picker-spacing-icon-to-disclosure-icon", "--spectrum-picker-spacing-label-to-picker", - "--spectrum-picker-spacing-label-to-picker-quiet", - "--spectrum-picker-spacing-picker-to-popover", - "--spectrum-picker-spacing-text-to-icon", + "--spectrum-picker-spacing-starting-icon-to-text", "--spectrum-picker-spacing-text-to-icon-inline-end", "--spectrum-picker-spacing-top-to-alert-icon", "--spectrum-picker-spacing-top-to-disclosure-icon", @@ -216,7 +192,8 @@ ], "global": [ "--spectrum-animation-duration-100", - "--spectrum-border-width-100", + "--spectrum-border-width-200", + "--spectrum-cjk-line-height-100", "--spectrum-component-bottom-to-text-100", "--spectrum-component-bottom-to-text-200", "--spectrum-component-bottom-to-text-300", @@ -229,6 +206,8 @@ "--spectrum-component-height-200", "--spectrum-component-height-300", "--spectrum-component-height-75", + "--spectrum-component-size-difference-down", + "--spectrum-component-size-width-ratio-down", "--spectrum-component-to-menu-extra-large", "--spectrum-component-to-menu-large", "--spectrum-component-to-menu-medium", @@ -237,28 +216,27 @@ "--spectrum-component-top-to-text-200", "--spectrum-component-top-to-text-300", "--spectrum-component-top-to-text-75", - "--spectrum-corner-radius-100", + "--spectrum-component-top-to-workflow-icon-100", + "--spectrum-component-top-to-workflow-icon-200", + "--spectrum-component-top-to-workflow-icon-300", + "--spectrum-component-top-to-workflow-icon-75", + "--spectrum-corner-radius-medium-size-extra-large", + "--spectrum-corner-radius-medium-size-large", + "--spectrum-corner-radius-medium-size-medium", + "--spectrum-corner-radius-medium-size-small", "--spectrum-default-font-style", - "--spectrum-disabled-background-color", "--spectrum-disabled-content-color", - "--spectrum-field-edge-to-text-quiet", + "--spectrum-downstate-height", + "--spectrum-downstate-width", + "--spectrum-field-default-width-extra-large", + "--spectrum-field-default-width-large", + "--spectrum-field-default-width-medium", + "--spectrum-field-default-width-small", "--spectrum-field-end-edge-to-disclosure-icon-100", "--spectrum-field-end-edge-to-disclosure-icon-200", "--spectrum-field-end-edge-to-disclosure-icon-300", "--spectrum-field-end-edge-to-disclosure-icon-75", "--spectrum-field-label-to-component", - "--spectrum-field-label-to-component-quiet-extra-large", - "--spectrum-field-label-to-component-quiet-large", - "--spectrum-field-label-to-component-quiet-medium", - "--spectrum-field-label-to-component-quiet-small", - "--spectrum-field-text-to-alert-icon-extra-large", - "--spectrum-field-text-to-alert-icon-large", - "--spectrum-field-text-to-alert-icon-medium", - "--spectrum-field-text-to-alert-icon-small", - "--spectrum-field-top-to-alert-icon-extra-large", - "--spectrum-field-top-to-alert-icon-large", - "--spectrum-field-top-to-alert-icon-medium", - "--spectrum-field-top-to-alert-icon-small", "--spectrum-field-top-to-disclosure-icon-100", "--spectrum-field-top-to-disclosure-icon-200", "--spectrum-field-top-to-disclosure-icon-300", @@ -267,7 +245,6 @@ "--spectrum-field-top-to-progress-circle-large", "--spectrum-field-top-to-progress-circle-medium", "--spectrum-field-top-to-progress-circle-small", - "--spectrum-field-width", "--spectrum-focus-indicator-color", "--spectrum-focus-indicator-gap", "--spectrum-focus-indicator-thickness", @@ -277,12 +254,6 @@ "--spectrum-font-size-75", "--spectrum-gray-100", "--spectrum-gray-200", - "--spectrum-gray-300", - "--spectrum-gray-500", - "--spectrum-gray-600", - "--spectrum-gray-700", - "--spectrum-gray-800", - "--spectrum-gray-900", "--spectrum-line-height-100", "--spectrum-negative-border-color-default", "--spectrum-negative-border-color-down", @@ -304,26 +275,10 @@ "--spectrum-text-to-visual-300", "--spectrum-text-to-visual-75" ], - "system-theme": [ - "--system-picker-background-color-active", - "--system-picker-background-color-default", - "--system-picker-background-color-default-open", - "--system-picker-background-color-hover", - "--system-picker-background-color-hover-open", - "--system-picker-background-color-key-focus", - "--system-picker-border-color-active", - "--system-picker-border-color-default", - "--system-picker-border-color-default-open", - "--system-picker-border-color-disabled", - "--system-picker-border-color-hover", - "--system-picker-border-color-hover-open", - "--system-picker-border-color-key-focus", - "--system-picker-border-width" - ], "passthroughs": [ - "--mod-button-animation-duration", "--mod-button-font-family", - "--mod-button-line-height" + "--mod-button-line-height", + "--mod-popover-animation-distance" ], "high-contrast": [ "--highcontrast-picker-background-color", diff --git a/components/picker/index.css b/components/picker/index.css index e59888c78f5..dddf46479fb 100644 --- a/components/picker/index.css +++ b/components/picker/index.css @@ -1,5 +1,5 @@ /*! - * Copyright 2024 Adobe. All rights reserved. + * Copyright 2025 Adobe. All rights reserved. * * This file is licensed to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. You may obtain a copy @@ -11,44 +11,63 @@ * governing permissions and limitations under the License. */ -@import "./themes/spectrum-two.css"; -@import "@spectrum-css/commons/basebutton.css"; - .spectrum-Picker { - /* font */ + /* Color */ + --spectrum-picker-background-color-default: var(--spectrum-gray-100); + --spectrum-picker-background-color-default-open: var(--spectrum-gray-200); + --spectrum-picker-background-color-hover: var(--spectrum-gray-200); + --spectrum-picker-background-color-hover-open: var(--spectrum-gray-200); + --spectrum-picker-background-color-active: var(--spectrum-gray-200); + --spectrum-picker-background-color-key-focus: var(--spectrum-gray-200); + + --spectrum-picker-border-color-default: transparent; + --spectrum-picker-border-color-default-open: transparent; + --spectrum-picker-border-color-hover: transparent; + --spectrum-picker-border-color-hover-open: transparent; + --spectrum-picker-border-color-active: transparent; + --spectrum-picker-border-color-key-focus: transparent; + + /* Font */ --spectrum-picker-font-size: var(--spectrum-font-size-100); --spectrum-picker-font-weight: var(--spectrum-regular-font-weight); --spectrum-picker-placeholder-font-style: var(--spectrum-default-font-style); --spectrum-picker-line-height: var(--spectrum-line-height-100); + --spectrum-picker-line-height-cjk: var(--spectrum-cjk-line-height-100); - /* height */ + /* Dimensions */ --spectrum-picker-block-size: var(--spectrum-component-height-100); - --spectrum-picker-inline-size: var(--spectrum-field-width); + --spectrum-picker-inline-size: var(--spectrum-field-default-width-medium); + --spectrum-picker-min-inline-size: calc(var(--spectrum-picker-minimum-width-multiplier) * var(--mod-picker-block-size, var(--spectrum-picker-block-size))); - /* border */ - --spectrum-picker-border-radius: var(--spectrum-corner-radius-100); + /* Border */ + --spectrum-picker-border-radius: var(--spectrum-corner-radius-medium-size-medium); + --spectrum-picker-border-width: var(--spectrum-border-width-200); - /* spacing */ + /* Spacing */ --spectrum-picker-spacing-top-to-text: var(--spectrum-component-top-to-text-100); --spectrum-picker-spacing-bottom-to-text: var(--spectrum-component-bottom-to-text-100); --spectrum-picker-spacing-edge-to-text: var(--spectrum-component-edge-to-text-100); - --spectrum-picker-spacing-edge-to-text-quiet: var(--spectrum-field-edge-to-text-quiet); + + /* Space from label component to Picker component. */ --spectrum-picker-spacing-label-to-picker: var(--spectrum-field-label-to-component); - --spectrum-picker-spacing-text-to-icon: var(--spectrum-text-to-visual-100); - --spectrum-picker-spacing-text-to-icon-inline-end: var(--spectrum-field-text-to-alert-icon-medium); + /* Space from optional starting icon to the text. */ + --spectrum-picker-spacing-starting-icon-to-text: var(--spectrum-text-to-visual-100); + + /* Space from text to either the disclosure icon or the alert/progress visual if present. */ + --spectrum-picker-spacing-text-to-icon-inline-end: var(--spectrum-text-to-visual-100); + + /* Space from alert/progress visual to the disclosure icon (chevron). */ --spectrum-picker-spacing-icon-to-disclosure-icon: var(--spectrum-picker-visual-to-disclosure-icon-medium); - --spectrum-picker-spacing-label-to-picker-quiet: var(--spectrum-field-label-to-component-quiet-medium); - --spectrum-picker-spacing-top-to-alert-icon: var(--spectrum-field-top-to-alert-icon-medium); + + --spectrum-picker-spacing-top-to-alert-icon: var(--spectrum-component-top-to-workflow-icon-100); --spectrum-picker-spacing-top-to-progress-circle: var(--spectrum-field-top-to-progress-circle-medium); --spectrum-picker-spacing-top-to-disclosure-icon: var(--spectrum-field-top-to-disclosure-icon-100); --spectrum-picker-spacing-edge-to-disclosure-icon: var(--spectrum-field-end-edge-to-disclosure-icon-100); - --spectrum-picker-spacing-edge-to-disclosure-icon-quiet: var(--spectrum-picker-end-edge-to-disclousure-icon-quiet); - /* animation */ + /* Animation */ --spectrum-picker-animation-duration: var(--spectrum-animation-duration-100); - /* color */ --spectrum-picker-font-color-default: var(--spectrum-neutral-content-color-default); --spectrum-picker-font-color-default-open: var(--spectrum-neutral-content-color-focus); --spectrum-picker-font-color-hover: var(--spectrum-neutral-content-color-hover); @@ -72,126 +91,122 @@ --spectrum-picker-icon-color-error: var(--spectrum-negative-visual-color); - --spectrum-picker-background-color-disabled: var(--spectrum-disabled-background-color); --spectrum-picker-font-color-disabled: var(--spectrum-disabled-content-color); --spectrum-picker-icon-color-disabled: var(--spectrum-disabled-content-color); - /* special cases for focus indicator */ + /* focus indicator */ --spectrum-picker-focus-indicator-gap: var(--spectrum-focus-indicator-gap); --spectrum-picker-focus-indicator-thickness: var(--spectrum-focus-indicator-thickness); --spectrum-picker-focus-indicator-color: var(--spectrum-focus-indicator-color); - & + .spectrum-Popover--bottom.is-open { - --spectrum-picker-spacing-picker-to-popover: var(--spectrum-component-to-menu-medium); - } + /* stylelint-disable-next-line spectrum-tools/no-unused-custom-properties -- used to assign Popover mods */ + --spectrum-picker-popover-animation-distance: var(--spectrum-component-to-menu-medium); + + --mod-popover-animation-distance: var(--spectrum-picker-popover-animation-distance); } .spectrum-Picker--sizeS { --spectrum-picker-font-size: var(--spectrum-font-size-75); --spectrum-picker-block-size: var(--spectrum-component-height-75); + --spectrum-picker-inline-size: var(--spectrum-field-default-width-small); + --spectrum-picker-border-radius: var(--spectrum-corner-radius-medium-size-small); --spectrum-picker-spacing-top-to-text: var(--spectrum-component-top-to-text-75); --spectrum-picker-spacing-bottom-to-text: var(--spectrum-component-bottom-to-text-75); --spectrum-picker-spacing-edge-to-text: var(--spectrum-component-edge-to-text-75); - --spectrum-picker-spacing-text-to-icon: var(--spectrum-text-to-visual-75); - --spectrum-picker-spacing-text-to-icon-inline-end: var(--spectrum-field-text-to-alert-icon-small); + --spectrum-picker-spacing-starting-icon-to-text: var(--spectrum-text-to-visual-75); + --spectrum-picker-spacing-text-to-icon-inline-end: var(--spectrum-text-to-visual-75); --spectrum-picker-spacing-icon-to-disclosure-icon: var(--spectrum-picker-visual-to-disclosure-icon-small); - --spectrum-picker-spacing-label-to-picker-quiet: var(--spectrum-field-label-to-component-quiet-small); - --spectrum-picker-spacing-top-to-alert-icon: var(--spectrum-field-top-to-alert-icon-small); + --spectrum-picker-spacing-top-to-alert-icon: var(--spectrum-component-top-to-workflow-icon-75); --spectrum-picker-spacing-top-to-progress-circle: var(--spectrum-field-top-to-progress-circle-small); --spectrum-picker-spacing-top-to-disclosure-icon: var(--spectrum-field-top-to-disclosure-icon-75); --spectrum-picker-spacing-edge-to-disclosure-icon: var(--spectrum-field-end-edge-to-disclosure-icon-75); - - & + .spectrum-Popover--bottom.is-open { - --spectrum-picker-spacing-picker-to-popover: var(--spectrum-component-to-menu-small); - } + /* stylelint-disable-next-line spectrum-tools/no-unused-custom-properties -- used to assign Popover mods */ + --spectrum-picker-popover-animation-distance: var(--spectrum-component-to-menu-small); } .spectrum-Picker--sizeL { --spectrum-picker-font-size: var(--spectrum-font-size-200); + --spectrum-picker-inline-size: var(--spectrum-field-default-width-large); --spectrum-picker-block-size: var(--spectrum-component-height-200); + --spectrum-picker-border-radius: var(--spectrum-corner-radius-medium-size-large); --spectrum-picker-spacing-top-to-text: var(--spectrum-component-top-to-text-200); --spectrum-picker-spacing-bottom-to-text: var(--spectrum-component-bottom-to-text-200); --spectrum-picker-spacing-edge-to-text: var(--spectrum-component-edge-to-text-200); - --spectrum-picker-spacing-text-to-icon: var(--spectrum-text-to-visual-200); - --spectrum-picker-spacing-text-to-icon-inline-end: var(--spectrum-field-text-to-alert-icon-large); + --spectrum-picker-spacing-starting-icon-to-text: var(--spectrum-text-to-visual-200); + --spectrum-picker-spacing-text-to-icon-inline-end: var(--spectrum-text-to-visual-200); --spectrum-picker-spacing-icon-to-disclosure-icon: var(--spectrum-picker-visual-to-disclosure-icon-large); - --spectrum-picker-spacing-label-to-picker-quiet: var(--spectrum-field-label-to-component-quiet-large); - --spectrum-picker-spacing-top-to-alert-icon: var(--spectrum-field-top-to-alert-icon-large); + --spectrum-picker-spacing-top-to-alert-icon: var(--spectrum-component-top-to-workflow-icon-200); --spectrum-picker-spacing-top-to-progress-circle: var(--spectrum-field-top-to-progress-circle-large); --spectrum-picker-spacing-top-to-disclosure-icon: var(--spectrum-field-top-to-disclosure-icon-200); --spectrum-picker-spacing-edge-to-disclosure-icon: var(--spectrum-field-end-edge-to-disclosure-icon-200); - - & + .spectrum-Popover--bottom.is-open { - --spectrum-picker-spacing-picker-to-popover: var(--spectrum-component-to-menu-large); - } + /* stylelint-disable-next-line spectrum-tools/no-unused-custom-properties -- used to assign Popover mods */ + --spectrum-picker-popover-animation-distance: var(--spectrum-component-to-menu-large); } .spectrum-Picker--sizeXL { --spectrum-picker-font-size: var(--spectrum-font-size-300); + --spectrum-picker-inline-size: var(--spectrum-field-default-width-extra-large); --spectrum-picker-block-size: var(--spectrum-component-height-300); + --spectrum-picker-border-radius: var(--spectrum-corner-radius-medium-size-extra-large); --spectrum-picker-spacing-top-to-text: var(--spectrum-component-top-to-text-300); --spectrum-picker-spacing-bottom-to-text: var(--spectrum-component-bottom-to-text-300); --spectrum-picker-spacing-edge-to-text: var(--spectrum-component-edge-to-text-300); - --spectrum-picker-spacing-text-to-icon: var(--spectrum-text-to-visual-300); - --spectrum-picker-spacing-text-to-icon-inline-end: var(--spectrum-field-text-to-alert-icon-extra-large); + --spectrum-picker-spacing-starting-icon-to-text: var(--spectrum-text-to-visual-300); + --spectrum-picker-spacing-text-to-icon-inline-end: var(--spectrum-text-to-visual-300); --spectrum-picker-spacing-icon-to-disclosure-icon: var(--spectrum-picker-visual-to-disclosure-icon-extra-large); - --spectrum-picker-spacing-label-to-picker-quiet: var(--spectrum-field-label-to-component-quiet-extra-large); - --spectrum-picker-spacing-top-to-alert-icon: var(--spectrum-field-top-to-alert-icon-extra-large); + --spectrum-picker-spacing-top-to-alert-icon: var(--spectrum-component-top-to-workflow-icon-300); --spectrum-picker-spacing-top-to-progress-circle: var(--spectrum-field-top-to-progress-circle-extra-large); --spectrum-picker-spacing-top-to-disclosure-icon: var(--spectrum-field-top-to-disclosure-icon-300); --spectrum-picker-spacing-edge-to-disclosure-icon: var(--spectrum-field-end-edge-to-disclosure-icon-300); - - & + .spectrum-Popover--bottom.is-open { - --spectrum-picker-spacing-picker-to-popover: var(--spectrum-component-to-menu-extra-large); - } + /* stylelint-disable-next-line spectrum-tools/no-unused-custom-properties -- used to assign Popover mods */ + --spectrum-picker-popover-animation-distance: var(--spectrum-component-to-menu-extra-large); } -/* Windows high contrast mode */ -@media (forced-colors: active) { - .spectrum-Picker { - --highcontrast-picker-focus-indicator-color: Highlight; +/* Note: .spectrum-Picker has been renamed to .spectrum-Picker-button. This selector now triggers the Popover component. */ +.spectrum-Picker-button { + cursor: pointer; + user-select: none; - --highcontrast-picker-border-color-default: ButtonBorder; - --highcontrast-picker-border-color-hover: Highlight; - --highcontrast-picker-border-color-disabled: GrayText; + /* Contain halo */ + position: relative; - --highcontrast-picker-content-color-default: ButtonText; - --highcontrast-picker-content-color-disabled: GrayText; - --highcontrast-picker-background-color: ButtonFace; + /* Show the button overflow in Edge. */ + overflow: visible; + display: flex; + align-items: center; + justify-content: center; - &:focus-visible, - &.is-keyboardFocused { - --highcontrast-picker-border-color-hover: ButtonText; - } + box-sizing: border-box; - /* Focus indicator */ - &::after { - /* Make sure default transparent border stays transparent. */ - forced-color-adjust: none; - } + /* Remove button the margin in Firefox and Safari. */ + margin: 0; - .spectrum-Picker-label { - /* Remove additional text backplate added in WHCM (Edge). */ - forced-color-adjust: none; - } - } -} + font-family: var(--mod-button-font-family, var(--spectrum-sans-font-family-stack)); -.spectrum-Picker { - @extend %spectrum-BaseButton; + /* Adjacent buttons should be aligned correctly */ + vertical-align: top; - /* Layout */ - display: flex; - box-sizing: border-box; + -webkit-font-smoothing: antialiased; + + /* Font smoothing for Firefox */ + -moz-osx-font-smoothing: grayscale; + + line-height: var(--mod-button-line-height, var(--spectrum-line-height-100)); + text-decoration: none; + + /* Remove the inheritance of text transform on button in Edge, Firefox, and IE. */ + text-transform: none; + + /* stylelint-disable-next-line property-no-vendor-prefix -- Correct the inability to style clickable types in iOS and Safari (normalize). */ + -webkit-appearance: button; - /* Minimum width is 2 times the height */ max-inline-size: 100%; - min-inline-size: calc(var(--spectrum-picker-minimum-width-multiplier) * var(--mod-picker-block-size, var(--spectrum-picker-block-size))); + min-inline-size: var(--mod-picker-min-inline-size, var(--spectrum-picker-min-inline-size)); inline-size: var(--mod-picker-inline-size, var(--spectrum-picker-inline-size)); block-size: var(--mod-picker-block-size, var(--spectrum-picker-block-size)); - padding-block: 0; - margin-block-start: var(--mod-picker-spacing-label-to-picker, var(--spectrum-picker-spacing-label-to-picker)); + margin-block-start: var(--mod-picker-spacing-label-to-picker, var(--spectrum-picker-spacing-label-to-picker)); + padding-block: 0; padding-inline-start: var(--mod-picker-spacing-edge-to-text, var(--spectrum-picker-spacing-edge-to-text)); padding-inline-end: var(--mod-picker-spacing-edge-to-disclosure-icon, var(--spectrum-picker-spacing-edge-to-disclosure-icon)); @@ -208,25 +223,24 @@ background-color: var(--highcontrast-picker-background-color, var(--mod-picker-background-color-default, var(--spectrum-picker-background-color-default))); border-color: var(--highcontrast-picker-border-color-default, var(--mod-picker-border-color-default, var(--spectrum-picker-border-color-default))); - /* Focus indicator */ - &::after { - pointer-events: none; - content: ""; - position: absolute; - block-size: calc(100% + (var(--mod-picker-focus-indicator-gap, var(--spectrum-picker-focus-indicator-gap)) * 2) + (var(--mod-picker-border-width, var(--spectrum-picker-border-width)) * 2)); - - inline-size: calc(100% + (var(--mod-picker-focus-indicator-gap, var(--spectrum-picker-focus-indicator-gap)) * 2) + (var(--mod-picker-border-width, var(--spectrum-picker-border-width)) * 2)); + /* Fix Firefox */ + &::-moz-focus-inner { + margin-block-start: -2px; + margin-block-end: -2px; + padding: 0; + border: 0; - margin-block-start: calc((var(--mod-picker-focus-indicator-gap, var(--spectrum-picker-focus-indicator-gap)) + var(--mod-picker-focus-indicator-thickness, var(--spectrum-picker-focus-indicator-thickness)) + var(--mod-picker-border-width, var(--spectrum-picker-border-width))) * -1); + /* Remove the inner border and padding for button in Firefox. */ + border-style: none; + } - margin-inline-start: calc((var(--mod-picker-focus-indicator-gap, var(--spectrum-picker-focus-indicator-gap)) + var(--mod-picker-focus-indicator-thickness, var(--spectrum-picker-focus-indicator-thickness)) + var(--mod-picker-border-width, var(--spectrum-picker-border-width))) * -1); + &:focus { + outline: none; + } - inset-inline: 0; - inset-block: 0; - border-style: solid; - border-width: var(--mod-picker-focus-indicator-thickness, var(--spectrum-picker-focus-indicator-thickness)); - border-color: transparent; - border-radius: calc(var(--mod-picker-border-radius, var(--spectrum-picker-border-radius)) + var(--mod-picker-focus-indicator-gap, var(--spectrum-picker-focus-indicator-gap)) + var(--mod-picker-border-width, var(--spectrum-picker-border-width))); + &:disabled, + &.is-disabled { + cursor: default; } &:hover { @@ -242,13 +256,14 @@ &:active { background-color: var(--highcontrast-picker-background-color, var(--mod-picker-background-color-active, var(--spectrum-picker-background-color-active))); border-color: var(--highcontrast-picker-border-color-default, var(--mod-picker-border-active, var(--spectrum-picker-border-color-active))); + transform: perspective(max(var(--spectrum-downstate-height), var(--spectrum-downstate-width) * var(--spectrum-component-size-width-ratio-down))) translateZ(var(--spectrum-component-size-difference-down)); /* Focus indicator */ &::after { border-color: transparent; } - &.is-placeholder .spectrum-Picker-label { + .spectrum-Picker-label.is-placeholder { color: var(--highcontrast-picker-content-color-default, var(--mod-picker-font-color-active, var(--spectrum-picker-font-color-active))); } } @@ -265,6 +280,27 @@ border-color: var(--highcontrast-picker-focus-indicator-color, var(--mod-picker-focus-indicator-color, var(--spectrum-picker-focus-indicator-color))); } + /* Focus indicator */ + &::after { + pointer-events: none; + content: ""; + position: absolute; + block-size: calc(100% + (var(--mod-picker-focus-indicator-gap, var(--spectrum-picker-focus-indicator-gap)) * 2) + (var(--mod-picker-border-width, var(--spectrum-picker-border-width)) * 2)); + + inline-size: calc(100% + (var(--mod-picker-focus-indicator-gap, var(--spectrum-picker-focus-indicator-gap)) * 2) + (var(--mod-picker-border-width, var(--spectrum-picker-border-width)) * 2)); + + margin-block-start: calc((var(--mod-picker-focus-indicator-gap, var(--spectrum-picker-focus-indicator-gap)) + var(--mod-picker-focus-indicator-thickness, var(--spectrum-picker-focus-indicator-thickness)) + var(--mod-picker-border-width, var(--spectrum-picker-border-width))) * -1); + + margin-inline-start: calc((var(--mod-picker-focus-indicator-gap, var(--spectrum-picker-focus-indicator-gap)) + var(--mod-picker-focus-indicator-thickness, var(--spectrum-picker-focus-indicator-thickness)) + var(--mod-picker-border-width, var(--spectrum-picker-border-width))) * -1); + + inset-inline: 0; + inset-block: 0; + border-style: solid; + border-width: var(--mod-picker-focus-indicator-thickness, var(--spectrum-picker-focus-indicator-thickness)); + border-color: transparent; + border-radius: calc(var(--mod-picker-border-radius, var(--spectrum-picker-border-radius)) + var(--mod-picker-focus-indicator-gap, var(--spectrum-picker-focus-indicator-gap)) + var(--mod-picker-border-width, var(--spectrum-picker-border-width))); + } + .spectrum-Picker-label.is-placeholder { color: var(--highcontrast-picker-content-color-default, var(--mod-picker-font-color-key-focus, var(--spectrum-picker-font-color-key-focus))); } @@ -274,7 +310,7 @@ } } - &.is-open:not(.spectrum-Picker--quiet, :disabled, .is-disabled) { + &.is-open:not(:disabled, .is-disabled, .is-loading) { color: var(--highcontrast-picker-content-color-default, var(--mod-picker-font-color-default-open, var(--spectrum-picker-font-color-default-open))); background-color: var(--highcontrast-picker-background-color, var(--mod-picker-background-color-default-open, var(--spectrum-picker-background-color-default-open))); border-color: var(--highcontrast-picker-border-color-default, var(--mod-picker-border-default-open, var(--spectrum-picker-border-color-default-open))); @@ -322,32 +358,17 @@ border-color: var(--highcontrast-picker-border-color-default, var(--mod-picker-border-color-error-key-focus, var(--spectrum-picker-border-color-error-key-focus))); } } +} - &.is-loading { - .spectrum-Picker-menuIcon { - color: var(--highcontrast-picker-content-color-disabled, var(--mod-picker-icon-color-disabled, var(--spectrum-picker-icon-color-disabled))); - } - } - - &.is-loading, - &.is-invalid { - .spectrum-Picker-label { - /* @deprecation --mod-picker-spacing-text-to-alert-icon-inline-start has been renamed to --mod-picker-spacing-text-to-icon-inline-end - and will be removed in a future version. */ - margin-inline-end: var(--mod-picker-spacing-text-to-icon-inline-end, var(--mod-picker-spacing-text-to-alert-icon-inline-start, var(--spectrum-picker-spacing-text-to-icon-inline-end))); - } - } - - .spectrum-Picker-icon { - flex-shrink: 0; - margin-inline-end: var(--mod-picker-spacing-text-to-icon, var(--spectrum-picker-spacing-text-to-icon)); - } +/* Optional workflow icon that appears before the text within the picker. */ +.spectrum-Picker .spectrum-Picker-icon { + flex-shrink: 0; + margin-inline-end: var(--mod-picker-spacing-starting-icon-to-text, var(--spectrum-picker-spacing-starting-icon-to-text)); } +/* Value: the text within the Picker (current value or placeholder) */ .spectrum-Picker-label { - /* Be the biggest, but also shrink! */ flex: 1 1 auto; - white-space: nowrap; overflow: hidden; @@ -358,14 +379,14 @@ text-overflow: ellipsis; text-align: start; - padding-block-start: var(--mod-picker-spacing-top-to-text, var(--spectrum-picker-spacing-top-to-text)); - padding-block-end: calc(var(--mod-picker-spacing-bottom-to-text, var(--spectrum-picker-spacing-bottom-to-text)) - var(--mod-picker-border-width, var(--spectrum-picker-border-width))); + margin-block-start: var(--mod-picker-spacing-top-to-text, var(--spectrum-picker-spacing-top-to-text)); + margin-block-end: calc(var(--mod-picker-spacing-bottom-to-text, var(--spectrum-picker-spacing-bottom-to-text)) - var(--mod-picker-border-width, var(--spectrum-picker-border-width))); + margin-inline-end: var(--mod-picker-spacing-text-to-icon-inline-end, var(--spectrum-picker-spacing-text-to-icon-inline-end)); &.is-placeholder { font-weight: var(--mod-picker-placeholder-font-weight, var(--spectrum-picker-font-weight)); font-style: var(--mod-picker-placeholder-font-style, var(--spectrum-picker-placeholder-font-style)); transition: color var(--mod-picker-animation-duration, var(--spectrum-picker-animation-duration)) ease-in-out; - color: var(--highcontrast-picker-content-color-default, var(--mod-picker-font-color-default, var(--spectrum-picker-font-color-default))); &:hover { @@ -376,19 +397,23 @@ color: var(--highcontrast-picker-content-color-default, var(--mod-picker-font-color-active, var(--spectrum-picker-font-color-active))); } } + + /* CJK (Chinese, Japanese, and Korean) language support */ + .spectrum-Picker:lang(ja) &, + .spectrum-Picker:lang(zh) &, + .spectrum-Picker:lang(ko) & { + line-height: var(--mod-picker-line-height-cjk, var(--spectrum-picker-line-height-cjk)); + } } -/* The picker chevron */ +/* Disclosure icon (chevron) */ .spectrum-Picker-menuIcon { display: inline-block; position: relative; vertical-align: top; - transition: color var(--mod-picker-animation-duration, var(--spectrum-picker-animation-duration)) ease-out; flex-shrink: 0; - - margin-inline-start: var(--mod-picker-spacing-icon-to-disclosure-icon, var(--spectrum-picker-spacing-icon-to-disclosure-icon)); margin-block: var(--mod-picker-spacing-top-to-disclosure-icon, var(--spectrum-picker-spacing-top-to-disclosure-icon)); - + transition: color var(--mod-picker-animation-duration, var(--spectrum-picker-animation-duration)) ease-out; color: var(--highcontrast-picker-content-color-default, var(--mod-picker-icon-color-default, var(--spectrum-picker-icon-color-default))); &:active { @@ -397,74 +422,17 @@ } .spectrum-Picker-validationIcon { - flex-shrink: 0; margin-block-start: calc(var(--mod-picker-spacing-top-to-alert-icon, var(--spectrum-picker-spacing-top-to-alert-icon)) - var(--mod-picker-border-width, var(--spectrum-picker-border-width))); margin-block-end: calc(var(--mod-picker-spacing-top-to-alert-icon, var(--spectrum-picker-spacing-top-to-alert-icon)) - var(--mod-picker-border-width, var(--spectrum-picker-border-width))); + margin-inline-end: var(--mod-picker-spacing-icon-to-disclosure-icon, var(--spectrum-picker-spacing-icon-to-disclosure-icon)); + flex-shrink: 0; } .spectrum-Picker .spectrum-ProgressCircle { margin-block-start: calc(var(--mod-picker-spacing-top-to-progress-circle, var(--spectrum-picker-spacing-top-to-progress-circle)) - var(--mod-picker-border-width, var(--spectrum-picker-border-width))); margin-block-end: calc(var(--mod-picker-spacing-top-to-progress-circle, var(--spectrum-picker-spacing-top-to-progress-circle)) - var(--mod-picker-border-width, var(--spectrum-picker-border-width))); -} - -.spectrum-Picker-label ~ .spectrum-Picker-menuIcon { - margin-inline-start: var(--mod-picker-spacing-text-to-icon, var(--spectrum-picker-spacing-text-to-icon)); -} - -.spectrum-Picker + .spectrum-Popover--bottom.is-open { - transform: translateY(var(--mod-picker-spacing-picker-to-popover, var(--spectrum-picker-spacing-picker-to-popover))); -} - -.spectrum-Picker--quiet { - inline-size: auto; - min-inline-size: 0; - border: none; - border-radius: 0; - padding-inline: var(--mod-picker-spacing-edge-to-text-quiet, var(--spectrum-picker-spacing-edge-to-text-quiet)); - margin-block-start: calc(var(--mod-picker-spacing-label-to-picker-quiet, var(--spectrum-picker-spacing-label-to-picker-quiet)) + (1px)); - color: var(--highcontrast-picker-content-color-default, var(--mod-picker-font-color-default, var(--spectrum-picker-font-color-default))); - background-color: var(--highcontrast-picker-background-color, transparent); - - &.spectrum-Picker--sideLabel { - margin-block-start: 0; - } - - .spectrum-Picker-menuIcon { - margin-inline-end: var(--mod-picker-spacing-edge-to-disclosure-icon-quiet, var(--spectrum-picker-spacing-edge-to-disclosure-icon-quiet)); - } - - &::after { - border: none; - block-size: auto; - inline-size: auto; - } - - &:hover { - background-color: var(--highcontrast-picker-background-color, transparent); - } - - &:focus-visible, - &.is-keyboardFocused { - background-color: var(--highcontrast-picker-background-color, transparent); - - /* Focus indicator changes from a ring to a line underneath. */ - &::after { - border: none; - border-radius: 0; - box-shadow: 0 var(--mod-picker-focus-indicator-thickness, var(--spectrum-picker-focus-indicator-thickness)) 0 0 var(--highcontrast-picker-focus-indicator-color, var(--mod-picker-focus-indicator-color, var(--spectrum-picker-focus-indicator-color))); - margin: calc((var(--mod-picker-focus-indicator-gap, var(--spectrum-picker-focus-indicator-gap)) + var(--mod-picker-border-width, var(--spectrum-picker-border-width))) * -1) 0; - } - } - - &:active, - &.is-open { - background-color: var(--highcontrast-picker-background-color, transparent); - } - - &.spectrum-Picker:disabled, - &.spectrum-Picker.is-disabled { - background-color: var(--highcontrast-picker-background-color, transparent); - } + margin-inline-end: var(--mod-picker-spacing-icon-to-disclosure-icon, var(--spectrum-picker-spacing-icon-to-disclosure-icon)); + flex-shrink: 0; } .spectrum-Picker--sideLabel { @@ -472,14 +440,14 @@ vertical-align: top; } -/* Disabled state: - Make sure this appears after any use of :hover while postcss-hover-media-feature is being used. The plugin moves - all hover styles within a media query that changes the order of the CSS, affecting styles with the same specificity. */ -.spectrum-Picker:disabled, -.spectrum-Picker.is-disabled { +/* Disabled and loading states: + Make sure this appears after any use of :hover while postcss-hover-media-feature is being used. The plugin moves + all hover styles within a media query that changes the order of the CSS, affecting styles with the same specificity. */ +.spectrum-Picker-button:disabled, +.spectrum-Picker-button.is-disabled { cursor: default; - background-color: var(--highcontrast-picker-background-color, var(--mod-picker-background-color-disabled, var(--spectrum-picker-background-color-disabled))); - border-color: var(--highcontrast-picker-border-color-disabled, var(--spectrum-picker-border-color-disabled)); + transform: none; + border-color: var(--highcontrast-picker-border-color-disabled, transparent); color: var(--highcontrast-picker-content-color-disabled, var(--mod-picker-font-color-disabled, var(--spectrum-picker-font-color-disabled))); .spectrum-Picker-icon, @@ -492,3 +460,42 @@ color: var(--highcontrast-picker-content-color-disabled, var(--mod-picker-font-color-disabled, var(--spectrum-picker-font-color-disabled))); } } + +.spectrum-Picker.is-loading { + transform: none; + + .spectrum-Picker-menuIcon { + color: var(--highcontrast-picker-content-color-disabled, var(--mod-picker-icon-color-disabled, var(--spectrum-picker-icon-color-disabled))); + } +} + +/* Forced colors / high contrast mode */ +@media (forced-colors: active) { + .spectrum-Picker { + --highcontrast-picker-focus-indicator-color: Highlight; + + --highcontrast-picker-border-color-default: ButtonBorder; + --highcontrast-picker-border-color-hover: Highlight; + --highcontrast-picker-border-color-disabled: GrayText; + + --highcontrast-picker-content-color-default: ButtonText; + --highcontrast-picker-content-color-disabled: GrayText; + --highcontrast-picker-background-color: ButtonFace; + + &:focus-visible, + &.is-keyboardFocused { + --highcontrast-picker-border-color-hover: ButtonText; + } + + /* Focus indicator */ + &::after { + /* Make sure default transparent border stays transparent. */ + forced-color-adjust: none; + } + + .spectrum-Picker-label { + /* Remove additional text backplate added in WHCM (Edge). */ + forced-color-adjust: none; + } + } +} diff --git a/components/picker/package.json b/components/picker/package.json index ef2ab02398d..d3c65950f6b 100644 --- a/components/picker/package.json +++ b/components/picker/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/picker", - "version": "9.2.0", + "version": "10.0.0-next.4", "description": "The Spectrum CSS picker component", "license": "Apache-2.0", "author": "Adobe", @@ -19,19 +19,17 @@ "./package.json": "./package.json", "./dist/*": "./dist/*", "./index.css": "./dist/index.css", - "./index-*.css": "./dist/index-*.css", "./metadata.json": "./dist/metadata.json", - "./themes/*": "./dist/themes/*", "./stories/*": "./stories/*" }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/helptext": ">=7.0.0 <8.0.0", - "@spectrum-css/icon": ">=9.0.0 <10.0.0", - "@spectrum-css/menu": ">=9.0.0 <10.0.0", - "@spectrum-css/popover": ">=8.0.0 <9.0.0", - "@spectrum-css/progresscircle": ">=5.0.0 <6.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/helptext": ">=8.0.0-next.0", + "@spectrum-css/icon": ">=10.0.0-next.0", + "@spectrum-css/menu": ">=10.0.0-next.0", + "@spectrum-css/popover": ">=9.0.0-next.0", + "@spectrum-css/progresscircle": ">=6.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/helptext": { @@ -54,13 +52,12 @@ } }, "devDependencies": { - "@spectrum-css/commons": "11.1.0", - "@spectrum-css/helptext": "7.2.0", - "@spectrum-css/icon": "9.2.0", - "@spectrum-css/menu": "9.3.0", - "@spectrum-css/popover": "8.3.0", - "@spectrum-css/progresscircle": "5.2.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/helptext": "8.0.0-next.2", + "@spectrum-css/icon": "10.0.0-next.3", + "@spectrum-css/menu": "10.0.0-next.6", + "@spectrum-css/popover": "9.0.0-next.5", + "@spectrum-css/progresscircle": "6.0.0-next.0", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/picker/stories/picker.stories.js b/components/picker/stories/picker.stories.js index c2fa56e619d..9a1cbfb2bfd 100644 --- a/components/picker/stories/picker.stories.js +++ b/components/picker/stories/picker.stories.js @@ -1,7 +1,8 @@ +import { default as IconStories } from "@spectrum-css/icon/stories/icon.stories.js"; import { WithDividers as MenuStories } from "@spectrum-css/menu/stories/menu.stories.js"; -import { Sizes } from "@spectrum-css/preview/decorators"; +import { Sizes, withDownStateDimensionCapture } from "@spectrum-css/preview/decorators"; import { disableDefaultModes } from "@spectrum-css/preview/modes"; -import { isActive, isDisabled, isHovered, isInvalid, isKeyboardFocused, isLoading, isOpen, isQuiet, size } from "@spectrum-css/preview/types"; +import { isActive, isDisabled, isHovered, isInvalid, isKeyboardFocused, isLoading, isOpen, size } from "@spectrum-css/preview/types"; import metadata from "../dist/metadata.json"; import packageJson from "../package.json"; import { PickerGroup } from "./picker.test.js"; @@ -17,7 +18,7 @@ export default { size: size(["s", "m", "l", "xl"]), label: { name: "Label", - description: "The text for the field label", + description: "The label text that is displayed above or to the side of the Picker. This uses a separate Label component outside of the Picker markup.", type: { name: "string" }, table: { type: { summary: "string" }, @@ -32,16 +33,21 @@ export default { type: { summary: "string" }, category: "Component", }, + control: { + type: "select", + labels: { + side: "side (inline start)", + }, + }, options: ["top", "side"], - control: { type: "select" }, }, withSwitch: { - name: "Show switch component", - description: "Display a separate switch component after the picker. Helpful for testing alignment with the picker when using the side label.", + name: "Display Switch component", + description: "Displays a Switch component after the Picker. This is used for testing the vertical alignment between the side label, Picker, and Switch.", type: { name: "boolean" }, table: { type: { summary: "boolean" }, - category: "Advanced", + category: "Content", }, control: "boolean", if: { arg: "labelPosition", eq: "side" }, @@ -54,11 +60,10 @@ export default { type: { summary: "boolean" }, category: "Advanced", }, - control: "boolean", }, placeholder: { - name: "Placeholder", - description: "The placeholder text prompts a user to select an option from the picker menu. It disappears once a user selects an option. This will not be displayed if the `value` control is set.", + name: "Value or placeholder", + description: "The text within the Picker that represents its current value or placeholder.", type: { name: "string" }, table: { type: { summary: "string" }, @@ -66,15 +71,16 @@ export default { }, control: { type: "text" }, }, - currentValue: { - name: "Value", - description: "The value shows the option that a user has selected.", - type: { name: "string" }, + currentValue: { table: { disable: true } }, + contentIconName: { + ...(IconStories?.argTypes?.iconName ?? {}), + name: "Icon", + description: "Optional workflow icon that appears before the value/placeholder text within the picker.", + if: { arg: "showWorkflowIcon", eq: true }, table: { - type: { summary: "string" }, - category: "Content", + type: { summary: "boolean" }, + category: "Advanced", }, - control: { type: "text" }, }, helpText: { name: "Help text", @@ -86,12 +92,18 @@ export default { }, control: { type: "text" }, }, - isQuiet, isOpen, isKeyboardFocused, isDisabled, - isLoading, - isInvalid, + isLoading: { + ...isLoading, + description: "When in the loading state, a progress circle will display next to the disclosure icon.", + if: { arg: "isDisabled", eq: false } + }, + isInvalid: { + ...isInvalid, + description: "When in the invalid state, some styles change on the Picker, and an invalid icon displays next to the disclosure icon.", + }, isHovered, isActive, popoverContent: { table: { disable: true } }, @@ -104,8 +116,8 @@ export default { placeholder: "Select a country", helpText: "", currentValue: "", + contentIconName: "Image", showWorkflowIcon: false, - isQuiet: false, isKeyboardFocused: false, isLoading: false, isDisabled: false, @@ -128,30 +140,28 @@ export default { ], }, parameters: { - docs: { - story: { - height: "400px" - } - }, design: { type: "figma", url: "https://www.figma.com/design/Mngz9H7WZLbrCvGQf3GnsY/S2-%2F-Desktop?node-id=739-1453", }, packageJson, metadata, + downState: { + selectors: [".spectrum-Picker:not(:disabled, .is-disabled, .is-loading)"], + }, + status: { + type: "migrated", + }, }, + decorators: [ + withDownStateDimensionCapture, + ], + tags: ["migrated"], }; export const Default = PickerGroup.bind({}); Default.args = {}; Default.tags = ["!autodocs"]; -Default.parameters = { - docs: { - story: { - height: "300px", - } - }, -}; // ********* VRT ONLY ********* // export const WithForcedColors = PickerGroup.bind({}); @@ -176,11 +186,6 @@ Standard.storyName = "Default"; Standard.tags = ["!dev"]; Standard.parameters = { chromatic: { disableSnapshot: true }, - docs: { - story: { - height: "300px", - } - }, }; /** @@ -209,11 +214,6 @@ SelectedValue.args = { SelectedValue.tags = ["!dev"]; SelectedValue.parameters = { chromatic: { disableSnapshot: true }, - docs: { - story: { - height: "300px", - } - }, }; /** @@ -266,11 +266,6 @@ Invalid.args = { }; Invalid.parameters = { chromatic: { disableSnapshot: true }, - docs: { - story: { - height: "300px", - } - }, }; export const Loading = Template.bind({}); @@ -285,52 +280,6 @@ Loading.parameters = { chromatic: { disableSnapshot: true }, }; -/** - * Quiet pickers have no visible background. This style works best when a clear layout (vertical stack, table, grid) - * makes it easy to parse the buttons. Too many quiet components in a small space can be hard to read. - */ -export const Quiet = ClosedAndOpenTemplate.bind({}); -Quiet.tags = ["!dev"]; -Quiet.args = { - isQuiet: true, -}; -Quiet.parameters = { - chromatic: { disableSnapshot: true }, - docs: { - story: { - height: "300px", - } - }, -}; - -export const QuietDisabled = DisabledTemplate.bind({}); -QuietDisabled.storyName = "Quiet and disabled"; -QuietDisabled.tags = ["!dev"]; -QuietDisabled.args = { - isDisabled: true, - isQuiet: true, -}; -QuietDisabled.parameters = { - chromatic: { disableSnapshot: true }, -}; - -export const QuietInvalid = ClosedAndOpenTemplate.bind({}); -QuietInvalid.storyName = "Quiet and invalid"; -QuietInvalid.tags = ["!dev"]; -QuietInvalid.args = { - isInvalid: true, - isQuiet: true, - helpText: "Select a country.", -}; -QuietInvalid.parameters = { - chromatic: { disableSnapshot: true }, - docs: { - story: { - height: "300px", - } - }, -}; - /** * The value and placeholder within the picker will truncate with an ellipsis when it is longer than the available horizontal space within the picker. * The full text of the option can be shown in the menu. diff --git a/components/picker/stories/picker.test.js b/components/picker/stories/picker.test.js index 82f7e060075..0df9b4b6c86 100644 --- a/components/picker/stories/picker.test.js +++ b/components/picker/stories/picker.test.js @@ -16,10 +16,6 @@ export const PickerGroup = Variants({ testHeading: "Default, with value and text overflow", currentValue: "The selected value of the picker, with long text the triggers the overflow behavior with ellipsis", }, - { - testHeading: "Quiet", - isQuiet: true, - }, { testHeading: "Side label", labelPosition: "side", @@ -32,6 +28,7 @@ export const PickerGroup = Variants({ { testHeading: "With thumbnail icon", showWorkflowIcon: true, + contentIconName: "Image", }, ], stateData: [ diff --git a/components/picker/stories/template.js b/components/picker/stories/template.js index 5bce15f0744..3e3025029f7 100644 --- a/components/picker/stories/template.js +++ b/components/picker/stories/template.js @@ -1,30 +1,27 @@ import { Template as FieldLabel } from "@spectrum-css/fieldlabel/stories/template.js"; import { Template as HelpText } from "@spectrum-css/helptext/stories/template.js"; import { Template as Icon } from "@spectrum-css/icon/stories/template.js"; +import { Template as InfieldProgressCircle } from "@spectrum-css/infieldprogresscircle/stories/template.js"; import { Template as Popover } from "@spectrum-css/popover/stories/template.js"; import { Container, getRandomId } from "@spectrum-css/preview/decorators"; -import { Template as ProgressCircle } from "@spectrum-css/progresscircle/stories/template.js"; import { Template as Switch } from "@spectrum-css/switch/stories/template.js"; import { html } from "lit"; import { classMap } from "lit/directives/class-map.js"; +import { ifDefined } from "lit/directives/if-defined.js"; import { styleMap } from "lit/directives/style-map.js"; import { when } from "lit/directives/when.js"; import "../index.css"; -import "../themes/spectrum.css"; -/* Must be imported last */ -import "../themes/express.css"; /** - * Template for Picker only (no popover or help text). + * Template for just the Picker. Does not include sibling Label and Help text. */ export const Picker = ({ rootClass = "spectrum-Picker", size = "m", - labelPosition, - placeholder = "", - currentValue = "", - isQuiet = false, + placeholder, + currentValue, + contentIconName, isKeyboardFocused = false, showWorkflowIcon = false, isOpen = false, @@ -33,18 +30,16 @@ export const Picker = ({ isDisabled = false, isHovered = false, isActive = false, + ariaLabeledBy, customClasses = [], customStyles = {}, - onclick, } = {}, context = {}) => { + const { updateArgs } = context; + return html`
+ ${when(helpText, () => + HelpText({ + size, + text: helpText, + hideIcon: true, + customClasses: [`${rootClass}-helptext`], + }, context))}
`; }; diff --git a/components/progressbar/themes/express.css b/components/progressbar/themes/express.css deleted file mode 100644 index 9fd550418f2..00000000000 --- a/components/progressbar/themes/express.css +++ /dev/null @@ -1,16 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--express */ - -@import "./spectrum.css"; diff --git a/components/progressbar/themes/spectrum-two.css b/components/progressbar/themes/spectrum-two.css deleted file mode 100644 index 3b705ef64c4..00000000000 --- a/components/progressbar/themes/spectrum-two.css +++ /dev/null @@ -1,19 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -@container style(--system: spectrum) { - .spectrum-ProgressBar { - --spectrum-progressbar-track-color: var(--spectrum-gray-200); - --spectrum-progressbar-track-color-white: var(--spectrum-transparent-white-400); - } -} diff --git a/components/progressbar/themes/spectrum.css b/components/progressbar/themes/spectrum.css deleted file mode 100644 index 3760cc4cfc4..00000000000 --- a/components/progressbar/themes/spectrum.css +++ /dev/null @@ -1,23 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--legacy */ - -@import "./spectrum-two.css"; - -@container style(--system: legacy) { - .spectrum-ProgressBar { - --spectrum-progressbar-track-color: var(--spectrum-gray-300); - --spectrum-progressbar-track-color-white: var(--spectrum-transparent-white-300); - } -} diff --git a/components/progresscircle/CHANGELOG.md b/components/progresscircle/CHANGELOG.md index acb75549329..309e1daf2c7 100644 --- a/components/progresscircle/CHANGELOG.md +++ b/components/progresscircle/CHANGELOG.md @@ -1,5 +1,12 @@ # Change log +## 6.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + ## 5.2.0 ### Minor Changes diff --git a/components/progresscircle/animation.css b/components/progresscircle/animation.css index 176d4da4c17..433f642948b 100644 --- a/components/progresscircle/animation.css +++ b/components/progresscircle/animation.css @@ -11,500 +11,23 @@ * governing permissions and limitations under the License. */ -.spectrum-ProgressCircle--indeterminate-fill-submask-2 { - animation: 1s infinite linear spectrum-fill-mask-2; -} - -@keyframes spectrum-fill-mask-1 { +@keyframes spectrum-fills-rotate { 0% { - transform: rotate(90deg); - } - - 1.69% { - transform: rotate(72.3deg); - } - - 3.39% { - transform: rotate(55.5deg); - } - - 5.08% { - transform: rotate(40.3deg); - } - - 6.78% { - transform: rotate(25deg); - } - - 8.47% { - transform: rotate(10.6deg); - } - - 10.17% { - transform: rotate(0deg); - } - - 11.86% { - transform: rotate(0deg); - } - - 13.56% { - transform: rotate(0deg); - } - - 15.25% { - transform: rotate(0deg); - } - - 16.95% { - transform: rotate(0deg); - } - - 18.64% { - transform: rotate(0deg); - } - - 20.34% { - transform: rotate(0deg); - } - - 22.03% { - transform: rotate(0deg); - } - - 23.73% { - transform: rotate(0deg); - } - - 25.42% { - transform: rotate(0deg); - } - - 27.12% { - transform: rotate(0deg); - } - - 28.81% { - transform: rotate(0deg); - } - - 30.51% { - transform: rotate(0deg); - } - - 32.2% { - transform: rotate(0deg); - } - - 33.9% { - transform: rotate(0deg); - } - - 35.59% { - transform: rotate(0deg); - } - - 37.29% { - transform: rotate(0deg); - } - - 38.98% { - transform: rotate(0deg); - } - - 40.68% { - transform: rotate(0deg); - } - - 42.37% { - transform: rotate(5.3deg); - } - - 44.07% { - transform: rotate(13.4deg); - } - - 45.76% { - transform: rotate(20.6deg); - } - - 47.46% { - transform: rotate(29deg); - } - - 49.15% { - transform: rotate(36.5deg); - } - - 50.85% { - transform: rotate(42.6deg); - } - - 52.54% { - transform: rotate(48.8deg); - } - - 54.24% { - transform: rotate(54.2deg); - } - - 55.93% { - transform: rotate(59.4deg); - } - - 57.63% { - transform: rotate(63.2deg); - } - - 59.32% { - transform: rotate(67.2deg); - } - - 61.02% { - transform: rotate(70.8deg); - } - - 62.71% { - transform: rotate(73.8deg); - } - - 64.41% { - transform: rotate(76.2deg); - } - - 66.1% { - transform: rotate(78.7deg); - } - - 67.8% { - transform: rotate(80.6deg); - } - - 69.49% { - transform: rotate(82.6deg); - } - - 71.19% { - transform: rotate(83.7deg); - } - - 72.88% { - transform: rotate(85deg); - } - - 74.58% { - transform: rotate(86.3deg); - } - - 76.27% { - transform: rotate(87deg); - } - - 77.97% { - transform: rotate(87.7deg); - } - - 79.66% { - transform: rotate(88.3deg); - } - - 81.36% { - transform: rotate(88.6deg); - } - - 83.05% { - transform: rotate(89.2deg); - } - - 84.75% { - transform: rotate(89.2deg); - } - - 86.44% { - transform: rotate(89.5deg); - } - - 88.14% { - transform: rotate(89.9deg); - } - - 89.83% { - transform: rotate(89.7deg); - } - - 91.53% { - transform: rotate(90.1deg); - } - - 93.22% { - transform: rotate(90.2deg); - } - - 94.92% { - transform: rotate(90.1deg); - } - - 96.61% { - transform: rotate(90deg); - } - - 98.31% { - transform: rotate(89.8deg); + transform: rotate(-90deg); } 100% { - transform: rotate(90deg); + transform: rotate(270deg); } } -@keyframes spectrum-fill-mask-2 { - 0% { - transform: rotate(180deg); - } - - 1.69% { - transform: rotate(180deg); - } - - 3.39% { - transform: rotate(180deg); - } - - 5.08% { - transform: rotate(180deg); - } - - 6.78% { - transform: rotate(180deg); - } - - 8.47% { - transform: rotate(180deg); - } - - 10.17% { - transform: rotate(179.2deg); - } - - 11.86% { - transform: rotate(164deg); - } - - 13.56% { - transform: rotate(151.8deg); - } - - 15.25% { - transform: rotate(140.8deg); - } - - 16.95% { - transform: rotate(130.3deg); - } - - 18.64% { - transform: rotate(120.4deg); - } - - 20.34% { - transform: rotate(110.8deg); - } - - 22.03% { - transform: rotate(101.6deg); - } - - 23.73% { - transform: rotate(93.5deg); - } - - 25.42% { - transform: rotate(85.4deg); - } - - 27.12% { - transform: rotate(78.1deg); - } - - 28.81% { - transform: rotate(71.2deg); - } - - 30.51% { - transform: rotate(89.1deg); - } - - 32.2% { - transform: rotate(105.5deg); - } - - 33.9% { - transform: rotate(121.3deg); - } - - 35.59% { - transform: rotate(135.5deg); - } - - 37.29% { - transform: rotate(148.4deg); - } - - 38.98% { - transform: rotate(161deg); - } - - 40.68% { - transform: rotate(173.5deg); - } - - 42.37% { - transform: rotate(180deg); - } - - 44.07% { - transform: rotate(180deg); - } - - 45.76% { - transform: rotate(180deg); - } - - 47.46% { - transform: rotate(180deg); - } - - 49.15% { - transform: rotate(180deg); - } - - 50.85% { - transform: rotate(180deg); - } - - 52.54% { - transform: rotate(180deg); - } - - 54.24% { - transform: rotate(180deg); - } - - 55.93% { - transform: rotate(180deg); - } - - 57.63% { - transform: rotate(180deg); - } - - 59.32% { - transform: rotate(180deg); - } - - 61.02% { - transform: rotate(180deg); - } - - 62.71% { - transform: rotate(180deg); - } - - 64.41% { - transform: rotate(180deg); - } - - 66.1% { - transform: rotate(180deg); - } - - 67.8% { - transform: rotate(180deg); - } - - 69.49% { - transform: rotate(180deg); - } - - 71.19% { - transform: rotate(180deg); - } - - 72.88% { - transform: rotate(180deg); - } - - 74.58% { - transform: rotate(180deg); - } - - 76.27% { - transform: rotate(180deg); - } - - 77.97% { - transform: rotate(180deg); - } - - 79.66% { - transform: rotate(180deg); - } - - 81.36% { - transform: rotate(180deg); - } - - 83.05% { - transform: rotate(180deg); - } - - 84.75% { - transform: rotate(180deg); - } - - 86.44% { - transform: rotate(180deg); - } - - 88.14% { - transform: rotate(180deg); - } - - 89.83% { - transform: rotate(180deg); - } - - 91.53% { - transform: rotate(180deg); - } - - 93.22% { - transform: rotate(180deg); - } - - 94.92% { - transform: rotate(180deg); - } - - 96.61% { - transform: rotate(180deg); - } - - 98.31% { - transform: rotate(180deg); - } - +@keyframes spectrum-dashoffset-animation { + 0%, 100% { - transform: rotate(180deg); + stroke-dashoffset: 75px; } -} -@keyframes spectrum-fills-rotate { - 0% { - transform: rotate(-90deg); - } - - 100% { - transform: rotate(270deg); + 30% { + stroke-dashoffset: 20px; } } diff --git a/components/progresscircle/dist/metadata.json b/components/progresscircle/dist/metadata.json index 82493f14621..a252d2638db 100644 --- a/components/progresscircle/dist/metadata.json +++ b/components/progresscircle/dist/metadata.json @@ -2,96 +2,25 @@ "sourceFile": "index.css", "selectors": [ ".spectrum-ProgressCircle", - ".spectrum-ProgressCircle--indeterminate .spectrum-ProgressCircle-fillSubMask1", - ".spectrum-ProgressCircle--indeterminate .spectrum-ProgressCircle-fillSubMask2", - ".spectrum-ProgressCircle--indeterminate .spectrum-ProgressCircle-fills", - ".spectrum-ProgressCircle--indeterminate-fill-submask-2", + ".spectrum-ProgressCircle--indeterminate .spectrum-ProgressCircle-fill", + ".spectrum-ProgressCircle--sizeL", + ".spectrum-ProgressCircle--sizeS", ".spectrum-ProgressCircle-fill", - ".spectrum-ProgressCircle-fillMask1", - ".spectrum-ProgressCircle-fillMask2", - ".spectrum-ProgressCircle-fillSubMask1", - ".spectrum-ProgressCircle-fillSubMask2", - ".spectrum-ProgressCircle-fills", ".spectrum-ProgressCircle-track", - ".spectrum-ProgressCircle.spectrum-ProgressCircle--large", - ".spectrum-ProgressCircle.spectrum-ProgressCircle--medium", - ".spectrum-ProgressCircle.spectrum-ProgressCircle--small", - ".spectrum-ProgressCircle.spectrum-ProgressCircle--staticWhite .spectrum-ProgressCircle-fill", - ".spectrum-ProgressCircle.spectrum-ProgressCircle--staticWhite .spectrum-ProgressCircle-track", - "0%", - "1.69%", - "10.17%", - "11.86%", - "13.56%", - "15.25%", - "16.95%", - "18.64%", - "20.34%", - "22.03%", - "23.73%", - "25.42%", - "27.12%", - "28.81%", - "3.39%", - "30.51%", - "32.2%", - "33.9%", - "35.59%", - "37.29%", - "38.98%", - "40.68%", - "42.37%", - "44.07%", - "45.76%", - "47.46%", - "49.15%", - "5.08%", - "50.85%", - "52.54%", - "54.24%", - "55.93%", - "57.63%", - "59.32%", - "6.78%", - "61.02%", - "62.71%", - "64.41%", - "66.1%", - "67.8%", - "69.49%", - "71.19%", - "72.88%", - "74.58%", - "76.27%", - "77.97%", - "79.66%", - "8.47%", - "81.36%", - "83.05%", - "84.75%", - "86.44%", - "88.14%", - "89.83%", - "91.53%", - "93.22%", - "94.92%", - "96.61%", - "98.31%", - "to" + ".spectrum-ProgressCircle.spectrum-ProgressCircle--staticBlack", + ".spectrum-ProgressCircle.spectrum-ProgressCircle--staticWhite", + ".spectrum-ProgressCircle:not(.spectrum-ProgressCircle--indeterminate) .spectrum-innerCircle", + ".spectrum-ProgressCircle:not(.spectrum-ProgressCircle--indeterminate) .spectrum-outerCircle" ], "modifiers": [ "--mod-progress-circle-fill-border-color", - "--mod-progress-circle-fill-border-color-over-background", "--mod-progress-circle-position", "--mod-progress-circle-size", "--mod-progress-circle-thickness", - "--mod-progress-circle-track-border-color", - "--mod-progress-circle-track-border-color-over-background", - "--mod-progress-circle-track-border-style" + "--mod-progress-circle-track-border-color" ], "component": [ "--spectrum-progress-circle-fill-border-color", - "--spectrum-progress-circle-fill-border-color-over-background", "--spectrum-progress-circle-size", "--spectrum-progress-circle-size-large", "--spectrum-progress-circle-size-medium", @@ -100,27 +29,19 @@ "--spectrum-progress-circle-thickness-large", "--spectrum-progress-circle-thickness-medium", "--spectrum-progress-circle-thickness-small", - "--spectrum-progress-circle-track-border-color", - "--spectrum-progress-circle-track-border-color-over-background", - "--spectrum-progress-circle-track-border-style" + "--spectrum-progress-circle-track-border-color" ], "global": [ "--spectrum-accent-content-color-default", - "--spectrum-gray-200", - "--spectrum-gray-300", - "--spectrum-transparent-white-1000", - "--spectrum-transparent-white-300", - "--spectrum-transparent-white-400", - "--spectrum-transparent-white-900" - ], - "system-theme": [ - "--system-progress-circle-fill-border-color-over-background", - "--system-progress-circle-track-border-color", - "--system-progress-circle-track-border-color-over-background" + "--spectrum-static-black-track-color", + "--spectrum-static-black-track-indicator-color", + "--spectrum-static-white-track-color", + "--spectrum-static-white-track-indicator-color", + "--spectrum-track-color" ], "passthroughs": [], "high-contrast": [ "--highcontrast-progress-circle-fill-border-color", - "--highcontrast-progress-circle-fill-border-color-over-background" + "--highcontrast-progress-circle-track-color" ] } diff --git a/components/progresscircle/index.css b/components/progresscircle/index.css index 019cbb78bbd..d2adf1c18dd 100644 --- a/components/progresscircle/index.css +++ b/components/progresscircle/index.css @@ -1,66 +1,40 @@ /*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ +Copyright 2024 Adobe. All rights reserved. +This file is licensed to you under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. You may obtain a copy +of the License at http://www.apache.org/licenses/LICENSE-2.0 -@import "./themes/spectrum-two.css"; +Unless required by applicable law or agreed to in writing, software distributed under +the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS +OF ANY KIND, either express or implied. See the License for the specific language +governing permissions and limitations under the License. +*/ -/* windows high contrast mode */ -@media (forced-colors: active) { - .spectrum-ProgressCircle { - /* fill is bright color */ - --highcontrast-progress-circle-fill-border-color: Highlight; - - /* fill over background is bright color */ - --highcontrast-progress-circle-fill-border-color-over-background: Highlight; - } - - /* track double for visibility */ - .spectrum-ProgressCircle-track { - --spectrum-progress-circle-track-border-style: double; - } -} +@import "animation.css"; .spectrum-ProgressCircle { /* circle unfilled border color */ - --spectrum-progress-circle-track-border-color: var(--spectrum-gray-300); + --spectrum-progress-circle-track-border-color: var(--spectrum-track-color); /* circle progress fill border color */ --spectrum-progress-circle-fill-border-color: var(--spectrum-accent-content-color-default); - /* over background unfilled border color */ - --spectrum-progress-circle-track-border-color-over-background: var(--spectrum-transparent-white-300); - - /* over background progress fill border color */ - --spectrum-progress-circle-fill-border-color-over-background: var(--spectrum-transparent-white-900); - - /* track border style */ - --spectrum-progress-circle-track-border-style: solid; - - &.spectrum-ProgressCircle--small { - --spectrum-progress-circle-size: var(--spectrum-progress-circle-size-small); - --spectrum-progress-circle-thickness: var(--spectrum-progress-circle-thickness-small); - } + /* default size and thickness */ + --spectrum-progress-circle-size: var(--spectrum-progress-circle-size-medium); + --spectrum-progress-circle-thickness: var(--spectrum-progress-circle-thickness-medium); +} - &, - &.spectrum-ProgressCircle--medium { - --spectrum-progress-circle-size: var(--spectrum-progress-circle-size-medium); - --spectrum-progress-circle-thickness: var(--spectrum-progress-circle-thickness-medium); - } +.spectrum-ProgressCircle--sizeS { + --spectrum-progress-circle-size: var(--spectrum-progress-circle-size-small); + --spectrum-progress-circle-thickness: var(--spectrum-progress-circle-thickness-small); +} - &.spectrum-ProgressCircle--large { - --spectrum-progress-circle-size: var(--spectrum-progress-circle-size-large); - --spectrum-progress-circle-thickness: var(--spectrum-progress-circle-thickness-large); - } +.spectrum-ProgressCircle--sizeL { + --spectrum-progress-circle-size: var(--spectrum-progress-circle-size-large); + --spectrum-progress-circle-thickness: var(--spectrum-progress-circle-thickness-large); +} +.spectrum-ProgressCircle { display: inline-block; inline-size: var(--mod-progress-circle-size, var(--spectrum-progress-circle-size)); block-size: var(--mod-progress-circle-size, var(--spectrum-progress-circle-size)); @@ -70,591 +44,66 @@ /* Fix for Safari rendering bug */ /* more info: https://github.com/adobe/spectrum-web-components/issues/1392 */ transform: translate3d(0, 0, 0); -} - -.spectrum-ProgressCircle-track { - box-sizing: border-box; - inline-size: var(--mod-progress-circle-size, var(--spectrum-progress-circle-size)); - block-size: var(--mod-progress-circle-size, var(--spectrum-progress-circle-size)); - border-style: var(--mod-progress-circle-track-border-style, var(--spectrum-progress-circle-track-border-style)); - border-width: var(--mod-progress-circle-thickness, var(--spectrum-progress-circle-thickness)); - border-radius: var(--mod-progress-circle-size, var(--spectrum-progress-circle-size)); - border-color: var(--mod-progress-circle-track-border-color, var(--spectrum-progress-circle-track-border-color)); -} + &.spectrum-ProgressCircle--staticWhite { + --spectrum-progress-circle-track-border-color: var(--spectrum-static-white-track-color); + --spectrum-progress-circle-fill-border-color: var(--spectrum-static-white-track-indicator-color); + } -/* circle progress fill parent container */ -.spectrum-ProgressCircle-fills { - position: absolute; - inset-block-start: 0; - inset-inline-start: 0; - inline-size: 100%; - block-size: 100%; + &.spectrum-ProgressCircle--staticBlack { + --spectrum-progress-circle-track-border-color: var(--spectrum-static-black-track-color); + --spectrum-progress-circle-fill-border-color: var(--spectrum-static-black-track-indicator-color); + } } -/* circle progress filled */ +.spectrum-ProgressCircle-track, .spectrum-ProgressCircle-fill { box-sizing: border-box; inline-size: var(--mod-progress-circle-size, var(--spectrum-progress-circle-size)); block-size: var(--mod-progress-circle-size, var(--spectrum-progress-circle-size)); - - border-style: solid; - border-width: var(--mod-progress-circle-thickness, var(--spectrum-progress-circle-thickness)); - border-radius: var(--mod-progress-circle-size, var(--spectrum-progress-circle-size)); - border-color: var(--highcontrast-progress-circle-fill-border-color, var(--mod-progress-circle-fill-border-color, var(--spectrum-progress-circle-fill-border-color))); } -/* circle colors over background */ -.spectrum-ProgressCircle.spectrum-ProgressCircle--staticWhite { - .spectrum-ProgressCircle-track { - border-color: var(--mod-progress-circle-track-border-color-over-background, var(--spectrum-progress-circle-track-border-color-over-background)); - } - - .spectrum-ProgressCircle-fill { - border-color: var(--highcontrast-progress-circle-fill-border-color-over-background, var(--mod-progress-circle-fill-border-color-over-background, var(--spectrum-progress-circle-fill-border-color-over-background))); - } -} - -/* animation masks - circle fill progress */ -.spectrum-ProgressCircle-fillMask1, -.spectrum-ProgressCircle-fillMask2 { - inline-size: 50%; - block-size: 100%; - transform-origin: 100% center; - transform: rotate(180deg); - overflow: hidden; - position: absolute; -} - -.spectrum-ProgressCircle-fillSubMask1, -.spectrum-ProgressCircle-fillSubMask2 { - inline-size: 100%; - block-size: 100%; - transform-origin: 100% center; - overflow: hidden; - transform: rotate(-180deg); +.spectrum-ProgressCircle-track { + stroke-width: var(--mod-progress-circle-thickness, var(--spectrum-progress-circle-thickness)); + stroke: var(--highcontrast-progress-circle-track-color, var(--mod-progress-circle-track-border-color, var(--spectrum-progress-circle-track-border-color))); } -.spectrum-ProgressCircle-fillMask2 { - transform: rotate(0deg); +/* circle progress filled */ +.spectrum-ProgressCircle-fill { + stroke-width: var(--mod-progress-circle-thickness, var(--spectrum-progress-circle-thickness)); + stroke: var(--highcontrast-progress-circle-fill-border-color, var(--mod-progress-circle-fill-border-color, var(--spectrum-progress-circle-fill-border-color))); + transform: rotate(-90deg); + transform-origin: center; } /* animation masks - circle indeterminate with continuous animation */ .spectrum-ProgressCircle--indeterminate { - .spectrum-ProgressCircle-fills { + .spectrum-ProgressCircle-fill { will-change: transform; - transform: translateZ(0); - animation: 1s infinite cubic-bezier(0.25, 0.78, 0.48, 0.89) spectrum-fills-rotate; + animation: + 1s cubic-bezier(0.6, 0.1, 0.3, 0.9) infinite spectrum-fills-rotate, + 1s cubic-bezier(0.25, 0.1, 0.25, 1.3) infinite spectrum-dashoffset-animation; transform-origin: center; } - - .spectrum-ProgressCircle-fillSubMask1 { - will-change: transform; - transform: translateZ(0); - animation: 1s infinite linear spectrum-fill-mask-1; - } - - .spectrum-ProgressCircle-fillSubMask2 { - will-change: transform; - transform: translateZ(0); - animation: 1s infinite linear spectrum-fill-mask-2; - } -} - -.spectrum-ProgressCircle--indeterminate-fill-submask-2 { - animation: 1s infinite linear spectrum-fill-mask-2; } -@keyframes spectrum-fill-mask-1 { - 0% { - transform: rotate(90deg); - } - - 1.69% { - transform: rotate(72.3deg); - } - - 3.39% { - transform: rotate(55.5deg); - } - - 5.08% { - transform: rotate(40.3deg); - } - - 6.78% { - transform: rotate(25deg); - } - - 8.47% { - transform: rotate(10.6deg); - } - - 10.17% { - transform: rotate(0deg); - } - - 11.86% { - transform: rotate(0deg); - } - - 13.56% { - transform: rotate(0deg); - } - - 15.25% { - transform: rotate(0deg); - } - - 16.95% { - transform: rotate(0deg); - } - - 18.64% { - transform: rotate(0deg); - } - - 20.34% { - transform: rotate(0deg); - } - - 22.03% { - transform: rotate(0deg); - } - - 23.73% { - transform: rotate(0deg); - } - - 25.42% { - transform: rotate(0deg); - } - - 27.12% { - transform: rotate(0deg); - } - - 28.81% { - transform: rotate(0deg); - } - - 30.51% { - transform: rotate(0deg); - } - - 32.2% { - transform: rotate(0deg); - } - - 33.9% { - transform: rotate(0deg); - } - - 35.59% { - transform: rotate(0deg); - } - - 37.29% { - transform: rotate(0deg); - } - - 38.98% { - transform: rotate(0deg); - } - - 40.68% { - transform: rotate(0deg); - } - - 42.37% { - transform: rotate(5.3deg); - } - - 44.07% { - transform: rotate(13.4deg); - } - - 45.76% { - transform: rotate(20.6deg); - } - - 47.46% { - transform: rotate(29deg); - } - - 49.15% { - transform: rotate(36.5deg); - } - - 50.85% { - transform: rotate(42.6deg); - } - - 52.54% { - transform: rotate(48.8deg); - } - - 54.24% { - transform: rotate(54.2deg); - } - - 55.93% { - transform: rotate(59.4deg); - } - - 57.63% { - transform: rotate(63.2deg); - } - - 59.32% { - transform: rotate(67.2deg); - } - - 61.02% { - transform: rotate(70.8deg); - } - - 62.71% { - transform: rotate(73.8deg); - } - - 64.41% { - transform: rotate(76.2deg); - } - - 66.1% { - transform: rotate(78.7deg); - } - - 67.8% { - transform: rotate(80.6deg); - } - - 69.49% { - transform: rotate(82.6deg); - } - - 71.19% { - transform: rotate(83.7deg); - } - - 72.88% { - transform: rotate(85deg); - } - - 74.58% { - transform: rotate(86.3deg); - } - - 76.27% { - transform: rotate(87deg); - } - - 77.97% { - transform: rotate(87.7deg); - } - - 79.66% { - transform: rotate(88.3deg); - } - - 81.36% { - transform: rotate(88.6deg); - } - - 83.05% { - transform: rotate(89.2deg); - } - - 84.75% { - transform: rotate(89.2deg); - } - - 86.44% { - transform: rotate(89.5deg); - } - - 88.14% { - transform: rotate(89.9deg); - } - - 89.83% { - transform: rotate(89.7deg); - } - - 91.53% { - transform: rotate(90.1deg); - } - - 93.22% { - transform: rotate(90.2deg); - } - - 94.92% { - transform: rotate(90.1deg); - } - - 96.61% { - transform: rotate(90deg); - } - - 98.31% { - transform: rotate(89.8deg); - } - - 100% { - transform: rotate(90deg); - } -} - -@keyframes spectrum-fill-mask-2 { - 0% { - transform: rotate(180deg); - } - - 1.69% { - transform: rotate(180deg); - } - - 3.39% { - transform: rotate(180deg); - } - - 5.08% { - transform: rotate(180deg); - } - - 6.78% { - transform: rotate(180deg); - } - - 8.47% { - transform: rotate(180deg); - } - - 10.17% { - transform: rotate(179.2deg); - } - - 11.86% { - transform: rotate(164deg); - } - - 13.56% { - transform: rotate(151.8deg); - } - - 15.25% { - transform: rotate(140.8deg); - } - - 16.95% { - transform: rotate(130.3deg); - } - - 18.64% { - transform: rotate(120.4deg); - } - - 20.34% { - transform: rotate(110.8deg); - } - - 22.03% { - transform: rotate(101.6deg); - } - - 23.73% { - transform: rotate(93.5deg); - } - - 25.42% { - transform: rotate(85.4deg); - } - - 27.12% { - transform: rotate(78.1deg); - } - - 28.81% { - transform: rotate(71.2deg); - } - - 30.51% { - transform: rotate(89.1deg); - } - - 32.2% { - transform: rotate(105.5deg); - } - - 33.9% { - transform: rotate(121.3deg); - } - - 35.59% { - transform: rotate(135.5deg); - } - - 37.29% { - transform: rotate(148.4deg); - } - - 38.98% { - transform: rotate(161deg); - } - - 40.68% { - transform: rotate(173.5deg); - } - - 42.37% { - transform: rotate(180deg); - } - - 44.07% { - transform: rotate(180deg); - } - - 45.76% { - transform: rotate(180deg); - } - - 47.46% { - transform: rotate(180deg); - } - - 49.15% { - transform: rotate(180deg); - } - - 50.85% { - transform: rotate(180deg); - } - - 52.54% { - transform: rotate(180deg); - } - - 54.24% { - transform: rotate(180deg); - } - - 55.93% { - transform: rotate(180deg); - } - - 57.63% { - transform: rotate(180deg); - } - - 59.32% { - transform: rotate(180deg); - } - - 61.02% { - transform: rotate(180deg); - } - - 62.71% { - transform: rotate(180deg); - } - - 64.41% { - transform: rotate(180deg); - } - - 66.1% { - transform: rotate(180deg); - } - - 67.8% { - transform: rotate(180deg); - } - - 69.49% { - transform: rotate(180deg); - } - - 71.19% { - transform: rotate(180deg); - } - - 72.88% { - transform: rotate(180deg); - } - - 74.58% { - transform: rotate(180deg); - } - - 76.27% { - transform: rotate(180deg); - } - - 77.97% { - transform: rotate(180deg); - } - - 79.66% { - transform: rotate(180deg); - } - - 81.36% { - transform: rotate(180deg); - } - - 83.05% { - transform: rotate(180deg); - } - - 84.75% { - transform: rotate(180deg); - } - - 86.44% { - transform: rotate(180deg); - } - - 88.14% { - transform: rotate(180deg); - } - - 89.83% { - transform: rotate(180deg); - } - - 91.53% { - transform: rotate(180deg); - } - - 93.22% { - transform: rotate(180deg); - } - - 94.92% { - transform: rotate(180deg); - } - - 96.61% { - transform: rotate(180deg); - } - - 98.31% { - transform: rotate(180deg); - } - - 100% { - transform: rotate(180deg); +/* windows high contrast mode */ +@media (forced-colors: active) { + .spectrum-ProgressCircle { + /* fill is bright color */ + --highcontrast-progress-circle-fill-border-color: Highlight; + --highcontrast-progress-circle-track-color: Background; } -} -@keyframes spectrum-fills-rotate { - 0% { - transform: rotate(-90deg); - } + .spectrum-ProgressCircle:not(.spectrum-ProgressCircle--indeterminate) { + .spectrum-innerCircle { + stroke: CanvasText; + } - 100% { - transform: rotate(270deg); + .spectrum-outerCircle { + border: 1px solid; + border-color: CanvasText; + border-radius: 50%; + } } } diff --git a/components/progresscircle/package.json b/components/progresscircle/package.json index 2413e8346d6..17cdaee5637 100644 --- a/components/progresscircle/package.json +++ b/components/progresscircle/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/progresscircle", - "version": "5.2.0", + "version": "6.0.0-next.0", "description": "The Spectrum CSS progress circle component", "license": "Apache-2.0", "author": "Adobe", @@ -19,14 +19,12 @@ "./package.json": "./package.json", "./dist/*": "./dist/*", "./index.css": "./dist/index.css", - "./index-*.css": "./dist/index-*.css", "./metadata.json": "./dist/metadata.json", - "./themes/*": "./dist/themes/*", "./stories/*": "./stories/*" }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/tokens": ">=16.0.1" + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/tokens": { @@ -34,7 +32,7 @@ } }, "devDependencies": { - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/progresscircle/stories/progresscircle.stories.js b/components/progresscircle/stories/progresscircle.stories.js index f64c2f2780a..653c01ec3d9 100644 --- a/components/progresscircle/stories/progresscircle.stories.js +++ b/components/progresscircle/stories/progresscircle.stories.js @@ -15,16 +15,28 @@ export default { argTypes: { size: size(["s", "m", "l"]), isIndeterminate, - staticColor: { - ...staticColor, - options: ["white"], - }, + staticColor, + value: { + name: "Percent filled", + type: { name: "number" }, + table: { + type: { summary: "number" }, + category: "Content", + }, + control: { + type: "range", + min: 0, + max: 100 + }, + if: { arg: "isIndeterminate", truthy: false }, + } }, args: { rootClass: "spectrum-ProgressCircle", size: "m", isIndeterminate: false, staticColor: undefined, + value: 43 }, parameters: { design: { @@ -33,7 +45,11 @@ export default { }, packageJson, metadata, + status: { + type: "migrated", + }, }, + tags: ["migrated"], }; export const Default = ProgressCircleGroup.bind({}); @@ -102,3 +118,25 @@ StaticWhiteIndeterminate.args = { StaticWhiteIndeterminate.parameters = { chromatic: { disableSnapshot: true }, }; + +export const StaticBlackDeterminate = Sizing.bind({}); +StaticBlackDeterminate.tags = ["!dev"]; +StaticBlackDeterminate.storyName = "Static black, default"; +StaticBlackDeterminate.args = { + staticColor: "black", + isIndeterminate: false, +}; +StaticBlackDeterminate.parameters = { + chromatic: { disableSnapshot: true }, +}; + +export const StaticBlackIndeterminate = Sizing.bind({}); +StaticBlackIndeterminate.tags = ["!dev"]; +StaticBlackIndeterminate.storyName = "Static black, indeterminate"; +StaticBlackIndeterminate.args = { + staticColor: "black", + isIndeterminate: true, +}; +StaticBlackIndeterminate.parameters = { + chromatic: { disableSnapshot: true }, +}; diff --git a/components/progresscircle/stories/progresscircle.test.js b/components/progresscircle/stories/progresscircle.test.js index 26c9d8e078c..83fe05791dc 100644 --- a/components/progresscircle/stories/progresscircle.test.js +++ b/components/progresscircle/stories/progresscircle.test.js @@ -11,6 +11,10 @@ export const ProgressCircleGroup = Variants({ testHeading: "Static white", staticColor: "white", }, + { + testHeading: "Static black", + staticColor: "black", + }, ], stateData: [ { diff --git a/components/progresscircle/stories/template.js b/components/progresscircle/stories/template.js index 2e27221f91a..1890e58d4b0 100644 --- a/components/progresscircle/stories/template.js +++ b/components/progresscircle/stories/template.js @@ -4,10 +4,9 @@ import { classMap } from "lit/directives/class-map.js"; import { ifDefined } from "lit/directives/if-defined.js"; import { styleMap } from "lit/directives/style-map.js"; +import { capitalize } from "lodash-es"; + import "../index.css"; -import "../themes/spectrum.css"; -/* Must be imported last */ -import "../themes/express.css"; export const Template = ({ id = getRandomId("progress-circle"), @@ -18,45 +17,48 @@ export const Template = ({ size = "m", staticColor, isIndeterminate = false, -} = {}) => { - let sizeClassName = "medium"; - switch (size) { - case "s": - sizeClassName = "small"; - break; - case "l": - sizeClassName = "large"; - break; - default: - sizeClassName = "medium"; - } + value, +}) => { + + let strokeWidth = size === "s" ? 2 : size === "l" ? 4 : 3; + + // SVG strokes are centered, so subtract half the stroke width from the radius to create an inner stroke. + let radius = `calc(50% - ${strokeWidth / 2}px)`; + + let insideRadius = `calc(50% - ${strokeWidth / 1}px)`; return html`
({ ...a, [c]: true }), {}), })} id=${ifDefined(id)} style=${styleMap(customStyles)} data-testid=${ifDefined(testId)} > -
-
-
-
-
-
-
-
-
-
-
-
-
+ + + + +
`; -}; \ No newline at end of file +}; diff --git a/components/progresscircle/themes/express.css b/components/progresscircle/themes/express.css deleted file mode 100644 index 9fd550418f2..00000000000 --- a/components/progresscircle/themes/express.css +++ /dev/null @@ -1,16 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--express */ - -@import "./spectrum.css"; diff --git a/components/progresscircle/themes/spectrum-two.css b/components/progresscircle/themes/spectrum-two.css deleted file mode 100644 index 93464f22940..00000000000 --- a/components/progresscircle/themes/spectrum-two.css +++ /dev/null @@ -1,22 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -@container style(--system: spectrum) { - .spectrum-ProgressCircle { - /* circle unfilled border color */ - --spectrum-progress-circle-track-border-color: var(--spectrum-gray-200); - - --spectrum-progress-circle-track-border-color-over-background: var(--spectrum-transparent-white-400); - --spectrum-progress-circle-fill-border-color-over-background: var(--spectrum-transparent-white-1000); - } -} diff --git a/components/progresscircle/themes/spectrum.css b/components/progresscircle/themes/spectrum.css deleted file mode 100644 index 2d0e45eece1..00000000000 --- a/components/progresscircle/themes/spectrum.css +++ /dev/null @@ -1,26 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--legacy */ - -@import "./spectrum-two.css"; - -@container style(--system: legacy) { - .spectrum-ProgressCircle { - /* circle unfilled border color */ - --spectrum-progress-circle-track-border-color: var(--spectrum-gray-300); - - --spectrum-progress-circle-track-border-color-over-background: var(--spectrum-transparent-white-300); - --spectrum-progress-circle-fill-border-color-over-background: var(--spectrum-transparent-white-900); - } -} diff --git a/components/radio/CHANGELOG.md b/components/radio/CHANGELOG.md index 5b58f0b6f15..d2d0ec4cb6b 100644 --- a/components/radio/CHANGELOG.md +++ b/components/radio/CHANGELOG.md @@ -1,5 +1,50 @@ # Change log +## 11.0.0-next.3 + +### Major Changes + +📝 [#4014](https://github.com/adobe/spectrum-css/pull/4014) [`35c066b`](https://github.com/adobe/spectrum-css/commit/35c066b29c311b1bfcf4507075f13b41222ffc84) Thanks [@castastrophe](https://github.com/castastrophe)! + +This update removes the `dir` attribute polyfill (served via a PostCSS transform to compiled assets) as the fallback is no longer necessary. The`dir` attribute support is available in all supported browsers and has been tested to correctly inherit inside web component shadow DOMs. This is a breaking change **only** to those relying on the `dir` attribute being present for styling, however, the `:dir` pseudo will correctly inherit values from their containers. To correctly determine the `dir` value of a node using JavaScript, you can use `getComputedStyle(node).direction`. + +## 11.0.0-next.2 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + +## 11.0.0-next.1 + +### Major Changes + +- [#3555](https://github.com/adobe/spectrum-css/pull/3555) [`0af6461`](https://github.com/adobe/spectrum-css/commit/0af646180cd61e1872cde39bed5436f97d378cc9) Thanks [@aramos-adobe](https://github.com/aramos-adobe)! - # Radio S2 Migration + + Updates: + - High contrast tokens have been modified + - Typography tokens modified + + ## New tokens + + `--spectrum-radio-border-width` + `--spectrum-radio-text-font-weight` + `--spectrum-radio-text-font-style` + + ## Modified tokens + + `--spectrum-radio-emphasized-accent-color` + `--spectrum-radio-emphasized-accent-color-hover` + `--spectrum-radio-emphasized-accent-color-down` + `--spectrum-radio-emphasized-accent-color-focus` + +## 11.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`a25e0a9`](https://github.com/adobe/spectrum-css/commit/a25e0a99e5a4736ab4e607e00739343101a2633b)]: + - @spectrum-css/icon@10.0.0-next.0 + ## 10.2.0 ### Minor Changes diff --git a/components/radio/dist/metadata.json b/components/radio/dist/metadata.json index abb2345e6dd..5671fe2386a 100644 --- a/components/radio/dist/metadata.json +++ b/components/radio/dist/metadata.json @@ -12,7 +12,6 @@ ".spectrum-Radio--emphasized:focus .spectrum-Radio-input:checked + .spectrum-Radio-button:before", ".spectrum-Radio--emphasized:hover .spectrum-Radio-input:checked + .spectrum-Radio-button:before", ".spectrum-Radio--sizeL", - ".spectrum-Radio--sizeM", ".spectrum-Radio--sizeS", ".spectrum-Radio--sizeXL", ".spectrum-Radio-button", @@ -26,10 +25,15 @@ ".spectrum-Radio-label:lang(ja)", ".spectrum-Radio-label:lang(ko)", ".spectrum-Radio-label:lang(zh)", + ".spectrum-Radio.is-active .spectrum-Radio-button:before", + ".spectrum-Radio.is-active .spectrum-Radio-input:checked + .spectrum-Radio-button:before", + ".spectrum-Radio.is-active .spectrum-Radio-label", ".spectrum-Radio.is-readOnly .spectrum-Radio-input", + ".spectrum-Radio.is-readOnly .spectrum-Radio-input + .spectrum-Radio-button:before", ".spectrum-Radio.is-readOnly .spectrum-Radio-input:checked:disabled ~ .spectrum-Radio-label", ".spectrum-Radio.is-readOnly .spectrum-Radio-input:disabled ~ .spectrum-Radio-label", ".spectrum-Radio.is-readOnly .spectrum-Radio-label", + ".spectrum-Radio.is-readOnly:hover .spectrum-Radio-input + .spectrum-Radio-button:before", ".spectrum-Radio:active .spectrum-Radio-button:before", ".spectrum-Radio:active .spectrum-Radio-input:checked + .spectrum-Radio-button:before", ".spectrum-Radio:active .spectrum-Radio-label", @@ -44,7 +48,7 @@ ".spectrum-Radio:lang(ja)", ".spectrum-Radio:lang(ko)", ".spectrum-Radio:lang(zh)", - "[dir=\"rtl\"] .spectrum-Radio .spectrum-Radio-button:after" + ".spectrum-Radio:not(.is-readOnly):active .spectrum-Radio-input:not(:disabled) + .spectrum-Radio-button" ], "modifiers": [ "--mod-radio-animation-duration", @@ -86,10 +90,6 @@ "--spectrum-radio-button-border-color-down", "--spectrum-radio-button-border-color-focus", "--spectrum-radio-button-border-color-hover", - "--spectrum-radio-button-checked-border-color-default", - "--spectrum-radio-button-checked-border-color-down", - "--spectrum-radio-button-checked-border-color-focus", - "--spectrum-radio-button-checked-border-color-hover", "--spectrum-radio-button-control-size", "--spectrum-radio-button-control-size-extra-large", "--spectrum-radio-button-control-size-large", @@ -120,12 +120,15 @@ "--spectrum-radio-neutral-content-color-down", "--spectrum-radio-neutral-content-color-focus", "--spectrum-radio-neutral-content-color-hover", + "--spectrum-radio-text-font-style", + "--spectrum-radio-text-font-weight", "--spectrum-radio-text-to-control" ], "global": [ - "--spectrum-accent-color-1000", - "--spectrum-accent-color-1100", - "--spectrum-accent-color-900", + "--spectrum-accent-content-color-default", + "--spectrum-accent-content-color-down", + "--spectrum-accent-content-color-hover", + "--spectrum-accent-content-color-key-focus", "--spectrum-animation-duration-100", "--spectrum-border-width-200", "--spectrum-cjk-line-height-100", @@ -137,10 +140,13 @@ "--spectrum-component-height-200", "--spectrum-component-height-300", "--spectrum-component-height-75", + "--spectrum-component-size-difference-down", + "--spectrum-component-size-minimum-perspective-down", "--spectrum-component-top-to-text-100", "--spectrum-component-top-to-text-200", "--spectrum-component-top-to-text-300", "--spectrum-component-top-to-text-75", + "--spectrum-default-font-style", "--spectrum-disabled-content-color", "--spectrum-focus-indicator-color", "--spectrum-focus-indicator-gap", @@ -149,31 +155,18 @@ "--spectrum-font-size-200", "--spectrum-font-size-300", "--spectrum-font-size-75", - "--spectrum-gray-50", - "--spectrum-gray-600", - "--spectrum-gray-700", - "--spectrum-gray-800", + "--spectrum-gray-25", "--spectrum-line-height-100", - "--spectrum-neutral-background-color-selected-default", - "--spectrum-neutral-background-color-selected-down", - "--spectrum-neutral-background-color-selected-hover", - "--spectrum-neutral-background-color-selected-key-focus", "--spectrum-neutral-content-color-default", "--spectrum-neutral-content-color-down", "--spectrum-neutral-content-color-hover", "--spectrum-neutral-content-color-key-focus", + "--spectrum-regular-font-weight", "--spectrum-text-to-control-100", "--spectrum-text-to-control-200", "--spectrum-text-to-control-300", "--spectrum-text-to-control-75" ], - "system-theme": [ - "--system-radio-button-background-color", - "--system-radio-button-border-color-default", - "--system-radio-button-border-color-down", - "--system-radio-button-border-color-focus", - "--system-radio-button-border-color-hover" - ], "passthroughs": [], "high-contrast": [ "--highcontrast-radio-button-border-color-default", diff --git a/components/radio/index.css b/components/radio/index.css index 1c2c92747c5..c3878f77634 100644 --- a/components/radio/index.css +++ b/components/radio/index.css @@ -11,8 +11,6 @@ * governing permissions and limitations under the License. */ -@import "./themes/spectrum-two.css"; - /* * Radio: * ::before is to style the input circle (selection indicator) @@ -20,6 +18,8 @@ */ .spectrum-Radio { + --spectrum-radio-button-background-color: var(--spectrum-gray-25); + /* state colors for all themes */ --spectrum-radio-neutral-content-color: var(--spectrum-neutral-content-color-default); --spectrum-radio-neutral-content-color-hover: var(--spectrum-neutral-content-color-hover); @@ -36,35 +36,22 @@ --spectrum-radio-disabled-border-color: var(--spectrum-disabled-content-color); /* emphasized state colors selection indicator all themes */ - --spectrum-radio-emphasized-accent-color: var(--spectrum-accent-color-900); - --spectrum-radio-emphasized-accent-color-hover: var(--spectrum-accent-color-1000); - --spectrum-radio-emphasized-accent-color-down: var(--spectrum-accent-color-1100); - --spectrum-radio-emphasized-accent-color-focus: var(--spectrum-accent-color-1000); - - /* selection indicator all themes */ - --spectrum-radio-border-width: var(--spectrum-border-width-200); + --spectrum-radio-emphasized-accent-color: var(--spectrum-accent-content-color-default); + --spectrum-radio-emphasized-accent-color-hover: var(--spectrum-accent-content-color-hover); + --spectrum-radio-emphasized-accent-color-down: var(--spectrum-accent-content-color-down); + --spectrum-radio-emphasized-accent-color-focus: var(--spectrum-accent-content-color-key-focus); - /* checked selection indicator */ - --spectrum-radio-button-checked-border-color-default: var(--spectrum-neutral-background-color-selected-default); - --spectrum-radio-button-checked-border-color-hover: var(--spectrum-neutral-background-color-selected-hover); - --spectrum-radio-button-checked-border-color-down: var(--spectrum-neutral-background-color-selected-down); - --spectrum-radio-button-checked-border-color-focus: var(--spectrum-neutral-background-color-selected-key-focus); + /* radio checked/unchecked selection indicator */ + --spectrum-radio-button-border-color-default: var(--spectrum-neutral-content-color-default); + --spectrum-radio-button-border-color-hover: var(--spectrum-neutral-content-color-hover); + --spectrum-radio-button-border-color-down: var(--spectrum-neutral-content-color-down); + --spectrum-radio-button-border-color-focus: var(--spectrum-neutral-content-color-key-focus); --spectrum-radio-line-height: var(--spectrum-line-height-100); /* animation all themes */ --spectrum-radio-animation-duration: var(--spectrum-animation-duration-100); - /* CJK language support all themes */ - &:lang(ja), - &:lang(zh), - &:lang(ko) { - --spectrum-radio-line-height-cjk: var(--spectrum-cjk-line-height-100); - } -} - -.spectrum-Radio, -.spectrum-Radio--sizeM { --spectrum-radio-height: var(--spectrum-component-height-100); --spectrum-radio-button-control-size: var(--spectrum-radio-button-control-size-medium); @@ -74,6 +61,16 @@ --spectrum-radio-button-top-to-control: var(--spectrum-radio-button-top-to-control-medium); --spectrum-radio-font-size: var(--spectrum-font-size-100); + --spectrum-radio-border-width: var(--spectrum-border-width-200); + --spectrum-radio-text-font-weight: var(--spectrum-regular-font-weight); + --spectrum-radio-text-font-style: var(--spectrum-default-font-style); + + /* CJK language support all themes */ + &:lang(ja), + &:lang(zh), + &:lang(ko) { + --spectrum-radio-line-height-cjk: var(--spectrum-cjk-line-height-100); + } } .spectrum-Radio--sizeS { @@ -112,51 +109,6 @@ --spectrum-radio-font-size: var(--spectrum-font-size-300); } -/* windows high contrast mode */ -@media (forced-colors: active) { - .spectrum-Radio { - /* high contrast text */ - --highcontrast-radio-neutral-content-color: CanvasText; - --highcontrast-radio-neutral-content-color-hover: CanvasText; - --highcontrast-radio-neutral-content-color-down: CanvasText; - --highcontrast-radio-neutral-content-color-focus: CanvasText; - - /* high contrast selector */ - --highcontrast-radio-button-border-color-default: ButtonText; - --highcontrast-radio-button-border-color-hover: Highlight; - --highcontrast-radio-button-border-color-down: ButtonText; - --highcontrast-radio-button-border-color-focus: Highlight; - - /* high contrast emphasized selector */ - --highcontrast-radio-emphasized-accent-color: ButtonText; - --highcontrast-radio-emphasized-accent-color-hover: Highlight; - --highcontrast-radio-emphasized-accent-color-down: ButtonText; - --highcontrast-radio-emphasized-accent-color-focus: Highlight; - - /* high contrast checked selector */ - --highcontrast-radio-button-checked-border-color-default: Highlight; - --highcontrast-radio-button-checked-border-color-hover: Highlight; - --highcontrast-radio-button-checked-border-color-down: Highlight; - --highcontrast-radio-button-checked-border-color-focus: Highlight; - - /* high contrast disabled text */ - --highcontrast-radio-disabled-content-color: GrayText; - - /* high contrast disabled selector */ - --highcontrast-radio-disabled-border-color: GrayText; - - /* high contrast focus ring */ - --highcontrast-radio-focus-indicator-color: CanvasText; - - /* ensure focus ring is visible if user agent has non-accessible system overrides */ - .spectrum-Radio-button { - &::after { - forced-color-adjust: none; - } - } - } -} - .spectrum-Radio { display: inline-flex; align-items: flex-start; @@ -174,7 +126,7 @@ /* checked selection indicator hover */ .spectrum-Radio-input:checked + .spectrum-Radio-button::before { - border-color: var(--highcontrast-radio-button-checked-border-color-hover, var(--mod-radio-button-checked-border-color-hover, var(--spectrum-radio-button-checked-border-color-hover))); + border-color: var(--highcontrast-radio-button-checked-border-color-hover, var(--mod-radio-button-checked-border-color-hover, var(--spectrum-radio-button-border-color-hover))); } .spectrum-Radio-label { @@ -182,7 +134,14 @@ } } - &:active { + &:not(.is-readOnly):active { + .spectrum-Radio-input:not(:disabled) + .spectrum-Radio-button { + transform: perspective(var(--spectrum-component-size-minimum-perspective-down)) translateZ(var(--spectrum-component-size-difference-down)); + } + } + + &:active, + &.is-active { /* selection indicator active */ .spectrum-Radio-button::before { border-color: var(--highcontrast-radio-button-border-color-down, var(--mod-radio-button-border-color-down, var(--spectrum-radio-button-border-color-down))); @@ -190,7 +149,7 @@ /* checked selection indicator active */ .spectrum-Radio-input:checked + .spectrum-Radio-button::before { - border-color: var(--highcontrast-radio-button-checked-border-color-down, var(--mod-radio-button-checked-border-color-down, var(--spectrum-radio-button-checked-border-color-down))); + border-color: var(--highcontrast-radio-button-checked-border-color-down, var(--mod-radio-button-checked-border-color-down, var(--spectrum-radio-button-border-color-down))); } .spectrum-Radio-label { @@ -216,7 +175,7 @@ /* selected selection indicator is focused state */ .spectrum-Radio-input:checked + .spectrum-Radio-button::before { - border-color: var(--highcontrast-radio-button-checked-border-color-focus, var(--mod-radio-button-checked-border-color-focus, var(--spectrum-radio-button-checked-border-color-focus))); + border-color: var(--highcontrast-radio-button-checked-border-color-focus, var(--mod-radio-button-checked-border-color-focus, var(--spectrum-radio-button-border-color-focus))); } .spectrum-Radio-label { @@ -309,7 +268,7 @@ &::before { /* half of element width minus half of indicator width is checked border width */ border-width: calc((var(--spectrum-radio-button-control-size) / 2) - (var(--spectrum-radio-button-selection-indicator) / 2)); - border-color: var(--highcontrast-radio-button-checked-border-color-default, var(--mod-radio-button-checked-border-color-default, var(--spectrum-radio-button-checked-border-color-default))); + border-color: var(--highcontrast-radio-button-checked-border-color-default, var(--mod-radio-button-checked-border-color-default, var(--spectrum-radio-button-border-color-default))); } } @@ -334,9 +293,8 @@ font-size: var(--mod-radio-font-size, var(--spectrum-radio-font-size)); - /* TODO: font weight and style tokens */ - /* font-weight: var(--spectrum-radio-text-font-weight); **** missing token resolves to 400 ****/ - /* font-style: var(--spectrum-radio-text-font-style); **** missing token resolves to normal ****/ + font-weight: var(--spectrum-radio-text-font-weight); + font-style: var(--spectrum-radio-text-font-style); color: var(--highcontrast-radio-neutral-content-color, var(--mod-radio-neutral-content-color, var(--spectrum-radio-neutral-content-color))); line-height: var(--mod-radio-line-height, var(--spectrum-radio-line-height)); @@ -403,3 +361,58 @@ } } } + +/* windows high contrast mode */ +@media (forced-colors: active) { + .spectrum-Radio { + /* high contrast text */ + --highcontrast-radio-neutral-content-color: CanvasText; + --highcontrast-radio-neutral-content-color-hover: CanvasText; + --highcontrast-radio-neutral-content-color-down: CanvasText; + --highcontrast-radio-neutral-content-color-focus: CanvasText; + + /* high contrast selector */ + --highcontrast-radio-button-border-color-default: ButtonText; + --highcontrast-radio-button-border-color-hover: Highlight; + --highcontrast-radio-button-border-color-down: ButtonText; + --highcontrast-radio-button-border-color-focus: Highlight; + + /* high contrast emphasized selector */ + --highcontrast-radio-emphasized-accent-color: Highlight; + --highcontrast-radio-emphasized-accent-color-hover: Highlight; + --highcontrast-radio-emphasized-accent-color-down: ButtonText; + --highcontrast-radio-emphasized-accent-color-focus: Highlight; + + /* high contrast checked selector */ + --highcontrast-radio-button-checked-border-color-default: Highlight; + --highcontrast-radio-button-checked-border-color-hover: Highlight; + --highcontrast-radio-button-checked-border-color-down: Highlight; + --highcontrast-radio-button-checked-border-color-focus: Highlight; + + /* high contrast disabled text */ + --highcontrast-radio-disabled-content-color: GrayText; + + /* high contrast disabled selector */ + --highcontrast-radio-disabled-border-color: GrayText; + + /* high contrast focus ring */ + --highcontrast-radio-focus-indicator-color: CanvasText; + + /* ensure focus ring is visible if user agent has non-accessible system overrides */ + .spectrum-Radio-button { + &::after { + forced-color-adjust: none; + } + } + + &.is-readOnly { + .spectrum-Radio-input + .spectrum-Radio-button::before { + border-color: var(--highcontrast-radio-button-border-color-default); + } + + &:hover .spectrum-Radio-input + .spectrum-Radio-button::before { + border-color: var(--highcontrast-radio-button-border-color-default); + } + } + } +} diff --git a/components/radio/package.json b/components/radio/package.json index a0cc5273599..9d785304873 100644 --- a/components/radio/package.json +++ b/components/radio/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/radio", - "version": "10.2.0", + "version": "11.0.0-next.3", "description": "The Spectrum CSS radio component", "license": "Apache-2.0", "author": "Adobe", @@ -19,15 +19,13 @@ "./package.json": "./package.json", "./dist/*": "./dist/*", "./index.css": "./dist/index.css", - "./index-*.css": "./dist/index-*.css", "./metadata.json": "./dist/metadata.json", - "./themes/*": "./dist/themes/*", "./stories/*": "./stories/*" }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/icon": ">=9.0.0 <10.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/icon": ">=10.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/icon": { @@ -38,8 +36,8 @@ } }, "devDependencies": { - "@spectrum-css/icon": "9.2.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/icon": "10.0.0-next.3", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/radio/stories/radio.stories.js b/components/radio/stories/radio.stories.js index 1d6ff3d9b16..ead1b1c051b 100644 --- a/components/radio/stories/radio.stories.js +++ b/components/radio/stories/radio.stories.js @@ -1,6 +1,6 @@ import { Sizes } from "@spectrum-css/preview/decorators"; import { disableDefaultModes } from "@spectrum-css/preview/modes"; -import { isChecked, isDisabled, isEmphasized, isReadOnly, size } from "@spectrum-css/preview/types"; +import { isActive, isChecked, isDisabled, isEmphasized, isFocused, isHovered, isReadOnly, size } from "@spectrum-css/preview/types"; import metadata from "../dist/metadata.json"; import packageJson from "../package.json"; import { RadioGroup } from "./radio.test.js"; @@ -40,6 +40,9 @@ export default { isChecked, isDisabled, isReadOnly, + isHovered, + isFocused, + isActive, }, args: { rootClass: "spectrum-Radio", @@ -49,6 +52,9 @@ export default { isChecked: false, isDisabled: false, isReadOnly: false, + isHovered: false, + isFocused: false, + isActive: false, }, parameters: { actions: { @@ -60,7 +66,11 @@ export default { }, packageJson, metadata, + status: { + type: "migrated", + }, }, + tags: ["migrated"], }; export const Default = RadioGroup.bind({}); diff --git a/components/radio/stories/radio.test.js b/components/radio/stories/radio.test.js index 13b743d62b3..a14b5daa761 100644 --- a/components/radio/stories/radio.test.js +++ b/components/radio/stories/radio.test.js @@ -18,7 +18,6 @@ export const RadioGroup = Variants({ customStyles: { "max-width": "220px", } - } ], stateData: [ @@ -26,13 +25,51 @@ export const RadioGroup = Variants({ testHeading: "Checked", isChecked: true, }, + { + testHeading: "Checked + hovered", + isChecked: true, + }, + { + testHeading: "Hover", + isHovered: true, + }, { testHeading: "Disabled", isDisabled: true, }, + { + testHeading: "Disabled + checked", + isDisabled: true, + isChecked: true, + }, + { + testHeading: "Disabled + checked + hovered", + isDisabled: true, + isChecked: true, + isHovered: true, + }, { testHeading: "Read-only", isReadOnly: true, }, + { + testHeading: "Read-only + checked", + isReadOnly: true, + isChecked: true, + }, + { + testHeading: "Read-only + checked + hovered", + isHovered: true, + isReadOnly: true, + isChecked: true, + }, + { + testHeading: "Active", + isActive: true + }, + { + testHeading: "Focus-visible", + isFocused: true, + }, ] }); diff --git a/components/radio/stories/template.js b/components/radio/stories/template.js index 68c3cbf0e96..3a1f613bc08 100644 --- a/components/radio/stories/template.js +++ b/components/radio/stories/template.js @@ -5,9 +5,6 @@ import { ifDefined } from "lit/directives/if-defined.js"; import { styleMap } from "lit/directives/style-map.js"; import "../index.css"; -import "../themes/spectrum.css"; -/* Must be imported last */ -import "../themes/express.css"; export const Template = ({ rootClass = "spectrum-Radio", @@ -18,6 +15,9 @@ export const Template = ({ isChecked = false, isDisabled = false, isReadOnly = false, + isFocused = false, + isActive = false, + isHovered, id = getRandomId("radio"), customClasses = [], customStyles = {}, @@ -37,7 +37,9 @@ export const Template = ({ [`${rootClass}--size${size?.toUpperCase()}`]: typeof size !== "undefined", [`${rootClass}--emphasized`]: isEmphasized, + "is-hover": isHovered, "is-readOnly" : isReadOnly, + "is-active" : isActive, ...customClasses.reduce((a, c) => ({ ...a, [c]: true }), {}), })} style=${styleMap(customStyles)} @@ -45,7 +47,11 @@ export const Template = ({ - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--express */ - -@import "./spectrum.css"; - -@container style(--system: express) { - .spectrum-Radio { - /* selection indicator */ - --spectrum-radio-button-border-color-default: var(--spectrum-gray-800); - --spectrum-radio-button-border-color-hover: var(--spectrum-gray-900); - --spectrum-radio-button-border-color-down: var(--spectrum-gray-900); - --spectrum-radio-button-border-color-focus: var(--spectrum-gray-900); - } -} diff --git a/components/radio/themes/spectrum-two.css b/components/radio/themes/spectrum-two.css deleted file mode 100644 index 48b980fc0e4..00000000000 --- a/components/radio/themes/spectrum-two.css +++ /dev/null @@ -1,24 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -@container style(--system: spectrum) { - .spectrum-Radio { - /* selection indicator */ - --spectrum-radio-button-border-color-default: var(--spectrum-gray-600); - --spectrum-radio-button-border-color-hover: var(--spectrum-gray-700); - --spectrum-radio-button-border-color-down: var(--spectrum-gray-800); - --spectrum-radio-button-border-color-focus: var(--spectrum-gray-700); - - --spectrum-radio-button-background-color: var(--spectrum-gray-50); - } -} diff --git a/components/radio/themes/spectrum.css b/components/radio/themes/spectrum.css deleted file mode 100644 index 33772fcc7c9..00000000000 --- a/components/radio/themes/spectrum.css +++ /dev/null @@ -1,22 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--legacy */ - -@import "./spectrum-two.css"; - -@container style(--system: legacy) { - .spectrum-Radio { - --spectrum-radio-button-background-color: var(--spectrum-gray-75); - } -} diff --git a/components/rating/CHANGELOG.md b/components/rating/CHANGELOG.md index a3fb44d3cd2..f4079305dd0 100644 --- a/components/rating/CHANGELOG.md +++ b/components/rating/CHANGELOG.md @@ -1,5 +1,83 @@ # Change log +## 7.0.0-next.2 + +### Major Changes + +- [#3627](https://github.com/adobe/spectrum-css/pull/3627) [`888e63d`](https://github.com/adobe/spectrum-css/commit/888e63d34cdb21b4ba007ebbd12ac469ead69726) Thanks [@cdransf](https://github.com/cdransf)! + +#### Spectrum 2 migration + +This migrates the `rating` component to S2. Custom properties have been remapped and added per the design specification. + +##### Additions + +The medium component variation is the default and a t-shirt size medium variation has been added. + +A tooltip may be displayed to a user indicating whether interacting with the component will clear or edit the rating. A control and documentation example have been added. + +A rating may have a partially filled star. The width and fill of this star is controlled by adding `.is-partial` to the parent `span` with classes of `spectrum-Rating-icon` and `is-selected` and then setting `--mod-rating-icon-fill` to the necessary fill percentage (e.g. `50%`). + +##### New mods + +`--mod-rating-width` +`--mod-rating-height` +`--mod-rating-bottom-to-content-area` +`--mod-rating-edge-to-content-area` +`--mod-rating-top-to-content-area` +`--mod-rating-icon-fill` + +##### Removed mods + +`--mod-rating-icon-spacing-vertical-top` +`--mod-rating-icon-count` +`--mod-rating-indicator-border-radius` +`--mod-rating-indicator-height` +`--mod-rating-icon-color-key-focus` + +##### New custom properties + +`--spectrum-rating-width` +`--spectrum-component-size-difference-down` +`--spectrum-component-size-minimum-perspective-down` +`--spectrum-corner-radius-medium-size-medium` +`--spectrum-corner-radius-medium-size-small` +`--spectrum-neutral-content-color-default` +`--spectrum-neutral-content-color-down` +`--spectrum-neutral-content-color-hover` +`--spectrum-spacing-75` +`--spectrum-workflow-icon-size-75` + +##### Removed custom properties + +`--spectrum-rating-indicator-width` +`--spectrum-rating-icon-color-key-focus` +`--spectrum-rating-icon-spacing-vertical-top` +`--spectrum-rating-indicator-height` +`--spectrum-rating-indicator-border-radius` +`--spectrum-accent-content-color-key-focus` +`--spectrum-border-width-200` +`--spectrum-component-top-to-workflow-icon-100` +`--spectrum-corner-radius-100` +`--spectrum-neutral-subdued-content-color-default` +`--spectrum-neutral-subdued-content-color-down` +`--spectrum-neutral-subdued-content-color-hover` +`--spectrum-neutral-subdued-content-color-key-focus` + +## 7.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + +## 7.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`a25e0a9`](https://github.com/adobe/spectrum-css/commit/a25e0a99e5a4736ab4e607e00739343101a2633b)]: + - @spectrum-css/icon@10.0.0-next.0 + ## 6.2.0 ### Minor Changes @@ -14,8 +92,6 @@ Ensure accurate exports are present for each component. Specifically, adding `th 📝 [`205182b`](https://github.com/adobe/spectrum-css/commit/205182bebcbe82813457aa098d8799b0a23423ee) Thanks [@castastrophe](https://github.com/castastrophe)! -## New feature - Minified and gzipped outputs available for all compiled CSS assets. ### Patch Changes diff --git a/components/rating/dist/metadata.json b/components/rating/dist/metadata.json index 75ee43e0895..591d987a853 100644 --- a/components/rating/dist/metadata.json +++ b/components/rating/dist/metadata.json @@ -7,17 +7,19 @@ ".spectrum-Rating--emphasized .spectrum-Rating-icon:hover ~ .spectrum-Rating-icon", ".spectrum-Rating--emphasized.is-focused .spectrum-Rating-icon.is-selected", ".spectrum-Rating--emphasized:hover .spectrum-Rating-icon", - ".spectrum-Rating--emphasized:hover .spectrum-Rating-icon.is-currentValue:after", ".spectrum-Rating--emphasized:hover .spectrum-Rating-icon:active", ".spectrum-Rating--emphasized:hover .spectrum-Rating-icon:hover", ".spectrum-Rating--emphasized:hover .spectrum-Rating-icon:hover ~ .spectrum-Rating-icon", + ".spectrum-Rating--sizeS", ".spectrum-Rating-icon", ".spectrum-Rating-icon .spectrum-Rating-starActive", ".spectrum-Rating-icon .spectrum-Rating-starInactive", - ".spectrum-Rating-icon.is-currentValue:after", + ".spectrum-Rating-icon svg", ".spectrum-Rating-icon.is-selected", ".spectrum-Rating-icon.is-selected .spectrum-Rating-starActive", ".spectrum-Rating-icon.is-selected .spectrum-Rating-starInactive", + ".spectrum-Rating-icon.is-selected.is-partial .spectrum-Rating-starActive", + ".spectrum-Rating-icon.is-selected.is-partial .spectrum-Rating-starInactive", ".spectrum-Rating-icon:hover ~ .spectrum-Rating-icon", ".spectrum-Rating-icon:hover ~ .spectrum-Rating-icon .spectrum-Rating-starActive", ".spectrum-Rating-icon:hover ~ .spectrum-Rating-icon .spectrum-Rating-starInactive", @@ -28,18 +30,18 @@ ".spectrum-Rating.is-disabled .spectrum-Rating-icon", ".spectrum-Rating.is-disabled .spectrum-Rating-icon.is-selected", ".spectrum-Rating.is-focused", - ".spectrum-Rating.is-focused .spectrum-Rating-icon", - ".spectrum-Rating.is-focused .spectrum-Rating-icon.is-selected", ".spectrum-Rating.is-readOnly", ".spectrum-Rating:hover .spectrum-Rating-icon", - ".spectrum-Rating:hover .spectrum-Rating-icon.is-currentValue:after", ".spectrum-Rating:hover .spectrum-Rating-icon:active", ".spectrum-Rating:hover .spectrum-Rating-icon:hover", ".spectrum-Rating:hover .spectrum-Rating-starActive", - ".spectrum-Rating:hover .spectrum-Rating-starInactive" + ".spectrum-Rating:hover .spectrum-Rating-starInactive", + ".spectrum-Rating:not(.is-readOnly) .spectrum-Rating-input:not(:disabled) ~ .spectrum-Rating-icon:active" ], "modifiers": [ "--mod-rating-border-radius", + "--mod-rating-bottom-to-content-area", + "--mod-rating-edge-to-content-area", "--mod-rating-emphasized-icon-color-default", "--mod-rating-emphasized-icon-color-down", "--mod-rating-emphasized-icon-color-hover", @@ -47,21 +49,26 @@ "--mod-rating-focus-indicator-color", "--mod-rating-focus-indicator-gap", "--mod-rating-focus-indicator-thickness", + "--mod-rating-height", "--mod-rating-icon-color-default", "--mod-rating-icon-color-disabled", "--mod-rating-icon-color-down", "--mod-rating-icon-color-hover", - "--mod-rating-icon-color-key-focus", - "--mod-rating-icon-count", + "--mod-rating-icon-fill", "--mod-rating-icon-height", "--mod-rating-icon-spacing", - "--mod-rating-icon-spacing-vertical-top", "--mod-rating-icon-width", - "--mod-rating-indicator-border-radius", - "--mod-rating-indicator-height" + "--mod-rating-top-to-content-area", + "--mod-rating-width" ], "component": [ "--spectrum-rating-border-radius", + "--spectrum-rating-bottom-to-content-area", + "--spectrum-rating-bottom-to-content-area-medium", + "--spectrum-rating-bottom-to-content-area-small", + "--spectrum-rating-edge-to-content-area", + "--spectrum-rating-edge-to-content-area-medium", + "--spectrum-rating-edge-to-content-area-small", "--spectrum-rating-emphasized-icon-color-default", "--spectrum-rating-emphasized-icon-color-down", "--spectrum-rating-emphasized-icon-color-hover", @@ -69,44 +76,42 @@ "--spectrum-rating-focus-indicator-color", "--spectrum-rating-focus-indicator-gap", "--spectrum-rating-focus-indicator-thickness", + "--spectrum-rating-height", + "--spectrum-rating-height-medium", + "--spectrum-rating-height-small", "--spectrum-rating-icon-color-default", "--spectrum-rating-icon-color-disabled", "--spectrum-rating-icon-color-down", "--spectrum-rating-icon-color-hover", - "--spectrum-rating-icon-color-key-focus", - "--spectrum-rating-icon-count", + "--spectrum-rating-icon-fill", "--spectrum-rating-icon-height", "--spectrum-rating-icon-spacing", - "--spectrum-rating-icon-spacing-vertical-top", "--spectrum-rating-icon-width", - "--spectrum-rating-indicator-border-radius", - "--spectrum-rating-indicator-height", - "--spectrum-rating-indicator-width" + "--spectrum-rating-top-to-content-area", + "--spectrum-rating-top-to-content-area-medium", + "--spectrum-rating-top-to-content-area-small", + "--spectrum-rating-width", + "--spectrum-rating-width-medium", + "--spectrum-rating-width-small" ], "global": [ "--spectrum-accent-content-color-default", "--spectrum-accent-content-color-down", "--spectrum-accent-content-color-hover", - "--spectrum-accent-content-color-key-focus", - "--spectrum-border-width-200", - "--spectrum-component-top-to-workflow-icon-100", - "--spectrum-corner-radius-100", + "--spectrum-component-size-difference-down", + "--spectrum-component-size-minimum-perspective-down", + "--spectrum-corner-radius-medium-size-medium", + "--spectrum-corner-radius-medium-size-small", "--spectrum-disabled-content-color", "--spectrum-focus-indicator-color", "--spectrum-focus-indicator-gap", "--spectrum-focus-indicator-thickness", - "--spectrum-neutral-subdued-content-color-default", - "--spectrum-neutral-subdued-content-color-down", - "--spectrum-neutral-subdued-content-color-hover", - "--spectrum-neutral-subdued-content-color-key-focus", - "--spectrum-workflow-icon-size-100" - ], - "system-theme": [ - "--system-rating-icon-color-default", - "--system-rating-icon-color-down", - "--system-rating-icon-color-hover", - "--system-rating-icon-color-key-focus", - "--system-rating-indicator-border-radius" + "--spectrum-neutral-content-color-default", + "--spectrum-neutral-content-color-down", + "--spectrum-neutral-content-color-hover", + "--spectrum-spacing-75", + "--spectrum-workflow-icon-size-100", + "--spectrum-workflow-icon-size-75" ], "passthroughs": [], "high-contrast": [ @@ -114,7 +119,6 @@ "--highcontrast-rating-emphasized-icon-color-down", "--highcontrast-rating-emphasized-icon-color-hover", "--highcontrast-rating-focus-color-outline", - "--highcontrast-rating-icon-color-disabled", - "--highcontrast-rating-icon-color-key-focus" + "--highcontrast-rating-icon-color-disabled" ] } diff --git a/components/rating/index.css b/components/rating/index.css index 02c76194916..8e53c47d3e0 100644 --- a/components/rating/index.css +++ b/components/rating/index.css @@ -1,5 +1,5 @@ /*! - * Copyright 2024 Adobe. All rights reserved. + * Copyright 2025 Adobe. All rights reserved. * * This file is licensed to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. You may obtain a copy @@ -11,59 +11,67 @@ * governing permissions and limitations under the License. */ -@import "./themes/spectrum-two.css"; - .spectrum-Rating { + --spectrum-rating-height: var(--spectrum-rating-height-medium); + --spectrum-rating-width: var(--spectrum-rating-width-medium); + /* Icon */ --spectrum-rating-icon-height: var(--spectrum-workflow-icon-size-100); --spectrum-rating-icon-width: var(--spectrum-workflow-icon-size-100); + --spectrum-rating-icon-color-default: var(--spectrum-neutral-content-color-default); + --spectrum-rating-icon-color-hover: var(--spectrum-neutral-content-color-hover); + --spectrum-rating-icon-color-down: var(--spectrum-neutral-content-color-down); /* Focus ring */ - --spectrum-rating-border-radius: var(--spectrum-corner-radius-100); + --spectrum-rating-border-radius: var(--spectrum-corner-radius-medium-size-medium); --spectrum-rating-focus-indicator-thickness: var(--spectrum-focus-indicator-thickness); --spectrum-rating-focus-indicator-color: var(--spectrum-focus-indicator-color); --spectrum-rating-focus-indicator-gap: var(--spectrum-focus-indicator-gap); - /* Spacing (top/bottom edge to icon) */ - --spectrum-rating-icon-spacing-vertical-top: var(--spectrum-component-top-to-workflow-icon-100); - - /* Indicator height */ - --spectrum-rating-indicator-height: var(--spectrum-border-width-200); + /* Spacing */ + --spectrum-rating-icon-spacing: var(--spectrum-spacing-75); + --spectrum-rating-top-to-content-area: var(--spectrum-rating-top-to-content-area-medium); + --spectrum-rating-bottom-to-content-area: var(--spectrum-rating-bottom-to-content-area-medium); + --spectrum-rating-edge-to-content-area: var(--spectrum-rating-edge-to-content-area-medium); /* Colors */ /* selected + emphasized */ --spectrum-rating-emphasized-icon-color-default: var(--spectrum-accent-content-color-default); --spectrum-rating-emphasized-icon-color-hover: var(--spectrum-accent-content-color-hover); --spectrum-rating-emphasized-icon-color-down: var(--spectrum-accent-content-color-down); - --spectrum-rating-emphasized-icon-color-key-focus: var(--spectrum-accent-content-color-key-focus); + --spectrum-rating-emphasized-icon-color-key-focus: var(--spectrum-accent-content-color-default); /* Disabled */ --spectrum-rating-icon-color-disabled: var(--spectrum-disabled-content-color); - --spectrum-rating-icon-count: var(--spectrum-rating-icon-count); +} +.spectrum-Rating { + box-sizing: border-box; position: relative; display: inline-flex; flex: 0 0 auto; - + justify-content: center; + align-items: center; gap: var(--mod-rating-icon-spacing, var(--spectrum-rating-icon-spacing)); + padding-block: var(--mod-rating-top-to-content-area, var(--spectrum-rating-top-to-content-area)) var(--mod-rating-bottom-to-content-area, var(--spectrum-rating-bottom-to-content-area)); + padding-inline: var(--mod-rating-edge-to-content-area, var(--spectrum-rating-edge-to-content-area)); - inline-size: calc((var(--mod-rating-icon-width, var(--spectrum-rating-icon-width)) + var(--mod-rating-icon-spacing, var(--spectrum-rating-icon-spacing))) * var(--mod-rating-icon-count, var(--spectrum-rating-icon-count))); border-radius: var(--mod-rating-border-radius, var(--spectrum-rating-border-radius)); - padding-inline: calc((var(--mod-rating-icon-spacing, var(--spectrum-rating-icon-spacing)) + var(--mod-rating-focus-indicator-gap, var(--spectrum-rating-focus-indicator-gap))) - 1.5px); - cursor: pointer; - &.is-focused { - box-shadow: 0 0 0 var(--mod-rating-focus-indicator-thickness, var(--spectrum-rating-focus-indicator-thickness)) var(--mod-rating-focus-indicator-color, var(--spectrum-rating-focus-indicator-color)); + block-size: var(--mod-rating-height, var(--spectrum-rating-height)); + inline-size: var(--mod-rating-width, var(--spectrum-rating-width)); - .spectrum-Rating-icon { - color: var(--highcontrast-rating-icon-color-key-focus, var(--mod-rating-icon-color-key-focus, var(--spectrum-rating-icon-color-key-focus))); + &:not(.is-readOnly) { + .spectrum-Rating-input:not(:disabled) ~ .spectrum-Rating-icon:active { + transform: perspective(var(--spectrum-component-size-minimum-perspective-down)) translateZ(var(--spectrum-component-size-difference-down)); } + } - .spectrum-Rating-icon.is-selected { - color: var(--highcontrast-rating-icon-color-key-focus, var(--mod-rating-icon-color-key-focus, var(--spectrum-rating-icon-color-key-focus))); - } + &.is-focused { + outline: var(--mod-rating-focus-indicator-thickness, var(--spectrum-rating-focus-indicator-thickness)) solid var(--mod-rating-focus-indicator-color, var(--spectrum-rating-focus-indicator-color)); + outline-offset: var(--mod-rating-focus-indicator-gap, var(--spectrum-rating-focus-indicator-gap)); } &:hover { @@ -81,12 +89,6 @@ color: var(--mod-rating-icon-color-down, var(--spectrum-rating-icon-color-down)); } - /* Show which star is currently selected */ - .spectrum-Rating-icon.is-currentValue::after { - /* Match the color of the star */ - background: currentColor; - } - /* When the entire component is hovered, show all solid icons */ .spectrum-Rating-starActive { display: block; @@ -104,6 +106,21 @@ } } +.spectrum-Rating--sizeS { + --mod-rating-height: var(--spectrum-rating-height-small); + --mod-rating-width: var(--spectrum-rating-width-small); + --mod-rating-top-to-content-area: var(--spectrum-rating-top-to-content-area-small); + --mod-rating-edge-to-content-area: var(--spectrum-rating-edge-to-content-area-small); + --mod-rating-bottom-to-content-area: var(--spectrum-rating-bottom-to-content-area-small); + + /* Icon */ + --mod-rating-icon-height: var(--spectrum-workflow-icon-size-75); + --mod-rating-icon-width: var(--spectrum-workflow-icon-size-75); + + /* Focus ring */ + --mod-rating-border-radius: var(--spectrum-corner-radius-medium-size-small); +} + .spectrum-Rating-input { position: absolute; z-index: 0; @@ -115,12 +132,18 @@ } .spectrum-Rating-icon { + --spectrum-rating-icon-fill: var(--mod-rating-icon-fill, 100%); + position: relative; background-size: contain; background-repeat: no-repeat; inline-size: var(--mod-rating-icon-width, var(--spectrum-rating-icon-width)); block-size: var(--mod-rating-icon-height, var(--spectrum-rating-icon-height)); - padding-block: calc(var(--mod-rating-icon-spacing-vertical-top, var(--spectrum-rating-icon-spacing-vertical-top)) + var(--mod-rating-focus-indicator-gap, var(--spectrum-rating-focus-indicator-gap))); + + svg { + inline-size: var(--mod-rating-icon-width, var(--spectrum-rating-icon-width)); + block-size: var(--mod-rating-icon-height, var(--spectrum-rating-icon-height)); + } .spectrum-Rating-starActive { display: none; @@ -128,6 +151,9 @@ .spectrum-Rating-starInactive { display: block; + position: absolute; + inset-block-start: 0; + z-index: 0; } &.is-selected { @@ -138,17 +164,14 @@ .spectrum-Rating-starInactive { display: none; } - } - &.is-currentValue::after { - border-radius: var(--mod-rating-indicator-border-radius, var(--spectrum-rating-indicator-border-radius)); - content: ""; - block-size: var(--mod-rating-indicator-height, var(--spectrum-rating-indicator-height)); - inline-size: var(--spectrum-rating-indicator-width); + &.is-partial .spectrum-Rating-starActive { + mask-image: linear-gradient(to right, black var(--spectrum-rating-icon-fill), transparent var(--spectrum-rating-icon-fill)); + } - /* position the indicator relative to the element's total bottom size (including bottom padding) */ - inset-block-end: calc((var(--mod-rating-focus-indicator-gap, var(--spectrum-rating-focus-indicator-gap)) * 2) - 1px); - position: absolute; + &.is-partial .spectrum-Rating-starInactive { + display: block; + } } /* All stars following the hovered star */ @@ -235,7 +258,6 @@ @media (forced-colors: active) { .spectrum-Rating { - --highcontrast-rating-icon-color-key-focus: CanvasText; --highcontrast-rating-icon-color-disabled: GrayText; --highcontrast-rating-emphasized-icon-color-default: Highlight; --highcontrast-rating-emphasized-icon-color-hover: Highlight; @@ -245,13 +267,5 @@ &.is-focused { outline: 1px solid var(--highcontrast-rating-focus-color-outline); } - - &:hover .spectrum-Rating-icon.is-currentValue::after { - background-color: var(--highcontrast-rating-icon-color-key-focus); - } - } - - .spectrum-Rating--emphasized:hover .spectrum-Rating-icon.is-currentValue::after { - background-color: var(--highcontrast-rating-emphasized-icon-color-default); } } diff --git a/components/rating/package.json b/components/rating/package.json index 74de124a190..239991ff1a4 100644 --- a/components/rating/package.json +++ b/components/rating/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/rating", - "version": "6.2.0", + "version": "7.0.0-next.2", "description": "The Spectrum CSS rating component", "license": "Apache-2.0", "author": "Adobe", @@ -19,15 +19,13 @@ "./package.json": "./package.json", "./dist/*": "./dist/*", "./index.css": "./dist/index.css", - "./index-*.css": "./dist/index-*.css", "./metadata.json": "./dist/metadata.json", - "./themes/*": "./dist/themes/*", "./stories/*": "./stories/*" }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/icon": ">=9.0.0 <10.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/icon": ">=10.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/icon": { @@ -38,8 +36,8 @@ } }, "devDependencies": { - "@spectrum-css/icon": "9.2.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/icon": "10.0.0-next.3", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/rating/stories/rating.stories.js b/components/rating/stories/rating.stories.js index e9315f918c2..a7def3b170c 100644 --- a/components/rating/stories/rating.stories.js +++ b/components/rating/stories/rating.stories.js @@ -1,5 +1,6 @@ +import { Sizes } from "@spectrum-css/preview/decorators"; import { disableDefaultModes } from "@spectrum-css/preview/modes"; -import { isDisabled, isEmphasized, isFocused, isReadOnly } from "@spectrum-css/preview/types"; +import { isDisabled, isEmphasized, isFocused, isReadOnly, size } from "@spectrum-css/preview/types"; import metadata from "../dist/metadata.json"; import packageJson from "../package.json"; import { RatingGroup } from "./rating.test.js"; @@ -12,15 +13,17 @@ import { Template } from "./template.js"; * - All active stars have the class `is-selected` applied. * - The current value (the last active star) has the class `is-currentValue` applied. * - When the rating receives focus, the class `is-focused` should be added to the component's root element (`.spectrum-Rating`). + * - A rating may have a partially filled star. The width and fill of this star is controlled by adding `.is-partial` to the parent `span` with classes of `spectrum-Rating-icon` and `is-selected` and then setting `--mod-rating-icon-fill` to the necessary fill percentage (e.g. `50%`). */ export default { title: "Rating", component: "Rating", argTypes: { isEmphasized, - isFocused, isDisabled, isReadOnly, + isFocused, + size: size(["s", "m"]), max: { name: "Maximum value", description: "The total number of stars. Star ratings should always have 5 available stars. This shouldn't be increased or decreased to fit various containers.", @@ -43,12 +46,26 @@ export default { }, control: { type: "number" }, }, + withTooltip: { + name: "With Tooltip", + description: + "A tooltip indicating whether a user is editing or clearing a rating may be displayed.", + type: { name: "boolean" }, + table: { + type: { summary: "boolean" }, + category: "Component", + }, + control: "boolean", + }, }, args: { rootClass: "spectrum-Rating", isDisabled: false, isEmphasized: false, isReadOnly: false, + isFocused: false, + withTooltip: false, + size: "m", max: 5, value: 3, }, @@ -59,13 +76,15 @@ export default { }, packageJson, metadata, + status: { + type: "migrated", + }, }, + tags: ["migrated"], }; /** - * A initial value of three is used for the following examples, to demonstrate both active and inactive stars. - * When hovering over a rating component that has a previously entered value, an underline appears under the - * current selection to provide context. + * An initial value of three is used for the following examples, to demonstrate both active and inactive stars. */ export const Default = RatingGroup.bind({}); Default.args = {}; @@ -82,9 +101,17 @@ WithForcedColors.parameters = { // ********* DOCS ONLY ********* // -/** - * A non-interactive rating. - */ +export const Sizing = (args, context) => Sizes({ + Template, + withBorder: false, + withHeading: false, + ...args, +}, context); +Sizing.tags = ["!dev"]; +Sizing.parameters = { + chromatic: { disableSnapshot: true }, +}; + export const ReadOnly = Template.bind({}); ReadOnly.storyName = "Read-only"; ReadOnly.tags = ["!dev"]; @@ -123,3 +150,54 @@ Disabled.args = { Disabled.parameters = { chromatic: { disableSnapshot: true }, }; + +export const Focused = Template.bind({}); +Focused.tags = ["!dev"]; +Focused.args = { + isFocused: true, +}; +Focused.parameters = { + chromatic: { disableSnapshot: true }, +}; + +/** + * When a selected star is hovered, the color of the star is slightly darker. + */ +export const Hovered = Template.bind({}); +Hovered.tags = ["!dev"]; +Hovered.args = { + value: 5, + isHovered: true, + isEmphasized: true, +}; +Hovered.parameters = { + chromatic: { disableSnapshot: true }, +}; + +/** + * A tooltip may be displayed to a user indicating whether interacting with the component will clear or edit the rating. + */ +export const WithTooltip = Template.bind({}); +WithTooltip.tags = ["!dev"]; +WithTooltip.args = { + withTooltip: true, +}; +WithTooltip.parameters = { + chromatic: { disableSnapshot: true }, +}; + +/** + * To implement a partially filled rating star, the star must have the `is-selected` class applied to its parent and the `is-partial` and `spectrum-Rating-starActive` classes applied. The fill can then be adjusted by setting `--mod-rating-icon-fill` to a valid percentage (e.g. 50%). + */ +export const WithPartial = Template.bind({}); +WithPartial.tags = ["!dev"]; +WithPartial.args = { + isPartial: true, + value: 5, + customStyles: { + "--mod-rating-icon-fill": "50%" + } +}; +WithPartial.parameters = { + chromatic: { disableSnapshot: true }, +}; diff --git a/components/rating/stories/rating.test.js b/components/rating/stories/rating.test.js index 3de9373689b..74769474070 100644 --- a/components/rating/stories/rating.test.js +++ b/components/rating/stories/rating.test.js @@ -25,5 +25,17 @@ export const RatingGroup = Variants({ testHeading: "Read-only", isReadOnly: true, }, + { + testHeading: "With tooltip", + withTooltip: true, + wrapperStyles: { + "padding-top": "35px" + } + }, + { + testHeading: "Hover", + value: 5, + isHovered: true, + }, ] }); diff --git a/components/rating/stories/template.js b/components/rating/stories/template.js index 47ea5c5f61a..3f3035097c2 100644 --- a/components/rating/stories/template.js +++ b/components/rating/stories/template.js @@ -1,14 +1,13 @@ import { Template as Icon } from "@spectrum-css/icon/stories/template.js"; +import { Template as Tooltip } from "@spectrum-css/tooltip/stories/template.js"; import { getRandomId } from "@spectrum-css/preview/decorators"; -import { html } from "lit"; +import { html, nothing } from "lit"; import { classMap } from "lit/directives/class-map.js"; import { ifDefined } from "lit/directives/if-defined.js"; import { repeat } from "lit/directives/repeat.js"; +import { styleMap } from "lit/directives/style-map.js"; import "../index.css"; -import "../themes/spectrum.css"; -/* Must be imported last */ -import "../themes/express.css"; export const Template = ({ rootClass = "spectrum-Rating", @@ -16,9 +15,14 @@ export const Template = ({ value = 0, isReadOnly = false, isFocused = false, + isHovered = false, isDisabled = true, isEmphasized = false, + withTooltip = false, + isPartial = false, + size = "s", customClasses = [], + customStyles = {}, id = getRandomId("rating"), } = {}, context = {}) => { const { updateArgs } = context; @@ -30,7 +34,10 @@ export const Template = ({ "is-disabled": isDisabled, "is-readOnly": isReadOnly, "is-focused": isFocused, + "is-hover": isHovered, [`${rootClass}--emphasized`]: isEmphasized, + [`${rootClass}--size${size?.toUpperCase()}`]: + typeof size !== "undefined", ...customClasses.reduce((a, c) => ({ ...a, [c]: true }), {}), })} id=${ifDefined(id)} @@ -41,6 +48,14 @@ export const Template = ({ updateArgs({ isFocused: false }); }} > + ${withTooltip + ? Tooltip({ + label: "Edit rating", + isOpen: true, + placement: "top", + showOnHover: true, + }, context) + : nothing} ${Icon({ - iconName: "Star", + iconName: "StarFilled", setName: "workflow", customClasses: [`${rootClass}-starActive`], }, context)} ${Icon({ - iconName: "StarOutline", + iconName: "Star", setName: "workflow", customClasses: [`${rootClass}-starInactive`], }, context)} diff --git a/components/rating/themes/express.css b/components/rating/themes/express.css deleted file mode 100644 index 1a0d5c792b2..00000000000 --- a/components/rating/themes/express.css +++ /dev/null @@ -1,25 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--express */ - -@import "./spectrum.css"; - -@container style(--system: express) { - .spectrum-Rating { - --spectrum-rating-icon-color-default: var(--spectrum-neutral-content-color-default); - --spectrum-rating-icon-color-hover: var(--spectrum-neutral-content-color-hover); - --spectrum-rating-icon-color-down: var(--spectrum-neutral-content-color-down); - --spectrum-rating-icon-color-key-focus: var(--spectrum-neutral-content-color-key-focus); - } -} diff --git a/components/rating/themes/spectrum-two.css b/components/rating/themes/spectrum-two.css deleted file mode 100644 index 0c2a8df9260..00000000000 --- a/components/rating/themes/spectrum-two.css +++ /dev/null @@ -1,23 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -@container style(--system: spectrum) { - .spectrum-Rating { - --spectrum-rating-icon-color-default: var(--spectrum-neutral-subdued-content-color-default); - --spectrum-rating-icon-color-hover: var(--spectrum-neutral-subdued-content-color-hover); - --spectrum-rating-icon-color-down: var(--spectrum-neutral-subdued-content-color-down); - --spectrum-rating-icon-color-key-focus: var(--spectrum-neutral-subdued-content-color-key-focus); - - --spectrum-rating-indicator-border-radius: 2px; - } -} diff --git a/components/rating/themes/spectrum.css b/components/rating/themes/spectrum.css deleted file mode 100644 index c99df8e652f..00000000000 --- a/components/rating/themes/spectrum.css +++ /dev/null @@ -1,22 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--legacy */ - -@import "./spectrum-two.css"; - -@container style(--system: legacy) { - .spectrum-Rating { - --spectrum-rating-indicator-border-radius: var(--spectrum-corner-radius-75); - } -} diff --git a/components/search/CHANGELOG.md b/components/search/CHANGELOG.md index b5bca280d4b..8e37c373184 100644 --- a/components/search/CHANGELOG.md +++ b/components/search/CHANGELOG.md @@ -1,5 +1,55 @@ # Change log +## 9.0.0-next.3 + +### Major Changes + +📝 [#4115](https://github.com/adobe/spectrum-css/pull/4115) [`e467fe0`](https://github.com/adobe/spectrum-css/commit/e467fe00cfef00311b77ec4b32c6ab1791b6923a) Thanks [@aramos-adobe](https://github.com/aramos-adobe)! + +## S2 Collapsed search field + +The search component allows for a minimized state where the search field is collapsed to a button. + +### Anatomy + +The collapsed state consists of a single action button that has a hover, keyboard focused, and disabled state. This state is triggered by the `is-collapsed` class on the search component. When the search field is in this state, the textfield is hidden and the search button is displayed. The button can be hovered and focused, and will expand the search field when clicked. + +### Usage + +The collapsed state is used to reduce the amount of space taken up by the search field. It is most commonly used next a filter button to allow users to quickly search and filter content. + +## 9.0.0-next.2 + +### Major Changes + +📝 [#2673](https://github.com/adobe/spectrum-css/pull/2673) [`89a3f2b`](https://github.com/adobe/spectrum-css/commit/89a3f2bfeed257a5eefeef229efaa3cc7555980c) Thanks [@mdt2](https://github.com/mdt2)! + +#### Search S2 migration + +Search now uses Spectrum 2 tokens and specifications. The following items have been adjusted: + +- Quiet variant has been deprecated and code removed (including removal of the custom property `--mod-search-quiet-button-offset`). +- Updates to colors, corner rounding, and spacing. +- Custom property mod adjustments: + - Added `--mod-search-top-to-icon`. + - Removed `--mod-workflow-icon-size-100`. + +## 9.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + +## 9.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`a25e0a9`](https://github.com/adobe/spectrum-css/commit/a25e0a99e5a4736ab4e607e00739343101a2633b)]: + - @spectrum-css/icon@10.0.0-next.0 + - @spectrum-css/clearbutton@8.0.0-next.0 + - @spectrum-css/textfield@9.0.0-next.0 + ## 8.2.0 ### Minor Changes @@ -12,7 +62,9 @@ Ensure accurate exports are present for each component. Specifically, adding `th ### Patch Changes -- [#3658](https://github.com/adobe/spectrum-css/pull/3658) [`e9fde67`](https://github.com/adobe/spectrum-css/commit/e9fde67bf341798a6ab34f227b2e7a417d1e5da7) Thanks [@rise-erpelding](https://github.com/rise-erpelding)! - Change S2 theme border color to gray-800 on keyfocus per design request in order to align with text field. +- [#3658](https://github.com/adobe/spectrum-css/pull/3658) [`e9fde67`](https://github.com/adobe/spectrum-css/commit/e9fde67bf341798a6ab34f227b2e7a417d1e5da7) Thanks [@rise-erpelding](https://github.com/rise-erpelding)! + +Change S2 theme border color to gray-800 on keyfocus per design request in order to align with text field. ## 8.1.1 diff --git a/components/search/dist/metadata.json b/components/search/dist/metadata.json index b701431ddf2..0d4bd84abfe 100644 --- a/components/search/dist/metadata.json +++ b/components/search/dist/metadata.json @@ -6,8 +6,6 @@ ".spectrum-Search .spectrum-Search-clearButton .spectrum-ClearButton-fill", ".spectrum-Search .spectrum-Search-textfield", ".spectrum-Search .spectrum-Search-textfield .spectrum-Search-input", - ".spectrum-Search--quiet", - ".spectrum-Search--quiet .spectrum-Search-input", ".spectrum-Search--sizeL", ".spectrum-Search--sizeS", ".spectrum-Search--sizeXL", @@ -24,13 +22,12 @@ ".spectrum-Search-textfield.is-focused:hover .spectrum-Search-icon", ".spectrum-Search-textfield.is-keyboardFocused .spectrum-Search-icon", ".spectrum-Search-textfield:hover .spectrum-Search-icon", + ".spectrum-Search.is-collapsed", ".spectrum-Search.is-disabled .spectrum-Search-clearButton", - ".spectrum-Search.spectrum-Search--sizeL", - ".spectrum-Search.spectrum-Search--sizeM", - ".spectrum-Search.spectrum-Search--sizeS", - ".spectrum-Search.spectrum-Search--sizeXL", - ".spectrum-Search:not(.spectrum-Search--quiet) .spectrum-Search-icon", - ".spectrum-Search:not(.spectrum-Search--quiet) .spectrum-Search-input" + ".spectrum-Search.is-expanded", + ".spectrum-Search:lang(ja)", + ".spectrum-Search:lang(ko)", + ".spectrum-Search:lang(zh)" ], "modifiers": [ "--mod-search-background-color", @@ -46,6 +43,7 @@ "--mod-search-border-width", "--mod-search-bottom-to-text", "--mod-search-button-inline-size", + "--mod-search-collapsed-animation-duration", "--mod-search-color-default", "--mod-search-color-disabled", "--mod-search-color-focus", @@ -65,6 +63,7 @@ "--mod-search-min-inline-size", "--mod-search-text-to-icon", "--mod-search-to-help-text", + "--mod-search-top-to-icon", "--mod-search-top-to-text" ], "component": [ @@ -81,6 +80,7 @@ "--spectrum-search-border-width", "--spectrum-search-bottom-to-text", "--spectrum-search-button-inline-size", + "--spectrum-search-collapsed-animation-duration", "--spectrum-search-color", "--spectrum-search-color-default", "--spectrum-search-color-disabled", @@ -102,33 +102,48 @@ "--spectrum-search-min-inline-size", "--spectrum-search-text-to-icon", "--spectrum-search-to-help-text", + "--spectrum-search-top-to-icon", "--spectrum-search-top-to-text" ], "global": [ - "--spectrum-border-width-100", + "--spectrum-animation-duration-800", + "--spectrum-border-width-200", + "--spectrum-cjk-line-height-100", "--spectrum-component-bottom-to-text-100", - "--spectrum-component-edge-to-visual-100", - "--spectrum-component-edge-to-visual-200", - "--spectrum-component-edge-to-visual-300", - "--spectrum-component-edge-to-visual-75", + "--spectrum-component-bottom-to-text-200", + "--spectrum-component-bottom-to-text-300", + "--spectrum-component-bottom-to-text-75", "--spectrum-component-height-100", "--spectrum-component-height-200", "--spectrum-component-height-300", "--spectrum-component-height-75", + "--spectrum-component-pill-edge-to-visual-100", + "--spectrum-component-pill-edge-to-visual-200", + "--spectrum-component-pill-edge-to-visual-300", + "--spectrum-component-pill-edge-to-visual-75", "--spectrum-component-top-to-text-100", - "--spectrum-corner-radius-100", + "--spectrum-component-top-to-text-200", + "--spectrum-component-top-to-text-300", + "--spectrum-component-top-to-text-75", + "--spectrum-component-top-to-workflow-icon-100", + "--spectrum-component-top-to-workflow-icon-200", + "--spectrum-component-top-to-workflow-icon-300", + "--spectrum-component-top-to-workflow-icon-75", + "--spectrum-corner-radius-full", "--spectrum-default-font-style", "--spectrum-disabled-border-color", "--spectrum-disabled-content-color", - "--spectrum-field-edge-to-visual-quiet", "--spectrum-field-width", "--spectrum-focus-indicator-color", "--spectrum-focus-indicator-gap", "--spectrum-focus-indicator-thickness", + "--spectrum-font-size-100", + "--spectrum-font-size-200", + "--spectrum-font-size-300", + "--spectrum-font-size-75", "--spectrum-gray-25", "--spectrum-gray-300", - "--spectrum-gray-500", - "--spectrum-gray-600", + "--spectrum-gray-400", "--spectrum-gray-800", "--spectrum-gray-900", "--spectrum-help-text-to-component", @@ -149,28 +164,6 @@ "--spectrum-workflow-icon-size-300", "--spectrum-workflow-icon-size-75" ], - "system-theme": [ - "--system-search-background-color", - "--system-search-background-color-disabled", - "--system-search-border-color-default", - "--system-search-border-color-disabled", - "--system-search-border-color-focus", - "--system-search-border-color-focus-hover", - "--system-search-border-color-hover", - "--system-search-border-color-key-focus", - "--system-search-border-radius", - "--system-search-edge-to-visual", - "--system-search-quiet-background-color-disabled", - "--system-search-quiet-border-color-disabled", - "--system-search-size-l-border-radius", - "--system-search-size-l-edge-to-visual", - "--system-search-size-m-border-radius", - "--system-search-size-m-edge-to-visual", - "--system-search-size-s-border-radius", - "--system-search-size-s-edge-to-visual", - "--system-search-size-xl-border-radius", - "--system-search-size-xl-edge-to-visual" - ], "passthroughs": [ "--mod-textfield-background-color", "--mod-textfield-background-color-disabled", @@ -187,6 +180,7 @@ "--mod-textfield-focus-indicator-width", "--mod-textfield-font-family", "--mod-textfield-font-weight", + "--mod-textfield-placeholder-font-size", "--mod-textfield-text-color-default", "--mod-textfield-text-color-disabled", "--mod-textfield-text-color-focus", diff --git a/components/search/index.css b/components/search/index.css index 3f98f73e145..675279bb8f0 100644 --- a/components/search/index.css +++ b/components/search/index.css @@ -1,5 +1,5 @@ /*! - * Copyright 2024 Adobe. All rights reserved. + * Copyright 2025 Adobe. All rights reserved. * * This file is licensed to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. You may obtain a copy @@ -11,9 +11,19 @@ * governing permissions and limitations under the License. */ -@import "./themes/spectrum-two.css"; - .spectrum-Search { + /* Background / Border */ + /* stylelint-disable spectrum-tools/no-unused-custom-properties -- used to assign Textfield mods */ + --spectrum-search-background-color: var(--spectrum-gray-25); + --spectrum-search-border-color-default: var(--spectrum-gray-300); + --spectrum-search-border-color-hover: var(--spectrum-gray-400); + --spectrum-search-border-color-focus: var(--spectrum-gray-800); + --spectrum-search-border-color-focus-hover: var(--spectrum-gray-900); + --spectrum-search-border-color-key-focus: var(--spectrum-gray-800); + --spectrum-search-border-width: var(--spectrum-border-width-200); + --spectrum-search-border-radius: var(--spectrum-corner-radius-full); + /* stylelint-enable spectrum-tools/no-unused-custom-properties */ + /* Size / Spacing */ --spectrum-search-inline-size: var(--spectrum-field-width); --spectrum-search-block-size: var(--spectrum-component-height-100); @@ -25,33 +35,50 @@ --spectrum-search-to-help-text: var(--spectrum-help-text-to-component); --spectrum-search-top-to-text: var(--spectrum-component-top-to-text-100); --spectrum-search-bottom-to-text: var(--spectrum-component-bottom-to-text-100); + --spectrum-search-edge-to-visual: var(--spectrum-component-pill-edge-to-visual-100); + --spectrum-search-top-to-icon: var(--spectrum-component-top-to-workflow-icon-100); /* Focus Indicator */ + /* stylelint-disable spectrum-tools/no-unused-custom-properties -- used to assign Textfield mods */ --spectrum-search-focus-indicator-thickness: var(--spectrum-focus-indicator-thickness); --spectrum-search-focus-indicator-gap: var(--spectrum-focus-indicator-gap); --spectrum-search-focus-indicator-color: var(--spectrum-focus-indicator-color); + /* stylelint-enable spectrum-tools/no-unused-custom-properties */ /* Font / Color */ + /* stylelint-disable-next-line spectrum-tools/no-unused-custom-properties -- used to assign Textfield mods */ --spectrum-search-font-family: var(--spectrum-sans-font-family-stack); + /* stylelint-disable-next-line spectrum-tools/no-unused-custom-properties -- used to assign Textfield mods */ --spectrum-search-font-weight: var(--spectrum-regular-font-weight); --spectrum-search-font-style: var(--spectrum-default-font-style); --spectrum-search-line-height: var(--spectrum-line-height-100); - --spectrum-search-color-default: var(--spectrum-neutral-content-color-default); --spectrum-search-color-hover: var(--spectrum-neutral-content-color-hover); --spectrum-search-color-focus: var(--spectrum-neutral-content-color-focus); --spectrum-search-color-focus-hover: var(--spectrum-neutral-content-color-focus-hover); --spectrum-search-color-key-focus: var(--spectrum-neutral-content-color-key-focus); - /* Background and Border */ - --spectrum-search-border-width: var(--spectrum-border-width-100); - /* Disabled */ --spectrum-search-color-disabled: var(--spectrum-disabled-content-color); - /* @passthrough start -- settings for nested Textfield component */ + /* stylelint-disable-next-line spectrum-tools/no-unused-custom-properties -- used to assign Textfield mods */ + --spectrum-search-background-color-disabled: var(--spectrum-gray-25); + /* stylelint-disable-next-line spectrum-tools/no-unused-custom-properties -- used to assign Textfield mods */ + --spectrum-search-border-color-disabled: var(--spectrum-disabled-border-color); + + /* Collapsed Search */ + --spectrum-search-collapsed-animation-duration: var(--spectrum-animation-duration-800); + + &:lang(ja), + &:lang(zh), + &:lang(ko) { + --spectrum-search-line-height: var(--spectrum-cjk-line-height-100); + } + + /* /* @passthrough start: nested Textfield component. */ --mod-textfield-font-family: var(--mod-search-font-family, var(--spectrum-search-font-family)); --mod-textfield-font-weight: var(--mod-search-font-weight, var(--spectrum-search-font-weight)); + --mod-textfield-placeholder-font-size: var(--spectrum-font-size-100); --mod-textfield-corner-radius: var(--mod-search-border-radius, var(--spectrum-search-border-radius)); --mod-textfield-border-width: var(--mod-search-border-width, var(--spectrum-search-border-width)); @@ -77,50 +104,68 @@ --mod-textfield-background-color: var(--mod-search-background-color, var(--spectrum-search-background-color)); --mod-textfield-background-color-disabled: var(--mod-search-background-color-disabled, var(--spectrum-search-background-color-disabled)); /* @passthrough end */ - - display: inline-block; - position: relative; - inline-size: var(--mod-search-inline-size, var(--spectrum-search-inline-size)); - min-inline-size: var(--mod-search-min-inline-size, var(--spectrum-search-min-inline-size)); - - .spectrum-HelpText { - margin-block-start: var(--mod-search-to-help-text, var(--spectrum-search-to-help-text)); - } } .spectrum-Search--sizeS { --spectrum-search-block-size: var(--spectrum-component-height-75); --spectrum-search-icon-size: var(--spectrum-workflow-icon-size-75); --spectrum-search-text-to-icon: var(--spectrum-text-to-visual-75); + --spectrum-search-edge-to-visual: var(--spectrum-component-pill-edge-to-visual-75); + --spectrum-search-top-to-icon: var(--spectrum-component-top-to-workflow-icon-75); + --spectrum-search-top-to-text: var(--spectrum-component-top-to-text-75); + --spectrum-search-bottom-to-text: var(--spectrum-component-bottom-to-text-75); + + --mod-textfield-placeholder-font-size: var(--spectrum-font-size-75); } .spectrum-Search--sizeL { --spectrum-search-block-size: var(--spectrum-component-height-200); --spectrum-search-icon-size: var(--spectrum-workflow-icon-size-200); --spectrum-search-text-to-icon: var(--spectrum-text-to-visual-200); + --spectrum-search-edge-to-visual: var(--spectrum-component-pill-edge-to-visual-200); + --spectrum-search-top-to-icon: var(--spectrum-component-top-to-workflow-icon-200); + --spectrum-search-top-to-text: var(--spectrum-component-top-to-text-200); + --spectrum-search-bottom-to-text: var(--spectrum-component-bottom-to-text-200); + + --mod-textfield-placeholder-font-size: var(--spectrum-font-size-200); } .spectrum-Search--sizeXL { --spectrum-search-block-size: var(--spectrum-component-height-300); --spectrum-search-icon-size: var(--spectrum-workflow-icon-size-300); --spectrum-search-text-to-icon: var(--spectrum-text-to-visual-300); + --spectrum-search-edge-to-visual: var(--spectrum-component-pill-edge-to-visual-300); + --spectrum-search-top-to-icon: var(--spectrum-component-top-to-workflow-icon-300); + --spectrum-search-top-to-text: var(--spectrum-component-top-to-text-300); + --spectrum-search-bottom-to-text: var(--spectrum-component-bottom-to-text-300); + + --mod-textfield-placeholder-font-size: var(--spectrum-font-size-300); } -@media (forced-colors: active) { - .spectrum-Search .spectrum-Search-textfield, - .spectrum-Search .spectrum-Search-textfield .spectrum-Search-input { - --highcontrast-search-color-default: CanvasText; - --highcontrast-search-color-hover: CanvasText; - --highcontrast-search-color-focus: CanvasText; - --highcontrast-search-color-disabled: GrayText; +/* Standard / Default */ +.spectrum-Search { + display: inline-block; + position: relative; + inline-size: var(--mod-search-inline-size, var(--spectrum-search-inline-size)); + min-inline-size: var(--mod-search-min-inline-size, var(--spectrum-search-min-inline-size)); + + .spectrum-HelpText { + margin-block-start: var(--mod-search-to-help-text, var(--spectrum-search-to-help-text)); } - .spectrum-Search .spectrum-Search-clearButton { - .spectrum-ClearButton-fill { - /* Avoid button background color overlapping on border. */ - forced-color-adjust: none; - background-color: transparent; - } + /* Animation for collapsible search expansion */ + &.is-collapsed { + transition: inline-size var(--mod-search-collapsed-animation-duration, var(--spectrum-search-collapsed-animation-duration)) ease-in-out; + inline-size: var(--mod-search-button-inline-size, var(--spectrum-search-block-size)); + min-inline-size: var(--mod-search-button-inline-size, var(--spectrum-search-block-size)); + transform-origin: left center; + } + + &.is-expanded { + transition: inline-size var(--mod-search-collapsed-animation-duration, var(--spectrum-search-collapsed-animation-duration)) ease-in-out; + inline-size: var(--mod-search-inline-size, var(--spectrum-search-inline-size)); + min-inline-size: auto; + transform-origin: left center; } } @@ -149,7 +194,8 @@ display: block; position: absolute; inset-block: 0; - margin-block: auto; + inset-inline-start: var(--mod-search-edge-to-visual, var(--spectrum-search-edge-to-visual)); + margin-block-start: var(--mod-search-top-to-icon, var(--spectrum-search-top-to-icon)); color: var(--spectrum-search-color); .spectrum-Search-textfield:hover & { @@ -182,6 +228,8 @@ block-size: var(--mod-search-block-size, var(--spectrum-search-block-size)); padding-block-start: calc(var(--mod-search-top-to-text, var(--spectrum-search-top-to-text)) - var(--mod-search-border-width, var(--spectrum-search-border-width))); padding-block-end: calc(var(--mod-search-bottom-to-text, var(--spectrum-search-bottom-to-text)) - var(--mod-search-border-width, var(--spectrum-search-border-width))); + padding-inline-start: calc(var(--mod-search-edge-to-visual, var(--spectrum-search-edge-to-visual)) - var(--mod-search-border-width, var(--spectrum-search-border-width)) + var(--mod-search-icon-size, var(--spectrum-search-icon-size)) + var(--mod-search-text-to-icon, var(--spectrum-search-text-to-icon))); + padding-inline-end: calc(var(--mod-search-button-inline-size, var(--spectrum-search-button-inline-size)) - var(--mod-search-border-width, var(--spectrum-search-border-width))); font-style: var(--mod-search-font-style, var(--spectrum-search-font-style)); line-height: var(--mod-search-line-height, var(--spectrum-search-line-height)); @@ -193,32 +241,20 @@ } } -/* Standard / Default Only */ -.spectrum-Search:not(.spectrum-Search--quiet) { - .spectrum-Search-icon { - inset-inline-start: var(--mod-search-edge-to-visual, var(--spectrum-search-edge-to-visual)); - } - - .spectrum-Search-input { - padding-inline-start: calc(var(--mod-search-edge-to-visual, var(--spectrum-search-edge-to-visual)) - var(--mod-search-border-width, var(--spectrum-search-border-width)) + var(--mod-search-icon-size, var(--spectrum-search-icon-size)) + var(--mod-search-text-to-icon, var(--spectrum-search-text-to-icon))); - padding-inline-end: var(--mod-search-button-inline-size, var(--spectrum-search-button-inline-size)); +@media (forced-colors: active) { + .spectrum-Search .spectrum-Search-textfield, + .spectrum-Search .spectrum-Search-textfield .spectrum-Search-input { + --highcontrast-search-color-default: CanvasText; + --highcontrast-search-color-hover: CanvasText; + --highcontrast-search-color-focus: CanvasText; + --highcontrast-search-color-disabled: GrayText; } -} - -/* Quiet Variant */ -.spectrum-Search--quiet { - --spectrum-search-background-color: transparent; - --spectrum-search-background-color-disabled: transparent; - --spectrum-search-border-color-disabled: var(--spectrum-disabled-border-color); - /* Added specificity, otherwise they are overridden by system specific themes. */ - --mod-search-border-radius: 0; - --mod-search-edge-to-visual: var(--spectrum-field-edge-to-visual-quiet); - - .spectrum-Search-input { - border-radius: var(--mod-search-border-radius, var(--spectrum-search-border-radius)); - padding-inline-start: calc(var(--mod-search-edge-to-visual, var(--spectrum-search-edge-to-visual)) + var(--mod-search-icon-size, var(--spectrum-search-icon-size)) + var(--mod-search-text-to-icon, var(--spectrum-search-text-to-icon))); - padding-inline-end: var(--mod-search-button-inline-size, var(--spectrum-search-button-inline-size)); - padding-block-start: var(--mod-search-top-to-text, var(--spectrum-search-top-to-text)); + .spectrum-Search .spectrum-Search-clearButton { + .spectrum-ClearButton-fill { + /* Avoid button background color overlapping on border. */ + forced-color-adjust: none; + background-color: transparent; + } } } diff --git a/components/search/package.json b/components/search/package.json index 16741af4489..580ef18f228 100644 --- a/components/search/package.json +++ b/components/search/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/search", - "version": "8.2.0", + "version": "9.0.0-next.3", "description": "The Spectrum CSS search component", "license": "Apache-2.0", "author": "Adobe", @@ -19,17 +19,15 @@ "./package.json": "./package.json", "./dist/*": "./dist/*", "./index.css": "./dist/index.css", - "./index-*.css": "./dist/index-*.css", "./metadata.json": "./dist/metadata.json", - "./themes/*": "./dist/themes/*", "./stories/*": "./stories/*" }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/clearbutton": ">=7.0.0 <8.0.0", - "@spectrum-css/icon": ">=9.0.0 <10.0.0", - "@spectrum-css/textfield": ">=8.0.0 <9.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/clearbutton": ">=8.0.0-next.0", + "@spectrum-css/icon": ">=10.0.0-next.0", + "@spectrum-css/textfield": ">=9.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/clearbutton": { @@ -46,10 +44,10 @@ } }, "devDependencies": { - "@spectrum-css/clearbutton": "7.3.0", - "@spectrum-css/icon": "9.2.0", - "@spectrum-css/textfield": "8.2.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/clearbutton": "8.0.0-next.2", + "@spectrum-css/icon": "10.0.0-next.3", + "@spectrum-css/textfield": "9.0.0-next.1", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/search/stories/search.stories.js b/components/search/stories/search.stories.js index fd3e3807c8e..5eaecf655f1 100644 --- a/components/search/stories/search.stories.js +++ b/components/search/stories/search.stories.js @@ -1,6 +1,6 @@ import { Sizes } from "@spectrum-css/preview/decorators"; import { disableDefaultModes } from "@spectrum-css/preview/modes"; -import { isDisabled, isQuiet, size } from "@spectrum-css/preview/types"; +import { isDisabled, isFocused, isHovered, isKeyboardFocused, size } from "@spectrum-css/preview/types"; import metadata from "../dist/metadata.json"; import packageJson from "../package.json"; import { SearchGroup } from "./search.test.js"; @@ -13,40 +13,67 @@ import { SearchOptions, Template } from "./template.js"; * This component contains a single input field with both a magnifying glass icon and a clear (“reset”) button displayed within it. When making use of this component, the clear button should only be displayed when the input has a value. */ export default { - title: "Search", - component: "Search", + title: "Search field", + component: "SearchField", argTypes: { size: size(["s", "m", "l", "xl"]), - isQuiet, isDisabled, - hasDescription: { - name: "Help Text", + isHovered, + showHelpText: { + name: "Show help text", description: "A search field can have help text below the field to give extra context or instruction about what a user should input. The description communicates a hint or helpful information, such as a search’s scope.", type: { name: "boolean" }, table: { type: { summary: "boolean" }, - category: "Advanced", + category: "Content", }, control: "boolean", + if: { arg: "isCollapsed", eq: false }, }, - description: { + helpTextLabel: { name: "Help text (description)", type: { name: "string" }, + table: { + type: { summary: "boolean" }, + category: "Content", + }, + control: { type: "text" }, + if: { arg: "showHelpText", eq: true }, + }, + isFocused, + isKeyboardFocused, + inputValue: { + name: "Value", + description: "When defined, this will set the value of the input, and the clear button will appear within the search field.", + type: { name: "string" }, control: { type: "text" }, table: { type: { summary: "string" }, - category: "Advanced", + category: "Content", }, - if: { arg: "hasDescription", eq: true }, + if: { arg: "isCollapsed", eq: false }, + }, + isCollapsed: { + name: "Collapsed", + type: { name: "boolean" }, + table: { + type: { summary: "boolean" }, + category: "Component", + }, + control: "boolean", }, }, args: { rootClass: "spectrum-Search", size: "m", - isQuiet: false, isDisabled: false, - hasDescription: false, - description: "Example help text. Lorem ipsum dolor sit amet.", + isFocused: false, + isHovered: false, + isKeyboardFocused: false, + showHelpText: false, + helpTextLabel: "Help text with a suggestion of what to search for", + inputValue: "", + isCollapsed: false, }, parameters: { actions: { @@ -54,6 +81,7 @@ export default { "change .spectrum-Search-input", "click .spectrum-Search-clearButton", "click .spectrum-Search-icon", + "click .spectrum-Search-actionButton", ], }, design: { @@ -62,15 +90,34 @@ export default { }, packageJson, metadata, + status: { + type: "migrated", + }, }, + tags: ["migrated"], }; export const Default = SearchGroup.bind({}); Default.args = {}; +Default.tags = ["!autodocs"]; // ********* DOCS ONLY ********* // +/** + * A search field should include a label and a search icon. In the default state before a search term is input, + * the label is in regular body text style to meet contrast ratios and to show that this is a field label, not placeholder text. + * Search fields should also include an aria-label in HTML (depending on the context, “aria-label” or “aria-labelledby”). + * The width of a search field can be customized appropriately for its context. + */ +export const Standard = SearchOptions.bind({}); +Standard.args = {}; +Standard.storyName = "Default"; +Standard.tags = ["!dev"]; -export const Disabled = SearchOptions.bind({}); +/** + * A search field in a disabled state shows that a search option exists, but is not available in that circumstance. + * This can be used to maintain layout continuity and communicate that it may become available later. + */ +export const Disabled = Template.bind({}); Disabled.args = { isDisabled: true, }; @@ -80,31 +127,44 @@ Disabled.parameters = { }; /** - * A search field can have [help text](?path=/docs/components-help-text--docs) below the field to give extra context or instruction about what a user should input. The description communicates a hint or helpful information, such as a search’s scope. + * A search field can have [help text](/docs/components-help-text--docs) below the field to give extra context or instruction about what a user should input. The description communicates a hint or helpful information, such as a search’s scope. * * When the help text is too long for the available horizontal space, it wraps to form another line. */ -export const HelpText = SearchGroup.bind({}); -HelpText.args = { - hasDescription: true, +export const WithHelpText = SearchGroup.bind({}); +WithHelpText.args = { + showHelpText: true, }; -HelpText.tags = ["!dev"]; -HelpText.parameters = { +WithHelpText.tags = ["!dev"]; +WithHelpText.parameters = { chromatic: { disableSnapshot: true }, }; +WithHelpText.storyName = "With help text"; /** - * A quiet search field can be used when searching isn’t a high priority action on the page. These search fields have no visible background, and this style works best when a clear layout makes the field easy to recognize. Too many quiet components in a small space can be hard to read. -*/ -export const Quiet = SearchGroup.bind({}); -Quiet.args = { - isQuiet: true, + * The value shows a user’s entered text. When the search field has an input value, [the clear button](/docs/components-clear-button--docs) appears with it. When the entered text is too long for the available horizontal space in the field, the text truncates. + */ +export const WithValue = SearchGroup.bind({}); +WithValue.args = { + inputValue: "What should I search for?", }; -Quiet.tags = ["!dev"]; -Quiet.parameters = { +WithValue.tags = ["!dev"]; +WithValue.parameters = { chromatic: { disableSnapshot: true }, }; +WithValue.storyName = "With value and clear button"; +/** + * A search field can be collapsed to show only the search button. This is useful when there is limited space available. It is most commonly used next a filter button to allow users to quickly search and filter content. + */ +export const Collapsed = Template.bind({}); +Collapsed.args = { + isCollapsed: true, +}; +Collapsed.tags = ["!dev"]; +Collapsed.parameters = { + chromatic: { disableSnapshot: true }, +}; /** * The medium size is the default and most frequently used option. Use the other sizes sparingly; they should be used to create a hierarchy of importance within the page. @@ -116,7 +176,7 @@ export const Sizing = (args, context) => Sizes({ ...args, }, context); Sizing.args = { - hasDescription: true + showHelpText: true }; Sizing.tags = ["!dev"]; Sizing.parameters = { diff --git a/components/search/stories/search.test.js b/components/search/stories/search.test.js index 880c56a3a4d..44b19ef2e6f 100644 --- a/components/search/stories/search.test.js +++ b/components/search/stories/search.test.js @@ -8,14 +8,43 @@ export const SearchGroup = Variants({ testHeading: "Default", }, { - testHeading: "Quiet", - isQuiet: true, + testHeading: "With help text", + showHelpText: true, + helpTextLabel: "Help text description goes here and just in case, let's also make it wrap." }, + { + testHeading: "With input value and clear button", + inputValue: "What should we search for?", + withStates: false, + }, + { + testHeading: "Collapsed", + isCollapsed: true, + } ], stateData: [ { testHeading: "Disabled", isDisabled: true, }, + { + testHeading: "Hovered", + isHovered: true, + }, + { + testHeading: "Focused", + isFocused: true, + ignore: ["Collapsed"], + }, + { + testHeading: "Focused + hovered", + isFocused: true, + isHovered: true, + ignore: ["Collapsed"], + }, + { + testHeading: "Keyboard focused", + isKeyboardFocused: true, + }, ] }); diff --git a/components/search/stories/template.js b/components/search/stories/template.js index 364c8d8fde6..490cbae9a85 100644 --- a/components/search/stories/template.js +++ b/components/search/stories/template.js @@ -1,3 +1,4 @@ +import { Template as ActionButton } from "@spectrum-css/actionbutton/stories/template.js"; import { Template as ClearButton } from "@spectrum-css/clearbutton/stories/template.js"; import { Template as HelpText } from "@spectrum-css/helptext/stories/template.js"; import { Container } from "@spectrum-css/preview/decorators"; @@ -7,73 +8,120 @@ import { classMap } from "lit/directives/class-map.js"; import { when } from "lit/directives/when.js"; import "../index.css"; -import "../themes/spectrum.css"; -/* Must be imported last */ -import "../themes/express.css"; export const Template = ({ rootClass = "spectrum-Search", customClasses = [], isDisabled = false, - isQuiet = false, - size, - hasDescription = false, - description, + isFocused = false, + isHovered = false, + isKeyboardFocused = false, + inputValue = "", + size = "m", + showHelpText = false, + helpTextLabel = "", + isCollapsed = false, } = {}, context = {}) => { + const { updateArgs } = context; return html` -
({ ...a, [c]: true }), {}), - })} - > - ${TextField({ + ({ ...a, [c]: true }), {}), + })} + aria-label="Search" + > + ${when(isCollapsed, () => + ActionButton({ + iconName: "Search", isDisabled, - isQuiet, + isHovered, size, - customClasses: [`${rootClass}-textfield`], - iconName: "Magnify", + isFocused: !isDisabled && (isFocused || isKeyboardFocused), + isQuiet: true, + customClasses: [ + `${rootClass}-actionButton`, + ], + onclick: () => { + updateArgs({ isCollapsed: !isCollapsed }); + }, + }, context) + )} + ${when(!isCollapsed, () => + TextField({ + isDisabled, + size, + customClasses: [ + `${rootClass}-textfield`, + isFocused && "is-focused", + isKeyboardFocused && "is-keyboardFocused", + isHovered && "is-hover" + ], + iconName: "Search", + setName: "workflow", type: "search", placeholder: "Search", name: "search", customInputClasses: [`${rootClass}-input`], customIconClasses: [`${rootClass}-icon`], autocomplete: false, - }, context)} - ${ClearButton({ - isDisabled, - size, - customClasses: [`${rootClass}-clearButton`], - }, context)} - ${when(hasDescription, () => - HelpText({ - text: description, - size, - isDisabled - }, context ))} -
- `; + value: inputValue, + }, context) + )} + ${when(inputValue && !isCollapsed, () => + ClearButton({ + isDisabled, + size, + customClasses: [`${rootClass}-clearButton`], + isFocusable: false, + }, context) + )} + ${when(showHelpText && !isCollapsed, () => + HelpText({ + text: helpTextLabel, + size, + isDisabled, + }, context))} + +`; }; -export const SearchOptions = ({ - ...args -}, context = {}) => Container({ +export const SearchOptions = (args, context) => Container({ withBorder: false, direction: "row", wrapperStyles: { columnGap: "12px", }, content: html` - ${Template({ - ...args, - }, context)} - ${Template({ - ...args, - isQuiet: true - }, context)} + ${Container({ + heading: "Default", + withBorder: false, + containerStyles: { + rowGap: "8px", + }, + content: Template(args, context) + })} + ${Container({ + heading: "Focused", + withBorder: false, + containerStyles: { + rowGap: "8px", + }, + content: Template({...args, isFocused: true,}, context) + })} + ${Container({ + heading: "Keyboard focused", + withBorder: false, + containerStyles: { + rowGap: "8px", + }, + content: Template({...args, isKeyboardFocused: true,}, context) + })} ` }, context); diff --git a/components/search/themes/express.css b/components/search/themes/express.css deleted file mode 100644 index 002ab9cecb6..00000000000 --- a/components/search/themes/express.css +++ /dev/null @@ -1,47 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--express */ - -@import "./spectrum.css"; - -@container style(--system: express) { - .spectrum-Search { - --spectrum-search-border-color-default: var(--spectrum-gray-400); - --spectrum-search-border-color-hover: var(--spectrum-gray-500); - --spectrum-search-border-color-focus: var(--spectrum-gray-800); - --spectrum-search-border-color-focus-hover: var(--spectrum-gray-900); - --spectrum-search-border-color-key-focus: var(--spectrum-gray-900); - - &, - &.spectrum-Search--sizeM { - --spectrum-search-border-radius: calc(var(--spectrum-component-height-100) / 2); - --spectrum-search-edge-to-visual: var(--spectrum-component-pill-edge-to-visual-100); - } - - &.spectrum-Search--sizeS { - --spectrum-search-border-radius: calc(var(--spectrum-component-height-75) / 2); - --spectrum-search-edge-to-visual: var(--spectrum-component-pill-edge-to-visual-75); - } - - &.spectrum-Search--sizeL { - --spectrum-search-border-radius: calc(var(--spectrum-component-height-200) / 2); - --spectrum-search-edge-to-visual: var(--spectrum-component-pill-edge-to-visual-200); - } - - &.spectrum-Search--sizeXL { - --spectrum-search-border-radius: calc(var(--spectrum-component-height-300) / 2); - --spectrum-search-edge-to-visual: var(--spectrum-component-pill-edge-to-visual-300); - } - } -} diff --git a/components/search/themes/spectrum-two.css b/components/search/themes/spectrum-two.css deleted file mode 100644 index 446eaea93a6..00000000000 --- a/components/search/themes/spectrum-two.css +++ /dev/null @@ -1,52 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -@container style(--system: spectrum) { - .spectrum-Search { - --spectrum-search-border-color-default: var(--spectrum-gray-500); - --spectrum-search-border-color-hover: var(--spectrum-gray-600); - --spectrum-search-border-color-focus: var(--spectrum-gray-800); - --spectrum-search-border-color-focus-hover: var(--spectrum-gray-900); - --spectrum-search-border-color-key-focus: var(--spectrum-gray-800); - - --spectrum-search-background-color: var(--spectrum-gray-25); - --spectrum-search-background-color-disabled: var(--spectrum-gray-25); - --spectrum-search-border-color-disabled: var(--spectrum-gray-300); - - &, - &.spectrum-Search--sizeM { - --spectrum-search-border-radius: var(--spectrum-corner-radius-100); - --spectrum-search-edge-to-visual: var(--spectrum-component-edge-to-visual-100); - } - - &.spectrum-Search--sizeS { - --spectrum-search-border-radius: var(--spectrum-corner-radius-100); - --spectrum-search-edge-to-visual: var(--spectrum-component-edge-to-visual-75); - } - - &.spectrum-Search--sizeL { - --spectrum-search-border-radius: var(--spectrum-corner-radius-100); - --spectrum-search-edge-to-visual: var(--spectrum-component-edge-to-visual-200); - } - - &.spectrum-Search--sizeXL { - --spectrum-search-border-radius: var(--spectrum-corner-radius-100); - --spectrum-search-edge-to-visual: var(--spectrum-component-edge-to-visual-300); - } - } - - .spectrum-Search--quiet { - --spectrum-search-background-color-disabled: transparent; - --spectrum-search-border-color-disabled: var(--spectrum-disabled-border-color); - } -} diff --git a/components/search/themes/spectrum.css b/components/search/themes/spectrum.css deleted file mode 100644 index 59756ec73de..00000000000 --- a/components/search/themes/spectrum.css +++ /dev/null @@ -1,25 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--legacy */ - -@import "./spectrum-two.css"; - -@container style(--system: legacy) { - .spectrum-Search { - --spectrum-search-background-color-disabled: var(--spectrum-disabled-background-color); - --spectrum-search-border-color-disabled: var(--spectrum-disabled-background-color); - --spectrum-search-background-color: var(--spectrum-gray-50); - --spectrum-search-border-color-key-focus: var(--spectrum-gray-900); - } -} diff --git a/components/sidenav/CHANGELOG.md b/components/sidenav/CHANGELOG.md index b9e4fe8233a..056461f634a 100644 --- a/components/sidenav/CHANGELOG.md +++ b/components/sidenav/CHANGELOG.md @@ -1,5 +1,43 @@ # Change log +## 8.0.0-next.3 + +### Patch Changes + +📝 [#4113](https://github.com/adobe/spectrum-css/pull/4113) [`cf4fc1a`](https://github.com/adobe/spectrum-css/commit/cf4fc1a01d23ba810f45a903ecc29a5c8aae33d1) Thanks [@castastrophe](https://github.com/castastrophe)! + +## Minor linting fixes + +- Removed unused custom properties across multiple components +- Fixed color function notation by converting `rgba()` to `rgb()` where appropriate +- Removed duplicate custom property declarations +- Fixed deprecated CSS properties (e.g., `word-wrap` → `overflow-wrap`) +- Removed unnecessary stylelint-disable comments + +_No visual or functional changes to components._ + +## 8.0.0-next.2 + +### Patch Changes + +📝 [#4044](https://github.com/adobe/spectrum-css/pull/4044) [`b1166bd`](https://github.com/adobe/spectrum-css/commit/b1166bd9e4542b3a665cc95498011a633c56e72a) Thanks [@5t3ph](https://github.com/5t3ph)! + +Replace deprecated `word-break: break-word` with `overflow-wrap: break-word` to align with modern CSS standards and improve cross-browser compatibility. This property was deprecated in Chrome 44 (July 2015) in favor of the standardized `overflow-wrap` property. + +## 8.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + +## 8.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`a25e0a9`](https://github.com/adobe/spectrum-css/commit/a25e0a99e5a4736ab4e607e00739343101a2633b)]: + - @spectrum-css/icon@10.0.0-next.0 + ## 7.2.0 ### Minor Changes diff --git a/components/sidenav/dist/metadata.json b/components/sidenav/dist/metadata.json index a0be758aa57..0215529e384 100644 --- a/components/sidenav/dist/metadata.json +++ b/components/sidenav/dist/metadata.json @@ -180,15 +180,6 @@ "--spectrum-text-to-visual-100", "--spectrum-workflow-icon-size-100" ], - "system-theme": [ - "--system-side-nav-background-hover", - "--system-side-nav-background-hover-selected", - "--system-side-nav-background-key-focus", - "--system-side-nav-background-key-focus-selected", - "--system-side-nav-item-background-default-selected", - "--system-side-nav-item-background-down", - "--system-side-nav-item-background-down-selected" - ], "passthroughs": [], "high-contrast": [ "--highcontrast-sidenav-background-hover", diff --git a/components/sidenav/index.css b/components/sidenav/index.css index 5f77d837144..c408228f7ca 100644 --- a/components/sidenav/index.css +++ b/components/sidenav/index.css @@ -11,41 +11,6 @@ * governing permissions and limitations under the License. */ -@import "./themes/spectrum-two.css"; - -@media (forced-colors: active) { - /* forced-color-adjust: preserve-parent-color addresses svg bug on icon hover */ - .spectrum-SideNav { - .spectrum-Icon { - forced-color-adjust: preserve-parent-color; - } - } - - .spectrum-SideNav-item { - --highcontrast-sidenav-content-disabled-color: GrayText; - - --highcontrast-sidenav-focus-ring-color: Highlight; - - --highcontrast-sidenav-content-color-default-selected: SelectedItemText; - --highcontrast-sidenav-item-background-default-selected: SelectedItem; - - --highcontrast-sidenav-background-key-focus-selected: Highlight; - --highcontrast-sidenav-background-hover-selected: Highlight; - --highcontrast-sidenav-item-background-down-selected: Highlight; - - --highcontrast-sidenav-item-background-down: Highlight; - --highcontrast-sidenav-background-hover: Highlight; - --highcontrast-sidenav-content-color-hover: HighlightText; - --highcontrast-sidenav-background-key-focus: Highlight; - - --highcontrast-sidenav-top-level-font-color: ButtonText; - --highcontrast-sidenav-content-color-default: ButtonText; - --highcontrast-sidenav-content-color-down: HighlightText; - - forced-color-adjust: none; - } -} - .spectrum-SideNav { /* focus indicator */ --spectrum-sidenav-focus-ring-size: var(--spectrum-focus-indicator-thickness); @@ -78,6 +43,13 @@ /* color - background */ --spectrum-sidenav-background-disabled: transparent; --spectrum-sidenav-background-default: transparent; + --spectrum-sidenav-background-hover: var(--spectrum-gray-100); + --spectrum-sidenav-item-background-down: var(--spectrum-gray-200); + --spectrum-sidenav-background-key-focus: var(--spectrum-gray-100); + --spectrum-sidenav-item-background-default-selected: var(--spectrum-gray-100); + --spectrum-sidenav-background-hover-selected: var(--spectrum-gray-200); + --spectrum-sidenav-item-background-down-selected: var(--spectrum-gray-200); + --spectrum-sidenav-background-key-focus-selected: var(--spectrum-gray-100); /* color font */ --spectrum-sidenav-header-color: var(--spectrum-gray-600); @@ -202,6 +174,9 @@ .spectrum-SideNav-link-text { margin-block-start: var(--mod-sidenav-top-to-label, var(--spectrum-sidenav-top-to-label)); margin-block-end: var(--mod-sidenav-bottom-to-label, var(--spectrum-sidenav-bottom-to-label)); + + /* Allow overflow-wrap to work and prevent text overflow */ + inline-size: 100%; } .spectrum-Icon { @@ -276,3 +251,36 @@ } } } + +@media (forced-colors: active) { + /* forced-color-adjust: preserve-parent-color addresses svg bug on icon hover */ + .spectrum-SideNav { + .spectrum-Icon { + forced-color-adjust: preserve-parent-color; + } + } + + .spectrum-SideNav-item { + --highcontrast-sidenav-content-disabled-color: GrayText; + + --highcontrast-sidenav-focus-ring-color: Highlight; + + --highcontrast-sidenav-content-color-default-selected: SelectedItemText; + --highcontrast-sidenav-item-background-default-selected: SelectedItem; + + --highcontrast-sidenav-background-key-focus-selected: Highlight; + --highcontrast-sidenav-background-hover-selected: Highlight; + --highcontrast-sidenav-item-background-down-selected: Highlight; + + --highcontrast-sidenav-item-background-down: Highlight; + --highcontrast-sidenav-background-hover: Highlight; + --highcontrast-sidenav-content-color-hover: HighlightText; + --highcontrast-sidenav-background-key-focus: Highlight; + + --highcontrast-sidenav-top-level-font-color: ButtonText; + --highcontrast-sidenav-content-color-default: ButtonText; + --highcontrast-sidenav-content-color-down: HighlightText; + + forced-color-adjust: none; + } +} diff --git a/components/sidenav/package.json b/components/sidenav/package.json index 354ba3d514f..dd7ea369d62 100644 --- a/components/sidenav/package.json +++ b/components/sidenav/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/sidenav", - "version": "7.2.0", + "version": "8.0.0-next.3", "description": "The Spectrum CSS sidenav component", "license": "Apache-2.0", "author": "Adobe", @@ -19,15 +19,13 @@ "./package.json": "./package.json", "./dist/*": "./dist/*", "./index.css": "./dist/index.css", - "./index-*.css": "./dist/index-*.css", "./metadata.json": "./dist/metadata.json", - "./themes/*": "./dist/themes/*", "./stories/*": "./stories/*" }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/icon": ">=9.0.0 <10.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/icon": ">=10.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/icon": { @@ -38,8 +36,8 @@ } }, "devDependencies": { - "@spectrum-css/icon": "9.2.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/icon": "10.0.0-next.3", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/sidenav/stories/sidenav.stories.js b/components/sidenav/stories/sidenav.stories.js index b5381efd78d..fb189e80e10 100644 --- a/components/sidenav/stories/sidenav.stories.js +++ b/components/sidenav/stories/sidenav.stories.js @@ -69,7 +69,11 @@ export default { }, packageJson, metadata, + status: { + type: "unmigrated", + }, }, + tags: ["unmigrated"], }; /** diff --git a/components/sidenav/stories/template.js b/components/sidenav/stories/template.js index 3aa9960e809..d3a832ab03a 100644 --- a/components/sidenav/stories/template.js +++ b/components/sidenav/stories/template.js @@ -7,9 +7,6 @@ import { repeat } from "lit/directives/repeat.js"; import { when } from "lit/directives/when.js"; import "../index.css"; -import "../themes/spectrum.css"; -/* Must be imported last */ -import "../themes/express.css"; export const Template = ({ rootClass = "spectrum-SideNav", diff --git a/components/sidenav/themes/express.css b/components/sidenav/themes/express.css deleted file mode 100644 index 9fd550418f2..00000000000 --- a/components/sidenav/themes/express.css +++ /dev/null @@ -1,16 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--express */ - -@import "./spectrum.css"; diff --git a/components/sidenav/themes/spectrum-two.css b/components/sidenav/themes/spectrum-two.css deleted file mode 100644 index 85869d92dbe..00000000000 --- a/components/sidenav/themes/spectrum-two.css +++ /dev/null @@ -1,25 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -@container style(--system: spectrum) { - .spectrum-SideNav { - --spectrum-sidenav-background-hover: var(--spectrum-gray-100); - --spectrum-sidenav-item-background-down: var(--spectrum-gray-200); - --spectrum-sidenav-background-key-focus: var(--spectrum-gray-100); - - --spectrum-sidenav-item-background-default-selected: var(--spectrum-gray-100); - --spectrum-sidenav-background-hover-selected: var(--spectrum-gray-200); - --spectrum-sidenav-item-background-down-selected: var(--spectrum-gray-200); - --spectrum-sidenav-background-key-focus-selected: var(--spectrum-gray-100); - } -} diff --git a/components/sidenav/themes/spectrum.css b/components/sidenav/themes/spectrum.css deleted file mode 100644 index 51828a4d8bf..00000000000 --- a/components/sidenav/themes/spectrum.css +++ /dev/null @@ -1,29 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--legacy */ - -@import "./spectrum-two.css"; - -@container style(--system: legacy) { - .spectrum-SideNav { - --spectrum-sidenav-background-hover: var(--spectrum-gray-200); - --spectrum-sidenav-item-background-down: var(--spectrum-gray-300); - --spectrum-sidenav-background-key-focus: var(--spectrum-gray-200); - - --spectrum-sidenav-item-background-default-selected: var(--spectrum-gray-200); - --spectrum-sidenav-background-hover-selected: var(--spectrum-gray-300); - --spectrum-sidenav-item-background-down-selected: var(--spectrum-gray-300); - --spectrum-sidenav-background-key-focus-selected: var(--spectrum-gray-200); - } -} diff --git a/components/slider/CHANGELOG.md b/components/slider/CHANGELOG.md index a16b4e7dd01..1083e26e891 100644 --- a/components/slider/CHANGELOG.md +++ b/components/slider/CHANGELOG.md @@ -1,5 +1,117 @@ # Change log +## 7.0.0-next.4 + +### Major Changes + +📝 [#3945](https://github.com/adobe/spectrum-css/pull/3945) [`8a39697`](https://github.com/adobe/spectrum-css/commit/8a3969751718d45ff1a4a0656e842cf490a8da94) Thanks [@aramos-adobe](https://github.com/aramos-adobe)! + +#### New features + +- Emphasized track fill color +- Precision control handle +- Large and thin track heights +- Embedded editable text field component + +#### Visual changes + +- No longer a gap between slider handle and the track +- Updated dimensions of slider handles for each size variant +- Updated WHCM for all variants + +#### New tokens + +`--spectrum-slider-control-to-field-label-editable-extra-large` +`--spectrum-slider-control-to-field-label-editable-large` +`--spectrum-slider-control-to-field-label-editable-medium` +`--spectrum-slider-control-to-field-label-editable-small` +`--spectrum-slider-control-to-side-field-label-extra-large` +`--spectrum-slider-control-to-side-field-label-large` +`--spectrum-slider-control-to-side-field-label-medium` +`--spectrum-slider-control-to-side-field-label-small` +`--spectrum-slider-control-to-text-field-extra-large` +`--spectrum-slider-control-to-text-field-large` +`--spectrum-slider-control-to-text-field-medium` +`--spectrum-slider-control-to-text-field-small` +`--spectrum-slider-editable-control-to-field-label` +`--spectrum-slider-editable-control-to-text-field` +`--spectrum-slider-editable-field-inline-size-extra-large` +`--spectrum-slider-editable-field-inline-size-large` +`--spectrum-slider-editable-field-inline-size-medium` +`--spectrum-slider-editable-field-inline-size-small` +`--spectrum-slider-emphasized-track-fill-color` +`--spectrum-slider-precision-handle-height` +`--spectrum-slider-precision-handle-height-extra-large` +`--spectrum-slider-precision-handle-height-large` +`--spectrum-slider-precision-handle-height-medium` +`--spectrum-slider-precision-handle-height-small` +`--spectrum-slider-precision-handle-width` +`--spectrum-slider-handle-extra-large` +`--spectrum-slider-handle-large` +`--spectrum-slider-handle-medium` +`--spectrum-slider-handle-small` + +#### New mods + +`--mod-slider-editable-control-to-text-field` +`--mod-slider-editable-field-inline-size` +`--mod-slider-disabled-border-color` +`--mod-slider-emphasized-tick-mark-color` +`--mod-slider-emphasized-track-fill-color` +`--mod-slider-inline-size` +`--mod-slider-label-font-style` +`--mod-slider-label-font-weight` +`--mod-slider-ramp-track-fill-color` +`--mod-slider-tick-mark-color-filled-track` +`--mod-slider-track-height-medium` + +#### Removed mods + +`--mod-disabled-border-color` +`--mod-sectrum-slider-ramp-handle-border-color-active` +`--mod-slider-handle-border-width-down` +`--mod-slider-handle-gap` +`--mod-slider-ramp-handle-background-color` +`--mod-slider-tick-handle-background-color` +`--mod-slider-tick-mark-color-disabled` +`--mod-slider-track-handleoffset` +`--mod-slider-track-margin-offset` +`--mod-slider-track-middle-handleoffset` + +## 7.0.0-next.3 + +### Major Changes + +📝 [#4014](https://github.com/adobe/spectrum-css/pull/4014) [`35c066b`](https://github.com/adobe/spectrum-css/commit/35c066b29c311b1bfcf4507075f13b41222ffc84) Thanks [@castastrophe](https://github.com/castastrophe)! + +This update removes the `dir` attribute polyfill (served via a PostCSS transform to compiled assets) as the fallback is no longer necessary. The`dir` attribute support is available in all supported browsers and has been tested to correctly inherit inside web component shadow DOMs. This is a breaking change **only** to those relying on the `dir` attribute being present for styling, however, the `:dir` pseudo will correctly inherit values from their containers. To correctly determine the `dir` value of a node using JavaScript, you can use `getComputedStyle(node).direction`. + +## 7.0.0-next.2 + +### Minor Changes + +- [#3656](https://github.com/adobe/spectrum-css/pull/3656) [`911c390`](https://github.com/adobe/spectrum-css/commit/911c390b9fa0b43187e5ab535874f2ed1ffeb88d) Thanks [@aramos-adobe](https://github.com/aramos-adobe)! - #### Including the touch action rule for draggable content + + The slider, color slider, color area, color wheel, color handle all deserve to have their touch-action property managed so that trying to set the value of those interfaces doesn't cause page scrolling in touch context. + + Adding `touch-action: none` to a slider or any draggable component is necessary to prevent the browser's default touch behaviors—such as scrolling, pinch-zooming, or double-tap zooming from interfering with the component's intended interaction. + + These components also include `user-select: none` to prevent selection or highlighting of any text elements. + +## 7.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + +## 7.0.0-next.0 + +### Patch Changes + +- Updated dependencies: + - @spectrum-css/stepper@8.0.0-next.0 + ## 6.4.0 ### Minor Changes @@ -12,17 +124,21 @@ Ensure accurate exports are present for each component. Specifically, adding `th ### Minor Changes -- [#3527](https://github.com/adobe/spectrum-css/pull/3527) [`5f1751c`](https://github.com/adobe/spectrum-css/commit/5f1751c82a5fe55ae0d999f5f50cfeca4c8a5c75) Thanks [@castastrophe](https://github.com/castastrophe)! - By updating the postcss-preset-env to the latest breaking change version, output for this component no longer injects the `.js-focus-within` and '[focus-within]` selectors for the focus-within polyfill. As this feature is not used in the SWC consumption, risk to the end user for this removal is low. +📝 [#3527](https://github.com/adobe/spectrum-css/pull/3527) [`5f1751c`](https://github.com/adobe/spectrum-css/commit/5f1751c82a5fe55ae0d999f5f50cfeca4c8a5c75) Thanks [@castastrophe](https://github.com/castastrophe)! + +By updating the postcss-preset-env to the latest breaking change version, output for this component no longer injects the `.js-focus-within` and '[focus-within]` selectors for the focus-within polyfill. As this feature is not used in the SWC consumption, risk to the end user for this removal is low. ## 6.2.0 ### Minor Changes -- [#3611](https://github.com/adobe/spectrum-css/pull/3611) [`8cb98c6`](https://github.com/adobe/spectrum-css/commit/8cb98c6127a91f902f305faeb800e3c787e97e66) Thanks [@aramos-adobe](https://github.com/aramos-adobe)! - # Slider: offset variant track fix +📝 [#3611](https://github.com/adobe/spectrum-css/pull/3611) [`8cb98c6`](https://github.com/adobe/spectrum-css/commit/8cb98c6127a91f902f305faeb800e3c787e97e66) Thanks [@aramos-adobe](https://github.com/aramos-adobe)! + +#### Slider: offset variant track fix - The border radius styles were not being applied to the second instance of the `spectrum-Slider-track` when the offset variant is activated. The reason for this bug is because when the `offset` is selected, the template structure changes as `spectrum-Slider-fill` gets added to the slider. +The border radius styles were not being applied to the second instance of the `spectrum-Slider-track` when the offset variant is activated. The reason for this bug is because when the `offset` is selected, the template structure changes as `spectrum-Slider-fill` gets added to the slider. - Adding a sibling combinator `&~.spectrum-Slider-track` to `spectrum-Slider-track` when offset is activated resolved the issue. +Adding a sibling combinator `&~.spectrum-Slider-track` to `spectrum-Slider-track` when offset is activated resolved the issue. ## 6.1.0 diff --git a/components/slider/dist/metadata.json b/components/slider/dist/metadata.json index 015c2145100..7eaea714d74 100644 --- a/components/slider/dist/metadata.json +++ b/components/slider/dist/metadata.json @@ -3,8 +3,18 @@ "selectors": [ ".spectrum-Slider", ".spectrum-Slider .spectrum-Slider-handle.is-focused:before", + ".spectrum-Slider--emphasized .spectrum-Slider-fill:before", + ".spectrum-Slider--emphasized .spectrum-Slider-ramp .spectrum-Slider-ramp-track-fill", + ".spectrum-Slider--emphasized .spectrum-Slider-tick:nth-child(-n + 4):after", + ".spectrum-Slider--emphasized .spectrum-Slider-track:first-child:before", + ".spectrum-Slider--emphasized.spectrum-Slider--range .spectrum-Slider-track:not(:first-of-type, :last-of-type):before", ".spectrum-Slider--filled .spectrum-Slider-track:first-child:before", - ".spectrum-Slider--ramp .spectrum-Slider-handle", + ".spectrum-Slider--filled:not(.spectrum-Slider--range, .is-disabled, .spectrum-Slider--emphasized) .spectrum-Slider-tick:nth-child(-n + 4):after", + ".spectrum-Slider--offset:not(.spectrum-Slider--range, .is-disabled, .spectrum-Slider--emphasized) .spectrum-Slider-tick:nth-child(-n + 4):after", + ".spectrum-Slider--precise .spectrum-Slider-handle", + ".spectrum-Slider--range .spectrum-Slider-tick:nth-child(3):after", + ".spectrum-Slider--range .spectrum-Slider-tick:nth-child(4):after", + ".spectrum-Slider--range .spectrum-Slider-tick:nth-child(5):after", ".spectrum-Slider--range .spectrum-Slider-track ~ .spectrum-Slider-track", ".spectrum-Slider--range .spectrum-Slider-track:first-of-type", ".spectrum-Slider--range .spectrum-Slider-track:first-of-type:before", @@ -13,9 +23,8 @@ ".spectrum-Slider--range .spectrum-Slider-track:not(:first-of-type, :last-of-type):before", ".spectrum-Slider--range .spectrum-Slider-value", ".spectrum-Slider--sideLabel", - ".spectrum-Slider--sideLabel .spectrum-Slider-controls", ".spectrum-Slider--sideLabel .spectrum-Slider-labelContainer", - ".spectrum-Slider--sideLabel .spectrum-Slider-labelContainer + .spectrum-Slider-controls", + ".spectrum-Slider--sideLabel .spectrum-Slider-labelContainer + .spectrum-Slider-content", ".spectrum-Slider--sideLabel .spectrum-Slider-labelContainer .spectrum-Slider-label", ".spectrum-Slider--sideLabel .spectrum-Slider-value", ".spectrum-Slider--sizeL", @@ -23,8 +32,12 @@ ".spectrum-Slider--sizeXL", ".spectrum-Slider--tick", ".spectrum-Slider--tick .spectrum-Slider-controls", - ".spectrum-Slider--tick .spectrum-Slider-handle", ".spectrum-Slider--tick .spectrum-Slider-tickLabel", + ".spectrum-Slider--track-height-large .spectrum-Slider-fill", + ".spectrum-Slider--track-height-large .spectrum-Slider-track", + ".spectrum-Slider-content", + ".spectrum-Slider-content--editable", + ".spectrum-Slider-content--editable .spectrum-Slider-controls", ".spectrum-Slider-controls", ".spectrum-Slider-controls:not(:has(.spectrum-Slider-ticks))", ".spectrum-Slider-fill", @@ -33,7 +46,6 @@ ".spectrum-Slider-handle", ".spectrum-Slider-handle.is-dragged", ".spectrum-Slider-handle.is-focused", - ".spectrum-Slider-handle.is-focused:before", ".spectrum-Slider-handle.is-tophandle", ".spectrum-Slider-handle:active", ".spectrum-Slider-handle:before", @@ -43,20 +55,25 @@ ".spectrum-Slider-input:focus", ".spectrum-Slider-label", ".spectrum-Slider-labelContainer", - ".spectrum-Slider-labelContainer + .spectrum-Slider-controls", + ".spectrum-Slider-labelContainer + .spectrum-Slider-content", + ".spectrum-Slider-labelContainer + .spectrum-Slider-content--editable", ".spectrum-Slider-labelContainer:lang(ja)", ".spectrum-Slider-labelContainer:lang(ko)", ".spectrum-Slider-labelContainer:lang(zh)", ".spectrum-Slider-ramp", - ".spectrum-Slider-ramp path", + ".spectrum-Slider-ramp .spectrum-Slider-ramp-track", + ".spectrum-Slider-ramp .spectrum-Slider-ramp-track-fill", ".spectrum-Slider-ramp svg", ".spectrum-Slider-tick", ".spectrum-Slider-tick .spectrum-Slider-tickLabel", + ".spectrum-Slider-tick.spectrum-Slider-tick--track-height-large:after", ".spectrum-Slider-tick:after", ".spectrum-Slider-tick:first-of-type", ".spectrum-Slider-tick:first-of-type .spectrum-Slider-tickLabel", + ".spectrum-Slider-tick:first-of-type:after", ".spectrum-Slider-tick:last-of-type", ".spectrum-Slider-tick:last-of-type .spectrum-Slider-tickLabel", + ".spectrum-Slider-tick:last-of-type:after", ".spectrum-Slider-ticks", ".spectrum-Slider-ticks ~ .spectrum-Slider-handleContainer .spectrum-Slider-handle", ".spectrum-Slider-track", @@ -82,31 +99,38 @@ ".spectrum-Slider.is-disabled .spectrum-Slider-track:before", ".spectrum-Slider.is-disabled.spectrum-Slider--filled .spectrum-Slider-track:first-child:before", ".spectrum-Slider.is-disabled.spectrum-Slider--range .spectrum-Slider-track:not(:first-of-type, :last-of-type):before", + ".spectrum-Slider.spectrum-Slider--precise:not(.is-disabled) .spectrum-Slider-handle.is-focused:before", + ".spectrum-Slider.spectrum-Slider--precise:not(.is-disabled) .spectrum-Slider-handle:focus-visible:before", + ".spectrum-Slider.spectrum-Slider--precise:not(.is-disabled) .spectrum-Slider-handle:focus:before", ".spectrum-Slider.spectrum-Slider--ramp .spectrum-Slider-handle", - ".spectrum-Slider.spectrum-Slider--sizeL", - ".spectrum-Slider.spectrum-Slider--sizeM", - ".spectrum-Slider.spectrum-Slider--sizeS", - ".spectrum-Slider.spectrum-Slider--sizeXL", ".spectrum-Slider:dir(rtl)", ".spectrum-Slider:dir(rtl) .spectrum-Slider-handle:before", + ".spectrum-Slider:not(.is-disabled) .spectrum-Slider-handle.is-focused", + ".spectrum-Slider:not(.is-disabled) .spectrum-Slider-handle.is-focused:before", + ".spectrum-Slider:not(.is-disabled) .spectrum-Slider-handle:focus", + ".spectrum-Slider:not(.is-disabled) .spectrum-Slider-handle:focus-visible", + ".spectrum-Slider:not(.is-disabled) .spectrum-Slider-handle:focus-visible:before", + ".spectrum-Slider:not(.is-disabled) .spectrum-Slider-handle:focus:before", ".spectrum-Slider:not(.is-disabled, .spectrum-Slider--filled, .spectrum-Slider--range) .spectrum-Slider-controls.is-focused", ".spectrum-Slider:not(.is-disabled, .spectrum-Slider--filled, .spectrum-Slider--range) .spectrum-Slider-controls:active", ".spectrum-Slider:not(.is-disabled, .spectrum-Slider--filled, .spectrum-Slider--range) .spectrum-Slider-controls:focus-within", ".spectrum-Slider:not(.is-disabled, .spectrum-Slider--filled, .spectrum-Slider--range) .spectrum-Slider-controls:hover", - ".spectrum-Slider:not(.spectrum-Slider--sideLabel) .spectrum-Slider-labelContainer + .spectrum-Slider-controls:has(.spectrum-Slider-ramp)", - "[dir=\"rtl\"] .spectrum-Slider", - "[dir=\"rtl\"] .spectrum-Slider .spectrum-Slider-handle:before" + ".spectrum-Slider:not(.spectrum-Slider--sideLabel) .spectrum-Slider-labelContainer + .spectrum-Slider-controls:has(.spectrum-Slider-ramp)" ], "modifiers": [ "--mod-animation-duration-100", - "--mod-disabled-border-color", "--mod-focus-indicator-gap", "--mod-font-size-75", "--mod-line-height-100", - "--mod-sectrum-slider-ramp-handle-border-color-active", "--mod-slider-cjk-line-height", "--mod-slider-control-height", + "--mod-slider-control-to-side-field-label", + "--mod-slider-control-to-text-field", "--mod-slider-controls-margin", + "--mod-slider-disabled-border-color", + "--mod-slider-editable-field-inline-size", + "--mod-slider-emphasized-tick-mark-color", + "--mod-slider-emphasized-track-fill-color", "--mod-slider-font-size", "--mod-slider-handle-background-color", "--mod-slider-handle-background-color-disabled", @@ -117,28 +141,27 @@ "--mod-slider-handle-border-color-key-focus", "--mod-slider-handle-border-radius", "--mod-slider-handle-border-width", - "--mod-slider-handle-border-width-down", "--mod-slider-handle-disabled-background-color", "--mod-slider-handle-focus-ring-color-key-focus", - "--mod-slider-handle-gap", "--mod-slider-handle-size", + "--mod-slider-inline-size", "--mod-slider-input-left", "--mod-slider-input-top-size", + "--mod-slider-label-font-family", + "--mod-slider-label-font-style", + "--mod-slider-label-font-weight", "--mod-slider-label-margin-start", "--mod-slider-label-text-color", "--mod-slider-label-text-color-disabled", - "--mod-slider-label-top-to-text", - "--mod-slider-min-size", - "--mod-slider-ramp-handle-background-color", "--mod-slider-ramp-track-color", "--mod-slider-ramp-track-color-disabled", + "--mod-slider-ramp-track-fill-color", "--mod-slider-ramp-track-height", "--mod-slider-range-track-reset", - "--mod-slider-tick-handle-background-color", "--mod-slider-tick-label-color", "--mod-slider-tick-mark-border-radius", "--mod-slider-tick-mark-color", - "--mod-slider-tick-mark-color-disabled", + "--mod-slider-tick-mark-color-filled-track", "--mod-slider-tick-mark-height", "--mod-slider-tick-mark-width", "--mod-slider-ticks-handle-background-color", @@ -148,22 +171,42 @@ "--mod-slider-track-fill-color", "--mod-slider-track-fill-color-disabled", "--mod-slider-track-fill-thickness", - "--mod-slider-track-handleoffset", - "--mod-slider-track-margin-offset", - "--mod-slider-track-middle-handleoffset", + "--mod-slider-track-height-medium", "--mod-slider-track-thickness", - "--mod-slider-value-inline-size", - "--mod-slider-value-side-padding-inline" + "--mod-slider-value-inline-size" ], "component": [ "--spectrum-slider-cjk-line-height", "--spectrum-slider-control-height", "--spectrum-slider-control-to-field-label", + "--spectrum-slider-control-to-field-label-editable-extra-large", + "--spectrum-slider-control-to-field-label-editable-large", + "--spectrum-slider-control-to-field-label-editable-medium", + "--spectrum-slider-control-to-field-label-editable-small", "--spectrum-slider-control-to-field-label-extra-large", "--spectrum-slider-control-to-field-label-large", "--spectrum-slider-control-to-field-label-medium", + "--spectrum-slider-control-to-field-label-side-extra-large", + "--spectrum-slider-control-to-field-label-side-large", + "--spectrum-slider-control-to-field-label-side-medium", + "--spectrum-slider-control-to-field-label-side-small", "--spectrum-slider-control-to-field-label-small", + "--spectrum-slider-control-to-side-field-label", + "--spectrum-slider-control-to-text-field", + "--spectrum-slider-control-to-text-field-extra-large", + "--spectrum-slider-control-to-text-field-large", + "--spectrum-slider-control-to-text-field-medium", + "--spectrum-slider-control-to-text-field-small", "--spectrum-slider-controls-margin", + "--spectrum-slider-downstate-perspective", + "--spectrum-slider-editable-control-to-field-label", + "--spectrum-slider-editable-field-inline-size-extra-large", + "--spectrum-slider-editable-field-inline-size-large", + "--spectrum-slider-editable-field-inline-size-medium", + "--spectrum-slider-editable-field-inline-size-small", + "--spectrum-slider-emphasized-tick-mark-color", + "--spectrum-slider-emphasized-track-fill-color", + "--spectrum-slider-focus-indicator-gap", "--spectrum-slider-font-size", "--spectrum-slider-handle-background-color", "--spectrum-slider-handle-background-color-disabled", @@ -174,38 +217,36 @@ "--spectrum-slider-handle-border-color-key-focus", "--spectrum-slider-handle-border-radius", "--spectrum-slider-handle-border-width", - "--spectrum-slider-handle-border-width-down", - "--spectrum-slider-handle-border-width-down-extra-large", - "--spectrum-slider-handle-border-width-down-large", - "--spectrum-slider-handle-border-width-down-medium", - "--spectrum-slider-handle-border-width-down-small", - "--spectrum-slider-handle-disabled-background-color", + "--spectrum-slider-handle-extra-large", "--spectrum-slider-handle-focus-ring-color-key-focus", "--spectrum-slider-handle-gap", + "--spectrum-slider-handle-large", "--spectrum-slider-handle-margin-left", + "--spectrum-slider-handle-medium", "--spectrum-slider-handle-size", - "--spectrum-slider-handle-size-extra-large", - "--spectrum-slider-handle-size-large", - "--spectrum-slider-handle-size-medium", - "--spectrum-slider-handle-size-small", + "--spectrum-slider-handle-small", + "--spectrum-slider-inline-size", "--spectrum-slider-input-left", "--spectrum-slider-input-top-size", + "--spectrum-slider-label-font-family", + "--spectrum-slider-label-font-style", + "--spectrum-slider-label-font-weight", "--spectrum-slider-label-margin-start", "--spectrum-slider-label-text-color", "--spectrum-slider-label-text-color-disabled", - "--spectrum-slider-label-top-to-text", - "--spectrum-slider-min-size", - "--spectrum-slider-ramp-handle-background-color", - "--spectrum-slider-ramp-handle-border-color-active", - "--spectrum-slider-ramp-track-color", + "--spectrum-slider-precision-handle-height", + "--spectrum-slider-precision-handle-height-extra-large", + "--spectrum-slider-precision-handle-height-large", + "--spectrum-slider-precision-handle-height-medium", + "--spectrum-slider-precision-handle-height-small", + "--spectrum-slider-precision-handle-width", "--spectrum-slider-ramp-track-color-disabled", "--spectrum-slider-ramp-track-height", "--spectrum-slider-range-track-reset", - "--spectrum-slider-tick-handle-background-color", "--spectrum-slider-tick-label-color", "--spectrum-slider-tick-mark-border-radius", "--spectrum-slider-tick-mark-color", - "--spectrum-slider-tick-mark-color-disabled", + "--spectrum-slider-tick-mark-color-filled-track", "--spectrum-slider-tick-mark-height", "--spectrum-slider-tick-mark-width", "--spectrum-slider-ticks-handle-background-color", @@ -215,77 +256,70 @@ "--spectrum-slider-track-fill-color", "--spectrum-slider-track-fill-color-disabled", "--spectrum-slider-track-fill-thickness", - "--spectrum-slider-track-handleoffset", - "--spectrum-slider-track-margin-offset", - "--spectrum-slider-track-middle-handleoffset", - "--spectrum-slider-track-thickness", - "--spectrum-slider-value-inline-size", - "--spectrum-slider-value-side-padding-inline" + "--spectrum-slider-track-height-large", + "--spectrum-slider-track-height-medium", + "--spectrum-slider-value-inline-size" ], "global": [ + "--spectrum-accent-color-1000", + "--spectrum-accent-content-color-default", "--spectrum-animation-duration-100", "--spectrum-border-width-200", "--spectrum-cjk-line-height-100", + "--spectrum-component-bottom-to-text-100", + "--spectrum-component-bottom-to-text-200", + "--spectrum-component-bottom-to-text-300", + "--spectrum-component-bottom-to-text-75", "--spectrum-component-height-100", "--spectrum-component-height-200", "--spectrum-component-height-300", "--spectrum-component-height-75", + "--spectrum-component-size-difference-down", + "--spectrum-component-size-minimum-perspective-down", "--spectrum-component-top-to-text-100", "--spectrum-component-top-to-text-200", + "--spectrum-component-top-to-text-300", "--spectrum-component-top-to-text-75", "--spectrum-corner-radius-500", + "--spectrum-default-font-style", "--spectrum-disabled-background-color", "--spectrum-disabled-border-color", "--spectrum-disabled-content-color", + "--spectrum-field-default-width-extra-large", + "--spectrum-field-default-width-large", + "--spectrum-field-default-width-medium", + "--spectrum-field-default-width-small", "--spectrum-focus-indicator-color", "--spectrum-focus-indicator-gap", "--spectrum-focus-indicator-thickness", "--spectrum-font-size-100", "--spectrum-font-size-200", + "--spectrum-font-size-300", "--spectrum-font-size-75", - "--spectrum-gray-100", - "--spectrum-gray-200", + "--spectrum-gray-25", "--spectrum-gray-400", "--spectrum-gray-700", "--spectrum-gray-75", "--spectrum-gray-800", + "--spectrum-gray-900", "--spectrum-line-height-100", "--spectrum-logical-rotation", "--spectrum-neutral-content-color-default", - "--spectrum-spacing-100", - "--spectrum-spacing-200", + "--spectrum-neutral-subdued-content-color-default", + "--spectrum-regular-font-weight", + "--spectrum-sans-font-family-stack", "--spectrum-spacing-300", - "--spectrum-spacing-900", - "--spectrum-text-to-visual-75" + "--spectrum-text-to-visual-75", + "--spectrum-track-color" ], - "system-theme": [ - "--system-slider-handle-background-color", - "--system-slider-handle-background-color-disabled", - "--system-slider-handle-border-color", - "--system-slider-handle-border-color-down", - "--system-slider-handle-border-color-hover", - "--system-slider-handle-border-color-key-focus", - "--system-slider-handle-border-radius", - "--system-slider-handle-disabled-background-color", - "--system-slider-handle-focus-ring-color-key-focus", - "--system-slider-ramp-handle-background-color", - "--system-slider-ramp-track-color", - "--system-slider-ramp-track-color-disabled", - "--system-slider-size-l-handle-border-radius", - "--system-slider-size-m-handle-border-radius", - "--system-slider-size-s-handle-border-radius", - "--system-slider-size-xl-handle-border-radius", - "--system-slider-tick-mark-color", - "--system-slider-ticks-handle-background-color", - "--system-slider-track-color", - "--system-slider-track-corner-radius", - "--system-slider-track-fill-color" + "passthroughs": [ + "--mod-fieldlabel-bottom-to-text", + "--mod-fieldlabel-top-to-text", + "--mod-textfield-width" ], - "passthroughs": [], "high-contrast": [ "--highcontrast-slider-filled-track-fill-color", "--highcontrast-slider-handle-background-color", - "--highcontrast-slider-handle-background-color-disabled", "--highcontrast-slider-handle-border-color", "--highcontrast-slider-handle-border-color-disabled", "--highcontrast-slider-handle-border-color-down", @@ -295,12 +329,11 @@ "--highcontrast-slider-handle-focus-ring-color-key-focus", "--highcontrast-slider-label-text-color", "--highcontrast-slider-label-text-color-disabled", - "--highcontrast-slider-ramp-handle-background-color", - "--highcontrast-slider-ramp-handle-border-color-active", "--highcontrast-slider-ramp-track-color", "--highcontrast-slider-ramp-track-color-disabled", "--highcontrast-slider-tick-mark-color", "--highcontrast-slider-tick-mark-color-disabled", + "--highcontrast-slider-tick-mark-color-filled-track", "--highcontrast-slider-track-color", "--highcontrast-slider-track-color-disabled", "--highcontrast-slider-track-color-static", diff --git a/components/slider/index.css b/components/slider/index.css index d49f584aab0..ed933f03039 100644 --- a/components/slider/index.css +++ b/components/slider/index.css @@ -11,108 +11,168 @@ * governing permissions and limitations under the License. */ -@import "./themes/spectrum-two.css"; - .spectrum-Slider { - /* default sizing, matches t-shirt size M */ - --spectrum-slider-font-size: var(--spectrum-font-size-75); - --spectrum-slider-handle-size: var(--spectrum-slider-handle-size-medium); + --spectrum-slider-font-size: var(--spectrum-font-size-100); + --spectrum-slider-handle-size: var(--spectrum-slider-handle-medium); --spectrum-slider-control-height: var(--spectrum-component-height-100); - --spectrum-slider-handle-border-width-down: var(--spectrum-slider-handle-border-width-down-medium); - --spectrum-slider-label-top-to-text: var(--spectrum-component-top-to-text-75); --spectrum-slider-control-to-field-label: var(--spectrum-slider-control-to-field-label-medium); - --spectrum-slider-value-side-padding-inline: var(--spectrum-spacing-200); + --spectrum-slider-control-to-side-field-label: var(--spectrum-slider-control-to-field-label-side-medium); + --spectrum-slider-inline-size: var(--spectrum-field-default-width-medium); + --spectrum-slider-label-font-weight: var(--spectrum-regular-font-weight); + --spectrum-slider-label-font-style: var(--spectrum-default-font-style); + --spectrum-slider-label-font-family: var(--spectrum-sans-font-family-stack); /* TODO: placeholder value for sideLabel variant value width */ --spectrum-slider-value-inline-size: 18px; --spectrum-slider-cjk-line-height: var(--spectrum-cjk-line-height-100); - --spectrum-slider-min-size: var(--spectrum-spacing-900); - --spectrum-slider-label-margin-start: var(--spectrum-spacing-300); --spectrum-slider-handle-border-width: var(--spectrum-border-width-200); --spectrum-slider-handle-margin-left: calc(var(--spectrum-slider-handle-size) / -2); --spectrum-slider-controls-margin: calc(var(--spectrum-slider-handle-size) / 2); - --spectrum-slider-track-margin-offset: calc(var(--spectrum-slider-controls-margin) * -1); - --spectrum-slider-track-middle-handleoffset: calc(var(--spectrum-slider-handle-gap) + calc(var(--spectrum-slider-handle-size) / 2)); --spectrum-slider-input-top-size: calc(var(--spectrum-slider-handle-size) / -2 / 4); - --spectrum-slider-track-fill-thickness: var(--spectrum-slider-track-thickness); + --spectrum-slider-track-fill-thickness: var(--spectrum-slider-track-height-medium); --spectrum-slider-tick-mark-width: var(--spectrum-border-width-200); --spectrum-slider-tick-mark-border-radius: 2px; - --spectrum-slider-tick-handle-background-color: var(--spectrum-gray-100); + --spectrum-slider-focus-indicator-gap: var(--spectrum-focus-indicator-gap); + --spectrum-slider-downstate-perspective: var(--spectrum-component-size-minimum-perspective-down); /* colors */ + --spectrum-slider-track-color: var(--spectrum-track-color); + --spectrum-slider-track-fill-color: var(--spectrum-gray-700); --spectrum-slider-track-color-disabled: var(--spectrum-disabled-background-color); + --spectrum-slider-ramp-track-color-disabled: var(--spectrum-slider-track-color-disabled); --spectrum-slider-track-fill-color-disabled: var(--spectrum-disabled-background-color); --spectrum-slider-handle-border-color-disabled: var(--spectrum-disabled-border-color); - --spectrum-slider-label-text-color: var(--spectrum-neutral-content-color-default); + --spectrum-slider-label-text-color: var(--spectrum-neutral-subdued-content-color-default); --spectrum-slider-tick-label-color: var(--spectrum-neutral-content-color-default); --spectrum-slider-label-text-color-disabled: var(--spectrum-disabled-content-color); - --spectrum-slider-tick-mark-color-disabled: var(--spectrum-disabled-background-color); - --spectrum-slider-ramp-handle-border-color-active: var(--spectrum-gray-100); + --spectrum-slider-handle-background-color: var(--spectrum-gray-25); + --spectrum-slider-handle-background-color-disabled: var(--spectrum-slider-handle-background-color); + --spectrum-slider-ticks-handle-background-color: var(--spectrum-gray-75); + --spectrum-slider-handle-border-color: var(--spectrum-gray-800); + --spectrum-slider-tick-mark-color: var(--spectrum-gray-400); + --spectrum-slider-tick-mark-color-filled-track: var(--spectrum-gray-800); + --spectrum-slider-emphasized-tick-mark-color: var(--spectrum-accent-color-1000); + --spectrum-slider-emphasized-track-fill-color: var(--spectrum-accent-content-color-default); - /* values */ - --spectrum-slider-input-left: calc(var(--spectrum-slider-handle-margin-left) / 4); - --spectrum-slider-track-handleoffset: var(--spectrum-slider-handle-gap); + --spectrum-slider-handle-border-color-hover: var(--spectrum-gray-900); + --spectrum-slider-handle-border-color-down: var(--spectrum-gray-900); + --spectrum-slider-handle-border-color-key-focus: var(--spectrum-gray-900); + --spectrum-slider-handle-focus-ring-color-key-focus: var(--spectrum-focus-indicator-color); - --spectrum-slider-range-track-reset: 0; + --spectrum-slider-precision-handle-height: var(--spectrum-slider-precision-handle-height-medium); - position: relative; + --spectrum-slider-control-to-text-field: var(--spectrum-slider-control-to-text-field-medium); + --spectrum-slider-editable-control-to-field-label: var(--spectrum-slider-control-to-field-label-editable-medium); - /* Don't let z-index'd child elements float above other things on the page */ - z-index: 0; - display: block; - min-inline-size: var(--mod-slider-min-size, var(--spectrum-slider-min-size)); - - user-select: none; + /* values */ + --spectrum-slider-input-left: calc(var(--spectrum-slider-handle-margin-left) / 4); + --spectrum-slider-range-track-reset: 0; + --spectrum-slider-track-corner-radius: 2px; + --spectrum-slider-handle-border-radius: var(--spectrum-slider-handle-size); - &:dir(rtl), - &:dir(rtl) { - --spectrum-logical-rotation: matrix(-1, 0, 0, 1, 0, 0); - } + /* Textfield passthrough */ + --mod-textfield-width: var(--mod-slider-editable-field-inline-size, var(--spectrum-slider-editable-field-inline-size-medium)); - &:not(.spectrum-Slider--sideLabel) .spectrum-Slider-labelContainer + .spectrum-Slider-controls:has(.spectrum-Slider-ramp) { - margin-block-start: calc(var(--mod-slider-ramp-track-height, var(--spectrum-slider-ramp-track-height)) / 2); - } + /* Field label passthrough */ + --mod-fieldlabel-top-to-text: var(--spectrum-component-top-to-text-100); + --mod-fieldlabel-bottom-to-text: var(--spectrum-component-bottom-to-text-100); } .spectrum-Slider--sizeS { --spectrum-slider-font-size: var(--spectrum-font-size-75); - --spectrum-slider-handle-size: var(--spectrum-slider-handle-size-small); + --spectrum-slider-handle-size: var(--spectrum-slider-handle-small); --spectrum-slider-control-height: var(--spectrum-component-height-75); - --spectrum-slider-handle-border-width-down: var(--spectrum-slider-handle-border-width-down-small); - --spectrum-slider-label-top-to-text: var(--spectrum-component-top-to-text-75); --spectrum-slider-control-to-field-label: var(--spectrum-slider-control-to-field-label-small); - --spectrum-slider-value-side-padding-inline: var(--spectrum-spacing-100); + --spectrum-slider-control-to-side-field-label: var(--spectrum-slider-control-to-field-label-side-small); + --spectrum-slider-handle-border-radius: var(--spectrum-corner-radius-500); + --spectrum-slider-inline-size: var(--spectrum-field-default-width-small); + --spectrum-slider-precision-handle-height: var(--spectrum-slider-precision-handle-height-small); + --spectrum-slider-control-to-text-field: var(--spectrum-slider-control-to-text-field-small); + --spectrum-slider-editable-control-to-field-label: var(--spectrum-slider-control-to-field-label-editable-small); + --mod-textfield-width: var(--spectrum-slider-editable-field-inline-size-small); + --mod-fieldlabel-top-to-text: var(--spectrum-component-top-to-text-75); + --mod-fieldlabel-bottom-to-text: var(--spectrum-component-bottom-to-text-75); } .spectrum-Slider--sizeL { - --spectrum-slider-font-size: var(--spectrum-font-size-100); - --spectrum-slider-handle-size: var(--spectrum-slider-handle-size-large); + --spectrum-slider-font-size: var(--spectrum-font-size-200); + --spectrum-slider-handle-size: var(--spectrum-slider-handle-large); --spectrum-slider-control-height: var(--spectrum-component-height-200); - --spectrum-slider-handle-border-width-down: var(--spectrum-slider-handle-border-width-down-large); - --spectrum-slider-label-top-to-text: var(--spectrum-component-top-to-text-100); + --spectrum-slider-control-to-field-label: var(--spectrum-slider-control-to-field-label-large); - --spectrum-slider-value-side-padding-inline: var(--spectrum-spacing-200); + --spectrum-slider-control-to-side-field-label: var(--spectrum-slider-control-to-field-label-side-large); + --spectrum-slider-handle-border-radius: calc(var(--spectrum-corner-radius-500) * 4); + --spectrum-slider-inline-size: var(--spectrum-field-default-width-large); + --spectrum-slider-precision-handle-height: var(--spectrum-slider-precision-handle-height-large); + --spectrum-slider-control-to-text-field: var(--spectrum-slider-control-to-text-field-large); + --spectrum-slider-editable-control-to-field-label: var(--spectrum-slider-control-to-field-label-editable-large); + --mod-textfield-width: var(--spectrum-slider-editable-field-inline-size-large); + --mod-fieldlabel-top-to-text: var(--spectrum-component-top-to-text-200); + --mod-fieldlabel-bottom-to-text: var(--spectrum-component-bottom-to-text-200); /* TODO: placeholder value for sideLabel variant value width */ --spectrum-slider-value-inline-size: 18px; } .spectrum-Slider--sizeXL { - --spectrum-slider-font-size: var(--spectrum-font-size-200); - --spectrum-slider-handle-size: var(--spectrum-slider-handle-size-extra-large); + --spectrum-slider-font-size: var(--spectrum-font-size-300); + --spectrum-slider-handle-size: var(--spectrum-slider-handle-extra-large); --spectrum-slider-control-height: var(--spectrum-component-height-300); - --spectrum-slider-handle-border-width-down: var(--spectrum-slider-handle-border-width-down-extra-large); - --spectrum-slider-label-top-to-text: var(--spectrum-component-top-to-text-200); --spectrum-slider-control-to-field-label: var(--spectrum-slider-control-to-field-label-extra-large); - --spectrum-slider-value-side-padding-inline: var(--spectrum-spacing-200); + --spectrum-slider-control-to-side-field-label: var(--spectrum-slider-control-to-field-label-side-extra-large); + --spectrum-slider-handle-border-radius: calc(var(--spectrum-corner-radius-500) * 4); + --spectrum-slider-inline-size: var(--spectrum-field-default-width-extra-large); + --spectrum-slider-precision-handle-height: var(--spectrum-slider-precision-handle-height-extra-large); + --spectrum-slider-control-to-text-field: var(--spectrum-slider-control-to-text-field-extra-large); + --spectrum-slider-editable-control-to-field-label: var(--spectrum-slider-control-to-field-label-editable-extra-large); + --mod-textfield-width: var(--spectrum-slider-editable-field-inline-size-extra-large); + --mod-fieldlabel-top-to-text: var(--spectrum-component-top-to-text-300); + --mod-fieldlabel-bottom-to-text: var(--spectrum-component-bottom-to-text-300); /* TODO: placeholder value for sideLabel variant value width */ --spectrum-slider-value-inline-size: 22px; } +.spectrum-Slider { + position: relative; + + /* Don't let z-index'd child elements float above other things on the page */ + z-index: 0; + display: block; + inline-size: var(--mod-slider-inline-size, var(--spectrum-slider-inline-size)); + + user-select: none; + + &:dir(rtl), + &:dir(rtl) { + --spectrum-logical-rotation: matrix(-1, 0, 0, 1, 0, 0); + } + + &:not(.spectrum-Slider--sideLabel) .spectrum-Slider-labelContainer + .spectrum-Slider-controls:has(.spectrum-Slider-ramp) { + margin-block-start: calc(var(--mod-slider-ramp-track-height, var(--spectrum-slider-ramp-track-height)) / 2); + } +} + +.spectrum-Slider--track-height-large { + .spectrum-Slider-track, + .spectrum-Slider-fill { + --spectrum-slider-track-fill-thickness: var(--spectrum-slider-track-height-large); + } +} + +.spectrum-Slider--precise { + .spectrum-Slider-handle { + inline-size: var(--spectrum-slider-precision-handle-width); + block-size: var(--spectrum-slider-precision-handle-height); + margin-inline: 0; + inset-block-start: calc(var(--mod-slider-control-height, var(--spectrum-slider-control-height)) / 2 - var(--spectrum-slider-precision-handle-height) / 2); + margin-inline-start: calc((var(--spectrum-slider-precision-handle-width) + var(--spectrum-slider-handle-border-width)) * -0.5); + } +} + .spectrum-Slider--sideLabel { display: flex; align-items: center; @@ -120,48 +180,63 @@ .spectrum-Slider-labelContainer { margin-block-start: 0; + /* This helps prevent the slider from shrinking when the label is long */ + flex: 1; + .spectrum-Slider-label { - margin-inline-end: var(--mod-slider-value-side-padding-inline, var(--spectrum-slider-value-side-padding-inline)); + margin-inline-end: var(--mod-slider-control-to-side-field-label, var(--spectrum-slider-control-to-side-field-label)); } } - .spectrum-Slider-labelContainer + .spectrum-Slider-controls { + .spectrum-Slider-labelContainer + .spectrum-Slider-content { margin-block-start: 0; } - .spectrum-Slider-controls { - margin-inline-end: var(--mod-slider-controls-margin, var(--spectrum-slider-controls-margin)); - } - .spectrum-Slider-value { - margin-inline-start: var(--mod-slider-value-side-padding-inline, var(--spectrum-slider-value-side-padding-inline)); + margin-inline-start: var(--mod-slider-control-to-text-field, var(--spectrum-slider-control-to-text-field)); inline-size: var(--mod-slider-value-inline-size, var(--spectrum-slider-value-inline-size)); text-align: start; } } +.spectrum-Slider-content { + inline-size: 100%; +} + +.spectrum-Slider-content--editable { + display: flex; + align-items: center; + gap: var(--mod-slider-control-to-text-field, var(--spectrum-slider-control-to-text-field)); + + .spectrum-Slider-controls { + /* This allows the text field to grow to design spec inline size */ + flex: 1; + } +} + .spectrum-Slider-controls { display: inline-block; box-sizing: border-box; cursor: pointer; position: relative; z-index: auto; + inline-size: 100%; &:not(:has(.spectrum-Slider-ticks)) { display: flex; align-items: center; } - /* These calculations prevent the track from spilling outside of the control */ - inline-size: calc(100% - calc(var(--mod-slider-controls-margin, var(--spectrum-slider-controls-margin))) * 2); - margin-inline-start: var(--mod-slider-controls-margin, var(--spectrum-slider-controls-margin)); - block-size: var(--mod-slider-control-height, var(--spectrum-slider-control-height)); vertical-align: top; } -.spectrum-Slider-labelContainer + .spectrum-Slider-controls { - margin-block-start: calc(-1 * var(--spectrum-slider-control-to-field-label)); +.spectrum-Slider-labelContainer + .spectrum-Slider-content { + margin-block-start: var(--spectrum-slider-control-to-field-label); +} + +.spectrum-Slider-labelContainer + .spectrum-Slider-content--editable { + margin-block-start: var(--spectrum-slider-editable-control-to-field-label); } /* TODO: Sliders with ticks + tick mark labels require more margin-block-end. @@ -185,8 +260,9 @@ padding-block: 0; padding-inline-start: 0; - padding-inline-end: var(--mod-slider-handle-gap, var(--spectrum-slider-handle-gap)); - margin-inline-start: var(--mod-slider-track-margin-offset, var(--spectrum-slider-track-margin-offset)); + + touch-action: none; /* Disable touch scrolling on touch devices to allow dragging slider */ + user-select: none; &::before { content: ""; @@ -221,16 +297,15 @@ inset-inline-start: auto; inset-inline-end: var(--mod-slider-range-track-reset, var(--spectrum-slider-range-track-reset)); padding-block: 0; - padding-inline-start: var(--mod-slider-track-handleoffset, var(--spectrum-slider-track-handleoffset)); padding-inline-end: 0; margin-inline-start: var(--mod-slider-range-track-reset, var(--spectrum-slider-range-track-reset)); - margin-inline-end: var(--mod-slider-track-margin-offset, var(--spectrum-slider-track-margin-offset)); + user-select: none; + touch-action: none; /* Disable touch scrolling on touch devices to allow dragging slider handle */ } /* over-write for Range, without the LTR RTL post-css hack */ .spectrum-Slider--range { .spectrum-Slider-track ~ .spectrum-Slider-track { - padding-inline: var(--mod-slider-track-middle-handleoffset, var(--spectrum-slider-track-middle-handleoffset)) var(--mod-slider-track-middle-handleoffset, var(--spectrum-slider-track-middle-handleoffset)); inset-inline: auto; margin-inline: var(--mod-slider-range-track-reset, var(--spectrum-slider-range-track-reset)); } @@ -239,7 +314,6 @@ .spectrum-Slider-fill { margin-inline-start: 0; padding-block: 0; - padding-inline-start: calc(var(--mod-slider-controls-margin, var(--spectrum-slider-controls-margin)) + var(--spectrum-slider-handle-gap, var(--spectrum-slider-handle-gap))); padding-inline-end: 0; } @@ -257,10 +331,8 @@ .spectrum-Slider-track { &:first-of-type { padding-inline-start: 0; - padding-inline-end: var(--mod-slider-track-handleoffset, var(--spectrum-slider-track-handleoffset)); inset-inline-start: var(--mod-slider-range-track-reset, var(--spectrum-slider-range-track-reset)); inset-inline-end: auto; - margin-inline-start: var(--mod-slider-track-margin-offset, var(--spectrum-slider-track-margin-offset)); } &:first-of-type::before { @@ -269,11 +341,9 @@ } &:last-of-type { - padding-inline-start: var(--spectrum-slider-track-handleoffset); padding-inline-end: 0; inset-inline-start: auto; inset-inline-end: var(--mod-slider-range-track-reset, var(--spectrum-slider-range-track-reset)); - margin-inline-end: var(--mod-slider-track-margin-offset, var(--spectrum-slider-track-margin-offset)); } &:last-of-type::before { @@ -285,10 +355,8 @@ .spectrum-Slider-ramp { block-size: var(--mod-slider-ramp-track-height, var(--spectrum-slider-ramp-track-height)); - position: absolute; - inset-inline-start: var(--spectrum-slider-track-margin-offset, var(--spectrum-slider-track-margin-offset)); - inset-inline-end: var(--spectrum-slider-track-margin-offset, var(--spectrum-slider-track-margin-offset)); + inline-size: 100%; svg { inline-size: 100%; @@ -300,6 +368,8 @@ } .spectrum-Slider-handle { + border-color: var(--highcontrast-slider-handle-border-color, var(--mod-slider-handle-border-color, var(--spectrum-slider-handle-border-color))); + background: var(--highcontrast-slider-handle-background-color, var(--mod-slider-handle-background-color, var(--spectrum-slider-handle-background-color))); position: absolute; inset-inline-start: 0; z-index: 2; @@ -315,15 +385,20 @@ border-width: var(--mod-slider-handle-border-width, var(--spectrum-slider-handle-border-width)); border-style: solid; - border-radius: var(--mod-slider-handle-border-radius, var(--spectrum-slider-handle-border-radius)); + border-radius: var(--mod-slider-handle-border-radius, var(--spectrum-slider-handle-size)); transition: border-width var(--mod-animation-duration-100, var(--spectrum-animation-duration-100)) ease-in-out; outline: none; + &:hover { + border-color: var(--highcontrast-slider-handle-border-color-hover, var(--mod-slider-handle-border-color-hover, var(--spectrum-slider-handle-border-color-hover))); + } + &:active, &.is-dragged { - border-width: var(--mod-slider-handle-border-width-down, var(--spectrum-slider-handle-border-width-down)); + border-color: var(--highcontrast-slider-handle-border-color-down, var(--mod-slider-handle-border-color-down, var(--spectrum-slider-handle-border-color-down))); + transform: perspective(var(--spectrum-slider-downstate-perspective)) translateZ(var(--spectrum-component-size-difference-down)); } &:active, @@ -358,10 +433,16 @@ } /* Keyboard focused */ - &.is-focused { + .spectrum-Slider:not(.is-disabled) &.is-focused, + .spectrum-Slider:not(.is-disabled) &:focus, + .spectrum-Slider:not(.is-disabled) &:focus-visible { + border-color: var(--highcontrast-slider-handle-border-color-key-focus, var(--mod-slider-handle-border-color-key-focus, var(--spectrum-slider-handle-border-color-key-focus))); + outline: 0; + &::before { - inline-size: calc(var(--mod-slider-handle-size, var(--spectrum-slider-handle-size)) + var(--mod-focus-indicator-gap, var(--spectrum-focus-indicator-gap)) * 2); - block-size: calc(var(--mod-slider-handle-size, var(--spectrum-slider-handle-size)) + var(--mod-focus-indicator-gap, var(--spectrum-focus-indicator-gap)) * 2); + box-shadow: 0 0 0 var(--spectrum-focus-indicator-thickness) var(--highcontrast-slider-handle-focus-ring-color-key-focus, var(--mod-slider-handle-focus-ring-color-key-focus, var(--spectrum-slider-handle-focus-ring-color-key-focus))); + inline-size: calc(var(--mod-slider-handle-size, var(--spectrum-slider-handle-size)) + var(--mod-focus-indicator-gap, var(--spectrum-slider-focus-indicator-gap)) * 2); + block-size: calc(var(--mod-slider-handle-size, var(--spectrum-slider-handle-size)) + var(--mod-focus-indicator-gap, var(--spectrum-slider-focus-indicator-gap)) * 2); } } } @@ -403,8 +484,9 @@ font-size: var(--mod-slider-font-size, var(--spectrum-slider-font-size)); line-height: var(--mod-line-height-100, var(--spectrum-line-height-100)); - - margin-block-start: var(--mod-slider-label-top-to-text, var(--spectrum-slider-label-top-to-text)); + font-weight: var(--mod-slider-label-font-weight, var(--spectrum-slider-label-font-weight)); + font-style: var(--mod-slider-label-font-style, var(--spectrum-slider-label-font-style)); + font-family: var(--mod-slider-label-font-family, var(--spectrum-slider-label-font-family)); /* international support */ &:lang(ja), @@ -433,12 +515,8 @@ /* setting tick marks in relation to label */ .spectrum-Slider--tick { - .spectrum-Slider-handle { - background-color: var(--mod-slider-tick-handle-background-color, var(--spectrum-slider-tick-handle-background-color)); - } - .spectrum-Slider-controls { - margin-block-start: calc(var(--spectrum-text-to-visual-75) - var(--mod-slider-tick-mark-height, var(--spectrum-slider-tick-mark-height)) / 2 - var(--mod-slider-track-thickness, var(--spectrum-slider-track-thickness)) / 2); + margin-block-start: calc(var(--spectrum-text-to-visual-75) - var(--mod-slider-tick-mark-height, var(--spectrum-slider-tick-mark-height)) / 2 - var(--mod-slider-track-height-medium, var(--spectrum-slider-track-height-medium)) / 2); } .spectrum-Slider-tickLabel { @@ -450,8 +528,8 @@ .spectrum-Slider-ticks { display: flex; justify-content: space-between; - z-index: 0; - margin-inline: var(--mod-slider-track-margin-offset, var(--spectrum-slider-track-margin-offset)); + z-index: 2; + position: relative; /* TODO: missing core-token for handle fill-color */ & ~ .spectrum-Slider-handleContainer { @@ -479,6 +557,13 @@ border-radius: var(--mod-slider-tick-mark-border-radius, var(--spectrum-slider-tick-mark-border-radius)); } + &.spectrum-Slider-tick--track-height-large { + &::after { + block-size: calc(var(--spectrum-slider-track-height-large) + 2px); + inset-block-start: -4px; + } + } + .spectrum-Slider-tickLabel { display: flex; align-items: center; @@ -497,6 +582,13 @@ } } + &:first-of-type, + &:last-of-type { + &::after { + opacity: 0; + } + } + &:first-of-type { /* fix off-by-one alignment */ inset-inline-start: calc(var(--mod-slider-tick-mark-width, var(--spectrum-slider-tick-mark-width)) / -2); @@ -567,42 +659,32 @@ .spectrum-Slider-fill { &::before { background: var(--highcontrast-slider-filled-track-fill-color, var(--mod-slider-track-fill-color, var(--spectrum-slider-track-fill-color))); + border-start-start-radius: var(--mod-slider-track-corner-radius, var(--spectrum-slider-track-corner-radius)); + border-end-start-radius: var(--mod-slider-track-corner-radius, var(--spectrum-slider-track-corner-radius)); } } -.spectrum-Slider-ramp { - path { - fill: var(--highcontrast-slider-ramp-track-color, var(--mod-slider-ramp-track-color, var(--spectrum-slider-ramp-track-color))); - } -} - -.spectrum-Slider-handle { - border-color: var(--highcontrast-slider-handle-border-color, var(--mod-slider-handle-border-color, var(--spectrum-slider-handle-border-color))); - background: var(--highcontrast-slider-handle-background-color, var(--mod-slider-handle-background-color, var(--spectrum-slider-handle-background-color))); - - &:hover { - border-color: var(--highcontrast-slider-handle-border-color-hover, var(--mod-slider-handle-border-color-hover, var(--spectrum-slider-handle-border-color-hover))); - } - - /* Keyboard focused with focus indicator. */ - &.is-focused { - border-color: var(--highcontrast-slider-handle-border-color-key-focus, var(--mod-slider-handle-border-color-key-focus, var(--spectrum-slider-handle-border-color-key-focus))); - +.spectrum-Slider--emphasized { + .spectrum-Slider-track:first-child, + &.spectrum-Slider--range .spectrum-Slider-track:not(:first-of-type, :last-of-type), + .spectrum-Slider-fill { &::before { - box-shadow: 0 0 0 var(--spectrum-focus-indicator-thickness) var(--highcontrast-slider-handle-focus-ring-color-key-focus, var(--mod-slider-handle-focus-ring-color-key-focus, var(--spectrum-slider-handle-focus-ring-color-key-focus))); + background: var(--highcontrast-slider-filled-track-fill-color, var(--mod-slider-emphasized-track-fill-color, var(--spectrum-slider-emphasized-track-fill-color))); } } - &:active, - &.is-dragged { - border-color: var(--highcontrast-slider-handle-border-color-down, var(--mod-slider-handle-border-color-down, var(--spectrum-slider-handle-border-color-down))); + .spectrum-Slider-ramp .spectrum-Slider-ramp-track-fill { + fill: var(--spectrum-slider-emphasized-track-fill-color); } } -.spectrum-Slider--ramp { - .spectrum-Slider-handle { - box-shadow: 0 0 0 var(--spectrum-slider-handle-gap) var(--highcontrast-slider-ramp-handle-border-color-active, var(--mod-sectrum-slider-ramp-handle-border-color-active, var(--spectrum-slider-ramp-handle-border-color-active))); - background: var(--mod-slider-ramp-handle-background-color, var(--highcontrast-slider-ramp-handle-background-color, var(--spectrum-slider-ramp-handle-background-color))); +.spectrum-Slider-ramp { + .spectrum-Slider-ramp-track { + fill: var(--highcontrast-slider-ramp-track-color, var(--mod-slider-ramp-track-color, var(--spectrum-slider-track-color))); + } + + .spectrum-Slider-ramp-track-fill { + fill: var(--highcontrast-slider-filled-track-fill-color, var(--mod-slider-ramp-track-fill-color, var(--spectrum-slider-track-fill-color))); } } @@ -610,16 +692,30 @@ background: transparent; } -.spectrum-Slider-tick { - &::after { - background-color: var(--highcontrast-slider-tick-mark-color, var(--mod-slider-tick-mark-color, var(--spectrum-slider-tick-mark-color))); +.spectrum-Slider--emphasized { + .spectrum-Slider-tick:nth-child(-n + 4) { + &::after { + background-color: var(--highcontrast-slider-tick-mark-color-filled-track, var(--mod-slider-emphasized-tick-mark-color, var(--spectrum-slider-emphasized-tick-mark-color))); + } } } -.spectrum-Slider-handle { - &.is-dragged { - border-color: var(--highcontrast-slider-handle-border-color-down, var(--mod-slider-handle-border-color-down, var(--spectrum-slider-handle-border-color-down))); - background: var(--highcontrast-slider-handle-background-color, var(--mod-slider-handle-background-color, var(--spectrum-slider-handle-background-color))); +.spectrum-Slider--filled, +.spectrum-Slider--offset { + &:not(.spectrum-Slider--range, .is-disabled, .spectrum-Slider--emphasized) .spectrum-Slider-tick:nth-child(-n + 4) { + &::after { + background-color: var(--highcontrast-slider-tick-mark-color-filled-track, var(--mod-slider-tick-mark-color-filled-track, var(--spectrum-slider-tick-mark-color-filled-track))); + } + } +} + +.spectrum-Slider--range { + .spectrum-Slider-tick:nth-child(3), + .spectrum-Slider-tick:nth-child(4), + .spectrum-Slider-tick:nth-child(5) { + &::after { + background-color: var(--highcontrast-slider-tick-mark-color-filled-track, var(--mod-slider-tick-mark-color-filled-track, var(--spectrum-slider-tick-mark-color-filled-track))); + } } } @@ -630,6 +726,17 @@ border-start-end-radius: 0; border-end-end-radius: 0; } + + &:first-of-type::before { + background: var(--highcontrast-slider-track-color, var(--mod-slider-track-fill-color, var(--spectrum-slider-track-color))); + } + } +} + +.spectrum-Slider-tick, +.spectrum-Slider.is-disabled .spectrum-Slider-tick { + &::after { + background-color: var(--highcontrast-slider-tick-mark-color, var(--mod-slider-tick-mark-color, var(--spectrum-slider-tick-mark-color))); } } @@ -650,15 +757,14 @@ .spectrum-Slider-handle { border-color: var(--highcontrast-slider-handle-border-color-disabled, var(--mod-slider-handle-border-color-disabled, var(--spectrum-slider-handle-border-color-disabled))); - background: var(--highcontrast-slider-handle-disabled-background-color, var(--mod-slider-handle-disabled-background-color, var(--spectrum-slider-handle-disabled-background-color))); + background: var(--highcontrast-slider-handle-disabled-background-color, var(--mod-slider-handle-disabled-background-color, var(--spectrum-slider-handle-background-color-disabled))); cursor: default; pointer-events: none; &:hover, &:active { - /* @todo need to update --mod with a component-specific prefix */ - border-color: var(--mod-disabled-border-color, var(--spectrum-disabled-border-color)); - background: var(--highcontrast-slider-handle-background-color-disabled, var(--mod-slider-handle-background-color-disabled, var(--spectrum-slider-handle-background-color-disabled))); + border-color: var(--highcontrast-slider-handle-border-color-disabled, var(--mod-slider-disabled-border-color, var(--spectrum-slider-handle-border-color-disabled))); + background: var(--highcontrast-slider-handle-disabled-background-color, var(--mod-slider-handle-background-color-disabled, var(--spectrum-slider-handle-background-color-disabled))); } } @@ -688,7 +794,7 @@ .spectrum-Slider-tick { &::after { - background-color: var(--highcontrast-slider-tick-mark-color-disabled, var(--mod-slider-tick-mark-color-disabled, var(--spectrum-slider-tick-mark-color-disabled))); + background-color: var(--highcontrast-slider-tick-mark-color-disabled, var(--mod-slider-tick-mark-color, var(--spectrum-slider-tick-mark-color))); } } @@ -699,6 +805,16 @@ } } +/* Highly specific override: ensure precise handle focus ring matches the thin handle shape for enabled sliders */ +.spectrum-Slider.spectrum-Slider--precise:not(.is-disabled) .spectrum-Slider-handle.is-focused::before, +.spectrum-Slider.spectrum-Slider--precise:not(.is-disabled) .spectrum-Slider-handle:focus::before, +.spectrum-Slider.spectrum-Slider--precise:not(.is-disabled) .spectrum-Slider-handle:focus-visible::before { + border-radius: var(--spectrum-slider-handle-border-radius); + block-size: calc(var(--spectrum-slider-precision-handle-height) + var(--spectrum-slider-focus-indicator-gap) * 2); + inline-size: calc(var(--spectrum-slider-precision-handle-width) + var(--spectrum-slider-focus-indicator-gap) * 2); + transition: none; +} + @media (forced-colors: active) { .spectrum-Slider { --highcontrast-slider-track-color: ButtonText; @@ -711,6 +827,7 @@ --highcontrast-slider-ramp-track-color-disabled: GrayText; --highcontrast-slider-tick-mark-color: ButtonText; --highcontrast-slider-tick-mark-color-disabled: GrayText; + --highcontrast-slider-tick-mark-color-filled-track: Highlight; --highcontrast-slider-handle-border-color: ButtonText; --highcontrast-slider-handle-border-color-hover: Highlight; @@ -719,12 +836,7 @@ --highcontrast-slider-handle-border-color-disabled: GrayText; --highcontrast-slider-handle-focus-ring-color-key-focus: CanvasText; --highcontrast-slider-handle-background-color: ButtonFace; - --highcontrast-slider-handle-background-color-disabled: GrayText; - --highcontrast-slider-handle-disabled-background-color: GrayText; - - --highcontrast-slider-ramp-handle-border-color-active: ButtonFace; - --highcontrast-slider-ramp-handle-background-color: ButtonFace; - + --highcontrast-slider-handle-disabled-background-color: Canvas; --highcontrast-slider-label-text-color: CanvasText; --highcontrast-slider-label-text-color-disabled: GrayText; @@ -746,8 +858,6 @@ .spectrum-Slider-controls.is-focused { --highcontrast-slider-track-color: Highlight; --highcontrast-slider-handle-border-color: Highlight; - --highcontrast-slider-ramp-track-color: Highlight; - --highcontrast-slider-tick-mark-color: Highlight; } } diff --git a/components/slider/package.json b/components/slider/package.json index 14fa29d60a1..b60b9ecb833 100644 --- a/components/slider/package.json +++ b/components/slider/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/slider", - "version": "6.4.0", + "version": "7.0.0-next.4", "description": "The Spectrum CSS slider component", "license": "Apache-2.0", "author": "Adobe", @@ -19,15 +19,13 @@ "./package.json": "./package.json", "./dist/*": "./dist/*", "./index.css": "./dist/index.css", - "./index-*.css": "./dist/index-*.css", "./metadata.json": "./dist/metadata.json", - "./themes/*": "./dist/themes/*", "./stories/*": "./stories/*" }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/stepper": ">=7.0.0 <8.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/stepper": ">=8.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/stepper": { @@ -38,8 +36,8 @@ } }, "devDependencies": { - "@spectrum-css/stepper": "7.2.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/stepper": "8.0.0-next.3", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/slider/stories/slider.stories.js b/components/slider/stories/slider.stories.js index 1d6f5b9d479..3b69d70d1f5 100644 --- a/components/slider/stories/slider.stories.js +++ b/components/slider/stories/slider.stories.js @@ -1,9 +1,9 @@ import { Sizes } from "@spectrum-css/preview/decorators"; import { disableDefaultModes } from "@spectrum-css/preview/modes"; -import { isDisabled, isFocused, size } from "@spectrum-css/preview/types"; +import { isActive, isDisabled, isEmphasized, isFocused, isHovered, size } from "@spectrum-css/preview/types"; import metadata from "../dist/metadata.json"; import packageJson from "../package.json"; -import { SliderGroup } from "./slider.test.js"; +import { SliderGroup, VariantGroup } from "./slider.test.js"; import { Template } from "./template.js"; /** @@ -71,8 +71,19 @@ export default { control: "select", options: ["ramp", "offset", "filled"], }, + trackHeight: { + name: "Track height", + type: { name: "string" }, + table: { + type: { summary: "string" }, + category: "Component", + }, + control: "select", + options: ["medium", "large"], + if: { arg: "variant", neq: "ramp" }, + }, labelPosition: { - name: "Label Position", + name: "Label position", type: { name: "string" }, table: { type: { summary: "string" }, @@ -81,8 +92,9 @@ export default { control: "select", options: ["top", "side"], }, - fillColor: { - name: "Fill color", + trackColor: { + name: "Track color", + description: "Supports standard color input or any valid input for the background property such as, linear-gradient(red, blue) or transparent. Not available for ramp variant.", type: { name: "string" }, table: { type: { summary: "string" }, @@ -112,26 +124,58 @@ export default { control: "boolean", if: { arg: "showTicks", truthy: true }, }, + isPrecise: { + name: "Precise handle control", + description: "Provides precise control for accurate values.", + type: { name: "boolean" }, + table: { + type: { summary: "boolean" }, + category: "Component", + }, + control: "boolean", + }, + isEditable: { + name: "Editable text input", + description: "Enables text input to also control the slider value.", + type: { name: "boolean" }, + table: { + type: { summary: "boolean" }, + category: "Component", + }, + control: "boolean", + }, + isEmphasized, + isActive, + isHovered, isDisabled, isFocused: { ...isFocused, if: { arg: "isDisabled", truthy: false }, }, - values: { table: { disable: true } }, + values: { + table: { disable: true } + }, }, args: { rootClass: "spectrum-Slider", + isEmphasized: false, + isActive: false, + isHovered: false, isDisabled: false, isFocused: false, showTicks: false, showTickLabels: false, labelPosition: "top", - label: "Slider label", + label: "Label", size: "m", - min: 10, - max: 20, - values: [14], - step: 2, + min: 0, + max: 30, + values: [15], + step: 5, + trackHeight: "medium", + isPrecise: false, + isEditable: false, + variant: "filled", }, parameters: { actions: { @@ -146,22 +190,30 @@ export default { }, packageJson, metadata, + status: { + type: "migrated", + }, }, + tags: ["migrated"], }; /** * Sliders should always have a label. In rare cases where context is sufficient and an accessibility expert has reviewed the design, the label could be undefined. Top labels are the default and are recommended because they work better with long copy, localization, and responsive layouts. + * The track of the slider can have a fill. By default, the fill originates from the left side of the track when the global direction is LTR and from the right side of the track when the global direction is RTL. */ export const Default = SliderGroup.bind({}); -Default.args = {}; +Default.args = { + variant: "filled", +}; // ********* DOCS ONLY ********* // /** - * If a slider's label is undefined, it should still include an aria-label in HTML (depending on the context, “aria-label” or “aria-labelledby”). + * If a slider's label is undefined, it should still include an aria-label in HTML (depending on the context, "aria-label" or "aria-labelledby"). */ export const WithoutLabel = Template.bind({}); WithoutLabel.args = { label: "", + variant: "filled", }; WithoutLabel.tags = ["!dev"]; WithoutLabel.storyName = "Without label"; @@ -171,6 +223,18 @@ WithoutLabel.parameters = { }, }; +export const Editable = Template.bind({}); +Editable.args = { + ...Default.args, + isEditable: true, +}; +Editable.tags = ["!dev"]; +Editable.parameters = { + chromatic: { + disableSnapshot: true, + }, +}; + export const Sizing = (args, context) => Sizes({ Template, withBorder: false, @@ -186,31 +250,28 @@ Sizing.parameters = { }; /** - * The track of the slider can have a fill. By default, the fill originates from the left side of the track. + * If the value represents an offset, the fill start or end can be set to represent the point of origin. This allows the slider fill to extend from the origin toward the handle, in either direction along the track. */ -export const Filled = Template.bind({}); -Filled.args = { +export const Offset = Template.bind({}); +Offset.args = { ...Default.args, - variant: "filled", + variant: "offset", + values: [-15], }; -Filled.tags = ["!dev"]; -Filled.parameters = { +Offset.tags = ["!dev"]; +Offset.parameters = { chromatic: { disableSnapshot: true, }, }; -/** - * With fill and offset. If the value represents an offset, the fill start can be set to represent the point of origin. This allows the slider fill to start from inside the track. - */ -export const FilledOffset = Template.bind({}); -FilledOffset.args = { +export const Precise = Template.bind({}); +Precise.args = { ...Default.args, - min: 0, - variant: "offset", + isPrecise: true, }; -FilledOffset.tags = ["!dev"]; -FilledOffset.parameters = { +Precise.tags = ["!dev"]; +Precise.parameters = { chromatic: { disableSnapshot: true, }, @@ -234,7 +295,7 @@ Ramp.parameters = { export const Range = Template.bind({}); Range.args = { ...Default.args, - values: [14, 16], + values: [10, 20], }; Range.tags = ["!dev"]; Range.parameters = { @@ -275,6 +336,24 @@ TickWithLabels.parameters = { }; TickWithLabels.storyName = "Tick with labels"; +/** + * Large track height. + */ +export const TrackHeight = Template.bind({}); +TrackHeight.args = { + ...Default.args, + trackHeight: "large", +}; +TrackHeight.tags = ["!dev"]; +TrackHeight.parameters = { + chromatic: { + disableSnapshot: true, + }, +}; +TrackHeight.storyName = "Large track height"; + + + export const Disabled = Template.bind({}); Disabled.args = { ...Default.args, @@ -287,34 +366,25 @@ Disabled.parameters = { }, }; -export const Focused = Template.bind({}); -Focused.args = { +export const Emphasized = Template.bind({}); +Emphasized.args = { ...Default.args, - isFocused: true, + isEmphasized: true, }; -Focused.tags = ["!dev"]; -Focused.parameters = { +Emphasized.tags = ["!dev"]; +Emphasized.parameters = { chromatic: { disableSnapshot: true, }, }; -/** - * A gradient can be added to the track of any slider to give more meaning to the range of values. Tracks with a gradient can also have a fill. A gradient track should not be used for choosing a precise color; use a [color slider](/docs/components-color-slider--docs), [color area](/docs/components-color-area--docs), or [color wheel](/docs/components-color-wheel--docs) instead. - */ -export const Gradient = Template.bind({}); -Gradient.args = { +export const Focused = Template.bind({}); +Focused.args = { ...Default.args, - customStyles: { - "--spectrum-slider-track-color": - "linear-gradient(to right, red, green 100%)", - "--spectrum-slider-track-color-rtl": - "linear-gradient(to left, red, green 100%)", - }, - label: "Slider label that is long and wraps to the next line", + isFocused: true, }; -Gradient.tags = ["!dev"]; -Gradient.parameters = { +Focused.tags = ["!dev"]; +Focused.parameters = { chromatic: { disableSnapshot: true, }, @@ -345,3 +415,7 @@ WithForcedColors.parameters = { modes: disableDefaultModes, }, }; + +// test with /?path=/story/components-slider--variant-tests&globals=testingPreview:!true +export const VariantTests = VariantGroup.bind({}); +VariantTests.tags = ["!autodocs", "!dev"]; diff --git a/components/slider/stories/slider.test.js b/components/slider/stories/slider.test.js index 22777744fd4..c36e23fc5fd 100644 --- a/components/slider/stories/slider.test.js +++ b/components/slider/stories/slider.test.js @@ -1,69 +1,442 @@ -import { Variants } from "@spectrum-css/preview/decorators"; +import { Sizes, Variants } from "@spectrum-css/preview/decorators"; import { Template } from "./template.js"; -export const SliderGroup = Variants({ +export const testData = [ + // Default variants + { + testHeading: "Default filled", + variant: "filled" + }, + { + testHeading: "Precise", + variant: "filled", + isPrecise: true + }, + { + testHeading: "Large track", + variant: "filled", + trackHeight: "large" + }, + { + testHeading: "Precise large track", + variant: "filled", + isPrecise: true, + trackHeight: "large" + }, + // Ticks variants + { + testHeading: "With ticks", + variant: "filled", + showTicks: true, + showTickLabels: true + }, + { + testHeading: "Precise with ticks", + variant: "filled", + showTicks: true, + showTickLabels: true, + isPrecise: true + }, + { + testHeading: "Large track with ticks", + variant: "filled", + showTicks: true, + showTickLabels: true, + trackHeight: "large" + }, + { + testHeading: "Large track with ticks and precise", + variant: "filled", + showTicks: true, + showTickLabels: true, + isPrecise: true, + trackHeight: "large" + }, + // Side label variants + { + testHeading: "Side label", + variant: "filled", + labelPosition: "side" + }, + { + testHeading: "Side label with precise", + variant: "filled", + labelPosition: "side", + isPrecise: true + }, + { + testHeading: "Large track with side label", + variant: "filled", + labelPosition: "side", + trackHeight: "large" + }, + { + testHeading: "Side label with ticks", + variant: "filled", + labelPosition: "side", + showTicks: true, + showTickLabels: true + }, + // Editable variants + { + testHeading: "Editable", + variant: "filled", + isEditable: true + }, + { + testHeading: "Editable with precise", + variant: "filled", + isEditable: true, + isPrecise: true + }, + { + testHeading: "Editable with large track", + variant: "filled", + isEditable: true, + trackHeight: "large" + }, + { + testHeading: "Editable with side label", + variant: "filled", + isEditable: true, + labelPosition: "side" + }, + // No label variants + { + testHeading: "No label", + variant: "filled", + label: "" + }, + { + testHeading: "No label with precise", + variant: "filled", + label: "", + isPrecise: true + }, + { + testHeading: "No label with large track", + variant: "filled", + label: "", + trackHeight: "large" + }, + { + testHeading: "No label with ticks", + variant: "filled", + label: "", + showTicks: true, + showTickLabels: true + }, + { + testHeading: "No label editable", + variant: "filled", + label: "", + isEditable: true + }, + { + testHeading: "No label editable with precise", + variant: "filled", + label: "", + isEditable: true, + isPrecise: true + }, + { + testHeading: "No label editable with large track", + variant: "filled", + label: "", + isEditable: true, + trackHeight: "large" + }, + // Disabled variants + { + testHeading: "Disabled", + variant: "filled", + isDisabled: true + }, + { + testHeading: "Disabled with precise", + variant: "filled", + isDisabled: true, + isPrecise: true + }, + { + testHeading: "Disabled with precise and large track", + variant: "filled", + isDisabled: true, + isPrecise: true, + trackHeight: "large" + }, + // Emphasized variants + { + testHeading: "Emphasized", + variant: "filled", + isEmphasized: true + }, + { + testHeading: "Emphasized with precise", + variant: "filled", + isEmphasized: true, + isPrecise: true + }, + { + testHeading: "Emphasized with large track", + variant: "filled", + isEmphasized: true, + trackHeight: "large" + }, + { + testHeading: "Emphasized with ticks", + variant: "filled", + isEmphasized: true, + showTicks: true, + showTickLabels: true + }, + { + testHeading: "Emphasized with ticks and large track", + variant: "filled", + isEmphasized: true, + showTicks: true, + showTickLabels: true, + trackHeight: "large" + }, + // Sizes variants + { + testHeading: "Large track height sizes", + variant: "filled", + Template: (args, context) => { return Sizes({Template: Template, ...args}, context); }, + trackHeight: "large", + withStates: false, + }, + { + testHeading: "Large track height sizes with precise", + variant: "filled", + isPrecise: true, + Template: (args, context) => { return Sizes({Template: Template, ...args}, context); }, + trackHeight: "large", + withStates: false, + }, + { + testHeading: "Sizes with precise", + variant: "filled", + isPrecise: true, + Template: (args, context) => { return Sizes({Template: Template, ...args}, context); }, + withStates: false, + }, +]; + +const rangeTestData = [ + // Default variants + { + testHeading: "Range", + variant: "filled", + values: [10, 20] + }, + { + testHeading: "Range with precise", + variant: "filled", + values: [10, 20], + isPrecise: true + }, + { + testHeading: "Range with large track", + variant: "filled", + values: [10, 20], + trackHeight: "large" + }, + { + testHeading: "Range with precise and large track", + variant: "filled", + values: [10, 20], + isPrecise: true, + trackHeight: "large" + }, + // Ticks variants + { + testHeading: "Range with ticks and large track", + variant: "filled", + showTicks: true, + showTickLabels: true, + values: [10, 20], + trackHeight: "large" + }, + // Side label variants + { + testHeading: "Range with side label", + variant: "filled", + labelPosition: "side", + values: [10, 20] + }, + // No label variants + { + testHeading: "Range with no label", + variant: "filled", + label: "", + values: [10, 20] + }, + // Emphasized variants + { + testHeading: "Emphasized range", + variant: "filled", + isEmphasized: true, + values: [10, 20] + }, + { + testHeading: "Emphasized range with precise", + variant: "filled", + isEmphasized: true, + values: [10, 20], + isPrecise: true + }, + { + testHeading: "Emphasized range with large track", + variant: "filled", + isEmphasized: true, + values: [10, 20], + trackHeight: "large" + }, + { + testHeading: "Emphasized range with precise and large track", + variant: "filled", + isEmphasized: true, + values: [10, 20], + isPrecise: true, + trackHeight: "large" + }, + { + testHeading: "Emphasized range with side label", + variant: "filled", + isEmphasized: true, + values: [10, 20], + labelPosition: "side" + }, + { + testHeading: "Emphasized range with editable", + variant: "filled", + isEmphasized: true, + values: [10, 20], + isEditable: true + }, + { + testHeading: "Emphasized range with no label", + variant: "filled", + isEmphasized: true, + values: [10, 20], + label: "" + }, +]; + +const rampTestData = [ + // Default variants + { + testHeading: "Ramp", + variant: "ramp" + }, + { + testHeading: "Ramp with precise", + variant: "ramp", + isPrecise: true + }, +]; + +const offsetTestData = [ + // Default variants + { + testHeading: "Offset", + variant: "offset", + values: [-15] + }, + { + testHeading: "Offset with precise", + variant: "offset", + values: [-15], + isPrecise: true + }, + { + testHeading: "Offset with large track", + variant: "offset", + values: [-15], + trackHeight: "large" + }, + { + testHeading: "Offset with precise and large track", + variant: "offset", + values: [-15], + isPrecise: true, + trackHeight: "large" + }, + // Ticks variants + { + testHeading: "Offset with ticks and large track", + variant: "offset", + showTicks: true, + showTickLabels: true, + values: [-15], + trackHeight: "large" + }, + // Side label variants + { + testHeading: "Offset with side label", + variant: "offset", + labelPosition: "side", + values: [-15] + }, + // Editable variants + { + testHeading: "Offset with editable", + variant: "offset", + isEditable: true, + values: [-15] + }, + // No label variants + { + testHeading: "Offset with no label", + variant: "offset", + label: "", + values: [-15] + }, + { + testHeading: "Offset with no label and editable", + variant: "offset", + label: "", + isEditable: true, + values: [-15] + }, + // Emphasized variants + { + testHeading: "Emphasized offset", + variant: "offset", + isEmphasized: true, + values: [-15] + }, +]; + +// Helper function to create a group with specific test data +const createGroup = (testData) => Variants({ Template, - testData: [ - { - testHeading: "Default", - }, - { - testHeading: "Without label", - label: undefined, - }, - { - testHeading: "Filled", - variant: "filled", - }, - { - testHeading: "Filled offset", - variant: "offset", - min: 0, - }, - { - testHeading: "Ramp", - variant: "ramp", - }, - { - testHeading: "Range", - values: [14, 16], - }, + testData, + stateData: [ { - testHeading: "Tick", - showTicks: true, + testHeading: "Hovered", + isHovered: true }, { - testHeading: "Tick with labels", - showTicks: true, - showTickLabels: true, + testHeading: "Active", + isActive: true }, { - testHeading: "Side label", - labelPosition: "side", + testHeading: "Focused", + isFocused: true }, { - testHeading: "Gradient", - customStyles: { - "--spectrum-slider-track-color": - "linear-gradient(to right, red, green 100%)", - "--spectrum-slider-track-color-rtl": - "linear-gradient(to left, red, green 100%)", - }, + testHeading: "Focused + Hovered", + isFocused: true, + isHovered: true }, - { - testHeading: "Truncation", - withStates: false, - label: "Slider label that is long and wraps to the next line", - } - ], - stateData: [ { testHeading: "Disabled", - isDisabled: true, - }, - { - testHeading: "Focused", - isFocused: true, - }, + isDisabled: true + } ] }); + +export const SliderGroup = createGroup(testData); +export const VariantGroup = createGroup([...rangeTestData, ...rampTestData, ...offsetTestData]); diff --git a/components/slider/stories/template.js b/components/slider/stories/template.js index c69a96b487a..e70fde57663 100644 --- a/components/slider/stories/template.js +++ b/components/slider/stories/template.js @@ -1,5 +1,6 @@ import { Template as FieldLabel } from "@spectrum-css/fieldlabel/stories/template.js"; import { getRandomId } from "@spectrum-css/preview/decorators"; +import { Template as TextField } from "@spectrum-css/textfield/stories/template.js"; import { html } from "lit"; import { classMap } from "lit/directives/class-map.js"; import { ifDefined } from "lit/directives/if-defined.js"; @@ -7,35 +8,53 @@ import { styleMap } from "lit/directives/style-map.js"; import { when } from "lit/directives/when.js"; import "../index.css"; -import "../themes/spectrum.css"; -/* Must be imported last */ -import "../themes/express.css"; export const Template = ({ rootClass = "spectrum-Slider", size, label, min = 0, - max = 10, + max = 15, step = 2, values = [], variant, + trackHeight, labelPosition, - fillColor, + trackColor, showTicks = false, showTickLabels = false, isDisabled = false, + isHovered = false, + isActive = false, isFocused = false, + isPrecise = false, + isEditable = false, + isEmphasized = false, customClasses = [], customStyles = {}, id = getRandomId("slider"), } = {}, context = {}) => { - const { globals = {}, updateArgs } = context; + // Auto-set values and range for offset variant + let finalValues = values; + let finalMin = min; + let finalMax = max; + if (variant === "offset") { + // Only set default value if no values are provided + if (values.length === 0) { + finalValues = [0]; // Default to center (0) + } + finalMin = -15; // Left edge = negative + finalMax = 15; // Right edge = positive + } + + const { globals = {}, updateArgs } = context; + let fillPercentage = 50; const isRTL = globals.textDirection !== "rtl"; - const rangeLength = max - min; - const centerPoint = rangeLength / 2 + min; + const rangeLength = finalMax - finalMin; + const centerPoint = rangeLength / 2 + finalMin; const isRamp = variant === "ramp"; + const maskWidth = (fillPercentage / 100) * 240; const rampSVG = html` `; - const getPosition = (v) => ((v - min) / rangeLength) * 100; + const getPosition = (v) => ((v - finalMin) / rangeLength) * 100; const getWidth = (start, end) => { const distance = end > start ? end - start : start - end; @@ -71,7 +96,10 @@ export const Template = ({ const ticks = []; for (let i = from; i <= to; i += step) { ticks.push(html` -
+
${when(showTickLabels, () => html`${i}`, undefined)}
@@ -87,13 +115,20 @@ export const Template = ({
1, + [`${rootClass}--offset`]: variant === "offset", + [`${rootClass}--range`]: finalValues.length > 1, [`${rootClass}--filled`]: variant === "filled", [`${rootClass}--tick`]: showTicks, + [`${rootClass}--track-height-${trackHeight}`]: trackHeight, + [`${rootClass}--precise`]: isPrecise, + [`${rootClass}--emphasized`]: isEmphasized, "is-disabled": isDisabled, [`${rootClass}--sideLabel`]: labelPosition === "side", ...customClasses.reduce((a, c) => ({ ...a, [c]: true }), {}), })} id=${ifDefined(id)} style=${styleMap({ - "--spectrum-slider-track-color": fillColor ? fillColor : undefined, - "inline-size": "240px", + "--spectrum-slider-track-color": trackColor ? trackColor : undefined, ...customStyles, })} - role=${ifDefined(values.length > 1 ? "group" : undefined)} + role=${ifDefined(finalValues.length > 1 ? "group" : undefined)} aria-labelledby=${ifDefined(label && id ? `${id}-label` : undefined)} @focusin=${function() { updateArgs({ isFocused: true }); @@ -144,7 +183,7 @@ export const Template = ({ ${when(label, () => html`
1 ? "presentation" : undefined)} + role=${ifDefined(finalValues.length > 1 ? "presentation" : undefined)} > ${FieldLabel({ size, @@ -154,7 +193,7 @@ export const Template = ({ forInput: id ? `${id}-1` : undefined, customClasses: [`${rootClass}-label`], }, context)} - ${when(values.length && labelPosition != "side", () => html` + ${when(finalValues.length && labelPosition != "side" && !isEditable, () => html`
- ${values[0]}${values.length > 1 ? ` - ${values[1]}` : ""} + ${finalValues[0]}${finalValues.length > 1 ? ` - ${finalValues[1]}` : ""}
`)}
`)} +
- ${values.map((value, idx) => { - const prevPoint = idx === 0 ? min : values[idx - 1]; + ${finalValues.map((value, idx) => { + const prevPoint = idx === 0 ? finalMin : finalValues[idx - 1]; const isFirst = idx === 0; - const isLast = idx === values.length - 1; + const isLast = idx === finalValues.length - 1; return [ !isRamp ? renderTrack({ @@ -192,7 +235,7 @@ export const Template = ({ ? html`
${rampSVG}
` : "", isFirst && showTicks && !isRamp - ? renderTick({ from: min, to: max }) + ? renderTick({ from: finalMin, to: finalMax }) : "", renderHandle({ position: getPosition(value), @@ -200,7 +243,7 @@ export const Template = ({ idx, }), isLast && !isRamp - ? renderTrack({ width: getWidth(value, max) }) + ? renderTrack({ width: getWidth(value, finalMax) }) : "", isLast && variant === "offset" ? html`
centerPoint - ? getPosition(centerPoint) - : getPosition(value) - }%`, - width: `${getWidth(value, centerPoint)}%`, + [isRTL ? "right" : "left"]: `${getPosition(centerPoint)}%`, + width: `${getWidth(centerPoint, value)}%`, }) )} >
` @@ -223,10 +262,22 @@ export const Template = ({ ]; })}
- ${when(values.length && labelPosition === "side", () => html` + ${when(isEditable, () => html` + ${TextField({ + value: finalValues[0], + id: id ? `${id}-offset` : undefined, + customClasses: [`${rootClass}-editable`], + isFocused, + isKeyboardFocused: isFocused, + isDisabled, + size, + }, context)} + `)} +
+ ${when(finalValues.length && labelPosition === "side" && !isEditable, () => html`
1 ? "presentation" : undefined)} + role=${ifDefined(finalValues.length > 1 ? "presentation" : undefined)} >
- ${values[0]}${values.length > 1 ? ` - ${values[1]}` : ""} + ${finalValues[0]}${finalValues.length > 1 ? ` - ${finalValues[1]}` : ""}
`)} diff --git a/components/slider/themes/express.css b/components/slider/themes/express.css deleted file mode 100644 index f9f149f4d93..00000000000 --- a/components/slider/themes/express.css +++ /dev/null @@ -1,39 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--express */ - -@import "./spectrum.css"; - -@container style(--system: express) { - .spectrum-Slider { - --spectrum-slider-track-color: var(--spectrum-gray-200); - --spectrum-slider-track-fill-color: var(--spectrum-gray-600); - --spectrum-slider-ramp-track-color: var(--spectrum-gray-300); - --spectrum-slider-ramp-track-color-disabled: var(--spectrum-gray-200); - - --spectrum-slider-handle-background-color: var(--spectrum-gray-50); - --spectrum-slider-handle-background-color-disabled: var(--spectrum-gray-50); - --spectrum-slider-ramp-handle-background-color: var(--spectrum-gray-50); - --spectrum-slider-ticks-handle-background-color: var(--spectrum-gray-50); - --spectrum-slider-handle-border-color: var(--spectrum-gray-800); - --spectrum-slider-handle-disabled-background-color: var(--spectrum-gray-50); - - --spectrum-slider-tick-mark-color: var(--spectrum-gray-200); - - --spectrum-slider-handle-border-color-hover: var(--spectrum-gray-900); - --spectrum-slider-handle-border-color-down: var(--spectrum-gray-900); - --spectrum-slider-handle-border-color-key-focus: var(--spectrum-gray-900); - --spectrum-slider-handle-focus-ring-color-key-focus: var(--spectrum-focus-indicator-color); - } -} diff --git a/components/slider/themes/spectrum-two.css b/components/slider/themes/spectrum-two.css deleted file mode 100644 index b118d77cffd..00000000000 --- a/components/slider/themes/spectrum-two.css +++ /dev/null @@ -1,54 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -@container style(--system: spectrum) { - .spectrum-Slider { - --spectrum-slider-track-color: var(--spectrum-gray-200); - --spectrum-slider-track-fill-color: var(--spectrum-gray-700); - --spectrum-slider-ramp-track-color: var(--spectrum-gray-400); - --spectrum-slider-ramp-track-color-disabled: var(--spectrum-gray-100); - - --spectrum-slider-handle-background-color: transparent; - --spectrum-slider-handle-background-color-disabled: transparent; - --spectrum-slider-ramp-handle-background-color: var(--spectrum-gray-75); - --spectrum-slider-ticks-handle-background-color: var(--spectrum-gray-75); - --spectrum-slider-handle-border-color: var(--spectrum-gray-700); - --spectrum-slider-handle-disabled-background-color: var(--spectrum-gray-75); - - --spectrum-slider-tick-mark-color: var(--spectrum-gray-200); - - --spectrum-slider-handle-border-color-hover: var(--spectrum-gray-800); - --spectrum-slider-handle-border-color-down: var(--spectrum-gray-800); - --spectrum-slider-handle-border-color-key-focus: var(--spectrum-gray-800); - --spectrum-slider-handle-focus-ring-color-key-focus: var(--spectrum-focus-indicator-color); - - --spectrum-slider-track-corner-radius: 2px; - - &, - &.spectrum-Slider--sizeM { - --spectrum-slider-handle-border-radius: var(--spectrum-corner-radius-500); - } - - &.spectrum-Slider--sizeS { - --spectrum-slider-handle-border-radius: var(--spectrum-corner-radius-500); - } - - &.spectrum-Slider--sizeL { - --spectrum-slider-handle-border-radius: calc(var(--spectrum-corner-radius-500) * 4); - } - - &.spectrum-Slider--sizeXL { - --spectrum-slider-handle-border-radius: calc(var(--spectrum-corner-radius-500) * 4); - } - } -} diff --git a/components/slider/themes/spectrum.css b/components/slider/themes/spectrum.css deleted file mode 100644 index f411427cc8d..00000000000 --- a/components/slider/themes/spectrum.css +++ /dev/null @@ -1,45 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--legacy */ - -@import "./spectrum-two.css"; - -@container style(--system: legacy) { - .spectrum-Slider { - --spectrum-slider-track-color: var(--spectrum-gray-300); - --spectrum-slider-ramp-track-color-disabled: var(--spectrum-gray-200); - --spectrum-slider-ramp-handle-background-color: var(--spectrum-gray-100); - --spectrum-slider-ticks-handle-background-color: var(--spectrum-gray-100); - --spectrum-slider-handle-disabled-background-color: var(--spectrum-gray-100); - --spectrum-slider-tick-mark-color: var(--spectrum-gray-300); - --spectrum-slider-track-corner-radius: var(--spectrum-corner-radius-75); - - &, - &.spectrum-Slider--sizeM { - --spectrum-slider-handle-border-radius: var(--spectrum-corner-radius-200); - } - - &.spectrum-Slider--sizeS { - --spectrum-slider-handle-border-radius: var(--spectrum-corner-radius-200); - } - - &.spectrum-Slider--sizeL { - --spectrum-slider-handle-border-radius: calc(var(--spectrum-corner-radius-200) * 4); - } - - &.spectrum-Slider--sizeXL { - --spectrum-slider-handle-border-radius: calc(var(--spectrum-corner-radius-200) * 4); - } - } -} diff --git a/components/splitview/CHANGELOG.md b/components/splitview/CHANGELOG.md index 49bf0297629..917b2a6709b 100644 --- a/components/splitview/CHANGELOG.md +++ b/components/splitview/CHANGELOG.md @@ -1,5 +1,12 @@ # Change log +## 8.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + ## 7.2.0 ### Minor Changes diff --git a/components/splitview/dist/metadata.json b/components/splitview/dist/metadata.json index 4902e8e2368..c6925723f7c 100644 --- a/components/splitview/dist/metadata.json +++ b/components/splitview/dist/metadata.json @@ -81,11 +81,6 @@ "--spectrum-gray-75", "--spectrum-gray-800" ], - "system-theme": [ - "--system-split-view-background-color", - "--system-split-view-gripper-border-radius", - "--system-split-view-handle-background-color" - ], "passthroughs": [], "high-contrast": [ "--highcontrast-splitview-handle-background-color", diff --git a/components/splitview/index.css b/components/splitview/index.css index 81ca706a34d..990108806d3 100644 --- a/components/splitview/index.css +++ b/components/splitview/index.css @@ -11,9 +11,11 @@ * governing permissions and limitations under the License. */ -@import "./themes/spectrum-two.css"; - .spectrum-SplitView { + --spectrum-splitview-background-color: var(--spectrum-gray-75); + --spectrum-splitview-handle-background-color: var(--spectrum-gray-200); + --spectrum-splitview-gripper-border-radius: 2px; + --spectrum-splitview-vertical-width: 100%; --spectrum-splitview-vertical-gripper-width: 50%; --spectrum-splitview-vertical-gripper-outer-width: 100%; diff --git a/components/splitview/package.json b/components/splitview/package.json index faf42fd57b9..4cc14111095 100644 --- a/components/splitview/package.json +++ b/components/splitview/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/splitview", - "version": "7.2.0", + "version": "8.0.0-next.0", "description": "The Spectrum CSS splitview component", "license": "Apache-2.0", "author": "Adobe", @@ -19,14 +19,12 @@ "./package.json": "./package.json", "./dist/*": "./dist/*", "./index.css": "./dist/index.css", - "./index-*.css": "./dist/index-*.css", "./metadata.json": "./dist/metadata.json", - "./themes/*": "./dist/themes/*", "./stories/*": "./stories/*" }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/tokens": ">=16.0.1" + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/tokens": { @@ -34,7 +32,7 @@ } }, "devDependencies": { - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/splitview/stories/splitview.stories.js b/components/splitview/stories/splitview.stories.js index 1c615f12b97..1753faa5214 100644 --- a/components/splitview/stories/splitview.stories.js +++ b/components/splitview/stories/splitview.stories.js @@ -81,7 +81,11 @@ export default { parameters: { packageJson, metadata, + status: { + type: "unmigrated", + }, }, + tags: ["unmigrated"], }; export const Horizontal = SplitViewGroup.bind({}); diff --git a/components/splitview/stories/splitview.test.js b/components/splitview/stories/splitview.test.js index d8236478d94..399fa9f4dd4 100644 --- a/components/splitview/stories/splitview.test.js +++ b/components/splitview/stories/splitview.test.js @@ -32,14 +32,14 @@ export const SplitViewGroup = Variants({ }, { testHeading: "Top collapsed", - orientation: "horizontal", + orientation: "vertical", collapsePosition: "top", panelLabels: ["Top", "Bottom"], panelStyles: ["height: 0;", "flex: 1;"], }, { testHeading: "Bottom collapsed", - orientation: "horizontal", + orientation: "vertical", collapsePosition: "bottom", panelLabels: ["Top", "Bottom"], panelStyles: ["flex: 1;", "height: 0;"], @@ -47,16 +47,19 @@ export const SplitViewGroup = Variants({ ], stateData: [ { - testHeading: "Focused", - isFocused: true, + testHeading: "Resizable/collapsible", + isResizable: true, + isCollapsible: true, }, { - testHeading: "Collapsible", - isCollapsible: true, + testHeading: "Resizable, focused", + isFocused: true, + isResizable: true, }, { - testHeading: "Resizable", + testHeading: "Resizable, active", isResizable: true, + isActive: true, }, ] }); diff --git a/components/splitview/stories/template.js b/components/splitview/stories/template.js index 4fb08b911dd..b133ceb0518 100644 --- a/components/splitview/stories/template.js +++ b/components/splitview/stories/template.js @@ -3,9 +3,6 @@ import { classMap } from "lit/directives/class-map.js"; import { when } from "lit/directives/when.js"; import "../index.css"; -import "../themes/spectrum.css"; -/* Must be imported last */ -import "../themes/express.css"; export const Template = ({ rootClass = "spectrum-SplitView", @@ -13,6 +10,7 @@ export const Template = ({ orientation = "horizontal", isResizable = false, isFocused = false, + isActive = false, isCollapsible = false, collapsePosition, panelLabels = [], @@ -49,7 +47,8 @@ export const Template = ({ class=${classMap({ [`${rootClass}-splitter`]: true, ["is-draggable"]: isResizable, - "is-focused": isFocused, + ["is-active"]: isActive, + ["is-focus-visible"]: isFocused, [`is-collapsed-${collapsibleClassName}`]: isCollapsible, })} tabindex="0" diff --git a/components/splitview/themes/express.css b/components/splitview/themes/express.css deleted file mode 100644 index 9fd550418f2..00000000000 --- a/components/splitview/themes/express.css +++ /dev/null @@ -1,16 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--express */ - -@import "./spectrum.css"; diff --git a/components/splitview/themes/spectrum-two.css b/components/splitview/themes/spectrum-two.css deleted file mode 100644 index 14ef6131e5a..00000000000 --- a/components/splitview/themes/spectrum-two.css +++ /dev/null @@ -1,20 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -@container style(--system: spectrum) { - .spectrum-SplitView { - --spectrum-splitview-background-color: var(--spectrum-gray-75); - --spectrum-splitview-handle-background-color: var(--spectrum-gray-200); - --spectrum-splitview-gripper-border-radius: 2px; - } -} diff --git a/components/splitview/themes/spectrum.css b/components/splitview/themes/spectrum.css deleted file mode 100644 index 209e46a4b3b..00000000000 --- a/components/splitview/themes/spectrum.css +++ /dev/null @@ -1,24 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--legacy */ - -@import "./spectrum-two.css"; - -@container style(--system: legacy) { - .spectrum-SplitView { - --spectrum-splitview-background-color: var(--spectrum-gray-100); - --spectrum-splitview-handle-background-color: var(--spectrum-gray-300); - --spectrum-splitview-gripper-border-radius: var(--spectrum-corner-radius-75); - } -} diff --git a/components/statuslight/CHANGELOG.md b/components/statuslight/CHANGELOG.md index 77025c40c83..e7dc46d479c 100644 --- a/components/statuslight/CHANGELOG.md +++ b/components/statuslight/CHANGELOG.md @@ -1,5 +1,31 @@ # Change log +## 10.0.0-next.2 + +### Patch Changes + +- [#3687](https://github.com/adobe/spectrum-css/pull/3687) [`53d1e5e`](https://github.com/adobe/spectrum-css/commit/53d1e5e7eb7817c37be3cfe5a253363dea744046) Thanks [@marissahuysentruyt](https://github.com/marissahuysentruyt)! - ### S2 status light fix + + This work removes the reference to `default-font-family` in favor for `sans-font-family-stack` to ensure the status light's font renders appropriately for web. + +## 10.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + +## 9.1.1-next.0 + +### Patch Changes + +- [#2352](https://github.com/adobe/spectrum-css/pull/2352) [`dce3669`](https://github.com/adobe/spectrum-css/commit/dce366923562d004c61e8a19da216f6ea6a11d40) Thanks [@pfulton](https://github.com/pfulton)! - Removes references to the accent variant, since the accent status light was deprecated in S2. + + Removed variant: + + `.spectrum-StatusLight--accent` + `--spectrum-statuslight-semantic-accent-color` + ## 9.2.0 ### Minor Changes diff --git a/components/statuslight/dist/metadata.json b/components/statuslight/dist/metadata.json index 7c7c6a7587f..07f3510d851 100644 --- a/components/statuslight/dist/metadata.json +++ b/components/statuslight/dist/metadata.json @@ -2,10 +2,11 @@ "sourceFile": "index.css", "selectors": [ ".spectrum-StatusLight", - ".spectrum-StatusLight--accent:before", ".spectrum-StatusLight--blue:before", + ".spectrum-StatusLight--brown:before", ".spectrum-StatusLight--celery:before", ".spectrum-StatusLight--chartreuse:before", + ".spectrum-StatusLight--cinnamon:before", ".spectrum-StatusLight--cyan:before", ".spectrum-StatusLight--fuchsia:before", ".spectrum-StatusLight--gray:before", @@ -18,14 +19,16 @@ ".spectrum-StatusLight--neutral:before", ".spectrum-StatusLight--notice:before", ".spectrum-StatusLight--orange:before", + ".spectrum-StatusLight--pink:before", ".spectrum-StatusLight--positive:before", ".spectrum-StatusLight--purple:before", ".spectrum-StatusLight--red:before", ".spectrum-StatusLight--seafoam:before", + ".spectrum-StatusLight--silver:before", ".spectrum-StatusLight--sizeL", - ".spectrum-StatusLight--sizeM", ".spectrum-StatusLight--sizeS", ".spectrum-StatusLight--sizeXL", + ".spectrum-StatusLight--turquoise:before", ".spectrum-StatusLight--yellow:before", ".spectrum-StatusLight:before", ".spectrum-StatusLight:lang(ja)", @@ -37,14 +40,18 @@ "--mod-statuslight-content-color-default", "--mod-statuslight-corner-radius", "--mod-statuslight-dot-size", + "--mod-statuslight-font-family", "--mod-statuslight-font-size", + "--mod-statuslight-font-style", "--mod-statuslight-font-weight", "--mod-statuslight-height", "--mod-statuslight-line-height", "--mod-statuslight-line-height-cjk", "--mod-statuslight-nonsemantic-blue-color", + "--mod-statuslight-nonsemantic-brown-color", "--mod-statuslight-nonsemantic-celery-color", "--mod-statuslight-nonsemantic-chartreuse-color", + "--mod-statuslight-nonsemantic-cinnamon-color", "--mod-statuslight-nonsemantic-cyan-color", "--mod-statuslight-nonsemantic-fuchsia-color", "--mod-statuslight-nonsemantic-gray-color", @@ -52,11 +59,13 @@ "--mod-statuslight-nonsemantic-indigo-color", "--mod-statuslight-nonsemantic-magenta-color", "--mod-statuslight-nonsemantic-orange-color", + "--mod-statuslight-nonsemantic-pink-color", "--mod-statuslight-nonsemantic-purple-color", "--mod-statuslight-nonsemantic-red-color", "--mod-statuslight-nonsemantic-seafoam-color", + "--mod-statuslight-nonsemantic-silver-color", + "--mod-statuslight-nonsemantic-turquoise-color", "--mod-statuslight-nonsemantic-yellow-color", - "--mod-statuslight-semantic-accent-color", "--mod-statuslight-semantic-info-color", "--mod-statuslight-semantic-negative-color", "--mod-statuslight-semantic-neutral-color", @@ -73,6 +82,10 @@ "--spectrum-status-light-dot-size-large", "--spectrum-status-light-dot-size-medium", "--spectrum-status-light-dot-size-small", + "--spectrum-status-light-text-to-visual-100", + "--spectrum-status-light-text-to-visual-200", + "--spectrum-status-light-text-to-visual-300", + "--spectrum-status-light-text-to-visual-75", "--spectrum-status-light-top-to-dot-extra-large", "--spectrum-status-light-top-to-dot-large", "--spectrum-status-light-top-to-dot-medium", @@ -81,14 +94,18 @@ "--spectrum-statuslight-content-color-default", "--spectrum-statuslight-corner-radius", "--spectrum-statuslight-dot-size", + "--spectrum-statuslight-font-family", "--spectrum-statuslight-font-size", + "--spectrum-statuslight-font-style", "--spectrum-statuslight-font-weight", "--spectrum-statuslight-height", "--spectrum-statuslight-line-height", "--spectrum-statuslight-line-height-cjk", "--spectrum-statuslight-nonsemantic-blue-color", + "--spectrum-statuslight-nonsemantic-brown-color", "--spectrum-statuslight-nonsemantic-celery-color", "--spectrum-statuslight-nonsemantic-chartreuse-color", + "--spectrum-statuslight-nonsemantic-cinnamon-color", "--spectrum-statuslight-nonsemantic-cyan-color", "--spectrum-statuslight-nonsemantic-fuchsia-color", "--spectrum-statuslight-nonsemantic-gray-color", @@ -96,11 +113,13 @@ "--spectrum-statuslight-nonsemantic-indigo-color", "--spectrum-statuslight-nonsemantic-magenta-color", "--spectrum-statuslight-nonsemantic-orange-color", + "--spectrum-statuslight-nonsemantic-pink-color", "--spectrum-statuslight-nonsemantic-purple-color", "--spectrum-statuslight-nonsemantic-red-color", "--spectrum-statuslight-nonsemantic-seafoam-color", + "--spectrum-statuslight-nonsemantic-silver-color", + "--spectrum-statuslight-nonsemantic-turquoise-color", "--spectrum-statuslight-nonsemantic-yellow-color", - "--spectrum-statuslight-semantic-accent-color", "--spectrum-statuslight-semantic-info-color", "--spectrum-statuslight-semantic-negative-color", "--spectrum-statuslight-semantic-neutral-color", @@ -114,11 +133,12 @@ "--spectrum-statuslight-subdued-content-color-default" ], "global": [ - "--spectrum-accent-visual-color", "--spectrum-blue-visual-color", "--spectrum-border-width-100", + "--spectrum-brown-visual-color", "--spectrum-celery-visual-color", "--spectrum-chartreuse-visual-color", + "--spectrum-cinnamon-visual-color", "--spectrum-cjk-line-height-100", "--spectrum-component-bottom-to-text-100", "--spectrum-component-bottom-to-text-200", @@ -132,12 +152,15 @@ "--spectrum-component-top-to-text-200", "--spectrum-component-top-to-text-300", "--spectrum-component-top-to-text-75", + "--spectrum-corner-radius-full", "--spectrum-cyan-visual-color", + "--spectrum-default-font-style", "--spectrum-font-size-100", "--spectrum-font-size-200", "--spectrum-font-size-300", "--spectrum-font-size-75", "--spectrum-fuchsia-visual-color", + "--spectrum-gray-600", "--spectrum-gray-visual-color", "--spectrum-green-visual-color", "--spectrum-indigo-visual-color", @@ -150,17 +173,17 @@ "--spectrum-neutral-visual-color", "--spectrum-notice-visual-color", "--spectrum-orange-visual-color", + "--spectrum-pink-visual-color", "--spectrum-positive-visual-color", "--spectrum-purple-visual-color", "--spectrum-red-visual-color", + "--spectrum-regular-font-weight", + "--spectrum-sans-font-family-stack", "--spectrum-seafoam-visual-color", - "--spectrum-text-to-visual-100", - "--spectrum-text-to-visual-200", - "--spectrum-text-to-visual-300", - "--spectrum-text-to-visual-75", + "--spectrum-silver-visual-color", + "--spectrum-turquoise-visual-color", "--spectrum-yellow-visual-color" ], - "system-theme": [], "passthroughs": [], "high-contrast": [ "--highcontrast-statuslight-content-color-default", diff --git a/components/statuslight/index.css b/components/statuslight/index.css index aed7e351d88..db810c053b9 100644 --- a/components/statuslight/index.css +++ b/components/statuslight/index.css @@ -11,17 +11,57 @@ * governing permissions and limitations under the License. */ -.spectrum-StatusLight, -.spectrum-StatusLight--sizeM { +.spectrum-StatusLight { + /* Static tokens */ + --spectrum-statuslight-corner-radius: var(--spectrum-corner-radius-full); + --spectrum-statuslight-border-width: var(--spectrum-border-width-100); + + /* Size */ --spectrum-statuslight-height: var(--spectrum-component-height-100); --spectrum-statuslight-dot-size: var(--spectrum-status-light-dot-size-medium); + --spectrum-statuslight-line-height: var(--spectrum-line-height-100); + --spectrum-statuslight-line-height-cjk: var(--spectrum-cjk-line-height-100); + /* Font */ + --spectrum-statuslight-font-family: var(--spectrum-sans-font-family-stack); + --spectrum-statuslight-font-weight: var(--spectrum-regular-font-weight); + --spectrum-statuslight-font-style: var(--spectrum-default-font-style); --spectrum-statuslight-font-size: var(--spectrum-font-size-100); - --spectrum-statuslight-spacing-dot-to-label: var(--spectrum-text-to-visual-100); + /* Space */ + --spectrum-statuslight-spacing-dot-to-label: var(--spectrum-status-light-text-to-visual-100); --spectrum-statuslight-spacing-top-to-dot: var(--spectrum-status-light-top-to-dot-medium); --spectrum-statuslight-spacing-top-to-label: var(--spectrum-component-top-to-text-100); --spectrum-statuslight-spacing-bottom-to-label: var(--spectrum-component-bottom-to-text-100); + + /* Color */ + --spectrum-statuslight-content-color-default: var(--spectrum-neutral-content-color-default); + --spectrum-statuslight-subdued-content-color-default: var(--spectrum-gray-600); + --spectrum-statuslight-semantic-neutral-color: var(--spectrum-neutral-visual-color); + --spectrum-statuslight-semantic-negative-color: var(--spectrum-negative-visual-color); + --spectrum-statuslight-semantic-info-color: var(--spectrum-informative-visual-color); + --spectrum-statuslight-semantic-notice-color: var(--spectrum-notice-visual-color); + --spectrum-statuslight-semantic-positive-color: var(--spectrum-positive-visual-color); + + --spectrum-statuslight-nonsemantic-gray-color: var(--spectrum-gray-visual-color); + --spectrum-statuslight-nonsemantic-red-color: var(--spectrum-red-visual-color); + --spectrum-statuslight-nonsemantic-orange-color: var(--spectrum-orange-visual-color); + --spectrum-statuslight-nonsemantic-yellow-color: var(--spectrum-yellow-visual-color); + --spectrum-statuslight-nonsemantic-chartreuse-color: var(--spectrum-chartreuse-visual-color); + --spectrum-statuslight-nonsemantic-celery-color: var(--spectrum-celery-visual-color); + --spectrum-statuslight-nonsemantic-green-color: var(--spectrum-green-visual-color); + --spectrum-statuslight-nonsemantic-seafoam-color: var(--spectrum-seafoam-visual-color); + --spectrum-statuslight-nonsemantic-cyan-color: var(--spectrum-cyan-visual-color); + --spectrum-statuslight-nonsemantic-blue-color: var(--spectrum-blue-visual-color); + --spectrum-statuslight-nonsemantic-indigo-color: var(--spectrum-indigo-visual-color); + --spectrum-statuslight-nonsemantic-purple-color: var(--spectrum-purple-visual-color); + --spectrum-statuslight-nonsemantic-fuchsia-color: var(--spectrum-fuchsia-visual-color); + --spectrum-statuslight-nonsemantic-magenta-color: var(--spectrum-magenta-visual-color); + --spectrum-statuslight-nonsemantic-pink-color: var(--spectrum-pink-visual-color); + --spectrum-statuslight-nonsemantic-turquoise-color: var(--spectrum-turquoise-visual-color); + --spectrum-statuslight-nonsemantic-cinnamon-color: var(--spectrum-cinnamon-visual-color); + --spectrum-statuslight-nonsemantic-brown-color: var(--spectrum-brown-visual-color); + --spectrum-statuslight-nonsemantic-silver-color: var(--spectrum-silver-visual-color); } .spectrum-StatusLight--sizeS { @@ -30,7 +70,7 @@ --spectrum-statuslight-font-size: var(--spectrum-font-size-75); - --spectrum-statuslight-spacing-dot-to-label: var(--spectrum-text-to-visual-75); + --spectrum-statuslight-spacing-dot-to-label: var(--spectrum-status-light-text-to-visual-75); --spectrum-statuslight-spacing-top-to-dot: var(--spectrum-status-light-top-to-dot-small); --spectrum-statuslight-spacing-top-to-label: var(--spectrum-component-top-to-text-75); --spectrum-statuslight-spacing-bottom-to-label: var(--spectrum-component-bottom-to-text-75); @@ -42,7 +82,7 @@ --spectrum-statuslight-font-size: var(--spectrum-font-size-200); - --spectrum-statuslight-spacing-dot-to-label: var(--spectrum-text-to-visual-200); + --spectrum-statuslight-spacing-dot-to-label: var(--spectrum-status-light-text-to-visual-200); --spectrum-statuslight-spacing-top-to-dot: var(--spectrum-status-light-top-to-dot-large); --spectrum-statuslight-spacing-top-to-label: var(--spectrum-component-top-to-text-200); --spectrum-statuslight-spacing-bottom-to-label: var(--spectrum-component-bottom-to-text-200); @@ -54,7 +94,7 @@ --spectrum-statuslight-font-size: var(--spectrum-font-size-300); - --spectrum-statuslight-spacing-dot-to-label: var(--spectrum-text-to-visual-300); + --spectrum-statuslight-spacing-dot-to-label: var(--spectrum-status-light-text-to-visual-300); --spectrum-statuslight-spacing-top-to-dot: var(--spectrum-status-light-top-to-dot-extra-large); --spectrum-statuslight-spacing-top-to-label: var(--spectrum-component-top-to-text-300); --spectrum-statuslight-spacing-bottom-to-label: var(--spectrum-component-bottom-to-text-300); @@ -71,7 +111,6 @@ --spectrum-statuslight-content-color-default: var(--spectrum-neutral-content-color-default); --spectrum-statuslight-subdued-content-color-default: var(--spectrum-neutral-subdued-content-color-default); --spectrum-statuslight-semantic-neutral-color: var(--spectrum-neutral-visual-color); - --spectrum-statuslight-semantic-accent-color: var(--spectrum-accent-visual-color); --spectrum-statuslight-semantic-negative-color: var(--spectrum-negative-visual-color); --spectrum-statuslight-semantic-info-color: var(--spectrum-informative-visual-color); --spectrum-statuslight-semantic-notice-color: var(--spectrum-notice-visual-color); @@ -104,6 +143,8 @@ font-size: var(--mod-statuslight-font-size, var(--spectrum-statuslight-font-size)); font-weight: var(--mod-statuslight-font-weight, var(--spectrum-statuslight-font-weight)); + font-family: var(--mod-statuslight-font-family, var(--spectrum-statuslight-font-family)); + font-style: var(--mod-statuslight-font-style, var(--spectrum-statuslight-font-style)); line-height: var(--mod-statuslight-line-height, var(--spectrum-statuslight-line-height)); @@ -118,7 +159,6 @@ /* Dot */ &::before { --spectrum-statuslight-spacing-computed-top-to-dot: calc(var(--mod-statuslight-spacing-top-to-dot, var(--spectrum-statuslight-spacing-top-to-dot)) - var(--mod-statuslight-spacing-top-to-label, var(--spectrum-statuslight-spacing-top-to-label))); - content: ""; flex-grow: 0; flex-shrink: 0; @@ -126,7 +166,6 @@ inline-size: var(--mod-statuslight-dot-size, var(--spectrum-statuslight-dot-size)); block-size: var(--mod-statuslight-dot-size, var(--spectrum-statuslight-dot-size)); border-radius: var(--mod-statuslight-corner-radius, var(--spectrum-statuslight-corner-radius)); - margin-block-start: var(--spectrum-statuslight-spacing-computed-top-to-dot); margin-inline-end: var(--mod-statuslight-spacing-dot-to-label, var(--spectrum-statuslight-spacing-dot-to-label)); } @@ -134,8 +173,6 @@ /* Semantic Colors */ .spectrum-StatusLight--neutral { - font-style: italic; - color: var(--highcontrast-statuslight-subdued-content-color-default, var(--mod-statuslight-subdued-content-color-default, var(--spectrum-statuslight-subdued-content-color-default))); &::before { @@ -143,10 +180,6 @@ } } -.spectrum-StatusLight--accent::before { - background-color: var(--mod-statuslight-semantic-accent-color, var(--spectrum-statuslight-semantic-accent-color)); -} - .spectrum-StatusLight--info::before { background-color: var(--mod-statuslight-semantic-info-color, var(--spectrum-statuslight-semantic-info-color)); } @@ -220,11 +253,30 @@ background-color: var(--mod-statuslight-nonsemantic-magenta-color, var(--spectrum-statuslight-nonsemantic-magenta-color)); } +.spectrum-StatusLight--pink::before { + background-color: var(--mod-statuslight-nonsemantic-pink-color, var(--spectrum-statuslight-nonsemantic-pink-color)); +} + +.spectrum-StatusLight--turquoise::before { + background-color: var(--mod-statuslight-nonsemantic-turquoise-color, var(--spectrum-statuslight-nonsemantic-turquoise-color)); +} + +.spectrum-StatusLight--cinnamon::before { + background-color: var(--mod-statuslight-nonsemantic-cinnamon-color, var(--spectrum-statuslight-nonsemantic-cinnamon-color)); +} + +.spectrum-StatusLight--brown::before { + background-color: var(--mod-statuslight-nonsemantic-brown-color, var(--spectrum-statuslight-nonsemantic-brown-color)); +} + +.spectrum-StatusLight--silver::before { + background-color: var(--mod-statuslight-nonsemantic-silver-color, var(--spectrum-statuslight-nonsemantic-silver-color)); +} + @media (forced-colors: active) { .spectrum-StatusLight { --highcontrast-statuslight-content-color-default: CanvasText; --highcontrast-statuslight-subdued-content-color-default: CanvasText; - forced-color-adjust: none; /* Dot */ diff --git a/components/statuslight/package.json b/components/statuslight/package.json index b477ea81949..64b68011827 100644 --- a/components/statuslight/package.json +++ b/components/statuslight/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/statuslight", - "version": "9.2.0", + "version": "10.0.0-next.2", "description": "The Spectrum CSS statuslight component", "license": "Apache-2.0", "author": "Adobe", @@ -24,7 +24,7 @@ }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/tokens": ">=16.0.1" + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/tokens": { @@ -32,7 +32,7 @@ } }, "devDependencies": { - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/statuslight/stories/statuslight.stories.js b/components/statuslight/stories/statuslight.stories.js index b385bcc9da3..cec593c5216 100644 --- a/components/statuslight/stories/statuslight.stories.js +++ b/components/statuslight/stories/statuslight.stories.js @@ -33,26 +33,30 @@ export default { category: "Component", }, options: [ - "accent", "info", "neutral", "positive", "notice", "negative", - "gray", - "red", - "orange", "yellow", "chartreuse", "celery", - "green", "seafoam", "cyan", - "blue", "indigo", "purple", "fuchsia", "magenta", + "gray", + "red", + "orange", + "green", + "blue", + "pink", + "turquoise", + "cinnamon", + "brown", + "silver", ], control: "select", }, @@ -71,7 +75,11 @@ export default { }, packageJson, metadata, + status: { + type: "migrated", + }, }, + tags: ["migrated"], }; /** diff --git a/components/statuslight/stories/statuslight.test.js b/components/statuslight/stories/statuslight.test.js index 9cfab9c3094..7fc72a9ce6b 100644 --- a/components/statuslight/stories/statuslight.test.js +++ b/components/statuslight/stories/statuslight.test.js @@ -4,7 +4,7 @@ import { Template } from "./template.js"; export const StatusLightGroup = Variants({ Template, testData: [ - ...["accent", "info", "positive", "negative", "notice", "neutral"].map((variant) => ({ + ...["info", "positive", "negative", "notice", "neutral"].map((variant) => ({ testHeading: variant.charAt(0).toUpperCase() + variant.slice(1), variant, })), diff --git a/components/statuslight/stories/template.js b/components/statuslight/stories/template.js index 2faf35797c8..be01af383ba 100644 --- a/components/statuslight/stories/template.js +++ b/components/statuslight/stories/template.js @@ -27,12 +27,10 @@ export const Template = ({
`; -// TODO: the accent variant will be removed in S2. export const SemanticGroup = (args, context) => Container({ withBorder: false, direction: "column", content: html`${[ - "accent", "neutral", "info", "negative", diff --git a/components/steplist/CHANGELOG.md b/components/steplist/CHANGELOG.md index 6da6e7bbeda..6d961792728 100644 --- a/components/steplist/CHANGELOG.md +++ b/components/steplist/CHANGELOG.md @@ -1,5 +1,28 @@ # Change log +## 8.0.0-next.2 + +### Major Changes + +📝 [#4014](https://github.com/adobe/spectrum-css/pull/4014) [`35c066b`](https://github.com/adobe/spectrum-css/commit/35c066b29c311b1bfcf4507075f13b41222ffc84) Thanks [@castastrophe](https://github.com/castastrophe)! + +This update removes the `dir` attribute polyfill (served via a PostCSS transform to compiled assets) as the fallback is no longer necessary. The`dir` attribute support is available in all supported browsers and has been tested to correctly inherit inside web component shadow DOMs. This is a breaking change **only** to those relying on the `dir` attribute being present for styling, however, the `:dir` pseudo will correctly inherit values from their containers. To correctly determine the `dir` value of a node using JavaScript, you can use `getComputedStyle(node).direction`. + +## 8.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + +## 8.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`a25e0a9`](https://github.com/adobe/spectrum-css/commit/a25e0a99e5a4736ab4e607e00739343101a2633b)]: + - @spectrum-css/icon@10.0.0-next.0 + - @spectrum-css/tooltip@8.0.0-next.0 + ## 7.2.0 ### Minor Changes diff --git a/components/steplist/dist/metadata.json b/components/steplist/dist/metadata.json index 3e4e5dc0bed..27faf429c11 100644 --- a/components/steplist/dist/metadata.json +++ b/components/steplist/dist/metadata.json @@ -40,10 +40,7 @@ ".spectrum-Steplist-label:dir(rtl)", ".spectrum-Steplist-marker", ".spectrum-Steplist-markerContainer", - ".spectrum-Steplist-segment", - "[dir=\"rtl\"] .spectrum-Steplist-item:last-child .spectrum-Steplist-label", - "[dir=\"rtl\"] .spectrum-Steplist-item:only-child .spectrum-Steplist-label", - "[dir=\"rtl\"] .spectrum-Steplist-label" + ".spectrum-Steplist-segment" ], "modifiers": [ "--mod-steplist-complete-label-text-color", @@ -91,10 +88,6 @@ "--spectrum-gray-700", "--spectrum-gray-800" ], - "system-theme": [ - "--system-steplist-incomplete-marker-border-color", - "--system-steplist-incomplete-segment-border-block-end-color" - ], "passthroughs": [], "high-contrast": [ "--highcontrast-steplist-complete-marker-background-color", diff --git a/components/steplist/index.css b/components/steplist/index.css index 7fc57091919..62900591018 100644 --- a/components/steplist/index.css +++ b/components/steplist/index.css @@ -11,9 +11,10 @@ * governing permissions and limitations under the License. */ -@import "./themes/spectrum-two.css"; - .spectrum-Steplist { + --spectrum-steplist-incomplete-marker-border-color: var(--spectrum-gray-200); + --spectrum-steplist-incomplete-segment-border-block-end-color: var(--spectrum-gray-200); + /* The width of a step */ --spectrum-steplist-step-width: 80px; diff --git a/components/steplist/package.json b/components/steplist/package.json index 973e1e622fc..5f0a7db1993 100644 --- a/components/steplist/package.json +++ b/components/steplist/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/steplist", - "version": "7.2.0", + "version": "8.0.0-next.2", "description": "The Spectrum CSS steplist component", "license": "Apache-2.0", "author": "Adobe", @@ -19,16 +19,14 @@ "./package.json": "./package.json", "./dist/*": "./dist/*", "./index.css": "./dist/index.css", - "./index-*.css": "./dist/index-*.css", "./metadata.json": "./dist/metadata.json", - "./themes/*": "./dist/themes/*", "./stories/*": "./stories/*" }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/icon": ">=9.0.0 <10.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0", - "@spectrum-css/tooltip": ">=7.0.0 <8.0.0" + "@spectrum-css/icon": ">=10.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0", + "@spectrum-css/tooltip": ">=8.0.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/icon": { @@ -42,9 +40,9 @@ } }, "devDependencies": { - "@spectrum-css/icon": "9.2.0", - "@spectrum-css/tokens": "16.0.2", - "@spectrum-css/tooltip": "7.2.0" + "@spectrum-css/icon": "10.0.0-next.3", + "@spectrum-css/tokens": "16.1.0-next.10", + "@spectrum-css/tooltip": "8.0.0-next.4" }, "keywords": [ "design-system", diff --git a/components/steplist/stories/steplist.stories.js b/components/steplist/stories/steplist.stories.js index 085bd832319..d23fba3b428 100644 --- a/components/steplist/stories/steplist.stories.js +++ b/components/steplist/stories/steplist.stories.js @@ -80,7 +80,11 @@ export default { }, packageJson, metadata, + status: { + type: "unmigrated", + }, }, + tags: ["unmigrated"], }; export const Default = SteplistGroup.bind({}); diff --git a/components/steplist/stories/template.js b/components/steplist/stories/template.js index ea9a57ef420..7edfdf8199b 100644 --- a/components/steplist/stories/template.js +++ b/components/steplist/stories/template.js @@ -6,9 +6,6 @@ import { ifDefined } from "lit/directives/if-defined.js"; import { repeat } from "lit/directives/repeat.js"; import "../index.css"; -import "../themes/spectrum.css"; -/* Must be imported last */ -import "../themes/express.css"; export const SteplistItem = ({ rootClass = "spectrum-Steplist-item", diff --git a/components/steplist/themes/express.css b/components/steplist/themes/express.css deleted file mode 100644 index 9fd550418f2..00000000000 --- a/components/steplist/themes/express.css +++ /dev/null @@ -1,16 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--express */ - -@import "./spectrum.css"; diff --git a/components/steplist/themes/spectrum-two.css b/components/steplist/themes/spectrum-two.css deleted file mode 100644 index 649e9fb4d3a..00000000000 --- a/components/steplist/themes/spectrum-two.css +++ /dev/null @@ -1,19 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -@container style(--system: spectrum) { - .spectrum-Steplist { - --spectrum-steplist-incomplete-marker-border-color: var(--spectrum-gray-200); - --spectrum-steplist-incomplete-segment-border-block-end-color: var(--spectrum-gray-200); - } -} diff --git a/components/steplist/themes/spectrum.css b/components/steplist/themes/spectrum.css deleted file mode 100644 index bfe1e5f6f8c..00000000000 --- a/components/steplist/themes/spectrum.css +++ /dev/null @@ -1,23 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--legacy */ - -@import "./spectrum-two.css"; - -@container style(--system: legacy) { - .spectrum-Steplist { - --spectrum-steplist-incomplete-marker-border-color: var(--spectrum-gray-300); - --spectrum-steplist-incomplete-segment-border-block-end-color: var(--spectrum-gray-300); - } -} diff --git a/components/stepper/CHANGELOG.md b/components/stepper/CHANGELOG.md index 5a8a0b09a82..5992d88e995 100644 --- a/components/stepper/CHANGELOG.md +++ b/components/stepper/CHANGELOG.md @@ -1,5 +1,119 @@ # Change log +## 8.0.0-next.3 + +### Patch Changes + +📝 [#4113](https://github.com/adobe/spectrum-css/pull/4113) [`cf4fc1a`](https://github.com/adobe/spectrum-css/commit/cf4fc1a01d23ba810f45a903ecc29a5c8aae33d1) Thanks [@castastrophe](https://github.com/castastrophe)! + +## Minor linting fixes + +- Removed unused custom properties across multiple components +- Fixed color function notation by converting `rgba()` to `rgb()` where appropriate +- Removed duplicate custom property declarations +- Fixed deprecated CSS properties (e.g., `word-wrap` → `overflow-wrap`) +- Removed unnecessary stylelint-disable comments + +_No visual or functional changes to components._ + +## 8.0.0-next.2 + +### Major Changes + +- [#3681](https://github.com/adobe/spectrum-css/pull/3681) [`0a23664`](https://github.com/adobe/spectrum-css/commit/0a23664bd74cd7966c19381a01ddda51c95dc097) Thanks [@marissahuysentruyt](https://github.com/marissahuysentruyt)! - ### Number field S2 Migration + + This work migrations the stepper/number field component to Spectrum 2! 🎉 The S1 stepper was very minimal, and didn't align with SWC or React's implementation. This migration should bring parity to the CSS component. New features include: + - the display name for this component has changed from `stepper` to `number field` (based on design's, React's and SWC's naming conventions.) + - _**Note:**_ The NPM package name has remained as "stepper," and hasn't yet changed to "number field."" + - an error state with alert icon + - optional help text + - embedded field label & optional positions + + #### Quick overview + + Because of all the new features and to align more with design, SWC and React, below is a quick recap of the following tokens & classes that have been renamed in the CSS: + - All `.spectrum-Stepper*` class names have been converted to `.spectrum-NumberField*` + - The `.hide-stepper` class has been converted to `.spectrum-NumberField--hiddenStepper` + - Custom properties have been renamed from `--spectrum-stepper*` to `--spectrum-numberfield*` + - Modifiable custom properties have been renamed from `--mod-stepper*` to `--mod-numberfield*` + - Markup has changed + - Styling lives on different elements + - Lots more Chromatic test coverage + + #### Markup + + Following React's lead, the markup of the number field has changed. More obviously, help text and field label components are embedded into `.spectrum-NumberField`, instead of necessitating separate components. The number field now incorporates an error state that better reflects the embedded textfield's error state, so there is now an alert icon within the markup in an invalid number field. Additionally, a new `.spectrum-NumberField-inputs` containing wrapper was introduced to encapsulate the textfield element and infield button elements. This container allowed for some extra alignment styles for those 2 elements and then freed up the opportunity to introduced an "unstyled" `input` (as described more below). Custom classes were also added to the nested textfield and input elements to ensure styles for number field were passed correctly to the correct elements (`.spectrum-NumberField-textfield` and `.spectrum-NumberField-input`). + + Stemming from the infield button S2 migration, there is also an extra container for the inline (previously "stacked") stepper buttons. + + #### Styling + + The `.spectrum-NumberField-textfield` div is where the S2 design language lives (instead of on the input element), while the actual `input` (`.spectrum-NumberField-input`) is unstyled and incorporated more subtly. Breaking changes were introduced in all previous custom properties, where any `--spectrum-stepper-*` or `--mod-stepper-*` properties were renamed to `--spectrum-numberfield-*`or `--mod-numberfield-*`. This also applied to class names, where `.spectrum-Stepper` changed to `.spectrum-NumberField`. The `hide-stepper` class has also been updated to match our class naming conventions (`.spectrum-NumberField--hiddenStepper`). + + #### Mods + + Modifiable custom properties have been renamed from `--mod-stepper*` to `--mod-numberfield`. + + ##### Removed custom properties include + + --mod-stepper-animation-duration + --mod-stepper-button-border-width + --mod-stepper-button-width + --mod-stepper-button-width-quiet + --mod-stepper-buttons-background-color + --mod-stepper-buttons-border-color + --mod-stepper-buttons-border-color-focus + --mod-stepper-buttons-border-color-focus-hover + --mod-stepper-buttons-border-color-hover + --mod-stepper-buttons-border-color-keyboard-focus + --mod-stepper-buttons-border-style + --mod-stepper-buttons-border-width + --mod-stepper-focus-indicator-visibility + --mod-stepper-height (renamed to --mod-numberfield-block-size) + --mod-stepper-width (renamed to --mod-numberfield-inline-size) + + ##### New custom properties include + + --mod-numberfield-background-color + --mod-numberfield-background-color-disabled + --mod-numberfield-block-size (renamed from --mod-stepper-height) + --mod-numberfield-border-color-disabled + --mod-numberfield-border-color-invalid-default + --mod-numberfield-border-color-invalid-focus + --mod-numberfield-border-color-invalid-focus-hover + --mod-numberfield-border-color-invalid-hover + --mod-numberfield-border-color-invalid-keyboard-focus + --mod-numberfield-button-inline-offset + --mod-numberfield-font-family + --mod-numberfield-font-size + --mod-numberfield-font-style + --mod-numberfield-font-weight + --mod-numberfield-hidden-stepper-min-inline-size + --mod-numberfield-inline-size (renamed from --mod-stepper-width) + --mod-numberfield-label-to-field + --mod-numberfield-line-height + --mod-numberfield-min-inline-size + --mod-numberfield-spacing-block-end-edge-to-text + --mod-numberfield-spacing-block-start-edge-to-text + --mod-numberfield-spacing-field-to-helptext + +## 8.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + +## 8.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`a25e0a9`](https://github.com/adobe/spectrum-css/commit/a25e0a99e5a4736ab4e607e00739343101a2633b)]: + - @spectrum-css/icon@10.0.0-next.0 + - @spectrum-css/actionbutton@8.0.0-next.0 + - @spectrum-css/infieldbutton@7.0.0-next.0 + - @spectrum-css/textfield@9.0.0-next.0 + ## 7.2.0 ### Minor Changes @@ -12,8 +126,10 @@ Ensure accurate exports are present for each component. Specifically, adding `th ### Patch Changes -- [#3621](https://github.com/adobe/spectrum-css/pull/3621) [`3aec28a`](https://github.com/adobe/spectrum-css/commit/3aec28aac60bdf32a585fa8ff38559d80b57ff86) Thanks [@marissahuysentruyt](https://github.com/marissahuysentruyt)! - - Updates `--spectrum-stepper-border-color-focus-hover` from `gray-800` to `gray-900`. - - Updates `--spectrum-stepper-buttons-border-color-keyboard-focus` from `gray-900` to `gray-800` to match the rest of the border color on keyboardFocus. +📝 [#3621](https://github.com/adobe/spectrum-css/pull/3621) [`3aec28a`](https://github.com/adobe/spectrum-css/commit/3aec28aac60bdf32a585fa8ff38559d80b57ff86) Thanks [@marissahuysentruyt](https://github.com/marissahuysentruyt)! + +- Updates `--spectrum-stepper-border-color-focus-hover` from `gray-800` to `gray-900`. +- Updates `--spectrum-stepper-buttons-border-color-keyboard-focus` from `gray-900` to `gray-800` to match the rest of the border color on keyboardFocus. ## 7.1.2 diff --git a/components/stepper/dist/metadata.json b/components/stepper/dist/metadata.json index cfea6e878d6..a8b7ec49b01 100644 --- a/components/stepper/dist/metadata.json +++ b/components/stepper/dist/metadata.json @@ -1,205 +1,281 @@ { "sourceFile": "index.css", "selectors": [ - ".spectrum-Stepper", - ".spectrum-Stepper--quiet", - ".spectrum-Stepper--quiet.hide-stepper .spectrum-Stepper-input", - ".spectrum-Stepper--quiet.is-keyboardFocused:not(.is-disabled)", - ".spectrum-Stepper--quiet:after", - ".spectrum-Stepper-button", - ".spectrum-Stepper-buttons", - ".spectrum-Stepper-input", - ".spectrum-Stepper.hide-stepper .spectrum-Stepper-input", - ".spectrum-Stepper.is-disabled", - ".spectrum-Stepper.is-focused:not(.is-disabled)", - ".spectrum-Stepper.is-focused:not(.is-disabled):hover", - ".spectrum-Stepper.is-invalid", - ".spectrum-Stepper.is-invalid.is-focused", - ".spectrum-Stepper.is-invalid.is-focused:hover", - ".spectrum-Stepper.is-invalid.is-keyboardFocused", - ".spectrum-Stepper.is-invalid:focus", - ".spectrum-Stepper.is-invalid:focus-visible", - ".spectrum-Stepper.is-invalid:focus:hover", - ".spectrum-Stepper.is-invalid:hover", - ".spectrum-Stepper.is-keyboardFocused:not(.is-disabled)", - ".spectrum-Stepper.spectrum-Stepper--quiet", - ".spectrum-Stepper.spectrum-Stepper--quiet.is-focused:not(.is-disabled)", - ".spectrum-Stepper.spectrum-Stepper--quiet.is-focused:not(.is-disabled):hover", - ".spectrum-Stepper.spectrum-Stepper--quiet.is-invalid", - ".spectrum-Stepper.spectrum-Stepper--quiet.is-keyboardFocused:not(.is-disabled)", - ".spectrum-Stepper.spectrum-Stepper--quiet.is-keyboardFocused:not(.is-disabled):hover", - ".spectrum-Stepper.spectrum-Stepper--quiet:not(.is-disabled):focus", - ".spectrum-Stepper.spectrum-Stepper--quiet:not(.is-disabled):focus:hover", - ".spectrum-Stepper.spectrum-Stepper--quiet:not(.is-disabled):hover", - ".spectrum-Stepper.spectrum-Stepper--sizeL", - ".spectrum-Stepper.spectrum-Stepper--sizeM", - ".spectrum-Stepper.spectrum-Stepper--sizeS", - ".spectrum-Stepper.spectrum-Stepper--sizeXL", - ".spectrum-Stepper:before", - ".spectrum-Stepper:hover:not(.is-invalid, .is-disabled, .is-focused)", - ".spectrum-Stepper:not(.is-disabled) .is-focused", - ".spectrum-Stepper:not(.is-disabled) .is-focused:hover", - ".spectrum-Stepper:not(.is-disabled):focus", - ".spectrum-Stepper:not(.is-disabled):focus-visible", - ".spectrum-Stepper:not(.is-disabled):focus:hover", - ".spectrum-Stepper:not(.is-disabled):hover", - ".spectrum-Stepper:not(.spectrum-Stepper--quiet)" + ".spectrum-NumberField", + ".spectrum-NumberField-buttons", + ".spectrum-NumberField-fieldLabel", + ".spectrum-NumberField-helpText", + ".spectrum-NumberField-input", + ".spectrum-NumberField-inputs", + ".spectrum-NumberField-inputs .spectrum-Textfield .spectrum-Textfield-input", + ".spectrum-NumberField-inputs .spectrum-Textfield.is-invalid .spectrum-NumberField-input", + ".spectrum-NumberField-textfield", + ".spectrum-NumberField-textfield.spectrum-Textfield.is-invalid .spectrum-Textfield-validationIcon", + ".spectrum-NumberField.is-disabled", + ".spectrum-NumberField.is-focused.is-hover:not(.is-disabled)", + ".spectrum-NumberField.is-focused.is-hover:not(.is-disabled, .is-readOnly)", + ".spectrum-NumberField.is-focused:not(.is-disabled)", + ".spectrum-NumberField.is-focused:not(.is-disabled):hover", + ".spectrum-NumberField.is-focused:not(.is-disabled, .is-readOnly)", + ".spectrum-NumberField.is-focused:not(.is-disabled, .is-readOnly):hover", + ".spectrum-NumberField.is-hover:not(.is-disabled)", + ".spectrum-NumberField.is-hover:not(.is-disabled):focus", + ".spectrum-NumberField.is-hover:not(.is-disabled):focus-visible", + ".spectrum-NumberField.is-hover:not(.is-disabled):focus-within", + ".spectrum-NumberField.is-hover:not(.is-disabled, .is-readOnly)", + ".spectrum-NumberField.is-hover:not(.is-disabled, .is-readOnly):focus", + ".spectrum-NumberField.is-hover:not(.is-disabled, .is-readOnly):focus-visible", + ".spectrum-NumberField.is-hover:not(.is-disabled, .is-readOnly):focus-within", + ".spectrum-NumberField.is-invalid", + ".spectrum-NumberField.is-keyboardFocused.is-hover:not(.is-disabled)", + ".spectrum-NumberField.is-keyboardFocused.is-hover:not(.is-disabled, .is-readOnly)", + ".spectrum-NumberField.is-keyboardFocused:not(.is-disabled)", + ".spectrum-NumberField.is-keyboardFocused:not(.is-disabled):hover", + ".spectrum-NumberField.is-keyboardFocused:not(.is-disabled, .is-readOnly)", + ".spectrum-NumberField.is-keyboardFocused:not(.is-disabled, .is-readOnly) .spectrum-NumberField-inputs", + ".spectrum-NumberField.is-keyboardFocused:not(.is-disabled, .is-readOnly):hover", + ".spectrum-NumberField.is-readOnly", + ".spectrum-NumberField.spectrum-NumberField--hiddenStepper", + ".spectrum-NumberField.spectrum-NumberField--hiddenStepper .spectrum-NumberField-textfield", + ".spectrum-NumberField.spectrum-NumberField--hiddenStepper .spectrum-NumberField-textfield .spectrum-NumberField-input", + ".spectrum-NumberField.spectrum-NumberField--hiddenStepper .spectrum-NumberField-textfield.spectrum-Textfield.is-invalid .spectrum-Textfield-validationIcon", + ".spectrum-NumberField.spectrum-NumberField--hiddenStepper .spectrum-NumberField-textfield:not(:has(.spectrum-Textfield-validationIcon)) .spectrum-NumberField-input", + ".spectrum-NumberField.spectrum-NumberField--sideLabel", + ".spectrum-NumberField.spectrum-NumberField--sideLabel .spectrum-NumberField-fieldLabel", + ".spectrum-NumberField.spectrum-NumberField--sideLabel .spectrum-NumberField-helpText", + ".spectrum-NumberField.spectrum-NumberField--sideLabel .spectrum-NumberField-inputs", + ".spectrum-NumberField.spectrum-NumberField--sizeL", + ".spectrum-NumberField.spectrum-NumberField--sizeS", + ".spectrum-NumberField.spectrum-NumberField--sizeXL", + ".spectrum-NumberField:before", + ".spectrum-NumberField:focus-visible .spectrum-NumberField-inputs", + ".spectrum-NumberField:lang(ja)", + ".spectrum-NumberField:lang(ko)", + ".spectrum-NumberField:lang(zh)", + ".spectrum-NumberField:not(.is-disabled):focus", + ".spectrum-NumberField:not(.is-disabled):focus-visible", + ".spectrum-NumberField:not(.is-disabled):focus-visible:hover", + ".spectrum-NumberField:not(.is-disabled):focus-within", + ".spectrum-NumberField:not(.is-disabled):focus-within:hover", + ".spectrum-NumberField:not(.is-disabled):focus:hover", + ".spectrum-NumberField:not(.is-disabled):hover", + ".spectrum-NumberField:not(.is-disabled, .is-readOnly):focus", + ".spectrum-NumberField:not(.is-disabled, .is-readOnly):focus-visible", + ".spectrum-NumberField:not(.is-disabled, .is-readOnly):focus-visible:hover", + ".spectrum-NumberField:not(.is-disabled, .is-readOnly):focus-within", + ".spectrum-NumberField:not(.is-disabled, .is-readOnly):focus-within:hover", + ".spectrum-NumberField:not(.is-disabled, .is-readOnly):focus:hover", + ".spectrum-NumberField:not(.is-disabled, .is-readOnly):hover" ], "modifiers": [ - "--mod-stepper-animation-duration", - "--mod-stepper-border-color", - "--mod-stepper-border-color-focus", - "--mod-stepper-border-color-focus-hover", - "--mod-stepper-border-color-focus-hover-invalid", - "--mod-stepper-border-color-focus-invalid", - "--mod-stepper-border-color-hover", - "--mod-stepper-border-color-hover-invalid", - "--mod-stepper-border-color-invalid", - "--mod-stepper-border-color-keyboard-focus", - "--mod-stepper-border-color-keyboard-focus-invalid", - "--mod-stepper-border-radius", - "--mod-stepper-border-width", - "--mod-stepper-button-border-width", - "--mod-stepper-button-width", - "--mod-stepper-button-width-quiet", - "--mod-stepper-buttons-background-color", - "--mod-stepper-buttons-border-color", - "--mod-stepper-buttons-border-color-focus", - "--mod-stepper-buttons-border-color-focus-hover", - "--mod-stepper-buttons-border-color-hover", - "--mod-stepper-buttons-border-color-keyboard-focus", - "--mod-stepper-buttons-border-style", - "--mod-stepper-buttons-border-width", - "--mod-stepper-focus-indicator-color", - "--mod-stepper-focus-indicator-gap", - "--mod-stepper-focus-indicator-visibility", - "--mod-stepper-focus-indicator-width", - "--mod-stepper-height", - "--mod-stepper-min-width-multiplier", - "--mod-stepper-width" - ], - "component": [ - "--spectrum-stepper-animation-duration", - "--spectrum-stepper-border-color", - "--spectrum-stepper-border-color-default", - "--spectrum-stepper-border-color-disabled", - "--spectrum-stepper-border-color-focus", - "--spectrum-stepper-border-color-focus-hover", - "--spectrum-stepper-border-color-focus-hover-invalid", - "--spectrum-stepper-border-color-focus-invalid", - "--spectrum-stepper-border-color-hover", - "--spectrum-stepper-border-color-invalid", - "--spectrum-stepper-border-color-keyboard-focus", - "--spectrum-stepper-border-color-keyboard-focus-invalid", - "--spectrum-stepper-border-radius", - "--spectrum-stepper-border-width", - "--spectrum-stepper-button-border-width", - "--spectrum-stepper-button-border-width-disabled", - "--spectrum-stepper-button-edge-to-fill", - "--spectrum-stepper-button-width", - "--spectrum-stepper-buttons-background-color", - "--spectrum-stepper-buttons-background-color-disabled", - "--spectrum-stepper-buttons-border-color", - "--spectrum-stepper-buttons-border-color-focus", - "--spectrum-stepper-buttons-border-color-focus-hover", - "--spectrum-stepper-buttons-border-color-hover", - "--spectrum-stepper-buttons-border-color-keyboard-focus", - "--spectrum-stepper-buttons-border-style", - "--spectrum-stepper-buttons-border-width", - "--spectrum-stepper-focus-indicator-color", - "--spectrum-stepper-focus-indicator-gap", - "--spectrum-stepper-focus-indicator-width", - "--spectrum-stepper-height", - "--spectrum-stepper-width" + "--mod-numberfield-background-color", + "--mod-numberfield-background-color-disabled", + "--mod-numberfield-block-size", + "--mod-numberfield-border-color", + "--mod-numberfield-border-color-disabled", + "--mod-numberfield-border-color-focus", + "--mod-numberfield-border-color-focus-hover", + "--mod-numberfield-border-color-focus-hover-invalid", + "--mod-numberfield-border-color-focus-invalid", + "--mod-numberfield-border-color-hover", + "--mod-numberfield-border-color-hover-invalid", + "--mod-numberfield-border-color-invalid", + "--mod-numberfield-border-color-invalid-default", + "--mod-numberfield-border-color-invalid-focus", + "--mod-numberfield-border-color-invalid-focus-hover", + "--mod-numberfield-border-color-invalid-hover", + "--mod-numberfield-border-color-invalid-keyboard-focus", + "--mod-numberfield-border-color-keyboard-focus", + "--mod-numberfield-border-color-keyboard-focus-invalid", + "--mod-numberfield-border-radius", + "--mod-numberfield-border-width", + "--mod-numberfield-button-inline-offset", + "--mod-numberfield-focus-indicator-color", + "--mod-numberfield-focus-indicator-gap", + "--mod-numberfield-focus-indicator-width", + "--mod-numberfield-font-family", + "--mod-numberfield-font-size", + "--mod-numberfield-font-style", + "--mod-numberfield-font-weight", + "--mod-numberfield-hidden-stepper-min-inline-size", + "--mod-numberfield-inline-size", + "--mod-numberfield-label-to-field", + "--mod-numberfield-line-height", + "--mod-numberfield-min-inline-size", + "--mod-numberfield-spacing-block-end-edge-to-text", + "--mod-numberfield-spacing-block-start-edge-to-text", + "--mod-numberfield-spacing-field-to-helptext", + "--mod-numberfield-text-color", + "--mod-numberfield-text-color-disabled", + "--mod-numberfield-text-color-focus", + "--mod-numberfield-text-color-focus-hover", + "--mod-numberfield-text-color-hover", + "--mod-numberfield-text-color-keyboard-focus" ], + "component": [], "global": [ - "--spectrum-animation-duration-100", - "--spectrum-border-width-100", "--spectrum-border-width-200", + "--spectrum-cjk-line-height-100", + "--spectrum-component-bottom-to-text-100", + "--spectrum-component-bottom-to-text-200", + "--spectrum-component-bottom-to-text-300", + "--spectrum-component-bottom-to-text-75", + "--spectrum-component-edge-to-text-100", + "--spectrum-component-edge-to-text-200", + "--spectrum-component-edge-to-text-300", + "--spectrum-component-edge-to-text-75", "--spectrum-component-height-100", "--spectrum-component-height-200", "--spectrum-component-height-300", "--spectrum-component-height-75", - "--spectrum-corner-radius-100", + "--spectrum-component-top-to-text-100", + "--spectrum-component-top-to-text-200", + "--spectrum-component-top-to-text-300", + "--spectrum-component-top-to-text-75", + "--spectrum-component-top-to-workflow-icon-100", + "--spectrum-component-top-to-workflow-icon-200", + "--spectrum-component-top-to-workflow-icon-300", + "--spectrum-component-top-to-workflow-icon-75", + "--spectrum-corner-radius-medium-size-extra-large", + "--spectrum-corner-radius-medium-size-large", + "--spectrum-corner-radius-medium-size-medium", + "--spectrum-corner-radius-medium-size-small", + "--spectrum-default-font-style", "--spectrum-disabled-border-color", + "--spectrum-disabled-content-color", + "--spectrum-field-default-width-extra-large", + "--spectrum-field-default-width-large", + "--spectrum-field-default-width-medium", + "--spectrum-field-default-width-small", + "--spectrum-field-label-to-component", "--spectrum-focus-indicator-color", "--spectrum-focus-indicator-gap", "--spectrum-focus-indicator-thickness", - "--spectrum-gray-100", + "--spectrum-font-size-100", + "--spectrum-font-size-200", + "--spectrum-font-size-300", + "--spectrum-font-size-75", + "--spectrum-gray-25", "--spectrum-gray-300", - "--spectrum-gray-50", - "--spectrum-gray-500", - "--spectrum-gray-600", + "--spectrum-gray-400", "--spectrum-gray-800", "--spectrum-gray-900", - "--spectrum-in-field-button-width-stacked-extra-large", - "--spectrum-in-field-button-width-stacked-large", - "--spectrum-in-field-button-width-stacked-medium", - "--spectrum-in-field-button-width-stacked-small", + "--spectrum-help-text-to-component", + "--spectrum-in-field-button-edge-to-fill-extra-large", + "--spectrum-in-field-button-edge-to-fill-large", + "--spectrum-in-field-button-edge-to-fill-medium", + "--spectrum-in-field-button-side-edge-to-fill-extra-large", + "--spectrum-in-field-button-side-edge-to-fill-large", + "--spectrum-in-field-button-side-edge-to-fill-medium", + "--spectrum-in-field-button-side-edge-to-fill-small", + "--spectrum-in-field-stepper-to-end-extra-large", + "--spectrum-in-field-stepper-to-end-large", + "--spectrum-in-field-stepper-to-end-medium", + "--spectrum-in-field-stepper-to-end-small", + "--spectrum-line-height-100", "--spectrum-negative-border-color-default", "--spectrum-negative-border-color-focus", "--spectrum-negative-border-color-focus-hover", "--spectrum-negative-border-color-hover", "--spectrum-negative-border-color-key-focus", - "--spectrum-text-field-minimum-width-multiplier" - ], - "system-theme": [ - "--system-stepper-border-color-default", - "--system-stepper-border-color-disabled", - "--system-stepper-border-color-focus", - "--system-stepper-border-color-focus-hover", - "--system-stepper-border-color-focus-hover-invalid", - "--system-stepper-border-color-focus-invalid", - "--system-stepper-border-color-hover", - "--system-stepper-border-color-invalid", - "--system-stepper-border-color-keyboard-focus", - "--system-stepper-border-color-keyboard-focus-invalid", - "--system-stepper-border-width", - "--system-stepper-button-border-width", - "--system-stepper-button-border-width-disabled", - "--system-stepper-buttons-background-color", - "--system-stepper-buttons-background-color-disabled", - "--system-stepper-buttons-border-color", - "--system-stepper-buttons-border-color-focus", - "--system-stepper-buttons-border-color-hover", - "--system-stepper-buttons-border-color-keyboard-focus", - "--system-stepper-buttons-border-style", - "--system-stepper-buttons-border-width", - "--system-stepper-quiet-button-edge-to-fill", - "--system-stepper-quiet-buttons-border-style" + "--spectrum-neutral-content-color-default", + "--spectrum-neutral-content-color-focus", + "--spectrum-neutral-content-color-focus-hover", + "--spectrum-neutral-content-color-hover", + "--spectrum-neutral-content-color-key-focus", + "--spectrum-number-field-minimum-width-multiplier", + "--spectrum-number-field-visual-to-in-field-stepper-extra-large", + "--spectrum-number-field-visual-to-in-field-stepper-large", + "--spectrum-number-field-visual-to-in-field-stepper-medium", + "--spectrum-number-field-visual-to-in-field-stepper-small", + "--spectrum-number-field-with-stepper-minimum-width-extra-large", + "--spectrum-number-field-with-stepper-minimum-width-large", + "--spectrum-number-field-with-stepper-minimum-width-medium", + "--spectrum-number-field-with-stepper-minimum-width-small", + "--spectrum-numberfield-alert-icon-size", + "--spectrum-numberfield-background-color", + "--spectrum-numberfield-background-color-disabled", + "--spectrum-numberfield-block-size", + "--spectrum-numberfield-border-color-default", + "--spectrum-numberfield-border-color-disabled", + "--spectrum-numberfield-border-color-focus", + "--spectrum-numberfield-border-color-focus-hover", + "--spectrum-numberfield-border-color-hover", + "--spectrum-numberfield-border-color-invalid-default", + "--spectrum-numberfield-border-color-invalid-focus", + "--spectrum-numberfield-border-color-invalid-focus-hover", + "--spectrum-numberfield-border-color-invalid-hover", + "--spectrum-numberfield-border-color-invalid-keyboard-focus", + "--spectrum-numberfield-border-color-keyboard-focus", + "--spectrum-numberfield-border-radius", + "--spectrum-numberfield-border-width", + "--spectrum-numberfield-button-container-size", + "--spectrum-numberfield-button-inline-offset", + "--spectrum-numberfield-button-inline-padding", + "--spectrum-numberfield-focus-indicator-color", + "--spectrum-numberfield-focus-indicator-gap", + "--spectrum-numberfield-focus-indicator-width", + "--spectrum-numberfield-font-family", + "--spectrum-numberfield-font-size", + "--spectrum-numberfield-font-style", + "--spectrum-numberfield-font-weight", + "--spectrum-numberfield-hidden-stepper-min-inline-size", + "--spectrum-numberfield-inline-size", + "--spectrum-numberfield-line-height", + "--spectrum-numberfield-min-inline-size", + "--spectrum-numberfield-spacing-block-end-edge-to-alert-icon", + "--spectrum-numberfield-spacing-block-end-edge-to-text", + "--spectrum-numberfield-spacing-block-start-edge-to-alert-icon", + "--spectrum-numberfield-spacing-block-start-edge-to-text", + "--spectrum-numberfield-spacing-field-to-helptext", + "--spectrum-numberfield-spacing-inline-edge-to-text", + "--spectrum-numberfield-spacing-label-to-field", + "--spectrum-numberfield-spacing-min-inline-end-text-to-stepper", + "--spectrum-numberfield-spacing-min-inline-end-value-to-icon", + "--spectrum-numberfield-spacing-side-label-to-field", + "--spectrum-numberfield-spacing-validation-icon-to-stepper", + "--spectrum-numberfield-text-color", + "--spectrum-numberfield-text-color-disabled", + "--spectrum-numberfield-text-color-focus", + "--spectrum-numberfield-text-color-focus-hover", + "--spectrum-numberfield-text-color-hover", + "--spectrum-numberfield-text-color-keyboard-focus", + "--spectrum-regular-font-weight", + "--spectrum-sans-font-family-stack", + "--spectrum-spacing-200", + "--spectrum-text-to-visual-100", + "--spectrum-text-to-visual-200", + "--spectrum-text-to-visual-300", + "--spectrum-text-to-visual-75", + "--spectrum-workflow-icon-size-100", + "--spectrum-workflow-icon-size-200", + "--spectrum-workflow-icon-size-300", + "--spectrum-workflow-icon-size-75" ], "passthroughs": [ - "--mod-infield-button-border-block-end-width", - "--mod-infield-button-border-color", - "--mod-infield-button-border-color-quiet", - "--mod-infield-button-border-color-quiet-disabled", - "--mod-infield-button-border-width", - "--mod-infield-button-edge-to-fill", - "--mod-infield-button-fill-justify-content", - "--mod-infield-button-inner-edge-to-fill", - "--mod-infield-button-stacked-bottom-border-block-end-width", - "--mod-infield-button-stacked-bottom-border-radius-end-end", - "--mod-infield-button-stacked-bottom-border-radius-end-start", - "--mod-infield-button-width-stacked", "--mod-textfield-background-color", - "--mod-textfield-border-color", - "--mod-textfield-border-color-disabled", - "--mod-textfield-border-color-hover", - "--mod-textfield-border-width", - "--mod-textfield-focus-indicator-color", - "--mod-textfield-focus-indicator-width", - "--mod-textfield-icon-spacing-inline-start-invalid" + "--mod-textfield-background-color-disabled", + "--mod-textfield-font-family", + "--mod-textfield-font-size", + "--mod-textfield-font-style", + "--mod-textfield-font-weight", + "--mod-textfield-height", + "--mod-textfield-icon-spacing-block-invalid", + "--mod-textfield-spacing-block-end", + "--mod-textfield-spacing-block-start", + "--mod-textfield-text-color-default", + "--mod-textfield-text-color-disabled", + "--mod-textfield-text-color-focus", + "--mod-textfield-width" ], "high-contrast": [ - "--highcontrast-infield-button-border-color", - "--highcontrast-infield-button-border-color-active", - "--highcontrast-stepper-border-color", - "--highcontrast-stepper-border-color-focus", - "--highcontrast-stepper-border-color-focus-hover", - "--highcontrast-stepper-border-color-hover", - "--highcontrast-stepper-border-color-keyboard-focus", - "--highcontrast-stepper-buttons-border-width", - "--highcontrast-stepper-focus-indicator-color", + "--highcontrast-numberfield-background-color", + "--highcontrast-numberfield-border-color", + "--highcontrast-numberfield-border-color-focus", + "--highcontrast-numberfield-border-color-focus-hover", + "--highcontrast-numberfield-border-color-hover", + "--highcontrast-numberfield-border-color-keyboard-focus", + "--highcontrast-numberfield-focus-indicator-color", "--highcontrast-textfield-border-color" ] } diff --git a/components/stepper/index.css b/components/stepper/index.css index f3c9682c07d..90dcf6864f9 100644 --- a/components/stepper/index.css +++ b/components/stepper/index.css @@ -1,5 +1,5 @@ /*! - * Copyright 2024 Adobe. All rights reserved. + * Copyright 2025 Adobe. All rights reserved. * * This file is licensed to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. You may obtain a copy @@ -11,348 +11,441 @@ * governing permissions and limitations under the License. */ -@import "./themes/spectrum-two.css"; - -/* --- High contrast settings --- */ -@media (forced-colors: active) { - .spectrum-Stepper { - --highcontrast-stepper-border-color: CanvasText; - --highcontrast-stepper-border-color-hover: Highlight; - --highcontrast-stepper-border-color-focus: Highlight; - --highcontrast-stepper-border-color-focus-hover: Highlight; - --highcontrast-stepper-border-color-keyboard-focus: CanvasText; - --highcontrast-stepper-focus-indicator-color: Highlight; - - &.is-invalid { - --highcontrast-stepper-border-color: Highlight; - --highcontrast-stepper-border-color-hover: Highlight; - --highcontrast-stepper-border-color-focus: Highlight; - --highcontrast-stepper-border-color-focus-hover: Highlight; - --highcontrast-stepper-border-color-keyboard-focus: Highlight; - } - - &.is-disabled { - --highcontrast-stepper-border-color: GrayText; - --highcontrast-stepper-buttons-border-width: var(--mod-stepper-border-width, var(--spectrum-stepper-border-width)); - } - - &:not(.is-disabled) { - &:hover { - --highcontrast-stepper-border-color: var(--highcontrast-stepper-border-color-hover); - } - - &.is-focused, - &:focus { - --highcontrast-stepper-border-color: var(--highcontrast-stepper-border-color-focus); - - &:hover { - --highcontrast-stepper-border-color: var(--highcontrast-stepper-border-color-focus-hover); - } - } - - &.is-keyboardFocused, - &:focus-visible { - --highcontrast-stepper-border-color: var(--highcontrast-stepper-border-color-keyboard-focus); - } - } +/* --- Component-level definitions --- */ +.spectrum-NumberField { + /* Border */ + --spectrum-numberfield-border-radius: var(--mod-numberfield-border-radius, var(--spectrum-corner-radius-medium-size-medium)); + --spectrum-numberfield-border-width: var(--mod-numberfield-border-width, var(--spectrum-border-width-200)); + --spectrum-numberfield-border-color-default: var(--highcontrast-numberfield-border-color, var(--mod-numberfield-border-color, var(--spectrum-gray-300))); + --spectrum-numberfield-border-color-hover: var(--highcontrast-numberfield-border-color-hover, var(--mod-numberfield-border-color-hover, var(--spectrum-gray-400))); + --spectrum-numberfield-border-color-focus: var(--highcontrast-numberfield-border-color-focus, var(--mod-numberfield-border-color-focus, var(--spectrum-gray-800))); + --spectrum-numberfield-border-color-keyboard-focus: var(--highcontrast-numberfield-border-color-keyboard-focus, var(--mod-numberfield-border-color-keyboard-focus, var(--spectrum-gray-800))); + --spectrum-numberfield-border-color-focus-hover: var(--highcontrast-numberfield-border-color-focus-hover, var(--mod-numberfield-border-color-focus-hover, var(--spectrum-gray-900))); + --spectrum-numberfield-border-color-disabled: var(--mod-numberfield-border-color-disabled, var(--spectrum-disabled-border-color)); + + /* Invalid border */ + --spectrum-numberfield-border-color-invalid-default: var(--mod-numberfield-border-color-invalid-default, var(--spectrum-negative-border-color-default)); + --spectrum-numberfield-border-color-invalid-hover: var(--mod-numberfield-border-color-invalid-hover, var(--spectrum-negative-border-color-hover)); + --spectrum-numberfield-border-color-invalid-focus: var(--mod-numberfield-border-color-invalid-focus, var(--spectrum-negative-border-color-focus)); + --spectrum-numberfield-border-color-invalid-focus-hover: var(--mod-numberfield-border-color-invalid-focus-hover, var(--spectrum-negative-border-color-focus-hover)); + --spectrum-numberfield-border-color-invalid-keyboard-focus: var(--mod-numberfield-border-color-invalid-keyboard-focus, var(--spectrum-negative-border-color-key-focus)); + + /* Text color */ + --spectrum-numberfield-text-color: var(--mod-numberfield-text-color, var(--spectrum-neutral-content-color-default)); + --spectrum-numberfield-text-color-hover: var(--mod-numberfield-text-color-hover, var(--spectrum-neutral-content-color-hover)); + /* stylelint-disable-next-line spectrum-tools/no-unused-custom-properties -- used to assign Textfield mods */ + --spectrum-numberfield-text-color-focus: var(--mod-numberfield-text-color-focus, var(--spectrum-neutral-content-color-focus)); + /* stylelint-disable-next-line spectrum-tools/no-unused-custom-properties -- used to assign Textfield mods */ + --spectrum-numberfield-text-color-focus-hover: var(--mod-numberfield-text-color-focus-hover, var(--spectrum-neutral-content-color-focus-hover)); + --spectrum-numberfield-text-color-keyboard-focus: var(--mod-numberfield-text-color-keyboard-focus, var(--spectrum-neutral-content-color-key-focus)); + --spectrum-numberfield-text-color-disabled: var(--mod-numberfield-text-color-disabled, var(--spectrum-disabled-content-color)); + + /* Background */ + --spectrum-numberfield-background-color: var(--highcontrast-numberfield-background-color, var(--mod-numberfield-background-color, var(--spectrum-gray-25))); + + /* --spectrum-numberfield-background-color-disabled: var(--mod-numberfield-background-color-disabled, var(--spectrum-disabled-background-color)); */ + --spectrum-numberfield-background-color-disabled: var(--mod-numberfield-background-color-disabled, var(--spectrum-gray-25)); + + /* Font */ + --spectrum-numberfield-font-family: var(--mod-numberfield-font-family, var(--spectrum-sans-font-family-stack)); + --spectrum-numberfield-font-weight: var(--mod-numberfield-font-weight, var(--spectrum-regular-font-weight)); + --spectrum-numberfield-font-size: var(--mod-numberfield-font-size, var(--spectrum-font-size-100)); + --spectrum-numberfield-font-style: var(--mod-numberfield-font-style, var(--spectrum-default-font-style)); + --spectrum-numberfield-line-height: var(--mod-numberfield-line-height, var(--spectrum-line-height-100)); + + /* Focus indicator */ + --spectrum-numberfield-focus-indicator-width: var(--mod-numberfield-focus-indicator-width, var(--spectrum-focus-indicator-thickness)); + --spectrum-numberfield-focus-indicator-gap: var(--mod-numberfield-focus-indicator-gap, var(--spectrum-focus-indicator-gap)); + --spectrum-numberfield-focus-indicator-color: var(--highcontrast-numberfield-focus-indicator-color, var(--mod-numberfield-focus-indicator-color, var(--spectrum-focus-indicator-color))); + + /* Dimensions */ + --spectrum-numberfield-block-size: var(--mod-numberfield-block-size, var(--spectrum-component-height-100)); + --spectrum-numberfield-inline-size: var(--mod-numberfield-inline-size, var(--spectrum-field-default-width-medium)); + --spectrum-numberfield-min-inline-size: var(--mod-numberfield-min-inline-size, var(--spectrum-number-field-with-stepper-minimum-width-medium)); + --spectrum-numberfield-hidden-stepper-min-inline-size: calc(var(--spectrum-number-field-minimum-width-multiplier) * var(--spectrum-numberfield-block-size)); + + /* Icons */ + --spectrum-numberfield-alert-icon-size: var(--spectrum-workflow-icon-size-100); + + /* Spacing */ + --spectrum-numberfield-spacing-inline-edge-to-text: calc(var(--spectrum-component-edge-to-text-100) - var(--spectrum-numberfield-border-width)); + --spectrum-numberfield-spacing-block-start-edge-to-text: var(--spectrum-component-top-to-text-100); + --spectrum-numberfield-spacing-block-end-edge-to-text: var(--spectrum-component-bottom-to-text-100); + + /* Button size and offset (to properly position the validation icons/padding) */ + --spectrum-numberfield-button-inline-padding: var(--spectrum-in-field-button-side-edge-to-fill-medium); + --spectrum-numberfield-button-container-size: calc((var(--spectrum-component-height-100) - var(--spectrum-in-field-button-edge-to-fill-medium)) * 2); + --spectrum-numberfield-button-inline-offset: var(--mod-numberfield-button-inline-offset, var(--spectrum-in-field-stepper-to-end-medium)); + + /* the input to the stepper buttons spacing accommodates the built-in padding on the infield buttons */ + --spectrum-numberfield-spacing-min-inline-end-text-to-stepper: calc(var(--spectrum-text-to-visual-100) - var(--spectrum-numberfield-button-inline-padding)); + --spectrum-numberfield-spacing-min-inline-end-value-to-icon: var(--spectrum-text-to-visual-100); + --spectrum-numberfield-spacing-field-to-helptext: var(--spectrum-help-text-to-component); + --spectrum-numberfield-spacing-label-to-field: var(--spectrum-field-label-to-component); + --spectrum-numberfield-spacing-validation-icon-to-stepper: calc(var(--spectrum-number-field-visual-to-in-field-stepper-medium) - var(--spectrum-numberfield-button-inline-padding)); + --spectrum-numberfield-spacing-side-label-to-field: var(--spectrum-spacing-200); + + --spectrum-numberfield-spacing-block-start-edge-to-alert-icon: var(--spectrum-component-top-to-workflow-icon-100); + + /* stylelint-disable-next-line spectrum-tools/no-unused-custom-properties -- documenting from token specs, but not used in textfield mod */ + --spectrum-numberfield-spacing-block-end-edge-to-alert-icon: var(--spectrum-component-top-to-workflow-icon-100); + + &.spectrum-NumberField--sizeS { + --spectrum-numberfield-border-radius: var(--mod-numberfield-border-radius, var(--spectrum-corner-radius-medium-size-small)); + --spectrum-numberfield-block-size: var(--mod-numberfield-block-size, var(--spectrum-component-height-75)); + --spectrum-numberfield-inline-size: var(--mod-numberfield-inline-size, var(--spectrum-field-default-width-small)); + --spectrum-numberfield-min-inline-size: var(--mod-numberfield-min-inline-size, var(--spectrum-number-field-with-stepper-minimum-width-small)); + --spectrum-numberfield-spacing-inline-edge-to-text: calc(var(--spectrum-component-edge-to-text-75) - var(--spectrum-numberfield-border-width)); + --spectrum-numberfield-font-size: var(--mod-numberfield-font-size, var(--spectrum-font-size-75)); + --spectrum-numberfield-spacing-block-start-edge-to-text: var(--spectrum-component-top-to-text-75); + --spectrum-numberfield-spacing-block-end-edge-to-text: var(--spectrum-component-bottom-to-text-75); + --spectrum-numberfield-spacing-min-inline-end-text-to-stepper: calc(var(--spectrum-text-to-visual-75) - var(--spectrum-numberfield-button-inline-padding)); + --spectrum-numberfield-spacing-min-inline-end-value-to-icon: var(--spectrum-text-to-visual-75); + --spectrum-numberfield-spacing-validation-icon-to-stepper: calc(var(--spectrum-number-field-visual-to-in-field-stepper-small) - var(--spectrum-numberfield-button-inline-padding)); + + --spectrum-numberfield-button-inline-padding: var(--spectrum-in-field-button-side-edge-to-fill-small); + + /* this 👇 container size does not include the infield buttons' inline-padding */ + --spectrum-numberfield-button-container-size: calc(var(--spectrum-component-height-75) * 2); + --spectrum-numberfield-button-inline-offset: var(--mod-numberfield-button-inline-offset, var(--spectrum-in-field-stepper-to-end-small)); + + --spectrum-numberfield-spacing-block-start-edge-to-alert-icon: var(--spectrum-component-top-to-workflow-icon-75); + + /* stylelint-disable-next-line spectrum-tools/no-unused-custom-properties -- documenting from token specs, but not used in textfield mod */ + --spectrum-numberfield-spacing-block-end-edge-to-alert-icon: var(--spectrum-component-top-to-workflow-icon-75); + --spectrum-numberfield-alert-icon-size: var(--spectrum-workflow-icon-size-75); } - /* @passthrough start */ - .spectrum-Stepper-input { - --highcontrast-textfield-border-color: var(--highcontrast-stepper-border-color); + &.spectrum-NumberField--sizeL { + --spectrum-numberfield-border-radius: var(--mod-numberfield-border-radius, var(--spectrum-corner-radius-medium-size-large)); + --spectrum-numberfield-block-size: var(--mod-numberfield-block-size, var(--spectrum-component-height-200)); + --spectrum-numberfield-inline-size: var(--mod-numberfield-inline-size, var(--spectrum-field-default-width-large)); + --spectrum-numberfield-min-inline-size: var(--mod-numberfield-min-inline-size, var(--spectrum-number-field-with-stepper-minimum-width-large)); + --spectrum-numberfield-spacing-inline-edge-to-text: calc(var(--spectrum-component-edge-to-text-200) - var(--spectrum-numberfield-border-width)); + --spectrum-numberfield-font-size: var(--mod-numberfield-font-size, var(--spectrum-font-size-200)); + --spectrum-numberfield-spacing-block-start-edge-to-text: var(--spectrum-component-top-to-text-200); + --spectrum-numberfield-spacing-block-end-edge-to-text: var(--spectrum-component-bottom-to-text-200); + --spectrum-numberfield-spacing-min-inline-end-text-to-stepper: calc(var(--spectrum-text-to-visual-200) - var(--spectrum-numberfield-button-inline-padding)); + --spectrum-numberfield-spacing-min-inline-end-value-to-icon: var(--spectrum-text-to-visual-200); + --spectrum-numberfield-spacing-validation-icon-to-stepper: calc(var(--spectrum-number-field-visual-to-in-field-stepper-large) - var(--spectrum-numberfield-button-inline-padding)); + + --spectrum-numberfield-button-inline-padding: var(--spectrum-in-field-button-side-edge-to-fill-large); + --spectrum-numberfield-button-container-size: calc((var(--spectrum-component-height-200) - var(--spectrum-in-field-button-edge-to-fill-large)) * 2); + --spectrum-numberfield-button-inline-offset: var(--mod-numberfield-button-inline-offset, var(--spectrum-in-field-stepper-to-end-large)); + + --spectrum-numberfield-spacing-block-start-edge-to-alert-icon: var(--spectrum-component-top-to-workflow-icon-200); + + /* stylelint-disable-next-line spectrum-tools/no-unused-custom-properties -- documenting from token specs, but not used in textfield mod */ + --spectrum-numberfield-spacing-block-end-edge-to-alert-icon: var(--spectrum-component-top-to-workflow-icon-200); + --spectrum-numberfield-alert-icon-size: var(--spectrum-workflow-icon-size-200); } - /* @passthrough end */ - /* @passthrough start */ - .spectrum-Stepper-button { - --highcontrast-infield-button-border-color: var(--highcontrast-stepper-border-color); - --highcontrast-infield-button-border-color-active: var(--highcontrast-stepper-border-color); + &.spectrum-NumberField--sizeXL { + --spectrum-numberfield-border-radius: var(--mod-numberfield-border-radius, var(--spectrum-corner-radius-medium-size-extra-large)); + --spectrum-numberfield-block-size: var(--mod-numberfield-block-size, var(--spectrum-component-height-300)); + --spectrum-numberfield-inline-size: var(--mod-numberfield-inline-size, var(--spectrum-field-default-width-extra-large)); + --spectrum-numberfield-min-inline-size: var(--mod-numberfield-min-inline-size, var(--spectrum-number-field-with-stepper-minimum-width-extra-large)); + --spectrum-numberfield-spacing-inline-edge-to-text: calc(var(--spectrum-component-edge-to-text-300) - var(--spectrum-numberfield-border-width)); + --spectrum-numberfield-font-size: var(--mod-numberfield-font-size, var(--spectrum-font-size-300)); + --spectrum-numberfield-spacing-block-start-edge-to-text: var(--spectrum-component-top-to-text-300); + --spectrum-numberfield-spacing-block-end-edge-to-text: var(--spectrum-component-bottom-to-text-300); + --spectrum-numberfield-spacing-min-inline-end-text-to-stepper: calc(var(--spectrum-text-to-visual-300) - var(--spectrum-numberfield-button-inline-padding)); + --spectrum-numberfield-spacing-min-inline-end-value-to-icon: var(--spectrum-text-to-visual-300); + --spectrum-numberfield-spacing-validation-icon-to-stepper: calc(var(--spectrum-number-field-visual-to-in-field-stepper-extra-large) - var(--spectrum-numberfield-button-inline-padding)); + + --spectrum-numberfield-button-inline-padding: var(--spectrum-in-field-button-side-edge-to-fill-extra-large); + --spectrum-numberfield-button-container-size: calc((var(--spectrum-component-height-300) - var(--spectrum-in-field-button-edge-to-fill-extra-large)) * 2); + --spectrum-numberfield-button-inline-offset: var(--mod-numberfield-button-inline-offset, var(--spectrum-in-field-stepper-to-end-extra-large)); + + --spectrum-numberfield-spacing-block-start-edge-to-alert-icon: var(--spectrum-component-top-to-workflow-icon-300); + + /* stylelint-disable-next-line spectrum-tools/no-unused-custom-properties -- documenting from token specs, but not used in textfield mod */ + --spectrum-numberfield-spacing-block-end-edge-to-alert-icon: var(--spectrum-component-top-to-workflow-icon-300); + --spectrum-numberfield-alert-icon-size: var(--spectrum-workflow-icon-size-300); } - /* @passthrough end */ -} -/* --- Component-level definitions --- */ -.spectrum-Stepper { - --spectrum-stepper-border-color: var(--highcontrast-stepper-border-color, var(--mod-stepper-border-color, var(--spectrum-stepper-border-color-default))); - --spectrum-stepper-border-radius: var(--mod-stepper-border-radius, var(--spectrum-corner-radius-100)); + &:not(.is-disabled, .is-readOnly).is-hover, + &:not(.is-disabled, .is-readOnly):hover { + --mod-numberfield-border-color: var(--highcontrast-numberfield-border-color-hover, var(--mod-numberfield-border-color-hover, var(--spectrum-numberfield-border-color-hover))); + } - --spectrum-stepper-focus-indicator-width: var(--mod-stepper-focus-indicator-width, var(--spectrum-focus-indicator-thickness)); - --spectrum-stepper-focus-indicator-gap: var(--mod-stepper-focus-indicator-gap, var(--spectrum-focus-indicator-gap)); - --spectrum-stepper-focus-indicator-color: var(--highcontrast-stepper-focus-indicator-color, var(--mod-stepper-focus-indicator-color, var(--spectrum-focus-indicator-color))); + &.is-invalid { + --mod-numberfield-border-color: var(--mod-numberfield-border-color-invalid, var(--spectrum-numberfield-border-color-invalid-default)); + --mod-numberfield-border-color-hover: var(--mod-numberfield-border-color-hover-invalid, var(--spectrum-numberfield-border-color-invalid-hover)); + --mod-numberfield-border-color-focus: var(--mod-numberfield-border-color-focus-invalid, var(--spectrum-numberfield-border-color-invalid-focus)); + --mod-numberfield-border-color-focus-hover: var(--mod-numberfield-border-color-focus-hover-invalid, var(--spectrum-numberfield-border-color-invalid-focus-hover)); + --mod-numberfield-border-color-keyboard-focus: var(--mod-numberfield-border-color-keyboard-focus-invalid, var(--spectrum-numberfield-border-color-invalid-keyboard-focus)); + } - --spectrum-stepper-animation-duration: var(--mod-stepper-animation-duration, var(--spectrum-animation-duration-100)); + &:not(.is-disabled, .is-readOnly).is-focused, + &:not(.is-disabled, .is-readOnly):focus, + &:not(.is-disabled, .is-readOnly):focus-within { + --mod-numberfield-border-color: var(--highcontrast-numberfield-border-color-focus, var(--mod-numberfield-border-color-focus, var(--spectrum-numberfield-border-color-focus))); - &, - &.spectrum-Stepper--sizeM { - --spectrum-stepper-button-width: var(--mod-stepper-button-width, var(--spectrum-in-field-button-width-stacked-medium)); - --spectrum-stepper-height: var(--mod-stepper-height, var(--spectrum-component-height-100)); + &.is-hover, + &:hover { + --mod-numberfield-border-color: var(--highcontrast-numberfield-border-color-focus-hover, var(--mod-numberfield-border-color-focus-hover, var(--spectrum-numberfield-border-color-focus-hover))); + } } - &.spectrum-Stepper--sizeS { - --spectrum-stepper-button-width: var(--mod-stepper-button-width, var(--spectrum-in-field-button-width-stacked-small)); - --spectrum-stepper-height: var(--mod-stepper-height, var(--spectrum-component-height-75)); - } + &:not(.is-disabled, .is-readOnly).is-keyboardFocused, + &:not(.is-disabled, .is-readOnly):focus-visible, + &:not(.is-disabled, .is-readOnly):focus-within { + --mod-numberfield-border-color: var(--highcontrast-numberfield-border-color-focus, var(--mod-numberfield-border-color-keyboard-focus, var(--spectrum-numberfield-border-color-keyboard-focus))); - &.spectrum-Stepper--sizeL { - --spectrum-stepper-button-width: var(--mod-stepper-button-width, var(--spectrum-in-field-button-width-stacked-large)); - --spectrum-stepper-height: var(--mod-stepper-height, var(--spectrum-component-height-200)); + &.is-hover, + &:hover { + --mod-numberfield-border-color: var(--highcontrast-numberfield-border-color-focus-hover, var(--mod-numberfield-border-color-focus-hover, var(--spectrum-numberfield-border-color-focus-hover))); + } } - &.spectrum-Stepper--sizeXL { - --spectrum-stepper-button-width: var(--mod-stepper-button-width, var(--spectrum-in-field-button-width-stacked-extra-large)); - --spectrum-stepper-height: var(--mod-stepper-height, var(--spectrum-component-height-300)); + &.is-readOnly { + --mod-numberfield-border-color: var(--spectrum-numberfield-border-color-disabled); } &.is-disabled { - --spectrum-stepper-buttons-border-width: var(--spectrum-stepper-button-border-width-disabled); - --spectrum-stepper-buttons-background-color: var(--spectrum-stepper-buttons-background-color-disabled); + --mod-numberfield-border-color: var(--spectrum-numberfield-border-color-disabled); + --mod-numberfield-background-color: var(--spectrum-numberfield-background-color-disabled); } - &.is-invalid { - --mod-stepper-border-color: var(--mod-stepper-border-color-invalid, var(--spectrum-negative-border-color-default)); - --mod-stepper-border-color-hover: var(--mod-stepper-border-color-hover-invalid, var(--spectrum-negative-border-color-hover)); - --mod-stepper-border-color-focus: var(--mod-stepper-border-color-focus-invalid, var(--spectrum-negative-border-color-focus)); - --mod-stepper-border-color-focus-hover: var(--mod-stepper-border-color-focus-hover-invalid, var(--spectrum-negative-border-color-focus-hover)); - --mod-stepper-border-color-keyboard-focus: var(--mod-stepper-border-color-keyboard-focus-invalid, var(--spectrum-negative-border-color-key-focus)); + &:lang(ja), + &:lang(zh), + &:lang(ko) { + --spectrum-numberfield-line-height: var(--spectrum-cjk-line-height-100); } + /* @passthrough start -- MODS for sub components */ + /* nested textfield */ + --mod-textfield-spacing-block-start: var(--mod-numberfield-spacing-block-start-edge-to-text, var(--spectrum-numberfield-spacing-block-start-edge-to-text)); + --mod-textfield-spacing-block-end: var(--mod-numberfield-spacing-block-end-edge-to-text, var(--spectrum-numberfield-spacing-block-end-edge-to-text)); + --mod-textfield-icon-spacing-block-invalid: calc(var(--spectrum-numberfield-spacing-block-start-edge-to-alert-icon) - var(--spectrum-numberfield-border-width)); + + /* this mod overrides the inline-size of the nested textfield */ + --mod-textfield-width: 100%; + --mod-textfield-height: calc(var(--mod-numberfield-block-size, var(--spectrum-numberfield-block-size)) - var(--mod-numberfield-border-width, var(--spectrum-numberfield-border-width)) * 2); + --mod-textfield-background-color: var(--mod-numberfield-background-color, var(--spectrum-numberfield-background-color, transparent)); + --mod-textfield-text-color-default: var(--mod-numberfield-text-color, var(--spectrum-numberfield-text-color)); + --mod-textfield-text-color-disabled: var(--mod-numberfield-text-color-disabled, var(--spectrum-numberfield-text-color-disabled)); + --mod-textfield-background-color-disabled: var(--mod-numberfield-background-color-disabled, var(--spectrum-numberfield-background-color-disabled)); + --mod-textfield-font-family: var(--mod-numberfield-font-family, var(--spectrum-numberfield-font-family)); + --mod-textfield-font-weight: var(--mod-numberfield-font-weight, var(--spectrum-numberfield-font-weight)); + --mod-textfield-font-style: var(--mod-numberfield-font-style, var(--spectrum-numberfield-font-style)); + --mod-textfield-font-size: var(--mod-numberfield-font-size, var(--spectrum-numberfield-font-size)); + + &:not(.is-disabled).is-hover, &:not(.is-disabled):hover { - --mod-stepper-border-color: var(--highcontrast-stepper-border-color-hover, var(--mod-stepper-border-color-hover, var(--spectrum-stepper-border-color-hover))); - } - - &:not(.is-disabled).is-focused, - &:not(.is-disabled):focus { - --mod-stepper-border-color: var(--highcontrast-stepper-border-color-focus, var(--mod-stepper-border-color-focus, var(--spectrum-stepper-border-color-focus))); - --mod-stepper-buttons-border-color: var(--highcontrast-stepper-border-color-focus, var(--mod-stepper-border-color-focus, var(--spectrum-stepper-border-color-focus))); - - &:hover { - --mod-stepper-border-color: var(--highcontrast-stepper-border-color-focus-hover, var(--mod-stepper-border-color-focus-hover, var(--spectrum-stepper-border-color-focus-hover))); - --mod-stepper-buttons-border-color: var(--highcontrast-stepper-border-color-focus-hover, var(--mod-stepper-border-color-focus-hover, var(--spectrum-stepper-border-color-focus-hover))); - } + /* overrides the textfield mod */ + --mod-textfield-text-color-default: var(--mod-numberfield-text-color-hover, var(--spectrum-numberfield-text-color-hover)); } - &:not(.is-disabled).is-keyboardFocused { - --mod-stepper-border-color: var(--highcontrast-stepper-border-color-focus, var(--mod-stepper-border-color-focus, var(--spectrum-stepper-border-color-keyboard-focus))); + &:not(.is-disabled).is-keyboardFocused, + &:not(.is-disabled):focus-visible, + &:not(.is-disabled):focus-within { + /* overrides the textfield mod */ + --mod-textfield-text-color-default: var(--mod-numberfield-text-color-keyboard-focus, var(--spectrum-numberfield-text-color-keyboard-focus)); } - &.spectrum-Stepper--quiet { - --mod-stepper-buttons-background-color: transparent; - - /* quiet hover */ - &:not(.is-disabled) { - &:hover { - --mod-stepper-buttons-background-color: transparent; - } - - &.is-keyboardFocused { - /* quiet focus indicator only on bottom border */ - --mod-stepper-focus-indicator-visibility: visible; - } - } + &:not(.is-disabled).is-focused, + &:not(.is-disabled):focus, + &:not(.is-disabled):focus-within { + --mod-textfield-text-color-focus: var(--mod-numberfield-text-color-focus, var(--spectrum-numberfield-text-color-focus)); - &.is-invalid { - --mod-stepper-border-color: var(--mod-stepper-border-color-invalid, var(--spectrum-negative-border-color-default)); + &.is-hover, + &:hover { + /* overrides the textfield mod */ + --mod-textfield-text-color-focus: var(--mod-numberfield-text-color-focus-hover, var(--spectrum-numberfield-text-color-focus-hover)); } } + /* @passthrough end */ } -/* --- Component-level passthroughs for nested components --- */ -/* @passthrough start -- MODS for sub components */ -.spectrum-Stepper { - --mod-infield-button-border-color: var(--mod-stepper-buttons-border-color, var(--spectrum-stepper-buttons-border-color)); - --mod-infield-button-border-color-quiet-disabled: var(--spectrum-disabled-border-color); - --mod-infield-button-border-width: var(--mod-stepper-button-border-width, var(--spectrum-stepper-button-border-width)); - - --mod-textfield-border-width: var(--mod-stepper-border-width, var(--spectrum-stepper-border-width)); - --mod-textfield-border-color: var(--spectrum-stepper-border-color); +/* --- Component styles --- */ +.spectrum-NumberField { + position: relative; + display: inline-grid; + min-inline-size: var(--spectrum-numberfield-min-inline-size); + inline-size: var(--spectrum-numberfield-inline-size); - &:not(.spectrum-Stepper--quiet) { - --mod-textfield-border-color-disabled: var(--spectrum-stepper-border-color-disabled); + &::before { + content: ""; } - &:hover:not(.is-invalid, .is-disabled, .is-focused) { - --mod-infield-button-border-color: var(--mod-stepper-buttons-border-color-hover, var(--spectrum-stepper-buttons-border-color-hover)); + &:not(.is-disabled, .is-readOnly).is-keyboardFocused .spectrum-NumberField-inputs, + &:focus-visible .spectrum-NumberField-inputs { + outline: var(--spectrum-numberfield-focus-indicator-width) solid; + outline-color: var(--spectrum-numberfield-focus-indicator-color); + outline-offset: var(--spectrum-numberfield-focus-indicator-gap); } - &:not(.is-disabled) { - .is-focused, - &:focus { - --mod-infield-button-border-color: var(--highcontrast-stepper-border-color-focus, var(--mod-stepper-buttons-border-color-focus, var(--spectrum-stepper-buttons-border-color-focus))); - --mod-textfield-focus-indicator-width: 0; + &.spectrum-NumberField--hiddenStepper { + min-inline-size: var(--mod-numberfield-hidden-stepper-min-inline-size, var(--spectrum-numberfield-hidden-stepper-min-inline-size)); - &:hover { - /* stylelint-disable-next-line spectrum-tools/no-unknown-custom-properties -- allows for --spectrum-stepper-buttons-border-color-focus-hover to be defined outside of current context */ - --mod-infield-button-border-color: var(--mod-stepper-buttons-border-color-focus-hover, var(--spectrum-stepper-buttons-border-color-focus-hover)); - --mod-textfield-focus-indicator-width: 0; - --mod-textfield-border-color: var(--highcontrast-stepper-border-color-focus-hover, var(--mod-stepper-border-color-focus-hover, var(--spectrum-stepper-border-color-focus-hover))); + .spectrum-NumberField-textfield { + padding-inline-end: var(--spectrum-numberfield-spacing-inline-edge-to-text); + + .spectrum-NumberField-input { + padding-inline-end: calc(var(--spectrum-numberfield-spacing-min-inline-end-value-to-icon) + var(--spectrum-numberfield-alert-icon-size)); } - } - &.is-keyboardFocused, - &:focus-visible { - --mod-infield-button-border-color: var(--highcontrast-stepper-border-color-keyboard-focus, var(--mod-stepper-buttons-border-color-keyboard-focus, var(--spectrum-stepper-buttons-border-color-keyboard-focus))); - --mod-textfield-focus-indicator-width: 0; - --mod-textfield-border-color: var(--highcontrast-stepper-border-color-keyboard-focus, var(--mod-stepper-border-color-keyboard-focus, var(--spectrum-stepper-border-color-keyboard-focus))); + &.spectrum-Textfield.is-invalid .spectrum-Textfield-validationIcon { + /* accommodate validation icons when stepper buttons are hidden */ + inset-inline-end: var(--spectrum-numberfield-spacing-inline-edge-to-text); + } + } - /* keyboard focus indicator is visible */ - outline: var(--spectrum-stepper-focus-indicator-width) solid; - outline-color: var(--spectrum-stepper-focus-indicator-color); - outline-offset: var(--spectrum-stepper-focus-indicator-gap); + .spectrum-NumberField-textfield:not(:has(.spectrum-Textfield-validationIcon)) { + .spectrum-NumberField-input { + padding-inline-end: 0; + } } } - &.is-invalid { - --mod-infield-button-border-color: var(--highcontrast-stepper-border-color, var(--mod-stepper-border-color-invalid, var(--spectrum-stepper-border-color-invalid))); - --mod-textfield-icon-spacing-inline-start-invalid: 0; + &.spectrum-NumberField--sideLabel { + grid-template-columns: auto auto auto; + grid-template-rows: auto auto; - &:hover { - --mod-infield-button-border-color: var(--highcontrast-stepper-border-color, var(--mod-stepper-border-color-hover-invalid, var(--spectrum-negative-border-color-hover))); + .spectrum-NumberField-fieldLabel { + grid-row: 1 / span 2; + grid-column: 1 / span 1; + margin-inline-end: var(--spectrum-numberfield-spacing-side-label-to-field, var(--spectrum-numberfield-spacing-side-label-to-field)); } - &.is-focused, - &:focus { - --mod-infield-button-border-color: var(--highcontrast-stepper-border-color, var(--mod-stepper-border-color-focus-invalid, var(--spectrum-stepper-border-color-focus-invalid))); - - &:hover { - --mod-infield-button-border-color: var(--highcontrast-stepper-border-color, var(--mod-stepper-border-color-focus-hover-invalid, var(--spectrum-stepper-border-color-focus-hover-invalid))); - } + .spectrum-NumberField-inputs { + grid-row: 1 / span 1; + grid-column: 2 / span 1; } - &.is-keyboardFocused, - &:focus-visible { - --mod-infield-button-border-color: var(--highcontrast-stepper-border-color, var(--mod-stepper-border-color-keyboard-focus-invalid, var(--spectrum-stepper-border-color-keyboard-focus-invalid))); + .spectrum-NumberField-helpText { + grid-row: 2; + grid-column: 2 / span 1; } } +} - &.spectrum-Stepper--quiet { - --mod-infield-button-width-stacked: var(--mod-stepper-button-width-quiet, var(--spectrum-stepper-button-width)); - --mod-infield-button-border-color: var(--spectrum-stepper-border-color); - --mod-infield-button-border-color-quiet: var(--spectrum-stepper-border-color); - --mod-infield-button-border-block-end-width: var(--mod-stepper-border-width, var(--spectrum-stepper-border-width)); - --mod-infield-button-stacked-bottom-border-block-end-width: var(--mod-stepper-border-width, var(--spectrum-stepper-border-width)); - --mod-infield-button-stacked-bottom-border-radius-end-end: 0; - --mod-infield-button-stacked-bottom-border-radius-end-start: 0; - --mod-infield-button-fill-justify-content: flex-end; - --mod-infield-button-inner-edge-to-fill: var(--spectrum-stepper-button-edge-to-fill); - --mod-infield-button-edge-to-fill: var(--spectrum-stepper-button-edge-to-fill); - - --mod-textfield-focus-indicator-color: transparent; - --mod-textfield-background-color: transparent; - --mod-textfield-border-color-hover: var(--highcontrast-stepper-border-color, var(--mod-stepper-border-color-hover, var(--spectrum-stepper-border-color-hover))); - - &:not(.is-disabled) { - &:hover { - --mod-textfield-border-color-hover: var(--highcontrast-stepper-border-color, var(--mod-stepper-border-color-hover, var(--spectrum-stepper-border-color-hover))); - --mod-infield-button-border-color: var(--highcontrast-stepper-border-color, var(--mod-stepper-border-color-hover, var(--spectrum-stepper-border-color-hover))); - } +/* Number field label */ +.spectrum-NumberField-fieldLabel { + margin-block-end: var(--mod-numberfield-label-to-field, var(--spectrum-numberfield-spacing-label-to-field)); +} - /* quiet focus */ - &.is-focused, - &:focus { - --mod-infield-button-border-color: var(--highcontrast-stepper-border-color, var(--mod-stepper-border-color-focus, var(--spectrum-stepper-border-color-focus))); +/* Number field help text */ +.spectrum-NumberField-helpText { + margin-block-start: var(--mod-numberfield-spacing-field-to-helptext, var(--spectrum-numberfield-spacing-field-to-helptext)); +} - /* stylelint-disable-next-line max-nesting-depth -- @todo reduce complexity of selectors */ - &:hover { - --mod-infield-button-border-color: var(--highcontrast-stepper-border-color, var(--mod-stepper-border-color-focus-hover, var(--spectrum-stepper-border-color-focus-hover))); - } - } +/* Number field container includes .spectrum-Textfield and .spectrum-InfieldButtons */ +.spectrum-NumberField-inputs { + /* gives the focus ring the proper border-radius */ + border-radius: var(--spectrum-numberfield-border-radius); + display: flex; + align-items: center; - &.is-keyboardFocused { - --mod-infield-button-border-color: var(--highcontrast-stepper-border-color, var(--mod-stepper-border-color-keyboard-focus, var(--spectrum-stepper-border-color-keyboard-focus))); + & .spectrum-Textfield .spectrum-Textfield-input { + /* removes the border-radius and outline from unstyled input to avoid double focus rings + (which was being inherited from .spectrum-Textfield) */ + outline: none; + border-radius: 0; + } - /* stylelint-disable-next-line max-nesting-depth -- @todo reduce complexity of selectors */ - &:hover { - --mod-infield-button-border-color: var(--highcontrast-stepper-border-color, var(--mod-stepper-border-color-hover, var(--spectrum-stepper-border-color-hover))); - } - } - } + & .spectrum-Textfield.is-invalid .spectrum-NumberField-input { + padding-inline-end: calc(var(--spectrum-numberfield-spacing-min-inline-end-value-to-icon) + var(--spectrum-numberfield-alert-icon-size) + var(--spectrum-numberfield-spacing-validation-icon-to-stepper)); } } -/* @passthrough end */ - -/* --- Component styles --- */ -.spectrum-Stepper { - --spectrum-stepper-width: var(--mod-stepper-width, calc(var(--spectrum-stepper-height) * var(--mod-stepper-min-width-multiplier, var(--spectrum-text-field-minimum-width-multiplier)) + var(--spectrum-stepper-button-width) + (var(--mod-stepper-border-width, var(--spectrum-stepper-border-width)) * 2))); - position: relative; +/* Nested textfield subcomponent */ +.spectrum-NumberField-textfield { display: inline-flex; - flex-flow: row nowrap; + flex-flow: column-reverse nowrap; - inline-size: var(--spectrum-stepper-width); - block-size: var(--spectrum-stepper-height); + /* gives the textfield container (instead of the input) the proper border styles */ + border: var(--spectrum-numberfield-border-width) solid var(--spectrum-numberfield-border-color-default); + padding-inline-start: var(--spectrum-numberfield-spacing-inline-edge-to-text); + padding-inline-end: calc(var(--spectrum-numberfield-button-container-size) + var(--spectrum-numberfield-button-inline-offset)); - border-radius: var(--spectrum-stepper-border-radius); + /* gives the textfield container (instead of the input) the proper border-radius */ + border-radius: var(--spectrum-numberfield-border-radius); - &::before { - content: ""; + /* gives the textfield container (instead of the input) the proper background color */ + background-color: var(--spectrum-numberfield-background-color, transparent); + + /* accommodate stepper buttons and validation icons */ + &.spectrum-Textfield.is-invalid .spectrum-Textfield-validationIcon { + inset-inline-end: calc(var(--spectrum-numberfield-button-container-size) + var(--spectrum-numberfield-spacing-validation-icon-to-stepper)); } } -/* Nested textfield subcomponent */ -.spectrum-Stepper-input { - border-start-end-radius: 0; - border-end-end-radius: 0; - border-inline-end-width: 0; +/* unstyled input element */ +.spectrum-NumberField-input { + line-height: var(--spectrum-numberfield-line-height); + padding-inline-start: 0; + padding-inline-end: var(--spectrum-numberfield-spacing-min-inline-end-text-to-stepper); + border: none; + + /* overrides the min-inline-size of the nested textfield input element */ + min-inline-size: 100%; } /* container for stepUp and stepDown buttons */ -.spectrum-Stepper-buttons { - display: flex; - flex-direction: column; - justify-content: center; - box-sizing: border-box; +.spectrum-NumberField-buttons { + position: absolute; + inset-inline-end: calc(var(--mod-numberfield-button-inline-offset, var(--spectrum-numberfield-button-inline-offset, 0px))); +} - block-size: var(--spectrum-stepper-height); - inline-size: var(--spectrum-stepper-button-width); +/* --- High contrast settings --- */ +@media (forced-colors: active) { + .spectrum-NumberField { + --highcontrast-numberfield-border-color: CanvasText; + --highcontrast-numberfield-background-color: Canvas; + --highcontrast-numberfield-border-color-hover: Highlight; + --highcontrast-numberfield-border-color-focus: Highlight; + --highcontrast-numberfield-border-color-focus-hover: Highlight; + --highcontrast-numberfield-border-color-keyboard-focus: CanvasText; + --highcontrast-numberfield-focus-indicator-color: Highlight; - border-color: var(--spectrum-stepper-border-color); - border-style: var(--mod-stepper-buttons-border-style, var(--spectrum-stepper-buttons-border-style)); - border-width: var(--highcontrast-stepper-buttons-border-width, var(--mod-stepper-buttons-border-width, var(--spectrum-stepper-buttons-border-width))); - border-inline-start-width: 0; + &.is-invalid { + --highcontrast-numberfield-border-color: Highlight; + --highcontrast-numberfield-border-color-hover: Highlight; + --highcontrast-numberfield-border-color-focus: Highlight; + --highcontrast-numberfield-border-color-focus-hover: Highlight; + --highcontrast-numberfield-border-color-keyboard-focus: Highlight; + } - /* Have to add border radius here to avoid overlapping textfield border */ - border-start-end-radius: var(--spectrum-stepper-border-radius); - border-end-end-radius: var(--spectrum-stepper-border-radius); + &.is-disabled { + --highcontrast-numberfield-border-color: GrayText; + } - background-color: var(--mod-stepper-buttons-background-color, var(--spectrum-stepper-buttons-background-color)); - transition: border-color var(--spectrum-stepper-animation-duration) ease-in-out; -} + &:not(.is-disabled) { + &.is-hover, + &:hover { + --highcontrast-numberfield-border-color: var(--highcontrast-numberfield-border-color-hover); + } -/* stylelint-disable-next-line selector-class-pattern -- @todo update hide-stepper class to standard variant syntax */ -.spectrum-Stepper.hide-stepper .spectrum-Stepper-input { - border-start-end-radius: var(--spectrum-stepper-border-radius); - border-end-end-radius: var(--spectrum-stepper-border-radius); - border-inline-end-width: var(--mod-stepper-border-width, var(--spectrum-stepper-border-width)); -} + &.is-focused, + &:focus, + &:focus-within { + --highcontrast-numberfield-border-color: var(--highcontrast-numberfield-border-color-focus); -/* --- Quiet variant styles --- */ -.spectrum-Stepper--quiet { - /* quiet corners are not rounded */ - border-start-start-radius: 0; - border-start-end-radius: 0; - border-end-start-radius: 0; - border-end-end-radius: 0; - - /* stylelint-disable selector-class-pattern -- @todo update hide-stepper class to standard variant syntax */ - &.hide-stepper .spectrum-Stepper-input { - border-inline-end-width: 0; - border-end-end-radius: 0; - } - /* stylelint-enable selector-class-pattern */ + &.is-hover, + &:hover { + --highcontrast-numberfield-border-color: var(--highcontrast-numberfield-border-color-focus-hover); + } + } - &::after { - visibility: var(--mod-stepper-focus-indicator-visibility, hidden); - content: ""; - position: absolute; - inset-block-end: calc(-1 * (var(--spectrum-stepper-focus-indicator-gap) + var(--spectrum-stepper-focus-indicator-width))); - inset-inline-start: 0; - inline-size: 100%; - block-size: var(--spectrum-stepper-focus-indicator-width); - background-color: var(--spectrum-stepper-focus-indicator-color); + &.is-keyboardFocused, + &:focus-visible, + &:focus-within { + --highcontrast-numberfield-border-color: var(--highcontrast-numberfield-border-color-keyboard-focus); + + &.is-hover, + &:hover { + --highcontrast-numberfield-border-color: var(--highcontrast-numberfield-border-color-focus-hover); + } + } + } } - /* quiet hover */ - &.is-keyboardFocused:not(.is-disabled) { - outline: none; + /* @passthrough start */ + .spectrum-NumberField-textfield { + --highcontrast-textfield-border-color: var(--highcontrast-numberfield-border-color); } + /* @passthrough end */ } diff --git a/components/stepper/package.json b/components/stepper/package.json index d0959f2a6a1..34a3e52b827 100644 --- a/components/stepper/package.json +++ b/components/stepper/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/stepper", - "version": "7.2.0", + "version": "8.0.0-next.3", "description": "The Spectrum CSS stepper component", "license": "Apache-2.0", "author": "Adobe", @@ -19,18 +19,16 @@ "./package.json": "./package.json", "./dist/*": "./dist/*", "./index.css": "./dist/index.css", - "./index-*.css": "./dist/index-*.css", "./metadata.json": "./dist/metadata.json", - "./themes/*": "./dist/themes/*", "./stories/*": "./stories/*" }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/actionbutton": ">=7.0.0 <8.0.0", - "@spectrum-css/icon": ">=9.0.0 <10.0.0", - "@spectrum-css/infieldbutton": ">=6.0.0 <7.0.0", - "@spectrum-css/textfield": ">=8.0.0 <9.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/actionbutton": ">=8.0.0-next.0", + "@spectrum-css/icon": ">=10.0.0-next.0", + "@spectrum-css/infieldbutton": ">=7.0.0-next.0", + "@spectrum-css/textfield": ">=9.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/actionbutton": { @@ -50,11 +48,11 @@ } }, "devDependencies": { - "@spectrum-css/actionbutton": "7.2.0", - "@spectrum-css/icon": "9.2.0", - "@spectrum-css/infieldbutton": "6.2.0", - "@spectrum-css/textfield": "8.2.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/actionbutton": "8.0.0-next.4", + "@spectrum-css/icon": "10.0.0-next.3", + "@spectrum-css/infieldbutton": "7.0.0-next.3", + "@spectrum-css/textfield": "9.0.0-next.1", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", @@ -71,7 +69,7 @@ "spectrum": [ { "guidelines": "https://spectrum-contributions.corp.adobe.com/page/number-field-beta", - "rootClass": "spectrum-Stepper" + "rootClass": "spectrum-NumberField" } ] } diff --git a/components/stepper/stories/stepper.stories.js b/components/stepper/stories/stepper.stories.js index 8775574a342..bd51dd147ca 100644 --- a/components/stepper/stories/stepper.stories.js +++ b/components/stepper/stories/stepper.stories.js @@ -1,22 +1,24 @@ -import { Sizes } from "@spectrum-css/preview/decorators"; +import { Sizes, withDownStateDimensionCapture } from "@spectrum-css/preview/decorators"; import { disableDefaultModes } from "@spectrum-css/preview/modes"; -import { isDisabled, isFocused, isHovered, isInvalid, isKeyboardFocused, isQuiet, size } from "@spectrum-css/preview/types"; +import { isDisabled, isFocused, isHovered, isKeyboardFocused, isReadOnly, size } from "@spectrum-css/preview/types"; +import { default as TextfieldStories } from "@spectrum-css/textfield/stories/textfield.stories.js"; import metadata from "../dist/metadata.json"; import packageJson from "../package.json"; -import { StepperGroup } from "./stepper.test.js"; +import { NumberFieldGroup } from "./stepper.test.js"; import { AllDefaultVariantsGroup, DisabledVariantsGroup, Template } from "./template.js"; /** - * A stepper can be used to increment or decrement a value by a specified amount via an up/down button. An input field displays the current value. + * A number field can be used to increment or decrement a value by a specified amount via add and subtract buttons. The input field displays the current value. + * + * Note that the number fields are non-functional on this page, but functionality is demonstrated on [the story page](/story/components-number-field--default). */ export default { - title: "Stepper", + title: "Number field", component: "Stepper", argTypes: { size: size(["s", "m", "l", "xl"]), - isQuiet, hideStepper: { - name: "Hide stepper", + name: "Hide stepper buttons", type: { name: "boolean" }, table: { type: { summary: "boolean" }, @@ -25,21 +27,51 @@ export default { control: "boolean", }, isDisabled, - isInvalid, + isInvalid: { + ...TextfieldStories?.argTypes?.isInvalid ?? {}, + }, isFocused, isHovered, isKeyboardFocused, + isReadOnly, + displayLabel: { + ...TextfieldStories?.argTypes?.displayLabel ?? {}, + }, + label: { + ...TextfieldStories?.argTypes?.labelText ?? {}, + }, + labelPosition: { + ...TextfieldStories?.argTypes?.labelPosition ?? {}, + }, + helpText: { + ...TextfieldStories?.argTypes?.helpText, + }, + value: { table: { disable: true, } }, + step: { + name: "Step value", + description: "The amount to increment or decrement the input value.", + table: { + type: { summary: "number" }, + category: "Content", + }, + control: "number", + }, }, args: { - rootClass: "spectrum-Stepper", + rootClass: "spectrum-NumberField", size: "m", - isQuiet: false, isFocused: false, isHovered: false, isKeyboardFocused: false, + isReadOnly: false, isInvalid: false, isDisabled: false, - hideStepper: false + hideStepper: false, + displayLabel: true, + label: "Field label", + labelPosition: "top", + helpText: "", + step: "1", }, parameters: { design: { @@ -48,10 +80,23 @@ export default { }, packageJson, metadata, + actions: { + handles: ["click .spectrum-InfieldButton:not([disabled])"], + }, + downState: { + selectors: [".spectrum-InfieldButton:not(:disabled)"], + }, + status: { + type: "migrated", + }, }, + tags: ["migrated"], + decorators: [ + withDownStateDimensionCapture, + ], }; -export const Default = StepperGroup.bind({}); +export const Default = NumberFieldGroup.bind({}); Default.args = {}; Default.tags = ["!autodocs"]; @@ -68,7 +113,18 @@ Sizing.parameters = { }; /** - * Steppers come in four different sizes: small, medium, large, and extra-large. The medium size is the default and most frequently used option. Use the other sizes sparingly; they should be used to create a hierarchy of importance within the page. + * Number fields come in four different sizes: small, medium, large, and extra-large. The medium size is the default and most + * frequently used option. Use the other sizes sparingly; they should be used to create a hierarchy of importance within the page. + * + * Number fields have a [field label](/docs/components-field-label--docs) that is positioned above the field by default. Having + * the label on the top is the default and is recommended because this works better with long copy, localization, and responsive + * layouts. + * + * The [inline infield buttons](/docs/components-in-field-button--docs#inline) are usually visible, but can be hidden. + * The amount of the increment/decrement step is 1 by default. + * + * When the label is too long for the available space, it will wrap to the next line. If the value within the number field input + * overflows, it will truncate with an ellipsis. To view truncated text, implementations can use a tooltip available on hover (desktop) or long press (mobile). If an error state is needed for smaller inputs, implementations should consider hiding the error icon so that more of the input value is visible. */ export const DefaultStates = AllDefaultVariantsGroup.bind({}); DefaultStates.args = {}; @@ -78,29 +134,55 @@ DefaultStates.parameters = { }; DefaultStates.storyName = "Default"; -export const Disabled = DisabledVariantsGroup.bind({}); -Disabled.args = { - isDisabled: true, +/** + * Number fields have a [field label](/docs/components-field-label--docs) that is positioned above the field by default, with a + * secondary option to be positioned on the side of the field. Having the label on the side is most useful for when vertical space is limited. + */ +export const SideLabel = AllDefaultVariantsGroup.bind({}); +SideLabel.args = { + labelPosition: "side", }; -Disabled.tags = ["!dev"]; -Disabled.parameters = { +SideLabel.tags = ["!dev"]; +SideLabel.parameters = { + chromatic: { disableSnapshot: true }, +}; +SideLabel.storyName = "Side label"; + +/** + * Number fields have a read-only option for when disabled content still needs to be shown. This allows for content to be copied, but not interacted with or changed. + */ +export const ReadOnly = DisabledVariantsGroup.bind({}); +ReadOnly.args = { + isReadOnly: true, +}; +ReadOnly.tags = ["!dev"]; +ReadOnly.parameters = { chromatic: { disableSnapshot: true }, }; -Disabled.storyName = "Disabled"; +ReadOnly.storyName = "Read-only"; -export const QuietStates = AllDefaultVariantsGroup.bind({}); -QuietStates.args = { - isQuiet: true, +export const InvalidStates = AllDefaultVariantsGroup.bind({}); +InvalidStates.args = { + isInvalid: true, + helpText: "Help text is here to assist", }; -QuietStates.tags = ["!dev"]; -QuietStates.parameters = { +InvalidStates.tags = ["!dev"]; +InvalidStates.parameters = { chromatic: { disableSnapshot: true }, }; -QuietStates.storyName = "Quiet"; +InvalidStates.storyName = "Invalid"; +export const Disabled = DisabledVariantsGroup.bind({}); +Disabled.args = { + isDisabled: true, +}; +Disabled.tags = ["!dev"]; +Disabled.parameters = { + chromatic: { disableSnapshot: true }, +}; // ********* VRT ONLY ********* // -export const WithForcedColors = StepperGroup.bind({}); +export const WithForcedColors = NumberFieldGroup.bind({}); WithForcedColors.tags = ["!autodocs", "!dev"]; WithForcedColors.parameters = { chromatic: { @@ -111,7 +193,7 @@ WithForcedColors.parameters = { // ********* DOCS ONLY ********* // /** - * Optional stepper buttons would appear to the side of the field. Regardless of if a stepper has these buttons or not, is should always accommodate arrow key shortcuts to increase or decrease the number. + * Number fields typically have stepper buttons visible by default, but implementations have the option to hide them. The component should always accommodate arrow key shortcuts to increase or decrease the value, regardless of whether its stepper buttons are visible. */ export const HideStepper = Template.bind({}); HideStepper.tags = ["!dev"]; @@ -123,4 +205,4 @@ HideStepper.parameters = { disableSnapshot: true, }, }; -HideStepper.storyName = "Hide stepper"; +HideStepper.storyName = "Hide stepper buttons"; diff --git a/components/stepper/stories/stepper.test.js b/components/stepper/stories/stepper.test.js index 60246d2133f..5b6f43e5b4c 100644 --- a/components/stepper/stories/stepper.test.js +++ b/components/stepper/stories/stepper.test.js @@ -1,31 +1,77 @@ import { Variants } from "@spectrum-css/preview/decorators"; import { Template } from "./template.js"; +import { capitalize } from "lodash-es"; -export const StepperGroup = Variants({ +export const NumberFieldGroup = Variants({ Template, testData: [ { testHeading: "Default", }, { - testHeading: "Quiet", - isQuiet: true, + testHeading: "Hidden stepper", + hideStepper: true, + }, + { + testHeading: "With help text", + helpText: "Help text is here to assist", + }, + { + testHeading: "Side label", + labelPosition: "side", + }, + { + testHeading: "Side label with help text", + labelPosition: "side", + helpText: "Help text is here to assist", }, { testHeading: "Invalid", isInvalid: true, + helpText: "Help text is here to assist", }, { - testHeading: "Quiet + invalid", - isQuiet: true, + testHeading: "Invalid hidden stepper", isInvalid: true, + hideStepper: true, + helpText: "Help text is here to assist", + }, + ...["s", "m", "l", "xl"].map((size) => ({ + testHeading: `Min width: ${capitalize(size)} number field, 100px width container`, + wrapperStyles: { + "inline-size": "100px", + }, + size, + withStates: false, + })), + ...["s", "m", "l", "xl"].map((size) => ({ + testHeading: `Min width: ${capitalize(size)} number field (hidden stepper buttons), 25px width container`, + wrapperStyles: { + "inline-size": "25px", + }, + size, + withStates: false, + hideStepper: true, + })), + { + testHeading: "Default + truncation", + withStates: false, + value: "1234567890123456789012345678901", }, - ], - stateData: [ { - testHeading: "Hide stepper", + testHeading: "Hidden Stepper + truncation", + withStates: false, hideStepper: true, + value: "1234567890123456789012345678901", + }, + { + testHeading: "Side label + truncation", + withStates: false, + labelPosition: "side", + value: "1234567890123456789012345678901", }, + ], + stateData: [ { testHeading: "Disabled", isDisabled: true, @@ -38,10 +84,20 @@ export const StepperGroup = Variants({ testHeading: "Focused", isFocused: true, }, + { + testHeading: "Focused + hovered", + isFocused: true, + isHovered: true, + }, { testHeading: "Keyboard-focused", isKeyboardFocused: true, }, + { + testHeading: "Keyboard-focused + hovered", + isKeyboardFocused: true, + isHovered: true, + }, { testHeading: "Disabled + hovered", isDisabled: true, @@ -57,5 +113,29 @@ export const StepperGroup = Variants({ isDisabled: true, isKeyboardFocused: true, }, + { + testHeading: "Read-only", + isReadOnly: true, + }, + { + testHeading: "Read-only + disabled", + isReadOnly: true, + isDisabled: true, + }, + { + testHeading: "Read-only + hovered", + isReadOnly: true, + isHovered: true, + }, + { + testHeading: "Read-only + focused", + isReadOnly: true, + isFocused: true, + }, + { + testHeading: "Read-only + keyboard-focused", + isReadOnly: true, + isKeyboardFocused: true, + }, ] }); diff --git a/components/stepper/stories/template.js b/components/stepper/stories/template.js index fbb818b72f3..1f780cb59ba 100644 --- a/components/stepper/stories/template.js +++ b/components/stepper/stories/template.js @@ -1,3 +1,5 @@ +import { Template as FieldLabel } from "@spectrum-css/fieldlabel/stories/template.js"; +import { Template as HelpText } from "@spectrum-css/helptext/stories/template.js"; import { Template as InfieldButton } from "@spectrum-css/infieldbutton/stories/template.js"; import { Container, getRandomId } from "@spectrum-css/preview/decorators"; import { Template as Textfield } from "@spectrum-css/textfield/stories/template.js"; @@ -8,101 +10,135 @@ import { styleMap } from "lit/directives/style-map.js"; import { when } from "lit/directives/when.js"; import "../index.css"; -import "../themes/spectrum.css"; -/* Must be imported last */ -import "../themes/express.css"; export const Template = ({ - rootClass = "spectrum-Stepper", + rootClass = "spectrum-NumberField", size = "m", - isQuiet = false, + displayLabel = true, + label, + labelPosition = "top", isFocused = false, isHovered = false, isKeyboardFocused = false, + isReadOnly = false, isInvalid = false, isDisabled = false, hideStepper = false, - id = getRandomId("stepper"), + helpText, + value = "0", + step = "1", + id = getRandomId("numberfield"), customClasses = [], customStyles = {}, } = {}, context = {}) => { - let iconSize = "75"; - switch (size) { - case "s": - iconSize = "50"; - break; - case "l": - iconSize = "100"; - break; - case "xl": - iconSize = "200"; - break; - default: - iconSize = "75"; - } + const { updateArgs } = context; + + /* these functions work on the story page, not the docs page. */ + const incrementValue = () => { + const newValue = String(parseFloat(value) + parseFloat(step)); + updateArgs?.({ value: newValue }); + return newValue; + }; + + const decrementValue = () => { + const newValue = String(parseFloat(value) - parseFloat(step)); + updateArgs?.({ value: newValue }); + return newValue; + }; return html`
({ ...a, [c]: true }), {}), })} + @keyup=${function(e) { + // Tab key was used. + if (e.keyCode === 9) { + // The element that was focused when the key was released is this textfield / input. + if (e.target == this || e.target?.parentNode == this) { + updateArgs?.({ isKeyboardFocused: true }); + // Manually add class since updateArgs doesn't always work on the Docs page. + this.classList.add("is-keyboardFocused"); + } + } + }} + @focusout=${function() { + updateArgs?.({ + isFocused: false, + isKeyboardFocused: false, + }); + // Manually remove class since updateArgs doesn't always work on the Docs page. + this.classList.remove("is-keyboardFocused"); + }} id=${ifDefined(id)} style=${styleMap({ - "--mod-actionbutton-icon-size": "10px", ...customStyles })} > - ${Textfield({ - size, - type: "number", - min: "-2", - max: "2", - step: "0.5", - value: "0", - isDisabled, - isQuiet, - id: id ? `${id}-input` : undefined, - customClasses: [`${rootClass}-textfield`], - customInputClasses: [`${rootClass}-input`], - }, context)} - ${when(!hideStepper, () => html` - - ${InfieldButton({ - size, - customClasses: [`${rootClass}-button`], - iconName: `ChevronUp${iconSize}`, - iconSet: "ui", - isDisabled, - isQuiet, - position: "top", - tabIndex: "-1" - }, context)} - ${InfieldButton({ + ${when(displayLabel && label, () => html` + ${FieldLabel({ + size, + label: label, + labelPosition: labelPosition, + isDisabled, + customClasses: [`${rootClass}-fieldLabel`], + }, context)} + `)} +
+ ${Textfield({ + size, + type: "number", + min: "-10", + max: "10", + step, + value, + isInvalid, + isFocused, + isDisabled, + isReadOnly, + id: id ? `${id}-input` : undefined, + customClasses: [`${rootClass}-textfield`], + customInputClasses: [`${rootClass}-input`], + }, context)} + ${when(!hideStepper, () => html` + + ${InfieldButton({ + isInline: true, + size, + onAdd: incrementValue, + onSubtract: decrementValue, + customClasses: [`${rootClass}-button`], + isDisabled: isDisabled || isReadOnly, + }, context)} + + `)} +
+ ${when(helpText, () => html` +
+ ${HelpText({ size, - customClasses: [`${rootClass}-button`], - iconName: `ChevronDown${iconSize}`, - iconSet: "ui", - isDisabled, - isQuiet, - position: "bottom", - tabIndex: "-1" + text: helpText, + variant: isInvalid ? "negative" : undefined, + hideIcon: true, + isDisabled: isDisabled || isReadOnly, }, context)} - +
`)}
`; }; -/* Shows all of the stepper states in one grouping. */ +/* Shows all of the number field states in one grouping. */ export const AllDefaultVariantsGroup = (args, context) => Container({ withBorder: false, content: html` @@ -114,14 +150,6 @@ export const AllDefaultVariantsGroup = (args, context) => Container({ heading: "Default", content: Template(args, context) }, context)} - ${Container({ - withBorder: false, - containerStyles: { - "gap": "8px", - }, - heading: "Invalid", - content: Template({...args, isInvalid: true}, context) - }, context)} ${Container({ withBorder: false, containerStyles: { @@ -143,8 +171,8 @@ export const AllDefaultVariantsGroup = (args, context) => Container({ containerStyles: { "gap": "8px", }, - heading: "Invalid, focused", - content: Template({...args, isInvalid: true, isFocused: true}, context) + heading: "Focused, hovered", + content: Template({...args, isHovered: true, isFocused: true}, context) }, context)} ${Container({ withBorder: false, @@ -154,18 +182,10 @@ export const AllDefaultVariantsGroup = (args, context) => Container({ heading: "Keyboard-focused", content: Template({...args, isKeyboardFocused: true}, context) }, context)} - ${Container({ - withBorder: false, - containerStyles: { - "gap": "8px", - }, - heading: "Invalid, keyboard-focused", - content: Template({...args, isInvalid: true, isKeyboardFocused: true}, context) - }, context)} ` }, context); -/* Shows the disabled variants of the default and quiet stories one grouping. */ +/* Shows the disabled states of the default and hidden stepper stories one grouping. */ export const DisabledVariantsGroup = (args, context) => Container({ withBorder: false, content: html` @@ -182,8 +202,8 @@ export const DisabledVariantsGroup = (args, context) => Container({ containerStyles: { "gap": "8px", }, - heading: "Quiet", - content: Template({...args, isQuiet: true}, context) + heading: "Hidden stepper buttons", + content: Template({...args, hideStepper: true}, context) }, context)} ` }, context); diff --git a/components/stepper/themes/express.css b/components/stepper/themes/express.css deleted file mode 100644 index 724f4e973ff..00000000000 --- a/components/stepper/themes/express.css +++ /dev/null @@ -1,53 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--express */ - -@import "./spectrum.css"; - -@container style(--system: express) { - .spectrum-Stepper { - --spectrum-stepper-border-width: var(--spectrum-border-width-200); - --spectrum-stepper-border-color-default: var(--spectrum-gray-400); - --spectrum-stepper-border-color-hover: var(--spectrum-gray-500); - --spectrum-stepper-border-color-focus: var(--spectrum-gray-800); - --spectrum-stepper-border-color-focus-hover: var(--spectrum-gray-900); - --spectrum-stepper-border-color-keyboard-focus: var(--spectrum-gray-900); - --spectrum-stepper-border-color-disabled: var(--spectrum-disabled-background-color); - - --spectrum-stepper-buttons-border-style: solid; - --spectrum-stepper-buttons-border-width: var(--spectrum-border-width-200); - --spectrum-stepper-buttons-border-color: transparent; - --spectrum-stepper-buttons-background-color: var(--spectrum-gray-50); - --spectrum-stepper-buttons-border-color-hover: transparent; - --spectrum-stepper-buttons-border-color-focus: transparent; - --spectrum-stepper-buttons-border-color-keyboard-focus: transparent; - - --spectrum-stepper-button-border-width: 0; - - /** Invalid **/ - --spectrum-stepper-border-color-invalid: transparent; - --spectrum-stepper-border-color-focus-invalid: transparent; - --spectrum-stepper-border-color-focus-hover-invalid: transparent; - --spectrum-stepper-border-color-keyboard-focus-invalid: transparent; - - /** Disabled **/ - --spectrum-stepper-button-border-width-disabled: 0; - --spectrum-stepper-buttons-background-color-disabled: var(--spectrum-disabled-background-color); - } - - .spectrum-Stepper--quiet { - --spectrum-stepper-buttons-border-style: none; - --spectrum-stepper-button-edge-to-fill: 0; - } -} diff --git a/components/stepper/themes/spectrum-two.css b/components/stepper/themes/spectrum-two.css deleted file mode 100644 index 18c580ff127..00000000000 --- a/components/stepper/themes/spectrum-two.css +++ /dev/null @@ -1,49 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -@container style(--system: spectrum) { - .spectrum-Stepper { - --spectrum-stepper-border-width: var(--spectrum-border-width-100); - --spectrum-stepper-border-color-default: var(--spectrum-gray-500); - --spectrum-stepper-border-color-hover: var(--spectrum-gray-600); - --spectrum-stepper-border-color-focus: var(--spectrum-gray-800); - --spectrum-stepper-border-color-focus-hover: var(--spectrum-gray-900); - --spectrum-stepper-border-color-keyboard-focus: var(--spectrum-gray-800); - - --spectrum-stepper-buttons-border-style: none; - --spectrum-stepper-buttons-border-width: 0; - --spectrum-stepper-buttons-border-color: var(--spectrum-gray-500); - --spectrum-stepper-buttons-background-color: var(--spectrum-gray-100); - --spectrum-stepper-buttons-border-color-hover: var(--spectrum-gray-600); - --spectrum-stepper-buttons-border-color-focus: var(--spectrum-gray-800); - --spectrum-stepper-buttons-border-color-keyboard-focus: var(--spectrum-gray-800); - - --spectrum-stepper-button-border-width: var(--spectrum-border-width-100); - - /** Invalid **/ - --spectrum-stepper-border-color-invalid: var(--spectrum-negative-border-color-default); - --spectrum-stepper-border-color-focus-invalid: var(--spectrum-negative-border-color-focus); - --spectrum-stepper-border-color-focus-hover-invalid: var(--spectrum-negative-border-color-focus-hover); - --spectrum-stepper-border-color-keyboard-focus-invalid: var(--spectrum-negative-border-color-key-focus); - - /** Disabled **/ - --spectrum-stepper-border-color-disabled: var(--spectrum-gray-300); - --spectrum-stepper-button-border-width-disabled: var(--spectrum-border-width-200); - --spectrum-stepper-buttons-background-color-disabled: var(--spectrum-gray-50); - } - - .spectrum-Stepper--quiet { - --spectrum-stepper-buttons-border-style: none; - --spectrum-stepper-button-edge-to-fill: 0; - } -} diff --git a/components/stepper/themes/spectrum.css b/components/stepper/themes/spectrum.css deleted file mode 100644 index 1b904f9f952..00000000000 --- a/components/stepper/themes/spectrum.css +++ /dev/null @@ -1,25 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--legacy */ - -@import "./spectrum-two.css"; - -@container style(--system: legacy) { - .spectrum-Stepper { - --spectrum-stepper-border-color-disabled: transparent; - --spectrum-stepper-button-border-width-disabled: var(--spectrum-border-width-100); - --spectrum-stepper-buttons-background-color: var(--spectrum-gray-50); - --spectrum-stepper-buttons-background-color-disabled: var(--spectrum-gray-100); - } -} diff --git a/components/swatch/CHANGELOG.md b/components/swatch/CHANGELOG.md index 0a5cfbf3548..3a7e691000b 100644 --- a/components/swatch/CHANGELOG.md +++ b/components/swatch/CHANGELOG.md @@ -1,5 +1,62 @@ # Change log +## 9.0.0-next.1 + +### Major Changes + +- [#3677](https://github.com/adobe/spectrum-css/pull/3677) [`d47295a`](https://github.com/adobe/spectrum-css/commit/d47295a06cf974c347d794ae4f71bc4c8c498025) Thanks [@cdransf](https://github.com/cdransf)! + +#### S2 migration for Swatch group + +This migrates the `swatch` and `swatchgroup` components to the latest Spectrum 2 designs. Custom properties have been remapped and added per the design specification. + +An `Add Swatch` variant has been added with the required color tokens and the specified add UI icon. + +The `Add Swatch` and `Mixed Value` variants may not be combined with background colors or images. To implement the `Add Swatch` you need to apply the `is-addSwatch` class to the `spectrum-Swatch` element. `Add swatch` keyboard focus may be applied by adding the `is-keyboardFocused` class to this combination of classes. + +The `spectrum-Swatch-icon` is used to set the expected color to icons contained within the swatch. + +The light and no border variants have been removed. Individual swatches have a border set to `--spectrum-gray-1000` at `42%` opacity, while the border opacity is set to `20%` in swatch groups. + +##### Removed custom properties + +`--spectrum-swatch-border-color` +`--spectrum-swatch-dash-icon-color` (replaced by `--spectrum-swatch-icon-color`) + +##### New custom properties + +`--spectrum-swatch-border-color-rgb` +`--spectrum-swatch-border-opacity` +`--spectrum-corner-radius-full` +`--spectrum-corner-radius-none` +`--spectrum-swatch-disabled-icon-border-opacity` +`--spectrum-swatch-icon-color` +`--spectrum-swatch-rectangle-width-multiplier` + +##### New mods + +`--mod-add-button-background` +`--mod-add-button-background-down` +`--mod-add-button-background-hover` +`--mod-add-button-background-keyboard-focus` +`--mod-corner-radius-full` +`--mod-mixed-button-background` +`--mod-swatchgroup-border-color` +`--mod-swatch-border-color-rgb` +`--mod-swatch-border-opacity` + +### Patch Changes + +- [#3871](https://github.com/adobe/spectrum-css/pull/3871) [`7578ad2`](https://github.com/adobe/spectrum-css/commit/7578ad20dc42b533f4cb04b37f02ad13eb85a576) Thanks [@cdransf](https://github.com/cdransf)! - Updates the add swatch icon to use the ui rather than workflow icon + +## 9.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + - @spectrum-css/opacitycheckerboard@5.0.0-next.0 + ## 8.2.0 ### Minor Changes diff --git a/components/swatch/dist/metadata.json b/components/swatch/dist/metadata.json index 896cc7acc7c..5b40e74c96e 100644 --- a/components/swatch/dist/metadata.json +++ b/components/swatch/dist/metadata.json @@ -4,8 +4,6 @@ ".spectrum-Swatch", ".spectrum-Swatch .spectrum-Swatch-disabledIcon", ".spectrum-Swatch .spectrum-Swatch-fill", - ".spectrum-Swatch--lightBorder .spectrum-Swatch-fill:before", - ".spectrum-Swatch--noBorder .spectrum-Swatch-fill:before", ".spectrum-Swatch--rectangle", ".spectrum-Swatch--roundingFull.is-selected:not(.spectrum-Swatch--rectangle) .spectrum-Swatch-fill", ".spectrum-Swatch--roundingFull.is-selected:not(.spectrum-Swatch--rectangle) .spectrum-Swatch-fill:before", @@ -22,7 +20,6 @@ ".spectrum-Swatch--roundingNone:after", ".spectrum-Swatch--roundingNone:before", ".spectrum-Swatch--sizeL", - ".spectrum-Swatch--sizeM", ".spectrum-Swatch--sizeS", ".spectrum-Swatch--sizeXS", ".spectrum-Swatch-disabledIcon", @@ -30,64 +27,79 @@ ".spectrum-Swatch-disabledIcon path:last-child", ".spectrum-Swatch-fill", ".spectrum-Swatch-fill:before", + ".spectrum-Swatch-icon", ".spectrum-Swatch-image", - ".spectrum-Swatch-mixedValueIcon", + ".spectrum-Swatch.is-addSwatch", + ".spectrum-Swatch.is-addSwatch .spectrum-Swatch-fill", + ".spectrum-Swatch.is-addSwatch .spectrum-Swatch-icon", + ".spectrum-Swatch.is-addSwatch.is-keyboardFocused", + ".spectrum-Swatch.is-addSwatch:active", + ".spectrum-Swatch.is-addSwatch:focus-visible", + ".spectrum-Swatch.is-addSwatch:hover", ".spectrum-Swatch.is-disabled", ".spectrum-Swatch.is-disabled .spectrum-Swatch-disabledIcon", ".spectrum-Swatch.is-image .spectrum-Swatch-fill:before", + ".spectrum-Swatch.is-keyboardFocused", + ".spectrum-Swatch.is-mixedValue", ".spectrum-Swatch.is-mixedValue .spectrum-Swatch-fill", - ".spectrum-Swatch.is-mixedValue .spectrum-Swatch-mixedValueIcon", - ".spectrum-Swatch.is-nothing .spectrum-Swatch-fill", - ".spectrum-Swatch.is-nothing .spectrum-Swatch-fill:after", - ".spectrum-Swatch.is-nothing.spectrum-Swatch--rectangle .spectrum-Swatch-fill:after", + ".spectrum-Swatch.is-mixedValue .spectrum-Swatch-icon", + ".spectrum-Swatch.is-nothing.spectrum-Swatch--rectangle:not(.spectrum-Swatch.is-mixedValue, .spectrum-Swatch.is-addSwatch) .spectrum-Swatch-fill:after", + ".spectrum-Swatch.is-nothing:not(.spectrum-Swatch.is-mixedValue, .spectrum-Swatch.is-addSwatch) .spectrum-Swatch-fill", + ".spectrum-Swatch.is-nothing:not(.spectrum-Swatch.is-mixedValue, .spectrum-Swatch.is-addSwatch) .spectrum-Swatch-fill:after", ".spectrum-Swatch.is-selected", ".spectrum-Swatch.is-selected .spectrum-Swatch-fill", ".spectrum-Swatch.is-selected .spectrum-Swatch-fill:before", ".spectrum-Swatch.is-selected:before", - ".spectrum-Swatch:after", ".spectrum-Swatch:before", - ".spectrum-Swatch:focus-visible:after", + ".spectrum-Swatch:focus-visible", ".spectrum-Swatch[disabled]", ".spectrum-Swatch[disabled] .spectrum-Swatch-disabledIcon" ], "modifiers": [ + "--mod-add-button-background", + "--mod-add-button-background-down", + "--mod-add-button-background-hover", + "--mod-add-button-background-keyboard-focus", "--mod-animation-duration-100", + "--mod-corner-radius-full", + "--mod-mixed-button-background", + "--mod-swatch-border", "--mod-swatch-border-color", - "--mod-swatch-border-color-light", "--mod-swatch-border-color-selected", + "--mod-swatch-border-opacity", "--mod-swatch-border-radius", "--mod-swatch-border-thickness", "--mod-swatch-border-thickness-selected", "--mod-swatch-disabled-icon-color", "--mod-swatch-disabled-icon-size", - "--mod-swatch-focus-indicator-border-radius", "--mod-swatch-focus-indicator-color", "--mod-swatch-focus-indicator-gap", "--mod-swatch-focus-indicator-thickness", "--mod-swatch-icon-border-color", + "--mod-swatch-icon-color", "--mod-swatch-inner-border-color-selected", "--mod-swatch-size", "--mod-swatch-slash-icon-color", "--mod-swatch-slash-thickness" ], "component": [ + "--spectrum-swatch-border", "--spectrum-swatch-border-color", - "--spectrum-swatch-border-color-light", - "--spectrum-swatch-border-color-opacity", "--spectrum-swatch-border-color-selected", + "--spectrum-swatch-border-opacity", "--spectrum-swatch-border-radius", "--spectrum-swatch-border-thickness", "--spectrum-swatch-border-thickness-selected", - "--spectrum-swatch-dash-icon-color", "--spectrum-swatch-disabled-icon-border-opacity", "--spectrum-swatch-disabled-icon-color", "--spectrum-swatch-disabled-icon-size", - "--spectrum-swatch-focus-indicator-border-radius", "--spectrum-swatch-focus-indicator-color", "--spectrum-swatch-focus-indicator-gap", "--spectrum-swatch-focus-indicator-thickness", "--spectrum-swatch-icon-border-color", + "--spectrum-swatch-icon-color", "--spectrum-swatch-inner-border-color-selected", + "--spectrum-swatch-rectangle-width-multiplier", "--spectrum-swatch-size", "--spectrum-swatch-size-extra-small", "--spectrum-swatch-size-large", @@ -101,31 +113,32 @@ "--spectrum-swatch-slash-thickness-small" ], "global": [ + "--spectrum-add-button-background", + "--spectrum-add-button-background-down", + "--spectrum-add-button-background-hover", + "--spectrum-add-button-background-keyboard-focus", "--spectrum-animation-duration-100", - "--spectrum-black-rgb", "--spectrum-border-width-100", "--spectrum-border-width-200", - "--spectrum-corner-radius-75", + "--spectrum-corner-radius-100", + "--spectrum-corner-radius-full", + "--spectrum-corner-radius-none", "--spectrum-focus-indicator-color", "--spectrum-focus-indicator-gap", "--spectrum-focus-indicator-thickness", - "--spectrum-gray-1000-rgb", + "--spectrum-gray-100", + "--spectrum-gray-1000", + "--spectrum-gray-200", "--spectrum-gray-25", - "--spectrum-gray-800", - "--spectrum-gray-900", + "--spectrum-mixed-button-background", + "--spectrum-negative-visual-color", + "--spectrum-neutral-content-color-default", "--spectrum-picked-color", - "--spectrum-red-900", "--spectrum-white", - "--spectrum-workflow-icon-size-100", "--spectrum-workflow-icon-size-200", "--spectrum-workflow-icon-size-50", "--spectrum-workflow-icon-size-75" ], - "system-theme": [ - "--system-swatch-border-color", - "--system-swatch-border-radius", - "--system-swatch-inner-border-color-selected" - ], "passthroughs": [], "high-contrast": [ "--highcontrast-swatch-background-color-selected", @@ -133,6 +146,7 @@ "--highcontrast-swatch-border-color-selected", "--highcontrast-swatch-disabled-icon-color", "--highcontrast-swatch-fill-foreground-color", - "--highcontrast-swatch-focus-indicator-color" + "--highcontrast-swatch-focus-indicator-color", + "--highcontrast-swatch-icon-color" ] } diff --git a/components/swatch/index.css b/components/swatch/index.css index 7ca59b71dd9..f5f261a3fa0 100644 --- a/components/swatch/index.css +++ b/components/swatch/index.css @@ -1,5 +1,5 @@ /*! - * Copyright 2024 Adobe. All rights reserved. + * Copyright 2025 Adobe. All rights reserved. * * This file is licensed to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. You may obtain a copy @@ -11,69 +11,73 @@ * governing permissions and limitations under the License. */ -@import "./themes/spectrum-two.css"; +.spectrum-Swatch { + /* Placeholder tokens */ + --spectrum-swatch-icon-border-color: var(--mod-swatch-icon-border-color, rgb(0 0 0 / var(--spectrum-swatch-disabled-icon-border-opacity))); + + /* Size */ + --spectrum-swatch-size: var(--mod-swatch-size, var(--spectrum-swatch-size-medium)); + --spectrum-swatch-border-radius: var(--mod-swatch-border-radius, var(--spectrum-corner-radius-100)); + --spectrum-swatch-border-thickness: var(--mod-swatch-border-thickness, var(--spectrum-border-width-100)); + --spectrum-swatch-border-thickness-selected: var(--mod-swatch-border-thickness-selected, var(--spectrum-border-width-200)); + --spectrum-swatch-disabled-icon-size: var(--mod-swatch-disabled-icon-size, var(--spectrum-workflow-icon-size-75)); + --spectrum-swatch-slash-thickness: var(--mod-swatch-slash-thickness, var(--spectrum-swatch-slash-thickness-medium)); + + /* Color */ + --spectrum-swatch-border-color-selected: var(--highcontrast-swatch-border-color-selected, var(--mod-swatch-border-color-selected, var(--spectrum-gray-1000))); + --spectrum-swatch-inner-border-color-selected: var(--highcontrast-swatch-background-color-selected, var(--mod-swatch-inner-border-color-selected, var(--spectrum-gray-25))); + --spectrum-swatch-disabled-icon-color: var(--highcontrast-swatch-disabled-icon-color, var(--mod-swatch-disabled-icon-color, var(--spectrum-white))); + --spectrum-swatch-icon-color: var(--highcontrast-swatch-icon-color, var(--mod-swatch-icon-color, var(--spectrum-neutral-content-color-default))); + --spectrum-swatch-slash-icon-color: var(--highcontrast-swatch-fill-foreground-color, var(--mod-swatch-slash-icon-color, var(--spectrum-negative-visual-color))); + --spectrum-mixed-button-background: var(--spectrum-gray-25); + --spectrum-add-button-background: var(--spectrum-gray-100); + --spectrum-add-button-background-hover: var(--spectrum-gray-200); + --spectrum-add-button-background-down: var(--spectrum-gray-200); + --spectrum-add-button-background-keyboard-focus: var(--spectrum-gray-200); + + /* TODO update to use tokens once available */ + --spectrum-swatch-border: rgb(from var(--mod-swatch-border-color, var(--spectrum-swatch-border-color)) r g b / var(--mod-swatch-border-opacity, var(--spectrum-swatch-border-opacity))); + + /* Focus ring */ + --spectrum-swatch-focus-indicator-color: var(--highcontrast-swatch-focus-indicator-color, var(--mod-swatch-focus-indicator-color, var(--spectrum-focus-indicator-color))); + --spectrum-swatch-focus-indicator-thickness: var(--mod-swatch-focus-indicator-thickness, var(--spectrum-focus-indicator-thickness)); + --spectrum-swatch-focus-indicator-gap: var(--mod-swatch-focus-indicator-gap, var(--spectrum-focus-indicator-gap)); +} -/* Windows high contrast mode */ -@media (forced-colors: active) { - .spectrum-Swatch { - --highcontrast-swatch-disabled-icon-color: GrayText; - --highcontrast-swatch-focus-indicator-color: ButtonText; - --highcontrast-swatch-background-color-selected: Background; - --highcontrast-swatch-border-color-selected: Highlight; - --highcontrast-swatch-border-color: ButtonText; - --highcontrast-swatch-fill-foreground-color: ButtonText; +/* The add-swatch's border color is the same as its background color for all states. */ +.spectrum-Swatch.is-addSwatch { + --spectrum-swatch-border: var(--spectrum-add-button-background); - .spectrum-Swatch-fill { - forced-color-adjust: none; - } + &:hover { + --spectrum-swatch-border: var(--spectrum-add-button-background-hover); } - .spectrum-Swatch[disabled], - .spectrum-Swatch.is-disabled { - --highcontrast-swatch-border-color: GrayText; + &:active { + --spectrum-swatch-border: var(--spectrum-add-button-background-down); } } -.spectrum-Swatch, -.spectrum-Swatch--sizeS { - --spectrum-swatch-size: var(--spectrum-swatch-size-small); - --spectrum-swatch-disabled-icon-size: var(--spectrum-workflow-icon-size-75); - --spectrum-swatch-slash-thickness: var(--spectrum-swatch-slash-thickness-small); -} - .spectrum-Swatch--sizeXS { - --spectrum-swatch-size: var(--spectrum-swatch-size-extra-small); - --spectrum-swatch-disabled-icon-size: var(--spectrum-workflow-icon-size-50); - --spectrum-swatch-slash-thickness: var(--spectrum-swatch-slash-thickness-extra-small); + --spectrum-swatch-size: var(--mod-swatch-size, var(--spectrum-swatch-size-extra-small)); + --spectrum-swatch-disabled-icon-size: var(--mod-swatch-disabled-icon-size, var(--spectrum-workflow-icon-size-50)); + --spectrum-swatch-slash-thickness: var(--mod-swatch-slash-thickness, var(--spectrum-swatch-slash-thickness-extra-small)); } -.spectrum-Swatch--sizeM { - --spectrum-swatch-size: var(--spectrum-swatch-size-medium); - --spectrum-swatch-disabled-icon-size: var(--spectrum-workflow-icon-size-100); - --spectrum-swatch-slash-thickness: var(--spectrum-swatch-slash-thickness-medium); +.spectrum-Swatch--sizeS { + --spectrum-swatch-size: var(--mod-swatch-size, var(--spectrum-swatch-size-small)); + --spectrum-swatch-disabled-icon-size: var(--mod-swatch-disabled-icon-size, var(--spectrum-workflow-icon-size-75)); + --spectrum-swatch-slash-thickness: var(--mod-swatch-slash-thickness, var(--spectrum-swatch-slash-thickness-small)); } .spectrum-Swatch--sizeL { - --spectrum-swatch-size: var(--spectrum-swatch-size-large); - --spectrum-swatch-disabled-icon-size: var(--spectrum-workflow-icon-size-200); - --spectrum-swatch-slash-thickness: var(--spectrum-swatch-slash-thickness-large); + --spectrum-swatch-size: var(--mod-swatch-size, var(--spectrum-swatch-size-large)); + --spectrum-swatch-disabled-icon-size: var(--mod-swatch-disabled-icon-size, var(--spectrum-workflow-icon-size-200)); + --spectrum-swatch-slash-thickness: var(--mod-swatch-slash-thickness, var(--spectrum-swatch-slash-thickness-large)); } .spectrum-Swatch { - --spectrum-swatch-focus-indicator-border-radius: 8px; - --spectrum-swatch-icon-border-color: rgb(var(--spectrum-black-rgb), var(--spectrum-swatch-disabled-icon-border-opacity)); - --spectrum-swatch-disabled-icon-color: var(--spectrum-white); - --spectrum-swatch-border-thickness: var(--spectrum-border-width-100); - --spectrum-swatch-border-thickness-selected: var(--spectrum-border-width-200); - --spectrum-swatch-focus-indicator-thickness: var(--spectrum-focus-indicator-thickness); - --spectrum-swatch-focus-indicator-gap: var(--spectrum-focus-indicator-gap); - --spectrum-swatch-border-color-selected: var(--spectrum-gray-900); - --spectrum-swatch-dash-icon-color: var(--spectrum-gray-800); - --spectrum-swatch-slash-icon-color: var(--spectrum-red-900); - --spectrum-swatch-focus-indicator-color: var(--spectrum-focus-indicator-color); - - inline-size: var(--mod-swatch-size, var(--spectrum-swatch-size)); - block-size: var(--mod-swatch-size, var(--spectrum-swatch-size)); + inline-size: var(--spectrum-swatch-size); + block-size: var(--spectrum-swatch-size); display: flex; align-items: center; @@ -82,30 +86,76 @@ /* contain selection indicator and focus-ring */ position: relative; - outline: none; + outline-width: 0; + outline-style: solid; + outline-color: transparent; /* don't let double clicking select stuff */ user-select: none; .spectrum-Swatch-disabledIcon { - inline-size: var(--mod-swatch-disabled-icon-size, var(--spectrum-swatch-disabled-icon-size)); - block-size: var(--mod-swatch-disabled-icon-size, var(--spectrum-swatch-disabled-icon-size)); + inline-size: var(--spectrum-swatch-disabled-icon-size); + block-size: var(--spectrum-swatch-disabled-icon-size); } &, &::before { - border-radius: var(--mod-swatch-border-radius, var(--spectrum-swatch-border-radius)); + border-radius: var(--spectrum-swatch-border-radius); + } + + &.is-mixedValue { + --spectrum-picked-color: var(--mod-mixed-button-background, var(--spectrum-mixed-button-background)); + } + + &.is-addSwatch { + --spectrum-picked-color: var(--mod-add-button-background, var(--spectrum-add-button-background)); + + .spectrum-Swatch-fill { + background: var(--spectrum-picked-color); + } + + &:hover { + --spectrum-picked-color: var(--mod-add-button-background-hover, var(--spectrum-add-button-background-hover)); + } + + &:active { + --spectrum-picked-color: var(--mod-add-button-background-down, var(--spectrum-add-button-background-down)); + } + + &:hover, + &:active { + cursor: pointer; + } + + &.is-keyboardFocused, + &:focus-visible { + --spectrum-picked-color: var(--mod-add-button-background-keyboard-focus, var(--spectrum-add-button-background-keyboard-focus)); + } + + .spectrum-Swatch-icon { + color: var(--spectrum-swatch-icon-color); + display: block; + } + } + + &.is-keyboardFocused, + &:focus-visible { + outline-width: var(--mod-swatch-focus-indicator-thickness, var(--spectrum-swatch-focus-indicator-thickness)); + outline-color: var(--mod-swatch-focus-indicator-color, var(--spectrum-swatch-focus-indicator-color)); + outline-offset: var(--mod-swatch-focus-indicator-gap, var(--spectrum-swatch-focus-indicator-gap)); + + transition: outline-color var(--mod-animation-duration-100, var(--spectrum-animation-duration-100)) ease-in-out; } &.is-selected { - background: var(--highcontrast-swatch-background-color-selected, var(--mod-swatch-inner-border-color-selected, var(--spectrum-swatch-inner-border-color-selected))); + background: var(--spectrum-swatch-inner-border-color-selected); .spectrum-Swatch-fill { clip-path: polygon( - calc(var(--mod-swatch-border-thickness-selected, var(--spectrum-swatch-border-thickness-selected)) * 2) calc(var(--mod-swatch-border-thickness-selected, var(--spectrum-swatch-border-thickness-selected)) * 2), - calc(100% - var(--mod-swatch-border-thickness-selected, var(--spectrum-swatch-border-thickness-selected)) * 2) calc(var(--mod-swatch-border-thickness-selected, var(--spectrum-swatch-border-thickness-selected)) * 2), - calc(100% - var(--mod-swatch-border-thickness-selected, var(--spectrum-swatch-border-thickness-selected)) * 2) calc(100% - var(--mod-swatch-border-thickness-selected, var(--spectrum-swatch-border-thickness-selected)) * 2), - calc(var(--mod-swatch-border-thickness-selected, var(--spectrum-swatch-border-thickness-selected)) * 2) calc(100% - var(--mod-swatch-border-thickness-selected, var(--spectrum-swatch-border-thickness-selected)) * 2) + calc(var(--spectrum-swatch-border-thickness-selected) * 2) calc(var(--spectrum-swatch-border-thickness-selected) * 2), + calc(100% - var(--spectrum-swatch-border-thickness-selected) * 2) calc(var(--spectrum-swatch-border-thickness-selected) * 2), + calc(100% - var(--spectrum-swatch-border-thickness-selected) * 2) calc(100% - var(--spectrum-swatch-border-thickness-selected) * 2), + calc(var(--spectrum-swatch-border-thickness-selected) * 2) calc(100% - var(--spectrum-swatch-border-thickness-selected) * 2) ); /* no border radius when selected */ @@ -134,30 +184,31 @@ background: var(--spectrum-picked-color, transparent); } - .spectrum-Swatch-mixedValueIcon { - color: var(--spectrum-swatch-dash-icon-color); + .spectrum-Swatch-icon { + color: var(--spectrum-swatch-icon-color); display: block; } } /* Swatch fill: Not fill with Slash */ - &.is-nothing { + &.is-nothing:not(&.is-mixedValue, &.is-addSwatch) { .spectrum-Swatch-fill { background: var(--spectrum-picked-color, transparent); background-image: none; &::after { - inline-size: var(--mod-swatch-slash-thickness, var(--spectrum-swatch-slash-thickness)); + inline-size: var(--spectrum-swatch-slash-thickness); content: ""; position: absolute; - transform: rotate(-45deg); + transform: rotate(45deg); block-size: 200%; /* just needs to be bigger than a swatch */ - background: var(--highcontrast-swatch-fill-foreground-color, var(--mod-swatch-slash-icon-color, var(--spectrum-swatch-slash-icon-color))); + background: var(--spectrum-swatch-slash-icon-color); } } &.spectrum-Swatch--rectangle .spectrum-Swatch-fill::after { - transform: rotate(-25deg); + transform: rotate(65deg); + block-size: 215%; } } @@ -174,36 +225,14 @@ position: absolute; inset: 0; - border-width: var(--mod-swatch-border-thickness-selected, var(--spectrum-swatch-border-thickness-selected)); + border-width: var(--spectrum-swatch-border-thickness-selected); border-style: solid; - border-color: var(--highcontrast-swatch-border-color-selected, var(--mod-swatch-border-color-selected, var(--spectrum-swatch-border-color-selected))); + border-color: var(--spectrum-swatch-border-color-selected); opacity: 0; pointer-events: none; } - - /* focus-ring */ - &::after { - content: ""; - position: absolute; - inset: calc(-2 * var(--mod-swatch-focus-indicator-gap, var(--spectrum-swatch-focus-indicator-gap))); - - opacity: 0; - - border-width: var(--mod-swatch-focus-indicator-thickness, var(--spectrum-swatch-focus-indicator-thickness)); - border-style: solid; - border-color: var(--highcontrast-swatch-focus-indicator-color, var(--mod-swatch-focus-indicator-color, var(--spectrum-swatch-focus-indicator-color))); - border-radius: var(--mod-swatch-focus-indicator-border-radius, var(--spectrum-swatch-focus-indicator-border-radius)); - - transition: opacity var(--mod-animation-duration-100, var(--spectrum-animation-duration-100)) ease-in-out; - } - - &:focus-visible { - &::after { - opacity: 1; - } - } } .spectrum-Swatch-fill { @@ -227,35 +256,21 @@ position: absolute; inset: 0; z-index: 0; + + /* Undefined variable allows custom stylesheet or JS to pass the value to this element */ background: var(--spectrum-picked-color, transparent); /* Swatch border */ - box-shadow: inset 0 0 0 var(--mod-swatch-border-thickness, var(--spectrum-swatch-border-thickness)) var(--highcontrast-swatch-border-color, var(--mod-swatch-border-color, var(--spectrum-swatch-border-color))); + box-shadow: inset 0 0 0 var(--mod-swatch-border-thickness, var(--spectrum-swatch-border-thickness)) var(--highcontrast-swatch-border-color, var(--mod-swatch-border, var(--spectrum-swatch-border))); border-radius: var(--mod-swatch-border-radius, var(--spectrum-swatch-border-radius)); } } -/* Variant: No border */ -.spectrum-Swatch--noBorder { - .spectrum-Swatch-fill { - &::before { - box-shadow: none; - background: var(--spectrum-picked-color, transparent); - } - } -} - -.spectrum-Swatch--lightBorder { - .spectrum-Swatch-fill { - &::before { - box-shadow: inset 0 0 0 var(--mod-swatch-border-thickness, var(--spectrum-swatch-border-thickness)) var(--mod-swatch-border-color-light, var(--spectrum-swatch-border-color-light)); - } - } -} - -.spectrum-Swatch-mixedValueIcon { +.spectrum-Swatch-icon { display: none; pointer-events: none; + + /* Undefined variable allows custom stylesheet or JS to pass the value to this element */ color: var(--spectrum-picked-color, transparent); } @@ -266,22 +281,22 @@ display: none; pointer-events: none; - color: var(--highcontrast-swatch-disabled-icon-color, var(--mod-swatch-disabled-icon-color, var(--spectrum-swatch-disabled-icon-color))); - stroke: var(--highcontrast-swatch-disabled-icon-color, var(--mod-swatch-disabled-icon-color, var(--spectrum-swatch-disabled-icon-color))); + color: var(--spectrum-swatch-disabled-icon-color); + stroke: var(--spectrum-swatch-disabled-icon-color); /* Icon fill color */ path:first-child { - fill: var(--highcontrast-swatch-disabled-icon-color, var(--mod-swatch-disabled-icon-color, var(--spectrum-swatch-disabled-icon-color))); + fill: var(--spectrum-swatch-disabled-icon-color); } /* Icon outline color - does not need a highcontrast token because the icon fill color provides contrast. */ path:last-child { - fill: var(--mod-swatch-icon-border-color, var(--spectrum-swatch-icon-border-color)); + fill: var(--spectrum-swatch-icon-border-color); } } .spectrum-Swatch--rectangle { - inline-size: calc(var(--mod-swatch-size, var(--spectrum-swatch-size)) * 2); + inline-size: calc(var(--spectrum-swatch-size) * var(--spectrum-swatch-rectangle-width-multiplier)); } /* Variant: Rounding - None */ @@ -293,7 +308,7 @@ .spectrum-Swatch-fill::before, &.is-selected .spectrum-Swatch-fill, &.is-selected .spectrum-Swatch-fill::before { - border-radius: 0; + border-radius: var(--spectrum-corner-radius-none); } } @@ -307,11 +322,11 @@ .spectrum-Swatch-fill::before, &.is-selected .spectrum-Swatch-fill, &.is-selected .spectrum-Swatch-fill::before { - border-radius: 100%; + border-radius: var(--mod-corner-radius-full, var(--spectrum-corner-radius-full)); } &.is-selected .spectrum-Swatch-fill { - clip-path: circle(calc(50% - (var(--mod-swatch-border-thickness-selected, var(--spectrum-swatch-border-thickness-selected)) * 2)) at 50% 50%); + clip-path: circle(calc(50% - (var(--spectrum-swatch-border-thickness-selected) * 2)) at 50% 50%); } } } @@ -326,3 +341,46 @@ width var(--mod-animation-duration-100, var(--spectrum-animation-duration-100)) ease-in-out, height var(--mod-animation-duration-100, var(--spectrum-animation-duration-100)) ease-in-out; } + +/* Windows high contrast mode */ +@media (forced-colors: active) { + .spectrum-Swatch { + --mod-mixed-button-background: ButtonFace; + + --mod-add-button-background: ButtonFace; + --mod-add-button-background-hover: ButtonText; + --mod-add-button-background-down: ButtonText; + + --highcontrast-swatch-disabled-icon-color: GrayText; + --highcontrast-swatch-focus-indicator-color: ButtonText; + --highcontrast-swatch-background-color-selected: ButtonFace; + --highcontrast-swatch-border-color-selected: Highlight; + --highcontrast-swatch-border-color: ButtonText; + --highcontrast-swatch-fill-foreground-color: ButtonText; + + .spectrum-Swatch-fill { + forced-color-adjust: none; + } + + &.is-mixedValue { + --highcontrast-swatch-icon-color: ButtonFace; + } + + &.is-addSwatch { + &:hover, + &:active { + --highcontrast-swatch-icon-color: ButtonFace; + } + + &.is-keyboardFocused, + &:focus-visible { + --highcontrast-swatch-icon-color: ButtonFace; + } + } + + &[disabled], + &.is-disabled { + --highcontrast-swatch-border-color: GrayText; + } + } +} diff --git a/components/swatch/package.json b/components/swatch/package.json index 4c4cc672fae..7ce58dc24ab 100644 --- a/components/swatch/package.json +++ b/components/swatch/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/swatch", - "version": "8.2.0", + "version": "9.0.0-next.1", "description": "The Spectrum CSS Color swatch component", "license": "Apache-2.0", "author": "Adobe", @@ -19,15 +19,13 @@ "./package.json": "./package.json", "./dist/*": "./dist/*", "./index.css": "./dist/index.css", - "./index-*.css": "./dist/index-*.css", "./metadata.json": "./dist/metadata.json", - "./themes/*": "./dist/themes/*", "./stories/*": "./stories/*" }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/opacitycheckerboard": ">=4.0.0 <5.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/opacitycheckerboard": ">=5.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/opacitycheckerboard": { @@ -38,8 +36,8 @@ } }, "devDependencies": { - "@spectrum-css/opacitycheckerboard": "4.2.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/opacitycheckerboard": "5.0.0-next.0", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/swatch/stories/swatch.stories.js b/components/swatch/stories/swatch.stories.js index d3d1b44b1c2..50b2ec74522 100644 --- a/components/swatch/stories/swatch.stories.js +++ b/components/swatch/stories/swatch.stories.js @@ -1,10 +1,10 @@ import { Sizes } from "@spectrum-css/preview/decorators"; import { disableDefaultModes } from "@spectrum-css/preview/modes"; -import { isDisabled, isSelected, size } from "@spectrum-css/preview/types"; +import { isDisabled, isHovered, isActive, isKeyboardFocused, isSelected, size } from "@spectrum-css/preview/types"; import metadata from "../dist/metadata.json"; import packageJson from "../package.json"; import { SwatchGroup } from "./swatch.test.js"; -import { BorderGroup, DisabledGroup, EmptyGroup, RoundingGroup, SizingGroup, Template } from "./template.js"; +import { DisabledGroup, EmptyGroup, RoundingGroup, SizingGroup, Template } from "./template.js"; /** * A swatch shows a small sample of a fill--such as a color, gradient, texture, or material--that is intended to be applied to an object. @@ -12,6 +12,9 @@ import { BorderGroup, DisabledGroup, EmptyGroup, RoundingGroup, SizingGroup, Tem * ## Usage notes * * Set `--spectrum-picked-color` to customize the swatch fill background color. + * + * By default, swatches have a border with 42% opacity. However, when swatches are used within a swatch group, the default border opacity changes . + * */ export default { title: "Swatch", @@ -20,7 +23,7 @@ export default { size: size(["xs", "s", "m", "l"]), swatchColor: { name: "Color", - description: "Supports standard color input or any valid input for the background property such as, linear-gradient(red, blue).", + description: "Supports standard color input or any valid input for the background property such as, linear-gradient(red, blue) or transparent.", type: { name: "string", required: true }, table: { type: { summary: "string" }, @@ -38,21 +41,24 @@ export default { category: "Component", defaultValue: { summary: "regular", }, }, - options: ["none", "regular", "full"], + options: ["regular", "none", "full"], control: "select", }, - isDisabled, + isDisabled: { + ...isDisabled, + if: { arg: "isAddSwatch", truthy: false }, + category: "State", + }, isSelected, - borderStyle: { - name: "Border style", - type: { name: "string" }, - table: { - type: { summary: "string", required: true }, - category: "Component", - }, - options: ["default", "none", "light"], - control: "select", + isHovered: { + ...isHovered, + if: { arg: "isAddSwatch", truthy: true }, }, + isActive: { + ...isActive, + if: { arg: "isAddSwatch", truthy: true }, + }, + isKeyboardFocused, shape: { name: "Swatch shape", description: "Swatches can have a square or rectangle shape.", @@ -85,6 +91,18 @@ export default { category: "Component", }, control: "boolean", + if: { arg: "isAddSwatch", truthy: false }, + }, + isAddSwatch: { + name: "Add swatch", + description: "A swatch that allows a user to add a new value.", + type: { name: "boolean" }, + table: { + type: { summary: "boolean" }, + category: "Component", + }, + control: "boolean", + if: { arg: "isMixedValue", truthy: false }, }, }, args: { @@ -92,11 +110,14 @@ export default { size: "m", isSelected: false, isDisabled: false, + isHovered: false, + isActive: false, + isKeyboardFocused: false, rounding: "regular", swatchColor: "rgb(174, 216, 230)", - borderStyle: "default", shape: "square", isMixedValue: false, + isAddSwatch: false, }, parameters: { design: { @@ -105,11 +126,15 @@ export default { }, packageJson, metadata, + status: { + type: "migrated", + }, }, + tags: ["migrated"], }; /** - * The medium size is the default and most frequently used option. By default, a swatch has a square shape. + * The medium size is the default and most frequently used option. By default, a swatch has a square shape, with rounded corners. */ export const Default = SwatchGroup.bind({}); Default.args = {}; @@ -145,7 +170,7 @@ Disabled.parameters = { }; /** - * Default rounding and full rounding are usually used when a swatch is presented by itself near other components. A rounding of “none” is used in a swatch group to help minimize the Hermann grid illusion that happens at the intersections of white space in the group. + * Default rounding and full rounding are usually used when a swatch is presented by itself near other components. A rounding of "none" is used in a swatch group to help minimize the Hermann grid illusion that happens at the intersections of white space in the group. */ export const Rounding = RoundingGroup.bind({}); Rounding.tags = ["!dev"]; @@ -168,17 +193,6 @@ Selected.parameters = { chromatic: { disableSnapshot: true }, }; -/** - * By default, swatches have a border. However, when swatches are used within a swatch group, there are additional border considerations. - * - When color swatches are used in a [swatch group](?path=/docs/components-swatch-group--docs), they typically have the `.spectrum-Swatch--noBorder` class. - * - When and only when color swatches used in a swatch group have low contrast (below 3:1 contrast with the background), those swatches will have a less prominent border compared to the swatch component when used by itself. They individually use the `.spectrum-Swatch--lightBorder` class. - */ -export const Border = BorderGroup.bind({}); -Border.tags = ["!dev"]; -Border.parameters = { - chromatic: { disableSnapshot: true }, -}; - /** * Swatches can also have a rectangle shape with an aspect ratio of 2:1. The square shape is the default and is used in swatch groups (e.g., a palette of colors). */ @@ -220,6 +234,24 @@ MixedValue.tags = ["!dev"]; MixedValue.parameters = { chromatic: { disableSnapshot: true }, }; +MixedValue.storyName = "Mixed value"; + +/** + * When a swatch allows a user to add a new value, the preview shows a `gray-50` fill and an add UI icon. + */ +export const AddSwatch = (args, context) => Sizes({ + Template: DisabledGroup, + withHeading: false, + ...args, +}, context); +AddSwatch.args = { + isAddSwatch: true, +}; +AddSwatch.tags = ["!dev"]; +AddSwatch.parameters = { + chromatic: { disableSnapshot: true }, +}; +AddSwatch.storyName = "Add swatch"; export const Gradient = Template.bind({}); Gradient.args = { diff --git a/components/swatch/stories/swatch.test.js b/components/swatch/stories/swatch.test.js index a441952d391..c9f0ebcad3e 100644 --- a/components/swatch/stories/swatch.test.js +++ b/components/swatch/stories/swatch.test.js @@ -19,19 +19,25 @@ export const Swatches = (args, context) => { Template({ ...args, rounding: "none", - borderStyle: "noBorder", swatchColor: "linear-gradient(to right, rgba(154, 116, 200, 0.5), rgb(174, 216, 230))", }, context), Template({ ...args, rounding: "full", - borderStyle: "lightBorder", swatchColor: `center / contain no-repeat url("${exampleImage}")`, }, context), Template({ ...args, isMixedValue: true, }, context), + Template({ + ...args, + isDisabled: true, + }, context), + Template({ + ...args, + isAddSwatch: true, + }, context), Template({ ...args, swatchColor: undefined, @@ -62,16 +68,12 @@ export const SwatchGroup = Variants({ rounding: "none" }, { - testHeading: "Full rounding", - rounding: "full" + testHeading: "Regular rounding", + rounding: "regular" }, { - testHeading: "Light border", - borderStyle: "lightBorder", - }, - { - testHeading: "No border", - borderStyle: "noBorder", + testHeading: "Full rounding", + rounding: "full" }, { testHeading: "Shape: rectangle", @@ -93,22 +95,44 @@ export const SwatchGroup = Variants({ testHeading: "Mixed value", isMixedValue: true, }, - ], - stateData: [ { - testHeading: "Disabled", - isDisabled: true, + testHeading: "Add", + isAddSwatch: true, }, { testHeading: "Empty", swatchColor: undefined, imageUrl: undefined, - isMixedValue: false, - borderStyle: "default", + }, + ], + stateData: [ + { + testHeading: "Empty", + swatchColor: undefined, + imageUrl: undefined, + ignore: ["Mixed value", "Add", "Empty"] }, { testHeading: "Selected", isSelected: true, }, + { + testHeading: "Keyboard focus", + isKeyboardFocused: true, + }, + { + testHeading: "Disabled", + isDisabled: true, + }, + { + testHeading: "Hovered", + isHovered: true, + include: ["Add"] + }, + { + testHeading: "Active", + isActive: true, + include: ["Add"] + }, ] }); diff --git a/components/swatch/stories/template.js b/components/swatch/stories/template.js index f3658577a3f..85065626106 100644 --- a/components/swatch/stories/template.js +++ b/components/swatch/stories/template.js @@ -9,19 +9,19 @@ import { when } from "lit/directives/when.js"; import { capitalize, lowerCase } from "lodash-es"; import "../index.css"; -import "../themes/spectrum.css"; -/* Must be imported last */ -import "../themes/express.css"; export const Template = ({ rootClass = "spectrum-Swatch", size = "m", - borderStyle = "default", shape = "square", imageUrl, isMixedValue = false, + isAddSwatch = false, isSelected = false, isDisabled = false, + isHovered = false, + isActive = false, + isKeyboardFocused = false, rounding = "regular", customClasses = [], swatchColor, @@ -30,14 +30,10 @@ export const Template = ({ } = {}, context = {}) => { const { updateArgs } = context; - switch (borderStyle) { - case "none": - borderStyle = "noBorder"; - break; - case "light": - borderStyle = "lightBorder"; - break; - } + let pickedColor = swatchColor; + + if (isMixedValue) pickedColor = "var(--spectrum-gray-25)"; + if (isAddSwatch) pickedColor = undefined; return html`
({ ...a, [c]: true }), {}), @@ -60,7 +59,7 @@ export const Template = ({ ?disabled=${isDisabled} id=${ifDefined(id)} style=${ifDefined(styleMap({ - "--spectrum-picked-color": isMixedValue ? "var(--spectrum-gray-50)" : swatchColor, + "--spectrum-picked-color": pickedColor, ...customStyles, }))} tabindex="0" @@ -75,7 +74,7 @@ export const Template = ({ updateArgs({ isSelected: !isSelected }); }} > - ${when((typeof imageUrl !== "undefined") && !isDisabled && !isMixedValue, () => html` + ${when((typeof imageUrl !== "undefined") && !isDisabled && !isMixedValue && !isAddSwatch, () => html` ${when(imageUrl, () => html`
@@ -107,9 +106,26 @@ export const Template = ({ `] : []), ...(isMixedValue ? [Icon({ - customClasses: [`${rootClass}-mixedValueIcon`], + customClasses: [`${rootClass}-icon`], + setName: "ui", + iconName: "Dash" + ({ + xs: "75", + s: "75", + m: "100", + l: "200", + }[size] || "100"), + useRef: false, + }, context)] : []), + ...(isAddSwatch ? [Icon({ + customClasses: [`${rootClass}-icon`], setName: "ui", - iconName: "Dash", + size, + iconName: "Add" + ({ + xs: "75", + s: "75", + m: "100", + l: "200", + }[size] || "100"), useRef: false, }, context)] : []), ] @@ -121,11 +137,10 @@ export const Template = ({ /* Shows a single group of swatches with all rounding options. */ export const RoundingGroup = (args, context) => Container({ - withBorder: false, content: html` ${Container({ withBorder: false, - heading: "Regular", + heading: "Regular (Default)", containerStyles: { "gap": "8px" }, content: Template(args, context), }, context)} @@ -144,34 +159,8 @@ export const RoundingGroup = (args, context) => Container({ ` }, context); -/* Shows a single group of swatches with all border options. */ -export const BorderGroup = (args, context) => Container({ - withBorder: false, - content: html` - ${Container({ - withBorder: false, - heading: "Default", - containerStyles: { "gap": "8px" }, - content: Template(args, context), - }, context)} - ${Container({ - withBorder: false, - heading: "No border", - containerStyles: { "gap": "8px" }, - content: Template({...args, borderStyle: "noBorder"}, context), - }, context)} - ${Container({ - withBorder: false, - heading: "Light Border", - containerStyles: { "gap": "8px" }, - content: Template({...args, borderStyle: "lightBorder"}, context), - }, context)} - ` -}, context); - /* Shows a single group of swatches that are empty/nothing in various shapes and rounding. */ export const EmptyGroup = (args, context) => Container({ - withBorder: false, content: html` ${Container({ withBorder: false, @@ -193,7 +182,6 @@ export const EmptyGroup = (args, context) => Container({ /* Shows a single group of disabled swatches. */ export const DisabledGroup = (args, context) => Container({ - withBorder: false, content: html` ${Container({ withBorder: false, @@ -209,7 +197,6 @@ export const DisabledGroup = (args, context) => Container({ }, context); export const SizingGroup = (args, context) =>Container({ - withBorder: false, content: html` ${Container({ withBorder: false, diff --git a/components/swatch/themes/express.css b/components/swatch/themes/express.css deleted file mode 100644 index 9fd550418f2..00000000000 --- a/components/swatch/themes/express.css +++ /dev/null @@ -1,16 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--express */ - -@import "./spectrum.css"; diff --git a/components/swatch/themes/spectrum-two.css b/components/swatch/themes/spectrum-two.css deleted file mode 100644 index d3e43e53e9d..00000000000 --- a/components/swatch/themes/spectrum-two.css +++ /dev/null @@ -1,21 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -@container style(--system: spectrum) { - /* Swatch tokens */ - .spectrum-Swatch { - --spectrum-swatch-border-color: rgb(var(--spectrum-gray-1000-rgb), var(--spectrum-swatch-border-color-opacity)); - --spectrum-swatch-inner-border-color-selected: var(--spectrum-gray-25); - --spectrum-swatch-border-radius: var(--spectrum-corner-radius-75); - } -} diff --git a/components/swatch/themes/spectrum.css b/components/swatch/themes/spectrum.css deleted file mode 100644 index b5bbacb244d..00000000000 --- a/components/swatch/themes/spectrum.css +++ /dev/null @@ -1,24 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--legacy */ - -@import "./spectrum-two.css"; - -@container style(--system: legacy) { - .spectrum-Swatch { - --spectrum-swatch-border-color: rgb(var(--spectrum-gray-900-rgb), var(--spectrum-swatch-border-color-opacity)); - --spectrum-swatch-inner-border-color-selected: var(--spectrum-gray-50); - --spectrum-swatch-border-radius: var(--spectrum-corner-radius-100); - } -} diff --git a/components/swatchgroup/CHANGELOG.md b/components/swatchgroup/CHANGELOG.md index 719e5b7db38..71cdd3db461 100644 --- a/components/swatchgroup/CHANGELOG.md +++ b/components/swatchgroup/CHANGELOG.md @@ -1,5 +1,58 @@ # Change log +## 6.0.0-next.1 + +### Major Changes + +- [#3677](https://github.com/adobe/spectrum-css/pull/3677) [`d47295a`](https://github.com/adobe/spectrum-css/commit/d47295a06cf974c347d794ae4f71bc4c8c498025) Thanks [@cdransf](https://github.com/cdransf)! + +#### S2 migration for Swatch group + +This migrates the `swatch` and `swatchgroup` components to the latest Spectrum 2 designs. Custom properties have been remapped and added per the design specification. + +An `Add Swatch` variant has been added with the required color tokens and the specified add UI icon. + +The `Add Swatch` and `Mixed Value` variants may not be combined with background colors or images. To implement the `Add Swatch` you need to apply the `is-addSwatch` class to the `spectrum-Swatch` element. `Add swatch` keyboard focus may be applied by adding the `is-keyboardFocused` class to this combination of classes. + +The `spectrum-Swatch-icon` is used to set the expected color to icons contained within the swatch. + +The light and no border variants have been removed. Individual swatches have a border set to `--spectrum-gray-1000` at `42%` opacity, while the border opacity is set to `20%` in swatch groups. + +##### Removed custom properties + +`--spectrum-swatch-border-color` +`--spectrum-swatch-dash-icon-color` (replaced by `--spectrum-swatch-icon-color`) + +##### New custom properties + +`--spectrum-swatch-border-color-rgb` +`--spectrum-swatch-border-opacity` +`--spectrum-corner-radius-full` +`--spectrum-corner-radius-none` +`--spectrum-swatch-disabled-icon-border-opacity` +`--spectrum-swatch-icon-color` +`--spectrum-swatch-rectangle-width-multiplier` + +##### New mods + +`--mod-add-button-background` +`--mod-add-button-background-down` +`--mod-add-button-background-hover` +`--mod-add-button-background-keyboard-focus` +`--mod-corner-radius-full` +`--mod-mixed-button-background` +`--mod-swatchgroup-border-color` +`--mod-swatch-border-color-rgb` +`--mod-swatch-border-opacity` + +## 6.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + - @spectrum-css/swatch@9.0.0-next.0 + ## 5.2.0 ### Minor Changes diff --git a/components/swatchgroup/dist/metadata.json b/components/swatchgroup/dist/metadata.json index 74adf019d54..73ac1e248a6 100644 --- a/components/swatchgroup/dist/metadata.json +++ b/components/swatchgroup/dist/metadata.json @@ -3,20 +3,19 @@ "selectors": [ ".spectrum-SwatchGroup", ".spectrum-SwatchGroup--compact", - ".spectrum-SwatchGroup--spacious" + ".spectrum-SwatchGroup--spacious:has(.spectrum-Swatch--sizeM, .spectrum-Swatch--sizeL)", + ".spectrum-SwatchGroup--spacious:has(.spectrum-Swatch--sizeXS, .spectrum-Swatch--sizeS)" ], - "modifiers": [ - "--mod-swatchgroup-spacing-compact", - "--mod-swatchgroup-spacing-regular", - "--mod-swatchgroup-spacing-spacious" + "modifiers": ["--mod-swatchgroup-spacing"], + "component": [ + "--spectrum-swatch-group-spacing-spacious", + "--spectrum-swatchgroup-spacing" ], - "component": ["--spectrum-swatchgroup-spacing"], "global": [ "--spectrum-spacing-100", "--spectrum-spacing-50", "--spectrum-spacing-75" ], - "system-theme": [], - "passthroughs": [], + "passthroughs": ["--mod-swatch-border-opacity"], "high-contrast": [] } diff --git a/components/swatchgroup/index.css b/components/swatchgroup/index.css index 78485c77529..c90ada7453c 100644 --- a/components/swatchgroup/index.css +++ b/components/swatchgroup/index.css @@ -1,5 +1,5 @@ /*! - * Copyright 2024 Adobe. All rights reserved. + * Copyright 2025 Adobe. All rights reserved. * * This file is licensed to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. You may obtain a copy @@ -14,23 +14,25 @@ .spectrum-SwatchGroup { --spectrum-swatchgroup-spacing: var(--spectrum-spacing-75); + --mod-swatch-border-opacity: 0.2; +} + +.spectrum-SwatchGroup { display: inline-flex; flex-flow: row wrap; align-items: flex-start; justify-content: flex-start; - - /* Regular (Default) */ - gap: var(--mod-swatchgroup-spacing-regular, var(--spectrum-swatchgroup-spacing)); + gap: var(--mod-swatchgroup-spacing, var(--spectrum-swatchgroup-spacing)); } -/* Compact */ .spectrum-SwatchGroup--compact { - --mod-swatchgroup-spacing-regular: var(--mod-swatchgroup-spacing-compact); --spectrum-swatchgroup-spacing: var(--spectrum-spacing-50); } -/* Spacious */ -.spectrum-SwatchGroup--spacious { - --mod-swatchgroup-spacing-regular: var(--mod-swatchgroup-spacing-spacious); +.spectrum-SwatchGroup--spacious:has(.spectrum-Swatch--sizeXS, .spectrum-Swatch--sizeS) { + --spectrum-swatchgroup-spacing: var(--spectrum-swatch-group-spacing-spacious); +} + +.spectrum-SwatchGroup--spacious:has(.spectrum-Swatch--sizeM, .spectrum-Swatch--sizeL) { --spectrum-swatchgroup-spacing: var(--spectrum-spacing-100); } diff --git a/components/swatchgroup/package.json b/components/swatchgroup/package.json index 7c482765b57..7493855cc6b 100644 --- a/components/swatchgroup/package.json +++ b/components/swatchgroup/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/swatchgroup", - "version": "5.2.0", + "version": "6.0.0-next.1", "description": "The Spectrum CSS Color swatch group component", "license": "Apache-2.0", "author": "Adobe", @@ -24,8 +24,8 @@ }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/swatch": ">=8.0.0 <9.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/swatch": ">=9.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/swatch": { @@ -36,8 +36,8 @@ } }, "devDependencies": { - "@spectrum-css/swatch": "8.2.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/swatch": "9.0.0-next.1", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/swatchgroup/stories/swatchgroup.stories.js b/components/swatchgroup/stories/swatchgroup.stories.js index 2a842f06695..669280b0882 100644 --- a/components/swatchgroup/stories/swatchgroup.stories.js +++ b/components/swatchgroup/stories/swatchgroup.stories.js @@ -11,21 +11,17 @@ import { RoundingTemplate, Template } from "./template.js"; * * ## Usage notes * + * The border opacity of swatches in a swatch group is 20%. + * * ### Corner rounding in swatch groups * - * A corner rounding of “none” (`.spectrum-Swatch--roundingNone` class) should be used in a swatch group in order to help minimize the Hermann grid illusion that happens at the intersections of the white space within the group. + * A corner rounding of "none" (`.spectrum-Swatch--roundingNone` class) should be used in a swatch group in order to help minimize the Hermann grid illusion that happens at the intersections of the white space within the group. * * The only exception is when a swatch group only takes up a single row. In that case, use any of the rounding options. * - * ### Apply border to low-contrast swatches only - * - * When swatches within a swatch group have low contrast (below 3:1 contrast with the background), they have a less prominent border compared to a single swatch component used by itself, and should have the `.spectrum-Swatch--lightBorder` class. This reduces the likelihood of the UI interfering with color perception and comparisons. Otherwise, swatches within a swatch group that meet contrast should have the `.spectrum-Swatch--noBorder` class. - * - * Implementations should apply the `.spectrum-Swatch--lightBorder` to the individual swatches of a swatch group that do not meet 3:1 contrast. - * * ### Density * - * Swatch groups come in 3 densities: regular (default), compact, and spacious. Compact and spacious densities retain the same swatch size as regular density, but have less or more padding between each swatch, respectively. + * Swatch groups come in several densities: regular (default), compact and spacious. Each density retains the same swatch size, but have less or more padding between each swatch, respectively. */ export default { title: "Swatch group", @@ -36,7 +32,10 @@ export default { shape: { table: { disable: true } }, imageUrl: { table: { disable: true } }, isMixedValue: { table: { disable: true } }, - gradient: { table: { disable: true } }, + isKeyboardFocused: { table: { disable: true } }, + isDisabled: { table: { disable: true } }, + isSelected: { table: { disable: true } }, + isAddSwatch: { table: { disable: true } }, density: { name: "Density", type: { name: "string" }, @@ -65,27 +64,13 @@ export default { defaultValue: { summary: "none", }, }, }, - borderStyle: { - ...Swatch.argTypes.borderStyle, - defaultValue: "noBorder", - description: "Apply the `spectrum-Swatch--lightBorder` class to a swatch in the swatch group when it has a color contrast ratio of less than 3:1.", - table: { - type: { summary: "string", required: true }, - category: "Component", - defaultValue: { summary: "noBorder" }, - }, - options: ["noBorder", "lightBorder"], - }, }, args: { rootClass: "spectrum-SwatchGroup", - size: "m", + containerWidth: "200px", density: "regular", + size: "m", rounding: "none", - borderStyle: "noBorder", - containerWidth: "200px", - isDisabled: false, - isSelected: false, items: [ {swatchColor: "rgb(184, 109, 70)",}, {swatchColor: "rgb(240, 56, 35)",}, @@ -118,11 +103,15 @@ export default { }, packageJson, metadata, + status: { + type: "migrated", + }, }, + tags: ["migrated"], }; /** - * The default swatch group has regular density. + * The default swatch group has medium density. */ export const Default = SwatchgroupGroup.bind({}); Default.args = {}; @@ -136,7 +125,7 @@ Compact.tags = ["!dev"]; Compact.parameters = { chromatic: { disableSnapshot: true }, }; -Compact.storyName = "Density - Compact"; +Compact.storyName = "Density - compact"; export const Spacious = Template.bind({}); Spacious.args = { @@ -146,7 +135,7 @@ Spacious.tags = ["!dev"]; Spacious.parameters = { chromatic: { disableSnapshot: true }, }; -Spacious.storyName = "Density - Spacious"; +Spacious.storyName = "Density - spacious"; /** * Only use rounded swatches if there is a single row. @@ -180,40 +169,6 @@ Sizing.parameters = { chromatic: { disableSnapshot: true }, }; -/** - * When swatches within a swatch group have low contrast (below 3:1 contrast with the background), the `.spectrum-Swatch--lightBorder` class should be applied to those swatches only. - * - * The swatch group example below contains all swatches with low contrast in light mode, therefore each has the `.spectrum-Swatch--lightBorder` class applied. - */ -export const WithLightBorder = Template.bind({}); -WithLightBorder.args = { - borderStyle: "lightBorder", - items: [ - {swatchColor: "rgb(237, 196, 172)"}, - {swatchColor: "rgb(255, 188, 180)"}, - {swatchColor: "rgb(255, 193, 94)"}, - {swatchColor: "rgb(245, 199, 0)"}, - {swatchColor: "rgb(229, 200, 157)"}, - {swatchColor: "rgb(182, 219, 0)"}, - {swatchColor: "rgb(129, 228, 58)"}, - {swatchColor: "rgb(107, 227, 162)"}, - {swatchColor: "rgb(92, 225, 194)"}, - {swatchColor: "rgb(111, 221, 228)"}, - {swatchColor: "rgb(138, 213, 255)"}, - {swatchColor: "rgb(172, 207, 253)"}, - {swatchColor: "rgb(192, 201, 255)"}, - {swatchColor: "rgb(221, 193, 246)"}, - {swatchColor: "rgb(247, 181, 255)"}, - {swatchColor: "rgb(255, 181, 230)"}, - {swatchColor: "rgb(255, 185, 208)"}, - ], -}; -WithLightBorder.tags = ["!dev"]; -WithLightBorder.storyName = "With light border"; -WithLightBorder.parameters = { - chromatic: { disableSnapshot: true }, -}; - // ********* VRT ONLY ********* // export const WithForcedColors = SwatchgroupGroup.bind({}); WithForcedColors.tags = ["!autodocs", "!dev"]; diff --git a/components/swatchgroup/stories/swatchgroup.test.js b/components/swatchgroup/stories/swatchgroup.test.js index fb182c67163..2f43e371043 100644 --- a/components/swatchgroup/stories/swatchgroup.test.js +++ b/components/swatchgroup/stories/swatchgroup.test.js @@ -5,46 +5,23 @@ export const SwatchgroupGroup = Variants({ Template, testData: [ { - testHeading: "Default", + testHeading: "Default (regular density)", }, { - testHeading: "Compact", + testHeading: "Compact density", density: "compact", }, { - testHeading: "Spacious", + testHeading: "Spacious density", density: "spacious", }, { - testHeading: "Full rounding", + testHeading: "Full rounding (regular density)", rounding: "full", }, { - testHeading: "Regular rounding", + testHeading: "Regular rounding (regular density)", rounding: "regular", }, - { - testHeading: "With light borders", - borderStyle: "lightBorder", - items: [ - {swatchColor: "rgb(237, 196, 172)"}, - {swatchColor: "rgb(255, 188, 180)"}, - {swatchColor: "rgb(255, 193, 94)"}, - {swatchColor: "rgb(245, 199, 0)"}, - {swatchColor: "rgb(229, 200, 157)"}, - {swatchColor: "rgb(182, 219, 0)"}, - {swatchColor: "rgb(129, 228, 58)"}, - {swatchColor: "rgb(107, 227, 162)"}, - {swatchColor: "rgb(92, 225, 194)"}, - {swatchColor: "rgb(111, 221, 228)"}, - {swatchColor: "rgb(138, 213, 255)"}, - {swatchColor: "rgb(172, 207, 253)"}, - {swatchColor: "rgb(192, 201, 255)"}, - {swatchColor: "rgb(221, 193, 246)"}, - {swatchColor: "rgb(247, 181, 255)"}, - {swatchColor: "rgb(255, 181, 230)"}, - {swatchColor: "rgb(255, 185, 208)"}, - ], - }, ], }); diff --git a/components/swatchgroup/stories/template.js b/components/swatchgroup/stories/template.js index 01c059998bd..f42b3fe0908 100644 --- a/components/swatchgroup/stories/template.js +++ b/components/swatchgroup/stories/template.js @@ -12,13 +12,10 @@ export const Template = ({ customClasses = [], size = "m", density = "regular", - rounding = "regular", - borderStyle = "noBorder", + rounding = "none", containerWidth, items = [], customStyles = {}, - isDisabled =false, - isSelected = false, id = getRandomId("swatchgroup"), } = {}, context = {}) => html`
Swatch({ size, rounding, - isDisabled, - isSelected, - borderStyle, ...swatch, }, context))}
diff --git a/components/switch/CHANGELOG.md b/components/switch/CHANGELOG.md index 215e3ab5753..d294db1533c 100644 --- a/components/switch/CHANGELOG.md +++ b/components/switch/CHANGELOG.md @@ -1,5 +1,33 @@ # Change log +## 7.0.0-next.2 + +### Major Changes + +📝 [#4014](https://github.com/adobe/spectrum-css/pull/4014) [`35c066b`](https://github.com/adobe/spectrum-css/commit/35c066b29c311b1bfcf4507075f13b41222ffc84) Thanks [@castastrophe](https://github.com/castastrophe)! + +This update removes the `dir` attribute polyfill (served via a PostCSS transform to compiled assets) as the fallback is no longer necessary. The`dir` attribute support is available in all supported browsers and has been tested to correctly inherit inside web component shadow DOMs. This is a breaking change **only** to those relying on the `dir` attribute being present for styling, however, the `:dir` pseudo will correctly inherit values from their containers. To correctly determine the `dir` value of a node using JavaScript, you can use `getComputedStyle(node).direction`. + +## 7.0.0-next.1 + +### Patch Changes + +- [#3687](https://github.com/adobe/spectrum-css/pull/3687) [`53d1e5e`](https://github.com/adobe/spectrum-css/commit/53d1e5e7eb7817c37be3cfe5a253363dea744046) Thanks [@marissahuysentruyt](https://github.com/marissahuysentruyt)! - ### S2 switch fixes + + This work addresses minor regressions in the Switch component. Animation tokens are reimplemented and their usage updated within the style definitions. + + Reference: + - [S2 switch migration](https://github.com/adobe/spectrum-css/pull/2651) + +- [#3767](https://github.com/adobe/spectrum-css/pull/3767) [`ca78d52`](https://github.com/adobe/spectrum-css/commit/ca78d52408730381f6dd41567c980bdfc5697022) Thanks [@saashapina](https://github.com/saashapina)! - Fix active down state specificity by increasing the specificity of the active state selector. This change was necessary because the `postcss-hover-media-feature` plugin converts hover styles into a media query for devices that support hover. Without this adjustment, the hover styles could override the active down state styles due to the way CSS specificity and order are handled. By adding the additional `.spectrum-Switch` class in the active state selector, we ensure that the active state takes precedence over the hover state, maintaining the correct visual behavior of the switch component across different interaction states. + +## 7.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + ## 6.2.0 ### Minor Changes diff --git a/components/switch/dist/metadata.json b/components/switch/dist/metadata.json index 00a47cdd798..03beda3b924 100644 --- a/components/switch/dist/metadata.json +++ b/components/switch/dist/metadata.json @@ -2,86 +2,71 @@ "sourceFile": "index.css", "selectors": [ ".spectrum-Switch", + ".spectrum-Switch .spectrum-Switch-input:disabled + .spectrum-Switch-switch", + ".spectrum-Switch .spectrum-Switch-input:disabled + .spectrum-Switch-switch:before", ".spectrum-Switch .spectrum-Switch-input:disabled ~ .spectrum-Switch-label", ".spectrum-Switch .spectrum-Switch-input:disabled:checked + .spectrum-Switch-switch", ".spectrum-Switch .spectrum-Switch-input:disabled:checked + .spectrum-Switch-switch:before", - ".spectrum-Switch .spectrum-Switch-input:disabled:not(:checked) + .spectrum-Switch-switch", - ".spectrum-Switch .spectrum-Switch-input:disabled:not(:checked) + .spectrum-Switch-switch:before", - ".spectrum-Switch .spectrum-Switch-input:focus-visible + .spectrum-Switch-switch:after", - ".spectrum-Switch .spectrum-Switch-input:focus-visible + .spectrum-Switch-switch:before", - ".spectrum-Switch .spectrum-Switch-input:focus-visible ~ .spectrum-Switch-label", - ".spectrum-Switch .spectrum-Switch-input:focus-visible:checked + .spectrum-Switch-switch", - ".spectrum-Switch .spectrum-Switch-input:focus-visible:checked + .spectrum-Switch-switch:before", - ".spectrum-Switch .spectrum-Switch-input:not(:checked) + .spectrum-Switch-switch", + ".spectrum-Switch .spectrum-Switch-input[disabled] + .spectrum-Switch-switch", + ".spectrum-Switch .spectrum-Switch-input[disabled] + .spectrum-Switch-switch:before", ".spectrum-Switch .spectrum-Switch-input[disabled] ~ .spectrum-Switch-label", ".spectrum-Switch .spectrum-Switch-input[disabled]:checked + .spectrum-Switch-switch", ".spectrum-Switch .spectrum-Switch-input[disabled]:checked + .spectrum-Switch-switch:before", - ".spectrum-Switch .spectrum-Switch-input[disabled]:not(:checked) + .spectrum-Switch-switch", - ".spectrum-Switch .spectrum-Switch-input[disabled]:not(:checked) + .spectrum-Switch-switch:before", - ".spectrum-Switch .spectrum-Switch-switch", - ".spectrum-Switch .spectrum-Switch-switch:before", + ".spectrum-Switch--active .spectrum-Switch-input:checked + .spectrum-Switch-switch", + ".spectrum-Switch--active .spectrum-Switch-input:checked + .spectrum-Switch-switch:before", + ".spectrum-Switch--active .spectrum-Switch-input:not(:disabled) + .spectrum-Switch-switch:before", + ".spectrum-Switch--active .spectrum-Switch-input:not(:disabled):checked + .spectrum-Switch-switch:before", + ".spectrum-Switch--active .spectrum-Switch-input:not(:disabled):checked + .spectrum-Switch-switch:before:dir(rtl)", ".spectrum-Switch--disabled", ".spectrum-Switch--sizeL", - ".spectrum-Switch--sizeM", ".spectrum-Switch--sizeS", ".spectrum-Switch--sizeXL", ".spectrum-Switch-input", ".spectrum-Switch-input:checked + .spectrum-Switch-switch", ".spectrum-Switch-input:checked + .spectrum-Switch-switch:before", - ".spectrum-Switch-input:checked + .spectrum-Switch-switch:dir(rtl):before", + ".spectrum-Switch-input:checked + .spectrum-Switch-switch:before:dir(rtl)", + ".spectrum-Switch-input:checked:focus-visible + .spectrum-Switch-switch", ".spectrum-Switch-input:disabled", - ".spectrum-Switch-input:disabled + .spectrum-Switch-switch", - ".spectrum-Switch-input:disabled + .spectrum-Switch-switch:before", - ".spectrum-Switch-input:disabled ~ .spectrum-Switch-label", - ".spectrum-Switch-input:disabled:checked + .spectrum-Switch-switch", - ".spectrum-Switch-input:disabled:checked + .spectrum-Switch-switch:before", + ".spectrum-Switch-input:focus-visible + .spectrum-Switch-switch", ".spectrum-Switch-input:focus-visible + .spectrum-Switch-switch:after", + ".spectrum-Switch-input:focus-visible + .spectrum-Switch-switch:before", + ".spectrum-Switch-input:focus-visible ~ .spectrum-Switch-label", ".spectrum-Switch-input[disabled]", - ".spectrum-Switch-input[disabled] + .spectrum-Switch-switch", - ".spectrum-Switch-input[disabled] + .spectrum-Switch-switch:before", - ".spectrum-Switch-input[disabled] ~ .spectrum-Switch-label", - ".spectrum-Switch-input[disabled]:checked + .spectrum-Switch-switch", - ".spectrum-Switch-input[disabled]:checked + .spectrum-Switch-switch:before", ".spectrum-Switch-label", + ".spectrum-Switch-label:lang(ja)", + ".spectrum-Switch-label:lang(ko)", + ".spectrum-Switch-label:lang(zh)", ".spectrum-Switch-switch", + ".spectrum-Switch-switch .spectrum-Switch--active", ".spectrum-Switch-switch:after", ".spectrum-Switch-switch:before", ".spectrum-Switch.spectrum-Switch--emphasized", - ".spectrum-Switch:active .spectrum-Switch-input + .spectrum-Switch-switch:before", - ".spectrum-Switch:active .spectrum-Switch-input ~ .spectrum-Switch-label", - ".spectrum-Switch:active .spectrum-Switch-input:checked:enabled + .spectrum-Switch-switch", - ".spectrum-Switch:active .spectrum-Switch-input:checked:enabled + .spectrum-Switch-switch:before", - ".spectrum-Switch:hover .spectrum-Switch-input + .spectrum-Switch-switch:before", - ".spectrum-Switch:hover .spectrum-Switch-input ~ .spectrum-Switch-label", - ".spectrum-Switch:hover .spectrum-Switch-input:checked:enabled + .spectrum-Switch-switch", - ".spectrum-Switch:hover .spectrum-Switch-input:checked:enabled + .spectrum-Switch-switch:before", + ".spectrum-Switch.spectrum-Switch:active .spectrum-Switch-input:checked + .spectrum-Switch-switch", + ".spectrum-Switch.spectrum-Switch:active .spectrum-Switch-input:checked + .spectrum-Switch-switch:before", + ".spectrum-Switch.spectrum-Switch:active .spectrum-Switch-switch", + ".spectrum-Switch.spectrum-Switch:active .spectrum-Switch-switch:before", + ".spectrum-Switch:active .spectrum-Switch-input:not(:disabled) + .spectrum-Switch-switch:before", + ".spectrum-Switch:active .spectrum-Switch-input:not(:disabled):checked + .spectrum-Switch-switch:before", + ".spectrum-Switch:active .spectrum-Switch-input:not(:disabled):checked + .spectrum-Switch-switch:before:dir(rtl)", + ".spectrum-Switch:active ~ .spectrum-Switch-label", + ".spectrum-Switch:hover .spectrum-Switch-input:checked + .spectrum-Switch-switch", + ".spectrum-Switch:hover .spectrum-Switch-input:checked + .spectrum-Switch-switch:before", ".spectrum-Switch:hover .spectrum-Switch-input:disabled + .spectrum-Switch-switch", ".spectrum-Switch:hover .spectrum-Switch-input:disabled + .spectrum-Switch-switch:before", ".spectrum-Switch:hover .spectrum-Switch-input:disabled ~ .spectrum-Switch-label", ".spectrum-Switch:hover .spectrum-Switch-input:disabled:checked + .spectrum-Switch-switch", ".spectrum-Switch:hover .spectrum-Switch-input:disabled:checked + .spectrum-Switch-switch:before", - ".spectrum-Switch:hover .spectrum-Switch-input:disabled:checked ~ .spectrum-Switch-label", - ".spectrum-Switch:hover .spectrum-Switch-input:focus-visible + .spectrum-Switch-switch:after", - ".spectrum-Switch:hover .spectrum-Switch-input:focus-visible + .spectrum-Switch-switch:before", - ".spectrum-Switch:hover .spectrum-Switch-input:focus-visible ~ .spectrum-Switch-label", - ".spectrum-Switch:hover .spectrum-Switch-input:focus-visible:checked + .spectrum-Switch-switch", - ".spectrum-Switch:hover .spectrum-Switch-input:focus-visible:checked + .spectrum-Switch-switch:before", - ".spectrum-Switch:hover .spectrum-Switch-input:not(:checked) + .spectrum-Switch-switch", ".spectrum-Switch:hover .spectrum-Switch-input[disabled] + .spectrum-Switch-switch", ".spectrum-Switch:hover .spectrum-Switch-input[disabled] + .spectrum-Switch-switch:before", ".spectrum-Switch:hover .spectrum-Switch-input[disabled] ~ .spectrum-Switch-label", ".spectrum-Switch:hover .spectrum-Switch-input[disabled]:checked + .spectrum-Switch-switch", ".spectrum-Switch:hover .spectrum-Switch-input[disabled]:checked + .spectrum-Switch-switch:before", - ".spectrum-Switch:hover .spectrum-Switch-input[disabled]:checked ~ .spectrum-Switch-label", - "[dir=\"rtl\"] .spectrum-Switch-input:checked + .spectrum-Switch-switch:before" + ".spectrum-Switch:hover .spectrum-Switch-switch", + ".spectrum-Switch:hover .spectrum-Switch-switch:before", + ".spectrum-Switch:hover ~ .spectrum-Switch-label" ], "modifiers": [ - "--mod-animation-duration-100", - "--mod-animation-duration-200", - "--mod-border-width-200", - "--mod-focus-indicator-gap", - "--mod-focus-indicator-thickness", - "--mod-line-height-100", + "--mod-switch-animation-duration-switch", "--mod-switch-background-color", "--mod-switch-background-color-disabled", "--mod-switch-background-color-selected-default", @@ -89,32 +74,48 @@ "--mod-switch-background-color-selected-down", "--mod-switch-background-color-selected-focus", "--mod-switch-background-color-selected-hover", + "--mod-switch-border-color-default", + "--mod-switch-border-color-disabled", + "--mod-switch-border-color-down", + "--mod-switch-border-color-focus", + "--mod-switch-border-color-hover", + "--mod-switch-border-color-selected-default", + "--mod-switch-border-color-selected-down", + "--mod-switch-border-color-selected-focus", + "--mod-switch-border-color-selected-hover", + "--mod-switch-border-radius", + "--mod-switch-border-width", + "--mod-switch-cjk-line-height", "--mod-switch-control-height", "--mod-switch-control-label-spacing", "--mod-switch-control-width", "--mod-switch-focus-indicator-color", + "--mod-switch-focus-indicator-gap", "--mod-switch-focus-indicator-thickness", "--mod-switch-font-size", - "--mod-switch-handle-background-color", - "--mod-switch-handle-border-color-default", - "--mod-switch-handle-border-color-disabled", - "--mod-switch-handle-border-color-down", - "--mod-switch-handle-border-color-focus", - "--mod-switch-handle-border-color-hover", - "--mod-switch-handle-border-color-selected-default", - "--mod-switch-handle-border-color-selected-down", - "--mod-switch-handle-border-color-selected-focus", - "--mod-switch-handle-border-color-selected-hover", + "--mod-switch-handle-background-color-default", + "--mod-switch-handle-background-color-disabled", + "--mod-switch-handle-background-color-down", + "--mod-switch-handle-background-color-focus", + "--mod-switch-handle-background-color-hover", + "--mod-switch-handle-background-color-selected", + "--mod-switch-handle-background-color-selected-disabled", + "--mod-switch-handle-selected-size", + "--mod-switch-handle-size", "--mod-switch-height", "--mod-switch-label-color-default", "--mod-switch-label-color-disabled", "--mod-switch-label-color-down", "--mod-switch-label-color-focus", "--mod-switch-label-color-hover", + "--mod-switch-line-height", + "--mod-switch-spacing-bottom-to-label", "--mod-switch-spacing-top-to-control", "--mod-switch-spacing-top-to-label" ], "component": [ + "--spectrum-switch-animation-duration-label", + "--spectrum-switch-animation-duration-switch", "--spectrum-switch-background-color", "--spectrum-switch-background-color-disabled", "--spectrum-switch-background-color-selected-default", @@ -122,6 +123,18 @@ "--spectrum-switch-background-color-selected-down", "--spectrum-switch-background-color-selected-focus", "--spectrum-switch-background-color-selected-hover", + "--spectrum-switch-border-color-default", + "--spectrum-switch-border-color-disabled", + "--spectrum-switch-border-color-down", + "--spectrum-switch-border-color-focus", + "--spectrum-switch-border-color-hover", + "--spectrum-switch-border-color-selected-default", + "--spectrum-switch-border-color-selected-down", + "--spectrum-switch-border-color-selected-focus", + "--spectrum-switch-border-color-selected-hover", + "--spectrum-switch-border-radius", + "--spectrum-switch-border-width", + "--spectrum-switch-cjk-line-height", "--spectrum-switch-control-height", "--spectrum-switch-control-height-extra-large", "--spectrum-switch-control-height-large", @@ -134,24 +147,34 @@ "--spectrum-switch-control-width-medium", "--spectrum-switch-control-width-small", "--spectrum-switch-focus-indicator-color", + "--spectrum-switch-focus-indicator-gap", "--spectrum-switch-focus-indicator-thickness", "--spectrum-switch-font-size", - "--spectrum-switch-handle-background-color", - "--spectrum-switch-handle-border-color-default", - "--spectrum-switch-handle-border-color-disabled", - "--spectrum-switch-handle-border-color-down", - "--spectrum-switch-handle-border-color-focus", - "--spectrum-switch-handle-border-color-hover", - "--spectrum-switch-handle-border-color-selected-default", - "--spectrum-switch-handle-border-color-selected-down", - "--spectrum-switch-handle-border-color-selected-focus", - "--spectrum-switch-handle-border-color-selected-hover", + "--spectrum-switch-handle-background-color-default", + "--spectrum-switch-handle-background-color-disabled", + "--spectrum-switch-handle-background-color-down", + "--spectrum-switch-handle-background-color-focus", + "--spectrum-switch-handle-background-color-hover", + "--spectrum-switch-handle-background-color-selected", + "--spectrum-switch-handle-background-color-selected-disabled", + "--spectrum-switch-handle-selected-size", + "--spectrum-switch-handle-selected-size-extra-large", + "--spectrum-switch-handle-selected-size-large", + "--spectrum-switch-handle-selected-size-medium", + "--spectrum-switch-handle-selected-size-small", + "--spectrum-switch-handle-size", + "--spectrum-switch-handle-size-extra-large", + "--spectrum-switch-handle-size-large", + "--spectrum-switch-handle-size-medium", + "--spectrum-switch-handle-size-small", "--spectrum-switch-label-color-default", "--spectrum-switch-label-color-disabled", "--spectrum-switch-label-color-down", "--spectrum-switch-label-color-focus", "--spectrum-switch-label-color-hover", + "--spectrum-switch-line-height", "--spectrum-switch-min-height", + "--spectrum-switch-spacing-bottom-to-label", "--spectrum-switch-spacing-top-to-control", "--spectrum-switch-spacing-top-to-label", "--spectrum-switch-top-to-control-extra-large", @@ -160,20 +183,29 @@ "--spectrum-switch-top-to-control-small" ], "global": [ - "--spectrum-accent-color-1000", - "--spectrum-accent-color-1100", - "--spectrum-accent-color-900", + "--spectrum-accent-background-color-default", + "--spectrum-accent-background-color-down", + "--spectrum-accent-background-color-hover", + "--spectrum-accent-background-color-key-focus", "--spectrum-animation-duration-100", "--spectrum-animation-duration-200", "--spectrum-border-width-200", + "--spectrum-cjk-line-height-100", + "--spectrum-component-bottom-to-text-100", + "--spectrum-component-bottom-to-text-200", + "--spectrum-component-bottom-to-text-300", + "--spectrum-component-bottom-to-text-75", "--spectrum-component-height-100", "--spectrum-component-height-200", "--spectrum-component-height-300", "--spectrum-component-height-75", + "--spectrum-component-size-difference-down", + "--spectrum-component-size-minimum-perspective-down", "--spectrum-component-top-to-text-100", "--spectrum-component-top-to-text-200", "--spectrum-component-top-to-text-300", "--spectrum-component-top-to-text-75", + "--spectrum-corner-radius-full", "--spectrum-disabled-content-color", "--spectrum-focus-indicator-color", "--spectrum-focus-indicator-gap", @@ -182,17 +214,12 @@ "--spectrum-font-size-200", "--spectrum-font-size-300", "--spectrum-font-size-75", - "--spectrum-gray-200", - "--spectrum-gray-50", - "--spectrum-gray-600", - "--spectrum-gray-700", - "--spectrum-gray-800", - "--spectrum-gray-900", + "--spectrum-gray-25", "--spectrum-line-height-100", - "--spectrum-neutral-background-color-selected-default", - "--spectrum-neutral-background-color-selected-down", - "--spectrum-neutral-background-color-selected-hover", - "--spectrum-neutral-background-color-selected-key-focus", + "--spectrum-neutral-background-color-default", + "--spectrum-neutral-background-color-down", + "--spectrum-neutral-background-color-hover", + "--spectrum-neutral-background-color-key-focus", "--spectrum-neutral-content-color-default", "--spectrum-neutral-content-color-down", "--spectrum-neutral-content-color-hover", @@ -202,38 +229,32 @@ "--spectrum-text-to-control-300", "--spectrum-text-to-control-75" ], - "system-theme": [ - "--system-switch-background-color", - "--system-switch-background-color-disabled", - "--system-switch-handle-background-color", - "--system-switch-handle-border-color-default", - "--system-switch-handle-border-color-down", - "--system-switch-handle-border-color-focus", - "--system-switch-handle-border-color-hover", - "--system-switch-handle-border-color-selected-default", - "--system-switch-handle-border-color-selected-down", - "--system-switch-handle-border-color-selected-focus", - "--system-switch-handle-border-color-selected-hover" - ], "passthroughs": [], "high-contrast": [ "--highcontrast-switch-background-color", + "--highcontrast-switch-background-color-disabled", "--highcontrast-switch-background-color-selected-default", "--highcontrast-switch-background-color-selected-disabled", "--highcontrast-switch-background-color-selected-down", "--highcontrast-switch-background-color-selected-focus", "--highcontrast-switch-background-color-selected-hover", + "--highcontrast-switch-border-color-default", + "--highcontrast-switch-border-color-disabled", + "--highcontrast-switch-border-color-down", + "--highcontrast-switch-border-color-focus", + "--highcontrast-switch-border-color-hover", + "--highcontrast-switch-border-color-selected-default", + "--highcontrast-switch-border-color-selected-down", + "--highcontrast-switch-border-color-selected-focus", + "--highcontrast-switch-border-color-selected-hover", "--highcontrast-switch-focus-indicator-color", - "--highcontrast-switch-handle-background-color", - "--highcontrast-switch-handle-border-color-default", - "--highcontrast-switch-handle-border-color-disabled", - "--highcontrast-switch-handle-border-color-down", - "--highcontrast-switch-handle-border-color-focus", - "--highcontrast-switch-handle-border-color-hover", - "--highcontrast-switch-handle-border-color-selected-default", - "--highcontrast-switch-handle-border-color-selected-down", - "--highcontrast-switch-handle-border-color-selected-focus", - "--highcontrast-switch-handle-border-color-selected-hover", + "--highcontrast-switch-handle-background-color-default", + "--highcontrast-switch-handle-background-color-disabled", + "--highcontrast-switch-handle-background-color-down", + "--highcontrast-switch-handle-background-color-focus", + "--highcontrast-switch-handle-background-color-hover", + "--highcontrast-switch-handle-background-color-selected", + "--highcontrast-switch-handle-background-color-selected-disabled", "--highcontrast-switch-label-color-default", "--highcontrast-switch-label-color-disabled", "--highcontrast-switch-label-color-down", diff --git a/components/switch/index.css b/components/switch/index.css index 763ad359ab8..f5d230cb767 100644 --- a/components/switch/index.css +++ b/components/switch/index.css @@ -1,5 +1,5 @@ /*! - * Copyright 2024 Adobe. All rights reserved. + * Copyright 2025 Adobe. All rights reserved. * * This file is licensed to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. You may obtain a copy @@ -11,8 +11,6 @@ * governing permissions and limitations under the License. */ -@import "./themes/spectrum-two.css"; - .spectrum-Switch { --spectrum-switch-label-color-default: var(--spectrum-neutral-content-color-default); --spectrum-switch-label-color-hover: var(--spectrum-neutral-content-color-hover); @@ -20,49 +18,77 @@ --spectrum-switch-label-color-focus: var(--spectrum-neutral-content-color-key-focus); --spectrum-switch-label-color-disabled: var(--spectrum-disabled-content-color); - --spectrum-switch-background-color-selected-default: var(--spectrum-neutral-background-color-selected-default); - --spectrum-switch-background-color-selected-hover: var(--spectrum-neutral-background-color-selected-hover); - --spectrum-switch-background-color-selected-down: var(--spectrum-neutral-background-color-selected-down); - --spectrum-switch-background-color-selected-focus: var(--spectrum-neutral-background-color-selected-key-focus); + --spectrum-switch-border-width: var(--spectrum-border-width-200); + + --spectrum-switch-border-color-default: var(--spectrum-neutral-content-color-default); + --spectrum-switch-border-color-hover: var(--spectrum-neutral-content-color-hover); + --spectrum-switch-border-color-down: var(--spectrum-neutral-content-color-down); + --spectrum-switch-border-color-focus: var(--spectrum-neutral-content-color-key-focus); + --spectrum-switch-border-color-disabled: var(--spectrum-disabled-content-color); + + --spectrum-switch-border-color-selected-default: var(--spectrum-neutral-content-color-default); + --spectrum-switch-border-color-selected-hover: var(--spectrum-neutral-content-color-hover); + --spectrum-switch-border-color-selected-down: var(--spectrum-neutral-content-color-down); + --spectrum-switch-border-color-selected-focus: var(--spectrum-neutral-content-color-key-focus); + + --spectrum-switch-background-color: var(--spectrum-gray-25); + --spectrum-switch-background-color-disabled: var(--spectrum-gray-25); + + --spectrum-switch-background-color-selected-default: var(--spectrum-neutral-background-color-default); + --spectrum-switch-background-color-selected-hover: var(--spectrum-neutral-background-color-hover); + --spectrum-switch-background-color-selected-down: var(--spectrum-neutral-background-color-down); + --spectrum-switch-background-color-selected-focus: var(--spectrum-neutral-background-color-key-focus); --spectrum-switch-background-color-selected-disabled: var(--spectrum-disabled-content-color); - --spectrum-switch-focus-indicator-thickness: var(--mod-focus-indicator-thickness, var(--spectrum-focus-indicator-thickness)); + --spectrum-switch-focus-indicator-thickness: var(--spectrum-focus-indicator-thickness); --spectrum-switch-focus-indicator-color: var(--spectrum-focus-indicator-color); - --spectrum-switch-handle-border-color-disabled: var(--spectrum-disabled-content-color); -} + --spectrum-switch-focus-indicator-gap: var(--spectrum-focus-indicator-gap); -.spectrum-Switch--disabled { - --spectrum-switch-label-color-default: var(--spectrum-disabled-content-color); -} + --spectrum-switch-handle-background-color-default: var(--spectrum-neutral-content-color-default); + --spectrum-switch-handle-background-color-hover: var(--spectrum-neutral-content-color-hover); + --spectrum-switch-handle-background-color-down: var(--spectrum-neutral-content-color-down); + --spectrum-switch-handle-background-color-focus: var(--spectrum-neutral-content-color-key-focus); + --spectrum-switch-handle-background-color-disabled: var(--spectrum-disabled-content-color); -.spectrum-Switch.spectrum-Switch--emphasized { - /* - Selector specificity needed to beat the cascade, post-build. - The `spectrum` & `express` theme vars get appended below this in the dist file - & the higher specificity here will override. - */ - /* selected + emphasized */ - --spectrum-switch-background-color-selected-default: var(--spectrum-accent-color-900); - --spectrum-switch-background-color-selected-hover: var(--spectrum-accent-color-1000); - --spectrum-switch-background-color-selected-down: var(--spectrum-accent-color-1100); - --spectrum-switch-background-color-selected-focus: var(--spectrum-accent-color-1000); - - --spectrum-switch-handle-border-color-selected-default: var(--spectrum-accent-color-900); - --spectrum-switch-handle-border-color-selected-hover: var(--spectrum-accent-color-1000); - --spectrum-switch-handle-border-color-selected-down: var(--spectrum-accent-color-1100); - --spectrum-switch-handle-border-color-selected-focus: var(--spectrum-accent-color-1000); -} + --spectrum-switch-handle-background-color-selected: var(--spectrum-gray-25); + --spectrum-switch-handle-background-color-selected-disabled: var(--spectrum-gray-25); + + --spectrum-switch-handle-size: var(--spectrum-switch-handle-size-medium); + --spectrum-switch-handle-selected-size: var(--spectrum-switch-handle-selected-size-medium); -.spectrum-Switch, -.spectrum-Switch--sizeM { + --spectrum-switch-animation-duration-switch: var(--spectrum-animation-duration-100); + --spectrum-switch-animation-duration-label: var(--spectrum-animation-duration-200); + + /* Default size - medium */ --spectrum-switch-min-height: var(--spectrum-component-height-100); --spectrum-switch-control-width: var(--spectrum-switch-control-width-medium); --spectrum-switch-control-height: var(--spectrum-switch-control-height-medium); --spectrum-switch-control-label-spacing: var(--spectrum-text-to-control-100); --spectrum-switch-spacing-top-to-control: var(--spectrum-switch-top-to-control-medium); --spectrum-switch-spacing-top-to-label: var(--spectrum-component-top-to-text-100); + --spectrum-switch-spacing-bottom-to-label: var(--spectrum-component-bottom-to-text-100); --spectrum-switch-font-size: var(--spectrum-font-size-100); + --spectrum-switch-line-height: var(--spectrum-line-height-100); + --spectrum-switch-cjk-line-height: var(--spectrum-cjk-line-height-100); + + --spectrum-switch-border-radius: var(--spectrum-corner-radius-full); +} + +.spectrum-Switch--disabled { + --spectrum-switch-label-color-default: var(--spectrum-disabled-content-color); +} + +.spectrum-Switch.spectrum-Switch--emphasized { + --spectrum-switch-background-color-selected-default: var(--spectrum-accent-background-color-default); + --spectrum-switch-background-color-selected-hover: var(--spectrum-accent-background-color-hover); + --spectrum-switch-background-color-selected-down: var(--spectrum-accent-background-color-down); + --spectrum-switch-background-color-selected-focus: var(--spectrum-accent-background-color-key-focus); + + --spectrum-switch-border-color-selected-default: var(--spectrum-accent-background-color-default); + --spectrum-switch-border-color-selected-hover: var(--spectrum-accent-background-color-hover); + --spectrum-switch-border-color-selected-down: var(--spectrum-accent-background-color-down); + --spectrum-switch-border-color-selected-focus: var(--spectrum-accent-background-color-key-focus); } .spectrum-Switch--sizeS { @@ -72,6 +98,10 @@ --spectrum-switch-control-label-spacing: var(--spectrum-text-to-control-75); --spectrum-switch-spacing-top-to-control: var(--spectrum-switch-top-to-control-small); --spectrum-switch-spacing-top-to-label: var(--spectrum-component-top-to-text-75); + --spectrum-switch-spacing-bottom-to-label: var(--spectrum-component-bottom-to-text-75); + + --spectrum-switch-handle-size: var(--spectrum-switch-handle-size-small); + --spectrum-switch-handle-selected-size: var(--spectrum-switch-handle-selected-size-small); --spectrum-switch-font-size: var(--spectrum-font-size-75); } @@ -83,6 +113,10 @@ --spectrum-switch-control-label-spacing: var(--spectrum-text-to-control-200); --spectrum-switch-spacing-top-to-control: var(--spectrum-switch-top-to-control-large); --spectrum-switch-spacing-top-to-label: var(--spectrum-component-top-to-text-200); + --spectrum-switch-spacing-bottom-to-label: var(--spectrum-component-bottom-to-text-200); + + --spectrum-switch-handle-size: var(--spectrum-switch-handle-size-large); + --spectrum-switch-handle-selected-size: var(--spectrum-switch-handle-selected-size-large); --spectrum-switch-font-size: var(--spectrum-font-size-200); } @@ -94,6 +128,10 @@ --spectrum-switch-control-label-spacing: var(--spectrum-text-to-control-300); --spectrum-switch-spacing-top-to-control: var(--spectrum-switch-top-to-control-extra-large); --spectrum-switch-spacing-top-to-label: var(--spectrum-component-top-to-text-300); + --spectrum-switch-spacing-bottom-to-label: var(--spectrum-component-bottom-to-text-300); + + --spectrum-switch-handle-size: var(--spectrum-switch-handle-size-extra-large); + --spectrum-switch-handle-selected-size: var(--spectrum-switch-handle-selected-size-extra-large); --spectrum-switch-font-size: var(--spectrum-font-size-300); } @@ -108,13 +146,8 @@ } .spectrum-Switch-input { - /* Remove the margin for input in Firefox and Safari. */ margin: 0; - - /* Add the correct box sizing for [type="checkbox"] in IE 10-. */ box-sizing: border-box; - - /* Remove the padding for [type="checkbox"] in IE 10-. */ padding: 0; position: absolute; @@ -127,43 +160,44 @@ cursor: pointer; - &:checked + .spectrum-Switch-switch { - &::before { - transform: translateX(calc(var(--mod-switch-control-width, var(--spectrum-switch-control-width)) - 100%)); - } - - &:dir(rtl)::before { - transform: translateX(calc(-1 * (var(--mod-switch-control-width, var(--spectrum-switch-control-width)) - 100%))); - } - } - &:disabled, &[disabled] { cursor: default; } - - &:focus-visible + .spectrum-Switch-switch { - &::after { - margin: calc(var(--mod-focus-indicator-gap, var(--spectrum-focus-indicator-gap)) * -1); - } - } } .spectrum-Switch-label { color: var(--highcontrast-switch-label-color-default, var(--mod-switch-label-color-default, var(--spectrum-switch-label-color-default))); margin-inline: var(--mod-switch-control-label-spacing, var(--spectrum-switch-control-label-spacing)); margin-block-start: var(--mod-switch-spacing-top-to-label, var(--spectrum-switch-spacing-top-to-label)); - margin-block-end: 0; + margin-block-end: var(--mod-switch-spacing-bottom-to-label, var(--spectrum-switch-spacing-bottom-to-label)); font-size: var(--mod-switch-font-size, var(--spectrum-switch-font-size)); - line-height: var(--mod-line-height-100, var(--spectrum-line-height-100)); - transition: color var(--mod-animation-duration-200, var(--spectrum-animation-duration-200)) ease-in-out; + line-height: var(--mod-switch-line-height, var(--spectrum-switch-line-height)); + transition: color var(--spectrum-switch-animation-duration-label) ease-in-out; + + &:lang(ja), + &:lang(zh), + &:lang(ko) { + line-height: var(--mod-switch-cjk-line-height, var(--spectrum-switch-cjk-line-height)); + } + + .spectrum-Switch:hover ~ & { + color: var(--highcontrast-switch-label-color-hover, var(--mod-switch-label-color-hover, var(--spectrum-switch-label-color-hover))); + } + + .spectrum-Switch:active ~ & { + color: var(--highcontrast-switch-label-color-down, var(--mod-switch-label-color-down, var(--spectrum-switch-label-color-down))); + } + + .spectrum-Switch-input:focus-visible ~ & { + color: var(--highcontrast-switch-label-color-focus, var(--mod-switch-label-color-focus, var(--spectrum-switch-label-color-focus))); + } } .spectrum-Switch-switch { display: inline-block; box-sizing: border-box; - /* positions the pseudo elements relative to this one */ position: relative; inline-size: var(--mod-switch-control-width, var(--spectrum-switch-control-width)); @@ -171,206 +205,173 @@ /* Fix vertical alignment when not wrapping since we're flex-start */ margin-block: calc(var(--mod-switch-height, var(--spectrum-switch-min-height)) - var(--mod-switch-control-height, var(--spectrum-switch-control-height)) - var(--mod-switch-spacing-top-to-control, var(--spectrum-switch-spacing-top-to-control))); margin-inline: 0; - flex-grow: 0; flex-shrink: 0; vertical-align: middle; transition: - background var(--mod-animation-duration-100, var(--spectrum-animation-duration-100)) ease-in-out, - border var(--mod-animation-duration-100, var(--spectrum-animation-duration-100)) ease-in-out; + background var(--mod-switch-animation-duration-switch, var(--spectrum-switch-animation-duration-switch)) ease-in-out, + border var(--mod-switch-animation-duration-switch, var(--spectrum-switch-animation-duration-switch)) ease-in-out; block-size: var(--mod-switch-control-height, var(--spectrum-switch-control-height)); inset-inline-start: 0; inset-inline-end: 0; - border-radius: calc(var(--mod-switch-control-height, var(--spectrum-switch-control-height)) / 2); + background-color: var(--highcontrast-switch-background-color, var(--mod-switch-background-color, var(--spectrum-switch-background-color))); + border-radius: var(--mod-switch-border-radius, var(--spectrum-switch-border-radius)); + border-width: var(--mod-switch-border-width, var(--spectrum-switch-border-width)); + border-color: var(--highcontrast-switch-border-color-default, var(--mod-switch-border-color-default, var(--spectrum-switch-border-color-default))); + border-style: solid; - &::before { - display: block; - position: absolute; - content: ""; - box-sizing: border-box; + .spectrum-Switch:hover & { + border-color: var(--highcontrast-switch-border-color-hover, var(--mod-switch-border-color-hover, var(--spectrum-switch-border-color-hover))); } - /* :before is used for the handle of the switch */ - &::before { - transition: - background var(--mod-animation-duration-100, var(--spectrum-animation-duration-100)) ease-in-out, - border var(--mod-animation-duration-100, var(--spectrum-animation-duration-100)) ease-in-out, - transform var(--mod-animation-duration-100, var(--spectrum-animation-duration-100)) ease-in-out, - box-shadow var(--mod-animation-duration-100, var(--spectrum-animation-duration-100)) ease-in-out; + .spectrum-Switch.spectrum-Switch:active &, + .spectrum-Switch--active { + border-color: var(--highcontrast-switch-border-color-down, var(--mod-switch-border-color-down, var(--spectrum-switch-border-color-down))); + } - inline-size: var(--mod-switch-control-height, var(--spectrum-switch-control-height)); - block-size: var(--mod-switch-control-height, var(--spectrum-switch-control-height)); + .spectrum-Switch-input:focus-visible + & { + border-color: var(--highcontrast-switch-border-color-focus, var(--mod-switch-border-color-focus, var(--spectrum-switch-border-color-focus))); + } - inset-block-start: 0; - inset-inline-start: 0; + .spectrum-Switch-input:checked + & { + background-color: var(--highcontrast-switch-background-color-selected-default, var(--mod-switch-background-color-selected-default, var(--spectrum-switch-background-color-selected-default))); + border-color: var(--highcontrast-switch-border-color-selected-default, var(--mod-switch-border-color-selected-default, var(--spectrum-switch-border-color-selected-default))); - border-width: var(--mod-border-width-200, var(--spectrum-border-width-200)); - border-radius: calc(var(--mod-switch-control-height, var(--spectrum-switch-control-height)) / 2); - border-style: solid; + .spectrum-Switch:hover & { + background-color: var(--highcontrast-switch-background-color-selected-hover, var(--mod-switch-background-color-selected-hover, var(--spectrum-switch-background-color-selected-hover))); + border-color: var(--highcontrast-switch-border-color-selected-hover, var(--mod-switch-border-color-selected-hover, var(--spectrum-switch-border-color-selected-hover))); + } + + /* Added specifity to ensure active state takes precedence over hover media queries */ + .spectrum-Switch.spectrum-Switch:active &, + .spectrum-Switch--active & { + background-color: var(--highcontrast-switch-background-color-selected-down, var(--mod-switch-background-color-selected-down, var(--spectrum-switch-background-color-selected-down))); + border-color: var(--highcontrast-switch-border-color-selected-down, var(--mod-switch-border-color-selected-down, var(--spectrum-switch-border-color-selected-down))); + } } - /* :after is used for the focus halo */ - &::after { - border-radius: calc(calc(var(--mod-switch-control-height, var(--spectrum-switch-control-height)) / 2) + var(--mod-focus-indicator-gap, var(--spectrum-focus-indicator-gap)) * 2); - content: ""; + .spectrum-Switch-input:checked:focus-visible + & { + background-color: var(--highcontrast-switch-background-color-selected-focus, var(--mod-switch-background-color-selected-focus, var(--spectrum-switch-background-color-selected-focus))); + border-color: var(--highcontrast-switch-border-color-selected-focus, var(--mod-switch-border-color-selected-focus, var(--spectrum-switch-border-color-selected-focus))); + } + + /* :before is used for the handle of the switch */ + &::before { display: block; position: absolute; - inset-inline-start: 0; - inset-inline-end: 0; - inset-block-end: 0; - inset-block-start: 0; - margin: 0; + content: ""; + box-sizing: border-box; transition: - opacity var(--mod-animation-duration-100, var(--spectrum-animation-duration-100)) ease-out, - margin var(--spectrum-animation-duration-100, var(--spectrum-animation-duration-100)) ease-out; - } -} + background var(--spectrum-switch-animation-duration-switch) ease-in-out, + border var(--spectrum-switch-animation-duration-switch) ease-in-out, + transform var(--spectrum-switch-animation-duration-switch) ease-in-out, + box-shadow var(--spectrum-switch-animation-duration-switch) ease-in-out; -.spectrum-Switch { - .spectrum-Switch-switch { - background-color: var(--highcontrast-switch-background-color, var(--mod-switch-background-color, var(--spectrum-switch-background-color))); + inline-size: var(--mod-switch-handle-size, var(--spectrum-switch-handle-size)); + block-size: var(--mod-switch-handle-size, var(--spectrum-switch-handle-size)); - &::before { - background-color: var(--highcontrast-switch-handle-background-color, var(--mod-switch-handle-background-color, var(--spectrum-switch-handle-background-color))); - border-color: var(--highcontrast-switch-handle-border-color-default, var(--mod-switch-handle-border-color-default, var(--spectrum-switch-handle-border-color-default))); - } - } -} + inset-block-start: calc((var(--mod-switch-control-height, var(--spectrum-switch-control-height)) - var(--mod-switch-handle-size, var(--spectrum-switch-handle-size))) * 0.25); + inset-inline-start: calc((var(--mod-switch-control-height, var(--spectrum-switch-control-height)) - var(--mod-switch-handle-size, var(--spectrum-switch-handle-size))) * 0.25); -.spectrum-Switch:hover { - .spectrum-Switch-input { - & + .spectrum-Switch-switch { - &::before { - border-color: var(--highcontrast-switch-handle-border-color-hover, var(--mod-switch-handle-border-color-hover, var(--spectrum-switch-handle-border-color-hover))); - box-shadow: none; - } - } + background-color: var(--highcontrast-switch-handle-background-color-default, var(--mod-switch-handle-background-color-default, var(--spectrum-switch-handle-background-color-default))); + border-radius: var(--mod-switch-border-radius, var(--spectrum-switch-border-radius)); - & ~ .spectrum-Switch-label { - color: var(--highcontrast-switch-label-color-hover, var(--mod-switch-label-color-hover, var(--spectrum-switch-label-color-hover))); + .spectrum-Switch:hover & { + background-color: var(--highcontrast-switch-handle-background-color-hover, var(--mod-switch-handle-background-color-hover, var(--spectrum-switch-handle-background-color-hover))); } - /* selected, not emphasized */ - &:checked:enabled + .spectrum-Switch-switch { - background-color: var(--highcontrast-switch-background-color-selected-hover, var(--mod-switch-background-color-selected-hover, var(--spectrum-switch-background-color-selected-hover))); + .spectrum-Switch.spectrum-Switch:active & { + background-color: var(--highcontrast-switch-handle-background-color-down, var(--mod-switch-handle-background-color-down, var(--spectrum-switch-handle-background-color-down))); + } - &::before { - border-color: var(--highcontrast-switch-handle-border-color-selected-hover, var(--mod-switch-handle-border-color-selected-hover, var(--spectrum-switch-handle-border-color-selected-hover))); - } + .spectrum-Switch-input:focus-visible + & { + background-color: var(--highcontrast-switch-handle-background-color-focus, var(--mod-switch-handle-background-color-focus, var(--spectrum-switch-handle-background-color-focus))); } - &:disabled, - &[disabled] { - & + .spectrum-Switch-switch { - background-color: var(--mod-switch-background-color-disabled, var(--spectrum-switch-background-color-disabled)); - } + /* Handle size changes when selected/checked */ + .spectrum-Switch-input:checked + & { + background-color: var(--highcontrast-switch-handle-background-color-selected, var(--mod-switch-handle-background-color-selected, var(--spectrum-switch-handle-background-color-selected))); - & + .spectrum-Switch-switch::before { - border-color: var(--highcontrast-switch-handle-border-color-disabled, var(--mod-switch-handle-border-color-disabled, var(--spectrum-switch-handle-border-color-disabled))); - } + inline-size: var(--mod-switch-handle-selected-size, var(--spectrum-switch-handle-selected-size)); + block-size: var(--mod-switch-handle-selected-size, var(--spectrum-switch-handle-selected-size)); - & ~ .spectrum-Switch-label { - color: var(--highcontrast-switch-label-color-disabled, var(--mod-switch-label-color-disabled, var(--spectrum-switch-label-color-disabled))); - } + inset-block-start: calc((var(--mod-switch-control-height, var(--spectrum-switch-control-height)) - var(--mod-switch-border-width, var(--spectrum-switch-border-width)) - var(--mod-switch-handle-selected-size, var(--spectrum-switch-handle-selected-size))) * 0.25); + inset-inline-start: calc((var(--mod-switch-control-height, var(--spectrum-switch-control-height)) - var(--mod-switch-border-width, var(--spectrum-switch-border-width)) - var(--mod-switch-handle-selected-size, var(--spectrum-switch-handle-selected-size))) * 0.25); - /* disabled + selected, not emphasized */ - &:checked + .spectrum-Switch-switch { - background-color: var(--highcontrast-switch-background-color-selected-disabled, var(--mod-switch-background-color-selected-disabled, var(--spectrum-switch-background-color-selected-disabled))); - } + transform: translateX(calc(100% + (var(--mod-switch-border-width, var(--spectrum-switch-border-width)) * 0.25))); - &:checked + .spectrum-Switch-switch::before { - border-color: var(--highcontrast-switch-handle-border-color-disabled, var(--mod-switch-handle-border-color-disabled, var(--spectrum-switch-handle-border-color-disabled))); + &:dir(rtl) { + transform: translateX(calc(-1 * (100% + (var(--mod-switch-border-width, var(--spectrum-switch-border-width)) * 0.25)))); } - &:checked ~ .spectrum-Switch-label { - color: var(--highcontrast-switch-label-color-disabled, var(--mod-switch-label-color-disabled, var(--spectrum-switch-label-color-disabled))); + .spectrum-Switch:hover & { + background-color: var(--highcontrast-switch-handle-background-color-selected, var(--mod-switch-handle-background-color-selected, var(--spectrum-switch-handle-background-color-selected))); } - } - } -} -.spectrum-Switch:active { - .spectrum-Switch-input { - & + .spectrum-Switch-switch { - &::before { - border-color: var(--highcontrast-switch-handle-border-color-down, var(--mod-switch-handle-border-color-down, var(--spectrum-switch-handle-border-color-down))); + .spectrum-Switch.spectrum-Switch:active &, + .spectrum-Switch--active & { + background-color: var(--spectrum-switch-handle-background-color-selected, var(--mod-switch-handle-background-color-selected, var(--spectrum-switch-handle-background-color-selected))); } } - & ~ .spectrum-Switch-label { - color: var(--highcontrast-switch-label-color-down, var(--mod-switch-label-color-down, var(--spectrum-switch-label-color-down))); + .spectrum-Switch:active .spectrum-Switch-input:not(:disabled) + &, + .spectrum-Switch--active .spectrum-Switch-input:not(:disabled) + & { + transform: perspective(var(--spectrum-component-size-minimum-perspective-down)) translateZ(var(--spectrum-component-size-difference-down)); } - /* selected, not emphasized */ - &:checked:enabled + .spectrum-Switch-switch { - background-color: var(--highcontrast-switch-background-color-selected-down, var(--mod-switch-background-color-selected-down, var(--spectrum-switch-background-color-selected-down))); + .spectrum-Switch:active .spectrum-Switch-input:not(:disabled):checked + &, + .spectrum-Switch--active .spectrum-Switch-input:not(:disabled):checked + & { + /* Add down state without overriding translateX */ + transform: translateX(calc(100% + (var(--mod-switch-border-width, var(--spectrum-switch-border-width)) * 0.25))) perspective(var(--spectrum-component-size-minimum-perspective-down)) translateZ(var(--spectrum-component-size-difference-down)); - &::before { - border-color: var(--highcontrast-switch-handle-border-color-selected-down, var(--mod-switch-handle-border-color-selected-down, var(--spectrum-switch-handle-border-color-selected-down))); + &:dir(rtl) { + /* Add down state without overriding translateX */ + transform: translateX(calc(-1 * (100% + (var(--mod-switch-border-width, var(--spectrum-switch-border-width)) * 0.25)))) perspective(var(--spectrum-component-size-minimum-perspective-down)) translateZ(var(--spectrum-component-size-difference-down)); } } } -} -/* key focus */ -/* :after is the focus ring */ -/* :before is used for the handle of the switch */ -.spectrum-Switch, -.spectrum-Switch:hover { - .spectrum-Switch-input:focus-visible { - & + .spectrum-Switch-switch { - &::after { - box-shadow: 0 0 0 var(--mod-switch-focus-indicator-thickness, var(--spectrum-switch-focus-indicator-thickness)) var(--highcontrast-switch-focus-indicator-color, var(--mod-switch-focus-indicator-color, var(--spectrum-switch-focus-indicator-color))); - } - - &::before { - border-color: var(--highcontrast-switch-handle-border-color-focus, var(--mod-switch-handle-border-color-focus, var(--spectrum-switch-handle-border-color-focus))); - } - } - - /* selected, not emphasized key focus */ - &:checked { - & + .spectrum-Switch-switch { - background-color: var(--highcontrast-switch-background-color-selected-focus, var(--mod-switch-background-color-selected-focus, var(--spectrum-switch-background-color-selected-focus))); - } - - & + .spectrum-Switch-switch::before { - border-color: var(--highcontrast-switch-handle-border-color-selected-focus, var(--mod-switch-handle-border-color-selected-focus, var(--spectrum-switch-handle-border-color-selected-focus))); - } - } - - & ~ .spectrum-Switch-label { - color: var(--highcontrast-switch-label-color-focus, var(--mod-switch-label-color-focus, var(--spectrum-switch-label-color-focus))); - } - } -} + /* :after is used for the track of the switch and the focus */ + &::after { + border-radius: var(--mod-switch-border-radius, var(--spectrum-switch-border-radius)); + content: ""; + display: block; + position: absolute; + inset-inline-start: 0; + inset-inline-end: 0; + inset-block-end: 0; + inset-block-start: 0; + margin: 0; -/* when checked, after transition or set manually */ -.spectrum-Switch-input { - /* selected, not emphasized */ - &:checked + .spectrum-Switch-switch { - background-color: var(--highcontrast-switch-background-color-selected-default, var(--mod-switch-background-color-selected-default, var(--spectrum-switch-background-color-selected-default))); + transition: + opacity var(--spectrum-switch-animation-duration-switch) ease-out, + outline-offset var(--spectrum-switch-animation-duration-switch) ease-out, + border var(--spectrum-switch-animation-duration-switch) ease-in-out; - &::before { - border-color: var(--highcontrast-switch-handle-border-color-selected-default, var(--mod-switch-handle-border-color-selected-default, var(--spectrum-switch-handle-border-color-selected-default))); + .spectrum-Switch-input:focus-visible + & { + outline: var(--mod-switch-focus-indicator-thickness, var(--spectrum-switch-focus-indicator-thickness)) solid var(--highcontrast-switch-focus-indicator-color, var(--mod-switch-focus-indicator-color, var(--spectrum-switch-focus-indicator-color))); + outline-offset: calc(var(--mod-switch-focus-indicator-gap, var(--spectrum-switch-focus-indicator-gap)) + var(--mod-switch-focus-indicator-thickness, var(--spectrum-switch-focus-indicator-thickness))); } } } /* disabled */ -.spectrum-Switch-input:disabled, -.spectrum-Switch-input[disabled] { +.spectrum-Switch .spectrum-Switch-input:disabled, +.spectrum-Switch .spectrum-Switch-input[disabled], +.spectrum-Switch:hover .spectrum-Switch-input:disabled, +.spectrum-Switch:hover .spectrum-Switch-input[disabled] { & + .spectrum-Switch-switch { - background-color: var(--mod-switch-background-color-disabled, var(--spectrum-switch-background-color-disabled)); + background-color: var(--highcontrast-switch-background-color-disabled, var(--mod-switch-background-color-disabled, var(--spectrum-switch-background-color-disabled))); + border-color: var(--highcontrast-switch-border-color-disabled, var(--mod-switch-border-color-disabled, var(--spectrum-switch-border-color-disabled))); &::before { - border-color: var(--highcontrast-switch-handle-border-color-disabled, var(--mod-switch-handle-border-color-disabled, var(--spectrum-switch-handle-border-color-disabled))); + background-color: var(--highcontrast-switch-handle-background-color-disabled, var(--mod-switch-handle-background-color-disabled, var(--spectrum-switch-handle-background-color-disabled))); } } @@ -378,12 +379,11 @@ color: var(--highcontrast-switch-label-color-disabled, var(--mod-switch-label-color-disabled, var(--spectrum-switch-label-color-disabled))); } - /* disabled + selected, not emphasized */ &:checked + .spectrum-Switch-switch { background-color: var(--highcontrast-switch-background-color-selected-disabled, var(--mod-switch-background-color-selected-disabled, var(--spectrum-switch-background-color-selected-disabled))); &::before { - border-color: var(--highcontrast-switch-handle-border-color-disabled, var(--mod-switch-handle-border-color-disabled, var(--spectrum-switch-handle-border-color-disabled))); + background-color: var(--highcontrast-switch-handle-background-color-selected-disabled, var(--mod-switch-handle-background-color-selected-disabled, var(--spectrum-switch-handle-background-color-selected-disabled))); } } @@ -401,83 +401,37 @@ --highcontrast-switch-label-color-focus: ButtonText; --highcontrast-switch-label-color-disabled: GrayText; - --highcontrast-switch-handle-background-color: ButtonFace; + --highcontrast-switch-background-color: transparent; + + --highcontrast-switch-border-color-default: ButtonText; + --highcontrast-switch-border-color-hover: Highlight; + --highcontrast-switch-border-color-down: ButtonText; + --highcontrast-switch-border-color-focus: ButtonText; + --highcontrast-switch-border-color-disabled: GrayText; + + --highcontrast-switch-border-color-selected-default: Highlight; + --highcontrast-switch-border-color-selected-hover: Highlight; + --highcontrast-switch-border-color-selected-down: Highlight; + --highcontrast-switch-border-color-selected-focus: Highlight; + + --highcontrast-switch-handle-background-color-default: ButtonText; + --highcontrast-switch-handle-background-color-hover: Highlight; + --highcontrast-switch-handle-background-color-down: ButtonText; + --highcontrast-switch-handle-background-color-focus: ButtonText; + --highcontrast-switch-handle-background-color-disabled: GrayText; - --highcontrast-switch-handle-border-color-default: ButtonText; - --highcontrast-switch-handle-border-color-hover: Highlight; - --highcontrast-switch-handle-border-color-down: Highlight; - --highcontrast-switch-handle-border-color-focus: Highlight; - --highcontrast-switch-handle-border-color-disabled: Highlight; + --highcontrast-switch-handle-background-color-selected: HighlightText; + --highcontrast-switch-handle-background-color-selected-disabled: ButtonFace; - --highcontrast-switch-handle-border-color-selected-default: Highlight; - --highcontrast-switch-handle-border-color-selected-hover: Highlight; - --highcontrast-switch-handle-border-color-selected-down: Highlight; - --highcontrast-switch-handle-border-color-selected-focus: Highlight; + --highcontrast-switch-background-color-disabled: ButtonFace; - --highcontrast-switch-background-color: ButtonFace; --highcontrast-switch-background-color-selected-default: Highlight; --highcontrast-switch-background-color-selected-hover: Highlight; --highcontrast-switch-background-color-selected-down: Highlight; --highcontrast-switch-background-color-selected-focus: Highlight; - --highcontrast-switch-background-color-selected-disabled: Highlight; + --highcontrast-switch-background-color-selected-disabled: GrayText; --highcontrast-switch-focus-indicator-color: ButtonText; - forced-color-adjust: none; - - .spectrum-Switch-input { - &:not(:checked) + .spectrum-Switch-switch { - box-shadow: inset 0 0 0 1px ButtonText; - } - } - - &:hover .spectrum-Switch-input { - &:not(:checked) + .spectrum-Switch-switch { - box-shadow: inset 0 0 0 1px Highlight; - } - - &:disabled, - &[disabled] { - &:checked + .spectrum-Switch-switch { - box-shadow: inset 0 0 0 1px GrayText; - background-color: GrayText; - } - - &:checked + .spectrum-Switch-switch::before { - border-color: GrayText; - background-color: ButtonFace; - } - } - } - - /* over-writes for disabled button */ - .spectrum-Switch-input { - &:disabled, - &[disabled] { - &:not(:checked) + .spectrum-Switch-switch { - box-shadow: inset 0 0 0 1px GrayText; - background-color: ButtonFace; - } - - &:not(:checked) + .spectrum-Switch-switch::before { - border-color: GrayText; - background-color: ButtonFace; - } - - &:checked + .spectrum-Switch-switch { - box-shadow: inset 0 0 0 1px GrayText; - background-color: GrayText; - } - - &:checked + .spectrum-Switch-switch::before { - border-color: GrayText; - background-color: ButtonFace; - } - - & ~ .spectrum-Switch-label { - color: GrayText; - } - } - } } } diff --git a/components/switch/package.json b/components/switch/package.json index 3114f06fc16..1177c0c6521 100644 --- a/components/switch/package.json +++ b/components/switch/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/switch", - "version": "6.2.0", + "version": "7.0.0-next.2", "description": "The Spectrum CSS switch component", "license": "Apache-2.0", "author": "Adobe", @@ -19,14 +19,12 @@ "./package.json": "./package.json", "./dist/*": "./dist/*", "./index.css": "./dist/index.css", - "./index-*.css": "./dist/index-*.css", "./metadata.json": "./dist/metadata.json", - "./themes/*": "./dist/themes/*", "./stories/*": "./stories/*" }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/tokens": ">=16.0.1" + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/tokens": { @@ -34,7 +32,7 @@ } }, "devDependencies": { - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/switch/stories/switch.stories.js b/components/switch/stories/switch.stories.js index 5286b307882..d3c38b01ad9 100644 --- a/components/switch/stories/switch.stories.js +++ b/components/switch/stories/switch.stories.js @@ -1,6 +1,6 @@ import { Sizes } from "@spectrum-css/preview/decorators"; import { disableDefaultModes } from "@spectrum-css/preview/modes"; -import { isChecked, isDisabled, isEmphasized, size } from "@spectrum-css/preview/types"; +import { isActive, isChecked, isDisabled, isEmphasized, size } from "@spectrum-css/preview/types"; import metadata from "../dist/metadata.json"; import packageJson from "../package.json"; import { SwitchGroup } from "./switch.test.js"; @@ -16,6 +16,7 @@ export default { size: size(["s", "m", "l", "xl"]), isEmphasized, isDisabled, + isActive, isChecked: { ...isChecked, name: "Selected", @@ -35,6 +36,7 @@ export default { isDisabled: false, isChecked: false, isEmphasized: false, + isActive: false, label: "Switch label", size: "m", }, @@ -45,7 +47,11 @@ export default { }, packageJson, metadata, + status: { + type: "migrated", + }, }, + tags: ["migrated"], }; export const Default = SwitchGroup.bind({}); diff --git a/components/switch/stories/switch.test.js b/components/switch/stories/switch.test.js index a0fc4a33bc8..2cb6be03e10 100644 --- a/components/switch/stories/switch.test.js +++ b/components/switch/stories/switch.test.js @@ -27,6 +27,15 @@ export const SwitchGroup = Variants({ testHeading: "Checked", isChecked: true, }, + { + testHeading: "Checked + Active", + isChecked: true, + isActive: true, + }, + { + testHeading: "UnChecked + Active", + isActive: true + }, { testHeading: "Checked and disabled", isChecked: true, diff --git a/components/switch/stories/template.js b/components/switch/stories/template.js index 5e67a3cc8b3..9897a14c864 100644 --- a/components/switch/stories/template.js +++ b/components/switch/stories/template.js @@ -6,9 +6,6 @@ import { styleMap } from "lit/directives/style-map.js"; import { when } from "lit/directives/when.js"; import "../index.css"; -import "../themes/spectrum.css"; -/* Must be imported last */ -import "../themes/express.css"; export const Template = ({ rootClass = "spectrum-Switch", @@ -16,10 +13,12 @@ export const Template = ({ label = "Switch label", isDisabled = false, isChecked = false, + isActive = false, isEmphasized = false, customClasses = [], customStyles = {}, id = getRandomId("switch"), + labelId, } = {}) => { // ID attribute value for the input element. const inputId = getRandomId("switch-input"); @@ -32,6 +31,7 @@ export const Template = ({ [`${rootClass}--emphasized`] : isEmphasized, [`${rootClass}--size${size?.toUpperCase()}`]: typeof size !== "undefined", + [`${rootClass}--active`]: isActive, ...customClasses.reduce((a, c) => ({ ...a, [c]: true }), {}), })} id=${ifDefined(id)} @@ -43,6 +43,7 @@ export const Template = ({ id=${inputId} ?disabled=${isDisabled} ?checked=${isChecked} + aria-labelledby=${ifDefined(labelId)} /> ${when(label, () => html` diff --git a/components/switch/themes/express.css b/components/switch/themes/express.css deleted file mode 100644 index ac5198ba733..00000000000 --- a/components/switch/themes/express.css +++ /dev/null @@ -1,30 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--express */ - -@import "./spectrum.css"; - -@container style(--system: express) { - .spectrum-Switch { - --spectrum-switch-handle-border-color-default: var(--spectrum-gray-800); - --spectrum-switch-handle-border-color-hover: var(--spectrum-gray-900); - --spectrum-switch-handle-border-color-down: var(--spectrum-gray-900); - --spectrum-switch-handle-border-color-focus: var(--spectrum-gray-900); - - --spectrum-switch-handle-border-color-selected-default: var(--spectrum-gray-800); - --spectrum-switch-handle-border-color-selected-hover: var(--spectrum-gray-900); - --spectrum-switch-handle-border-color-selected-down: var(--spectrum-gray-900); - --spectrum-switch-handle-border-color-selected-focus: var(--spectrum-gray-900); - } -} diff --git a/components/switch/themes/spectrum-two.css b/components/switch/themes/spectrum-two.css deleted file mode 100644 index c2ed1a192a4..00000000000 --- a/components/switch/themes/spectrum-two.css +++ /dev/null @@ -1,30 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -@container style(--system: spectrum) { - .spectrum-Switch { - --spectrum-switch-handle-border-color-default: var(--spectrum-gray-600); - --spectrum-switch-handle-border-color-hover: var(--spectrum-gray-700); - --spectrum-switch-handle-border-color-down: var(--spectrum-gray-800); - --spectrum-switch-handle-border-color-focus: var(--spectrum-gray-700); - - --spectrum-switch-handle-border-color-selected-default: var(--spectrum-gray-700); - --spectrum-switch-handle-border-color-selected-hover: var(--spectrum-gray-800); - --spectrum-switch-handle-border-color-selected-down: var(--spectrum-gray-900); - --spectrum-switch-handle-border-color-selected-focus: var(--spectrum-gray-800); - - --spectrum-switch-background-color: var(--spectrum-gray-200); - --spectrum-switch-background-color-disabled: var(--spectrum-gray-200); - --spectrum-switch-handle-background-color: var(--spectrum-gray-50); - } -} diff --git a/components/switch/themes/spectrum.css b/components/switch/themes/spectrum.css deleted file mode 100644 index 8b32e03d8f3..00000000000 --- a/components/switch/themes/spectrum.css +++ /dev/null @@ -1,24 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--legacy */ - -@import "./spectrum-two.css"; - -@container style(--system: legacy) { - .spectrum-Switch { - --spectrum-switch-background-color: var(--spectrum-gray-300); - --spectrum-switch-background-color-disabled: var(--spectrum-gray-300); - --spectrum-switch-handle-background-color: var(--spectrum-gray-75); - } -} diff --git a/components/table/CHANGELOG.md b/components/table/CHANGELOG.md index a8bc2d5235c..af957b82d31 100644 --- a/components/table/CHANGELOG.md +++ b/components/table/CHANGELOG.md @@ -1,5 +1,164 @@ # Change log +## 9.0.0-next.4 + +### Major Changes + +📝 [#4014](https://github.com/adobe/spectrum-css/pull/4014) [`35c066b`](https://github.com/adobe/spectrum-css/commit/35c066b29c311b1bfcf4507075f13b41222ffc84) Thanks [@castastrophe](https://github.com/castastrophe)! + +This update removes the `dir` attribute polyfill (served via a PostCSS transform to compiled assets) as the fallback is no longer necessary. The`dir` attribute support is available in all supported browsers and has been tested to correctly inherit inside web component shadow DOMs. This is a breaking change **only** to those relying on the `dir` attribute being present for styling, however, the `:dir` pseudo will correctly inherit values from their containers. To correctly determine the `dir` value of a node using JavaScript, you can use `getComputedStyle(node).direction`. + +## 9.0.0-next.3 + +### Minor Changes + +📝 [#3818](https://github.com/adobe/spectrum-css/pull/3818) [`f20e1e7`](https://github.com/adobe/spectrum-css/commit/f20e1e7ff402b591706cc791d9207fdedb80cd1e) Thanks [@marissahuysentruyt](https://github.com/marissahuysentruyt)! + +#### S2 table migration (continued) + +##### Net-new features + +- New sparkline SVGs available for cell content + +##### Description of other S2 table work + +A new `.spectrum-Table-headCell--alignEnd` class was created to correspond to tables that may have end-aligned numerical data so the head cell follows the text alignment correctly. + +Semantically, if a table should enable column sorting, the content of a column's head cell should actually be a button, since it is triggering an action. If the column header cell could trigger a menu, the content of that cell should also be a button. New markup has been included to improve the semantic design of the content of header cells, utilizing button components to signify an action can be triggered, or a menu can be triggered. + +In Storybook, new stories have been added to the docs page and the testing grid for Chromatic. These stories include `WithMenuButton`, `WithChartContent`. Documentation has been added for each of these stories, as well as expanded in other stories. + +##### Modifier changes + +###### Renamed modifiers + +| Old modifier | New modifier | +| ------------------------------ | ----------------------------------------- | +| `--mod-table-row-active-color` | `--mod-table-row-background-color-active` | + +###### New modifiers + +- `--mod-table-header-font-style` +- `--mod-table-header-icons-color-active` +- `--mod-table-header-icons-color-default` +- `--mod-table-header-icons-color-hover` +- `--mod-table-header-icons-color-key-focus` +- `--mod-table-row-font-family` +- `--mod-table-row-font-style` +- `--mod-table-row-text-color-active` +- `--mod-table-row-text-color-hover` + +###### Removed modifiers + +- `--mod-table-header-background-color-quiet` +- `--mod-table-row-background-color-quiet` + +## 9.0.0-next.2 + +### Major Changes + +📝 [#3799](https://github.com/adobe/spectrum-css/pull/3799) [`c86d476`](https://github.com/adobe/spectrum-css/commit/c86d476f4a470dbca86b823d399583fd76d37871) Thanks [@marissahuysentruyt](https://github.com/marissahuysentruyt)! + +#### S2 table migration + +Compared to the S1 table, this component has updated corner rounding, updated color tokens, some updated spacing, and an overall refreshed look. + +##### Net-new features + +- The S2 table supports an empty state, rendering an illustrated message component. +- As data is loading to the table, this component will render a progress circle during the loading state. +- There are 2 selection modes: single-select and multi-select. Multi-select tables (`selectionMode: "multiple"`) render an indeterminate checkbox in the `thead`/`div` equivalent. Single-select tables (`selectionMode: "single"`) do not render the indeterminate checkbox in the header row. (Note: the `selectionMode` arg is disabled and will not render in the Storybook control table.) +- For tables with sortable column, there are three new S2 icons used: `Sort` to indicate "general" sorting, `SortUp` for ascending sort direction, `SortDown` for descending sort direction. +- Tables support thumbnail, avatar, and icon components as content within a cell. +- Focus indicators for entire rows have been updated for rows to include a side focus indicator. + +###### Description of other S2 table work + +T-shirt sizing for tables is not technically supported, so t-shirt size classes (i.e. `.spectrum-Table--sizeS`), have been removed across all density variants. + +The `.spectrum-Table-cell--alignRight` class has been renamed to `.spectrum-Table-cell--alignEnd` to reflect the preference for "logical" positioning. The `.spectrum-Table-cell--alignCenter` class has been refactored to `.spectrum-Table-cell--alignStart`. + +In S1, the CSS table component only supported thumbnails. Because the S2 table supports thumbnails, as well as avatars and icons, most of the language regarding thumbnails has also changed. For instance, the `showThumbnail` storybook arg was refactored to `visualElement`. The following CSS classes have been removed or refactored to remove the thumbnail language in favor of "visual" instead: + +- `.spectrum-Table-thumbnailInner` >> `.spectrum-Table-visualInner` +- `.spectrum-Table-row--thumbnail` >> **removed** +- `.spectrum-Table-cell--thumbnail` >> **removed** +- `.spectrum-Table-thumbnailInner` >> **removed** +- `.spectrum-Table-thumbnailContent` >> **removed** +- `.spectrum-Table-thumbnailInner` >> **removed** + +The drop zones have been refactored to approach the drop zone indicators as pseudo elements, as opposed to `outline` properties. + +Because there are multiple sort icons in the S2 table, `.spectrum-Table-sortedIcon` has been renamed to `.spectrum-Table-sortIcon`. + +Individual cell focus rings have rounded corners. + +The outer table border extends all the way around the `thead`/`div` equivalent. + +In Storybook, several new stories have been added to the docs page and the testing grid for Chromatic. These stories include `EmptyState`, `LoadingState`, `SingleSelect`, `NumericalData`, `TableStates`, `Sortable`. Documentation has been added for each of these stories, as well as expanded in other stories. + +##### Modifiers + +###### Renamed + +| Old Modifier | New modifier | +| -------------------------------------------------- | ------------------------------------------------- | +| `--mod-table-border-radius--quiet` | `--mod-table-border-radius-quiet` | +| `--mod-table-header-top-to-text` | `--mod-table-header-row-top-to-text` | +| `--mod-table-header-bottom-to-text` | `--mod-table-header-row-bottom-to-text` | +| `--mod-table-cell-inline-space` | `--mod-table-cell-inline-spacing` | +| `--mod-table-checkbox-to-text` | `--mod-table-checkbox-to-cell-content` | +| `--mod-table-header-background-color--quiet` | `--mod-table-header-background-color-quiet` | +| `--mod-table-header-bottom-to-text` | `--mod-table-header-row-bottom-to-text` | +| `--mod-table-header-top-to-text` | `--mod-table-header-row-top-to-text` | +| `--mod-table-min-row-height--compact` | `--mod-table-min-row-height-compact` | +| `--mod-table-min-row-height--spacious` | `--mod-table-min-row-height-spacious` | +| `--mod-table-outer-border-inline-width--quiet` | `--mod-table-outer-border-inline-width-quiet` | +| `--mod-table-row-background-color--quiet` | `--mod-table-row-background-color-quiet` | +| `--mod-table-row-checkbox-block-spacing--compact` | `--mod-table-row-checkbox-block-spacing-compact` | +| `--mod-table-row-checkbox-block-spacing--spacious` | `--mod-table-row-checkbox-block-spacing-spacious` | +| `--mod-table-thumbnail-to-text` | `--mod-table-visual-to-text` | + +###### New + +- `--mod-table-avatar-size` +- `--mod-table-avatar-size-compact` +- `--mod-table-avatar-size-spacious` +- `--mod-table-section-header-inline-start-spacing` +- `--mod-table-summary-row-bottom-to-text` +- `--mod-table-summary-row-min-height` +- `--mod-table-summary-row-top-to-text` + +###### Removed + +- `--mod-table-edge-to-content` +- `--mod-table-header-row-checkbox-block-spacing` +- `--mod-table-avatar-size-spacious` +- `--mod-table-row-bottom-to-text--compact` +- `--mod-table-row-bottom-to-text--spacious` +- `--mod-table-row-top-to-text--compact` +- `--mod-table-row-top-to-text--spacious` +- `--mod-table-thumbnail-block-spacing"` +- `--mod-table-thumbnail-block-spacing-compact` +- `--mod-table-thumbnail-block-spacing-spacious` + +## 9.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + - @spectrum-css/thumbnail@9.0.0-next.0 + +## 9.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`a25e0a9`](https://github.com/adobe/spectrum-css/commit/a25e0a99e5a4736ab4e607e00739343101a2633b)]: + - @spectrum-css/icon@10.0.0-next.0 + - @spectrum-css/button@15.0.0-next.0 + - @spectrum-css/checkbox@11.0.0-next.0 + ## 8.2.0 ### Minor Changes diff --git a/components/table/dist/metadata.json b/components/table/dist/metadata.json index e319678fb13..cf66742117b 100644 --- a/components/table/dist/metadata.json +++ b/components/table/dist/metadata.json @@ -2,20 +2,13 @@ "sourceFile": "index.css", "selectors": [ ".spectrum-Table", + ".spectrum-Table .spectrum-Table-row--summary", ".spectrum-Table--compact", - ".spectrum-Table--compact.spectrum-Table--sizeL", - ".spectrum-Table--compact.spectrum-Table--sizeS", - ".spectrum-Table--compact.spectrum-Table--sizeXL", ".spectrum-Table--emphasized", ".spectrum-Table--quiet", - ".spectrum-Table--sizeL", - ".spectrum-Table--sizeM", - ".spectrum-Table--sizeS", - ".spectrum-Table--sizeXL", + ".spectrum-Table--quiet .spectrum-Table-headRow:first-child .spectrum-Table-headCell:first-child", + ".spectrum-Table--quiet .spectrum-Table-headRow:first-child .spectrum-Table-headCell:last-child", ".spectrum-Table--spacious", - ".spectrum-Table--spacious.spectrum-Table--sizeL", - ".spectrum-Table--spacious.spectrum-Table--sizeS", - ".spectrum-Table--spacious.spectrum-Table--sizeXL", ".spectrum-Table-body", ".spectrum-Table-body .spectrum-Table-row .spectrum-Table-cell:first-child", ".spectrum-Table-body .spectrum-Table-row .spectrum-Table-cell:last-child", @@ -24,19 +17,20 @@ ".spectrum-Table-body.is-drop-target", ".spectrum-Table-body.is-drop-target .spectrum-Table-row", ".spectrum-Table-body.is-drop-target .spectrum-Table-row .spectrum-Table-checkbox .spectrum-Checkbox-box:before", + ".spectrum-Table-body.is-drop-target:after", ".spectrum-Table-cell", - ".spectrum-Table-cell--alignCenter", - ".spectrum-Table-cell--alignRight", + ".spectrum-Table-cell--alignEnd", + ".spectrum-Table-cell--alignStart", ".spectrum-Table-cell--collapsible", ".spectrum-Table-cell--divider", - ".spectrum-Table-cell.is-focused", + ".spectrum-Table-cell:focus", ".spectrum-Table-cell:focus-visible", + ".spectrum-Table-cell:focus-visible:after", + ".spectrum-Table-cell:focus:after", + ".spectrum-Table-chartContent .spectrum-Table-chartImage", ".spectrum-Table-checkboxCell", ".spectrum-Table-checkboxCell .spectrum-Table-checkbox", - ".spectrum-Table-checkboxCell.spectrum-Table-cell .spectrum-Table-checkbox", - ".spectrum-Table-checkboxCell.spectrum-Table-headCell .spectrum-Table-checkbox", ".spectrum-Table-collapseInner", - ".spectrum-Table-collapseInner .spectrum-Table-collapseContent", ".spectrum-Table-columnTitle", ".spectrum-Table-disclosureIcon.spectrum-Table-disclosureIcon", ".spectrum-Table-disclosureIcon.spectrum-Table-disclosureIcon.is-keyboardFocused", @@ -50,22 +44,59 @@ ".spectrum-Table-head", ".spectrum-Table-head [role=\"row\"]", ".spectrum-Table-headCell", - ".spectrum-Table-headCell .spectrum-Table-menuIcon", - ".spectrum-Table-headCell .spectrum-Table-sortedIcon", - ".spectrum-Table-headCell.is-focused", + ".spectrum-Table-headCell .spectrum-Table-menuButton", + ".spectrum-Table-headCell .spectrum-Table-menuButton:active", + ".spectrum-Table-headCell .spectrum-Table-menuButton:focus", + ".spectrum-Table-headCell .spectrum-Table-menuButton:focus-visible", + ".spectrum-Table-headCell .spectrum-Table-menuButton:focus:hover", + ".spectrum-Table-headCell .spectrum-Table-menuButton:hover", + ".spectrum-Table-headCell .spectrum-Table-sortButton", + ".spectrum-Table-headCell .spectrum-Table-sortButton.is-keyboardFocused", + ".spectrum-Table-headCell .spectrum-Table-sortButton:active", + ".spectrum-Table-headCell .spectrum-Table-sortButton:focus", + ".spectrum-Table-headCell .spectrum-Table-sortButton:focus-visible", + ".spectrum-Table-headCell .spectrum-Table-sortButton:hover", ".spectrum-Table-headCell.is-sortable", + ".spectrum-Table-headCell.is-sortable .spectrum-Table-sortButton", + ".spectrum-Table-headCell.is-sortable .spectrum-Table-sortButton .spectrum-Icon", + ".spectrum-Table-headCell.is-sortable .spectrum-Table-sortButton:active", + ".spectrum-Table-headCell.is-sortable .spectrum-Table-sortButton:after", + ".spectrum-Table-headCell.is-sortable .spectrum-Table-sortButton:focus", + ".spectrum-Table-headCell.is-sortable .spectrum-Table-sortButton:focus-visible", + ".spectrum-Table-headCell.is-sortable .spectrum-Table-sortButton:hover", ".spectrum-Table-headCell.is-sortable.is-keyboardFocused", ".spectrum-Table-headCell.is-sortable:active", ".spectrum-Table-headCell.is-sortable:focus", ".spectrum-Table-headCell.is-sortable:focus-visible", - ".spectrum-Table-headCell.is-sortable:focus:hover", ".spectrum-Table-headCell.is-sortable:hover", - ".spectrum-Table-headCell.is-sorted-asc .spectrum-Table-sortedIcon", - ".spectrum-Table-headCell.is-sorted-desc .spectrum-Table-sortedIcon", + ".spectrum-Table-headCell.spectrum-Table-hasMenuButton", + ".spectrum-Table-headCell.spectrum-Table-hasMenuButton .spectrum-Table-sortButton", + ".spectrum-Table-headCell.spectrum-Table-hasMenuButton .spectrum-Table-sortButton .spectrum-Button-label", + ".spectrum-Table-headCell.spectrum-Table-hasMenuButton .spectrum-Table-sortButton .spectrum-Button-label:after", + ".spectrum-Table-headCell.spectrum-Table-hasMenuButton .spectrum-Table-sortButton .spectrum-Icon", + ".spectrum-Table-headCell.spectrum-Table-hasMenuButton .spectrum-Table-sortButton:focus-visible:after", + ".spectrum-Table-headCell.spectrum-Table-hasMenuButton .spectrum-Table-sortButton:hover", + ".spectrum-Table-headCell.spectrum-Table-hasMenuButton.is-keyboardFocused", + ".spectrum-Table-headCell.spectrum-Table-hasMenuButton:active", + ".spectrum-Table-headCell.spectrum-Table-hasMenuButton:focus", + ".spectrum-Table-headCell.spectrum-Table-hasMenuButton:focus-visible", + ".spectrum-Table-headCell.spectrum-Table-hasMenuButton:hover", + ".spectrum-Table-headCell:focus", ".spectrum-Table-headCell:focus-visible", + ".spectrum-Table-headCell:focus-visible:after", + ".spectrum-Table-headCell:focus:after", + ".spectrum-Table-headRow .spectrum-ActionButton:after", + ".spectrum-Table-headRow .spectrum-Table-checkboxCell", + ".spectrum-Table-headRow .spectrum-Table-checkboxCell .spectrum-Table-checkbox", + ".spectrum-Table-headRow .spectrum-Table-headCell", + ".spectrum-Table-headRow .spectrum-Table-headCell--alignEnd", + ".spectrum-Table-headRow .spectrum-Table-headCell.is-sortable", + ".spectrum-Table-headRow:first-child .spectrum-Table-headCell:first-child", + ".spectrum-Table-headRow:last-child .spectrum-Table-headCell:last-child", ".spectrum-Table-main", - ".spectrum-Table-menuIcon", ".spectrum-Table-row", + ".spectrum-Table-row .is-emphasized", + ".spectrum-Table-row .spectrum-Table-cell", ".spectrum-Table-row--collapsible", ".spectrum-Table-row--collapsible .spectrum-Table-checkboxCell", ".spectrum-Table-row--collapsible .spectrum-Table-disclosureIcon", @@ -83,28 +114,34 @@ ".spectrum-Table-row--sectionHeader:hover", ".spectrum-Table-row--summary", ".spectrum-Table-row--summary .spectrum-Table-cell", - ".spectrum-Table-row--thumbnail", - ".spectrum-Table-row--thumbnail .spectrum-Table-cell", - ".spectrum-Table-row--thumbnail .spectrum-Table-cell--thumbnail", - ".spectrum-Table-row--thumbnail.spectrum-Table-row--collapsible", + ".spectrum-Table-row--summary:hover", ".spectrum-Table-row.is-drop-target", ".spectrum-Table-row.is-drop-target .spectrum-Table-cell", ".spectrum-Table-row.is-drop-target .spectrum-Table-checkbox .spectrum-Checkbox-box:before", - ".spectrum-Table-row.is-focused", - ".spectrum-Table-row.is-focused .spectrum-Table-checkbox .spectrum-Checkbox-box:before", ".spectrum-Table-row.is-selected", + ".spectrum-Table-row.is-selected .spectrum-Table-cell", ".spectrum-Table-row.is-selected .spectrum-Table-checkbox .spectrum-Checkbox-box:before", - ".spectrum-Table-row.is-selected.is-focused", + ".spectrum-Table-row.is-selected:active", ".spectrum-Table-row.is-selected:focus-visible", ".spectrum-Table-row.is-selected:hover", + ".spectrum-Table-row.is-selected:not(:has(+ .is-selected)) .spectrum-Table-cell", ".spectrum-Table-row:active", ".spectrum-Table-row:first-child", - ".spectrum-Table-row:first-child .spectrum-Table-cell:first-child", ".spectrum-Table-row:first-child .spectrum-Table-cell:last-child", ".spectrum-Table-row:focus", + ".spectrum-Table-row:focus .spectrum-Table-cell:first-child", + ".spectrum-Table-row:focus .spectrum-Table-cell:first-child:before", + ".spectrum-Table-row:focus .spectrum-Table-checkbox .spectrum-Checkbox-box:before", ".spectrum-Table-row:focus-visible", + ".spectrum-Table-row:focus-visible .spectrum-Table-cell:first-child", + ".spectrum-Table-row:focus-visible .spectrum-Table-cell:first-child:before", ".spectrum-Table-row:focus-visible .spectrum-Table-checkbox .spectrum-Checkbox-box:before", + ".spectrum-Table-row:focus-visible:hover", + ".spectrum-Table-row:focus-visible:last-child .spectrum-Table-cell:first-child:before", + ".spectrum-Table-row:focus:hover", + ".spectrum-Table-row:focus:last-child .spectrum-Table-cell:first-child:before", ".spectrum-Table-row:hover", + ".spectrum-Table-row:hover .spectrum-Table-cell:first-child:before", ".spectrum-Table-row:hover .spectrum-Table-checkbox .spectrum-Checkbox-box:before", ".spectrum-Table-row:last-child", ".spectrum-Table-row:last-child .spectrum-Table-cell:first-child", @@ -115,23 +152,27 @@ ".spectrum-Table-scroller .spectrum-Table-body .spectrum-Table-row:first-child .spectrum-Table-cell", ".spectrum-Table-scroller .spectrum-Table-body .spectrum-Table-row:last-child .spectrum-Table-cell", ".spectrum-Table-scroller .spectrum-Table-head", - ".spectrum-Table-scroller .spectrum-Table-headCell", - ".spectrum-Table-scroller.spectrum-Table--quiet", - ".spectrum-Table-sortedIcon", - ".spectrum-Table-thumbnailInner", - ".spectrum-Table-thumbnailInner .spectrum-Table-thumbnailContent", - ".spectrum-Table-thumbnailInner .spectrum-Thumbnail", + ".spectrum-Table-scroller .spectrum-Table-headRow:first-child .spectrum-Table-headCell", + ".spectrum-Table-visualInner", + ".spectrum-Table-visualInner .spectrum-Avatar", + ".spectrum-Table-visualInner .spectrum-Icon", + ".spectrum-Table-visualInner .spectrum-Thumbnail", ".spectrum-Table:dir(rtl)", - ".spectrum-Table:not(.spectrum-Table-scroller)", - "[dir=\"rtl\"] .spectrum-Table" + ".spectrum-Table:lang(ja)", + ".spectrum-Table:lang(ko)", + ".spectrum-Table:lang(zh)", + ".spectrum-Table:not(.spectrum-Table-scroller)" ], "modifiers": [ + "--mod-table-avatar-size", + "--mod-table-avatar-size-compact", + "--mod-table-avatar-size-spacious", "--mod-table-border-color", "--mod-table-border-radius", - "--mod-table-border-radius--quiet", + "--mod-table-border-radius-quiet", "--mod-table-border-width", - "--mod-table-cell-inline-space", - "--mod-table-checkbox-to-text", + "--mod-table-cell-inline-spacing", + "--mod-table-checkbox-to-cell-content", "--mod-table-collapsible-disclosure-inline-spacing", "--mod-table-collapsible-icon-animation-duration", "--mod-table-current-header-height", @@ -144,21 +185,24 @@ "--mod-table-divider-color", "--mod-table-drop-zone-background-color", "--mod-table-drop-zone-outline-color", - "--mod-table-edge-to-content", "--mod-table-focus-indicator-color", "--mod-table-focus-indicator-thickness", "--mod-table-header-background-color", - "--mod-table-header-background-color--quiet", "--mod-table-header-background-color-scrollable", - "--mod-table-header-bottom-to-text", - "--mod-table-header-checkbox-block-spacing", "--mod-table-header-font-family", "--mod-table-header-font-size", + "--mod-table-header-font-style", "--mod-table-header-font-weight", + "--mod-table-header-icons-color-active", + "--mod-table-header-icons-color-default", + "--mod-table-header-icons-color-hover", + "--mod-table-header-icons-color-key-focus", "--mod-table-header-line-height", + "--mod-table-header-row-bottom-to-text", + "--mod-table-header-row-checkbox-block-spacing", + "--mod-table-header-row-top-to-text", "--mod-table-header-text-color", "--mod-table-header-text-transform", - "--mod-table-header-top-to-text", "--mod-table-header-vertical-align", "--mod-table-icon-color-active", "--mod-table-icon-color-default", @@ -166,30 +210,28 @@ "--mod-table-icon-color-focus-hover", "--mod-table-icon-color-hover", "--mod-table-icon-color-key-focus", - "--mod-table-icon-to-text", "--mod-table-min-header-height", "--mod-table-min-row-height", - "--mod-table-min-row-height--compact", - "--mod-table-min-row-height--spacious", + "--mod-table-min-row-height-compact", + "--mod-table-min-row-height-spacious", "--mod-table-outer-border-inline-width", - "--mod-table-outer-border-inline-width--quiet", - "--mod-table-row-active-color", + "--mod-table-outer-border-inline-width-quiet", "--mod-table-row-background-color", - "--mod-table-row-background-color--quiet", + "--mod-table-row-background-color-active", "--mod-table-row-background-color-hover", "--mod-table-row-bottom-to-text", - "--mod-table-row-bottom-to-text--compact", - "--mod-table-row-bottom-to-text--spacious", "--mod-table-row-checkbox-block-spacing", - "--mod-table-row-checkbox-block-spacing--compact", - "--mod-table-row-checkbox-block-spacing--spacious", + "--mod-table-row-checkbox-block-spacing-compact", + "--mod-table-row-checkbox-block-spacing-spacious", + "--mod-table-row-font-family", "--mod-table-row-font-size", + "--mod-table-row-font-style", "--mod-table-row-font-weight", "--mod-table-row-line-height", "--mod-table-row-text-color", + "--mod-table-row-text-color-active", + "--mod-table-row-text-color-hover", "--mod-table-row-top-to-text", - "--mod-table-row-top-to-text--compact", - "--mod-table-row-top-to-text--spacious", "--mod-table-section-header-background-color", "--mod-table-section-header-block-end-spacing", "--mod-table-section-header-block-start-spacing", @@ -197,6 +239,7 @@ "--mod-table-section-header-font-size", "--mod-table-section-header-font-style", "--mod-table-section-header-font-weight", + "--mod-table-section-header-inline-start-spacing", "--mod-table-section-header-line-height", "--mod-table-section-header-min-height", "--mod-table-section-header-text-color", @@ -204,43 +247,37 @@ "--mod-table-selected-row-background-color-focus", "--mod-table-selected-row-background-color-non-emphasized", "--mod-table-selected-row-background-color-non-emphasized-focus", - "--mod-table-sort-icon-inline-end-spacing", - "--mod-table-sort-icon-inline-start-spacing", "--mod-table-summary-row-background-color", + "--mod-table-summary-row-bottom-to-text", "--mod-table-summary-row-font-family", "--mod-table-summary-row-font-size", "--mod-table-summary-row-font-style", "--mod-table-summary-row-font-weight", "--mod-table-summary-row-line-height", + "--mod-table-summary-row-min-height", "--mod-table-summary-row-text-color", - "--mod-table-thumbnail-block-spacing", - "--mod-table-thumbnail-block-spacing-compact", - "--mod-table-thumbnail-block-spacing-spacious", + "--mod-table-summary-row-top-to-text", "--mod-table-thumbnail-size", "--mod-table-thumbnail-size-compact", "--mod-table-thumbnail-size-spacious", - "--mod-table-thumbnail-to-text", - "--mod-table-transition-duration" + "--mod-table-transition-duration", + "--mod-table-visual-to-text" ], "component": [ + "--spectrum-table-avatar-size", "--spectrum-table-border-color", "--spectrum-table-border-divider-width", "--spectrum-table-border-radius", "--spectrum-table-border-width", "--spectrum-table-cell-background-color", - "--spectrum-table-cell-inline-space", + "--spectrum-table-cell-inline-spacing", + "--spectrum-table-checkbox-to-cell-content", "--spectrum-table-checkbox-to-text", "--spectrum-table-collapsible-disclosure-inline-spacing", "--spectrum-table-collapsible-icon-animation-duration", "--spectrum-table-collapsible-tier-indent", - "--spectrum-table-column-header-row-bottom-to-text-extra-large", - "--spectrum-table-column-header-row-bottom-to-text-large", "--spectrum-table-column-header-row-bottom-to-text-medium", - "--spectrum-table-column-header-row-bottom-to-text-small", - "--spectrum-table-column-header-row-top-to-text-extra-large", - "--spectrum-table-column-header-row-top-to-text-large", "--spectrum-table-column-header-row-top-to-text-medium", - "--spectrum-table-column-header-row-top-to-text-small", "--spectrum-table-default-vertical-align", "--spectrum-table-disclosure-icon-size", "--spectrum-table-divider-color", @@ -249,216 +286,163 @@ "--spectrum-table-edge-to-content", "--spectrum-table-focus-indicator-color", "--spectrum-table-focus-indicator-thickness", + "--spectrum-table-focused-cell-border-radius", "--spectrum-table-header-background-color", - "--spectrum-table-header-bottom-to-text", - "--spectrum-table-header-checkbox-block-spacing", "--spectrum-table-header-font-weight", - "--spectrum-table-header-row-checkbox-to-top-extra-large", - "--spectrum-table-header-row-checkbox-to-top-large", + "--spectrum-table-header-icons-color-active", + "--spectrum-table-header-icons-color-default", + "--spectrum-table-header-icons-color-hover", + "--spectrum-table-header-icons-color-key-focus", + "--spectrum-table-header-row-bottom-to-text", + "--spectrum-table-header-row-checkbox-block-spacing", "--spectrum-table-header-row-checkbox-to-top-medium", - "--spectrum-table-header-row-checkbox-to-top-small", + "--spectrum-table-header-row-top-to-text", "--spectrum-table-header-text-color", - "--spectrum-table-header-top-to-text", - "--spectrum-table-header-vertical-align", "--spectrum-table-icon-color", "--spectrum-table-icon-color-active", "--spectrum-table-icon-color-default", - "--spectrum-table-icon-color-focus", - "--spectrum-table-icon-color-focus-hover", "--spectrum-table-icon-color-hover", "--spectrum-table-icon-color-key-focus", - "--spectrum-table-icon-to-text", - "--spectrum-table-min-header-height", + "--spectrum-table-min-header-row-height", "--spectrum-table-min-row-height", "--spectrum-table-outer-border-inline-width", - "--spectrum-table-row-active-color", "--spectrum-table-row-background-color", + "--spectrum-table-row-background-color-active", "--spectrum-table-row-background-color-hover", "--spectrum-table-row-bottom-to-text", - "--spectrum-table-row-bottom-to-text-extra-large-compact", - "--spectrum-table-row-bottom-to-text-extra-large-regular", - "--spectrum-table-row-bottom-to-text-extra-large-spacious", - "--spectrum-table-row-bottom-to-text-large-compact", - "--spectrum-table-row-bottom-to-text-large-regular", - "--spectrum-table-row-bottom-to-text-large-spacious", + "--spectrum-table-row-bottom-to-text-medium", "--spectrum-table-row-bottom-to-text-medium-compact", - "--spectrum-table-row-bottom-to-text-medium-regular", "--spectrum-table-row-bottom-to-text-medium-spacious", - "--spectrum-table-row-bottom-to-text-small-compact", - "--spectrum-table-row-bottom-to-text-small-regular", - "--spectrum-table-row-bottom-to-text-small-spacious", "--spectrum-table-row-checkbox-block-spacing", - "--spectrum-table-row-checkbox-to-top-extra-large-compact", - "--spectrum-table-row-checkbox-to-top-extra-large-regular", - "--spectrum-table-row-checkbox-to-top-extra-large-spacious", - "--spectrum-table-row-checkbox-to-top-large-compact", - "--spectrum-table-row-checkbox-to-top-large-regular", - "--spectrum-table-row-checkbox-to-top-large-spacious", + "--spectrum-table-row-checkbox-to-top-medium", "--spectrum-table-row-checkbox-to-top-medium-compact", - "--spectrum-table-row-checkbox-to-top-medium-regular", "--spectrum-table-row-checkbox-to-top-medium-spacious", - "--spectrum-table-row-checkbox-to-top-small-compact", - "--spectrum-table-row-checkbox-to-top-small-regular", - "--spectrum-table-row-checkbox-to-top-small-spacious", "--spectrum-table-row-down-opacity", + "--spectrum-table-row-focus-indicator-width", "--spectrum-table-row-font-family", "--spectrum-table-row-font-size", "--spectrum-table-row-font-style", "--spectrum-table-row-font-weight", - "--spectrum-table-row-height-extra-large-compact", - "--spectrum-table-row-height-extra-large-regular", - "--spectrum-table-row-height-extra-large-spacious", - "--spectrum-table-row-height-large-compact", - "--spectrum-table-row-height-large-regular", - "--spectrum-table-row-height-large-spacious", + "--spectrum-table-row-height-medium", "--spectrum-table-row-height-medium-compact", - "--spectrum-table-row-height-medium-regular", "--spectrum-table-row-height-medium-spacious", - "--spectrum-table-row-height-small-compact", - "--spectrum-table-row-height-small-regular", - "--spectrum-table-row-height-small-spacious", "--spectrum-table-row-hover-opacity", "--spectrum-table-row-line-height", "--spectrum-table-row-text-color", + "--spectrum-table-row-text-color-active", + "--spectrum-table-row-text-color-hover", + "--spectrum-table-row-text-color-key-focus", "--spectrum-table-row-tier", "--spectrum-table-row-top-to-text", - "--spectrum-table-row-top-to-text-extra-large-compact", - "--spectrum-table-row-top-to-text-extra-large-regular", - "--spectrum-table-row-top-to-text-extra-large-spacious", - "--spectrum-table-row-top-to-text-large-compact", - "--spectrum-table-row-top-to-text-large-regular", - "--spectrum-table-row-top-to-text-large-spacious", + "--spectrum-table-row-top-to-text-medium", "--spectrum-table-row-top-to-text-medium-compact", - "--spectrum-table-row-top-to-text-medium-regular", "--spectrum-table-row-top-to-text-medium-spacious", - "--spectrum-table-row-top-to-text-small-compact", - "--spectrum-table-row-top-to-text-small-regular", - "--spectrum-table-row-top-to-text-small-spacious", "--spectrum-table-section-header-background-color", "--spectrum-table-section-header-block-end-spacing", "--spectrum-table-section-header-block-start-spacing", "--spectrum-table-section-header-font-weight", "--spectrum-table-section-header-min-height", - "--spectrum-table-section-header-row-height-extra-large", - "--spectrum-table-section-header-row-height-large", "--spectrum-table-section-header-row-height-medium", - "--spectrum-table-section-header-row-height-small", "--spectrum-table-selected-cell-background-color", "--spectrum-table-selected-cell-background-color-focus", "--spectrum-table-selected-row-background-color", - "--spectrum-table-selected-row-background-color-focus", + "--spectrum-table-selected-row-background-color-active", + "--spectrum-table-selected-row-background-color-hover", "--spectrum-table-selected-row-background-color-non-emphasized", "--spectrum-table-selected-row-background-color-non-emphasized-focus", + "--spectrum-table-selected-row-background-color-rgb", "--spectrum-table-selected-row-background-opacity", "--spectrum-table-selected-row-background-opacity-hover", "--spectrum-table-selected-row-background-opacity-non-emphasized", "--spectrum-table-selected-row-background-opacity-non-emphasized-hover", "--spectrum-table-summary-row-background-color", "--spectrum-table-summary-row-font-weight", - "--spectrum-table-thumbnail-block-spacing", - "--spectrum-table-thumbnail-cell-block-spacing", - "--spectrum-table-thumbnail-inner-content-block-spacing", - "--spectrum-table-thumbnail-inner-minimum-block-spacing", "--spectrum-table-thumbnail-size", - "--spectrum-table-thumbnail-to-text", - "--spectrum-table-thumbnail-to-top-minimum-extra-large-compact", - "--spectrum-table-thumbnail-to-top-minimum-extra-large-regular", - "--spectrum-table-thumbnail-to-top-minimum-extra-large-spacious", - "--spectrum-table-thumbnail-to-top-minimum-large-compact", - "--spectrum-table-thumbnail-to-top-minimum-large-regular", - "--spectrum-table-thumbnail-to-top-minimum-large-spacious", - "--spectrum-table-thumbnail-to-top-minimum-medium-compact", - "--spectrum-table-thumbnail-to-top-minimum-medium-regular", - "--spectrum-table-thumbnail-to-top-minimum-medium-spacious", - "--spectrum-table-thumbnail-to-top-minimum-small-compact", - "--spectrum-table-thumbnail-to-top-minimum-small-regular", - "--spectrum-table-thumbnail-to-top-minimum-small-spacious", - "--spectrum-table-transition-duration" + "--spectrum-table-transition-duration", + "--spectrum-table-visual-to-text" ], "global": [ "--spectrum-accent-visual-color", "--spectrum-animation-duration-100", - "--spectrum-background-layer-1-color", - "--spectrum-blue-900-rgb", + "--spectrum-avatar-size-100", + "--spectrum-avatar-size-50", + "--spectrum-avatar-size-75", "--spectrum-body-color", "--spectrum-bold-font-weight", "--spectrum-checkbox-control-size-small", + "--spectrum-cjk-line-height-100", "--spectrum-component-bottom-to-text-100", - "--spectrum-component-bottom-to-text-200", - "--spectrum-component-bottom-to-text-300", - "--spectrum-component-bottom-to-text-75", "--spectrum-component-height-100", - "--spectrum-component-height-200", - "--spectrum-component-height-300", - "--spectrum-component-height-75", "--spectrum-component-top-to-text-100", - "--spectrum-component-top-to-text-200", - "--spectrum-component-top-to-text-300", - "--spectrum-component-top-to-text-75", - "--spectrum-corner-radius-100", + "--spectrum-corner-radius-medium-size-extra-small", + "--spectrum-corner-radius-small-default", "--spectrum-default-font-style", "--spectrum-drop-zone-background-color-opacity", "--spectrum-drop-zone-background-color-rgb", "--spectrum-focus-indicator-color", "--spectrum-focus-indicator-thickness", "--spectrum-font-size-100", - "--spectrum-font-size-200", - "--spectrum-font-size-300", - "--spectrum-font-size-75", - "--spectrum-gray-100", "--spectrum-gray-200", "--spectrum-gray-25", "--spectrum-gray-300", - "--spectrum-gray-50", "--spectrum-gray-700-rgb", "--spectrum-gray-75", "--spectrum-gray-900-rgb", "--spectrum-line-height-100", "--spectrum-logical-rotation", "--spectrum-neutral-content-color-default", + "--spectrum-neutral-content-color-down", + "--spectrum-neutral-content-color-hover", + "--spectrum-neutral-content-color-key-focus", "--spectrum-neutral-subdued-content-color-default", "--spectrum-neutral-subdued-content-color-down", "--spectrum-neutral-subdued-content-color-hover", "--spectrum-neutral-subdued-content-color-key-focus", "--spectrum-regular-font-weight", "--spectrum-sans-font-family-stack", + "--spectrum-side-focus-indicator", "--spectrum-spacing-300", - "--spectrum-text-to-visual-100", - "--spectrum-text-to-visual-200", "--spectrum-text-to-visual-300", + "--spectrum-thumbnail-size-100", "--spectrum-thumbnail-size-200", - "--spectrum-thumbnail-size-300", - "--spectrum-thumbnail-size-50", - "--spectrum-thumbnail-size-500", - "--spectrum-thumbnail-size-700", - "--spectrum-thumbnail-size-800", - "--spectrum-transparent-white-100", - "--spectrum-transparent-white-25" + "--spectrum-thumbnail-size-75" ], - "system-theme": [ - "--system-table-border-color", - "--system-table-divider-color", - "--system-table-header-background-color", - "--system-table-icon-color-focus", - "--system-table-icon-color-focus-hover", - "--system-table-quiet-header-background-color", - "--system-table-quiet-row-background-color", - "--system-table-row-background-color", - "--system-table-section-header-background-color", - "--system-table-summary-row-background-color" + "passthroughs": [ + "--mod-avatar-block-size", + "--mod-avatar-inline-size", + "--mod-button-background-color-default", + "--mod-button-background-color-down", + "--mod-button-background-color-focus", + "--mod-button-background-color-hover", + "--mod-button-border-radius", + "--mod-button-content-color-default", + "--mod-button-content-color-down", + "--mod-button-content-color-focus", + "--mod-button-content-color-hover", + "--mod-button-edge-to-text", + "--mod-button-focus-ring-border-radius", + "--mod-button-font-family", + "--mod-button-font-size", + "--mod-button-font-weight", + "--mod-button-line-height", + "--mod-button-padding-label-to-icon", + "--mod-checkbox-margin-block", + "--mod-icon-color", + "--mod-thumbnail-size" ], - "passthroughs": ["--mod-checkbox-spacing", "--mod-thumbnail-size"], "high-contrast": [ "--highcontrast-table-border-color", - "--highcontrast-table-cell-focus-extra-offset", "--highcontrast-table-cell-focus-indicator-color", "--highcontrast-table-divider-color", "--highcontrast-table-focus-indicator-color", + "--highcontrast-table-header-text-color", + "--highcontrast-table-header-text-color-hover", "--highcontrast-table-icon-color", "--highcontrast-table-icon-color-focus", "--highcontrast-table-row-background-color", "--highcontrast-table-row-background-color-hover", "--highcontrast-table-row-text-color", + "--highcontrast-table-row-text-color-focus", "--highcontrast-table-row-text-color-hover", "--highcontrast-table-section-header-background-color", "--highcontrast-table-section-header-text-color", diff --git a/components/table/index.css b/components/table/index.css index 12bb85cd56c..9f358a08f3f 100644 --- a/components/table/index.css +++ b/components/table/index.css @@ -1,5 +1,5 @@ /*! - * Copyright 2024 Adobe. All rights reserved. + * Copyright 2025 Adobe. All rights reserved. * * This file is licensed to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. You may obtain a copy @@ -11,520 +11,537 @@ * governing permissions and limitations under the License. */ -@import "./themes/spectrum-two.css"; +.spectrum-Table { + /* Animation */ + --spectrum-table-transition-duration: var(--spectrum-animation-duration-100); -/********* HIGH CONTRAST *********/ -@media (forced-colors: active) { - .spectrum-Table { - --highcontrast-table-row-background-color: Canvas; - --highcontrast-table-row-text-color: CanvasText; - --highcontrast-table-divider-color: CanvasText; - --highcontrast-table-border-color: CanvasText; - --highcontrast-table-icon-color: CanvasText; - --highcontrast-table-icon-color-focus: Highlight; + /* Background colors */ + --spectrum-table-header-background-color: var(--spectrum-gray-75); + --spectrum-table-row-background-color: var(--spectrum-gray-25); - --highcontrast-table-selected-row-background-color: Highlight; - --highcontrast-table-selected-row-text-color: HighlightText; + --spectrum-table-summary-row-background-color: var(--spectrum-gray-200); + --spectrum-table-section-header-background-color: var(--spectrum-gray-200); - @supports (color: SelectedItem) { - --highcontrast-table-selected-row-background-color: SelectedItem; - --highcontrast-table-selected-row-text-color: SelectedItemText; - } + /* @todo Refactor or remove these properties once the RGB stripped value is available. */ + --spectrum-table-selected-row-background-color: rgb(var(--spectrum-table-selected-row-background-color-rgb), var(--spectrum-table-selected-row-background-opacity)); + --spectrum-table-selected-row-background-color-non-emphasized: rgb(var(--spectrum-gray-700-rgb), var(--spectrum-table-selected-row-background-opacity-non-emphasized)); + --spectrum-table-selected-row-background-color-hover: rgb(var(--spectrum-table-selected-row-background-color-rgb), var(--spectrum-table-selected-row-background-opacity-hover)); + --spectrum-table-selected-row-background-color-active: rgb(var(--spectrum-table-selected-row-background-color-rgb), var(--spectrum-table-selected-row-background-opacity-hover)); + --spectrum-table-selected-row-background-color-non-emphasized-focus: rgb(var(--spectrum-gray-700-rgb), var(--spectrum-table-selected-row-background-opacity-non-emphasized-hover)); - --highcontrast-table-selected-row-background-color-focus: Highlight; - --highcontrast-table-selected-row-text-color-focus: HighlightText; - --highcontrast-table-row-background-color-hover: Highlight; - --highcontrast-table-row-text-color-hover: HighlightText; + --spectrum-table-cell-background-color: var(--highcontrast-table-row-background-color, var(--mod-table-row-background-color, var(--spectrum-table-row-background-color))); + --spectrum-table-selected-cell-background-color: var(--highcontrast-table-selected-row-background-color, var(--mod-table-selected-row-background-color-non-emphasized, var(--spectrum-table-selected-row-background-color-non-emphasized))); - --highcontrast-table-section-header-text-color: Canvas; - --highcontrast-table-section-header-background-color: CanvasText; + --spectrum-table-drop-zone-background-color: rgb(var(--spectrum-drop-zone-background-color-rgb), var(--spectrum-drop-zone-background-color-opacity)); + --spectrum-table-drop-zone-outline-color: var(--spectrum-accent-visual-color); - --highcontrast-table-focus-indicator-color: Highlight; - --highcontrast-table-transition-duration: 0; - } + /* Row States */ + /* @todo Refactor or remove these properties once the RGB stripped value is available. */ + --spectrum-table-row-background-color-hover: rgb(var(--spectrum-gray-900-rgb), var(--spectrum-table-row-hover-opacity)); + --spectrum-table-row-background-color-active: rgb(var(--spectrum-gray-900-rgb), var(--spectrum-table-row-down-opacity)); /* active/down state background color */ - .spectrum-Table-cell { - /* Removes unstylable readability backplate. */ - forced-color-adjust: none; - } + /* Border */ + --spectrum-table-border-color: var(--spectrum-gray-300); + --spectrum-table-border-radius: var(--spectrum-corner-radius-medium-size-extra-small); + --spectrum-table-border-width: var(--spectrum-table-border-divider-width); + --spectrum-table-outer-border-inline-width: var(--spectrum-table-border-divider-width); - .spectrum-Table-row { - &:hover, - &:focus-visible, - &.is-focused { - .spectrum-Table-checkbox .spectrum-Checkbox-box::before { - outline: var(--highcontrast-table-row-text-color-hover) 1px solid; - } - } - } + /* Divider */ + --spectrum-table-divider-color: var(--spectrum-gray-300); - .spectrum-Table-row.is-selected, - .spectrum-Table-row.is-drop-target, - .spectrum-Table-body.is-drop-target .spectrum-Table-row { - /* Ensure negative offset outline contrasts on top of SelectedItem background. */ - --highcontrast-table-cell-focus-indicator-color: var(--highcontrast-table-selected-row-text-color); - --highcontrast-table-cell-focus-extra-offset: 1px; + /* Focus indicators */ + --spectrum-table-focus-indicator-thickness: var(--spectrum-focus-indicator-thickness); + --spectrum-table-focus-indicator-color: var(--spectrum-focus-indicator-color); + --spectrum-table-row-focus-indicator-width: var(--spectrum-side-focus-indicator); - .spectrum-Table-checkbox .spectrum-Checkbox-box::before { - outline: var(--highcontrast-table-selected-row-text-color) 1px solid; - } - } -} + /* Individual focused table cells still have a border-radius */ + --spectrum-table-focused-cell-border-radius: var(--spectrum-corner-radius-small-default); -.spectrum-Table { - --spectrum-table-cell-inline-space: var(--spectrum-table-edge-to-content); + --spectrum-table-selected-cell-background-color-focus: var(--highcontrast-table-selected-row-background-color-focus, var(--mod-table-selected-row-background-color-non-emphasized-focus, var(--spectrum-table-selected-row-background-color-non-emphasized-focus))); - --spectrum-table-border-radius: var(--spectrum-corner-radius-100); - --spectrum-table-border-width: var(--spectrum-table-border-divider-width); - --spectrum-table-outer-border-inline-width: var(--spectrum-table-border-divider-width); + /* Visual (avatar, icons, thumbnails) */ + --spectrum-table-icon-color-default: var(--spectrum-neutral-content-color-default); + --spectrum-table-icon-color-hover: var(--spectrum-neutral-content-color-hover); + --spectrum-table-icon-color-active: var(--spectrum-neutral-content-color-down); + --spectrum-table-icon-color-key-focus: var(--spectrum-neutral-content-color-key-focus); + --spectrum-table-disclosure-icon-size: var(--spectrum-component-height-100); + --spectrum-table-icon-color: var(--highcontrast-table-icon-color, var(--mod-table-icon-color-default, var(--spectrum-table-icon-color-default))); - --spectrum-table-default-vertical-align: top; - --spectrum-table-header-vertical-align: middle; + --spectrum-table-header-icons-color-default: var(--spectrum-neutral-subdued-content-color-default); + --spectrum-table-header-icons-color-hover: var(--spectrum-neutral-subdued-content-color-hover); + --spectrum-table-header-icons-color-active: var(--spectrum-neutral-subdued-content-color-down); + --spectrum-table-header-icons-color-key-focus: var(--spectrum-neutral-subdued-content-color-key-focus); + /* Alignment */ + --spectrum-table-default-vertical-align: middle; + + /* Font */ --spectrum-table-header-font-weight: var(--spectrum-bold-font-weight); + --spectrum-table-header-text-color: var(--spectrum-body-color); --spectrum-table-row-font-family: var(--spectrum-sans-font-family-stack); --spectrum-table-row-font-weight: var(--spectrum-regular-font-weight); --spectrum-table-row-font-style: var(--spectrum-default-font-style); --spectrum-table-row-line-height: var(--spectrum-line-height-100); - - --spectrum-table-border-color: var(--spectrum-gray-300); - --spectrum-table-divider-color: var(--spectrum-gray-300); - --spectrum-table-header-background-color: var(--spectrum-transparent-white-100); - --spectrum-table-header-text-color: var(--spectrum-body-color); - --spectrum-table-row-background-color: var(--spectrum-gray-50); --spectrum-table-row-text-color: var(--spectrum-neutral-content-color-default); + --spectrum-table-row-text-color-hover: var(--spectrum-neutral-content-color-hover); + --spectrum-table-row-text-color-active: var(--spectrum-neutral-content-color-down); + --spectrum-table-row-text-color-key-focus: var(--spectrum-neutral-content-color-key-focus); + --spectrum-table-row-font-size: var(--spectrum-font-size-100); - /* @todo Refactor or remove these properties once the RGB stripped value is available. */ - --spectrum-table-selected-row-background-color: rgb(var(--spectrum-blue-900-rgb), var(--spectrum-table-selected-row-background-opacity)); - --spectrum-table-selected-row-background-color-non-emphasized: rgb(var(--spectrum-gray-700-rgb), var(--spectrum-table-selected-row-background-opacity-non-emphasized)); - --spectrum-table-row-background-color-hover: rgb(var(--spectrum-gray-900-rgb), var(--spectrum-table-row-hover-opacity)); - --spectrum-table-row-active-color: rgb(var(--spectrum-gray-900-rgb), var(--spectrum-table-row-down-opacity)); - --spectrum-table-selected-row-background-color-focus: rgb(var(--spectrum-blue-900-rgb), var(--spectrum-table-selected-row-background-opacity-hover)); - --spectrum-table-selected-row-background-color-non-emphasized-focus: rgb(var(--spectrum-gray-700-rgb), var(--spectrum-table-selected-row-background-opacity-non-emphasized-hover)); + --spectrum-table-summary-row-font-weight: var(--spectrum-bold-font-weight); + --spectrum-table-section-header-font-weight: var(--spectrum-bold-font-weight); - --spectrum-table-icon-color-default: var(--spectrum-neutral-subdued-content-color-default); - --spectrum-table-icon-color-hover: var(--spectrum-neutral-subdued-content-color-hover); - --spectrum-table-icon-color-active: var(--spectrum-neutral-subdued-content-color-down); - --spectrum-table-icon-color-focus: var(--spectrum-neutral-subdued-content-color-key-focus); - --spectrum-table-icon-color-focus-hover: var(--spectrum-neutral-subdued-content-color-key-focus); - --spectrum-table-icon-color-key-focus: var(--spectrum-neutral-subdued-content-color-key-focus); + /* Size and Spacing */ + --spectrum-table-min-header-row-height: var(--spectrum-component-height-100); + --spectrum-table-header-row-top-to-text: var(--spectrum-table-column-header-row-top-to-text-medium); + --spectrum-table-header-row-bottom-to-text: var(--spectrum-table-column-header-row-bottom-to-text-medium); - --spectrum-table-focus-indicator-thickness: var(--spectrum-focus-indicator-thickness); - --spectrum-table-focus-indicator-color: var(--spectrum-focus-indicator-color); + --spectrum-table-min-row-height: var(--spectrum-table-row-height-medium); + --spectrum-table-row-top-to-text: var(--spectrum-table-row-top-to-text-medium); + --spectrum-table-row-bottom-to-text: var(--spectrum-table-row-bottom-to-text-medium); - --spectrum-table-drop-zone-background-color: rgb(var(--spectrum-drop-zone-background-color-rgb), var(--spectrum-drop-zone-background-color-opacity)); - --spectrum-table-drop-zone-outline-color: var(--spectrum-accent-visual-color); + --spectrum-table-header-row-checkbox-block-spacing: var(--spectrum-table-header-row-checkbox-to-top-medium); + --spectrum-table-row-checkbox-block-spacing: var(--spectrum-table-row-checkbox-to-top-medium); - --spectrum-table-transition-duration: var(--spectrum-animation-duration-100); + --spectrum-table-section-header-min-height: var(--spectrum-table-section-header-row-height-medium); + --spectrum-table-section-header-block-start-spacing: var(--spectrum-component-top-to-text-100); + --spectrum-table-section-header-block-end-spacing: var(--spectrum-component-bottom-to-text-100); - /* Summary Row and Section Header Row */ - --spectrum-table-summary-row-font-weight: var(--spectrum-bold-font-weight); - --spectrum-table-summary-row-background-color: var(--spectrum-gray-200); + --spectrum-table-visual-to-text: var(--spectrum-text-to-visual-300); + --spectrum-table-thumbnail-size: var(--spectrum-thumbnail-size-100); + --spectrum-table-avatar-size: var(--spectrum-avatar-size-75); - --spectrum-table-section-header-font-weight: var(--spectrum-bold-font-weight); - --spectrum-table-section-header-background-color: var(--spectrum-gray-200); + --spectrum-table-cell-inline-spacing: var(--spectrum-table-edge-to-content); + --spectrum-table-checkbox-to-cell-content: var(--spectrum-table-checkbox-to-text); - /* Collapsible and thumbnails */ --spectrum-table-collapsible-tier-indent: var(--spectrum-spacing-300); --spectrum-table-collapsible-disclosure-inline-spacing: 0px; --spectrum-table-collapsible-icon-animation-duration: var(--spectrum-animation-duration-100); - --spectrum-table-cell-background-color: var(--highcontrast-table-row-background-color, var(--mod-table-row-background-color, var(--spectrum-table-row-background-color))); - --spectrum-table-selected-cell-background-color: var(--highcontrast-table-selected-row-background-color, var(--mod-table-selected-row-background-color-non-emphasized, var(--spectrum-table-selected-row-background-color-non-emphasized))); - --spectrum-table-selected-cell-background-color-focus: var(--highcontrast-table-selected-row-background-color-focus, var(--mod-table-selected-row-background-color-non-emphasized-focus, var(--spectrum-table-selected-row-background-color-non-emphasized-focus))); - /* @passthrough */ --mod-thumbnail-size: var(--mod-table-thumbnail-size, var(--spectrum-table-thumbnail-size)); + --mod-avatar-block-size: var(--mod-table-avatar-size, var(--spectrum-table-avatar-size)); + --mod-avatar-inline-size: var(--mod-table-avatar-size, var(--spectrum-table-avatar-size)); + + /* Button for menus in header cells */ + --mod-button-font-weight: var(--mod-table-header-font-weight, var(--spectrum-table-header-font-weight)); + --mod-button-font-size: var(--mod-table-header-font-size, var(--spectrum-table-row-font-size)); + --mod-button-font-family: var(--mod-table-header-font-family, var(--spectrum-table-row-font-family)); + --mod-button-line-height: var(--mod-table-header-line-height, var(--spectrum-table-row-line-height)); + --mod-button-background-color-default: transparent; + --mod-button-background-color-hover: transparent; + --mod-button-background-color-focus: transparent; + --mod-button-background-color-down: transparent; + --mod-button-content-color-default: var(--mod-table-header-text-color, var(--spectrum-table-header-text-color)); + --mod-button-content-color-hover: var(--mod-table-header-text-color, var(--spectrum-table-header-text-color)); + --mod-button-content-color-focus: var(--mod-table-header-text-color, var(--spectrum-table-header-text-color)); + --mod-button-content-color-down: var(--mod-table-header-text-color, var(--spectrum-table-header-text-color)); + --mod-button-edge-to-text: var(--mod-table-cell-inline-spacing, var(--spectrum-table-cell-inline-spacing)); + --mod-button-padding-label-to-icon: var(--mod-table-visual-to-text, var(--spectrum-table-visual-to-text)); + --mod-button-border-radius: calc(var(--mod-table-border-radius, var(--spectrum-table-focused-cell-border-radius)) - var(--mod-table-border-width, var(--spectrum-table-border-width))); + --mod-button-focus-ring-border-radius: calc(var(--mod-table-border-radius, var(--spectrum-table-focused-cell-border-radius)) - var(--mod-table-border-width, var(--spectrum-table-border-width))); &:dir(rtl) { --spectrum-logical-rotation: matrix(-1, 0, 0, 1, 0, 0); } -} - -.spectrum-Table, -.spectrum-Table--sizeM { - --spectrum-table-min-header-height: var(--spectrum-component-height-100); - --spectrum-table-header-top-to-text: var(--spectrum-table-column-header-row-top-to-text-medium); - --spectrum-table-header-bottom-to-text: var(--spectrum-table-column-header-row-bottom-to-text-medium); - - --spectrum-table-min-row-height: var(--spectrum-table-row-height-medium-regular); - --spectrum-table-row-top-to-text: var(--spectrum-table-row-top-to-text-medium-regular); - --spectrum-table-row-bottom-to-text: var(--spectrum-table-row-bottom-to-text-medium-regular); - - --spectrum-table-icon-to-text: var(--spectrum-text-to-visual-100); - - /* Typography */ - --spectrum-table-row-font-size: var(--spectrum-font-size-100); - - /* Row Selection */ - --spectrum-table-header-checkbox-block-spacing: var(--spectrum-table-header-row-checkbox-to-top-medium); - --spectrum-table-row-checkbox-block-spacing: var(--spectrum-table-row-checkbox-to-top-medium-regular); - - /* Summary Row and Section Header Row */ - --spectrum-table-section-header-min-height: var(--spectrum-table-section-header-row-height-medium); - --spectrum-table-section-header-block-start-spacing: var(--spectrum-component-top-to-text-100); - --spectrum-table-section-header-block-end-spacing: var(--spectrum-component-bottom-to-text-100); - /* Collapsible and Thumbnails */ - --spectrum-table-disclosure-icon-size: var(--spectrum-component-height-100); - - --spectrum-table-thumbnail-block-spacing: var(--spectrum-table-thumbnail-to-top-minimum-medium-regular); - --spectrum-table-thumbnail-to-text: var(--spectrum-text-to-visual-100); - --spectrum-table-thumbnail-size: var(--spectrum-thumbnail-size-300); + &:lang(ja), + &:lang(zh), + &:lang(ko) { + --spectrum-table-row-line-height: var(--spectrum-cjk-line-height-100); + } } -.spectrum-Table--sizeS { +/********* VARIANTS *********/ +.spectrum-Table--compact { /* Size and Spacing */ - --spectrum-table-min-header-height: var(--spectrum-component-height-100); - --spectrum-table-header-top-to-text: var(--spectrum-table-column-header-row-top-to-text-small); - --spectrum-table-header-bottom-to-text: var(--spectrum-table-column-header-row-bottom-to-text-small); - - --spectrum-table-min-row-height: var(--spectrum-table-row-height-small-regular); - --spectrum-table-row-top-to-text: var(--spectrum-table-row-top-to-text-small-regular); - --spectrum-table-row-bottom-to-text: var(--spectrum-table-row-bottom-to-text-small-regular); - - --spectrum-table-icon-to-text: var(--spectrum-text-to-visual-100); - - /* Typography */ - --spectrum-table-row-font-size: var(--spectrum-font-size-75); + --spectrum-table-min-row-height: var(--mod-table-min-row-height-compact, var(--spectrum-table-row-height-medium-compact)); + --spectrum-table-row-top-to-text: var(--spectrum-table-row-top-to-text-medium-compact); + --spectrum-table-row-bottom-to-text: var(--spectrum-table-row-bottom-to-text-medium-compact); /* Row Selection */ - --spectrum-table-header-checkbox-block-spacing: var(--spectrum-table-header-row-checkbox-to-top-small); - --spectrum-table-row-checkbox-block-spacing: var(--spectrum-table-row-checkbox-to-top-small-regular); - - /* Summary Row and Section Header Row */ - --spectrum-table-section-header-min-height: var(--spectrum-table-section-header-row-height-small); - --spectrum-table-section-header-block-start-spacing: var(--spectrum-component-top-to-text-75); - --spectrum-table-section-header-block-end-spacing: var(--spectrum-component-bottom-to-text-75); + --spectrum-table-row-checkbox-block-spacing: var(--mod-table-row-checkbox-block-spacing-compact, var(--spectrum-table-row-checkbox-to-top-medium-compact)); - /* Collapsible and Thumbnails */ - --spectrum-table-disclosure-icon-size: var(--spectrum-component-height-75); - - --spectrum-table-thumbnail-block-spacing: var(--spectrum-table-thumbnail-to-top-minimum-small-regular); - --spectrum-table-thumbnail-to-text: var(--spectrum-text-to-visual-100); - --spectrum-table-thumbnail-size: var(--spectrum-thumbnail-size-200); + /* Visuals */ + --mod-table-thumbnail-size: var(--mod-table-thumbnail-size-compact, var(--spectrum-thumbnail-size-75)); + --mod-table-avatar-size: var(--mod-table-avatar-size-compact, var(--spectrum-avatar-size-50)); } -.spectrum-Table--sizeL { +.spectrum-Table--spacious { /* Size and Spacing */ - --spectrum-table-min-header-height: var(--spectrum-component-height-200); - --spectrum-table-header-top-to-text: var(--spectrum-table-column-header-row-top-to-text-large); - --spectrum-table-header-bottom-to-text: var(--spectrum-table-column-header-row-bottom-to-text-large); - - --spectrum-table-min-row-height: var(--spectrum-table-row-height-large-regular); - --spectrum-table-row-top-to-text: var(--spectrum-table-row-top-to-text-large-regular); - --spectrum-table-row-bottom-to-text: var(--spectrum-table-row-bottom-to-text-large-regular); - - --spectrum-table-icon-to-text: var(--spectrum-text-to-visual-200); - - /* Typography */ - --spectrum-table-row-font-size: var(--spectrum-font-size-200); + --spectrum-table-min-row-height: var(--mod-table-min-row-height-spacious, var(--spectrum-table-row-height-medium-spacious)); + --spectrum-table-row-top-to-text: var(--spectrum-table-row-top-to-text-medium-spacious); + --spectrum-table-row-bottom-to-text: var(--spectrum-table-row-bottom-to-text-medium-spacious); /* Row Selection */ - --spectrum-table-header-checkbox-block-spacing: var(--spectrum-table-header-row-checkbox-to-top-large); - --spectrum-table-row-checkbox-block-spacing: var(--spectrum-table-row-checkbox-to-top-large-regular); + --spectrum-table-row-checkbox-block-spacing: var(--mod-table-row-checkbox-block-spacing-spacious, var(--spectrum-table-row-checkbox-to-top-medium-spacious)); - /* Summary Row and Section Header Row */ - --spectrum-table-section-header-min-height: var(--spectrum-table-section-header-row-height-large); - --spectrum-table-section-header-block-start-spacing: var(--spectrum-component-top-to-text-200); - --spectrum-table-section-header-block-end-spacing: var(--spectrum-component-bottom-to-text-200); + /* Visuals */ + --mod-table-thumbnail-size: var(--mod-table-thumbnail-size-spacious, var(--spectrum-thumbnail-size-200)); + --mod-table-avatar-size: var(--mod-table-avatar-size-spacious, var(--spectrum-avatar-size-100)); +} - /* Collapsible and Thumbnails */ - --spectrum-table-disclosure-icon-size: var(--spectrum-component-height-200); +.spectrum-Table--emphasized, +.spectrum-Table-row .is-emphasized { + --spectrum-table-selected-cell-background-color: var(--highcontrast-table-selected-row-background-color, var(--mod-table-selected-row-background-color, var(--spectrum-table-selected-row-background-color))); + --spectrum-table-selected-cell-background-color-focus: var(--highcontrast-table-selected-row-background-color-focus, var(--mod-table-selected-row-background-color-focus, var(--spectrum-table-selected-row-background-color-hover))); +} - --spectrum-table-thumbnail-block-spacing: var(--spectrum-table-thumbnail-to-top-minimum-large-regular); - --spectrum-table-thumbnail-to-text: var(--spectrum-text-to-visual-200); - --spectrum-table-thumbnail-size: var(--spectrum-thumbnail-size-500); +.spectrum-Table--quiet { + --spectrum-table-border-radius: var(--mod-table-border-radius-quiet, 0px); + --spectrum-table-outer-border-inline-width: var(--mod-table-outer-border-inline-width-quiet, 0px); } -.spectrum-Table--sizeXL { - /* Size and Spacing */ - --spectrum-table-min-header-height: var(--spectrum-component-height-300); - --spectrum-table-header-top-to-text: var(--spectrum-table-column-header-row-top-to-text-extra-large); - --spectrum-table-header-bottom-to-text: var(--spectrum-table-column-header-row-bottom-to-text-extra-large); +.spectrum-Table-scroller { + --spectrum-table-header-background-color: var(--mod-table-header-background-color-scrollable, var(--spectrum-gray-75)); +} - --spectrum-table-min-row-height: var(--spectrum-table-row-height-extra-large-regular); - --spectrum-table-row-top-to-text: var(--spectrum-table-row-top-to-text-extra-large-regular); - --spectrum-table-row-bottom-to-text: var(--spectrum-table-row-bottom-to-text-extra-large-regular); +.spectrum-Table-row { + &:focus-visible, + &:focus { + --highcontrast-table-icon-color: var(--highcontrast-table-row-text-color-focus); + --spectrum-table-row-text-color: var(--spectrum-table-row-text-color-key-focus); - --spectrum-table-icon-to-text: var(--spectrum-text-to-visual-300); + &:hover { + --spectrum-table-row-text-color: var(--spectrum-table-row-text-color-key-focus); + } + } - /* Typography */ - --spectrum-table-row-font-size: var(--spectrum-font-size-300); + &:hover { + --highcontrast-table-row-text-color: var(--highcontrast-table-row-text-color-hover); + --highcontrast-table-icon-color: var(--highcontrast-table-row-text-color-hover); + --spectrum-table-cell-background-color: var(--highcontrast-table-row-background-color-hover, var(--mod-table-row-background-color-hover, var(--spectrum-table-row-background-color-hover))); + --spectrum-table-row-text-color: var(--highcontrast-table-row-text-color-hover, var(--mod-table-row-text-color-hover, var(--spectrum-table-row-text-color-hover))); + } - /* Row Selection */ - --spectrum-table-header-checkbox-block-spacing: var(--spectrum-table-header-row-checkbox-to-top-extra-large); - --spectrum-table-row-checkbox-block-spacing: var(--spectrum-table-row-checkbox-to-top-extra-large-regular); + &:active { + --highcontrast-table-row-text-color: var(--highcontrast-table-row-text-color-hover); + --highcontrast-table-icon-color: var(--highcontrast-table-row-text-color-hover); + --spectrum-table-cell-background-color: var(--highcontrast-table-row-background-color-hover, var(--mod-table-row-background-color-active, var(--spectrum-table-row-background-color-active))); + --spectrum-table-row-text-color: var(--highcontrast-table-row-text-color-hover, var(--mod-table-row-text-color-active, var(--spectrum-table-row-text-color-active))); + } - /* Summary Row and Section Header Row */ - --spectrum-table-section-header-min-height: var(--spectrum-table-section-header-row-height-extra-large); - --spectrum-table-section-header-block-start-spacing: var(--spectrum-component-top-to-text-300); - --spectrum-table-section-header-block-end-spacing: var(--spectrum-component-bottom-to-text-300); + &.is-selected { + --highcontrast-table-row-text-color: var(--highcontrast-table-selected-row-text-color); + --highcontrast-table-icon-color: var(--highcontrast-table-selected-row-text-color); + --spectrum-table-cell-background-color: var(--highcontrast-table-selected-row-background-color, var(--spectrum-table-selected-cell-background-color)); + --spectrum-table-divider-color: var(--spectrum-table-focus-indicator-color); + --spectrum-table-border-color: var(--spectrum-table-focus-indicator-color); - /* Collapsible and Thumbnails */ - --spectrum-table-disclosure-icon-size: var(--spectrum-component-height-300); + &:hover, + &:focus-visible { + --highcontrast-table-row-text-color: var(--highcontrast-table-selected-row-text-color-focus); + --highcontrast-table-icon-color: var(--highcontrast-table-selected-row-text-color-focus); + --spectrum-table-cell-background-color: var(--highcontrast-table-selected-row-background-color-focus, var(--spectrum-table-selected-cell-background-color-focus)); + } - --spectrum-table-thumbnail-block-spacing: var(--spectrum-table-thumbnail-to-top-minimum-extra-large-regular); - --spectrum-table-thumbnail-to-text: var(--spectrum-text-to-visual-300); - --spectrum-table-thumbnail-size: var(--spectrum-thumbnail-size-700); -} + &:active { + --spectrum-table-cell-background-color: var(--spectrum-table-selected-row-background-color-active); + } + } -/********* VARIANTS *********/ -.spectrum-Table--compact { - /* Size and Spacing */ - --mod-table-min-row-height: var(--mod-table-min-row-height--compact, var(--spectrum-table-row-height-medium-compact)); - --mod-table-row-top-to-text: var(--mod-table-row-top-to-text--compact, var(--spectrum-table-row-top-to-text-medium-compact)); - --mod-table-row-bottom-to-text: var(--mod-table-row-bottom-to-text--compact, var(--spectrum-table-row-bottom-to-text-medium-compact)); + &.is-drop-target, + .spectrum-Table-body.is-drop-target & { + --highcontrast-table-row-text-color: var(--highcontrast-table-selected-row-text-color); + --highcontrast-table-icon-color: var(--highcontrast-table-selected-row-text-color); + --spectrum-table-cell-background-color: var(--highcontrast-table-selected-row-background-color, var(--mod-table-drop-zone-background-color, var(--spectrum-table-drop-zone-background-color))); + } +} - /* Row Selection */ - --mod-table-row-checkbox-block-spacing: var(--mod-table-row-checkbox-block-spacing--compact, var(--spectrum-table-row-checkbox-to-top-medium-compact)); +.spectrum-Table-headCell { + &.is-sortable, + &.spectrum-Table-hasMenuButton, + .spectrum-Table-sortButton { + --spectrum-table-icon-color: var(--highcontrast-table-icon-color, var(--mod-table-header-icons-color-default, var(--spectrum-table-header-icons-color-default))); - /* Collapsible and Thumbnails */ - --mod-table-thumbnail-block-spacing: var(--mod-table-thumbnail-block-spacing-compact, var(--spectrum-table-thumbnail-to-top-minimum-medium-compact)); - --mod-table-thumbnail-size: var(--mod-table-thumbnail-size-compact, var(--spectrum-thumbnail-size-200)); + &:hover { + --spectrum-table-icon-color: var(--highcontrast-table-icon-color-focus, var(--mod-table-header-icons-color-hover, var(--spectrum-table-header-icons-color-hover))); + } - &.spectrum-Table--sizeS { - /* Size and Spacing */ - --mod-table-min-row-height: var(--mod-table-min-row-height--compact, var(--spectrum-table-row-height-small-compact)); - --mod-table-row-top-to-text: var(--mod-table-row-top-to-text--compact, var(--spectrum-table-row-top-to-text-small-compact)); - --mod-table-row-bottom-to-text: var(--mod-table-row-bottom-to-text--compact, var(--spectrum-table-row-bottom-to-text-small-compact)); + &:active { + --spectrum-table-icon-color: var(--highcontrast-table-icon-color-focus, var(--mod-table-header-icons-color-active, var(--spectrum-table-header-icons-color-active))); + } - /* Row Selection */ - --mod-table-row-checkbox-block-spacing: var(--mod-table-row-checkbox-block-spacing--compact, var(--spectrum-table-row-checkbox-to-top-small-compact)); + &:focus, + &:focus-visible, + &.is-keyboardFocused { + --spectrum-table-icon-color: var(--highcontrast-table-icon-color-focus, var(--mod-table-header-icons-color-key-focus, var(--spectrum-table-header-icons-color-key-focus))); + } + } - /* Collapsible and Thumbnails */ - --mod-table-thumbnail-block-spacing: var(--mod-table-thumbnail-block-spacing-compact, var(--spectrum-table-thumbnail-to-top-minimum-small-compact)); - --mod-table-thumbnail-size: var(--mod-table-thumbnail-size-compact, var(--spectrum-thumbnail-size-50)); + /* These styles get applied to the headCell when the headCell has the --hasMenuButton class. */ + &.spectrum-Table-hasMenuButton { + --spectrum-table-cell-inline-spacing: 0; + --spectrum-table-header-row-top-to-text: 0; + --spectrum-table-header-row-bottom-to-text: 0; } - &.spectrum-Table--sizeL { - /* Size and Spacing */ - --mod-table-min-row-height: var(--mod-table-min-row-height--compact, var(--spectrum-table-row-height-large-compact)); - --mod-table-row-top-to-text: var(--mod-table-row-top-to-text--compact, var(--spectrum-table-row-top-to-text-large-compact)); - --mod-table-row-bottom-to-text: var(--mod-table-row-bottom-to-text--compact, var(--spectrum-table-row-bottom-to-text-large-compact)); + /* These styles get applied to the icon within that menu button. */ + & .spectrum-Table-menuButton { + --mod-icon-color: var(--spectrum-table-header-icons-color-default); - /* Row Selection */ - --mod-table-row-checkbox-block-spacing: var(--mod-table-row-checkbox-block-spacing--compact, var(--spectrum-table-row-checkbox-to-top-large-compact)); + &:hover { + --mod-icon-color: var(--spectrum-table-header-icons-color-hover); + } - /* Collapsible and Thumbnails */ - --mod-table-thumbnail-block-spacing: var(--mod-table-thumbnail-block-spacing-compact, var(--spectrum-table-thumbnail-to-top-minimum-large-compact)); - --mod-table-thumbnail-size: var(--mod-table-thumbnail-size-compact, var(--spectrum-thumbnail-size-300)); - } + &:active { + --mod-icon-color: var(--spectrum-table-header-icons-color-active); + } - &.spectrum-Table--sizeXL { - /* Size and Spacing */ - --mod-table-min-row-height: var(--mod-table-min-row-height--compact, var(--spectrum-table-row-height-extra-large-compact)); - --mod-table-row-top-to-text: var(--mod-table-row-top-to-text--compact, var(--spectrum-table-row-top-to-text-extra-large-compact)); - --mod-table-row-bottom-to-text: var(--mod-table-row-bottom-to-text--compact, var(--spectrum-table-row-bottom-to-text-extra-large-compact)); + &:focus, + &:focus:hover, + &:focus-visible { + --mod-icon-color: var(--spectrum-table-header-icons-color-key-focus); + } + } +} - /* Row Selection */ - --mod-table-row-checkbox-block-spacing: var(--mod-table-row-checkbox-block-spacing--compact, var(--spectrum-table-row-checkbox-to-top-extra-large-compact)); +.spectrum-Table-row--summary { + --spectrum-table-cell-background-color: var(--highcontrast-table-row-background-color, var(--mod-table-summary-row-background-color, var(--spectrum-table-summary-row-background-color))); - /* Collapsible and Thumbnails */ - --mod-table-thumbnail-block-spacing: var(--mod-table-thumbnail-block-spacing-compact, var(--spectrum-table-thumbnail-to-top-minimum-extra-large-compact)); - --mod-table-thumbnail-size: var(--mod-table-thumbnail-size-compact, var(--spectrum-thumbnail-size-500)); + &:hover { + --spectrum-table-cell-background-color: var(--highcontrast-table-row-background-color, var(--mod-table-summary-row-background-color, var(--spectrum-table-summary-row-background-color))); } } -.spectrum-Table--spacious { - /* Size and Spacing */ - --mod-table-min-row-height: var(--mod-table-min-row-height--spacious, var(--spectrum-table-row-height-medium-spacious)); - --mod-table-row-top-to-text: var(--mod-table-row-top-to-text--spacious, var(--spectrum-table-row-top-to-text-medium-spacious)); - --mod-table-row-bottom-to-text: var(--mod-table-row-bottom-to-text--spacious, var(--spectrum-table-row-bottom-to-text-medium-spacious)); +.spectrum-Table-row--sectionHeader { + --spectrum-table-cell-background-color: var(--highcontrast-table-section-header-background-color, var(--mod-table-section-header-background-color, var(--spectrum-table-section-header-background-color))); - /* Row Selection */ - --mod-table-row-checkbox-block-spacing: var(--mod-table-row-checkbox-block-spacing--spacious, var(--spectrum-table-row-checkbox-to-top-medium-spacious)); + &:hover { + --highcontrast-table-row-text-color: var(--highcontrast-table-section-header-text-color); + --spectrum-table-cell-background-color: var(--highcontrast-table-section-header-background-color, var(--mod-table-section-header-background-color, var(--spectrum-table-section-header-background-color))); + } +} + +/********* REGULAR / DEFAULT TABLE *********/ +.spectrum-Table:not(.spectrum-Table-scroller), +.spectrum-Table-main { + border-collapse: separate; + border-spacing: 0; + display: table; +} - /* Collapsible and Thumbnails */ - --mod-table-thumbnail-block-spacing: var(--mod-table-thumbnail-block-spacing-spacious, var(--spectrum-table-thumbnail-to-top-minimum-medium-spacious)); - --mod-table-thumbnail-size: var(--mod-table-thumbnail-size-spacious, var(--spectrum-thumbnail-size-500)); +/********* HEAD CELLS *********/ +.spectrum-Table-headRow { + .spectrum-Table-headCell { + box-sizing: border-box; + text-align: start; + vertical-align: var(--mod-table-header-vertical-align, var(--spectrum-table-default-vertical-align)); - &.spectrum-Table--sizeS { - /* Size and Spacing */ - --mod-table-min-row-height: var(--mod-table-min-row-height--spacious, var(--spectrum-table-row-height-small-spacious)); - --mod-table-row-top-to-text: var(--mod-table-row-top-to-text--spacious, var(--spectrum-table-row-top-to-text-small-spacious)); - --mod-table-row-bottom-to-text: var(--mod-table-row-bottom-to-text--spacious, var(--spectrum-table-row-bottom-to-text-small-spacious)); + font-family: var(--mod-table-header-font-family, var(--spectrum-table-row-font-family)); + font-size: var(--mod-table-header-font-size, var(--spectrum-table-row-font-size)); + font-weight: var(--mod-table-header-font-weight, var(--spectrum-table-header-font-weight)); + font-style: var(--mod-table-header-font-style, var(--spectrum-table-row-font-style)); + line-height: var(--mod-table-header-line-height, var(--spectrum-table-row-line-height)); + text-transform: var(--mod-table-header-text-transform, none); - /* Row Selection */ - --mod-table-row-checkbox-block-spacing: var(--mod-table-row-checkbox-block-spacing--spacious, var(--spectrum-table-row-checkbox-to-top-small-spacious)); + /* block-size functions as min-block-size when using display table-cell. */ + block-size: var(--mod-table-min-header-height, var(--spectrum-table-min-header-row-height)); - /* Collapsible and Thumbnails */ - --mod-table-thumbnail-block-spacing: var(--mod-table-thumbnail-block-spacing-spacious, var(--spectrum-table-thumbnail-to-top-minimum-small-spacious)); - --mod-table-thumbnail-size: var(--mod-table-thumbnail-size-spacious, var(--spectrum-thumbnail-size-300)); - } + padding-block: var(--mod-table-header-row-top-to-text, var(--spectrum-table-header-row-top-to-text)) var(--mod-table-header-row-bottom-to-text, var(--spectrum-table-header-row-bottom-to-text)); + padding-inline: var(--mod-table-cell-inline-spacing, var(--spectrum-table-cell-inline-spacing)); - &.spectrum-Table--sizeL { - /* Size and Spacing */ - --mod-table-min-row-height: var(--mod-table-min-row-height--spacious, var(--spectrum-table-row-height-large-spacious)); - --mod-table-row-top-to-text: var(--mod-table-row-top-to-text--spacious, var(--spectrum-table-row-top-to-text-large-spacious)); - --mod-table-row-bottom-to-text: var(--mod-table-row-bottom-to-text--spacious, var(--spectrum-table-row-bottom-to-text-large-spacious)); + color: var(--mod-table-header-text-color, var(--spectrum-table-header-text-color)); + background-color: var(--mod-table-header-background-color, var(--spectrum-table-header-background-color)); + border-block-start: var(--mod-table-border-width, var(--spectrum-table-border-width)) solid var(--highcontrast-table-border-color, var(--mod-table-border-color, var(--spectrum-table-border-color))); - /* Row Selection */ - --mod-table-row-checkbox-block-spacing: var(--mod-table-row-checkbox-block-spacing--spacious, var(--spectrum-table-row-checkbox-to-top-large-spacious)); + cursor: var(--mod-table-cursor-header-default, initial); + outline: 0; - /* Collapsible and Thumbnails */ - --mod-table-thumbnail-block-spacing: var(--mod-table-thumbnail-block-spacing-spacious, var(--spectrum-table-thumbnail-to-top-minimum-large-spacious)); - --mod-table-thumbnail-size: var(--mod-table-thumbnail-size-spacious, var(--spectrum-thumbnail-size-700)); + &.is-sortable { + cursor: var(--mod-table-cursor-header-sortable, pointer); + } } - &.spectrum-Table--sizeXL { - /* Size and Spacing */ - --mod-table-min-row-height: var(--mod-table-min-row-height--spacious, var(--spectrum-table-row-height-extra-large-spacious)); - --mod-table-row-top-to-text: var(--mod-table-row-top-to-text--spacious, var(--spectrum-table-row-top-to-text-extra-large-spacious)); - --mod-table-row-bottom-to-text: var(--mod-table-row-bottom-to-text--spacious, var(--spectrum-table-row-bottom-to-text-extra-large-spacious)); + /* Places the focus indicator above the table cell borders. */ + .spectrum-ActionButton::after { + z-index: 1; + } - /* Row Selection */ - --mod-table-row-checkbox-block-spacing: var(--mod-table-row-checkbox-block-spacing--spacious, var(--spectrum-table-row-checkbox-to-top-extra-large-spacious)); + &:first-child .spectrum-Table-headCell:first-child { + border-start-start-radius: var(--mod-table-border-radius, var(--spectrum-table-border-radius)); + border-inline-start: var(--mod-table-border-width, var(--spectrum-table-border-width)) solid var(--highcontrast-table-border-color, var(--mod-table-border-color, var(--spectrum-table-border-color))); + } - /* Collapsible and Thumbnails */ - --mod-table-thumbnail-block-spacing: var(--mod-table-thumbnail-block-spacing-spacious, var(--spectrum-table-thumbnail-to-top-minimum-extra-large-spacious)); - --mod-table-thumbnail-size: var(--mod-table-thumbnail-size-spacious, var(--spectrum-thumbnail-size-800)); + &:last-child .spectrum-Table-headCell:last-child { + border-start-end-radius: var(--mod-table-border-radius, var(--spectrum-table-border-radius)); + border-inline-end: var(--mod-table-border-width, var(--spectrum-table-border-width)) solid var(--highcontrast-table-border-color, var(--mod-table-border-color, var(--spectrum-table-border-color))); } -} -.spectrum-Table--emphasized { - --spectrum-table-selected-cell-background-color: var(--highcontrast-table-selected-row-background-color, var(--mod-table-selected-row-background-color, var(--spectrum-table-selected-row-background-color))); - --spectrum-table-selected-cell-background-color-focus: var(--highcontrast-table-selected-row-background-color-focus, var(--mod-table-selected-row-background-color-focus, var(--spectrum-table-selected-row-background-color-focus))); -} + /* Checkbox cell in header row */ + .spectrum-Table-checkboxCell { + padding-inline-start: calc(var(--mod-table-cell-inline-spacing, var(--spectrum-table-cell-inline-spacing)) - var(--mod-table-outer-border-inline-width, var(--spectrum-table-outer-border-inline-width))); -.spectrum-Table--quiet { - --mod-table-border-radius: var(--mod-table-border-radius--quiet, 0px); - --mod-table-outer-border-inline-width: var(--mod-table-outer-border-inline-width--quiet, 0px); - --mod-table-header-background-color: var(--mod-table-header-background-color--quiet, var(--spectrum-transparent-white-100)); - --mod-table-row-background-color: var(--mod-table-row-background-color--quiet, var(--spectrum-transparent-white-100)); -} + /* the calc subtraction is because the --spectrum-table-checkbox-to-text spacing value + includes the inline start padding in the adjacent cell. */ + padding-inline-end: calc(var(--mod-table-checkbox-to-cell-content, var(--spectrum-table-checkbox-to-cell-content)) - var(--mod-table-cell-inline-spacing, var(--spectrum-table-cell-inline-spacing))); + padding-block: var(--mod-table-header-row-checkbox-block-spacing, var(--spectrum-table-header-row-checkbox-block-spacing)); -/********* REGULAR / DEFAULT *********/ -.spectrum-Table:not(.spectrum-Table-scroller), -.spectrum-Table-main { - border-collapse: separate; - border-spacing: 0; - display: table; + .spectrum-Table-checkbox { + --mod-checkbox-margin-block: 0px; + + min-block-size: initial; + } + } } -.spectrum-Table-sortedIcon { - display: none; - vertical-align: baseline; - margin-inline-start: var(--mod-table-sort-icon-inline-start-spacing, 0); - margin-inline-end: var(--mod-table-sort-icon-inline-end-spacing, var(--mod-table-icon-to-text, var(--spectrum-table-icon-to-text))); - transition: transform var(--highcontrast-table-transition-duration, var(--mod-table-transition-duration, var(--spectrum-table-transition-duration))) ease-in-out; +/* Quiet table header rows do not have inline borders */ +.spectrum-Table--quiet .spectrum-Table-headRow:first-child { + .spectrum-Table-headCell:first-child { + border-inline-start: 0; + } + + .spectrum-Table-headCell:last-child { + border-inline-end: 0; + } } -.spectrum-Table-menuIcon { +/********* ICONS- SORT, DISCLOSURE/MENU *********/ +/* Head cell column text */ +.spectrum-Table-columnTitle { + display: inline-block; vertical-align: middle; - margin-inline-start: var(--mod-table-icon-to-text, var(--spectrum-table-icon-to-text)); } -.spectrum-Table-headCell { - --spectrum-table-icon-color: var(--highcontrast-table-icon-color, var(--mod-table-icon-color-default, var(--spectrum-table-icon-color-default))); - - box-sizing: border-box; - text-align: start; - vertical-align: var(--mod-table-header-vertical-align, var(--spectrum-table-header-vertical-align)); - - font-family: var(--mod-table-header-font-family, var(--spectrum-table-row-font-family)); - font-size: var(--mod-table-header-font-size, var(--spectrum-table-row-font-size)); - font-weight: var(--mod-table-header-font-weight, var(--spectrum-table-header-font-weight)); - line-height: var(--mod-table-header-line-height, var(--spectrum-table-row-line-height)); - text-transform: var(--mod-table-header-text-transform, none); +/* A "sortable-only" head cell has no padding around its button. */ +.spectrum-Table-headCell.is-sortable { + padding: 0; - /* block-size functions as min-block-size when using display table-cell. */ - block-size: var(--mod-table-min-header-height, var(--spectrum-table-min-header-height)); + /* Ensure the button text color is the same as the header text color, particularly in high contrast mode. */ + .spectrum-Table-sortButton { + color: var(--highcontrast-table-header-text-color, var(--mod-table-header-text-color, var(--spectrum-table-header-text-color))); - padding-block: var(--mod-table-header-top-to-text, var(--spectrum-table-header-top-to-text)) var(--mod-table-header-bottom-to-text, var(--spectrum-table-header-bottom-to-text)); - padding-inline: var(--mod-table-cell-inline-space, var(--spectrum-table-cell-inline-space)); + /* Avoids flash of a different text color from the button in WHCM. */ + forced-color-adjust: none; - color: var(--mod-table-header-text-color, var(--spectrum-table-header-text-color)); - background-color: var(--mod-table-header-background-color, var(--spectrum-table-header-background-color)); + &:hover, + &:focus, + &:focus-visible, + &:active { + color: var(--highcontrast-table-header-text-color-hover, var(--mod-table-header-text-color, var(--spectrum-table-header-text-color))); + } + } - border-radius: 0; - transition: color var(--highcontrast-table-transition-duration, var(--mod-table-transition-duration, var(--spectrum-table-transition-duration))) ease-in-out; - cursor: var(--mod-table-cursor-header-default, initial); - outline: 0; + /* Focus indicator- brings the focus indicator above the border and matches the table cell dimensions. */ + .spectrum-Table-sortButton::after { + inset: calc(3 * var(--mod-table-border-width, var(--spectrum-table-border-width))); + z-index: 1; + } - .spectrum-Table-sortedIcon, - .spectrum-Table-menuIcon { + .spectrum-Table-sortButton .spectrum-Icon { color: var(--spectrum-table-icon-color); + transition: transform var(--highcontrast-table-transition-duration, var(--mod-table-transition-duration, var(--spectrum-table-transition-duration))) ease-in-out; } +} - &.is-sortable { - cursor: var(--mod-table-cursor-header-sortable, pointer); +/* Head cell column text in the button that opens the menu */ +.spectrum-Table-headCell.spectrum-Table-hasMenuButton { + .spectrum-Table-sortButton { + min-inline-size: 100%; + justify-content: flex-start; + color: var(--highcontrast-table-header-text-color, var(--mod-table-header-text-color, var(--spectrum-table-header-text-color))); + + /* Avoids flash of a different text color from the button in WHCM. */ + forced-color-adjust: none; &:hover { - --spectrum-table-icon-color: var(--highcontrast-table-icon-color-focus, var(--mod-table-icon-color-hover, var(--spectrum-table-icon-color-hover))); + color: var(--highcontrast-table-header-text-color-hover, var(--mod-table-header-text-color, var(--spectrum-table-header-text-color))); } - &:active { - --spectrum-table-icon-color: var(--highcontrast-table-icon-color-focus, var(--mod-table-icon-color-active, var(--spectrum-table-icon-color-active))); - } + /* Focus indicator- brings the focus indicator above the cell borders and matches the table cell dimensions. */ + &:focus-visible::after { + inset: var(--mod-table-border-width, var(--spectrum-table-border-width)); + z-index: 1; - &:focus { - --spectrum-table-icon-color: var(--highcontrast-table-icon-color-focus, var(--mod-table-icon-color-focus, var(--spectrum-table-icon-color-focus))); - } + /* Remove the box-shadow of .spectrum-Button, which was generating a different corner radius for the focus indicator. */ + box-shadow: none; - &:focus:hover { - --spectrum-table-icon-color: var(--highcontrast-table-icon-color-focus, var(--mod-table-icon-color-focus-hover, var(--spectrum-table-icon-color-focus-hover))); + /* Add focus indicator border to match the other table cell focus indicators. */ + border: var(--mod-table-focus-indicator-thickness, var(--spectrum-table-focus-indicator-thickness)) solid var(--highcontrast-table-cell-focus-indicator-color, var(--highcontrast-table-focus-indicator-color, var(--mod-table-focus-indicator-color, var(--spectrum-table-focus-indicator-color)))); } - &:focus-visible, - &.is-keyboardFocused { - --spectrum-table-icon-color: var(--highcontrast-table-icon-color-focus, var(--mod-table-icon-color-key-focus, var(--spectrum-table-icon-color-key-focus))); + .spectrum-Button-label { + vertical-align: middle; + display: inline-block; } - } - &.is-sorted-asc, - &.is-sorted-desc { - .spectrum-Table-sortedIcon { + .spectrum-Button-label::after { + content: ""; display: inline-block; + mask-image: url('data:image/svg+xml,'); + mask-size: contain; + mask-repeat: no-repeat; + mask-position: center; + + block-size: 10px; + inline-size: 10px; + background-color: var(--spectrum-table-icon-color); + transform: rotate(90deg); + vertical-align: middle; + margin-inline-start: var(--mod-table-visual-to-text, var(--spectrum-table-visual-to-text)); } - } - &.is-sorted-asc { - .spectrum-Table-sortedIcon { - transform: rotateZ(-90deg); + & .spectrum-Icon { + transition: transform var(--highcontrast-table-transition-duration, var(--mod-table-transition-duration, var(--spectrum-table-transition-duration))) ease-in-out; + color: var(--spectrum-table-icon-color); } } } -.spectrum-Table-columnTitle { - display: inline-block; -} - -.spectrum-Table-cell--alignCenter { - text-align: center; +/********* TEXT ALIGNMENT *********/ +.spectrum-Table-cell--alignStart { + text-align: start; } -.spectrum-Table-cell--alignRight { +.spectrum-Table-cell--alignEnd, +.spectrum-Table-headRow .spectrum-Table-headCell--alignEnd { text-align: end; } +/********* TABLE BODY *********/ .spectrum-Table-body { position: relative; border: none; - border-radius: var(--mod-table-border-radius, var(--spectrum-table-border-radius)); + border-end-start-radius: calc(var(--mod-table-border-radius, var(--spectrum-table-border-radius)) - var(--mod-table-border-width, var(--spectrum-table-border-width))); + border-end-end-radius: calc(var(--mod-table-border-radius, var(--spectrum-table-border-radius)) - var(--mod-table-border-width, var(--spectrum-table-border-width))); display: table-row-group; &.is-drop-target { - /* Make sure negative offset outline is not covered by borders. */ + /* Make sure borders are not visible behind the pseudo-element */ --mod-table-border-color: transparent; - outline-width: var(--mod-table-focus-indicator-thickness, var(--spectrum-table-focus-indicator-thickness)); - outline-style: solid; - outline-color: var(--highcontrast-table-focus-indicator-color, var(--mod-table-drop-zone-outline-color, var(--spectrum-table-drop-zone-outline-color))); + /* Remove the outline since we'll replace it with an ::after pseudo-element */ + outline: none; + position: relative; + z-index: 0; + + &::after { + content: ""; + position: absolute; + inset: 0; + border-end-start-radius: var(--mod-table-border-radius, var(--spectrum-table-border-radius)); + border-end-end-radius: var(--mod-table-border-radius, var(--spectrum-table-border-radius)); + border: var(--mod-table-focus-indicator-thickness, var(--spectrum-table-focus-indicator-thickness)) solid var(--highcontrast-table-focus-indicator-color, var(--mod-table-drop-zone-outline-color, var(--spectrum-table-drop-zone-outline-color))); + pointer-events: none; + z-index: 1; + } } } -/* Outside border, row divider lines, and rounded corners: +/********* CELLS *********/ +.spectrum-Table-cell { + /* Outside border, row divider lines, and rounded corners: The tbody tag doesn't allow setting a border or border-radius. To make them work, border styles are instead applied to the individual cells around the outside, while using border-collapse: separate. */ -/* Row divider lines */ -.spectrum-Table-cell { + /* Row divider lines */ border-block-start: var(--mod-table-border-width, var(--spectrum-table-border-width)) solid var(--highcontrast-table-divider-color, var(--mod-table-divider-color, var(--spectrum-table-divider-color))); /* Cells within table body */ box-sizing: border-box; + font-family: var(--mod-table-row-font-family, var(--spectrum-table-row-font-family)); + font-style: var(--mod-table-row-font-style, var(--spectrum-table-row-font-style)); font-size: var(--mod-table-row-font-size, var(--spectrum-table-row-font-size)); font-weight: var(--mod-table-row-font-weight, var(--spectrum-table-row-font-weight)); line-height: var(--mod-table-row-line-height, var(--spectrum-table-row-line-height)); @@ -537,13 +554,44 @@ padding-block-start: calc(var(--mod-table-row-top-to-text, var(--spectrum-table-row-top-to-text)) - var(--mod-table-border-width, var(--spectrum-table-border-width))); padding-block-end: var(--mod-table-row-bottom-to-text, var(--spectrum-table-row-bottom-to-text)); - padding-inline: calc(var(--mod-table-edge-to-content, var(--spectrum-table-edge-to-content)) - var(--mod-table-outer-border-inline-width, var(--spectrum-table-outer-border-inline-width))); + padding-inline: calc(var(--mod-table-cell-inline-spacing, var(--spectrum-table-cell-inline-spacing)) - var(--mod-table-outer-border-inline-width, var(--spectrum-table-outer-border-inline-width))); } -/* Outside border */ +/* Focus Indicator (Ring) */ +.spectrum-Table-cell, +.spectrum-Table-headCell { + position: relative; + display: table-cell; + + &:focus, + &:focus-visible { + position: relative; + + /* Remove the outline since we'll replace it with an ::after pseudo-element */ + outline: none; + z-index: 1; /* Ensure cell focus indicator appears above row focus indicator */ + + &::after { + content: ""; + position: absolute; + inset: calc(-1 * var(--mod-table-border-width, var(--spectrum-table-border-width))); + border-radius: calc(var(--mod-table-border-radius, var(--spectrum-table-focused-cell-border-radius)) - var(--mod-table-border-width, var(--spectrum-table-border-width))); + border: var(--mod-table-focus-indicator-thickness, var(--spectrum-table-focus-indicator-thickness)) solid var(--highcontrast-table-cell-focus-indicator-color, var(--highcontrast-table-focus-indicator-color, var(--mod-table-focus-indicator-color, var(--spectrum-table-focus-indicator-color)))); + pointer-events: none; + } + } +} + +/* Cells that display a column divider (vertical border). */ +.spectrum-Table-cell--divider { + border-inline-end: var(--mod-table-border-width, var(--spectrum-table-border-width)) solid var(--highcontrast-table-divider-color, var(--mod-table-divider-color, var(--spectrum-table-divider-color))); +} + +/********* ROWS *********/ +/* Outside border (the table's border) */ .spectrum-Table-body .spectrum-Table-row { &:first-child .spectrum-Table-cell { - border-block-start: var(--mod-table-border-width, var(--spectrum-table-border-width)) solid var(--highcontrast-table-border-color, var(--mod-table-border-color, var(--spectrum-table-border-color))); + border-block-start: var(--mod-table-border-width, var(--spectrum-table-border-width)) solid var(--highcontrast-table-border-color, var(--mod-table-divider-color, var(--spectrum-table-divider-color))); } &:last-child .spectrum-Table-cell { @@ -567,18 +615,22 @@ cursor: var(--mod-table-cursor-row-default, pointer); border-block-start: none; - &:first-child .spectrum-Table-cell:first-child { - border-start-start-radius: var(--mod-table-border-radius, var(--spectrum-table-border-radius)); + /* most cells within the table body have no border-radius */ + .spectrum-Table-cell { + border-radius: 0; } + /* first cell of first row in table body */ &:first-child .spectrum-Table-cell:last-child { - border-start-end-radius: var(--mod-table-border-radius, var(--spectrum-table-border-radius)); + border-radius: 0; } + /* first cell of last row in table body */ &:last-child .spectrum-Table-cell:first-child { border-end-start-radius: var(--mod-table-border-radius, var(--spectrum-table-border-radius)); } + /* last cell of last row in table body */ &:last-child .spectrum-Table-cell:last-child { border-end-end-radius: var(--mod-table-border-radius, var(--spectrum-table-border-radius)); } @@ -594,48 +646,56 @@ border-end-end-radius: var(--mod-table-border-radius, var(--spectrum-table-border-radius)); } - &:focus { - outline: 0; - } - - &:hover, - &:focus-visible, - &.is-focused { - --highcontrast-table-row-text-color: var(--highcontrast-table-row-text-color-hover); - --highcontrast-table-icon-color: var(--highcontrast-table-row-text-color-hover); - --spectrum-table-cell-background-color: var(--highcontrast-table-row-background-color-hover, var(--mod-table-row-background-color-hover, var(--spectrum-table-row-background-color-hover))); + /* Selected rows */ + &.is-selected { + .spectrum-Table-cell { + /* Remove bottom border by default for all selected rows to conditionally add it back. */ + border-block-end: none; + } } - &:active { - --highcontrast-table-row-text-color: var(--highcontrast-table-row-text-color-hover); - --highcontrast-table-icon-color: var(--highcontrast-table-row-text-color-hover); - --spectrum-table-cell-background-color: var(--highcontrast-table-row-background-color-hover, var(--mod-table-row-active-color, var(--spectrum-table-row-active-color))); + /* Adding the bottom border only to the last selected row in a sequence achieves 1px border between adjacent selected rows */ + &.is-selected:not(:has(+ .is-selected)) .spectrum-Table-cell { + border-block-end: var(--mod-table-border-width, var(--spectrum-table-border-width)) solid var(--highcontrast-table-focus-indicator-color, var(--mod-table-focus-indicator-color, var(--spectrum-table-focus-indicator-color))); } - &.is-selected { - --highcontrast-table-row-text-color: var(--highcontrast-table-selected-row-text-color); - --highcontrast-table-icon-color: var(--highcontrast-table-selected-row-text-color); - --spectrum-table-cell-background-color: var(--highcontrast-table-selected-row-background-color, var(--spectrum-table-selected-cell-background-color)); + /* Row focus indicator */ + &:focus-visible, + &:focus { + outline: none; - &:hover, - &:focus-visible, - &.is-focused { - --highcontrast-table-row-text-color: var(--highcontrast-table-selected-row-text-color-focus); - --highcontrast-table-icon-color: var(--highcontrast-table-selected-row-text-color-focus); - --spectrum-table-cell-background-color: var(--highcontrast-table-selected-row-background-color-focus, var(--spectrum-table-selected-cell-background-color-focus)); + /* First cell of focused rows need fancy new focus indicator borders & no border-radius, and the thicker row focus indicator */ + .spectrum-Table-cell:first-child { + position: relative; + border-inline-start: 0; + + /* Because the ::before element technically removes the table's inline border, the first cell needs the entire cell-inline-padding padding to avoid horizontal layout shift when a row is focused. */ + padding-inline-start: var(--mod-table-cell-inline-spacing, var(--spectrum-table-cell-inline-spacing)); + + /* The side row focus indicator line */ + &::before { + content: ""; + position: absolute; + inset-block-start: 0; + inset-block-end: 0; + inset-inline-start: 0; + inline-size: var(--spectrum-table-row-focus-indicator-width); + background-color: var(--spectrum-table-focus-indicator-color); + z-index: 1; + } } - } - &.is-drop-target, - .spectrum-Table-body.is-drop-target & { - --highcontrast-table-row-text-color: var(--highcontrast-table-selected-row-text-color); - --highcontrast-table-icon-color: var(--highcontrast-table-selected-row-text-color); - --spectrum-table-cell-background-color: var(--highcontrast-table-selected-row-background-color, var(--mod-table-drop-zone-background-color, var(--spectrum-table-drop-zone-background-color))); + /* In a focused row that is last in the table, the first cell needs rounded corners at the bottom of the row focus indicator line */ + &:last-child .spectrum-Table-cell:first-child::before { + border-end-start-radius: var(--mod-table-border-radius, var(--spectrum-table-border-radius)); + } } &.is-drop-target { /* Make sure negative offset outline is not covered by borders. */ --mod-table-border-color: var(--highcontrast-table-focus-indicator-color, transparent); + border-start-start-radius: 0; + border-start-end-radius: 0; outline-width: var(--mod-table-focus-indicator-thickness, var(--spectrum-table-focus-indicator-thickness)); outline-style: solid; @@ -648,33 +708,15 @@ } } -/* Focus Indicator (Ring) */ -.spectrum-Table-cell, -.spectrum-Table-headCell { - position: relative; - display: table-cell; - - &:focus-visible, - &.is-focused { - outline-width: var(--mod-table-focus-indicator-thickness, var(--spectrum-table-focus-indicator-thickness)); - outline-style: solid; - outline-color: var(--highcontrast-table-cell-focus-indicator-color, var(--highcontrast-table-focus-indicator-color, var(--mod-table-focus-indicator-color, var(--spectrum-table-focus-indicator-color)))); - outline-offset: calc((-1 * var(--mod-table-focus-indicator-thickness, var(--spectrum-table-focus-indicator-thickness))) - var(--highcontrast-table-cell-focus-extra-offset, 0px)); - } -} - -/* Cells that display a column divider (vertical border). */ -.spectrum-Table-cell--divider { - border-inline-end: var(--mod-table-border-width, var(--spectrum-table-border-width)) solid var(--highcontrast-table-divider-color, var(--mod-table-divider-color, var(--spectrum-table-divider-color))); -} - .spectrum-Table-row--summary { - --spectrum-table-cell-background-color: var(--highcontrast-table-row-background-color, var(--mod-table-summary-row-background-color, var(--spectrum-table-summary-row-background-color))); - .spectrum-Table-cell { font-weight: var(--mod-table-summary-row-font-weight, var(--spectrum-table-summary-row-font-weight)); - /* Make unique summary row mods available to these default row styles: */ + /* Summary rows are typically the same dimensions as other non-header rows, but we make + mods available to override the default row styles */ + block-size: var(--mod-table-summary-row-min-height, var(--spectrum-table-min-row-height)); + padding-block-start: calc(var(--mod-table-summary-row-top-to-text, var(--spectrum-table-row-top-to-text)) - var(--mod-table-border-width, var(--spectrum-table-border-width))); + padding-block-end: var(--mod-table-summary-row-bottom-to-text, var(--spectrum-table-row-bottom-to-text)); font-size: var(--mod-table-summary-row-font-size, var(--spectrum-table-row-font-size)); font-family: var(--mod-table-summary-row-font-family, var(--spectrum-table-row-font-family)); font-style: var(--mod-table-summary-row-font-style, var(--spectrum-table-row-font-style)); @@ -684,7 +726,6 @@ } .spectrum-Table-row--sectionHeader { - --spectrum-table-cell-background-color: var(--highcontrast-table-section-header-background-color, var(--mod-table-section-header-background-color, var(--spectrum-table-section-header-background-color))); cursor: var(--mod-table-cursor-section-header, initial); .spectrum-Table-cell { @@ -695,48 +736,35 @@ block-size: var(--mod-table-section-header-min-height, var(--spectrum-table-section-header-min-height)); padding-block-start: calc(var(--mod-table-section-header-block-start-spacing, var(--spectrum-table-section-header-block-start-spacing)) - var(--mod-table-border-width, var(--spectrum-table-border-width))); - padding-block-end: calc(var(--mod-table-section-header-block-end-spacing, var(--spectrum-table-section-header-block-end-spacing)) - var(--mod-table-border-width, var(--spectrum-table-border-width))); + padding-block-end: var(--mod-table-section-header-block-end-spacing, var(--spectrum-table-section-header-block-end-spacing)); /* Make unique section header mods available to these default row styles: */ + padding-inline-start: calc(var(--mod-table-section-header-inline-start-spacing, var(--spectrum-table-cell-inline-spacing)) - var(--mod-table-outer-border-inline-width, var(--spectrum-table-outer-border-inline-width))); font-size: var(--mod-table-section-header-font-size, var(--spectrum-table-row-font-size)); font-family: var(--mod-table-section-header-font-family, var(--spectrum-table-row-font-family)); font-style: var(--mod-table-section-header-font-style, var(--spectrum-table-row-font-style)); line-height: var(--mod-table-section-header-line-height, var(--spectrum-table-row-line-height)); color: var(--highcontrast-table-section-header-text-color, var(--mod-table-section-header-text-color, var(--spectrum-table-row-text-color))); } - - &:hover { - --highcontrast-table-row-text-color: var(--highcontrast-table-section-header-text-color); - --spectrum-table-cell-background-color: var(--highcontrast-table-section-header-background-color, var(--mod-table-section-header-background-color, var(--spectrum-table-section-header-background-color))); - } } +/* Checkbox cell styles are further down the cascade to override some of the checkbox styles for collapsible tables. */ +/********* CHECKBOX CELLS *********/ .spectrum-Table-checkboxCell { /* Prevent width expansion with 100% width table. */ inline-size: var(--spectrum-checkbox-control-size-small); /* The calc subtraction is because the --spectrum-table-checkbox-to-text spacing value includes the inline start padding in the adjacent cell. */ - padding-inline-end: calc(var(--mod-table-checkbox-to-text, var(--spectrum-table-checkbox-to-text)) - var(--mod-table-edge-to-content, var(--spectrum-table-edge-to-content))); - - /* Block spacing must be moved to calculated margin on the checkbox element. */ - padding-block: 0; + padding-inline-end: calc(var(--mod-table-checkbox-to-cell-content, var(--spectrum-table-checkbox-to-cell-content)) - var(--mod-table-cell-inline-spacing, var(--spectrum-table-cell-inline-spacing))); + padding-block-start: calc(var(--mod-table-row-checkbox-block-spacing, var(--spectrum-table-row-checkbox-block-spacing)) - var(--mod-table-border-width, var(--spectrum-table-border-width))); + padding-block-end: var(--mod-table-row-checkbox-block-spacing, var(--spectrum-table-row-checkbox-block-spacing)); .spectrum-Table-checkbox { - --mod-checkbox-spacing: 0px; + --mod-checkbox-margin-block: 0px; min-block-size: initial; } - - &.spectrum-Table-cell .spectrum-Table-checkbox { - margin-block-start: calc(var(--mod-table-row-checkbox-block-spacing, var(--spectrum-table-row-checkbox-block-spacing)) - var(--mod-table-border-width, var(--spectrum-table-border-width))); - margin-block-end: var(--mod-table-row-checkbox-block-spacing, var(--spectrum-table-row-checkbox-block-spacing)); - } - - &.spectrum-Table-headCell .spectrum-Table-checkbox { - margin-block-start: calc(var(--mod-table-header-checkbox-block-spacing, var(--spectrum-table-header-checkbox-block-spacing)) - var(--mod-table-border-width, var(--spectrum-table-border-width))); - margin-block-end: var(--mod-table-header-checkbox-block-spacing, var(--spectrum-table-header-checkbox-block-spacing)); - } } /********* DIVS *********/ @@ -753,8 +781,6 @@ /********* SCROLLABLE *********/ /* Wrapper that allows a scrollable body and sticky column header. */ .spectrum-Table-scroller { - --spectrum-table-header-background-color: var(--mod-table-header-background-color-scrollable, var(--spectrum-background-layer-1-color, var(--spectrum-gray-75))); - box-sizing: border-box; display: inline-block; position: relative; @@ -766,11 +792,7 @@ /* Make sure shift-tab reverse keyboard navigation keeps the whole cell in focus. --mod-table-current-header-height should be dynamically updated with JS to match the table header height. */ - scroll-padding-top: var(--mod-table-current-header-height, calc((var(--mod-table-header-line-height, var(--spectrum-table-row-line-height)) * var(--mod-table-header-font-size, var(--spectrum-table-row-font-size))) + var(--mod-table-header-top-to-text, var(--spectrum-table-header-top-to-text)) + var(--mod-table-header-bottom-to-text, var(--spectrum-table-header-bottom-to-text)) + var(--mod-table-border-width, var(--spectrum-table-border-width)))); - - &.spectrum-Table--quiet { - border-block-start: none; - } + scroll-padding-top: var(--mod-table-current-header-height, calc((var(--mod-table-header-line-height, var(--spectrum-table-row-line-height)) * var(--mod-table-header-font-size, var(--spectrum-table-row-font-size))) + var(--mod-table-header-row-top-to-text, var(--spectrum-table-header-row-top-to-text)) + var(--mod-table-header-row-bottom-to-text, var(--spectrum-table-header-row-bottom-to-text)) + var(--mod-table-border-width, var(--spectrum-table-border-width)))); .spectrum-Table-head { position: sticky; @@ -778,11 +800,14 @@ z-index: 2; } - .spectrum-Table-headCell { + /* Remove borders that have been replaced by borders on scroller wrapper or pseudo elements. */ + .spectrum-Table-headRow:first-child .spectrum-Table-headCell { border-block-end: var(--mod-table-border-width, var(--spectrum-table-border-width)) solid var(--highcontrast-table-border-color, var(--mod-table-border-color, var(--spectrum-table-border-color))); + border-block-start: 0; + border-inline: 0; + border-radius: 0; } - /* Remove borders that have been replaced by borders on wrapper or pseudo elements. */ .spectrum-Table-body .spectrum-Table-row { &:first-child .spectrum-Table-cell { border-block-start: none; @@ -859,7 +884,6 @@ .spectrum-Table-cell--collapsible { padding-inline-start: calc(var(--spectrum-table-row-tier, 0px) * var(--spectrum-table-collapsible-tier-indent)); - padding-block: 0; } .spectrum-Table-collapseInner { @@ -867,12 +891,7 @@ flex-direction: row; flex-wrap: nowrap; justify-content: flex-start; - align-items: flex-start; - - .spectrum-Table-collapseContent { - padding-block-start: calc(var(--mod-table-row-top-to-text, var(--spectrum-table-row-top-to-text)) - var(--mod-table-border-width, var(--spectrum-table-border-width))); - padding-block-end: var(--mod-table-row-bottom-to-text, var(--spectrum-table-row-bottom-to-text)); - } + align-items: center; } .spectrum-Table-disclosureIcon.spectrum-Table-disclosureIcon { @@ -889,10 +908,10 @@ border: 0; color: var(--spectrum-table-icon-color); - transform: var(--spectrum-logical-rotation,); + transform: var(--spectrum-logical-rotation); &[aria-expanded="true"] { - transform: var(--spectrum-logical-rotation,) rotate(90deg); + transform: var(--spectrum-logical-rotation) rotate(90deg); } &::after { @@ -908,16 +927,16 @@ } &:focus { - --spectrum-table-icon-color: var(--highcontrast-table-icon-color, var(--mod-table-icon-color-focus, var(--spectrum-table-icon-color-focus))); + --spectrum-table-icon-color: var(--highcontrast-table-icon-color, var(--mod-table-icon-color-focus, var(--spectrum-table-icon-color-key-focus))); &:hover { - --spectrum-table-icon-color: var(--highcontrast-table-icon-color, var(--mod-table-icon-color-focus-hover, var(--spectrum-table-icon-color-focus-hover))); + --spectrum-table-icon-color: var(--highcontrast-table-icon-color, var(--mod-table-icon-color-focus-hover, var(--spectrum-table-icon-color-key-focus))); } } &:focus-visible, &.is-keyboardFocused { - --spectrum-table-icon-color: var(--highcontrast-table-icon-color, var(--mod-table-icon-color-key-focus, var(--spectrum-table-icon-color-key-focus))); + --spectrum-table-icon-color: var(--highcontrast-table-icon-color-focus, var(--mod-table-icon-color-key-focus, var(--spectrum-table-icon-color-key-focus))); outline-width: var(--mod-table-focus-indicator-thickness, var(--spectrum-table-focus-indicator-thickness)); outline-style: solid; @@ -926,45 +945,111 @@ } } -/********* THUMBNAILS *********/ -.spectrum-Table-row--thumbnail { - --spectrum-table-thumbnail-cell-block-spacing: var(--mod-table-thumbnail-block-spacing, var(--spectrum-table-thumbnail-block-spacing)); - --spectrum-table-thumbnail-inner-content-block-spacing: max(0px, calc((var(--mod-table-thumbnail-size, var(--spectrum-table-thumbnail-size)) - (var(--mod-table-row-line-height, var(--spectrum-table-row-line-height)) * var(--mod-table-header-font-size, var(--spectrum-table-row-font-size)))) / 2)); - - /* Cell that does not have a thumbnail, within a row that has a thumbnail. */ - .spectrum-Table-cell { - padding-block: calc(var(--spectrum-table-thumbnail-cell-block-spacing) + var(--spectrum-table-thumbnail-inner-content-block-spacing)); - } - - /* Cell that does have a thumbnail has its padding moved within the "Inner" and "Content" alignment wrappers. */ - .spectrum-Table-cell--thumbnail { - padding-block: 0; - } - - /* Sometimes the padding must be larger to match any extra space created by the disclosure icon (e.g. compact + large ). */ - &.spectrum-Table-row--collapsible { - --spectrum-table-thumbnail-inner-minimum-block-spacing: max(0px, calc((var(--mod-table-disclosure-icon-size, var(--spectrum-table-disclosure-icon-size)) - var(--mod-table-thumbnail-size, var(--spectrum-table-thumbnail-size))) / 2)); - --spectrum-table-thumbnail-cell-block-spacing: max(var(--mod-table-thumbnail-block-spacing, var(--spectrum-table-thumbnail-block-spacing)), var(--spectrum-table-thumbnail-inner-minimum-block-spacing)); - } -} - -.spectrum-Table-thumbnailInner { +/********* VISUALS- THUMBNAILS, AVATARS, ICONS *********/ +.spectrum-Table-visualInner { display: flex; flex-direction: row; flex-wrap: nowrap; justify-content: flex-start; - align-items: flex-start; - padding-block: var(--spectrum-table-thumbnail-cell-block-spacing); + align-items: center; + gap: var(--spectrum-table-visual-to-text); - .spectrum-Thumbnail { + .spectrum-Thumbnail, + .spectrum-Icon, + .spectrum-Avatar { flex-grow: 0; flex-shrink: 0; - margin-inline-end: var(--mod-table-thumbnail-to-text, var(--spectrum-table-thumbnail-to-text)); + margin-inline-end: var(--mod-table-visual-to-text, var(--spectrum-table-visual-to-text)); line-height: var(--mod-table-row-line-height, var(--spectrum-table-row-line-height)); } +} + +/********* SPARKLINE CHARTS *********/ +.spectrum-Table-chartContent { + .spectrum-Table-chartImage { + display: block; + inline-size: fit-content; + block-size: auto; + } +} + +/********* HIGH CONTRAST *********/ +@media (forced-colors: active) { + .spectrum-Table { + --highcontrast-table-row-background-color: Canvas; + --highcontrast-table-row-text-color: CanvasText; + --highcontrast-table-divider-color: CanvasText; + --highcontrast-table-border-color: CanvasText; + --highcontrast-table-icon-color: CanvasText; + --highcontrast-table-icon-color-focus: Highlight; + + --highcontrast-table-selected-row-background-color: Highlight; + --highcontrast-table-selected-row-text-color: HighlightText; + + /* Button text colors */ + --highcontrast-table-header-text-color: CanvasText; + --highcontrast-table-header-text-color-hover: Highlight; + + @supports (color: SelectedItem) { + --highcontrast-table-selected-row-background-color: SelectedItem; + --highcontrast-table-selected-row-text-color: SelectedItemText; + } + + --highcontrast-table-selected-row-background-color-focus: Highlight; + --highcontrast-table-selected-row-text-color-focus: HighlightText; + --highcontrast-table-row-background-color-hover: Highlight; + --highcontrast-table-row-text-color-hover: HighlightText; + --highcontrast-table-row-text-color-focus: HighlightText; + + --highcontrast-table-section-header-text-color: Canvas; + --highcontrast-table-section-header-background-color: CanvasText; + + --highcontrast-table-focus-indicator-color: Highlight; + --highcontrast-table-transition-duration: 0; + + & .spectrum-Table-row--summary { + --highcontrast-table-row-text-color: CanvasText; + } + } + + .spectrum-Table-cell { + /* Removes unstylable readability backplate. */ + forced-color-adjust: none; + + /* Make sure border colors are visible in high contrast mode */ + border: var(--spectrum-table-border-width) solid Highlight; + + &:focus-visible, + &:focus { + &::after { + border-color: Highlight; + } + } + } + + .spectrum-Table-row { + &:hover, + &:focus-visible, + &:focus { + .spectrum-Table-checkbox .spectrum-Checkbox-box::before { + outline: var(--highcontrast-table-row-text-color-hover) 1px solid; + } + + /* corresponds to the row focus indicator with a ::before pseudo element */ + .spectrum-Table-cell:first-child::before { + background-color: Highlight; + } + } + } + + .spectrum-Table-row.is-selected, + .spectrum-Table-row.is-drop-target, + .spectrum-Table-body.is-drop-target .spectrum-Table-row { + /* Ensure negative offset outline contrasts on top of SelectedItem background. */ + --highcontrast-table-cell-focus-indicator-color: var(--highcontrast-table-selected-row-text-color); - .spectrum-Table-thumbnailContent { - /* Vertically centers text with the middle of the thumbnail. */ - padding-block: var(--spectrum-table-thumbnail-inner-content-block-spacing); + .spectrum-Table-checkbox .spectrum-Checkbox-box::before { + outline: var(--highcontrast-table-selected-row-text-color) 1px solid; + } } } diff --git a/components/table/package.json b/components/table/package.json index 717a4eff427..0a632d7249f 100644 --- a/components/table/package.json +++ b/components/table/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/table", - "version": "8.2.0", + "version": "9.0.0-next.4", "description": "The Spectrum CSS table component", "license": "Apache-2.0", "author": "Adobe", @@ -19,18 +19,16 @@ "./package.json": "./package.json", "./dist/*": "./dist/*", "./index.css": "./dist/index.css", - "./index-*.css": "./dist/index-*.css", "./metadata.json": "./dist/metadata.json", - "./themes/*": "./dist/themes/*", "./stories/*": "./stories/*" }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/button": ">=14.0.0 <15.0.0", - "@spectrum-css/checkbox": ">=10.0.0 <11.0.0", - "@spectrum-css/icon": ">=9.0.0 <10.0.0", - "@spectrum-css/thumbnail": ">=8.0.0 <9.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/button": ">=15.0.0-next.0", + "@spectrum-css/checkbox": ">=11.0.0-next.0", + "@spectrum-css/icon": ">=10.0.0-next.0", + "@spectrum-css/thumbnail": ">=9.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/button": { @@ -50,11 +48,11 @@ } }, "devDependencies": { - "@spectrum-css/button": "14.2.0", - "@spectrum-css/checkbox": "10.2.0", - "@spectrum-css/icon": "9.2.0", - "@spectrum-css/thumbnail": "8.2.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/button": "15.0.0-next.2", + "@spectrum-css/checkbox": "11.0.0-next.2", + "@spectrum-css/icon": "10.0.0-next.3", + "@spectrum-css/thumbnail": "9.0.0-next.1", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/table/stories/table.stories.js b/components/table/stories/table.stories.js index 834a90f4630..3979b332cce 100644 --- a/components/table/stories/table.stories.js +++ b/components/table/stories/table.stories.js @@ -1,6 +1,5 @@ -import { Sizes } from "@spectrum-css/preview/decorators"; import { disableDefaultModes } from "@spectrum-css/preview/modes"; -import { isEmphasized, isQuiet, size } from "@spectrum-css/preview/types"; +import { isEmphasized, isLoading, isQuiet } from "@spectrum-css/preview/types"; import metadata from "../dist/metadata.json"; import packageJson from "../package.json"; import { TableGroup } from "./table.test.js"; @@ -13,7 +12,6 @@ export default { title: "Table", component: "Table", argTypes: { - size: size(["s", "m", "l", "xl"]), density: { name: "Density", table: { @@ -24,11 +22,15 @@ export default { control: "select", }, isQuiet, - isEmphasized, + isEmphasized: { + ...isEmphasized, + description: "Emphasized styling on the table affects colors of selected rows and any checkboxes." + }, + isLoading, useDivs: { name: "Use divs for markup", description: - "Use 'div' elements for all of the table markup instead of the 'table' element.", + "Use `div` elements for all of the table markup instead of the `table` element.", type: { name: "boolean" }, table: { type: { summary: "boolean" }, @@ -47,10 +49,21 @@ export default { }, control: "boolean", }, - showThumbnails: { - name: "Show thumbnails in content", - description: - "Uses the thumbnail component at the start of the first column's cells.", + selectionMode: { + name: "Selection mode", + description: "Determines whether items in the table can be selected, and if users can select only one or multiple items.", + type: { name: "string", required: true }, + table: { + type: { summary: "string" }, + category: "Selection", + disable: true, + }, + options: ["none", "single", "multiple"], + control: "select", + }, + hasColumnDividers: { + name: "Show dividers between columns", + description: "Sets dividers between table columns.", type: { name: "boolean" }, table: { type: { summary: "boolean" }, @@ -58,9 +71,9 @@ export default { }, control: "boolean", }, - hasColumnDividers: { - name: "Show dividers between columns", - description: "Sets dividers between table columns.", + hasMenu: { + name: "Has a menu", + description: "Adds an action button to header cell to indicate that the column has a hidden menu.", type: { name: "boolean" }, table: { type: { summary: "boolean" }, @@ -68,30 +81,68 @@ export default { }, control: "boolean", }, + isSortable: { + name: "Enable sortable columns", + description: "Table columns can be sortable and are indicated by appropriate sort icons.", + type: { name: "boolean" }, + table: { + type: { summary: "boolean" }, + category: "Component", + }, + control: "boolean", + }, + sortIcon: { + name: "Sort icon", + description: "Sort icons are used to indicate the sort direction of a column. The `none` option is used to indicate that the column is not sorted.", + type: { name: "string" }, + table: { + type: { summary: "string" }, + category: "Component", + }, + options: ["Sort", "SortUp", "SortDown"], + control: "select", + if: { arg: "isSortable", eq: true }, + }, isDropTarget: { name: "Dropzone (drop target)", type: { name: "boolean" }, table: { type: { summary: "boolean" }, category: "State", + disable: true, }, control: "boolean", }, rowItems: { table: { disable: true }, }, + hasChartContent: { + name: "Chart content in cells", + description: "In some instances, a chart can be displayed in the cells of the table.", + type: { name: "boolean" }, + table: { + type: { summary: "boolean" }, + category: "Component", + disable: true, + }, + control: "boolean", + }, }, args: { rootClass: "spectrum-Table", - size: "m", - density: "standard", + density: "regular", isQuiet: false, + isLoading: false, isEmphasized: true, + selectionMode: "none", useDivs: false, - showThumbnails: false, isDropTarget: false, useScroller: false, hasColumnDividers: false, + hasMenu: false, + hasChartContent: false, + isSortable: false, + sortIcon: "Sort", rowItems: [ { cellContent: "Row item alpha", @@ -117,9 +168,14 @@ export default { }, packageJson, metadata, + status: { + type: "migrated" + }, }, + tags: ["migrated"], }; + const ExampleRowItems = [ { cellContent: ["Table row alpha", "Alpha", "Table row alpha"], @@ -127,7 +183,7 @@ const ExampleRowItems = [ }, { cellContent: [ - "Table row bravo. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", + "Selected row bravo. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", "Bravo", "Table row bravo. Lorem ipsum dolor sit amet.", ], @@ -135,7 +191,7 @@ const ExampleRowItems = [ isSelected: true, }, { - cellContent: "Table row charlie", + cellContent: "Selected row charlie", showCheckbox: true, isSelected: true, }, @@ -154,29 +210,52 @@ const ExampleRowItems = [ ]; /** - * The medium size is the default and recommended option. The default table also uses the regular density. + * The default table also uses the regular density. Similar to a paragraph of text, textual data is always start-aligned within a table. Never use center alignment. */ export const Default = TableGroup.bind({}); Default.args = {}; // ********* DOCS ONLY ********* // /** - * Tables come in four different sizes: small, medium, large, and extra-large. The medium size is the default and recommended option. + * The empty state variant displays an [illustrated message](/docs/components-illustrated-message--docs) when there is no data to display. + */ +export const EmptyState = Template.bind({}); +EmptyState.args = { + rowItems: [], +}; +EmptyState.parameters = { + chromatic: { disableSnapshot: true }, +}; +EmptyState.storyName = "Empty state"; +EmptyState.argTypes = { + isEmphasized: { table: { disable: true } }, + isQuiet: { table: { disable: true } }, + isLoading: { table: { disable: true } }, + hasColumnDividers: { table: { disable: true } }, + hasMenu: { table: { disable: true } }, + isSortable: { table: { disable: true } }, + sortIcon: { table: { disable: true } }, + isDropTarget: { table: { disable: true } }, + useDivs: { table: { disable: true } }, + useScroller: { table: { disable: true } }, +}; + +/** + * A table may render a [progress circle](/docs/components-progress-circle--docs) while populating data. */ -export const Sizing = (args, context) => Sizes({ - Template, - withHeading: false, - withBorder: false, - ...args, -}, context); -Sizing.args = {}; -Sizing.tags = ["!dev"]; -Sizing.parameters = { +export const LoadingState = Template.bind({}); +LoadingState.args = { + ...Default.args, + isLoading: true, +}; +LoadingState.tags = ["!dev"]; +LoadingState.parameters = { chromatic: { disableSnapshot: true }, }; +LoadingState.storyName = "Loading state"; /** - * The compact variant decreases the spacing used within the table. + * The compact variant decreases the spacing used within the table rows, except for the header row. */ export const Compact = Template.bind({}); Compact.args = { @@ -190,7 +269,7 @@ Compact.parameters = { Compact.storyName = "Density - compact"; /** - * The spacious variant increases the spacing used within the table. + * The spacious variant increases the spacing used within the table rows, except for the header row. */ export const Spacious = Template.bind({}); Spacious.args = { @@ -204,22 +283,62 @@ Spacious.parameters = { Spacious.storyName = "Density - spacious"; /** - * The standard multi-select table includes a column of checkboxes used for selecting rows. + * The standard multi-select table includes a column of checkboxes used for selecting rows. When the selection mode + * is set to `multiple`, users may select more than one table row. Typically, an [indeterminate checkbox](/docs/components-checkbox--docs) + * is used to indicate that ability. */ export const MultiSelect = Template.bind({}); -MultiSelect.storyName = "Multi-select"; +MultiSelect.storyName = "Selection mode: multiple"; MultiSelect.args = { rowItems: ExampleRowItems, + selectionMode: "multiple", }; MultiSelect.parameters = { chromatic: { disableSnapshot: true }, }; +/** + * When the selection mode is set to `single`, users may select only one table row. + */ +export const SingleSelect = Template.bind({}); +SingleSelect.storyName = "Selection mode: single"; +SingleSelect.args = { + selectionMode: "single", + rowItems: [ + { + cellContent: ["Pikachu", "Electric", "35"], + textAlignment: { + 2: "end" + }, + showCheckbox: true, + isSelected: true, + isChecked: true, + }, + { + cellContent: ["Charmander", "Fire", "39"], + textAlignment: { + 2: "end" + }, + showCheckbox: true, + }, + { + cellContent: ["Mew", "Psychic", "100"], + textAlignment: { + 2: "end" + }, + showCheckbox: true, + } + ], +}; +SingleSelect.parameters = { + chromatic: { disableSnapshot: true }, +}; + /** * Excluding the `.spectrum-Table--emphasized` class will change the style of selected rows. */ export const NonEmphasizedMultiSelect = Template.bind({}); -NonEmphasizedMultiSelect.storyName = "Non-emphasized multi-select"; +NonEmphasizedMultiSelect.storyName = "Selection mode: multiple, non-emphasized styling"; NonEmphasizedMultiSelect.args = { ...MultiSelect.args, isEmphasized: false, @@ -230,7 +349,90 @@ NonEmphasizedMultiSelect.parameters = { }; /** - * The quiet table has a transparent background and no borders on the left and right. + * Numerical data should generally be end-aligned for the ease of scanning and comparing. Numerical data should only be start-aligned when numbers are arbitrary identifiers, known as “nominal numbers,” which means they can’t be compared or combined arithmetically (e.g., ZIP codes, IP addresses, phone numbers). + * + * Column headers follow the alignment of the data, so for end-aligned numerical data, implementations should add the `.spectrum-Table-headCell--alignEnd` class to affected header cells (not shown below). + */ +export const NumericalData = Template.bind({}); +NumericalData.args = { + rowItems: [ + { + cellContent: ["Pikachu", "Electric", "35"], + textAlignment: { + 2: "end" + } + }, + { + cellContent: ["Charmander", "Fire", "39"], + textAlignment: { + 2: "end" + } + }, + { + cellContent: ["Mew", "Psychic", "100"], + textAlignment: { + 2: "end" + } + } + ], +}; +NumericalData.storyName = "Numerical data"; +NumericalData.parameters = { + chromatic: { disableSnapshot: true }, +}; + +/** + * The cells and rows within the table have different states based on selection and focus. Implementations should add appropriate tab stops to indicate focus on a row correctly. + */ +export const TableStates = Template.bind({}); +TableStates.args = { + rowItems: [ + { + cellContent: "Focused selected row, no rounded corners", + isFocused: true, + isSelected: true, + }, + { + cellContent: "Selected, hovered row", + isSelected: true, + isHovered: true, + }, + { + cellContent: ["Selected unfocused row, with a focused cell", "Focused cell", "Unfocused cell"], + isSelected: true, + cellCustomClasses: { + 1: ["is-focus-visible"] + } + }, + { + cellContent: "Focused unselected row, no rounded corners", + isFocused: true, + }, + { + cellContent: ["Table row with a focused cell", "Focused cell", "Unfocused cell"], + cellCustomClasses: { + 1: ["is-focus-visible"] + } + }, + { + cellContent: "Hovered row", + isHovered: true, + + }, + { + cellContent: "Focused selected row, with rounded corners", + isFocused: true, + isSelected: true, + } + ], +}; +TableStates.storyName = "Row and cell states"; +TableStates.parameters = { + chromatic: { disableSnapshot: true }, +}; + +/** + * Quiet tables are for when a table is meant to be supplementary, subtle, or lightweight. The quiet table utilizes the `.spectrum-Table--quiet` class and does not have borders on the left and right. */ export const Quiet = Template.bind({}); Quiet.args = { @@ -242,6 +444,76 @@ Quiet.parameters = { chromatic: { disableSnapshot: true }, }; +/** + * Tables with enabled column sorting can show different states of sorting: unsorted, ascending, and descending. The content of the header cell is an [button](/docs/components-button--docs), that has a class of `.spectrum-Table-sortButton`, which should contain the sorting icon, as well as the header label. + * + * When a column is sorted in ascending order, use the `SortUp` icon, as seen below. If sorted in descending order, use the `SortDown` icon. If the sort is undefined, use the more general `Sort` icon. + * + * The `aria-sort` attribute should be set on the `.spectrum-Table-headCell .is-sortable` element for the column that is currently sorted, and when sorting is active. `aria-sort` should not be set on more than one column at a time. + * + * Implementations will develop their own sorting functionality. The `aria-sort` attribute should be removed from a column header when the column is not sorted. + */ +export const Sortable = Template.bind({}); +Sortable.args = { + ...Default.args, + isSortable: true, + sortIcon: "Sort", +}; +Sortable.parameters = { + chromatic: { disableSnapshot: true }, +}; +Sortable.storyName = "Sortable columns"; +Sortable.tags = ["!dev"]; + +/** + * Tables can have additional actions in the header cells that could trigger a menu, as indicated by the chevron. Oftentimes, the menu is used to show users the available sorting options. The content of the header cell is an [button](/docs/components-button--docs), that has a class of `.spectrum-Table-sortButton`, which should contain the sorting icon when applicable, as well as the header label. + * + * The `aria-sort` attribute should be set on the `.spectrum-Table-hasMenuButton` element for the column that is currently sorted, and when sorting is active. + */ +export const WithMenuButton = Template.bind({}); +WithMenuButton.args = { + ...Default.args, + hasMenu: true, +}; +WithMenuButton.storyName = "Sortable columns: with menu button"; +WithMenuButton.parameters = { + chromatic: { disableSnapshot: true }, +}; +WithMenuButton.tags = ["!dev"]; + +/** + * In some use cases, a sparkline chart can be displayed in a cell of the table. There are informative, negative, positive, and notice sparkline charts available for implementations. + */ +export const WithChartContent = Template.bind({}); +WithChartContent.args = { + hasChartContent: true, + rowItems: [ + { cellContent: ["Informative sparkline", "200", "sparkline-informative.svg"], + textAlignment: { + 1: "end" + } + }, + { cellContent: ["Negative sparkline", "0", "sparkline-negative.svg"], + textAlignment: { + 1: "end" + } + }, + { cellContent: ["Positive sparkline", "600", "sparkline-positive.svg"], + textAlignment: { + 1: "end" + } + },{ cellContent: ["Notice sparkline", "400", "sparkline-notice.svg"], + textAlignment: { + 1: "end" + } + }, + ] +}; +WithChartContent.storyName = "With chart content"; +WithChartContent.parameters = { + chromatic: { disableSnapshot: true }, +}; + /** * A quiet multi-select table has emphasized styling by default, but excluding the `.spectrum-Table--emphasized` class will change the style of selected rows. */ @@ -249,15 +521,18 @@ export const QuietMultiSelect = Template.bind({}); QuietMultiSelect.args = { ...MultiSelect.args, isQuiet: true, + selectionMode: "multiple", }; QuietMultiSelect.tags = ["!dev"]; -QuietMultiSelect.storyName = "Quiet multi-select"; +QuietMultiSelect.storyName = "Selection mode: multiple, quiet styling"; QuietMultiSelect.parameters = { chromatic: { disableSnapshot: true }, }; /** - * The standard table can display column dividers by including the `.spectrum-Table-cell--divider` class with `.spectrum-Table-cell`. Use sparingly to group related content. + * Column dividers are for organizing table content and aid the user in parsing related data. These are optional; use them carefully to group related content. + * + * The standard table can display column dividers by including the `.spectrum-Table-cell--divider` class with `.spectrum-Table-cell`. */ export const WithColumnDividers = Template.bind({}); WithColumnDividers.args = { @@ -271,11 +546,15 @@ WithColumnDividers.parameters = { }; /** - * Tables can have a summary row to show totals, at either the top or the bottom of the table. This example shows both the optional summary row at the bottom, and a row marked as selected. + * Tables can have a summary row to show totals, at either the top or the bottom of the table. This example shows both the optional summary row at the top, and a row marked as selected. */ export const SummaryAndSelected = Template.bind({}); SummaryAndSelected.args = { rowItems: [ + { + cellContent: "Summary row", + isSummaryRow: true, + }, { cellContent: "Table row alpha", }, @@ -283,19 +562,15 @@ SummaryAndSelected.args = { cellContent: "Table row bravo", }, { - cellContent: "Table row charlie", + cellContent: "Selected row charlie", isSelected: true, }, { cellContent: "Table row delta", }, - { - cellContent: "Summary row", - isSummaryRow: true, - }, ], }; -SummaryAndSelected.storyName = "Summary and selected"; +SummaryAndSelected.storyName = "Summary and selected rows"; SummaryAndSelected.parameters = { chromatic: { disableSnapshot: true }, }; @@ -331,7 +606,7 @@ SectionHeader.args = { }, ], }; -SectionHeader.storyName = "Section header"; +SectionHeader.storyName = "Section headers"; SectionHeader.parameters = { chromatic: { disableSnapshot: true }, }; @@ -341,13 +616,13 @@ SectionHeaderQuiet.args = { ...SectionHeader.args, isQuiet: true, }; -SectionHeaderQuiet.storyName = "Section header: quiet"; +SectionHeaderQuiet.storyName = "Section headers: quiet styling"; SectionHeaderQuiet.parameters = { chromatic: { disableSnapshot: true }, }; +SectionHeaderQuiet.tags = ["!dev"]; /** - * * A table can be wrapped in a fixed height `div` with the `.spectrum-Table-scroller` class. This allows scrolling of the table body and makes the column headers sticky (i.e. fixed to the top on scroll). * * When using the scrollable wrapper, the column headers must have a solid background color set. This can be customized to match the parent background with the custom property `--mod-table-header-background-color-scrollable`. @@ -367,7 +642,7 @@ Scrollable.args = { cellContent: "Table row bravo", }, { - cellContent: "Table row charlie", + cellContent: "Selected row charlie", isSelected: true, }, { @@ -391,20 +666,47 @@ Scrollable.parameters = { }; /** - * A table can also be made up of `div` tags if needed, instead of a ``. This example uses both the div markup, and the scrollable wrapper. + * A table can also be made up of `div` tags if needed, instead of a `
`. This example uses both the `div` markup, and the scrollable wrapper. */ export const DivsScrollable = Template.bind({}); -DivsScrollable.storyName = "Scrollable with divs"; +DivsScrollable.storyName = "Scrollable table with divs"; DivsScrollable.args = { ...Scrollable.args, useDivs: true, - rowItems: ExampleRowItems, }; DivsScrollable.tags = ["!dev"]; DivsScrollable.parameters = { chromatic: { disableSnapshot: true }, }; + +/** + * Thumbnails, avatars, and other icons can be used in the table content, with some additional markup and classes for alignment. + */ +export const Visuals = Template.bind({}); +Visuals.args = { + rowItems: [ + { + cellContent: "Avatar example", + visualElement: "avatar", + }, + { + cellContent: "Icon example", + visualElement: "icon", + }, + { + cellContent: "Thumbnail example", + visualElement: "thumbnail", + }, + ], +}; +Visuals.parameters = { + chromatic: { disableSnapshot: true }, +}; +Visuals.storyName = "With visuals"; + + +// TODO: The design team doesn't have support for collapsible rows in the table component, so they are removed from the docs page for now. /** * In a table with collapsible rows, all child items must have columns that match the parent items. If they don’t, consider using multiple drill-in tables, [Miller columns](/docs/components-miller-columns--docs), or [breadcrumbs](/docs/components-breadcrumbs--docs) instead. */ @@ -421,7 +723,7 @@ Collapsible.args = { }, { cellContent: - "Table row bravo. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt.", + "Table row bravo. There is actually another collapsed row here that's not visible. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt.", isCollapsible: true, tier: 1, ariaControls: "table-cr-charlie", @@ -439,7 +741,7 @@ Collapsible.args = { id: "table-cr-charlie", }, { - cellContent: "Table row delta", + cellContent: "Selected row delta", isSelected: true, isCollapsible: true, isExpanded: true, @@ -470,10 +772,13 @@ Collapsible.args = { Collapsible.parameters = { chromatic: { disableSnapshot: true }, }; +Collapsible.storyName = "Collapsible rows"; +Collapsible.tags = ["!autodocs", "!dev"]; export const CollapsibleMultiSelect = Template.bind({}); -CollapsibleMultiSelect.storyName = "Collapsible multi-select"; +CollapsibleMultiSelect.storyName = "Selection mode: multiple, collapsible rows"; CollapsibleMultiSelect.args = { + selectionMode: "multiple", rowItems: [ { showCheckbox: true, @@ -487,7 +792,7 @@ CollapsibleMultiSelect.args = { { showCheckbox: true, cellContent: - "Table row bravo. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt.", + "Table row bravo. There is actually another collapsed row here that's not visible. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt.", isCollapsible: true, tier: 1, ariaControls: "table-cr-charlie", @@ -507,7 +812,7 @@ CollapsibleMultiSelect.args = { }, { showCheckbox: true, - cellContent: "Table row delta", + cellContent: "Selected row delta", isSelected: true, isCollapsible: true, isExpanded: true, @@ -541,73 +846,66 @@ CollapsibleMultiSelect.args = { CollapsibleMultiSelect.parameters = { chromatic: { disableSnapshot: true }, }; +CollapsibleMultiSelect.tags = ["!autodocs", "!dev"]; /** - * Thumbnails can be used in the table content, with some additional markup and classes for alignment. - */ -export const Thumbnails = Template.bind({}); -Thumbnails.args = { - showThumbnails: true, - rowItems: [ - { - cellContent: ["Table row alpha", "Test", "2"], - }, - { - cellContent: ["Table row bravo", "Test", "28"], - }, - { - cellContent: [ - "Table row charlie. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt.", - "Test", - "23", - ], - }, - { - cellContent: ["Table row delta", "Test", "7"], - }, - ], -}; -Thumbnails.tags = ["!dev"]; -Thumbnails.parameters = { - chromatic: { disableSnapshot: true }, -}; - -/** - * The thumbnail table variant can also be combined with collapsible rows. + * The table can also combine visuals with collapsible rows. */ -export const ThumbnailsCollapsible = Template.bind({}); -ThumbnailsCollapsible.args = { - showThumbnails: true, +export const VisualsCollapsible = Template.bind({}); +VisualsCollapsible.args = { rowItems: [ { cellContent: "Table row alpha", isCollapsible: true, isExpanded: true, tier: 0, - ariaControls: "table-cr-bravo", + ariaControls: "table-cr-bravo table-cr-delta", id: "table-cr-alpha", }, { cellContent: - "Table row bravo. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt.", + "Table row bravo. There is actually another collapsed row here that's not visible. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt.", isCollapsible: true, tier: 1, ariaControls: "table-cr-charlie", id: "table-cr-bravo", + visualElement: "avatar", }, { - cellContent: "Table row charlie", + cellContent: [ + "Table row charlie", + "Default not visible", + "Default not visible", + ], + isCollapsible: true, + isHidden: true, + tier: 2, + id: "table-cr-charlie", + }, + { + cellContent: "Selected row delta", + isSelected: true, + isCollapsible: true, + isExpanded: true, + tier: 1, + ariaControls: "table-cr-echo table-cr-foxtrot", + id: "table-cr-delta", + visualElement: "icon", + }, + { + cellContent: "Table row echo", tier: 2, isLastTier: true, isCollapsible: true, - id: "table-cr-charlie", + id: "table-cr-echo", + visualElement: "thumbnail", }, { - cellContent: "Table row delta", + cellContent: "Table row foxtrot", tier: 2, isLastTier: true, isCollapsible: true, - id: "table-cr-delta", + id: "table-cr-foxtrot", }, { cellContent: "Summary row", @@ -615,19 +913,22 @@ ThumbnailsCollapsible.args = { }, ], }; -ThumbnailsCollapsible.storyName = "Thumbnails: collapsible"; -ThumbnailsCollapsible.parameters = { +VisualsCollapsible.tags = ["!autodocs", "!dev"]; +VisualsCollapsible.storyName = "With visuals: collapsible rows"; +VisualsCollapsible.parameters = { chromatic: { disableSnapshot: true }, }; +// TODO: The design team doesn't have dropzones in the table component, so they are removed from the docs page for now. /** * The table body can accept dropped content. */ export const BodyDropZone = Template.bind({}); BodyDropZone.args = { + ...Default.args, isDropTarget: true, }; -BodyDropZone.tags = ["!dev"]; +BodyDropZone.tags = ["!autodocs", "!dev"]; BodyDropZone.storyName = "Dropzone: body"; BodyDropZone.parameters = { chromatic: { disableSnapshot: true }, @@ -662,6 +963,7 @@ RowDropZone.args = { }, ], }; +RowDropZone.tags = ["!autodocs", "!dev"]; RowDropZone.storyName = "Dropzone: row"; RowDropZone.parameters = { chromatic: { disableSnapshot: true }, @@ -672,7 +974,7 @@ RowDropZoneQuiet.args = { ...RowDropZone.args, isQuiet: true, }; -RowDropZoneQuiet.tags = ["!dev"]; +RowDropZoneQuiet.tags = ["!autodocs", "!dev"]; RowDropZoneQuiet.storyName = "Dropzone: row, quiet"; RowDropZoneQuiet.parameters = { chromatic: { disableSnapshot: true }, diff --git a/components/table/stories/table.test.js b/components/table/stories/table.test.js index 73022af599f..efde820a61a 100644 --- a/components/table/stories/table.test.js +++ b/components/table/stories/table.test.js @@ -133,22 +133,61 @@ export const TableGroup = Variants({ hasColumnDividers: true, }, { - testHeading: "Summary: selected", + testHeading: "Empty state", + rowItems: [], + }, + { + testHeading: "Loading state", + isLoading: true, + }, + { + testHeading: "Summary and selected rows", rowItems: ExampleSummarySelectedContent, }, { - testHeading: "Multi-select: emphasized", + testHeading: "Selection mode: multiple, emphasized", rowItems: ExampleMultiSelectContent, + selectionMode: "multiple", }, { - testHeading: "Multi-select: non-emphasized", - isEmphasized: false, + testHeading: "Selection mode: single, emphasized", + rowItems: [ + { + cellContent: ["Pikachu", "Electric", "35"], + textAlignment: { + 2: "end" + }, + showCheckbox: true, + isSelected: true, + isChecked: true, + }, + { + cellContent: ["Charmander", "Fire", "39"], + textAlignment: { + 2: "end" + }, + showCheckbox: true, + }, + { + cellContent: ["Mew", "Psychic", "100"], + textAlignment: { + 2: "end" + }, + showCheckbox: true, + } + ], + }, + { + testHeading: "Selection mode: multiple, non-emphasized", rowItems: ExampleMultiSelectContent, + isEmphasized: false, + selectionMode: "multiple", }, { - testHeading: "Quiet multi-select: emphasized", + testHeading: "Selection mode: multiple, quiet, emphasized", isQuiet: true, rowItems: ExampleMultiSelectContent, + selectionMode: "multiple", }, { testHeading: "Scrollable", @@ -161,6 +200,14 @@ export const TableGroup = Variants({ useScroller: true, rowItems: ExampleMultiSelectContent, }, + { + testHeading: "Sortable columns", + isSortable: true, + }, + { + testHeading: "Head cell with menu button", + hasMenu: true, + }, { testHeading: "Section headers", rowItems: ExampleSectionHeadersContent, @@ -230,7 +277,8 @@ export const TableGroup = Variants({ ], }, { - testHeading: "Collapsible: multi-select", + testHeading: "Selection mode: multiple, collapsible", + selectionMode: "multiple", rowItems: [ { showCheckbox: true, @@ -296,60 +344,100 @@ export const TableGroup = Variants({ ], }, { - testHeading: "Thumbnails", - showThumbnails: true, + testHeading: "End-alignment for numerical data", rowItems: [ { - cellContent: ["Table row alpha", "Test", "2"], + cellContent: ["Pikachu", "Electric", "35"], + textAlignment: { + 2: "end" + } }, { - cellContent: ["Table row bravo", "Test", "28"], + cellContent: ["Charmander", "Fire", "39"], + textAlignment: { + 2: "end" + } }, { - cellContent: [ - "Table row charlie. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt.", - "Test", - "23", - ], + cellContent: ["Mew", "Psychic", "100"], + textAlignment: { + 2: "end" + } + }, + ], + }, + { + testHeading: "Visual elements", + rowItems: [ + { + cellContent: "Avatar example", + visualElement: "avatar", + }, + { + cellContent: "Icon example", + visualElement: "icon", }, { - cellContent: ["Table row delta", "Test", "7"], + cellContent: "Thumbnail example", + visualElement: "thumbnail", }, ], }, { - testHeading: "Thumbnail: collapsible", - showThumbnails: true, + testHeading: "Visual elements: collapsible", rowItems: [ { cellContent: "Table row alpha", isCollapsible: true, isExpanded: true, tier: 0, - ariaControls: "table-cr-bravo", + ariaControls: "table-cr-bravo table-cr-delta", id: "table-cr-alpha", }, { cellContent: - "Table row bravo. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt.", + "Table row bravo. There is actually another collapsed row here that's not visible. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt.", isCollapsible: true, tier: 1, ariaControls: "table-cr-charlie", id: "table-cr-bravo", + visualElement: "avatar", }, { - cellContent: "Table row charlie", + cellContent: [ + "Table row charlie", + "Default not visible", + "Default not visible", + ], + isCollapsible: true, + isHidden: true, + tier: 2, + id: "table-cr-charlie", + }, + { + cellContent: "Selected row delta", + isSelected: true, + isCollapsible: true, + isExpanded: true, + tier: 1, + ariaControls: "table-cr-echo table-cr-foxtrot", + id: "table-cr-delta", + visualElement: "icon", + }, + { + cellContent: "Table row echo", tier: 2, isLastTier: true, isCollapsible: true, - id: "table-cr-charlie", + id: "table-cr-echo", + visualElement: "thumbnail", }, { - cellContent: "Table row delta", + cellContent: "Table row foxtrot", tier: 2, isLastTier: true, isCollapsible: true, - id: "table-cr-delta", + id: "table-cr-foxtrot", }, { cellContent: "Summary row", @@ -370,5 +458,72 @@ export const TableGroup = Variants({ testHeading: "Body drop target", isDropTarget: true, }, + { + testHeading: "Focus, selected states for rows and cells", + rowItems: [ + { + cellContent: "Focused selected row, no rounded corners", + isFocused: true, + isSelected: true, + }, + { + cellContent: "Selected, hovered row", + isSelected: true, + isHovered: true, + }, + { + cellContent: ["Selected unfocused row, with a focused cell", "Focused cell", "Unfocused cell"], + isSelected: true, + cellCustomClasses: { + 1: ["is-focus-visible"] + } + }, + { + cellContent: "Focused unselected row, no rounded corners", + isFocused: true, + }, + { + cellContent: ["Table row with a focused cell", "Focused cell", "Unfocused cell"], + cellCustomClasses: { + 1: ["is-focus-visible"] + } + }, + { + cellContent: "Hovered row", + isHovered: true, + + }, + { + cellContent: "Focused selected row, with rounded corners", + isFocused: true, + isSelected: true, + } + ] + }, + { + testHeading: "Sparkline charts", + hasChartContent: true, + rowItems: [ + { cellContent: ["Informative sparkline", "200", "sparkline-informative.svg"], + textAlignment: { + 1: "end" + } + }, + { cellContent: ["Negative sparkline", "0", "sparkline-negative.svg"], + textAlignment: { + 1: "end" + } + }, + { cellContent: ["Positive sparkline", "600", "sparkline-positive.svg"], + textAlignment: { + 1: "end" + } + },{ cellContent: ["Notice sparkline", "400", "sparkline-notice.svg"], + textAlignment: { + 1: "end" + } + }, + ] + } ], }); diff --git a/components/table/stories/template.js b/components/table/stories/template.js index 662a6e3206b..fb3838182ab 100644 --- a/components/table/stories/template.js +++ b/components/table/stories/template.js @@ -1,7 +1,10 @@ +import { Template as Avatar } from "@spectrum-css/avatar/stories/template.js"; import { Template as Button } from "@spectrum-css/button/stories/template.js"; import { Template as Checkbox } from "@spectrum-css/checkbox/stories/template.js"; import { Template as Icon } from "@spectrum-css/icon/stories/template.js"; +import { Template as IllustratedMessage } from "@spectrum-css/illustratedmessage/stories/template.js"; import { getRandomId } from "@spectrum-css/preview/decorators"; +import { Template as ProgressCircle } from "@spectrum-css/progresscircle/stories/template.js"; import { Template as Thumbnail } from "@spectrum-css/thumbnail/stories/template.js"; import { classMap } from "lit/directives/class-map.js"; import { ifDefined } from "lit/directives/if-defined.js"; @@ -9,32 +12,34 @@ import { when } from "lit/directives/when.js"; import { html, literal } from "lit/static-html.js"; import "../index.css"; -import "../themes/spectrum.css"; -/* Must be imported last */ -import "../themes/express.css"; export const TableRowItem = ({ rootClass = "spectrum-Table", cellContent = "Row Item Text", showCheckbox = false, isSelected = false, + isFocused = false, + isHovered = false, isSummaryRow = false, isSectionHeader = false, - tableIsEmphasized = true, + isEmphasized = true, isCollapsible = false, isExpanded = false, isHidden = false, hasColumnDividers = false, + density = "regular", tier, isLastTier = false, useDivs = false, - showThumbnails = false, + visualElement, + textAlignment, isDropTarget = false, ariaControls, customClasses = [], - size = "m", + cellCustomClasses = {}, + hasChartContent = false, } = {}, context = {}) => { - const useThumbnail = showThumbnails && !isSummaryRow && !isSectionHeader; + const useVisuals = visualElement !== undefined && !isSummaryRow && !isSectionHeader; const useColumnDividers = hasColumnDividers && !isSummaryRow && !isSectionHeader; // Use Table tags or Div tags. @@ -47,15 +52,37 @@ export const TableRowItem = ({ const content = Array.isArray(cellContent) ? cellContent[columnIndex] : cellContent; - if (useThumbnail && columnIndex < 2) { + + if (useVisuals && columnIndex < 2) { return html` -
- ${Thumbnail({ - size: "300", - imageURL: "example-card-landscape.png", - isCover: true, - }, context)} -
${content}
+
+ ${visualElement === "thumbnail" ? + Thumbnail({ + size: ({ + compact: "75", + regular: "100", + spacious: "200", + }[density] || "100"), + imageURL: "example-card-landscape.png", + isCover: true, + }, context) + : visualElement === "avatar" ? + Avatar({ + size: ({ + compact: "50", + regular: "75", + spacious: "100", + }[density] || "75"), + imageURL: "example-card-landscape.png", + isCover: true, + }, context) + : visualElement === "icon" ? + Icon({ + iconName: "Image", + setName: "workflow", + }, context) + : null} +
${content}
`; } @@ -64,6 +91,11 @@ export const TableRowItem = ({ } }; + // For each column, apply the text alignment specified in textAlignment + const getTextAlignment = (columnIndex) => { + return textAlignment?.[columnIndex] || "start"; + }; + return html` <${rowTag} class=${classMap({ @@ -71,9 +103,10 @@ export const TableRowItem = ({ [`${rootClass}-row--summary`]: isSummaryRow, [`${rootClass}-row--sectionHeader`]: isSectionHeader, [`${rootClass}-row--collapsible`]: isCollapsible, - [`${rootClass}-row--thumbnail`]: useThumbnail, [`${rootClass}-cell--divider`]: useColumnDividers, ["is-selected"]: isSelected, + ["is-focus-visible"]: isFocused, + ["is-hover"]: isHovered, ["is-expanded"]: isExpanded, ["is-last-tier"]: isLastTier, ["is-drop-target"]: isDropTarget, @@ -90,12 +123,14 @@ export const TableRowItem = ({ class=${classMap({ [`${rootClass}-cell`]: true, [`${rootClass}-checkboxCell`]: true, + [`${rootClass}-cell--alignEnd`]: getTextAlignment(0) === "end", + ...cellCustomClasses?.[0]?.reduce((a, c) => ({ ...a, [c]: true }), {}), })} > ${when(!isSummaryRow, () => Checkbox({ - size, - isEmphasized: tableIsEmphasized, + size: "m", + isEmphasized, isChecked: isSelected, customClasses: [`${rootClass}-checkbox`], }, context) @@ -104,41 +139,47 @@ export const TableRowItem = ({ )} ${isCollapsible - ? html` - <${cellTag} - role=${ifDefined(showCheckbox ? "gridcell" : useDivs ? "cell" : undefined)} - class=${classMap({ - [`${rootClass}-cell`]: true, - [`${rootClass}-cell--collapsible`]: true, - [`${rootClass}-cell--thumbnail`]: useThumbnail, - [`${rootClass}-cell--divider`]: useColumnDividers, - })} - > -
- ${when(!isLastTier, () => - Button({ - size, - iconName: "ChevronRight100", - iconSet: "ui", - hideLabel: true, - customClasses: [`${rootClass}-disclosureIcon`], - ariaExpanded: isExpanded, - ariaControls, - }, context) - )} - ${useThumbnail ? getCellContent(0) : html`
${getCellContent(0)}
`} -
- ` - : html` - <${cellTag} - role=${ifDefined(showCheckbox ? "gridcell" : useDivs ? "cell" : undefined)} - class=${classMap({ - [`${rootClass}-cell`]: true, - [`${rootClass}-cell--thumbnail`]: useThumbnail, - [`${rootClass}-cell--divider`]: useColumnDividers, - })} - colspan=${ifDefined(isSectionHeader && showCheckbox ? "4" : isSectionHeader ? "3" : undefined)} - >${getCellContent(0)}` + ? html` + <${cellTag} + role=${ifDefined(showCheckbox ? "gridcell" : useDivs ? "cell" : undefined)} + class=${classMap({ + [`${rootClass}-cell`]: true, + [`${rootClass}-cell--collapsible`]: true, + [`${rootClass}-cell--visual`]: useVisuals, + [`${rootClass}-cell--divider`]: useColumnDividers, + [`${rootClass}-cell--alignEnd`]: getTextAlignment(0) === "end", + ...cellCustomClasses?.[showCheckbox ? 1 : 0]?.reduce((a, c) => ({ ...a, [c]: true }), {}), + })} + > +
+ ${when(!isLastTier, () => + Button({ + size: "m", + iconName: "ChevronRight100", + iconSet: "ui", + hideLabel: true, + customClasses: [`${rootClass}-disclosureIcon`], + ariaExpanded: isExpanded, + ariaControls, + }, context) + )} + ${useVisuals ? getCellContent(0) : html`
${getCellContent(0)}
`} +
+ ` + : html` + <${cellTag} + role=${ifDefined(showCheckbox ? "gridcell" : useDivs ? "cell" : undefined)} + class=${classMap({ + [`${rootClass}-cell`]: true, + [`${rootClass}-cell--visual`]: useVisuals, + [`${rootClass}-cell--divider`]: useColumnDividers, + [`${rootClass}-cell--alignEnd`]: getTextAlignment(0) === "end", + ...cellCustomClasses?.[showCheckbox ? 1 : 0]?.reduce((a, c) => ({ ...a, [c]: true }), {}), + })} + colspan=${ifDefined(isSectionHeader && showCheckbox ? "4" : isSectionHeader ? "3" : undefined)} + > + ${getCellContent(0)} + ` } ${when(!isSectionHeader, () => html` @@ -146,8 +187,10 @@ export const TableRowItem = ({ role=${ifDefined(showCheckbox ? "gridcell" : useDivs ? "cell" : undefined)} class=${classMap({ [`${rootClass}-cell`]: true, - [`${rootClass}-cell--thumbnail`]: useThumbnail, + [`${rootClass}-cell--visual`]: useVisuals, [`${rootClass}-cell--divider`]: useColumnDividers, + [`${rootClass}-cell--alignEnd`]: getTextAlignment(1) === "end", + ...cellCustomClasses?.[showCheckbox ? 2 : 1]?.reduce((a, c) => ({ ...a, [c]: true }), {}), })} >${getCellContent(1)} @@ -156,8 +199,16 @@ export const TableRowItem = ({ class=${classMap({ [`${rootClass}-cell`]: true, [`${rootClass}-cell--divider`]: useColumnDividers, + [`${rootClass}-cell--alignEnd`]: getTextAlignment(2) === "end", + ...cellCustomClasses?.[showCheckbox ? 3 : 2]?.reduce((a, c) => ({ ...a, [c]: true }), {}), })} - >${getCellContent(2)}` + > + ${when(hasChartContent, () => html` +
+ Chart +
+ `, () => getCellContent(2))} + ` )} `; @@ -165,20 +216,55 @@ export const TableRowItem = ({ export const Template = ({ rootClass = "spectrum-Table", - size = "m", - density = "standard", + density = "regular", isQuiet = false, isEmphasized = true, + isLoading = false, useDivs = false, + selectionMode = "none", useScroller = false, - showThumbnails = false, + visualElement, isDropTarget = false, hasColumnDividers = false, + isSortable = false, + sortIcon = "Sort", + hasMenu = false, + hasChartContent = false, rowItems = [], customClasses = [], id = getRandomId("table"), } = {}, context = {}) => { - if (!rowItems || !rowItems.length) return html``; + + // Empty state + if (!rowItems || !rowItems.length) return html` + ${IllustratedMessage({ + illustration: "NoData", + illustrationSet: "workflow", + title: "Empty state title", + description: "No data to display. Description of status. Give more information about what a user can do or expect, or how to make items appear here.", + isHorizontal: true, + hasButtons: true, + size: ({ + "compact": "s", + "regular": "m", + "spacious": "l", + }[density] || "regular"), + }, context)} + `; + + // Loading state + if (isLoading) { + return html` + ${ProgressCircle({ + size: ({ + "compact": "s", + "regular": "m", + "spacious": "l", + }[density] || "regular"), + isIndeterminate: true, + }, context)} + `; + } // Use Table tags or Div tags. const tableTag = useDivs ? literal`div` : literal`table`; @@ -188,7 +274,6 @@ export const Template = ({ const thTag = useDivs ? literal`div` : literal`th`; const rootClassMapVariants = { - [`${rootClass}--size${size?.toUpperCase()}`]: typeof size !== "undefined", [`${rootClass}--${density}`]: density !== "standard", [`${rootClass}--quiet`]: isQuiet, [`${rootClass}--emphasized`]: isEmphasized, @@ -196,6 +281,7 @@ export const Template = ({ }; const useCheckboxCell = rowItems.some((item) => item.showCheckbox === true); + const ariaSortValue = sortIcon === "SortUp" ? "ascending" : sortIcon === "SortDown" ? "descending" : "none"; const tableHtml = html` <${tableTag} @@ -206,8 +292,7 @@ export const Template = ({ })} id=${ifDefined(id)} role=${ifDefined(useCheckboxCell ? "grid" : useDivs ? "table" : undefined)} - aria-multiselectable=${ifDefined(useCheckboxCell ? "true" : undefined)} - style="max-width: 800px;" + aria-multiselectable=${ifDefined(selectionMode === "multiple" ? "true" : undefined)} > <${theadTag} class="${rootClass}-head" @@ -215,57 +300,69 @@ export const Template = ({ > <${rowTag} role=${ifDefined(useDivs ? "row" : undefined)} + class="${rootClass}-headRow" > ${when(useCheckboxCell, () => html` <${thTag} class="spectrum-Table-headCell spectrum-Table-checkboxCell" role=${ifDefined(useDivs ? "columnheader" : undefined)} > - ${Checkbox({ - size, - isEmphasized: isEmphasized, - isChecked: false, - isIndeterminate: true, - customClasses: [`${rootClass}-checkbox`], + ${when(selectionMode === "multiple", () => html` + ${Checkbox({ + size: "m", + isEmphasized: isEmphasized, + isChecked: false, + isIndeterminate: true, + customClasses: [`${rootClass}-checkbox`], }, context)} - ` + `)} + `, )} <${thTag} - class="${rootClass}-headCell is-sortable is-sorted-desc" + class=${classMap({ + [`${rootClass}-headCell`]: true, + ["is-sortable"]: isSortable, + ["is-sorted-asc"]: sortIcon === "SortUp", + ["is-sorted-desc"]: sortIcon === "SortDown", + [`${rootClass}-hasMenuButton`]: hasMenu, + })} role=${ifDefined(useDivs ? "columnheader" : undefined)} - aria-sort="descending" - tabindex="0" + aria-sort=${ifDefined(isSortable || hasMenu ? ariaSortValue : undefined)} > - ${Icon({ - iconName: "ArrowDown100", - setName: "ui", - size, - customClasses: [`${rootClass}-sortedIcon`], - }, context)}Column title${ - Icon({ - iconName: "ChevronDown100", - setName: "ui", - size, - customClasses: [`${rootClass}-menuIcon`], - }, context)} + ${when(hasMenu || isSortable, () => html` + ${when(isSortable, () => Button({ + size: "m", + variant: "secondary", + iconName: sortIcon, + iconSet: "workflow", + label: "Column title", + customClasses: [`${rootClass}-sortButton`], + }, context) + )} + ${when(!isSortable, () => Button({ + size: "m", + variant: "secondary", + iconName: "SortUp", + iconSet: "workflow", + label: "Column title", + customClasses: [`${rootClass}-sortButton`], + }, context) + )} + `, () => html`Column title` + )} <${thTag} - class="${rootClass}-headCell is-sortable" + class="${rootClass}-headCell" role=${ifDefined(useDivs ? "columnheader" : undefined)} - aria-sort="none" - tabindex="0" > - ${Icon({ - iconName: "ArrowDown100", - setName: "ui", - size, - customClasses: [`${rootClass}-sortedIcon`], - }, context)}Column title + Column title <${thTag} class="${rootClass}-headCell" role=${ifDefined(useDivs ? "columnheader" : undefined)} - >Column title + > + Column title + <${tbodyTag} @@ -278,11 +375,13 @@ export const Template = ({ ${rowItems.map((item) => TableRowItem({ rootClass, - size, + density, useDivs, - showThumbnails, + visualElement, hasColumnDividers, - tableIsEmphasized: isEmphasized, + hasMenu, + hasChartContent, + isEmphasized, ...item, }, context) )} diff --git a/components/table/themes/express.css b/components/table/themes/express.css deleted file mode 100644 index 9fd550418f2..00000000000 --- a/components/table/themes/express.css +++ /dev/null @@ -1,16 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--express */ - -@import "./spectrum.css"; diff --git a/components/table/themes/spectrum-two.css b/components/table/themes/spectrum-two.css deleted file mode 100644 index 1c0a4684070..00000000000 --- a/components/table/themes/spectrum-two.css +++ /dev/null @@ -1,30 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -@container style(--system: spectrum) { - .spectrum-Table { - --spectrum-table-header-background-color: var(--spectrum-transparent-white-25); - --spectrum-table-border-color: var(--spectrum-gray-200); - --spectrum-table-divider-color: var(--spectrum-gray-200); - --spectrum-table-row-background-color: var(--spectrum-gray-25); - --spectrum-table-summary-row-background-color: var(--spectrum-gray-100); - --spectrum-table-section-header-background-color: var(--spectrum-gray-100); - --spectrum-table-icon-color-focus: var(--spectrum-neutral-subdued-content-color-key-focus); - --spectrum-table-icon-color-focus-hover: var(--spectrum-neutral-subdued-content-color-hover); - } - - .spectrum-Table--quiet { - --spectrum-table-header-background-color: var(--spectrum-transparent-white-25); - --spectrum-table-row-background-color: var(--spectrum-transparent-white-25); - } -} diff --git a/components/table/themes/spectrum.css b/components/table/themes/spectrum.css deleted file mode 100644 index a40d7fabde2..00000000000 --- a/components/table/themes/spectrum.css +++ /dev/null @@ -1,34 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--legacy */ - -@import "./spectrum-two.css"; - -@container style(--system: legacy) { - .spectrum-Table { - --spectrum-table-header-background-color: var(--spectrum-transparent-white-100); - --spectrum-table-border-color: var(--spectrum-gray-300); - --spectrum-table-divider-color: var(--spectrum-gray-300); - --spectrum-table-row-background-color: var(--spectrum-gray-50); - --spectrum-table-summary-row-background-color: var(--spectrum-gray-200); - --spectrum-table-section-header-background-color: var(--spectrum-gray-200); - --spectrum-table-icon-color-focus: var(--spectrum-neutral-subdued-content-color-key-focus); - --spectrum-table-icon-color-focus-hover: var(--spectrum-neutral-subdued-content-down); - } - - .spectrum-Table--quiet { - --spectrum-table-header-background-color: var(--spectrum-transparent-white-100); - --spectrum-table-row-background-color: var(--spectrum-transparent-white-100); - } -} diff --git a/components/tabs/CHANGELOG.md b/components/tabs/CHANGELOG.md index cc9cdafb91b..ce171b422c4 100644 --- a/components/tabs/CHANGELOG.md +++ b/components/tabs/CHANGELOG.md @@ -1,5 +1,75 @@ # Change log +## 7.0.0-next.2 + +### Major Changes + +📝 [#4003](https://github.com/adobe/spectrum-css/pull/4003) [`7f48b7c`](https://github.com/adobe/spectrum-css/commit/7f48b7c6384f8c7d598637226a17aff1c8e8b61c) Thanks [@rise-erpelding](https://github.com/rise-erpelding)! + +Tab has now been migrated to Spectrum 2. This migration brings with it several major changes: + +- Emphasized variant has been removed +- The divider line has been removed and all variants now resemble what was formerly the quiet variant +- Removal of t-shirt sizes (only one size is available) +- Updated high contrast styles +- The focus indicator's size has changed to accommodate the selection indicator inside of the focus outline + +Overflow and vertical variants, aside from what applies from the notes above, remain mostly unchanged and currently are not fully supported in S2. One exception: a bug fix was made to allow density variants to be visible in the overflow variant (previously, the overflow variant was identical for both densities). + +A full list of added and removed mods can be found below. However, please note the following mod name changes: + +- `--mod-tabs-divider-size` is now `--mod-tabs-selection-indicator-thickness` +- `--mod-tabs-divider-border-radius` is now `--mod-tabs-selection-indicator-border-radius` + +Removed mods + +- `--mod-tabs-color-hover-emphasized` +- `--mod-tabs-color-key-focus-emphasized` +- `--mod-tabs-color-selected-emphasized` +- `--mod-tabs-divider-background-color` +- `--mod-tabs-divider-border-radius` +- `--mod-tabs-divider-size` +- `--mod-tabs-item-vertical-spacing` +- `--mod-tabs-list-background-direction` +- `--mod-tabs-list-background-direction-vertical` +- `--mod-tabs-list-background-direction-vertical-right` +- `--mod-tabs-selection-indicator-color-emphasized` +- `--mod-tabs-start-to-item-quiet` + +Added mods + +- `--mod-tabs-color-selected-hover` +- `--mod-tabs-color-selected-key-focus` +- `--mod-tabs-item-border-radius` +- `--mod-tabs-item-horizontal-spacing-compact` +- `--mod-tabs-label-to-selection-indicator` +- `--mod-tabs-label-to-selection-indicator-compact` +- `--mod-tabs-selection-indicator-border-radius` +- `--mod-tabs-selection-indicator-color-disabled` +- `--mod-tabs-selection-indicator-thickness` +- `--mod-tabs-side-to-icon` +- `--mod-tabs-side-to-icon-compact` + +📝 [#4014](https://github.com/adobe/spectrum-css/pull/4014) [`35c066b`](https://github.com/adobe/spectrum-css/commit/35c066b29c311b1bfcf4507075f13b41222ffc84) Thanks [@castastrophe](https://github.com/castastrophe)! + +This update removes the `dir` attribute polyfill (served via a PostCSS transform to compiled assets) as the fallback is no longer necessary. The`dir` attribute support is available in all supported browsers and has been tested to correctly inherit inside web component shadow DOMs. This is a breaking change **only** to those relying on the `dir` attribute being present for styling, however, the `:dir` pseudo will correctly inherit values from their containers. To correctly determine the `dir` value of a node using JavaScript, you can use `getComputedStyle(node).direction`. + +## 7.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + +## 7.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`a25e0a9`](https://github.com/adobe/spectrum-css/commit/a25e0a99e5a4736ab4e607e00739343101a2633b)]: + - @spectrum-css/icon@10.0.0-next.0 + - @spectrum-css/menu@10.0.0-next.0 + - @spectrum-css/picker@10.0.0-next.0 + ## 6.2.0 ### Minor Changes diff --git a/components/tabs/dist/metadata.json b/components/tabs/dist/metadata.json index 544295ef045..879d8bd7440 100644 --- a/components/tabs/dist/metadata.json +++ b/components/tabs/dist/metadata.json @@ -2,38 +2,33 @@ "sourceFile": "index.css", "selectors": [ ".spectrum-Tabs", - ".spectrum-Tabs .is-selected:before", - ".spectrum-Tabs .is-selected:focus", - ".spectrum-Tabs .is-selected:focus-visible", - ".spectrum-Tabs .spectrum-Tabs-item .spectrum-Icon", - ".spectrum-Tabs .spectrum-Tabs-item .spectrum-Tabs-itemLabel", + ".spectrum-Tabs .spectrum-Picker-button", + ".spectrum-Tabs .spectrum-Tabs-item.is-selected", + ".spectrum-Tabs .spectrum-Tabs-item.is-selected .spectrum-Icon", + ".spectrum-Tabs .spectrum-Tabs-item.is-selected.is-disabled .spectrum-Icon", + ".spectrum-Tabs .spectrum-Tabs-item.is-selected.is-disabled .spectrum-Tabs-selectionIndicator", ".spectrum-Tabs--horizontal", ".spectrum-Tabs--horizontal .spectrum-Tabs-item", - ".spectrum-Tabs--horizontal .spectrum-Tabs-item + :not(.spectrum-Tabs-selectionIndicator)", ".spectrum-Tabs--horizontal .spectrum-Tabs-selectionIndicator", ".spectrum-Tabs--horizontal.spectrum-Tabs--compact", - ".spectrum-Tabs--quiet", - ".spectrum-Tabs--quiet .spectrum-Tabs-selectionIndicator", ".spectrum-Tabs--vertical", ".spectrum-Tabs--vertical .spectrum-Icon", ".spectrum-Tabs--vertical .spectrum-Tabs-item", - ".spectrum-Tabs--vertical .spectrum-Tabs-item:before", ".spectrum-Tabs--vertical .spectrum-Tabs-selectionIndicator", ".spectrum-Tabs--vertical-right", ".spectrum-Tabs--vertical-right .spectrum-Icon", ".spectrum-Tabs--vertical-right .spectrum-Tabs-item", - ".spectrum-Tabs--vertical-right .spectrum-Tabs-item:before", ".spectrum-Tabs--vertical-right .spectrum-Tabs-selectionIndicator", - ".spectrum-Tabs--vertical-right.spectrum-Tabs--quiet", - ".spectrum-Tabs--vertical-right:dir(rtl)", - ".spectrum-Tabs--vertical.spectrum-Tabs--quiet", - ".spectrum-Tabs--vertical:dir(rtl)", ".spectrum-Tabs-item", ".spectrum-Tabs-item .spectrum-Icon", ".spectrum-Tabs-item .spectrum-Icon + .spectrum-Tabs-itemLabel", ".spectrum-Tabs-item.is-disabled", ".spectrum-Tabs-item.is-disabled .spectrum-Tabs-itemLabel", + ".spectrum-Tabs-item.is-disabled .spectrum-Tabs-selectionIndicator", ".spectrum-Tabs-item.is-selected", + ".spectrum-Tabs-item.is-selected.is-disabled", + ".spectrum-Tabs-item.is-selected:focus-visible", + ".spectrum-Tabs-item.is-selected:hover", ".spectrum-Tabs-item:before", ".spectrum-Tabs-item:focus-visible", ".spectrum-Tabs-item:focus-visible:before", @@ -41,18 +36,7 @@ ".spectrum-Tabs-itemLabel", ".spectrum-Tabs-itemLabel:empty", ".spectrum-Tabs-selectionIndicator", - ".spectrum-Tabs.spectrum-Tabs--compact", - ".spectrum-Tabs.spectrum-Tabs--compact.spectrum-Tabs--sizeL", - ".spectrum-Tabs.spectrum-Tabs--compact.spectrum-Tabs--sizeS", - ".spectrum-Tabs.spectrum-Tabs--compact.spectrum-Tabs--sizeXL", - ".spectrum-Tabs.spectrum-Tabs--emphasized", - ".spectrum-Tabs.spectrum-Tabs--quiet", - ".spectrum-Tabs.spectrum-Tabs--sizeL", - ".spectrum-Tabs.spectrum-Tabs--sizeS", - ".spectrum-Tabs.spectrum-Tabs--sizeXL", - ".spectrum-Tabs.spectrum-Tabs--vertical.spectrum-Tabs--compact .spectrum-Tabs-item:before", - "[dir=\"rtl\"] .spectrum-Tabs--vertical", - "[dir=\"rtl\"] .spectrum-Tabs--vertical-right" + ".spectrum-Tabs.spectrum-Tabs--compact" ], "modifiers": [ "--mod-tabs-animation-duration", @@ -62,14 +46,10 @@ "--mod-tabs-color", "--mod-tabs-color-disabled", "--mod-tabs-color-hover", - "--mod-tabs-color-hover-emphasized", "--mod-tabs-color-key-focus", - "--mod-tabs-color-key-focus-emphasized", "--mod-tabs-color-selected", - "--mod-tabs-color-selected-emphasized", - "--mod-tabs-divider-background-color", - "--mod-tabs-divider-border-radius", - "--mod-tabs-divider-size", + "--mod-tabs-color-selected-hover", + "--mod-tabs-color-selected-key-focus", "--mod-tabs-focus-indicator-border-radius", "--mod-tabs-focus-indicator-color", "--mod-tabs-focus-indicator-gap", @@ -80,24 +60,28 @@ "--mod-tabs-font-weight", "--mod-tabs-icon-size", "--mod-tabs-icon-to-text", + "--mod-tabs-item-border-radius", "--mod-tabs-item-height", "--mod-tabs-item-height-compact", "--mod-tabs-item-horizontal-spacing", - "--mod-tabs-item-vertical-spacing", + "--mod-tabs-item-horizontal-spacing-compact", + "--mod-tabs-label-to-selection-indicator", + "--mod-tabs-label-to-selection-indicator-compact", "--mod-tabs-line-height", - "--mod-tabs-list-background-direction", - "--mod-tabs-list-background-direction-vertical", - "--mod-tabs-list-background-direction-vertical-right", + "--mod-tabs-selection-indicator-border-radius", "--mod-tabs-selection-indicator-color", - "--mod-tabs-selection-indicator-color-emphasized", + "--mod-tabs-selection-indicator-color-disabled", + "--mod-tabs-selection-indicator-thickness", + "--mod-tabs-side-to-icon", + "--mod-tabs-side-to-icon-compact", "--mod-tabs-start-to-edge", - "--mod-tabs-start-to-item-quiet", "--mod-tabs-top-to-icon", "--mod-tabs-top-to-icon-compact", "--mod-tabs-top-to-text", "--mod-tabs-top-to-text-compact" ], "component": [ + "--spectrum-tab-selection-indicator-thickness", "--spectrum-tabs-animation-duration", "--spectrum-tabs-animation-ease", "--spectrum-tabs-bottom-to-text", @@ -106,9 +90,8 @@ "--spectrum-tabs-color-hover", "--spectrum-tabs-color-key-focus", "--spectrum-tabs-color-selected", - "--spectrum-tabs-divider-background-color", - "--spectrum-tabs-divider-border-radius", - "--spectrum-tabs-divider-size", + "--spectrum-tabs-color-selected-hover", + "--spectrum-tabs-color-selected-key-focus", "--spectrum-tabs-focus-indicator-border-radius", "--spectrum-tabs-focus-indicator-color", "--spectrum-tabs-focus-indicator-gap", @@ -119,107 +102,73 @@ "--spectrum-tabs-font-weight", "--spectrum-tabs-icon-size", "--spectrum-tabs-icon-to-text", + "--spectrum-tabs-item-border-radius", "--spectrum-tabs-item-height", "--spectrum-tabs-item-horizontal-spacing", - "--spectrum-tabs-item-vertical-spacing", + "--spectrum-tabs-label-to-selection-indicator", "--spectrum-tabs-line-height", - "--spectrum-tabs-list-background-direction", + "--spectrum-tabs-selection-indicator-border-radius", "--spectrum-tabs-selection-indicator-color", + "--spectrum-tabs-selection-indicator-color-disabled", + "--spectrum-tabs-selection-indicator-thickness", + "--spectrum-tabs-side-to-icon", "--spectrum-tabs-start-to-edge", "--spectrum-tabs-top-to-icon", "--spectrum-tabs-top-to-text" ], "global": [ - "--spectrum-accent-content-color-default", - "--spectrum-accent-content-color-hover", - "--spectrum-accent-content-color-key-focus", "--spectrum-animation-duration-100", "--spectrum-animation-ease-in-out", - "--spectrum-border-width-200", + "--spectrum-corner-radius-0", "--spectrum-corner-radius-100", + "--spectrum-corner-radius-full", "--spectrum-default-font-style", + "--spectrum-disabled-border-color", + "--spectrum-disabled-content-color", "--spectrum-focus-indicator-color", + "--spectrum-focus-indicator-gap", "--spectrum-focus-indicator-thickness", "--spectrum-font-size-100", - "--spectrum-font-size-200", - "--spectrum-font-size-300", - "--spectrum-font-size-75", - "--spectrum-gray-200", - "--spectrum-gray-500", "--spectrum-line-height-100", + "--spectrum-neutral-content-color-default", + "--spectrum-neutral-content-color-hover", + "--spectrum-neutral-content-color-key-focus", "--spectrum-neutral-subdued-content-color-default", "--spectrum-neutral-subdued-content-color-down", "--spectrum-neutral-subdued-content-color-hover", "--spectrum-neutral-subdued-content-color-key-focus", "--spectrum-regular-font-weight", "--spectrum-sans-font-family-stack", - "--spectrum-tab-item-bottom-to-text-extra-large", - "--spectrum-tab-item-bottom-to-text-large", + "--spectrum-spacing-200", + "--spectrum-spacing-75", + "--spectrum-tab-item-bottom-to-text-compact-medium", "--spectrum-tab-item-bottom-to-text-medium", - "--spectrum-tab-item-bottom-to-text-small", - "--spectrum-tab-item-compact-height-extra-large", - "--spectrum-tab-item-compact-height-large", "--spectrum-tab-item-compact-height-medium", - "--spectrum-tab-item-compact-height-small", - "--spectrum-tab-item-focus-indicator-gap-extra-large", - "--spectrum-tab-item-focus-indicator-gap-large", - "--spectrum-tab-item-focus-indicator-gap-medium", - "--spectrum-tab-item-focus-indicator-gap-small", - "--spectrum-tab-item-height-extra-large", - "--spectrum-tab-item-height-large", "--spectrum-tab-item-height-medium", - "--spectrum-tab-item-height-small", - "--spectrum-tab-item-start-to-edge-extra-large", - "--spectrum-tab-item-start-to-edge-large", + "--spectrum-tab-item-side-to-workflow-icon-compact-medium", + "--spectrum-tab-item-side-to-workflow-icon-medium", "--spectrum-tab-item-start-to-edge-medium", - "--spectrum-tab-item-start-to-edge-small", - "--spectrum-tab-item-to-tab-item-horizontal-extra-large", - "--spectrum-tab-item-to-tab-item-horizontal-large", + "--spectrum-tab-item-to-tab-item-compact-horizontal-medium", "--spectrum-tab-item-to-tab-item-horizontal-medium", - "--spectrum-tab-item-to-tab-item-horizontal-small", - "--spectrum-tab-item-to-tab-item-vertical-extra-large", - "--spectrum-tab-item-to-tab-item-vertical-large", - "--spectrum-tab-item-to-tab-item-vertical-medium", - "--spectrum-tab-item-to-tab-item-vertical-small", - "--spectrum-tab-item-top-to-text-compact-extra-large", - "--spectrum-tab-item-top-to-text-compact-large", "--spectrum-tab-item-top-to-text-compact-medium", - "--spectrum-tab-item-top-to-text-compact-small", - "--spectrum-tab-item-top-to-text-extra-large", - "--spectrum-tab-item-top-to-text-large", "--spectrum-tab-item-top-to-text-medium", - "--spectrum-tab-item-top-to-text-small", - "--spectrum-tab-item-top-to-workflow-icon-compact-extra-large", - "--spectrum-tab-item-top-to-workflow-icon-compact-large", "--spectrum-tab-item-top-to-workflow-icon-compact-medium", - "--spectrum-tab-item-top-to-workflow-icon-compact-small", - "--spectrum-tab-item-top-to-workflow-icon-extra-large", - "--spectrum-tab-item-top-to-workflow-icon-large", "--spectrum-tab-item-top-to-workflow-icon-medium", - "--spectrum-tab-item-top-to-workflow-icon-small", "--spectrum-text-to-visual-100", - "--spectrum-text-to-visual-200", - "--spectrum-text-to-visual-300", - "--spectrum-text-to-visual-75", - "--spectrum-workflow-icon-size-100", - "--spectrum-workflow-icon-size-200", - "--spectrum-workflow-icon-size-50", - "--spectrum-workflow-icon-size-75" + "--spectrum-workflow-icon-size-100" ], - "system-theme": [ - "--system-tabs-divider-background-color", - "--system-tabs-font-weight" - ], - "passthroughs": [], + "passthroughs": ["--mod-picker-block-size"], "high-contrast": [ + "--highcontrast-tabs-background-color-selected", "--highcontrast-tabs-color", "--highcontrast-tabs-color-disabled", "--highcontrast-tabs-color-hover", "--highcontrast-tabs-color-key-focus", "--highcontrast-tabs-color-selected", - "--highcontrast-tabs-divider-background-color", - "--highcontrast-tabs-focus-indicator-background-color", + "--highcontrast-tabs-color-selected-hover", + "--highcontrast-tabs-color-selected-key-focus", "--highcontrast-tabs-focus-indicator-color", - "--highcontrast-tabs-selection-indicator-color" + "--highcontrast-tabs-selection-indicator-color", + "--highcontrast-tabs-selection-indicator-color-disabled" ] } diff --git a/components/tabs/index.css b/components/tabs/index.css index 6727243f384..0b86ec831b5 100644 --- a/components/tabs/index.css +++ b/components/tabs/index.css @@ -1,5 +1,5 @@ /*! - * Copyright 2024 Adobe. All rights reserved. + * Copyright 2025 Adobe. All rights reserved. * * This file is licensed to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. You may obtain a copy @@ -11,149 +11,67 @@ * governing permissions and limitations under the License. */ -@import "./themes/spectrum-two.css"; - .spectrum-Tabs { - /* Default is Medium sizing */ - --spectrum-tabs-item-height: var(--spectrum-tab-item-height-medium); - --spectrum-tabs-item-horizontal-spacing: var(--spectrum-tab-item-to-tab-item-horizontal-medium); - --spectrum-tabs-item-vertical-spacing: var(--spectrum-tab-item-to-tab-item-vertical-medium); - --spectrum-tabs-start-to-edge: var(--spectrum-tab-item-start-to-edge-medium); - --spectrum-tabs-top-to-text: var(--spectrum-tab-item-top-to-text-medium); - --spectrum-tabs-bottom-to-text: var(--spectrum-tab-item-bottom-to-text-medium); - - --spectrum-tabs-icon-size: var(--spectrum-workflow-icon-size-75); - --spectrum-tabs-icon-to-text: var(--spectrum-text-to-visual-100); - --spectrum-tabs-top-to-icon: var(--spectrum-tab-item-top-to-workflow-icon-medium); - - --spectrum-tabs-color: var(--spectrum-neutral-subdued-content-color-default); - --spectrum-tabs-color-selected: var(--spectrum-neutral-subdued-content-color-down); - --spectrum-tabs-color-hover: var(--spectrum-neutral-subdued-content-color-hover); - --spectrum-tabs-color-key-focus: var(--spectrum-neutral-subdued-content-color-key-focus); - --spectrum-tabs-color-disabled: var(--spectrum-gray-500); - - --spectrum-tabs-font-family: var(--spectrum-sans-font-family-stack); - --spectrum-tabs-font-style: var(--spectrum-default-font-style); - --spectrum-tabs-font-size: var(--spectrum-font-size-100); - --spectrum-tabs-line-height: var(--spectrum-line-height-100); - - /* Focus Indicator */ - --spectrum-tabs-focus-indicator-width: var(--spectrum-focus-indicator-thickness); - --spectrum-tabs-focus-indicator-border-radius: var(--spectrum-corner-radius-100); - --spectrum-tabs-focus-indicator-gap: var(--spectrum-tab-item-focus-indicator-gap-medium); - --spectrum-tabs-focus-indicator-color: var(--spectrum-focus-indicator-color); - --spectrum-tabs-selection-indicator-color: var(--spectrum-neutral-subdued-content-color-down); - - --spectrum-tabs-list-background-direction: top; - --spectrum-tabs-divider-size: var(--spectrum-border-width-200); - --spectrum-tabs-divider-border-radius: 1px; - - --spectrum-tabs-animation-duration: var(--spectrum-animation-duration-100); - --spectrum-tabs-animation-ease: var(--spectrum-animation-ease-in-out); - - &.spectrum-Tabs--sizeS { - --spectrum-tabs-item-height: var(--spectrum-tab-item-height-small); - --spectrum-tabs-item-horizontal-spacing: var(--spectrum-tab-item-to-tab-item-horizontal-small); - --spectrum-tabs-item-vertical-spacing: var(--spectrum-tab-item-to-tab-item-vertical-small); - --spectrum-tabs-start-to-edge: var(--spectrum-tab-item-start-to-edge-small); - --spectrum-tabs-top-to-text: var(--spectrum-tab-item-top-to-text-small); - --spectrum-tabs-bottom-to-text: var(--spectrum-tab-item-bottom-to-text-small); - - --spectrum-tabs-icon-size: var(--spectrum-workflow-icon-size-50); - --spectrum-tabs-icon-to-text: var(--spectrum-text-to-visual-75); - --spectrum-tabs-top-to-icon: var(--spectrum-tab-item-top-to-workflow-icon-small); - - --spectrum-tabs-focus-indicator-gap: var(--spectrum-tab-item-focus-indicator-gap-small); - --spectrum-tabs-font-size: var(--spectrum-font-size-75); - } - - &.spectrum-Tabs--sizeL { - --spectrum-tabs-item-height: var(--spectrum-tab-item-height-large); - --spectrum-tabs-item-horizontal-spacing: var(--spectrum-tab-item-to-tab-item-horizontal-large); - --spectrum-tabs-item-vertical-spacing: var(--spectrum-tab-item-to-tab-item-vertical-large); - --spectrum-tabs-start-to-edge: var(--spectrum-tab-item-start-to-edge-large); - --spectrum-tabs-top-to-text: var(--spectrum-tab-item-top-to-text-large); - --spectrum-tabs-bottom-to-text: var(--spectrum-tab-item-bottom-to-text-large); - - --spectrum-tabs-icon-size: var(--spectrum-workflow-icon-size-100); - --spectrum-tabs-icon-to-text: var(--spectrum-text-to-visual-200); - --spectrum-tabs-top-to-icon: var(--spectrum-tab-item-top-to-workflow-icon-large); - - --spectrum-tabs-focus-indicator-gap: var(--spectrum-tab-item-focus-indicator-gap-large); - --spectrum-tabs-font-size: var(--spectrum-font-size-200); - } - - &.spectrum-Tabs--sizeXL { - --spectrum-tabs-item-height: var(--spectrum-tab-item-height-extra-large); - --spectrum-tabs-item-horizontal-spacing: var(--spectrum-tab-item-to-tab-item-horizontal-extra-large); - --spectrum-tabs-item-vertical-spacing: var(--spectrum-tab-item-to-tab-item-vertical-extra-large); - --spectrum-tabs-start-to-edge: var(--spectrum-tab-item-start-to-edge-extra-large); - --spectrum-tabs-top-to-text: var(--spectrum-tab-item-top-to-text-extra-large); - --spectrum-tabs-bottom-to-text: var(--spectrum-tab-item-bottom-to-text-extra-large); - - --spectrum-tabs-icon-size: var(--spectrum-workflow-icon-size-200); - --spectrum-tabs-icon-to-text: var(--spectrum-text-to-visual-300); - --spectrum-tabs-top-to-icon: var(--spectrum-tab-item-top-to-workflow-icon-extra-large); - - --spectrum-tabs-focus-indicator-gap: var(--spectrum-tab-item-focus-indicator-gap-extra-large); - --spectrum-tabs-font-size: var(--spectrum-font-size-300); - } - - &.spectrum-Tabs--emphasized { - --mod-tabs-color-selected: var(--mod-tabs-color-selected-emphasized, var(--spectrum-accent-content-color-default)); - --mod-tabs-color-hover: var(--mod-tabs-color-hover-emphasized, var(--spectrum-accent-content-color-hover)); - --mod-tabs-color-key-focus: var(--mod-tabs-color-key-focus-emphasized, var(--spectrum-accent-content-color-key-focus)); - - --mod-tabs-selection-indicator-color: var(--mod-tabs-selection-indicator-color-emphasized, var(--spectrum-accent-content-color-default)); - } -} - -.spectrum-Tabs--vertical { - --mod-tabs-list-background-direction: var(--mod-tabs-list-background-direction-vertical, right); -} - -.spectrum-Tabs--vertical-right { - --mod-tabs-list-background-direction: var(--mod-tabs-list-background-direction-vertical-right, left); -} - -.spectrum-Tabs--vertical:dir(rtl) { - --mod-tabs-list-background-direction: var(--mod-tabs-list-background-direction-vertical, left); -} - -.spectrum-Tabs--vertical-right:dir(rtl) { - --mod-tabs-list-background-direction: var(--mod-tabs-list-background-direction-vertical, right); + --spectrum-tabs-item-height: var(--mod-tabs-item-height, var(--spectrum-tab-item-height-medium)); + --spectrum-tabs-start-to-edge: var(--mod-tabs-start-to-edge, var(--spectrum-tab-item-start-to-edge-medium)); + --spectrum-tabs-top-to-text: var(--mod-tabs-top-to-text, var(--spectrum-tab-item-top-to-text-medium)); + --spectrum-tabs-bottom-to-text: var(--mod-tabs-bottom-to-text, var(--spectrum-tab-item-bottom-to-text-medium)); + --spectrum-tabs-label-to-selection-indicator: var(--mod-tabs-label-to-selection-indicator, var(--spectrum-spacing-200)); + --spectrum-tabs-item-horizontal-spacing: var(--mod-tabs-item-horizontal-spacing, var(--spectrum-tab-item-to-tab-item-horizontal-medium)); + + --spectrum-tabs-icon-size: var(--mod-tabs-icon-size, var(--spectrum-workflow-icon-size-100)); + --spectrum-tabs-icon-to-text: var(--mod-tabs-icon-to-text, var(--spectrum-text-to-visual-100)); + --spectrum-tabs-top-to-icon: var(--mod-tabs-top-to-icon, var(--spectrum-tab-item-top-to-workflow-icon-medium)); + --spectrum-tabs-side-to-icon: var(--mod-tabs-side-to-icon, var(--spectrum-tab-item-side-to-workflow-icon-medium)); + + --spectrum-tabs-item-border-radius: var(--mod-tabs-item-border-radius, var(--spectrum-corner-radius-0)); + + --spectrum-tabs-color: var(--highcontrast-tabs-color, var(--mod-tabs-color, var(--spectrum-neutral-subdued-content-color-default))); + --spectrum-tabs-color-hover: var(--highcontrast-tabs-color-hover, var(--mod-tabs-color-hover, var(--spectrum-neutral-subdued-content-color-hover))); + --spectrum-tabs-color-key-focus: var(--highcontrast-tabs-color-key-focus, var(--mod-tabs-color-key-focus, var(--spectrum-neutral-subdued-content-color-key-focus))); + --spectrum-tabs-color-selected: var(--highcontrast-tabs-color-selected, var(--mod-tabs-color-selected, var(--spectrum-neutral-content-color-default))); + --spectrum-tabs-color-selected-hover: var(--highcontrast-tabs-color-selected-hover, var(--mod-tabs-color-selected-hover, var(--spectrum-neutral-content-color-hover))); + --spectrum-tabs-color-selected-key-focus: var(--highcontrast-tabs-color-selected-key-focus, var(--mod-tabs-color-selected-key-focus, var(--spectrum-neutral-content-color-key-focus))); + --spectrum-tabs-color-disabled: var(--highcontrast-tabs-color-disabled, var(--mod-tabs-color-disabled, var(--spectrum-disabled-content-color))); + --spectrum-tabs-selection-indicator-color-disabled: var(--highcontrast-tabs-selection-indicator-color-disabled, var(--mod-tabs-selection-indicator-color-disabled, var(--spectrum-disabled-border-color))); + + --spectrum-tabs-font-weight: var(--mod-tabs-font-weight, var(--spectrum-regular-font-weight)); + --spectrum-tabs-font-family: var(--mod-tabs-font-family, var(--spectrum-sans-font-family-stack)); + --spectrum-tabs-font-style: var(--mod-tabs-font-style, var(--spectrum-default-font-style)); + --spectrum-tabs-font-size: var(--mod-tabs-font-size, var(--spectrum-font-size-100)); + --spectrum-tabs-line-height: var(--mod-tabs-line-height, var(--spectrum-line-height-100)); + + --spectrum-tabs-focus-indicator-width: var(--mod-tabs-focus-indicator-width, var(--spectrum-focus-indicator-thickness)); + --spectrum-tabs-focus-indicator-border-radius: var(--mod-tabs-focus-indicator-border-radius, var(--spectrum-corner-radius-100)); /* component rounding + focus indicator thickness + focus indicator gap = 0 + 2px + 2px = 4px */ + --spectrum-tabs-focus-indicator-gap: var(--mod-tabs-focus-indicator-gap, var(--spectrum-focus-indicator-gap)); + --spectrum-tabs-focus-indicator-color: var(--highcontrast-tabs-focus-indicator-color, var(--mod-tabs-focus-indicator-color, var(--spectrum-focus-indicator-color))); + + --spectrum-tabs-selection-indicator-color: var(--highcontrast-tabs-selection-indicator-color, var(--mod-tabs-selection-indicator-color, var(--spectrum-neutral-subdued-content-color-down))); + --spectrum-tabs-selection-indicator-thickness: var(--mod-tabs-selection-indicator-thickness, var(--spectrum-tab-selection-indicator-thickness)); + --spectrum-tabs-selection-indicator-border-radius: var(--mod-tabs-selection-indicator-border-radius, var(--spectrum-corner-radius-full)); + + --spectrum-tabs-animation-duration: var(--mod-tabs-animation-duration, var(--spectrum-animation-duration-100)); + --spectrum-tabs-animation-ease: var(--mod-tabs-animation-ease, var(--spectrum-animation-ease-in-out)); } .spectrum-Tabs.spectrum-Tabs--compact { - --mod-tabs-item-height: var(--mod-tabs-item-height-compact, var(--spectrum-tab-item-compact-height-medium)); - --mod-tabs-top-to-text: var(--mod-tabs-top-to-text-compact, var(--spectrum-tab-item-top-to-text-compact-medium)); - --mod-tabs-bottom-to-text: var(--mod-tabs-bottom-to-text-compact, var(--spectrum-tab-item-top-to-text-compact-medium)); - --mod-tabs-top-to-icon: var(--mod-tabs-top-to-icon-compact, var(--spectrum-tab-item-top-to-workflow-icon-compact-medium)); - - &.spectrum-Tabs--sizeS { - --mod-tabs-item-height: var(--mod-tabs-item-height-compact, var(--spectrum-tab-item-compact-height-small)); - --mod-tabs-top-to-text: var(--mod-tabs-top-to-text-compact, var(--spectrum-tab-item-top-to-text-compact-small)); - --mod-tabs-bottom-to-text: var(--mod-tabs-bottom-to-text-compact, var(--spectrum-tab-item-top-to-text-compact-small)); - --mod-tabs-top-to-icon: var(--mod-tabs-top-to-icon-compact, var(--spectrum-tab-item-top-to-workflow-icon-compact-small)); - } - - &.spectrum-Tabs--sizeL { - --mod-tabs-item-height: var(--mod-tabs-item-height-compact, var(--spectrum-tab-item-compact-height-large)); - --mod-tabs-top-to-text: var(--mod-tabs-top-to-text-compact, var(--spectrum-tab-item-top-to-text-compact-large)); - --mod-tabs-bottom-to-text: var(--mod-tabs-bottom-to-text-compact, var(--spectrum-tab-item-top-to-text-compact-large)); - --mod-tabs-top-to-icon: var(--mod-tabs-top-to-icon-compact, var(--spectrum-tab-item-top-to-workflow-icon-compact-large)); - } + --spectrum-tabs-item-height: var(--mod-tabs-item-height-compact, var(--spectrum-tab-item-compact-height-medium)); + --spectrum-tabs-top-to-text: var(--mod-tabs-top-to-text-compact, var(--spectrum-tab-item-top-to-text-compact-medium)); + --spectrum-tabs-bottom-to-text: var(--mod-tabs-bottom-to-text-compact, var(--spectrum-tab-item-bottom-to-text-compact-medium)); + --spectrum-tabs-label-to-selection-indicator: var(--mod-tabs-label-to-selection-indicator-compact, var(--spectrum-spacing-75)); + --spectrum-tabs-item-horizontal-spacing: var(--mod-tabs-item-horizontal-spacing-compact, var(--spectrum-tab-item-to-tab-item-compact-horizontal-medium)); + --spectrum-tabs-top-to-icon: var(--mod-tabs-top-to-icon-compact, var(--spectrum-tab-item-top-to-workflow-icon-compact-medium)); + --spectrum-tabs-side-to-icon: var(--mod-tabs-side-to-icon-compact, var(--spectrum-tab-item-side-to-workflow-icon-compact-medium)); +} - &.spectrum-Tabs--sizeXL { - --mod-tabs-item-height: var(--mod-tabs-item-height-compact, var(--spectrum-tab-item-compact-height-extra-large)); - --mod-tabs-top-to-text: var(--mod-tabs-top-to-text-compact, var(--spectrum-tab-item-top-to-text-compact-extra-large)); - --mod-tabs-bottom-to-text: var(--mod-tabs-bottom-to-text-compact, var(--spectrum-tab-item-top-to-text-compact-extra-large)); - --mod-tabs-top-to-icon: var(--mod-tabs-top-to-icon-compact, var(--spectrum-tab-item-top-to-workflow-icon-compact-extra-large)); - } +/* @passthrough -- picker styling for overflow tabs */ +.spectrum-Tabs .spectrum-Picker-button { + --mod-picker-block-size: var(--spectrum-tabs-item-height); } .spectrum-Tabs { display: flex; + gap: var(--spectrum-tabs-item-horizontal-spacing); /* Contain the selection indicator */ position: relative; @@ -164,8 +82,6 @@ /* Friends should align to the top of the tabs */ vertical-align: top; - - background: linear-gradient(to var(--mod-tabs-list-background-direction, var(--spectrum-tabs-list-background-direction)), var(--highcontrast-tabs-divider-background-color, var(--mod-tabs-divider-background-color, var(--spectrum-tabs-divider-background-color))) 0 var(--mod-tabs-divider-size, var(--spectrum-tabs-divider-size)), transparent var(--mod-tabs-divider-size, var(--spectrum-tabs-divider-size))); } .spectrum-Tabs-item { @@ -173,7 +89,7 @@ position: relative; box-sizing: border-box; - block-size: calc(var(--mod-tabs-item-height, var(--spectrum-tabs-item-height)) - var(--mod-tabs-divider-size, var(--spectrum-tabs-divider-size))); + block-size: var(--spectrum-tabs-item-height); /* Float above the tab line */ z-index: 1; @@ -181,64 +97,78 @@ text-decoration: none; white-space: nowrap; - color: var(--highcontrast-tabs-color, var(--mod-tabs-color, var(--spectrum-tabs-color))); + color: var(--spectrum-tabs-color); - transition: color var(--mod-tabs-animation-duration, var(--spectrum-tabs-animation-duration)) ease-out; + transition: color var(--spectrum-tabs-animation-duration) ease-out; cursor: pointer; outline: none; + border-radius: var(--spectrum-tabs-item-border-radius); .spectrum-Icon { /* Vertical centering */ - block-size: var(--mod-tabs-icon-size, var(--spectrum-tabs-icon-size)); - inline-size: var(--mod-tabs-icon-size, var(--spectrum-tabs-icon-size)); - margin-block-start: var(--mod-tabs-top-to-icon, var(--spectrum-tabs-top-to-icon)); + block-size: var(--spectrum-tabs-icon-size); + inline-size: var(--spectrum-tabs-icon-size); + margin-block-start: var(--spectrum-tabs-top-to-icon); + margin-inline: var(--spectrum-tabs-side-to-icon); & + .spectrum-Tabs-itemLabel { - margin-inline-start: var(--mod-tabs-icon-to-text, var(--spectrum-tabs-icon-to-text)); + margin-inline-start: calc(var(--spectrum-tabs-icon-to-text) - var(--spectrum-tabs-side-to-icon)); } } &::before { content: ""; position: absolute; - box-sizing: border-box; - block-size: calc(100% - var(--mod-tabs-top-to-text, var(--spectrum-tabs-top-to-text))); - inline-size: calc(100% + var(--mod-tabs-focus-indicator-gap, var(--spectrum-tabs-focus-indicator-gap)) * 2); - - inset-block-start: calc(var(--mod-tabs-top-to-text, var(--spectrum-tabs-top-to-text)) / 2); - inset-inline-start: calc(-1 * var(--mod-tabs-focus-indicator-gap, var(--spectrum-tabs-focus-indicator-gap))); - inset-inline-end: calc(-1 * var(--mod-tabs-focus-indicator-gap, var(--spectrum-tabs-focus-indicator-gap))); + block-size: calc(100% + var(--spectrum-tabs-focus-indicator-gap) * 2 + var(--spectrum-tabs-focus-indicator-width) * 2); + inline-size: calc(100% + var(--spectrum-tabs-focus-indicator-gap) * 2 + var(--spectrum-tabs-focus-indicator-width) * 2); + margin: calc(-1 * (var(--spectrum-tabs-focus-indicator-gap) + var(--spectrum-tabs-focus-indicator-width))); - border: var(--mod-tabs-focus-indicator-width, var(--spectrum-tabs-focus-indicator-width)) solid transparent; - border-radius: var(--mod-tabs-focus-indicator-border-radius, var(--spectrum-tabs-focus-indicator-border-radius)); + border: var(--spectrum-tabs-focus-indicator-width) solid transparent; + border-radius: var(--spectrum-tabs-focus-indicator-border-radius); pointer-events: none; } &:hover { - color: var(--highcontrast-tabs-color-hover, var(--mod-tabs-color-hover, var(--spectrum-tabs-color-hover))); + color: var(--spectrum-tabs-color-hover); } &.is-selected { - color: var(--highcontrast-tabs-color-selected, var(--mod-tabs-color-selected, var(--spectrum-tabs-color-selected))); + color: var(--spectrum-tabs-color-selected); + + &:hover { + color: var(--spectrum-tabs-color-selected-hover); + } + + &:focus-visible { + color: var(--spectrum-tabs-color-selected-key-focus); + } + + &.is-disabled { + color: var(--spectrum-tabs-color-disabled); + } } &.is-disabled { cursor: default; - color: var(--highcontrast-tabs-color-disabled, var(--mod-tabs-color-disabled, var(--spectrum-tabs-color-disabled))); + color: var(--spectrum-tabs-color-disabled); .spectrum-Tabs-itemLabel { cursor: default; } + + .spectrum-Tabs-selectionIndicator { + background-color: var(--spectrum-tabs-selection-indicator-color-disabled); + } } &:focus-visible { - color: var(--highcontrast-tabs-color-key-focus, var(--mod-tabs-color-key-focus, var(--spectrum-tabs-color-key-focus))); + color: var(--spectrum-tabs-color-key-focus); &::before { - border-color: var(--highcontrast-tabs-focus-indicator-color, var(--mod-tabs-focus-indicator-color, var(--spectrum-tabs-focus-indicator-color))); + border-color: var(--spectrum-tabs-focus-indicator-color); } } } @@ -248,13 +178,13 @@ display: inline-block; vertical-align: top; - font-family: var(--mod-tabs-font-family, var(--spectrum-tabs-font-family)); - font-style: var(--mod-tabs-font-style, var(--spectrum-tabs-font-style)); - font-size: var(--mod-tabs-font-size, var(--spectrum-tabs-font-size)); - font-weight: var(--mod-tabs-font-weight, var(--spectrum-tabs-font-weight)); - line-height: var(--mod-tabs-line-height, var(--spectrum-tabs-line-height)); - margin-block-start: var(--mod-tabs-top-to-text, var(--spectrum-tabs-top-to-text)); - margin-block-end: var(--mod-tabs-bottom-to-text, var(--spectrum-tabs-bottom-to-text)); + font-family: var(--spectrum-tabs-font-family); + font-style: var(--spectrum-tabs-font-style); + font-size: var(--spectrum-tabs-font-size); + font-weight: var(--spectrum-tabs-font-weight); + line-height: var(--spectrum-tabs-line-height); + margin-block-start: var(--spectrum-tabs-top-to-text); + margin-block-end: var(--spectrum-tabs-bottom-to-text); /* support links */ text-decoration: none; @@ -268,15 +198,16 @@ .spectrum-Tabs-selectionIndicator { position: absolute; inset-inline-start: 0; - background-color: var(--highcontrast-tabs-selection-indicator-color, var(--mod-tabs-selection-indicator-color, var(--spectrum-tabs-selection-indicator-color))); + background-color: var(--spectrum-tabs-selection-indicator-color); /* Be below the tab */ z-index: 0; - transition: transform var(--mod-tabs-animation-duration, var(--spectrum-tabs-animation-duration)) var(--mod-tabs-animation-ease, var(--spectrum-tabs-animation-ease)); + /* @todo: set transition: none for initial positioning */ + transition: transform var(--spectrum-tabs-animation-duration) var(--spectrum-tabs-animation-ease); transform-origin: top left; - border-radius: var(--mod-tabs-divider-border-radius, var(--spectrum-tabs-divider-border-radius)); + border-radius: var(--spectrum-tabs-selection-indicator-border-radius); } .spectrum-Tabs--horizontal { @@ -284,128 +215,90 @@ .spectrum-Tabs-item { vertical-align: top; - - /* Target anything since React likes to add lots of happy
s around all things */ - & + *:not(.spectrum-Tabs-selectionIndicator) { - margin-inline-start: var(--mod-tabs-item-horizontal-spacing, var(--spectrum-tabs-item-horizontal-spacing)); - } } .spectrum-Tabs-selectionIndicator { position: absolute; inset-block-end: 0; - block-size: var(--mod-tabs-divider-size, var(--spectrum-tabs-divider-size)); + inline-size: 100%; + block-size: var(--spectrum-tabs-selection-indicator-thickness); + margin-block-start: var(--spectrum-tabs-label-to-selection-indicator); } &.spectrum-Tabs--compact { - /* The ActionButton is taller than the tabs, so don't push tabs around */ + /* The overflow ActionButton is taller than the tabs, so don't push tabs around */ box-sizing: content-box; align-items: end; } } -/* Quiet tabs should not extend all the way across the screen as their line doesn't */ -.spectrum-Tabs--quiet { - display: inline-flex; - background: none; - border-color: transparent; - - .spectrum-Tabs-selectionIndicator { - padding-inline-start: var(--mod-tabs-start-to-item-quiet); - } -} - .spectrum-Tabs--vertical, .spectrum-Tabs--vertical-right { display: inline-flex; flex-direction: column; padding: 0; - &.spectrum-Tabs--quiet { - border-color: transparent; - } - .spectrum-Tabs-item { - block-size: var(--mod-tabs-item-height, var(--spectrum-tabs-item-height)); - line-height: var(--mod-tabs-item-height, var(--spectrum-tabs-item-height)); + block-size: var(--spectrum-tabs-item-height); + line-height: var(--spectrum-tabs-item-height); padding-block: 0; - margin-block-end: var(--mod-tabs-item-vertical-spacing, var(--spectrum-tabs-item-vertical-spacing)); - margin-inline-start: var(--mod-tabs-start-to-edge, var(--spectrum-tabs-start-to-edge)); - margin-inline-end: var(--mod-tabs-start-to-edge, var(--spectrum-tabs-start-to-edge)); - - &::before { - inset-inline-start: calc(-1 * var(--mod-tabs-focus-indicator-gap, var(--spectrum-tabs-focus-indicator-gap))); - } + margin-inline-start: var(--spectrum-tabs-start-to-edge); + margin-inline-end: var(--spectrum-tabs-start-to-edge); } .spectrum-Icon { - line-height: var(--mod-tabs-item-height, var(--spectrum-tabs-item-height)); + line-height: var(--spectrum-tabs-item-height); } .spectrum-Tabs-selectionIndicator { position: absolute; - inset-inline-start: 0; + inset-inline-start: calc(-1 * var(--spectrum-tabs-start-to-edge)); inset-block-start: 0; - inline-size: var(--mod-tabs-divider-size, var(--spectrum-tabs-divider-size)); + inline-size: var(--spectrum-tabs-selection-indicator-thickness); + block-size: 100%; } } .spectrum-Tabs--vertical-right { .spectrum-Tabs-selectionIndicator { - inset-inline: auto 0; + inset-inline: auto calc(-1 * var(--spectrum-tabs-start-to-edge)); } } @media (forced-colors: active) { .spectrum-Tabs { - --highcontrast-tabs-divider-background-color: var(--spectrum-gray-500); - --highcontrast-tabs-selection-indicator-color: Highlight; - --highcontrast-tabs-focus-indicator-color: CanvasText; - --highcontrast-tabs-focus-indicator-background-color: Highlight; - + --highcontrast-tabs-background-color-selected: SelectedItem; + --highcontrast-tabs-color-selected: SelectedItemText; + --highcontrast-tabs-color-selected-key-focus: SelectedItemText; + --highcontrast-tabs-color-selected-hover: SelectedItemText; + --highcontrast-tabs-selection-indicator-color: CanvasText; + --highcontrast-tabs-focus-indicator-color: Highlight; --highcontrast-tabs-color: ButtonText; --highcontrast-tabs-color-hover: ButtonText; - --highcontrast-tabs-color-selected: HighlightText; --highcontrast-tabs-color-key-focus: ButtonText; --highcontrast-tabs-color-disabled: GrayText; + --highcontrast-tabs-selection-indicator-color-disabled: GrayText; - /* Prevents black box behind text on Highlight background */ + /* Prevents black box behind text on SelectedItem background */ forced-color-adjust: none; - .spectrum-Tabs-item { - .spectrum-Icon { - z-index: 1; - position: relative; - } - - .spectrum-Tabs-itemLabel { - position: relative; - z-index: 1; - } - } - - .is-selected { - &::before { - background-color: var(--highcontrast-tabs-focus-indicator-background-color); - } + .spectrum-Tabs-item.is-selected { + background-color: var(--highcontrast-tabs-background-color-selected); - &:focus, - &:focus-visible { + .spectrum-Icon { color: var(--highcontrast-tabs-color-selected); } - } - &.spectrum-Tabs--vertical.spectrum-Tabs--compact .spectrum-Tabs-item { - &::before { - block-size: 100%; - inset-block-start: 0; - } - } + &.is-disabled { + .spectrum-Icon { + color: var(--highcontrast-tabs-color-disabled); + } - /* Quiet tabs get a bottom border in WHCM */ - &.spectrum-Tabs--quiet { - background: linear-gradient(to var(--mod-tabs-list-background-direction, var(--spectrum-tabs-list-background-direction)), var(--highcontrast-tabs-divider-background-color, var(--mod-tabs-divider-background-color, var(--spectrum-tabs-divider-background-color))) 0 var(--mod-tabs-divider-size, var(--spectrum-tabs-divider-size)), transparent var(--mod-tabs-divider-size, var(--spectrum-tabs-divider-size))); + .spectrum-Tabs-selectionIndicator { + background-color: var(--highcontrast-tabs-selection-indicator-color-disabled); + } + } } } } diff --git a/components/tabs/package.json b/components/tabs/package.json index a83498a2b76..c9ac2234b6d 100644 --- a/components/tabs/package.json +++ b/components/tabs/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/tabs", - "version": "6.2.0", + "version": "7.0.0-next.2", "description": "The Spectrum CSS tabs component", "license": "Apache-2.0", "author": "Adobe", @@ -19,17 +19,15 @@ "./package.json": "./package.json", "./dist/*": "./dist/*", "./index.css": "./dist/index.css", - "./index-*.css": "./dist/index-*.css", "./metadata.json": "./dist/metadata.json", - "./themes/*": "./dist/themes/*", "./stories/*": "./stories/*" }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/icon": ">=9.0.0 <10.0.0", - "@spectrum-css/menu": ">=9.0.0 <10.0.0", - "@spectrum-css/picker": ">=9.0.0 <10.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/icon": ">=10.0.0-next.0", + "@spectrum-css/menu": ">=10.0.0-next.0", + "@spectrum-css/picker": ">=10.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/icon": { @@ -46,10 +44,10 @@ } }, "devDependencies": { - "@spectrum-css/icon": "9.2.0", - "@spectrum-css/menu": "9.3.0", - "@spectrum-css/picker": "9.2.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/icon": "10.0.0-next.3", + "@spectrum-css/menu": "10.0.0-next.6", + "@spectrum-css/picker": "10.0.0-next.4", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/tabs/stories/tabs.stories.js b/components/tabs/stories/tabs.stories.js index 1b26856e13f..7e7b45d5dbd 100644 --- a/components/tabs/stories/tabs.stories.js +++ b/components/tabs/stories/tabs.stories.js @@ -1,10 +1,8 @@ -import { Sizes } from "@spectrum-css/preview/decorators"; import { disableDefaultModes } from "@spectrum-css/preview/modes"; -import { isEmphasized, isQuiet, size } from "@spectrum-css/preview/types"; import metadata from "../dist/metadata.json"; import packageJson from "../package.json"; import { TabsGroups } from "./tabs.test.js"; -import { CompactGroup, OverflowGroup, QuietGroup, Template, VerticalGroup } from "./template.js"; +import { CompactGroup, OverflowGroup, Template, VerticalGroup } from "./template.js"; /** * Tabs organize content into multiple sections and allow users to navigate between them. The content under the set of tabs should be related and form a coherent unit. Tabs can be either horizontal or vertical. @@ -12,11 +10,13 @@ import { CompactGroup, OverflowGroup, QuietGroup, Template, VerticalGroup } from * ## Usage notes * * ### Use icons consistently - * Icons are optional, but don’t mix the use of icons in tabs if they are utilized. Navigation controls require a clear spacial relationship to one another, and mixing the use of icons can dramatically impact the visual balance and presence for each tab item. + * Icons are optional, but don't mix the use of icons in tabs if they are utilized. Navigation controls require a clear spacial relationship to one another, and mixing the use of icons can dramatically impact the visual balance and presence for each tab item. * * ### Setting the selected tab item - * Only one tab item can be selected at any given time. The selected tab item is designated by the `is-selected` class. A selection indicator line is shown under or next to the selected tab item. + * Only one tab item can be selected at any given time. The selected tab item is designated by the `.is-selected` class. A selection indicator line is shown under or next to the selected tab item. * + * ### Quiet tabs + * The quiet variant has been deprecated for Spectrum 2. By default, all tabs look similar to what was formerly the quiet variant, with no divider spanning across all tab items. */ export default { @@ -24,7 +24,6 @@ export default { component: "Tabs", argTypes: { content: { table: { disable: true } }, - size: size(["s", "m", "l", "xl"]), orientation: { name: "Orientation", type: { name: "string", required: true }, @@ -37,8 +36,6 @@ export default { control: "select", default: "horizontal", }, - isQuiet, - isEmphasized, hasRightAlignedTabs: { name: "Right-aligned tabs", type: { name: "boolean" }, @@ -63,14 +60,12 @@ export default { }, isCompact: { name: "Compact", - description: "Compact tabs should never be used without the quiet styles.", type: { name: "boolean" }, table: { type: { summary: "boolean" }, category: "State", }, control: "boolean", - if: { arg: "isQuiet", truthy: true }, }, iconOnly: { name: "Icon only", @@ -81,14 +76,21 @@ export default { }, control: "boolean", }, + labelOnly: { + name: "Label only", + type: { name: "boolean" }, + table: { + type: { summary: "boolean" }, + category: "Component", + }, + control: "boolean", + }, }, args: { rootClass: "spectrum-Tabs", - isQuiet: false, - isEmphasized: false, isCompact: false, iconOnly: false, - size: "m", + labelOnly: false, orientation: "horizontal", hasRightAlignedTabs: false, useAnchors: false, @@ -104,7 +106,7 @@ export default { }, { label: "Tab 3", - icon: "Document", + icon: "File", isDisabled: true, }, ], @@ -119,29 +121,34 @@ export default { }, packageJson, metadata, + status: { + type: "migrated", + }, }, + tags: ["migrated"], }; /** - * Basic, default tab items should have a label for accessibility. If a label isn’t present, it must include an icon and becomes an icon-only tab item. + * #### Labels * - * By default, tabs have a divider that spans across all tab items. This style works as a way to anchor them to the page. These types of tabs are best used at the top of a page, as a top-level navigation. + * Basic, default tab items should have a label for accessibility. If a label isn't present, it must include an icon and becomes an icon-only tab item. * - * Tabs are horizontal by default and should be used when horizontal space is limited. + * #### Icons * + * Icons can be displayed in tab items. Icons should only be used in a tab item when absolutely necessary: when adding essential value and having a strong association with the label. Icons should not be used just as decoration. If the tab item does not have a visible label, it must still have a tooltip to disclose the label. */ export const Default = TabsGroups.bind({}); Default.args = {}; // ********* DOCS ONLY ********* // /** - * Vertical tabs should be used when horizontal space is more generous and when the list of sections is greater than can be presented to the user in a horizontal format. + * Vertical tabs should be used when horizontal space is more limited and when the list of sections is greater than can be presented to the user in a horizontal format. */ export const Vertical = VerticalGroup.bind({}); Vertical.args = { orientation: "vertical", }; -Vertical.tags = ["!dev"]; +Vertical.tags = ["!dev", "!autodocs"]; // TODO: remove "!autodocs" when vertical tabs are supported in S2 Vertical.parameters = { chromatic: { disableSnapshot: true }, }; @@ -152,7 +159,7 @@ VerticalRight.args = { hasRightAlignedTabs: true, }; VerticalRight.storyName = "Vertical right"; -VerticalRight.tags = ["!dev"]; +VerticalRight.tags = ["!dev", "!autodocs"]; // TODO: remove "!autodocs" when vertical tabs are supported in S2 VerticalRight.parameters = { chromatic: { disableSnapshot: true }, }; @@ -166,45 +173,18 @@ export const Overflow = OverflowGroup.bind({}); Overflow.args = { orientation: "overflow", }; -Overflow.tags = ["!dev"]; +Overflow.tags = ["!dev", "!autodocs"]; // TODO: remove "!autodocs" when overflow tabs are supported in S2 Overflow.parameters = { chromatic: { disableSnapshot: true }, }; /** - * The medium size is the default and most frequently used option. Use the other sizes sparingly; they should be used to create a hierarchy of importance within the page. - */ -export const Sizing = (args, context) => Sizes({ - Template, - withHeading: false, - withBorder: false, - ...args, -}, context); -Sizing.args = Default.args; -Sizing.tags = ["!dev"]; -Sizing.parameters = { - chromatic: { disableSnapshot: true }, -}; - -/** - * Quiet tabs have no visible divider across the tab items apart from the one that shows the selected tab item. These should be used as sub-level navigation or for containers. - */ -export const Quiet = QuietGroup.bind({}); -Quiet.args = { - isQuiet: true, -}; -Quiet.tags = ["!dev"]; -Quiet.parameters = { - chromatic: { disableSnapshot: true }, -}; - -/** - * Compact tabs should never be used without the quiet variation. + * In addition to the default, regular density, tabs also come in a compact density which has tighter spacing. */ export const Compact = CompactGroup.bind({}); +Compact.storyName = "Density: compact"; Compact.args = { isCompact: true, - isQuiet: true, }; Compact.tags = ["!dev"]; Compact.parameters = { @@ -238,18 +218,6 @@ Disabled.parameters = { chromatic: { disableSnapshot: true }, }; -/** - * Emphasized tabs have blue text for the selected state for visual prominence and to draw more attention to them. This is optimal for when the selection should call attention, such as the main navigation for a website. - */ -export const Emphasized = Template.bind({}); -Emphasized.args = { - isEmphasized: true, -}; -Emphasized.tags = ["!dev"]; -Emphasized.parameters = { - chromatic: { disableSnapshot: true }, -}; - /** * Tab items can alternatively be anchor tags (``) instead of `div` elements to allow for navigation to on-page anchors. Do not use horizontal tabs for this adaptation. */ diff --git a/components/tabs/stories/tabs.test.js b/components/tabs/stories/tabs.test.js index e0d6fa07578..87a5d965b64 100644 --- a/components/tabs/stories/tabs.test.js +++ b/components/tabs/stories/tabs.test.js @@ -1,22 +1,9 @@ import { Variants } from "@spectrum-css/preview/decorators"; import { Template } from "./template.js"; -const ExampleLabelOnlyTabContent = [ - { - label: "Selected", - isSelected: true, - }, - { - label: "Disabled", - isDisabled: true, - }, - { - label: "Tab 3", - }, -]; - export const TabsGroups = Variants({ Template, + withSizes: false, wrapperStyles: { "column-gap": "80px", }, @@ -24,44 +11,18 @@ export const TabsGroups = Variants({ { testHeading: "Default", }, - { - testHeading: "Emphasized", - isEmphasized: true, - }, - { - testHeading: "Quiet", - isQuiet: true, - }, - { - testHeading: "Quiet emphasized", - isQuiet: true, - isEmphasized: true, - }, { testHeading: "Compact", isCompact: true, - isQuiet: true, - }, - { - testHeading: "Compact emphasized", - isCompact: true, - isQuiet: true, - isEmphasized: true, }, { testHeading: "Vertical tabs", orientation: "vertical", }, - { - testHeading: "Emphasized vertical tabs", - orientation: "vertical", - isEmphasized: true, - }, { testHeading: "Compact vertical tabs", orientation: "vertical", isCompact: true, - isQuiet: true, }, { testHeading: "Right vertical tabs", @@ -76,7 +37,49 @@ export const TabsGroups = Variants({ testHeading: "Compact overflow", orientation: "overflow", isCompact: true, - isQuiet: true, + }, + { + testHeading: "Hover colors", + withStates: false, + content: [ + { + label: "Hovered unselected tab", + icon: "Folder", + isHovered: true, + }, + { + label: "Hovered selected tab", + icon: "Image", + isSelected: true, + isHovered: true, + }, + { + label: "Unhovered unselected tab", + icon: "File", + }, + { + label: "Disabled tab", + icon: "Archive", + isDisabled: true, + } + ] + }, + { + testHeading: "Disabled tabs", + withStates: false, + content: [ + { + label: "Selected tab", + icon: "Archive", + isSelected: true, + isDisabled: true, + }, + { + label: "Unselected tab", + icon: "File", + isDisabled: true, + } + ] }, { testHeading: "With anchor tags", @@ -86,11 +89,31 @@ export const TabsGroups = Variants({ stateData: [ { testHeading: "Label only", - content: ExampleLabelOnlyTabContent, + labelOnly: true, }, { testHeading: "Icon only", - iconOnly: true + iconOnly: true, }, + { + testHeading: "Selected tab focused", + content: [ + { + label: "Tab 1", + icon: "Folder", + }, + { + label: "Selected focused tab", + icon: "Image", + isSelected: true, + isFocused: true, + }, + { + label: "Tab 3", + icon: "File", + } + ], + ignore: ["Overflow", "Compact overflow"], + } ] }); diff --git a/components/tabs/stories/template.js b/components/tabs/stories/template.js index 716f45ea2e5..b977dd2fc31 100644 --- a/components/tabs/stories/template.js +++ b/components/tabs/stories/template.js @@ -10,20 +10,15 @@ import { when } from "lit/directives/when.js"; import { html, literal } from "lit/static-html.js"; import "../index.css"; -import "../themes/spectrum.css"; -/* Must be imported last */ -import "../themes/express.css"; export const Template = ({ rootClass = "spectrum-Tabs", customClasses = [], - size = "m", orientation = "horizontal", - isQuiet = false, isOpen = false, - isEmphasized = false, isCompact = false, iconOnly = false, + labelOnly = false, hasRightAlignedTabs = false, useAnchors = false, id = getRandomId("tabs"), @@ -43,39 +38,19 @@ export const Template = ({ // Note: Lit must use the 'literal' function for dynamic tags to work. const tabMarkup = useAnchors ? literal`a` : literal`div`; - const selectionIndicator = (isSelected) => when( - isSelected, - () => html` -
` - ); - return html`
({ ...a, [c]: true }), {}), })} style=${styleMap(customStyles)} id=${ifDefined(id)} + role="tablist" > ${when(!isOverflow, () => repeat( content, @@ -88,23 +63,32 @@ export const Template = ({ [`${rootClass}-item`]: true, "is-selected": item?.isSelected ?? false, "is-disabled": item?.isDisabled ?? false, + "is-focus-visible": item?.isFocused ?? false, + "is-hover": item?.isHovered ?? false, })} - tabindex="0" + tabindex=${item?.isDisabled ? "-1" : "0"} id=${getRandomId("tab-item")} + role="tab" + aria-selected=${item?.isSelected ?? false} + aria-disabled=${item?.isDisabled ?? false} > - ${when(item.icon, () => + ${when(item.icon && !labelOnly, () => Icon({ iconName: item.icon, setName: "workflow", - size, }, context) )} ${when(item.label && !iconOnly, () => html` - + ${item.label} `)} - ${selectionIndicator(item.isSelected)} + ${when(item.isSelected, () => html` +
+ `)} `; } @@ -115,12 +99,10 @@ export const Template = ({ ), () => html` ${Picker({ isQuiet: true, - size, isOpen, placeholder: !iconOnly ? content?.[0].label : Icon({ iconName: content?.[0].icon, setName: "workflow", - size, }, context), name: content?.[0].label, id: "tab-selector", @@ -130,7 +112,6 @@ export const Template = ({ popoverContent: [ () => Menu({ selectionMode: "none", - size, role: "listbox", subrole: "option", customStyles: { minWidth: "max-content" }, @@ -145,7 +126,7 @@ export const Template = ({ }, context), ] }, context)} - ${selectionIndicator(true)} +
`)}
`; @@ -183,7 +164,7 @@ export const OverflowGroup = (args, context) => Container({ withBorder: false, heading: "Compact overflow", containerStyles: { "gap": "8px", }, - content: Template({...args, isCompact: true, isQuiet: true}, context), + content: Template({...args, isCompact: true}, context), }, context)} ` }, context); @@ -199,86 +180,23 @@ export const VerticalGroup = (args, context) => Container({ containerStyles: {"gap": "8px"}, content: Template(args, context), }, context)} - ${Container({ - withBorder: false, - heading: "Emphasized, with label and icon", - containerStyles: {"gap": "8px"}, - content: Template({...args, isEmphasized: true, }, context), - }, context)} ${Container({ withBorder: false, heading: "Label only", containerStyles: {"gap": "8px"}, content: Template({...args, content: LabelOnlyTabsContent, }, context), }, context)} - ${Container({ - withBorder: false, - heading: "Emphasized, with label only", - containerStyles: {"gap": "8px"}, - content: Template({...args, isEmphasized: true, content: LabelOnlyTabsContent, }, context), - }, context)} ${Container({ withBorder: false, heading: "Compact, with label and icon", containerStyles: {"gap": "8px"}, - content: Template({...args, isCompact: true, isQuiet: true, }, context), - }, context)} - ${Container({ - withBorder: false, - heading: "Compact, emphasized, with label and icon", - containerStyles: {"gap": "8px"}, - content: Template({...args, isEmphasized: true, isCompact: true, isQuiet: true, }, context), + content: Template({...args, isCompact: true, }, context), }, context)} ${Container({ withBorder: false, heading: "Compact, label only", containerStyles: {"gap": "8px"}, - content: Template({...args, content: LabelOnlyTabsContent, isCompact: true, isQuiet: true, }, context), - }, context)} - ${Container({ - withBorder: false, - heading: "Compact, emphasized label only", - containerStyles: {"gap": "8px"}, - content: Template({...args, isEmphasized: true, content: LabelOnlyTabsContent, isCompact: true, isQuiet: true, }, context), - }, context)} - ` -}, context); - -/* Shows variants of quiet story in a single group. */ -export const QuietGroup = (args, context) => Container({ - direction: "column", - withBorder: false, - withHeading: false, - content: html` - ${Container({ - withBorder: false, - heading: "Label and icon", - content: Template(args, context), - }, context)} - ${Container({ - withBorder: false, - heading: "Emphasized, with label and icon", - content: Template({...args, isEmphasized: true, }, context), - }, context)} - ${Container({ - withBorder: false, - heading: "Label only", - content: Template({...args, content: LabelOnlyTabsContent, }, context), - }, context)} - ${Container({ - withBorder: false, - heading: "Emphasized, with label only", - content: Template({...args, isEmphasized: true, content: LabelOnlyTabsContent, }, context), - }, context)} - ${Container({ - withBorder: false, - heading: "Icon only", - content: Template({...args, iconOnly: true, }, context), - }, context)} - ${Container({ - withBorder: false, - heading: "Emphasized, icon-only", - content: Template({...args, isEmphasized: true, iconOnly: true, }, context), + content: Template({...args, content: LabelOnlyTabsContent, isCompact: true, }, context), }, context)} ` }, context); @@ -291,14 +209,9 @@ export const CompactGroup = (args, context) => Container({ content: html` ${Container({ withBorder: false, - heading: "Label and icon (quiet)", + heading: "Label and icon", content: Template(args, context), }, context)} - ${Container({ - withBorder: false, - heading: "Emphasized, with label and icon (quiet)", - content: Template({...args, isEmphasized: true, }, context), - }, context)} ${Container({ withBorder: false, heading: "Label only", @@ -306,18 +219,8 @@ export const CompactGroup = (args, context) => Container({ }, context)} ${Container({ withBorder: false, - heading: "Emphasized, with label only (quiet)", - content: Template({...args, isEmphasized: true, content: LabelOnlyTabsContent, }, context), - }, context)} - ${Container({ - withBorder: false, - heading: "Icon only (quiet)", + heading: "Icon only", content: Template({...args, iconOnly: true, }, context), }, context)} - ${Container({ - withBorder: false, - heading: "Emphasized, icon-only (quiet)", - content: Template({...args, isEmphasized: true, iconOnly: true, }, context), - }, context)} ` }, context); diff --git a/components/tabs/themes/express.css b/components/tabs/themes/express.css deleted file mode 100644 index 83b105f4ac8..00000000000 --- a/components/tabs/themes/express.css +++ /dev/null @@ -1,22 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--express */ - -@import "./spectrum.css"; - -@container style(--system: express) { - .spectrum-Tabs { - --spectrum-tabs-font-weight: var(--spectrum-bold-font-weight); - } -} diff --git a/components/tabs/themes/spectrum-two.css b/components/tabs/themes/spectrum-two.css deleted file mode 100644 index 71d71c3c719..00000000000 --- a/components/tabs/themes/spectrum-two.css +++ /dev/null @@ -1,19 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -@container style(--system: spectrum) { - .spectrum-Tabs { - --spectrum-tabs-font-weight: var(--spectrum-regular-font-weight); - --spectrum-tabs-divider-background-color: var(--spectrum-gray-200); - } -} diff --git a/components/tabs/themes/spectrum.css b/components/tabs/themes/spectrum.css deleted file mode 100644 index 97cb90cac5b..00000000000 --- a/components/tabs/themes/spectrum.css +++ /dev/null @@ -1,23 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--legacy */ - -@import "./spectrum-two.css"; - -@container style(--system: legacy) { - .spectrum-Tabs { - --spectrum-tabs-font-weight: var(--spectrum-regular-font-weight); - --spectrum-tabs-divider-background-color: var(--spectrum-gray-300); - } -} diff --git a/components/tag/CHANGELOG.md b/components/tag/CHANGELOG.md index 235ff11dec7..bbac3fb95b2 100644 --- a/components/tag/CHANGELOG.md +++ b/components/tag/CHANGELOG.md @@ -1,5 +1,80 @@ # Change log +## 11.0.0-next.2 + +### Major Changes + +- [#3682](https://github.com/adobe/spectrum-css/pull/3682) [`6d53893`](https://github.com/adobe/spectrum-css/commit/6d5389364504bc8373212276651055aa6c51bb76) Thanks [@rise-erpelding](https://github.com/rise-erpelding)! - Tag now uses Spectrum 2 tokens and specifications: + - The invalid variant has been removed, tag errors are now displayed with help text within the tag group only. + - Borders remain in high contrast but are otherwise transparent. + - Thumbnail has been added as a visual option. + - Tag now has a max-inline-size. + - Read-only tags are now supported. + - Passthroughs for clear button have been updated to match the current spec. + - Default t-shirt size for tag is small. + - Clear button has accessibly sized target. + - Emphasized tags have accent coloring only when they are selected. + + Changed mods: + - "--mod-tag-avatar-spacing-inline-end" --> "--mod-tag-visual-spacing-inline-end", + - "--mod-tag-icon-spacing-inline-end" --> "--mod-tag-visual-spacing-inline-end", + - "--mod-tag-spacing-inline-start" --> "--mod-tag-label-spacing-inline", + - "--mod-tag-label-spacing-inline-end" --> "--mod-tag-label-spacing-inline" + - "--mod-tag-clear-button-spacing-inline-start" --> "--mod-tag-label-to-clear-icon", + - "--mod-tag-clear-button-spacing-inline-end" --> "--mod-tag-edge-to-clear-icon" + + Added mods: + - "--mod-tag-avatar-size", + - "--mod-tag-clear-button-size", + - "--mod-tag-label-font-family", + - "--mod-tag-label-font-style", + - "--mod-tag-label-line-height-cjk", + - "--mod-tag-maximum-width-multiplier", + - "--mod-tag-min-inline-size", + - "--mod-tag-thumbnail-size", + - "--mod-tag-visual-spacing-inline-start" + + Removed mods: + - "--mod-tag-background-color-invalid-selected", + - "--mod-tag-background-color-invalid-selected-active", + - "--mod-tag-background-color-invalid-selected-focus", + - "--mod-tag-background-color-invalid-selected-hover", + - "--mod-tag-border-color-emphasized-active", + - "--mod-tag-border-color-emphasized-focus", + - "--mod-tag-border-color-emphasized-hover", + - "--mod-tag-border-color-invalid", + - "--mod-tag-border-color-invalid-active", + - "--mod-tag-border-color-invalid-focus", + - "--mod-tag-border-color-invalid-hover", + - "--mod-tag-border-color-invalid-selected", + - "--mod-tag-border-color-invalid-selected-active", + - "--mod-tag-border-color-invalid-selected-focus", + - "--mod-tag-border-color-invalid-selected-hover", + - "--mod-tag-border-color-selected-active", + - "--mod-tag-border-color-selected-focus", + - "--mod-tag-border-color-selected-hover", + - "--mod-tag-content-color-invalid", + - "--mod-tag-content-color-invalid-active", + - "--mod-tag-content-color-invalid-focus", + - "--mod-tag-content-color-invalid-hover", + - "--mod-tag-content-color-invalid-selected", + +## 11.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + - @spectrum-css/avatar@10.0.0-next.0 + +## 11.0.0-next.0 + +### Patch Changes + +- Updated dependencies [[`a25e0a9`](https://github.com/adobe/spectrum-css/commit/a25e0a99e5a4736ab4e607e00739343101a2633b)]: + - @spectrum-css/icon@10.0.0-next.0 + - @spectrum-css/clearbutton@8.0.0-next.0 + ## 10.2.0 ### Minor Changes diff --git a/components/tag/dist/metadata.json b/components/tag/dist/metadata.json index 10a87e4aa2c..e4503014031 100644 --- a/components/tag/dist/metadata.json +++ b/components/tag/dist/metadata.json @@ -4,46 +4,32 @@ ".spectrum-Tag", ".spectrum-Tag .spectrum-Avatar", ".spectrum-Tag .spectrum-Tag-clearButton", - ".spectrum-Tag .spectrum-Tag-clearButton .spectrum-ClearButton-fill", ".spectrum-Tag .spectrum-Tag-itemIcon", ".spectrum-Tag .spectrum-Tag-itemLabel", + ".spectrum-Tag .spectrum-Thumbnail", ".spectrum-Tag--sizeL", ".spectrum-Tag--sizeM", - ".spectrum-Tag--sizeS", ".spectrum-Tag.is-disabled", ".spectrum-Tag.is-disabled .spectrum-Avatar", - ".spectrum-Tag.is-emphasized", - ".spectrum-Tag.is-emphasized.is-focused", - ".spectrum-Tag.is-emphasized:active", - ".spectrum-Tag.is-emphasized:focus-visible", - ".spectrum-Tag.is-emphasized:hover", - ".spectrum-Tag.is-focused", - ".spectrum-Tag.is-focused:after", - ".spectrum-Tag.is-invalid", - ".spectrum-Tag.is-invalid.is-focused", - ".spectrum-Tag.is-invalid.is-selected", - ".spectrum-Tag.is-invalid.is-selected.is-focused", - ".spectrum-Tag.is-invalid.is-selected:active", - ".spectrum-Tag.is-invalid.is-selected:focus-visible", - ".spectrum-Tag.is-invalid.is-selected:hover", - ".spectrum-Tag.is-invalid:active", - ".spectrum-Tag.is-invalid:focus-visible", - ".spectrum-Tag.is-invalid:hover", + ".spectrum-Tag.is-disabled .spectrum-Thumbnail", ".spectrum-Tag.is-selected", - ".spectrum-Tag.is-selected.is-focused", - ".spectrum-Tag.is-selected:active", - ".spectrum-Tag.is-selected:focus-visible", - ".spectrum-Tag.is-selected:hover", - ".spectrum-Tag:active", - ".spectrum-Tag:focus-visible", - ".spectrum-Tag:focus-visible:after", - ".spectrum-Tag:hover" + ".spectrum-Tag.is-selected:not(.is-disabled, .is-readOnly)", + ".spectrum-Tag.spectrum-Tag--emphasized", + ".spectrum-Tag.spectrum-Tag--emphasized.is-selected:not(.is-disabled, .is-readOnly)", + ".spectrum-Tag.spectrum-Tag.is-disabled", + ".spectrum-Tag:lang(ja)", + ".spectrum-Tag:lang(ko)", + ".spectrum-Tag:lang(zh)", + ".spectrum-Tag:not(.is-disabled, .is-readOnly):active", + ".spectrum-Tag:not(.is-disabled, .is-readOnly):focus-visible", + ".spectrum-Tag:not(.is-disabled, .is-readOnly):focus-visible:after", + ".spectrum-Tag:not(.is-disabled, .is-readOnly):hover" ], "modifiers": [ "--mod-tag-animation-duration", + "--mod-tag-avatar-size", "--mod-tag-avatar-spacing-block-end", "--mod-tag-avatar-spacing-block-start", - "--mod-tag-avatar-spacing-inline-end", "--mod-tag-background-color", "--mod-tag-background-color-active", "--mod-tag-background-color-disabled", @@ -53,10 +39,6 @@ "--mod-tag-background-color-emphasized-hover", "--mod-tag-background-color-focus", "--mod-tag-background-color-hover", - "--mod-tag-background-color-invalid-selected", - "--mod-tag-background-color-invalid-selected-active", - "--mod-tag-background-color-invalid-selected-focus", - "--mod-tag-background-color-invalid-selected-hover", "--mod-tag-background-color-selected", "--mod-tag-background-color-selected-active", "--mod-tag-background-color-selected-focus", @@ -65,40 +47,21 @@ "--mod-tag-border-color-active", "--mod-tag-border-color-disabled", "--mod-tag-border-color-emphasized", - "--mod-tag-border-color-emphasized-active", - "--mod-tag-border-color-emphasized-focus", - "--mod-tag-border-color-emphasized-hover", "--mod-tag-border-color-focus", "--mod-tag-border-color-hover", - "--mod-tag-border-color-invalid", - "--mod-tag-border-color-invalid-active", - "--mod-tag-border-color-invalid-focus", - "--mod-tag-border-color-invalid-hover", - "--mod-tag-border-color-invalid-selected", - "--mod-tag-border-color-invalid-selected-active", - "--mod-tag-border-color-invalid-selected-focus", - "--mod-tag-border-color-invalid-selected-hover", "--mod-tag-border-color-selected", - "--mod-tag-border-color-selected-active", - "--mod-tag-border-color-selected-focus", - "--mod-tag-border-color-selected-hover", "--mod-tag-border-width", + "--mod-tag-clear-button-size", "--mod-tag-clear-button-spacing-block", - "--mod-tag-clear-button-spacing-inline-end", - "--mod-tag-clear-button-spacing-inline-start", "--mod-tag-content-color", "--mod-tag-content-color-active", "--mod-tag-content-color-disabled", "--mod-tag-content-color-emphasized", "--mod-tag-content-color-focus", "--mod-tag-content-color-hover", - "--mod-tag-content-color-invalid", - "--mod-tag-content-color-invalid-active", - "--mod-tag-content-color-invalid-focus", - "--mod-tag-content-color-invalid-hover", - "--mod-tag-content-color-invalid-selected", "--mod-tag-content-color-selected", "--mod-tag-corner-radius", + "--mod-tag-edge-to-clear-icon", "--mod-tag-focus-ring-color", "--mod-tag-focus-ring-gap", "--mod-tag-focus-ring-thickness", @@ -107,73 +70,45 @@ "--mod-tag-icon-size", "--mod-tag-icon-spacing-block-end", "--mod-tag-icon-spacing-block-start", - "--mod-tag-icon-spacing-inline-end", + "--mod-tag-label-font-family", + "--mod-tag-label-font-style", "--mod-tag-label-font-weight", "--mod-tag-label-line-height", + "--mod-tag-label-line-height-cjk", "--mod-tag-label-spacing-block", - "--mod-tag-label-spacing-inline-end", - "--mod-tag-spacing-inline-start" + "--mod-tag-label-spacing-inline", + "--mod-tag-label-to-clear-icon", + "--mod-tag-maximum-width-multiplier", + "--mod-tag-min-inline-size", + "--mod-tag-thumbnail-size", + "--mod-tag-visual-spacing-inline-end", + "--mod-tag-visual-spacing-inline-start" ], "component": [ "--spectrum-tag-animation-duration", + "--spectrum-tag-avatar-size", "--spectrum-tag-avatar-spacing-block-end", "--spectrum-tag-avatar-spacing-block-start", - "--spectrum-tag-avatar-spacing-inline-end", "--spectrum-tag-background-color", "--spectrum-tag-background-color-active", - "--spectrum-tag-background-color-disabled", - "--spectrum-tag-background-color-emphasized", - "--spectrum-tag-background-color-emphasized-active", - "--spectrum-tag-background-color-emphasized-focus", - "--spectrum-tag-background-color-emphasized-hover", "--spectrum-tag-background-color-focus", "--spectrum-tag-background-color-hover", - "--spectrum-tag-background-color-invalid-selected", - "--spectrum-tag-background-color-invalid-selected-active", - "--spectrum-tag-background-color-invalid-selected-focus", - "--spectrum-tag-background-color-invalid-selected-hover", - "--spectrum-tag-background-color-selected", - "--spectrum-tag-background-color-selected-active", - "--spectrum-tag-background-color-selected-focus", - "--spectrum-tag-background-color-selected-hover", "--spectrum-tag-border-color", "--spectrum-tag-border-color-active", - "--spectrum-tag-border-color-disabled", - "--spectrum-tag-border-color-emphasized", - "--spectrum-tag-border-color-emphasized-active", - "--spectrum-tag-border-color-emphasized-focus", - "--spectrum-tag-border-color-emphasized-hover", "--spectrum-tag-border-color-focus", "--spectrum-tag-border-color-hover", - "--spectrum-tag-border-color-invalid", - "--spectrum-tag-border-color-invalid-active", - "--spectrum-tag-border-color-invalid-focus", - "--spectrum-tag-border-color-invalid-hover", - "--spectrum-tag-border-color-invalid-selected", - "--spectrum-tag-border-color-invalid-selected-active", - "--spectrum-tag-border-color-invalid-selected-focus", - "--spectrum-tag-border-color-invalid-selected-hover", - "--spectrum-tag-border-color-selected", - "--spectrum-tag-border-color-selected-active", - "--spectrum-tag-border-color-selected-focus", - "--spectrum-tag-border-color-selected-hover", "--spectrum-tag-border-width", + "--spectrum-tag-clear-button-size", "--spectrum-tag-clear-button-spacing-block", - "--spectrum-tag-clear-button-spacing-inline-end", - "--spectrum-tag-clear-button-spacing-inline-start", "--spectrum-tag-content-color", "--spectrum-tag-content-color-active", - "--spectrum-tag-content-color-disabled", - "--spectrum-tag-content-color-emphasized", "--spectrum-tag-content-color-focus", "--spectrum-tag-content-color-hover", - "--spectrum-tag-content-color-invalid", - "--spectrum-tag-content-color-invalid-active", - "--spectrum-tag-content-color-invalid-focus", - "--spectrum-tag-content-color-invalid-hover", - "--spectrum-tag-content-color-invalid-selected", - "--spectrum-tag-content-color-selected", "--spectrum-tag-corner-radius", + "--spectrum-tag-edge-to-clear-icon", + "--spectrum-tag-edge-to-clear-icon-large", + "--spectrum-tag-edge-to-clear-icon-medium", + "--spectrum-tag-edge-to-clear-icon-small", "--spectrum-tag-focus-ring-color", "--spectrum-tag-focus-ring-gap", "--spectrum-tag-focus-ring-thickness", @@ -182,30 +117,31 @@ "--spectrum-tag-icon-size", "--spectrum-tag-icon-spacing-block-end", "--spectrum-tag-icon-spacing-block-start", - "--spectrum-tag-icon-spacing-inline-end", + "--spectrum-tag-label-font-family", + "--spectrum-tag-label-font-style", "--spectrum-tag-label-font-weight", "--spectrum-tag-label-line-height", + "--spectrum-tag-label-line-height-cjk", "--spectrum-tag-label-spacing-block", - "--spectrum-tag-label-spacing-inline-end", - "--spectrum-tag-size-large-clear-button-spacing-inline-end", - "--spectrum-tag-size-large-corner-radius", - "--spectrum-tag-size-large-label-spacing-inline-end", - "--spectrum-tag-size-large-spacing-inline-start", - "--spectrum-tag-size-medium-clear-button-spacing-inline-end", - "--spectrum-tag-size-medium-corner-radius", - "--spectrum-tag-size-medium-label-spacing-inline-end", - "--spectrum-tag-size-medium-spacing-inline-start", - "--spectrum-tag-size-small-clear-button-spacing-inline-end", - "--spectrum-tag-size-small-corner-radius", - "--spectrum-tag-size-small-label-spacing-inline-end", - "--spectrum-tag-size-small-spacing-inline-start", - "--spectrum-tag-spacing-inline-start", + "--spectrum-tag-label-spacing-inline", + "--spectrum-tag-label-to-clear-icon", + "--spectrum-tag-label-to-clear-icon-large", + "--spectrum-tag-label-to-clear-icon-medium", + "--spectrum-tag-label-to-clear-icon-small", + "--spectrum-tag-maximum-width-multiplier", + "--spectrum-tag-min-inline-size", + "--spectrum-tag-minimum-width-large", + "--spectrum-tag-minimum-width-medium", + "--spectrum-tag-minimum-width-small", + "--spectrum-tag-thumbnail-size", "--spectrum-tag-top-to-avatar-large", "--spectrum-tag-top-to-avatar-medium", "--spectrum-tag-top-to-avatar-small", "--spectrum-tag-top-to-cross-icon-large", "--spectrum-tag-top-to-cross-icon-medium", - "--spectrum-tag-top-to-cross-icon-small" + "--spectrum-tag-top-to-cross-icon-small", + "--spectrum-tag-visual-spacing-inline-end", + "--spectrum-tag-visual-spacing-inline-start" ], "global": [ "--spectrum-accent-background-color-default", @@ -214,9 +150,11 @@ "--spectrum-accent-background-color-key-focus", "--spectrum-animation-duration-100", "--spectrum-avatar-opacity-disabled", + "--spectrum-avatar-size-100", + "--spectrum-avatar-size-50", + "--spectrum-avatar-size-75", "--spectrum-border-width-100", - "--spectrum-clearbutton-fill-background-color", - "--spectrum-clearbutton-fill-size", + "--spectrum-cjk-line-height-100", "--spectrum-component-edge-to-text-100", "--spectrum-component-edge-to-text-200", "--spectrum-component-edge-to-text-75", @@ -226,15 +164,25 @@ "--spectrum-component-height-100", "--spectrum-component-height-200", "--spectrum-component-height-75", + "--spectrum-component-size-difference-down", + "--spectrum-component-size-width-ratio-down", "--spectrum-component-top-to-text-100", "--spectrum-component-top-to-text-200", "--spectrum-component-top-to-text-75", "--spectrum-component-top-to-workflow-icon-100", "--spectrum-component-top-to-workflow-icon-200", "--spectrum-component-top-to-workflow-icon-75", - "--spectrum-corner-radius-100", + "--spectrum-corner-radius-medium-size-large", + "--spectrum-corner-radius-medium-size-medium", + "--spectrum-corner-radius-medium-size-small", + "--spectrum-cross-icon-size-100", + "--spectrum-cross-icon-size-200", + "--spectrum-cross-icon-size-75", + "--spectrum-default-font-style", "--spectrum-disabled-background-color", "--spectrum-disabled-content-color", + "--spectrum-downstate-height", + "--spectrum-downstate-width", "--spectrum-focus-indicator-color", "--spectrum-focus-indicator-gap", "--spectrum-focus-indicator-thickness", @@ -242,82 +190,44 @@ "--spectrum-font-size-200", "--spectrum-font-size-75", "--spectrum-gray-100", + "--spectrum-gray-200", "--spectrum-gray-25", - "--spectrum-gray-50", - "--spectrum-gray-700", - "--spectrum-gray-800", - "--spectrum-gray-900", "--spectrum-line-height-100", - "--spectrum-negative-background-color-default", - "--spectrum-negative-background-color-down", - "--spectrum-negative-background-color-hover", - "--spectrum-negative-background-color-key-focus", - "--spectrum-negative-color-1000", - "--spectrum-negative-color-1100", - "--spectrum-negative-color-900", - "--spectrum-negative-content-color-default", - "--spectrum-negative-content-color-down", - "--spectrum-negative-content-color-hover", - "--spectrum-negative-content-color-key-focus", - "--spectrum-neutral-background-color-selected-default", - "--spectrum-neutral-background-color-selected-down", - "--spectrum-neutral-background-color-selected-hover", - "--spectrum-neutral-background-color-selected-key-focus", - "--spectrum-neutral-subdued-background-color-default", - "--spectrum-neutral-subdued-background-color-down", - "--spectrum-neutral-subdued-background-color-hover", - "--spectrum-neutral-subdued-background-color-key-focus", - "--spectrum-neutral-subdued-content-color-default", - "--spectrum-neutral-subdued-content-color-down", - "--spectrum-neutral-subdued-content-color-hover", - "--spectrum-neutral-subdued-content-color-key-focus", - "--spectrum-regular-font-weight", + "--spectrum-medium-font-weight", + "--spectrum-neutral-background-color-default", + "--spectrum-neutral-background-color-down", + "--spectrum-neutral-background-color-hover", + "--spectrum-neutral-background-color-key-focus", + "--spectrum-neutral-content-color-default", + "--spectrum-neutral-content-color-down", + "--spectrum-neutral-content-color-hover", + "--spectrum-neutral-content-color-key-focus", + "--spectrum-sans-font-family-stack", "--spectrum-text-to-visual-100", "--spectrum-text-to-visual-200", "--spectrum-text-to-visual-75", + "--spectrum-thumbnail-opacity-disabled", + "--spectrum-thumbnail-size-100", + "--spectrum-thumbnail-size-50", + "--spectrum-thumbnail-size-75", "--spectrum-white", "--spectrum-workflow-icon-size-100", "--spectrum-workflow-icon-size-200", "--spectrum-workflow-icon-size-75" ], - "system-theme": [ - "--system-tag-background-color", - "--system-tag-background-color-active", - "--system-tag-background-color-disabled", - "--system-tag-background-color-focus", - "--system-tag-background-color-hover", - "--system-tag-border-color", - "--system-tag-border-color-active", - "--system-tag-border-color-disabled", - "--system-tag-border-color-focus", - "--system-tag-border-color-hover", - "--system-tag-border-color-selected", - "--system-tag-border-color-selected-active", - "--system-tag-border-color-selected-focus", - "--system-tag-border-color-selected-hover", - "--system-tag-content-color", - "--system-tag-content-color-active", - "--system-tag-content-color-focus", - "--system-tag-content-color-hover", - "--system-tag-content-color-selected", - "--system-tag-size-large-clear-button-spacing-inline-end", - "--system-tag-size-large-corner-radius", - "--system-tag-size-large-label-spacing-inline-end", - "--system-tag-size-large-spacing-inline-start", - "--system-tag-size-medium-clear-button-spacing-inline-end", - "--system-tag-size-medium-corner-radius", - "--system-tag-size-medium-label-spacing-inline-end", - "--system-tag-size-medium-spacing-inline-start", - "--system-tag-size-small-clear-button-spacing-inline-end", - "--system-tag-size-small-corner-radius", - "--system-tag-size-small-label-spacing-inline-end", - "--system-tag-size-small-spacing-inline-start" - ], "passthroughs": [ + "--mod-avatar-block-size", + "--mod-avatar-inline-size", "--mod-avatar-opacity-disabled", + "--mod-clear-button-background-color", + "--mod-clear-button-height", + "--mod-clear-button-icon-color", + "--mod-clear-button-icon-color-hover", + "--mod-clear-button-icon-color-key-focus", "--mod-clear-button-width", - "--mod-clearbutton-fill-background-color", - "--mod-clearbutton-fill-size" + "--mod-icon-size", + "--mod-thumbnail-opacity-disabled", + "--mod-thumbnail-size" ], "high-contrast": [ "--highcontrast-tag-background-color", @@ -329,10 +239,6 @@ "--highcontrast-tag-background-color-emphasized-hover", "--highcontrast-tag-background-color-focus", "--highcontrast-tag-background-color-hover", - "--highcontrast-tag-background-color-invalid-selected", - "--highcontrast-tag-background-color-invalid-selected-active", - "--highcontrast-tag-background-color-invalid-selected-focus", - "--highcontrast-tag-background-color-invalid-selected-hover", "--highcontrast-tag-background-color-selected", "--highcontrast-tag-background-color-selected-active", "--highcontrast-tag-background-color-selected-focus", @@ -341,34 +247,15 @@ "--highcontrast-tag-border-color-active", "--highcontrast-tag-border-color-disabled", "--highcontrast-tag-border-color-emphasized", - "--highcontrast-tag-border-color-emphasized-active", - "--highcontrast-tag-border-color-emphasized-focus", - "--highcontrast-tag-border-color-emphasized-hover", "--highcontrast-tag-border-color-focus", "--highcontrast-tag-border-color-hover", - "--highcontrast-tag-border-color-invalid", - "--highcontrast-tag-border-color-invalid-active", - "--highcontrast-tag-border-color-invalid-focus", - "--highcontrast-tag-border-color-invalid-hover", - "--highcontrast-tag-border-color-invalid-selected", - "--highcontrast-tag-border-color-invalid-selected-active", - "--highcontrast-tag-border-color-invalid-selected-focus", - "--highcontrast-tag-border-color-invalid-selected-hover", "--highcontrast-tag-border-color-selected", - "--highcontrast-tag-border-color-selected-active", - "--highcontrast-tag-border-color-selected-focus", - "--highcontrast-tag-border-color-selected-hover", "--highcontrast-tag-content-color", "--highcontrast-tag-content-color-active", "--highcontrast-tag-content-color-disabled", "--highcontrast-tag-content-color-emphasized", "--highcontrast-tag-content-color-focus", "--highcontrast-tag-content-color-hover", - "--highcontrast-tag-content-color-invalid", - "--highcontrast-tag-content-color-invalid-active", - "--highcontrast-tag-content-color-invalid-focus", - "--highcontrast-tag-content-color-invalid-hover", - "--highcontrast-tag-content-color-invalid-selected", "--highcontrast-tag-content-color-selected", "--highcontrast-tag-focus-ring-color" ] diff --git a/components/tag/index.css b/components/tag/index.css index 9385b432e60..48f1e3237dc 100644 --- a/components/tag/index.css +++ b/components/tag/index.css @@ -1,5 +1,5 @@ /*! - * Copyright 2024 Adobe. All rights reserved. + * Copyright 2025 Adobe. All rights reserved. * * This file is licensed to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. You may obtain a copy @@ -11,174 +11,217 @@ * governing permissions and limitations under the License. */ -@import "./themes/spectrum-two.css"; - .spectrum-Tag { - /* TODO - replace placeholder disabled avatar opacity with correct token once avatar is migrated */ - --spectrum-avatar-opacity-disabled: 0.3; - --spectrum-tag-animation-duration: var(--spectrum-animation-duration-100); + + /* border color - transparent unless modified or high contrast mode */ --spectrum-tag-border-width: var(--spectrum-border-width-100); + --spectrum-tag-border-color: var(--highcontrast-tag-border-color, var(--mod-tag-border-color, transparent)); + --spectrum-tag-border-color-hover: var(--highcontrast-tag-border-color-hover, var(--mod-tag-border-color-hover, transparent)); + --spectrum-tag-border-color-active: var(--highcontrast-tag-border-color-active, var(--mod-tag-border-color-active, transparent)); + --spectrum-tag-border-color-focus: var(--highcontrast-tag-border-color-focus, var(--mod-tag-border-color-focus, transparent)); + + /* background color */ + --spectrum-tag-background-color: var(--highcontrast-tag-background-color, var(--mod-tag-background-color, var(--spectrum-gray-100))); + --spectrum-tag-background-color-hover: var(--highcontrast-tag-background-color-hover, var(--mod-tag-background-color-hover, var(--spectrum-gray-200))); + --spectrum-tag-background-color-active: var(--highcontrast-tag-background-color-active, var(--mod-tag-background-color-active, var(--spectrum-gray-200))); + --spectrum-tag-background-color-focus: var(--highcontrast-tag-background-color-focus, var(--mod-tag-background-color-focus, var(--spectrum-gray-200))); + + /* content color */ + --spectrum-tag-content-color: var(--highcontrast-tag-content-color, var(--mod-tag-content-color, var(--spectrum-neutral-content-color-default))); + --spectrum-tag-content-color-hover: var(--highcontrast-tag-content-color-hover, var(--mod-tag-content-color-hover, var(--spectrum-neutral-content-color-hover))); + --spectrum-tag-content-color-active: var(--highcontrast-tag-content-color-active, var(--mod-tag-content-color-active, var(--spectrum-neutral-content-color-down))); + --spectrum-tag-content-color-focus: var(--highcontrast-tag-content-color-focus, var(--mod-tag-content-color-focus, var(--spectrum-neutral-content-color-key-focus))); /* focus ring */ --spectrum-tag-focus-ring-thickness: var(--spectrum-focus-indicator-thickness); --spectrum-tag-focus-ring-gap: var(--spectrum-focus-indicator-gap); - --spectrum-tag-focus-ring-color: var(--spectrum-focus-indicator-color); + --spectrum-tag-focus-ring-color: var(--highcontrast-tag-focus-ring-color, var(--mod-tag-focus-ring-color, var(--spectrum-focus-indicator-color))); /* label */ --spectrum-tag-label-line-height: var(--spectrum-line-height-100); - --spectrum-tag-label-font-weight: var(--spectrum-regular-font-weight); - - --spectrum-tag-background-color-selected: var(--spectrum-neutral-background-color-selected-default); - --spectrum-tag-background-color-selected-hover: var(--spectrum-neutral-background-color-selected-hover); - --spectrum-tag-background-color-selected-active: var(--spectrum-neutral-background-color-selected-down); - --spectrum-tag-background-color-selected-focus: var(--spectrum-neutral-background-color-selected-key-focus); - - /* invalid variant */ - --spectrum-tag-border-color-invalid: var(--spectrum-negative-color-900); - --spectrum-tag-border-color-invalid-hover: var(--spectrum-negative-color-1000); - --spectrum-tag-border-color-invalid-active: var(--spectrum-negative-color-1100); - --spectrum-tag-border-color-invalid-focus: var(--spectrum-negative-color-1000); - - /* invalid variant content */ - --spectrum-tag-content-color-invalid: var(--spectrum-negative-content-color-default); - --spectrum-tag-content-color-invalid-hover: var(--spectrum-negative-content-color-hover); - --spectrum-tag-content-color-invalid-active: var(--spectrum-negative-content-color-down); - --spectrum-tag-content-color-invalid-focus: var(--spectrum-negative-content-color-key-focus); - - /* invalid selected variant */ - --spectrum-tag-border-color-invalid-selected: var(--spectrum-negative-background-color-default); - --spectrum-tag-border-color-invalid-selected-hover: var(--spectrum-negative-background-color-hover); - --spectrum-tag-border-color-invalid-selected-focus: var(--spectrum-negative-background-color-down); - --spectrum-tag-border-color-invalid-selected-active: var(--spectrum-negative-background-color-key-focus); - --spectrum-tag-background-color-invalid-selected: var(--spectrum-negative-background-color-default); - --spectrum-tag-background-color-invalid-selected-hover: var(--spectrum-negative-background-color-hover); - --spectrum-tag-background-color-invalid-selected-active: var(--spectrum-negative-background-color-down); - --spectrum-tag-background-color-invalid-selected-focus: var(--spectrum-negative-background-color-key-focus); - - /* invalid selected variant content */ - --spectrum-tag-content-color-invalid-selected: var(--spectrum-white); - - /* emphasized variant */ - --spectrum-tag-border-color-emphasized: var(--spectrum-accent-background-color-default); - --spectrum-tag-border-color-emphasized-hover: var(--spectrum-accent-background-color-hover); - --spectrum-tag-border-color-emphasized-active: var(--spectrum-accent-background-color-down); - --spectrum-tag-border-color-emphasized-focus: var(--spectrum-accent-background-color-key-focus); - --spectrum-tag-background-color-emphasized: var(--spectrum-accent-background-color-default); - --spectrum-tag-background-color-emphasized-hover: var(--spectrum-accent-background-color-hover); - --spectrum-tag-background-color-emphasized-active: var(--spectrum-accent-background-color-down); - --spectrum-tag-background-color-emphasized-focus: var(--spectrum-accent-background-color-key-focus); - - /* emphasized variant content */ - --spectrum-tag-content-color-emphasized: var(--spectrum-white); - - /* disabled variant content */ - --spectrum-tag-content-color-disabled: var(--spectrum-disabled-content-color); -} - -.spectrum-Tag, -.spectrum-Tag--sizeM { - --spectrum-tag-height: var(--spectrum-component-height-100); - --spectrum-tag-font-size: var(--spectrum-font-size-100); - --spectrum-tag-icon-size: var(--spectrum-workflow-icon-size-100); - - --spectrum-tag-clear-button-spacing-inline-start: var(--spectrum-text-to-visual-100); - --spectrum-tag-clear-button-spacing-block: var(--spectrum-tag-top-to-cross-icon-medium); - - --spectrum-tag-icon-spacing-block-start: var(--spectrum-component-top-to-workflow-icon-100); - --spectrum-tag-icon-spacing-block-end: var(--spectrum-component-top-to-workflow-icon-100); - --spectrum-tag-icon-spacing-inline-end: var(--spectrum-text-to-visual-100); + --spectrum-tag-label-line-height-cjk: var(--spectrum-cjk-line-height-100); + --spectrum-tag-label-font-family: var(--spectrum-sans-font-family-stack); + --spectrum-tag-label-font-style: var(--spectrum-default-font-style); + --spectrum-tag-label-font-weight: var(--spectrum-medium-font-weight); - --spectrum-tag-avatar-spacing-block-start: var(--spectrum-tag-top-to-avatar-medium); /* 6px 9px */ - --spectrum-tag-avatar-spacing-block-end: var(--spectrum-tag-top-to-avatar-medium); - --spectrum-tag-avatar-spacing-inline-end: var(--spectrum-text-to-visual-100); - - --spectrum-tag-label-spacing-block: var(--spectrum-component-top-to-text-100); - - /* tokens based on theme and t-shirt size */ - --spectrum-tag-corner-radius: var(--spectrum-tag-size-medium-corner-radius); - --spectrum-tag-spacing-inline-start: var(--spectrum-tag-size-medium-spacing-inline-start); - --spectrum-tag-label-spacing-inline-end: var(--spectrum-tag-size-medium-label-spacing-inline-end); - --spectrum-tag-clear-button-spacing-inline-end: var(--spectrum-tag-size-medium-clear-button-spacing-inline-end); -} - -/* t-shirt sizes */ -.spectrum-Tag--sizeS { + /* default size/sizeS */ --spectrum-tag-height: var(--spectrum-component-height-75); + --spectrum-tag-min-inline-size: var(--spectrum-tag-minimum-width-small); --spectrum-tag-font-size: var(--spectrum-font-size-75); --spectrum-tag-icon-size: var(--spectrum-workflow-icon-size-75); + --spectrum-tag-corner-radius: var(--spectrum-corner-radius-medium-size-small); - --spectrum-tag-clear-button-spacing-inline-start: var(--spectrum-text-to-visual-75); + --spectrum-tag-clear-button-size: var(--spectrum-cross-icon-size-75); --spectrum-tag-clear-button-spacing-block: var(--spectrum-tag-top-to-cross-icon-small); + --spectrum-tag-label-to-clear-icon: var(--spectrum-tag-label-to-clear-icon-small); + --spectrum-tag-edge-to-clear-icon: var(--spectrum-tag-edge-to-clear-icon-small); + + --spectrum-tag-visual-spacing-inline-start: var(--spectrum-component-edge-to-visual-75); + --spectrum-tag-visual-spacing-inline-end: var(--spectrum-text-to-visual-75); --spectrum-tag-icon-spacing-block-start: var(--spectrum-component-top-to-workflow-icon-75); --spectrum-tag-icon-spacing-block-end: var(--spectrum-component-top-to-workflow-icon-75); - --spectrum-tag-icon-spacing-inline-end: var(--spectrum-text-to-visual-75); + --spectrum-tag-avatar-size: var(--spectrum-avatar-size-50); --spectrum-tag-avatar-spacing-block-start: var(--spectrum-tag-top-to-avatar-small); --spectrum-tag-avatar-spacing-block-end: var(--spectrum-tag-top-to-avatar-small); - --spectrum-tag-avatar-spacing-inline-end: var(--spectrum-text-to-visual-75); + + --spectrum-tag-thumbnail-size: var(--spectrum-thumbnail-size-50); --spectrum-tag-label-spacing-block: var(--spectrum-component-top-to-text-75); + --spectrum-tag-label-spacing-inline: var(--spectrum-component-edge-to-text-75); + + /* @passthrough start for nested components */ + --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)); + --mod-clear-button-background-color: transparent; + --mod-clear-button-icon-color: currentColor; + --mod-clear-button-icon-color-hover: currentColor; + --mod-clear-button-icon-color-key-focus: currentColor; + + --mod-icon-size: var(--mod-tag-clear-button-size, var(--spectrum-tag-clear-button-size)); + + /* clear icon inline spacing + icon size */ + --mod-clear-button-width: calc(var(--mod-tag-label-to-clear-icon, var(--spectrum-tag-label-to-clear-icon)) + var(--mod-tag-edge-to-clear-icon, var(--spectrum-tag-edge-to-clear-icon)) + var(--mod-tag-clear-button-size, var(--spectrum-tag-clear-button-size))); + + /* clear icon block spacing + icon size */ + --mod-clear-button-height: calc(2 * var(--mod-tag-clear-button-spacing-block, var(--spectrum-tag-clear-button-spacing-block)) + var(--mod-tag-clear-button-size, var(--spectrum-tag-clear-button-size))); + /* @passthrough end */ + + &:lang(ja), + &:lang(zh), + &:lang(ko) { + --mod-tag-label-line-height: var(--mod-tag-label-line-height-cjk, var(--spectrum-tag-label-line-height-cjk)); + } + + &.is-selected:not(.is-disabled, .is-readOnly) { + --spectrum-tag-border-color: var(--highcontrast-tag-border-color-selected, var(--mod-tag-border-color-selected, transparent)); + --spectrum-tag-background-color: var(--highcontrast-tag-background-color-selected, var(--mod-tag-background-color-selected, var(--spectrum-neutral-background-color-default))); + --spectrum-tag-content-color: var(--highcontrast-tag-content-color-selected, var(--mod-tag-content-color-selected, var(--spectrum-gray-25))); + + --spectrum-tag-border-color-hover: var(--highcontrast-tag-border-color-selected, var(--mod-tag-border-color-selected, transparent)); + --spectrum-tag-background-color-hover: var(--highcontrast-tag-background-color-selected-hover, var(--mod-tag-background-color-selected-hover, var(--spectrum-neutral-background-color-hover))); + --spectrum-tag-content-color-hover: var(--highcontrast-tag-content-color-selected, var(--mod-tag-content-color-selected, var(--spectrum-gray-25))); + + --spectrum-tag-border-color-active: var(--highcontrast-tag-border-color-selected, var(--mod-tag-border-color-selected, transparent)); + --spectrum-tag-background-color-active: var(--highcontrast-tag-background-color-selected-active, var(--mod-tag-background-color-selected-active, var(--spectrum-neutral-background-color-down))); + --spectrum-tag-content-color-active: var(--highcontrast-tag-content-color-selected, var(--mod-tag-content-color-selected, var(--spectrum-gray-25))); + + --spectrum-tag-border-color-focus: var(--highcontrast-tag-border-color-selected, var(--mod-tag-border-color-selected, transparent)); + --spectrum-tag-background-color-focus: var(--highcontrast-tag-background-color-selected-focus, var(--mod-tag-background-color-selected-focus, var(--spectrum-neutral-background-color-key-focus))); + --spectrum-tag-content-color-focus: var(--highcontrast-tag-content-color-selected, var(--mod-tag-content-color-selected, var(--spectrum-gray-25))); + } + + &.spectrum-Tag--emphasized.is-selected:not(.is-disabled, .is-readOnly) { + --spectrum-tag-border-color: var(--highcontrast-tag-border-color-emphasized, var(--mod-tag-border-color-emphasized, transparent)); + --spectrum-tag-background-color: var(--highcontrast-tag-background-color-emphasized, var(--mod-tag-background-color-emphasized, var(--spectrum-accent-background-color-default))); + --spectrum-tag-content-color: var(--highcontrast-tag-content-color-emphasized, var(--mod-tag-content-color-emphasized, var(--spectrum-white))); + + --spectrum-tag-border-color-hover: var(--highcontrast-tag-border-color-emphasized, var(--mod-tag-border-color-emphasized, transparent)); + --spectrum-tag-background-color-hover: var(--highcontrast-tag-background-color-emphasized-hover, var(--mod-tag-background-color-emphasized-hover, var(--spectrum-accent-background-color-hover))); + --spectrum-tag-content-color-hover: var(--highcontrast-tag-content-color-emphasized, var(--mod-tag-content-color-emphasized, var(--spectrum-white))); + + --spectrum-tag-border-color-active: var(--highcontrast-tag-border-color-emphasized, var(--mod-tag-border-color-emphasized, transparent)); + --spectrum-tag-background-color-active: var(--highcontrast-tag-background-color-emphasized-active, var(--mod-tag-background-color-emphasized-active, var(--spectrum-accent-background-color-down))); + --spectrum-tag-content-color-active: var(--highcontrast-tag-content-color-emphasized, var(--mod-tag-content-color-emphasized, var(--spectrum-white))); - /* tokens based on theme and t-shirt size */ - --spectrum-tag-corner-radius: var(--spectrum-tag-size-small-corner-radius); - --spectrum-tag-spacing-inline-start: var(--spectrum-tag-size-small-spacing-inline-start); - --spectrum-tag-label-spacing-inline-end: var(--spectrum-tag-size-small-label-spacing-inline-end); - --spectrum-tag-clear-button-spacing-inline-end: var(--spectrum-tag-size-small-clear-button-spacing-inline-end); + --spectrum-tag-border-color-focus: var(--highcontrast-tag-border-color-emphasized, var(--mod-tag-border-color-emphasized, transparent)); + --spectrum-tag-background-color-focus: var(--highcontrast-tag-background-color-emphasized-focus, var(--mod-tag-background-color-emphasized-focus, var(--spectrum-accent-background-color-key-focus))); + --spectrum-tag-content-color-focus: var(--highcontrast-tag-content-color-emphasized, var(--mod-tag-content-color-emphasized, var(--spectrum-white))); + } + + &.spectrum-Tag.is-disabled { + --spectrum-tag-border-color: var(--highcontrast-tag-border-color-disabled, var(--mod-tag-border-color-disabled, transparent)); + --spectrum-tag-background-color: var(--highcontrast-tag-background-color-disabled, var(--mod-tag-background-color-disabled, var(--spectrum-disabled-background-color))); + --spectrum-tag-content-color: var(--highcontrast-tag-content-color-disabled, var(--mod-tag-content-color-disabled, var(--spectrum-disabled-content-color))); + } +} + +/* t-shirt sizes - small is default */ +.spectrum-Tag--sizeM { + --spectrum-tag-height: var(--spectrum-component-height-100); + --spectrum-tag-min-inline-size: var(--spectrum-tag-minimum-width-medium); + --spectrum-tag-font-size: var(--spectrum-font-size-100); + --spectrum-tag-icon-size: var(--spectrum-workflow-icon-size-100); + --spectrum-tag-corner-radius: var(--spectrum-corner-radius-medium-size-medium); + + --spectrum-tag-clear-button-size: var(--spectrum-cross-icon-size-100); + --spectrum-tag-clear-button-spacing-block: var(--spectrum-tag-top-to-cross-icon-medium); + --spectrum-tag-label-to-clear-icon: var(--spectrum-tag-label-to-clear-icon-medium); + --spectrum-tag-edge-to-clear-icon: var(--spectrum-tag-edge-to-clear-icon-medium); + + --spectrum-tag-visual-spacing-inline-start: var(--spectrum-component-edge-to-visual-100); + --spectrum-tag-visual-spacing-inline-end: var(--spectrum-text-to-visual-100); + + --spectrum-tag-icon-spacing-block-start: var(--spectrum-component-top-to-workflow-icon-100); + --spectrum-tag-icon-spacing-block-end: var(--spectrum-component-top-to-workflow-icon-100); + + --spectrum-tag-avatar-size: var(--spectrum-avatar-size-75); + --spectrum-tag-avatar-spacing-block-start: var(--spectrum-tag-top-to-avatar-medium); + --spectrum-tag-avatar-spacing-block-end: var(--spectrum-tag-top-to-avatar-medium); + + --spectrum-tag-thumbnail-size: var(--spectrum-thumbnail-size-75); + + --spectrum-tag-label-spacing-block: var(--spectrum-component-top-to-text-100); + --spectrum-tag-label-spacing-inline: var(--spectrum-component-edge-to-text-100); } .spectrum-Tag--sizeL { --spectrum-tag-height: var(--spectrum-component-height-200); + --spectrum-tag-min-inline-size: var(--spectrum-tag-minimum-width-large); --spectrum-tag-font-size: var(--spectrum-font-size-200); --spectrum-tag-icon-size: var(--spectrum-workflow-icon-size-200); + --spectrum-tag-corner-radius: var(--spectrum-corner-radius-medium-size-large); - --spectrum-tag-clear-button-spacing-inline-start: var(--spectrum-text-to-visual-200); + --spectrum-tag-clear-button-size: var(--spectrum-cross-icon-size-200); --spectrum-tag-clear-button-spacing-block: var(--spectrum-tag-top-to-cross-icon-large); + --spectrum-tag-label-to-clear-icon: var(--spectrum-tag-label-to-clear-icon-large); + --spectrum-tag-edge-to-clear-icon: var(--spectrum-tag-edge-to-clear-icon-large); + + --spectrum-tag-visual-spacing-inline-start: var(--spectrum-component-edge-to-visual-200); + --spectrum-tag-visual-spacing-inline-end: var(--spectrum-text-to-visual-200); --spectrum-tag-icon-spacing-block-start: var(--spectrum-component-top-to-workflow-icon-200); --spectrum-tag-icon-spacing-block-end: var(--spectrum-component-top-to-workflow-icon-200); - --spectrum-tag-icon-spacing-inline-end: var(--spectrum-text-to-visual-200); + --spectrum-tag-avatar-size: var(--spectrum-avatar-size-100); --spectrum-tag-avatar-spacing-block-start: var(--spectrum-tag-top-to-avatar-large); --spectrum-tag-avatar-spacing-block-end: var(--spectrum-tag-top-to-avatar-large); - --spectrum-tag-avatar-spacing-inline-end: var(--spectrum-text-to-visual-200); - --spectrum-tag-label-spacing-block: var(--spectrum-component-top-to-text-200); + --spectrum-tag-thumbnail-size: var(--spectrum-thumbnail-size-100); - /* tokens based on theme and t-shirt size */ - --spectrum-tag-corner-radius: var(--spectrum-tag-size-large-corner-radius); - --spectrum-tag-spacing-inline-start: var(--spectrum-tag-size-large-spacing-inline-start); - --spectrum-tag-label-spacing-inline-end: var(--spectrum-tag-size-large-label-spacing-inline-end); - --spectrum-tag-clear-button-spacing-inline-end: var(--spectrum-tag-size-large-clear-button-spacing-inline-end); + --spectrum-tag-label-spacing-block: var(--spectrum-component-top-to-text-200); + --spectrum-tag-label-spacing-inline: var(--spectrum-component-edge-to-text-200); } .spectrum-Tag { - border-color: var(--highcontrast-tag-border-color, var(--mod-tag-border-color, var(--spectrum-tag-border-color))); - background-color: var(--highcontrast-tag-background-color, var(--mod-tag-background-color, var(--spectrum-tag-background-color))); - color: var(--highcontrast-tag-content-color, var(--mod-tag-content-color, var(--spectrum-tag-content-color))); + /* mod/highcontrast colors specified at top */ + border-color: var(--spectrum-tag-border-color); + background-color: var(--spectrum-tag-background-color); + color: var(--spectrum-tag-content-color); border-radius: var(--mod-tag-corner-radius, var(--spectrum-tag-corner-radius)); border-width: var(--mod-tag-border-width, var(--spectrum-tag-border-width)); border-style: solid; - padding-inline-start: calc(var(--mod-tag-spacing-inline-start, var(--spectrum-tag-spacing-inline-start)) - var(--mod-tag-border-width, var(--spectrum-tag-border-width))); + padding-inline-start: calc(var(--mod-tag-label-spacing-inline, var(--spectrum-tag-label-spacing-inline)) - var(--mod-tag-border-width, var(--spectrum-tag-border-width))); padding-inline-end: 0; block-size: var(--mod-tag-height, var(--spectrum-tag-height)); + min-inline-size: var(--mod-tag-min-inline-size, var(--spectrum-tag-min-inline-size)); position: relative; display: inline-flex; align-items: center; box-sizing: border-box; vertical-align: bottom; - max-inline-size: 100%; + max-inline-size: calc(var(--mod-tag-height, var(--spectrum-tag-height)) * var(--mod-tag-maximum-width-multiplier, var(--spectrum-tag-maximum-width-multiplier))); outline: none; - user-select: none; transition: border-color var(--mod-tag-animation-duration, var(--spectrum-tag-animation-duration)) ease-in-out, color var(--mod-tag-animation-duration, var(--spectrum-tag-animation-duration)) ease-in-out, - box-shadow var(--mod-tag-animation-duration, var(--spectrum-tag-animation-duration)) ease-in-out, background-color var(--mod-tag-animation-duration, var(--spectrum-tag-animation-duration)) ease-in-out; .spectrum-Tag-itemIcon { @@ -187,53 +230,50 @@ margin-block-start: calc(var(--mod-tag-icon-spacing-block-start, var(--spectrum-tag-icon-spacing-block-start)) - var(--mod-tag-border-width, var(--spectrum-tag-border-width))); margin-block-end: calc(var(--mod-tag-icon-spacing-block-end, var(--spectrum-tag-icon-spacing-block-end)) - var(--mod-tag-border-width, var(--spectrum-tag-border-width))); - margin-inline-end: var(--mod-tag-icon-spacing-inline-end, var(--spectrum-tag-icon-spacing-inline-end)); flex-shrink: 0; } .spectrum-Avatar { margin-block-start: calc(var(--mod-tag-avatar-spacing-block-start, var(--spectrum-tag-avatar-spacing-block-start)) - var(--mod-tag-border-width, var(--spectrum-tag-border-width))); margin-block-end: calc(var(--mod-tag-avatar-spacing-block-end, var(--spectrum-tag-avatar-spacing-block-end)) - var(--mod-tag-border-width, var(--spectrum-tag-border-width))); - margin-inline-end: var(--mod-tag-avatar-spacing-inline-end, var(--spectrum-tag-avatar-spacing-inline-end)); + } + + .spectrum-Thumbnail { + /* prevent thumbnail shrinking when label is longer */ + flex-shrink: 0; + } + + .spectrum-Tag-itemIcon, + .spectrum-Avatar, + .spectrum-Thumbnail { + /* set visual inline-start spacing, but take away label spacing, this will result in negative margin - this calc does not need border width */ + margin-inline-start: calc(var(--mod-tag-visual-spacing-inline-start, var(--spectrum-tag-visual-spacing-inline-start)) - var(--mod-tag-label-spacing-inline, var(--spectrum-tag-label-spacing-inline))); + margin-inline-end: var(--mod-tag-visual-spacing-inline-end, var(--spectrum-tag-visual-spacing-inline-end)); } /* clear button */ .spectrum-Tag-clearButton { - /* width of fill neutralized to ensure correct inline spacing within tag */ - --mod-clear-button-width: fit-content; - --spectrum-clearbutton-fill-size: fit-content; - --spectrum-clearbutton-fill-background-color: transparent; - box-sizing: border-box; + flex-shrink: 0; - padding-block-start: calc(var(--mod-tag-clear-button-spacing-block, var(--spectrum-tag-clear-button-spacing-block)) - var(--mod-tag-border-width, var(--spectrum-tag-border-width))); - padding-block-end: calc(var(--mod-tag-clear-button-spacing-block, var(--spectrum-tag-clear-button-spacing-block)) - var(--mod-tag-border-width, var(--spectrum-tag-border-width))); - - /* move button negative calc to cancel label end margin, then add button start margin */ - margin-inline-start: calc(var(--mod-tag-clear-button-spacing-inline-start, var(--spectrum-tag-clear-button-spacing-inline-start)) + (var(--mod-tag-label-spacing-inline-end, var(--spectrum-tag-label-spacing-inline-end)) * -1)); - - /* end spacing is theme-specific */ - margin-inline-end: calc(var(--mod-tag-clear-button-spacing-inline-end, var(--spectrum-tag-clear-button-spacing-inline-end)) - var(--mod-tag-border-width, var(--spectrum-tag-border-width))); - - /* ensure clear button is correct color */ - color: currentColor; - - .spectrum-ClearButton-fill { - background-color: var(--mod-clearbutton-fill-background-color, var(--spectrum-clearbutton-fill-background-color)); + /* remove label inline-end spacing with negative margin */ + margin-inline-start: calc((var(--mod-tag-label-spacing-inline, var(--spectrum-tag-label-spacing-inline)) - var(--mod-tag-border-width, var(--spectrum-tag-border-width))) * -1); - inline-size: var(--mod-clearbutton-fill-size, var(--spectrum-clearbutton-fill-size)); - block-size: var(--mod-clearbutton-fill-size, var(--spectrum-clearbutton-fill-size)); - } + /* remove border width from clear button */ + margin-inline-end: calc(var(--mod-tag-border-width, var(--spectrum-tag-border-width)) * -1); } .spectrum-Tag-itemLabel { block-size: 100%; box-sizing: border-box; + line-height: var(--mod-tag-label-line-height, var(--spectrum-tag-label-line-height)); + font-family: var(--mod-tag-label-font-family, var(--spectrum-tag-label-font-family)); + font-style: var(--mod-tag-label-font-style, var(--spectrum-tag-label-font-style)); font-weight: var(--mod-tag-label-font-weight, var(--spectrum-tag-label-font-weight)); + font-size: var(--mod-tag-font-size, var(--spectrum-tag-font-size)); flex: 1 1 auto; - font-size: var(--mod-tag-font-size, var(--spectrum-tag-font-size)); cursor: default; overflow: hidden; white-space: nowrap; @@ -242,37 +282,37 @@ padding-block-start: calc(var(--mod-tag-label-spacing-block, var(--spectrum-tag-label-spacing-block)) - var(--mod-tag-border-width, var(--spectrum-tag-border-width))); /* space from label text to end edge */ - margin-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))); + margin-inline-end: calc(var(--mod-tag-label-spacing-inline, var(--spectrum-tag-label-spacing-inline)) - var(--mod-tag-border-width, var(--spectrum-tag-border-width))); } - &:hover { - border-color: var(--highcontrast-tag-border-color-hover, var(--mod-tag-border-color-hover, var(--spectrum-tag-border-color-hover))); - background-color: var(--highcontrast-tag-background-color-hover, var(--mod-tag-background-color-hover, var(--spectrum-tag-background-color-hover))); - color: var(--highcontrast-tag-content-color-hover, var(--mod-tag-content-color-hover, var(--spectrum-tag-content-color-hover))); + &:not(.is-disabled, .is-readOnly):hover { + /* mod/highcontrast specified at top */ + border-color: var(--spectrum-tag-border-color-hover); + background-color: var(--spectrum-tag-background-color-hover); + color: var(--spectrum-tag-content-color-hover); } - &:active { - border-color: var(--highcontrast-tag-border-color-active, var(--mod-tag-border-color-active, var(--spectrum-tag-border-color-active))); - background-color: var(--highcontrast-tag-background-color-active, var(--mod-tag-background-color-active, var(--spectrum-tag-background-color-active))); - color: var(--highcontrast-tag-content-color-active, var(--mod-tag-content-color-active, var(--spectrum-tag-content-color-active))); + &:not(.is-disabled, .is-readOnly):active { + /* mod/highcontrast specified at top */ + border-color: var(--spectrum-tag-border-color-active); + background-color: var(--spectrum-tag-background-color-active); + color: var(--spectrum-tag-content-color-active); + transform: perspective(max(var(--spectrum-downstate-height), var(--spectrum-downstate-width) * var(--spectrum-component-size-width-ratio-down))) translateZ(var(--spectrum-component-size-difference-down)); } - &:focus-visible, - &.is-focused { - border-color: var(--highcontrast-tag-border-color-focus, var(--mod-tag-border-color-focus, var(--spectrum-tag-border-color-focus))); - background-color: var(--highcontrast-tag-background-color-focus, var(--mod-tag-background-color-focus, var(--spectrum-tag-background-color-focus))); - color: var(--highcontrast-tag-content-color-focus, var(--mod-tag-content-color-focus, var(--spectrum-tag-content-color-focus))); + &:not(.is-disabled, .is-readOnly):focus-visible { + /* mod/highcontrast specified at top */ + border-color: var(--spectrum-tag-border-color-focus); + background-color: var(--spectrum-tag-background-color-focus); + color: var(--spectrum-tag-content-color-focus); /* focus indicator */ &::after { content: ""; display: inline-block; position: absolute; - inset-block-start: calc(-1 * var(--mod-tag-focus-ring-gap, var(--spectrum-tag-focus-ring-gap)) - var(--mod-tag-border-width, var(--spectrum-tag-border-width)) - var(--mod-tag-focus-ring-thickness, var(--spectrum-tag-focus-ring-thickness))); - inset-block-end: calc(-1 * var(--mod-tag-focus-ring-gap, var(--spectrum-tag-focus-ring-gap)) - var(--mod-tag-border-width, var(--spectrum-tag-border-width)) - var(--mod-tag-focus-ring-thickness, var(--spectrum-tag-focus-ring-thickness))); - inset-inline-start: calc(-1 * var(--mod-tag-focus-ring-gap, var(--spectrum-tag-focus-ring-gap)) - var(--mod-tag-border-width, var(--spectrum-tag-border-width)) - var(--mod-tag-focus-ring-thickness, var(--spectrum-tag-focus-ring-thickness))); - inset-inline-end: calc(-1 * var(--mod-tag-focus-ring-gap, var(--spectrum-tag-focus-ring-gap)) - var(--mod-tag-border-width, var(--spectrum-tag-border-width)) - var(--mod-tag-focus-ring-thickness, var(--spectrum-tag-focus-ring-thickness))); - border-color: var(--highcontrast-tag-focus-ring-color, var(--mod-tag-focus-ring-color, var(--spectrum-tag-focus-ring-color))); + inset: calc(-1 * var(--mod-tag-focus-ring-gap, var(--spectrum-tag-focus-ring-gap)) - var(--mod-tag-border-width, var(--spectrum-tag-border-width)) - var(--mod-tag-focus-ring-thickness, var(--spectrum-tag-focus-ring-thickness))); + border-color: var(--spectrum-tag-focus-ring-color); /* mod/highcontrast specified at top */ border-radius: calc(var(--mod-tag-corner-radius, var(--spectrum-tag-corner-radius)) + var(--mod-tag-focus-ring-gap, var(--spectrum-tag-focus-ring-gap)) + var(--mod-tag-border-width, var(--spectrum-tag-border-width))); border-width: var(--mod-tag-focus-ring-thickness, var(--spectrum-tag-focus-ring-thickness)); border-style: solid; @@ -281,108 +321,18 @@ } } -/* selected */ -.spectrum-Tag.is-selected { - border-color: var(--highcontrast-tag-border-color-selected, var(--mod-tag-border-color-selected, var(--spectrum-tag-border-color-selected))); - background-color: var(--highcontrast-tag-background-color-selected, var(--mod-tag-background-color-selected, var(--spectrum-tag-background-color-selected))); - color: var(--highcontrast-tag-content-color-selected, var(--mod-tag-content-color-selected, var(--spectrum-tag-content-color-selected))); - - &:hover { - border-color: var(--highcontrast-tag-border-color-selected-hover, var(--mod-tag-border-color-selected-hover, var(--spectrum-tag-border-color-selected-hover))); - background-color: var(--highcontrast-tag-background-color-selected-hover, var(--mod-tag-background-color-selected-hover, var(--spectrum-tag-background-color-selected-hover))); - color: var(--highcontrast-tag-content-color-selected, var(--mod-tag-content-color-selected, var(--spectrum-tag-content-color-selected))); - } - - &:active { - border-color: var(--highcontrast-tag-border-color-selected-active, var(--mod-tag-border-color-selected-active, var(--spectrum-tag-border-color-selected-active))); - background-color: var(--highcontrast-tag-background-color-selected-active, var(--mod-tag-background-color-selected-active, var(--spectrum-tag-background-color-selected-active))); - } - - &:focus-visible, - &.is-focused { - border-color: var(--highcontrast-tag-border-color-selected-focus, var(--mod-tag-border-color-selected-focus, var(--spectrum-tag-border-color-selected-focus))); - background-color: var(--highcontrast-tag-background-color-selected-focus, var(--mod-tag-background-color-selected-focus, var(--spectrum-tag-background-color-selected-focus))); - } -} - -.spectrum-Tag.is-invalid { - border-color: var(--highcontrast-tag-border-color-invalid, var(--mod-tag-border-color-invalid, var(--spectrum-tag-border-color-invalid))); - color: var(--highcontrast-tag-content-color-invalid, var(--mod-tag-content-color-invalid, var(--spectrum-tag-content-color-invalid))); - - &:hover { - border-color: var(--highcontrast-tag-border-color-invalid-hover, var(--mod-tag-border-color-invalid-hover, var(--spectrum-tag-border-color-invalid-hover))); - color: var(--highcontrast-tag-content-color-invalid-hover, var(--mod-tag-content-color-invalid-hover, var(--spectrum-tag-content-color-invalid-hover))); - } - - &:active { - border-color: var(--highcontrast-tag-border-color-invalid-active, var(--mod-tag-border-color-invalid-active, var(--spectrum-tag-border-color-invalid-active))); - color: var(--highcontrast-tag-content-color-invalid-active, var(--mod-tag-content-color-invalid-active, var(--spectrum-tag-content-color-invalid-active))); - } - - &:focus-visible, - &.is-focused { - border-color: var(--highcontrast-tag-border-color-invalid-focus, var(--mod-tag-border-color-invalid-focus, var(--spectrum-tag-border-color-invalid-focus))); - color: var(--highcontrast-tag-content-color-invalid-focus, var(--mod-tag-content-color-invalid-focus, var(--spectrum-tag-content-color-invalid-focus))); - } - - &.is-selected { - border-color: var(--highcontrast-tag-border-color-invalid-selected, var(--mod-tag-border-color-invalid-selected, var(--spectrum-tag-border-color-invalid-selected))); - background-color: var(--highcontrast-tag-background-color-invalid-selected, var(--mod-tag-background-color-invalid-selected, var(--spectrum-tag-background-color-invalid-selected))); - color: var(--highcontrast-tag-content-color-invalid-selected, var(--mod-tag-content-color-invalid-selected, var(--spectrum-tag-content-color-invalid-selected))); - - &:hover { - border-color: var(--highcontrast-tag-border-color-invalid-selected-hover, var(--mod-tag-border-color-invalid-selected-hover, var(--spectrum-tag-border-color-invalid-selected-hover))); - background-color: var(--highcontrast-tag-background-color-invalid-selected-hover, var(--mod-tag-background-color-invalid-selected-hover, var(--spectrum-tag-background-color-invalid-selected-hover))); - color: var(--highcontrast-tag-content-color-invalid-selected, var(--mod-tag-content-color-invalid-selected, var(--spectrum-tag-content-color-invalid-selected))); - } - - &:active { - border-color: var(--highcontrast-tag-border-color-invalid-selected-active, var(--mod-tag-border-color-invalid-selected-active, var(--spectrum-tag-border-color-invalid-selected-active))); - background-color: var(--highcontrast-tag-background-color-invalid-selected-active, var(--mod-tag-background-color-invalid-selected-active, var(--spectrum-tag-background-color-invalid-selected-active))); - } - - &:focus-visible, - &.is-focused { - border-color: var(--highcontrast-tag-border-color-invalid-selected-focus, var(--mod-tag-border-color-invalid-selected-focus, var(--spectrum-tag-border-color-invalid-selected-focus))); - background-color: var(--highcontrast-tag-background-color-invalid-selected-focus, var(--mod-tag-background-color-invalid-selected-focus, var(--spectrum-tag-background-color-invalid-selected-focus))); - } - } -} - -/* emphasized */ -.spectrum-Tag.is-emphasized { - border-color: var(--highcontrast-tag-border-color-emphasized, var(--mod-tag-border-color-emphasized, var(--spectrum-tag-border-color-emphasized))); - background-color: var(--highcontrast-tag-background-color-emphasized, var(--mod-tag-background-color-emphasized, var(--spectrum-tag-background-color-emphasized))); - color: var(--highcontrast-tag-content-color-emphasized, var(--mod-tag-content-color-emphasized, var(--spectrum-tag-content-color-emphasized))); - - &:hover { - border-color: var(--highcontrast-tag-border-color-emphasized-hover, var(--mod-tag-border-color-emphasized-hover, var(--spectrum-tag-border-color-emphasized-hover))); - background-color: var(--highcontrast-tag-background-color-emphasized-hover, var(--mod-tag-background-color-emphasized-hover, var(--spectrum-tag-background-color-emphasized-hover))); - color: var(--highcontrast-tag-content-color-emphasized, var(--mod-tag-content-color-emphasized, var(--spectrum-tag-content-color-emphasized))); - } - - &:active { - border-color: var(--highcontrast-tag-border-color-emphasized-active, var(--mod-tag-border-color-emphasized-active, var(--spectrum-tag-border-color-emphasized-active))); - background-color: var(--highcontrast-tag-background-color-emphasized-active, var(--mod-tag-background-color-emphasized-active, var(--spectrum-tag-background-color-emphasized-active))); - } - - &:focus-visible, - &.is-focused { - border-color: var(--highcontrast-tag-border-color-emphasized-focus, var(--mod-tag-border-color-emphasized-focus, var(--spectrum-tag-border-color-emphasized-focus))); - background-color: var(--highcontrast-tag-background-color-emphasized-focus, var(--mod-tag-background-color-emphasized-focus, var(--spectrum-tag-background-color-emphasized-focus))); - } -} - /* disabled */ .spectrum-Tag.is-disabled { - border-color: var(--highcontrast-tag-border-color-disabled, var(--mod-tag-border-color-disabled, var(--spectrum-tag-border-color-disabled))); - background-color: var(--highcontrast-tag-background-color-disabled, var(--mod-tag-background-color-disabled, var(--spectrum-tag-background-color-disabled))); - color: var(--highcontrast-tag-content-color-disabled, var(--mod-tag-content-color-disabled, var(--spectrum-tag-content-color-disabled))); pointer-events: none; + user-select: none; .spectrum-Avatar { opacity: var(--mod-avatar-opacity-disabled, var(--spectrum-avatar-opacity-disabled)); } + + .spectrum-Thumbnail { + opacity: var(--mod-thumbnail-opacity-disabled, var(--spectrum-thumbnail-opacity-disabled)); + } } /* windows high contrast mode */ @@ -391,7 +341,7 @@ --highcontrast-tag-border-color: ButtonText; --highcontrast-tag-border-color-hover: ButtonText; --highcontrast-tag-border-color-active: ButtonText; - --highcontrast-tag-border-color-focus: Highlight; + --highcontrast-tag-border-color-focus: ButtonText; --highcontrast-tag-background-color: ButtonFace; --highcontrast-tag-background-color-hover: ButtonFace; @@ -404,14 +354,10 @@ --highcontrast-tag-content-color-focus: ButtonText; --highcontrast-tag-focus-ring-color: Highlight; - forced-color-adjust: none; &.is-selected { --highcontrast-tag-border-color-selected: Highlight; - --highcontrast-tag-border-color-selected-hover: Highlight; - --highcontrast-tag-border-color-selected-active: Highlight; - --highcontrast-tag-border-color-selected-focus: Highlight; --highcontrast-tag-background-color-selected: Highlight; --highcontrast-tag-background-color-selected-hover: Highlight; @@ -427,37 +373,8 @@ --highcontrast-tag-content-color-disabled: GrayText; } - &.is-invalid { - --highcontrast-tag-border-color-invalid: Highlight; - --highcontrast-tag-border-color-invalid-hover: Highlight; - --highcontrast-tag-border-color-invalid-active: Highlight; - --highcontrast-tag-border-color-invalid-focus: Highlight; - - --highcontrast-tag-content-color-invalid: CanvasText; - --highcontrast-tag-content-color-invalid-hover: CanvasText; - --highcontrast-tag-content-color-invalid-active: CanvasText; - --highcontrast-tag-content-color-invalid-focus: CanvasText; - - &.is-selected { - --highcontrast-tag-border-color-invalid-selected: Highlight; - --highcontrast-tag-border-color-invalid-selected-hover: Highlight; - --highcontrast-tag-border-color-invalid-selected-focus: Highlight; - --highcontrast-tag-border-color-invalid-selected-active: Highlight; - - --highcontrast-tag-background-color-invalid-selected: Highlight; - --highcontrast-tag-background-color-invalid-selected-hover: Highlight; - --highcontrast-tag-background-color-invalid-selected-active: Highlight; - --highcontrast-tag-background-color-invalid-selected-focus: Highlight; - - --highcontrast-tag-content-color-invalid-selected: HighlightText; - } - } - - &.is-emphasized { + &.spectrum-Tag--emphasized { --highcontrast-tag-border-color-emphasized: Highlight; - --highcontrast-tag-border-color-emphasized-hover: Highlight; - --highcontrast-tag-border-color-emphasized-active: Highlight; - --highcontrast-tag-border-color-emphasized-focus: Highlight; --highcontrast-tag-background-color-emphasized: ButtonFace; --highcontrast-tag-background-color-emphasized-hover: ButtonFace; diff --git a/components/tag/package.json b/components/tag/package.json index 5f2224da272..4c232b38028 100644 --- a/components/tag/package.json +++ b/components/tag/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/tag", - "version": "10.2.0", + "version": "11.0.0-next.2", "description": "The Spectrum CSS tags component", "license": "Apache-2.0", "author": "Adobe", @@ -19,17 +19,15 @@ "./package.json": "./package.json", "./dist/*": "./dist/*", "./index.css": "./dist/index.css", - "./index-*.css": "./dist/index-*.css", "./metadata.json": "./dist/metadata.json", - "./themes/*": "./dist/themes/*", "./stories/*": "./stories/*" }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/avatar": ">=9.0.0 <10.0.0", - "@spectrum-css/clearbutton": ">=7.0.0 <8.0.0", - "@spectrum-css/icon": ">=9.0.0 <10.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/avatar": ">=10.0.0-next.0", + "@spectrum-css/clearbutton": ">=8.0.0-next.0", + "@spectrum-css/icon": ">=10.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/avatar": { @@ -46,10 +44,10 @@ } }, "devDependencies": { - "@spectrum-css/avatar": "9.2.0", - "@spectrum-css/clearbutton": "7.3.0", - "@spectrum-css/icon": "9.2.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/avatar": "10.0.0-next.0", + "@spectrum-css/clearbutton": "8.0.0-next.2", + "@spectrum-css/icon": "10.0.0-next.3", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/tag/stories/tag.stories.js b/components/tag/stories/tag.stories.js index 6061c450e7d..cbbc0a1b485 100644 --- a/components/tag/stories/tag.stories.js +++ b/components/tag/stories/tag.stories.js @@ -1,11 +1,11 @@ import { default as IconStories } from "@spectrum-css/icon/stories/icon.stories.js"; -import { Sizes } from "@spectrum-css/preview/decorators"; +import { Sizes, withDownStateDimensionCapture } from "@spectrum-css/preview/decorators"; import { disableDefaultModes } from "@spectrum-css/preview/modes"; -import { isDisabled, isEmphasized, isInvalid, isSelected, size } from "@spectrum-css/preview/types"; +import { isActive, isDisabled, isEmphasized, isHovered, isKeyboardFocused, isReadOnly, isSelected, size } from "@spectrum-css/preview/types"; import metadata from "../dist/metadata.json"; import packageJson from "../package.json"; import { TagGroups } from "./tag.test.js"; -import { SelectedTemplate, TagsDefaultOptions } from "./template.js"; +import { TagsDefaultOptions } from "./template.js"; /** * A tag categorizes content. It can represent keywords or people, and are [grouped](?path=/docs/components-tag-group--docs) to describe an item or a search request. @@ -15,29 +15,29 @@ export default { component: "Tag", argTypes: { size: size(["s", "m", "l"]), - hasIcon: { - name: "Has icon", - type: { name: "boolean" }, + label: { + name: "Label", + type: { name: "string" }, table: { - type: { summary: "boolean" }, - category: "Component", + type: { summary: "string" }, + category: "Content", }, - control: "boolean", - if: { arg: "hasAvatar", truthy: false }, - }, - iconName: { - ...(IconStories?.argTypes?.iconName ?? {}), - if: { arg: "hasIcon", truthy: true }, + control: { type: "text" }, }, - hasAvatar: { - name: "Has avatar", - type: { name: "boolean" }, + visualContent: { + name: "Visual content", + description: "Can consist of a thumbnail, icon, or avatar.", + type: { name: "string" }, table: { - type: { summary: "boolean" }, - category: "Component", + type: { summary: "string" }, + category: "Content", }, - control: "boolean", - if: { arg: "hasIcon", truthy: false }, + options: ["none", "avatar", "icon", "thumbnail"], + control: "select", + }, + iconName: { + ...(IconStories?.argTypes?.iconName ?? {}), + if: { arg: "visualContent", eq: "icon" }, }, avatarUrl: { name: "Avatar image", @@ -47,27 +47,28 @@ export default { category: "Content", }, control: { type: "file", accept: ".svg,.png,.jpg,.jpeg,.webc" }, - if: { arg: "hasAvatar", truthy: true }, + if: { arg: "visualContent", eq: "avatar" }, }, - label: { - name: "Label", + thumbnailUrl: { + name: "Thumbnail image", type: { name: "string" }, table: { type: { summary: "string" }, category: "Content", }, - control: { type: "text" }, - }, - isEmphasized: { - ...isEmphasized, - if: { arg: "isInvalid", truthy: false }, + control: { type: "file", accept: ".svg,.png,.jpg,.jpeg,.webc" }, + if: { arg: "visualContent", eq: "thumbnail" }, }, - isInvalid, + isEmphasized, isDisabled, isSelected, - hasClearButton: { - name: "Clear button", - description: "True if a button is present to clear the tag.", + isHovered, + isKeyboardFocused, + isActive, + isReadOnly, + isRemovable: { + name: "Removable", + description: "Has a clear button to clear the tag.", type: { name: "boolean" }, table: { type: { summary: "boolean" }, @@ -78,17 +79,19 @@ export default { }, args: { rootClass: "spectrum-Tag", - size: "m", + size: "s", label: "Tag label", - hasIcon: false, - iconName: "Info", + iconName: "Circle", avatarUrl: "example-ava.png", - hasAvatar: false, + thumbnailUrl: "example-card-landscape.png", isSelected: false, isDisabled: false, - isInvalid: false, isEmphasized: false, - hasClearButton: false, + isHovered: false, + isKeyboardFocused: false, + isActive: false, + isReadOnly: false, + isRemovable: false, }, parameters: { actions: { @@ -100,7 +103,17 @@ export default { }, packageJson, metadata, + downState: { + selectors: [".spectrum-Tag:not(:disabled)"], + }, + status: { + type: "migrated", + }, }, + decorators: [ + withDownStateDimensionCapture, + ], + tags: ["migrated"], }; export const Default = TagGroups.bind({}); @@ -108,7 +121,6 @@ Default.tags = ["!autodocs"]; Default.args = {}; // ********* VRT ONLY ********* // -// @todo combine variants into one snapshot export const WithForcedColors = TagGroups.bind({}); WithForcedColors.tags = ["!autodocs", "!dev"]; WithForcedColors.parameters = { @@ -119,66 +131,85 @@ WithForcedColors.parameters = { }; // ********* DOCS ONLY ********* // - +/** + * Tags should always include a label to represent search terms, filters, or keywords. Tags also + * have the option to include an [icon](?path=/docs/components-icon--docs), + * [avatar](?path=/docs/components-avatar--docs), or + * [thumbnail](?path=/docs/components-thumbnail--docs) in addition to the label. + */ export const Standard = TagsDefaultOptions.bind({}); Standard.args = Default.args; +Standard.storyName = "Default"; Standard.tags = ["!dev"]; Standard.parameters = { chromatic: { disableSnapshot: true }, }; -Standard.storyName = "Default"; -export const Selected = SelectedTemplate.bind({}); +export const Selected = TagsDefaultOptions.bind({}); +Selected.storyName = "Selected default"; Selected.tags = ["!dev"]; Selected.args = { isSelected: true }; - Selected.parameters = { chromatic: { disableSnapshot: true }, }; +/** + * A tag in a disabled state shows that a tag exists, but is not available in that circumstance. + * This can be used to maintain layout continuity and communicate that a tag may become available later. + */ export const Disabled = TagsDefaultOptions.bind({}); Disabled.tags = ["!dev"]; Disabled.args = { isDisabled: true, }; - Disabled.parameters = { chromatic: { disableSnapshot: true }, }; export const Emphasized = TagsDefaultOptions.bind({}); +Emphasized.storyName = "Selected emphasized"; Emphasized.tags = ["!dev"]; Emphasized.args = { - isEmphasized: true + isEmphasized: true, + isSelected: true, }; - Emphasized.parameters = { chromatic: { disableSnapshot: true }, }; -export const Invalid = TagGroups.bind({}); -Invalid.tags = ["!dev"]; -Invalid.args = { - isInvalid: true -}; - -Invalid.parameters = { - chromatic: { disableSnapshot: true }, -}; - +/** + * Tags have the option to be removable or not. Removable tags have a small clear ("x") button. + */ export const Removable = TagsDefaultOptions.bind({}); +Removable.storyName = "Default, removable"; Removable.tags = ["!dev"]; Removable.args = { - hasClearButton: true, + isRemovable: true, }; - Removable.parameters = { chromatic: { disableSnapshot: true }, }; +/** + * Tags have a read-only option for when content in the disabled state still needs to be shown. + * Read-only tags cannot be interacted with or changed. + */ +export const ReadOnly = TagsDefaultOptions.bind({}); +ReadOnly.storyName = "Read-only"; +ReadOnly.tags = ["!dev"]; +ReadOnly.args = { + isReadOnly: true, +}; +ReadOnly.parameters = { + chromatic: { disableSnapshot: true }, +}; + +/** + * The default size of a tag is small, but tags are also available in medium and large sizes. + */ export const Sizing = (args, context) => Sizes({ Template: TagsDefaultOptions, withHeading: false, @@ -192,16 +223,22 @@ Sizing.parameters = { /** - * When the tag text is too long for the available horizontal space, it truncates. The full text should be revealed with a tooltip on hover. + * When the tag text is too long for the available horizontal space, it truncates. The full text + * should be revealed with a tooltip on hover. Tags have a maximum width that differs depending on + * the size of the tag. * */ -export const TextOverflow = TagGroups.bind({}); +export const TextOverflow = (args, context) => Sizes({ + Template: TagGroups, + withHeading: false, + withBorder: false, + ...args, +}, context); TextOverflow.tags = ["!dev"]; TextOverflow.args = { hasIcon: true, iconName: "CheckmarkCircle", label: "An example of text overflow behavior. When the button text is too long for the horizontal space available, it will truncate and stay on one line.", - customStyles: { "max-inline-size": "200px" } }; TextOverflow.parameters = { diff --git a/components/tag/stories/tag.test.js b/components/tag/stories/tag.test.js index c4f4e390164..5c3ed2194d7 100644 --- a/components/tag/stories/tag.test.js +++ b/components/tag/stories/tag.test.js @@ -1,51 +1,140 @@ import { Variants } from "@spectrum-css/preview/decorators"; -import { Template } from "./template.js"; +import { TagsDefaultOptions, Template } from "./template.js"; export const TagGroups = Variants({ Template, + SizeTemplate: TagsDefaultOptions, sizeDirection: "row", testData: [ { testHeading: "Default", }, { - testHeading: "Is removable", - hasClearButton: true, + testHeading: "Emphasized", + isEmphasized: true, }, { - testHeading: "With icon", - hasIcon: true, - iconName: "Info", + testHeading: "Disabled with states", + isDisabled: true, }, + // variants with visuals { - testHeading: "With avatar", - hasAvatar: true, + testHeading: "Default, with icon", + iconName: "Circle", + }, + { + testHeading: "Default, with avatar", avatarUrl: "example-ava.png", }, + { + testHeading: "Emphasized, with thumbnail", + isEmphasized: true, + thumbnailUrl: "example-card-landscape.png", + }, + // read-only + { + testHeading: "Default, read-only", + isReadOnly: true, + }, + { + testHeading: "Emphasized, read-only", + isReadOnly: true, + isEmphasized: true, + isSelected: true, + }, + // truncated, which many states below ignore { testHeading: "Truncated", label: "Tag label that truncates when it gets too long", - customStyles: { - "max-inline-size": "200px" - } } ], stateData: [ { - testHeading: "Invalid", - isInvalid: true, + testHeading: "Removable", + isRemovable: true, + }, + { + testHeading: "Hovered", + isHovered: true, + ignore: ["Truncated"], + }, + { + testHeading: "Keyboard focused", + isKeyboardFocused: true, + ignore: ["Truncated"], + }, + { + testHeading: "Active", + isActive: true, + ignore: ["Truncated"], }, { testHeading: "Disabled", isDisabled: true, + ignore: ["Truncated", "Disabled with states"], }, { testHeading: "Selected", isSelected: true, + ignore: ["Truncated"], }, { - testHeading: "Emphasized", - isEmphasized: true, + testHeading: "Selected & removable", + isSelected: true, + isRemovable: true, + ignore: ["Truncated"], + }, + { + testHeading: "Selected & hovered", + isSelected: true, + isHovered: true, + ignore: ["Truncated"], + }, + { + testHeading: "Selected & keyboard focused", + isSelected: true, + isKeyboardFocused: true, + ignore: ["Truncated"], + }, + { + testHeading: "Selected & active", + isSelected: true, + isActive: true, + ignore: ["Truncated"], + }, + // adding visuals as states so we can test them in the truncated section + { + testHeading: "With icon", + iconName: "Circle", + include: ["Truncated"], + }, + { + testHeading: "With icon, removable", + iconName: "Circle", + isRemovable: true, + include: ["Truncated"], + }, + { + testHeading: "With avatar", + avatarUrl: "example-ava.png", + include: ["Truncated"], + }, + { + testHeading: "With avatar, removable", + avatarUrl: "example-ava.png", + isRemovable: true, + include: ["Truncated"], + }, + { + testHeading: "With thumbnail", + thumbnailUrl: "example-card-landscape.png", + include: ["Truncated"], + }, + { + testHeading: "With thumbnail, removable", + thumbnailUrl: "example-card-landscape.png", + isRemovable: true, + include: ["Truncated"], }, ] }); diff --git a/components/tag/stories/template.js b/components/tag/stories/template.js index 90c72435bae..6eee8ba8ee3 100644 --- a/components/tag/stories/template.js +++ b/components/tag/stories/template.js @@ -2,33 +2,35 @@ import { Template as Avatar } from "@spectrum-css/avatar/stories/template.js"; import { Template as ClearButton } from "@spectrum-css/clearbutton/stories/template.js"; import { Template as Icon } from "@spectrum-css/icon/stories/template.js"; import { Container, getRandomId } from "@spectrum-css/preview/decorators"; -import { html, nothing } from "lit"; +import { Template as Thumbnail } from "@spectrum-css/thumbnail/stories/template.js"; +import { html } from "lit"; import { classMap } from "lit/directives/class-map.js"; import { ifDefined } from "lit/directives/if-defined.js"; import { styleMap } from "lit/directives/style-map.js"; import { when } from "lit/directives/when.js"; import "../index.css"; -import "../themes/spectrum.css"; -/* Must be imported last */ -import "../themes/express.css"; export const Template = ({ rootClass = "spectrum-Tag", - size = "m", - iconName, - avatarUrl, - label, + size = "s", + iconName = "", + avatarUrl = "", + thumbnailUrl = "", + label = "", isSelected = false, isEmphasized = false, isDisabled = false, - isInvalid = false, - hasClearButton = false, + isHovered = false, + isKeyboardFocused = false, + isActive = false, + isReadOnly = false, + isRemovable = false, id = getRandomId("tag"), customClasses = [], customStyles = {}, } = {}, context = {}) => { - if(isInvalid) iconName = "Alert"; + const { updateArgs } = context; return html`
({ ...a, [c]: true }), {}), })} id=${ifDefined(id)} tabindex=${isDisabled ? "-1" : "0"} style=${styleMap(customStyles)} + @click=${function() { + if (isReadOnly || isDisabled) return; + updateArgs({ isSelected: !isSelected }); + }} > - ${when(avatarUrl && !isInvalid, () => + ${when(avatarUrl, () => Avatar({ + size: ({ + s: "50", + m: "75", + l: "100", + }[size] || "75"), image: avatarUrl, - size: "50", }, context) )} - ${when(iconName || isInvalid, () => + ${when(iconName, () => Icon({ size, iconName, @@ -60,16 +73,28 @@ export const Template = ({ customClasses: [`${rootClass}-itemIcon`], }, context) )} + ${when(thumbnailUrl, () => + Thumbnail({ + size: ({ + s: "50", + m: "75", + l: "100", + }[size] || "75"), + imageURL: thumbnailUrl, + }, context) + )} ${label} - ${when(hasClearButton, () => + ${when(isRemovable, () => ClearButton({ size, + isDisabled, + isFocusable: false, customClasses: [`${rootClass}-clearButton`], onclick: (evt) => { - const el = evt.target; - if (!el) return; + const button = evt.currentTarget; + if (!button) return; - const wrapper = el.closest(rootClass); + const wrapper = button.closest(`.${rootClass}`); wrapper.parentNode.removeChild(wrapper); }, }, context) @@ -88,36 +113,23 @@ export const TagsDefaultOptions = ({ }, content: html` ${Template(args, context)} - ${!args.isInvalid ? - Template({ + ${args.isRemovable ? "" : Template({ + ...args, + isRemovable: true, + }, context)} + ${Template({ ...args, hasIcon: true, - iconName: "CheckmarkCircle" - }, context): nothing } - ${!args.isInvalid ? - Template({ + iconName: "CheckmarkCircle", + }, context)} + ${Template({ + ...args, + hasThumbnail: true, + thumbnailUrl: "example-card-landscape.png", + }, context)} + ${Template({ ...args, hasAvatar: true, avatarUrl: "example-ava.png", - }, context): nothing }`, -}, context); - -export const SelectedTemplate = (args, context) => Container({ - withBorder: false, - direction: "row", - wrapperStyles: { - rowGap: "12px", - }, - content: html`${[ - { isSelected: true, isDisabled: false, heading: "Selected" }, - { isSelected: true, isDisabled: false, isInvalid: true, heading: "Selected + Invalid" }, - ].map(({isSelected, heading, isInvalid}) => Container({ - withBorder: false, - heading: heading, - content: TagsDefaultOptions({ - ...args, - isSelected, - isInvalid - }) - }, context))}` + }, context)}`, }, context); diff --git a/components/tag/themes/express.css b/components/tag/themes/express.css deleted file mode 100644 index 7c2c2e67303..00000000000 --- a/components/tag/themes/express.css +++ /dev/null @@ -1,64 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--express */ - -@import "./spectrum.css"; - -@container style(--system: express) { - .spectrum-Tag { - /* border */ - --spectrum-tag-background-color: transparent; - --spectrum-tag-background-color-hover: var(--spectrum-gray-300); - --spectrum-tag-background-color-active: var(--spectrum-gray-400); - --spectrum-tag-background-color-focus: var(--spectrum-gray-300); - - /* express has pill style full corner radius */ - --spectrum-tag-size-small-corner-radius: var(--spectrum-component-height-75); - --spectrum-tag-size-medium-corner-radius: var(--spectrum-component-height-100); - --spectrum-tag-size-large-corner-radius: var(--spectrum-component-height-200); - - /* background */ - --spectrum-tag-border-color: var(--spectrum-gray-300); - --spectrum-tag-border-color-hover: var(--spectrum-gray-400); - --spectrum-tag-border-color-active: var(--spectrum-gray-500); - --spectrum-tag-border-color-focus: var(--spectrum-gray-400); - - /* content color */ - --spectrum-tag-content-color: var(--spectrum-neutral-content-color-default); - --spectrum-tag-content-color-hover: var(--spectrum-neutral-content-color-hover); - --spectrum-tag-content-color-active: var(--spectrum-neutral-content-color-down); - --spectrum-tag-content-color-focus: var(--spectrum-neutral-content-color-key-focus); - - /* selected */ - --spectrum-tag-border-color-selected: var(--spectrum-neutral-background-color-default); - --spectrum-tag-border-color-selected-hover: var(--spectrum-neutral-background-color-hover); - --spectrum-tag-border-color-selected-active: var(--spectrum-neutral-background-color-down); - --spectrum-tag-border-color-selected-focus: var(--spectrum-neutral-background-color-key-focus); - - /* disabled */ - --spectrum-tag-border-color-disabled: var(--spectrum-disabled-border-color); - --spectrum-tag-background-color-disabled: transparent; - - /* tokens based on theme and t-shirt size */ - --spectrum-tag-size-small-spacing-inline-start: var(--spectrum-component-pill-edge-to-visual-75); - --spectrum-tag-size-small-label-spacing-inline-end: var(--spectrum-component-pill-edge-to-text-75); - --spectrum-tag-size-small-clear-button-spacing-inline-end: var(--spectrum-component-pill-edge-to-visual-75); - --spectrum-tag-size-medium-spacing-inline-start: var(--spectrum-component-pill-edge-to-visual-100); - --spectrum-tag-size-medium-label-spacing-inline-end: var(--spectrum-component-pill-edge-to-text-100); - --spectrum-tag-size-medium-clear-button-spacing-inline-end: var(--spectrum-component-pill-edge-to-visual-100); - --spectrum-tag-size-large-spacing-inline-start: var(--spectrum-component-pill-edge-to-visual-200); - --spectrum-tag-size-large-label-spacing-inline-end: var(--spectrum-component-pill-edge-to-text-200); - --spectrum-tag-size-large-clear-button-spacing-inline-end: var(--spectrum-component-pill-edge-to-visual-200); - } -} diff --git a/components/tag/themes/spectrum-two.css b/components/tag/themes/spectrum-two.css deleted file mode 100644 index f9c51730f48..00000000000 --- a/components/tag/themes/spectrum-two.css +++ /dev/null @@ -1,56 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -@container style(--system: spectrum) { - .spectrum-Tag { - --spectrum-tag-background-color: var(--spectrum-gray-50); - --spectrum-tag-background-color-hover: var(--spectrum-gray-50); - --spectrum-tag-background-color-active: var(--spectrum-gray-100); - --spectrum-tag-background-color-focus: var(--spectrum-gray-50); - - --spectrum-tag-size-small-corner-radius: var(--spectrum-corner-radius-100); - --spectrum-tag-size-medium-corner-radius: var(--spectrum-corner-radius-100); - --spectrum-tag-size-large-corner-radius: var(--spectrum-corner-radius-100); - - --spectrum-tag-border-color: var(--spectrum-gray-700); - --spectrum-tag-border-color-hover: var(--spectrum-gray-800); - --spectrum-tag-border-color-active: var(--spectrum-gray-900); - --spectrum-tag-border-color-focus: var(--spectrum-gray-800); - - --spectrum-tag-content-color: var(--spectrum-neutral-subdued-content-color-default); - --spectrum-tag-content-color-hover: var(--spectrum-neutral-subdued-content-color-hover); - --spectrum-tag-content-color-active: var(--spectrum-neutral-subdued-content-color-down); - --spectrum-tag-content-color-focus: var(--spectrum-neutral-subdued-content-color-key-focus); - --spectrum-tag-content-color-selected: var(--spectrum-gray-25); - - --spectrum-tag-border-color-selected: var(--spectrum-neutral-subdued-background-color-default); - --spectrum-tag-border-color-selected-hover: var(--spectrum-neutral-subdued-background-color-hover); - --spectrum-tag-border-color-selected-active: var(--spectrum-neutral-subdued-background-color-down); - --spectrum-tag-border-color-selected-focus: var(--spectrum-neutral-subdued-background-color-key-focus); - - /* disabled variant */ - --spectrum-tag-border-color-disabled: transparent; - --spectrum-tag-background-color-disabled: var(--spectrum-disabled-background-color); - - /* tokens based on theme and t-shirt size */ - --spectrum-tag-size-small-spacing-inline-start: var(--spectrum-component-edge-to-visual-75); - --spectrum-tag-size-small-label-spacing-inline-end: var(--spectrum-component-edge-to-text-75); - --spectrum-tag-size-small-clear-button-spacing-inline-end: var(--spectrum-component-edge-to-visual-75); - --spectrum-tag-size-medium-spacing-inline-start: var(--spectrum-component-edge-to-visual-100); - --spectrum-tag-size-medium-label-spacing-inline-end: var(--spectrum-component-edge-to-text-100); - --spectrum-tag-size-medium-clear-button-spacing-inline-end: var(--spectrum-component-edge-to-visual-100); - --spectrum-tag-size-large-spacing-inline-start: var(--spectrum-component-edge-to-visual-200); - --spectrum-tag-size-large-label-spacing-inline-end: var(--spectrum-component-edge-to-text-200); - --spectrum-tag-size-large-clear-button-spacing-inline-end: var(--spectrum-component-edge-to-visual-200); - } -} diff --git a/components/tag/themes/spectrum.css b/components/tag/themes/spectrum.css deleted file mode 100644 index 171968e1f50..00000000000 --- a/components/tag/themes/spectrum.css +++ /dev/null @@ -1,27 +0,0 @@ -/*! - * Copyright 2024 Adobe. All rights reserved. - * - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ - -/* @combine .spectrum.spectrum--legacy */ - -@import "./spectrum-two.css"; - -@container style(--system: legacy) { - .spectrum-Tag { - --spectrum-tag-background-color: var(--spectrum-gray-75); - --spectrum-tag-background-color-hover: var(--spectrum-gray-75); - --spectrum-tag-background-color-active: var(--spectrum-gray-200); - --spectrum-tag-background-color-focus: var(--spectrum-gray-75); - - --spectrum-tag-content-color-selected: var(--spectrum-gray-50); - } -} diff --git a/components/taggroup/CHANGELOG.md b/components/taggroup/CHANGELOG.md index c3bbde6a074..7588dc59aae 100644 --- a/components/taggroup/CHANGELOG.md +++ b/components/taggroup/CHANGELOG.md @@ -1,5 +1,60 @@ # Change log +## 8.0.0-next.2 + +### Major Changes + +📝 [#3966](https://github.com/adobe/spectrum-css/pull/3966) [`88948bf`](https://github.com/adobe/spectrum-css/commit/88948bf722acde7176716879968cb2f1f0fdb5e1) Thanks [@rise-erpelding](https://github.com/rise-erpelding)! + +The Spectrum 2 version of Tag Group is a major change from its Spectrum 1 counterpart. + +Major style changes include: + +- 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` + +## 8.0.0-next.1 + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + +## 8.0.0-next.0 + +### Patch Changes + +- Updated dependencies []: + - @spectrum-css/tag@11.0.0-next.0 + ## 7.2.0 ### Minor Changes diff --git a/components/taggroup/dist/metadata.json b/components/taggroup/dist/metadata.json index 10ed81256ff..28ca5140d81 100644 --- a/components/taggroup/dist/metadata.json +++ b/components/taggroup/dist/metadata.json @@ -1,16 +1,58 @@ { "sourceFile": "index.css", - "selectors": [".spectrum-TagGroup", ".spectrum-TagGroup-item"], + "selectors": [ + ".spectrum-TagGroup", + ".spectrum-TagGroup--sideLabel", + ".spectrum-TagGroup--sideLabel .spectrum-TagGroup-actionButton", + ".spectrum-TagGroup--sideLabel .spectrum-TagGroup-helpText", + ".spectrum-TagGroup--sideLabel .spectrum-TagGroup-label", + ".spectrum-TagGroup--sideLabel .spectrum-TagGroup-tags", + ".spectrum-TagGroup--sizeL", + ".spectrum-TagGroup--sizeS", + ".spectrum-TagGroup-actionButton", + ".spectrum-TagGroup-helpText", + ".spectrum-TagGroup-label", + ".spectrum-TagGroup-tags", + ".spectrum-TagGroup:lang(ja)", + ".spectrum-TagGroup:lang(ko)", + ".spectrum-TagGroup:lang(zh)" + ], "modifiers": [ - "--mod-tag-group-item-margin-block", - "--mod-tag-group-item-margin-inline" + "--mod-body-cjk-line-height", + "--mod-body-font-size", + "--mod-body-line-height", + "--mod-body-margin-end", + "--mod-body-margin-start", + "--mod-tag-group-block-spacing-label-to-tags", + "--mod-tag-group-block-tag-spacing", + "--mod-tag-group-inline-spacing-label-to-tags", + "--mod-tag-group-inline-tag-spacing", + "--mod-tag-group-spacing-help-text-to-tags" ], "component": [ - "--spectrum-tag-group-item-margin-block", - "--spectrum-tag-group-item-margin-inline" + "--spectrum-tag-group-block-spacing-label-to-tags", + "--spectrum-tag-group-block-tag-spacing", + "--spectrum-tag-group-inline-spacing-label-to-tags", + "--spectrum-tag-group-inline-tag-spacing", + "--spectrum-tag-group-spacing-help-text-to-tags" + ], + "global": [ + "--spectrum-cjk-line-height-100", + "--spectrum-component-bottom-to-text-100", + "--spectrum-component-bottom-to-text-200", + "--spectrum-component-bottom-to-text-75", + "--spectrum-component-top-to-text-100", + "--spectrum-component-top-to-text-200", + "--spectrum-component-top-to-text-75", + "--spectrum-field-label-to-component", + "--spectrum-font-size-100", + "--spectrum-font-size-200", + "--spectrum-font-size-75", + "--spectrum-help-text-to-component", + "--spectrum-line-height-100", + "--spectrum-spacing-100", + "--spectrum-spacing-200" ], - "global": ["--spectrum-spacing-75"], - "system-theme": [], "passthroughs": [], "high-contrast": [] } diff --git a/components/taggroup/index.css b/components/taggroup/index.css index e3b323bb91f..6975c5186ba 100644 --- a/components/taggroup/index.css +++ b/components/taggroup/index.css @@ -1,5 +1,5 @@ /*! - * Copyright 2024 Adobe. All rights reserved. + * Copyright 2025 Adobe. All rights reserved. * * This file is licensed to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. You may obtain a copy @@ -12,17 +12,93 @@ */ .spectrum-TagGroup { - --spectrum-tag-group-item-margin-block: var(--spectrum-spacing-75); - --spectrum-tag-group-item-margin-inline: var(--spectrum-spacing-75); + --spectrum-tag-group-inline-tag-spacing: var(--spectrum-spacing-200); + --spectrum-tag-group-block-tag-spacing: var(--spectrum-spacing-200); + --spectrum-tag-group-block-spacing-label-to-tags: var(--spectrum-field-label-to-component); + --spectrum-tag-group-inline-spacing-label-to-tags: var(--spectrum-spacing-200); + --spectrum-tag-group-spacing-help-text-to-tags: var(--spectrum-help-text-to-component); + /* 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); + } +} + +.spectrum-TagGroup--sizeS { + --spectrum-tag-group-inline-tag-spacing: var(--spectrum-spacing-100); + --spectrum-tag-group-block-tag-spacing: var(--spectrum-spacing-100); + + /* passthroughs for body typography element in empty state */ + --mod-body-font-size: var(--spectrum-font-size-75); + --mod-body-margin-start: var(--spectrum-component-top-to-text-75); + --mod-body-margin-end: var(--spectrum-component-bottom-to-text-75); +} + +.spectrum-TagGroup--sizeL { + --spectrum-tag-group-inline-tag-spacing: var(--spectrum-spacing-200); + --spectrum-tag-group-block-tag-spacing: var(--spectrum-spacing-200); + + /* passthroughs for body typography element in empty state */ + --mod-body-font-size: var(--spectrum-font-size-200); + --mod-body-margin-start: var(--spectrum-component-top-to-text-200); + --mod-body-margin-end: var(--spectrum-component-bottom-to-text-200); +} + +.spectrum-TagGroup { + display: grid; + grid-template-rows: auto auto auto auto; +} + +.spectrum-TagGroup-tags { display: inline-flex; flex-wrap: wrap; - margin: 0; - padding: 0; - list-style: none; + column-gap: var(--mod-tag-group-inline-tag-spacing, var(--spectrum-tag-group-inline-tag-spacing)); + row-gap: var(--mod-tag-group-block-tag-spacing, var(--spectrum-tag-group-block-tag-spacing)); + margin-block-end: var(--mod-tag-group-block-tag-spacing, var(--spectrum-tag-group-block-tag-spacing)); +} + +.spectrum-TagGroup-label { + margin-block-end: var(--mod-tag-group-block-spacing-label-to-tags, var(--spectrum-tag-group-block-spacing-label-to-tags)); } -.spectrum-TagGroup-item { - margin-block: var(--mod-tag-group-item-margin-block, var(--spectrum-tag-group-item-margin-block)); - margin-inline: var(--mod-tag-group-item-margin-inline, var(--spectrum-tag-group-item-margin-inline)); +.spectrum-TagGroup-actionButton { + justify-self: start; +} + +.spectrum-TagGroup-helpText { + margin-block-start: var(--mod-tag-group-spacing-help-text-to-tags, var(--spectrum-tag-group-spacing-help-text-to-tags)); +} + +.spectrum-TagGroup--sideLabel { + grid-template-columns: auto auto; + grid-template-rows: auto auto auto; + + .spectrum-TagGroup-label { + grid-row: 1; + grid-column: 1; + margin-block-end: 0; + margin-inline-end: var(--mod-tag-group-inline-spacing-label-to-tags, var(--spectrum-tag-group-inline-spacing-label-to-tags)); + } + + .spectrum-TagGroup-tags { + grid-row: 1; + grid-column: 2; + } + + .spectrum-TagGroup-actionButton { + grid-row: 2; + grid-column: 2; + } + + .spectrum-TagGroup-helpText { + grid-row: 3; + grid-column: 2; + } } diff --git a/components/taggroup/package.json b/components/taggroup/package.json index 9fbfcea2d2e..924b241e771 100644 --- a/components/taggroup/package.json +++ b/components/taggroup/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/taggroup", - "version": "7.2.0", + "version": "8.0.0-next.2", "description": "The Spectrum CSS tag group component", "license": "Apache-2.0", "author": "Adobe", @@ -24,8 +24,8 @@ }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/tag": ">=10.0.0 <11.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/tag": ">=11.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/tag": { @@ -36,8 +36,8 @@ } }, "devDependencies": { - "@spectrum-css/tag": "10.2.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/tag": "11.0.0-next.2", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/taggroup/stories/taggroup.stories.js b/components/taggroup/stories/taggroup.stories.js index 66ef23e885d..0a10a82c09e 100644 --- a/components/taggroup/stories/taggroup.stories.js +++ b/components/taggroup/stories/taggroup.stories.js @@ -1,8 +1,10 @@ +import { Sizes, withDownStateDimensionCapture } from "@spectrum-css/preview/decorators"; import { disableDefaultModes } from "@spectrum-css/preview/modes"; +import { isInvalid } from "@spectrum-css/preview/types"; import { default as TagStories } from "@spectrum-css/tag/stories/tag.stories.js"; import metadata from "../dist/metadata.json"; import packageJson from "../package.json"; -import { TagGroups } from "./taggroup.test.js"; +import { exampleTagItems, TagGroupDisabledItemAndActionButton, TagGroups, TagGroupSizingTemplate } from "./taggroup.test.js"; import { Template } from "./template.js"; const ignoreProps = ["rootClass", "hasClearButton", "label"]; @@ -23,31 +25,89 @@ export default { else value.table = { ...value.table, category: "Tag settings" }; return { ...acc, [key]: value }; }, {}), - ariaLabel: { - name: "Aria-label", - type: { name: "string" }, + isInvalid: { + ...isInvalid, + description: "Displays help text below the tag group with invalid icon and styling.", + if: { arg: "helpText", neq: "" }, + }, + ariaLabel: { table: { disable: true } }, + label: { table: { disable: true } }, + items: { table: { disable: true } }, + actionButtonText: { + name: "Action button text", + description: "Displays an action button below the tag group, if left blank, the action button will not be displayed.", + type: { name: "text" }, + table: { + type: { summary: "text" }, + category: "Action button settings", + }, + control: "text", + }, + hasDisabledActionButton: { + name: "Has disabled action button", + description: "Displays the action button in a disabled state.", + type: { name: "boolean" }, table: { - type: { summary: "string" }, + type: { summary: "boolean" }, + category: "Action button settings", + }, + if: { arg: "actionButtonText", truthy: true }, + }, + fieldLabel: { + name: "Field label", + description: "Displays a label above the tag group, if left blank, the label will not be displayed.", + type: { name: "text" }, + table: { + type: { summary: "text" }, category: "Content", }, - control: { type: "text" }, + control: "text", }, - items: { table: { disable: true } }, - isRemovable: { - name: "Removable tags", - description: "True if a button is present to clear the tag.", + fieldLabelPosition: { + name: "Field label position", type: { name: "boolean" }, table: { type: { summary: "boolean" }, - category: "Shared settings", + category: "Content", + }, + options: ["top", "side"], + control: "select", + if: { arg: "fieldLabel", truthy: true }, + }, + helpText: { + name: "Help text", + description: "Displays help text below the tag group, if left blank, the help text will not be displayed.", + type: { name: "text" }, + table: { + type: { summary: "text" }, + category: "Content", }, - control: "boolean", + control: "text", + }, + numberOfTags: { + name: "Number of tags", + description: "The number of tags to display in the tag group. If the number of tags is 0, the tag group will show a placeholder text to communicate the empty state.", + type: { name: "number" }, + table: { + type: { summary: "number" }, + category: "Content", + }, + control: { type: "number", min: 0, max: 30, step: 1 }, }, }, args: { + ...TagStories.args, rootClass: "spectrum-TagGroup", isRemovable: false, size: "m", + actionButtonText: "Show all", + helpText: "Help text description", + fieldLabel: "Tag group label", + fieldLabelPosition: "top", + isInvalid: false, + numberOfTags: 3, + ariaLabel: "Tags", + hasDisabledActionButton: false, }, parameters: { actions: { @@ -61,66 +121,196 @@ export default { }, packageJson, metadata, - }, -}; - -export const Default = TagGroups.bind({}); -Default.args = { - ariaLabel: "Tags", - items: [ - { - label: "Tag 1", + downState: { + selectors: [".spectrum-Tag", ".spectrum-ActionButton"], }, - { - label: "Tag 2", - }, - { - label: "Tag 3", + status: { + type: "migrated", }, + }, + decorators: [ + withDownStateDimensionCapture, ], + tags: ["migrated"], }; +export const Default = TagGroups.bind({}); +Default.tags = ["!autodocs"]; + // ********* DOCS ONLY ********* // +/** + * A tag group on its own should always have a label. Labels can be placed either on top or on the side of the tags, but top labels are the default and are recommended because they work better with long copy, localization, and responsive layouts. + */ +export const DefaultWithLabel = TagGroups.bind({}); +DefaultWithLabel.storyName = "Label position - default/top"; +DefaultWithLabel.tags = ["!dev"]; +DefaultWithLabel.parameters = { + chromatic: { + disableSnapshot: true, + }, +}; +DefaultWithLabel.args = { + actionButtonText: "", + helpText: "", + items: exampleTagItems, + fieldLabel: "Tags", +}; + +/** + * Tag group labels can also be placed on the side of the tag group. Side labels are most useful when vertical space is limited. + */ +export const SideLabel = Template.bind({}); +SideLabel.storyName = "Label position - side"; +SideLabel.tags = ["!dev"]; +SideLabel.parameters = { + chromatic: { + disableSnapshot: true, + }, +}; +SideLabel.args = { + fieldLabelPosition: "side", + items: exampleTagItems, + fieldLabel: "Tags", + helpText: "These tags were automatically added." +}; + /** * A tag group can contain removable tags when the context is for editing or non-removable tags when tags are read-only. Removable and non-removable tags cannot be combined within the tag group. + * + * When horizontal space is limited in a tag group, the tags wrap to form another line. Individual tags don't wrap between lines; they'll either move to the next line or the text within the tag will truncate. */ -export const Removable = Template.bind({}); -Removable.tags = ["!dev"]; -Removable.parameters = { +export const RemovableAndWrapping = Template.bind({}); +RemovableAndWrapping.storyName = "Removable and wrapping"; +RemovableAndWrapping.tags = ["!dev"]; +RemovableAndWrapping.parameters = { chromatic: { disableSnapshot: true, }, }; -Removable.args = { +RemovableAndWrapping.args = { + fieldLabel: "Tags", + actionButtonText: "", + helpText: "", isRemovable: true, - isEmphasized: false, - customStyles: {"max-width": "300px"}, + customStyles: {"max-inline-size": "300px"}, items: [ { - label: "Tag 1 Example", + label: "Hiking and camping", }, { - label: "Tag 2 Example", + label: "Surfing", }, { - label: "Tag 3 Example", + label: "Outdoors", }, { - label: "Tag 4", + label: "Tag with avatar", avatarUrl: "example-ava.png", }, { - label: "Tag 5", + label: "Traveling", }, { - label: "Tag 6", + label: "Tag with thumbnail", + thumbnailUrl: "flowers.png", }, { - label: "Tag 7", + label: "Tag with icon", + iconName: "Cloud", }, ], }; +/** + * A single quiet [action button](?path=/docs/components-action-button--docs) 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. + */ +export const WithActionButton = Template.bind({}); +WithActionButton.storyName = "With action button"; +WithActionButton.tags = ["!dev"]; +WithActionButton.parameters = { + chromatic: { + disableSnapshot: true, + }, +}; +WithActionButton.args = { + actionButtonText: "Show all (13)", + helpText: "", + items: exampleTagItems, + fieldLabel: "Tags", +}; + +/** + * A tag group can have [help text](?path=/docs/components-help-text--docs) below the group to give extra context or instruction. The help text may be invalid, indicating an error for when requirements aren't met. + */ +export const WithHelpText = Template.bind({}); +WithHelpText.storyName = "With help text"; +WithHelpText.tags = ["!dev"]; +WithHelpText.parameters = { + chromatic: { + disableSnapshot: true, + }, +}; +WithHelpText.args = { + fieldLabel: "Tags", + isInvalid: true, + actionButtonText: "", + helpText: "Add at least three tags.", + items: [ + { label: "2025" }, + { label: "Australia" }, + ], +}; + +/** + * 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. + */ +export const Disabled = TagGroupDisabledItemAndActionButton.bind({}); +Disabled.storyName = "With disabled tag and action button"; +Disabled.tags = ["!dev"]; +Disabled.parameters = { + chromatic: { + disableSnapshot: true, + }, +}; +Disabled.args = { + fieldLabel: "Tags", + helpText: "These tags were automatically added." +}; + +/** + * When a stand alone tag group has no tags, it may show placeholder text to communicate the empty state. The placeholder text can be customized, or another element may be shown to communicate the empty state rather than placeholder text. + */ +export const WithNoTags = Template.bind({}); +WithNoTags.storyName = "With no tags (empty state)"; +WithNoTags.tags = ["!dev"]; +WithNoTags.parameters = { + chromatic: { + disableSnapshot: true, + }, +}; +WithNoTags.args = { + fieldLabel: "Tags", + numberOfTags: 0, + helpText: "", + actionButtonText: "", +}; + +/** + * The default size of a tag group is medium, but tags are also available in small and large sizes. + */ +export const Sizing = (args, context) => Sizes({ + Template: TagGroupSizingTemplate, + withHeading: false, + withBorder: false, + ...args, +}, context); +Sizing.tags = ["!dev"]; +Sizing.parameters = { + chromatic: { disableSnapshot: true }, +}; + // ********* VRT ONLY ********* // export const WithForcedColors = TagGroups.bind({}); WithForcedColors.args = Default.args; diff --git a/components/taggroup/stories/taggroup.test.js b/components/taggroup/stories/taggroup.test.js index 737d8543f83..0c4078cf75f 100644 --- a/components/taggroup/stories/taggroup.test.js +++ b/components/taggroup/stories/taggroup.test.js @@ -1,45 +1,104 @@ import { Variants } from "@spectrum-css/preview/decorators"; +import { html } from "lit"; import { Template } from "./template.js"; +export const exampleTagItems = [ + { label: "2025" }, + { label: "Outdoors" }, + { label: "Blue" }, + { label: "Australia" }, + { label: "Project Alpha" }, + { label: "Project Beta" }, +]; + +const overflowingTagItems = [ + ...exampleTagItems, + { label: "Sports" }, + { label: "Surfing" }, + { label: "Water" }, + { label: "Hawaii" }, +]; + +const itemsWithDisabledTag = [ + ...exampleTagItems, + { label: "Disabled tag", isDisabled: true }, +]; + +export const TagGroupSizingTemplate = (args, context) => { + return html` + ${Template({ + ...args, + items: exampleTagItems, + customStyles: { + "max-width": "300px", + }, + }, context)} + `; +}; + +export const TagGroupDisabledItemAndActionButton = (args, context) => { + return html` + ${Template({ + ...args, + items: itemsWithDisabledTag, + hasDisabledActionButton: true, + }, context)} + `; +}; + export const TagGroups = Variants({ Template, + SizeTemplate: TagGroupSizingTemplate, sizeDirection: "row", testData: [ { testHeading: "Default", + actionButtonText: "", + helpText: "", + items: exampleTagItems, }, { - testHeading: "Is removable", + testHeading: "Removable, with action button and help text", isRemovable: true, + actionButtonText: "Show all", + helpText: "Add at least three tags.", + isInvalid: true, + items: [ + { label: "2025" }, + { label: "Australia" }, + ], }, { - testHeading: "Overflow", - isRemovable: true, - isEmphasized: false, + testHeading: "Top label variant showing action button, help text, and wrapping rows of tags", + actionButtonText: "Show all", + helpText: "Tags are automatically added.", + isInvalid: false, customStyles: {"max-width": "300px"}, - items: [ - { - label: "Tag 1 Example", - }, - { - label: "Tag 2 Example", - }, - { - label: "Tag 3 Example", - }, - { - label: "Tag 4", - }, - { - label: "Tag 5", - }, - { - label: "Tag 6", - }, - { - label: "Tag 7", - }, - ], - } + items: overflowingTagItems, + }, + { + testHeading: "Side label variant showing action button, help text, and wrapping rows of tags", + actionButtonText: "Show all", + helpText: "Tags are automatically added.", + isInvalid: false, + fieldLabelPosition: "side", + customStyles: {"max-width": "400px"}, + items: overflowingTagItems, + }, + { + testHeading: "Empty state, top label", + numberOfTags: 0, + helpText: "No tags added", + actionButtonText: "", + items: [], + }, + { + testHeading: "Empty state, side label", + fieldLabelPosition: "side", + numberOfTags: 0, + helpText: "No tags added", + actionButtonText: "", + items: [], + }, ], }); diff --git a/components/taggroup/stories/template.js b/components/taggroup/stories/template.js index 34bf5d50f77..0493d9da9da 100644 --- a/components/taggroup/stories/template.js +++ b/components/taggroup/stories/template.js @@ -1,38 +1,100 @@ +import { Template as ActionButton } from "@spectrum-css/actionbutton/stories/template.js"; +import { Template as FieldLabel } from "@spectrum-css/fieldlabel/stories/template.js"; +import { Template as HelpText } from "@spectrum-css/helptext/stories/template.js"; +import { getRandomId } from "@spectrum-css/preview/decorators"; import { Template as Tag } from "@spectrum-css/tag/stories/template.js"; +import { Template as Typography } from "@spectrum-css/typography/stories/template.js"; import { html } from "lit"; import { classMap } from "lit/directives/class-map.js"; import { ifDefined } from "lit/directives/if-defined.js"; import { styleMap } from "lit/directives/style-map.js"; +import { when } from "lit/directives/when.js"; import "../index.css"; export const Template = ({ rootClass = "spectrum-TagGroup", ariaLabel, + id = getRandomId("taggroup"), + numberOfTags = 3, items = [], isRemovable = false, customClasses = [], customStyles = {}, size = "m", + actionButtonText = "", + fieldLabel, + fieldLabelPosition = "top", + helpText, + isInvalid = false, + hasDisabledActionButton = false, ...args } = {}, context = {}) => { + const tags = Array.isArray(items) && items.length > 0 + ? items + : (typeof numberOfTags === "number" && numberOfTags > 0 + ? Array.from({ length: numberOfTags }, (_, i) => ({ label: `Tag ${i + 1}` })) + : []); + return html` -
({ ...a, [c]: true }), {}), - })} - style=${styleMap(customStyles)} - role="list" - aria-label=${ifDefined(ariaLabel)} - > - ${items.map((i) => Tag({ - ...i, - ...args, +
({ ...a, [c]: true }), {}), + })} + id=${ifDefined(id)} + style=${styleMap(customStyles)} + > + ${when(fieldLabel, () => html` + ${FieldLabel({ + size, + label: fieldLabel, + customClasses: [`${rootClass}-label`], + }, context)} + `)} + ${when(numberOfTags !== 0, () => html` +
+ ${tags.map((i) => Tag({ + ...i, + ...args, + size, + isRemovable, + isDisabled: i.isDisabled, + label: i.label, + id: getRandomId("tag-item"), + customClasses: [`${rootClass}-tag`], + }, context))} +
+ `, () => html` + ${Typography({ + semantics: "body", + content: ["None"], + }, context)} + `)} + ${when(actionButtonText, () => html` + ${ActionButton({ + size, + isQuiet: true, + isDisabled: hasDisabledActionButton, + label: actionButtonText, + customClasses: [`${rootClass}-actionButton`], + }, context)} + `)} + ${when(helpText, () => html` + ${HelpText({ size, - hasClearButton: isRemovable, - customClasses: [`${rootClass}-item`], - }, context))} + text: helpText, + variant: isInvalid ? "negative" : undefined, + customClasses: [`${rootClass}-helpText`], + }, context)} + `)}
`; }; diff --git a/components/textfield/CHANGELOG.md b/components/textfield/CHANGELOG.md index b947018cda6..c048d311933 100644 --- a/components/textfield/CHANGELOG.md +++ b/components/textfield/CHANGELOG.md @@ -1,5 +1,61 @@ # Change log +## 9.0.0-next.1 + +### Major Changes + +📝 [#2856](https://github.com/adobe/spectrum-css/pull/2856) [`19ca328`](https://github.com/adobe/spectrum-css/commit/19ca32861f1e2f5ce818df919c112b6ce18db910) Thanks [@rise-erpelding](https://github.com/rise-erpelding)! + +#### Migrate to Spectrum 2 + +- Default styles are used for medium +- Removal of quiet variant +- Style adjustments to match design spec: + - Spacing start/end edge to value for XL component should use `component-edge-to-text-300`, not `-200` + - Spacing top edge to value should change with size, now uses different spacing tokens for each component tshirt size according to spec (`component-top-to-text-75`, `-100`, `-200`, and `-300`) + - Spacing bottom edge to value should change with size, now uses different spacing tokens for each component tshirt size according to spec (`component-bottom-to-text-75`, `-100`, `-200`, and `-300`) + - Border thickness has been increased to 2px, and border colors have been updated to match spec + - Adjust side label inline spacing to field, should be `spacing-200` for all tshirt sizes + - Change disabled background color to `gray-25` + - Change disabled-border-color from transparent to `disabled-border-color` +- Use new and updated tokens: + - use tokens for textfield width (`field-default-width-small`, `-medium`, `-large`, `-extra-large`) + - use updated corner radius tokens + - use different component-bottom-to-text tokens for character-count-spacing-block + - update tokens for alert icon block spacing + - update tokens for alert and invalid inline-start spacing + - update font tokens + +Adds mods: + +- `--mod-textfield-character-count-color` +- `--mod-textfield-character-count-font-style` +- `--mod-textfield-character-count-line-height` +- `--mod-textfield-character-count-line-height-cjk` +- `--mod-textfield-font-style` +- `--mod-textfield-line-height` (used for multiline only) +- `--mod-textfield-line-height-cjk` + +Removes mods: + +- `--mod-text-area-min-block-size-quiet` +- `--mod-textfield-character-count-spacing-block-quiet` +- `--mod-textfield-icon-spacing-inline-end-quiet-invalid` +- `--mod-textfield-icon-spacing-inline-end-quiet-valid` +- `--mod-textfield-label-spacing-block-quiet` +- `--mod-textfield-spacing-block-quiet` +- `--mod-textfield-spacing-inline-quiet` + +Changed mods: + +- `--mod-texfield-animation-duration` --> `--mod-textfield-animation-duration` +- `--mod-texfield-placeholder-font-size` --> `--mod-texfield-placeholder-font-size` + +### Patch Changes + +- Updated dependencies [[`60a156d`](https://github.com/adobe/spectrum-css/commit/60a156d7c0efcc999bc440274bbbbf586beb274b)]: + - @spectrum-css/tokens@16.1.0-next.0 + ## 8.2.0 ### Minor Changes @@ -16,6 +72,13 @@ Ensure accurate exports are present for each component. Specifically, adding `th - Updated border color on keyboard focus state for textfield in spectrum-two theme. +## 9.0.0-next.0 + +### Patch Changes + +- Updated dependencies []: + - @spectrum-css/helptext@8.0.0-next.0 + ## 8.1.0 ### Minor Changes diff --git a/components/textfield/dist/metadata.json b/components/textfield/dist/metadata.json index 7e36cb740e0..073bc68dfb2 100644 --- a/components/textfield/dist/metadata.json +++ b/components/textfield/dist/metadata.json @@ -1,59 +1,29 @@ { "sourceFile": "index.css", "selectors": [ - ".is-focused .spectrum-Textfield-input", - ".is-focused .spectrum-Textfield-input::placeholder", - ".is-focused .spectrum-Textfield-input:hover", - ".is-focused .spectrum-Textfield-input:hover::placeholder", - ".is-invalid .spectrum-Textfield-input", - ".is-invalid .spectrum-Textfield-input:focus", - ".is-invalid .spectrum-Textfield-input:focus-visible", - ".is-invalid .spectrum-Textfield-input:focus:hover", - ".is-invalid .spectrum-Textfield-input:hover:not(.is-disabled)", - ".is-invalid.is-focused .spectrum-Textfield-input", - ".is-invalid.is-focused .spectrum-Textfield-input:hover", - ".is-invalid.is-keyboardFocused .spectrum-Textfield-input", - ".is-invalid:focus .spectrum-Textfield-input", - ".is-invalid:focus .spectrum-Textfield-input:hover", - ".is-invalid:hover:not(.is-disabled) .spectrum-Textfield-input", - ".is-keyboardFocused .spectrum-Textfield-input", - ".is-keyboardFocused .spectrum-Textfield-input::placeholder", - ".is-valid .spectrum-Textfield-input", ".spectrum-Textfield", ".spectrum-Textfield .spectrum-FieldLabel", ".spectrum-Textfield .spectrum-HelpText", - ".spectrum-Textfield .spectrum-Textfield-input", ".spectrum-Textfield .spectrum-Textfield-input::placeholder", - ".spectrum-Textfield--multiline", ".spectrum-Textfield--multiline .spectrum-Textfield-input", + ".spectrum-Textfield--multiline .spectrum-Textfield-input:lang(ja)", + ".spectrum-Textfield--multiline .spectrum-Textfield-input:lang(ko)", + ".spectrum-Textfield--multiline .spectrum-Textfield-input:lang(zh)", ".spectrum-Textfield--multiline.spectrum-Textfield--grows .spectrum-Textfield-input", ".spectrum-Textfield--multiline.spectrum-Textfield--grows.spectrum-Textfield--sideLabel .spectrum-Textfield-input", - ".spectrum-Textfield--multiline.spectrum-Textfield--quiet .spectrum-Textfield-input", - ".spectrum-Textfield--quiet .spectrum-FieldLabel", - ".spectrum-Textfield--quiet .spectrum-Textfield-characterCount", - ".spectrum-Textfield--quiet .spectrum-Textfield-input", - ".spectrum-Textfield--quiet .spectrum-Textfield-validationIcon", - ".spectrum-Textfield--quiet.is-disabled .spectrum-Textfield-input", - ".spectrum-Textfield--quiet.is-disabled .spectrum-Textfield-input::placeholder", - ".spectrum-Textfield--quiet.is-disabled:hover .spectrum-Textfield-input", - ".spectrum-Textfield--quiet.is-disabled:hover .spectrum-Textfield-input::placeholder", - ".spectrum-Textfield--quiet.is-invalid .spectrum-Textfield-input", - ".spectrum-Textfield--quiet.is-invalid .spectrum-Textfield-validationIcon", - ".spectrum-Textfield--quiet.is-keyboardFocused:after", - ".spectrum-Textfield--quiet.is-valid .spectrum-Textfield-input", - ".spectrum-Textfield--quiet.is-valid .spectrum-Textfield-validationIcon", - ".spectrum-Textfield--quiet:after", ".spectrum-Textfield--sideLabel", ".spectrum-Textfield--sideLabel .spectrum-FieldLabel", ".spectrum-Textfield--sideLabel .spectrum-HelpText", ".spectrum-Textfield--sideLabel .spectrum-Textfield-characterCount", ".spectrum-Textfield--sideLabel .spectrum-Textfield-input", ".spectrum-Textfield--sideLabel .spectrum-Textfield-validationIcon", - ".spectrum-Textfield--sideLabel:after", ".spectrum-Textfield--sizeL", ".spectrum-Textfield--sizeS", ".spectrum-Textfield--sizeXL", ".spectrum-Textfield-characterCount", + ".spectrum-Textfield-characterCount:lang(ja)", + ".spectrum-Textfield-characterCount:lang(ko)", + ".spectrum-Textfield-characterCount:lang(zh)", ".spectrum-Textfield-input", ".spectrum-Textfield-input:-moz-ui-invalid", ".spectrum-Textfield-input::placeholder", @@ -65,40 +35,67 @@ ".spectrum-Textfield-input:focus:hover::placeholder", ".spectrum-Textfield-input:hover", ".spectrum-Textfield-input:hover::placeholder", - ".spectrum-Textfield-input:lang(ja)::placeholder", - ".spectrum-Textfield-input:lang(ko)::placeholder", - ".spectrum-Textfield-input:lang(zh)::placeholder", ".spectrum-Textfield-input:read-only", ".spectrum-Textfield-input:read-only::placeholder", ".spectrum-Textfield-input[type=\"number\"]", ".spectrum-Textfield-input[type=\"number\"]::-webkit-inner-spin-button", ".spectrum-Textfield-input[type=\"number\"]::-webkit-outer-spin-button", ".spectrum-Textfield.is-disabled .spectrum-FieldLabel", + ".spectrum-Textfield.is-disabled .spectrum-HelpText .spectrum-HelpText-text", + ".spectrum-Textfield.is-disabled .spectrum-Textfield-characterCount", ".spectrum-Textfield.is-disabled .spectrum-Textfield-input", ".spectrum-Textfield.is-disabled .spectrum-Textfield-input::placeholder", + ".spectrum-Textfield.is-disabled .spectrum-Textfield-input:read-only::placeholder", ".spectrum-Textfield.is-disabled .spectrum-Textfield-validationIcon", + ".spectrum-Textfield.is-disabled .spectrum-Textfield.is-readOnly .spectrum-Textfield-input::placeholder", + ".spectrum-Textfield.is-disabled .spectrum-Textfield.is-readOnly:hover .spectrum-Textfield-input::placeholder", ".spectrum-Textfield.is-disabled:hover .spectrum-Textfield-input", ".spectrum-Textfield.is-disabled:hover .spectrum-Textfield-input::placeholder", + ".spectrum-Textfield.is-disabled:hover .spectrum-Textfield-input:read-only::placeholder", + ".spectrum-Textfield.is-disabled:hover .spectrum-Textfield.is-readOnly .spectrum-Textfield-input::placeholder", + ".spectrum-Textfield.is-disabled:hover .spectrum-Textfield.is-readOnly:hover .spectrum-Textfield-input::placeholder", + ".spectrum-Textfield.is-focused .spectrum-Textfield-input", + ".spectrum-Textfield.is-focused .spectrum-Textfield-input::placeholder", + ".spectrum-Textfield.is-focused .spectrum-Textfield-input:hover", + ".spectrum-Textfield.is-focused .spectrum-Textfield-input:hover::placeholder", + ".spectrum-Textfield.is-focused:hover .spectrum-Textfield-input", + ".spectrum-Textfield.is-focused:hover .spectrum-Textfield-input::placeholder", + ".spectrum-Textfield.is-invalid .spectrum-Textfield-input", + ".spectrum-Textfield.is-invalid .spectrum-Textfield-input:focus", + ".spectrum-Textfield.is-invalid .spectrum-Textfield-input:focus:hover", ".spectrum-Textfield.is-invalid .spectrum-Textfield-validationIcon", + ".spectrum-Textfield.is-invalid.is-focused .spectrum-Textfield-input", + ".spectrum-Textfield.is-invalid.is-focused .spectrum-Textfield-input:hover", + ".spectrum-Textfield.is-invalid.is-focused:hover .spectrum-Textfield-input", + ".spectrum-Textfield.is-invalid.is-keyboardFocused .spectrum-Textfield-input", + ".spectrum-Textfield.is-invalid.is-keyboardFocused:hover .spectrum-Textfield-input", + ".spectrum-Textfield.is-invalid:focus .spectrum-Textfield-input", + ".spectrum-Textfield.is-invalid:focus .spectrum-Textfield-input:hover", + ".spectrum-Textfield.is-invalid:focus:hover .spectrum-Textfield-input", + ".spectrum-Textfield.is-invalid:hover:not(.is-disabled, .is-readOnly) .spectrum-Textfield-input", + ".spectrum-Textfield.is-invalid:not(.is-disabled, .is-readOnly) .spectrum-Textfield-input:hover", + ".spectrum-Textfield.is-keyboardFocused .spectrum-Textfield-input", + ".spectrum-Textfield.is-keyboardFocused .spectrum-Textfield-input::placeholder", + ".spectrum-Textfield.is-keyboardFocused:hover .spectrum-Textfield-input", + ".spectrum-Textfield.is-keyboardFocused:hover .spectrum-Textfield-input::placeholder", ".spectrum-Textfield.is-readOnly .spectrum-Textfield-input", ".spectrum-Textfield.is-readOnly .spectrum-Textfield-input::placeholder", ".spectrum-Textfield.is-readOnly .spectrum-Textfield-validationIcon", + ".spectrum-Textfield.is-readOnly.is-disabled .spectrum-Textfield-input", ".spectrum-Textfield.is-readOnly:hover .spectrum-Textfield-input", ".spectrum-Textfield.is-readOnly:hover .spectrum-Textfield-input::placeholder", + ".spectrum-Textfield.is-valid .spectrum-Textfield-input", ".spectrum-Textfield.is-valid .spectrum-Textfield-validationIcon", - ".spectrum-Textfield.spectrum-Textfield--quiet", ".spectrum-Textfield.spectrum-Textfield--sideLabel .spectrum-Textfield-validationIcon", - ".spectrum-Textfield.spectrum-Textfield--sizeL", - ".spectrum-Textfield.spectrum-Textfield--sizeS", - ".spectrum-Textfield.spectrum-Textfield--sizeXL", + ".spectrum-Textfield:focus:hover .spectrum-Textfield-input", + ".spectrum-Textfield:focus:hover .spectrum-Textfield-input::placeholder", ".spectrum-Textfield:hover .spectrum-Textfield-input", ".spectrum-Textfield:hover .spectrum-Textfield-input::placeholder" ], "modifiers": [ - "--mod-texfield-animation-duration", "--mod-text-area-min-block-size", - "--mod-text-area-min-block-size-quiet", "--mod-text-area-min-inline-size", + "--mod-textfield-animation-duration", "--mod-textfield-background-color", "--mod-textfield-background-color-disabled", "--mod-textfield-border-color", @@ -113,11 +110,8 @@ "--mod-textfield-border-color-invalid-keyboard-focus", "--mod-textfield-border-color-keyboard-focus", "--mod-textfield-border-width", - "--mod-textfield-character-count-font-family", - "--mod-textfield-character-count-font-size", - "--mod-textfield-character-count-font-weight", + "--mod-textfield-character-count-color", "--mod-textfield-character-count-spacing-block", - "--mod-textfield-character-count-spacing-block-quiet", "--mod-textfield-character-count-spacing-block-side", "--mod-textfield-character-count-spacing-inline", "--mod-textfield-character-count-spacing-inline-side", @@ -126,6 +120,8 @@ "--mod-textfield-focus-indicator-gap", "--mod-textfield-focus-indicator-width", "--mod-textfield-font-family", + "--mod-textfield-font-size", + "--mod-textfield-font-style", "--mod-textfield-font-weight", "--mod-textfield-height", "--mod-textfield-helptext-spacing-block", @@ -136,21 +132,17 @@ "--mod-textfield-icon-spacing-block-invalid", "--mod-textfield-icon-spacing-block-valid", "--mod-textfield-icon-spacing-inline-end-invalid", - "--mod-textfield-icon-spacing-inline-end-quiet-invalid", - "--mod-textfield-icon-spacing-inline-end-quiet-valid", "--mod-textfield-icon-spacing-inline-end-valid", "--mod-textfield-icon-spacing-inline-start-invalid", "--mod-textfield-icon-spacing-inline-start-valid", "--mod-textfield-label-spacing-block", - "--mod-textfield-label-spacing-block-quiet", "--mod-textfield-label-spacing-inline-side-label", + "--mod-textfield-line-height", + "--mod-textfield-line-height-cjk", "--mod-textfield-min-width", - "--mod-textfield-placeholder-font-size", "--mod-textfield-spacing-block-end", - "--mod-textfield-spacing-block-quiet", "--mod-textfield-spacing-block-start", "--mod-textfield-spacing-inline", - "--mod-textfield-spacing-inline-quiet", "--mod-textfield-text-color-default", "--mod-textfield-text-color-disabled", "--mod-textfield-text-color-focus", @@ -164,6 +156,7 @@ ], "component": [ "--spectrum-text-field-minimum-width-multiplier", + "--spectrum-textfield-animation-duration", "--spectrum-textfield-background-color", "--spectrum-textfield-background-color-disabled", "--spectrum-textfield-border-color", @@ -178,11 +171,8 @@ "--spectrum-textfield-border-color-invalid-keyboard-focus", "--spectrum-textfield-border-color-keyboard-focus", "--spectrum-textfield-border-width", - "--spectrum-textfield-character-count-font-family", - "--spectrum-textfield-character-count-font-size", - "--spectrum-textfield-character-count-font-weight", + "--spectrum-textfield-character-count-color", "--spectrum-textfield-character-count-spacing-block", - "--spectrum-textfield-character-count-spacing-block-quiet", "--spectrum-textfield-character-count-spacing-block-side", "--spectrum-textfield-character-count-spacing-inline", "--spectrum-textfield-character-count-spacing-inline-side", @@ -191,6 +181,8 @@ "--spectrum-textfield-focus-indicator-gap", "--spectrum-textfield-focus-indicator-width", "--spectrum-textfield-font-family", + "--spectrum-textfield-font-size", + "--spectrum-textfield-font-style", "--spectrum-textfield-font-weight", "--spectrum-textfield-height", "--spectrum-textfield-helptext-spacing-block", @@ -201,22 +193,18 @@ "--spectrum-textfield-icon-spacing-block-invalid", "--spectrum-textfield-icon-spacing-block-valid", "--spectrum-textfield-icon-spacing-inline-end-invalid", - "--spectrum-textfield-icon-spacing-inline-end-quiet-invalid", - "--spectrum-textfield-icon-spacing-inline-end-quiet-valid", "--spectrum-textfield-icon-spacing-inline-end-valid", "--spectrum-textfield-icon-spacing-inline-start-invalid", "--spectrum-textfield-icon-spacing-inline-start-valid", "--spectrum-textfield-input-line-height", "--spectrum-textfield-label-spacing-block", - "--spectrum-textfield-label-spacing-block-quiet", "--spectrum-textfield-label-spacing-inline-side-label", + "--spectrum-textfield-line-height", + "--spectrum-textfield-line-height-cjk", "--spectrum-textfield-min-width", - "--spectrum-textfield-placeholder-font-size", "--spectrum-textfield-spacing-block-end", - "--spectrum-textfield-spacing-block-quiet", "--spectrum-textfield-spacing-block-start", "--spectrum-textfield-spacing-inline", - "--spectrum-textfield-spacing-inline-quiet", "--spectrum-textfield-text-color-default", "--spectrum-textfield-text-color-disabled", "--spectrum-textfield-text-color-focus", @@ -230,57 +218,52 @@ ], "global": [ "--spectrum-animation-duration-100", - "--spectrum-border-width-100", - "--spectrum-character-count-to-field-quiet-extra-large", - "--spectrum-character-count-to-field-quiet-large", - "--spectrum-character-count-to-field-quiet-medium", - "--spectrum-character-count-to-field-quiet-small", + "--spectrum-border-width-200", "--spectrum-checkmark-icon-size-100", "--spectrum-checkmark-icon-size-200", "--spectrum-checkmark-icon-size-300", "--spectrum-checkmark-icon-size-75", + "--spectrum-cjk-line-height-100", "--spectrum-component-bottom-to-text-100", "--spectrum-component-bottom-to-text-200", + "--spectrum-component-bottom-to-text-300", "--spectrum-component-bottom-to-text-75", "--spectrum-component-edge-to-text-100", "--spectrum-component-edge-to-text-200", + "--spectrum-component-edge-to-text-300", "--spectrum-component-edge-to-text-75", "--spectrum-component-height-100", "--spectrum-component-height-200", "--spectrum-component-height-300", "--spectrum-component-height-75", "--spectrum-component-top-to-text-100", + "--spectrum-component-top-to-text-200", + "--spectrum-component-top-to-text-300", + "--spectrum-component-top-to-text-75", "--spectrum-component-top-to-workflow-icon-100", "--spectrum-component-top-to-workflow-icon-200", "--spectrum-component-top-to-workflow-icon-300", "--spectrum-component-top-to-workflow-icon-75", - "--spectrum-corner-radius-100", + "--spectrum-corner-radius-medium-size-extra-large", + "--spectrum-corner-radius-medium-size-large", + "--spectrum-corner-radius-medium-size-medium", + "--spectrum-corner-radius-medium-size-small", + "--spectrum-default-font-style", + "--spectrum-disabled-border-color", "--spectrum-disabled-content-color", + "--spectrum-field-default-width-extra-large", + "--spectrum-field-default-width-large", + "--spectrum-field-default-width-medium", + "--spectrum-field-default-width-small", "--spectrum-field-edge-to-alert-icon-extra-large", "--spectrum-field-edge-to-alert-icon-large", "--spectrum-field-edge-to-alert-icon-medium", - "--spectrum-field-edge-to-alert-icon-quiet", "--spectrum-field-edge-to-alert-icon-small", - "--spectrum-field-edge-to-border-quiet", - "--spectrum-field-edge-to-text-quiet", "--spectrum-field-edge-to-validation-icon-extra-large", "--spectrum-field-edge-to-validation-icon-large", "--spectrum-field-edge-to-validation-icon-medium", - "--spectrum-field-edge-to-validation-icon-quiet", "--spectrum-field-edge-to-validation-icon-small", "--spectrum-field-label-to-component", - "--spectrum-field-label-to-component-quiet-extra-large", - "--spectrum-field-label-to-component-quiet-large", - "--spectrum-field-label-to-component-quiet-medium", - "--spectrum-field-label-to-component-quiet-small", - "--spectrum-field-text-to-alert-icon-extra-large", - "--spectrum-field-text-to-alert-icon-large", - "--spectrum-field-text-to-alert-icon-medium", - "--spectrum-field-text-to-alert-icon-small", - "--spectrum-field-text-to-validation-icon-extra-large", - "--spectrum-field-text-to-validation-icon-large", - "--spectrum-field-text-to-validation-icon-medium", - "--spectrum-field-text-to-validation-icon-small", "--spectrum-field-top-to-validation-icon-extra-large", "--spectrum-field-top-to-validation-icon-large", "--spectrum-field-top-to-validation-icon-medium", @@ -294,11 +277,11 @@ "--spectrum-font-size-75", "--spectrum-gray-25", "--spectrum-gray-300", - "--spectrum-gray-500", - "--spectrum-gray-600", + "--spectrum-gray-400", "--spectrum-gray-800", "--spectrum-gray-900", "--spectrum-help-text-to-component", + "--spectrum-line-height-100", "--spectrum-negative-border-color-default", "--spectrum-negative-border-color-focus", "--spectrum-negative-border-color-focus-hover", @@ -310,56 +293,46 @@ "--spectrum-neutral-content-color-focus-hover", "--spectrum-neutral-content-color-hover", "--spectrum-neutral-content-color-key-focus", + "--spectrum-neutral-subdued-content-color-default", "--spectrum-positive-visual-color", "--spectrum-regular-font-weight", "--spectrum-sans-font-family-stack", "--spectrum-side-label-character-count-to-field", - "--spectrum-side-label-character-count-top-margin-extra-large", - "--spectrum-side-label-character-count-top-margin-large", - "--spectrum-side-label-character-count-top-margin-medium", - "--spectrum-side-label-character-count-top-margin-small", - "--spectrum-spacing-100", "--spectrum-spacing-200", - "--spectrum-texfield-animation-duration", "--spectrum-text-area-min-block-size", - "--spectrum-text-area-min-block-size-quiet", "--spectrum-text-area-min-inline-size", "--spectrum-text-area-minimum-height", "--spectrum-text-area-minimum-width", + "--spectrum-text-to-visual-100", + "--spectrum-text-to-visual-200", + "--spectrum-text-to-visual-300", + "--spectrum-text-to-visual-75", "--spectrum-workflow-icon-size-100", "--spectrum-workflow-icon-size-200", "--spectrum-workflow-icon-size-300", "--spectrum-workflow-icon-size-75" ], - "system-theme": [ - "--system-textfield-background-color", - "--system-textfield-background-color-disabled", - "--system-textfield-border-color", - "--system-textfield-border-color-disabled", - "--system-textfield-border-color-focus", - "--system-textfield-border-color-focus-hover", - "--system-textfield-border-color-hover", - "--system-textfield-border-color-keyboard-focus", - "--system-textfield-border-width", - "--system-textfield-icon-spacing-block-invalid", - "--system-textfield-quiet-border-color-disabled", - "--system-textfield-size-l-icon-spacing-block-invalid", - "--system-textfield-size-s-icon-spacing-block-invalid", - "--system-textfield-size-xl-icon-spacing-block-invalid" - ], "passthroughs": [], "high-contrast": [ + "--highcontrast-textfield-background-color", + "--highcontrast-textfield-background-color-disabled", "--highcontrast-textfield-border-color", + "--highcontrast-textfield-border-color-disabled", "--highcontrast-textfield-border-color-focus", + "--highcontrast-textfield-border-color-focus-hover", "--highcontrast-textfield-border-color-hover", "--highcontrast-textfield-border-color-invalid-default", "--highcontrast-textfield-border-color-invalid-focus", + "--highcontrast-textfield-border-color-invalid-focus-hover", "--highcontrast-textfield-border-color-invalid-hover", "--highcontrast-textfield-border-color-invalid-keyboard-focus", "--highcontrast-textfield-border-color-keyboard-focus", + "--highcontrast-textfield-border-color-readonly", "--highcontrast-textfield-focus-indicator-color", "--highcontrast-textfield-text-color-default", "--highcontrast-textfield-text-color-disabled", + "--highcontrast-textfield-text-color-focus", + "--highcontrast-textfield-text-color-focus-hover", "--highcontrast-textfield-text-color-hover", "--highcontrast-textfield-text-color-invalid", "--highcontrast-textfield-text-color-keyboard-focus", diff --git a/components/textfield/index.css b/components/textfield/index.css index 329672d06a4..1117d3ca174 100644 --- a/components/textfield/index.css +++ b/components/textfield/index.css @@ -11,50 +11,70 @@ * governing permissions and limitations under the License. */ -@import "./themes/spectrum-two.css"; - .spectrum-Textfield { - /* set input line-height to the height of the textfield - prevents the cutting off of diacritics in some languages */ - /* disallow mod for max compatibility */ - --spectrum-textfield-input-line-height: var(--spectrum-textfield-height); - --spectrum-texfield-animation-duration: var(--spectrum-animation-duration-100); + --spectrum-textfield-animation-duration: var(--spectrum-animation-duration-100); - --spectrum-textfield-width: 240px; /* override per api */ - --spectrum-textfield-min-width: var(--spectrum-text-field-minimum-width-multiplier); - --spectrum-textfield-corner-radius: var(--spectrum-corner-radius-100); + /* default height/width/border radius */ + --spectrum-textfield-height: var(--spectrum-component-height-100); + --spectrum-textfield-width: var(--spectrum-field-default-width-medium); + --spectrum-textfield-min-width: calc(var(--spectrum-textfield-height) * var(--spectrum-text-field-minimum-width-multiplier)); + --spectrum-textfield-border-width: var(--spectrum-border-width-200); + --spectrum-textfield-corner-radius: var(--spectrum-corner-radius-medium-size-medium); /* default spacing */ - --spectrum-textfield-spacing-inline-quiet: var(--spectrum-field-edge-to-text-quiet); + --spectrum-textfield-spacing-inline: var(--spectrum-component-edge-to-text-100); --spectrum-textfield-spacing-block-start: var(--spectrum-component-top-to-text-100); --spectrum-textfield-spacing-block-end: var(--spectrum-component-bottom-to-text-100); - --spectrum-textfield-spacing-block-quiet: var(--spectrum-field-edge-to-border-quiet); - /* default label spacing */ + /* default field label and help text spacing */ --spectrum-textfield-label-spacing-block: var(--spectrum-field-label-to-component); - - /* default help text spacing */ + --spectrum-textfield-label-spacing-inline-side-label: var(--spectrum-spacing-200); --spectrum-textfield-helptext-spacing-block: var(--spectrum-help-text-to-component); + /* default icon size */ + --spectrum-textfield-icon-size-invalid: var(--spectrum-workflow-icon-size-100); + --spectrum-textfield-icon-size-valid: var(--spectrum-checkmark-icon-size-100); + /* default icon spacing - invalid */ - --spectrum-textfield-icon-spacing-inline-end-quiet-invalid: var(--spectrum-field-edge-to-alert-icon-quiet); + --spectrum-textfield-icon-spacing-inline-start-invalid: var(--spectrum-text-to-visual-100); + --spectrum-textfield-icon-spacing-inline-end-invalid: var(--spectrum-field-edge-to-alert-icon-medium); + --spectrum-textfield-icon-spacing-block-invalid: var(--spectrum-component-top-to-workflow-icon-100); /* default icon spacing - valid */ - --spectrum-textfield-icon-spacing-inline-end-quiet-valid: var(--spectrum-field-edge-to-validation-icon-quiet); + --spectrum-textfield-icon-spacing-inline-start-valid: var(--spectrum-text-to-visual-100); + --spectrum-textfield-icon-spacing-inline-end-valid: var(--spectrum-field-edge-to-validation-icon-medium); + --spectrum-textfield-icon-spacing-block-valid: var(--spectrum-field-top-to-validation-icon-medium); /* font styles */ --spectrum-textfield-font-family: var(--spectrum-sans-font-family-stack); --spectrum-textfield-font-weight: var(--spectrum-regular-font-weight); + --spectrum-textfield-font-style: var(--spectrum-default-font-style); + --spectrum-textfield-font-size: var(--spectrum-font-size-100); + --spectrum-textfield-line-height: var(--spectrum-line-height-100); + --spectrum-textfield-line-height-cjk: var(--spectrum-cjk-line-height-100); + + /* set input line-height to the height of the textfield - prevents the cutting off of diacritics in some languages */ + --spectrum-textfield-input-line-height: var(--spectrum-textfield-height); /* character count */ - --spectrum-textfield-character-count-font-family: var(--spectrum-sans-font-family-stack); - --spectrum-textfield-character-count-font-weight: var(--spectrum-regular-font-weight); + --spectrum-textfield-character-count-color: var(--spectrum-neutral-subdued-content-color-default); --spectrum-textfield-character-count-spacing-inline: var(--spectrum-spacing-200); + --spectrum-textfield-character-count-spacing-block: var(--spectrum-component-bottom-to-text-100); --spectrum-textfield-character-count-spacing-inline-side: var(--spectrum-side-label-character-count-to-field); + --spectrum-textfield-character-count-spacing-block-side: var(--spectrum-component-top-to-text-100); /* focus indicator */ --spectrum-textfield-focus-indicator-width: var(--spectrum-focus-indicator-thickness); --spectrum-textfield-focus-indicator-gap: var(--spectrum-focus-indicator-gap); + /*** Colors ***/ + --spectrum-textfield-background-color: var(--mod-textfield-background-color, var(--spectrum-gray-25)); + --spectrum-textfield-border-color: var(--spectrum-gray-300); + --spectrum-textfield-border-color-hover: var(--spectrum-gray-400); + --spectrum-textfield-border-color-focus: var(--spectrum-gray-800); + --spectrum-textfield-border-color-focus-hover: var(--spectrum-gray-900); + --spectrum-textfield-border-color-keyboard-focus: var(--spectrum-gray-800); + /* Text Colors */ --spectrum-textfield-text-color-default: var(--spectrum-neutral-content-color-default); --spectrum-textfield-text-color-hover: var(--spectrum-neutral-content-color-hover); @@ -66,6 +86,8 @@ --spectrum-textfield-text-color-readonly: var(--spectrum-neutral-content-color-default); /* Disabled Colors */ + --spectrum-textfield-background-color-disabled: var(--highcontrast-textfield-background-color-disabled, var(--mod-textfield-background-color-disabled, var(--spectrum-gray-25))); + --spectrum-textfield-border-color-disabled: var(--highcontrast-textfield-border-color-disabled, var(--mod-textfield-border-color-disabled, var(--spectrum-disabled-border-color))); --spectrum-textfield-text-color-disabled: var(--spectrum-disabled-content-color); /* Invalid Colors */ @@ -75,7 +97,6 @@ --spectrum-textfield-border-color-invalid-focus-hover: var(--spectrum-negative-border-color-focus-hover); --spectrum-textfield-border-color-invalid-keyboard-focus: var(--spectrum-negative-border-color-key-focus); --spectrum-textfield-icon-color-invalid: var(--spectrum-negative-visual-color); - --spectrum-textfield-text-color-invalid: var(--spectrum-neutral-content-color-default); /* Valid Colors */ @@ -88,94 +109,85 @@ /* Text Area / Multiline */ --spectrum-text-area-min-inline-size: var(--spectrum-text-area-minimum-width); --spectrum-text-area-min-block-size: var(--spectrum-text-area-minimum-height); - - /* Default sizing values: Medium */ - --spectrum-textfield-height: var(--spectrum-component-height-100); - --spectrum-textfield-label-spacing-block-quiet: var(--spectrum-field-label-to-component-quiet-medium); - --spectrum-textfield-label-spacing-inline-side-label: var(--spectrum-spacing-200); - --spectrum-textfield-placeholder-font-size: var(--spectrum-font-size-100); - --spectrum-textfield-spacing-inline: var(--spectrum-component-edge-to-text-100); - --spectrum-textfield-icon-size-invalid: var(--spectrum-workflow-icon-size-100); - --spectrum-textfield-icon-size-valid: var(--spectrum-checkmark-icon-size-100); - --spectrum-textfield-icon-spacing-inline-end-invalid: var(--spectrum-field-edge-to-alert-icon-medium); - --spectrum-textfield-icon-spacing-inline-end-valid: var(--spectrum-field-edge-to-validation-icon-medium); - --spectrum-textfield-icon-spacing-block-valid: var(--spectrum-field-top-to-validation-icon-medium); - --spectrum-textfield-icon-spacing-inline-start-invalid: var(--spectrum-field-text-to-alert-icon-medium); - --spectrum-textfield-icon-spacing-inline-start-valid: var(--spectrum-field-text-to-validation-icon-medium); - --spectrum-textfield-character-count-font-size: var(--spectrum-font-size-75); - --spectrum-textfield-character-count-spacing-block: var(--spectrum-component-bottom-to-text-75); - --spectrum-textfield-character-count-spacing-block-quiet: var(--spectrum-character-count-to-field-quiet-medium); - --spectrum-textfield-character-count-spacing-block-side: var(--spectrum-side-label-character-count-top-margin-medium); - - /* Text Area / Multiline size medium */ - --spectrum-text-area-min-block-size-quiet: var(--spectrum-component-height-100); } /********* Text field t-shirt sizes *********/ .spectrum-Textfield--sizeS { --spectrum-textfield-height: var(--spectrum-component-height-75); - --spectrum-textfield-label-spacing-block-quiet: var(--spectrum-field-label-to-component-quiet-small); - --spectrum-textfield-label-spacing-inline-side-label: var(--spectrum-spacing-100); - --spectrum-textfield-placeholder-font-size: var(--spectrum-font-size-75); + --spectrum-textfield-width: var(--spectrum-field-default-width-small); + --spectrum-textfield-corner-radius: var(--spectrum-corner-radius-medium-size-small); + --spectrum-textfield-spacing-inline: var(--spectrum-component-edge-to-text-75); + --spectrum-textfield-spacing-block-start: var(--spectrum-component-top-to-text-75); + --spectrum-textfield-spacing-block-end: var(--spectrum-component-bottom-to-text-75); + --spectrum-textfield-icon-size-invalid: var(--spectrum-workflow-icon-size-75); --spectrum-textfield-icon-size-valid: var(--spectrum-checkmark-icon-size-75); + + --spectrum-textfield-icon-spacing-inline-start-invalid: var(--spectrum-text-to-visual-75); --spectrum-textfield-icon-spacing-inline-end-invalid: var(--spectrum-field-edge-to-alert-icon-small); + --spectrum-textfield-icon-spacing-block-invalid: var(--spectrum-component-top-to-workflow-icon-75); + + --spectrum-textfield-icon-spacing-inline-start-valid: var(--spectrum-text-to-visual-75); --spectrum-textfield-icon-spacing-inline-end-valid: var(--spectrum-field-edge-to-validation-icon-small); --spectrum-textfield-icon-spacing-block-valid: var(--spectrum-field-top-to-validation-icon-small); - --spectrum-textfield-icon-spacing-inline-start-invalid: var(--spectrum-field-text-to-alert-icon-small); - --spectrum-textfield-icon-spacing-inline-start-valid: var(--spectrum-field-text-to-validation-icon-small); - --spectrum-textfield-character-count-font-size: var(--spectrum-font-size-75); - --spectrum-textfield-character-count-spacing-block: var(--spectrum-component-bottom-to-text-75); - --spectrum-textfield-character-count-spacing-block-quiet: var(--spectrum-character-count-to-field-quiet-small); - --spectrum-textfield-character-count-spacing-block-side: var(--spectrum-side-label-character-count-top-margin-small); - /* Text Area / Multiline size small */ - --spectrum-text-area-min-block-size-quiet: var(--spectrum-component-height-75); + --spectrum-textfield-font-size: var(--spectrum-font-size-75); + + --spectrum-textfield-character-count-spacing-block: var(--spectrum-component-bottom-to-text-75); + --spectrum-textfield-character-count-spacing-block-side: var(--spectrum-component-top-to-text-75); } .spectrum-Textfield--sizeL { --spectrum-textfield-height: var(--spectrum-component-height-200); - --spectrum-textfield-label-spacing-block-quiet: var(--spectrum-field-label-to-component-quiet-large); - --spectrum-textfield-label-spacing-inline-side-label: var(--spectrum-spacing-200); - --spectrum-textfield-placeholder-font-size: var(--spectrum-font-size-200); + --spectrum-textfield-width: var(--spectrum-field-default-width-large); + --spectrum-textfield-corner-radius: var(--spectrum-corner-radius-medium-size-large); + --spectrum-textfield-spacing-inline: var(--spectrum-component-edge-to-text-200); + --spectrum-textfield-spacing-block-start: var(--spectrum-component-top-to-text-200); + --spectrum-textfield-spacing-block-end: var(--spectrum-component-bottom-to-text-200); + --spectrum-textfield-icon-size-invalid: var(--spectrum-workflow-icon-size-200); --spectrum-textfield-icon-size-valid: var(--spectrum-checkmark-icon-size-200); + + --spectrum-textfield-icon-spacing-inline-start-invalid: var(--spectrum-text-to-visual-200); --spectrum-textfield-icon-spacing-inline-end-invalid: var(--spectrum-field-edge-to-alert-icon-large); + --spectrum-textfield-icon-spacing-block-invalid: var(--spectrum-component-top-to-workflow-icon-200); + + --spectrum-textfield-icon-spacing-inline-start-valid: var(--spectrum-text-to-visual-200); --spectrum-textfield-icon-spacing-inline-end-valid: var(--spectrum-field-edge-to-validation-icon-large); --spectrum-textfield-icon-spacing-block-valid: var(--spectrum-field-top-to-validation-icon-large); - --spectrum-textfield-icon-spacing-inline-start-invalid: var(--spectrum-field-text-to-alert-icon-large); - --spectrum-textfield-icon-spacing-inline-start-valid: var(--spectrum-field-text-to-validation-icon-large); - --spectrum-textfield-character-count-font-size: var(--spectrum-font-size-100); - --spectrum-textfield-character-count-spacing-block: var(--spectrum-component-bottom-to-text-100); - --spectrum-textfield-character-count-spacing-block-quiet: var(--spectrum-character-count-to-field-quiet-large); - --spectrum-textfield-character-count-spacing-block-side: var(--spectrum-side-label-character-count-top-margin-large); - /* Text Area / Multiline size large */ - --spectrum-text-area-min-block-size-quiet: var(--spectrum-component-height-200); + --spectrum-textfield-font-size: var(--spectrum-font-size-200); + + --spectrum-textfield-character-count-spacing-block: var(--spectrum-component-bottom-to-text-200); + --spectrum-textfield-character-count-spacing-block-side: var(--spectrum-component-top-to-text-200); } .spectrum-Textfield--sizeXL { --spectrum-textfield-height: var(--spectrum-component-height-300); - --spectrum-textfield-label-spacing-block-quiet: var(--spectrum-field-label-to-component-quiet-extra-large); - --spectrum-textfield-label-spacing-inline-side-label: var(--spectrum-spacing-200); - --spectrum-textfield-placeholder-font-size: var(--spectrum-font-size-300); - --spectrum-textfield-spacing-inline: var(--spectrum-component-edge-to-text-200); + --spectrum-textfield-width: var(--spectrum-field-default-width-extra-large); + --spectrum-textfield-corner-radius: var(--spectrum-corner-radius-medium-size-extra-large); + + --spectrum-textfield-spacing-inline: var(--spectrum-component-edge-to-text-300); + --spectrum-textfield-spacing-block-start: var(--spectrum-component-top-to-text-300); + --spectrum-textfield-spacing-block-end: var(--spectrum-component-bottom-to-text-300); + --spectrum-textfield-icon-size-invalid: var(--spectrum-workflow-icon-size-300); --spectrum-textfield-icon-size-valid: var(--spectrum-checkmark-icon-size-300); + + --spectrum-textfield-icon-spacing-inline-start-invalid: var(--spectrum-text-to-visual-300); --spectrum-textfield-icon-spacing-inline-end-invalid: var(--spectrum-field-edge-to-alert-icon-extra-large); + --spectrum-textfield-icon-spacing-block-invalid: var(--spectrum-component-top-to-workflow-icon-300); + + --spectrum-textfield-icon-spacing-inline-start-valid: var(--spectrum-text-to-visual-300); --spectrum-textfield-icon-spacing-inline-end-valid: var(--spectrum-field-edge-to-validation-icon-extra-large); --spectrum-textfield-icon-spacing-block-valid: var(--spectrum-field-top-to-validation-icon-extra-large); - --spectrum-textfield-icon-spacing-inline-start-invalid: var(--spectrum-field-text-to-alert-icon-extra-large); - --spectrum-textfield-icon-spacing-inline-start-valid: var(--spectrum-field-text-to-validation-icon-extra-large); - --spectrum-textfield-character-count-font-size: var(--spectrum-font-size-200); - --spectrum-textfield-character-count-spacing-block: var(--spectrum-component-bottom-to-text-200); - --spectrum-textfield-character-count-spacing-block-quiet: var(--spectrum-character-count-to-field-quiet-extra-large); - --spectrum-textfield-character-count-spacing-block-side: var(--spectrum-side-label-character-count-top-margin-extra-large); - /* Text Area / Multiline size extra large */ - --spectrum-text-area-min-block-size-quiet: var(--spectrum-component-height-300); + --spectrum-textfield-font-size: var(--spectrum-font-size-300); + + --spectrum-textfield-character-count-spacing-block: var(--spectrum-component-bottom-to-text-300); + --spectrum-textfield-character-count-spacing-block-side: var(--spectrum-component-top-to-text-300); } /********* TEXT FIELD and TEXT AREA Outer Wrapper *********/ @@ -219,6 +231,7 @@ /****** Validation Icon - Valid ✅ ******/ .spectrum-Textfield.is-valid & { + /* validation icon does not need to account for border width */ inset-block-start: var(--mod-textfield-icon-spacing-block-valid, var(--spectrum-textfield-icon-spacing-block-valid)); inset-block-end: var(--mod-textfield-icon-spacing-block-valid, var(--spectrum-textfield-icon-spacing-block-valid)); inset-inline-end: var(--mod-textfield-icon-spacing-inline-end-valid, var(--spectrum-textfield-icon-spacing-inline-end-valid)); @@ -228,6 +241,8 @@ /****** Validation Icon - Invalid ⚠️ ******/ .spectrum-Textfield.is-invalid & { block-size: var(--mod-textfield-icon-size-invalid, var(--spectrum-textfield-icon-size-invalid)); + + /* validation icon does not need to account for border width */ inline-size: var(--mod-textfield-icon-size-invalid, var(--spectrum-textfield-icon-size-invalid)); inset-block-start: var(--mod-textfield-icon-spacing-block-invalid, var(--spectrum-textfield-icon-spacing-block-invalid)); inset-block-end: var(--mod-textfield-icon-spacing-block-invalid, var(--spectrum-textfield-icon-spacing-block-invalid)); @@ -240,18 +255,6 @@ /* Disabled validation icons are transparent */ color: transparent; } - - .spectrum-Textfield--quiet & { - padding-inline-end: 0; - } - - .spectrum-Textfield--quiet.is-valid & { - inset-inline-end: var(--mod-textfield-icon-spacing-inline-end-quiet-valid, var(--spectrum-textfield-icon-spacing-inline-end-quiet-valid)); - } - - .spectrum-Textfield--quiet.is-invalid & { - inset-inline-end: var(--mod-textfield-icon-spacing-inline-end-quiet-invalid, var(--spectrum-textfield-icon-spacing-inline-end-quiet-invalid)); - } } /********* Child Component - Label *********/ @@ -262,24 +265,27 @@ grid-column: 1 / span 1; } - .spectrum-Textfield--quiet & { - margin-block-end: var(--mod-textfield-label-spacing-block-quiet, var(--spectrum-textfield-label-spacing-block-quiet)); - } - .spectrum-Textfield.is-disabled & { - color: var(--spectrum-textfield-text-color-disabled); + color: var(--highcontrast-textfield-text-color-disabled, var(--mod-textfield-text-color-disabled, var(--spectrum-textfield-text-color-disabled))); } } /********* Child Component - Help Text *********/ -.spectrum-Textfield .spectrum-HelpText { - margin-block-start: var(--mod-textfield-helptext-spacing-block, var(--spectrum-textfield-helptext-spacing-block)); - grid-row: 3; - grid-column: 1 / span 2; +.spectrum-HelpText { + .spectrum-Textfield & { + margin-block-start: var(--mod-textfield-helptext-spacing-block, var(--spectrum-textfield-helptext-spacing-block)); + grid-row: 3; + grid-column: 1 / span 2; + } + + .spectrum-Textfield.is-disabled & .spectrum-HelpText-text { + color: var(--highcontrast-textfield-text-color-disabled, var(--mod-textfield-text-color-disabled, var(--spectrum-textfield-text-color-disabled))); + } } /********* Child Element - Character Count *********/ .spectrum-Textfield-characterCount { + color: var(--mod-textfield-character-count-color, var(--spectrum-textfield-character-count-color)); display: inline-flex; align-items: flex-end; justify-content: flex-end; @@ -287,15 +293,23 @@ margin-block-end: var(--mod-textfield-character-count-spacing-block, var(--spectrum-textfield-character-count-spacing-block)); margin-inline-start: var(--mod-textfield-character-count-spacing-inline, var(--spectrum-textfield-character-count-spacing-inline)); margin-inline-end: 0; - font-size: var(--mod-textfield-character-count-font-size, var(--spectrum-textfield-character-count-font-size)); - font-family: var(--mod-textfield-character-count-font-family, var(--spectrum-textfield-character-count-font-family)); - font-weight: var(--mod-textfield-character-count-font-weight, var(--spectrum-textfield-character-count-font-weight)); + font-size: var(--mod-textfield-font-size, var(--spectrum-textfield-font-size)); + font-family: var(--mod-textfield-font-family, var(--spectrum-textfield-font-family)); + font-weight: var(--mod-textfield-font-weight, var(--spectrum-textfield-font-weight)); + font-style: var(--mod-textfield-font-style, var(--spectrum-textfield-font-style)); + line-height: var(--mod-textfield-line-height, var(--spectrum-textfield-line-height)); grid-row: 1; grid-column: 2 / span 1; padding-inline-end: calc(var(--mod-textfield-corner-radius, var(--spectrum-textfield-corner-radius)) / 2); - .spectrum-Textfield--quiet & { - margin-block-end: var(--mod-textfield-character-count-spacing-block-quiet, var(--spectrum-textfield-character-count-spacing-block-quiet)); + .spectrum-Textfield.is-disabled & { + color: var(--highcontrast-textfield-text-color-disabled, var(--mod-textfield-text-color-disabled, var(--spectrum-textfield-text-color-disabled))); + } + + &:lang(ja), + &:lang(zh), + &:lang(ko) { + --spectrum-textfield-line-height: var(--mod-textfield-line-height-cjk, var(--spectrum-textfield-line-height-cjk)); } } @@ -309,21 +323,21 @@ block-size: var(--mod-textfield-height, var(--spectrum-textfield-height)); padding-block-start: calc(var(--mod-textfield-spacing-block-start, var(--spectrum-textfield-spacing-block-start)) - var(--mod-textfield-border-width, var(--spectrum-textfield-border-width))); padding-block-end: calc(var(--mod-textfield-spacing-block-end, var(--spectrum-textfield-spacing-block-end)) - var(--mod-textfield-border-width, var(--spectrum-textfield-border-width))); - padding-inline: calc(var(--mod-textfield-spacing-inline, var(--spectrum-textfield-spacing-inline)) - var(--mod-textfield-border-width, var(--spectrum-textfield-border-width))); vertical-align: top; /* used to align them correctly in forms. */ outline: none; - background-color: var(--mod-textfield-background-color, var(--spectrum-textfield-background-color)); + background-color: var(--highcontrast-textfield-background-color, var(--spectrum-textfield-background-color)); border-width: var(--mod-textfield-border-width, var(--spectrum-textfield-border-width)); border-style: solid; border-color: var(--highcontrast-textfield-border-color, var(--mod-textfield-border-color, var(--spectrum-textfield-border-color))); border-radius: var(--mod-textfield-corner-radius, var(--spectrum-textfield-corner-radius)); - transition: border-color var(--mod-texfield-animation-duration, var(--spectrum-texfield-animation-duration)) ease-in-out; + transition: border-color var(--mod-textfield-animation-duration, var(--spectrum-textfield-animation-duration)) ease-in-out; - font-size: var(--mod-textfield-placeholder-font-size, var(--spectrum-textfield-placeholder-font-size)); + font-size: var(--mod-textfield-font-size, var(--spectrum-textfield-font-size)); font-family: var(--mod-textfield-font-family, var(--spectrum-textfield-font-family)); font-weight: var(--mod-textfield-font-weight, var(--spectrum-textfield-font-weight)); + font-style: var(--mod-textfield-font-style, var(--spectrum-textfield-font-style)); color: var(--highcontrast-textfield-text-color-default, var(--mod-textfield-text-color-default, var(--spectrum-textfield-text-color-default))); text-overflow: ellipsis; @@ -331,6 +345,9 @@ grid-row: 2; grid-column: 1 / span 2; + /* prevents unexpected color changes for border in high contrast mode */ + forced-color-adjust: none; + /*** ↓ Browser Mitigations for Input ↓ ***/ /* Firefox and Safari - Remove the margin for input. */ margin: 0; @@ -357,20 +374,12 @@ &::placeholder { /* Normalize opacity between browsers. */ opacity: 1; - font-size: var(--mod-textfield-placeholder-font-size, var(--spectrum-textfield-placeholder-font-size)); + font-size: var(--mod-textfield-font-size, var(--spectrum-textfield-font-size)); font-family: var(--mod-textfield-font-family, var(--spectrum-textfield-font-family)); font-weight: var(--mod-textfield-font-weight, var(--spectrum-textfield-font-weight)); + font-style: var(--mod-textfield-font-style, var(--spectrum-textfield-font-style)); color: var(--highcontrast-textfield-text-color-default, var(--mod-textfield-text-color-default, var(--spectrum-textfield-text-color-default))); - transition: color var(--mod-texfield-animation-duration, var(--spectrum-texfield-animation-duration)) ease-in-out; - } - - /*** Input Placeholder Text - CJK ***/ - &:lang(ja), - &:lang(zh), - &:lang(ko) { - &::placeholder { - font-style: normal; - } + transition: color var(--mod-textfield-animation-duration, var(--spectrum-textfield-animation-duration)) ease-in-out; } /* hover */ @@ -385,28 +394,41 @@ } /* mouse focus */ - .is-focused &, + .spectrum-Textfield.is-focused &, &:focus { border-color: var(--highcontrast-textfield-border-color-focus, var(--mod-textfield-border-color-focus, var(--spectrum-textfield-border-color-focus))); - color: var(--mod-textfield-text-color-focus, var(--spectrum-textfield-text-color-focus)); + color: var(--highcontrast-textfield-text-color-focus, var(--mod-textfield-text-color-focus, var(--spectrum-textfield-text-color-focus))); &::placeholder { - color: var(--mod-textfield-text-color-focus, var(--spectrum-textfield-text-color-focus)); + color: var(--highcontrast-textfield-text-color-focus, var(--mod-textfield-text-color-focus, var(--spectrum-textfield-text-color-focus))); } /* focus hover */ &:hover { - border-color: var(--mod-textfield-border-color-focus-hover, var(--spectrum-textfield-border-color-focus-hover)); - color: var(--mod-textfield-text-color-focus-hover, var(--spectrum-textfield-text-color-focus-hover)); + border-color: var(--highcontrast-textfield-border-color-focus-hover, var(--mod-textfield-border-color-focus-hover, var(--spectrum-textfield-border-color-focus-hover))); + color: var(--highcontrast-textfield-text-color-focus-hover, var(--mod-textfield-text-color-focus-hover, var(--spectrum-textfield-text-color-focus-hover))); + + &::placeholder { + color: var(--highcontrast-textfield-text-color-focus-hover, var(--mod-textfield-text-color-focus-hover, var(--spectrum-textfield-text-color-focus-hover))); + } } + } + + /* focus hover */ + .spectrum-Textfield:focus:hover &, + .spectrum-Textfield.is-focused:hover &, + .spectrum-Textfield.is-keyboardFocused:hover &, + &:focus:hover { + border-color: var(--highcontrast-textfield-border-color-focus-hover, var(--mod-textfield-border-color-focus-hover, var(--spectrum-textfield-border-color-focus-hover))); + color: var(--highcontrast-textfield-text-color-focus-hover, var(--mod-textfield-text-color-focus-hover, var(--spectrum-textfield-text-color-focus-hover))); - &:hover::placeholder { - color: var(--mod-textfield-text-color-focus-hover, var(--spectrum-textfield-text-color-focus-hover)); + &::placeholder { + color: var(--highcontrast-textfield-text-color-focus-hover, var(--mod-textfield-text-color-focus-hover, var(--spectrum-textfield-text-color-focus-hover))); } } /* keyboard focus */ - .is-keyboardFocused & { + .spectrum-Textfield.is-keyboardFocused & { border-color: var(--highcontrast-textfield-border-color-keyboard-focus, var(--mod-textfield-border-color-keyboard-focus, var(--spectrum-textfield-border-color-keyboard-focus))); color: var(--highcontrast-textfield-text-color-keyboard-focus, var(--mod-textfield-text-color-keyboard-focus, var(--spectrum-textfield-text-color-keyboard-focus))); @@ -421,39 +443,46 @@ } /*** Input Valid ✅ ***/ - .is-valid & { + .spectrum-Textfield.is-valid & { + /* creates spacing between text end and icon start, sum of icon start spacing + icon size + icon end spacing - border */ padding-inline-end: calc(var(--mod-textfield-icon-spacing-inline-start-valid, var(--spectrum-textfield-icon-spacing-inline-start-valid)) + var(--mod-textfield-icon-size-valid, var(--spectrum-textfield-icon-size-valid)) + var(--mod-textfield-icon-spacing-inline-end-valid, var(--spectrum-textfield-icon-spacing-inline-end-valid)) - var(--mod-textfield-border-width, var(--spectrum-textfield-border-width))); color: var(--highcontrast-textfield-text-color-valid, var(--mod-textfield-text-color-valid, var(--spectrum-textfield-text-color-valid))); } /*** Input Invalid ⚠️ ***/ - .is-invalid & { + .spectrum-Textfield.is-invalid & { + /* creates spacing between text end and icon start, sum of icon start spacing + icon size + icon end spacing - border */ padding-inline-end: calc(var(--mod-textfield-icon-spacing-inline-start-invalid, var(--spectrum-textfield-icon-spacing-inline-start-invalid)) + var(--mod-textfield-icon-size-invalid, var(--spectrum-textfield-icon-size-invalid)) + var(--mod-textfield-icon-spacing-inline-end-invalid, var(--spectrum-textfield-icon-spacing-inline-end-invalid)) - var(--mod-textfield-border-width, var(--spectrum-textfield-border-width))); color: var(--highcontrast-textfield-text-color-invalid, var(--mod-textfield-text-color-invalid, var(--spectrum-textfield-text-color-invalid))); border-color: var(--highcontrast-textfield-border-color-invalid-default, var(--mod-textfield-border-color-invalid-default, var(--spectrum-textfield-border-color-invalid-default))); } /* Invalid hover */ - .is-invalid:hover:not(.is-disabled) &, - .is-invalid &:hover:not(.is-disabled) { + .spectrum-Textfield.is-invalid:hover:not(.is-disabled, .is-readOnly) &, + .spectrum-Textfield.is-invalid:not(.is-disabled, .is-readOnly) &:hover { border-color: var(--highcontrast-textfield-border-color-invalid-hover, var(--mod-textfield-border-color-invalid-hover, var(--spectrum-textfield-border-color-invalid-hover))); } /* Invalid mouse focus */ - .is-invalid.is-focused &, - .is-invalid:focus &, - .is-invalid &:focus { + .spectrum-Textfield.is-invalid.is-focused &, + .spectrum-Textfield.is-invalid:focus &, + .spectrum-Textfield.is-invalid &:focus { border-color: var(--highcontrast-textfield-border-color-invalid-focus, var(--mod-textfield-border-color-invalid-focus, var(--spectrum-textfield-border-color-invalid-focus))); /* focus hover */ &:hover { - border-color: var(--mod-textfield-border-color-invalid-focus-hover, var(--spectrum-textfield-border-color-invalid-focus-hover)); + border-color: var(--highcontrast-textfield-border-color-invalid-focus-hover, var(--mod-textfield-border-color-invalid-focus-hover, var(--spectrum-textfield-border-color-invalid-focus-hover))); } } + .spectrum-Textfield.is-invalid:focus:hover &, + .spectrum-Textfield.is-invalid.is-focused:hover &, + .spectrum-Textfield.is-invalid.is-keyboardFocused:hover & { + border-color: var(--highcontrast-textfield-border-color-invalid-focus-hover, var(--mod-textfield-border-color-invalid-focus-hover, var(--spectrum-textfield-border-color-invalid-focus-hover))); + } + /* invalid keyboard focus */ - .is-invalid.is-keyboardFocused &, - .is-invalid &:focus-visible { + .spectrum-Textfield.is-invalid.is-keyboardFocused & { border-color: var(--highcontrast-textfield-border-color-invalid-keyboard-focus, var(--mod-textfield-border-color-invalid-keyboard-focus, var(--spectrum-textfield-border-color-invalid-keyboard-focus))); } @@ -461,8 +490,8 @@ .spectrum-Textfield.is-disabled &, .spectrum-Textfield.is-disabled:hover &, &:disabled { - background-color: var(--mod-textfield-background-color-disabled, var(--spectrum-textfield-background-color-disabled)); - border-color: var(--mod-textfield-border-color-disabled, var(--spectrum-textfield-border-color-disabled)); + background-color: var(--spectrum-textfield-background-color-disabled); + border-color: var(--spectrum-textfield-border-color-disabled); color: var(--highcontrast-textfield-text-color-disabled, var(--mod-textfield-text-color-disabled, var(--spectrum-textfield-text-color-disabled))); /* Disable the resize functionality when disabled */ @@ -476,50 +505,31 @@ } } - /****** Input - Quiet 🤫 ******/ - .spectrum-Textfield--quiet & { - outline: none; - border-block-start-width: 0; - border-inline-width: 0; - - margin-block-end: var(--mod-textfield-spacing-block-quiet, var(--spectrum-textfield-spacing-block-quiet)); - padding-block-start: var(--mod-textfield-spacing-block-start, var(--spectrum-textfield-spacing-block-start)); - padding-inline: var(--mod-textfield-spacing-inline-quiet, var(--spectrum-textfield-spacing-inline-quiet)); - background-color: transparent; - border-radius: 0; - - /* Treat all quiet inputs and text areas the same */ - resize: none; - overflow-y: hidden; - } - - /****** Input - Quiet 🤫 + Disabled 🚫 ******/ - .spectrum-Textfield--quiet.is-disabled &, - .spectrum-Textfield--quiet.is-disabled:hover &, - &:disabled { - background-color: transparent; - border-color: var(--mod-textfield-border-color-disabled, var(--spectrum-textfield-border-color-disabled)); - color: var(--highcontrast-textfield-text-color-disabled, var(--mod-textfield-text-color-disabled, var(--spectrum-textfield-text-color-disabled))); - - &::placeholder { - color: var(--highcontrast-textfield-text-color-disabled, var(--mod-textfield-text-color-disabled, var(--spectrum-textfield-text-color-disabled))); - } - } - /****** Input ReadOnly ******/ .spectrum-Textfield.is-readOnly &, .spectrum-Textfield.is-readOnly:hover &, &:read-only { background-color: transparent; - border-color: transparent; + border-color: var(--highcontrast-textfield-border-color-readonly, transparent); color: var(--highcontrast-textfield-text-color-readonly, var(--mod-textfield-text-color-readonly, var(--spectrum-textfield-text-color-readonly))); outline: none; &::placeholder { color: var(--highcontrast-textfield-text-color-readonly, var(--mod-textfield-text-color-readonly, var(--spectrum-textfield-text-color-readonly))); background-color: transparent; + + .spectrum-Textfield.is-disabled &, + .spectrum-Textfield.is-disabled:hover & { + color: var(--highcontrast-textfield-text-color-disabled, var(--mod-textfield-text-color-disabled, var(--spectrum-textfield-text-color-disabled))); + } } } + + /****** ReadOnly & Disabled ******/ + .spectrum-Textfield.is-readOnly.is-disabled & { + border-color: var(--highcontrast-textfield-border-color-disabled, transparent); + color: var(--highcontrast-textfield-text-color-disabled, var(--mod-textfield-text-color-disabled, var(--spectrum-textfield-text-color-disabled))); + } } /*** Layout Variant - Side Label ***/ @@ -527,12 +537,6 @@ grid-template-columns: auto auto auto; grid-template-rows: auto auto; - /*** Focus Indicator ***/ - &::after { - grid-row: 1 / span 1; - grid-column: 2 / span 1; - } - .spectrum-FieldLabel { margin-inline-end: var(--mod-textfield-label-spacing-inline-side-label, var(--spectrum-textfield-label-spacing-inline-side-label)); grid-row: 1 / span 2; @@ -565,12 +569,17 @@ /*** Text Area ***/ .spectrum-Textfield--multiline { - --spectrum-textfield-input-line-height: normal; - .spectrum-Textfield-input { + line-height: var(--mod-textfield-line-height, var(--spectrum-textfield-line-height)); min-inline-size: var(--mod-text-area-min-inline-size, var(--spectrum-text-area-min-inline-size)); min-block-size: var(--mod-text-area-min-block-size, var(--spectrum-text-area-min-block-size)); resize: inherit; + + &:lang(ja), + &:lang(zh), + &:lang(ko) { + --spectrum-textfield-line-height: var(--mod-textfield-line-height-cjk, var(--spectrum-textfield-line-height-cjk)); + } } &.spectrum-Textfield--grows { @@ -582,40 +591,6 @@ grid-row: 1 / auto; } } - - &.spectrum-Textfield--quiet .spectrum-Textfield-input { - min-block-size: var(--mod-text-area-min-block-size-quiet, var(--spectrum-text-area-min-block-size-quiet)); - - /* Treat all quiet inputs and text areas the same */ - resize: none; - overflow-y: hidden; - } -} - -.spectrum-Textfield--quiet { - &::after { - content: ""; - pointer-events: none; - position: absolute; - inset-block-end: calc(-1 * (var(--mod-textfield-focus-indicator-gap, var(--spectrum-textfield-focus-indicator-gap)) + var(--mod-textfield-focus-indicator-width, var(--spectrum-textfield-focus-indicator-width)))); - inset-inline-start: 0; - inline-size: 100%; - block-size: var(--mod-textfield-focus-indicator-width, var(--spectrum-textfield-focus-indicator-width)); - } - - &.is-keyboardFocused::after { - background-color: var(--highcontrast-textfield-focus-indicator-color, var(--mod-textfield-focus-indicator-color, var(--spectrum-textfield-focus-indicator-color))); - } - - /*** Quiet Input Invalid ⚠️ ***/ - &.is-invalid .spectrum-Textfield-input { - padding-inline-end: calc(var(--mod-textfield-icon-spacing-inline-start-invalid, var(--spectrum-textfield-icon-spacing-inline-start-invalid)) + var(--mod-textfield-icon-size-invalid, var(--spectrum-textfield-icon-size-invalid))); - } - - /*** Quiet Input Valid ✅ ***/ - &.is-valid .spectrum-Textfield-input { - padding-inline-end: calc(var(--mod-textfield-icon-spacing-inline-start-valid, var(--spectrum-textfield-icon-spacing-inline-start-valid)) + var(--mod-textfield-icon-size-valid, var(--spectrum-textfield-icon-size-valid))); - } } /********* WHCM *********/ @@ -624,31 +599,33 @@ --highcontrast-textfield-border-color: CanvasText; --highcontrast-textfield-border-color-hover: Highlight; --highcontrast-textfield-border-color-focus: Highlight; - --highcontrast-textfield-border-color-keyboard-focus: CanvasText; + --highcontrast-textfield-border-color-keyboard-focus: Highlight; + --highcontrast-textfield-border-color-focus-hover: Highlight; --highcontrast-textfield-focus-indicator-color: Highlight; + --highcontrast-textfield-background-color: Canvas; + + --highcontrast-textfield-background-color-disabled: Canvas; + --highcontrast-textfield-border-color-disabled: GrayText; + + --highcontrast-textfield-border-color-readonly: CanvasText; --highcontrast-textfield-border-color-invalid-default: Highlight; --highcontrast-textfield-border-color-invalid-hover: Highlight; --highcontrast-textfield-border-color-invalid-focus: Highlight; --highcontrast-textfield-border-color-invalid-keyboard-focus: Highlight; + --highcontrast-textfield-border-color-invalid-focus-hover: Highlight; - --highcontrast-textfield-text-color-valid: CanvasText; - --highcontrast-textfield-text-color-invalid: CanvasText; - - .spectrum-Textfield-input { + &, + .spectrum-Textfield-input::placeholder { + --highcontrast-textfield-text-color-valid: CanvasText; + --highcontrast-textfield-text-color-invalid: CanvasText; --highcontrast-textfield-text-color-default: CanvasText; --highcontrast-textfield-text-color-hover: CanvasText; + --highcontrast-textfield-text-color-focus: CanvasText; + --highcontrast-textfield-text-color-focus-hover: CanvasText; --highcontrast-textfield-text-color-keyboard-focus: CanvasText; --highcontrast-textfield-text-color-disabled: GrayText; --highcontrast-textfield-text-color-readonly: CanvasText; - - &::placeholder { - --highcontrast-textfield-text-color-default: GrayText; - --highcontrast-textfield-text-color-hover: GrayText; - --highcontrast-textfield-text-color-keyboard-focus: GrayText; - --highcontrast-textfield-text-color-disabled: GrayText; - --highcontrast-textfield-text-color-readonly: CanvasText; - } } } } diff --git a/components/textfield/package.json b/components/textfield/package.json index 89bcd78bb76..a1b1d1d70d4 100644 --- a/components/textfield/package.json +++ b/components/textfield/package.json @@ -1,6 +1,6 @@ { "name": "@spectrum-css/textfield", - "version": "8.2.0", + "version": "9.0.0-next.1", "description": "The Spectrum CSS textfield component", "license": "Apache-2.0", "author": "Adobe", @@ -19,15 +19,13 @@ "./package.json": "./package.json", "./dist/*": "./dist/*", "./index.css": "./dist/index.css", - "./index-*.css": "./dist/index-*.css", "./metadata.json": "./dist/metadata.json", - "./themes/*": "./dist/themes/*", "./stories/*": "./stories/*" }, "main": "dist/index.css", "peerDependencies": { - "@spectrum-css/helptext": ">=7.0.0 <8.0.0", - "@spectrum-css/tokens": ">=16.0.0 <17.0.0" + "@spectrum-css/helptext": ">=8.0.0-next.0", + "@spectrum-css/tokens": ">=16.1.0-next.0" }, "peerDependenciesMeta": { "@spectrum-css/helptext": { @@ -38,8 +36,8 @@ } }, "devDependencies": { - "@spectrum-css/helptext": "7.2.0", - "@spectrum-css/tokens": "16.0.2" + "@spectrum-css/helptext": "8.0.0-next.2", + "@spectrum-css/tokens": "16.1.0-next.10" }, "keywords": [ "design-system", diff --git a/components/textfield/stories/template.js b/components/textfield/stories/template.js index 5f20b0abb86..22d119703e8 100644 --- a/components/textfield/stories/template.js +++ b/components/textfield/stories/template.js @@ -1,8 +1,8 @@ import { Template as FieldLabel } from "@spectrum-css/fieldlabel/stories/template.js"; import { Template as HelpText } from "@spectrum-css/helptext/stories/template.js"; import { Template as Icon } from "@spectrum-css/icon/stories/template.js"; +import { Template as InfieldProgressCircle } from "@spectrum-css/infieldprogresscircle/stories/template.js"; import { Container, getRandomId } from "@spectrum-css/preview/decorators"; -import { Template as ProgressCircle } from "@spectrum-css/progresscircle/stories/template.js"; import { html } from "lit"; import { classMap } from "lit/directives/class-map.js"; import { ifDefined } from "lit/directives/if-defined.js"; @@ -10,9 +10,6 @@ import { styleMap } from "lit/directives/style-map.js"; import { when } from "lit/directives/when.js"; import "../index.css"; -import "../themes/spectrum.css"; -/* Must be imported last */ -import "../themes/express.css"; /** * @typedef API @@ -21,13 +18,12 @@ import "../themes/express.css"; * @property {string[]} [customClasses=[]] * @property {string[]} [customInputClasses=[]] * @property {string[]} [customIconClasses=[]] - * @property {string[]} [customProgressCircleClasses=[]] + * @property {string[]} [customInfieldProgressCircleClasses=[]] * @property {Record} [customStyles={}] * @property {boolean} [isInvalid=false] * @property {boolean} [isValid=false] * @property {boolean} [multiline=false] * @property {boolean} [grows=false] - * @property {boolean} [isQuiet=false] * @property {boolean} [isFocused=false] * @property {boolean} [isDisabled=false] * @property {boolean} [isRequired=false] @@ -61,27 +57,29 @@ export const Template = ({ customClasses = [], customInputClasses = [], customIconClasses = [], - customProgressCircleClasses = [], + customInfieldProgressCircleClasses = [], isInvalid = false, isValid = false, multiline = false, grows = false, - isQuiet = false, isFocused = false, isDisabled = false, + isHovered = false, isRequired = false, + isRequiredWithoutAsterisk = false, isReadOnly = false, isKeyboardFocused = false, isLoading = false, - displayLabel = false, + displayLabel, labelPosition = "top", labelText, characterCount, iconName, - iconSet, + iconSet = "workflow", pattern, placeholder, name, + step, helpText = "", id = getRandomId("textfield"), value = "", @@ -94,12 +92,17 @@ export const Template = ({ // Override icon name and set if the field is invalid or valid if (isInvalid) { - iconName = "Alert"; + iconName = "AlertTriangle"; iconSet = "workflow"; } else if (isValid) { - iconName = "Checkmark"; iconSet = "ui"; + iconName = "Checkmark" + ({ + s: "75", + m: "100", + l: "200", + xl: "300", + }[size] || "100"); } return html` @@ -110,10 +113,10 @@ export const Template = ({ typeof size !== "undefined", [`${rootClass}--multiline`]: multiline, [`${rootClass}--grows`]: grows, - [`${rootClass}--quiet`]: isQuiet, [`${rootClass}--sideLabel`]: labelPosition === "side", "is-invalid": isInvalid, "is-valid": isValid, + "is-hover": isHovered, "is-focused": isFocused, "is-keyboardFocused": isKeyboardFocused, "is-disabled": isDisabled, @@ -152,6 +155,7 @@ export const Template = ({ size, label: labelText, isDisabled, + isRequired: isRequired && !isRequiredWithoutAsterisk, }, context))} ${when(typeof characterCount !== "undefined", () => html` ${characterCount}`)} @@ -184,6 +188,7 @@ export const Template = ({ />`, () => html`` )} - ${when(isLoading, () => ProgressCircle({ + ${when(isLoading, () => InfieldProgressCircle({ isIndeterminate: true, - size: "s", - customClasses: customProgressCircleClasses, + size: size, + customClasses: customInfieldProgressCircleClasses, }, context))} ${when(helpText, () => HelpText({ @@ -218,7 +223,7 @@ export const Template = ({ }; export const HelpTextOptions = (args, context) => Container({ - direction: "column", + direction: "row", withBorder: false, withHeading: false, content: html` @@ -238,67 +243,62 @@ export const HelpTextOptions = (args, context) => Container({ export const TextFieldOptions = (args, context) => Container({ direction: "row", withBorder: false, - wrapperStyles: { - rowGap: "12px", - }, content: html` ${Container({ withBorder: false, - containerStyles: { - "gap": "8px", - }, heading: "Default", content: Template(args, context) }, context)} ${Container({ withBorder: false, - containerStyles: { - "gap": "8px", - }, - heading: "Invalid", - content: Template({...args, isInvalid: true}, context) + heading: "Focused", + content: Template({...args, isFocused: true}, context) }, context)} ${Container({ withBorder: false, - containerStyles: { - "gap": "8px", - }, - heading: "Focused", - content: Template({...args, isFocused: true}, context) + heading: "Keyboard focused", + content: Template({...args, isKeyboardFocused: true}, context) + }, context)} + ` +}, context); + +export const InvalidOptions = (args, context) => Container({ + direction: "row", + withBorder: false, + withHeading: false, + content: html` + ${Container({ + withBorder: false, + heading: "Invalid", + content: Template({...args, isInvalid: true}, context) }, context)} ${Container({ withBorder: false, - containerStyles: { - "gap": "8px", - }, heading: "Invalid, focused", content: Template({...args, isInvalid: true, isFocused: true}, context) }, context)} ` }, context); -export const KeyboardFocusTemplate = (args, context) => Container({ - direction: "column", +export const RequiredOptions = (args, context) => Container({ + direction: "row", withBorder: false, - wrapperStyles: { - rowGap: "12px", - }, + withHeading: false, content: html` ${Container({ withBorder: false, - containerStyles: { - "gap": "8px", - }, - heading: "Default", - content: Template({...args, isKeyboardFocused: true}, context) + heading: "Required with (required) label", + content: Template({...args, isRequired: true, isRequiredWithoutAsterisk: true, labelText: "Email address (required)", value: "abc@adobe.com", helpText: "Email address is required"}, context), + }, context)} + ${Container({ + withBorder: false, + heading: "Required with asterisk", + content: Template({...args, isRequired: true, labelText: "Email address", value: "abc@adobe.com", helpText: "Email address is required"}, context), }, context)} ${Container({ withBorder: false, - containerStyles: { - "gap": "8px", - }, - heading: "Quiet", - content: Template({...args, isKeyboardFocused: true, isQuiet: true}, context) + heading: "Required with asterisk, side label", + content: Template({...args, isRequired: true, labelPosition: "side", labelText: "Email address", value: "abc@adobe.com", helpText: "Email address is required"}, context), }, context)} ` }, context); diff --git a/components/textfield/stories/textarea.stories.js b/components/textfield/stories/textarea.stories.js index 340820af2db..2fda3aeded8 100644 --- a/components/textfield/stories/textarea.stories.js +++ b/components/textfield/stories/textarea.stories.js @@ -2,12 +2,15 @@ import { Sizes } from "@spectrum-css/preview/decorators"; import { disableDefaultModes } from "@spectrum-css/preview/modes"; import metadata from "../dist/metadata.json"; import packageJson from "../package.json"; -import { HelpTextOptionsTextArea, KeyboardFocusTemplate, Template, TextAreaOptions } from "./textarea.template.js"; +import { HelpTextOptionsTextArea, InvalidOptionsTextArea, RequiredOptionsTextArea, Template, TextAreaOptions } from "./textarea.template.js"; import { TextAreaGroup } from "./textarea.test.js"; import { default as Textfield } from "./textfield.stories.js"; /** - * A text area is multi-line text field using the `