@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.
Files changed (260) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +516 -2
  3. package/dist/Extend.d.ts +15 -0
  4. package/dist/Extend.d.ts.map +1 -0
  5. package/dist/Extend.js +1 -0
  6. package/dist/Node.d.ts +71 -0
  7. package/dist/Node.d.ts.map +1 -0
  8. package/dist/Palette-BIJ96BEh.js +84 -0
  9. package/dist/Palette.d.ts +8 -0
  10. package/dist/Palette.d.ts.map +1 -0
  11. package/dist/Palette.js +1 -0
  12. package/dist/Standard-BPpzr5SM.js +488 -0
  13. package/dist/Standard.d.ts +249 -0
  14. package/dist/Standard.d.ts.map +1 -0
  15. package/dist/Standard.js +1 -0
  16. package/dist/Ui-B9xQqqNT.js +468 -0
  17. package/dist/Ui.d.ts +500 -0
  18. package/dist/Ui.d.ts.map +1 -0
  19. package/dist/Ui.js +1 -0
  20. package/dist/index.d.ts +25 -0
  21. package/dist/index.d.ts.map +1 -0
  22. package/dist/index.js +4 -0
  23. package/dist/rolldown-runtime-BMBA7GOT.js +10 -0
  24. package/dist/standard/button/button.d.ts +21 -0
  25. package/dist/standard/button/button.d.ts.map +1 -0
  26. package/dist/standard/colour/colour.d.ts +93 -0
  27. package/dist/standard/colour/colour.d.ts.map +1 -0
  28. package/dist/standard/field/field.d.ts +91 -0
  29. package/dist/standard/field/field.d.ts.map +1 -0
  30. package/dist/standard/form/form.d.ts +16 -0
  31. package/dist/standard/form/form.d.ts.map +1 -0
  32. package/dist/standard/icon/icon.d.ts +31 -0
  33. package/dist/standard/icon/icon.d.ts.map +1 -0
  34. package/dist/standard/image/image.d.ts +21 -0
  35. package/dist/standard/image/image.d.ts.map +1 -0
  36. package/dist/standard/layout/layout.d.ts +73 -0
  37. package/dist/standard/layout/layout.d.ts.map +1 -0
  38. package/dist/standard/list/list.d.ts +26 -0
  39. package/dist/standard/list/list.d.ts.map +1 -0
  40. package/dist/standard/page/page.d.ts +20 -0
  41. package/dist/standard/page/page.d.ts.map +1 -0
  42. package/dist/standard/table/table.d.ts +18 -0
  43. package/dist/standard/table/table.d.ts.map +1 -0
  44. package/dist/standard/text/text.d.ts +39 -0
  45. package/dist/standard/text/text.d.ts.map +1 -0
  46. package/dist/standard/tokens/classes.d.ts +16 -0
  47. package/dist/standard/tokens/classes.d.ts.map +1 -0
  48. package/dist/standard/tokens/tokens.d.ts +162 -0
  49. package/dist/standard/tokens/tokens.d.ts.map +1 -0
  50. package/dist/standard.css +2 -0
  51. package/dist/ui/arrow/arrow.d.ts +18 -0
  52. package/dist/ui/arrow/arrow.d.ts.map +1 -0
  53. package/dist/ui/avatar/avatar.d.ts +15 -0
  54. package/dist/ui/avatar/avatar.d.ts.map +1 -0
  55. package/dist/ui/board/board.d.ts +34 -0
  56. package/dist/ui/board/board.d.ts.map +1 -0
  57. package/dist/ui/bullet/bullet.d.ts +15 -0
  58. package/dist/ui/bullet/bullet.d.ts.map +1 -0
  59. package/dist/ui/card/card.d.ts +24 -0
  60. package/dist/ui/card/card.d.ts.map +1 -0
  61. package/dist/ui/carousel/carousel.d.ts +17 -0
  62. package/dist/ui/carousel/carousel.d.ts.map +1 -0
  63. package/dist/ui/check/check.d.ts +20 -0
  64. package/dist/ui/check/check.d.ts.map +1 -0
  65. package/dist/ui/choice/choice.d.ts +19 -0
  66. package/dist/ui/choice/choice.d.ts.map +1 -0
  67. package/dist/ui/control/control.d.ts +57 -0
  68. package/dist/ui/control/control.d.ts.map +1 -0
  69. package/dist/ui/dialog/dialog.d.ts +30 -0
  70. package/dist/ui/dialog/dialog.d.ts.map +1 -0
  71. package/dist/ui/disclosure/disclosure.d.ts +20 -0
  72. package/dist/ui/disclosure/disclosure.d.ts.map +1 -0
  73. package/dist/ui/flap/flap.d.ts +18 -0
  74. package/dist/ui/flap/flap.d.ts.map +1 -0
  75. package/dist/ui/item/item.d.ts +21 -0
  76. package/dist/ui/item/item.d.ts.map +1 -0
  77. package/dist/ui/key/key.d.ts +12 -0
  78. package/dist/ui/key/key.d.ts.map +1 -0
  79. package/dist/ui/menu/menu.d.ts +26 -0
  80. package/dist/ui/menu/menu.d.ts.map +1 -0
  81. package/dist/ui/modal/modal.d.ts +22 -0
  82. package/dist/ui/modal/modal.d.ts.map +1 -0
  83. package/dist/ui/navigator/navigator.d.ts +137 -0
  84. package/dist/ui/navigator/navigator.d.ts.map +1 -0
  85. package/dist/ui/notice/notice.d.ts +34 -0
  86. package/dist/ui/notice/notice.d.ts.map +1 -0
  87. package/dist/ui/options/options.d.ts +19 -0
  88. package/dist/ui/options/options.d.ts.map +1 -0
  89. package/dist/ui/pager/pager.d.ts +29 -0
  90. package/dist/ui/pager/pager.d.ts.map +1 -0
  91. package/dist/ui/pagination/pagination.d.ts +14 -0
  92. package/dist/ui/pagination/pagination.d.ts.map +1 -0
  93. package/dist/ui/popover/popover.d.ts +20 -0
  94. package/dist/ui/popover/popover.d.ts.map +1 -0
  95. package/dist/ui/progress/progress.d.ts +17 -0
  96. package/dist/ui/progress/progress.d.ts.map +1 -0
  97. package/dist/ui/route/route.d.ts +27 -0
  98. package/dist/ui/route/route.d.ts.map +1 -0
  99. package/dist/ui/sheet/sheet.d.ts +35 -0
  100. package/dist/ui/sheet/sheet.d.ts.map +1 -0
  101. package/dist/ui/skeleton/skeleton.d.ts +15 -0
  102. package/dist/ui/skeleton/skeleton.d.ts.map +1 -0
  103. package/dist/ui/slider/slider.d.ts +23 -0
  104. package/dist/ui/slider/slider.d.ts.map +1 -0
  105. package/dist/ui/stepper/stepper.d.ts +32 -0
  106. package/dist/ui/stepper/stepper.d.ts.map +1 -0
  107. package/dist/ui/tabs/tabs.d.ts +22 -0
  108. package/dist/ui/tabs/tabs.d.ts.map +1 -0
  109. package/dist/ui/tag/tag.d.ts +17 -0
  110. package/dist/ui/tag/tag.d.ts.map +1 -0
  111. package/dist/ui/tile/tile.d.ts +38 -0
  112. package/dist/ui/tile/tile.d.ts.map +1 -0
  113. package/dist/ui/toasts/toasts.d.ts +17 -0
  114. package/dist/ui/toasts/toasts.d.ts.map +1 -0
  115. package/dist/ui/toggle/toggle.d.ts +17 -0
  116. package/dist/ui/toggle/toggle.d.ts.map +1 -0
  117. package/dist/ui/trail/trail.d.ts +22 -0
  118. package/dist/ui/trail/trail.d.ts.map +1 -0
  119. package/package.json +70 -3
  120. package/src/Extend.ts +14 -0
  121. package/src/Node.ts +44 -0
  122. package/src/Palette.ts +7 -0
  123. package/src/Standard.ts +109 -0
  124. package/src/Ui.ts +156 -0
  125. package/src/index.ts +27 -0
  126. package/src/standard/button/button.module.css +43 -0
  127. package/src/standard/button/button.module.d.css.ts +6 -0
  128. package/src/standard/button/button.ts +38 -0
  129. package/src/standard/colour/colour.ts +197 -0
  130. package/src/standard/field/field.module.css +222 -0
  131. package/src/standard/field/field.module.d.css.ts +13 -0
  132. package/src/standard/field/field.ts +266 -0
  133. package/src/standard/form/form.ts +25 -0
  134. package/src/standard/icon/icon.module.css +349 -0
  135. package/src/standard/icon/icon.module.d.css.ts +112 -0
  136. package/src/standard/icon/icon.ts +148 -0
  137. package/src/standard/image/image.module.css +42 -0
  138. package/src/standard/image/image.module.d.css.ts +12 -0
  139. package/src/standard/image/image.ts +39 -0
  140. package/src/standard/layout/layout.module.css +224 -0
  141. package/src/standard/layout/layout.module.d.css.ts +41 -0
  142. package/src/standard/layout/layout.ts +133 -0
  143. package/src/standard/list/list.module.css +71 -0
  144. package/src/standard/list/list.module.d.css.ts +10 -0
  145. package/src/standard/list/list.ts +53 -0
  146. package/src/standard/page/page.module.css +244 -0
  147. package/src/standard/page/page.module.d.css.ts +9 -0
  148. package/src/standard/page/page.ts +32 -0
  149. package/src/standard/table/table.module.css +40 -0
  150. package/src/standard/table/table.module.d.css.ts +6 -0
  151. package/src/standard/table/table.ts +36 -0
  152. package/src/standard/text/text.module.css +149 -0
  153. package/src/standard/text/text.module.d.css.ts +19 -0
  154. package/src/standard/text/text.ts +77 -0
  155. package/src/standard/tokens/classes.ts +31 -0
  156. package/src/standard/tokens/tokens.module.css +294 -0
  157. package/src/standard/tokens/tokens.module.d.css.ts +40 -0
  158. package/src/standard/tokens/tokens.ts +339 -0
  159. package/src/ui/arrow/arrow.module.css +38 -0
  160. package/src/ui/arrow/arrow.module.d.css.ts +13 -0
  161. package/src/ui/arrow/arrow.ts +35 -0
  162. package/src/ui/avatar/avatar.module.css +25 -0
  163. package/src/ui/avatar/avatar.module.d.css.ts +5 -0
  164. package/src/ui/avatar/avatar.ts +28 -0
  165. package/src/ui/board/board.module.css +94 -0
  166. package/src/ui/board/board.module.d.css.ts +10 -0
  167. package/src/ui/board/board.ts +84 -0
  168. package/src/ui/bullet/bullet.module.css +28 -0
  169. package/src/ui/bullet/bullet.module.d.css.ts +5 -0
  170. package/src/ui/bullet/bullet.ts +16 -0
  171. package/src/ui/card/card.module.css +80 -0
  172. package/src/ui/card/card.module.d.css.ts +6 -0
  173. package/src/ui/card/card.ts +42 -0
  174. package/src/ui/carousel/carousel.module.css +24 -0
  175. package/src/ui/carousel/carousel.module.d.css.ts +5 -0
  176. package/src/ui/carousel/carousel.ts +30 -0
  177. package/src/ui/check/check.module.css +53 -0
  178. package/src/ui/check/check.module.d.css.ts +8 -0
  179. package/src/ui/check/check.ts +46 -0
  180. package/src/ui/choice/choice.module.css +32 -0
  181. package/src/ui/choice/choice.module.d.css.ts +6 -0
  182. package/src/ui/choice/choice.ts +31 -0
  183. package/src/ui/control/control.module.css +127 -0
  184. package/src/ui/control/control.module.d.css.ts +12 -0
  185. package/src/ui/control/control.ts +97 -0
  186. package/src/ui/dialog/dialog.module.css +42 -0
  187. package/src/ui/dialog/dialog.module.d.css.ts +6 -0
  188. package/src/ui/dialog/dialog.ts +44 -0
  189. package/src/ui/disclosure/disclosure.module.css +57 -0
  190. package/src/ui/disclosure/disclosure.module.d.css.ts +7 -0
  191. package/src/ui/disclosure/disclosure.ts +32 -0
  192. package/src/ui/flap/flap.module.css +161 -0
  193. package/src/ui/flap/flap.module.d.css.ts +48 -0
  194. package/src/ui/flap/flap.ts +78 -0
  195. package/src/ui/item/item.module.css +39 -0
  196. package/src/ui/item/item.module.d.css.ts +7 -0
  197. package/src/ui/item/item.ts +33 -0
  198. package/src/ui/key/key.module.css +15 -0
  199. package/src/ui/key/key.module.d.css.ts +5 -0
  200. package/src/ui/key/key.ts +13 -0
  201. package/src/ui/menu/menu.module.css +11 -0
  202. package/src/ui/menu/menu.module.d.css.ts +5 -0
  203. package/src/ui/menu/menu.ts +48 -0
  204. package/src/ui/modal/modal.module.css +66 -0
  205. package/src/ui/modal/modal.module.d.css.ts +8 -0
  206. package/src/ui/modal/modal.ts +55 -0
  207. package/src/ui/navigator/navigator.module.css +658 -0
  208. package/src/ui/navigator/navigator.module.d.css.ts +39 -0
  209. package/src/ui/navigator/navigator.ts +337 -0
  210. package/src/ui/notice/notice.module.css +80 -0
  211. package/src/ui/notice/notice.module.d.css.ts +10 -0
  212. package/src/ui/notice/notice.ts +57 -0
  213. package/src/ui/options/options.module.css +30 -0
  214. package/src/ui/options/options.module.d.css.ts +6 -0
  215. package/src/ui/options/options.ts +31 -0
  216. package/src/ui/pager/pager.module.css +38 -0
  217. package/src/ui/pager/pager.module.d.css.ts +8 -0
  218. package/src/ui/pager/pager.ts +48 -0
  219. package/src/ui/pagination/pagination.module.css +38 -0
  220. package/src/ui/pagination/pagination.module.d.css.ts +7 -0
  221. package/src/ui/pagination/pagination.ts +52 -0
  222. package/src/ui/popover/popover.module.css +94 -0
  223. package/src/ui/popover/popover.module.d.css.ts +8 -0
  224. package/src/ui/popover/popover.ts +139 -0
  225. package/src/ui/progress/progress.module.css +69 -0
  226. package/src/ui/progress/progress.module.d.css.ts +6 -0
  227. package/src/ui/progress/progress.ts +26 -0
  228. package/src/ui/route/route.module.css +116 -0
  229. package/src/ui/route/route.module.d.css.ts +11 -0
  230. package/src/ui/route/route.ts +58 -0
  231. package/src/ui/sheet/sheet.module.css +194 -0
  232. package/src/ui/sheet/sheet.module.d.css.ts +7 -0
  233. package/src/ui/sheet/sheet.ts +47 -0
  234. package/src/ui/skeleton/skeleton.module.css +44 -0
  235. package/src/ui/skeleton/skeleton.module.d.css.ts +6 -0
  236. package/src/ui/skeleton/skeleton.ts +20 -0
  237. package/src/ui/slider/slider.module.css +56 -0
  238. package/src/ui/slider/slider.module.d.css.ts +6 -0
  239. package/src/ui/slider/slider.ts +48 -0
  240. package/src/ui/stepper/stepper.module.css +32 -0
  241. package/src/ui/stepper/stepper.module.d.css.ts +7 -0
  242. package/src/ui/stepper/stepper.ts +62 -0
  243. package/src/ui/tabs/tabs.module.css +38 -0
  244. package/src/ui/tabs/tabs.module.d.css.ts +6 -0
  245. package/src/ui/tabs/tabs.ts +24 -0
  246. package/src/ui/tag/tag.module.css +23 -0
  247. package/src/ui/tag/tag.module.d.css.ts +5 -0
  248. package/src/ui/tag/tag.ts +17 -0
  249. package/src/ui/tile/tile.module.css +137 -0
  250. package/src/ui/tile/tile.module.d.css.ts +13 -0
  251. package/src/ui/tile/tile.ts +69 -0
  252. package/src/ui/toasts/toasts.module.css +38 -0
  253. package/src/ui/toasts/toasts.module.d.css.ts +6 -0
  254. package/src/ui/toasts/toasts.ts +26 -0
  255. package/src/ui/toggle/toggle.module.css +46 -0
  256. package/src/ui/toggle/toggle.module.d.css.ts +6 -0
  257. package/src/ui/toggle/toggle.ts +29 -0
  258. package/src/ui/trail/trail.module.css +42 -0
  259. package/src/ui/trail/trail.module.d.css.ts +5 -0
  260. package/src/ui/trail/trail.ts +28 -0
@@ -0,0 +1,137 @@
1
+ /* tile: one large thing to press. */
2
+
3
+ @layer standard.ui {
4
+ .tile {
5
+ display: grid;
6
+ grid-template-columns: minmax(0, 1fr);
7
+ /* What is in it starts at its top, however high it is made: tiles in a row start on one line. */
8
+ align-content: start;
9
+ row-gap: calc(var(--s-unit) / 2);
10
+ inline-size: 100%;
11
+ min-block-size: calc(16 * var(--s-unit));
12
+ padding: calc(2 * var(--s-unit));
13
+ /* A surface: a step from its ground towards its text, and a step more while pressed. */
14
+ background: color-mix(in oklch, var(--s-fg) calc(var(--s-ui-tint, 8%) + var(--s-ui-press)), var(--s-bg));
15
+ color: var(--s-fg);
16
+ /* One that leads somewhere is a link, and looks no different. */
17
+ text-decoration: none;
18
+ text-align: start;
19
+
20
+ & > span {
21
+ display: block;
22
+ }
23
+ }
24
+
25
+ /* A surface given a line is filled with it, edge to edge. */
26
+ :is(.tile, .tile-set):global(.s-ui-lined) {
27
+ --s-bg: var(--s-line);
28
+ --s-fg: var(--s-on-line);
29
+ --s-mark: var(--s-on-line);
30
+ --s-on-mark: var(--s-line);
31
+ --s-read: var(--s-on-line);
32
+ --s-wrong: var(--s-on-line);
33
+ --s-muted: var(--s-accent-soft);
34
+ --s-flat: 1;
35
+ /* A block of colour is the colour itself. */
36
+ --s-ui-tint: 0%;
37
+ }
38
+
39
+ /* A picture runs to the tile's edges on three sides, and what is written starts under it. */
40
+ .tile-image {
41
+ display: block;
42
+ inline-size: calc(100% + 4 * var(--s-unit));
43
+ max-inline-size: none;
44
+ aspect-ratio: 3 / 2;
45
+ margin: calc(-2 * var(--s-unit)) calc(-2 * var(--s-unit)) var(--s-unit);
46
+ object-fit: cover;
47
+ background: var(--s-muted);
48
+ }
49
+
50
+ .tile-icon {
51
+ font-size: 2rem;
52
+ line-height: 1;
53
+ margin-block-end: var(--s-unit);
54
+ }
55
+
56
+ .tile-value {
57
+ font-size: 3rem;
58
+ line-height: 1;
59
+ font-weight: 700;
60
+ letter-spacing: -0.03em;
61
+ font-variant-numeric: tabular-nums;
62
+ }
63
+
64
+ /* A figure too long for that size, such as an amount of money, is set a step smaller, and breaks before it runs out of the tile. */
65
+ .tile-long {
66
+ font-size: 2rem;
67
+ line-height: 1.25;
68
+ letter-spacing: -0.02em;
69
+ overflow-wrap: anywhere;
70
+ }
71
+
72
+ .tile-label {
73
+ font-size: 1.25rem;
74
+ line-height: 1.5rem;
75
+ font-weight: 700;
76
+ }
77
+
78
+ .tile-note {
79
+ font-size: 0.875rem;
80
+ line-height: 1.5rem;
81
+ color: var(--s-muted);
82
+ }
83
+
84
+ /* What gives under a press is the tile itself. */
85
+ .tile {
86
+ transition: scale var(--s-quick) var(--s-ease);
87
+ }
88
+ .tile:active:not(:disabled) {
89
+ scale: 0.98;
90
+ }
91
+
92
+ /*
93
+ * A tile and what can be done to it are one block: the actions are across
94
+ * the tile's foot, edge to edge, with no gap, as the answers of a dialog are.
95
+ */
96
+ .tile-set {
97
+ display: grid;
98
+ grid-template-columns: minmax(0, 1fr);
99
+ grid-template-rows: 1fr auto;
100
+ inline-size: 100%;
101
+ transition: scale var(--s-quick) var(--s-ease);
102
+ }
103
+
104
+ /* Where there is no action, the tile's surface goes on. */
105
+ .tile-actions {
106
+ background: color-mix(in oklch, var(--s-fg) var(--s-ui-tint, 8%), var(--s-bg));
107
+ }
108
+
109
+ /* A tile with no colour is a tint of its text, so its actions step on towards the text; one filled with a colour leaves them to step away. */
110
+ .tile-set:not(:global(.s-ui-lined), [class*="tone-accent"]) > .tile-actions {
111
+ --s-ui-step: var(--s-fg);
112
+ }
113
+
114
+ /*
115
+ * On a ground of its own, the colour of the text may be the very ground the
116
+ * page is on, and a block of it would be a hole in the surface. So there the
117
+ * one that goes on is a block of the mark's colour.
118
+ */
119
+ .tile-set[class*="tone-"] > .tile-actions {
120
+ --s-ui-go: var(--s-mark);
121
+ --s-ui-on-go: var(--s-on-mark);
122
+ }
123
+
124
+ /* Smaller than a dialog's, as the tile is, and their labels start where the tile's text does. */
125
+ .tile-actions > button {
126
+ min-block-size: var(--s-target);
127
+ padding: calc(1.5 * var(--s-unit)) calc(2 * var(--s-unit));
128
+ }
129
+
130
+ /* Whichever is pressed, the block gives as one. */
131
+ .tile-set:has(:active:not(:disabled)) {
132
+ scale: 0.98;
133
+ }
134
+ .tile-set > .tile:active:not(:disabled) {
135
+ scale: none;
136
+ }
137
+ }
@@ -0,0 +1,13 @@
1
+ declare const styles: {
2
+ readonly "tile": string;
3
+ readonly "tile-actions": string;
4
+ readonly "tile-icon": string;
5
+ readonly "tile-image": string;
6
+ readonly "tile-label": string;
7
+ readonly "tile-long": string;
8
+ readonly "tile-note": string;
9
+ readonly "tile-set": string;
10
+ readonly "tile-value": string;
11
+ };
12
+ export = styles;
13
+
@@ -0,0 +1,69 @@
1
+ /**
2
+ * `tile`: one large thing to press.
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 { tone } from "../../standard/tokens/classes.ts"
9
+ import type { Colour, Tone } from "../../standard/tokens/tokens.ts"
10
+ import control from "../control/control.module.css"
11
+ import { type Actions, actions, line } from "../control/control.ts"
12
+ import { type Icon, iconOf } from "../../standard/icon/icon.ts"
13
+ import styles from "./tile.module.css"
14
+
15
+ export const tile = <Msg>(h: Html.H<Msg>) => ({
16
+ /** One large thing to press: a pictogram, a figure, a name and a note. With a colour, it is filled with it. */
17
+ tile: (options: {
18
+ readonly label: string
19
+ /** What a press sends. Left out, give it an `href`: a tile that leads to a place is a link. */
20
+ readonly onPress?: Msg
21
+ /** Where it leads. */
22
+ readonly href?: string
23
+ readonly value?: string
24
+ readonly note?: string
25
+ readonly icon?: Icon
26
+ /** A picture across its top, edge to edge: what the tile leads to, when that is a thing to be seen. */
27
+ readonly image?: { readonly src: string; readonly alt: string }
28
+ readonly colour?: Colour
29
+ readonly tone?: Tone
30
+ readonly disabled?: boolean
31
+ /**
32
+ * What can be done to the thing the tile shows, such as removing it from a list: large buttons across the
33
+ * tile's foot, edge to edge, as the answers of a `dialog` are. A button set under a tile, with a gap between,
34
+ * does not say what it acts on.
35
+ */
36
+ readonly actions?: Actions<Msg>
37
+ }): Node<"block", Msg> => {
38
+ const list = options.actions ?? []
39
+ // The ground and the colour are those of the whole block: with an action they are set on what holds the two.
40
+ const ground = [options.tone !== undefined && tone(options.tone), line(options.colour)]
41
+ const look = [control.control, styles.tile, ...(list.length === 0 ? ground : [])]
42
+ const body = [
43
+ options.image !== undefined &&
44
+ h.img
45
+ .class(styles["tile-image"])
46
+ .attr("src", options.image.src)
47
+ .attr("alt", options.image.alt)
48
+ .attr("loading", "lazy"),
49
+ options.icon !== undefined && h.span.class(styles["tile-icon"]).children(iconOf(h, options.icon)),
50
+ options.value !== undefined &&
51
+ h.span.class(styles["tile-value"], options.value.length > 8 && styles["tile-long"]).children(options.value),
52
+ h.span.class(styles["tile-label"]).children(options.label),
53
+ options.note !== undefined && h.span.class(styles["tile-note"]).children(options.note)
54
+ ]
55
+ const button = h.button
56
+ .class(...look)
57
+ .attr("type", "button")
58
+ .disabled(options.disabled === true)
59
+ const pressed =
60
+ options.href !== undefined && options.disabled !== true
61
+ ? h.a
62
+ .class(...look)
63
+ .attr("href", options.href)
64
+ .children(body)
65
+ : (options.onPress === undefined ? button : button.on("click", options.onPress)).children(body)
66
+ if (list.length === 0) return node(pressed)
67
+ return node(h.div.class(styles["tile-set"], ...ground).children(pressed, actions(h, styles["tile-actions"], list)))
68
+ }
69
+ })
@@ -0,0 +1,38 @@
1
+ /* toasts: what just happened, at the bottom of the window. */
2
+
3
+ @layer standard.ui {
4
+ /* The last child of the page: it takes up no room, and stays at the bottom of the window. */
5
+ .toasts {
6
+ position: sticky;
7
+ inset-block-end: 0;
8
+ z-index: 1;
9
+ block-size: 0;
10
+ margin-block-start: auto;
11
+ /* What was just said stays in the window while the page under it changes. */
12
+ view-transition-name: s-ui-toasts;
13
+ }
14
+
15
+ .toasts-list {
16
+ position: absolute;
17
+ inset-block-end: max(calc(2 * var(--s-unit)), env(safe-area-inset-bottom));
18
+ inset-inline-start: var(--s-margin);
19
+ display: grid;
20
+ row-gap: var(--s-unit);
21
+ inline-size: min(26rem, 100% - 2 * var(--s-margin));
22
+
23
+ & > :global(.s-ui-notice) {
24
+ /* Up from under the bottom of the window. */
25
+ transition: translate var(--s-move) var(--s-ease);
26
+
27
+ @starting-style {
28
+ translate: 0 calc(100% + 6 * var(--s-unit));
29
+ }
30
+ }
31
+ }
32
+ }
33
+
34
+ @media print {
35
+ .toasts {
36
+ display: none;
37
+ }
38
+ }
@@ -0,0 +1,6 @@
1
+ declare const styles: {
2
+ readonly "toasts": string;
3
+ readonly "toasts-list": string;
4
+ };
5
+ export = styles;
6
+
@@ -0,0 +1,26 @@
1
+ /**
2
+ * `toasts`: what just happened, said at the bottom of the window.
3
+ *
4
+ * @since 0.4.0
5
+ */
6
+ import type { Html } from "effect/ui/html"
7
+ import { type Child, contents as inner, node, type Node } from "../../Node.ts"
8
+ import styles from "./toasts.module.css"
9
+
10
+ export const toasts = <Msg>(h: Html.H<Msg>) => ({
11
+ /**
12
+ * What just happened, said at the bottom of the window. Its children
13
+ * are `s.notice`s the Model holds. Make it the last child of the page.
14
+ */
15
+ toasts: <R = never>(
16
+ options: { readonly label: string },
17
+ ...children: ReadonlyArray<Child<"block", Msg, R>>
18
+ ): Node<"block", Msg, R> =>
19
+ node(
20
+ h.div
21
+ .class(styles.toasts)
22
+ .attr("role", "region")
23
+ .attr("aria-label", options.label)
24
+ .children(h.div.class(styles["toasts-list"]).children(inner(children)))
25
+ )
26
+ })
@@ -0,0 +1,46 @@
1
+ /* toggle: on or off, at once. */
2
+
3
+ @layer standard.ui {
4
+ .toggle {
5
+ position: relative;
6
+ display: inline-flex;
7
+ align-items: start;
8
+ column-gap: calc(2 * var(--s-unit));
9
+ justify-self: start;
10
+ padding-block: calc((var(--s-target) - 1.5rem) / 2);
11
+ background: transparent;
12
+ font-weight: 700;
13
+ line-height: 1.5rem;
14
+ }
15
+
16
+ /* A track with two places, and a block that is in one of them. */
17
+ .track {
18
+ flex: none;
19
+ position: relative;
20
+ inline-size: calc(6 * var(--s-unit));
21
+ block-size: calc(3 * var(--s-unit));
22
+ background: color-mix(in oklch, var(--s-fg) calc(16% + var(--s-ui-press)), transparent);
23
+
24
+ &::after {
25
+ content: "";
26
+ position: absolute;
27
+ inset-block: calc(var(--s-unit) / 2);
28
+ inset-inline-start: calc(var(--s-unit) / 2);
29
+ inline-size: calc(2 * var(--s-unit));
30
+ background: currentColor;
31
+ }
32
+
33
+ [aria-checked="true"] > & {
34
+ background: currentColor;
35
+
36
+ &::after {
37
+ inset-inline-start: calc(3.5 * var(--s-unit));
38
+ background: var(--s-bg);
39
+ }
40
+ }
41
+ }
42
+
43
+ .track::after {
44
+ transition: inset-inline-start var(--s-move) var(--s-ease);
45
+ }
46
+ }
@@ -0,0 +1,6 @@
1
+ declare const styles: {
2
+ readonly "toggle": string;
3
+ readonly "track": string;
4
+ };
5
+ export = styles;
6
+
@@ -0,0 +1,29 @@
1
+ /**
2
+ * `toggle`: something that is on or off.
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 control from "../control/control.module.css"
9
+ import styles from "./toggle.module.css"
10
+
11
+ export const toggle = <Msg>(h: Html.H<Msg>) => ({
12
+ /** Something that is on or off, and takes effect at once. */
13
+ toggle: (options: {
14
+ readonly label: string
15
+ readonly on: boolean
16
+ readonly onChange: (on: boolean) => Msg
17
+ readonly disabled?: boolean
18
+ }): Node<"block", Msg> =>
19
+ node(
20
+ h.button
21
+ .class(control.control, styles.toggle)
22
+ .attr("type", "button")
23
+ .attr("role", "switch")
24
+ .attr("aria-checked", options.on ? "true" : "false")
25
+ .disabled(options.disabled === true)
26
+ .on("click", options.onChange(!options.on))
27
+ .children(h.span.class(styles.track).attr("aria-hidden", "true"), h.span.children(options.label))
28
+ )
29
+ })
@@ -0,0 +1,42 @@
1
+ /* trail: the way here, from the top. */
2
+
3
+ @layer standard.ui {
4
+ /* The way here, from the top. */
5
+ .trail {
6
+ display: flex;
7
+ flex-wrap: wrap;
8
+ align-items: baseline;
9
+ column-gap: var(--s-unit);
10
+ list-style: none;
11
+ font-size: 0.875rem;
12
+ line-height: 1.5rem;
13
+
14
+ & > li {
15
+ display: flex;
16
+ align-items: baseline;
17
+ column-gap: var(--s-unit);
18
+ }
19
+
20
+ & > li + li::before {
21
+ content: "";
22
+ inline-size: 0.7em;
23
+ block-size: 0.7em;
24
+ background: var(--s-muted);
25
+ clip-path: polygon(50% 0, 95% 45%, 83.7% 56.3%, 58% 30.6%, 58% 100%, 42% 100%, 42% 30.6%, 16.3% 56.3%, 5% 45%);
26
+ rotate: 90deg;
27
+ }
28
+
29
+ & a {
30
+ color: var(--s-muted);
31
+ text-decoration: none;
32
+
33
+ &:active {
34
+ color: var(--s-read);
35
+ }
36
+ }
37
+
38
+ & [aria-current="page"] {
39
+ font-weight: 700;
40
+ }
41
+ }
42
+ }
@@ -0,0 +1,5 @@
1
+ declare const styles: {
2
+ readonly "trail": string;
3
+ };
4
+ export = styles;
5
+
@@ -0,0 +1,28 @@
1
+ /**
2
+ * `trail`: the way here from the top.
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 styles from "./trail.module.css"
9
+
10
+ export const trail = <Msg>(h: Html.H<Msg>) => ({
11
+ /**
12
+ * Where you came from: the way here from the top, each step a link back,
13
+ * the last one the page you are on.
14
+ */
15
+ trail: (options: {
16
+ readonly label: string
17
+ readonly steps: ReadonlyArray<{ readonly label: string; readonly href: string }>
18
+ readonly here: string
19
+ }): Node<"block", Msg> =>
20
+ node(
21
+ h.nav.attr("aria-label", options.label).children(
22
+ h.ol.class(styles.trail).children(
23
+ options.steps.map((step) => h.li.children(h.a.attr("href", step.href).children(step.label))),
24
+ h.li.children(h.span.attr("aria-current", "page").children(options.here))
25
+ )
26
+ )
27
+ )
28
+ })