@trading-game/design-intelligence-layer 1.0.6 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +12 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +12 -5
- package/dist/index.js.map +1 -1
- package/docs/components/stepper.md +9 -6
- package/docs/foundations/typography.md +12 -0
- package/package.json +1 -1
- package/src/styles.css +7 -7
|
@@ -12,17 +12,17 @@ The mobile amount tray — a centred amount with frosted − / + circles either
|
|
|
12
12
|
|
|
13
13
|
- Container — full-width row, `data-slot="stepper"`, `data-disabled`.
|
|
14
14
|
- − / + — composed `<Button variant="frosted" size="icon-lg">` (48px brand-selected tint circles); each disables at its bound.
|
|
15
|
-
- Two rows — the optional
|
|
15
|
+
- Two rows — the optional sentence-case `label` spans the whole control, then a 4px gap, then the `−` / amount / `+` row. The label is deliberately **not** nested in the value column: doing so made the buttons centre against the label-plus-amount stack, which dropped them off the amount's centre line.
|
|
16
16
|
- Centre of the row — the editable amount (`role="spinbutton"`, tabular semibold figure), flanked by the two circles.
|
|
17
17
|
|
|
18
18
|
## API
|
|
19
19
|
|
|
20
20
|
| Prop | Type | Default | Notes |
|
|
21
21
|
| --- | --- | --- | --- |
|
|
22
|
-
| `label` | `ReactNode` | — |
|
|
22
|
+
| `label` | `ReactNode` | — | Sentence-case caption above the amount, e.g. `"Stake (USDT)"`. Renders in the shared `caption` type style, so a Stepper sits level with other captioned controls in a form row. |
|
|
23
23
|
| `value` / `defaultValue` | `number` | `0` | Controlled / uncontrolled. |
|
|
24
24
|
| `onValueChange` | `(n: number) => void` | — | |
|
|
25
|
-
| `min` / `max` | `number` | ±∞ | Buttons disable at the bounds; typed values clamp on commit. |
|
|
25
|
+
| `min` / `max` | `number` | ±∞ | Buttons disable at the bounds; typed values clamp on commit. Bounds need not sit on the step grid — `min={0.5} step={1}` is legal and `0.5` is exactly reachable. |
|
|
26
26
|
| `step` | `number` | `1` | Decimal steps set the display precision (0.5 → "2.50"). |
|
|
27
27
|
| `disabled` | `boolean` | `false` | Pointer events off; the `+`/`−` render Button's own disabled state and the label and amount switch to `text-disabled-default`. No wash on the wrapper — stacking one over the Buttons' own dim multiplied to ~6% and made them invisible. |
|
|
28
28
|
| `placeholder`, `id`, `name`, `aria-label` | | — | Pass-through to the amount input. |
|
|
@@ -41,12 +41,13 @@ import { Stepper } from "@trading-game/design-intelligence-layer"
|
|
|
41
41
|
|
|
42
42
|
| Token | Value |
|
|
43
43
|
| --- | --- |
|
|
44
|
-
| `--stepper-stake-label-*` | 12 / medium / 16
|
|
45
|
-
| `--stepper-stake-amount-*` |
|
|
44
|
+
| `--stepper-stake-label-*` | Aliases `--type-caption-*` — 12 / medium / 16 / `tracking-loose`, sentence case |
|
|
45
|
+
| `--stepper-stake-amount-*` | 20 / semibold / 28, tabular — matches [Numpad](./numpad.md)'s digit size |
|
|
46
46
|
|
|
47
47
|
## Behaviour
|
|
48
48
|
|
|
49
|
-
- The amount is directly editable: type, then blur or Enter commits
|
|
49
|
+
- The amount is directly editable: type, then blur or Enter commits; ArrowUp/ArrowDown step the value.
|
|
50
|
+
- **The bounds are exempt from step rounding.** A value at or past a bound commits as exactly that bound; only values strictly inside the range are rounded to the step's precision (then clamped as a backstop). So `min`/`max` are both exactly *reachable* and *stable* even when they sit off the step grid: with `min={0.5} step={1}`, decrementing from `1` lands on `0.5` and stays there across blur and re-commit. Rounding a bound would move the value off it — `Math.round(0.5)` is `1` — and a clamp afterwards can't undo that, since `1` is inside the range; the pre-1.0.7 component rounded after clamping and so returned `1` forever, making `min` unreachable.
|
|
50
51
|
- `onValueChange` fires with the committed number.
|
|
51
52
|
- Full-width by default — constrain with `className` (`max-w-90` in the demo).
|
|
52
53
|
|
|
@@ -54,8 +55,10 @@ import { Stepper } from "@trading-game/design-intelligence-layer"
|
|
|
54
55
|
|
|
55
56
|
**Do**
|
|
56
57
|
- Put the unit in the `label` ("Stake (USDT)").
|
|
58
|
+
- Write `label` copy in sentence case; currency codes stay capitalised as proper nouns.
|
|
57
59
|
- Pair with [Numpad](./numpad.md) on mobile amount screens.
|
|
58
60
|
|
|
59
61
|
**Don't**
|
|
60
62
|
- Don't use it for long-range values — that's [Slider](./slider.md).
|
|
61
63
|
- Don't hide the label on money amounts; the unit matters.
|
|
64
|
+
- Don't hand-roll a caption above a Stepper to dodge the label's case — use `label`.
|
|
@@ -68,6 +68,18 @@ Recurring ladders:
|
|
|
68
68
|
- **Overlay titles** (Dialog, Alert Dialog, Drawer, Sheet, Empty): 18/semibold/24; their descriptions 14/regular/20.
|
|
69
69
|
- **Small labels** (Badge sm, Kbd-like chips, Sidebar labels, Bottom Navigation, menu headings): 12/16, medium.
|
|
70
70
|
- **Helper text** (Field description/error): fixed **12/16 at every field size** — help text never scales with the control.
|
|
71
|
+
- **Standalone figures** (Stepper amount, Input OTP, Numpad keys): **20/28**. Weight varies with the job — the Stepper amount and OTP are semibold, Numpad keys medium — but the size is fixed, so a value typed on the pad reads at the same size in the tray above it. Only the Stepper amount adds `tabular-nums`, since it is the one that changes in place while the user holds `−` / `+`.
|
|
72
|
+
|
|
73
|
+
### Aliasing a foundation style
|
|
74
|
+
|
|
75
|
+
A component token normally points at a **primitive** step. Point it at a **semantic** `--type-*` instead when the component's text does the same job as a foundation style, so the two cannot drift apart:
|
|
76
|
+
|
|
77
|
+
```css
|
|
78
|
+
--stepper-stake-label-font-size: var(--type-caption-size);
|
|
79
|
+
--stepper-stake-label-tracking: var(--type-caption-tracking);
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
The Stepper's `label` names the control beneath it — a caption's job — so it aliases `--type-caption-*` rather than re-declaring 12/16. Reserve this for a genuine role match: aliasing because two things happen to share a size today just couples them by accident.
|
|
71
83
|
|
|
72
84
|
## The one shared family: `--menu-*`
|
|
73
85
|
|
package/package.json
CHANGED
package/src/styles.css
CHANGED
|
@@ -1165,12 +1165,13 @@
|
|
|
1165
1165
|
--bottom-navigation-label-active-font-weight: var(--primitive-font-weight-semibold);
|
|
1166
1166
|
|
|
1167
1167
|
/* ── Stepper (stake variant) — component type tokens (private) ── */
|
|
1168
|
-
--stepper-stake-label-font-size: var(--
|
|
1169
|
-
--stepper-stake-label-font-weight: var(--
|
|
1170
|
-
--stepper-stake-label-line-height: var(--
|
|
1171
|
-
--stepper-stake-
|
|
1168
|
+
--stepper-stake-label-font-size: var(--type-caption-size);
|
|
1169
|
+
--stepper-stake-label-font-weight: var(--type-caption-weight);
|
|
1170
|
+
--stepper-stake-label-line-height: var(--type-caption-line);
|
|
1171
|
+
--stepper-stake-label-tracking: var(--type-caption-tracking);
|
|
1172
|
+
--stepper-stake-amount-font-size: var(--primitive-font-size-20);
|
|
1172
1173
|
--stepper-stake-amount-font-weight: var(--primitive-font-weight-semibold);
|
|
1173
|
-
--stepper-stake-amount-line-height: var(--primitive-line-height-
|
|
1174
|
+
--stepper-stake-amount-line-height: var(--primitive-line-height-28);
|
|
1174
1175
|
|
|
1175
1176
|
/* ── Progress — component type tokens (private) ── */
|
|
1176
1177
|
--progress-label-font-size: var(--primitive-font-size-12);
|
|
@@ -1981,8 +1982,7 @@
|
|
|
1981
1982
|
font-size: var(--stepper-stake-label-font-size);
|
|
1982
1983
|
line-height: var(--stepper-stake-label-line-height);
|
|
1983
1984
|
font-weight: var(--stepper-stake-label-font-weight);
|
|
1984
|
-
letter-spacing:
|
|
1985
|
-
text-transform: uppercase;
|
|
1985
|
+
letter-spacing: var(--stepper-stake-label-tracking);
|
|
1986
1986
|
}
|
|
1987
1987
|
|
|
1988
1988
|
.type-stepper-stake-amount {
|