@yarcl/react 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (223) hide show
  1. package/README.md +14 -2
  2. package/{src/apply.ts → dist/apply.d.ts} +4 -23
  3. package/dist/apply.js +37 -0
  4. package/dist/classes.d.ts +13 -0
  5. package/dist/classes.js +22 -0
  6. package/dist/cli.d.ts +2 -0
  7. package/dist/cli.js +58 -0
  8. package/dist/color.js +49 -32
  9. package/dist/components/Accordion.d.ts +96 -0
  10. package/dist/components/Accordion.js +148 -0
  11. package/dist/components/Alert.d.ts +60 -0
  12. package/dist/components/Alert.js +61 -0
  13. package/dist/components/Avatar.d.ts +100 -0
  14. package/dist/components/Avatar.js +89 -0
  15. package/dist/components/Badge.d.ts +44 -0
  16. package/dist/components/Badge.js +43 -0
  17. package/dist/components/Breadcrumb.d.ts +77 -0
  18. package/dist/components/Breadcrumb.js +126 -0
  19. package/dist/components/Button.d.ts +18 -0
  20. package/dist/components/Button.js +33 -0
  21. package/dist/components/ButtonGroup.d.ts +29 -0
  22. package/dist/components/ButtonGroup.js +37 -0
  23. package/dist/components/Card.d.ts +36 -0
  24. package/dist/components/Card.js +26 -0
  25. package/dist/components/Checkbox.d.ts +28 -0
  26. package/dist/components/Checkbox.js +38 -0
  27. package/dist/components/Combobox.d.ts +75 -0
  28. package/dist/components/Combobox.js +362 -0
  29. package/dist/components/CommandPalette.d.ts +92 -0
  30. package/dist/components/CommandPalette.js +293 -0
  31. package/dist/components/DatePicker.d.ts +157 -0
  32. package/dist/components/DatePicker.js +230 -0
  33. package/dist/components/Dialog.d.ts +25 -0
  34. package/dist/components/Dialog.js +29 -0
  35. package/dist/components/Divider.d.ts +23 -0
  36. package/dist/components/Divider.js +25 -0
  37. package/dist/components/Drawer.d.ts +21 -0
  38. package/dist/components/Drawer.js +25 -0
  39. package/dist/components/EmptyState.d.ts +51 -0
  40. package/dist/components/EmptyState.js +47 -0
  41. package/dist/components/Field.d.ts +27 -0
  42. package/dist/components/Field.js +59 -0
  43. package/dist/components/Heading.d.ts +26 -0
  44. package/dist/components/Heading.js +25 -0
  45. package/dist/components/HoverCard.d.ts +47 -0
  46. package/dist/components/HoverCard.js +53 -0
  47. package/dist/components/IconButton.d.ts +19 -0
  48. package/dist/components/IconButton.js +32 -0
  49. package/dist/components/Inline.d.ts +21 -0
  50. package/dist/components/Inline.js +24 -0
  51. package/dist/components/Input.d.ts +19 -0
  52. package/dist/components/Input.js +25 -0
  53. package/dist/components/Label.d.ts +46 -0
  54. package/dist/components/Label.js +33 -0
  55. package/dist/components/Link.d.ts +27 -0
  56. package/dist/components/Link.js +26 -0
  57. package/dist/components/Menu.d.ts +73 -0
  58. package/dist/components/Menu.js +143 -0
  59. package/dist/components/Modal.d.ts +45 -0
  60. package/dist/components/Modal.js +110 -0
  61. package/dist/components/NumberInput.d.ts +49 -0
  62. package/dist/components/NumberInput.js +130 -0
  63. package/dist/components/Pagination.d.ts +86 -0
  64. package/dist/components/Pagination.js +119 -0
  65. package/dist/components/Popover.d.ts +72 -0
  66. package/dist/components/Popover.js +87 -0
  67. package/dist/components/Progress.d.ts +60 -0
  68. package/dist/components/Progress.js +59 -0
  69. package/dist/components/Radio.d.ts +32 -0
  70. package/dist/components/Radio.js +47 -0
  71. package/dist/components/RadioGroup.d.ts +57 -0
  72. package/dist/components/RadioGroup.js +68 -0
  73. package/dist/components/Select.d.ts +47 -0
  74. package/dist/components/Select.js +138 -0
  75. package/dist/components/Skeleton.d.ts +46 -0
  76. package/dist/components/Skeleton.js +40 -0
  77. package/dist/components/Slider.d.ts +126 -0
  78. package/dist/components/Slider.js +166 -0
  79. package/dist/components/Spinner.d.ts +23 -0
  80. package/dist/components/Spinner.js +23 -0
  81. package/dist/components/Stack.d.ts +35 -0
  82. package/dist/components/Stack.js +24 -0
  83. package/dist/components/Switch.d.ts +27 -0
  84. package/dist/components/Switch.js +33 -0
  85. package/dist/components/Table.d.ts +71 -0
  86. package/dist/components/Table.js +61 -0
  87. package/dist/components/Tabs.d.ts +66 -0
  88. package/dist/components/Tabs.js +109 -0
  89. package/dist/components/Text.d.ts +32 -0
  90. package/dist/components/Text.js +28 -0
  91. package/dist/components/Textarea.d.ts +15 -0
  92. package/dist/components/Textarea.js +24 -0
  93. package/dist/components/Toast.d.ts +90 -0
  94. package/dist/components/Toast.js +156 -0
  95. package/dist/components/ToggleGroup.d.ts +79 -0
  96. package/dist/components/ToggleGroup.js +101 -0
  97. package/dist/components/Tooltip.d.ts +46 -0
  98. package/dist/components/Tooltip.js +62 -0
  99. package/dist/components/VisuallyHidden.d.ts +18 -0
  100. package/dist/components/VisuallyHidden.js +22 -0
  101. package/dist/contrast.d.ts +32 -0
  102. package/dist/css.d.ts +2 -2
  103. package/dist/css.js +193 -157
  104. package/dist/define.d.ts +40 -15
  105. package/dist/define.js +30 -27
  106. package/dist/demo.d.ts +2 -0
  107. package/dist/demo.js +2 -0
  108. package/dist/esbuild.cjs +5 -0
  109. package/dist/esbuild.d.ts +4 -0
  110. package/dist/esbuild.js +6 -0
  111. package/dist/field-context.d.ts +16 -0
  112. package/dist/field-context.js +17 -0
  113. package/dist/floating.d.ts +12 -0
  114. package/dist/floating.js +52 -0
  115. package/dist/hooks.d.ts +1 -0
  116. package/dist/hooks.js +12 -0
  117. package/{src/index.ts → dist/index.d.ts} +11 -33
  118. package/dist/index.js +50 -0
  119. package/dist/init.d.ts +18 -0
  120. package/dist/init.js +224 -0
  121. package/dist/plugin.d.ts +10 -26
  122. package/dist/plugin.js +152 -78
  123. package/dist/reference/DemoYarcl.d.ts +12 -0
  124. package/dist/reference/DemoYarcl.js +312 -0
  125. package/dist/reference/DesignReference.d.ts +24 -0
  126. package/dist/reference/DesignReference.js +403 -0
  127. package/dist/reference/index.js +2 -0
  128. package/dist/rollup.cjs +5 -0
  129. package/dist/rollup.d.ts +4 -0
  130. package/dist/rollup.js +6 -0
  131. package/dist/rspack.cjs +5 -0
  132. package/dist/rspack.d.ts +4 -0
  133. package/dist/rspack.js +6 -0
  134. package/dist/runtime.d.ts +13 -0
  135. package/dist/runtime.js +30 -0
  136. package/dist/setup.d.ts +6 -0
  137. package/dist/setup.js +33 -0
  138. package/{src → dist}/styles.css +224 -106
  139. package/dist/themes/bloom.d.ts +295 -0
  140. package/dist/themes/bloom.js +202 -0
  141. package/dist/themes/brutalist.d.ts +277 -0
  142. package/dist/themes/brutalist.js +199 -0
  143. package/dist/themes/compact.d.ts +274 -0
  144. package/dist/themes/compact.js +200 -0
  145. package/dist/themes/contract.d.ts +23 -0
  146. package/dist/themes/editorial.d.ts +277 -0
  147. package/dist/themes/editorial.js +183 -0
  148. package/dist/themes/index.d.ts +1425 -0
  149. package/dist/themes/index.js +45 -0
  150. package/{src/types.ts → dist/types.d.ts} +40 -37
  151. package/dist/vite.cjs +5 -0
  152. package/dist/vite.d.ts +4 -0
  153. package/dist/vite.js +6 -0
  154. package/dist/webpack.cjs +5 -0
  155. package/dist/webpack.d.ts +4 -0
  156. package/dist/webpack.js +6 -0
  157. package/dist/yarcl.config.d.ts +276 -0
  158. package/dist/yarcl.config.js +273 -0
  159. package/package.json +69 -17
  160. package/src/classes.ts +0 -23
  161. package/src/color.ts +0 -48
  162. package/src/components/Accordion.tsx +0 -274
  163. package/src/components/Alert.tsx +0 -85
  164. package/src/components/Badge.tsx +0 -79
  165. package/src/components/Breadcrumb.tsx +0 -239
  166. package/src/components/Button.tsx +0 -58
  167. package/src/components/ButtonGroup.tsx +0 -61
  168. package/src/components/Card.tsx +0 -50
  169. package/src/components/Checkbox.tsx +0 -49
  170. package/src/components/Combobox.tsx +0 -522
  171. package/src/components/CommandPalette.tsx +0 -452
  172. package/src/components/DatePicker.tsx +0 -432
  173. package/src/components/Dialog.tsx +0 -39
  174. package/src/components/Divider.tsx +0 -34
  175. package/src/components/Drawer.tsx +0 -31
  176. package/src/components/Field.tsx +0 -61
  177. package/src/components/Heading.tsx +0 -40
  178. package/src/components/HoverCard.tsx +0 -108
  179. package/src/components/IconButton.tsx +0 -59
  180. package/src/components/Inline.tsx +0 -42
  181. package/src/components/Input.tsx +0 -28
  182. package/src/components/Label.tsx +0 -58
  183. package/src/components/Link.tsx +0 -41
  184. package/src/components/Menu.tsx +0 -207
  185. package/src/components/Modal.tsx +0 -164
  186. package/src/components/NumberInput.tsx +0 -208
  187. package/src/components/Pagination.tsx +0 -227
  188. package/src/components/Popover.tsx +0 -140
  189. package/src/components/Progress.tsx +0 -122
  190. package/src/components/Radio.tsx +0 -59
  191. package/src/components/RadioGroup.tsx +0 -114
  192. package/src/components/Select.tsx +0 -197
  193. package/src/components/Skeleton.tsx +0 -95
  194. package/src/components/Slider.tsx +0 -315
  195. package/src/components/Spinner.tsx +0 -38
  196. package/src/components/Stack.tsx +0 -57
  197. package/src/components/Switch.tsx +0 -42
  198. package/src/components/Table.tsx +0 -99
  199. package/src/components/Tabs.tsx +0 -159
  200. package/src/components/Text.tsx +0 -67
  201. package/src/components/Textarea.tsx +0 -26
  202. package/src/components/Toast.tsx +0 -190
  203. package/src/components/ToggleGroup.tsx +0 -227
  204. package/src/components/Tooltip.tsx +0 -78
  205. package/src/contrast.ts +0 -82
  206. package/src/css.ts +0 -228
  207. package/src/define.check.ts +0 -259
  208. package/src/define.ts +0 -379
  209. package/src/field-context.ts +0 -31
  210. package/src/floating.tsx +0 -61
  211. package/src/hooks.ts +0 -19
  212. package/src/plugin.ts +0 -94
  213. package/src/reference/DesignReference.tsx +0 -374
  214. package/src/runtime.ts +0 -38
  215. package/src/themes/bloom.ts +0 -72
  216. package/src/themes/brutalist.ts +0 -63
  217. package/src/themes/compact.ts +0 -63
  218. package/src/themes/contract.ts +0 -24
  219. package/src/themes/editorial.ts +0 -55
  220. package/src/themes/index.ts +0 -47
  221. package/src/yarcl.config.ts +0 -104
  222. /package/{src/reference/index.ts → dist/reference/index.d.ts} +0 -0
  223. /package/{src → dist}/reference/reference.css +0 -0
@@ -0,0 +1,273 @@
1
+ import { defineConfig } from "./define.js";
2
+ //#region src/yarcl.config.ts
3
+ /** The library's default design system, used when the consumer provides no config. */
4
+ var yarcl_config_default = defineConfig({
5
+ colors: {
6
+ primary: {
7
+ light: "#2d4bb8",
8
+ dark: "#8aa2ff"
9
+ },
10
+ neutral: {
11
+ light: "#4b5263",
12
+ dark: "#a3a9b8"
13
+ },
14
+ success: {
15
+ light: "#15803d",
16
+ dark: "#4ade80"
17
+ },
18
+ warning: {
19
+ light: "#b45309",
20
+ dark: "#fbbf24"
21
+ },
22
+ danger: {
23
+ light: "#dc2626",
24
+ dark: "#f87171"
25
+ },
26
+ info: {
27
+ light: "#0369a1",
28
+ dark: "#38bdf8"
29
+ }
30
+ },
31
+ neutrals: {
32
+ bg: {
33
+ light: "#f8f9fb",
34
+ dark: "#0f1115"
35
+ },
36
+ surface: {
37
+ light: "#ffffff",
38
+ dark: "#181b21"
39
+ },
40
+ text: {
41
+ light: "#101828",
42
+ dark: "#e6e8ec"
43
+ },
44
+ muted: {
45
+ light: "#667085",
46
+ dark: "#8b93a1"
47
+ },
48
+ border: {
49
+ light: "#d0d5dd",
50
+ dark: "#2e333d"
51
+ }
52
+ },
53
+ sizes: {
54
+ xs: {
55
+ height: "1.75rem",
56
+ paddingX: "0.625rem",
57
+ fontSize: "0.75rem",
58
+ iconSize: "0.75rem"
59
+ },
60
+ sm: {
61
+ height: "2rem",
62
+ paddingX: "0.75rem",
63
+ fontSize: "0.8125rem",
64
+ iconSize: "0.875rem"
65
+ },
66
+ md: {
67
+ height: "2.5rem",
68
+ paddingX: "1rem",
69
+ fontSize: "0.875rem",
70
+ iconSize: "1rem"
71
+ },
72
+ lg: {
73
+ height: "3rem",
74
+ paddingX: "1.25rem",
75
+ fontSize: "1rem",
76
+ iconSize: "1.25rem"
77
+ },
78
+ xl: {
79
+ height: "3.5rem",
80
+ paddingX: "1.5rem",
81
+ fontSize: "1.125rem",
82
+ iconSize: "1.5rem"
83
+ }
84
+ },
85
+ radii: {
86
+ square: "0",
87
+ sm: "0.25rem",
88
+ md: "0.375rem",
89
+ lg: "0.5rem",
90
+ xl: "0.75rem",
91
+ rounded: "9999px"
92
+ },
93
+ variants: {
94
+ solid: {
95
+ background: "fill",
96
+ border: "color",
97
+ text: "on"
98
+ },
99
+ soft: {
100
+ background: "tint",
101
+ border: "none",
102
+ text: "color"
103
+ },
104
+ outline: {
105
+ background: "none",
106
+ border: "color",
107
+ text: "color"
108
+ },
109
+ ghost: {
110
+ background: "none",
111
+ border: "none",
112
+ text: "color"
113
+ }
114
+ },
115
+ spacing: {
116
+ xs: "0.25rem",
117
+ sm: "0.5rem",
118
+ md: "1rem",
119
+ lg: "1.5rem",
120
+ xl: "2rem"
121
+ },
122
+ shadows: {
123
+ sm: "0 1px 2px light-dark(rgb(0 0 0 / 0.08), rgb(0 0 0 / 0.5))",
124
+ md: "0 4px 12px light-dark(rgb(0 0 0 / 0.12), rgb(0 0 0 / 0.6))",
125
+ lg: "0 12px 32px light-dark(rgb(0 0 0 / 0.18), rgb(0 0 0 / 0.7))"
126
+ },
127
+ density: {
128
+ compact: {
129
+ paddingX: "0.5rem",
130
+ paddingY: "0.25rem",
131
+ fontSize: "0.8125rem"
132
+ },
133
+ comfortable: {
134
+ paddingX: "0.75rem",
135
+ paddingY: "0.625rem",
136
+ fontSize: "0.875rem"
137
+ }
138
+ },
139
+ modalSizes: {
140
+ sm: "24rem",
141
+ md: "32rem",
142
+ lg: "48rem",
143
+ xl: "64rem",
144
+ full: "100vw"
145
+ },
146
+ typography: {
147
+ families: {
148
+ sans: "system-ui, -apple-system, \"Segoe UI\", Roboto, sans-serif",
149
+ mono: "ui-monospace, \"SF Mono\", Menlo, Consolas, monospace"
150
+ },
151
+ styles: {
152
+ display: {
153
+ family: "sans",
154
+ size: "2.25rem",
155
+ weight: 800,
156
+ lineHeight: 1.1,
157
+ letterSpacing: "-0.02em"
158
+ },
159
+ heading: {
160
+ family: "sans",
161
+ size: "1.5rem",
162
+ weight: 700,
163
+ lineHeight: 1.25,
164
+ letterSpacing: "-0.01em"
165
+ },
166
+ subheading: {
167
+ family: "sans",
168
+ size: "1.125rem",
169
+ weight: 600,
170
+ lineHeight: 1.35
171
+ },
172
+ body: {
173
+ family: "sans",
174
+ size: "1rem",
175
+ weight: 400,
176
+ lineHeight: 1.5
177
+ },
178
+ caption: {
179
+ family: "sans",
180
+ size: "0.8125rem",
181
+ weight: 400,
182
+ lineHeight: 1.4
183
+ },
184
+ code: {
185
+ family: "mono",
186
+ size: "0.875rem",
187
+ weight: 400,
188
+ lineHeight: 1.5
189
+ },
190
+ label: {
191
+ family: "sans",
192
+ size: "0.875rem",
193
+ weight: 500,
194
+ lineHeight: 1.4
195
+ }
196
+ },
197
+ headings: {
198
+ h1: "display",
199
+ h2: "heading",
200
+ h3: "subheading",
201
+ h4: "subheading",
202
+ h5: "label",
203
+ h6: "label"
204
+ }
205
+ },
206
+ zIndex: {
207
+ dropdown: 1e3,
208
+ tooltip: 1100,
209
+ dialog: 1200,
210
+ toast: 1300
211
+ },
212
+ motion: {
213
+ fast: "120ms",
214
+ base: "200ms",
215
+ easing: "cubic-bezier(0.2, 0, 0, 1)"
216
+ },
217
+ timing: {
218
+ tooltipDelay: 400,
219
+ hoverOpenDelay: 300,
220
+ hoverCloseDelay: 150,
221
+ toastDuration: 5e3
222
+ },
223
+ borders: { width: "1px" },
224
+ focusRing: {
225
+ width: "2px",
226
+ offset: "2px",
227
+ color: "primary"
228
+ },
229
+ defaults: {
230
+ size: "md",
231
+ radius: "md",
232
+ color: "primary",
233
+ variant: "solid",
234
+ errorColor: "danger",
235
+ textStyle: "body",
236
+ labelStyle: "label",
237
+ helperStyle: "caption",
238
+ gap: "md",
239
+ padding: "lg",
240
+ floatingShadow: "md",
241
+ density: "comfortable",
242
+ softVariant: "soft",
243
+ modalSize: "md"
244
+ },
245
+ components: {
246
+ Avatar: { radius: "rounded" },
247
+ EmptyState: {
248
+ color: "neutral",
249
+ gap: "sm",
250
+ padding: "lg",
251
+ textStyle: "body"
252
+ },
253
+ Alert: {
254
+ gap: "sm",
255
+ padding: "md",
256
+ textStyle: "label"
257
+ },
258
+ Drawer: { size: "sm" },
259
+ Tooltip: {
260
+ radius: "md",
261
+ padding: "sm",
262
+ textStyle: "caption"
263
+ },
264
+ Toast: {
265
+ radius: "lg",
266
+ gap: "sm",
267
+ padding: "md",
268
+ textStyle: "label"
269
+ }
270
+ }
271
+ });
272
+ //#endregion
273
+ export { yarcl_config_default as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yarcl/react",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Yet another react component library. Your config file is the design system: every key becomes a typed prop and a rendered style.",
5
5
  "license": "MIT",
6
6
  "author": "Eugene Yakhnenko",
@@ -17,29 +17,79 @@
17
17
  "design-system",
18
18
  "design-tokens",
19
19
  "theming",
20
- "vite-plugin",
20
+ "build-plugin",
21
21
  "typescript"
22
22
  ],
23
23
  "type": "module",
24
+ "bin": {
25
+ "yarcl": "./dist/cli.js"
26
+ },
27
+ "sideEffects": [
28
+ "./dist/index.js",
29
+ "**/*.css"
30
+ ],
24
31
  "files": [
25
- "src",
26
32
  "dist"
27
33
  ],
28
34
  "exports": {
29
- ".": "./src/index.ts",
30
- "./define": "./src/define.ts",
31
- "./defaults": "./src/yarcl.config.ts",
32
- "./plugin": {
33
- "types": "./dist/plugin.d.ts",
34
- "default": "./dist/plugin.js"
35
+ ".": {
36
+ "types": "./dist/index.d.ts",
37
+ "default": "./dist/index.js"
38
+ },
39
+ "./define": {
40
+ "types": "./dist/define.d.ts",
41
+ "default": "./dist/define.js"
42
+ },
43
+ "./defaults": {
44
+ "types": "./dist/yarcl.config.d.ts",
45
+ "default": "./dist/yarcl.config.js"
46
+ },
47
+ "./vite": {
48
+ "types": "./dist/vite.d.ts",
49
+ "import": "./dist/vite.js",
50
+ "require": "./dist/vite.cjs"
51
+ },
52
+ "./webpack": {
53
+ "types": "./dist/webpack.d.ts",
54
+ "import": "./dist/webpack.js",
55
+ "require": "./dist/webpack.cjs"
56
+ },
57
+ "./rspack": {
58
+ "types": "./dist/rspack.d.ts",
59
+ "import": "./dist/rspack.js",
60
+ "require": "./dist/rspack.cjs"
61
+ },
62
+ "./rollup": {
63
+ "types": "./dist/rollup.d.ts",
64
+ "import": "./dist/rollup.js",
65
+ "require": "./dist/rollup.cjs"
66
+ },
67
+ "./esbuild": {
68
+ "types": "./dist/esbuild.d.ts",
69
+ "import": "./dist/esbuild.js",
70
+ "require": "./dist/esbuild.cjs"
71
+ },
72
+ "./reference": {
73
+ "types": "./dist/reference/index.d.ts",
74
+ "default": "./dist/reference/index.js"
75
+ },
76
+ "./demo": {
77
+ "types": "./dist/demo.d.ts",
78
+ "default": "./dist/demo.js"
79
+ },
80
+ "./themes": {
81
+ "types": "./dist/themes/index.d.ts",
82
+ "default": "./dist/themes/index.js"
35
83
  },
36
- "./reference": "./src/reference/index.ts",
37
- "./themes": "./src/themes/index.ts",
38
- "./css": "./src/apply.ts"
84
+ "./css": {
85
+ "types": "./dist/apply.d.ts",
86
+ "default": "./dist/apply.js"
87
+ }
39
88
  },
40
89
  "scripts": {
41
- "build": "tsc -p tsconfig.build.json",
42
- "prepare": "tsc -p tsconfig.build.json"
90
+ "build": "node scripts/build.mjs",
91
+ "prepare": "node scripts/build.mjs",
92
+ "test": "vitest run --config vitest.config.ts"
43
93
  },
44
94
  "publishConfig": {
45
95
  "access": "public",
@@ -47,12 +97,14 @@
47
97
  },
48
98
  "peerDependencies": {
49
99
  "react": ">=19",
50
- "react-dom": ">=19",
51
- "vite": ">=6.1"
100
+ "react-dom": ">=19"
52
101
  },
53
102
  "dependencies": {
54
103
  "@floating-ui/react": "^0.27.20",
55
- "date-fns": "^4.4.0"
104
+ "date-fns": "^4.4.0",
105
+ "jiti": "^2.7.0",
106
+ "jsonc-parser": "^3.3.1",
107
+ "unplugin": "^3.4.0"
56
108
  },
57
109
  "devDependencies": {
58
110
  "@types/node": "^24.0.0",
package/src/classes.ts DELETED
@@ -1,23 +0,0 @@
1
- import { activeConfig } from './runtime';
2
- import type { Color, Density, Radius, Shadow, Size, Spacing, TextStyle, Variant } from './types';
3
-
4
- export function cx(...parts: (string | false | null | undefined)[]): string {
5
- return parts.filter(Boolean).join(' ');
6
- }
7
-
8
- export const sizeClass = (size: Size = activeConfig().defaults.size) => `yarcl-size-${size}`;
9
- export function radiusClass(radius?: Radius | 'size', size?: Size): string | undefined {
10
- const value: Radius | 'size' = radius ?? (activeConfig().defaults.radius as Radius | 'size');
11
- if (value !== 'size') return `yarcl-radius-${value}`;
12
- const match = size ?? activeConfig().defaults.size;
13
- return match in activeConfig().radii ? `yarcl-radius-${match}` : undefined;
14
- }
15
- export const colorClass = (color: Color = activeConfig().defaults.color) => `yarcl-color-${color}`;
16
- export const variantClass = (variant: Variant = activeConfig().defaults.variant) => `yarcl-variant-${variant}`;
17
- export const gapClass = (gap: Spacing = activeConfig().defaults.gap) => `yarcl-gap-${gap}`;
18
- export const paddingClass = (padding: Spacing = activeConfig().defaults.padding) => `yarcl-padding-${padding}`;
19
- export const shadowClass = (shadow?: Shadow) => shadow && `yarcl-shadow-${shadow}`;
20
- export const typeClass = (style: TextStyle) => `yarcl-type-${style}`;
21
- export const densityClass = (density: Density = activeConfig().defaults.density) => `yarcl-density-${density}`;
22
- export const softVariantClass = (variant: Variant = activeConfig().defaults.softVariant) => `yarcl-variant-${variant}`;
23
-
package/src/color.ts DELETED
@@ -1,48 +0,0 @@
1
- type Rgb = [number, number, number];
2
-
3
- export function parseHex(value: string): Rgb | null {
4
- const hex = value.trim().replace(/^#/, '');
5
- if (!/^([0-9a-f]{3}|[0-9a-f]{6})$/i.test(hex)) return null;
6
- const full = hex.length === 3 ? [...hex].map((c) => c + c).join('') : hex;
7
- return [0, 2, 4].map((i) => parseInt(full.slice(i, i + 2), 16)) as Rgb;
8
- }
9
-
10
- function luminance([r, g, b]: Rgb): number {
11
- const [lr, lg, lb] = [r, g, b].map((c) => {
12
- const s = c / 255;
13
- return s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
14
- });
15
- return 0.2126 * lr + 0.7152 * lg + 0.0722 * lb;
16
- }
17
-
18
- export function contrast(a: Rgb, b: Rgb): number {
19
- const [hi, lo] = [luminance(a), luminance(b)].sort((x, y) => y - x);
20
- return (hi + 0.05) / (lo + 0.05);
21
- }
22
-
23
- const WHITE: Rgb = [255, 255, 255];
24
- const BLACK: Rgb = [0, 0, 0];
25
-
26
- export function mix(a: Rgb, b: Rgb, amount: number): Rgb {
27
- return a.map((channel, i) => Math.round(channel + (b[i] - channel) * amount)) as Rgb;
28
- }
29
-
30
- export function toHex(rgb: Rgb): string {
31
- return `#${rgb.map((c) => c.toString(16).padStart(2, '0')).join('')}`;
32
- }
33
-
34
- /**
35
- * The color, mixed toward `toward` in small steps until it reaches `min` contrast
36
- * against every background. Returns the color unchanged when it already passes.
37
- */
38
- export function readableText(color: Rgb, backgrounds: Rgb[], toward: Rgb, min: number): Rgb {
39
- for (let step = 0; step <= 20; step++) {
40
- const candidate = mix(color, toward, step / 20);
41
- if (backgrounds.every((bg) => contrast(candidate, bg) >= min)) return candidate;
42
- }
43
- return toward;
44
- }
45
-
46
- export function readableOn(background: Rgb): string {
47
- return contrast(background, WHITE) >= contrast(background, BLACK) ? '#ffffff' : '#000000';
48
- }