Skip to content

Commit 0a23664

Browse files
feat(stepper): s2 number field/stepper migration (#3681)
* chore(numberfield): update package.json rootClass to NumberField * docs(numberfield): update template.js - updates rootClass to NumberField - imports new nested components - use inline infield buttons instead of separate stacked infield buttons - adds support for side label - updates templates for docs page - adds +/- functionality to number field * docs(numberfield): update stories for docs page - updates documentation to use number field language instead of stepper - imports new numberfield templates - adds support for displaying the field label, label position, help text and label text - adds side label, invalid states stories - updates some sentence-case display names for stories - removes quiet variant stories - updates display title to Number field - adds migrated tag/status - adds story for read-only state on docs page and expands on some documentation * docs(numberfield): adds more test coverage - updates any stepper language to number field - adds test coverage for hidden stepper, side label, help text, invalid, minimum width, and truncation - adds test case for focus + hover, keyboardFocus + hover, disabled+ keyboardFocus - adds min width size test cases - adds test cases * feat(numberfield): s2 style migration - new tokens used - cleans up/standardizes mod usage for textfield - cleans up/standardizes selectors so they are consistent across states/ variants - adds styles for read-only state - updates all custom properties to use numberfield prefix instead of stepper - adds style definitions for new features including hidden stepper, side label, help text, invalid, minimum width - uses textfield mods where possible to reduce the number of custom styles number field has - removes any textfield mods that are overwritten by number field styles - updates metadata - general clean up (stylelint warnings are addressed, some corrected mod definitions) * chore(numberfield): updates metadata.json * chore(numberfield): add changeset
1 parent d5e2951 commit 0a23664

File tree

10 files changed

+996
-561
lines changed

10 files changed

+996
-561
lines changed

.changeset/itchy-waves-work.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
"@spectrum-css/stepper": major
3+
---
4+
5+
### Number field S2 Migration
6+
7+
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:
8+
9+
- the display name for this component has changed from `stepper` to `number field` (based on design's, React's and SWC's naming conventions.)
10+
- _**Note:**_ The NPM package name has remained as "stepper," and hasn't yet changed to "number field.""
11+
- an error state with alert icon
12+
- optional help text
13+
- embedded field label & optional positions
14+
15+
#### Quick overview
16+
17+
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:
18+
19+
- All `.spectrum-Stepper*` class names have been converted to `.spectrum-NumberField*`
20+
- The `.hide-stepper` class has been converted to `.spectrum-NumberField--hiddenStepper`
21+
- Custom properties have been renamed from `--spectrum-stepper*` to `--spectrum-numberfield*`
22+
- Modifiable custom properties have been renamed from `--mod-stepper*` to `--mod-numberfield*`
23+
- Markup has changed
24+
- Styling lives on different elements
25+
- Lots more Chromatic test coverage
26+
27+
#### Markup
28+
29+
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`).
30+
31+
Stemming from the infield button S2 migration, there is also an extra container for the inline (previously "stacked") stepper buttons.
32+
33+
#### Styling
34+
35+
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`).
36+
37+
#### Mods
38+
39+
Modifiable custom properties have been renamed from `--mod-stepper*` to `--mod-numberfield`.
40+
41+
##### Removed custom properties include
42+
43+
--mod-stepper-animation-duration
44+
--mod-stepper-button-border-width
45+
--mod-stepper-button-width
46+
--mod-stepper-button-width-quiet
47+
--mod-stepper-buttons-background-color
48+
--mod-stepper-buttons-border-color
49+
--mod-stepper-buttons-border-color-focus
50+
--mod-stepper-buttons-border-color-focus-hover
51+
--mod-stepper-buttons-border-color-hover
52+
--mod-stepper-buttons-border-color-keyboard-focus
53+
--mod-stepper-buttons-border-style
54+
--mod-stepper-buttons-border-width
55+
--mod-stepper-focus-indicator-visibility
56+
--mod-stepper-height (renamed to --mod-numberfield-block-size)
57+
--mod-stepper-width (renamed to --mod-numberfield-inline-size)
58+
59+
##### New custom properties include
60+
61+
--mod-numberfield-background-color
62+
--mod-numberfield-background-color-disabled
63+
--mod-numberfield-block-size (renamed from --mod-stepper-height)
64+
--mod-numberfield-border-color-disabled
65+
--mod-numberfield-border-color-invalid-default
66+
--mod-numberfield-border-color-invalid-focus
67+
--mod-numberfield-border-color-invalid-focus-hover
68+
--mod-numberfield-border-color-invalid-hover
69+
--mod-numberfield-border-color-invalid-keyboard-focus
70+
--mod-numberfield-button-inline-offset
71+
--mod-numberfield-font-family
72+
--mod-numberfield-font-size
73+
--mod-numberfield-font-style
74+
--mod-numberfield-font-weight
75+
--mod-numberfield-hidden-stepper-min-inline-size
76+
--mod-numberfield-inline-size (renamed from --mod-stepper-width)
77+
--mod-numberfield-label-to-field
78+
--mod-numberfield-line-height
79+
--mod-numberfield-min-inline-size
80+
--mod-numberfield-spacing-block-end-edge-to-text
81+
--mod-numberfield-spacing-block-start-edge-to-text
82+
--mod-numberfield-spacing-field-to-helptext

components/form/stories/form.stories.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Template as Fieldgroup } from "@spectrum-css/fieldgroup/stories/template.js";
22
import { Template as Picker } from "@spectrum-css/picker/stories/template.js";
33
import { disableDefaultModes } from "@spectrum-css/preview/modes";
4-
import { Template as Stepper } from "@spectrum-css/stepper/stories/template.js";
4+
import { Template as NumberField } from "@spectrum-css/stepper/stories/template.js";
55
import { Template as TextField } from "@spectrum-css/textfield/stories/template.js";
66
import metadata from "../dist/metadata.json";
77
import packageJson from "../package.json";
@@ -97,7 +97,7 @@ export default {
9797
label: "Age",
9898
id: "form-example-amount",
9999
content: [
100-
(passthroughs, context) => Stepper({
100+
(passthroughs, context) => NumberField({
101101
...passthroughs,
102102
}, context),
103103
]

components/infieldbutton/stories/template.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const Template = (
2020
isActive,
2121
isInline,
2222
tabIndex = 0,
23-
onMinus,
23+
onSubtract,
2424
onAdd,
2525
onclick,
2626
} = {},
@@ -44,7 +44,7 @@ export const Template = (
4444
...customClasses.reduce((a, c) => ({ ...a, [c]: true }), {}),
4545
})}
4646
?disabled=${isDisabled}
47-
@click=${onMinus}
47+
@click=${onSubtract}
4848
aria-haspopup="listbox"
4949
type="button"
5050
tabindex=${tabIndex}

0 commit comments

Comments
 (0)