@nmnmcc/standard 0.0.0-stage → 0.4.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/LICENSE +21 -0
- package/README.md +516 -2
- package/dist/Extend.d.ts +15 -0
- package/dist/Extend.d.ts.map +1 -0
- package/dist/Extend.js +1 -0
- package/dist/Node.d.ts +71 -0
- package/dist/Node.d.ts.map +1 -0
- package/dist/Palette-BIJ96BEh.js +84 -0
- package/dist/Palette.d.ts +8 -0
- package/dist/Palette.d.ts.map +1 -0
- package/dist/Palette.js +1 -0
- package/dist/Standard-BPpzr5SM.js +488 -0
- package/dist/Standard.d.ts +249 -0
- package/dist/Standard.d.ts.map +1 -0
- package/dist/Standard.js +1 -0
- package/dist/Ui-B9xQqqNT.js +468 -0
- package/dist/Ui.d.ts +500 -0
- package/dist/Ui.d.ts.map +1 -0
- package/dist/Ui.js +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/rolldown-runtime-BMBA7GOT.js +10 -0
- package/dist/standard/button/button.d.ts +21 -0
- package/dist/standard/button/button.d.ts.map +1 -0
- package/dist/standard/colour/colour.d.ts +93 -0
- package/dist/standard/colour/colour.d.ts.map +1 -0
- package/dist/standard/field/field.d.ts +91 -0
- package/dist/standard/field/field.d.ts.map +1 -0
- package/dist/standard/form/form.d.ts +16 -0
- package/dist/standard/form/form.d.ts.map +1 -0
- package/dist/standard/icon/icon.d.ts +31 -0
- package/dist/standard/icon/icon.d.ts.map +1 -0
- package/dist/standard/image/image.d.ts +21 -0
- package/dist/standard/image/image.d.ts.map +1 -0
- package/dist/standard/layout/layout.d.ts +73 -0
- package/dist/standard/layout/layout.d.ts.map +1 -0
- package/dist/standard/list/list.d.ts +26 -0
- package/dist/standard/list/list.d.ts.map +1 -0
- package/dist/standard/page/page.d.ts +20 -0
- package/dist/standard/page/page.d.ts.map +1 -0
- package/dist/standard/table/table.d.ts +18 -0
- package/dist/standard/table/table.d.ts.map +1 -0
- package/dist/standard/text/text.d.ts +39 -0
- package/dist/standard/text/text.d.ts.map +1 -0
- package/dist/standard/tokens/classes.d.ts +16 -0
- package/dist/standard/tokens/classes.d.ts.map +1 -0
- package/dist/standard/tokens/tokens.d.ts +162 -0
- package/dist/standard/tokens/tokens.d.ts.map +1 -0
- package/dist/standard.css +2 -0
- package/dist/ui/arrow/arrow.d.ts +18 -0
- package/dist/ui/arrow/arrow.d.ts.map +1 -0
- package/dist/ui/avatar/avatar.d.ts +15 -0
- package/dist/ui/avatar/avatar.d.ts.map +1 -0
- package/dist/ui/board/board.d.ts +34 -0
- package/dist/ui/board/board.d.ts.map +1 -0
- package/dist/ui/bullet/bullet.d.ts +15 -0
- package/dist/ui/bullet/bullet.d.ts.map +1 -0
- package/dist/ui/card/card.d.ts +24 -0
- package/dist/ui/card/card.d.ts.map +1 -0
- package/dist/ui/carousel/carousel.d.ts +17 -0
- package/dist/ui/carousel/carousel.d.ts.map +1 -0
- package/dist/ui/check/check.d.ts +20 -0
- package/dist/ui/check/check.d.ts.map +1 -0
- package/dist/ui/choice/choice.d.ts +19 -0
- package/dist/ui/choice/choice.d.ts.map +1 -0
- package/dist/ui/control/control.d.ts +57 -0
- package/dist/ui/control/control.d.ts.map +1 -0
- package/dist/ui/dialog/dialog.d.ts +30 -0
- package/dist/ui/dialog/dialog.d.ts.map +1 -0
- package/dist/ui/disclosure/disclosure.d.ts +20 -0
- package/dist/ui/disclosure/disclosure.d.ts.map +1 -0
- package/dist/ui/flap/flap.d.ts +18 -0
- package/dist/ui/flap/flap.d.ts.map +1 -0
- package/dist/ui/item/item.d.ts +21 -0
- package/dist/ui/item/item.d.ts.map +1 -0
- package/dist/ui/key/key.d.ts +12 -0
- package/dist/ui/key/key.d.ts.map +1 -0
- package/dist/ui/menu/menu.d.ts +26 -0
- package/dist/ui/menu/menu.d.ts.map +1 -0
- package/dist/ui/modal/modal.d.ts +22 -0
- package/dist/ui/modal/modal.d.ts.map +1 -0
- package/dist/ui/navigator/navigator.d.ts +137 -0
- package/dist/ui/navigator/navigator.d.ts.map +1 -0
- package/dist/ui/notice/notice.d.ts +34 -0
- package/dist/ui/notice/notice.d.ts.map +1 -0
- package/dist/ui/options/options.d.ts +19 -0
- package/dist/ui/options/options.d.ts.map +1 -0
- package/dist/ui/pager/pager.d.ts +29 -0
- package/dist/ui/pager/pager.d.ts.map +1 -0
- package/dist/ui/pagination/pagination.d.ts +14 -0
- package/dist/ui/pagination/pagination.d.ts.map +1 -0
- package/dist/ui/popover/popover.d.ts +20 -0
- package/dist/ui/popover/popover.d.ts.map +1 -0
- package/dist/ui/progress/progress.d.ts +17 -0
- package/dist/ui/progress/progress.d.ts.map +1 -0
- package/dist/ui/route/route.d.ts +27 -0
- package/dist/ui/route/route.d.ts.map +1 -0
- package/dist/ui/sheet/sheet.d.ts +35 -0
- package/dist/ui/sheet/sheet.d.ts.map +1 -0
- package/dist/ui/skeleton/skeleton.d.ts +15 -0
- package/dist/ui/skeleton/skeleton.d.ts.map +1 -0
- package/dist/ui/slider/slider.d.ts +23 -0
- package/dist/ui/slider/slider.d.ts.map +1 -0
- package/dist/ui/stepper/stepper.d.ts +32 -0
- package/dist/ui/stepper/stepper.d.ts.map +1 -0
- package/dist/ui/tabs/tabs.d.ts +22 -0
- package/dist/ui/tabs/tabs.d.ts.map +1 -0
- package/dist/ui/tag/tag.d.ts +17 -0
- package/dist/ui/tag/tag.d.ts.map +1 -0
- package/dist/ui/tile/tile.d.ts +38 -0
- package/dist/ui/tile/tile.d.ts.map +1 -0
- package/dist/ui/toasts/toasts.d.ts +17 -0
- package/dist/ui/toasts/toasts.d.ts.map +1 -0
- package/dist/ui/toggle/toggle.d.ts +17 -0
- package/dist/ui/toggle/toggle.d.ts.map +1 -0
- package/dist/ui/trail/trail.d.ts +22 -0
- package/dist/ui/trail/trail.d.ts.map +1 -0
- package/package.json +70 -3
- package/src/Extend.ts +14 -0
- package/src/Node.ts +44 -0
- package/src/Palette.ts +7 -0
- package/src/Standard.ts +109 -0
- package/src/Ui.ts +156 -0
- package/src/index.ts +27 -0
- package/src/standard/button/button.module.css +43 -0
- package/src/standard/button/button.module.d.css.ts +6 -0
- package/src/standard/button/button.ts +38 -0
- package/src/standard/colour/colour.ts +197 -0
- package/src/standard/field/field.module.css +222 -0
- package/src/standard/field/field.module.d.css.ts +13 -0
- package/src/standard/field/field.ts +266 -0
- package/src/standard/form/form.ts +25 -0
- package/src/standard/icon/icon.module.css +349 -0
- package/src/standard/icon/icon.module.d.css.ts +112 -0
- package/src/standard/icon/icon.ts +148 -0
- package/src/standard/image/image.module.css +42 -0
- package/src/standard/image/image.module.d.css.ts +12 -0
- package/src/standard/image/image.ts +39 -0
- package/src/standard/layout/layout.module.css +224 -0
- package/src/standard/layout/layout.module.d.css.ts +41 -0
- package/src/standard/layout/layout.ts +133 -0
- package/src/standard/list/list.module.css +71 -0
- package/src/standard/list/list.module.d.css.ts +10 -0
- package/src/standard/list/list.ts +53 -0
- package/src/standard/page/page.module.css +244 -0
- package/src/standard/page/page.module.d.css.ts +9 -0
- package/src/standard/page/page.ts +32 -0
- package/src/standard/table/table.module.css +40 -0
- package/src/standard/table/table.module.d.css.ts +6 -0
- package/src/standard/table/table.ts +36 -0
- package/src/standard/text/text.module.css +149 -0
- package/src/standard/text/text.module.d.css.ts +19 -0
- package/src/standard/text/text.ts +77 -0
- package/src/standard/tokens/classes.ts +31 -0
- package/src/standard/tokens/tokens.module.css +294 -0
- package/src/standard/tokens/tokens.module.d.css.ts +40 -0
- package/src/standard/tokens/tokens.ts +339 -0
- package/src/ui/arrow/arrow.module.css +38 -0
- package/src/ui/arrow/arrow.module.d.css.ts +13 -0
- package/src/ui/arrow/arrow.ts +35 -0
- package/src/ui/avatar/avatar.module.css +25 -0
- package/src/ui/avatar/avatar.module.d.css.ts +5 -0
- package/src/ui/avatar/avatar.ts +28 -0
- package/src/ui/board/board.module.css +94 -0
- package/src/ui/board/board.module.d.css.ts +10 -0
- package/src/ui/board/board.ts +84 -0
- package/src/ui/bullet/bullet.module.css +28 -0
- package/src/ui/bullet/bullet.module.d.css.ts +5 -0
- package/src/ui/bullet/bullet.ts +16 -0
- package/src/ui/card/card.module.css +80 -0
- package/src/ui/card/card.module.d.css.ts +6 -0
- package/src/ui/card/card.ts +42 -0
- package/src/ui/carousel/carousel.module.css +24 -0
- package/src/ui/carousel/carousel.module.d.css.ts +5 -0
- package/src/ui/carousel/carousel.ts +30 -0
- package/src/ui/check/check.module.css +53 -0
- package/src/ui/check/check.module.d.css.ts +8 -0
- package/src/ui/check/check.ts +46 -0
- package/src/ui/choice/choice.module.css +32 -0
- package/src/ui/choice/choice.module.d.css.ts +6 -0
- package/src/ui/choice/choice.ts +31 -0
- package/src/ui/control/control.module.css +127 -0
- package/src/ui/control/control.module.d.css.ts +12 -0
- package/src/ui/control/control.ts +97 -0
- package/src/ui/dialog/dialog.module.css +42 -0
- package/src/ui/dialog/dialog.module.d.css.ts +6 -0
- package/src/ui/dialog/dialog.ts +44 -0
- package/src/ui/disclosure/disclosure.module.css +57 -0
- package/src/ui/disclosure/disclosure.module.d.css.ts +7 -0
- package/src/ui/disclosure/disclosure.ts +32 -0
- package/src/ui/flap/flap.module.css +161 -0
- package/src/ui/flap/flap.module.d.css.ts +48 -0
- package/src/ui/flap/flap.ts +78 -0
- package/src/ui/item/item.module.css +39 -0
- package/src/ui/item/item.module.d.css.ts +7 -0
- package/src/ui/item/item.ts +33 -0
- package/src/ui/key/key.module.css +15 -0
- package/src/ui/key/key.module.d.css.ts +5 -0
- package/src/ui/key/key.ts +13 -0
- package/src/ui/menu/menu.module.css +11 -0
- package/src/ui/menu/menu.module.d.css.ts +5 -0
- package/src/ui/menu/menu.ts +48 -0
- package/src/ui/modal/modal.module.css +66 -0
- package/src/ui/modal/modal.module.d.css.ts +8 -0
- package/src/ui/modal/modal.ts +55 -0
- package/src/ui/navigator/navigator.module.css +658 -0
- package/src/ui/navigator/navigator.module.d.css.ts +39 -0
- package/src/ui/navigator/navigator.ts +337 -0
- package/src/ui/notice/notice.module.css +80 -0
- package/src/ui/notice/notice.module.d.css.ts +10 -0
- package/src/ui/notice/notice.ts +57 -0
- package/src/ui/options/options.module.css +30 -0
- package/src/ui/options/options.module.d.css.ts +6 -0
- package/src/ui/options/options.ts +31 -0
- package/src/ui/pager/pager.module.css +38 -0
- package/src/ui/pager/pager.module.d.css.ts +8 -0
- package/src/ui/pager/pager.ts +48 -0
- package/src/ui/pagination/pagination.module.css +38 -0
- package/src/ui/pagination/pagination.module.d.css.ts +7 -0
- package/src/ui/pagination/pagination.ts +52 -0
- package/src/ui/popover/popover.module.css +94 -0
- package/src/ui/popover/popover.module.d.css.ts +8 -0
- package/src/ui/popover/popover.ts +139 -0
- package/src/ui/progress/progress.module.css +69 -0
- package/src/ui/progress/progress.module.d.css.ts +6 -0
- package/src/ui/progress/progress.ts +26 -0
- package/src/ui/route/route.module.css +116 -0
- package/src/ui/route/route.module.d.css.ts +11 -0
- package/src/ui/route/route.ts +58 -0
- package/src/ui/sheet/sheet.module.css +194 -0
- package/src/ui/sheet/sheet.module.d.css.ts +7 -0
- package/src/ui/sheet/sheet.ts +47 -0
- package/src/ui/skeleton/skeleton.module.css +44 -0
- package/src/ui/skeleton/skeleton.module.d.css.ts +6 -0
- package/src/ui/skeleton/skeleton.ts +20 -0
- package/src/ui/slider/slider.module.css +56 -0
- package/src/ui/slider/slider.module.d.css.ts +6 -0
- package/src/ui/slider/slider.ts +48 -0
- package/src/ui/stepper/stepper.module.css +32 -0
- package/src/ui/stepper/stepper.module.d.css.ts +7 -0
- package/src/ui/stepper/stepper.ts +62 -0
- package/src/ui/tabs/tabs.module.css +38 -0
- package/src/ui/tabs/tabs.module.d.css.ts +6 -0
- package/src/ui/tabs/tabs.ts +24 -0
- package/src/ui/tag/tag.module.css +23 -0
- package/src/ui/tag/tag.module.d.css.ts +5 -0
- package/src/ui/tag/tag.ts +17 -0
- package/src/ui/tile/tile.module.css +137 -0
- package/src/ui/tile/tile.module.d.css.ts +13 -0
- package/src/ui/tile/tile.ts +69 -0
- package/src/ui/toasts/toasts.module.css +38 -0
- package/src/ui/toasts/toasts.module.d.css.ts +6 -0
- package/src/ui/toasts/toasts.ts +26 -0
- package/src/ui/toggle/toggle.module.css +46 -0
- package/src/ui/toggle/toggle.module.d.css.ts +6 -0
- package/src/ui/toggle/toggle.ts +29 -0
- package/src/ui/trail/trail.module.css +42 -0
- package/src/ui/trail/trail.module.d.css.ts +5 -0
- package/src/ui/trail/trail.ts +28 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `image`: a picture, cropped to a ratio.
|
|
3
|
+
*
|
|
4
|
+
* @since 0.4.0
|
|
5
|
+
*/
|
|
6
|
+
import type { Html } from "effect/ui/html"
|
|
7
|
+
import { node, type Node } from "../../Node.ts"
|
|
8
|
+
import { on } from "../tokens/classes.ts"
|
|
9
|
+
import styles from "./image.module.css"
|
|
10
|
+
import type { Ratio } from "../tokens/tokens.ts"
|
|
11
|
+
|
|
12
|
+
const ratios = { "1/1": "1x1", "4/3": "4x3", "3/2": "3x2", "16/9": "16x9", "3/4": "3x4", "2/3": "2x3" } as const
|
|
13
|
+
|
|
14
|
+
export const image = <Msg>(h: Html.H<Msg>) => ({
|
|
15
|
+
/**
|
|
16
|
+
* An image, cropped to a ratio. With a `caption`, it is a figure: the
|
|
17
|
+
* caption is set small under it, and belongs to it for a screen reader.
|
|
18
|
+
*/
|
|
19
|
+
image: (options: {
|
|
20
|
+
readonly src: string
|
|
21
|
+
readonly alt: string
|
|
22
|
+
readonly ratio?: Ratio
|
|
23
|
+
readonly caption?: string
|
|
24
|
+
}): Node<"block", Msg> => {
|
|
25
|
+
const img = h.img
|
|
26
|
+
.class(
|
|
27
|
+
styles.image,
|
|
28
|
+
on(options.ratio, (ratio) => styles[`ratio-${ratios[ratio]}`])
|
|
29
|
+
)
|
|
30
|
+
.attr("src", options.src)
|
|
31
|
+
.attr("alt", options.alt)
|
|
32
|
+
.attr("loading", "lazy")
|
|
33
|
+
return node(
|
|
34
|
+
options.caption === undefined
|
|
35
|
+
? img
|
|
36
|
+
: h.figure.class(styles.figure).children(img, h.figcaption.children(options.caption))
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
})
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
/* The layout: section, grid, col, stack, row and rule. */
|
|
2
|
+
|
|
3
|
+
@layer standard.tokens {
|
|
4
|
+
/*
|
|
5
|
+
* A region that picks a colour but no ground keeps the ground it is on, and
|
|
6
|
+
* its colour as text is the one that can be read there: on paper, on ink,
|
|
7
|
+
* or, on a block of another colour, what that block carries.
|
|
8
|
+
*/
|
|
9
|
+
.section[class*="accent-"]:not([class*="tone-"]) {
|
|
10
|
+
--s-mark: var(--s-accent);
|
|
11
|
+
--s-on-mark: var(--s-on-accent);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.span-1 {
|
|
15
|
+
--s-span: 1;
|
|
16
|
+
}
|
|
17
|
+
.span-2 {
|
|
18
|
+
--s-span: 2;
|
|
19
|
+
}
|
|
20
|
+
.span-3 {
|
|
21
|
+
--s-span: 3;
|
|
22
|
+
}
|
|
23
|
+
.span-4 {
|
|
24
|
+
--s-span: 4;
|
|
25
|
+
}
|
|
26
|
+
.span-5 {
|
|
27
|
+
--s-span: 5;
|
|
28
|
+
}
|
|
29
|
+
.span-6 {
|
|
30
|
+
--s-span: 6;
|
|
31
|
+
}
|
|
32
|
+
.span-7 {
|
|
33
|
+
--s-span: 7;
|
|
34
|
+
}
|
|
35
|
+
.span-8 {
|
|
36
|
+
--s-span: 8;
|
|
37
|
+
}
|
|
38
|
+
.span-9 {
|
|
39
|
+
--s-span: 9;
|
|
40
|
+
}
|
|
41
|
+
.span-10 {
|
|
42
|
+
--s-span: 10;
|
|
43
|
+
}
|
|
44
|
+
.span-11 {
|
|
45
|
+
--s-span: 11;
|
|
46
|
+
}
|
|
47
|
+
.span-12 {
|
|
48
|
+
--s-span: 12;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.start-1 {
|
|
52
|
+
--s-start: 1;
|
|
53
|
+
}
|
|
54
|
+
.start-2 {
|
|
55
|
+
--s-start: 2;
|
|
56
|
+
}
|
|
57
|
+
.start-3 {
|
|
58
|
+
--s-start: 3;
|
|
59
|
+
}
|
|
60
|
+
.start-4 {
|
|
61
|
+
--s-start: 4;
|
|
62
|
+
}
|
|
63
|
+
.start-5 {
|
|
64
|
+
--s-start: 5;
|
|
65
|
+
}
|
|
66
|
+
.start-6 {
|
|
67
|
+
--s-start: 6;
|
|
68
|
+
}
|
|
69
|
+
.start-7 {
|
|
70
|
+
--s-start: 7;
|
|
71
|
+
}
|
|
72
|
+
.start-8 {
|
|
73
|
+
--s-start: 8;
|
|
74
|
+
}
|
|
75
|
+
.start-9 {
|
|
76
|
+
--s-start: 9;
|
|
77
|
+
}
|
|
78
|
+
.start-10 {
|
|
79
|
+
--s-start: 10;
|
|
80
|
+
}
|
|
81
|
+
.start-11 {
|
|
82
|
+
--s-start: 11;
|
|
83
|
+
}
|
|
84
|
+
.start-12 {
|
|
85
|
+
--s-start: 12;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/*
|
|
89
|
+
* The defaults. They are in the layer the token classes are in, at zero
|
|
90
|
+
* specificity, so a token class always wins. In a later layer they
|
|
91
|
+
* would win themselves, whatever their specificity.
|
|
92
|
+
*/
|
|
93
|
+
:where(.section) {
|
|
94
|
+
--s-gap: calc(4 * var(--s-unit));
|
|
95
|
+
--s-pad: calc(6 * var(--s-unit));
|
|
96
|
+
}
|
|
97
|
+
:where(.grid) {
|
|
98
|
+
--s-gap: calc(4 * var(--s-unit));
|
|
99
|
+
}
|
|
100
|
+
:where(.col, .stack, .row) {
|
|
101
|
+
--s-gap: calc(2 * var(--s-unit));
|
|
102
|
+
}
|
|
103
|
+
:where(.row) {
|
|
104
|
+
--s-align: baseline;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
@layer standard.layout {
|
|
109
|
+
.section,
|
|
110
|
+
.stack,
|
|
111
|
+
.col {
|
|
112
|
+
display: grid;
|
|
113
|
+
grid-template-columns: minmax(0, 1fr);
|
|
114
|
+
align-content: start;
|
|
115
|
+
row-gap: var(--s-gap);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.section {
|
|
119
|
+
padding-block: var(--s-pad);
|
|
120
|
+
padding-inline: var(--s-margin);
|
|
121
|
+
background: var(--s-bg);
|
|
122
|
+
color: var(--s-fg);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.grid {
|
|
126
|
+
display: grid;
|
|
127
|
+
grid-template-columns: repeat(12, minmax(0, 1fr));
|
|
128
|
+
column-gap: var(--s-gutter);
|
|
129
|
+
row-gap: var(--s-gap);
|
|
130
|
+
align-items: var(--s-align);
|
|
131
|
+
|
|
132
|
+
/* Whatever isn't a column takes the full width. */
|
|
133
|
+
& > * {
|
|
134
|
+
grid-column: 1 / -1;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.col {
|
|
139
|
+
grid-column: auto / span var(--s-span);
|
|
140
|
+
align-self: var(--s-align);
|
|
141
|
+
|
|
142
|
+
/* A start that would push the span off the grid shortens the span. */
|
|
143
|
+
&.placed {
|
|
144
|
+
grid-column: var(--s-start) / span min(var(--s-span), 13 - var(--s-start));
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/* In a grid, a column passes the tracks it covers down to its children, so a grid inside it stays on the same twelve. */
|
|
148
|
+
.grid > & {
|
|
149
|
+
grid-template-columns: subgrid;
|
|
150
|
+
|
|
151
|
+
& > * {
|
|
152
|
+
grid-column: 1 / -1;
|
|
153
|
+
}
|
|
154
|
+
& > .grid {
|
|
155
|
+
grid-template-columns: subgrid;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.row {
|
|
161
|
+
display: flex;
|
|
162
|
+
flex-wrap: wrap;
|
|
163
|
+
gap: var(--s-gap);
|
|
164
|
+
align-items: var(--s-align);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.rule {
|
|
168
|
+
inline-size: 100%;
|
|
169
|
+
block-size: var(--s-hair);
|
|
170
|
+
background: currentColor;
|
|
171
|
+
|
|
172
|
+
&.weight-bold {
|
|
173
|
+
block-size: var(--s-unit);
|
|
174
|
+
}
|
|
175
|
+
&.rule-accent {
|
|
176
|
+
background: var(--s-read);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/* Its first child takes the height that is left over, so columns side by side end on one line, and so does what is in them. */
|
|
181
|
+
.col.fill {
|
|
182
|
+
align-content: stretch;
|
|
183
|
+
grid-template-rows: 1fr;
|
|
184
|
+
grid-auto-rows: auto;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.sticky {
|
|
188
|
+
position: sticky;
|
|
189
|
+
inset-block-start: calc(3 * var(--s-unit));
|
|
190
|
+
align-self: start;
|
|
191
|
+
max-block-size: calc(100dvb - 6 * var(--s-unit));
|
|
192
|
+
overflow-y: auto;
|
|
193
|
+
overscroll-behavior: contain;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/* On a narrow page every column takes the full width, in source order. */
|
|
197
|
+
@container s-page (inline-size < 48rem) {
|
|
198
|
+
.col,
|
|
199
|
+
.col.placed {
|
|
200
|
+
grid-column: 1 / -1;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
.sticky {
|
|
204
|
+
position: static;
|
|
205
|
+
max-block-size: none;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.only-wide {
|
|
209
|
+
display: none;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
@container s-page (inline-size >= 48rem) {
|
|
214
|
+
.only-narrow {
|
|
215
|
+
display: none;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
@media print {
|
|
221
|
+
.section {
|
|
222
|
+
break-inside: avoid;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
declare const styles: {
|
|
2
|
+
readonly "col": string;
|
|
3
|
+
readonly "fill": string;
|
|
4
|
+
readonly "grid": string;
|
|
5
|
+
readonly "only-narrow": string;
|
|
6
|
+
readonly "only-wide": string;
|
|
7
|
+
readonly "placed": string;
|
|
8
|
+
readonly "row": string;
|
|
9
|
+
readonly "rule": string;
|
|
10
|
+
readonly "rule-accent": string;
|
|
11
|
+
readonly "section": string;
|
|
12
|
+
readonly "span-1": string;
|
|
13
|
+
readonly "span-10": string;
|
|
14
|
+
readonly "span-11": string;
|
|
15
|
+
readonly "span-12": string;
|
|
16
|
+
readonly "span-2": string;
|
|
17
|
+
readonly "span-3": string;
|
|
18
|
+
readonly "span-4": string;
|
|
19
|
+
readonly "span-5": string;
|
|
20
|
+
readonly "span-6": string;
|
|
21
|
+
readonly "span-7": string;
|
|
22
|
+
readonly "span-8": string;
|
|
23
|
+
readonly "span-9": string;
|
|
24
|
+
readonly "stack": string;
|
|
25
|
+
readonly "start-1": string;
|
|
26
|
+
readonly "start-10": string;
|
|
27
|
+
readonly "start-11": string;
|
|
28
|
+
readonly "start-12": string;
|
|
29
|
+
readonly "start-2": string;
|
|
30
|
+
readonly "start-3": string;
|
|
31
|
+
readonly "start-4": string;
|
|
32
|
+
readonly "start-5": string;
|
|
33
|
+
readonly "start-6": string;
|
|
34
|
+
readonly "start-7": string;
|
|
35
|
+
readonly "start-8": string;
|
|
36
|
+
readonly "start-9": string;
|
|
37
|
+
readonly "sticky": string;
|
|
38
|
+
readonly "weight-bold": string;
|
|
39
|
+
};
|
|
40
|
+
export = styles;
|
|
41
|
+
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The layout: `section`, `grid`, `col`, `stack`, `row` and `rule`.
|
|
3
|
+
*
|
|
4
|
+
* @since 0.4.0
|
|
5
|
+
*/
|
|
6
|
+
import type { Html } from "effect/ui/html"
|
|
7
|
+
import { type Child, contents as inner, type Kind, node, type Node } from "../../Node.ts"
|
|
8
|
+
import { accent, align, gap, on, pad, selectable, tone } from "../tokens/classes.ts"
|
|
9
|
+
import styles from "./layout.module.css"
|
|
10
|
+
import type { Align, Colour, Landmark, Only, Space, Span, Tone } from "../tokens/tokens.ts"
|
|
11
|
+
|
|
12
|
+
export const layout = <Msg>(h: Html.H<Msg>) => ({
|
|
13
|
+
/** A full-width region with its own ground, accent colour and padding. Its children stack. */
|
|
14
|
+
section: <R = never>(
|
|
15
|
+
options: {
|
|
16
|
+
readonly as?: Landmark
|
|
17
|
+
readonly tone?: Tone
|
|
18
|
+
readonly accent?: Colour
|
|
19
|
+
readonly pad?: Space
|
|
20
|
+
readonly gap?: Space
|
|
21
|
+
readonly label?: string
|
|
22
|
+
/** Its text can be selected and copied. No text can be, unless a region says so. */
|
|
23
|
+
readonly select?: boolean
|
|
24
|
+
},
|
|
25
|
+
...children: ReadonlyArray<Child<Kind, Msg, R>>
|
|
26
|
+
): Node<"block", Msg, R> =>
|
|
27
|
+
node(
|
|
28
|
+
h[options.as ?? "section"]
|
|
29
|
+
.class(
|
|
30
|
+
styles.section,
|
|
31
|
+
on(options.accent, accent),
|
|
32
|
+
on(options.tone, tone),
|
|
33
|
+
on(options.pad, pad),
|
|
34
|
+
on(options.gap, gap),
|
|
35
|
+
options.select === true && selectable
|
|
36
|
+
)
|
|
37
|
+
.attr("aria-label", options.label)
|
|
38
|
+
.children(inner(children))
|
|
39
|
+
),
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The twelve columns. Children are `s.col`s, and anything else takes the
|
|
43
|
+
* full width. A grid directly inside a column continues the columns of the
|
|
44
|
+
* grid above it instead of starting its own.
|
|
45
|
+
*/
|
|
46
|
+
grid: <R = never>(
|
|
47
|
+
options: { readonly gap?: Space; readonly align?: Align },
|
|
48
|
+
...children: ReadonlyArray<Child<Kind, Msg, R>>
|
|
49
|
+
): Node<"block", Msg, R> =>
|
|
50
|
+
node(h.div.class(styles.grid, on(options.gap, gap), on(options.align, align)).children(inner(children))),
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* A run of columns in a grid. Its children stack. A `start` that would
|
|
54
|
+
* push the span past the twelfth column shortens the span.
|
|
55
|
+
*/
|
|
56
|
+
col: <R = never>(
|
|
57
|
+
options: {
|
|
58
|
+
readonly span: Span
|
|
59
|
+
readonly start?: Span
|
|
60
|
+
readonly gap?: Space
|
|
61
|
+
readonly align?: Align
|
|
62
|
+
readonly only?: Only
|
|
63
|
+
/** Stays in view while the rest of its row scrolls past. */
|
|
64
|
+
readonly sticky?: boolean
|
|
65
|
+
/**
|
|
66
|
+
* Its first child takes whatever height the row leaves over. Columns
|
|
67
|
+
* side by side are as high as the highest of them: with this, what is
|
|
68
|
+
* in them is too, and whatever comes under it sits on one line.
|
|
69
|
+
*/
|
|
70
|
+
readonly fill?: boolean
|
|
71
|
+
},
|
|
72
|
+
...children: ReadonlyArray<Child<Kind, Msg, R>>
|
|
73
|
+
): Node<"block", Msg, R> =>
|
|
74
|
+
node(
|
|
75
|
+
h.div
|
|
76
|
+
.class(
|
|
77
|
+
styles.col,
|
|
78
|
+
styles[`span-${options.span}`],
|
|
79
|
+
on(options.start, (n) => `${styles.placed} ${styles[`start-${n}`]}`),
|
|
80
|
+
on(options.only, (name) => styles[`only-${name}`]),
|
|
81
|
+
options.sticky === true && styles.sticky,
|
|
82
|
+
options.fill === true && styles.fill,
|
|
83
|
+
on(options.gap, gap),
|
|
84
|
+
on(options.align, align)
|
|
85
|
+
)
|
|
86
|
+
.children(inner(children))
|
|
87
|
+
),
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Children one under the other. With `as` it is a landmark as well: an
|
|
91
|
+
* article in a column of a page, or an aside beside one. A `section` is a
|
|
92
|
+
* region as wide as the page; this is one inside it.
|
|
93
|
+
*/
|
|
94
|
+
stack: <R = never>(
|
|
95
|
+
options: {
|
|
96
|
+
readonly as?: Landmark
|
|
97
|
+
readonly label?: string
|
|
98
|
+
readonly gap?: Space
|
|
99
|
+
readonly only?: Only
|
|
100
|
+
/** Its text can be selected and copied. No text can be, unless a region says so. */
|
|
101
|
+
readonly select?: boolean
|
|
102
|
+
},
|
|
103
|
+
...children: ReadonlyArray<Child<Kind, Msg, R>>
|
|
104
|
+
): Node<"block", Msg, R> =>
|
|
105
|
+
node(
|
|
106
|
+
h[options.as ?? "div"]
|
|
107
|
+
.class(
|
|
108
|
+
styles.stack,
|
|
109
|
+
options.select === true && selectable,
|
|
110
|
+
on(options.gap, gap),
|
|
111
|
+
on(options.only, (name) => styles[`only-${name}`])
|
|
112
|
+
)
|
|
113
|
+
.attr("aria-label", options.label)
|
|
114
|
+
.children(inner(children))
|
|
115
|
+
),
|
|
116
|
+
|
|
117
|
+
/** Children side by side from the left, wrapping when they run out of room. */
|
|
118
|
+
row: <R = never>(
|
|
119
|
+
options: { readonly gap?: Space; readonly align?: Align },
|
|
120
|
+
...children: ReadonlyArray<Child<Kind, Msg, R>>
|
|
121
|
+
): Node<"block", Msg, R> =>
|
|
122
|
+
node(h.div.class(styles.row, on(options.gap, gap), on(options.align, align)).children(inner(children))),
|
|
123
|
+
|
|
124
|
+
/** A horizontal line. */
|
|
125
|
+
rule: (options: { readonly weight?: "hair" | "bold"; readonly accent?: boolean } = {}): Node<"block", Msg> =>
|
|
126
|
+
node(
|
|
127
|
+
h.hr.class(
|
|
128
|
+
styles.rule,
|
|
129
|
+
options.weight === "bold" && styles["weight-bold"],
|
|
130
|
+
options.accent === true && styles["rule-accent"]
|
|
131
|
+
)
|
|
132
|
+
)
|
|
133
|
+
})
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/* list: items one under the other. */
|
|
2
|
+
|
|
3
|
+
@layer standard.type {
|
|
4
|
+
.list {
|
|
5
|
+
display: grid;
|
|
6
|
+
row-gap: var(--s-unit);
|
|
7
|
+
padding-inline-start: 1.5em;
|
|
8
|
+
list-style-type: "– ";
|
|
9
|
+
|
|
10
|
+
&.marker-number {
|
|
11
|
+
list-style-type: decimal;
|
|
12
|
+
font-variant-numeric: tabular-nums;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
&.marker-none {
|
|
16
|
+
list-style: none;
|
|
17
|
+
padding-inline-start: 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/* Each item is a block of its own, with a hairline gap between it and the next. */
|
|
21
|
+
&.ruled {
|
|
22
|
+
row-gap: calc(var(--s-unit) / 4);
|
|
23
|
+
|
|
24
|
+
& > li {
|
|
25
|
+
padding: calc(1.5 * var(--s-unit)) calc(2 * var(--s-unit));
|
|
26
|
+
background: color-mix(in oklch, var(--s-fg) 6%, transparent);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* An `item` of ui brings its own margin, so that its actions reach the row's edges. */
|
|
30
|
+
& > li:has(> :global(.s-ui-item)) {
|
|
31
|
+
padding: 0;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/* facts: names and what they are. A name is a label, small and wide-set; its value is the text. */
|
|
37
|
+
.facts {
|
|
38
|
+
display: grid;
|
|
39
|
+
row-gap: calc(1.5 * var(--s-unit));
|
|
40
|
+
|
|
41
|
+
& > div {
|
|
42
|
+
display: grid;
|
|
43
|
+
row-gap: calc(var(--s-unit) / 4);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
& dt {
|
|
47
|
+
font-size: 0.75rem;
|
|
48
|
+
line-height: 1rem;
|
|
49
|
+
font-weight: 700;
|
|
50
|
+
letter-spacing: 0.08em;
|
|
51
|
+
text-transform: uppercase;
|
|
52
|
+
color: var(--s-muted);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
& dd {
|
|
56
|
+
font-variant-numeric: tabular-nums;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/* Beside: the names in one column and the values in the next, each pair on a baseline. */
|
|
60
|
+
&.beside {
|
|
61
|
+
grid-template-columns: max-content minmax(0, 1fr);
|
|
62
|
+
column-gap: var(--s-gutter);
|
|
63
|
+
|
|
64
|
+
& > div {
|
|
65
|
+
grid-column: 1 / -1;
|
|
66
|
+
grid-template-columns: subgrid;
|
|
67
|
+
align-items: baseline;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `list`: items one under the other.
|
|
3
|
+
*
|
|
4
|
+
* @since 0.4.0
|
|
5
|
+
*/
|
|
6
|
+
import type { Html } from "effect/ui/html"
|
|
7
|
+
import { type Child, contents as inner, type Kind, node, type Node } from "../../Node.ts"
|
|
8
|
+
import styles from "./list.module.css"
|
|
9
|
+
|
|
10
|
+
export const list = <Msg>(h: Html.H<Msg>) => ({
|
|
11
|
+
/** A list. Each child is an item, and a hole is no item. */
|
|
12
|
+
list: <R = never>(
|
|
13
|
+
options: { readonly marker?: "dash" | "number" | "none"; readonly ruled?: boolean },
|
|
14
|
+
...items: ReadonlyArray<Child<Kind, Msg, R>>
|
|
15
|
+
): Node<"block", Msg, R> =>
|
|
16
|
+
node(
|
|
17
|
+
h[options.marker === "number" ? "ol" : "ul"]
|
|
18
|
+
.class(
|
|
19
|
+
styles.list,
|
|
20
|
+
options.marker === "number" && styles["marker-number"],
|
|
21
|
+
options.marker === "none" && styles["marker-none"],
|
|
22
|
+
options.ruled === true && styles.ruled
|
|
23
|
+
)
|
|
24
|
+
.children(
|
|
25
|
+
inner(items).flatMap((item) =>
|
|
26
|
+
item === false || item === null || item === undefined ? [] : [h.li.children(item)]
|
|
27
|
+
)
|
|
28
|
+
)
|
|
29
|
+
),
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Facts about one thing: each a name and what it is, such as the number of
|
|
33
|
+
* an account or the date of a payment. The names are set small above their
|
|
34
|
+
* values, or beside them with `beside`.
|
|
35
|
+
*/
|
|
36
|
+
facts: <R = never>(
|
|
37
|
+
options: { readonly beside?: boolean },
|
|
38
|
+
...items: ReadonlyArray<
|
|
39
|
+
{ readonly name: string; readonly value: Child<"inline", Msg, R> } | false | null | undefined
|
|
40
|
+
>
|
|
41
|
+
): Node<"block", Msg, R> =>
|
|
42
|
+
node(
|
|
43
|
+
h.dl
|
|
44
|
+
.class(styles.facts, options.beside === true && styles.beside)
|
|
45
|
+
.children(
|
|
46
|
+
items.flatMap((item) =>
|
|
47
|
+
item === false || item === null || item === undefined
|
|
48
|
+
? []
|
|
49
|
+
: [h.div.children(h.dt.children(item.name), h.dd.children(inner([item.value])))]
|
|
50
|
+
)
|
|
51
|
+
)
|
|
52
|
+
)
|
|
53
|
+
})
|