@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,38 @@
1
+ /* arrow: the arrow of a direction sign. */
2
+
3
+ @layer standard.ui {
4
+ /* The arrow of a direction sign, cut from a square and turned. */
5
+ .arrow {
6
+ display: inline-block;
7
+ inline-size: 0.8em;
8
+ block-size: 0.8em;
9
+ background: currentColor;
10
+ 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%);
11
+ forced-color-adjust: none;
12
+
13
+ &.dir-up {
14
+ rotate: 0deg;
15
+ }
16
+ &.dir-up-right {
17
+ rotate: 45deg;
18
+ }
19
+ &.dir-right {
20
+ rotate: 90deg;
21
+ }
22
+ &.dir-down-right {
23
+ rotate: 135deg;
24
+ }
25
+ &.dir-down {
26
+ rotate: 180deg;
27
+ }
28
+ &.dir-down-left {
29
+ rotate: 225deg;
30
+ }
31
+ &.dir-left {
32
+ rotate: 270deg;
33
+ }
34
+ &.dir-up-left {
35
+ rotate: 315deg;
36
+ }
37
+ }
38
+ }
@@ -0,0 +1,13 @@
1
+ declare const styles: {
2
+ readonly "arrow": string;
3
+ readonly "dir-down": string;
4
+ readonly "dir-down-left": string;
5
+ readonly "dir-down-right": string;
6
+ readonly "dir-left": string;
7
+ readonly "dir-right": string;
8
+ readonly "dir-up": string;
9
+ readonly "dir-up-left": string;
10
+ readonly "dir-up-right": string;
11
+ };
12
+ export = styles;
13
+
@@ -0,0 +1,35 @@
1
+ /**
2
+ * `arrow`: the arrow of a direction sign.
3
+ *
4
+ * @since 0.4.0
5
+ */
6
+ import { Schema } from "effect"
7
+ import type { Html } from "effect/ui/html"
8
+ import { node, type Node } from "../../Node.ts"
9
+ import styles from "./arrow.module.css"
10
+
11
+ /** The direction an arrow points in. */
12
+ export const Direction = Schema.Literals([
13
+ "up",
14
+ "up-right",
15
+ "right",
16
+ "down-right",
17
+ "down",
18
+ "down-left",
19
+ "left",
20
+ "up-left"
21
+ ])
22
+ export type Direction = typeof Direction.Type
23
+
24
+ /** The arrow itself, for a component that has one in it. A screen reader reads it only when it has a label. */
25
+ export const arrowOf = <Msg>(h: Html.H<Msg>, direction: Direction, label?: string) =>
26
+ h.span
27
+ .class(styles.arrow, styles[`dir-${direction}`])
28
+ .attr("role", label === undefined ? undefined : "img")
29
+ .attr("aria-label", label)
30
+ .attr("aria-hidden", label === undefined ? "true" : undefined)
31
+
32
+ export const arrow = <Msg>(h: Html.H<Msg>) => ({
33
+ /** The arrow of a direction sign. A screen reader reads it only when it has a label. */
34
+ arrow: (direction: Direction, label?: string): Node<"inline", Msg> => node(arrowOf(h, direction, label))
35
+ })
@@ -0,0 +1,25 @@
1
+ /* avatar: a person, shown by a picture or by their initials. */
2
+
3
+ @layer standard.ui {
4
+ .avatar {
5
+ display: inline-grid;
6
+ place-items: center;
7
+ inline-size: calc(5 * var(--s-unit));
8
+ block-size: calc(5 * var(--s-unit));
9
+ background: var(--s-fg);
10
+ color: var(--s-bg);
11
+ font-size: 0.875rem;
12
+ font-weight: 700;
13
+ line-height: 1;
14
+ letter-spacing: 0.04em;
15
+ text-transform: uppercase;
16
+ overflow: clip;
17
+ vertical-align: middle;
18
+
19
+ & > img {
20
+ inline-size: 100%;
21
+ block-size: 100%;
22
+ object-fit: cover;
23
+ }
24
+ }
25
+ }
@@ -0,0 +1,5 @@
1
+ declare const styles: {
2
+ readonly "avatar": string;
3
+ };
4
+ export = styles;
5
+
@@ -0,0 +1,28 @@
1
+ /**
2
+ * `avatar`: a person, shown by a picture or by their initials.
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 "./avatar.module.css"
9
+
10
+ export const avatar = <Msg>(h: Html.H<Msg>) => ({
11
+ /** A person, shown by a picture or by their initials. */
12
+ avatar: (options: { readonly name: string; readonly src?: string }): Node<"inline", Msg> =>
13
+ node(
14
+ h.span
15
+ .class(styles.avatar)
16
+ .attr("role", "img")
17
+ .attr("aria-label", options.name)
18
+ .children(
19
+ options.src === undefined
20
+ ? options.name
21
+ .split(/\s+/)
22
+ .slice(0, 2)
23
+ .map((word) => word.slice(0, 1))
24
+ .join("")
25
+ : h.img.attr("src", options.src).attr("alt", "")
26
+ )
27
+ )
28
+ })
@@ -0,0 +1,94 @@
1
+ /* board: a list you scan for one row, and a row to press for more. */
2
+
3
+ @layer standard.ui {
4
+ .board {
5
+ padding: var(--s-unit) calc(1.5 * var(--s-unit)) calc(2 * var(--s-unit));
6
+ /* A surface: a step from its ground towards its text. */
7
+ background: color-mix(in oklch, var(--s-fg) 8%, var(--s-bg));
8
+ color: var(--s-fg);
9
+ overflow-x: auto;
10
+ overscroll-behavior-inline: contain;
11
+
12
+ & table {
13
+ inline-size: 100%;
14
+ border-collapse: collapse;
15
+ font-variant-numeric: tabular-nums;
16
+ }
17
+
18
+ & th,
19
+ & td {
20
+ padding-block: var(--s-unit);
21
+ padding-inline: calc(1.5 * var(--s-unit)) var(--s-gutter);
22
+ vertical-align: baseline;
23
+ white-space: nowrap;
24
+ }
25
+
26
+ & th {
27
+ color: var(--s-muted);
28
+ }
29
+
30
+ /* A tint on every other row tells the rows apart. */
31
+ & tbody tr:nth-child(even) {
32
+ background: color-mix(in oklch, var(--s-fg) calc(10% + var(--s-ui-press, 0%)), transparent);
33
+ }
34
+
35
+ & td {
36
+ font-size: 1.25rem;
37
+ line-height: 2rem;
38
+ font-weight: 700;
39
+ }
40
+
41
+ & :is(th, td):last-child {
42
+ padding-inline-end: calc(1.5 * var(--s-unit));
43
+ }
44
+ & .numeric {
45
+ text-align: end;
46
+ }
47
+ }
48
+
49
+ /* The whole row takes the press. Its button is what the keyboard reaches. */
50
+ .board-row {
51
+ background: color-mix(in oklch, var(--s-fg) var(--s-ui-press), transparent);
52
+
53
+ & button {
54
+ background: transparent;
55
+ cursor: inherit;
56
+ }
57
+ }
58
+
59
+ /* Dense: rows of body text. The first cell, which names the row, keeps its weight. */
60
+ .board-dense :is(th, td) {
61
+ padding-inline-end: calc(2 * var(--s-unit));
62
+ }
63
+
64
+ .board-dense td {
65
+ font-size: 1rem;
66
+ line-height: 1.5rem;
67
+ font-weight: 400;
68
+ /* Every cell starts on the first line of the name, however many lines the name takes. */
69
+ vertical-align: top;
70
+
71
+ /* And it alone may break onto a second line, so that a long name never pushes the last column out of sight. */
72
+ &:first-child {
73
+ font-weight: 700;
74
+ white-space: normal;
75
+ overflow-wrap: anywhere;
76
+
77
+ & button {
78
+ text-align: start;
79
+ }
80
+ }
81
+ }
82
+
83
+ @container s-page (inline-size < 48rem) {
84
+ .board .board-wide {
85
+ display: none;
86
+ }
87
+ }
88
+
89
+ @container s-page (inline-size >= 48rem) {
90
+ .board .board-narrow {
91
+ display: none;
92
+ }
93
+ }
94
+ }
@@ -0,0 +1,10 @@
1
+ declare const styles: {
2
+ readonly "board": string;
3
+ readonly "board-dense": string;
4
+ readonly "board-narrow": string;
5
+ readonly "board-row": string;
6
+ readonly "board-wide": string;
7
+ readonly "numeric": string;
8
+ };
9
+ export = styles;
10
+
@@ -0,0 +1,84 @@
1
+ /**
2
+ * `board`: a list you scan for one row.
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 { tone } from "../../standard/tokens/classes.ts"
9
+ import type { Only, Tone } from "../../standard/tokens/tokens.ts"
10
+ import control from "../control/control.module.css"
11
+ import styles from "./board.module.css"
12
+
13
+ export const board = <Msg>(h: Html.H<Msg>) => ({
14
+ /**
15
+ * A list you scan for one row: short text, in tabular figures. A row
16
+ * with `onSelect` takes a press anywhere on it, and the keyboard reaches
17
+ * it by its first cell. A cell is text with nothing to load: because the
18
+ * cells have no requirements, the types of rows built in a `map` are
19
+ * inferred cleanly.
20
+ */
21
+ board: (options: {
22
+ readonly label: string
23
+ readonly columns: ReadonlyArray<{
24
+ readonly title: string
25
+ readonly numeric?: boolean
26
+ /** The width of page the column is shown at. One that can be done without is left out of a narrow page, so the rows still fit. */
27
+ readonly only?: Only
28
+ }>
29
+ readonly rows: ReadonlyArray<{
30
+ readonly cells: ReadonlyArray<Child<"inline", Msg>>
31
+ readonly onSelect?: Msg
32
+ }>
33
+ readonly tone?: Tone
34
+ /** Rows at the size of body text, for a list that is long or has much in each row. */
35
+ readonly dense?: boolean
36
+ }): Node<"block", Msg> => {
37
+ const numeric = (index: number) => [
38
+ options.columns[index]?.numeric === true && styles.numeric,
39
+ options.columns[index]?.only === "wide" && styles["board-wide"],
40
+ options.columns[index]?.only === "narrow" && styles["board-narrow"]
41
+ ]
42
+ return node(
43
+ h.div
44
+ .class(
45
+ styles.board,
46
+ options.dense === true && styles["board-dense"],
47
+ options.tone !== undefined && tone(options.tone)
48
+ )
49
+ .children(
50
+ h.table.attr("aria-label", options.label).children(
51
+ h.thead.children(
52
+ h.tr.children(
53
+ options.columns.map((column, index) =>
54
+ h.th
55
+ .attr("scope", "col")
56
+ .class(control.legend, ...numeric(index))
57
+ .children(column.title)
58
+ )
59
+ )
60
+ ),
61
+ h.tbody.children(
62
+ options.rows.map(({ cells, onSelect }) => {
63
+ const row = h.tr.children(
64
+ cells.map((cell, index) =>
65
+ h.td
66
+ .class(...numeric(index))
67
+ .children(
68
+ onSelect !== undefined && index === 0
69
+ ? h.button.attr("type", "button").children(inner([cell]))
70
+ : inner([cell])
71
+ )
72
+ )
73
+ )
74
+ // The button has no handler of its own: its click bubbles up to the row's.
75
+ return onSelect === undefined
76
+ ? row
77
+ : row.class(control.control, styles["board-row"]).on("click", onSelect)
78
+ })
79
+ )
80
+ )
81
+ )
82
+ )
83
+ }
84
+ })
@@ -0,0 +1,28 @@
1
+ /* bullet: the roundel of a line. */
2
+
3
+ @layer standard.ui {
4
+ /* Without a colour, it is in the colour of the text. */
5
+ :where(.bullet) {
6
+ --s-line: var(--s-fg);
7
+ --s-on-line: var(--s-bg);
8
+ }
9
+
10
+ .bullet {
11
+ display: inline-grid;
12
+ place-items: center;
13
+ min-inline-size: 1.75em;
14
+ block-size: 1.75em;
15
+ padding-inline: 0.35em;
16
+ /* A roundel: with the stop marker, the only curve there is. */
17
+ border-radius: 999px;
18
+ background: var(--s-line);
19
+ color: var(--s-on-line);
20
+ font-size: 0.8em;
21
+ font-weight: 700;
22
+ line-height: 1;
23
+ letter-spacing: 0;
24
+ font-variant-numeric: tabular-nums;
25
+ vertical-align: 0.1em;
26
+ forced-color-adjust: none;
27
+ }
28
+ }
@@ -0,0 +1,5 @@
1
+ declare const styles: {
2
+ readonly "bullet": string;
3
+ };
4
+ export = styles;
5
+
@@ -0,0 +1,16 @@
1
+ /**
2
+ * `bullet`: a letter or a number on a colour.
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 type { Colour } from "../../standard/tokens/tokens.ts"
9
+ import styles from "./bullet.module.css"
10
+ import { line } from "../control/control.ts"
11
+
12
+ export const bullet = <Msg>(h: Html.H<Msg>) => ({
13
+ /** A bullet: a letter or a number on a colour, for telling things of one kind apart by both at once. */
14
+ bullet: (options: { readonly colour?: Colour }, label: string): Node<"inline", Msg> =>
15
+ node(h.span.class(styles.bullet, line(options.colour)).children(label))
16
+ })
@@ -0,0 +1,80 @@
1
+ /* card: a surface that sets some content apart. */
2
+
3
+ /* The default is in the layer the token classes are in, at zero specificity, so a `gap` wins. */
4
+ @layer standard.tokens {
5
+ :where(.card) {
6
+ --s-gap: calc(2 * var(--s-unit));
7
+ }
8
+ }
9
+
10
+ @layer standard.ui {
11
+ .card {
12
+ display: grid;
13
+ grid-template-columns: minmax(0, 1fr);
14
+ align-content: start;
15
+ row-gap: var(--s-gap);
16
+ padding: calc(3 * var(--s-unit));
17
+ background: color-mix(in oklch, var(--s-fg) 8%, var(--s-bg));
18
+ color: var(--s-fg);
19
+
20
+ &:is([class*="tone-"], :global(.s-ui-lined)) {
21
+ background: var(--s-bg);
22
+ }
23
+
24
+ /*
25
+ * Tints don't stack: a ruled list in a card is cut out of it, down to the
26
+ * ground the card is on. A second tint on the first would take muted text
27
+ * below the contrast it is picked for.
28
+ */
29
+ &:not([class*="tone-"], :global(.s-ui-lined)) :global(.s-ruled) > li {
30
+ background: var(--s-bg);
31
+ }
32
+ }
33
+
34
+ /*
35
+ * What can be done about it, across its foot: out to its edges, through
36
+ * its padding. They are at the card's foot however little is in it: in a
37
+ * card made as high as its neighbours, they do not follow what is written,
38
+ * they stay in the corner. So what is over them is a column, and they take
39
+ * the room that is left above them.
40
+ */
41
+ .card:has(> .card-actions) {
42
+ display: flex;
43
+ flex-direction: column;
44
+
45
+ & > * {
46
+ flex: none;
47
+ }
48
+ }
49
+
50
+ .card-actions {
51
+ margin: auto calc(-3 * var(--s-unit)) calc(-3 * var(--s-unit));
52
+ }
53
+
54
+ /* A card with no colour is its text's colour or a tint of it, so its actions step towards the text; one filled with a colour leaves them to step away. */
55
+ .card:not(:global(.s-ui-lined), [class*="tone-accent"]) > .card-actions {
56
+ --s-ui-step: var(--s-fg);
57
+ }
58
+
59
+ /*
60
+ * On a ground of its own, the colour of the text may be the very ground the
61
+ * page is on, and a block of it would be a hole in the surface. So there the
62
+ * one that goes on is a block of the mark's colour.
63
+ */
64
+ .card[class*="tone-"] > .card-actions {
65
+ --s-ui-go: var(--s-mark);
66
+ --s-ui-on-go: var(--s-on-mark);
67
+ }
68
+
69
+ /* A surface given a line is filled with it, edge to edge. */
70
+ .card:global(.s-ui-lined) {
71
+ --s-bg: var(--s-line);
72
+ --s-fg: var(--s-on-line);
73
+ --s-mark: var(--s-on-line);
74
+ --s-on-mark: var(--s-line);
75
+ --s-read: var(--s-on-line);
76
+ --s-wrong: var(--s-on-line);
77
+ --s-muted: var(--s-accent-soft);
78
+ --s-flat: 1;
79
+ }
80
+ }
@@ -0,0 +1,6 @@
1
+ declare const styles: {
2
+ readonly "card": string;
3
+ readonly "card-actions": string;
4
+ };
5
+ export = styles;
6
+
@@ -0,0 +1,42 @@
1
+ /**
2
+ * `card`: a surface that sets some content apart.
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 { gap, tone } from "../../standard/tokens/classes.ts"
9
+ import type { Colour, Space, Tone } from "../../standard/tokens/tokens.ts"
10
+ import styles from "./card.module.css"
11
+ import { type Actions, actions, line } from "../control/control.ts"
12
+
13
+ export const card = <Msg>(h: Html.H<Msg>) => ({
14
+ /** A surface that sets some content apart: a tint of the page, or with a colour, filled with it. Unlike a tile, it is not pressed; what is pressed is its `actions`. */
15
+ card: <R = never>(
16
+ options: {
17
+ readonly colour?: Colour
18
+ readonly tone?: Tone
19
+ readonly gap?: Space
20
+ /**
21
+ * What can be done about what the card shows, such as paying the sum it adds up: large buttons across
22
+ * its foot, edge to edge, as the answers of a `dialog` are. A button set under a card, with a gap
23
+ * between, does not say what it acts on.
24
+ */
25
+ readonly actions?: Actions<Msg>
26
+ },
27
+ ...children: ReadonlyArray<Child<Kind, Msg, R>>
28
+ ): Node<"block", Msg, R> =>
29
+ node(
30
+ h.div
31
+ .class(
32
+ styles.card,
33
+ options.tone === undefined ? undefined : tone(options.tone),
34
+ options.gap === undefined ? undefined : gap(options.gap),
35
+ line(options.colour)
36
+ )
37
+ .children(
38
+ inner(children),
39
+ (options.actions ?? []).length > 0 && actions(h, styles["card-actions"], options.actions ?? [])
40
+ )
41
+ )
42
+ })
@@ -0,0 +1,24 @@
1
+ /* carousel: several things of a kind, one after another. */
2
+
3
+ @layer standard.ui {
4
+ .carousel {
5
+ display: grid;
6
+ grid-auto-flow: column;
7
+ grid-auto-columns: min(80%, 20rem);
8
+ column-gap: var(--s-gutter);
9
+ padding-block-end: var(--s-unit);
10
+ overflow-x: auto;
11
+ overscroll-behavior-inline: contain;
12
+ scroll-snap-type: inline mandatory;
13
+ scroll-behavior: smooth;
14
+ /* A mouse with no sideways wheel has a scrollbar to drag. */
15
+ scrollbar-width: thin;
16
+ scrollbar-color: currentColor transparent;
17
+ list-style: none;
18
+
19
+ & > li {
20
+ display: grid;
21
+ scroll-snap-align: start;
22
+ }
23
+ }
24
+ }
@@ -0,0 +1,5 @@
1
+ declare const styles: {
2
+ readonly "carousel": string;
3
+ };
4
+ export = styles;
5
+
@@ -0,0 +1,30 @@
1
+ /**
2
+ * `carousel`: several things of a kind, one after another.
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 "./carousel.module.css"
9
+
10
+ export const carousel = <Msg>(h: Html.H<Msg>) => ({
11
+ /**
12
+ * Several things of a kind, one after another: swiped under a finger,
13
+ * scrolled by the arrow keys or a wheel, and stopping on each one.
14
+ */
15
+ carousel: <R = never>(
16
+ options: { readonly label: string },
17
+ ...items: ReadonlyArray<Child<"block", Msg, R>>
18
+ ): Node<"block", Msg, R> =>
19
+ node(
20
+ h.ul
21
+ .class(styles.carousel)
22
+ .attr("aria-label", options.label)
23
+ .attr("tabindex", "0")
24
+ .children(
25
+ inner(items).flatMap((item) =>
26
+ item === false || item === null || item === undefined ? [] : [h.li.children(item)]
27
+ )
28
+ )
29
+ )
30
+ })
@@ -0,0 +1,53 @@
1
+ /* check: something you agree to or not. */
2
+
3
+ @layer standard.ui {
4
+ .check {
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 box that is empty or full: a block either way, a step from the ground while empty and the colour of the text when full. */
17
+ .box {
18
+ flex: none;
19
+ position: relative;
20
+ inline-size: calc(3 * 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
+ /* Full, the box is filled from its middle. */
25
+ &::after {
26
+ content: "";
27
+ position: absolute;
28
+ inset: calc(1.5 * var(--s-unit));
29
+ background: currentColor;
30
+ }
31
+
32
+ :checked + &::after {
33
+ inset: 0;
34
+ }
35
+ }
36
+
37
+ .box::after {
38
+ transition: inset var(--s-quick) var(--s-ease);
39
+ }
40
+
41
+ /* What is wrong with it is said under it, in the colour that marks an error on a field. */
42
+ .check-field {
43
+ display: grid;
44
+ row-gap: calc(var(--s-unit) / 2);
45
+ justify-items: start;
46
+ }
47
+
48
+ .check-error {
49
+ font-size: 0.875rem;
50
+ line-height: 1.5rem;
51
+ color: var(--s-wrong);
52
+ }
53
+ }
@@ -0,0 +1,8 @@
1
+ declare const styles: {
2
+ readonly "box": string;
3
+ readonly "check": string;
4
+ readonly "check-error": string;
5
+ readonly "check-field": string;
6
+ };
7
+ export = styles;
8
+