Skip to content

Commit 5731bae

Browse files
jawinnpfulton
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 890c32e commit 5731bae

19 files changed

+1146
-1127
lines changed

.changeset/nine-kings-repair.md

+15
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

+8
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ body {
3636
-webkit-tap-highlight-color: rgba(0, 0, 0, 0%);
3737
}
3838

39+
.spectrum .spectrum-examples-static-black {
40+
background: var(--spectrum-examples-gradient-static-black);
41+
}
42+
43+
.spectrum .spectrum-examples-static-white {
44+
background: var(--spectrum-examples-gradient-static-white)
45+
}
46+
3947
/* Hide the SVG elements that only include references */
4048
svg:has(symbol):not(:has(use)) {
4149
display: none;

.storybook/main.js

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const componentPkgs = readdirSync(componentsPath, {
1010

1111
module.exports = {
1212
stories: [
13+
"../components/*/stories/*.mdx",
1314
"../components/*/stories/*.stories.js",
1415
"./guides/*.mdx",
1516
"./foundations/*/*.mdx",

.storybook/manager.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ addons.setConfig({
5050
sidebar: {
5151
showRoots: false,
5252
filters: {
53-
patterns: (item) => !(item.id.includes('forced-colors') || item.tags.includes('foundation')),
53+
patterns: (item) => !item.id.includes('forced-colors') && ['foundation','is-hidden-story'].every((tag) => !item.tags.includes(tag)),
5454
}
5555
},
5656
});

components/button/index.css

+355-140
Large diffs are not rendered by default.

components/button/metadata/button-accent.yml

+48-39
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,29 @@ sections:
88
This component can be modified via its `--mod-*` prefixed custom properties. A list of those prefixed custom properties can be found <a class="spectrum-Link" href="https://github.com/adobe/spectrum-css/tree/main/components/button/metadata/mods.md">here</a>.
99
- name: Migration Guide
1010
description: |
11-
### x/x/2024 - Version 13.0.0
11+
### Version 13.0.0
1212
#### Spectrum 2 release
13-
Button now uses Spectrum 2 tokens and specifications. A few notable changes:
14-
- The mod custom property `--mod-line-height-100` has been renamed to `--mod-button-line-height`.
15-
- The mod custom property `--mod-sans-font-family-stack` has been renamed to `--mod-button-font-family`.
16-
- The mod custom property `--mod-animation-duration-100` has been renamed to `--mod-button-animation-duration`.
17-
18-
### Versions prior to 13.0.0
19-
#### Fill or Outline class required
20-
All buttons now require either the `.spectrum-Button--fill` or `.spectrum-Button--outline` class.
21-
22-
#### CTA replaced by Accent with Fill
23-
Replace all `.spectrum-Button--cta` with `.spectrum-Button--accent .spectrum-Button--fill`.
13+
Button now uses Spectrum 2 tokens and specifications, which includes many color changes to all variants. A few other notable changes:
14+
- Outline buttons are no longer available in accent and negative options — use the filled variant instead.
15+
- Medium size is now the default. The class `.spectrum-Button--sizeM` is now unnecessary for this size, and has been removed.
16+
- The `.spectrum-Button--fill` class is no longer needed and has been removed.
17+
18+
The following `--mod` custom properties have been renamed:
19+
- `--mod-line-height-100` has been renamed to `--mod-button-line-height`.
20+
- `--mod-sans-font-family-stack` has been renamed to `--mod-button-font-family`.
21+
- `--mod-animation-duration-100` has been renamed to `--mod-button-animation-duration`.
22+
- `--mod-bold-font-weight` has been renamed to `--mod-button-font-weight`.
23+
24+
### Version 11.0.0
25+
#### Remove focus-ring class
26+
We've migrated away from the focus-ring class in favor of the native `:focus-visible` pseudo-class due to changes in browser support.
2427
28+
### Version 10.0.0
2529
#### Icon Only
2630
Add the `.spectrum-Button--iconOnly` class to apply the correct styling when an icon is used without a label.
2731
Provide an `aria-label` on the button itself when using this variant for accessibility.
2832
29-
#### T-shirt sizing
30-
Button now supports t-shirt sizing and requires that you specify the size of button by adding a `.spectrum-Button--size*` class.
31-
3233
#### Change workflow icon size
33-
3434
Previously, all Buttons used `.spectrum-Icon--sizeS`. This has changed:
3535
3636
| Button classname | Workflow icon classname |
@@ -40,8 +40,17 @@ sections:
4040
| `.spectrum-Button--sizeL` | `.spectrum-Icon--sizeL` |
4141
| `.spectrum-Button--sizeXL` | `.spectrum-Icon--sizeXL` |
4242
43-
#### Remove focus-ring class
44-
We've migrated away from the focus-ring class in favor of the native `:focus-visible` pseudo-class due to changes in browser support.
43+
### Version 6.0.0
44+
#### Fill or Outline class required
45+
All buttons now require either the `.spectrum-Button--fill` or `.spectrum-Button--outline` class.
46+
47+
#### CTA replaced by Accent with Fill
48+
Replace all `.spectrum-Button--cta` with `.spectrum-Button--accent .spectrum-Button--fill`.
49+
50+
### Version 3.0.0
51+
#### T-shirt sizing
52+
Button now supports t-shirt sizing and requires that you specify the size of button by adding a `.spectrum-Button--size*` class.
53+
4554
examples:
4655
- id: button-accent
4756
name: Sizing
@@ -50,18 +59,18 @@ examples:
5059
<div class="spectrum-Examples-item">
5160
<h4 class="spectrum-Heading spectrum-Heading--sizeXS spectrum-Examples-itemHeading">S</h4>
5261
53-
<button class="spectrum-Button spectrum-Button--fill spectrum-Button--accent spectrum-Button--sizeS">
62+
<button class="spectrum-Button spectrum-Button--accent spectrum-Button--sizeS">
5463
<span class="spectrum-Button-label">Edit</span>
5564
</button>
5665
57-
<button class="spectrum-Button spectrum-Button--fill spectrum-Button--accent spectrum-Button--sizeS">
66+
<button class="spectrum-Button spectrum-Button--accent spectrum-Button--sizeS">
5867
<svg class="spectrum-Icon spectrum-Icon--sizeS" focusable="false" aria-hidden="true">
5968
<use xlink:href="#spectrum-icon-18-Edit" />
6069
</svg>
6170
<span class="spectrum-Button-label">Edit</span>
6271
</button>
6372
64-
<button class="spectrum-Button spectrum-Button--fill spectrum-Button--accent spectrum-Button--sizeS spectrum-Button--iconOnly" aria-label="Edit">
73+
<button class="spectrum-Button spectrum-Button--accent spectrum-Button--sizeS spectrum-Button--iconOnly" aria-label="Edit">
6574
<svg class="spectrum-Icon spectrum-Icon--sizeS" focusable="false" aria-hidden="true">
6675
<use xlink:href="#spectrum-icon-18-Edit" />
6776
</svg>
@@ -70,18 +79,18 @@ examples:
7079
<div class="spectrum-Examples-item">
7180
<h4 class="spectrum-Heading spectrum-Heading--sizeXS spectrum-Examples-itemHeading">M (default)</h4>
7281
73-
<button class="spectrum-Button spectrum-Button--fill spectrum-Button--accent spectrum-Button--sizeM">
82+
<button class="spectrum-Button spectrum-Button--accent">
7483
<span class="spectrum-Button-label">Edit</span>
7584
</button>
7685
77-
<button class="spectrum-Button spectrum-Button--fill spectrum-Button--accent spectrum-Button--sizeM">
86+
<button class="spectrum-Button spectrum-Button--accent">
7887
<svg class="spectrum-Icon spectrum-Icon--sizeM" focusable="false" aria-hidden="true">
7988
<use xlink:href="#spectrum-icon-18-Edit" />
8089
</svg>
8190
<span class="spectrum-Button-label">Edit</span>
8291
</button>
8392
84-
<button class="spectrum-Button spectrum-Button--fill spectrum-Button--accent spectrum-Button--sizeM spectrum-Button--iconOnly" aria-label="Edit">
93+
<button class="spectrum-Button spectrum-Button--accent spectrum-Button--iconOnly" aria-label="Edit">
8594
<svg class="spectrum-Icon spectrum-Icon--sizeM" focusable="false" aria-hidden="true">
8695
<use xlink:href="#spectrum-icon-18-Edit" />
8796
</svg>
@@ -91,18 +100,18 @@ examples:
91100
<div class="spectrum-Examples-item">
92101
<h4 class="spectrum-Heading spectrum-Heading--sizeXS spectrum-Examples-itemHeading">L</h4>
93102
94-
<button class="spectrum-Button spectrum-Button--fill spectrum-Button--accent spectrum-Button--sizeL">
103+
<button class="spectrum-Button spectrum-Button--accent spectrum-Button--sizeL">
95104
<span class="spectrum-Button-label">Edit</span>
96105
</button>
97106
98-
<button class="spectrum-Button spectrum-Button--fill spectrum-Button--accent spectrum-Button--sizeL">
107+
<button class="spectrum-Button spectrum-Button--accent spectrum-Button--sizeL">
99108
<svg class="spectrum-Icon spectrum-Icon--sizeL" focusable="false" aria-hidden="true">
100109
<use xlink:href="#spectrum-icon-18-Edit" />
101110
</svg>
102111
<span class="spectrum-Button-label">Edit</span>
103112
</button>
104113
105-
<button class="spectrum-Button spectrum-Button--fill spectrum-Button--accent spectrum-Button--sizeL spectrum-Button--iconOnly" aria-label="Edit">
114+
<button class="spectrum-Button spectrum-Button--accent spectrum-Button--sizeL spectrum-Button--iconOnly" aria-label="Edit">
106115
<svg class="spectrum-Icon spectrum-Icon--sizeL" focusable="false" aria-hidden="true">
107116
<use xlink:href="#spectrum-icon-18-Edit" />
108117
</svg>
@@ -112,18 +121,18 @@ examples:
112121
<div class="spectrum-Examples-item">
113122
<h4 class="spectrum-Heading spectrum-Heading--sizeXS spectrum-Examples-itemHeading">XL</h4>
114123
115-
<button class="spectrum-Button spectrum-Button--fill spectrum-Button--accent spectrum-Button--sizeXL">
124+
<button class="spectrum-Button spectrum-Button--accent spectrum-Button--sizeXL">
116125
<span class="spectrum-Button-label">Edit</span>
117126
</button>
118127
119-
<button class="spectrum-Button spectrum-Button--fill spectrum-Button--accent spectrum-Button--sizeXL">
128+
<button class="spectrum-Button spectrum-Button--accent spectrum-Button--sizeXL">
120129
<svg class="spectrum-Icon spectrum-Icon--sizeXL" focusable="false" aria-hidden="true">
121130
<use xlink:href="#spectrum-icon-18-Edit" />
122131
</svg>
123132
<span class="spectrum-Button-label">Edit</span>
124133
</button>
125134
126-
<button class="spectrum-Button spectrum-Button--fill spectrum-Button--accent spectrum-Button--sizeXL spectrum-Button--iconOnly" aria-label="Edit">
135+
<button class="spectrum-Button spectrum-Button--accent spectrum-Button--sizeXL spectrum-Button--iconOnly" aria-label="Edit">
127136
<svg class="spectrum-Icon spectrum-Icon--sizeXL" focusable="false" aria-hidden="true">
128137
<use xlink:href="#spectrum-icon-18-Edit" />
129138
</svg>
@@ -136,18 +145,18 @@ examples:
136145
markup: |
137146
<div class="spectrum-Examples">
138147
<div class="spectrum-Examples-item">
139-
<button class="spectrum-Button spectrum-Button--sizeM spectrum-Button--fill spectrum-Button--accent" disabled>
148+
<button class="spectrum-Button spectrum-Button--accent" disabled>
140149
<span class="spectrum-Button-label">Button</span>
141150
</button>
142151
143-
<button class="spectrum-Button spectrum-Button--sizeM spectrum-Button--fill spectrum-Button--accent" disabled>
152+
<button class="spectrum-Button spectrum-Button--accent" disabled>
144153
<svg class="spectrum-Icon spectrum-Icon--sizeM" focusable="false" aria-hidden="true">
145154
<use xlink:href="#spectrum-icon-18-Edit" />
146155
</svg>
147156
<span class="spectrum-Button-label">Edit</span>
148157
</button>
149158
150-
<button class="spectrum-Button spectrum-Button--sizeM spectrum-Button--fill spectrum-Button--accent spectrum-Button--iconOnly" aria-label="Edit" disabled>
159+
<button class="spectrum-Button spectrum-Button--accent spectrum-Button--iconOnly" aria-label="Edit" disabled>
151160
<svg class="spectrum-Icon spectrum-Icon--sizeM" focusable="false" aria-hidden="true">
152161
<use xlink:href="#spectrum-icon-18-Edit" />
153162
</svg>
@@ -182,18 +191,18 @@ examples:
182191
<div class="spectrum-Examples-item">
183192
<h4 class="spectrum-Heading spectrum-Heading--sizeXS spectrum-Examples-itemHeading">M (default)</h4>
184193
185-
<button class="spectrum-Button spectrum-Button--outline spectrum-Button--accent spectrum-Button--sizeM">
194+
<button class="spectrum-Button spectrum-Button--outline spectrum-Button--accent">
186195
<span class="spectrum-Button-label">Edit</span>
187196
</button>
188197
189-
<button class="spectrum-Button spectrum-Button--outline spectrum-Button--accent spectrum-Button--sizeM">
198+
<button class="spectrum-Button spectrum-Button--outline spectrum-Button--accent">
190199
<svg class="spectrum-Icon spectrum-Icon--sizeM" focusable="false" aria-hidden="true">
191200
<use xlink:href="#spectrum-icon-18-Edit" />
192201
</svg>
193202
<span class="spectrum-Button-label">Edit</span>
194203
</button>
195204
196-
<button class="spectrum-Button spectrum-Button--outline spectrum-Button--accent spectrum-Button--sizeM spectrum-Button--iconOnly" aria-label="Edit">
205+
<button class="spectrum-Button spectrum-Button--outline spectrum-Button--accent spectrum-Button--iconOnly" aria-label="Edit">
197206
<svg class="spectrum-Icon spectrum-Icon--sizeM" focusable="false" aria-hidden="true">
198207
<use xlink:href="#spectrum-icon-18-Edit" />
199208
</svg>
@@ -248,18 +257,18 @@ examples:
248257
markup: |
249258
<div class="spectrum-Examples">
250259
<div class="spectrum-Examples-item">
251-
<button class="spectrum-Button spectrum-Button--sizeM spectrum-Button--outline spectrum-Button--accent" disabled>
260+
<button class="spectrum-Button spectrum-Button--outline spectrum-Button--accent" disabled>
252261
<span class="spectrum-Button-label">Button</span>
253262
</button>
254263
255-
<button class="spectrum-Button spectrum-Button--sizeM spectrum-Button--outline spectrum-Button--accent" disabled>
264+
<button class="spectrum-Button spectrum-Button--outline spectrum-Button--accent" disabled>
256265
<svg class="spectrum-Icon spectrum-Icon--sizeM" focusable="false" aria-hidden="true">
257266
<use xlink:href="#spectrum-icon-18-Edit" />
258267
</svg>
259268
<span class="spectrum-Button-label">Edit</span>
260269
</button>
261270
262-
<button class="spectrum-Button spectrum-Button--sizeM spectrum-Button--outline spectrum-Button--accent spectrum-Button--iconOnly" aria-label="Edit" disabled>
271+
<button class="spectrum-Button spectrum-Button--outline spectrum-Button--accent spectrum-Button--iconOnly" aria-label="Edit" disabled>
263272
<svg class="spectrum-Icon spectrum-Icon--sizeM" focusable="false" aria-hidden="true">
264273
<use xlink:href="#spectrum-icon-18-Edit" />
265274
</svg>

0 commit comments

Comments
 (0)