Skip to content

feat(stepper): s2 number field/stepper migration #3681

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
3a28b43
chore(numberfield): update package.json rootClass to NumberField
marissahuysentruyt Apr 23, 2025
6c87417
docs(numberfield): update template.js
marissahuysentruyt Apr 23, 2025
010e080
docs(numberfield): update stories for docs page
marissahuysentruyt Apr 23, 2025
24bd4a2
docs(numberfield): adds more test coverage
marissahuysentruyt Apr 23, 2025
eb1e689
feat(numberfield): s2 style migration
marissahuysentruyt Apr 23, 2025
1f1785a
fix(form): updates number field language in comments
marissahuysentruyt Apr 23, 2025
e26d1d1
chore(numberfield): updates metadata.json
marissahuysentruyt Apr 23, 2025
c77a857
chore(form): add changeset
marissahuysentruyt Apr 23, 2025
4c5925d
chore(numberfield): add changeset
marissahuysentruyt Apr 23, 2025
d57d6de
fix(numberfield): linter fixes and update metadata
marissahuysentruyt Apr 23, 2025
bf3cc74
chore(numberfield): clean up testing file
marissahuysentruyt Apr 29, 2025
0d87c3e
docs(numberfield): corrects grammar, adds migrated tag/status
marissahuysentruyt Apr 29, 2025
3a81f7b
chore(numberfield): linting, remove displayLabel
marissahuysentruyt Apr 29, 2025
4ae151b
chore(numberfield): adds min width size test cases
marissahuysentruyt Apr 29, 2025
a21f6ce
refactor(numberfield): address textfield mods
marissahuysentruyt Apr 29, 2025
1c9e832
fix(numberfield): add readOnly state
marissahuysentruyt Apr 30, 2025
d84c403
docs(numberfield): adds functionality to number field
marissahuysentruyt Apr 30, 2025
0281733
docs(numberfield): add more documentation
marissahuysentruyt May 6, 2025
f258a77
chore(form): revert comment change and changeset
marissahuysentruyt May 6, 2025
1a2db66
fix(numberfield): adjust calc for input to stepper spacing
marissahuysentruyt May 7, 2025
b67c1d4
fix(numberfield): accommodate border width in inline padding
marissahuysentruyt May 7, 2025
a3d06b5
fix(numberfield): adjust calc for input to stepper spacing
marissahuysentruyt May 7, 2025
86e55f1
fix(numberfield): adjust calc for input to stepper spacing
marissahuysentruyt May 7, 2025
bd77043
fix(numberfield): add offset to inline-end padding
marissahuysentruyt May 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions .changeset/itchy-waves-work.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
"@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*`
- 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
4 changes: 2 additions & 2 deletions components/form/stories/form.stories.js
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -97,7 +97,7 @@ export default {
label: "Age",
id: "form-example-amount",
content: [
(passthroughs, context) => Stepper({
(passthroughs, context) => NumberField({
...passthroughs,
}, context),
]
Expand Down
4 changes: 2 additions & 2 deletions components/infieldbutton/stories/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const Template = (
isActive,
isInline,
tabIndex = 0,
onMinus,
onSubtract,
onAdd,
onclick,
} = {},
Expand All @@ -44,7 +44,7 @@ export const Template = (
...customClasses.reduce((a, c) => ({ ...a, [c]: true }), {}),
})}
?disabled=${isDisabled}
@click=${onMinus}
@click=${onSubtract}
aria-haspopup="listbox"
type="button"
tabindex=${tabIndex}
Expand Down
Loading
Loading