@nmnmcc/standard 0.0.0-stage → 0.4.1
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,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `check`: something you agree to or not.
|
|
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 "./check.module.css"
|
|
10
|
+
|
|
11
|
+
export const check = <Msg>(h: Html.H<Msg>) => ({
|
|
12
|
+
/** Something you agree to or not, as part of a form. */
|
|
13
|
+
check: (options: {
|
|
14
|
+
readonly name: string
|
|
15
|
+
readonly label: string
|
|
16
|
+
readonly checked: boolean
|
|
17
|
+
readonly onChange: (checked: boolean) => Msg
|
|
18
|
+
/** What is wrong with it as it stands, such as a consent that has to be given. */
|
|
19
|
+
readonly error?: string | null
|
|
20
|
+
readonly disabled?: boolean
|
|
21
|
+
}): Node<"block", Msg> => {
|
|
22
|
+
const error =
|
|
23
|
+
options.error === undefined || options.error === null || options.error === "" ? undefined : options.error
|
|
24
|
+
const id = h.id(`s-ui-check-${options.name}-error`)
|
|
25
|
+
const check = h.label.class(control.control, styles.check).children(
|
|
26
|
+
h.input
|
|
27
|
+
.class(control.native)
|
|
28
|
+
.attr("type", "checkbox")
|
|
29
|
+
.attr("name", options.name)
|
|
30
|
+
.attr("aria-invalid", error === undefined ? undefined : "true")
|
|
31
|
+
.attr("aria-describedby", error === undefined ? undefined : id)
|
|
32
|
+
.checked(options.checked)
|
|
33
|
+
.disabled(options.disabled === true)
|
|
34
|
+
.on("change", options.onChange(!options.checked)),
|
|
35
|
+
h.span.class(styles.box).attr("aria-hidden", "true"),
|
|
36
|
+
h.span.children(options.label)
|
|
37
|
+
)
|
|
38
|
+
return node(
|
|
39
|
+
error === undefined
|
|
40
|
+
? check
|
|
41
|
+
: h.div
|
|
42
|
+
.class(styles["check-field"])
|
|
43
|
+
.children(check, h.p.class(styles["check-error"]).attr("id", id).attr("role", "alert").children(error))
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
})
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/* `choice`: which value a setting has, by native radio buttons. */
|
|
2
|
+
|
|
3
|
+
@layer standard.ui {
|
|
4
|
+
/* Which value a setting has. */
|
|
5
|
+
.choice {
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-wrap: wrap;
|
|
8
|
+
row-gap: var(--s-unit);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.segment {
|
|
12
|
+
position: relative;
|
|
13
|
+
display: grid;
|
|
14
|
+
/* Its label starts at its top, at the same inset in every segment, however many lines a neighbour's runs to. */
|
|
15
|
+
align-content: start;
|
|
16
|
+
padding: calc((var(--s-target) - 1.5rem) / 2) calc(2.25 * var(--s-unit));
|
|
17
|
+
background: color-mix(in oklch, var(--s-fg) calc(16% + var(--s-ui-press)), transparent);
|
|
18
|
+
font-weight: 700;
|
|
19
|
+
line-height: 1.5rem;
|
|
20
|
+
|
|
21
|
+
/* Neighbours touch, and are one block; the one that is chosen stands out of it. */
|
|
22
|
+
&:has(:checked) {
|
|
23
|
+
background: var(--s-fg);
|
|
24
|
+
color: var(--s-bg);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&:has(:checked:disabled) {
|
|
28
|
+
background: var(--s-muted);
|
|
29
|
+
color: var(--s-bg);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `choice`: which of a few values a setting has.
|
|
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 { type Item, radios } from "../control/control.ts"
|
|
10
|
+
import styles from "./choice.module.css"
|
|
11
|
+
|
|
12
|
+
export const choice = <Msg>(h: Html.H<Msg>) => ({
|
|
13
|
+
/** Which of a few values a setting has, under a label. The arrow keys move between them. */
|
|
14
|
+
choice: <A extends string>(options: {
|
|
15
|
+
readonly name: string
|
|
16
|
+
readonly label: string
|
|
17
|
+
readonly value: A
|
|
18
|
+
readonly onChange: (value: A) => Msg
|
|
19
|
+
readonly items: ReadonlyArray<Item<A>>
|
|
20
|
+
}): Node<"block", Msg> => {
|
|
21
|
+
const id = h.id(`s-ui-${options.name}-label`)
|
|
22
|
+
return node(
|
|
23
|
+
h.div
|
|
24
|
+
.class(control.field)
|
|
25
|
+
.children(
|
|
26
|
+
h.p.class(control.legend).attr("id", id).children(options.label),
|
|
27
|
+
radios(h, { group: styles.choice, item: styles.segment }, options).attr("aria-labelledby", id)
|
|
28
|
+
)
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
})
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/* What every component shares: the control, the one interaction model there is; a native input under it; a label; a line's colour. */
|
|
2
|
+
|
|
3
|
+
@layer standard.ui {
|
|
4
|
+
.control {
|
|
5
|
+
/* How much of the text's colour is mixed into the control's ground: more on hover, more again while pressed. */
|
|
6
|
+
--s-ui-press: 0%;
|
|
7
|
+
|
|
8
|
+
min-block-size: var(--s-target);
|
|
9
|
+
cursor: pointer;
|
|
10
|
+
user-select: none;
|
|
11
|
+
/* No wait for a second tap, and no double-tap zoom. */
|
|
12
|
+
touch-action: manipulation;
|
|
13
|
+
|
|
14
|
+
/* Pressed is the same for a finger, a button and the space bar. */
|
|
15
|
+
&:active,
|
|
16
|
+
&:has(:active) {
|
|
17
|
+
--s-ui-press: 20%;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/* The focus ring is drawn inside, so a scrolling or clipping parent can't cut it off. */
|
|
21
|
+
&:focus-visible,
|
|
22
|
+
&:has(:focus-visible) {
|
|
23
|
+
outline: calc(var(--s-unit) / 4) solid var(--s-read);
|
|
24
|
+
outline-offset: calc(var(--s-unit) / -4);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&:disabled,
|
|
28
|
+
&:has(:disabled) {
|
|
29
|
+
--s-ui-press: 0%;
|
|
30
|
+
color: var(--s-muted);
|
|
31
|
+
cursor: not-allowed;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/* A native input that fills its control, unseen: the browser keeps its keys, and the label takes the press. */
|
|
36
|
+
.native {
|
|
37
|
+
position: absolute;
|
|
38
|
+
inset: 0;
|
|
39
|
+
inline-size: 100%;
|
|
40
|
+
block-size: 100%;
|
|
41
|
+
opacity: 0;
|
|
42
|
+
cursor: inherit;
|
|
43
|
+
appearance: none;
|
|
44
|
+
|
|
45
|
+
&:focus-visible {
|
|
46
|
+
outline: none;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.legend {
|
|
51
|
+
font-size: 0.75rem;
|
|
52
|
+
line-height: 1rem;
|
|
53
|
+
font-weight: 700;
|
|
54
|
+
letter-spacing: 0.08em;
|
|
55
|
+
text-transform: uppercase;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.field {
|
|
59
|
+
display: grid;
|
|
60
|
+
row-gap: var(--s-unit);
|
|
61
|
+
justify-items: start;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/* A component given a colour takes it as its line's: `--s-line`, and `--s-on-line` for text on it. */
|
|
65
|
+
.lined {
|
|
66
|
+
--s-line: var(--s-accent);
|
|
67
|
+
--s-on-line: var(--s-on-accent);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/*
|
|
71
|
+
* The actions of a surface, at its foot: large buttons, touching, with no
|
|
72
|
+
* margin round them. There are two at most, and how wide they are follows
|
|
73
|
+
* from how wide the surface is.
|
|
74
|
+
*
|
|
75
|
+
* A surface up to 36rem wide is one column of a page: a tile, a card, a
|
|
76
|
+
* sheet, a dialog. Its actions share the whole foot: one fills it from
|
|
77
|
+
* edge to edge, two take half each.
|
|
78
|
+
*
|
|
79
|
+
* A surface wider than that is a band across the page, and a button as
|
|
80
|
+
* wide as a band is no longer a button. There each action is 16rem wide,
|
|
81
|
+
* which is half of the widest column, and they stand at the end of the
|
|
82
|
+
* foot, in the corner where the eye ends up.
|
|
83
|
+
*
|
|
84
|
+
* The second number is 16rem while the foot is wider than 36rem, and the
|
|
85
|
+
* whole foot while it is not: the difference is multiplied until it is
|
|
86
|
+
* one or the other.
|
|
87
|
+
*/
|
|
88
|
+
.actions {
|
|
89
|
+
display: grid;
|
|
90
|
+
grid-auto-flow: column;
|
|
91
|
+
grid-auto-columns: minmax(0, min(100%, max(16rem, (36rem - 100%) * 9999)));
|
|
92
|
+
justify-content: end;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/*
|
|
96
|
+
* One of them: a step from the surface's ground, away from its text.
|
|
97
|
+
* Away, because the text on a block of colour may already be at the
|
|
98
|
+
* lowest contrast that is readable: a step towards it would take it
|
|
99
|
+
* under. So a block with white text goes deeper, and one with black
|
|
100
|
+
* text goes lighter. A surface that is itself a tint of its text sets
|
|
101
|
+
* `--s-ui-step` to that text, and the step goes on the same way.
|
|
102
|
+
*/
|
|
103
|
+
.action {
|
|
104
|
+
--s-ui-away: oklch(from var(--s-fg) clamp(0, (0.5 - l) * 1000, 1) 0 0);
|
|
105
|
+
|
|
106
|
+
/* Its label is at its top, a pictogram and its word on one line. */
|
|
107
|
+
display: block;
|
|
108
|
+
min-block-size: calc(8 * var(--s-unit));
|
|
109
|
+
padding: calc(2 * var(--s-unit)) calc(3 * var(--s-unit));
|
|
110
|
+
/* Mixed in a space with no hue to turn: the step is in lightness only. */
|
|
111
|
+
background: color-mix(in oklab, var(--s-ui-step, var(--s-ui-away)) calc(16% + var(--s-ui-press)), var(--s-bg));
|
|
112
|
+
color: var(--s-fg);
|
|
113
|
+
font-weight: 700;
|
|
114
|
+
line-height: 1.5rem;
|
|
115
|
+
text-align: start;
|
|
116
|
+
|
|
117
|
+
/* The one that goes on: a block of the colour the surface's text is in. */
|
|
118
|
+
&.action-primary {
|
|
119
|
+
background: color-mix(in oklch, var(--s-bg) var(--s-ui-press), var(--s-ui-go, var(--s-fg)));
|
|
120
|
+
color: var(--s-ui-on-go, var(--s-bg));
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
&:disabled {
|
|
124
|
+
color: var(--s-muted);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare const styles: {
|
|
2
|
+
readonly "action": string;
|
|
3
|
+
readonly "action-primary": string;
|
|
4
|
+
readonly "actions": string;
|
|
5
|
+
readonly "control": string;
|
|
6
|
+
readonly "field": string;
|
|
7
|
+
readonly "legend": string;
|
|
8
|
+
readonly "lined": string;
|
|
9
|
+
readonly "native": string;
|
|
10
|
+
};
|
|
11
|
+
export = styles;
|
|
12
|
+
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the components share: a line's colour, native radio buttons, and the actions across the foot of a surface.
|
|
3
|
+
*
|
|
4
|
+
* @since 0.4.0
|
|
5
|
+
*/
|
|
6
|
+
import type { Html } from "effect/ui/html"
|
|
7
|
+
import { accent } from "../../standard/tokens/classes.ts"
|
|
8
|
+
import type { Colour } from "../../standard/tokens/tokens.ts"
|
|
9
|
+
import { type Icon, leading } from "../../standard/icon/icon.ts"
|
|
10
|
+
import styles from "./control.module.css"
|
|
11
|
+
|
|
12
|
+
/** A colour of the language's, for telling things of one kind apart. It says which one, and nothing else. */
|
|
13
|
+
export const line = (colour: Colour | undefined): string | undefined =>
|
|
14
|
+
colour === undefined ? undefined : `${accent(colour)} ${styles.lined}`
|
|
15
|
+
|
|
16
|
+
/** One of the values a `tabs`, a `choice` or an `options` offers. */
|
|
17
|
+
export interface Item<A extends string> {
|
|
18
|
+
readonly value: A
|
|
19
|
+
readonly label: string
|
|
20
|
+
/** A pictogram before the label. */
|
|
21
|
+
readonly icon?: Icon
|
|
22
|
+
readonly disabled?: boolean
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Native radio buttons under one name: the browser moves between them with the arrow keys. */
|
|
26
|
+
export const radios = <Msg, A extends string>(
|
|
27
|
+
h: Html.H<Msg>,
|
|
28
|
+
look: { readonly group: string; readonly item: string },
|
|
29
|
+
options: {
|
|
30
|
+
readonly name: string
|
|
31
|
+
readonly value: A
|
|
32
|
+
readonly onChange: (value: A) => Msg
|
|
33
|
+
readonly items: ReadonlyArray<Item<A>>
|
|
34
|
+
}
|
|
35
|
+
) => {
|
|
36
|
+
const name = h.id(`s-ui-${options.name}`)
|
|
37
|
+
return h.div
|
|
38
|
+
.class(look.group)
|
|
39
|
+
.attr("role", "radiogroup")
|
|
40
|
+
.children(
|
|
41
|
+
options.items.map((item) =>
|
|
42
|
+
h.label.class(styles.control, look.item).children(
|
|
43
|
+
h.input
|
|
44
|
+
.class(styles.native)
|
|
45
|
+
.attr("type", "radio")
|
|
46
|
+
.attr("name", name)
|
|
47
|
+
.attr("value", item.value)
|
|
48
|
+
.checked(item.value === options.value)
|
|
49
|
+
.disabled(item.disabled === true)
|
|
50
|
+
.on("change", () => options.onChange(item.value)),
|
|
51
|
+
h.span.children(leading(h, item.icon), item.label)
|
|
52
|
+
)
|
|
53
|
+
)
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** One thing to do to what a surface shows or asks: an answer to a `dialog`, or what is done to the thing a `tile` shows. */
|
|
58
|
+
export interface Action<Msg> {
|
|
59
|
+
readonly label: string
|
|
60
|
+
/** What a press sends. Left out, the action submits the form it is in: a card or a sheet inside a `form` ends it this way. */
|
|
61
|
+
readonly onPress?: Msg
|
|
62
|
+
/** A pictogram before the label. */
|
|
63
|
+
readonly icon?: Icon
|
|
64
|
+
readonly disabled?: boolean
|
|
65
|
+
/** The one that goes on: a block of the colour the surface's text is in. There is one at most, and it is last. */
|
|
66
|
+
readonly primary?: boolean
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* The actions of one surface: two at most, the one that goes on and the one
|
|
71
|
+
* that doesn't. Alone, either may stand; together, the one that doesn't is
|
|
72
|
+
* first and the `primary` one last. A third thing to do belongs in a `menu`.
|
|
73
|
+
*/
|
|
74
|
+
export type Actions<Msg> =
|
|
75
|
+
| readonly []
|
|
76
|
+
| readonly [Action<Msg>]
|
|
77
|
+
| readonly [Action<Msg> & { readonly primary?: false }, Action<Msg> & { readonly primary: true }]
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The actions of a surface, across its foot: large buttons, edge to edge and
|
|
81
|
+
* touching. One fills the foot; two share it, half each. They are part of
|
|
82
|
+
* the surface, so there is no doubt what they act on; and each is a block of
|
|
83
|
+
* its own, a step from the surface, so there is no doubt it can be pressed.
|
|
84
|
+
*/
|
|
85
|
+
export const actions = <Msg>(h: Html.H<Msg>, place: string, list: Actions<Msg>) =>
|
|
86
|
+
h.div.class(styles.actions, place).children(
|
|
87
|
+
list.map((action) => {
|
|
88
|
+
const button = h.button
|
|
89
|
+
.class(styles.control, styles.action, action.primary === true && styles["action-primary"])
|
|
90
|
+
.attr("type", action.onPress === undefined ? "submit" : "button")
|
|
91
|
+
.disabled(action.disabled === true)
|
|
92
|
+
return (action.onPress === undefined ? button : button.on("click", action.onPress)).children(
|
|
93
|
+
leading(h, action.icon),
|
|
94
|
+
action.label
|
|
95
|
+
)
|
|
96
|
+
})
|
|
97
|
+
)
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/* dialog: a question that needs an answer. */
|
|
2
|
+
|
|
3
|
+
@layer standard.ui {
|
|
4
|
+
/* A question that needs an answer. Flush with the page's margin, a block of the accent, and let down from above the window. */
|
|
5
|
+
.dialog {
|
|
6
|
+
inset-block: 12dvb auto;
|
|
7
|
+
inset-inline: var(--s-margin) auto;
|
|
8
|
+
inline-size: min(32rem, 100% - 2 * var(--s-margin));
|
|
9
|
+
max-block-size: 76dvb;
|
|
10
|
+
--s-bg: var(--s-accent);
|
|
11
|
+
--s-fg: var(--s-on-accent);
|
|
12
|
+
--s-mark: var(--s-on-accent);
|
|
13
|
+
--s-on-mark: var(--s-accent);
|
|
14
|
+
--s-read: var(--s-on-accent);
|
|
15
|
+
--s-wrong: var(--s-on-accent);
|
|
16
|
+
--s-muted: var(--s-accent-soft);
|
|
17
|
+
--s-flat: 1;
|
|
18
|
+
translate: 0 calc(-100% - 12dvb);
|
|
19
|
+
|
|
20
|
+
@starting-style {
|
|
21
|
+
&[open] {
|
|
22
|
+
translate: 0 calc(-100% - 12dvb);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/*
|
|
27
|
+
* While its question is open, the page behind it steps back: a veil of
|
|
28
|
+
* the page's own ground is drawn over it. So the page gets paler in the
|
|
29
|
+
* light scheme and darker in the dark scheme, and what still stands out
|
|
30
|
+
* is the question. The veil appears the moment the dialog does and goes
|
|
31
|
+
* the moment it does: it does not fade.
|
|
32
|
+
*/
|
|
33
|
+
&::backdrop {
|
|
34
|
+
background: color-mix(in oklch, var(--s-paper) 72%, transparent);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* The answers, across the bottom: out to the edges of the dialog, through its padding. */
|
|
39
|
+
.dialog-actions {
|
|
40
|
+
margin: 0 calc(-3 * var(--s-unit)) calc(-3 * var(--s-unit));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `dialog`: a question that needs an answer before anything else.
|
|
3
|
+
*
|
|
4
|
+
* @since 0.4.0
|
|
5
|
+
*/
|
|
6
|
+
import type { Html } from "effect/ui/html"
|
|
7
|
+
import { type Child, type Kind, node, type Node } from "../../Node.ts"
|
|
8
|
+
import { type Actions, actions } from "../control/control.ts"
|
|
9
|
+
import { modal } from "../modal/modal.ts"
|
|
10
|
+
import styles from "./dialog.module.css"
|
|
11
|
+
|
|
12
|
+
export const dialog = <Msg>(h: Html.H<Msg>) => ({
|
|
13
|
+
/**
|
|
14
|
+
* A question that needs an answer before anything else. With `alert` a
|
|
15
|
+
* press outside it doesn't dismiss it: only Escape and its buttons do.
|
|
16
|
+
*
|
|
17
|
+
* With `actions` the answers are large buttons across its bottom, edge to
|
|
18
|
+
* edge and touching: the one that goes on, `primary` and last, a block of
|
|
19
|
+
* the colour the dialog's text is in; and before it the one that doesn't.
|
|
20
|
+
* There are two at most, and one alone fills the bottom.
|
|
21
|
+
*/
|
|
22
|
+
dialog: <R = never>(
|
|
23
|
+
options: {
|
|
24
|
+
readonly open: boolean
|
|
25
|
+
readonly title: string
|
|
26
|
+
readonly close: { readonly label: string; readonly onPress: Msg }
|
|
27
|
+
readonly alert?: boolean
|
|
28
|
+
readonly actions?: Actions<Msg>
|
|
29
|
+
},
|
|
30
|
+
...children: ReadonlyArray<Child<Kind, Msg, R>>
|
|
31
|
+
): Node<"block", Msg, R> => {
|
|
32
|
+
const list = options.actions ?? []
|
|
33
|
+
return node(
|
|
34
|
+
modal(
|
|
35
|
+
h,
|
|
36
|
+
"dialog",
|
|
37
|
+
[styles.dialog],
|
|
38
|
+
options,
|
|
39
|
+
children,
|
|
40
|
+
list.length > 0 && actions(h, styles["dialog-actions"], list)
|
|
41
|
+
)
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
})
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/* disclosure: more, on request. */
|
|
2
|
+
|
|
3
|
+
@layer standard.ui {
|
|
4
|
+
.disclosure {
|
|
5
|
+
/* So a height can travel to `auto`. */
|
|
6
|
+
interpolate-size: allow-keywords;
|
|
7
|
+
|
|
8
|
+
&::details-content {
|
|
9
|
+
block-size: 0;
|
|
10
|
+
overflow: clip;
|
|
11
|
+
transition:
|
|
12
|
+
block-size var(--s-move) var(--s-ease),
|
|
13
|
+
content-visibility var(--s-move) allow-discrete;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
&[open]::details-content {
|
|
17
|
+
block-size: auto;
|
|
18
|
+
}
|
|
19
|
+
&[open] > .summary > :global(.s-ui-arrow) {
|
|
20
|
+
rotate: 0deg;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/* Open, its heading is a block of the text's colour. */
|
|
24
|
+
&[open] > .summary {
|
|
25
|
+
background: color-mix(in oklch, var(--s-bg) var(--s-ui-press), var(--s-fg));
|
|
26
|
+
color: var(--s-bg);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.summary {
|
|
31
|
+
display: grid;
|
|
32
|
+
grid-template-columns: minmax(0, 1fr) auto;
|
|
33
|
+
column-gap: var(--s-gutter);
|
|
34
|
+
align-items: baseline;
|
|
35
|
+
padding-block: calc((var(--s-target) - 1.5rem) / 2);
|
|
36
|
+
padding-inline: calc(2 * var(--s-unit));
|
|
37
|
+
background: color-mix(in oklch, var(--s-fg) calc(8% + var(--s-ui-press)), transparent);
|
|
38
|
+
font-weight: 700;
|
|
39
|
+
line-height: 1.5rem;
|
|
40
|
+
list-style: none;
|
|
41
|
+
|
|
42
|
+
&::-webkit-details-marker {
|
|
43
|
+
display: none;
|
|
44
|
+
}
|
|
45
|
+
/* The arrow points to where the content will go, and turns to point back. */
|
|
46
|
+
& > :global(.s-ui-arrow) {
|
|
47
|
+
transition: rotate var(--s-move) var(--s-ease);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.disclosure-body {
|
|
52
|
+
display: grid;
|
|
53
|
+
grid-template-columns: minmax(0, 1fr);
|
|
54
|
+
row-gap: calc(2 * var(--s-unit));
|
|
55
|
+
padding: calc(2 * var(--s-unit)) calc(2 * var(--s-unit)) calc(3 * var(--s-unit));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `disclosure`: more, on request.
|
|
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 { arrowOf } from "../arrow/arrow.ts"
|
|
9
|
+
import control from "../control/control.module.css"
|
|
10
|
+
import styles from "./disclosure.module.css"
|
|
11
|
+
|
|
12
|
+
export const disclosure = <Msg>(h: Html.H<Msg>) => ({
|
|
13
|
+
/**
|
|
14
|
+
* More, on request: a heading that opens what is under it. Disclosures
|
|
15
|
+
* with the same `name` are an accordion: opening one closes the
|
|
16
|
+
* others.
|
|
17
|
+
*/
|
|
18
|
+
disclosure: <R = never>(
|
|
19
|
+
options: { readonly title: string; readonly name?: string; readonly open?: boolean },
|
|
20
|
+
...children: ReadonlyArray<Child<Kind, Msg, R>>
|
|
21
|
+
): Node<"block", Msg, R> =>
|
|
22
|
+
node(
|
|
23
|
+
h.details
|
|
24
|
+
.class(styles.disclosure)
|
|
25
|
+
.attr("name", options.name)
|
|
26
|
+
.attr("open", options.open === true ? "" : undefined)
|
|
27
|
+
.children(
|
|
28
|
+
h.summary.class(control.control, styles.summary).children(h.span.children(options.title), arrowOf(h, "down")),
|
|
29
|
+
h.div.class(styles["disclosure-body"]).children(inner(children))
|
|
30
|
+
)
|
|
31
|
+
)
|
|
32
|
+
})
|