@hanzo/ui 8.0.44 → 8.0.46
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/backends/gui/aspect-ratio.cjs +14 -1
- package/dist/backends/gui/aspect-ratio.d.ts +13 -0
- package/dist/backends/gui/aspect-ratio.d.ts.map +1 -1
- package/dist/backends/gui/aspect-ratio.js +14 -1
- package/dist/backends/gui/aspect-ratio.js.map +1 -1
- package/dist/backends/gui/button.cjs +30 -6
- package/dist/backends/gui/button.d.ts.map +1 -1
- package/dist/backends/gui/button.js +30 -6
- package/dist/backends/gui/button.js.map +1 -1
- package/dist/backends/gui/card.cjs +42 -3
- package/dist/backends/gui/card.d.ts +48 -3
- package/dist/backends/gui/card.d.ts.map +1 -1
- package/dist/backends/gui/card.js +41 -3
- package/dist/backends/gui/card.js.map +1 -1
- package/dist/backends/gui/grid.cjs +61 -0
- package/dist/backends/gui/grid.d.ts +16 -0
- package/dist/backends/gui/grid.d.ts.map +1 -0
- package/dist/backends/gui/grid.js +59 -0
- package/dist/backends/gui/grid.js.map +1 -0
- package/dist/backends/gui/index.cjs +7 -2
- package/dist/backends/gui/index.d.ts +3 -1
- package/dist/backends/gui/index.d.ts.map +1 -1
- package/dist/backends/gui/index.js +3 -1
- package/dist/backends/gui/index.js.map +1 -1
- package/dist/backends/gui/section.cjs +39 -0
- package/dist/backends/gui/section.d.ts +29 -0
- package/dist/backends/gui/section.d.ts.map +1 -0
- package/dist/backends/gui/section.js +37 -0
- package/dist/backends/gui/section.js.map +1 -0
- package/dist/core/index.cjs +7 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +7 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/tokens.cjs +31 -27
- package/dist/core/tokens.d.ts +19 -10
- package/dist/core/tokens.d.ts.map +1 -1
- package/dist/core/tokens.js +18 -9
- package/dist/core/tokens.js.map +1 -1
- package/dist/gallery.cjs +10 -1
- package/dist/gallery.d.ts.map +1 -1
- package/dist/gallery.js +11 -2
- package/dist/gallery.js.map +1 -1
- package/dist/gui-config.cjs +11 -0
- package/dist/gui-config.d.ts +182 -0
- package/dist/gui-config.d.ts.map +1 -1
- package/dist/gui-config.js +11 -0
- package/dist/gui-config.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/primitives/CardMedia.cjs +8 -0
- package/dist/primitives/CardMedia.d.ts +2 -0
- package/dist/primitives/CardMedia.d.ts.map +1 -0
- package/dist/primitives/CardMedia.js +5 -0
- package/dist/primitives/CardMedia.js.map +1 -0
- package/dist/primitives/Grid.cjs +8 -0
- package/dist/primitives/Grid.d.ts +2 -0
- package/dist/primitives/Grid.d.ts.map +1 -0
- package/dist/primitives/Grid.js +5 -0
- package/dist/primitives/Grid.js.map +1 -0
- package/dist/primitives/Section.cjs +8 -0
- package/dist/primitives/Section.d.ts +2 -0
- package/dist/primitives/Section.d.ts.map +1 -0
- package/dist/primitives/Section.js +5 -0
- package/dist/primitives/Section.js.map +1 -0
- package/dist/styles/motion.css +27 -0
- package/dist/styles.css +978 -42
- package/dist/theme.css +920 -39
- package/package.json +8 -12
|
@@ -9,7 +9,20 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
9
9
|
* `aspectRatio` is a first-class layout property of the gui/Yoga box model, so
|
|
10
10
|
* there is nothing to compute and no padding-bottom trick: the ratio is the
|
|
11
11
|
* style. That is why this is the whole component on web, native and desktop.
|
|
12
|
+
*
|
|
13
|
+
* The reason to reach for it is that the box has an intrinsic height BEFORE its
|
|
14
|
+
* content loads. An `<img>` with no ratio is 0px tall until the bytes arrive,
|
|
15
|
+
* which is both the "media box rendered at zero height" defect and the layout
|
|
16
|
+
* shift when it finally does. Ratio first, content second — the box is never
|
|
17
|
+
* zero-height, so nothing below it ever moves.
|
|
18
|
+
*
|
|
19
|
+
* `overflow: hidden` is not decoration: the child is sized to FILL this box (see
|
|
20
|
+
* the `[data-slot='aspect-ratio'] > img` rule in styles/motion.css), and a
|
|
21
|
+
* cover-fitted image is by definition larger than its frame on one axis.
|
|
22
|
+
* `position: relative` makes this the containing block, so an absolutely
|
|
23
|
+
* positioned overlay — a play button, a scrim, a badge — lands on the media
|
|
24
|
+
* instead of on the page.
|
|
12
25
|
*/
|
|
13
26
|
const gui_1 = require("@hanzo/gui");
|
|
14
|
-
const AspectRatio = ({ ratio = 1, ...props }) => ((0, jsx_runtime_1.jsx)(gui_1.YStack, { "data-slot": "aspect-ratio", width: "100%", aspectRatio: ratio, ...props }));
|
|
27
|
+
const AspectRatio = ({ ratio = 1, ...props }) => ((0, jsx_runtime_1.jsx)(gui_1.YStack, { "data-slot": "aspect-ratio", width: "100%", aspectRatio: ratio, overflow: "hidden", position: "relative", ...props, "data-ratio": "" }));
|
|
15
28
|
exports.AspectRatio = AspectRatio;
|
|
@@ -4,6 +4,19 @@
|
|
|
4
4
|
* `aspectRatio` is a first-class layout property of the gui/Yoga box model, so
|
|
5
5
|
* there is nothing to compute and no padding-bottom trick: the ratio is the
|
|
6
6
|
* style. That is why this is the whole component on web, native and desktop.
|
|
7
|
+
*
|
|
8
|
+
* The reason to reach for it is that the box has an intrinsic height BEFORE its
|
|
9
|
+
* content loads. An `<img>` with no ratio is 0px tall until the bytes arrive,
|
|
10
|
+
* which is both the "media box rendered at zero height" defect and the layout
|
|
11
|
+
* shift when it finally does. Ratio first, content second — the box is never
|
|
12
|
+
* zero-height, so nothing below it ever moves.
|
|
13
|
+
*
|
|
14
|
+
* `overflow: hidden` is not decoration: the child is sized to FILL this box (see
|
|
15
|
+
* the `[data-slot='aspect-ratio'] > img` rule in styles/motion.css), and a
|
|
16
|
+
* cover-fitted image is by definition larger than its frame on one axis.
|
|
17
|
+
* `position: relative` makes this the containing block, so an absolutely
|
|
18
|
+
* positioned overlay — a play button, a scrim, a badge — lands on the media
|
|
19
|
+
* instead of on the page.
|
|
7
20
|
*/
|
|
8
21
|
import { type YStackProps } from '@hanzo/gui';
|
|
9
22
|
export interface AspectRatioProps extends YStackProps {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aspect-ratio.d.ts","sourceRoot":"","sources":["../../../src/backends/gui/aspect-ratio.tsx"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"aspect-ratio.d.ts","sourceRoot":"","sources":["../../../src/backends/gui/aspect-ratio.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,YAAY,CAAA;AAErD,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,kDAAkD;IAClD,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,QAAA,MAAM,WAAW,GAAI,qBAAyB,gBAAgB,4CAe7D,CAAA;AAED,OAAO,EAAE,WAAW,EAAE,CAAA"}
|
|
@@ -6,8 +6,21 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
6
6
|
* `aspectRatio` is a first-class layout property of the gui/Yoga box model, so
|
|
7
7
|
* there is nothing to compute and no padding-bottom trick: the ratio is the
|
|
8
8
|
* style. That is why this is the whole component on web, native and desktop.
|
|
9
|
+
*
|
|
10
|
+
* The reason to reach for it is that the box has an intrinsic height BEFORE its
|
|
11
|
+
* content loads. An `<img>` with no ratio is 0px tall until the bytes arrive,
|
|
12
|
+
* which is both the "media box rendered at zero height" defect and the layout
|
|
13
|
+
* shift when it finally does. Ratio first, content second — the box is never
|
|
14
|
+
* zero-height, so nothing below it ever moves.
|
|
15
|
+
*
|
|
16
|
+
* `overflow: hidden` is not decoration: the child is sized to FILL this box (see
|
|
17
|
+
* the `[data-slot='aspect-ratio'] > img` rule in styles/motion.css), and a
|
|
18
|
+
* cover-fitted image is by definition larger than its frame on one axis.
|
|
19
|
+
* `position: relative` makes this the containing block, so an absolutely
|
|
20
|
+
* positioned overlay — a play button, a scrim, a badge — lands on the media
|
|
21
|
+
* instead of on the page.
|
|
9
22
|
*/
|
|
10
23
|
import { YStack } from '@hanzo/gui';
|
|
11
|
-
const AspectRatio = ({ ratio = 1, ...props }) => (_jsx(YStack, { "data-slot": "aspect-ratio", width: "100%", aspectRatio: ratio, ...props }));
|
|
24
|
+
const AspectRatio = ({ ratio = 1, ...props }) => (_jsx(YStack, { "data-slot": "aspect-ratio", width: "100%", aspectRatio: ratio, overflow: "hidden", position: "relative", ...props, "data-ratio": "" }));
|
|
12
25
|
export { AspectRatio };
|
|
13
26
|
//# sourceMappingURL=aspect-ratio.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aspect-ratio.js","sourceRoot":"","sources":["../../../src/backends/gui/aspect-ratio.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ
|
|
1
|
+
{"version":3,"file":"aspect-ratio.js","sourceRoot":"","sources":["../../../src/backends/gui/aspect-ratio.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,MAAM,EAAoB,MAAM,YAAY,CAAA;AAOrD,MAAM,WAAW,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,GAAG,KAAK,EAAoB,EAAE,EAAE,CAAC,CACjE,KAAC,MAAM,iBACK,cAAc,EACxB,KAAK,EAAC,MAAM,EACZ,WAAW,EAAE,KAAK,EAClB,QAAQ,EAAC,QAAQ,EACjB,QAAQ,EAAC,UAAU,KACf,KAAK,gBAME,EAAE,GACb,CACH,CAAA;AAED,OAAO,EAAE,WAAW,EAAE,CAAA"}
|
|
@@ -96,12 +96,36 @@ const Frame = (0, gui_1.styled)(gui_1.Button.Frame, {
|
|
|
96
96
|
},
|
|
97
97
|
},
|
|
98
98
|
size: {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
99
|
+
// minHeight, NOT height. A control has to be a predictable size, and it
|
|
100
|
+
// still is: text at this type scale is shorter than the box, so every
|
|
101
|
+
// ordinary Button renders at exactly these numbers. What changes is the
|
|
102
|
+
// failure: a pinned `height` CLIPS anything taller, which is how a 119px
|
|
103
|
+
// thumbnail shipped rendered as a 30px sliver with a green build. A floor
|
|
104
|
+
// cannot clip — the button grows and the mistake is visible immediately
|
|
105
|
+
// instead of silently cropping content.
|
|
106
|
+
//
|
|
107
|
+
// Same for the icon sizes' width: a floor keeps them square without
|
|
108
|
+
// truncating a child that is wider than the box.
|
|
109
|
+
// `height: 'auto'` + `minHeight`, and BOTH halves are load-bearing.
|
|
110
|
+
//
|
|
111
|
+
// minHeight alone is not enough: dropping `height` lets GuiButton.Frame's
|
|
112
|
+
// own size variant supply one (measured: 44px), which re-pins the box and
|
|
113
|
+
// ALSO makes every ordinary button 8px taller. `height: 'auto'` is what
|
|
114
|
+
// turns that off, and minHeight is what keeps the control its designed
|
|
115
|
+
// size once it is off.
|
|
116
|
+
//
|
|
117
|
+
// Together: text is shorter than the floor, so an ordinary Button still
|
|
118
|
+
// measures exactly these numbers. Anything taller GROWS instead of being
|
|
119
|
+
// cropped — a pinned height is how a 119px thumbnail shipped rendered as
|
|
120
|
+
// a 36px sliver with a green build. Both directions are asserted in
|
|
121
|
+
// consumer.spec.ts, because getting one right and the other wrong is
|
|
122
|
+
// exactly what happened on the first attempt.
|
|
123
|
+
default: { height: 'auto', minHeight: HEIGHT.default, px: '$4' },
|
|
124
|
+
sm: { height: 'auto', minHeight: HEIGHT.sm, px: '$3', gap: '$1.5' },
|
|
125
|
+
lg: { height: 'auto', minHeight: HEIGHT.lg, px: '$6' },
|
|
126
|
+
icon: { height: 'auto', minHeight: HEIGHT.icon, width: 'auto', minWidth: HEIGHT.icon, px: 0 },
|
|
127
|
+
'icon-sm': { height: 'auto', minHeight: HEIGHT['icon-sm'], width: 'auto', minWidth: HEIGHT['icon-sm'], px: 0 },
|
|
128
|
+
'icon-lg': { height: 'auto', minHeight: HEIGHT['icon-lg'], width: 'auto', minWidth: HEIGHT['icon-lg'], px: 0 },
|
|
105
129
|
},
|
|
106
130
|
disabled: {
|
|
107
131
|
true: { opacity: 0.5, pointerEvents: 'none', cursor: 'default' },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../src/backends/gui/button.tsx"],"names":[],"mappings":"AAyBA,OAAO,EAAiC,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAK1F,MAAM,MAAM,aAAa,GACrB,SAAS,GACT,aAAa,GACb,SAAS,GACT,WAAW,GACX,OAAO,GACP,MAAM,GACN,SAAS,GACT,QAAQ,GACR,WAAW,CAAA;AAEf,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,IAAI,GAAG,IAAI,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,CAAA;AAqBjF,QAAA,MAAM,KAAK;;;;;;;;
|
|
1
|
+
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../src/backends/gui/button.tsx"],"names":[],"mappings":"AAyBA,OAAO,EAAiC,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAK1F,MAAM,MAAM,aAAa,GACrB,SAAS,GACT,aAAa,GACb,SAAS,GACT,WAAW,GACX,OAAO,GACP,MAAM,GACN,SAAS,GACT,QAAQ,GACR,WAAW,CAAA;AAEf,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,IAAI,GAAG,IAAI,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,CAAA;AAqBjF,QAAA,MAAM,KAAK;;;;;;;;8CAuFT,CAAA;AAEF;;;GAGG;AACH,eAAO,MAAM,cAAc,GAAI,gCAI5B;IAAE,OAAO,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC;IAAC,IAAI,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,WAK1E,CAAA;AAEd,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,KAAK,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG,UAAU,CAAC,GAAG;IAC9F,OAAO,CAAC,EAAE,aAAa,GAAG,IAAI,CAAA;IAC9B,IAAI,CAAC,EAAE,UAAU,GAAG,IAAI,CAAA;IACxB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB;;;;;;;;;;OAUG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;;;OAKG;IACH,IAAI,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAA;CACrC,CAAA;AAED,iBAAS,MAAM,CAAC,EACd,SAAS,EACT,OAAmB,EACnB,IAAgB,EAChB,OAAe,EACf,SAAiB,EACjB,QAAQ,EACR,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,WAAW,2CA2Bb;AAED,OAAO,EAAE,MAAM,EAAE,CAAA"}
|
|
@@ -92,12 +92,36 @@ const Frame = styled(GuiButton.Frame, {
|
|
|
92
92
|
},
|
|
93
93
|
},
|
|
94
94
|
size: {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
95
|
+
// minHeight, NOT height. A control has to be a predictable size, and it
|
|
96
|
+
// still is: text at this type scale is shorter than the box, so every
|
|
97
|
+
// ordinary Button renders at exactly these numbers. What changes is the
|
|
98
|
+
// failure: a pinned `height` CLIPS anything taller, which is how a 119px
|
|
99
|
+
// thumbnail shipped rendered as a 30px sliver with a green build. A floor
|
|
100
|
+
// cannot clip — the button grows and the mistake is visible immediately
|
|
101
|
+
// instead of silently cropping content.
|
|
102
|
+
//
|
|
103
|
+
// Same for the icon sizes' width: a floor keeps them square without
|
|
104
|
+
// truncating a child that is wider than the box.
|
|
105
|
+
// `height: 'auto'` + `minHeight`, and BOTH halves are load-bearing.
|
|
106
|
+
//
|
|
107
|
+
// minHeight alone is not enough: dropping `height` lets GuiButton.Frame's
|
|
108
|
+
// own size variant supply one (measured: 44px), which re-pins the box and
|
|
109
|
+
// ALSO makes every ordinary button 8px taller. `height: 'auto'` is what
|
|
110
|
+
// turns that off, and minHeight is what keeps the control its designed
|
|
111
|
+
// size once it is off.
|
|
112
|
+
//
|
|
113
|
+
// Together: text is shorter than the floor, so an ordinary Button still
|
|
114
|
+
// measures exactly these numbers. Anything taller GROWS instead of being
|
|
115
|
+
// cropped — a pinned height is how a 119px thumbnail shipped rendered as
|
|
116
|
+
// a 36px sliver with a green build. Both directions are asserted in
|
|
117
|
+
// consumer.spec.ts, because getting one right and the other wrong is
|
|
118
|
+
// exactly what happened on the first attempt.
|
|
119
|
+
default: { height: 'auto', minHeight: HEIGHT.default, px: '$4' },
|
|
120
|
+
sm: { height: 'auto', minHeight: HEIGHT.sm, px: '$3', gap: '$1.5' },
|
|
121
|
+
lg: { height: 'auto', minHeight: HEIGHT.lg, px: '$6' },
|
|
122
|
+
icon: { height: 'auto', minHeight: HEIGHT.icon, width: 'auto', minWidth: HEIGHT.icon, px: 0 },
|
|
123
|
+
'icon-sm': { height: 'auto', minHeight: HEIGHT['icon-sm'], width: 'auto', minWidth: HEIGHT['icon-sm'], px: 0 },
|
|
124
|
+
'icon-lg': { height: 'auto', minHeight: HEIGHT['icon-lg'], width: 'auto', minWidth: HEIGHT['icon-lg'], px: 0 },
|
|
101
125
|
},
|
|
102
126
|
disabled: {
|
|
103
127
|
true: { opacity: 0.5, pointerEvents: 'none', cursor: 'default' },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.js","sourceRoot":"","sources":["../../../src/backends/gui/button.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACjE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAuC,MAAM,OAAO,CAAA;AAE1F,OAAO,EAAE,GAAG,EAA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AAQ,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC,EACpC,SAAS,EAAE,cAAc,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,KACnD,KAAK,aAER,SAAS,IAAI,KAAC,OAAO,IAAC,IAAI,EAAC,OAAO,GAAG,EACrC,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC,IAAa,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,IAC3D,CACT,CAAA;AACH,CAAC;AAED,OAAO,EAAE,MAAM,EAAE,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';"use strict";
|
|
2
2
|
'use client';
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.CardContent = exports.CardDescription = exports.CardAction = exports.CardTitle = exports.CardFooter = exports.CardHeader = exports.Card = void 0;
|
|
4
|
+
exports.CardMedia = exports.CardContent = exports.CardDescription = exports.CardAction = exports.CardTitle = exports.CardFooter = exports.CardHeader = exports.Card = void 0;
|
|
5
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
6
|
/**
|
|
7
7
|
* Card — surface, header, title, description, action, content, footer.
|
|
@@ -10,6 +10,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
10
10
|
* and a row is the one box model that also exists on native.
|
|
11
11
|
*/
|
|
12
12
|
const gui_1 = require("@hanzo/gui");
|
|
13
|
+
const aspect_ratio_1 = require("./aspect-ratio.cjs");
|
|
13
14
|
const ink_1 = require("./ink.cjs");
|
|
14
15
|
const slot_1 = require("./slot.cjs");
|
|
15
16
|
const PAD = 24;
|
|
@@ -40,8 +41,24 @@ const DescriptionFrame = (0, gui_1.styled)(gui_1.SizableText, { name: 'CardDescr
|
|
|
40
41
|
const ActionFrame = (0, gui_1.styled)(gui_1.XStack, { name: 'CardAction', self: 'flex-end', shrink: 0 });
|
|
41
42
|
const ContentFrame = (0, gui_1.styled)(gui_1.YStack, { name: 'CardContent', px: PAD });
|
|
42
43
|
const FooterFrame = (0, gui_1.styled)(gui_1.XStack, { name: 'CardFooter', px: PAD, items: 'center' });
|
|
43
|
-
const Card = (p) => (0, jsx_runtime_1.jsx)(CardFrame, { ...(0, slot_1.slot)('card'), ...
|
|
44
|
-
|
|
44
|
+
const Card = ({ interactive, onPress, ...p }) => ((0, jsx_runtime_1.jsx)(CardFrame, { ...(0, slot_1.slot)('card'), ...(interactive
|
|
45
|
+
? {
|
|
46
|
+
role: 'button',
|
|
47
|
+
tabIndex: 0,
|
|
48
|
+
cursor: 'pointer',
|
|
49
|
+
hoverStyle: { borderColor: '$color8' },
|
|
50
|
+
focusStyle: { borderColor: '$color8', outlineWidth: 2, outlineStyle: 'solid', outlineColor: '$color8' },
|
|
51
|
+
// A div with role="button" is not a button: the browser gives it no
|
|
52
|
+
// keyboard activation, so it has to be spelled out or the card is
|
|
53
|
+
// mouse-only. Space must also preventDefault or the page scrolls.
|
|
54
|
+
onKeyDown: (e) => {
|
|
55
|
+
if (e.key !== 'Enter' && e.key !== ' ')
|
|
56
|
+
return;
|
|
57
|
+
e.preventDefault();
|
|
58
|
+
onPress?.(e);
|
|
59
|
+
},
|
|
60
|
+
}
|
|
61
|
+
: null), onPress: onPress, ...p }));
|
|
45
62
|
const CardHeader = (p) => (0, jsx_runtime_1.jsx)(HeaderFrame, { ...(0, slot_1.slot)('card-header'), ...p });
|
|
46
63
|
exports.CardHeader = CardHeader;
|
|
47
64
|
const CardTitle = (p) => (0, jsx_runtime_1.jsx)(TitleFrame, { ...(0, slot_1.slot)('card-title'), ...p });
|
|
@@ -54,3 +71,25 @@ const CardContent = ({ children, ...p }) => ((0, jsx_runtime_1.jsx)(ContentFrame
|
|
|
54
71
|
exports.CardContent = CardContent;
|
|
55
72
|
const CardFooter = ({ children, ...p }) => ((0, jsx_runtime_1.jsx)(FooterFrame, { ...(0, slot_1.slot)('card-footer'), ...p, children: (0, ink_1.ink)(children) }));
|
|
56
73
|
exports.CardFooter = CardFooter;
|
|
74
|
+
const CardMedia = ({ ratio = 16 / 10, ...p }) => ((0, jsx_runtime_1.jsx)(aspect_ratio_1.AspectRatio, { ...(0, slot_1.slot)('card-media'), ratio: ratio, mt: -PAD, ...p }));
|
|
75
|
+
exports.CardMedia = CardMedia;
|
|
76
|
+
/**
|
|
77
|
+
* The dot-namespace. `Card.Media`, `Card.Body`, `Card.Title`, `Card.Meta` are
|
|
78
|
+
* the SAME components as the named exports beside them, not second copies —
|
|
79
|
+
* `withStaticProperties` hangs the existing implementations off `Card`. Nothing
|
|
80
|
+
* here can drift from the named export, because there is nothing here to drift.
|
|
81
|
+
*
|
|
82
|
+
* The named exports keep their shadcn-lineage spelling because 79 call sites in
|
|
83
|
+
* hanzo.app are written against it; renaming them would be a breaking change
|
|
84
|
+
* bought for nothing.
|
|
85
|
+
*/
|
|
86
|
+
const CardNamespace = (0, gui_1.withStaticProperties)(Card, {
|
|
87
|
+
Media: CardMedia,
|
|
88
|
+
Header: CardHeader,
|
|
89
|
+
Title: CardTitle,
|
|
90
|
+
Meta: CardDescription,
|
|
91
|
+
Body: CardContent,
|
|
92
|
+
Action: CardAction,
|
|
93
|
+
Footer: CardFooter,
|
|
94
|
+
});
|
|
95
|
+
exports.Card = CardNamespace;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ComponentProps } from 'react';
|
|
2
|
+
import { type AspectRatioProps } from './aspect-ratio.js';
|
|
2
3
|
declare const CardFrame: import("@hanzogui/web").GuiComponent<import("@hanzogui/web").TamaDefer, import("@hanzogui/web").GuiElement, import("@hanzogui/core").RNGuiViewNonStyleProps, import("@hanzogui/web").StackStyleBase, {
|
|
3
4
|
elevation?: number | import("@hanzogui/web").SizeTokens | undefined;
|
|
4
5
|
fullscreen?: boolean | undefined;
|
|
@@ -27,19 +28,63 @@ declare const FooterFrame: import("@hanzogui/web").GuiComponent<import("@hanzogu
|
|
|
27
28
|
elevation?: number | import("@hanzogui/web").SizeTokens | undefined;
|
|
28
29
|
fullscreen?: boolean | undefined;
|
|
29
30
|
}, import("@hanzogui/web").StaticConfigPublic>;
|
|
30
|
-
export type CardProps = ComponentProps<typeof CardFrame
|
|
31
|
+
export type CardProps = ComponentProps<typeof CardFrame> & {
|
|
32
|
+
/**
|
|
33
|
+
* The whole card is the control. Makes it focusable, gives it the button role
|
|
34
|
+
* and the Enter/Space keys, and lights it on hover and focus.
|
|
35
|
+
*
|
|
36
|
+
* This exists so nobody wraps a Card in a <Button> again. A Button pins its
|
|
37
|
+
* own height — correctly, it is a control — and a card put inside one gets
|
|
38
|
+
* clipped to a 30px sliver. The affordance belongs on the surface, not around
|
|
39
|
+
* it.
|
|
40
|
+
*/
|
|
41
|
+
interactive?: boolean;
|
|
42
|
+
};
|
|
31
43
|
export type CardHeaderProps = ComponentProps<typeof HeaderFrame>;
|
|
32
44
|
export type CardTitleProps = ComponentProps<typeof TitleFrame>;
|
|
33
45
|
export type CardDescriptionProps = ComponentProps<typeof DescriptionFrame>;
|
|
34
46
|
export type CardActionProps = ComponentProps<typeof ActionFrame>;
|
|
35
47
|
export type CardContentProps = ComponentProps<typeof ContentFrame>;
|
|
36
48
|
export type CardFooterProps = ComponentProps<typeof FooterFrame>;
|
|
37
|
-
declare const Card: (p: CardProps) => import("react/jsx-runtime").JSX.Element;
|
|
38
49
|
declare const CardHeader: (p: CardHeaderProps) => import("react/jsx-runtime").JSX.Element;
|
|
39
50
|
declare const CardTitle: (p: CardTitleProps) => import("react/jsx-runtime").JSX.Element;
|
|
40
51
|
declare const CardDescription: (p: CardDescriptionProps) => import("react/jsx-runtime").JSX.Element;
|
|
41
52
|
declare const CardAction: (p: CardActionProps) => import("react/jsx-runtime").JSX.Element;
|
|
42
53
|
declare const CardContent: ({ children, ...p }: CardContentProps) => import("react/jsx-runtime").JSX.Element;
|
|
43
54
|
declare const CardFooter: ({ children, ...p }: CardFooterProps) => import("react/jsx-runtime").JSX.Element;
|
|
44
|
-
|
|
55
|
+
/**
|
|
56
|
+
* CardMedia — the picture at the top of a card, edge to edge.
|
|
57
|
+
*
|
|
58
|
+
* Full-bleed needs one correction and only one: the Card frame has vertical
|
|
59
|
+
* padding and no horizontal padding (the header/content/footer carry their own
|
|
60
|
+
* `px`), so the media is already the full width and only has to climb back over
|
|
61
|
+
* the frame's top padding. Hence `mt: -PAD` and nothing else — no negative
|
|
62
|
+
* horizontal margin, which is the version that leaks past a rounded corner.
|
|
63
|
+
*
|
|
64
|
+
* It is an AspectRatio, so it has a height before the image loads. That is the
|
|
65
|
+
* whole point: a card whose media is a bare <img> is a card that is 0px tall
|
|
66
|
+
* until the network answers, and then jumps.
|
|
67
|
+
*/
|
|
68
|
+
export type CardMediaProps = AspectRatioProps;
|
|
69
|
+
declare const CardMedia: ({ ratio, ...p }: CardMediaProps) => import("react/jsx-runtime").JSX.Element;
|
|
70
|
+
/**
|
|
71
|
+
* The dot-namespace. `Card.Media`, `Card.Body`, `Card.Title`, `Card.Meta` are
|
|
72
|
+
* the SAME components as the named exports beside them, not second copies —
|
|
73
|
+
* `withStaticProperties` hangs the existing implementations off `Card`. Nothing
|
|
74
|
+
* here can drift from the named export, because there is nothing here to drift.
|
|
75
|
+
*
|
|
76
|
+
* The named exports keep their shadcn-lineage spelling because 79 call sites in
|
|
77
|
+
* hanzo.app are written against it; renaming them would be a breaking change
|
|
78
|
+
* bought for nothing.
|
|
79
|
+
*/
|
|
80
|
+
declare const CardNamespace: (({ interactive, onPress, ...p }: CardProps) => import("react/jsx-runtime").JSX.Element) & {
|
|
81
|
+
Media: ({ ratio, ...p }: CardMediaProps) => import("react/jsx-runtime").JSX.Element;
|
|
82
|
+
Header: (p: CardHeaderProps) => import("react/jsx-runtime").JSX.Element;
|
|
83
|
+
Title: (p: CardTitleProps) => import("react/jsx-runtime").JSX.Element;
|
|
84
|
+
Meta: (p: CardDescriptionProps) => import("react/jsx-runtime").JSX.Element;
|
|
85
|
+
Body: ({ children, ...p }: CardContentProps) => import("react/jsx-runtime").JSX.Element;
|
|
86
|
+
Action: (p: CardActionProps) => import("react/jsx-runtime").JSX.Element;
|
|
87
|
+
Footer: ({ children, ...p }: CardFooterProps) => import("react/jsx-runtime").JSX.Element;
|
|
88
|
+
};
|
|
89
|
+
export { CardNamespace as Card, CardHeader, CardFooter, CardTitle, CardAction, CardDescription, CardContent, CardMedia, };
|
|
45
90
|
//# sourceMappingURL=card.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"card.d.ts","sourceRoot":"","sources":["../../../src/backends/gui/card.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"card.d.ts","sourceRoot":"","sources":["../../../src/backends/gui/card.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,cAAc,EAAiB,MAAM,OAAO,CAAA;AAC1D,OAAO,EAAe,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAMnE,QAAA,MAAM,SAAS;;;8CAQb,CAAA;AASF,QAAA,MAAM,WAAW;;;8CAKf,CAAA;AAEF,QAAA,MAAM,UAAU;;;8CAA4E,CAAA;AAC5F,QAAA,MAAM,gBAAgB;;;8CAAkF,CAAA;AACxG,QAAA,MAAM,WAAW;;;8CAAsE,CAAA;AACvF,QAAA,MAAM,YAAY;;;8CAAmD,CAAA;AACrE,QAAA,MAAM,WAAW;;;8CAAmE,CAAA;AAEpF,MAAM,MAAM,SAAS,GAAG,cAAc,CAAC,OAAO,SAAS,CAAC,GAAG;IACzD;;;;;;;;OAQG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB,CAAA;AACD,MAAM,MAAM,eAAe,GAAG,cAAc,CAAC,OAAO,WAAW,CAAC,CAAA;AAChE,MAAM,MAAM,cAAc,GAAG,cAAc,CAAC,OAAO,UAAU,CAAC,CAAA;AAC9D,MAAM,MAAM,oBAAoB,GAAG,cAAc,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAC1E,MAAM,MAAM,eAAe,GAAG,cAAc,CAAC,OAAO,WAAW,CAAC,CAAA;AAChE,MAAM,MAAM,gBAAgB,GAAG,cAAc,CAAC,OAAO,YAAY,CAAC,CAAA;AAClE,MAAM,MAAM,eAAe,GAAG,cAAc,CAAC,OAAO,WAAW,CAAC,CAAA;AA0BhE,QAAA,MAAM,UAAU,GAAI,GAAG,eAAe,4CAAoD,CAAA;AAC1F,QAAA,MAAM,SAAS,GAAI,GAAG,cAAc,4CAAkD,CAAA;AACtF,QAAA,MAAM,eAAe,GAAI,GAAG,oBAAoB,4CAA8D,CAAA;AAC9G,QAAA,MAAM,UAAU,GAAI,GAAG,eAAe,4CAAoD,CAAA;AAC1F,QAAA,MAAM,WAAW,GAAI,oBAAoB,gBAAgB,4CAExD,CAAA;AACD,QAAA,MAAM,UAAU,GAAI,oBAAoB,eAAe,4CAEtD,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,cAAc,GAAG,gBAAgB,CAAA;AAC7C,QAAA,MAAM,SAAS,GAAI,iBAA2B,cAAc,4CAE3D,CAAA;AAED;;;;;;;;;GASG;AACH,QAAA,MAAM,aAAa,oCA/D2B,SAAS;6BAiDT,cAAc;gBAzBrC,eAAe;eAChB,cAAc;cACR,oBAAoB;+BAEP,gBAAgB;gBADlC,eAAe;iCAIE,eAAe;CAwCrD,CAAA;AAEF,OAAO,EACL,aAAa,IAAI,IAAI,EACrB,UAAU,EACV,UAAU,EACV,SAAS,EACT,UAAU,EACV,eAAe,EACf,WAAW,EACX,SAAS,GACV,CAAA"}
|
|
@@ -6,7 +6,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
6
6
|
* The header is a row whose action sits at its end: gui/Yoga has no CSS grid,
|
|
7
7
|
* and a row is the one box model that also exists on native.
|
|
8
8
|
*/
|
|
9
|
-
import { SizableText, XStack, YStack, styled } from '@hanzo/gui';
|
|
9
|
+
import { SizableText, XStack, YStack, styled, withStaticProperties } from '@hanzo/gui';
|
|
10
|
+
import { AspectRatio } from './aspect-ratio.js';
|
|
10
11
|
import { ink } from './ink.js';
|
|
11
12
|
import { slot } from './slot.js';
|
|
12
13
|
const PAD = 24;
|
|
@@ -37,12 +38,49 @@ const DescriptionFrame = styled(SizableText, { name: 'CardDescription', size: '$
|
|
|
37
38
|
const ActionFrame = styled(XStack, { name: 'CardAction', self: 'flex-end', shrink: 0 });
|
|
38
39
|
const ContentFrame = styled(YStack, { name: 'CardContent', px: PAD });
|
|
39
40
|
const FooterFrame = styled(XStack, { name: 'CardFooter', px: PAD, items: 'center' });
|
|
40
|
-
const Card = (p) => _jsx(CardFrame, { ...slot('card'), ...
|
|
41
|
+
const Card = ({ interactive, onPress, ...p }) => (_jsx(CardFrame, { ...slot('card'), ...(interactive
|
|
42
|
+
? {
|
|
43
|
+
role: 'button',
|
|
44
|
+
tabIndex: 0,
|
|
45
|
+
cursor: 'pointer',
|
|
46
|
+
hoverStyle: { borderColor: '$color8' },
|
|
47
|
+
focusStyle: { borderColor: '$color8', outlineWidth: 2, outlineStyle: 'solid', outlineColor: '$color8' },
|
|
48
|
+
// A div with role="button" is not a button: the browser gives it no
|
|
49
|
+
// keyboard activation, so it has to be spelled out or the card is
|
|
50
|
+
// mouse-only. Space must also preventDefault or the page scrolls.
|
|
51
|
+
onKeyDown: (e) => {
|
|
52
|
+
if (e.key !== 'Enter' && e.key !== ' ')
|
|
53
|
+
return;
|
|
54
|
+
e.preventDefault();
|
|
55
|
+
onPress?.(e);
|
|
56
|
+
},
|
|
57
|
+
}
|
|
58
|
+
: null), onPress: onPress, ...p }));
|
|
41
59
|
const CardHeader = (p) => _jsx(HeaderFrame, { ...slot('card-header'), ...p });
|
|
42
60
|
const CardTitle = (p) => _jsx(TitleFrame, { ...slot('card-title'), ...p });
|
|
43
61
|
const CardDescription = (p) => _jsx(DescriptionFrame, { ...slot('card-description'), ...p });
|
|
44
62
|
const CardAction = (p) => _jsx(ActionFrame, { ...slot('card-action'), ...p });
|
|
45
63
|
const CardContent = ({ children, ...p }) => (_jsx(ContentFrame, { ...slot('card-content'), ...p, children: ink(children) }));
|
|
46
64
|
const CardFooter = ({ children, ...p }) => (_jsx(FooterFrame, { ...slot('card-footer'), ...p, children: ink(children) }));
|
|
47
|
-
|
|
65
|
+
const CardMedia = ({ ratio = 16 / 10, ...p }) => (_jsx(AspectRatio, { ...slot('card-media'), ratio: ratio, mt: -PAD, ...p }));
|
|
66
|
+
/**
|
|
67
|
+
* The dot-namespace. `Card.Media`, `Card.Body`, `Card.Title`, `Card.Meta` are
|
|
68
|
+
* the SAME components as the named exports beside them, not second copies —
|
|
69
|
+
* `withStaticProperties` hangs the existing implementations off `Card`. Nothing
|
|
70
|
+
* here can drift from the named export, because there is nothing here to drift.
|
|
71
|
+
*
|
|
72
|
+
* The named exports keep their shadcn-lineage spelling because 79 call sites in
|
|
73
|
+
* hanzo.app are written against it; renaming them would be a breaking change
|
|
74
|
+
* bought for nothing.
|
|
75
|
+
*/
|
|
76
|
+
const CardNamespace = withStaticProperties(Card, {
|
|
77
|
+
Media: CardMedia,
|
|
78
|
+
Header: CardHeader,
|
|
79
|
+
Title: CardTitle,
|
|
80
|
+
Meta: CardDescription,
|
|
81
|
+
Body: CardContent,
|
|
82
|
+
Action: CardAction,
|
|
83
|
+
Footer: CardFooter,
|
|
84
|
+
});
|
|
85
|
+
export { CardNamespace as Card, CardHeader, CardFooter, CardTitle, CardAction, CardDescription, CardContent, CardMedia, };
|
|
48
86
|
//# sourceMappingURL=card.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"card.js","sourceRoot":"","sources":["../../../src/backends/gui/card.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ;;;;;GAKG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"card.js","sourceRoot":"","sources":["../../../src/backends/gui/card.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;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U,EACV,UAAU,EACV,SAAS,EACT,UAAU,EACV,eAAe,EACf,WAAW,EACX,SAAS,GACV,CAAA"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
'use client';"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.Grid = void 0;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
/**
|
|
7
|
+
* Grid — a real CSS grid whose tracks come from the CONTAINER, not the children.
|
|
8
|
+
*
|
|
9
|
+
* This exists to kill a specific shipped defect: hand-rolled
|
|
10
|
+
* `width="calc(25% - 7.5px)"` grids that collapse asymmetrically. That shape is
|
|
11
|
+
* broken by construction — each child computes its own width, so the row is only
|
|
12
|
+
* even while every child agrees, and one long word or one `box-sizing` surprise
|
|
13
|
+
* makes the row ragged. Nothing about it can be fixed by tuning the number.
|
|
14
|
+
*
|
|
15
|
+
* Here the parent declares the tracks once and the children have no say. Equal
|
|
16
|
+
* columns are structural, not arithmetic, and no child can widen its own track.
|
|
17
|
+
*
|
|
18
|
+
* Why a plain div and not a gui YStack: gui's box model is Yoga, which is
|
|
19
|
+
* flexbox and has no grid — a YStack would compile its own `display:flex`
|
|
20
|
+
* atomic class and fight the grid. Inline styles, not a stylesheet class, so
|
|
21
|
+
* there is no rule to fail to ship: this package's own checker exists because
|
|
22
|
+
* "class with no rule" has shipped here three times.
|
|
23
|
+
*
|
|
24
|
+
* The two track formulas, both deliberate:
|
|
25
|
+
*
|
|
26
|
+
* auto repeat(auto-fill, minmax(min(Npx, 100%), 1fr))
|
|
27
|
+
* The `min(Npx, 100%)` is what makes it safe below N: a bare
|
|
28
|
+
* `minmax(240px, 1fr)` forces a 240px track inside a 200px phone and
|
|
29
|
+
* overflows the viewport horizontally. Responsive with ZERO breakpoint
|
|
30
|
+
* props — the wrap count follows the container, so the same tree is
|
|
31
|
+
* right at 390 and at 1280.
|
|
32
|
+
*
|
|
33
|
+
* cols repeat(n, minmax(0, 1fr))
|
|
34
|
+
* `1fr` alone means `minmax(auto, 1fr)`, and `auto` floors the track at
|
|
35
|
+
* the content's min-content width — so one long unbroken string pushes
|
|
36
|
+
* its own column wider and every sibling narrower. That IS the ragged
|
|
37
|
+
* row. `minmax(0, 1fr)` is the fix.
|
|
38
|
+
*
|
|
39
|
+
* `[data-slot='grid'] > *` also gets `min-width: 0` in the stylesheet, for the
|
|
40
|
+
* same reason: a grid item's default `min-width: auto` lets its content set the
|
|
41
|
+
* floor and blow the track out.
|
|
42
|
+
*/
|
|
43
|
+
const gui_1 = require("@hanzo/gui");
|
|
44
|
+
/** `'$3'` -> 12. A raw number passes through as px. */
|
|
45
|
+
const space = (v, fallback) => {
|
|
46
|
+
if (v == null)
|
|
47
|
+
return fallback;
|
|
48
|
+
if (typeof v === 'number')
|
|
49
|
+
return v;
|
|
50
|
+
const t = (0, gui_1.getTokenValue)(v, 'space');
|
|
51
|
+
return typeof t === 'number' ? t : fallback;
|
|
52
|
+
};
|
|
53
|
+
const Grid = ({ min = 240, cols, gap = '$3', style, ...props }) => {
|
|
54
|
+
const g = space(gap, 12);
|
|
55
|
+
const columns = cols
|
|
56
|
+
? `repeat(${cols}, minmax(0, 1fr))`
|
|
57
|
+
: `repeat(auto-fill, minmax(min(${min}px, 100%), 1fr))`;
|
|
58
|
+
const grid = { display: 'grid', gridTemplateColumns: columns, gap: g };
|
|
59
|
+
return (0, jsx_runtime_1.jsx)("div", { "data-slot": "grid", style: { ...grid, ...style }, ...props });
|
|
60
|
+
};
|
|
61
|
+
exports.Grid = Grid;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ComponentProps, ReactNode } from 'react';
|
|
2
|
+
export interface GridProps extends Omit<ComponentProps<'div'>, 'children'> {
|
|
3
|
+
/**
|
|
4
|
+
* Narrowest a column may get before the grid drops one. The whole responsive
|
|
5
|
+
* story: no breakpoints, no props per screen size.
|
|
6
|
+
*/
|
|
7
|
+
min?: number;
|
|
8
|
+
/** Fixed column count. Overrides `min` — use it when the count is the design. */
|
|
9
|
+
cols?: number;
|
|
10
|
+
/** A `$n` space token or a raw px number. */
|
|
11
|
+
gap?: number | string;
|
|
12
|
+
children?: ReactNode;
|
|
13
|
+
}
|
|
14
|
+
declare const Grid: ({ min, cols, gap, style, ...props }: GridProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export { Grid };
|
|
16
|
+
//# sourceMappingURL=grid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../../../src/backends/gui/grid.tsx"],"names":[],"mappings":"AAwCA,OAAO,KAAK,EAAE,cAAc,EAAiB,SAAS,EAAE,MAAM,OAAO,CAAA;AAErE,MAAM,WAAW,SAAU,SAAQ,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC;IACxE;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,iFAAiF;IACjF,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,6CAA6C;IAC7C,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACrB,QAAQ,CAAC,EAAE,SAAS,CAAA;CACrB;AAUD,QAAA,MAAM,IAAI,GAAI,qCAAkD,SAAS,4CAOxE,CAAA;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* Grid — a real CSS grid whose tracks come from the CONTAINER, not the children.
|
|
5
|
+
*
|
|
6
|
+
* This exists to kill a specific shipped defect: hand-rolled
|
|
7
|
+
* `width="calc(25% - 7.5px)"` grids that collapse asymmetrically. That shape is
|
|
8
|
+
* broken by construction — each child computes its own width, so the row is only
|
|
9
|
+
* even while every child agrees, and one long word or one `box-sizing` surprise
|
|
10
|
+
* makes the row ragged. Nothing about it can be fixed by tuning the number.
|
|
11
|
+
*
|
|
12
|
+
* Here the parent declares the tracks once and the children have no say. Equal
|
|
13
|
+
* columns are structural, not arithmetic, and no child can widen its own track.
|
|
14
|
+
*
|
|
15
|
+
* Why a plain div and not a gui YStack: gui's box model is Yoga, which is
|
|
16
|
+
* flexbox and has no grid — a YStack would compile its own `display:flex`
|
|
17
|
+
* atomic class and fight the grid. Inline styles, not a stylesheet class, so
|
|
18
|
+
* there is no rule to fail to ship: this package's own checker exists because
|
|
19
|
+
* "class with no rule" has shipped here three times.
|
|
20
|
+
*
|
|
21
|
+
* The two track formulas, both deliberate:
|
|
22
|
+
*
|
|
23
|
+
* auto repeat(auto-fill, minmax(min(Npx, 100%), 1fr))
|
|
24
|
+
* The `min(Npx, 100%)` is what makes it safe below N: a bare
|
|
25
|
+
* `minmax(240px, 1fr)` forces a 240px track inside a 200px phone and
|
|
26
|
+
* overflows the viewport horizontally. Responsive with ZERO breakpoint
|
|
27
|
+
* props — the wrap count follows the container, so the same tree is
|
|
28
|
+
* right at 390 and at 1280.
|
|
29
|
+
*
|
|
30
|
+
* cols repeat(n, minmax(0, 1fr))
|
|
31
|
+
* `1fr` alone means `minmax(auto, 1fr)`, and `auto` floors the track at
|
|
32
|
+
* the content's min-content width — so one long unbroken string pushes
|
|
33
|
+
* its own column wider and every sibling narrower. That IS the ragged
|
|
34
|
+
* row. `minmax(0, 1fr)` is the fix.
|
|
35
|
+
*
|
|
36
|
+
* `[data-slot='grid'] > *` also gets `min-width: 0` in the stylesheet, for the
|
|
37
|
+
* same reason: a grid item's default `min-width: auto` lets its content set the
|
|
38
|
+
* floor and blow the track out.
|
|
39
|
+
*/
|
|
40
|
+
import { getTokenValue } from '@hanzo/gui';
|
|
41
|
+
/** `'$3'` -> 12. A raw number passes through as px. */
|
|
42
|
+
const space = (v, fallback) => {
|
|
43
|
+
if (v == null)
|
|
44
|
+
return fallback;
|
|
45
|
+
if (typeof v === 'number')
|
|
46
|
+
return v;
|
|
47
|
+
const t = getTokenValue(v, 'space');
|
|
48
|
+
return typeof t === 'number' ? t : fallback;
|
|
49
|
+
};
|
|
50
|
+
const Grid = ({ min = 240, cols, gap = '$3', style, ...props }) => {
|
|
51
|
+
const g = space(gap, 12);
|
|
52
|
+
const columns = cols
|
|
53
|
+
? `repeat(${cols}, minmax(0, 1fr))`
|
|
54
|
+
: `repeat(auto-fill, minmax(min(${min}px, 100%), 1fr))`;
|
|
55
|
+
const grid = { display: 'grid', gridTemplateColumns: columns, gap: g };
|
|
56
|
+
return _jsx("div", { "data-slot": "grid", style: { ...grid, ...style }, ...props });
|
|
57
|
+
};
|
|
58
|
+
export { Grid };
|
|
59
|
+
//# sourceMappingURL=grid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grid.js","sourceRoot":"","sources":["../../../src/backends/gui/grid.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAgB1C,uDAAuD;AACvD,MAAM,KAAK,GAAG,CAAC,CAA8B,EAAE,QAAgB,EAAU,EAAE;IACzE,IAAI,CAAC,IAAI,IAAI;QAAE,OAAO,QAAQ,CAAA;IAC9B,IAAI,OAAO,CAAC,KAAK,QAAQ;QAAE,OAAO,CAAC,CAAA;IACnC,MAAM,CAAC,GAAG,aAAa,CAAC,CAAU,EAAE,OAAO,CAAC,CAAA;IAC5C,OAAO,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAA;AAC7C,CAAC,CAAA;AAED,MAAM,IAAI,GAAG,CAAC,EAAE,GAAG,GAAG,GAAG,EAAE,IAAI,EAAE,GAAG,GAAG,IAAI,EAAE,KAAK,EAAE,GAAG,KAAK,EAAa,EAAE,EAAE;IAC3E,MAAM,CAAC,GAAG,KAAK,CAAC,GAAG,EAAE,EAAE,CAAC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