@newtone-dev/ui-react-web 0.2.0 → 0.5.0
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/README.md +40 -14
- package/dist/action/action.css +64 -5
- package/dist/action/action.d.ts +22 -1
- package/dist/action/action.d.ts.map +1 -1
- package/dist/action/action.js +16 -2
- package/dist/action/action.js.map +1 -1
- package/dist/button/button.css +81 -5
- package/dist/button/button.d.ts +24 -1
- package/dist/button/button.d.ts.map +1 -1
- package/dist/button/button.js +12 -2
- package/dist/button/button.js.map +1 -1
- package/dist/control/control.css +49 -23
- package/dist/control/control.d.ts +33 -9
- package/dist/control/control.d.ts.map +1 -1
- package/dist/control/control.js +31 -17
- package/dist/control/control.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/navbar/link/drawer/drawer.css +4 -3
- package/dist/navbar/link/link.css +15 -3
- package/dist/navbar/menu-button/menu-button.css +10 -3
- package/dist/navbar/navbar.css +186 -4
- package/dist/navbar/navbar.d.ts +33 -1
- package/dist/navbar/navbar.d.ts.map +1 -1
- package/dist/navbar/navbar.js +4 -2
- package/dist/navbar/navbar.js.map +1 -1
- package/dist/page/band.d.ts +52 -0
- package/dist/page/band.d.ts.map +1 -0
- package/dist/page/band.js +36 -0
- package/dist/page/band.js.map +1 -0
- package/dist/page/index.d.ts +4 -0
- package/dist/page/index.d.ts.map +1 -0
- package/dist/page/index.js +8 -0
- package/dist/page/index.js.map +1 -0
- package/dist/page/page.css +240 -0
- package/dist/page/page.d.ts +137 -0
- package/dist/page/page.d.ts.map +1 -0
- package/dist/page/page.js +29 -0
- package/dist/page/page.js.map +1 -0
- package/dist/quick-action/quick-action.css +36 -7
- package/dist/quick-action/quick-action.d.ts +26 -6
- package/dist/quick-action/quick-action.d.ts.map +1 -1
- package/dist/quick-action/quick-action.js +11 -7
- package/dist/quick-action/quick-action.js.map +1 -1
- package/dist/wrapper/wrapper.d.ts +11 -2
- package/dist/wrapper/wrapper.d.ts.map +1 -1
- package/dist/wrapper/wrapper.js +5 -1
- package/dist/wrapper/wrapper.js.map +1 -1
- package/package.json +6 -1
package/README.md
CHANGED
|
@@ -9,18 +9,31 @@ Newtone's component library for React on the web.
|
|
|
9
9
|
|
|
10
10
|
## What is here
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
**Twenty-six components and a colour port.** `ls src/*/index.ts` is the complete public API that
|
|
13
|
+
JavaScript can reach; `package.json`'s `exports` map is the complete one including stylesheets.
|
|
14
|
+
**This table is the spine and not the list** — the blueprint above carries every component.
|
|
15
15
|
|
|
16
16
|
| | |
|
|
17
17
|
| --- | --- |
|
|
18
18
|
| `Surface` | Owns the context its contents read: `theme`, `elevation`, `mode` |
|
|
19
|
-
| `Button` | Discharges `contracts/button.md`. Three variants, five states |
|
|
19
|
+
| `Button` | Discharges `contracts/button.md`. Three variants, five states, **three size rungs** |
|
|
20
20
|
| `Text` | Discharges `contracts/typography.md`. `font`, `weight`, `case`, `figures`, `ligatures` |
|
|
21
|
+
| `Navbar` | Discharges `contracts/navbar.md`. Parts and knobs; arrangements belong to the site |
|
|
21
22
|
| `Identity` | A scoped seed set: re-derives colour for one subtree |
|
|
22
23
|
| `color.ts` | A port of `contracts/color-derivation.md` — the runtime half of identity |
|
|
23
24
|
|
|
25
|
+
### Control sizes
|
|
26
|
+
|
|
27
|
+
**Every control here is one of five heights — 36, 40, 44, 48, 56 — on one of two type pairs,
|
|
28
|
+
14/20 or 16/24.** A `size` prop picks a rung and the rung carries its height, its type pair, its
|
|
29
|
+
glyph and its padding together; there is no second axis. `contracts/button.md`, *Sizes*.
|
|
30
|
+
|
|
31
|
+
| | `sm` | `md` | `lg` |
|
|
32
|
+
| --- | --- | --- | --- |
|
|
33
|
+
| `Control` | 36 | 40 | 44 |
|
|
34
|
+
| `Button`, `Navbar` | 40 | 44 | 48 |
|
|
35
|
+
| `Action`, `QuickAction` | 48 | — | 56 |
|
|
36
|
+
|
|
24
37
|
## The idea in one example
|
|
25
38
|
|
|
26
39
|
```tsx
|
|
@@ -64,20 +77,33 @@ The derivation is computed, not tabulated: fifty-one steps spaced evenly in CIE
|
|
|
64
77
|
chroma taken from the Display P3 ceiling. `src/color.ts` and the tokens repo's
|
|
65
78
|
`compute/` are two implementations of one contract and must produce the same bytes.
|
|
66
79
|
|
|
67
|
-
##
|
|
80
|
+
## The build
|
|
68
81
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
82
|
+
`npm run build` — `tsc` to `dist/`, then `copy-styles.mjs`, which walks `src` and copies all 29
|
|
83
|
+
stylesheets across verbatim because `tsc` emits no CSS. `dist/` is gitignored and built on publish
|
|
84
|
+
by `prepublishOnly`; there is no bundler.
|
|
85
|
+
|
|
86
|
+
**This section said *There is no build* until 2026-09-21**, and had been wrong since the build
|
|
87
|
+
landed. `tsconfig.json` sets `"module": "NodeNext"`, which is why every relative import here carries
|
|
88
|
+
an explicit extension — a bundler resolved `from './button'` and Node ESM does not.
|
|
72
89
|
|
|
73
90
|
## Consuming
|
|
74
91
|
|
|
75
|
-
|
|
92
|
+
**Published to npm as `@newtone-dev/ui-react-web`.** It declares `react` as a peer (`^18 || ^19`)
|
|
93
|
+
and does **not** depend on `@newtone-dev/ui-tokens`: every component reads `--newtone-*` custom
|
|
94
|
+
properties by name, and supplying them is the consuming site's job.
|
|
95
|
+
|
|
96
|
+
```sh
|
|
97
|
+
npm install @newtone-dev/ui-react-web @newtone-dev/ui-tokens
|
|
98
|
+
```
|
|
76
99
|
|
|
77
100
|
```ts
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
alias: [
|
|
81
|
-
{ find: /^@newtone\/ui-react-web$/, replacement: '<path>/newtone_ui_react-web/src/index.ts' },
|
|
82
|
-
]
|
|
101
|
+
import { Surface, Button } from '@newtone-dev/ui-react-web'
|
|
102
|
+
import '@newtone-dev/ui-react-web/button.css'
|
|
83
103
|
```
|
|
104
|
+
|
|
105
|
+
**Stylesheets are imported one at a time, per component**, and every path a consumer may import is a
|
|
106
|
+
key in the `exports` map. `sideEffects` names `**/*.css` so a bundler keeps them.
|
|
107
|
+
|
|
108
|
+
**This section said *Nothing is published to npm* until 2026-09-21**, three weeks after
|
|
109
|
+
`publishConfig.access` and `prepublishOnly` were added.
|
package/dist/action/action.css
CHANGED
|
@@ -42,11 +42,43 @@
|
|
|
42
42
|
align-items: center;
|
|
43
43
|
justify-content: center;
|
|
44
44
|
gap: var(--newtone-action-gap);
|
|
45
|
-
|
|
45
|
+
|
|
46
|
+
/* THE RUNG ARRIVES THROUGH FOUR LOCAL PROPERTIES the size rules below set. That indirection is
|
|
47
|
+
* what keeps `--icon-end` below a single rule -- it resolves the same `--newtone-action-pad-y`
|
|
48
|
+
* without knowing which rung set it -- and what lets the published height name its two numbers
|
|
49
|
+
* once. contracts/button.md, *Sizes*. */
|
|
50
|
+
/* THE BORDER IS SUBTRACTED FROM THE BLOCK PADDING so the rung names the OUTER box, which is
|
|
51
|
+
* what a ladder of heights has to mean -- `Control` has done this since it landed. Without it
|
|
52
|
+
* this rendered 46 against a 44 rung, measured on a page rather than read off this file:
|
|
53
|
+
* governance/evidence/verify-what-renders-not-what-was-written.md. The inline axis is NOT
|
|
54
|
+
* adjusted, because it is a proportion rather than a rung. */
|
|
55
|
+
/* THE INLINE PADDING IS DERIVED AND NOT AUTHORED, from 2026-09-21 late.
|
|
56
|
+
*
|
|
57
|
+
* Joshua, that day: *"48px buttons should have 12/20 paddings, depending on icon/text being on
|
|
58
|
+
* that side. And from there we should implement similar proportions on the bigger and smaller
|
|
59
|
+
* buttons."* A 48 box is 24 of leading in 2 x 12, so **12 IS ITS BLOCK PADDING** -- his glyph
|
|
60
|
+
* number is not a new value, it is the one the rung already has. And 20 is that plus one gap,
|
|
61
|
+
* which is governance/code/an-icon-and-the-text-beside-it-do-not-take-the-same-padding.md
|
|
62
|
+
* stated as arithmetic: *the difference is the component's own gap and never a new number.*
|
|
63
|
+
*
|
|
64
|
+
* SO ONE RELATION REPLACES A VALUE PER RUNG, and every rung gets his proportions for free:
|
|
65
|
+
* 36 -> 8/16, 40 -> 10/18, 44 -> 12/20, 48 -> 12/20, 56 -> 16/24. **44 and 48 share an inset
|
|
66
|
+
* on purpose** -- both hold their type in 12px of clear space, which is what the inset measures.
|
|
67
|
+
*
|
|
68
|
+
* THE BORDER IS SUBTRACTED ON BOTH AXES so these are rim-to-text distances rather than padding
|
|
69
|
+
* box numbers. Without it a 48 button reads 21 on the side he said should read 20. */
|
|
70
|
+
padding: calc(var(--newtone-action-pad-y) - 1px)
|
|
71
|
+
calc(var(--newtone-action-pad-y) + var(--newtone-action-gap) - 1px);
|
|
46
72
|
font-family: var(--newtone-action-label-family);
|
|
47
|
-
font-size: var(--newtone-action-
|
|
73
|
+
font-size: var(--newtone-action-text-size);
|
|
48
74
|
font-weight: var(--newtone-action-label-weight);
|
|
49
|
-
line-height: var(--newtone-action-
|
|
75
|
+
line-height: var(--newtone-action-text-leading);
|
|
76
|
+
|
|
77
|
+
/* PUBLISHED, NEVER DECLARED -- issues/open/156. `sm` comes to 48, which is Button's `lg`, and a
|
|
78
|
+
* row holding one of each can now read both instead of a consumer tuning one until it matches.
|
|
79
|
+
* Read it; writing it changes no geometry, because the box is the padding. */
|
|
80
|
+
--newtone-action-height: calc(var(--newtone-action-text-leading) + 2 * var(--newtone-action-pad-y));
|
|
81
|
+
|
|
50
82
|
border: 1px solid;
|
|
51
83
|
border-radius: var(--newtone-action-radius);
|
|
52
84
|
cursor: pointer;
|
|
@@ -74,10 +106,37 @@
|
|
|
74
106
|
outline-offset: 2px;
|
|
75
107
|
}
|
|
76
108
|
|
|
109
|
+
/* ---- the rungs ----------------------------------------------------------
|
|
110
|
+
*
|
|
111
|
+
* 48 and 56 -- the top two of the ladder's five. contracts/button.md, *Sizes*.
|
|
112
|
+
*
|
|
113
|
+
* BOTH TAKE 16/24, so only the box grows. That is what being at the top means here: an Action is
|
|
114
|
+
* *the one thing a page is asking for*, and the two rungs are how loudly, not how much it says.
|
|
115
|
+
*
|
|
116
|
+
* THE LABEL USED TO BE 18/21.6 -- `typography.size.lg` on a ratio -- against a 24px glyph. Three
|
|
117
|
+
* numbers from three places, and 21.6 chosen by nobody. Each rung now names both leaves of one
|
|
118
|
+
* step. issues/open/157. */
|
|
119
|
+
.newtone-action--sm {
|
|
120
|
+
--newtone-action-pad-y: var(--newtone-action-size-sm-padding-y);
|
|
121
|
+
--newtone-action-text-size: var(--newtone-action-size-sm-label-size);
|
|
122
|
+
--newtone-action-text-leading: var(--newtone-action-size-sm-label-line-height);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.newtone-action--lg {
|
|
126
|
+
--newtone-action-pad-y: var(--newtone-action-size-lg-padding-y);
|
|
127
|
+
--newtone-action-text-size: var(--newtone-action-size-lg-label-size);
|
|
128
|
+
--newtone-action-text-leading: var(--newtone-action-size-lg-label-line-height);
|
|
129
|
+
}
|
|
130
|
+
|
|
77
131
|
/* One class, so it publishes at the same 0,1,0 as everything else here, and it touches a property
|
|
78
|
-
* `--fill` does not -- the two compose in either order.
|
|
132
|
+
* `--fill` does not -- the two compose in either order.
|
|
133
|
+
*
|
|
134
|
+
* IT READS THE RUNG'S PADDING AND NOT A TOKEN, so one rule serves both rungs: 24 becomes 16 at
|
|
135
|
+
* `lg`, 20 becomes 12 at `sm`. The gap is 8 at every rung -- deliberately off the ladder -- so the
|
|
136
|
+
* difference between the word's rim and the glyph's is one constant and cannot be recomputed wrong
|
|
137
|
+
* per rung. governance/code/an-icon-and-the-text-beside-it-do-not-take-the-same-padding.md. */
|
|
79
138
|
.newtone-action--icon-end {
|
|
80
|
-
padding-inline-end: calc(var(--newtone-action-
|
|
139
|
+
padding-inline-end: calc(var(--newtone-action-pad-y) - 1px);
|
|
81
140
|
}
|
|
82
141
|
|
|
83
142
|
.newtone-action--fill {
|
package/dist/action/action.d.ts
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
import type { AnchorHTMLAttributes, ButtonHTMLAttributes } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Two rungs of the ladder's five: **48 and 56**, the top of it.
|
|
4
|
+
*
|
|
5
|
+
* AN ACTION IS ABOVE A BUTTON AT BOTH, which is the whole of what this component is -- *a pill,
|
|
6
|
+
* larger than a Button*, with no `variant`, because a second task would mean neither is the task.
|
|
7
|
+
* contracts/button.md, *Sizes*.
|
|
8
|
+
*
|
|
9
|
+
* `sm` IS 48, WHICH IS ALSO BUTTON'S `lg`, ON PURPOSE. adenario_website's hero holds one of each
|
|
10
|
+
* and had been keeping them level with three hand-tuned custom properties in its own scope --
|
|
11
|
+
* issues/open/156. They now agree because both name a rung, and both publish their height.
|
|
12
|
+
*/
|
|
13
|
+
export type ActionSize = 'sm' | 'lg';
|
|
2
14
|
interface ActionCommon {
|
|
3
15
|
/** The action's words. Required and always rendered -- an action is a specific, named ask. */
|
|
4
16
|
label: string;
|
|
@@ -13,6 +25,15 @@ interface ActionCommon {
|
|
|
13
25
|
* `action.css` and governance/code/an-icon-and-the-text-beside-it-do-not-take-the-same-padding.md.
|
|
14
26
|
*/
|
|
15
27
|
iconEnd?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Which rung: 48 or 56. Defaults to `lg`, which is 56 -- where the one existing call site
|
|
30
|
+
* already was, so nothing on any page moves by more than half a pixel.
|
|
31
|
+
*
|
|
32
|
+
* **The label moves a lot even though the box does not.** It was `typography.size.lg` on a
|
|
33
|
+
* ratio -- 18/21.6 -- and is now the 16/24 step at both rungs. A reader sees that and not the
|
|
34
|
+
* 0.4px the box gained.
|
|
35
|
+
*/
|
|
36
|
+
size?: ActionSize;
|
|
16
37
|
/** Stretch to the container's inline size -- a phone's call to action, a card's footer. */
|
|
17
38
|
fill?: boolean;
|
|
18
39
|
}
|
|
@@ -57,6 +78,6 @@ export type ActionProps = ActionCommon & ((Omit<ButtonHTMLAttributes<HTMLButtonE
|
|
|
57
78
|
* does nothing, which is an honest placeholder and not a form control: `type="button"` is
|
|
58
79
|
* hardcoded, so it cannot submit a form it happens to be standing in.
|
|
59
80
|
*/
|
|
60
|
-
export declare function Action({ label, ariaLabel, iconEnd, fill, className, ...rest }: ActionProps): import("react").JSX.Element;
|
|
81
|
+
export declare function Action({ label, ariaLabel, iconEnd, size, fill, className, ...rest }: ActionProps): import("react").JSX.Element;
|
|
61
82
|
export {};
|
|
62
83
|
//# sourceMappingURL=action.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../src/action/action.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAA;AAGvE,UAAU,YAAY;IAClB,8FAA8F;IAC9F,KAAK,EAAE,MAAM,CAAA;IACb,qFAAqF;IACrF,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,2FAA2F;IAC3F,IAAI,CAAC,EAAE,OAAO,CAAA;CACjB;AAED,MAAM,MAAM,WAAW,GAAG,YAAY,GAClC,CACM,CAAC,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC,GAAG;IACxE,IAAI,CAAC,EAAE,SAAS,CAAA;CACnB,CAAC,GACF,CAAC,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,YAAY,CAAC,GAAG;IACjF,4EAA4E;IAC5E,IAAI,EAAE,MAAM,CAAA;CACf,CAAC,CACP,CAAA;AAEL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,MAAM,CAAC,EACnB,KAAK,EACL,SAAS,EACT,OAAO,EACP,IAAY,EACZ,SAAS,EACT,GAAG,IAAI,EACV,EAAE,WAAW,+
|
|
1
|
+
{"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../src/action/action.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAA;AAGvE;;;;;;;;;;GAUG;AACH,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,CAAA;AAgBpC,UAAU,YAAY;IAClB,8FAA8F;IAC9F,KAAK,EAAE,MAAM,CAAA;IACb,qFAAqF;IACrF,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,UAAU,CAAA;IACjB,2FAA2F;IAC3F,IAAI,CAAC,EAAE,OAAO,CAAA;CACjB;AAED,MAAM,MAAM,WAAW,GAAG,YAAY,GAClC,CACM,CAAC,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC,GAAG;IACxE,IAAI,CAAC,EAAE,SAAS,CAAA;CACnB,CAAC,GACF,CAAC,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,YAAY,CAAC,GAAG;IACjF,4EAA4E;IAC5E,IAAI,EAAE,MAAM,CAAA;CACf,CAAC,CACP,CAAA;AAEL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,MAAM,CAAC,EACnB,KAAK,EACL,SAAS,EACT,OAAO,EACP,IAAW,EACX,IAAY,EACZ,SAAS,EACT,GAAG,IAAI,EACV,EAAE,WAAW,+BA6Cb"}
|
package/dist/action/action.js
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Icon } from '../icon/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* THE GLYPH THAT PAIRS WITH EACH RUNG'S LABEL LEADING.
|
|
5
|
+
*
|
|
6
|
+
* Both rungs take 16/24, so both take the 24px mark. **It is a map and not a constant** because the
|
|
7
|
+
* pairing is the fact: a glyph is sized to the leading of the text beside it, and a rung that took
|
|
8
|
+
* 14/20 would take 20. governance/code/an-icon-and-the-text-beside-it-share-one-size-and-leading-pair.md.
|
|
9
|
+
*
|
|
10
|
+
* IT WAS `size="md"` WRITTEN INTO THE RENDER until 2026-09-21, against a label of 18/21.6 -- so the
|
|
11
|
+
* glyph belonged to the 16/24 pair, the size belonged to no pair at all, and the leading was 2.4px
|
|
12
|
+
* short of the mark it stood against. issues/open/157 named it in those words: *a size written into
|
|
13
|
+
* the render is a size that cannot follow the component's own step*.
|
|
14
|
+
*/
|
|
15
|
+
const GLYPH = { sm: 'md', lg: 'md' };
|
|
3
16
|
/**
|
|
4
17
|
* The one thing a page is asking for.
|
|
5
18
|
*
|
|
@@ -35,12 +48,13 @@ import { Icon } from '../icon/index.js';
|
|
|
35
48
|
* does nothing, which is an honest placeholder and not a form control: `type="button"` is
|
|
36
49
|
* hardcoded, so it cannot submit a form it happens to be standing in.
|
|
37
50
|
*/
|
|
38
|
-
export function Action({ label, ariaLabel, iconEnd, fill = false, className, ...rest }) {
|
|
51
|
+
export function Action({ label, ariaLabel, iconEnd, size = 'lg', fill = false, className, ...rest }) {
|
|
39
52
|
// `--icon-end` is keyed on the glyph being PRESENT and not on the prop being declared, because
|
|
40
53
|
// the class does one thing -- take a gap off the padding on the glyph's side -- and a pill with
|
|
41
54
|
// no glyph in it would be 16px short on one side for nothing. See action.css.
|
|
42
55
|
const classes = [
|
|
43
56
|
'newtone-action',
|
|
57
|
+
`newtone-action--${size}`,
|
|
44
58
|
iconEnd === undefined ? null : 'newtone-action--icon-end',
|
|
45
59
|
fill ? 'newtone-action--fill' : null,
|
|
46
60
|
className,
|
|
@@ -49,7 +63,7 @@ export function Action({ label, ariaLabel, iconEnd, fill = false, className, ...
|
|
|
49
63
|
.join(' ');
|
|
50
64
|
// The label is always present, so the control always has a name and the glyph is decorative.
|
|
51
65
|
// `Icon` writes its own `aria-hidden`.
|
|
52
|
-
const content = (_jsxs(_Fragment, { children: [_jsx("span", { className: "newtone-action-label", children: label }), iconEnd === undefined ? null : _jsx(Icon, { name: iconEnd, size:
|
|
66
|
+
const content = (_jsxs(_Fragment, { children: [_jsx("span", { className: "newtone-action-label", children: label }), iconEnd === undefined ? null : _jsx(Icon, { name: iconEnd, size: GLYPH[size] })] }));
|
|
53
67
|
if (rest.href !== undefined) {
|
|
54
68
|
const { href, ...anchor } = rest;
|
|
55
69
|
return (_jsx("a", { href: href, className: classes, "aria-label": ariaLabel, ...anchor, children: content }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action.js","sourceRoot":"","sources":["../../src/action/action.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"action.js","sourceRoot":"","sources":["../../src/action/action.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAiB,MAAM,kBAAkB,CAAA;AAetD;;;;;;;;;;;GAWG;AACH,MAAM,KAAK,GAAiC,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,CAAA;AAwClE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,UAAU,MAAM,CAAC,EACnB,KAAK,EACL,SAAS,EACT,OAAO,EACP,IAAI,GAAG,IAAI,EACX,IAAI,GAAG,KAAK,EACZ,SAAS,EACT,GAAG,IAAI,EACG;IACV,+FAA+F;IAC/F,gGAAgG;IAChG,8EAA8E;IAC9E,MAAM,OAAO,GAAG;QACZ,gBAAgB;QAChB,mBAAmB,IAAI,EAAE;QACzB,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,0BAA0B;QACzD,IAAI,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,IAAI;QACpC,SAAS;KACZ;SACI,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,GAAG,CAAC,CAAA;IAEd,6FAA6F;IAC7F,uCAAuC;IACvC,MAAM,OAAO,GAAG,CACZ,8BACI,eAAM,SAAS,EAAC,sBAAsB,YAAE,KAAK,GAAQ,EACpD,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAC,IAAI,IAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,GAAI,IAC3E,CACN,CAAA;IAED,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,EAAE,GAAG,IAG3B,CAAA;QACD,OAAO,CACH,YAAG,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,gBAAc,SAAS,KAAM,MAAM,YAC/D,OAAO,GACR,CACP,CAAA;IACL,CAAC;IAED,OAAO,CACH,iBACI,IAAI,EAAC,QAAQ,EACb,SAAS,EAAE,OAAO,gBACN,SAAS,KAChB,IAAgD,YAEpD,OAAO,GACH,CACZ,CAAA;AACL,CAAC"}
|
package/dist/button/button.css
CHANGED
|
@@ -1,17 +1,59 @@
|
|
|
1
1
|
/* Button's own styles. Every value is a button.* token; nothing here names a colour, and
|
|
2
|
-
nothing here mentions a facet.
|
|
3
|
-
|
|
2
|
+
nothing here mentions a facet. Border width is a literal because the tokens repo has nothing
|
|
3
|
+
to point at and says so -- contracts/button.md, "Deliberately not in v1", Border width. */
|
|
4
4
|
|
|
5
5
|
.newtone-button {
|
|
6
6
|
display: inline-flex;
|
|
7
7
|
align-items: center;
|
|
8
8
|
justify-content: center;
|
|
9
9
|
gap: var(--newtone-button-gap);
|
|
10
|
-
|
|
10
|
+
|
|
11
|
+
/* THE RUNG IS READ FROM THREE LOCAL PROPERTIES THE SIZE RULES BELOW SET, rather than from
|
|
12
|
+
`--newtone-button-size-md-*` directly. That indirection is what lets a rung be ONE rule --
|
|
13
|
+
three declarations instead of a copy of this whole block per size -- and it is also what
|
|
14
|
+
makes the height below expressible, since `calc()` needs the two numbers by one name.
|
|
15
|
+
contracts/button.md, *Sizes*. */
|
|
16
|
+
/* THE BORDER IS SUBTRACTED FROM THE BLOCK PADDING so the rung names the OUTER box, which is
|
|
17
|
+
* what a ladder of heights has to mean -- `Control` has done this since it landed. Without it
|
|
18
|
+
* this rendered 46 against a 44 rung, measured on a page rather than read off this file:
|
|
19
|
+
* governance/evidence/verify-what-renders-not-what-was-written.md. The inline axis is NOT
|
|
20
|
+
* adjusted, because it is a proportion rather than a rung. */
|
|
21
|
+
/* THE INLINE PADDING IS DERIVED AND NOT AUTHORED, from 2026-09-21 late.
|
|
22
|
+
*
|
|
23
|
+
* Joshua, that day: *"48px buttons should have 12/20 paddings, depending on icon/text being on
|
|
24
|
+
* that side. And from there we should implement similar proportions on the bigger and smaller
|
|
25
|
+
* buttons."* A 48 box is 24 of leading in 2 x 12, so **12 IS ITS BLOCK PADDING** -- his glyph
|
|
26
|
+
* number is not a new value, it is the one the rung already has. And 20 is that plus one gap,
|
|
27
|
+
* which is governance/code/an-icon-and-the-text-beside-it-do-not-take-the-same-padding.md
|
|
28
|
+
* stated as arithmetic: *the difference is the component's own gap and never a new number.*
|
|
29
|
+
*
|
|
30
|
+
* SO ONE RELATION REPLACES A VALUE PER RUNG, and every rung gets his proportions for free:
|
|
31
|
+
* 36 -> 8/16, 40 -> 10/18, 44 -> 12/20, 48 -> 12/20, 56 -> 16/24. **44 and 48 share an inset
|
|
32
|
+
* on purpose** -- both hold their type in 12px of clear space, which is what the inset measures.
|
|
33
|
+
*
|
|
34
|
+
* THE BORDER IS SUBTRACTED ON BOTH AXES so these are rim-to-text distances rather than padding
|
|
35
|
+
* box numbers. Without it a 48 button reads 21 on the side he said should read 20. */
|
|
36
|
+
padding: calc(var(--newtone-button-pad-y) - 1px)
|
|
37
|
+
calc(var(--newtone-button-pad-y) + var(--newtone-button-gap) - 1px);
|
|
11
38
|
font-family: var(--newtone-button-label-family);
|
|
12
|
-
font-size: var(--newtone-button-
|
|
39
|
+
font-size: var(--newtone-button-text-size);
|
|
13
40
|
font-weight: var(--newtone-button-label-weight);
|
|
14
|
-
line-height: var(--newtone-button-
|
|
41
|
+
line-height: var(--newtone-button-text-leading);
|
|
42
|
+
|
|
43
|
+
/* THE HEIGHT IS PUBLISHED AND NEVER DECLARED, and the difference is the whole of why this is
|
|
44
|
+
one line rather than a `min-block-size` beside the padding. The box is already
|
|
45
|
+
leading + 2 x padding + 2 x border; writing that number again as a declaration would be a
|
|
46
|
+
second copy of one fact, free to drift from the padding that produces it --
|
|
47
|
+
governance/documents/staleness/a-second-copy-is-a-thing-that-drifts.md.
|
|
48
|
+
|
|
49
|
+
So this ASSERTS NOTHING and merely states, in a property a neighbour can read, what the box
|
|
50
|
+
came to. issues/open/156 is the reason it exists: two controls in one row agreed on a height
|
|
51
|
+
with nothing anywhere able to say so, and a hand-tuned padding in a consumer's scope was
|
|
52
|
+
keeping them level. A row can now read both and compare them.
|
|
53
|
+
|
|
54
|
+
READ IT; DO NOT WRITE IT. Setting this changes no geometry -- the box is the padding. */
|
|
55
|
+
--newtone-button-height: calc(var(--newtone-button-text-leading) + 2 * var(--newtone-button-pad-y));
|
|
56
|
+
|
|
15
57
|
border: 1px solid;
|
|
16
58
|
border-radius: var(--newtone-button-radius);
|
|
17
59
|
cursor: pointer;
|
|
@@ -27,6 +69,40 @@
|
|
|
27
69
|
text-align: center;
|
|
28
70
|
}
|
|
29
71
|
|
|
72
|
+
/* ---- the rungs ----------------------------------------------------------
|
|
73
|
+
*
|
|
74
|
+
* 40, 44, 48 -- three of the ladder's five. contracts/button.md, *Sizes*.
|
|
75
|
+
*
|
|
76
|
+
* ONE RULE EACH, AND EACH NAMES BOTH LEAVES OF ONE STEP. A rung may not take a size from
|
|
77
|
+
* `typography.size` and a leading from `typography.line-height`: that is a ratio applied to a
|
|
78
|
+
* size, and it is how this component came to render 16 / 19.2 for five days after the step group
|
|
79
|
+
* was built to end exactly that. governance/code/an-icon-and-the-text-beside-it-share-one-size-
|
|
80
|
+
* and-leading-pair.md, and contracts/typography.md section 7.2.
|
|
81
|
+
*
|
|
82
|
+
* PADDING-BLOCK IS THE LADDER AND PADDING-INLINE IS THIS COMPONENT'S OWN PROPORTION, which is why
|
|
83
|
+
* the first barely moves and the second does. The block padding is whatever makes the height; the
|
|
84
|
+
* inline padding is a judgement about how a word should sit in a box, and a 48px box with a 40px
|
|
85
|
+
* box's inset reads as cramped.
|
|
86
|
+
*/
|
|
87
|
+
|
|
88
|
+
.newtone-button--sm {
|
|
89
|
+
--newtone-button-pad-y: var(--newtone-button-size-sm-padding-y);
|
|
90
|
+
--newtone-button-text-size: var(--newtone-button-size-sm-label-size);
|
|
91
|
+
--newtone-button-text-leading: var(--newtone-button-size-sm-label-line-height);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.newtone-button--md {
|
|
95
|
+
--newtone-button-pad-y: var(--newtone-button-size-md-padding-y);
|
|
96
|
+
--newtone-button-text-size: var(--newtone-button-size-md-label-size);
|
|
97
|
+
--newtone-button-text-leading: var(--newtone-button-size-md-label-line-height);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.newtone-button--lg {
|
|
101
|
+
--newtone-button-pad-y: var(--newtone-button-size-lg-padding-y);
|
|
102
|
+
--newtone-button-text-size: var(--newtone-button-size-lg-label-size);
|
|
103
|
+
--newtone-button-text-leading: var(--newtone-button-size-lg-label-line-height);
|
|
104
|
+
}
|
|
105
|
+
|
|
30
106
|
/* :focus-visible, not :focus -- the contract is explicit, and focus is not optional.
|
|
31
107
|
The ring is per variant: it sits against that variant's own fill, and area decides
|
|
32
108
|
how much contrast it needs. */
|
package/dist/button/button.d.ts
CHANGED
|
@@ -1,8 +1,31 @@
|
|
|
1
1
|
import type { AnchorHTMLAttributes, ButtonHTMLAttributes, ReactNode } from 'react';
|
|
2
2
|
export type ButtonVariant = 'primary' | 'secondary' | 'tertiary';
|
|
3
|
+
/**
|
|
4
|
+
* Three rungs of the ladder's five: **40, 44, 48**.
|
|
5
|
+
*
|
|
6
|
+
* A rung is one decision, not two. It carries its height, its type pair, its padding and (when this
|
|
7
|
+
* component gains a glyph slot) its icon size TOGETHER, so a caller cannot assemble a combination
|
|
8
|
+
* nobody chose -- governance/code/a-controls-size-is-one-rung-and-the-rung-carries-everything.md.
|
|
9
|
+
* There is deliberately no second axis: five heights against two type pairs is ten combinations,
|
|
10
|
+
* eight of which nobody decided.
|
|
11
|
+
*
|
|
12
|
+
* `Control` sits a rung below this at every position and `Action` above it. A Button reaching
|
|
13
|
+
* either end would be one of those two wearing the wrong name.
|
|
14
|
+
*/
|
|
15
|
+
export type ButtonSize = 'sm' | 'md' | 'lg';
|
|
3
16
|
interface ButtonCommon {
|
|
4
17
|
/** All three exist. There is no default-by-omission in the contract. */
|
|
5
18
|
variant?: ButtonVariant;
|
|
19
|
+
/**
|
|
20
|
+
* Which rung. Defaults to `md` -- 44px on 14/20.
|
|
21
|
+
*
|
|
22
|
+
* **This default is not what an un-sized Button used to render.** Until 2026-09-21 the box was
|
|
23
|
+
* 37.2px on 16/19.2, which is on no ladder and no type step: the size came from
|
|
24
|
+
* `typography.size.base` and the leading from a RATIO, so nobody chose either number. Every
|
|
25
|
+
* existing call site grows by about seven pixels, and that is the correction rather than a
|
|
26
|
+
* side effect.
|
|
27
|
+
*/
|
|
28
|
+
size?: ButtonSize;
|
|
6
29
|
/** The `label` slot. Required; a Button has no other slot in v1. */
|
|
7
30
|
children: ReactNode;
|
|
8
31
|
}
|
|
@@ -31,6 +54,6 @@ export type ButtonProps = (ButtonCommon & Omit<ButtonHTMLAttributes<HTMLButtonEl
|
|
|
31
54
|
* sits on -- so the same Button inverts on an `emphasis` surface with nothing passed to it.
|
|
32
55
|
* Adding a `theme` prop here would put the 24-way context product back on every component.
|
|
33
56
|
*/
|
|
34
|
-
export declare function Button({ variant, children, className, ...rest }: ButtonProps): import("react").JSX.Element;
|
|
57
|
+
export declare function Button({ variant, size, children, className, ...rest }: ButtonProps): import("react").JSX.Element;
|
|
35
58
|
export {};
|
|
36
59
|
//# sourceMappingURL=button.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../src/button/button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAElF,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,WAAW,GAAG,UAAU,CAAA;AAEhE,UAAU,YAAY;IAClB,wEAAwE;IACxE,OAAO,CAAC,EAAE,aAAa,CAAA;IACvB,oEAAoE;IACpE,QAAQ,EAAE,SAAS,CAAA;CACtB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GACjB,CAAC,YAAY,GACT,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,UAAU,CAAC,GAAG;IACxD,oEAAoE;IACpE,IAAI,CAAC,EAAE,SAAS,CAAA;CACnB,CAAC,GACN,CAAC,YAAY,GACT,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,UAAU,GAAG,MAAM,CAAC,GAAG;IACjE;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAA;CACf,CAAC,CAAA;AAEZ;;;;;;;GAOG;AACH,wBAAgB,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../src/button/button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAElF,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,WAAW,GAAG,UAAU,CAAA;AAEhE;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;AAE3C,UAAU,YAAY;IAClB,wEAAwE;IACxE,OAAO,CAAC,EAAE,aAAa,CAAA;IACvB;;;;;;;;OAQG;IACH,IAAI,CAAC,EAAE,UAAU,CAAA;IACjB,oEAAoE;IACpE,QAAQ,EAAE,SAAS,CAAA;CACtB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GACjB,CAAC,YAAY,GACT,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,UAAU,CAAC,GAAG;IACxD,oEAAoE;IACpE,IAAI,CAAC,EAAE,SAAS,CAAA;CACnB,CAAC,GACN,CAAC,YAAY,GACT,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,UAAU,GAAG,MAAM,CAAC,GAAG;IACjE;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAA;CACf,CAAC,CAAA;AAEZ;;;;;;;GAOG;AACH,wBAAgB,MAAM,CAAC,EACnB,OAAmB,EACnB,IAAW,EACX,QAAQ,EACR,SAAS,EACT,GAAG,IAAI,EACV,EAAE,WAAW,+BAwCb"}
|
package/dist/button/button.js
CHANGED
|
@@ -7,10 +7,20 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
7
7
|
* sits on -- so the same Button inverts on an `emphasis` surface with nothing passed to it.
|
|
8
8
|
* Adding a `theme` prop here would put the 24-way context product back on every component.
|
|
9
9
|
*/
|
|
10
|
-
export function Button({ variant = 'primary', children, className, ...rest }) {
|
|
10
|
+
export function Button({ variant = 'primary', size = 'md', children, className, ...rest }) {
|
|
11
11
|
// One class list, both arms. The whole of the destination change is which element wears it --
|
|
12
12
|
// no token moves, no variant is added, and `button.*` stays the only group this file reads.
|
|
13
|
-
|
|
13
|
+
//
|
|
14
|
+
// THE RUNG IS A CLASS AND NOT AN INLINE STYLE, so a consuming site can still out-specify it the
|
|
15
|
+
// way it out-specifies everything else here, and so the three rung rules sit at the same one
|
|
16
|
+
// class of specificity as the variants -- newtone_ui_react-web.md section 5, *Every rule in a
|
|
17
|
+
// component's stylesheet is at one class of specificity*.
|
|
18
|
+
const classes = [
|
|
19
|
+
'newtone-button',
|
|
20
|
+
`newtone-button--${variant}`,
|
|
21
|
+
`newtone-button--${size}`,
|
|
22
|
+
className,
|
|
23
|
+
]
|
|
14
24
|
.filter(Boolean)
|
|
15
25
|
.join(' ');
|
|
16
26
|
if (rest.href !== undefined) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.js","sourceRoot":"","sources":["../../src/button/button.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"button.js","sourceRoot":"","sources":["../../src/button/button.tsx"],"names":[],"mappings":";AAyDA;;;;;;;GAOG;AACH,MAAM,UAAU,MAAM,CAAC,EACnB,OAAO,GAAG,SAAS,EACnB,IAAI,GAAG,IAAI,EACX,QAAQ,EACR,SAAS,EACT,GAAG,IAAI,EACG;IACV,8FAA8F;IAC9F,4FAA4F;IAC5F,EAAE;IACF,gGAAgG;IAChG,6FAA6F;IAC7F,8FAA8F;IAC9F,0DAA0D;IAC1D,MAAM,OAAO,GAAG;QACZ,gBAAgB;QAChB,mBAAmB,OAAO,EAAE;QAC5B,mBAAmB,IAAI,EAAE;QACzB,SAAS;KACZ;SACI,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,GAAG,CAAC,CAAA;IAEd,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,EAAE,GAAG,IAG3B,CAAA;QACD,OAAO,CACH,YAAG,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,KAAM,MAAM,YACxC,QAAQ,GACT,CACP,CAAA;IACL,CAAC;IAED,+FAA+F;IAC/F,0FAA0F;IAC1F,OAAO,CACH,iBACI,IAAI,EAAC,QAAQ,EACb,SAAS,EAAE,OAAO,KACb,IAAgD,YAEpD,QAAQ,GACJ,CACZ,CAAA;AACL,CAAC"}
|
package/dist/control/control.css
CHANGED
|
@@ -3,15 +3,16 @@
|
|
|
3
3
|
*
|
|
4
4
|
* ---- the box is square when it is bare, and a row when it is labelled -----
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* pair is two numbers that can stop agreeing.
|
|
6
|
+
* THE PADDING IS ONE VALUE PER RUNG rather than an x/y pair: equal padding around one glyph is what
|
|
7
|
+
* makes a bare control square, and a pair is two numbers that can stop agreeing. The glyph is 20 at
|
|
8
|
+
* every rung, so the padding alone moves the box -- 8, 10 and 12 give 36, 40 and 44.
|
|
10
9
|
*
|
|
11
|
-
* **
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
10
|
+
* **Those three are rungs of a closed ladder** -- 36, 40, 44, 48, 56, contracts/button.md, *Sizes* --
|
|
11
|
+
* and they replaced a 44px FLOOR on 2026-09-21. A floor only refuses what is under it, so 41 and 47
|
|
12
|
+
* were conformant and neither is a decision; a closed set can ask the question a floor cannot, which
|
|
13
|
+
* is *is this number one of five*. `sm` at 36 is the size this component refused at 28, and 28 is
|
|
14
|
+
* still refused -- for the better reason that it is not on the ladder.
|
|
15
|
+
* newtone_ui_react-web.md section 5 carries the amended invariant.
|
|
15
16
|
*
|
|
16
17
|
* A labelled control keeps the same block padding and gains the label plus a gap, so it grows along
|
|
17
18
|
* the inline axis only -- the height is the size, whether or not there is a word in it.
|
|
@@ -74,9 +75,21 @@
|
|
|
74
75
|
gap: var(--newtone-control-gap);
|
|
75
76
|
font-family: var(--newtone-control-label-family);
|
|
76
77
|
font-weight: var(--newtone-control-label-weight);
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
*
|
|
78
|
+
|
|
79
|
+
/* THE PAIR AND THE PADDING ARRIVE FROM THE RUNG BELOW, by way of three local properties. Each
|
|
80
|
+
* rung takes a whole step -- all three are 14/20 today -- and a step is the pair that matches
|
|
81
|
+
* the glyph beside it. Reading a size here and a leading somewhere else is the half-a-pair this
|
|
82
|
+
* component shipped once already. */
|
|
83
|
+
padding: calc(var(--newtone-control-pad) - 1px);
|
|
84
|
+
font-size: var(--newtone-control-text-size);
|
|
85
|
+
line-height: var(--newtone-control-text-leading);
|
|
86
|
+
|
|
87
|
+
/* PUBLISHED, NEVER DECLARED. The box is the padding plus the leading plus the border; stating
|
|
88
|
+
* a height as well would be a second copy of that sum, free to drift from it. This is what the
|
|
89
|
+
* box CAME TO, in a property a neighbouring control or a row can read -- issues/open/156.
|
|
90
|
+
* Read it; writing it changes no geometry. */
|
|
91
|
+
--newtone-control-height: calc(var(--newtone-control-text-leading) + 2 * var(--newtone-control-pad));
|
|
92
|
+
|
|
80
93
|
border: 1px solid;
|
|
81
94
|
border-radius: var(--newtone-control-radius);
|
|
82
95
|
cursor: pointer;
|
|
@@ -86,24 +99,37 @@
|
|
|
86
99
|
block-size: fit-content;
|
|
87
100
|
}
|
|
88
101
|
|
|
89
|
-
/*
|
|
90
|
-
*
|
|
102
|
+
/* ---- the rungs ----------------------------------------------------------
|
|
103
|
+
*
|
|
104
|
+
* 36, 40, 44 -- three of the ladder's five, and a rung below Button at every position.
|
|
105
|
+
* contracts/button.md, *Sizes*.
|
|
91
106
|
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
107
|
+
* THE BORDER IS SUBTRACTED ONCE HERE so each rung states only its padding VALUE and the classes
|
|
108
|
+
* describe the OUTER box: 20 + 2x8 = 36, 20 + 2x10 = 40, 20 + 2x12 = 44. The glyph is 20 at every
|
|
109
|
+
* rung because every rung takes 14/20, so the padding alone moves the box.
|
|
95
110
|
*
|
|
96
|
-
*
|
|
111
|
+
* `--newtone-control-pad` IS SET PER RUNG AND READ BY THE BASE RULE, so a rung is three
|
|
112
|
+
* declarations rather than a copy of the box. The published height below needs the two numbers by
|
|
113
|
+
* one name in any case.
|
|
114
|
+
*
|
|
115
|
+
* EACH RUNG NAMES BOTH LEAVES OF ONE STEP. Taking a size from one group and a leading from another
|
|
116
|
+
* is what put a 24px glyph against 14/16.8 here on the day this component landed. */
|
|
117
|
+
.newtone-control--sm {
|
|
118
|
+
--newtone-control-pad: var(--newtone-control-size-sm-padding);
|
|
119
|
+
--newtone-control-text-size: var(--newtone-control-size-sm-label-size);
|
|
120
|
+
--newtone-control-text-leading: var(--newtone-control-size-sm-label-line-height);
|
|
121
|
+
}
|
|
122
|
+
|
|
97
123
|
.newtone-control--md {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
124
|
+
--newtone-control-pad: var(--newtone-control-size-md-padding);
|
|
125
|
+
--newtone-control-text-size: var(--newtone-control-size-md-label-size);
|
|
126
|
+
--newtone-control-text-leading: var(--newtone-control-size-md-label-line-height);
|
|
101
127
|
}
|
|
102
128
|
|
|
103
129
|
.newtone-control--lg {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
130
|
+
--newtone-control-pad: var(--newtone-control-size-lg-padding);
|
|
131
|
+
--newtone-control-text-size: var(--newtone-control-size-lg-label-size);
|
|
132
|
+
--newtone-control-text-leading: var(--newtone-control-size-lg-label-line-height);
|
|
107
133
|
}
|
|
108
134
|
|
|
109
135
|
/* A bare control needs NO rule of its own to be square, and the first draft of this sheet wrote two.
|
|
@@ -1,14 +1,29 @@
|
|
|
1
1
|
import type { AnchorHTMLAttributes, ButtonHTMLAttributes } from 'react';
|
|
2
2
|
export type ControlVariant = 'primary' | 'secondary';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Three rungs of the ladder's five: **36, 40, 44**.
|
|
5
|
+
*
|
|
6
|
+
* A CONTROL SITS A RUNG BELOW A BUTTON AT EVERY POSITION, and that is the design rather than an
|
|
7
|
+
* accident of porting. A control is chrome -- a back arrow, a pager, a close -- and a page's Button
|
|
8
|
+
* is the page speaking. contracts/button.md, *Sizes*.
|
|
9
|
+
*
|
|
10
|
+
* `lg` WAS 56 AND `md` WAS 44 UNTIL 2026-09-21, so every existing Control gets smaller unless its
|
|
11
|
+
* call site moves up a rung. `sm` at 36 is the size this component refused at 28 and has now
|
|
12
|
+
* gained from the other end: not by lowering a floor, but because the floor became a closed set of
|
|
13
|
+
* five heights -- newtone_ui_react-web.md section 5.
|
|
14
|
+
*/
|
|
15
|
+
export type ControlSize = 'sm' | 'md' | 'lg';
|
|
4
16
|
interface ControlCommon {
|
|
5
17
|
/** A Material Symbols ligature -- `arrow_back`, `chevron_right`, `close`. */
|
|
6
18
|
icon: string;
|
|
7
19
|
/** `primary` is the soft outline, `secondary` the ghost. Neither is ever the accent. */
|
|
8
20
|
variant?: ControlVariant;
|
|
9
21
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
22
|
+
* Which rung: 36, 40 or 44. Defaults to `md`, which is 40.
|
|
23
|
+
*
|
|
24
|
+
* **`md` was 44 and `lg` was 56 until 2026-09-21**, so this default renders four pixels shorter
|
|
25
|
+
* than it used to and `lg` twelve. A call site that wanted the old `md` now asks for `lg`; a
|
|
26
|
+
* call site that wanted the old `lg` has no rung here and wants an `Action`.
|
|
12
27
|
*/
|
|
13
28
|
size?: ControlSize;
|
|
14
29
|
/** Fill the glyph (the family's `FILL` axis). Defaults to outlined. */
|
|
@@ -91,13 +106,22 @@ export type ControlProps = ControlCommon & ControlName & ControlElement;
|
|
|
91
106
|
* draws *Previous* and *Next* beside the glyphs. Both breaks are argued in
|
|
92
107
|
* `components/control.md`; neither is a rule that was copied past without being read.
|
|
93
108
|
*
|
|
94
|
-
* ----
|
|
109
|
+
* ---- `sm` came back at 36, and not by lowering a floor ---------------------
|
|
110
|
+
*
|
|
111
|
+
* The reference ships `sm` at **28px**. `icon-link.tsx` in this library argues that 44px is a floor
|
|
112
|
+
* rather than a taste -- the smallest target a finger reliably hits, the same number on every
|
|
113
|
+
* platform -- and draws a 2.75rem box for it. **A library cannot hold both sentences**, so this one
|
|
114
|
+
* shipped nothing under 44 and carried a trigger for a call site that could say why the floor did
|
|
115
|
+
* not apply to it.
|
|
116
|
+
*
|
|
117
|
+
* THAT TRIGGER NEVER FIRED. What changed on 2026-09-21 is that the floor became a LADDER -- five
|
|
118
|
+
* heights, closed -- and this component's three rungs on it are 36, 40 and 44. **28 is still
|
|
119
|
+
* refused, and for a better reason than before**: it is not on the ladder. A floor only refuses
|
|
120
|
+
* what is under it, so 41 and 47 were conformant and neither is a decision; a closed set can ask
|
|
121
|
+
* the question a floor cannot, which is *is this number one of five*.
|
|
95
122
|
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
* every platform -- and draws a 2.75rem box for it. **A library cannot hold both sentences.** `md`
|
|
99
|
-
* is 48 and `lg` is 64, and a control smaller than the floor needs a call site that can say why the
|
|
100
|
-
* floor does not apply to it.
|
|
123
|
+
* newtone_ui_react-web.md section 5 carries the amended invariant and why 44 (WCAG 2.5.5, AAA) gave
|
|
124
|
+
* way to 36 (clear of 2.5.8's 24x24, AA).
|
|
101
125
|
*
|
|
102
126
|
* ---- no transition, and that is a vocabulary this library does not have ----
|
|
103
127
|
*
|