@koide-labs/ui 0.0.0 → 0.0.2

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 (383) hide show
  1. package/README.md +53 -3
  2. package/{src/-types.ts → dist/-types.d.ts} +1 -6
  3. package/dist/-types.js +1 -0
  4. package/dist/-utils.d.ts +19 -0
  5. package/dist/-utils.js +33 -0
  6. package/dist/Button-DrPFFzo7.js +31 -0
  7. package/dist/CompositeRoot-CVk5a-pR.js +233 -0
  8. package/dist/DirectionContext-C2o_MF_i.js +9 -0
  9. package/dist/FieldItemContext-DAvk99to.js +11 -0
  10. package/dist/FloatingPortal-tWyuKRSN.js +435 -0
  11. package/dist/FloatingPortalLite-DVyq6YhV.js +28 -0
  12. package/dist/InternalBackdrop-jYAiOJ8v.js +574 -0
  13. package/dist/LabelableContext-BMvjVwor.js +169 -0
  14. package/dist/ToolbarRootContext-CvvL0Tk1.js +9 -0
  15. package/dist/clamp-D0KDAQIz.js +6 -0
  16. package/dist/clsx-OuTLNxxd.js +16 -0
  17. package/dist/components/accordion/index.d.ts +12 -0
  18. package/dist/components/accordion/index.js +699 -0
  19. package/dist/components/alert-dialog/index.d.ts +26 -0
  20. package/dist/components/alert-dialog/index.js +136 -0
  21. package/dist/components/anchor/index.d.ts +8 -0
  22. package/dist/components/anchor/index.js +38 -0
  23. package/dist/components/avatar/index.d.ts +21 -0
  24. package/dist/components/avatar/index.js +161 -0
  25. package/dist/components/badge/index.d.ts +16 -0
  26. package/dist/components/badge/index.js +40 -0
  27. package/dist/components/button/index.d.ts +24 -0
  28. package/dist/components/button/index.js +47 -0
  29. package/dist/components/checkbox/index.d.ts +9 -0
  30. package/dist/components/checkbox/index.js +269 -0
  31. package/dist/components/code/index.d.ts +9 -0
  32. package/dist/components/code/index.js +10 -0
  33. package/dist/components/collapse/index.d.ts +11 -0
  34. package/dist/components/collapse/index.js +41 -0
  35. package/dist/components/command/index.d.ts +14 -0
  36. package/dist/components/command/index.js +1695 -0
  37. package/dist/components/context-menu/index.d.ts +42 -0
  38. package/dist/components/context-menu/index.js +1444 -0
  39. package/dist/components/dialog/index.d.ts +48 -0
  40. package/dist/components/dialog/index.js +138 -0
  41. package/dist/components/heading/index.d.ts +44 -0
  42. package/dist/components/heading/index.js +56 -0
  43. package/dist/components/icon/icon-names.d.ts +1 -0
  44. package/dist/components/icon/icon-names.js +1 -0
  45. package/dist/components/icon/index.d.ts +24 -0
  46. package/dist/components/icon/index.js +43 -0
  47. package/dist/components/icon-button/index.d.ts +12 -0
  48. package/dist/components/icon-button/index.js +45 -0
  49. package/dist/components/inline-code/index.d.ts +6 -0
  50. package/dist/components/inline-code/index.js +22 -0
  51. package/dist/components/input/index.d.ts +3 -0
  52. package/dist/components/input/index.js +119 -0
  53. package/dist/components/meter/index.d.ts +18 -0
  54. package/dist/components/meter/index.js +165 -0
  55. package/dist/components/multiline-input/index.d.ts +6 -0
  56. package/dist/components/multiline-input/index.js +100 -0
  57. package/dist/components/number-input/index.d.ts +10 -0
  58. package/dist/components/number-input/index.js +1169 -0
  59. package/dist/components/password-input/index.d.ts +2 -0
  60. package/dist/components/password-input/index.js +29 -0
  61. package/dist/components/pill/index.d.ts +13 -0
  62. package/dist/components/pill/index.js +38 -0
  63. package/dist/components/popover/index.d.ts +21 -0
  64. package/dist/components/popover/index.js +636 -0
  65. package/dist/components/preview-card/index.d.ts +17 -0
  66. package/dist/components/preview-card/index.js +402 -0
  67. package/dist/components/radio/index.d.ts +13 -0
  68. package/dist/components/radio/index.js +404 -0
  69. package/dist/components/search-bar/index.d.ts +12 -0
  70. package/dist/components/search-bar/index.js +48 -0
  71. package/dist/components/select/index.d.ts +16 -0
  72. package/dist/components/select/index.js +1263 -0
  73. package/dist/components/separator/index.d.ts +7 -0
  74. package/dist/components/separator/index.js +6 -0
  75. package/dist/components/slider/index.d.ts +5 -0
  76. package/dist/components/slider/index.js +902 -0
  77. package/dist/components/spinner/index.d.ts +2 -0
  78. package/dist/components/spinner/index.js +13 -0
  79. package/dist/components/stacked-avatars/index.d.ts +14 -0
  80. package/dist/components/stacked-avatars/index.js +92 -0
  81. package/dist/components/status-banner/index.d.ts +17 -0
  82. package/dist/components/status-banner/index.js +69 -0
  83. package/dist/components/surface/index.d.ts +27 -0
  84. package/dist/components/surface/index.js +41 -0
  85. package/dist/components/switch/index.d.ts +5 -0
  86. package/dist/components/switch/index.js +196 -0
  87. package/dist/components/tabs/index.d.ts +18 -0
  88. package/dist/components/tabs/index.js +509 -0
  89. package/dist/components/text/index.d.ts +26 -0
  90. package/dist/components/text/index.js +51 -0
  91. package/dist/components/theme-provider/index.d.ts +2 -0
  92. package/dist/components/theme-provider/index.js +6 -0
  93. package/dist/components/theme-provider/theme-context.d.ts +9 -0
  94. package/dist/components/theme-provider/theme-context.js +13 -0
  95. package/dist/components/theme-provider/theme-provider.d.ts +17 -0
  96. package/dist/components/theme-provider/theme-provider.js +30 -0
  97. package/dist/components/timestamp/index.d.ts +23 -0
  98. package/dist/components/timestamp/index.js +1392 -0
  99. package/dist/components/toast/index.d.ts +2 -0
  100. package/dist/components/toast/index.js +7 -0
  101. package/dist/components/toast/toast.d.ts +2 -0
  102. package/dist/components/toast/toast.js +878 -0
  103. package/dist/components/toast/use-toast-manager.d.ts +27 -0
  104. package/dist/components/toast/use-toast-manager.js +4 -0
  105. package/dist/components/tooltip/index.d.ts +14 -0
  106. package/dist/components/tooltip/index.js +712 -0
  107. package/dist/components/tooltip/tooltip-arrow.d.ts +3 -0
  108. package/dist/components/tooltip/tooltip-arrow.js +6 -0
  109. package/dist/components/view/index.d.ts +30 -0
  110. package/dist/components/view/index.js +84 -0
  111. package/dist/components/visually-hidden/index.d.ts +1 -0
  112. package/dist/components/visually-hidden/index.js +4 -0
  113. package/dist/composite-Bx7Szd_T.js +208 -0
  114. package/dist/composite-C9L5QmZL.js +66 -0
  115. package/dist/createBaseUIEventDetails-D8M2Yl-a.js +59 -0
  116. package/dist/detectBrowser-I-s3yzIE.js +43 -0
  117. package/dist/dialog.css +1 -0
  118. package/dist/dialog.module-BeF-6XAo.js +415 -0
  119. package/dist/element-CZEOj04G.js +80 -0
  120. package/dist/event-CKoGyQEJ.js +30 -0
  121. package/dist/floating-ui.utils-C7pRWMZ_.js +128 -0
  122. package/dist/floating-ui.utils.dom-C7FS5id0.js +135 -0
  123. package/dist/formatErrorMessage-BqPuTBN-.js +7 -0
  124. package/dist/formatNumber-1UNwjeqf.js +25 -0
  125. package/dist/getDisabledMountTransitionStyles-YfHPge6T.js +1510 -0
  126. package/dist/index-BX1XbbRk.js +1206 -0
  127. package/dist/index-CeuccO-T.js +109 -0
  128. package/dist/index-DN9Bn1qm.js +29 -0
  129. package/dist/index-FMoPxlJ2.js +52 -0
  130. package/dist/index.css +1 -0
  131. package/dist/index.d.ts +42 -0
  132. package/dist/index.js +108 -0
  133. package/dist/index10.css +1 -0
  134. package/dist/index11.css +1 -0
  135. package/dist/index12.css +1 -0
  136. package/dist/index13.css +1 -0
  137. package/dist/index14.css +1 -0
  138. package/dist/index15.css +1 -0
  139. package/dist/index16.css +1 -0
  140. package/dist/index17.css +1 -0
  141. package/dist/index18.css +1 -0
  142. package/dist/index19.css +1 -0
  143. package/dist/index2.css +1 -0
  144. package/dist/index20.css +1 -0
  145. package/dist/index21.css +1 -0
  146. package/dist/index22.css +1 -0
  147. package/dist/index23.css +1 -0
  148. package/dist/index24.css +1 -0
  149. package/dist/index25.css +1 -0
  150. package/dist/index26.css +1 -0
  151. package/dist/index27.css +1 -0
  152. package/dist/index28.css +1 -0
  153. package/dist/index29.css +1 -0
  154. package/dist/index3.css +1 -0
  155. package/dist/index30.css +1 -0
  156. package/dist/index31.css +1 -0
  157. package/dist/index32.css +1 -0
  158. package/dist/index33.css +1 -0
  159. package/dist/index34.css +1 -0
  160. package/dist/index35.css +1 -0
  161. package/dist/index36.css +1 -0
  162. package/dist/index37.css +1 -0
  163. package/dist/index4.css +1 -0
  164. package/dist/index5.css +1 -0
  165. package/dist/index6.css +1 -0
  166. package/dist/index7.css +1 -0
  167. package/dist/index8.css +1 -0
  168. package/dist/index9.css +1 -0
  169. package/dist/inertValue-BCYGsdmf.js +7 -0
  170. package/dist/input.css +1 -0
  171. package/dist/input.module-DDQY_Ij6.js +7 -0
  172. package/dist/integrations/react-markdown/index.d.ts +5 -0
  173. package/dist/integrations/react-markdown/index.js +6895 -0
  174. package/dist/integrations/remix/index.d.ts +9 -0
  175. package/{src/integrations/remix.ts → dist/integrations/remix/index.js} +7 -4
  176. package/dist/integrations/tailwind.css +1 -0
  177. package/dist/integrations/twemoij/index.d.ts +3 -0
  178. package/dist/integrations/twemoij/index.js +18 -0
  179. package/dist/isElementDisabled-Cbd8W9kH.js +6 -0
  180. package/dist/owner-rKN292Q9.js +6 -0
  181. package/dist/safePolygon-DWy1dGKJ.js +308 -0
  182. package/dist/styles/core.css +1 -0
  183. package/dist/styles/tokens.d.ts +400 -0
  184. package/{src/styles/tokens.ts → dist/styles/tokens.js} +54 -96
  185. package/dist/toast.css +1 -0
  186. package/dist/tooltip-arrow-C1qXdi5T.js +24 -0
  187. package/dist/tooltip-arrow.css +1 -0
  188. package/dist/transitions.css +1 -0
  189. package/dist/transitions.module-CWX8e5cx.js +1343 -0
  190. package/dist/use-toast-manager-Dq-44AuW.js +37 -0
  191. package/dist/useAnimationFrame-451ugS_6.js +68 -0
  192. package/dist/useBaseUiId-B7WyxtIE.js +7 -0
  193. package/dist/useButton-DfIwsdb8.js +127 -0
  194. package/dist/useCompositeListItem-OkcAim_1.js +148 -0
  195. package/dist/useControlled-Du4sJyMj.js +31 -0
  196. package/dist/useHoverReferenceInteraction-SfOBPoXM.js +264 -0
  197. package/dist/useId-C5kyn6tA.js +22 -0
  198. package/dist/useIsoLayoutEffect-CIDbvm3Q.js +6 -0
  199. package/dist/useLabelableId-Ci_jDvmv.js +29 -0
  200. package/dist/useOnMount-VRW6CK2u.js +8 -0
  201. package/dist/useOpenChangeComplete-Dse9kY9E.js +61 -0
  202. package/dist/usePopupAutoResize-CNR6Ekmx.js +85 -0
  203. package/dist/useRender-CLx7dR_1.js +7 -0
  204. package/dist/useRenderElement-DwToLA61.js +244 -0
  205. package/dist/useRole-oDBdbuwQ.js +77 -0
  206. package/dist/useStableCallback-CkTrVkNX.js +29 -0
  207. package/dist/useSyncedFloatingRootContext-Dorsv-jf.js +167 -0
  208. package/dist/useTimeout-CflX-kz3.js +32 -0
  209. package/dist/useTransitionStatus-CUfcuGAV.js +42 -0
  210. package/dist/useTypeahead-D85V2IUx.js +333 -0
  211. package/dist/useValueAsRef-HURLzret.js +19 -0
  212. package/dist/useValueChanged-DL757-yD.js +14 -0
  213. package/dist/valueToPercent-DaP9qN4u.js +6 -0
  214. package/dist/view.css +1 -0
  215. package/dist/view.module-DfDLgJE0.js +6 -0
  216. package/dist/visuallyHidden-CpJ-mhai.js +16 -0
  217. package/dist/warn-CKtX8MLJ.js +11 -0
  218. package/package.json +18 -2
  219. package/.husky/pre-commit +0 -1
  220. package/.storybook/main.ts +0 -25
  221. package/.storybook/preview-head.html +0 -6
  222. package/.storybook/preview.tsx +0 -48
  223. package/.storybook/vitest.setup.ts +0 -8
  224. package/eslint.config.mjs +0 -29
  225. package/lint-staged.config.js +0 -15
  226. package/pnpm-workspace.yaml +0 -2
  227. package/postcss.config.mjs +0 -7
  228. package/prettier.config.mjs +0 -24
  229. package/scripts/build-icon-types.ts +0 -38
  230. package/src/-utils.tsx +0 -64
  231. package/src/components/accordion/accordion.module.css +0 -44
  232. package/src/components/accordion/accordion.stories.tsx +0 -36
  233. package/src/components/accordion/index.tsx +0 -67
  234. package/src/components/alert-dialog/alert-dialog.module.css +0 -5
  235. package/src/components/alert-dialog/alert-dialog.stories.tsx +0 -53
  236. package/src/components/alert-dialog/index.tsx +0 -138
  237. package/src/components/anchor/anchor.module.css +0 -18
  238. package/src/components/anchor/anchor.stories.tsx +0 -28
  239. package/src/components/anchor/index.tsx +0 -45
  240. package/src/components/avatar/avatar.module.css +0 -56
  241. package/src/components/avatar/avatar.stories.tsx +0 -61
  242. package/src/components/avatar/index.tsx +0 -82
  243. package/src/components/badge/badge.module.css +0 -35
  244. package/src/components/badge/badge.stories.tsx +0 -60
  245. package/src/components/badge/index.tsx +0 -71
  246. package/src/components/button/button.module.css +0 -42
  247. package/src/components/button/button.stories.tsx +0 -108
  248. package/src/components/button/index.tsx +0 -63
  249. package/src/components/checkbox/checkbox.module.css +0 -36
  250. package/src/components/checkbox/checkbox.stories.tsx +0 -21
  251. package/src/components/checkbox/index.tsx +0 -41
  252. package/src/components/code/code.module.css +0 -20
  253. package/src/components/code/code.stories.tsx +0 -42
  254. package/src/components/code/index.tsx +0 -73
  255. package/src/components/collapse/collapse.module.css +0 -27
  256. package/src/components/collapse/collapse.stories.tsx +0 -27
  257. package/src/components/collapse/index.tsx +0 -59
  258. package/src/components/command/command.module.css +0 -95
  259. package/src/components/command/command.stories.tsx +0 -38
  260. package/src/components/command/index.tsx +0 -108
  261. package/src/components/context-menu/context-menu.module.css +0 -36
  262. package/src/components/context-menu/context-menu.stories.tsx +0 -99
  263. package/src/components/context-menu/index.tsx +0 -242
  264. package/src/components/dialog/dialog.module.css +0 -71
  265. package/src/components/dialog/dialog.stories.tsx +0 -29
  266. package/src/components/dialog/index.tsx +0 -148
  267. package/src/components/heading/heading.module.css +0 -3
  268. package/src/components/heading/heading.stories.tsx +0 -52
  269. package/src/components/heading/index.tsx +0 -112
  270. package/src/components/icon/icon-names.ts +0 -3189
  271. package/src/components/icon/icon.module.css +0 -36
  272. package/src/components/icon/icon.stories.tsx +0 -40
  273. package/src/components/icon/index.tsx +0 -60
  274. package/src/components/icon-button/icon-button.module.css +0 -33
  275. package/src/components/icon-button/icon-button.stories.tsx +0 -59
  276. package/src/components/icon-button/index.tsx +0 -48
  277. package/src/components/inline-code/index.tsx +0 -29
  278. package/src/components/inline-code/inline-code.module.css +0 -13
  279. package/src/components/inline-code/inline-code.stories.tsx +0 -31
  280. package/src/components/input/index.tsx +0 -22
  281. package/src/components/input/input.module.css +0 -23
  282. package/src/components/input/input.stories.tsx +0 -52
  283. package/src/components/meter/index.tsx +0 -55
  284. package/src/components/meter/meter.module.css +0 -23
  285. package/src/components/meter/meter.stories.tsx +0 -31
  286. package/src/components/multiline-input/index.tsx +0 -58
  287. package/src/components/multiline-input/multiline-input.stories.tsx +0 -26
  288. package/src/components/number-input/index.tsx +0 -74
  289. package/src/components/number-input/number-input.module.css +0 -41
  290. package/src/components/number-input/number-input.stories.tsx +0 -24
  291. package/src/components/password-input/index.tsx +0 -24
  292. package/src/components/password-input/password-input.module.css +0 -10
  293. package/src/components/password-input/password-input.stories.tsx +0 -24
  294. package/src/components/pill/index.tsx +0 -45
  295. package/src/components/pill/pill.module.css +0 -22
  296. package/src/components/pill/pill.stories.tsx +0 -83
  297. package/src/components/popover/index.tsx +0 -94
  298. package/src/components/popover/popover.module.css +0 -8
  299. package/src/components/popover/popover.stories.tsx +0 -53
  300. package/src/components/preview-card/index.tsx +0 -68
  301. package/src/components/preview-card/preview-card.module.css +0 -5
  302. package/src/components/preview-card/preview-card.stories.tsx +0 -58
  303. package/src/components/radio/index.tsx +0 -67
  304. package/src/components/radio/radio-group.module.css +0 -5
  305. package/src/components/radio/radio.module.css +0 -36
  306. package/src/components/radio/radio.stories.tsx +0 -27
  307. package/src/components/search-bar/index.tsx +0 -60
  308. package/src/components/search-bar/search-bar.module.css +0 -29
  309. package/src/components/search-bar/search-bar.stories.tsx +0 -37
  310. package/src/components/select/index.tsx +0 -132
  311. package/src/components/select/select.module.css +0 -63
  312. package/src/components/select/select.stories.tsx +0 -49
  313. package/src/components/separator/index.tsx +0 -28
  314. package/src/components/separator/separator.module.css +0 -24
  315. package/src/components/separator/separator.stories.tsx +0 -40
  316. package/src/components/slider/index.tsx +0 -28
  317. package/src/components/slider/slider.module.css +0 -52
  318. package/src/components/slider/slider.stories.tsx +0 -53
  319. package/src/components/spinner/index.tsx +0 -14
  320. package/src/components/spinner/spinner.module.css +0 -13
  321. package/src/components/spinner/spinner.stories.tsx +0 -17
  322. package/src/components/stacked-avatars/index.tsx +0 -88
  323. package/src/components/stacked-avatars/stacked-avatars.module.css +0 -79
  324. package/src/components/stacked-avatars/stacked-avatars.stories.tsx +0 -48
  325. package/src/components/status-banner/index.tsx +0 -96
  326. package/src/components/status-banner/status-banner.module.css +0 -52
  327. package/src/components/status-banner/status-banner.stories.tsx +0 -44
  328. package/src/components/surface/index.tsx +0 -83
  329. package/src/components/surface/surface.module.css +0 -35
  330. package/src/components/surface/surface.stories.tsx +0 -84
  331. package/src/components/switch/index.tsx +0 -23
  332. package/src/components/switch/switch.module.css +0 -45
  333. package/src/components/switch/switch.stories.tsx +0 -48
  334. package/src/components/tabs/index.tsx +0 -126
  335. package/src/components/tabs/tabs.module.css +0 -134
  336. package/src/components/tabs/tabs.stories.tsx +0 -88
  337. package/src/components/text/index.tsx +0 -69
  338. package/src/components/text/text.module.css +0 -76
  339. package/src/components/text/text.stories.tsx +0 -107
  340. package/src/components/theme-provider/index.ts +0 -2
  341. package/src/components/theme-provider/theme-context.tsx +0 -18
  342. package/src/components/theme-provider/theme-provider.stories.tsx +0 -47
  343. package/src/components/theme-provider/theme-provider.tsx +0 -77
  344. package/src/components/timestamp/index.tsx +0 -131
  345. package/src/components/timestamp/timestamp.module.css +0 -8
  346. package/src/components/timestamp/timestamp.stories.tsx +0 -37
  347. package/src/components/toast/index.ts +0 -2
  348. package/src/components/toast/toast.module.css +0 -163
  349. package/src/components/toast/toast.stories.tsx +0 -53
  350. package/src/components/toast/toast.tsx +0 -104
  351. package/src/components/toast/use-toast-manager.ts +0 -63
  352. package/src/components/tooltip/index.tsx +0 -61
  353. package/src/components/tooltip/tooltip-arrow.tsx +0 -17
  354. package/src/components/tooltip/tooltip.module.css +0 -44
  355. package/src/components/tooltip/tooltip.stories.tsx +0 -76
  356. package/src/components/view/index.tsx +0 -137
  357. package/src/components/view/view.module.css +0 -11
  358. package/src/components/view/view.stories.tsx +0 -131
  359. package/src/components/view/view_colorway.module.css +0 -280
  360. package/src/components/view/view_interactive.module.css +0 -127
  361. package/src/components/view/view_loading.module.css +0 -58
  362. package/src/components/visually-hidden/index.ts +0 -1
  363. package/src/index.ts +0 -49
  364. package/src/integrations/react-markdown/index.tsx +0 -134
  365. package/src/integrations/react-markdown/react-markdown.module.css +0 -62
  366. package/src/integrations/react-markdown/react-markdown.stories.tsx +0 -31
  367. package/src/integrations/tailwind.css +0 -173
  368. package/src/integrations/twemoij/index.tsx +0 -13
  369. package/src/integrations/twemoij/twemoji.module.css +0 -7
  370. package/src/integrations/twemoij/twemoji.stories.tsx +0 -40
  371. package/src/stories/components/all-variants.tsx +0 -40
  372. package/src/stories/data.ts +0 -72
  373. package/src/stories/utils.ts +0 -20
  374. package/src/styles/core.css +0 -153
  375. package/src/styles/themes/dark.css +0 -86
  376. package/src/styles/themes/light.css +0 -86
  377. package/src/styles/transitions.module.css +0 -31
  378. package/stylelint.config.mjs +0 -29
  379. package/tsconfig.app.json +0 -35
  380. package/tsconfig.json +0 -7
  381. package/tsconfig.node.json +0 -26
  382. package/vite.config.ts +0 -103
  383. package/vitest.shims.d.ts +0 -1
@@ -1,18 +0,0 @@
1
- .anchor {
2
- cursor: pointer;
3
- color: var(--primary-stronger);
4
- font-weight: var(--font-weight-regular);
5
- font-size: var(--font-size-default);
6
- line-height: var(--line-height-default);
7
- text-decoration: underline;
8
-
9
- &:visited {
10
- color: var(--blurple-stronger);
11
- }
12
- }
13
-
14
- .anchor__icon {
15
- /* you got me. a magic number in a sea of tokens. */
16
- vertical-align: -5%;
17
- margin-left: var(--space-2);
18
- }
@@ -1,28 +0,0 @@
1
- import type { Meta, StoryObj } from "@storybook/react-vite";
2
-
3
- import { tokens } from "~/styles/tokens";
4
-
5
- import { Anchor } from ".";
6
- import { Surface } from "../surface";
7
- import { Text } from "../text";
8
-
9
- const meta = {
10
- title: "Anchor",
11
- component: Anchor,
12
- parameters: { layout: "centered" },
13
- } satisfies Meta<typeof Anchor>;
14
-
15
- export default meta;
16
-
17
- type Story = StoryObj<typeof meta>;
18
-
19
- export const Default: Story = {
20
- args: { href: "https://npham.dev", external: true },
21
- render: (props) => (
22
- <Surface elevated style={{ padding: tokens.space16 }}>
23
- <Text>
24
- Visit my amazing <Anchor {...props}>portfolio</Anchor> or perish.
25
- </Text>
26
- </Surface>
27
- ),
28
- };
@@ -1,45 +0,0 @@
1
- import { mergeProps, useRender } from "@base-ui/react";
2
-
3
- import { Icon } from "../icon";
4
-
5
- import styles from "./anchor.module.css";
6
-
7
- export type AnchorProps = useRender.ComponentProps<"a"> & {
8
- /**
9
- * Open this link in a new tab
10
- */
11
- external?: boolean;
12
- };
13
-
14
- export function Anchor({ external, render, children, ...props }: AnchorProps) {
15
- const element = useRender({
16
- defaultTagName: "a",
17
- render,
18
- props: mergeProps(
19
- {
20
- className: styles["anchor"],
21
- ...(external
22
- ? {
23
- target: "_blank",
24
- rel: "noreferrer",
25
- }
26
- : {}),
27
- children: (
28
- <>
29
- {children}
30
- {external ? (
31
- <Icon
32
- name="external-link-line"
33
- size="sm"
34
- className={styles["anchor__icon"]}
35
- />
36
- ) : null}
37
- </>
38
- ),
39
- },
40
- props,
41
- ),
42
- });
43
-
44
- return element;
45
- }
@@ -1,56 +0,0 @@
1
- .avatar {
2
- display: flex;
3
- position: relative;
4
- flex-shrink: 0;
5
- border-width: 1px;
6
- border-style: solid;
7
- border-color: var(--outline-dimmest);
8
- border-radius: var(--border-radius-round);
9
- background-color: var(--background-highest);
10
- width: var(--avatar-size);
11
- height: var(--avatar-size);
12
- overflow: hidden;
13
- }
14
-
15
- .avatar__image {
16
- width: 100%;
17
- height: 100%;
18
- object-fit: cover;
19
- }
20
-
21
- .avatar__fallback {
22
- display: flex;
23
- flex: 1 1 0%;
24
- justify-content: center;
25
- align-items: center;
26
- border-radius: var(--border-radius-round);
27
- width: 100%;
28
- height: 100%;
29
- color: var(--foreground-dimmest);
30
- font-size: calc(var(--avatar-size) / 2.5);
31
- }
32
-
33
- /* Avatar size variants */
34
- .avatar_size_sm {
35
- --avatar-size: var(--space-24);
36
- }
37
-
38
- .avatar_size_md {
39
- --avatar-size: var(--space-32);
40
- }
41
-
42
- .avatar_size_lg {
43
- --avatar-size: var(--space-40);
44
- }
45
-
46
- .avatar_size_xl {
47
- --avatar-size: var(--space-48);
48
- }
49
-
50
- .avatar_size_2xl {
51
- --avatar-size: var(--space-56);
52
- }
53
-
54
- .avatar_size_3xl {
55
- --avatar-size: var(--space-64);
56
- }
@@ -1,61 +0,0 @@
1
- import type { Meta, StoryObj } from "@storybook/react-vite";
2
-
3
- import { AllVariants } from "~/stories/components/all-variants";
4
- import { sizes } from "~/stories/data";
5
-
6
- import { Avatar } from ".";
7
-
8
- const meta = {
9
- title: "Avatar",
10
- component: Avatar,
11
- parameters: { layout: "centered" },
12
- argTypes: {
13
- size: {
14
- control: "select",
15
- options: sizes,
16
- },
17
- },
18
- } satisfies Meta<typeof Avatar>;
19
-
20
- export default meta;
21
-
22
- type Story = StoryObj<typeof meta>;
23
-
24
- export const Default: Story = {
25
- args: {
26
- image: "https://avatars.githubusercontent.com/u/146884027?v=4",
27
- username: "npham-dev",
28
- size: "md",
29
- },
30
- render: (props) => <Avatar {...props} />,
31
- };
32
-
33
- export const Fallback: Story = {
34
- args: {
35
- username: "npham-dev",
36
- size: "md",
37
- },
38
- render: (props) => <Avatar {...props} />,
39
- };
40
-
41
- export const AllSizes: Story = {
42
- args: {
43
- image: "https://avatars.githubusercontent.com/u/146884027?v=4",
44
- username: "npham-dev",
45
- },
46
- argTypes: {
47
- size: {
48
- control: false,
49
- },
50
- },
51
- render: (props) => (
52
- <AllVariants
53
- variantName="size"
54
- variants={sizes}
55
- element={<Avatar {...props} />}
56
- style={{
57
- flexDirection: "row",
58
- }}
59
- />
60
- ),
61
- };
@@ -1,82 +0,0 @@
1
- import { Avatar as AvatarPrimitive } from "@base-ui/react/avatar";
2
- import clsx from "clsx";
3
-
4
- import type { Size } from "~/styles/tokens";
5
-
6
- import styles from "./avatar.module.css";
7
-
8
- export interface AvatarProps extends AvatarPrimitive.Root.Props {
9
- /**
10
- * Avatar url; if not provided, uses fallback based on username or fullName.
11
- */
12
- image?: string | null;
13
-
14
- /**
15
- * Used for initials if avatar image is not provided.
16
- */
17
- username: string;
18
-
19
- /**
20
- * User's first & last name. Used for initials, takes precedence over username.
21
- */
22
- fullName?: string;
23
-
24
- /**
25
- * Size of the avatar, defaults to "md".
26
- */
27
- size?: Size;
28
- }
29
-
30
- export function Avatar({
31
- image,
32
- username,
33
- fullName,
34
- size = "md",
35
- className,
36
- ...props
37
- }: AvatarProps) {
38
- const fallback = getAvatarFallback(username, fullName);
39
- return (
40
- <AvatarPrimitive.Root
41
- className={clsx(
42
- styles["avatar"],
43
- styles[`avatar_size_${size}`],
44
- className,
45
- )}
46
- {...props}
47
- >
48
- {image ? (
49
- <AvatarPrimitive.Image
50
- src={image}
51
- className={styles["avatar__image"]}
52
- />
53
- ) : null}
54
- <AvatarPrimitive.Fallback className={styles["avatar__fallback"]}>
55
- {fallback}
56
- </AvatarPrimitive.Fallback>
57
- </AvatarPrimitive.Root>
58
- );
59
- }
60
-
61
- /**
62
- * Create 2 letter avatar fallback (depending on what is provided) \
63
- * Prioritizes full name over usernmae
64
- * @param username user selected name
65
- * @param fullName real name of the user
66
- * @returns 2 letter, uppercase avatar fallback
67
- */
68
- function getAvatarFallback(username: string, fullName?: string) {
69
- let fallback = username.substring(0, 2);
70
-
71
- if (fullName) {
72
- // if full name w/ lastName is provided, use first and last initials
73
- // otherwise use first two letters of the name
74
- const [firstName, lastName] = fullName.split(" ");
75
- fallback =
76
- firstName && lastName
77
- ? firstName.charAt(0) + lastName.charAt(0)
78
- : fullName.substring(0, 2);
79
- }
80
-
81
- return fallback.toLocaleUpperCase();
82
- }
@@ -1,35 +0,0 @@
1
- .badge {
2
- display: inline-flex;
3
- align-items: center;
4
- gap: var(--space-4);
5
- cursor: default;
6
- border-radius: var(--border-radius-16);
7
- background-color: var(--view-colorway-dimmer);
8
- padding: var(--space-4) var(--space-8);
9
- height: var(--space-24);
10
- color: var(--view-colorway-strongest);
11
- font-size: var(--font-size-small);
12
- line-height: 1;
13
- white-space: nowrap;
14
- }
15
-
16
- .badge_shiny {
17
- display: inline-flex;
18
- flex-direction: row;
19
- align-items: center;
20
- transition: none;
21
- background-image: radial-gradient(
22
- circle at top left,
23
- var(--view-colorway-dimmest) 34%,
24
- var(--view-colorway-dimmer) 50%,
25
- var(--view-colorway-dimmest) 66%
26
- );
27
- background-position: left;
28
- background-size: 300% 100%;
29
-
30
- &:hover {
31
- transition: background-position 600ms
32
- var(--transition-timing-function-chill);
33
- background-position: right;
34
- }
35
- }
@@ -1,60 +0,0 @@
1
- import type { Meta, StoryObj } from "@storybook/react-vite";
2
-
3
- import { colors } from "~/stories/data";
4
- import { disable } from "~/stories/utils";
5
- import { tokens } from "~/styles/tokens";
6
-
7
- import { Badge } from ".";
8
- import { View } from "../view";
9
-
10
- const meta = {
11
- title: "Badge",
12
- component: Badge,
13
- parameters: { layout: "centered" },
14
- argTypes: {
15
- color: {
16
- control: "select",
17
- options: colors,
18
- },
19
- },
20
- } satisfies Meta<typeof Badge>;
21
-
22
- export default meta;
23
-
24
- type Story = StoryObj<typeof meta>;
25
-
26
- export const Default: Story = {
27
- args: {
28
- color: "orange",
29
- icon: "sparkling-line",
30
- name: "Pro",
31
- shiny: true,
32
- },
33
- render: (args) => <Badge {...args} />,
34
- };
35
-
36
- export const ExampleBadges: Story = {
37
- argTypes: {
38
- ...disable(["icon", "name", "color", "shiny", "tagline"]),
39
- },
40
- args: {
41
- name: "",
42
- color: "primary",
43
- },
44
- render: () => (
45
- <View
46
- style={{
47
- flexDirection: "row",
48
- flexWrap: "wrap",
49
- gap: tokens.space8,
50
- maxWidth: tokens.space256,
51
- }}
52
- >
53
- <Badge name="Admin" color="yellow" />
54
- <Badge name="Detective" color="green" />
55
- <Badge icon="checkbox-circle-line" name="Verified" color="green" />
56
- <Badge name="Language Jammer" color="purple" />
57
- <Badge name="Community Monitor" color="teal" />
58
- </View>
59
- ),
60
- };
@@ -1,71 +0,0 @@
1
- import { mergeProps, useRender } from "@base-ui/react";
2
- import { clsx } from "clsx";
3
-
4
- import { Icon } from "../icon";
5
- import type { IconName } from "../icon/icon-names";
6
- import { Text } from "../text";
7
- import { Tooltip } from "../tooltip";
8
- import { View, type Color } from "../view";
9
-
10
- import styles from "./badge.module.css";
11
-
12
- export interface BadgeProps extends Omit<
13
- useRender.ComponentProps<"span">,
14
- "children"
15
- > {
16
- /** Optional icon, goes before name */
17
- icon?: IconName;
18
-
19
- /** Name of badge to be displayed, goes after icon */
20
- name: string;
21
-
22
- /** Communicate purpose with color. Defaults to "primary". */
23
- color?: Color;
24
-
25
- /** Add shiny hover effect. */
26
- shiny?: boolean;
27
-
28
- /** Tagline of badge. */
29
- tagline?: string;
30
- }
31
-
32
- export function Badge({
33
- icon,
34
- name,
35
- color,
36
- shiny,
37
- tagline,
38
- render,
39
- ...props
40
- }: BadgeProps) {
41
- const element = useRender({
42
- defaultTagName: "span",
43
- render,
44
- props: mergeProps(
45
- {
46
- className: clsx(styles["badge"], shiny && styles["badge_shiny"]),
47
- children: (
48
- <>
49
- {icon ? <Icon name={icon} /> : null}
50
- {name}
51
- </>
52
- ),
53
- },
54
- props,
55
- ),
56
- });
57
-
58
- const label = <View color={color}>{element}</View>;
59
-
60
- if (!tagline) {
61
- return label;
62
- }
63
-
64
- return (
65
- <Tooltip trigger={label}>
66
- <Text size="sm" multiline>
67
- {tagline}
68
- </Text>
69
- </Tooltip>
70
- );
71
- }
@@ -1,42 +0,0 @@
1
- .button {
2
- display: flex;
3
- flex-direction: row;
4
- justify-content: center;
5
- align-items: center;
6
- gap: var(--space-8);
7
- box-sizing: border-box;
8
- border-radius: var(--border-radius-default);
9
- padding-inline: var(--button-padding-inline);
10
- height: var(--button-height);
11
- white-space: nowrap;
12
- }
13
-
14
- .button_height_sm {
15
- --button-padding-inline: var(--space-12);
16
- --button-height: var(--space-28);
17
- }
18
-
19
- .button_height_md {
20
- --button-padding-inline: var(--space-16);
21
- --button-height: var(--space-32);
22
- }
23
-
24
- .button_height_lg {
25
- --button-padding-inline: var(--space-20);
26
- --button-height: var(--space-40);
27
- }
28
-
29
- .button_height_xl {
30
- --button-padding-inline: var(--space-24);
31
- --button-height: var(--space-48);
32
- }
33
-
34
- .button_height_2xl {
35
- --button-padding-inline: var(--space-28);
36
- --button-height: var(--space-56);
37
- }
38
-
39
- .button_height_3xl {
40
- --button-padding-inline: var(--space-32);
41
- --button-height: var(--space-64);
42
- }
@@ -1,108 +0,0 @@
1
- import type { Meta, StoryObj } from "@storybook/react-vite";
2
-
3
- import { AllVariants } from "~/stories/components/all-variants";
4
- import { colorVariants, sizes } from "~/stories/data";
5
- import { tokens } from "~/styles/tokens";
6
-
7
- import { Button } from ".";
8
- import { Surface } from "../surface";
9
- import { Text } from "../text";
10
- import { View } from "../view";
11
-
12
- const meta = {
13
- title: "Button",
14
- component: Button,
15
- parameters: { layout: "centered" },
16
- argTypes: {
17
- size: {
18
- control: "select",
19
- options: sizes,
20
- },
21
- loading: {
22
- control: "boolean",
23
- },
24
- },
25
- } satisfies Meta<typeof Button>;
26
-
27
- export default meta;
28
-
29
- type Story = StoryObj<typeof meta>;
30
-
31
- export const Default: Story = {
32
- args: {
33
- interactive: "primary_fill",
34
- leftIcon: "square-line",
35
- },
36
- render: (props) => <Button {...props}>Hello World</Button>,
37
- };
38
-
39
- export const Link: Story = {
40
- args: {
41
- size: "md",
42
- leftIcon: "external-link-line",
43
- interactive: "primary_fill",
44
- loading: false,
45
- },
46
- render: (args) => (
47
- <Button
48
- {...args}
49
- render={<a href="https://natmfat.com" target="_blank" rel="noreferrer" />}
50
- nativeButton={false}
51
- >
52
- Open Website
53
- </Button>
54
- ),
55
- };
56
-
57
- export const AllSizes: Story = {
58
- args: {
59
- interactive: "fill",
60
- leftIcon: "square-line",
61
- },
62
- render: (args) => (
63
- <AllVariants
64
- variantName="size"
65
- variants={sizes}
66
- element={
67
- <Button style={{ width: "fit-content" }} {...args}>
68
- Hello World
69
- </Button>
70
- }
71
- />
72
- ),
73
- };
74
-
75
- <Surface elevated style={{ gap: tokens.space16, padding: tokens.space16 }}>
76
- {colorVariants.map((variant) => (
77
- <View key={variant} style={{ gap: tokens.space2 }}>
78
- <Text color="dimmest">{variant}</Text>
79
- </View>
80
- ))}
81
- </Surface>;
82
-
83
- export const AllPrimaryVariants: Story = {
84
- argTypes: {
85
- interactive: {
86
- table: {
87
- disable: true,
88
- },
89
- },
90
- },
91
- args: {
92
- size: "md",
93
- leftIcon: "square-line",
94
- loading: false,
95
- disabled: false,
96
- },
97
- render: (args) => (
98
- <AllVariants
99
- variantName="interactive"
100
- variants={colorVariants.map((variant) => `primary_${variant}`)}
101
- element={
102
- <Button style={{ width: "fit-content" }} {...args}>
103
- Hello World
104
- </Button>
105
- }
106
- />
107
- ),
108
- };
@@ -1,63 +0,0 @@
1
- import { Button as ButtonPrimitive } from "@base-ui/react/button";
2
- import clsx from "clsx";
3
- import type { ComponentProps } from "react";
4
-
5
- import { textify } from "~/-utils";
6
- import type { Size } from "~/styles/tokens";
7
-
8
- import { Icon } from "../icon";
9
- import type { IconName } from "../icon/icon-names";
10
- import { View, type ViewProps } from "../view";
11
-
12
- import styles from "./button.module.css";
13
-
14
- export type ButtonProps = ComponentProps<"button"> &
15
- ViewProps<"button"> & {
16
- /**
17
- * Size of the button
18
- */
19
- size?: Size;
20
-
21
- /**
22
- * Icon to display on the left side of the button content
23
- */
24
- leftIcon?: IconName;
25
-
26
- /**
27
- * Icon to display on the right side of the button content
28
- */
29
- rightIcon?: IconName;
30
-
31
- /**
32
- * The button can remain keyboard accessible while being rendered as another tag
33
- * {@link https://base-ui.com/react/components/button}
34
- */
35
- nativeButton?: boolean;
36
- };
37
-
38
- export function Button({
39
- size = "md",
40
- leftIcon,
41
- rightIcon,
42
- children,
43
- render,
44
- ...props
45
- }: ButtonProps) {
46
- return (
47
- <View<"button">
48
- interactive={true}
49
- render={
50
- <ButtonPrimitive
51
- className={clsx(styles["button"], styles[`button_height_${size}`])}
52
- focusableWhenDisabled={!!props.loading}
53
- render={render}
54
- />
55
- }
56
- {...props}
57
- >
58
- {leftIcon ? <Icon name={leftIcon} size={size} /> : null}
59
- {textify(children, { size, color: "inherit" })}
60
- {rightIcon ? <Icon name={rightIcon} size={size} /> : null}
61
- </View>
62
- );
63
- }