@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,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `tag`: a word that says what state or kind a thing is.
|
|
3
|
+
*
|
|
4
|
+
* @since 0.4.0
|
|
5
|
+
*/
|
|
6
|
+
import type { Html } from "effect/ui/html";
|
|
7
|
+
import { type Node } from "../../Node.ts";
|
|
8
|
+
import type { Colour } from "../../standard/tokens/tokens.ts";
|
|
9
|
+
import { type Icon } from "../../standard/icon/icon.ts";
|
|
10
|
+
export declare const tag: <Msg>(h: Html.H<Msg>) => {
|
|
11
|
+
/** A word that says what state or kind a thing is. */
|
|
12
|
+
tag: (options: {
|
|
13
|
+
readonly colour?: Colour;
|
|
14
|
+
readonly icon?: Icon;
|
|
15
|
+
}, label: string) => Node<"inline", Msg>;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=tag.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tag.d.ts","sourceRoot":"","sources":["../../../src/ui/tag/tag.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAQ,KAAK,IAAI,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAA;AAE7D,OAAO,EAAE,KAAK,IAAI,EAAW,MAAM,6BAA6B,CAAA;AAGhE,eAAO,MAAM,GAAG,GAAI,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC;IACrC,sDAAsD;IACtD,GAAG,YAAY;QAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAA;KAAE,SAAS,MAAM,KAAG,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC;CAEtG,CAAA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
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 { type Node } from "../../Node.ts";
|
|
8
|
+
import type { Colour, Tone } from "../../standard/tokens/tokens.ts";
|
|
9
|
+
import { type Actions } from "../control/control.ts";
|
|
10
|
+
import { type Icon } from "../../standard/icon/icon.ts";
|
|
11
|
+
export declare const tile: <Msg>(h: Html.H<Msg>) => {
|
|
12
|
+
/** One large thing to press: a pictogram, a figure, a name and a note. With a colour, it is filled with it. */
|
|
13
|
+
tile: (options: {
|
|
14
|
+
readonly label: string;
|
|
15
|
+
/** What a press sends. Left out, give it an `href`: a tile that leads to a place is a link. */
|
|
16
|
+
readonly onPress?: Msg;
|
|
17
|
+
/** Where it leads. */
|
|
18
|
+
readonly href?: string;
|
|
19
|
+
readonly value?: string;
|
|
20
|
+
readonly note?: string;
|
|
21
|
+
readonly icon?: Icon;
|
|
22
|
+
/** A picture across its top, edge to edge: what the tile leads to, when that is a thing to be seen. */
|
|
23
|
+
readonly image?: {
|
|
24
|
+
readonly src: string;
|
|
25
|
+
readonly alt: string;
|
|
26
|
+
};
|
|
27
|
+
readonly colour?: Colour;
|
|
28
|
+
readonly tone?: Tone;
|
|
29
|
+
readonly disabled?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* What can be done to the thing the tile shows, such as removing it from a list: large buttons across the
|
|
32
|
+
* tile's foot, edge to edge, as the answers of a `dialog` are. A button set under a tile, with a gap between,
|
|
33
|
+
* does not say what it acts on.
|
|
34
|
+
*/
|
|
35
|
+
readonly actions?: Actions<Msg>;
|
|
36
|
+
}) => Node<"block", Msg>;
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=tile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tile.d.ts","sourceRoot":"","sources":["../../../src/ui/tile/tile.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAQ,KAAK,IAAI,EAAE,MAAM,eAAe,CAAA;AAE/C,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,iCAAiC,CAAA;AAEnE,OAAO,EAAE,KAAK,OAAO,EAAiB,MAAM,uBAAuB,CAAA;AACnE,OAAO,EAAE,KAAK,IAAI,EAAU,MAAM,6BAA6B,CAAA;AAG/D,eAAO,MAAM,IAAI,GAAI,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC;IACtC,+GAA+G;IAC/G,IAAI,YAAY;QACd,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;QACtB,+FAA+F;QAC/F,QAAQ,CAAC,OAAO,CAAC,EAAE,GAAG,CAAA;QACtB,sBAAsB;QACtB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;QACtB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;QACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;QACtB,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAA;QACpB,uGAAuG;QACvG,QAAQ,CAAC,KAAK,CAAC,EAAE;YAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;YAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;SAAE,CAAA;QAC/D,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;QACxB,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAA;QACpB,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;QAC3B;;;;WAIG;QACH,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,CAAA;KAChC,KAAG,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC;CAgCtB,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
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, type Node } from "../../Node.ts";
|
|
8
|
+
export declare const toasts: <Msg>(h: Html.H<Msg>) => {
|
|
9
|
+
/**
|
|
10
|
+
* What just happened, said at the bottom of the window. Its children
|
|
11
|
+
* are `s.notice`s the Model holds. Make it the last child of the page.
|
|
12
|
+
*/
|
|
13
|
+
toasts: <R = never>(options: {
|
|
14
|
+
readonly label: string;
|
|
15
|
+
}, ...children: ReadonlyArray<Child<"block", Msg, R>>) => Node<"block", Msg, R>;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=toasts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toasts.d.ts","sourceRoot":"","sources":["../../../src/ui/toasts/toasts.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,KAAK,KAAK,EAA2B,KAAK,IAAI,EAAE,MAAM,eAAe,CAAA;AAG9E,eAAO,MAAM,MAAM,GAAI,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC;IACxC;;;OAGG;IACH,MAAM,GAAG,CAAC,GAAG,KAAK,WACP;QAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,eACtB,aAAa,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,KACjD,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC;CAQxB,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
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 { type Node } from "../../Node.ts";
|
|
8
|
+
export declare const toggle: <Msg>(h: Html.H<Msg>) => {
|
|
9
|
+
/** Something that is on or off, and takes effect at once. */
|
|
10
|
+
toggle: (options: {
|
|
11
|
+
readonly label: string;
|
|
12
|
+
readonly on: boolean;
|
|
13
|
+
readonly onChange: (on: boolean) => Msg;
|
|
14
|
+
readonly disabled?: boolean;
|
|
15
|
+
}) => Node<"block", Msg>;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=toggle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toggle.d.ts","sourceRoot":"","sources":["../../../src/ui/toggle/toggle.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAQ,KAAK,IAAI,EAAE,MAAM,eAAe,CAAA;AAI/C,eAAO,MAAM,MAAM,GAAI,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC;IACxC,6DAA6D;IAC7D,MAAM,YAAY;QAChB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;QACtB,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAA;QACpB,QAAQ,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE,OAAO,KAAK,GAAG,CAAA;QACvC,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAC5B,KAAG,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC;CAWtB,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
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 { type Node } from "../../Node.ts";
|
|
8
|
+
export declare const trail: <Msg>(h: Html.H<Msg>) => {
|
|
9
|
+
/**
|
|
10
|
+
* Where you came from: the way here from the top, each step a link back,
|
|
11
|
+
* the last one the page you are on.
|
|
12
|
+
*/
|
|
13
|
+
trail: (options: {
|
|
14
|
+
readonly label: string;
|
|
15
|
+
readonly steps: ReadonlyArray<{
|
|
16
|
+
readonly label: string;
|
|
17
|
+
readonly href: string;
|
|
18
|
+
}>;
|
|
19
|
+
readonly here: string;
|
|
20
|
+
}) => Node<"block", Msg>;
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=trail.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trail.d.ts","sourceRoot":"","sources":["../../../src/ui/trail/trail.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAQ,KAAK,IAAI,EAAE,MAAM,eAAe,CAAA;AAG/C,eAAO,MAAM,KAAK,GAAI,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC;IACvC;;;OAGG;IACH,KAAK,YAAY;QACf,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;QACtB,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;YAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;YAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;QAChF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KACtB,KAAG,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC;CAStB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,73 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nmnmcc/standard",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.4.1",
|
|
4
|
+
"description": "A design language for interfaces on effect/ui: every page built with it is Swiss Style by construction. The language, and interactive components in it.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "NMNM.CC",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/nmnmcc/standard.git",
|
|
10
|
+
"directory": "packages/standard"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://nmnmcc.github.io/standard/",
|
|
13
|
+
"type": "module",
|
|
14
|
+
"sideEffects": [
|
|
15
|
+
"**/*.css"
|
|
16
|
+
],
|
|
17
|
+
"bugs": "https://github.com/nmnmcc/standard/issues",
|
|
18
|
+
"keywords": [
|
|
19
|
+
"effect",
|
|
20
|
+
"design-system",
|
|
21
|
+
"swiss-style",
|
|
22
|
+
"ui",
|
|
23
|
+
"components"
|
|
24
|
+
],
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist",
|
|
30
|
+
"src"
|
|
31
|
+
],
|
|
32
|
+
"exports": {
|
|
33
|
+
".": {
|
|
34
|
+
"types": "./dist/index.d.ts",
|
|
35
|
+
"default": "./dist/index.js"
|
|
36
|
+
},
|
|
37
|
+
"./Standard": {
|
|
38
|
+
"types": "./dist/Standard.d.ts",
|
|
39
|
+
"default": "./dist/Standard.js"
|
|
40
|
+
},
|
|
41
|
+
"./Ui": {
|
|
42
|
+
"types": "./dist/Ui.d.ts",
|
|
43
|
+
"default": "./dist/Ui.js"
|
|
44
|
+
},
|
|
45
|
+
"./Extend": {
|
|
46
|
+
"types": "./dist/Extend.d.ts",
|
|
47
|
+
"default": "./dist/Extend.js"
|
|
48
|
+
},
|
|
49
|
+
"./Palette": {
|
|
50
|
+
"types": "./dist/Palette.d.ts",
|
|
51
|
+
"default": "./dist/Palette.js"
|
|
52
|
+
},
|
|
53
|
+
"./standard.css": "./dist/standard.css"
|
|
54
|
+
},
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"effect": "^4.2.0"
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@effect/vitest": "^4.2.0",
|
|
60
|
+
"@material-symbols/svg-700": "^0.50.0",
|
|
61
|
+
"effect": "^4.2.0",
|
|
62
|
+
"typed-css-modules": "^0.9.1",
|
|
63
|
+
"typescript": "^7.0.2",
|
|
64
|
+
"vite": "^8.4.1",
|
|
65
|
+
"vitest": "^5.1.2"
|
|
66
|
+
},
|
|
67
|
+
"scripts": {
|
|
68
|
+
"types": "tcm --allowArbitraryExtensions --silent src",
|
|
69
|
+
"build": "pnpm types && vite build && tsc -p tsconfig.build.json",
|
|
70
|
+
"check": "pnpm types && tsc -p tsconfig.json --noEmit",
|
|
71
|
+
"test": "pnpm types && vitest run"
|
|
72
|
+
}
|
|
6
73
|
}
|
package/src/Extend.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The entry point for a layer built on top of the language, as `Ui` is.
|
|
3
|
+
*
|
|
4
|
+
* It makes nodes out of what `h` builds and opens them again, so whoever
|
|
5
|
+
* imports it is responsible for the result being Swiss. A page that
|
|
6
|
+
* doesn't import this entry point can't leave the system.
|
|
7
|
+
*
|
|
8
|
+
* @since 0.3.0
|
|
9
|
+
*/
|
|
10
|
+
export { type Child, component, content, contents, type Kind, node, type Node } from "./Node.ts"
|
|
11
|
+
export { builders } from "./Standard.ts"
|
|
12
|
+
/** The classes of a button, for an element that looks like one and does something else, such as opening a menu. */
|
|
13
|
+
export { look as button } from "./standard/button/button.ts"
|
|
14
|
+
export { accent, gap, pad, tone } from "./standard/tokens/classes.ts"
|
package/src/Node.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the builders make and take.
|
|
3
|
+
*
|
|
4
|
+
* @since 0.3.0
|
|
5
|
+
*/
|
|
6
|
+
import type { Component, View } from "effect/ui"
|
|
7
|
+
import { Html } from "effect/ui/html"
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The key a node keeps its content under. The package doesn't export it from
|
|
11
|
+
* its main entry point, so a page can't make a node or open one.
|
|
12
|
+
*/
|
|
13
|
+
export const TypeId: unique symbol = Symbol("@nmnmcc/standard/Node")
|
|
14
|
+
|
|
15
|
+
/** Whether a node is a block of the layout or a run of text. */
|
|
16
|
+
export type Kind = "block" | "inline"
|
|
17
|
+
|
|
18
|
+
/** What a builder returns, and all a builder takes. */
|
|
19
|
+
export interface Node<K extends Kind, Msg, R = never> {
|
|
20
|
+
readonly [TypeId]: View.Content<Msg, R>
|
|
21
|
+
readonly "~K"?: K
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** A child of a builder: a node, text, or a hole that renders nothing. */
|
|
25
|
+
export type Child<K extends Kind, Msg, R = never> = Node<K, Msg, R> | string | false | null | undefined
|
|
26
|
+
|
|
27
|
+
/** Wraps what `h` built as a node. */
|
|
28
|
+
export const node = <K extends Kind, Msg, R>(content: View.Content<Msg, R>): Node<K, Msg, R> => ({ [TypeId]: content })
|
|
29
|
+
|
|
30
|
+
/** What a node holds, to pass to `h`. */
|
|
31
|
+
export const content = <K extends Kind, Msg, R>(self: Node<K, Msg, R>): View.Content<Msg, R> => self[TypeId]
|
|
32
|
+
|
|
33
|
+
/** What children hold, to pass to `.children(...)`. */
|
|
34
|
+
export const contents = <K extends Kind, Msg, R>(children: ReadonlyArray<Child<K, Msg, R>>) =>
|
|
35
|
+
children.map((child) => (typeof child === "object" && child !== null ? child[TypeId] : child))
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A component whose view returns a node. A layer wraps this with its own
|
|
39
|
+
* builders in place of `h`.
|
|
40
|
+
*/
|
|
41
|
+
export const component = <Name extends string, Props, Model, Msg, Events, R, L, Sl extends string, SR, Ch, RV>(
|
|
42
|
+
logic: Component.Logic<Name, Props, Model, Msg, Events, R, L, Sl, SR, Ch>,
|
|
43
|
+
view: (h: Html.H<Msg> & { readonly props: Props }, model: Model) => Node<"block", Msg, RV>
|
|
44
|
+
) => Html.component(logic).make({ view: (h, model) => content(view(h, model)) })
|
package/src/Palette.ts
ADDED
package/src/Standard.ts
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swiss Style, by construction, over `effect/ui`.
|
|
3
|
+
*
|
|
4
|
+
* A view written with this module gets `s` in place of `h`. `s` has no
|
|
5
|
+
* class, no style and no attribute to reach for: every visual choice is a
|
|
6
|
+
* token, and the stylesheet is the only place where a token gets a value. The
|
|
7
|
+
* stylesheet is a typed CSS Module, so a token with no class in it doesn't
|
|
8
|
+
* compile. Inside those limits the builders nest freely.
|
|
9
|
+
*
|
|
10
|
+
* @since 0.2.0
|
|
11
|
+
*/
|
|
12
|
+
// First, before any other stylesheet: it sets the order of the cascade layers.
|
|
13
|
+
import "./standard/tokens/tokens.module.css"
|
|
14
|
+
import type { Component, View } from "effect/ui"
|
|
15
|
+
import type { Html } from "effect/ui/html"
|
|
16
|
+
import { component as define, node, type Node } from "./Node.ts"
|
|
17
|
+
import { button } from "./standard/button/button.ts"
|
|
18
|
+
import { field } from "./standard/field/field.ts"
|
|
19
|
+
import { form } from "./standard/form/form.ts"
|
|
20
|
+
import { icon } from "./standard/icon/icon.ts"
|
|
21
|
+
import { image } from "./standard/image/image.ts"
|
|
22
|
+
import { layout } from "./standard/layout/layout.ts"
|
|
23
|
+
import { list } from "./standard/list/list.ts"
|
|
24
|
+
import { page } from "./standard/page/page.ts"
|
|
25
|
+
import { table } from "./standard/table/table.ts"
|
|
26
|
+
import { text } from "./standard/text/text.ts"
|
|
27
|
+
|
|
28
|
+
export { Icon } from "./standard/icon/icon.ts"
|
|
29
|
+
export * from "./standard/tokens/tokens.ts"
|
|
30
|
+
|
|
31
|
+
export type { Child, Kind, Node } from "./Node.ts"
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The builders, bound to a view's `h`. A view gets them as `s`; a layer built
|
|
35
|
+
* on top of this one adds its own builders to them. Each is in `src/standard`,
|
|
36
|
+
* in the file named on its line.
|
|
37
|
+
*
|
|
38
|
+
* @since 0.3.0
|
|
39
|
+
*/
|
|
40
|
+
export const builders = <Msg, Props>(h: Html.H<Msg> & { readonly props: Props }) => ({
|
|
41
|
+
/** The props of the component being rendered. */
|
|
42
|
+
props: h.props,
|
|
43
|
+
|
|
44
|
+
...page(h), // `page`
|
|
45
|
+
...layout(h), // `section`, `grid`, `col`, `stack`, `row`, `rule`
|
|
46
|
+
...text(h), // `text`, `em`, `code`, `listing`, `quote`, `link`, `br`
|
|
47
|
+
...icon(h), // `icon`
|
|
48
|
+
...list(h), // `list`
|
|
49
|
+
...image(h), // `image`
|
|
50
|
+
...table(h), // `table`
|
|
51
|
+
...button(h), // `button`
|
|
52
|
+
...field(h), // `field`, `textarea`, `select`
|
|
53
|
+
...form(h), // `form`
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Another component, placed by calling it with the helper passed in:
|
|
57
|
+
* `s.child((h) => Counter(h, { props: { start: 1 } }))`. What it shows is
|
|
58
|
+
* its own business, so this is where a chart or a map comes in.
|
|
59
|
+
*/
|
|
60
|
+
child: <R = never>(place: (h: View.HelperBase<Msg, unknown>) => View.Child<Msg, R>): Node<"block", Msg, R> =>
|
|
61
|
+
node(place(h))
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* `s` in a view: the builders, bound to the component's messages and props.
|
|
66
|
+
*
|
|
67
|
+
* @since 0.2.0
|
|
68
|
+
*/
|
|
69
|
+
export type S<Msg, Props = unknown> = ReturnType<typeof builders<Msg, Props>>
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* A component whose view is built with `s`.
|
|
73
|
+
*
|
|
74
|
+
* **Example** (A counter)
|
|
75
|
+
*
|
|
76
|
+
* ```ts
|
|
77
|
+
* import { Standard } from "@nmnmcc/standard"
|
|
78
|
+
* import { Schema } from "effect"
|
|
79
|
+
* import { Component } from "effect/ui"
|
|
80
|
+
*
|
|
81
|
+
* const Logic = Component.define({
|
|
82
|
+
* name: "Counter",
|
|
83
|
+
* model: Schema.Number,
|
|
84
|
+
* message: Schema.Literal("ClickedAdd")
|
|
85
|
+
* }).logic({
|
|
86
|
+
* init: () => 0,
|
|
87
|
+
* update: ($) => $.model + 1
|
|
88
|
+
* })
|
|
89
|
+
*
|
|
90
|
+
* export const Counter = Standard.component(Logic, (s, count) =>
|
|
91
|
+
* s.page({},
|
|
92
|
+
* s.section({ as: "main", pad: 8 },
|
|
93
|
+
* s.grid({},
|
|
94
|
+
* s.col({ span: 8 },
|
|
95
|
+
* s.text("display", String(count)),
|
|
96
|
+
* s.button({ onClick: "ClickedAdd" }, "Add one")
|
|
97
|
+
* )
|
|
98
|
+
* )
|
|
99
|
+
* )
|
|
100
|
+
* )
|
|
101
|
+
* )
|
|
102
|
+
* ```
|
|
103
|
+
*
|
|
104
|
+
* @since 0.2.0
|
|
105
|
+
*/
|
|
106
|
+
export const component = <Name extends string, Props, Model, Msg, Events, R, L, Sl extends string, SR, Ch, RV>(
|
|
107
|
+
logic: Component.Logic<Name, Props, Model, Msg, Events, R, L, Sl, SR, Ch>,
|
|
108
|
+
view: (s: S<Msg, Props>, model: Model) => Node<"block", Msg, RV>
|
|
109
|
+
) => define(logic, (h, model) => view(builders(h), model))
|
package/src/Ui.ts
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interactive components in the language of `Standard`.
|
|
3
|
+
*
|
|
4
|
+
* The module is organised around what a person does to a component, not
|
|
5
|
+
* around the screen: each builder is a thing to press, choose, switch,
|
|
6
|
+
* follow or dismiss, and it behaves the same under a mouse, a finger and a
|
|
7
|
+
* keyboard. What is on, selected or current is a block of colour, never a
|
|
8
|
+
* line under or beside a word. An app has a `navigator`: everywhere one can
|
|
9
|
+
* go, at the side of the page, along its top, or along its bottom.
|
|
10
|
+
*
|
|
11
|
+
* From the signage of public transport it takes how signs work, not how
|
|
12
|
+
* they look: one thing said per sign, at a size read at a glance; direction
|
|
13
|
+
* shown by position and by an arrow; colour telling things of one kind
|
|
14
|
+
* apart, and never colour alone. It doesn't take lines, stations or maps:
|
|
15
|
+
* an app isn't a network.
|
|
16
|
+
*
|
|
17
|
+
* `s` here is `Standard`'s `s` with these builders added.
|
|
18
|
+
*
|
|
19
|
+
* @since 0.1.0
|
|
20
|
+
*/
|
|
21
|
+
import type { Component } from "effect/ui"
|
|
22
|
+
import type { Html } from "effect/ui/html"
|
|
23
|
+
import { component as define, type Node } from "./Node.ts"
|
|
24
|
+
import * as Standard from "./Standard.ts"
|
|
25
|
+
import { arrow } from "./ui/arrow/arrow.ts"
|
|
26
|
+
import { avatar } from "./ui/avatar/avatar.ts"
|
|
27
|
+
import { board } from "./ui/board/board.ts"
|
|
28
|
+
import { bullet } from "./ui/bullet/bullet.ts"
|
|
29
|
+
import { card } from "./ui/card/card.ts"
|
|
30
|
+
import { carousel } from "./ui/carousel/carousel.ts"
|
|
31
|
+
import { check } from "./ui/check/check.ts"
|
|
32
|
+
import { choice } from "./ui/choice/choice.ts"
|
|
33
|
+
import { dialog } from "./ui/dialog/dialog.ts"
|
|
34
|
+
import { disclosure } from "./ui/disclosure/disclosure.ts"
|
|
35
|
+
import { flap } from "./ui/flap/flap.ts"
|
|
36
|
+
import { item } from "./ui/item/item.ts"
|
|
37
|
+
import { key } from "./ui/key/key.ts"
|
|
38
|
+
import { menu } from "./ui/menu/menu.ts"
|
|
39
|
+
import { navigator } from "./ui/navigator/navigator.ts"
|
|
40
|
+
import { notice } from "./ui/notice/notice.ts"
|
|
41
|
+
import { options } from "./ui/options/options.ts"
|
|
42
|
+
import { pager } from "./ui/pager/pager.ts"
|
|
43
|
+
import { pagination } from "./ui/pagination/pagination.ts"
|
|
44
|
+
import { popover } from "./ui/popover/popover.ts"
|
|
45
|
+
import { progress } from "./ui/progress/progress.ts"
|
|
46
|
+
import { route } from "./ui/route/route.ts"
|
|
47
|
+
import { sheet } from "./ui/sheet/sheet.ts"
|
|
48
|
+
import { skeleton } from "./ui/skeleton/skeleton.ts"
|
|
49
|
+
import { slider } from "./ui/slider/slider.ts"
|
|
50
|
+
import { stepper } from "./ui/stepper/stepper.ts"
|
|
51
|
+
import { tabs } from "./ui/tabs/tabs.ts"
|
|
52
|
+
import { tag } from "./ui/tag/tag.ts"
|
|
53
|
+
import { tile } from "./ui/tile/tile.ts"
|
|
54
|
+
import { toasts } from "./ui/toasts/toasts.ts"
|
|
55
|
+
import { toggle } from "./ui/toggle/toggle.ts"
|
|
56
|
+
import { trail } from "./ui/trail/trail.ts"
|
|
57
|
+
|
|
58
|
+
export { Direction } from "./ui/arrow/arrow.ts"
|
|
59
|
+
export type { Action, Actions, Item } from "./ui/control/control.ts"
|
|
60
|
+
export { Hold, Place } from "./ui/navigator/navigator.ts"
|
|
61
|
+
export { Level } from "./ui/notice/notice.ts"
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The language's builders and the components, bound to a view's `h`. Each
|
|
65
|
+
* component is in `src/ui`, in the file of its name, with its stylesheet
|
|
66
|
+
* beside it.
|
|
67
|
+
*
|
|
68
|
+
* @since 0.1.0
|
|
69
|
+
*/
|
|
70
|
+
export const builders = <Msg, Props>(h: Html.H<Msg> & { readonly props: Props }) => ({
|
|
71
|
+
...Standard.builders(h),
|
|
72
|
+
|
|
73
|
+
// What the components are labelled with.
|
|
74
|
+
...bullet(h),
|
|
75
|
+
...arrow(h),
|
|
76
|
+
...flap(h),
|
|
77
|
+
...tag(h),
|
|
78
|
+
...avatar(h),
|
|
79
|
+
...key(h),
|
|
80
|
+
|
|
81
|
+
// Things to press, choose and switch.
|
|
82
|
+
...tile(h),
|
|
83
|
+
...tabs(h),
|
|
84
|
+
...choice(h),
|
|
85
|
+
...options(h),
|
|
86
|
+
...toggle(h),
|
|
87
|
+
...check(h),
|
|
88
|
+
...slider(h),
|
|
89
|
+
...stepper(h),
|
|
90
|
+
...menu(h),
|
|
91
|
+
|
|
92
|
+
// What is shown, and how far along it is.
|
|
93
|
+
...card(h),
|
|
94
|
+
...item(h),
|
|
95
|
+
...board(h),
|
|
96
|
+
...route(h),
|
|
97
|
+
...progress(h),
|
|
98
|
+
...skeleton(h),
|
|
99
|
+
...carousel(h),
|
|
100
|
+
|
|
101
|
+
// More, on request, and what a person is told.
|
|
102
|
+
...disclosure(h),
|
|
103
|
+
...popover(h),
|
|
104
|
+
...sheet(h),
|
|
105
|
+
...dialog(h),
|
|
106
|
+
...notice(h),
|
|
107
|
+
...toasts(h),
|
|
108
|
+
|
|
109
|
+
// Where one is, where one came from, where one can go.
|
|
110
|
+
...navigator(h),
|
|
111
|
+
...trail(h),
|
|
112
|
+
...pager(h),
|
|
113
|
+
...pagination(h)
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* `s` in a view: the language's builders and the components.
|
|
118
|
+
*
|
|
119
|
+
* @since 0.1.0
|
|
120
|
+
*/
|
|
121
|
+
export type S<Msg, Props = unknown> = ReturnType<typeof builders<Msg, Props>>
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* A component whose view is built with `s`.
|
|
125
|
+
*
|
|
126
|
+
* **Example** (A switch)
|
|
127
|
+
*
|
|
128
|
+
* ```ts
|
|
129
|
+
* import { Ui } from "@nmnmcc/standard"
|
|
130
|
+
* import { Schema } from "effect"
|
|
131
|
+
* import { Component } from "effect/ui"
|
|
132
|
+
*
|
|
133
|
+
* const Logic = Component.define({
|
|
134
|
+
* name: "StepFree",
|
|
135
|
+
* model: Schema.Boolean,
|
|
136
|
+
* message: Schema.Literal("Switched")
|
|
137
|
+
* }).logic({
|
|
138
|
+
* init: () => false,
|
|
139
|
+
* update: ($) => !$.model
|
|
140
|
+
* })
|
|
141
|
+
*
|
|
142
|
+
* export const StepFree = Ui.component(Logic, (s, on) =>
|
|
143
|
+
* s.page({},
|
|
144
|
+
* s.section({ as: "main" },
|
|
145
|
+
* s.toggle({ label: "Step-free routes only", on, onChange: () => "Switched" })
|
|
146
|
+
* )
|
|
147
|
+
* )
|
|
148
|
+
* )
|
|
149
|
+
* ```
|
|
150
|
+
*
|
|
151
|
+
* @since 0.1.0
|
|
152
|
+
*/
|
|
153
|
+
export const component = <Name extends string, Props, Model, Msg, Events, R, L, Sl extends string, SR, Ch, RV>(
|
|
154
|
+
logic: Component.Logic<Name, Props, Model, Msg, Events, R, L, Sl, SR, Ch>,
|
|
155
|
+
view: (s: S<Msg, Props>, model: Model) => Node<"block", Msg, RV>
|
|
156
|
+
) => define(logic, (h, model) => view(builders(h), model))
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @since 0.4.0
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The language itself: grid, type, colour, text, forms, and the movement of
|
|
7
|
+
* a change of view.
|
|
8
|
+
*
|
|
9
|
+
* @since 0.1.0
|
|
10
|
+
*/
|
|
11
|
+
export * as Standard from "./Standard.ts"
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Interactive components in the language: `Standard`'s `s`, with things to
|
|
15
|
+
* press, choose, switch, follow and dismiss added.
|
|
16
|
+
*
|
|
17
|
+
* @since 0.1.0
|
|
18
|
+
*/
|
|
19
|
+
export * as Ui from "./Ui.ts"
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* How the colours are made: the algorithm the palette comes from, and what
|
|
23
|
+
* it guarantees for every hue.
|
|
24
|
+
*
|
|
25
|
+
* @since 0.4.0
|
|
26
|
+
*/
|
|
27
|
+
export * as Palette from "./Palette.ts"
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/* button: the simplest thing to press. */
|
|
2
|
+
|
|
3
|
+
@layer standard.controls {
|
|
4
|
+
.button {
|
|
5
|
+
justify-self: start;
|
|
6
|
+
align-self: start;
|
|
7
|
+
padding: calc(1.75 * var(--s-unit)) calc(3.25 * var(--s-unit));
|
|
8
|
+
background: var(--s-fg);
|
|
9
|
+
color: var(--s-bg);
|
|
10
|
+
font-weight: 700;
|
|
11
|
+
line-height: 1.5rem;
|
|
12
|
+
min-block-size: var(--s-target);
|
|
13
|
+
cursor: pointer;
|
|
14
|
+
user-select: none;
|
|
15
|
+
/* No wait for a second tap, and no zoom on a double tap. */
|
|
16
|
+
touch-action: manipulation;
|
|
17
|
+
|
|
18
|
+
/* The lighter of the two is a block as well: a step from the ground towards the text, and no frame. */
|
|
19
|
+
&.kind-secondary {
|
|
20
|
+
background: color-mix(in oklch, var(--s-fg) 16%, transparent);
|
|
21
|
+
color: var(--s-fg);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&:active:not(:disabled) {
|
|
25
|
+
background: var(--s-mark);
|
|
26
|
+
color: var(--s-on-mark);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&:disabled {
|
|
30
|
+
background: color-mix(in oklch, var(--s-fg) 8%, transparent);
|
|
31
|
+
color: var(--s-muted);
|
|
32
|
+
cursor: not-allowed;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/* A state changes at once: no colour fades into another. What gives under a press is the button itself. */
|
|
37
|
+
.button {
|
|
38
|
+
transition: scale var(--s-quick) var(--s-ease);
|
|
39
|
+
}
|
|
40
|
+
.button:active:not(:disabled) {
|
|
41
|
+
scale: 0.97;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `button`: the simplest 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 { type Icon, leading } from "../icon/icon.ts"
|
|
9
|
+
import styles from "./button.module.css"
|
|
10
|
+
|
|
11
|
+
/** The classes of a button, for an element that looks like one and does something else, such as opening a menu. */
|
|
12
|
+
export const look = (kind: "primary" | "secondary"): string =>
|
|
13
|
+
kind === "secondary" ? `${styles.button} ${styles["kind-secondary"]}` : styles.button
|
|
14
|
+
|
|
15
|
+
export const button = <Msg>(h: Html.H<Msg>) => ({
|
|
16
|
+
/** A button. With an `icon`, a pictogram before its label, never in place of it. */
|
|
17
|
+
button: (
|
|
18
|
+
options: {
|
|
19
|
+
readonly onClick?: Msg
|
|
20
|
+
readonly kind?: "primary" | "secondary"
|
|
21
|
+
readonly type?: "button" | "submit"
|
|
22
|
+
readonly disabled?: boolean
|
|
23
|
+
readonly icon?: Icon
|
|
24
|
+
},
|
|
25
|
+
label: string
|
|
26
|
+
): Node<"block", Msg> => {
|
|
27
|
+
const button = h.button
|
|
28
|
+
.class(styles.button, options.kind === "secondary" && styles["kind-secondary"])
|
|
29
|
+
.attr("type", options.type ?? "button")
|
|
30
|
+
.disabled(options.disabled === true)
|
|
31
|
+
return node(
|
|
32
|
+
(options.onClick === undefined ? button : button.on("click", options.onClick)).children(
|
|
33
|
+
leading(h, options.icon),
|
|
34
|
+
label
|
|
35
|
+
)
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
})
|