@newtone-dev/ui-react-web 0.21.0 → 0.22.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/dist/button/button.css
CHANGED
|
@@ -52,7 +52,9 @@
|
|
|
52
52
|
keeping them level. A row can now read both and compare them.
|
|
53
53
|
|
|
54
54
|
READ IT; DO NOT WRITE IT. Setting this changes no geometry -- the box is the padding. */
|
|
55
|
-
--newtone-button-height: calc(
|
|
55
|
+
--newtone-button-height: calc(
|
|
56
|
+
var(--newtone-button-text-leading) + 2 * var(--newtone-button-pad-y)
|
|
57
|
+
);
|
|
56
58
|
|
|
57
59
|
border: 1px solid;
|
|
58
60
|
border-radius: var(--newtone-button-radius);
|
|
@@ -103,6 +105,14 @@
|
|
|
103
105
|
--newtone-button-text-leading: var(--newtone-button-size-lg-label-line-height);
|
|
104
106
|
}
|
|
105
107
|
|
|
108
|
+
/* WITH A TRAILING GLYPH THE GLYPH'S SIDE IS THE RUNG'S BLOCK PADDING, and the word's side keeps
|
|
109
|
+
* `pad-y + gap`. One rule for every rung because it reads the rung's own variable, and it is
|
|
110
|
+
* `Action`'s `--icon-end` with this component's name in it. contracts/button.md, *Slots*;
|
|
111
|
+
* governance/code/an-icon-and-the-text-beside-it-do-not-take-the-same-padding.md. */
|
|
112
|
+
.newtone-button--icon-end {
|
|
113
|
+
padding-inline-end: calc(var(--newtone-button-pad-y) - 1px);
|
|
114
|
+
}
|
|
115
|
+
|
|
106
116
|
/* :focus-visible, not :focus -- the contract is explicit, and focus is not optional.
|
|
107
117
|
The ring is per variant: it sits against that variant's own fill, and area decides
|
|
108
118
|
how much contrast it needs. */
|
package/dist/button/button.d.ts
CHANGED
|
@@ -26,8 +26,16 @@ interface ButtonCommon {
|
|
|
26
26
|
* side effect.
|
|
27
27
|
*/
|
|
28
28
|
size?: ButtonSize;
|
|
29
|
-
/** The `label` slot. Required
|
|
29
|
+
/** The `label` slot. Required. */
|
|
30
30
|
children: ReactNode;
|
|
31
|
+
/**
|
|
32
|
+
* A trailing glyph, by name. There is no leading slot: a glyph on a button points ONWARD, at
|
|
33
|
+
* what pressing it leads to -- `Action`'s spelling and its reason. **Its presence takes one gap
|
|
34
|
+
* off the padding on its own side**, so the glyph sits `padding-block` from the rim and the word
|
|
35
|
+
* `padding-block + gap`. Sized by the rung. Since 2026-10-01, react-web 0.22.0;
|
|
36
|
+
* contracts/button.md, *Slots*, and governance/code/an-icon-and-the-text-beside-it-do-not-take-the-same-padding.md.
|
|
37
|
+
*/
|
|
38
|
+
iconEnd?: string;
|
|
31
39
|
}
|
|
32
40
|
/**
|
|
33
41
|
* The two halves of the contract's **Action / Destination** pair, typed so that exactly one can be
|
|
@@ -54,6 +62,6 @@ export type ButtonProps = (ButtonCommon & Omit<ButtonHTMLAttributes<HTMLButtonEl
|
|
|
54
62
|
* sits on -- so the same Button inverts on an `emphasis` surface with nothing passed to it.
|
|
55
63
|
* Adding a `theme` prop here would put the 24-way context product back on every component.
|
|
56
64
|
*/
|
|
57
|
-
export declare function Button({ variant, size, children, className, ...rest }: ButtonProps): import("react").JSX.Element;
|
|
65
|
+
export declare function Button({ variant, size, children, iconEnd, className, ...rest }: ButtonProps): import("react").JSX.Element;
|
|
58
66
|
export {};
|
|
59
67
|
//# 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;
|
|
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;AAGlF,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,WAAW,GAAG,UAAU,CAAA;AAEhE;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;AAK3C,UAAU,YAAY;IAClB,wEAAwE;IACxE,OAAO,CAAC,EAAE,aAAa,CAAA;IACvB;;;;;;;;OAQG;IACH,IAAI,CAAC,EAAE,UAAU,CAAA;IACjB,kCAAkC;IAClC,QAAQ,EAAE,SAAS,CAAA;IACnB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CACnB;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,OAAO,EACP,SAAS,EACT,GAAG,IAAI,EACV,EAAE,WAAW,+BAsDb"}
|
package/dist/button/button.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Icon } from '../icon/index.js';
|
|
3
|
+
// THE GLYPH IS THE RUNG'S, from contracts/button.md's *glyph* column: 20 at 40 and 44, 24 at 48.
|
|
4
|
+
const GLYPH = { sm: 'sm', md: 'sm', lg: 'md' };
|
|
2
5
|
/**
|
|
3
6
|
* Discharges blueprints/newtone/contracts/button.md.
|
|
4
7
|
*
|
|
@@ -7,7 +10,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
7
10
|
* sits on -- so the same Button inverts on an `emphasis` surface with nothing passed to it.
|
|
8
11
|
* Adding a `theme` prop here would put the 24-way context product back on every component.
|
|
9
12
|
*/
|
|
10
|
-
export function Button({ variant = 'primary', size = 'md', children, className, ...rest }) {
|
|
13
|
+
export function Button({ variant = 'primary', size = 'md', children, iconEnd, className, ...rest }) {
|
|
11
14
|
// One class list, both arms. The whole of the destination change is which element wears it --
|
|
12
15
|
// no token moves, no variant is added, and `button.*` stays the only group this file reads.
|
|
13
16
|
//
|
|
@@ -19,16 +22,21 @@ export function Button({ variant = 'primary', size = 'md', children, className,
|
|
|
19
22
|
'newtone-button',
|
|
20
23
|
`newtone-button--${variant}`,
|
|
21
24
|
`newtone-button--${size}`,
|
|
25
|
+
// Keyed on the glyph being PRESENT, as `Action`'s is: a button with no glyph keeps both sides.
|
|
26
|
+
iconEnd === undefined ? null : 'newtone-button--icon-end',
|
|
22
27
|
className,
|
|
23
28
|
]
|
|
24
29
|
.filter(Boolean)
|
|
25
30
|
.join(' ');
|
|
31
|
+
// With a glyph the label is wrapped, so the glyph is the one element after it. `Icon` writes its
|
|
32
|
+
// own `aria-hidden`, so the button's name is still the label.
|
|
33
|
+
const content = iconEnd === undefined ? (children) : (_jsxs(_Fragment, { children: [_jsx("span", { className: "newtone-button-label", children: children }), _jsx(Icon, { name: iconEnd, size: GLYPH[size] })] }));
|
|
26
34
|
if (rest.href !== undefined) {
|
|
27
35
|
const { href, ...anchor } = rest;
|
|
28
|
-
return (_jsx("a", { href: href, className: classes, ...anchor, children:
|
|
36
|
+
return (_jsx("a", { href: href, className: classes, ...anchor, children: content }));
|
|
29
37
|
}
|
|
30
38
|
// `type="button"` stays FIRST so a caller inside a form can still say `submit` -- the contract
|
|
31
39
|
// defers `type` as a prop, and this is the spread already doing it rather than a new one.
|
|
32
|
-
return (_jsx("button", { type: "button", className: classes, ...rest, children:
|
|
40
|
+
return (_jsx("button", { type: "button", className: classes, ...rest, children: content }));
|
|
33
41
|
}
|
|
34
42
|
//# sourceMappingURL=button.js.map
|
|
@@ -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":";AACA,OAAO,EAAE,IAAI,EAAiB,MAAM,kBAAkB,CAAA;AAkBtD,iGAAiG;AACjG,MAAM,KAAK,GAAiC,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,CAAA;AAiD5E;;;;;;;GAOG;AACH,MAAM,UAAU,MAAM,CAAC,EACnB,OAAO,GAAG,SAAS,EACnB,IAAI,GAAG,IAAI,EACX,QAAQ,EACR,OAAO,EACP,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,+FAA+F;QAC/F,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,0BAA0B;QACzD,SAAS;KACZ;SACI,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,GAAG,CAAC,CAAA;IAEd,iGAAiG;IACjG,8DAA8D;IAC9D,MAAM,OAAO,GACT,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,CACpB,QAAQ,CACX,CAAC,CAAC,CAAC,CACA,8BACI,eAAM,SAAS,EAAC,sBAAsB,YAAE,QAAQ,GAAQ,EACxD,KAAC,IAAI,IAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,GAAI,IAC3C,CACN,CAAA;IAEL,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,OAAO,GACR,CACP,CAAA;IACL,CAAC;IAED,+FAA+F;IAC/F,0FAA0F;IAC1F,OAAO,CACH,iBACI,IAAI,EAAC,QAAQ,EACb,SAAS,EAAE,OAAO,KACb,IAAgD,YAEpD,OAAO,GACH,CACZ,CAAA;AACL,CAAC"}
|