@shipfox/react-ui 0.3.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 (290) hide show
  1. package/.storybook/preview.tsx +1 -1
  2. package/.turbo/turbo-build.log +2 -2
  3. package/.turbo/turbo-check.log +2 -2
  4. package/.turbo/turbo-type.log +1 -1
  5. package/CHANGELOG.md +11 -0
  6. package/dist/components/alert/alert.d.ts +2 -2
  7. package/dist/components/alert/alert.js +3 -3
  8. package/dist/components/alert/alert.js.map +1 -1
  9. package/dist/components/alert/alert.stories.js +2 -2
  10. package/dist/components/alert/alert.stories.js.map +1 -1
  11. package/dist/components/avatar/avatar-group.js +3 -3
  12. package/dist/components/avatar/avatar-group.js.map +1 -1
  13. package/dist/components/avatar/avatar.d.ts +4 -1
  14. package/dist/components/avatar/avatar.d.ts.map +1 -1
  15. package/dist/components/avatar/avatar.js +7 -8
  16. package/dist/components/avatar/avatar.js.map +1 -1
  17. package/dist/components/avatar/avatar.stories.js +15 -3
  18. package/dist/components/avatar/avatar.stories.js.map +1 -1
  19. package/dist/components/badge/badge.d.ts +48 -0
  20. package/dist/components/badge/badge.d.ts.map +1 -0
  21. package/dist/components/badge/badge.js +72 -0
  22. package/dist/components/badge/badge.js.map +1 -0
  23. package/dist/components/badge/badge.stories.js +802 -0
  24. package/dist/components/badge/badge.stories.js.map +1 -0
  25. package/dist/components/badge/icon-badge.d.ts +9 -0
  26. package/dist/components/badge/icon-badge.d.ts.map +1 -0
  27. package/dist/components/badge/icon-badge.js +32 -0
  28. package/dist/components/badge/icon-badge.js.map +1 -0
  29. package/dist/components/badge/index.d.ts +5 -0
  30. package/dist/components/badge/index.d.ts.map +1 -0
  31. package/dist/components/badge/index.js +6 -0
  32. package/dist/components/badge/index.js.map +1 -0
  33. package/dist/components/badge/status-badge.d.ts +9 -0
  34. package/dist/components/badge/status-badge.d.ts.map +1 -0
  35. package/dist/components/badge/status-badge.js +29 -0
  36. package/dist/components/badge/status-badge.js.map +1 -0
  37. package/dist/components/badge/user-badge.d.ts +8 -0
  38. package/dist/components/badge/user-badge.d.ts.map +1 -0
  39. package/dist/components/badge/user-badge.js +24 -0
  40. package/dist/components/badge/user-badge.js.map +1 -0
  41. package/dist/components/{button.d.ts → button/button.d.ts} +1 -1
  42. package/dist/components/button/button.d.ts.map +1 -0
  43. package/dist/components/{button.js → button/button.js} +2 -2
  44. package/dist/components/button/button.js.map +1 -0
  45. package/dist/components/{button.stories.js → button/button.stories.js} +1 -1
  46. package/dist/components/button/button.stories.js.map +1 -0
  47. package/dist/components/button/index.d.ts +2 -0
  48. package/dist/components/button/index.d.ts.map +1 -0
  49. package/dist/components/button/index.js +3 -0
  50. package/dist/components/button/index.js.map +1 -0
  51. package/dist/components/checkbox/checkbox-label.d.ts +14 -0
  52. package/dist/components/checkbox/checkbox-label.d.ts.map +1 -0
  53. package/dist/components/checkbox/checkbox-label.js +82 -0
  54. package/dist/components/checkbox/checkbox-label.js.map +1 -0
  55. package/dist/components/checkbox/checkbox-links.d.ts +18 -0
  56. package/dist/components/checkbox/checkbox-links.d.ts.map +1 -0
  57. package/dist/components/checkbox/checkbox-links.js +58 -0
  58. package/dist/components/checkbox/checkbox-links.js.map +1 -0
  59. package/dist/components/checkbox/checkbox.d.ts +9 -0
  60. package/dist/components/checkbox/checkbox.d.ts.map +1 -0
  61. package/dist/components/checkbox/checkbox.js +49 -0
  62. package/dist/components/checkbox/checkbox.js.map +1 -0
  63. package/dist/components/checkbox/checkbox.stories.js +566 -0
  64. package/dist/components/checkbox/checkbox.stories.js.map +1 -0
  65. package/dist/components/checkbox/index.d.ts +4 -0
  66. package/dist/components/checkbox/index.d.ts.map +1 -0
  67. package/dist/components/checkbox/index.js +5 -0
  68. package/dist/components/checkbox/index.js.map +1 -0
  69. package/dist/components/code-block/code-block-footer.d.ts +26 -0
  70. package/dist/components/code-block/code-block-footer.d.ts.map +1 -0
  71. package/dist/components/code-block/code-block-footer.js +86 -0
  72. package/dist/components/code-block/code-block-footer.js.map +1 -0
  73. package/dist/components/code-block/code-block.d.ts +50 -0
  74. package/dist/components/code-block/code-block.d.ts.map +1 -0
  75. package/dist/components/code-block/code-block.js +142 -0
  76. package/dist/components/code-block/code-block.js.map +1 -0
  77. package/dist/components/code-block/code-block.stories.js +341 -0
  78. package/dist/components/code-block/code-block.stories.js.map +1 -0
  79. package/dist/components/code-block/code-content.d.ts +11 -0
  80. package/dist/components/code-block/code-content.d.ts.map +1 -0
  81. package/dist/components/code-block/code-content.js +29 -0
  82. package/dist/components/code-block/code-content.js.map +1 -0
  83. package/dist/components/code-block/code-copy-button.d.ts +11 -0
  84. package/dist/components/code-block/code-copy-button.d.ts.map +1 -0
  85. package/dist/components/code-block/code-copy-button.js +49 -0
  86. package/dist/components/code-block/code-copy-button.js.map +1 -0
  87. package/dist/components/code-block/code-tabs.d.ts +16 -0
  88. package/dist/components/code-block/code-tabs.d.ts.map +1 -0
  89. package/dist/components/code-block/code-tabs.js +98 -0
  90. package/dist/components/code-block/code-tabs.js.map +1 -0
  91. package/dist/components/code-block/index.d.ts +4 -0
  92. package/dist/components/code-block/index.d.ts.map +1 -0
  93. package/dist/components/code-block/index.js +5 -0
  94. package/dist/components/code-block/index.js.map +1 -0
  95. package/dist/components/dynamic-item/dynamic-item.d.ts +13 -0
  96. package/dist/components/dynamic-item/dynamic-item.d.ts.map +1 -0
  97. package/dist/components/dynamic-item/dynamic-item.js +43 -0
  98. package/dist/components/dynamic-item/dynamic-item.js.map +1 -0
  99. package/dist/components/dynamic-item/dynamic-item.stories.js +375 -0
  100. package/dist/components/dynamic-item/dynamic-item.stories.js.map +1 -0
  101. package/dist/components/dynamic-item/index.d.ts +2 -0
  102. package/dist/components/dynamic-item/index.d.ts.map +1 -0
  103. package/dist/components/dynamic-item/index.js +3 -0
  104. package/dist/components/dynamic-item/index.js.map +1 -0
  105. package/dist/components/icon/custom/index.d.ts +2 -0
  106. package/dist/components/icon/custom/index.d.ts.map +1 -1
  107. package/dist/components/icon/custom/index.js +2 -0
  108. package/dist/components/icon/custom/index.js.map +1 -1
  109. package/dist/components/icon/custom/slack-logo.d.ts +6 -0
  110. package/dist/components/icon/custom/slack-logo.d.ts.map +1 -0
  111. package/dist/components/icon/custom/slack-logo.js +34 -0
  112. package/dist/components/icon/custom/slack-logo.js.map +1 -0
  113. package/dist/components/icon/custom/stripe-logo.d.ts +8 -0
  114. package/dist/components/icon/custom/stripe-logo.d.ts.map +1 -0
  115. package/dist/components/icon/custom/stripe-logo.js +24 -0
  116. package/dist/components/icon/custom/stripe-logo.js.map +1 -0
  117. package/dist/components/icon/icon.d.ts +11 -2
  118. package/dist/components/icon/icon.d.ts.map +1 -1
  119. package/dist/components/icon/icon.js +12 -3
  120. package/dist/components/icon/icon.js.map +1 -1
  121. package/dist/components/icon/icon.stories.js +6 -3
  122. package/dist/components/icon/icon.stories.js.map +1 -1
  123. package/dist/components/index.d.ts +9 -1
  124. package/dist/components/index.d.ts.map +1 -1
  125. package/dist/components/index.js +10 -2
  126. package/dist/components/index.js.map +1 -1
  127. package/dist/components/inline-tips/inline-tips.d.ts +1 -1
  128. package/dist/components/inline-tips/inline-tips.d.ts.map +1 -1
  129. package/dist/components/inline-tips/inline-tips.js +1 -1
  130. package/dist/components/inline-tips/inline-tips.js.map +1 -1
  131. package/dist/components/inline-tips/inline-tips.stories.js +5 -5
  132. package/dist/components/inline-tips/inline-tips.stories.js.map +1 -1
  133. package/dist/components/input/index.d.ts +2 -0
  134. package/dist/components/input/index.d.ts.map +1 -0
  135. package/dist/components/input/index.js +3 -0
  136. package/dist/components/input/index.js.map +1 -0
  137. package/dist/components/input/input.d.ts.map +1 -0
  138. package/dist/components/{input.js → input/input.js} +2 -2
  139. package/dist/components/input/input.js.map +1 -0
  140. package/dist/components/{input.stories.js → input/input.stories.js} +1 -1
  141. package/dist/components/input/input.stories.js.map +1 -0
  142. package/dist/components/item/index.d.ts +2 -0
  143. package/dist/components/item/index.d.ts.map +1 -0
  144. package/dist/components/item/index.js +3 -0
  145. package/dist/components/item/index.js.map +1 -0
  146. package/dist/components/item/item.d.ts +32 -0
  147. package/dist/components/item/item.d.ts.map +1 -0
  148. package/dist/components/item/item.js +120 -0
  149. package/dist/components/item/item.js.map +1 -0
  150. package/dist/components/item/item.stories.js +232 -0
  151. package/dist/components/item/item.stories.js.map +1 -0
  152. package/dist/components/label/index.d.ts +2 -0
  153. package/dist/components/label/index.d.ts.map +1 -0
  154. package/dist/components/label/index.js +3 -0
  155. package/dist/components/label/index.js.map +1 -0
  156. package/dist/components/label/label.d.ts +7 -0
  157. package/dist/components/label/label.d.ts.map +1 -0
  158. package/dist/components/label/label.js +13 -0
  159. package/dist/components/label/label.js.map +1 -0
  160. package/dist/components/label/label.stories.js +105 -0
  161. package/dist/components/label/label.stories.js.map +1 -0
  162. package/dist/components/moving-border/moving-border.d.ts +9 -0
  163. package/dist/components/moving-border/moving-border.d.ts.map +1 -0
  164. package/dist/components/moving-border/moving-border.js +54 -0
  165. package/dist/components/moving-border/moving-border.js.map +1 -0
  166. package/dist/components/textarea/textarea.js +1 -1
  167. package/dist/components/textarea/textarea.js.map +1 -1
  168. package/dist/components/theme/index.d.ts +2 -0
  169. package/dist/components/theme/index.d.ts.map +1 -0
  170. package/dist/components/theme/index.js +3 -0
  171. package/dist/components/theme/index.js.map +1 -0
  172. package/dist/components/{theme-provider.d.ts → theme/theme-provider.d.ts} +1 -1
  173. package/dist/components/theme/theme-provider.d.ts.map +1 -0
  174. package/dist/components/{theme-provider.js → theme/theme-provider.js} +1 -1
  175. package/dist/components/theme/theme-provider.js.map +1 -0
  176. package/dist/components/toast/index.d.ts +3 -0
  177. package/dist/components/toast/index.d.ts.map +1 -0
  178. package/dist/components/toast/index.js +4 -0
  179. package/dist/components/toast/index.js.map +1 -0
  180. package/dist/components/toast/toast-custom.d.ts +19 -0
  181. package/dist/components/toast/toast-custom.d.ts.map +1 -0
  182. package/dist/components/toast/toast-custom.js +134 -0
  183. package/dist/components/toast/toast-custom.js.map +1 -0
  184. package/dist/components/toast/toast.d.ts +5 -0
  185. package/dist/components/toast/toast.d.ts.map +1 -0
  186. package/dist/components/toast/toast.js +40 -0
  187. package/dist/components/toast/toast.js.map +1 -0
  188. package/dist/components/toast/toast.stories.js +326 -0
  189. package/dist/components/toast/toast.stories.js.map +1 -0
  190. package/dist/components/tooltip/index.d.ts +2 -0
  191. package/dist/components/tooltip/index.d.ts.map +1 -0
  192. package/dist/components/tooltip/index.js +3 -0
  193. package/dist/components/tooltip/index.js.map +1 -0
  194. package/dist/components/tooltip/tooltip.d.ts +18 -5
  195. package/dist/components/tooltip/tooltip.d.ts.map +1 -1
  196. package/dist/components/tooltip/tooltip.js +63 -3
  197. package/dist/components/tooltip/tooltip.js.map +1 -1
  198. package/dist/components/tooltip/tooltip.stories.js +560 -0
  199. package/dist/components/tooltip/tooltip.stories.js.map +1 -0
  200. package/dist/hooks/index.d.ts +3 -0
  201. package/dist/hooks/index.d.ts.map +1 -1
  202. package/dist/hooks/index.js +3 -0
  203. package/dist/hooks/index.js.map +1 -1
  204. package/dist/hooks/useResolvedTheme.d.ts +2 -0
  205. package/dist/hooks/useResolvedTheme.d.ts.map +1 -0
  206. package/dist/hooks/useResolvedTheme.js +24 -0
  207. package/dist/hooks/useResolvedTheme.js.map +1 -0
  208. package/dist/hooks/useShikiHighlight.d.ts +28 -0
  209. package/dist/hooks/useShikiHighlight.d.ts.map +1 -0
  210. package/dist/hooks/useShikiHighlight.js +106 -0
  211. package/dist/hooks/useShikiHighlight.js.map +1 -0
  212. package/dist/hooks/useShikiStyleInjection.d.ts +2 -0
  213. package/dist/hooks/useShikiStyleInjection.d.ts.map +1 -0
  214. package/dist/hooks/useShikiStyleInjection.js +34 -0
  215. package/dist/hooks/useShikiStyleInjection.js.map +1 -0
  216. package/index.css +101 -9
  217. package/package.json +6 -3
  218. package/src/assets/illustration-1.svg +92 -0
  219. package/src/assets/illustration-2.svg +14 -0
  220. package/src/assets/illustration-gradient.svg +7049 -0
  221. package/src/components/alert/alert.stories.tsx +2 -2
  222. package/src/components/alert/alert.tsx +3 -3
  223. package/src/components/avatar/avatar-group.tsx +3 -3
  224. package/src/components/avatar/avatar.stories.tsx +9 -2
  225. package/src/components/avatar/avatar.tsx +10 -6
  226. package/src/components/badge/badge.stories.tsx +468 -0
  227. package/src/components/badge/badge.tsx +147 -0
  228. package/src/components/badge/icon-badge.tsx +43 -0
  229. package/src/components/badge/index.ts +4 -0
  230. package/src/components/badge/status-badge.tsx +43 -0
  231. package/src/components/badge/user-badge.tsx +34 -0
  232. package/src/components/{button.tsx → button/button.tsx} +1 -1
  233. package/src/components/button/index.ts +1 -0
  234. package/src/components/checkbox/checkbox-label.tsx +125 -0
  235. package/src/components/checkbox/checkbox-links.tsx +90 -0
  236. package/src/components/checkbox/checkbox.stories.tsx +375 -0
  237. package/src/components/checkbox/checkbox.tsx +71 -0
  238. package/src/components/checkbox/index.ts +3 -0
  239. package/src/components/code-block/code-block-footer.tsx +173 -0
  240. package/src/components/code-block/code-block.stories.tsx +323 -0
  241. package/src/components/code-block/code-block.tsx +283 -0
  242. package/src/components/code-block/code-content.tsx +60 -0
  243. package/src/components/code-block/code-copy-button.tsx +73 -0
  244. package/src/components/code-block/code-tabs.tsx +170 -0
  245. package/src/components/code-block/index.ts +3 -0
  246. package/src/components/dynamic-item/dynamic-item.stories.tsx +261 -0
  247. package/src/components/dynamic-item/dynamic-item.tsx +68 -0
  248. package/src/components/dynamic-item/index.ts +1 -0
  249. package/src/components/icon/custom/index.ts +2 -0
  250. package/src/components/icon/custom/slack-logo.tsx +35 -0
  251. package/src/components/icon/custom/stripe-logo.tsx +27 -0
  252. package/src/components/icon/icon.stories.tsx +3 -1
  253. package/src/components/icon/icon.tsx +19 -1
  254. package/src/components/index.ts +9 -1
  255. package/src/components/inline-tips/inline-tips.stories.tsx +3 -3
  256. package/src/components/inline-tips/inline-tips.tsx +2 -2
  257. package/src/components/input/index.ts +1 -0
  258. package/src/components/{input.tsx → input/input.tsx} +1 -1
  259. package/src/components/item/index.ts +1 -0
  260. package/src/components/item/item.stories.tsx +150 -0
  261. package/src/components/item/item.tsx +182 -0
  262. package/src/components/label/index.ts +1 -0
  263. package/src/components/label/label.stories.tsx +67 -0
  264. package/src/components/label/label.tsx +15 -0
  265. package/src/components/moving-border/moving-border.tsx +67 -0
  266. package/src/components/textarea/textarea.tsx +1 -1
  267. package/src/components/theme/index.ts +1 -0
  268. package/src/components/toast/index.ts +2 -0
  269. package/src/components/toast/toast-custom.tsx +154 -0
  270. package/src/components/toast/toast.stories.tsx +369 -0
  271. package/src/components/toast/toast.tsx +41 -0
  272. package/src/components/tooltip/index.ts +1 -0
  273. package/src/components/tooltip/tooltip.stories.tsx +284 -0
  274. package/src/components/tooltip/tooltip.tsx +79 -10
  275. package/src/hooks/index.ts +3 -0
  276. package/src/hooks/useResolvedTheme.ts +34 -0
  277. package/src/hooks/useShikiHighlight.ts +140 -0
  278. package/src/hooks/useShikiStyleInjection.ts +34 -0
  279. package/dist/components/button.d.ts.map +0 -1
  280. package/dist/components/button.js.map +0 -1
  281. package/dist/components/button.stories.js.map +0 -1
  282. package/dist/components/input.d.ts.map +0 -1
  283. package/dist/components/input.js.map +0 -1
  284. package/dist/components/input.stories.js.map +0 -1
  285. package/dist/components/theme-provider.d.ts.map +0 -1
  286. package/dist/components/theme-provider.js.map +0 -1
  287. /package/dist/components/{input.d.ts → input/input.d.ts} +0 -0
  288. /package/src/components/{button.stories.tsx → button/button.stories.tsx} +0 -0
  289. /package/src/components/{input.stories.tsx → input/input.stories.tsx} +0 -0
  290. /package/src/components/{theme-provider.tsx → theme/theme-provider.tsx} +0 -0
@@ -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
+ };
@@ -0,0 +1,41 @@
1
+ import {useTheme} from 'hooks/useTheme';
2
+ import {AlertTriangle, CheckCircle2, Info, Loader2, XCircle} from 'lucide-react';
3
+ import {
4
+ Toaster as SonnerToaster,
5
+ type ToasterProps as SonnerToasterProps,
6
+ toast as sonnerToast,
7
+ } from 'sonner';
8
+
9
+ type ToasterProps = Omit<SonnerToasterProps, 'theme'>;
10
+
11
+ function Toaster({...props}: ToasterProps) {
12
+ const {theme} = useTheme();
13
+
14
+ return (
15
+ <SonnerToaster
16
+ theme={theme as SonnerToasterProps['theme']}
17
+ className="toaster group"
18
+ toastOptions={{
19
+ classNames: {
20
+ toast:
21
+ 'group toast group-[.toaster]:bg-background-components-base group-[.toaster]:text-foreground-neutral-base group-[.toaster]:border group-[.toaster]:border-border-neutral-base group-[.toaster]:shadow-tooltip rounded-8 p-8',
22
+ description: 'group-[.toast]:text-foreground-neutral-muted text-xs leading-20 mt-4',
23
+ actionButton:
24
+ 'group-[.toast]:bg-background-button-neutral-default group-[.toast]:text-foreground-neutral-base group-[.toast]:hover:bg-background-button-neutral-hover rounded-6 px-8 py-4 text-xs font-medium',
25
+ cancelButton:
26
+ 'group-[.toast]:bg-background-button-transparent-default group-[.toast]:text-foreground-neutral-base group-[.toast]:hover:bg-background-button-transparent-hover rounded-6 px-8 py-4 text-xs font-medium',
27
+ },
28
+ }}
29
+ icons={{
30
+ success: <CheckCircle2 className="size-20 text-tag-success-icon" />,
31
+ info: <Info className="size-20 text-tag-blue-icon" />,
32
+ warning: <AlertTriangle className="size-20 text-tag-warning-icon" />,
33
+ error: <XCircle className="size-20 text-tag-error-icon" />,
34
+ loading: <Loader2 className="size-20 text-tag-neutral-icon animate-spin" />,
35
+ }}
36
+ {...props}
37
+ />
38
+ );
39
+ }
40
+
41
+ export {Toaster, sonnerToast as toast, type ToasterProps};
@@ -0,0 +1 @@
1
+ export * from './tooltip';