Skip to content

Commit b2c6357

Browse files
mdt2Melissa Thompsonjawinncastastrophe
authored
feat(actionbutton): s2 migration (#2669)
* feat(actionbutton): s2 migration Migrates the action button component to spectrum 2, using updated and new design token specs. Includes down state transform, removal of medium class, changes to mod custom properties, and storybook updates. * docs(actionbutton): remove problematic click and focus events - The click event was treating all action buttons as toggles, not allowing testing of the active/down state on click on the default button. It also does not work well when multiple buttons are present. - The focus events were inaccurately showing the focus indicator on click; the styles for this work differently because they are for focus-visible. The focused control/arg is for the storybook only class used for testing, which applies in a different manner. * docs(actionbutton): update docs, selected state toggle Some small documentation improvements, especially around the selected state. Adds additional notes about the selected state being optional and for toggles (per SWC docs and guidelines). * fix(actionbutton): selected + disabled + quiet background color This combination of states should continue to have the background color rather than the quiet transparent background. Per design feedback, the quiet + disabled + selected should display the same as the default disabled + selected. * chore(actionbutton): generate new metadata * chore(actionbutton): add stylelint exception for downstate variables * feat(actionbutton): add font-style property and token * fix(actionbutton): static variants do not support emphasized Update tests to remove static black + emphasized and static white + emphasized, as these are not on the design spec and not supported. Updates some Docs page descriptions to make this clear. * feat(actionbutton): add cjk line-height support Use design spec defined CJK line-height in action button. Replaces line-height declaration coming from the extended BaseButton, along with a mod name appropriate for the component. * fix(actionbutton): high contrast adjustments - Fix for high contrast border styles not being solid. - Quiet variants no longer show a border and blend into background with Canvas and CanvasText color pair. - Focus indicator color changed from ButtonText to CanvasText, because this indicator appears outside of the element (it does not appear on top of a ButtonFace background). * docs(actionbutton): disable static color control if emphasized * docs(actionbutton): add docs link to popover * fix(actionbutton): static + quiet + disabled + selected background Fixes the issue where the static black and white, quiet, selected, and disabled state in the testing grid was showing the static quiet background color instead of the static disabled background color. * fix(actionbutton): set default system colors for high contrast The noted readability backplate issue was present on more than just the selected state; it was just difficult to see without contrasting colors. So this has been moved to the default, along with setting default system color values. * refactor(actionbutton): simplify high contrast styles Refactors high contrast styles and custom properties to remove unnecessary variables, and adds some documentation. * fix(actionbutton): use full line-height to prevent cut off diacritics Keep the previous S1 behavior of setting the line-height to the full component height. This prevents Thai diacritics from being cut off (see existing Storybook test). Note: this line-height is taller than both line-height-100 and cjk-line-height-100 listed on the design spec. Using those had resulted in the diacritics cutting off again. * chore(actionbutton): update changeset description and rebuild metadata * feat(actionbutton): refactor using "has" to reduce complexity Adjust some selectors to use :has in order to remove some overly complex calc functions, and to use the inline spacing tokens more like they are defined on the token specs. Now that :has is supported and used in our library, this simplifies this usage and removes some requirements for the source order of action button's child elements. * docs(actionbutton): remove outdated docs and add static docs Usage notes about using a mod for static colors no longer applies; the --mod-actionbutton-content-color-default-selected mod and similar selected state mods work correctly to change the content color for static. Adds some basic intro docs for static colors, pulled from the guidelines. * docs(actionbutton): add docs story for text overflow behavior * docs(actionbutton): clarify text overflow docs description * docs(actionbutton): remove size medium class from appearing in markup The .spectrum-ActionButton--sizeM class is no longer used but was still appearing in the examples markup. * chore(actionbutton): update copyright year * fix(actionbutton): disable css transitions in high contrast In Windows High Contrast, the border color briefly was flashing orange (ButtonBorder) after hover, before it switched back to the correct color as defined by the styles. This fixes that issue. This removes CSS transitions in high contrast to avoid some of these rendering issues and previously noticed sluggishness in the system color transitions. * chore(actionbutton): rebuild metadata * chore: update changeset * chore(actionbutton): storybook template update --------- Co-authored-by: Melissa Thompson <[email protected]> Co-authored-by: Josh Winn <[email protected]> Co-authored-by: [ Cassondra ] <[email protected]>
1 parent fcfa916 commit b2c6357

File tree

6 files changed

+452
-422
lines changed

6 files changed

+452
-422
lines changed

.changeset/chilled-peaches-enjoy.md

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
"@spectrum-css/actionbutton": major
3+
---
4+
5+
Action button now uses Spectrum 2 tokens and design specifications. A few notable changes:
6+
7+
- Medium is now the default size and `.spectrum-ActionButton--sizeM` has been removed.
8+
- Includes the Spectrum 2 down state transform.
9+
- 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.
10+
- 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.
11+
- Background and content colors were updated.
12+
- Mod custom properties have been adjusted:
13+
- Renamed:
14+
- `--mod-line-height-100` renamed to `--mod-actionbutton-line-height`.
15+
- `--mod-sans-font-family-stack` renamed to `--mod-button-font-family`.
16+
- `--mod-animation-duration-100` renamed to `--mod-button-animation-duration`.
17+
- Removed:
18+
- `--mod-actionbutton-border-color-default`
19+
- `--mod-actionbutton-border-color-disabled`
20+
- `--mod-actionbutton-border-color-down`
21+
- `--mod-actionbutton-border-color-focus`
22+
- `--mod-actionbutton-border-color-hover`
23+
- `--mod-actionbutton-border-width`
24+
- `--mod-actionbutton-static-content-color`
25+
- New:
26+
- `--mod-actionbutton-font-weight`
27+
- `--mod-actionbutton-font-style`

components/actionbutton/dist/metadata.json

+57-57
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,29 @@
22
"sourceFile": "index.css",
33
"selectors": [
44
".spectrum-ActionButton",
5+
".spectrum-ActionButton .spectrum-ActionButton-hold",
6+
".spectrum-ActionButton .spectrum-ActionButton-icon",
7+
".spectrum-ActionButton .spectrum-ActionButton-label",
58
".spectrum-ActionButton--sizeL",
69
".spectrum-ActionButton--sizeS",
710
".spectrum-ActionButton--sizeXL",
811
".spectrum-ActionButton--sizeXS",
912
".spectrum-ActionButton-hold",
10-
".spectrum-ActionButton-hold + .spectrum-ActionButton-icon",
1113
".spectrum-ActionButton-icon",
12-
".spectrum-ActionButton-icon:only-child",
1314
".spectrum-ActionButton-label",
1415
".spectrum-ActionButton-label:empty",
1516
".spectrum-ActionButton.is-disabled",
1617
".spectrum-ActionButton.is-selected",
17-
".spectrum-ActionButton.is-selected .is-disabled.spectrum-ActionButton--staticBlack",
18-
".spectrum-ActionButton.is-selected .is-disabled.spectrum-ActionButton--staticWhite",
19-
".spectrum-ActionButton.is-selected .spectrum-ActionButton-hold",
20-
".spectrum-ActionButton.is-selected .spectrum-ActionButton-icon",
21-
".spectrum-ActionButton.is-selected .spectrum-ActionButton-label",
22-
".spectrum-ActionButton.is-selected.spectrum-ActionButton--emphasized:not(.spectrum-ActionButton--staticBlack, .spectrum-ActionButton--staticWhite)",
23-
".spectrum-ActionButton.is-selected.spectrum-ActionButton--staticBlack:disabled",
24-
".spectrum-ActionButton.is-selected.spectrum-ActionButton--staticWhite:disabled",
18+
".spectrum-ActionButton.is-selected.spectrum-ActionButton--emphasized",
19+
".spectrum-ActionButton.is-selected.spectrum-ActionButton--staticBlack",
20+
".spectrum-ActionButton.is-selected.spectrum-ActionButton--staticWhite",
2521
".spectrum-ActionButton.spectrum-ActionButton--quiet",
26-
".spectrum-ActionButton.spectrum-ActionButton--quiet.is-disabled:not(.is-selected)",
22+
".spectrum-ActionButton.spectrum-ActionButton--quiet.is-selected",
2723
".spectrum-ActionButton.spectrum-ActionButton--quiet:disabled:not(.is-selected)",
2824
".spectrum-ActionButton.spectrum-ActionButton--staticBlack",
29-
".spectrum-ActionButton.spectrum-ActionButton--staticBlack .is-disabled",
3025
".spectrum-ActionButton.spectrum-ActionButton--staticBlack.spectrum-ActionButton--quiet",
31-
".spectrum-ActionButton.spectrum-ActionButton--staticBlack:disabled",
3226
".spectrum-ActionButton.spectrum-ActionButton--staticWhite",
33-
".spectrum-ActionButton.spectrum-ActionButton--staticWhite .is-disabled",
3427
".spectrum-ActionButton.spectrum-ActionButton--staticWhite.spectrum-ActionButton--quiet",
35-
".spectrum-ActionButton.spectrum-ActionButton--staticWhite:disabled",
3628
".spectrum-ActionButton::-moz-focus-inner",
3729
".spectrum-ActionButton:active",
3830
".spectrum-ActionButton:after",
@@ -41,43 +33,58 @@
4133
".spectrum-ActionButton:focus",
4234
".spectrum-ActionButton:focus-visible",
4335
".spectrum-ActionButton:focus-visible:after",
36+
".spectrum-ActionButton:has(.spectrum-ActionButton-icon)",
4437
".spectrum-ActionButton:hover",
38+
".spectrum-ActionButton:not(:has(.spectrum-ActionButton-label))",
4539
"[dir=\"rtl\"] .spectrum-ActionButton",
4640
"a.spectrum-ActionButton"
4741
],
4842
"modifiers": [
4943
"--mod-actionbutton-animation-duration",
5044
"--mod-actionbutton-background-color-default",
45+
"--mod-actionbutton-background-color-default-selected",
46+
"--mod-actionbutton-background-color-default-selected-emphasized",
5147
"--mod-actionbutton-background-color-disabled",
5248
"--mod-actionbutton-background-color-down",
49+
"--mod-actionbutton-background-color-down-selected",
50+
"--mod-actionbutton-background-color-down-selected-emphasized",
5351
"--mod-actionbutton-background-color-focus",
52+
"--mod-actionbutton-background-color-focus-selected",
53+
"--mod-actionbutton-background-color-focus-selected-emphasized",
5454
"--mod-actionbutton-background-color-hover",
55-
"--mod-actionbutton-border-color-default",
56-
"--mod-actionbutton-border-color-disabled",
57-
"--mod-actionbutton-border-color-down",
58-
"--mod-actionbutton-border-color-focus",
59-
"--mod-actionbutton-border-color-hover",
55+
"--mod-actionbutton-background-color-hover-selected",
56+
"--mod-actionbutton-background-color-hover-selected-emphasized",
6057
"--mod-actionbutton-border-radius",
61-
"--mod-actionbutton-border-width",
6258
"--mod-actionbutton-content-color-default",
59+
"--mod-actionbutton-content-color-default-selected",
60+
"--mod-actionbutton-content-color-default-selected-emphasized",
6361
"--mod-actionbutton-content-color-disabled",
6462
"--mod-actionbutton-content-color-down",
63+
"--mod-actionbutton-content-color-down-selected",
64+
"--mod-actionbutton-content-color-down-selected-emphasized",
6565
"--mod-actionbutton-content-color-focus",
66+
"--mod-actionbutton-content-color-focus-selected",
67+
"--mod-actionbutton-content-color-focus-selected-emphasized",
6668
"--mod-actionbutton-content-color-hover",
69+
"--mod-actionbutton-content-color-hover-selected",
70+
"--mod-actionbutton-content-color-hover-selected-emphasized",
6771
"--mod-actionbutton-edge-to-hold-icon",
6872
"--mod-actionbutton-edge-to-text",
6973
"--mod-actionbutton-edge-to-visual",
7074
"--mod-actionbutton-edge-to-visual-only",
7175
"--mod-actionbutton-focus-indicator-border-radius",
7276
"--mod-actionbutton-focus-indicator-color",
7377
"--mod-actionbutton-focus-indicator-gap",
78+
"--mod-actionbutton-focus-indicator-thickness",
79+
"--mod-actionbutton-font-size",
80+
"--mod-actionbutton-font-style",
81+
"--mod-actionbutton-font-weight",
7482
"--mod-actionbutton-height",
7583
"--mod-actionbutton-icon-size",
7684
"--mod-actionbutton-label-color",
85+
"--mod-actionbutton-line-height",
7786
"--mod-actionbutton-min-width",
78-
"--mod-actionbutton-text-to-visual",
79-
"--mod-disabled-background-color",
80-
"--mod-disabled-content-color"
87+
"--mod-actionbutton-text-to-visual"
8188
],
8289
"component": [
8390
"--spectrum-action-button-edge-to-hold-icon-extra-large",
@@ -91,24 +98,15 @@
9198
"--spectrum-actionbutton-background-color-down",
9299
"--spectrum-actionbutton-background-color-focus",
93100
"--spectrum-actionbutton-background-color-hover",
94-
"--spectrum-actionbutton-background-color-selected",
95-
"--spectrum-actionbutton-background-color-selected-disabled",
96-
"--spectrum-actionbutton-background-color-selected-down",
97-
"--spectrum-actionbutton-background-color-selected-focus",
98-
"--spectrum-actionbutton-background-color-selected-hover",
99-
"--spectrum-actionbutton-border-color-default",
100-
"--spectrum-actionbutton-border-color-disabled",
101-
"--spectrum-actionbutton-border-color-down",
102-
"--spectrum-actionbutton-border-color-focus",
103-
"--spectrum-actionbutton-border-color-hover",
101+
"--spectrum-actionbutton-border-color",
104102
"--spectrum-actionbutton-border-radius",
105103
"--spectrum-actionbutton-border-width",
106104
"--spectrum-actionbutton-content-color-default",
107105
"--spectrum-actionbutton-content-color-disabled",
108106
"--spectrum-actionbutton-content-color-down",
109107
"--spectrum-actionbutton-content-color-focus",
110108
"--spectrum-actionbutton-content-color-hover",
111-
"--spectrum-actionbutton-content-color-selected",
109+
"--spectrum-actionbutton-downstate-perspective",
112110
"--spectrum-actionbutton-edge-to-hold-icon",
113111
"--spectrum-actionbutton-edge-to-text",
114112
"--spectrum-actionbutton-edge-to-visual",
@@ -118,8 +116,11 @@
118116
"--spectrum-actionbutton-focus-indicator-gap",
119117
"--spectrum-actionbutton-focus-indicator-thickness",
120118
"--spectrum-actionbutton-font-size",
119+
"--spectrum-actionbutton-font-style",
120+
"--spectrum-actionbutton-font-weight",
121121
"--spectrum-actionbutton-height",
122122
"--spectrum-actionbutton-icon-size",
123+
"--spectrum-actionbutton-line-height",
123124
"--spectrum-actionbutton-min-width",
124125
"--spectrum-actionbutton-text-to-visual"
125126
],
@@ -129,6 +130,7 @@
129130
"--spectrum-accent-background-color-hover",
130131
"--spectrum-accent-background-color-key-focus",
131132
"--spectrum-animation-duration-100",
133+
"--spectrum-black",
132134
"--spectrum-border-width-100",
133135
"--spectrum-component-edge-to-text-100",
134136
"--spectrum-component-edge-to-text-200",
@@ -150,14 +152,23 @@
150152
"--spectrum-component-height-300",
151153
"--spectrum-component-height-50",
152154
"--spectrum-component-height-75",
155+
"--spectrum-component-size-difference-down",
156+
"--spectrum-component-size-minimum-perspective-down",
157+
"--spectrum-component-size-width-ratio-down",
153158
"--spectrum-corner-radius-medium-size-extra-large",
154159
"--spectrum-corner-radius-medium-size-extra-small",
155160
"--spectrum-corner-radius-medium-size-large",
156161
"--spectrum-corner-radius-medium-size-medium",
157162
"--spectrum-corner-radius-medium-size-small",
163+
"--spectrum-default-font-style",
158164
"--spectrum-disabled-background-color",
159-
"--spectrum-disabled-border-color",
160165
"--spectrum-disabled-content-color",
166+
"--spectrum-disabled-static-black-background-color",
167+
"--spectrum-disabled-static-black-content-color",
168+
"--spectrum-disabled-static-white-background-color",
169+
"--spectrum-disabled-static-white-content-color",
170+
"--spectrum-downstate-height",
171+
"--spectrum-downstate-width",
161172
"--spectrum-focus-indicator-color",
162173
"--spectrum-focus-indicator-gap",
163174
"--spectrum-focus-indicator-thickness",
@@ -169,12 +180,9 @@
169180
"--spectrum-gray-100",
170181
"--spectrum-gray-200",
171182
"--spectrum-gray-25",
172-
"--spectrum-gray-400",
173-
"--spectrum-gray-50",
174-
"--spectrum-gray-500",
175-
"--spectrum-gray-600",
176183
"--spectrum-line-height-100",
177184
"--spectrum-logical-rotation",
185+
"--spectrum-medium-font-weight",
178186
"--spectrum-neutral-background-color-selected-default",
179187
"--spectrum-neutral-background-color-selected-down",
180188
"--spectrum-neutral-background-color-selected-hover",
@@ -193,14 +201,14 @@
193201
"--spectrum-text-to-visual-75",
194202
"--spectrum-transparent-black-100",
195203
"--spectrum-transparent-black-200",
196-
"--spectrum-transparent-black-500",
197-
"--spectrum-transparent-black-600",
198-
"--spectrum-transparent-black-700",
204+
"--spectrum-transparent-black-25",
205+
"--spectrum-transparent-black-800",
206+
"--spectrum-transparent-black-900",
199207
"--spectrum-transparent-white-100",
200208
"--spectrum-transparent-white-200",
201-
"--spectrum-transparent-white-500",
202-
"--spectrum-transparent-white-600",
203-
"--spectrum-transparent-white-700",
209+
"--spectrum-transparent-white-25",
210+
"--spectrum-transparent-white-800",
211+
"--spectrum-transparent-white-900",
204212
"--spectrum-white",
205213
"--spectrum-workflow-icon-size-100",
206214
"--spectrum-workflow-icon-size-200",
@@ -214,20 +222,12 @@
214222
"--mod-button-line-height"
215223
],
216224
"high-contrast": [
225+
"--highcontrast-actionbutton-animation-duration",
217226
"--highcontrast-actionbutton-background-color-default",
218227
"--highcontrast-actionbutton-background-color-disabled",
219-
"--highcontrast-actionbutton-background-color-down",
220-
"--highcontrast-actionbutton-background-color-focus",
221-
"--highcontrast-actionbutton-background-color-hover",
222-
"--highcontrast-actionbutton-border-color-default",
223-
"--highcontrast-actionbutton-border-color-disabled",
224-
"--highcontrast-actionbutton-border-color-down",
225-
"--highcontrast-actionbutton-border-color-focus",
226-
"--highcontrast-actionbutton-border-color-hover",
228+
"--highcontrast-actionbutton-border-color",
227229
"--highcontrast-actionbutton-content-color-default",
228230
"--highcontrast-actionbutton-content-color-disabled",
229-
"--highcontrast-actionbutton-content-color-down",
230-
"--highcontrast-actionbutton-content-color-focus",
231-
"--highcontrast-actionbutton-content-color-hover"
231+
"--highcontrast-actionbutton-focus-indicator-color"
232232
]
233233
}

0 commit comments

Comments
 (0)