Skip to content

Commit b263842

Browse files
jawinncastastrophe
authored andcommitted
feat(button): migrate to Spectrum 2 (#2600)
* refactor(button): spectrum 2 styles and cleanup Spectrum 2 changes to CSS: - integrate themes css into main css - use s2 corner rounding - use s2 colors Cleanup items of note: - make medium size the default - consolidate and organize focus indicator styles. Some declarations were repeated. - Rename mod for font weight that was referencing a global token instead of a component specific name. - simplify repetitive disabled custom properties - removed some unused css; static variant declarations at the end of the file were being overridden by more specific styles - remove unused is-selected, emphasized, and quiet classes that are not used on this component - remove the spectrum-Button--fill class. it was already the default. * fix(button): high contrast - ensure matching color pairs for accent Ensures that a matching background and foreground color pair is used for the high contrast colors, for Accent hover, down, and focus. Changes the content color to HighlightText to ensure contrast when these have a background set to Highlight. * docs(button): update documentation and storybook for s2 - Some improvements and additions to the spectrum 2 release notes. - Updates migration guide notes to include version and dates for the previous notes. - Removes spectrum-Button--sizeM class from examples. Excludes the spectrum-Button--sizeM class in the storybook template. - Removes medium size class from storybook - Fixes default flex alignment stretching buttons vertically in Storybook to the tallest button. * fix(button): calculate corner rounding to support wrapping design Calculate corner rounding based on the component height, so that the rounding looks correct when there is wrapping text. Otherwise, when the button wraps, it has too much rounding as compared to the design when using the corner-radius-full token. * feat(button): outline option removals and use accent as the default Removes the outline option for the accent and negative variants, and makes sure that the accent variant is the default. == outline option removal == Per design feedback and updated design spec changelog, the outline treatment (style) is no longer supported for the Accent and Negative color variants: "Outline buttons are no longer available in accent and negative options — use the filled variant instead" This removes their CSS, lists the change in the migration notes, and disables the treatment control for the Accent and Negative stories. It also removes the outline example in the template for those two stories. == use accent as the default == Use accent styles for the default button when there is no variant class applied, to match the default defined on the guidelines. * fix(button): additional s2 style adjustments and organization - make usage of edge to visual values consistent - use full corner rounding on icon-only variant, which does not need to account for wrapping text - correct static white secondary outline background color, per PR review - chore: apply linter formatting * docs(button): custom mdx docs page Create an MDX "Docs" page that works as a replacement for the YML docs pages, and covers the important Button options from there and the guidelines. Adds the tag "is-hidden-story" for excluding Storybook sidebar items. * chore(button): add changeset * build(button): use beta version of commons dependency Since the commons version on main was updated to 10.0, the Button started building with the wrong version of commons when importing basebutton.css and listing mods that have been removed in the version of commons in the spectrum-two branch. * chore(button): clear up linter warnings Fixes warnings and errors from stylelint and eslint. * fix(button): correct focus indicator rounding and basebutton mod The focus indicator rounding needed an additional calc in order to have the correct rounding. While testing --mod-button-focus-ring-gap and some other mods, it was also noticed that a declaration being imported from basebutton was causing some of the mod names to be different and the mod to not work correctly (basebutton is generating a selector for the margin of .spectrum-Button:focus-visible::after).
1 parent 2e0fa81 commit b263842

File tree

7 files changed

+465
-709
lines changed

7 files changed

+465
-709
lines changed

.changeset/nine-kings-repair.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
"@spectrum-css/button": major
3+
---
4+
5+
#### Spectrum 2 migration
6+
Button now uses Spectrum 2 tokens and specifications, which includes many color changes to all variants. A few other notable changes:
7+
- Outline buttons are no longer available in accent and negative options — use the filled variant instead.
8+
- Medium size is now the default. The class `.spectrum-Button--sizeM` is now unnecessary for this size, and has been removed.
9+
- The `.spectrum-Button--fill` class is no longer needed and has been removed.
10+
11+
The following `--mod` custom properties have been renamed:
12+
- `--mod-line-height-100` has been renamed to `--mod-button-line-height`
13+
- `--mod-sans-font-family-stack` has been renamed to `--mod-button-font-family`
14+
- `--mod-animation-duration-100` has been renamed to `--mod-button-animation-duration`
15+
- `--mod-bold-font-weight` has been renamed to `--mod-button-font-weight`

.storybook/assets/base.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ body {
3939
background-color: var(--spectrum-background-layer-1-color);
4040
}
4141

42+
.spectrum .spectrum-examples-static-black {
43+
background: var(--spectrum-examples-gradient-static-black);
44+
}
45+
46+
.spectrum .spectrum-examples-static-white {
47+
background: var(--spectrum-examples-gradient-static-white)
48+
}
49+
4250
/* Hide the SVG elements that only include references */
4351
svg:has(symbol):not(:has(use)) {
4452
display: none;

.storybook/manager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ addons.setConfig({
6666
sidebar: {
6767
showRoots: false,
6868
filters: {
69-
patterns: (item) => !(item.id.includes('forced-colors') || item.tags.includes('foundation')),
69+
patterns: (item) => !item.id.includes('forced-colors') && ['foundation','is-hidden-story'].every((tag) => !item.tags.includes(tag)),
7070
}
7171
},
7272
});

components/button/dist/metadata.json

Lines changed: 20 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -6,53 +6,38 @@
66
".spectrum-Button .spectrum-Icon",
77
".spectrum-Button .spectrum-Icon + .spectrum-Button-label",
88
".spectrum-Button .spectrum-ProgressCircle",
9-
".spectrum-Button--noWrap .spectrum-Button-label",
109
".spectrum-Button--sizeL",
1110
".spectrum-Button--sizeS",
11+
".spectrum-Button--sizeS.spectrum-Button--iconOnly",
1212
".spectrum-Button--sizeXL",
1313
".spectrum-Button-label",
1414
".spectrum-Button-label:empty",
1515
".spectrum-Button.is-disabled",
16+
".spectrum-Button.is-focused",
1617
".spectrum-Button.is-focused:after",
1718
".spectrum-Button.is-pending",
1819
".spectrum-Button.is-pending .spectrum-Button-label",
1920
".spectrum-Button.is-pending .spectrum-Icon",
2021
".spectrum-Button.is-pending .spectrum-ProgressCircle",
21-
".spectrum-Button.is-selected",
22-
".spectrum-Button.is-selected.spectrum-Button--emphasized",
2322
".spectrum-Button.spectrum-Button--accent",
24-
".spectrum-Button.spectrum-Button--accent.spectrum-Button--fill",
25-
".spectrum-Button.spectrum-Button--accent.spectrum-Button--outline",
23+
".spectrum-Button.spectrum-Button--accent .spectrum-Button-label",
2624
".spectrum-Button.spectrum-Button--iconOnly",
2725
".spectrum-Button.spectrum-Button--iconOnly .spectrum-Icon",
2826
".spectrum-Button.spectrum-Button--iconOnly:after",
2927
".spectrum-Button.spectrum-Button--negative",
30-
".spectrum-Button.spectrum-Button--negative.spectrum-Button--outline",
3128
".spectrum-Button.spectrum-Button--outline",
3229
".spectrum-Button.spectrum-Button--primary",
3330
".spectrum-Button.spectrum-Button--primary.spectrum-Button--outline",
34-
".spectrum-Button.spectrum-Button--quiet",
3531
".spectrum-Button.spectrum-Button--secondary",
3632
".spectrum-Button.spectrum-Button--secondary.spectrum-Button--outline",
37-
".spectrum-Button.spectrum-Button--secondary:not(.spectrum-Button--outline)",
3833
".spectrum-Button.spectrum-Button--staticBlack",
39-
".spectrum-Button.spectrum-Button--staticBlack.is-selected",
4034
".spectrum-Button.spectrum-Button--staticBlack.spectrum-Button--outline",
41-
".spectrum-Button.spectrum-Button--staticBlack.spectrum-Button--outline:not(.spectrum-Button--secondary)",
42-
".spectrum-Button.spectrum-Button--staticBlack.spectrum-Button--quiet",
4335
".spectrum-Button.spectrum-Button--staticBlack.spectrum-Button--secondary",
4436
".spectrum-Button.spectrum-Button--staticBlack.spectrum-Button--secondary.spectrum-Button--outline",
45-
".spectrum-Button.spectrum-Button--staticBlack.spectrum-Button--secondary:not(.spectrum-Button--outline)",
4637
".spectrum-Button.spectrum-Button--staticWhite",
47-
".spectrum-Button.spectrum-Button--staticWhite.is-selected",
48-
".spectrum-Button.spectrum-Button--staticWhite.spectrum-Button--accent",
4938
".spectrum-Button.spectrum-Button--staticWhite.spectrum-Button--outline",
50-
".spectrum-Button.spectrum-Button--staticWhite.spectrum-Button--outline.spectrum-Button--secondary",
51-
".spectrum-Button.spectrum-Button--staticWhite.spectrum-Button--outline:not(.spectrum-Button--secondary)",
52-
".spectrum-Button.spectrum-Button--staticWhite.spectrum-Button--quiet",
5339
".spectrum-Button.spectrum-Button--staticWhite.spectrum-Button--secondary",
5440
".spectrum-Button.spectrum-Button--staticWhite.spectrum-Button--secondary.spectrum-Button--outline",
55-
".spectrum-Button.spectrum-Button--staticWhite.spectrum-Button--secondary:not(.spectrum-Button--outline)",
5641
".spectrum-Button::-moz-focus-inner",
5742
".spectrum-Button:active",
5843
".spectrum-Button:after",
@@ -61,14 +46,15 @@
6146
".spectrum-Button:focus-visible",
6247
".spectrum-Button:focus-visible:after",
6348
".spectrum-Button:hover",
49+
".spectrum-Button:not(.spectrum-Button--primary, .spectrum-Button--negative, .spectrum-Button--secondary, .spectrum-Button--staticBlack, .spectrum-Button--staticWhite)",
50+
".spectrum-Button:not(.spectrum-Button--primary, .spectrum-Button--negative, .spectrum-Button--secondary, .spectrum-Button--staticBlack, .spectrum-Button--staticWhite) .spectrum-Button-label",
6451
".spectrum-Button[pending]",
6552
".spectrum-Button[pending] .spectrum-Button-label",
6653
".spectrum-Button[pending] .spectrum-Icon",
6754
".spectrum-Button[pending] .spectrum-ProgressCircle",
6855
"a.spectrum-Button"
6956
],
7057
"modifiers": [
71-
"--mod-bold-font-weight",
7258
"--mod-button-animation-duration",
7359
"--mod-button-background-color-default",
7460
"--mod-button-background-color-disabled",
@@ -91,29 +77,25 @@
9177
"--mod-button-edge-to-text",
9278
"--mod-button-edge-to-visual",
9379
"--mod-button-edge-to-visual-only",
94-
"--mod-button-focus-indicator-gap",
9580
"--mod-button-focus-ring-border-radius",
9681
"--mod-button-focus-ring-color",
9782
"--mod-button-focus-ring-gap",
9883
"--mod-button-focus-ring-thickness",
9984
"--mod-button-font-family",
10085
"--mod-button-font-size",
86+
"--mod-button-font-weight",
10187
"--mod-button-height",
10288
"--mod-button-icon-margin-block-start",
10389
"--mod-button-line-height",
10490
"--mod-button-margin-block",
10591
"--mod-button-margin-left",
10692
"--mod-button-margin-right",
107-
"--mod-button-max-inline-size",
10893
"--mod-button-min-width",
10994
"--mod-button-padding-label-to-icon",
110-
"--mod-button-static-content-color",
11195
"--mod-button-text-align",
11296
"--mod-button-text-align-with-icon",
11397
"--mod-button-top-to-icon",
114-
"--mod-button-top-to-text",
115-
"--mod-focus-indicator-gap",
116-
"--mod-static-black-focus-indicator-color"
98+
"--mod-button-top-to-text"
11799
],
118100
"component": [
119101
"--spectrum-button-animation-duration",
@@ -146,21 +128,14 @@
146128
"--spectrum-button-focus-ring-gap",
147129
"--spectrum-button-focus-ring-thickness",
148130
"--spectrum-button-font-size",
131+
"--spectrum-button-font-weight",
149132
"--spectrum-button-height",
133+
"--spectrum-button-icon-size-difference",
150134
"--spectrum-button-intended-icon-size",
151135
"--spectrum-button-line-height",
152136
"--spectrum-button-min-width",
153137
"--spectrum-button-minimum-width-multiplier",
154138
"--spectrum-button-padding-label-to-icon",
155-
"--spectrum-button-sized-bottom-to-text",
156-
"--spectrum-button-sized-edge-to-text",
157-
"--spectrum-button-sized-edge-to-visual",
158-
"--spectrum-button-sized-edge-to-visual-only",
159-
"--spectrum-button-sized-font-size",
160-
"--spectrum-button-sized-height",
161-
"--spectrum-button-sized-padding-label-to-icon",
162-
"--spectrum-button-sized-top-to-icon",
163-
"--spectrum-button-sized-top-to-text",
164139
"--spectrum-button-top-to-icon",
165140
"--spectrum-button-top-to-text",
166141
"--spectrum-button-top-to-text-extra-large",
@@ -173,15 +148,6 @@
173148
"--spectrum-accent-background-color-down",
174149
"--spectrum-accent-background-color-hover",
175150
"--spectrum-accent-background-color-key-focus",
176-
"--spectrum-accent-color-1000",
177-
"--spectrum-accent-color-1100",
178-
"--spectrum-accent-color-200",
179-
"--spectrum-accent-color-300",
180-
"--spectrum-accent-color-900",
181-
"--spectrum-accent-content-color-default",
182-
"--spectrum-accent-content-color-down",
183-
"--spectrum-accent-content-color-hover",
184-
"--spectrum-accent-content-color-key-focus",
185151
"--spectrum-animation-duration-100",
186152
"--spectrum-black",
187153
"--spectrum-bold-font-weight",
@@ -209,6 +175,7 @@
209175
"--spectrum-component-top-to-workflow-icon-200",
210176
"--spectrum-component-top-to-workflow-icon-300",
211177
"--spectrum-component-top-to-workflow-icon-75",
178+
"--spectrum-corner-radius-full",
212179
"--spectrum-disabled-background-color",
213180
"--spectrum-disabled-border-color",
214181
"--spectrum-disabled-content-color",
@@ -233,9 +200,6 @@
233200
"--spectrum-gray-25",
234201
"--spectrum-gray-300",
235202
"--spectrum-gray-400",
236-
"--spectrum-gray-50",
237-
"--spectrum-gray-500",
238-
"--spectrum-gray-600",
239203
"--spectrum-gray-800",
240204
"--spectrum-gray-900",
241205
"--spectrum-icon-block-size",
@@ -244,15 +208,6 @@
244208
"--spectrum-negative-background-color-down",
245209
"--spectrum-negative-background-color-hover",
246210
"--spectrum-negative-background-color-key-focus",
247-
"--spectrum-negative-color-1000",
248-
"--spectrum-negative-color-1100",
249-
"--spectrum-negative-color-200",
250-
"--spectrum-negative-color-300",
251-
"--spectrum-negative-color-900",
252-
"--spectrum-negative-content-color-default",
253-
"--spectrum-negative-content-color-down",
254-
"--spectrum-negative-content-color-hover",
255-
"--spectrum-negative-content-color-key-focus",
256211
"--spectrum-neutral-background-color-default",
257212
"--spectrum-neutral-background-color-down",
258213
"--spectrum-neutral-background-color-hover",
@@ -261,10 +216,6 @@
261216
"--spectrum-neutral-content-color-down",
262217
"--spectrum-neutral-content-color-hover",
263218
"--spectrum-neutral-content-color-key-focus",
264-
"--spectrum-neutral-subdued-background-color-default",
265-
"--spectrum-neutral-subdued-background-color-down",
266-
"--spectrum-neutral-subdued-background-color-hover",
267-
"--spectrum-neutral-subdued-background-color-key-focus",
268219
"--spectrum-progress-circle-thickness-medium",
269220
"--spectrum-sans-font-family-stack",
270221
"--spectrum-static-black-focus-indicator-color",
@@ -273,18 +224,19 @@
273224
"--spectrum-text-to-visual-200",
274225
"--spectrum-text-to-visual-300",
275226
"--spectrum-text-to-visual-75",
276-
"--spectrum-transparent-black-1000",
227+
"--spectrum-transparent-black-100",
228+
"--spectrum-transparent-black-200",
229+
"--spectrum-transparent-black-25",
277230
"--spectrum-transparent-black-300",
278231
"--spectrum-transparent-black-400",
279-
"--spectrum-transparent-black-500",
280-
"--spectrum-transparent-black-600",
281-
"--spectrum-transparent-black-700",
232+
"--spectrum-transparent-black-800",
282233
"--spectrum-transparent-black-900",
283-
"--spectrum-transparent-white-1000",
234+
"--spectrum-transparent-white-100",
235+
"--spectrum-transparent-white-200",
236+
"--spectrum-transparent-white-25",
284237
"--spectrum-transparent-white-300",
285238
"--spectrum-transparent-white-400",
286-
"--spectrum-transparent-white-500",
287-
"--spectrum-transparent-white-600",
239+
"--spectrum-transparent-white-800",
288240
"--spectrum-transparent-white-900",
289241
"--spectrum-white",
290242
"--spectrum-workflow-icon-size-100",
@@ -314,6 +266,7 @@
314266
"--highcontrast-button-content-color-disabled",
315267
"--highcontrast-button-content-color-down",
316268
"--highcontrast-button-content-color-focus",
317-
"--highcontrast-button-content-color-hover"
269+
"--highcontrast-button-content-color-hover",
270+
"--highcontrast-button-focus-ring-color"
318271
]
319272
}

0 commit comments

Comments
 (0)