@colisweb/rescript-toolkit 2.67.0 → 2.68.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitlab-ci.yml +3 -2
- package/.yarn/cache/boolbase-npm-1.0.0-965fe9af6d-3e25c80ef6.zip +0 -0
- package/.yarn/cache/camelcase-npm-3.0.0-0c65af0c7f-ae4fe1c17c.zip +0 -0
- package/.yarn/cache/comma-separated-tokens-npm-1.0.8-00dbbf3418-0adcb07174.zip +0 -0
- package/.yarn/cache/css-selector-parser-npm-1.4.1-b8c642c4c5-31948754e5.zip +0 -0
- package/.yarn/cache/fault-npm-2.0.1-c462630f58-c9b30f47d9.zip +0 -0
- package/.yarn/cache/format-npm-0.2.2-679f3acc64-646a60e133.zip +0 -0
- package/.yarn/cache/github-slugger-npm-2.0.0-3afba76e6c-250375cde2.zip +0 -0
- package/.yarn/cache/hast-util-has-property-npm-1.0.4-a09b607810-23025cee66.zip +0 -0
- package/.yarn/cache/hast-util-has-property-npm-2.0.1-aa6919669c-cc909b7e29.zip +0 -0
- package/.yarn/cache/hast-util-heading-rank-npm-2.1.1-0d71da5801-a49233e9ac.zip +0 -0
- package/.yarn/cache/hast-util-is-element-npm-1.1.0-be10e62fa7-30fad3f65e.zip +0 -0
- package/.yarn/cache/hast-util-is-element-npm-2.1.3-3051d610ff-9d988f6839.zip +0 -0
- package/.yarn/cache/hast-util-select-npm-1.0.1-115974f390-9cdb20850f.zip +0 -0
- package/.yarn/cache/hast-util-to-string-npm-2.0.0-c6108aa2b8-0c087f8dee.zip +0 -0
- package/.yarn/cache/hast-util-to-text-npm-3.1.2-922eb1f623-d17cf3344c.zip +0 -0
- package/.yarn/cache/hast-util-whitespace-npm-1.0.4-43bb1ff3d0-b7f4a1942b.zip +0 -0
- package/.yarn/cache/{husky-npm-8.0.2-46c70b41ed-e101656fcb.zip → husky-npm-8.0.3-b0b59c5127-837bc7e441.zip} +0 -0
- package/.yarn/cache/lowlight-npm-2.8.0-c65abb6cac-c45a91e715.zip +0 -0
- package/.yarn/cache/not-npm-0.1.0-a1712708cd-8043bb53bc.zip +0 -0
- package/.yarn/cache/nth-check-npm-1.0.2-3f6d0d22eb-59e115fdd7.zip +0 -0
- package/.yarn/cache/property-information-npm-3.2.0-ae434c241d-ed2614520d.zip +0 -0
- package/.yarn/cache/rehype-add-classes-npm-1.0.0-ddf6b4e74d-25c0e2dbf5.zip +0 -0
- package/.yarn/cache/rehype-autolink-headings-npm-6.1.1-fe8058cc11-60782fb2e5.zip +0 -0
- package/.yarn/cache/rehype-highlight-npm-6.0.0-5179257139-5a70e7ad45.zip +0 -0
- package/.yarn/cache/rehype-slug-npm-5.1.0-ae08840ba8-2a7c17fd74.zip +0 -0
- package/.yarn/cache/space-separated-tokens-npm-1.1.5-2352c83473-8ef68f1cfa.zip +0 -0
- package/.yarn/cache/unist-util-find-after-npm-4.0.0-11b3b7fb4f-8381ef0bad.zip +0 -0
- package/.yarn/cache/zwitch-npm-1.0.5-5911cef6ce-28a1bebaca.zip +0 -0
- package/.yarn/install-state.gz +0 -0
- package/package.json +8 -5
- package/playground/{App.res → PlaygroundApp.res} +14 -7
- package/playground/PlaygroundComponents.res +114 -0
- package/playground/PlaygroundLocales.res +1 -0
- package/playground/PlaygroundRouter.res +23 -0
- package/playground/{CodeBlock.res → Playground_CodeBlock.res} +12 -16
- package/playground/components/Playground_Alert.res +25 -0
- package/playground/components/Playground_Button.res +75 -0
- package/playground/components/Playground_Label.res +16 -0
- package/playground/components/Playground_Modal.res +53 -0
- package/playground/components/Playground_MultiSelect.res +91 -0
- package/playground/components/Playground_Switch.res +2 -2
- package/playground/custom.css +4 -1
- package/playground/{stories/IntroductionColors.stories.mdx → design/DesignSystem_Colors.mdx} +0 -0
- package/playground/{stories/IntroductionFonts.stories.mdx → design/DesignSystem_Fonts.mdx} +0 -0
- package/playground/{stories/IntroductionMediaQueries.stories.mdx → design/DesignSystem_MediaQueries.mdx} +0 -0
- package/playground/design/Playground_DesignSystem.res +12 -0
- package/playground/{stories/TailwindConfigBreakpoints.js → design/TailwindConfigBreakpoints.jsx} +1 -1
- package/playground/{stories/TailwindConfigColorsPreview.js → design/TailwindConfigColorsPreview.jsx} +1 -1
- package/playground/{stories/TailwindConfigFontsPreview.js → design/TailwindConfigFontsPreview.jsx} +1 -1
- package/playground/docs/ApiDecoding.mdx +70 -0
- package/playground/docs/Form.mdx +109 -0
- package/playground/docs/Identifiers.mdx +38 -0
- package/playground/{Doc.res → docs/Playground_Docs.res} +8 -8
- package/playground/docs/Primitives.mdx +53 -0
- package/playground/docs/Request.mdx +281 -0
- package/playground/docs/Router.mdx +43 -0
- package/playground/docs/Setup.mdx +51 -0
- package/playground/docs/Unleash.mdx +53 -0
- package/playground/main.jsx +1 -1
- package/src/intl/Toolkit__Intl.res +5 -9
- package/src/intl/Toolkit__Intl.resi +1 -0
- package/src/logger/Toolkit__BrowserLogger.res +15 -15
- package/src/router/Toolkit__Router.res +2 -1
- package/src/tailwind/tailwind.config.cjs +3 -5
- package/src/ui/Toolkit__Ui_MultiSelect.res +21 -0
- package/src/ui/styles.css +6 -3
- package/vite.config.js +44 -1
- package/.yarn/cache/cosmiconfig-npm-7.0.0-b9d0d7d156-6801feaa02.zip +0 -0
- package/.yarn/cache/import-fresh-npm-3.3.0-3e34265ca9-2cacfad06e.zip +0 -0
- package/.yarn/cache/klona-npm-2.0.4-6bc4e7cd86-abc6690882.zip +0 -0
- package/.yarn/cache/postcss-loader-npm-4.2.0-f01fec2503-c45ec1ca1b.zip +0 -0
- package/.yarn/cache/semver-npm-7.3.4-4c3baf0ead-96451bfd7c.zip +0 -0
- package/playground/Playground_Component.res +0 -33
- package/playground/Playground_ComponentDetails.res +0 -25
- package/playground/Playground_ComponentsList.res +0 -43
- package/playground/stories/Toolkit__UI_AlertStory.res +0 -111
- package/playground/stories/Toolkit__UI_LabelStory.res +0 -39
- package/playground/stories/Toolkit__UI_ModalStory.res +0 -211
- package/playground/stories/Toolkit__UI_MultiSelectStory.res +0 -132
- package/playground/stories/Toolkit__Ui_ButtonStory.res +0 -324
package/.gitlab-ci.yml
CHANGED
|
@@ -47,7 +47,7 @@ publish rescript-toolkit:
|
|
|
47
47
|
# -----------------------------------------------
|
|
48
48
|
pages:
|
|
49
49
|
image: node:16-bullseye
|
|
50
|
-
extends: .rules-only-for-
|
|
50
|
+
extends: .rules-only-for-master
|
|
51
51
|
tags:
|
|
52
52
|
- aws
|
|
53
53
|
stage: deploy
|
|
@@ -55,9 +55,10 @@ pages:
|
|
|
55
55
|
- export NPM_TOKEN=${NPM_TOKEN:-undefined}
|
|
56
56
|
- yarn
|
|
57
57
|
- yarn build
|
|
58
|
+
- cp -a dist/. public/
|
|
58
59
|
artifacts:
|
|
59
60
|
paths:
|
|
60
|
-
-
|
|
61
|
+
- public
|
|
61
62
|
cache:
|
|
62
63
|
key: "yarn-$CI_COMMIT_REF_SLUG"
|
|
63
64
|
paths:
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/.yarn/install-state.gz
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@colisweb/rescript-toolkit",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.68.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"clean": "rescript clean",
|
|
@@ -59,8 +59,7 @@
|
|
|
59
59
|
"lenses-ppx": "6.1.10",
|
|
60
60
|
"list-selectors": "2.0.1",
|
|
61
61
|
"lodash": "4.17.21",
|
|
62
|
-
"postcss": "8.4.
|
|
63
|
-
"postcss-loader": "4.2.0",
|
|
62
|
+
"postcss": "8.4.21",
|
|
64
63
|
"postcss-preset-env": "7.8.3",
|
|
65
64
|
"prismjs": "1.29.0",
|
|
66
65
|
"react": "18.2.0",
|
|
@@ -95,12 +94,16 @@
|
|
|
95
94
|
"@vitejs/plugin-react": "^3.0.0",
|
|
96
95
|
"babel-loader": "8.2.5",
|
|
97
96
|
"highlight.js": "11.7.0",
|
|
98
|
-
"husky": "8.0.
|
|
97
|
+
"husky": "8.0.3",
|
|
99
98
|
"is-ci": "3.0.1",
|
|
100
99
|
"raw-loader": "4.0.2",
|
|
101
100
|
"react-is": "18.2.0",
|
|
101
|
+
"rehype-add-classes": "^1.0.0",
|
|
102
|
+
"rehype-autolink-headings": "^6.1.1",
|
|
103
|
+
"rehype-highlight": "^6.0.0",
|
|
104
|
+
"rehype-slug": "^5.1.0",
|
|
102
105
|
"sass": "1.56.1",
|
|
103
|
-
"vite": "
|
|
106
|
+
"vite": "4.0.4"
|
|
104
107
|
},
|
|
105
108
|
"packageManager": "yarn@3.3.1"
|
|
106
109
|
}
|
|
@@ -72,18 +72,25 @@ let make = () => {
|
|
|
72
72
|
<PlaygroundRouter.Breadcrumb />
|
|
73
73
|
<div className="p-4">
|
|
74
74
|
{switch currentRoute {
|
|
75
|
-
| Home => <
|
|
75
|
+
| Home => <Playground_Docs.Setup />
|
|
76
76
|
| Docs(doc) =>
|
|
77
77
|
switch doc {
|
|
78
|
-
| Identifiers => <
|
|
79
|
-
| ApiDecoding => <
|
|
80
|
-
| Form => <
|
|
81
|
-
| Requests => <
|
|
78
|
+
| Identifiers => <Playground_Docs.Identifiers />
|
|
79
|
+
| ApiDecoding => <Playground_Docs.ApiDecoding />
|
|
80
|
+
| Form => <Playground_Docs.Form />
|
|
81
|
+
| Requests => <Playground_Docs.Requests />
|
|
82
82
|
}
|
|
83
|
+
| DesignSystem(_route) => React.null
|
|
84
|
+
// switch route {
|
|
85
|
+
// | Fonts => <Playground_DesignSystem.Fonts />
|
|
86
|
+
// | Colors => <Playground_DesignSystem.Colors />
|
|
87
|
+
// | MediaQueries => <Playground_DesignSystem.MediaQueries />
|
|
88
|
+
// }
|
|
89
|
+
|
|
83
90
|
| Components(component) =>
|
|
84
91
|
switch component {
|
|
85
|
-
| List => <
|
|
86
|
-
| Details(component) => <
|
|
92
|
+
| List => <PlaygroundComponents.List />
|
|
93
|
+
| Details(component) => <PlaygroundComponents.Details component />
|
|
87
94
|
}
|
|
88
95
|
|
|
89
96
|
| NotFound => "NotFound"->React.string
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
module type Config = {
|
|
2
|
+
let resi: string
|
|
3
|
+
let codeExample: string
|
|
4
|
+
@react.component
|
|
5
|
+
let make: unit => React.element
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
let components: array<(string, module(Config))> = [
|
|
9
|
+
("card", module(Playground_Card)),
|
|
10
|
+
("switch", module(Playground_Switch)),
|
|
11
|
+
("button", module(Playground_Button)),
|
|
12
|
+
("label", module(Playground_Label)),
|
|
13
|
+
("alert", module(Playground_Alert)),
|
|
14
|
+
("modal", module(Playground_Modal)),
|
|
15
|
+
("multiselect", module(Playground_MultiSelect)),
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
module List = {
|
|
19
|
+
module ComponentLink = {
|
|
20
|
+
@react.component
|
|
21
|
+
let make = (~name) => {
|
|
22
|
+
<PlaygroundRouter.Link
|
|
23
|
+
route={Components(Details(name))}
|
|
24
|
+
className="p-4 rounded-lg border bg-white hover:border-primary-700 w-64">
|
|
25
|
+
<strong className="capitalize"> {name->React.string} </strong>
|
|
26
|
+
</PlaygroundRouter.Link>
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@react.component
|
|
31
|
+
let make = () => {
|
|
32
|
+
let (search, setSearch) = React.useState(() => "")
|
|
33
|
+
|
|
34
|
+
<div>
|
|
35
|
+
<h1 className="text-4xl font-bold font-display mb-4 flex flex-row gap-4 items-center">
|
|
36
|
+
{"Components"->React.string}
|
|
37
|
+
<input
|
|
38
|
+
type_="search"
|
|
39
|
+
placeholder="Search"
|
|
40
|
+
value={search}
|
|
41
|
+
onChange={event => {
|
|
42
|
+
let target = event->ReactEvent.Form.target
|
|
43
|
+
|
|
44
|
+
setSearch(_ => target["value"])
|
|
45
|
+
}}
|
|
46
|
+
className="bg-white text-sm font-sans px-4 font-normal rounded-md border border-neutral-300 focus:border-primary-700 h-10 w-60"
|
|
47
|
+
/>
|
|
48
|
+
</h1>
|
|
49
|
+
<div className="flex flex-row flex-wrap gap-4">
|
|
50
|
+
{components
|
|
51
|
+
->Array.keep(((name, _)) => name->Js.String2.toLowerCase->Js.String2.includes(search))
|
|
52
|
+
->Array.map(((name, _)) => <ComponentLink name key={name} />)
|
|
53
|
+
->React.array}
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
module Details = {
|
|
60
|
+
module Component = {
|
|
61
|
+
@react.component
|
|
62
|
+
let make = (~component: module(Config)) => {
|
|
63
|
+
let module(Config) = component
|
|
64
|
+
<div>
|
|
65
|
+
<ReachUi.Tabs>
|
|
66
|
+
<ReachUi.TabList className="mb-4">
|
|
67
|
+
<ReachUi.Tab> {"Example"->React.string} </ReachUi.Tab>
|
|
68
|
+
<ReachUi.Tab> {"Code example"->React.string} </ReachUi.Tab>
|
|
69
|
+
<ReachUi.Tab> {"API"->React.string} </ReachUi.Tab>
|
|
70
|
+
</ReachUi.TabList>
|
|
71
|
+
<ReachUi.TabPanels>
|
|
72
|
+
<ReachUi.TabPanel>
|
|
73
|
+
<Config />
|
|
74
|
+
</ReachUi.TabPanel>
|
|
75
|
+
<ReachUi.TabPanel>
|
|
76
|
+
<Playground_CodeBlock code={Config.codeExample} />
|
|
77
|
+
</ReachUi.TabPanel>
|
|
78
|
+
<ReachUi.TabPanel>
|
|
79
|
+
<Playground_CodeBlock code={Config.resi} />
|
|
80
|
+
</ReachUi.TabPanel>
|
|
81
|
+
</ReachUi.TabPanels>
|
|
82
|
+
</ReachUi.Tabs>
|
|
83
|
+
</div>
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
@react.component
|
|
88
|
+
let make = (~component: string) => {
|
|
89
|
+
PlaygroundRouter.Breadcrumb.use([
|
|
90
|
+
{
|
|
91
|
+
route: Components(List),
|
|
92
|
+
text: "Components"->React.string,
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
route: Components(Details(component)),
|
|
96
|
+
text: <span className="capitalize"> {`${component}`->React.string} </span>,
|
|
97
|
+
},
|
|
98
|
+
])
|
|
99
|
+
<div>
|
|
100
|
+
<h1 className="text-4xl font-bold font-display mb-4 capitalize">
|
|
101
|
+
{component->React.string}
|
|
102
|
+
</h1>
|
|
103
|
+
<div>
|
|
104
|
+
{components
|
|
105
|
+
->Array.getBy(((name, _)) => {
|
|
106
|
+
component === name
|
|
107
|
+
})
|
|
108
|
+
->Option.mapWithDefault("unknown"->React.string, ((_, playgroundModule)) => {
|
|
109
|
+
<Component component={playgroundModule} />
|
|
110
|
+
})}
|
|
111
|
+
</div>
|
|
112
|
+
</div>
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -8,10 +8,16 @@ module RouterConfig = {
|
|
|
8
8
|
| Requests
|
|
9
9
|
| Form
|
|
10
10
|
|
|
11
|
+
type designRoutes =
|
|
12
|
+
| Fonts
|
|
13
|
+
| Colors
|
|
14
|
+
| MediaQueries
|
|
15
|
+
|
|
11
16
|
type t =
|
|
12
17
|
| Home
|
|
13
18
|
| Docs(docRoutes)
|
|
14
19
|
| Components(componentRoutes)
|
|
20
|
+
| DesignSystem(designRoutes)
|
|
15
21
|
| NotFound
|
|
16
22
|
|
|
17
23
|
let make = (url: RescriptReactRouter.url) => {
|
|
@@ -25,6 +31,13 @@ module RouterConfig = {
|
|
|
25
31
|
| list{"requests"} => Docs(Requests)
|
|
26
32
|
| _ => NotFound
|
|
27
33
|
}
|
|
34
|
+
| list{"design", ...rest} =>
|
|
35
|
+
switch rest {
|
|
36
|
+
| list{"fonts"} => DesignSystem(Fonts)
|
|
37
|
+
| list{"colors"} => DesignSystem(Colors)
|
|
38
|
+
| list{"mediaQueries"} => DesignSystem(MediaQueries)
|
|
39
|
+
| _ => NotFound
|
|
40
|
+
}
|
|
28
41
|
| list{"components", ...rest} =>
|
|
29
42
|
switch rest {
|
|
30
43
|
| list{} => Components(List)
|
|
@@ -50,6 +63,16 @@ module RouterConfig = {
|
|
|
50
63
|
}
|
|
51
64
|
}
|
|
52
65
|
|
|
66
|
+
| DesignSystem(designRoute) => {
|
|
67
|
+
let base = "/design"
|
|
68
|
+
|
|
69
|
+
switch designRoute {
|
|
70
|
+
| Fonts => `${base}/fonts`
|
|
71
|
+
| Colors => `${base}/colors`
|
|
72
|
+
| MediaQueries => `${base}/mediaQueries`
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
53
76
|
| Components(route) => {
|
|
54
77
|
let base = "/components"
|
|
55
78
|
|
|
@@ -3,34 +3,30 @@ module HighlightJs = {
|
|
|
3
3
|
external registerLanguage: (string, 'a) => unit = "registerLanguage"
|
|
4
4
|
@module("highlight.js") @scope("default")
|
|
5
5
|
external highlightAll: unit => unit = "highlightAll"
|
|
6
|
+
|
|
7
|
+
type result = {value: string}
|
|
8
|
+
@module("highlight.js") @scope("default")
|
|
9
|
+
external highlight: (string, 'a) => result = "highlight"
|
|
6
10
|
}
|
|
7
11
|
|
|
8
12
|
@module("../../../playground/utils/rescript-highlight")
|
|
9
13
|
external rescriptModule: 'a = "default"
|
|
10
|
-
@module("highlight.js/lib/languages/bash")
|
|
11
|
-
external bashModule: 'a = "default"
|
|
12
|
-
@module("highlight.js/lib/languages/javascript")
|
|
13
|
-
external javascriptModule: 'a = "default"
|
|
14
14
|
|
|
15
15
|
HighlightJs.registerLanguage("rescript", rescriptModule)
|
|
16
|
-
HighlightJs.registerLanguage("bash", bashModule)
|
|
17
|
-
HighlightJs.registerLanguage("js", javascriptModule)
|
|
18
16
|
|
|
19
17
|
@react.component
|
|
20
|
-
let make = (~
|
|
21
|
-
React.useEffect0(() => {
|
|
22
|
-
HighlightJs.highlightAll()
|
|
23
|
-
|
|
24
|
-
None
|
|
25
|
-
})
|
|
26
|
-
|
|
18
|
+
let make = (~code) => {
|
|
27
19
|
<div className="Code border rounded-lg mb-6 relative">
|
|
28
20
|
<pre className="p-4">
|
|
29
|
-
<code
|
|
21
|
+
<code
|
|
22
|
+
dangerouslySetInnerHTML={
|
|
23
|
+
"__html": HighlightJs.highlight(code, {"language": "rescript"}).value,
|
|
24
|
+
}
|
|
25
|
+
/>
|
|
30
26
|
</pre>
|
|
31
27
|
<button
|
|
32
|
-
className="absolute right-0
|
|
33
|
-
onClick={_ => Browser.Navigator.Clipboard.writeText(Obj.magic(
|
|
28
|
+
className="absolute right-0 top-0 bg-white rounded-tl rounded-br text-sm px-2 border-b border-l hover:bg-neutral-200"
|
|
29
|
+
onClick={_ => Browser.Navigator.Clipboard.writeText(Obj.magic(code))}>
|
|
34
30
|
{"Copy"->React.string}
|
|
35
31
|
</button>
|
|
36
32
|
</div>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
open Toolkit__Ui
|
|
2
|
+
|
|
3
|
+
@module("@root/src/ui/Toolkit__Ui_Alert.resi?raw")
|
|
4
|
+
external resi: string = "default"
|
|
5
|
+
|
|
6
|
+
@module("@root/playground/components/Playground_Alert.res?raw")
|
|
7
|
+
external codeExample: string = "default"
|
|
8
|
+
|
|
9
|
+
@react.component
|
|
10
|
+
let make = () => {
|
|
11
|
+
let variants: array<Alert.status> = [#success, #error, #info, #warning]
|
|
12
|
+
|
|
13
|
+
<div className="flex flex-col gap-8">
|
|
14
|
+
{variants
|
|
15
|
+
->Array.map(variant => {
|
|
16
|
+
<div key={(variant :> string)}>
|
|
17
|
+
<h3> {(variant :> string)->React.string} </h3>
|
|
18
|
+
<Alert
|
|
19
|
+
title={"Title"->React.string} description={"Description"->React.string} status=variant
|
|
20
|
+
/>
|
|
21
|
+
</div>
|
|
22
|
+
})
|
|
23
|
+
->React.array}
|
|
24
|
+
</div>
|
|
25
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
@module("@root/src/ui/Toolkit__Ui_Button.resi?raw")
|
|
2
|
+
external resi: string = "default"
|
|
3
|
+
|
|
4
|
+
@module("@root/playground/components/Playground_Button.res?raw")
|
|
5
|
+
external codeExample: string = "default"
|
|
6
|
+
|
|
7
|
+
@react.component
|
|
8
|
+
let make = () => {
|
|
9
|
+
let colors: array<Toolkit__Ui_Button.color> = [
|
|
10
|
+
#primary,
|
|
11
|
+
#black,
|
|
12
|
+
#white,
|
|
13
|
+
#gray,
|
|
14
|
+
#success,
|
|
15
|
+
#info,
|
|
16
|
+
#danger,
|
|
17
|
+
#warning,
|
|
18
|
+
#neutral,
|
|
19
|
+
#neutralLight,
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
let sizes = Js.Dict.fromArray([("xs", #xs), ("sm", #sm), ("md", #md), ("lg", #lg)])
|
|
23
|
+
let variants = Js.Dict.fromArray([
|
|
24
|
+
("default", #default),
|
|
25
|
+
("text", #text),
|
|
26
|
+
("link", #link),
|
|
27
|
+
("outline", #outline),
|
|
28
|
+
("pill", #pill),
|
|
29
|
+
])
|
|
30
|
+
|
|
31
|
+
<div>
|
|
32
|
+
{colors
|
|
33
|
+
->Array.mapWithIndex((i, color) =>
|
|
34
|
+
<div
|
|
35
|
+
key={i->Int.toString ++ (color :> string)}
|
|
36
|
+
className="flex flex-col gap-4 first:border-0 border-t pt-4 first:pt-0 border-neutral-500">
|
|
37
|
+
<h2> {(color :> string)->React.string} </h2>
|
|
38
|
+
<div className="flex flex-row flex-wrap gap-8">
|
|
39
|
+
{variants
|
|
40
|
+
->Js.Dict.entries
|
|
41
|
+
->Array.map(((variantText, variant)) => {
|
|
42
|
+
<div>
|
|
43
|
+
<h4> {variantText->React.string} </h4>
|
|
44
|
+
<div className="flex flex-col">
|
|
45
|
+
{[false, true]
|
|
46
|
+
->Array.mapWithIndex(
|
|
47
|
+
(j, disabled) =>
|
|
48
|
+
<div className="flex items-center gap-1 mb-2">
|
|
49
|
+
{sizes
|
|
50
|
+
->Js.Dict.entries
|
|
51
|
+
->Array.mapWithIndex(
|
|
52
|
+
(k, (sizeText, size)) =>
|
|
53
|
+
<div
|
|
54
|
+
key={(i + j + k)->Int.toString ++ ((color :> string) ++ sizeText)}
|
|
55
|
+
className="flex flex-col justify-center items-center">
|
|
56
|
+
<Toolkit__Ui_Button variant color size disabled>
|
|
57
|
+
{"hello"->React.string}
|
|
58
|
+
</Toolkit__Ui_Button>
|
|
59
|
+
<span className="text-xxs"> {sizeText->React.string} </span>
|
|
60
|
+
</div>,
|
|
61
|
+
)
|
|
62
|
+
->React.array}
|
|
63
|
+
</div>,
|
|
64
|
+
)
|
|
65
|
+
->React.array}
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
68
|
+
})
|
|
69
|
+
->React.array}
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
72
|
+
)
|
|
73
|
+
->React.array}
|
|
74
|
+
</div>
|
|
75
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
open Toolkit__Ui
|
|
2
|
+
|
|
3
|
+
@module("@root/src/ui/Toolkit__Ui_Label.resi?raw")
|
|
4
|
+
external resi: string = "default"
|
|
5
|
+
|
|
6
|
+
@module("@root/playground/components/Playground_Label.res?raw")
|
|
7
|
+
external codeExample: string = "default"
|
|
8
|
+
|
|
9
|
+
@react.component
|
|
10
|
+
let make = () =>
|
|
11
|
+
<div>
|
|
12
|
+
<Label htmlFor="test"> {"Label"->React.string} </Label>
|
|
13
|
+
<Label htmlFor="test" optionalMessage={"Optional"->React.string}>
|
|
14
|
+
{"Label"->React.string}
|
|
15
|
+
</Label>
|
|
16
|
+
</div>
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
open Toolkit__Ui
|
|
2
|
+
|
|
3
|
+
@module("@root/src/ui/Toolkit__Ui_Modal.resi?raw")
|
|
4
|
+
external resi: string = "default"
|
|
5
|
+
|
|
6
|
+
@module("@root/playground/components/Playground_Modal.res?raw")
|
|
7
|
+
external codeExample: string = "default"
|
|
8
|
+
|
|
9
|
+
@react.component
|
|
10
|
+
let make = () => {
|
|
11
|
+
let modalSize: array<Modal.size> = [#lg, #md, #sm, #xs]
|
|
12
|
+
|
|
13
|
+
let modalColor: array<Modal.color> = [#primary, #success, #danger, #neutral]
|
|
14
|
+
|
|
15
|
+
let (isVisible, setVisibility) = React.useState(() => false)
|
|
16
|
+
let (size, setSize) = React.useState(() => #md)
|
|
17
|
+
let (modalType, setModalType) = React.useState(() => #default)
|
|
18
|
+
|
|
19
|
+
<div className="flex flex-col gap-4 items-start">
|
|
20
|
+
<div>
|
|
21
|
+
<Toolkit__Ui_Label htmlFor="size"> {"Size :"->React.string} </Toolkit__Ui_Label>
|
|
22
|
+
<Toolkit__Ui.Select
|
|
23
|
+
id="size"
|
|
24
|
+
value={Obj.magic(size)}
|
|
25
|
+
onChange={value => {
|
|
26
|
+
setSize(_ => value)
|
|
27
|
+
}}
|
|
28
|
+
options={modalSize->Array.map(value => (value->Obj.magic, value->Obj.magic, true))}
|
|
29
|
+
/>
|
|
30
|
+
</div>
|
|
31
|
+
<div>
|
|
32
|
+
<Toolkit__Ui_Label htmlFor="color"> {"Color :"->React.string} </Toolkit__Ui_Label>
|
|
33
|
+
<Toolkit__Ui.Select
|
|
34
|
+
id="size"
|
|
35
|
+
onChange={value => {
|
|
36
|
+
setModalType(_ => value === "" ? #default : #colored(Obj.magic(value)))
|
|
37
|
+
}}
|
|
38
|
+
options={[("default", "", true)]->Array.concat(
|
|
39
|
+
modalColor->Array.map(value => (value->Obj.magic, value->Obj.magic, true)),
|
|
40
|
+
)}
|
|
41
|
+
/>
|
|
42
|
+
</div>
|
|
43
|
+
<Button onClick={_ => setVisibility(_ => true)}> {"Show modal"->React.string} </Button>
|
|
44
|
+
<Modal
|
|
45
|
+
isVisible
|
|
46
|
+
title={"title"->React.string}
|
|
47
|
+
body={"Body"->React.string}
|
|
48
|
+
hide={() => setVisibility(_ => false)}
|
|
49
|
+
size
|
|
50
|
+
type_=modalType
|
|
51
|
+
/>
|
|
52
|
+
</div>
|
|
53
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
@module("@root/src/ui/Toolkit__Ui_MultiSelect.resi?raw")
|
|
2
|
+
external resi: string = "default"
|
|
3
|
+
|
|
4
|
+
@module("@root/playground/components/Playground_MultiSelect.res?raw")
|
|
5
|
+
external codeExample: string = "default"
|
|
6
|
+
|
|
7
|
+
@react.component
|
|
8
|
+
let make = () => {
|
|
9
|
+
let options1: array<Toolkit__Ui_MultiSelect.item> = [
|
|
10
|
+
{
|
|
11
|
+
itemLabel: <p className="flex flex-row text-danger-500">
|
|
12
|
+
<BsReactIcons.FaAngleDown />
|
|
13
|
+
{"test"->React.string}
|
|
14
|
+
</p>,
|
|
15
|
+
label: "Test",
|
|
16
|
+
value: "test",
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
itemLabel: <p> {"test2"->React.string} </p>,
|
|
20
|
+
label: "Test2",
|
|
21
|
+
value: "test2",
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
itemLabel: <p> {"test3"->React.string} </p>,
|
|
25
|
+
label: "Test3",
|
|
26
|
+
value: "test3",
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
itemLabel: <p> {"test4"->React.string} </p>,
|
|
30
|
+
label: "Test4",
|
|
31
|
+
value: "test4",
|
|
32
|
+
},
|
|
33
|
+
]
|
|
34
|
+
let options2: array<Toolkit__Ui_MultiSelect.item> = [
|
|
35
|
+
{
|
|
36
|
+
itemLabel: <p> {"test4"->React.string} </p>,
|
|
37
|
+
label: "Test4",
|
|
38
|
+
value: "test4",
|
|
39
|
+
},
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
let tmp = Toolkit__Hooks.useDisclosure()
|
|
43
|
+
|
|
44
|
+
let options = tmp.isOpen ? options2 : options1
|
|
45
|
+
|
|
46
|
+
<div className="flex flex-col gap-8 items-start">
|
|
47
|
+
<Toolkit__Ui_Button onClick={_ => tmp.toggle()}>
|
|
48
|
+
{"Change options"->React.string}
|
|
49
|
+
</Toolkit__Ui_Button>
|
|
50
|
+
<Toolkit__Ui_MultiSelect
|
|
51
|
+
searchPlaceholder="Filter"
|
|
52
|
+
buttonClassName={"w-48"}
|
|
53
|
+
dropdownClassName="w-60"
|
|
54
|
+
placeholder={<span> {"Select me"->React.string} </span>}
|
|
55
|
+
onChange={Js.log}
|
|
56
|
+
options
|
|
57
|
+
/>
|
|
58
|
+
<div>
|
|
59
|
+
<h3 className="mb-2"> {"Preselected options"->React.string} </h3>
|
|
60
|
+
<Toolkit__Ui_MultiSelect
|
|
61
|
+
searchPlaceholder="Filter"
|
|
62
|
+
buttonClassName={"w-48"}
|
|
63
|
+
dropdownClassName="w-60"
|
|
64
|
+
defaultValue={options}
|
|
65
|
+
placeholder={<span> {"Select me"->React.string} </span>}
|
|
66
|
+
onChange={Js.log}
|
|
67
|
+
options
|
|
68
|
+
/>
|
|
69
|
+
</div>
|
|
70
|
+
<div>
|
|
71
|
+
<h3 className="mb-2"> {"Search"->React.string} </h3>
|
|
72
|
+
<p className="mb-1">
|
|
73
|
+
{"Search input is displayed when there are more than 5 options"->React.string}
|
|
74
|
+
</p>
|
|
75
|
+
<Toolkit__Ui_MultiSelect
|
|
76
|
+
searchPlaceholder="Filter"
|
|
77
|
+
buttonClassName={"w-48"}
|
|
78
|
+
dropdownClassName="w-60 max-h-[300px] overflow-auto"
|
|
79
|
+
options={Array.makeBy(10, (i): Toolkit__Ui.MultiSelect.item => {
|
|
80
|
+
{
|
|
81
|
+
itemLabel: <p> {`label ${i->Int.toString}`->React.string} </p>,
|
|
82
|
+
label: `label ${i->Int.toString}`,
|
|
83
|
+
value: `label ${i->Int.toString}`,
|
|
84
|
+
}
|
|
85
|
+
})}
|
|
86
|
+
placeholder={<span> {"Select me"->React.string} </span>}
|
|
87
|
+
onChange={Js.log}
|
|
88
|
+
/>
|
|
89
|
+
</div>
|
|
90
|
+
</div>
|
|
91
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
open Toolkit__Ui
|
|
2
2
|
|
|
3
|
-
@module("
|
|
3
|
+
@module("@root/src/ui/Toolkit__Ui_Switch.resi?raw")
|
|
4
4
|
external resi: string = "default"
|
|
5
5
|
|
|
6
|
-
@module("
|
|
6
|
+
@module("@root/playground/components/Playground_Switch.res?raw")
|
|
7
7
|
external codeExample: string = "default"
|
|
8
8
|
|
|
9
9
|
@react.component
|