aidos-ui 4.0.4 → 4.0.5

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 (376) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +23 -3
  3. package/dist/index.d.ts +797 -68
  4. package/dist/index.js +3868 -68
  5. package/dist/index.js.map +1 -1
  6. package/dist/jsx-dev-runtime.d.ts +6 -2
  7. package/dist/jsx-dev-runtime.js +87 -42
  8. package/dist/jsx-dev-runtime.js.map +1 -1
  9. package/dist/jsx-runtime.d.ts +1 -1
  10. package/dist/jsx-runtime.js +2 -2
  11. package/dist/jsx-runtime.js.map +1 -1
  12. package/dist/vite-plugin-jss-debug.d.ts +3 -1
  13. package/dist/vite-plugin-jss-debug.js +57 -74
  14. package/dist/vite-plugin-jss-debug.js.map +1 -1
  15. package/package.json +58 -27
  16. package/.prettierrc +0 -4
  17. package/CLAUDE.md +0 -72
  18. package/dist/Badge.d.ts +0 -6
  19. package/dist/Badge.js +0 -22
  20. package/dist/Badge.js.map +0 -1
  21. package/dist/BaseButton.d.ts +0 -14
  22. package/dist/BaseButton.js +0 -23
  23. package/dist/BaseButton.js.map +0 -1
  24. package/dist/BaseInput.d.ts +0 -14
  25. package/dist/BaseInput.js +0 -15
  26. package/dist/BaseInput.js.map +0 -1
  27. package/dist/BaseLink.d.ts +0 -18
  28. package/dist/BaseLink.js +0 -29
  29. package/dist/BaseLink.js.map +0 -1
  30. package/dist/BaseList.d.ts +0 -6
  31. package/dist/BaseList.js +0 -14
  32. package/dist/BaseList.js.map +0 -1
  33. package/dist/BaseListAddOn.d.ts +0 -5
  34. package/dist/BaseListAddOn.js +0 -7
  35. package/dist/BaseListAddOn.js.map +0 -1
  36. package/dist/BaseListItem.d.ts +0 -26
  37. package/dist/BaseListItem.js +0 -29
  38. package/dist/BaseListItem.js.map +0 -1
  39. package/dist/BaseView.d.ts +0 -12
  40. package/dist/BaseView.js +0 -26
  41. package/dist/BaseView.js.map +0 -1
  42. package/dist/Box.d.ts +0 -4
  43. package/dist/Box.js +0 -6
  44. package/dist/Box.js.map +0 -1
  45. package/dist/Button.d.ts +0 -20
  46. package/dist/Button.js +0 -19
  47. package/dist/Button.js.map +0 -1
  48. package/dist/Calendar.d.ts +0 -18
  49. package/dist/Calendar.js +0 -57
  50. package/dist/Calendar.js.map +0 -1
  51. package/dist/Card.d.ts +0 -4
  52. package/dist/Card.js +0 -14
  53. package/dist/Card.js.map +0 -1
  54. package/dist/Checkbox.d.ts +0 -11
  55. package/dist/Checkbox.js +0 -32
  56. package/dist/Checkbox.js.map +0 -1
  57. package/dist/Circle.d.ts +0 -5
  58. package/dist/Circle.js +0 -12
  59. package/dist/Circle.js.map +0 -1
  60. package/dist/Column.d.ts +0 -6
  61. package/dist/Column.js +0 -7
  62. package/dist/Column.js.map +0 -1
  63. package/dist/DarkMode.d.ts +0 -13
  64. package/dist/DarkMode.js +0 -62
  65. package/dist/DarkMode.js.map +0 -1
  66. package/dist/DateInput.d.ts +0 -13
  67. package/dist/DateInput.js +0 -29
  68. package/dist/DateInput.js.map +0 -1
  69. package/dist/DatePicker.d.ts +0 -11
  70. package/dist/DatePicker.js +0 -34
  71. package/dist/DatePicker.js.map +0 -1
  72. package/dist/DatetimeInput.d.ts +0 -13
  73. package/dist/DatetimeInput.js +0 -31
  74. package/dist/DatetimeInput.js.map +0 -1
  75. package/dist/DesignBook.d.ts +0 -1
  76. package/dist/DesignBook.js +0 -55
  77. package/dist/DesignBook.js.map +0 -1
  78. package/dist/Dialog.d.ts +0 -17
  79. package/dist/Dialog.js +0 -92
  80. package/dist/Dialog.js.map +0 -1
  81. package/dist/Dropdown.d.ts +0 -14
  82. package/dist/Dropdown.js +0 -65
  83. package/dist/Dropdown.js.map +0 -1
  84. package/dist/Emitter.d.ts +0 -6
  85. package/dist/Emitter.js +0 -19
  86. package/dist/Emitter.js.map +0 -1
  87. package/dist/FlexLayout.d.ts +0 -11
  88. package/dist/FlexLayout.js +0 -18
  89. package/dist/FlexLayout.js.map +0 -1
  90. package/dist/Icon.d.ts +0 -12
  91. package/dist/Icon.js +0 -60
  92. package/dist/Icon.js.map +0 -1
  93. package/dist/IconButton.d.ts +0 -11
  94. package/dist/IconButton.js +0 -34
  95. package/dist/IconButton.js.map +0 -1
  96. package/dist/IconLink.d.ts +0 -9
  97. package/dist/IconLink.js +0 -32
  98. package/dist/IconLink.js.map +0 -1
  99. package/dist/IconType.d.ts +0 -1
  100. package/dist/IconType.js +0 -2
  101. package/dist/IconType.js.map +0 -1
  102. package/dist/Interactable.d.ts +0 -50
  103. package/dist/Interactable.js +0 -169
  104. package/dist/Interactable.js.map +0 -1
  105. package/dist/JSSComment.d.ts +0 -10
  106. package/dist/JSSComment.js +0 -52
  107. package/dist/JSSComment.js.map +0 -1
  108. package/dist/Link.d.ts +0 -22
  109. package/dist/Link.js +0 -29
  110. package/dist/Link.js.map +0 -1
  111. package/dist/List.d.ts +0 -15
  112. package/dist/List.js +0 -29
  113. package/dist/List.js.map +0 -1
  114. package/dist/ListButtonItem.d.ts +0 -14
  115. package/dist/ListButtonItem.js +0 -11
  116. package/dist/ListButtonItem.js.map +0 -1
  117. package/dist/ListDivider.d.ts +0 -1
  118. package/dist/ListDivider.js +0 -12
  119. package/dist/ListDivider.js.map +0 -1
  120. package/dist/ListHeaderItem.d.ts +0 -10
  121. package/dist/ListHeaderItem.js +0 -15
  122. package/dist/ListHeaderItem.js.map +0 -1
  123. package/dist/ListItem.d.ts +0 -9
  124. package/dist/ListItem.js +0 -9
  125. package/dist/ListItem.js.map +0 -1
  126. package/dist/ListLinkItem.d.ts +0 -16
  127. package/dist/ListLinkItem.js +0 -11
  128. package/dist/ListLinkItem.js.map +0 -1
  129. package/dist/ListSpacer.d.ts +0 -1
  130. package/dist/ListSpacer.js +0 -13
  131. package/dist/ListSpacer.js.map +0 -1
  132. package/dist/MenuIcon.d.ts +0 -5
  133. package/dist/MenuIcon.js +0 -31
  134. package/dist/MenuIcon.js.map +0 -1
  135. package/dist/NextJSRouter.d.ts +0 -1
  136. package/dist/NextJSRouter.js +0 -37
  137. package/dist/NextJSRouter.js.map +0 -1
  138. package/dist/NextJSRouterState.d.ts +0 -38
  139. package/dist/NextJSRouterState.js +0 -111
  140. package/dist/NextJSRouterState.js.map +0 -1
  141. package/dist/OnVisible.d.ts +0 -5
  142. package/dist/OnVisible.js +0 -28
  143. package/dist/OnVisible.js.map +0 -1
  144. package/dist/Popover.d.ts +0 -22
  145. package/dist/Popover.js +0 -90
  146. package/dist/Popover.js.map +0 -1
  147. package/dist/ProgressBar.d.ts +0 -7
  148. package/dist/ProgressBar.js +0 -42
  149. package/dist/ProgressBar.js.map +0 -1
  150. package/dist/ProgressCircle.d.ts +0 -5
  151. package/dist/ProgressCircle.js +0 -12
  152. package/dist/ProgressCircle.js.map +0 -1
  153. package/dist/Providers.d.ts +0 -9
  154. package/dist/Providers.js +0 -16
  155. package/dist/Providers.js.map +0 -1
  156. package/dist/RangeInput.d.ts +0 -14
  157. package/dist/RangeInput.js +0 -32
  158. package/dist/RangeInput.js.map +0 -1
  159. package/dist/ResultOrError.d.ts +0 -13
  160. package/dist/ResultOrError.js +0 -7
  161. package/dist/ResultOrError.js.map +0 -1
  162. package/dist/RootView.d.ts +0 -5
  163. package/dist/RootView.js +0 -35
  164. package/dist/RootView.js.map +0 -1
  165. package/dist/Row.d.ts +0 -6
  166. package/dist/Row.js +0 -7
  167. package/dist/Row.js.map +0 -1
  168. package/dist/Select.d.ts +0 -9
  169. package/dist/Select.js +0 -17
  170. package/dist/Select.js.map +0 -1
  171. package/dist/StackContext.d.ts +0 -8
  172. package/dist/StackContext.js +0 -25
  173. package/dist/StackContext.js.map +0 -1
  174. package/dist/StaticCheckbox.d.ts +0 -16
  175. package/dist/StaticCheckbox.js +0 -48
  176. package/dist/StaticCheckbox.js.map +0 -1
  177. package/dist/Storage.d.ts +0 -13
  178. package/dist/Storage.js +0 -146
  179. package/dist/Storage.js.map +0 -1
  180. package/dist/Stream.d.ts +0 -9
  181. package/dist/Stream.js +0 -36
  182. package/dist/Stream.js.map +0 -1
  183. package/dist/Sublist.d.ts +0 -12
  184. package/dist/Sublist.js +0 -18
  185. package/dist/Sublist.js.map +0 -1
  186. package/dist/SubmitIconInput.d.ts +0 -8
  187. package/dist/SubmitIconInput.js +0 -25
  188. package/dist/SubmitIconInput.js.map +0 -1
  189. package/dist/Tabs.d.ts +0 -23
  190. package/dist/Tabs.js +0 -39
  191. package/dist/Tabs.js.map +0 -1
  192. package/dist/Text.d.ts +0 -25
  193. package/dist/Text.js +0 -52
  194. package/dist/Text.js.map +0 -1
  195. package/dist/TextArea.d.ts +0 -11
  196. package/dist/TextArea.js +0 -27
  197. package/dist/TextArea.js.map +0 -1
  198. package/dist/TextInput.d.ts +0 -15
  199. package/dist/TextInput.js +0 -61
  200. package/dist/TextInput.js.map +0 -1
  201. package/dist/TextInputWithState.d.ts +0 -8
  202. package/dist/TextInputWithState.js +0 -14
  203. package/dist/TextInputWithState.js.map +0 -1
  204. package/dist/TextPairing.d.ts +0 -21
  205. package/dist/TextPairing.js +0 -26
  206. package/dist/TextPairing.js.map +0 -1
  207. package/dist/TimeInput.d.ts +0 -15
  208. package/dist/TimeInput.js +0 -58
  209. package/dist/TimeInput.js.map +0 -1
  210. package/dist/Tooltip.d.ts +0 -11
  211. package/dist/Tooltip.js +0 -73
  212. package/dist/Tooltip.js.map +0 -1
  213. package/dist/aria.d.ts +0 -8
  214. package/dist/aria.js +0 -42
  215. package/dist/aria.js.map +0 -1
  216. package/dist/guid.d.ts +0 -1
  217. package/dist/guid.js +0 -7
  218. package/dist/guid.js.map +0 -1
  219. package/dist/hash.d.ts +0 -1
  220. package/dist/hash.js +0 -20
  221. package/dist/hash.js.map +0 -1
  222. package/dist/isServer.d.ts +0 -1
  223. package/dist/isServer.js +0 -4
  224. package/dist/isServer.js.map +0 -1
  225. package/dist/jss.d.ts +0 -122
  226. package/dist/jss.js +0 -515
  227. package/dist/jss.js.map +0 -1
  228. package/dist/numberToBase.d.ts +0 -1
  229. package/dist/numberToBase.js +0 -44
  230. package/dist/numberToBase.js.map +0 -1
  231. package/dist/stateMachineContextFactory.d.ts +0 -36
  232. package/dist/stateMachineContextFactory.js +0 -48
  233. package/dist/stateMachineContextFactory.js.map +0 -1
  234. package/dist/useCookie.d.ts +0 -9
  235. package/dist/useCookie.js +0 -67
  236. package/dist/useCookie.js.map +0 -1
  237. package/dist/useKeyboard.d.ts +0 -8
  238. package/dist/useKeyboard.js +0 -26
  239. package/dist/useKeyboard.js.map +0 -1
  240. package/dist/useNavigation.d.ts +0 -5
  241. package/dist/useNavigation.js +0 -79
  242. package/dist/useNavigation.js.map +0 -1
  243. package/dist/usePromise.d.ts +0 -1
  244. package/dist/usePromise.js +0 -12
  245. package/dist/usePromise.js.map +0 -1
  246. package/dist/useRefEffect.d.ts +0 -1
  247. package/dist/useRefEffect.js +0 -15
  248. package/dist/useRefEffect.js.map +0 -1
  249. package/jss-debug-loader.mjs +0 -44
  250. package/next-env.d.ts +0 -6
  251. package/next.config.js +0 -33
  252. package/scripts/embeddings.js +0 -93
  253. package/scripts/openai_embeddings.js +0 -100
  254. package/scripts/publish.js +0 -28
  255. package/scripts/test_embeddings.js +0 -47
  256. package/src/Badge.tsx +0 -36
  257. package/src/BaseButton.tsx +0 -62
  258. package/src/BaseInput.tsx +0 -63
  259. package/src/BaseLink.tsx +0 -80
  260. package/src/BaseList.tsx +0 -26
  261. package/src/BaseListAddOn.tsx +0 -10
  262. package/src/BaseListItem.tsx +0 -119
  263. package/src/BaseView.tsx +0 -57
  264. package/src/Box.tsx +0 -20
  265. package/src/Button.tsx +0 -90
  266. package/src/Calendar.tsx +0 -123
  267. package/src/Card.tsx +0 -30
  268. package/src/Checkbox.tsx +0 -63
  269. package/src/Circle.tsx +0 -24
  270. package/src/Column.tsx +0 -12
  271. package/src/DarkMode.tsx +0 -100
  272. package/src/DateInput.tsx +0 -63
  273. package/src/DatePicker.tsx +0 -67
  274. package/src/DatetimeInput.tsx +0 -64
  275. package/src/DesignBook.tsx +0 -677
  276. package/src/Dialog.tsx +0 -150
  277. package/src/Dropdown.tsx +0 -146
  278. package/src/Emitter.ts +0 -26
  279. package/src/FlexLayout.tsx +0 -53
  280. package/src/Icon.tsx +0 -80
  281. package/src/IconButton.tsx +0 -81
  282. package/src/IconLink.tsx +0 -59
  283. package/src/IconType.ts +0 -787
  284. package/src/Interactable.tsx +0 -210
  285. package/src/JSSComment.tsx +0 -56
  286. package/src/Link.tsx +0 -110
  287. package/src/List.tsx +0 -58
  288. package/src/ListButtonItem.tsx +0 -69
  289. package/src/ListDivider.tsx +0 -13
  290. package/src/ListHeaderItem.tsx +0 -45
  291. package/src/ListItem.tsx +0 -24
  292. package/src/ListLinkItem.tsx +0 -76
  293. package/src/ListSpacer.tsx +0 -14
  294. package/src/MenuIcon.tsx +0 -50
  295. package/src/NextJSRouter.tsx +0 -60
  296. package/src/NextJSRouterState.tsx +0 -154
  297. package/src/OnVisible.tsx +0 -42
  298. package/src/Popover.tsx +0 -145
  299. package/src/ProgressBar.tsx +0 -63
  300. package/src/ProgressCircle.tsx +0 -38
  301. package/src/Providers.tsx +0 -33
  302. package/src/RangeInput.tsx +0 -82
  303. package/src/ResultOrError.ts +0 -15
  304. package/src/RootView.tsx +0 -55
  305. package/src/Row.tsx +0 -12
  306. package/src/Select.tsx +0 -39
  307. package/src/StackContext.tsx +0 -52
  308. package/src/StaticCheckbox.tsx +0 -72
  309. package/src/Storage.tsx +0 -198
  310. package/src/Stream.tsx +0 -50
  311. package/src/Sublist.tsx +0 -61
  312. package/src/SubmitIconInput.tsx +0 -45
  313. package/src/Tabs.tsx +0 -110
  314. package/src/Text.tsx +0 -111
  315. package/src/TextArea.tsx +0 -58
  316. package/src/TextInput.tsx +0 -123
  317. package/src/TextInputWithState.tsx +0 -32
  318. package/src/TextPairing.tsx +0 -115
  319. package/src/TimeInput.tsx +0 -109
  320. package/src/Tooltip.tsx +0 -109
  321. package/src/aria.ts +0 -72
  322. package/src/docs/mdx.tsx +0 -137
  323. package/src/docs/pages.ts +0 -115
  324. package/src/docs/searchIndex.ts +0 -1
  325. package/src/examples/ExampleDialog.tsx +0 -28
  326. package/src/guid.ts +0 -7
  327. package/src/hash.ts +0 -21
  328. package/src/index.ts +0 -68
  329. package/src/isServer.ts +0 -3
  330. package/src/jss.tsx +0 -712
  331. package/src/jsx-dev-runtime.ts +0 -74
  332. package/src/jsx-runtime.ts +0 -2
  333. package/src/numberToBase.ts +0 -52
  334. package/src/pages/Badge.mdx +0 -152
  335. package/src/pages/Button.mdx +0 -163
  336. package/src/pages/Calendar.mdx +0 -254
  337. package/src/pages/Card.mdx +0 -147
  338. package/src/pages/Checkbox.mdx +0 -131
  339. package/src/pages/Dialog.mdx +0 -197
  340. package/src/pages/FlexLayout.mdx +0 -211
  341. package/src/pages/Hashing.mdx +0 -211
  342. package/src/pages/Icon.mdx +0 -171
  343. package/src/pages/IconButton.mdx +0 -155
  344. package/src/pages/Link.mdx +0 -160
  345. package/src/pages/List.mdx +0 -262
  346. package/src/pages/ListHeader.mdx +0 -220
  347. package/src/pages/Popover.mdx +0 -223
  348. package/src/pages/ProgressBar.mdx +0 -200
  349. package/src/pages/ProgressCircle.mdx +0 -218
  350. package/src/pages/RangeInput.mdx +0 -237
  351. package/src/pages/Tabs.mdx +0 -281
  352. package/src/pages/Text.mdx +0 -154
  353. package/src/pages/TextInput.mdx +0 -235
  354. package/src/pages/TextPairing.mdx +0 -204
  355. package/src/pages/TimeInput.mdx +0 -178
  356. package/src/pages/Tooltip.mdx +0 -115
  357. package/src/pages/_app.tsx +0 -466
  358. package/src/pages/_document.tsx +0 -30
  359. package/src/pages/css-in-js.mdx +0 -240
  360. package/src/pages/index.mdx +0 -58
  361. package/src/pages/navigation.mdx +0 -158
  362. package/src/pages/prism.css +0 -3
  363. package/src/pages/useCookie.mdx +0 -176
  364. package/src/pages/useKeyboard.mdx +0 -257
  365. package/src/pages/useNavigation.mdx +0 -258
  366. package/src/pages/usePromise.mdx +0 -280
  367. package/src/pages/useRefEffect.mdx +0 -251
  368. package/src/stateMachineContextFactory.tsx +0 -111
  369. package/src/useCookie.tsx +0 -95
  370. package/src/useKeyboard.tsx +0 -43
  371. package/src/useNavigation.tsx +0 -89
  372. package/src/usePromise.tsx +0 -18
  373. package/src/useRefEffect.tsx +0 -18
  374. package/src/vite-plugin-jss-debug.ts +0 -77
  375. package/tsconfig.build.json +0 -23
  376. package/tsconfig.json +0 -38
@@ -1,211 +0,0 @@
1
- # Hashing and Unique IDs
2
-
3
- Utility functions for generating consistent hashes and converting numbers to different bases. Useful for creating unique identifiers, keys, and compact representations.
4
-
5
- ---
6
-
7
- ## hash
8
-
9
- Generates a numeric hash from a string. The hash is deterministic - the same input always produces the same output.
10
-
11
- ### Signature
12
-
13
- ```ts
14
- function hash(source: string, modulus?: number): number
15
- ```
16
-
17
- ### Parameters
18
-
19
- | Parameter | Type | Default | Description |
20
- |-----------|------|---------|-------------|
21
- | `source` | `string` | Required | The string to hash |
22
- | `modulus` | `number` | - | Optional modulus to constrain the hash range |
23
-
24
- ### Returns
25
-
26
- A non-negative integer hash value.
27
-
28
- ### Basic usage
29
-
30
- ```js
31
- import { hash } from "aidos-ui";
32
-
33
- const id = hash("ABC"); // 64578
34
- const id2 = hash("ABC"); // 64578 (same input = same output)
35
- const id3 = hash("ABCD"); // Different value
36
- ```
37
-
38
- ### With modulus
39
-
40
- Constrain the hash to a specific range:
41
-
42
- ```js
43
- // Hash constrained to 0-9
44
- const small_id = hash("ABC", 10); // 8
45
-
46
- // Hash constrained to 0-99
47
- const medium_id = hash("ABC", 100); // 78
48
-
49
- // Useful for array indices
50
- const colors = ["red", "blue", "green", "yellow"];
51
- const colorIndex = hash("user123", colors.length);
52
- const userColor = colors[colorIndex];
53
- ```
54
-
55
- ### Use cases
56
-
57
- ```js
58
- // Consistent avatar colors
59
- function getUserColor(userId) {
60
- const colors = ["#FF5733", "#33FF57", "#3357FF", "#FF33F5"];
61
- return colors[hash(userId, colors.length)];
62
- }
63
-
64
- // Cache keys
65
- const cacheKey = hash(JSON.stringify(params));
66
-
67
- // Partitioning
68
- const partition = hash(userId, 10); // 0-9
69
- ```
70
-
71
- ---
72
-
73
- ## numberToBase
74
-
75
- Converts a number to a string representation in an arbitrary base using custom characters.
76
-
77
- ### Signature
78
-
79
- ```ts
80
- function numberToBase(
81
- value: number,
82
- alphabet?: string[]
83
- ): string
84
- ```
85
-
86
- ### Parameters
87
-
88
- | Parameter | Type | Default | Description |
89
- |-----------|------|---------|-------------|
90
- | `value` | `number` | Required | The number to convert |
91
- | `alphabet` | `string[]` | `["a"-"z"]` | Characters to use for each digit |
92
-
93
- ### Returns
94
-
95
- A string representation of the number in the given base.
96
-
97
- ### Basic usage
98
-
99
- ```js
100
- import { numberToBase } from "aidos-ui";
101
-
102
- // Default: base-26 using lowercase letters
103
- const id = numberToBase(hash("ABC")); // "cqmv"
104
- const id2 = numberToBase(12345); // "wmt"
105
- ```
106
-
107
- ### Custom bases
108
-
109
- ```js
110
- // Binary (base-2)
111
- numberToBase(8, ["0", "1"]); // "1000"
112
-
113
- // With custom symbols
114
- numberToBase(hash("ABC"), ["?", "!"]); // "!!!!!???!???!?!"
115
-
116
- // Hexadecimal-like
117
- const hex = ["0", "1", "2", "3", "4", "5", "6", "7",
118
- "8", "9", "a", "b", "c", "d", "e", "f"];
119
- numberToBase(255, hex); // "ff"
120
-
121
- // URL-safe characters
122
- const urlSafe = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".split("");
123
- numberToBase(123456789, urlSafe); // Compact URL-safe ID
124
- ```
125
-
126
- ### Combining with hash
127
-
128
- ```js
129
- // Generate compact, unique IDs
130
- function generateId(input) {
131
- return numberToBase(hash(input));
132
- }
133
-
134
- const userId = generateId("user@example.com"); // e.g., "xkcd"
135
- const postId = generateId("blog-post-title"); // e.g., "qwer"
136
- ```
137
-
138
- ---
139
-
140
- ## Common patterns
141
-
142
- ### Unique class names
143
-
144
- ```js
145
- function uniqueClassName(styles) {
146
- const styleString = JSON.stringify(styles);
147
- return `_${numberToBase(hash(styleString))}`;
148
- }
149
-
150
- const className = uniqueClassName({ color: "red" }); // e.g., "_abc"
151
- ```
152
-
153
- ### Consistent randomization
154
-
155
- ```js
156
- // Same input always gives same "random" result
157
- function pseudoRandom(seed, max) {
158
- return hash(seed, max);
159
- }
160
-
161
- // Consistent shuffle based on seed
162
- function seededShuffle(array, seed) {
163
- return array.slice().sort((a, b) => {
164
- return hash(`${seed}-${a}`) - hash(`${seed}-${b}`);
165
- });
166
- }
167
- ```
168
-
169
- ### Short URLs
170
-
171
- ```js
172
- // Convert database IDs to short codes
173
- function toShortCode(numericId) {
174
- const chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".split("");
175
- return numberToBase(numericId, chars);
176
- }
177
-
178
- toShortCode(123456); // e.g., "w7e"
179
- ```
180
-
181
- ### Color from string
182
-
183
- ```js
184
- function stringToColor(str) {
185
- const h = hash(str, 360);
186
- return `hsl(${h}, 70%, 50%)`;
187
- }
188
-
189
- stringToColor("John"); // Consistent color for "John"
190
- stringToColor("Jane"); // Different color for "Jane"
191
- ```
192
-
193
- ---
194
-
195
- ## Algorithm details
196
-
197
- The `hash` function uses a simple but effective string hashing algorithm:
198
- - Iterates through each character
199
- - Combines character codes using bit shifting
200
- - Produces a 32-bit integer hash
201
- - Applies modulus if specified
202
-
203
- This is suitable for:
204
- - Generating consistent keys
205
- - Distributing values evenly
206
- - Creating pseudo-random but reproducible results
207
-
208
- Not suitable for:
209
- - Cryptographic purposes
210
- - Security-sensitive hashing
211
- - Password storage
@@ -1,171 +0,0 @@
1
- import { Icon } from "../Icon";
2
- import { Row } from "../Row";
3
- import { Column } from "../Column";
4
-
5
- # Icon
6
-
7
- The `Icon` component displays vector icons using [Iconify](https://iconify.design/) under the hood, giving you access to 200,000+ icons from 150+ icon sets including Font Awesome, Material Design, and more.
8
-
9
- ---
10
-
11
- ## Props
12
-
13
- | Prop | Type | Required | Description |
14
- |------|------|----------|-------------|
15
- | `icon` | `IconType` | Yes | The icon identifier (e.g., `"fa-check"`, `"fa-github"`) |
16
- | `size` | `Size` | Yes | Icon size: `"xsmall"` (8px), `"small"` (12px), `"medium"` (18px), `"large"` (24px), `"xlarge"` (32px), `"xxlarge"` (48px), `"xxxlarge"` (64px) |
17
- | `color` | `TextColor` | Yes | Icon color: `"primary"`, `"secondary"`, `"highlight"`, `"negative"`, `"subtle"`, `"light"` |
18
- | `ariaLabel` | `string` | No | Accessible label for screen readers |
19
-
20
- ---
21
-
22
- ## Sizes
23
-
24
- Icons come in seven predefined sizes to maintain consistency across your application.
25
-
26
- <Column gap="medium">
27
- <Row justify="space-around" align="center">
28
- <Icon icon="fa-star" color="primary" size="xsmall" />
29
- <Icon icon="fa-star" color="primary" size="small" />
30
- <Icon icon="fa-star" color="primary" size="medium" />
31
- <Icon icon="fa-star" color="primary" size="large" />
32
- <Icon icon="fa-star" color="primary" size="xlarge" />
33
- <Icon icon="fa-star" color="primary" size="xxlarge" />
34
- <Icon icon="fa-star" color="primary" size="xxxlarge" />
35
- </Row>
36
- </Column>
37
-
38
- ```js
39
- <Icon icon="fa-star" color="primary" size="xsmall" /> // 8px
40
- <Icon icon="fa-star" color="primary" size="small" /> // 12px
41
- <Icon icon="fa-star" color="primary" size="medium" /> // 18px
42
- <Icon icon="fa-star" color="primary" size="large" /> // 24px
43
- <Icon icon="fa-star" color="primary" size="xlarge" /> // 32px
44
- <Icon icon="fa-star" color="primary" size="xxlarge" /> // 48px
45
- <Icon icon="fa-star" color="primary" size="xxxlarge" /> // 64px
46
- ```
47
-
48
- ---
49
-
50
- ## Colors
51
-
52
- Icons inherit semantic colors from the theme system, ensuring they adapt correctly to light and dark modes.
53
-
54
- <Column gap="medium">
55
- <Row justify="space-around">
56
- <Icon icon="fa-heart" color="primary" size="large" />
57
- <Icon icon="fa-heart" color="secondary" size="large" />
58
- <Icon icon="fa-heart" color="highlight" size="large" />
59
- <Icon icon="fa-heart" color="negative" size="large" />
60
- <Icon icon="fa-heart" color="subtle" size="large" />
61
- <Icon icon="fa-heart" color="light" size="large" />
62
- </Row>
63
- </Column>
64
-
65
- ```js
66
- <Icon icon="fa-heart" color="primary" size="large" /> // Main content color
67
- <Icon icon="fa-heart" color="secondary" size="large" /> // Secondary content
68
- <Icon icon="fa-heart" color="highlight" size="large" /> // Accent/brand color
69
- <Icon icon="fa-heart" color="negative" size="large" /> // Error/destructive
70
- <Icon icon="fa-heart" color="subtle" size="large" /> // Muted/disabled
71
- <Icon icon="fa-heart" color="light" size="large" /> // Light/inverted
72
- ```
73
-
74
- ---
75
-
76
- ## Icon examples
77
-
78
- A selection of commonly used icons:
79
-
80
- <Column gap="medium">
81
- <Row justify="space-around">
82
- <Icon icon="fa-check" color="primary" size="medium" />
83
- <Icon icon="fa-close" color="negative" size="medium" />
84
- <Icon icon="fa-search" color="secondary" size="medium" />
85
- <Icon icon="fa-user" color="primary" size="medium" />
86
- <Icon icon="fa-cog" color="secondary" size="medium" />
87
- <Icon icon="fa-bell" color="highlight" size="medium" />
88
- </Row>
89
- <Row justify="space-around">
90
- <Icon icon="fa-github" color="primary" size="medium" />
91
- <Icon icon="fa-twitter" color="primary" size="medium" />
92
- <Icon icon="fa-linkedin" color="primary" size="medium" />
93
- <Icon icon="fa-envelope" color="primary" size="medium" />
94
- <Icon icon="fa-phone" color="primary" size="medium" />
95
- <Icon icon="fa-globe" color="primary" size="medium" />
96
- </Row>
97
- </Column>
98
-
99
- ```js
100
- // Action icons
101
- <Icon icon="fa-check" color="primary" size="medium" />
102
- <Icon icon="fa-close" color="negative" size="medium" />
103
- <Icon icon="fa-search" color="secondary" size="medium" />
104
-
105
- // Social icons
106
- <Icon icon="fa-github" color="primary" size="medium" />
107
- <Icon icon="fa-twitter" color="primary" size="medium" />
108
- ```
109
-
110
- ---
111
-
112
- ## Accessibility
113
-
114
- Always provide an `ariaLabel` when the icon conveys meaning that isn't available through surrounding text.
115
-
116
- ```js
117
- // Decorative icon (no label needed if text explains it)
118
- <Button>
119
- <Icon icon="fa-download" color="light" size="small" />
120
- Download
121
- </Button>
122
-
123
- // Meaningful icon (needs label for screen readers)
124
- <Icon
125
- icon="fa-warning"
126
- color="negative"
127
- size="medium"
128
- ariaLabel="Warning"
129
- />
130
- ```
131
-
132
- ---
133
-
134
- ## Preloading icons
135
-
136
- By default, Iconify loads icons asynchronously from a CDN. To prevent flickering on initial render, you can preload icons by bundling them with your application.
137
-
138
- **Option 1: Preload an entire icon set**
139
-
140
- ```bash
141
- npm install @iconify-json/fa
142
- ```
143
-
144
- ```js
145
- import { addCollection } from "@iconify/react";
146
- import faIcons from "@iconify-json/fa/icons.json";
147
-
148
- // Call once at app initialization (e.g., in _app.tsx)
149
- addCollection(faIcons);
150
- ```
151
-
152
- **Option 2: Preload individual icons**
153
-
154
- ```bash
155
- npm install @iconify-icons/fa
156
- ```
157
-
158
- ```js
159
- import { addIcon } from "@iconify/react";
160
- import faCheck from "@iconify-icons/fa/check";
161
- import faClose from "@iconify-icons/fa/close";
162
-
163
- addIcon("fa:check", faCheck);
164
- addIcon("fa:close", faClose);
165
- ```
166
-
167
- ---
168
-
169
- ## Finding icons
170
-
171
- Browse available icons at [Iconify Icon Sets](https://icon-sets.iconify.design/). The component uses Font Awesome 4 icons by default (prefixed with `fa-`), but you can use any Iconify-supported icon set.
@@ -1,155 +0,0 @@
1
- import { IconButton } from "../IconButton";
2
- import { Row } from "../Row";
3
- import { Column } from "../Column";
4
-
5
- # IconButton
6
-
7
- A circular button containing only an icon. Use IconButton for compact actions where space is limited or when the icon alone clearly communicates the action's purpose.
8
-
9
- ---
10
-
11
- ## Props
12
-
13
- | Prop | Type | Required | Default | Description |
14
- |------|------|----------|---------|-------------|
15
- | `icon` | `IconType` | Yes | - | The icon to display |
16
- | `size` | `Size` | Yes | - | Button size: `"xsmall"` (20px), `"small"` (24px), `"medium"` (32px), `"large"` (40px), `"xlarge"` (48px) |
17
- | `color` | `InteractableColor` | Yes | - | `"positive"`, `"secondary"`, `"negative"`, `"dark"`, `"light"` |
18
- | `onClick` | `function` | Yes | - | Click handler |
19
- | `bare` | `boolean` | No | `false` | Removes background for a lighter appearance |
20
- | `border` | `boolean` | No | `false` | Adds a border |
21
- | `disabled` | `boolean` | No | `false` | Disables interaction |
22
- | `aria-label` | `string` | No | - | Accessible label (recommended) |
23
-
24
- ---
25
-
26
- ## Basic variants
27
-
28
- IconButtons come in different colors to indicate their purpose. Always pair with a clear, recognizable icon.
29
-
30
- <Row gap="large" align="center" padding="large" justify="center">
31
- <IconButton size="medium" icon="fa-check" color="positive" onClick={() => {}} />
32
- <IconButton size="medium" icon="fa-pencil" color="secondary" onClick={() => {}} />
33
- <IconButton size="medium" icon="fa-trash" color="negative" onClick={() => {}} />
34
- <IconButton size="medium" icon="fa-check" color="positive" disabled onClick={() => {}} />
35
- </Row>
36
-
37
- ```js
38
- <IconButton
39
- icon="fa-check"
40
- size="medium"
41
- color="positive"
42
- aria-label="Confirm"
43
- onClick={() => {}}
44
- />
45
-
46
- <IconButton
47
- icon="fa-pencil"
48
- size="medium"
49
- color="secondary"
50
- aria-label="Edit"
51
- onClick={() => {}}
52
- />
53
-
54
- <IconButton
55
- icon="fa-trash"
56
- size="medium"
57
- color="negative"
58
- aria-label="Delete"
59
- onClick={() => {}}
60
- />
61
- ```
62
-
63
- ---
64
-
65
- ## Bare variant
66
-
67
- The `bare` variant removes the background, creating a subtle button that works well in toolbars or alongside other content.
68
-
69
- <Row gap="large" align="center" padding="large" justify="center">
70
- <IconButton bare size="medium" icon="fa-check" color="positive" onClick={() => {}} />
71
- <IconButton bare size="medium" icon="fa-pencil" color="secondary" onClick={() => {}} />
72
- <IconButton bare size="medium" icon="fa-trash" color="negative" onClick={() => {}} />
73
- <IconButton bare size="medium" icon="fa-check" color="positive" disabled onClick={() => {}} />
74
- </Row>
75
-
76
- ```js
77
- <IconButton
78
- bare
79
- icon="fa-close"
80
- size="medium"
81
- color="secondary"
82
- aria-label="Close"
83
- onClick={() => {}}
84
- />
85
- ```
86
-
87
- ---
88
-
89
- ## Sizes
90
-
91
- IconButtons scale proportionally, maintaining their circular shape at all sizes.
92
-
93
- <Row gap="large" align="center" padding="large" justify="center">
94
- <IconButton size="xsmall" icon="fa-star" color="positive" onClick={() => {}} />
95
- <IconButton size="small" icon="fa-star" color="positive" onClick={() => {}} />
96
- <IconButton size="medium" icon="fa-star" color="positive" onClick={() => {}} />
97
- <IconButton size="large" icon="fa-star" color="positive" onClick={() => {}} />
98
- <IconButton size="xlarge" icon="fa-star" color="positive" onClick={() => {}} />
99
- </Row>
100
-
101
- ```js
102
- <IconButton size="xsmall" icon="fa-star" color="positive" onClick={() => {}} /> // 20px
103
- <IconButton size="small" icon="fa-star" color="positive" onClick={() => {}} /> // 24px
104
- <IconButton size="medium" icon="fa-star" color="positive" onClick={() => {}} /> // 32px
105
- <IconButton size="large" icon="fa-star" color="positive" onClick={() => {}} /> // 40px
106
- <IconButton size="xlarge" icon="fa-star" color="positive" onClick={() => {}} /> // 48px
107
- ```
108
-
109
- ---
110
-
111
- ## Common use cases
112
-
113
- <Row gap="large" align="center" padding="large" justify="center">
114
- <IconButton bare size="medium" icon="fa-heart" color="negative" aria-label="Like" onClick={() => {}} />
115
- <IconButton bare size="medium" icon="fa-bookmark" color="secondary" aria-label="Save" onClick={() => {}} />
116
- <IconButton bare size="medium" icon="fa-share" color="secondary" aria-label="Share" onClick={() => {}} />
117
- <IconButton bare size="medium" icon="fa-ellipsis-h" color="secondary" aria-label="More options" onClick={() => {}} />
118
- </Row>
119
-
120
- ```js
121
- // Social actions
122
- <IconButton bare icon="fa-heart" size="medium" color="negative" aria-label="Like" onClick={() => {}} />
123
- <IconButton bare icon="fa-bookmark" size="medium" color="secondary" aria-label="Save" onClick={() => {}} />
124
- <IconButton bare icon="fa-share" size="medium" color="secondary" aria-label="Share" onClick={() => {}} />
125
-
126
- // Menu trigger
127
- <IconButton bare icon="fa-ellipsis-h" size="medium" color="secondary" aria-label="More options" onClick={() => {}} />
128
- ```
129
-
130
- ---
131
-
132
- ## Accessibility
133
-
134
- Since IconButtons have no visible text, always provide an `aria-label` to describe the action for screen reader users.
135
-
136
- ```js
137
- // Good - has accessible label
138
- <IconButton
139
- icon="fa-trash"
140
- size="medium"
141
- color="negative"
142
- aria-label="Delete item"
143
- onClick={() => {}}
144
- />
145
-
146
- // Bad - no accessible label
147
- <IconButton
148
- icon="fa-trash"
149
- size="medium"
150
- color="negative"
151
- onClick={() => {}}
152
- />
153
- ```
154
-
155
- Consider using a `Tooltip` component alongside IconButton to provide visual hints for all users.
@@ -1,160 +0,0 @@
1
- import { Link } from "../Link";
2
- import { Row } from "../Row";
3
- import { Column } from "../Column";
4
-
5
- # Link
6
-
7
- The `Link` component provides styled navigation that looks like a button but renders as a semantic `<a>` anchor element. Use it for navigation actions where you want button-like styling.
8
-
9
- ---
10
-
11
- ## Props
12
-
13
- | Prop | Type | Required | Default | Description |
14
- |------|------|----------|---------|-------------|
15
- | `children` | `ReactNode` | Yes | - | Link text content |
16
- | `href` | `string` | Yes | - | Navigation destination URL |
17
- | `color` | `InteractableColor` | Yes | - | `"positive"`, `"primary"`, `"negative"`, `"dark"`, `"light"` |
18
- | `bare` | `boolean` | No | `false` | Removes background for a lighter appearance |
19
- | `border` | `boolean` | No | `false` | Adds a border matching the text color |
20
- | `disabled` | `boolean` | No | `false` | Disables interaction |
21
- | `underline` | `boolean` | No | `false` | Adds text underline decoration |
22
- | `icon` | `IconType` | No | - | Icon to display alongside text |
23
- | `iconPosition` | `"left"` \| `"right"` | No | `"left"` | Icon placement relative to text |
24
- | `iconSize` | `Size` | No | `"medium"` | Icon size |
25
- | `size` | `Size` | No | `"medium"` | Text size |
26
- | `padding` | `Padding` | No | `"medium"` | Internal padding |
27
- | `inline` | `boolean` | No | `true` | Display as inline-flex (true) or flex (false) |
28
- | `bold` | `boolean` | No | `false` | Bold text |
29
- | `target` | `string` | No | - | Link target (e.g., `"_blank"` for new tab) |
30
-
31
- ---
32
-
33
- ## Color variants
34
-
35
- Links share the same color system as buttons, providing visual consistency across your application.
36
-
37
- <Row gap="large" align="center" padding="large" justify="center">
38
- <Link color="positive" href="/">Positive</Link>
39
- <Link color="primary" href="/">Primary</Link>
40
- <Link color="negative" href="/">Negative</Link>
41
- <Link color="dark" href="/">Dark</Link>
42
- <Link color="light" href="/">Light</Link>
43
- </Row>
44
-
45
- ```js
46
- <Link color="positive" href="/signup">Sign up</Link>
47
- <Link color="primary" href="/learn-more">Learn more</Link>
48
- <Link color="negative" href="/delete">Delete account</Link>
49
- ```
50
-
51
- ---
52
-
53
- ## Bare variant
54
-
55
- The `bare` prop creates a lighter appearance without a background, ideal for inline links or secondary navigation.
56
-
57
- <Row gap="large" align="center" padding="large" justify="center">
58
- <Link bare color="positive" href="/">Positive</Link>
59
- <Link bare color="primary" href="/">Primary</Link>
60
- <Link bare color="negative" href="/">Negative</Link>
61
- </Row>
62
-
63
- ```js
64
- <Link bare color="positive" href="/docs">Documentation</Link>
65
- <Link bare color="primary" href="/about">About us</Link>
66
- ```
67
-
68
- ---
69
-
70
- ## With border
71
-
72
- Combine `bare` and `border` for outlined link styles.
73
-
74
- <Row gap="large" align="center" padding="large" justify="center">
75
- <Link border bare color="positive" href="/">Positive</Link>
76
- <Link border bare color="primary" href="/">Primary</Link>
77
- <Link border bare color="negative" href="/">Negative</Link>
78
- </Row>
79
-
80
- ```js
81
- <Link border bare color="positive" href="/signup">
82
- Get started
83
- </Link>
84
- ```
85
-
86
- ---
87
-
88
- ## With underline
89
-
90
- The `underline` prop adds a text decoration, useful for traditional link styling within paragraphs.
91
-
92
- <Row gap="large" align="center" padding="large" justify="center">
93
- <Link bare underline color="positive" href="/">Learn more</Link>
94
- <Link bare underline color="primary" href="/">Read docs</Link>
95
- </Row>
96
-
97
- ```js
98
- <Link bare underline color="positive" href="/docs">
99
- Learn more
100
- </Link>
101
- ```
102
-
103
- ---
104
-
105
- ## With icon
106
-
107
- Add icons to reinforce the link's purpose or indicate external navigation.
108
-
109
- <Row gap="large" align="center" padding="large" justify="center">
110
- <Link color="positive" icon="fa-external-link" iconPosition="right" href="/" target="_blank">External</Link>
111
- <Link color="primary" icon="fa-download" href="/">Download</Link>
112
- <Link bare color="primary" icon="fa-arrow-left" href="/">Back</Link>
113
- </Row>
114
-
115
- ```js
116
- <Link
117
- color="positive"
118
- icon="fa-external-link"
119
- iconPosition="right"
120
- href="https://example.com"
121
- target="_blank"
122
- >
123
- External link
124
- </Link>
125
-
126
- <Link color="primary" icon="fa-download" href="/file.pdf">
127
- Download PDF
128
- </Link>
129
- ```
130
-
131
- ---
132
-
133
- ## Disabled state
134
-
135
- Disabled links prevent navigation and display a muted appearance.
136
-
137
- <Row gap="large" align="center" padding="large" justify="center">
138
- <Link color="positive" disabled href="/">Disabled</Link>
139
- <Link bare color="positive" disabled href="/">Disabled bare</Link>
140
- </Row>
141
-
142
- ```js
143
- <Link color="positive" disabled href="/premium">
144
- Premium only
145
- </Link>
146
- ```
147
-
148
- ---
149
-
150
- ## Link vs Button
151
-
152
- Use `Link` when:
153
- - The action navigates to a new page or URL
154
- - You want the browser's native link behaviors (right-click, cmd+click)
155
- - SEO matters for the destination
156
-
157
- Use `Button` when:
158
- - The action triggers an in-page operation
159
- - No navigation occurs
160
- - Form submissions