@shipfox/react-ui 0.2.0 → 0.4.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 (323) hide show
  1. package/.storybook/preview.tsx +1 -1
  2. package/.turbo/turbo-build.log +2 -2
  3. package/.turbo/turbo-check.log +3 -3
  4. package/.turbo/turbo-type.log +1 -1
  5. package/CHANGELOG.md +17 -0
  6. package/dist/components/alert/alert.d.ts +18 -0
  7. package/dist/components/alert/alert.d.ts.map +1 -0
  8. package/dist/components/alert/alert.js +123 -0
  9. package/dist/components/alert/alert.js.map +1 -0
  10. package/dist/components/alert/alert.stories.js +112 -0
  11. package/dist/components/alert/alert.stories.js.map +1 -0
  12. package/dist/components/alert/index.d.ts +2 -0
  13. package/dist/components/alert/index.d.ts.map +1 -0
  14. package/dist/components/alert/index.js +3 -0
  15. package/dist/components/alert/index.js.map +1 -0
  16. package/dist/components/avatar/avatar-group.d.ts +18 -0
  17. package/dist/components/avatar/avatar-group.d.ts.map +1 -0
  18. package/dist/components/avatar/avatar-group.js +132 -0
  19. package/dist/components/avatar/avatar-group.js.map +1 -0
  20. package/dist/components/avatar/avatar.d.ts +24 -0
  21. package/dist/components/avatar/avatar.d.ts.map +1 -0
  22. package/dist/components/avatar/avatar.js +165 -0
  23. package/dist/components/avatar/avatar.js.map +1 -0
  24. package/dist/components/avatar/avatar.stories.js +267 -0
  25. package/dist/components/avatar/avatar.stories.js.map +1 -0
  26. package/dist/components/avatar/index.d.ts +3 -0
  27. package/dist/components/avatar/index.d.ts.map +1 -0
  28. package/dist/components/avatar/index.js +4 -0
  29. package/dist/components/avatar/index.js.map +1 -0
  30. package/dist/components/badge/badge.d.ts +48 -0
  31. package/dist/components/badge/badge.d.ts.map +1 -0
  32. package/dist/components/badge/badge.js +72 -0
  33. package/dist/components/badge/badge.js.map +1 -0
  34. package/dist/components/badge/badge.stories.js +802 -0
  35. package/dist/components/badge/badge.stories.js.map +1 -0
  36. package/dist/components/badge/icon-badge.d.ts +9 -0
  37. package/dist/components/badge/icon-badge.d.ts.map +1 -0
  38. package/dist/components/badge/icon-badge.js +32 -0
  39. package/dist/components/badge/icon-badge.js.map +1 -0
  40. package/dist/components/badge/index.d.ts +5 -0
  41. package/dist/components/badge/index.d.ts.map +1 -0
  42. package/dist/components/badge/index.js +6 -0
  43. package/dist/components/badge/index.js.map +1 -0
  44. package/dist/components/badge/status-badge.d.ts +9 -0
  45. package/dist/components/badge/status-badge.d.ts.map +1 -0
  46. package/dist/components/badge/status-badge.js +29 -0
  47. package/dist/components/badge/status-badge.js.map +1 -0
  48. package/dist/components/badge/user-badge.d.ts +8 -0
  49. package/dist/components/badge/user-badge.d.ts.map +1 -0
  50. package/dist/components/badge/user-badge.js +24 -0
  51. package/dist/components/badge/user-badge.js.map +1 -0
  52. package/dist/components/{button.d.ts → button/button.d.ts} +1 -1
  53. package/dist/components/button/button.d.ts.map +1 -0
  54. package/dist/components/{button.js → button/button.js} +2 -2
  55. package/dist/components/button/button.js.map +1 -0
  56. package/dist/components/{button.stories.js → button/button.stories.js} +1 -1
  57. package/dist/components/button/button.stories.js.map +1 -0
  58. package/dist/components/button/index.d.ts +2 -0
  59. package/dist/components/button/index.d.ts.map +1 -0
  60. package/dist/components/button/index.js +3 -0
  61. package/dist/components/button/index.js.map +1 -0
  62. package/dist/components/checkbox/checkbox-label.d.ts +14 -0
  63. package/dist/components/checkbox/checkbox-label.d.ts.map +1 -0
  64. package/dist/components/checkbox/checkbox-label.js +82 -0
  65. package/dist/components/checkbox/checkbox-label.js.map +1 -0
  66. package/dist/components/checkbox/checkbox-links.d.ts +18 -0
  67. package/dist/components/checkbox/checkbox-links.d.ts.map +1 -0
  68. package/dist/components/checkbox/checkbox-links.js +58 -0
  69. package/dist/components/checkbox/checkbox-links.js.map +1 -0
  70. package/dist/components/checkbox/checkbox.d.ts +9 -0
  71. package/dist/components/checkbox/checkbox.d.ts.map +1 -0
  72. package/dist/components/checkbox/checkbox.js +49 -0
  73. package/dist/components/checkbox/checkbox.js.map +1 -0
  74. package/dist/components/checkbox/checkbox.stories.js +566 -0
  75. package/dist/components/checkbox/checkbox.stories.js.map +1 -0
  76. package/dist/components/checkbox/index.d.ts +4 -0
  77. package/dist/components/checkbox/index.d.ts.map +1 -0
  78. package/dist/components/checkbox/index.js +5 -0
  79. package/dist/components/checkbox/index.js.map +1 -0
  80. package/dist/components/code-block/code-block-footer.d.ts +26 -0
  81. package/dist/components/code-block/code-block-footer.d.ts.map +1 -0
  82. package/dist/components/code-block/code-block-footer.js +86 -0
  83. package/dist/components/code-block/code-block-footer.js.map +1 -0
  84. package/dist/components/code-block/code-block.d.ts +50 -0
  85. package/dist/components/code-block/code-block.d.ts.map +1 -0
  86. package/dist/components/code-block/code-block.js +142 -0
  87. package/dist/components/code-block/code-block.js.map +1 -0
  88. package/dist/components/code-block/code-block.stories.js +341 -0
  89. package/dist/components/code-block/code-block.stories.js.map +1 -0
  90. package/dist/components/code-block/code-content.d.ts +11 -0
  91. package/dist/components/code-block/code-content.d.ts.map +1 -0
  92. package/dist/components/code-block/code-content.js +29 -0
  93. package/dist/components/code-block/code-content.js.map +1 -0
  94. package/dist/components/code-block/code-copy-button.d.ts +11 -0
  95. package/dist/components/code-block/code-copy-button.d.ts.map +1 -0
  96. package/dist/components/code-block/code-copy-button.js +49 -0
  97. package/dist/components/code-block/code-copy-button.js.map +1 -0
  98. package/dist/components/code-block/code-tabs.d.ts +16 -0
  99. package/dist/components/code-block/code-tabs.d.ts.map +1 -0
  100. package/dist/components/code-block/code-tabs.js +98 -0
  101. package/dist/components/code-block/code-tabs.js.map +1 -0
  102. package/dist/components/code-block/index.d.ts +4 -0
  103. package/dist/components/code-block/index.d.ts.map +1 -0
  104. package/dist/components/code-block/index.js +5 -0
  105. package/dist/components/code-block/index.js.map +1 -0
  106. package/dist/components/dynamic-item/dynamic-item.d.ts +13 -0
  107. package/dist/components/dynamic-item/dynamic-item.d.ts.map +1 -0
  108. package/dist/components/dynamic-item/dynamic-item.js +43 -0
  109. package/dist/components/dynamic-item/dynamic-item.js.map +1 -0
  110. package/dist/components/dynamic-item/dynamic-item.stories.js +375 -0
  111. package/dist/components/dynamic-item/dynamic-item.stories.js.map +1 -0
  112. package/dist/components/dynamic-item/index.d.ts +2 -0
  113. package/dist/components/dynamic-item/index.d.ts.map +1 -0
  114. package/dist/components/dynamic-item/index.js +3 -0
  115. package/dist/components/dynamic-item/index.js.map +1 -0
  116. package/dist/components/icon/custom/index.d.ts +3 -0
  117. package/dist/components/icon/custom/index.d.ts.map +1 -1
  118. package/dist/components/icon/custom/index.js +3 -0
  119. package/dist/components/icon/custom/index.js.map +1 -1
  120. package/dist/components/icon/custom/shipfox-logo.d.ts +8 -0
  121. package/dist/components/icon/custom/shipfox-logo.d.ts.map +1 -0
  122. package/dist/components/icon/custom/shipfox-logo.js +22 -0
  123. package/dist/components/icon/custom/shipfox-logo.js.map +1 -0
  124. package/dist/components/icon/custom/slack-logo.d.ts +6 -0
  125. package/dist/components/icon/custom/slack-logo.d.ts.map +1 -0
  126. package/dist/components/icon/custom/slack-logo.js +34 -0
  127. package/dist/components/icon/custom/slack-logo.js.map +1 -0
  128. package/dist/components/icon/custom/stripe-logo.d.ts +8 -0
  129. package/dist/components/icon/custom/stripe-logo.d.ts.map +1 -0
  130. package/dist/components/icon/custom/stripe-logo.js +24 -0
  131. package/dist/components/icon/custom/stripe-logo.js.map +1 -0
  132. package/dist/components/icon/icon.d.ts +13 -1
  133. package/dist/components/icon/icon.d.ts.map +1 -1
  134. package/dist/components/icon/icon.js +15 -3
  135. package/dist/components/icon/icon.js.map +1 -1
  136. package/dist/components/icon/icon.stories.js +6 -3
  137. package/dist/components/icon/icon.stories.js.map +1 -1
  138. package/dist/components/index.d.ts +12 -1
  139. package/dist/components/index.d.ts.map +1 -1
  140. package/dist/components/index.js +13 -2
  141. package/dist/components/index.js.map +1 -1
  142. package/dist/components/inline-tips/index.d.ts +2 -0
  143. package/dist/components/inline-tips/index.d.ts.map +1 -0
  144. package/dist/components/inline-tips/index.js +3 -0
  145. package/dist/components/inline-tips/index.js.map +1 -0
  146. package/dist/components/inline-tips/inline-tips.d.ts +19 -0
  147. package/dist/components/inline-tips/inline-tips.d.ts.map +1 -0
  148. package/dist/components/inline-tips/inline-tips.js +98 -0
  149. package/dist/components/inline-tips/inline-tips.js.map +1 -0
  150. package/dist/components/inline-tips/inline-tips.stories.js +214 -0
  151. package/dist/components/inline-tips/inline-tips.stories.js.map +1 -0
  152. package/dist/components/input/index.d.ts +2 -0
  153. package/dist/components/input/index.d.ts.map +1 -0
  154. package/dist/components/input/index.js +3 -0
  155. package/dist/components/input/index.js.map +1 -0
  156. package/dist/components/input/input.d.ts.map +1 -0
  157. package/dist/components/{input.js → input/input.js} +2 -2
  158. package/dist/components/input/input.js.map +1 -0
  159. package/dist/components/{input.stories.js → input/input.stories.js} +1 -1
  160. package/dist/components/input/input.stories.js.map +1 -0
  161. package/dist/components/item/index.d.ts +2 -0
  162. package/dist/components/item/index.d.ts.map +1 -0
  163. package/dist/components/item/index.js +3 -0
  164. package/dist/components/item/index.js.map +1 -0
  165. package/dist/components/item/item.d.ts +32 -0
  166. package/dist/components/item/item.d.ts.map +1 -0
  167. package/dist/components/item/item.js +120 -0
  168. package/dist/components/item/item.js.map +1 -0
  169. package/dist/components/item/item.stories.js +232 -0
  170. package/dist/components/item/item.stories.js.map +1 -0
  171. package/dist/components/label/index.d.ts +2 -0
  172. package/dist/components/label/index.d.ts.map +1 -0
  173. package/dist/components/label/index.js +3 -0
  174. package/dist/components/label/index.js.map +1 -0
  175. package/dist/components/label/label.d.ts +7 -0
  176. package/dist/components/label/label.d.ts.map +1 -0
  177. package/dist/components/label/label.js +13 -0
  178. package/dist/components/label/label.js.map +1 -0
  179. package/dist/components/label/label.stories.js +105 -0
  180. package/dist/components/label/label.stories.js.map +1 -0
  181. package/dist/components/moving-border/moving-border.d.ts +9 -0
  182. package/dist/components/moving-border/moving-border.d.ts.map +1 -0
  183. package/dist/components/moving-border/moving-border.js +54 -0
  184. package/dist/components/moving-border/moving-border.js.map +1 -0
  185. package/dist/components/textarea/textarea.js +1 -1
  186. package/dist/components/textarea/textarea.js.map +1 -1
  187. package/dist/components/theme/index.d.ts +2 -0
  188. package/dist/components/theme/index.d.ts.map +1 -0
  189. package/dist/components/theme/index.js +3 -0
  190. package/dist/components/theme/index.js.map +1 -0
  191. package/dist/components/{theme-provider.d.ts → theme/theme-provider.d.ts} +1 -1
  192. package/dist/components/theme/theme-provider.d.ts.map +1 -0
  193. package/dist/components/{theme-provider.js → theme/theme-provider.js} +1 -1
  194. package/dist/components/theme/theme-provider.js.map +1 -0
  195. package/dist/components/toast/index.d.ts +3 -0
  196. package/dist/components/toast/index.d.ts.map +1 -0
  197. package/dist/components/toast/index.js +4 -0
  198. package/dist/components/toast/index.js.map +1 -0
  199. package/dist/components/toast/toast-custom.d.ts +19 -0
  200. package/dist/components/toast/toast-custom.d.ts.map +1 -0
  201. package/dist/components/toast/toast-custom.js +134 -0
  202. package/dist/components/toast/toast-custom.js.map +1 -0
  203. package/dist/components/toast/toast.d.ts +5 -0
  204. package/dist/components/toast/toast.d.ts.map +1 -0
  205. package/dist/components/toast/toast.js +40 -0
  206. package/dist/components/toast/toast.js.map +1 -0
  207. package/dist/components/toast/toast.stories.js +326 -0
  208. package/dist/components/toast/toast.stories.js.map +1 -0
  209. package/dist/components/tooltip/index.d.ts +2 -0
  210. package/dist/components/tooltip/index.d.ts.map +1 -0
  211. package/dist/components/tooltip/index.js +3 -0
  212. package/dist/components/tooltip/index.js.map +1 -0
  213. package/dist/components/tooltip/tooltip.d.ts +20 -0
  214. package/dist/components/tooltip/tooltip.d.ts.map +1 -0
  215. package/dist/components/tooltip/tooltip.js +98 -0
  216. package/dist/components/tooltip/tooltip.js.map +1 -0
  217. package/dist/components/tooltip/tooltip.stories.js +560 -0
  218. package/dist/components/tooltip/tooltip.stories.js.map +1 -0
  219. package/dist/hooks/index.d.ts +3 -0
  220. package/dist/hooks/index.d.ts.map +1 -1
  221. package/dist/hooks/index.js +3 -0
  222. package/dist/hooks/index.js.map +1 -1
  223. package/dist/hooks/useResolvedTheme.d.ts +2 -0
  224. package/dist/hooks/useResolvedTheme.d.ts.map +1 -0
  225. package/dist/hooks/useResolvedTheme.js +24 -0
  226. package/dist/hooks/useResolvedTheme.js.map +1 -0
  227. package/dist/hooks/useShikiHighlight.d.ts +28 -0
  228. package/dist/hooks/useShikiHighlight.d.ts.map +1 -0
  229. package/dist/hooks/useShikiHighlight.js +106 -0
  230. package/dist/hooks/useShikiHighlight.js.map +1 -0
  231. package/dist/hooks/useShikiStyleInjection.d.ts +2 -0
  232. package/dist/hooks/useShikiStyleInjection.d.ts.map +1 -0
  233. package/dist/hooks/useShikiStyleInjection.js +34 -0
  234. package/dist/hooks/useShikiStyleInjection.js.map +1 -0
  235. package/dist/utils/avatar.d.ts +3 -0
  236. package/dist/utils/avatar.d.ts.map +1 -0
  237. package/dist/utils/avatar.js +32 -0
  238. package/dist/utils/avatar.js.map +1 -0
  239. package/dist/utils/index.d.ts +1 -0
  240. package/dist/utils/index.d.ts.map +1 -1
  241. package/dist/utils/index.js +1 -0
  242. package/dist/utils/index.js.map +1 -1
  243. package/index.css +130 -7
  244. package/package.json +7 -4
  245. package/src/assets/illustration-1.svg +92 -0
  246. package/src/assets/illustration-2.svg +14 -0
  247. package/src/assets/illustration-gradient.svg +7049 -0
  248. package/src/components/alert/alert.stories.tsx +77 -0
  249. package/src/components/alert/alert.tsx +144 -0
  250. package/src/components/alert/index.ts +1 -0
  251. package/src/components/avatar/avatar-group.tsx +186 -0
  252. package/src/components/avatar/avatar.stories.tsx +179 -0
  253. package/src/components/avatar/avatar.tsx +219 -0
  254. package/src/components/avatar/index.ts +2 -0
  255. package/src/components/badge/badge.stories.tsx +468 -0
  256. package/src/components/badge/badge.tsx +147 -0
  257. package/src/components/badge/icon-badge.tsx +43 -0
  258. package/src/components/badge/index.ts +4 -0
  259. package/src/components/badge/status-badge.tsx +43 -0
  260. package/src/components/badge/user-badge.tsx +34 -0
  261. package/src/components/{button.tsx → button/button.tsx} +1 -1
  262. package/src/components/button/index.ts +1 -0
  263. package/src/components/checkbox/checkbox-label.tsx +125 -0
  264. package/src/components/checkbox/checkbox-links.tsx +90 -0
  265. package/src/components/checkbox/checkbox.stories.tsx +375 -0
  266. package/src/components/checkbox/checkbox.tsx +71 -0
  267. package/src/components/checkbox/index.ts +3 -0
  268. package/src/components/code-block/code-block-footer.tsx +173 -0
  269. package/src/components/code-block/code-block.stories.tsx +323 -0
  270. package/src/components/code-block/code-block.tsx +283 -0
  271. package/src/components/code-block/code-content.tsx +60 -0
  272. package/src/components/code-block/code-copy-button.tsx +73 -0
  273. package/src/components/code-block/code-tabs.tsx +170 -0
  274. package/src/components/code-block/index.ts +3 -0
  275. package/src/components/dynamic-item/dynamic-item.stories.tsx +261 -0
  276. package/src/components/dynamic-item/dynamic-item.tsx +68 -0
  277. package/src/components/dynamic-item/index.ts +1 -0
  278. package/src/components/icon/custom/index.ts +3 -0
  279. package/src/components/icon/custom/shipfox-logo.tsx +20 -0
  280. package/src/components/icon/custom/slack-logo.tsx +35 -0
  281. package/src/components/icon/custom/stripe-logo.tsx +27 -0
  282. package/src/components/icon/icon.stories.tsx +3 -1
  283. package/src/components/icon/icon.tsx +29 -1
  284. package/src/components/index.ts +12 -1
  285. package/src/components/inline-tips/index.ts +1 -0
  286. package/src/components/inline-tips/inline-tips.stories.tsx +126 -0
  287. package/src/components/inline-tips/inline-tips.tsx +132 -0
  288. package/src/components/input/index.ts +1 -0
  289. package/src/components/{input.tsx → input/input.tsx} +1 -1
  290. package/src/components/item/index.ts +1 -0
  291. package/src/components/item/item.stories.tsx +150 -0
  292. package/src/components/item/item.tsx +182 -0
  293. package/src/components/label/index.ts +1 -0
  294. package/src/components/label/label.stories.tsx +67 -0
  295. package/src/components/label/label.tsx +15 -0
  296. package/src/components/moving-border/moving-border.tsx +67 -0
  297. package/src/components/textarea/textarea.tsx +1 -1
  298. package/src/components/theme/index.ts +1 -0
  299. package/src/components/toast/index.ts +2 -0
  300. package/src/components/toast/toast-custom.tsx +154 -0
  301. package/src/components/toast/toast.stories.tsx +369 -0
  302. package/src/components/toast/toast.tsx +41 -0
  303. package/src/components/tooltip/index.ts +1 -0
  304. package/src/components/tooltip/tooltip.stories.tsx +284 -0
  305. package/src/components/tooltip/tooltip.tsx +121 -0
  306. package/src/hooks/index.ts +3 -0
  307. package/src/hooks/useResolvedTheme.ts +34 -0
  308. package/src/hooks/useShikiHighlight.ts +140 -0
  309. package/src/hooks/useShikiStyleInjection.ts +34 -0
  310. package/src/utils/avatar.ts +27 -0
  311. package/src/utils/index.ts +1 -0
  312. package/dist/components/button.d.ts.map +0 -1
  313. package/dist/components/button.js.map +0 -1
  314. package/dist/components/button.stories.js.map +0 -1
  315. package/dist/components/input.d.ts.map +0 -1
  316. package/dist/components/input.js.map +0 -1
  317. package/dist/components/input.stories.js.map +0 -1
  318. package/dist/components/theme-provider.d.ts.map +0 -1
  319. package/dist/components/theme-provider.js.map +0 -1
  320. /package/dist/components/{input.d.ts → input/input.d.ts} +0 -0
  321. /package/src/components/{button.stories.tsx → button/button.stories.tsx} +0 -0
  322. /package/src/components/{input.stories.tsx → input/input.stories.tsx} +0 -0
  323. /package/src/components/{theme-provider.tsx → theme/theme-provider.tsx} +0 -0
@@ -0,0 +1,67 @@
1
+ import type {Meta, StoryObj} from '@storybook/react';
2
+ import {Checkbox} from 'components/checkbox';
3
+ import {Input} from 'components/input/input';
4
+ import {Textarea} from 'components/textarea';
5
+ import {Label} from './label';
6
+
7
+ const meta = {
8
+ title: 'Components/Label',
9
+ component: Label,
10
+ tags: ['autodocs'],
11
+ argTypes: {
12
+ htmlFor: {control: 'text'},
13
+ },
14
+ } satisfies Meta<typeof Label>;
15
+
16
+ export default meta;
17
+
18
+ type Story = StoryObj<typeof meta>;
19
+
20
+ export const Default: Story = {
21
+ render: () => (
22
+ <div className="flex flex-col gap-8">
23
+ <Label htmlFor="email">Email</Label>
24
+ <Input id="email" type="email" placeholder="Enter your email" />
25
+ </div>
26
+ ),
27
+ };
28
+
29
+ export const WithCheckbox: Story = {
30
+ render: () => (
31
+ <div className="flex items-center gap-8">
32
+ <Checkbox id="terms" />
33
+ <Label htmlFor="terms">Accept terms and conditions</Label>
34
+ </div>
35
+ ),
36
+ };
37
+
38
+ export const WithTextarea: Story = {
39
+ render: () => (
40
+ <div className="flex flex-col gap-8">
41
+ <Label htmlFor="message">Message</Label>
42
+ <Textarea id="message" placeholder="Enter your message" />
43
+ </div>
44
+ ),
45
+ };
46
+
47
+ export const Required: Story = {
48
+ render: () => (
49
+ <div className="flex flex-col gap-8">
50
+ <Label htmlFor="required-field">
51
+ Required Field <span className="text-foreground-highlight-error">*</span>
52
+ </Label>
53
+ <Input id="required-field" type="text" placeholder="This field is required" />
54
+ </div>
55
+ ),
56
+ };
57
+
58
+ export const Disabled: Story = {
59
+ render: () => (
60
+ <div className="flex flex-col gap-8">
61
+ <Label htmlFor="disabled-field" className="opacity-50">
62
+ Disabled Field
63
+ </Label>
64
+ <Input id="disabled-field" type="text" placeholder="Disabled input" disabled />
65
+ </div>
66
+ ),
67
+ };
@@ -0,0 +1,15 @@
1
+ import * as LabelPrimitive from '@radix-ui/react-label';
2
+ import {cva, type VariantProps} from 'class-variance-authority';
3
+ import type {ComponentProps} from 'react';
4
+ import {cn} from 'utils/cn';
5
+
6
+ export const labelVariants = cva(
7
+ 'text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70',
8
+ );
9
+
10
+ export type LabelProps = ComponentProps<typeof LabelPrimitive.Root> &
11
+ VariantProps<typeof labelVariants>;
12
+
13
+ export function Label({className, ...props}: LabelProps) {
14
+ return <LabelPrimitive.Root className={cn(labelVariants(), className)} {...props} />;
15
+ }
@@ -0,0 +1,67 @@
1
+ import {
2
+ motion,
3
+ useAnimationFrame,
4
+ useMotionTemplate,
5
+ useMotionValue,
6
+ useTransform,
7
+ } from 'framer-motion';
8
+ import type {ComponentProps} from 'react';
9
+ import {useRef} from 'react';
10
+
11
+ export type MovingBorderProps = {
12
+ children: React.ReactNode;
13
+ duration?: number;
14
+ rx?: string;
15
+ ry?: string;
16
+ } & ComponentProps<'svg'>;
17
+
18
+ export function MovingBorder({
19
+ children,
20
+ duration = 3000,
21
+ rx,
22
+ ry,
23
+ ...otherProps
24
+ }: MovingBorderProps) {
25
+ const pathRef = useRef<SVGRectElement | null>(null);
26
+ const progress = useMotionValue<number>(0);
27
+
28
+ useAnimationFrame((time: number) => {
29
+ const length = pathRef.current?.getTotalLength();
30
+ if (length) {
31
+ const pxPerMillisecond = length / duration;
32
+ progress.set((time * pxPerMillisecond) % length);
33
+ }
34
+ });
35
+
36
+ const x = useTransform(progress, (val: number) => pathRef.current?.getPointAtLength(val)?.x ?? 0);
37
+ const y = useTransform(progress, (val: number) => pathRef.current?.getPointAtLength(val)?.y ?? 0);
38
+
39
+ const transform = useMotionTemplate`translateX(${x}px) translateY(${y}px) translateX(-50%) translateY(-50%)`;
40
+
41
+ return (
42
+ <>
43
+ <svg
44
+ xmlns="http://www.w3.org/2000/svg"
45
+ preserveAspectRatio="none"
46
+ className="absolute h-full w-full"
47
+ width="100%"
48
+ height="100%"
49
+ {...otherProps}
50
+ >
51
+ <title>Moving Border</title>
52
+ <rect fill="none" width="100%" height="100%" rx={rx} ry={ry} ref={pathRef} />
53
+ </svg>
54
+ <motion.div
55
+ style={{
56
+ position: 'absolute',
57
+ top: 0,
58
+ left: 0,
59
+ display: 'inline-block',
60
+ transform,
61
+ }}
62
+ >
63
+ {children}
64
+ </motion.div>
65
+ </>
66
+ );
67
+ }
@@ -27,7 +27,7 @@ export function Textarea({className, variant, size, ...props}: TextareaProps) {
27
27
  <textarea
28
28
  data-slot="textarea"
29
29
  className={cn(
30
- 'textarea-resize-custom placeholder:text-foreground-neutral-muted w-full min-w-0 rounded-6 px-8 pr-24 text-sm leading-20 text-foreground-neutral-base shadow-border-base transition-[color,box-shadow] outline-none',
30
+ 'textarea-resize-custom placeholder:text-foreground-neutral-muted w-full min-w-0 rounded-6 px-8 pr-24 text-sm leading-20 text-foreground-neutral-base shadow-button-neutral transition-[color,box-shadow] outline-none',
31
31
  'hover:bg-background-field-hover',
32
32
  'selection:bg-background-accent-neutral-soft selection:text-foreground-neutral-on-inverted',
33
33
  'disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-background-neutral-disabled disabled:shadow-none disabled:text-foreground-neutral-disabled',
@@ -0,0 +1 @@
1
+ export * from './theme-provider';
@@ -0,0 +1,2 @@
1
+ export {Toaster, type ToasterProps, toast} from './toast';
2
+ export {ToastCustom, type ToastCustomProps} from './toast-custom';
@@ -0,0 +1,154 @@
1
+ import {cva, type VariantProps} from 'class-variance-authority';
2
+ import {Icon} from 'components/icon/icon';
3
+ import type {ReactNode} from 'react';
4
+ import {cn} from 'utils/cn';
5
+
6
+ const toastCustomVariants = cva('group relative flex items-start gap-8', {
7
+ variants: {
8
+ variant: {
9
+ default: 'text-tag-neutral-icon',
10
+ info: 'text-tag-neutral-icon',
11
+ success: 'text-tag-success-icon',
12
+ warning: 'text-tag-warning-icon',
13
+ error: 'text-tag-error-icon',
14
+ },
15
+ },
16
+ defaultVariants: {
17
+ variant: 'default',
18
+ },
19
+ });
20
+
21
+ export type ToastAction = {
22
+ label: string;
23
+ onClick: () => void;
24
+ };
25
+
26
+ export type ToastCustomProps = VariantProps<typeof toastCustomVariants> & {
27
+ title?: string;
28
+ description?: string;
29
+ content?: string;
30
+ actions?: ToastAction[];
31
+ onClose?: () => void;
32
+ className?: string;
33
+ };
34
+
35
+ function getDefaultIcon(variant: ToastCustomProps['variant'] = 'default'): ReactNode {
36
+ switch (variant) {
37
+ case 'info':
38
+ return <Icon name="info" size={20} />;
39
+ case 'success':
40
+ return <Icon name="checkCircleSolid" size={20} />;
41
+ case 'warning':
42
+ return <Icon name="info" size={20} />;
43
+ case 'error':
44
+ return <Icon name="xCircleSolid" size={20} />;
45
+ default:
46
+ return <Icon name="info" size={20} />;
47
+ }
48
+ }
49
+
50
+ export function ToastCustom({
51
+ variant = 'default',
52
+ title,
53
+ description,
54
+ content,
55
+ actions,
56
+ onClose,
57
+ className,
58
+ }: ToastCustomProps) {
59
+ const hasTitle = Boolean(title);
60
+ const hasDescription = Boolean(description);
61
+ const hasContent = Boolean(content);
62
+ const hasActions = Boolean(actions && actions.length > 0);
63
+ const isSimple = hasContent && !hasTitle && !hasDescription;
64
+
65
+ return (
66
+ <div data-slot="toast-custom" className={cn(toastCustomVariants({variant}), className)}>
67
+ <div className="w-20 h-20 rounded-full flex items-start justify-center shrink-0 pt-1">
68
+ {getDefaultIcon(variant)}
69
+ </div>
70
+
71
+ <div className="flex-1 min-w-0">
72
+ {hasTitle && (
73
+ <div
74
+ data-slot="toast-custom-title"
75
+ className="font-medium text-sm leading-20 text-foreground-neutral-base mb-4"
76
+ >
77
+ {title}
78
+ </div>
79
+ )}
80
+ {hasDescription && (
81
+ <div
82
+ data-slot="toast-custom-description"
83
+ className="text-xs leading-20 text-foreground-neutral-muted mb-8"
84
+ >
85
+ {description}
86
+ </div>
87
+ )}
88
+ {isSimple ? (
89
+ <div className="flex items-center justify-between gap-16 min-w-400 mr-30">
90
+ <div
91
+ data-slot="toast-custom-content"
92
+ className="text-sm leading-20 text-foreground-neutral-base"
93
+ >
94
+ {content}
95
+ </div>
96
+ {hasActions && (
97
+ <div data-slot="toast-custom-actions" className="flex items-center gap-16">
98
+ {actions?.map((action) => (
99
+ <button
100
+ key={action.label}
101
+ data-slot="toast-custom-action"
102
+ type="button"
103
+ onClick={action.onClick}
104
+ className="bg-transparent border-none p-0 cursor-pointer text-xs font-medium leading-20 text-foreground-neutral-base hover:text-foreground-neutral-subtle transition-colors duration-150 outline-none focus-visible:ring-2 focus-visible:ring-background-accent-blue-base focus-visible:ring-offset-2"
105
+ >
106
+ {action.label}
107
+ </button>
108
+ ))}
109
+ </div>
110
+ )}
111
+ </div>
112
+ ) : (
113
+ <>
114
+ {hasContent && !hasTitle && (
115
+ <div
116
+ data-slot="toast-custom-content"
117
+ className="text-sm leading-20 text-foreground-neutral-base mb-8"
118
+ >
119
+ {content}
120
+ </div>
121
+ )}
122
+ {hasActions && (
123
+ <div data-slot="toast-custom-actions" className="flex items-center gap-16 mt-8">
124
+ {actions?.map((action) => (
125
+ <button
126
+ key={action.label}
127
+ data-slot="toast-custom-action"
128
+ type="button"
129
+ onClick={action.onClick}
130
+ className="bg-transparent border-none p-0 cursor-pointer text-xs font-medium leading-20 text-foreground-neutral-base hover:text-foreground-neutral-subtle transition-colors duration-150 outline-none focus-visible:ring-2 focus-visible:ring-background-accent-blue-base focus-visible:ring-offset-2"
131
+ >
132
+ {action.label}
133
+ </button>
134
+ ))}
135
+ </div>
136
+ )}
137
+ </>
138
+ )}
139
+ </div>
140
+
141
+ {onClose && (
142
+ <button
143
+ data-slot="toast-custom-close"
144
+ type="button"
145
+ onClick={onClose}
146
+ className="absolute cursor-pointer -top-2 -right-2 rounded-4 p-4 bg-transparent border-none text-foreground-neutral-muted hover:text-foreground-neutral-base hover:bg-background-components-hover transition-colors duration-150 outline-none focus-visible:ring-2 focus-visible:ring-background-accent-blue-base focus-visible:ring-offset-2 shrink-0"
147
+ aria-label="Close"
148
+ >
149
+ <Icon name="close" className="w-16 h-16" />
150
+ </button>
151
+ )}
152
+ </div>
153
+ );
154
+ }
@@ -0,0 +1,369 @@
1
+ import type {Meta, StoryObj} from '@storybook/react';
2
+ import {Button} from 'components/button/button';
3
+ import {Code} from 'components/typography';
4
+ import {Toaster, toast} from './toast';
5
+ import {ToastCustom} from './toast-custom';
6
+
7
+ const meta = {
8
+ title: 'Components/Toast',
9
+ component: Toaster,
10
+ tags: ['autodocs'],
11
+ parameters: {
12
+ layout: 'centered',
13
+ },
14
+ decorators: [
15
+ (Story) => (
16
+ <>
17
+ <Story />
18
+ <div className="flex flex-wrap justify-center items-center gap-32">
19
+ {/* Regular Toasts */}
20
+ <div className="flex flex-col gap-8">
21
+ <Code variant="label" className="text-foreground-neutral-subtle text-center">
22
+ REGULAR TOASTS
23
+ </Code>
24
+ <Button
25
+ onClick={() => {
26
+ toast('Event has been created');
27
+ }}
28
+ >
29
+ Default Toast
30
+ </Button>
31
+ <Button
32
+ onClick={() => {
33
+ toast.success('Success! Your changes have been saved.');
34
+ }}
35
+ >
36
+ Success Toast
37
+ </Button>
38
+ <Button
39
+ onClick={() => {
40
+ toast.error('Error! Something went wrong.');
41
+ }}
42
+ >
43
+ Error Toast
44
+ </Button>
45
+ <Button
46
+ onClick={() => {
47
+ toast.warning('Warning! Please review your input.');
48
+ }}
49
+ >
50
+ Warning Toast
51
+ </Button>
52
+ <Button
53
+ onClick={() => {
54
+ toast.info('Info: This is an informational message.');
55
+ }}
56
+ >
57
+ Info Toast
58
+ </Button>
59
+ <Button
60
+ onClick={() => {
61
+ toast('Event has been created', {
62
+ description: 'Sunday, December 03, 2023 at 9:00 AM',
63
+ });
64
+ }}
65
+ >
66
+ Toast with Description
67
+ </Button>
68
+ <Button
69
+ onClick={() => {
70
+ toast('Event has been created', {
71
+ description: 'Sunday, December 03, 2023 at 9:00 AM',
72
+ action: {
73
+ label: 'Undo',
74
+ onClick: () => {
75
+ toast('Undo clicked');
76
+ },
77
+ },
78
+ });
79
+ }}
80
+ >
81
+ Toast with Action
82
+ </Button>
83
+ <Button
84
+ onClick={() => {
85
+ const promise = new Promise((resolve) => {
86
+ setTimeout(() => {
87
+ resolve({name: 'Sonner'});
88
+ }, 2000);
89
+ });
90
+
91
+ toast.promise(promise, {
92
+ loading: 'Loading...',
93
+ success: (data) => {
94
+ return `${(data as {name: string}).name} toast has been added`;
95
+ },
96
+ error: 'Error',
97
+ });
98
+ }}
99
+ >
100
+ Promise Toast
101
+ </Button>
102
+ </div>
103
+ {/* Custom Toasts */}
104
+ <div className="flex flex-col gap-8 text-center">
105
+ <Code variant="label" className="text-foreground-neutral-subtle">
106
+ CUSTOM TOASTS
107
+ </Code>
108
+ <Button
109
+ onClick={() => {
110
+ toast.custom(
111
+ (t) => (
112
+ <ToastCustom
113
+ variant="success"
114
+ title="Insert your alert title here"
115
+ description="Insert the alert description here. It would look better as two lines of text."
116
+ actions={[
117
+ {
118
+ label: 'Upgrade',
119
+ onClick: () => {
120
+ toast('Upgrade clicked');
121
+ toast.dismiss(t);
122
+ },
123
+ },
124
+ {
125
+ label: 'Learn more',
126
+ onClick: () => {
127
+ toast('Learn more clicked');
128
+ toast.dismiss(t);
129
+ },
130
+ },
131
+ ]}
132
+ onClose={() => toast.dismiss(t)}
133
+ />
134
+ ),
135
+ {
136
+ duration: Infinity,
137
+ },
138
+ );
139
+ }}
140
+ >
141
+ Custom Toast (Success - Full)
142
+ </Button>
143
+ <Button
144
+ onClick={() => {
145
+ toast.custom(
146
+ (t) => (
147
+ <ToastCustom
148
+ variant="info"
149
+ title="Insert your alert title here"
150
+ description="Insert the alert description here. It would look better as two lines of text."
151
+ actions={[
152
+ {
153
+ label: 'Upgrade',
154
+ onClick: () => {
155
+ toast('Upgrade clicked');
156
+ toast.dismiss(t);
157
+ },
158
+ },
159
+ {
160
+ label: 'Learn more',
161
+ onClick: () => {
162
+ toast('Learn more clicked');
163
+ toast.dismiss(t);
164
+ },
165
+ },
166
+ ]}
167
+ onClose={() => toast.dismiss(t)}
168
+ />
169
+ ),
170
+ {
171
+ duration: Infinity,
172
+ },
173
+ );
174
+ }}
175
+ >
176
+ Custom Toast (Info - Full)
177
+ </Button>
178
+ <Button
179
+ onClick={() => {
180
+ toast.custom(
181
+ (t) => (
182
+ <ToastCustom
183
+ variant="warning"
184
+ title="Insert your alert title here"
185
+ description="Insert the alert description here. It would look better as two lines of text."
186
+ actions={[
187
+ {
188
+ label: 'Upgrade',
189
+ onClick: () => {
190
+ toast('Upgrade clicked');
191
+ toast.dismiss(t);
192
+ },
193
+ },
194
+ {
195
+ label: 'Learn more',
196
+ onClick: () => {
197
+ toast('Learn more clicked');
198
+ toast.dismiss(t);
199
+ },
200
+ },
201
+ ]}
202
+ onClose={() => toast.dismiss(t)}
203
+ />
204
+ ),
205
+ {
206
+ duration: Infinity,
207
+ },
208
+ );
209
+ }}
210
+ >
211
+ Custom Toast (Warning - Full)
212
+ </Button>
213
+ <Button
214
+ onClick={() => {
215
+ toast.custom(
216
+ (t) => (
217
+ <ToastCustom
218
+ variant="error"
219
+ title="Insert your alert title here"
220
+ description="Insert the alert description here. It would look better as two lines of text."
221
+ actions={[
222
+ {
223
+ label: 'Upgrade',
224
+ onClick: () => {
225
+ toast('Upgrade clicked');
226
+ toast.dismiss(t);
227
+ },
228
+ },
229
+ {
230
+ label: 'Learn more',
231
+ onClick: () => {
232
+ toast('Learn more clicked');
233
+ toast.dismiss(t);
234
+ },
235
+ },
236
+ ]}
237
+ onClose={() => toast.dismiss(t)}
238
+ />
239
+ ),
240
+ {
241
+ duration: Infinity,
242
+ },
243
+ );
244
+ }}
245
+ >
246
+ Custom Toast (Error - Full)
247
+ </Button>
248
+ <Button
249
+ onClick={() => {
250
+ toast.custom(
251
+ (t) => (
252
+ <ToastCustom
253
+ variant="success"
254
+ content="Insert your alert content here"
255
+ actions={[
256
+ {
257
+ label: 'Learn more',
258
+ onClick: () => {
259
+ toast('Learn more clicked');
260
+ toast.dismiss(t);
261
+ },
262
+ },
263
+ ]}
264
+ onClose={() => toast.dismiss(t)}
265
+ />
266
+ ),
267
+ {
268
+ duration: Infinity,
269
+ },
270
+ );
271
+ }}
272
+ >
273
+ Custom Toast (Success - Simple)
274
+ </Button>
275
+ <Button
276
+ onClick={() => {
277
+ toast.custom(
278
+ (t) => (
279
+ <ToastCustom
280
+ variant="info"
281
+ content="Insert your alert content here"
282
+ actions={[
283
+ {
284
+ label: 'Learn more',
285
+ onClick: () => {
286
+ toast('Learn more clicked');
287
+ toast.dismiss(t);
288
+ },
289
+ },
290
+ ]}
291
+ onClose={() => toast.dismiss(t)}
292
+ />
293
+ ),
294
+ {
295
+ duration: Infinity,
296
+ },
297
+ );
298
+ }}
299
+ >
300
+ Custom Toast (Info - Simple)
301
+ </Button>
302
+ <Button
303
+ onClick={() => {
304
+ toast.custom(
305
+ (t) => (
306
+ <ToastCustom
307
+ variant="warning"
308
+ content="Insert your alert content here"
309
+ actions={[
310
+ {
311
+ label: 'Learn more',
312
+ onClick: () => {
313
+ toast('Learn more clicked');
314
+ toast.dismiss(t);
315
+ },
316
+ },
317
+ ]}
318
+ onClose={() => toast.dismiss(t)}
319
+ />
320
+ ),
321
+ {
322
+ duration: Infinity,
323
+ },
324
+ );
325
+ }}
326
+ >
327
+ Custom Toast (Warning - Simple)
328
+ </Button>
329
+ <Button
330
+ onClick={() => {
331
+ toast.custom(
332
+ (t) => (
333
+ <ToastCustom
334
+ variant="error"
335
+ content="Insert your alert content here"
336
+ actions={[
337
+ {
338
+ label: 'Learn more',
339
+ onClick: () => {
340
+ toast('Learn more clicked');
341
+ toast.dismiss(t);
342
+ },
343
+ },
344
+ ]}
345
+ onClose={() => toast.dismiss(t)}
346
+ />
347
+ ),
348
+ {
349
+ duration: Infinity,
350
+ },
351
+ );
352
+ }}
353
+ >
354
+ Custom Toast (Error - Simple)
355
+ </Button>
356
+ </div>
357
+ </div>
358
+ </>
359
+ ),
360
+ ],
361
+ } satisfies Meta<typeof Toaster>;
362
+
363
+ export default meta;
364
+
365
+ type Story = StoryObj<typeof meta>;
366
+
367
+ export const Default: Story = {
368
+ render: () => <Toaster position="top-center" />,
369
+ };