@yuno-payments/dashboard-design-system 0.0.1

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 (71) hide show
  1. package/.storybook/main.ts +20 -0
  2. package/.storybook/preview.ts +18 -0
  3. package/.storybook/vitest.setup.ts +7 -0
  4. package/README.md +69 -0
  5. package/components.json +21 -0
  6. package/eslint.config.js +26 -0
  7. package/index.html +13 -0
  8. package/package.json +57 -0
  9. package/public/vite.svg +1 -0
  10. package/src/App.css +42 -0
  11. package/src/App.tsx +11 -0
  12. package/src/assets/react.svg +1 -0
  13. package/src/components/atoms/button/button.stories.tsx +222 -0
  14. package/src/components/atoms/button/button.test.tsx +78 -0
  15. package/src/components/atoms/button/index.tsx +80 -0
  16. package/src/components/atoms/checkbox/checkbox.stories.tsx +314 -0
  17. package/src/components/atoms/checkbox/checkbox.test.tsx +278 -0
  18. package/src/components/atoms/checkbox/index.tsx +103 -0
  19. package/src/components/atoms/chip/chip.stories.tsx +317 -0
  20. package/src/components/atoms/chip/chip.test.tsx +300 -0
  21. package/src/components/atoms/chip/index.tsx +114 -0
  22. package/src/components/atoms/input/index.tsx +27 -0
  23. package/src/components/atoms/link/index.tsx +79 -0
  24. package/src/components/atoms/link/link.stories.tsx +159 -0
  25. package/src/components/atoms/link/link.test.tsx +176 -0
  26. package/src/components/atoms/radiobutton/index.tsx +103 -0
  27. package/src/components/atoms/radiobutton/radiobutton.stories.tsx +314 -0
  28. package/src/components/atoms/radiobutton/radiobutton.test.tsx +245 -0
  29. package/src/components/atoms/tag/index.tsx +196 -0
  30. package/src/components/atoms/tag/tag.stories.tsx +281 -0
  31. package/src/components/atoms/tag/tag.test.tsx +282 -0
  32. package/src/components/atoms/typography/index.tsx +62 -0
  33. package/src/components/atoms/typography/typography.stories.tsx +214 -0
  34. package/src/components/atoms/typography/typography.test.tsx +187 -0
  35. package/src/components/index.tsx +17 -0
  36. package/src/components/molecules/announcement/announcement.stories.tsx +277 -0
  37. package/src/components/molecules/announcement/announcement.test.tsx +354 -0
  38. package/src/components/molecules/announcement/index.tsx +200 -0
  39. package/src/components/molecules/notification-alert/index.tsx +293 -0
  40. package/src/components/molecules/notification-alert/notification-alert.stories.tsx +418 -0
  41. package/src/components/molecules/notification-alert/notification-alert.test.tsx +454 -0
  42. package/src/components/molecules/popover/index.tsx +175 -0
  43. package/src/components/molecules/popover/popover.stories.tsx +241 -0
  44. package/src/components/molecules/popover/popover.test.tsx +191 -0
  45. package/src/components/molecules/textfield/index.tsx +154 -0
  46. package/src/components/molecules/textfield/textfield.stories.tsx +168 -0
  47. package/src/components/molecules/textfield/textfield.test.tsx +157 -0
  48. package/src/components/molecules/tooltip/index.tsx +263 -0
  49. package/src/components/molecules/tooltip/tooltip.stories.tsx +363 -0
  50. package/src/components/molecules/tooltip/tooltip.test.tsx +468 -0
  51. package/src/components/organisms/dialog/dialog.stories.tsx +522 -0
  52. package/src/components/organisms/dialog/dialog.test.tsx +525 -0
  53. package/src/components/organisms/dialog/index.tsx +233 -0
  54. package/src/components/organisms/dropdown/dropdown.stories.tsx +529 -0
  55. package/src/components/organisms/dropdown/dropdown.test.tsx +390 -0
  56. package/src/components/organisms/dropdown/index.tsx +624 -0
  57. package/src/index.css +184 -0
  58. package/src/lib/color-utils.ts +94 -0
  59. package/src/lib/utils.ts +6 -0
  60. package/src/main.tsx +10 -0
  61. package/src/stories/Colors.stories.tsx +107 -0
  62. package/src/stories/Shadows.stories.tsx +110 -0
  63. package/src/stories/Spacing.stories.tsx +121 -0
  64. package/src/stories/Typography.stories.tsx +197 -0
  65. package/src/vite-env.d.ts +1 -0
  66. package/tsconfig.app.json +33 -0
  67. package/tsconfig.json +13 -0
  68. package/tsconfig.node.json +25 -0
  69. package/vite.config.ts +43 -0
  70. package/vitest.config.ts +15 -0
  71. package/vitest.shims.d.ts +1 -0
@@ -0,0 +1,363 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite'
2
+ import { Tooltip } from './index'
3
+ import { Button } from '../../atoms/button'
4
+
5
+ const meta = {
6
+ title: 'Molecules/Tooltip',
7
+ component: Tooltip,
8
+ parameters: {
9
+ layout: 'centered',
10
+ docs: {
11
+ description: {
12
+ component: 'A tooltip component that displays additional information on hover or click.',
13
+ },
14
+ },
15
+ },
16
+ tags: ['autodocs'],
17
+ argTypes: {
18
+ title: {
19
+ control: 'text',
20
+ description: 'The title content of the tooltip',
21
+ },
22
+ description: {
23
+ control: 'text',
24
+ description: 'The description content of the tooltip',
25
+ },
26
+ showOn: {
27
+ control: 'select',
28
+ options: ['hover', 'click'],
29
+ description: 'How the tooltip is triggered',
30
+ },
31
+ side: {
32
+ control: 'select',
33
+ options: ['top', 'bottom', 'left', 'right'],
34
+ description: 'The side where the tooltip appears',
35
+ },
36
+ isAvailable: {
37
+ control: 'boolean',
38
+ description: 'Whether the tooltip is available/enabled',
39
+ },
40
+ isRemovableWithX: {
41
+ control: 'boolean',
42
+ description: 'Whether to show a close button',
43
+ },
44
+ maxWidth: {
45
+ control: 'number',
46
+ description: 'Maximum width of the tooltip in pixels',
47
+ },
48
+ zIndex: {
49
+ control: 'number',
50
+ description: 'Z-index of the tooltip',
51
+ },
52
+ children: {
53
+ control: 'text',
54
+ description: 'The trigger element',
55
+ },
56
+ },
57
+ } satisfies Meta<typeof Tooltip>
58
+
59
+ export default meta
60
+ type Story = StoryObj<typeof meta>
61
+
62
+ export const Default: Story = {
63
+ args: {
64
+ title: 'This is a tooltip',
65
+ children: 'Hover me',
66
+ },
67
+ }
68
+
69
+ export const WithDescription: Story = {
70
+ args: {
71
+ title: 'Tooltip Title',
72
+ description: 'This is a longer description that provides more context about the element.',
73
+ children: 'Hover me',
74
+ },
75
+ }
76
+
77
+ export const DescriptionOnly: Story = {
78
+ args: {
79
+ description: 'This tooltip only has a description without a title.',
80
+ children: 'Hover me',
81
+ },
82
+ }
83
+
84
+ export const ClickTrigger: Story = {
85
+ args: {
86
+ title: 'Click Tooltip',
87
+ description: 'This tooltip appears on click instead of hover.',
88
+ showOn: 'click',
89
+ children: 'Click me',
90
+ },
91
+ }
92
+
93
+ export const WithCloseButton: Story = {
94
+ args: {
95
+ title: 'Removable Tooltip',
96
+ description: 'This tooltip has a close button.',
97
+ isRemovableWithX: true,
98
+ children: 'Hover me',
99
+ },
100
+ }
101
+
102
+ export const ClickWithCloseButton: Story = {
103
+ args: {
104
+ title: 'Click & Close',
105
+ description: 'This tooltip appears on click and has a close button.',
106
+ showOn: 'click',
107
+ isRemovableWithX: true,
108
+ children: 'Click me',
109
+ },
110
+ }
111
+
112
+ export const Positioning: Story = {
113
+ render: () => (
114
+ <div className="grid grid-cols-3 gap-8 p-8">
115
+ <div></div>
116
+ <Tooltip title="Top tooltip" side="top">
117
+ <Button variant="outline">Top</Button>
118
+ </Tooltip>
119
+ <div></div>
120
+
121
+ <Tooltip title="Left tooltip" side="left">
122
+ <Button variant="outline">Left</Button>
123
+ </Tooltip>
124
+ <div></div>
125
+ <Tooltip title="Right tooltip" side="right">
126
+ <Button variant="outline">Right</Button>
127
+ </Tooltip>
128
+
129
+ <div></div>
130
+ <Tooltip title="Bottom tooltip" side="bottom">
131
+ <Button variant="outline">Bottom</Button>
132
+ </Tooltip>
133
+ <div></div>
134
+ </div>
135
+ ),
136
+ parameters: {
137
+ docs: {
138
+ description: {
139
+ story: 'Tooltips can be positioned on different sides of the trigger element.',
140
+ },
141
+ },
142
+ },
143
+ }
144
+
145
+ export const CustomWidth: Story = {
146
+ args: {
147
+ title: 'Custom Width Tooltip',
148
+ description: 'This tooltip has a custom maximum width of 400 pixels, which allows for longer content to be displayed without wrapping too early.',
149
+ maxWidth: 400,
150
+ children: 'Hover me',
151
+ },
152
+ }
153
+
154
+ export const LongTitle: Story = {
155
+ args: {
156
+ title: 'This is a very long title that will be truncated automatically when it exceeds the maximum length limit of 85 characters',
157
+ description: 'The title above should be truncated with ellipsis.',
158
+ children: 'Hover me',
159
+ },
160
+ }
161
+
162
+ export const Disabled: Story = {
163
+ args: {
164
+ title: 'This tooltip is disabled',
165
+ isAvailable: false,
166
+ children: 'Hover me (disabled)',
167
+ },
168
+ parameters: {
169
+ docs: {
170
+ description: {
171
+ story: 'When isAvailable is false, the tooltip will not appear.',
172
+ },
173
+ },
174
+ },
175
+ }
176
+
177
+ export const WithButton: Story = {
178
+ render: () => (
179
+ <Tooltip title="Button Tooltip" description="This tooltip is attached to a button component.">
180
+ <Button>Button with Tooltip</Button>
181
+ </Tooltip>
182
+ ),
183
+ }
184
+
185
+ export const Interactive: Story = {
186
+ render: () => (
187
+ <div className="flex gap-4">
188
+ <Tooltip title="Hover Tooltip" description="This appears on hover">
189
+ <Button variant="outline">Hover</Button>
190
+ </Tooltip>
191
+
192
+ <Tooltip title="Click Tooltip" description="This appears on click" showOn="click">
193
+ <Button variant="outline">Click</Button>
194
+ </Tooltip>
195
+
196
+ <Tooltip
197
+ title="Removable Tooltip"
198
+ description="This has a close button"
199
+ isRemovableWithX
200
+ >
201
+ <Button variant="outline">With Close</Button>
202
+ </Tooltip>
203
+ </div>
204
+ ),
205
+ parameters: {
206
+ docs: {
207
+ description: {
208
+ story: 'Different interaction modes for tooltips.',
209
+ },
210
+ },
211
+ },
212
+ }
213
+
214
+ export const Docs: Story = {
215
+ render: () => (
216
+ <div className="max-w-4xl mx-auto p-6 space-y-8">
217
+ <div>
218
+ <h1 className="text-3xl font-bold mb-4">Tooltip Component</h1>
219
+ <p className="text-lg text-muted-foreground mb-6">
220
+ The Tooltip component provides contextual information when users hover over or click on elements.
221
+ It supports various trigger modes, positioning options, and customization features.
222
+ </p>
223
+ </div>
224
+
225
+ <div className="space-y-6">
226
+ <section>
227
+ <h2 className="text-2xl font-semibold mb-3">Basic Usage</h2>
228
+ <p className="text-muted-foreground mb-4">
229
+ The simplest tooltip shows on hover with a title.
230
+ </p>
231
+ <div className="flex gap-4 p-4 border rounded-lg">
232
+ <Tooltip title="Basic tooltip">
233
+ <Button variant="outline">Hover me</Button>
234
+ </Tooltip>
235
+ </div>
236
+ </section>
237
+
238
+ <section>
239
+ <h2 className="text-2xl font-semibold mb-3">With Description</h2>
240
+ <p className="text-muted-foreground mb-4">
241
+ Tooltips can include both a title and description for more detailed information.
242
+ </p>
243
+ <div className="flex gap-4 p-4 border rounded-lg">
244
+ <Tooltip
245
+ title="Detailed Tooltip"
246
+ description="This provides additional context and information about the element."
247
+ >
248
+ <Button variant="outline">Hover for details</Button>
249
+ </Tooltip>
250
+ </div>
251
+ </section>
252
+
253
+ <section>
254
+ <h2 className="text-2xl font-semibold mb-3">Trigger Modes</h2>
255
+ <p className="text-muted-foreground mb-4">
256
+ Tooltips can be triggered by hover (default) or click interactions.
257
+ </p>
258
+ <div className="flex gap-4 p-4 border rounded-lg">
259
+ <Tooltip title="Hover Tooltip" description="Appears on hover">
260
+ <Button variant="outline">Hover</Button>
261
+ </Tooltip>
262
+ <Tooltip title="Click Tooltip" description="Appears on click" showOn="click">
263
+ <Button variant="outline">Click</Button>
264
+ </Tooltip>
265
+ </div>
266
+ </section>
267
+
268
+ <section>
269
+ <h2 className="text-2xl font-semibold mb-3">Positioning</h2>
270
+ <p className="text-muted-foreground mb-4">
271
+ Tooltips can be positioned on any side of the trigger element.
272
+ </p>
273
+ <div className="grid grid-cols-3 gap-4 p-4 border rounded-lg place-items-center">
274
+ <div></div>
275
+ <Tooltip title="Top" side="top">
276
+ <Button variant="outline" size="sm">Top</Button>
277
+ </Tooltip>
278
+ <div></div>
279
+
280
+ <Tooltip title="Left" side="left">
281
+ <Button variant="outline" size="sm">Left</Button>
282
+ </Tooltip>
283
+ <div></div>
284
+ <Tooltip title="Right" side="right">
285
+ <Button variant="outline" size="sm">Right</Button>
286
+ </Tooltip>
287
+
288
+ <div></div>
289
+ <Tooltip title="Bottom" side="bottom">
290
+ <Button variant="outline" size="sm">Bottom</Button>
291
+ </Tooltip>
292
+ <div></div>
293
+ </div>
294
+ </section>
295
+
296
+ <section>
297
+ <h2 className="text-2xl font-semibold mb-3">Removable Tooltips</h2>
298
+ <p className="text-muted-foreground mb-4">
299
+ Tooltips can include a close button for manual dismissal.
300
+ </p>
301
+ <div className="flex gap-4 p-4 border rounded-lg">
302
+ <Tooltip
303
+ title="Removable Tooltip"
304
+ description="Click the X to close this tooltip"
305
+ isRemovableWithX
306
+ >
307
+ <Button variant="outline">With Close Button</Button>
308
+ </Tooltip>
309
+ </div>
310
+ </section>
311
+
312
+ <section>
313
+ <h2 className="text-2xl font-semibold mb-3">Customization</h2>
314
+ <p className="text-muted-foreground mb-4">
315
+ Tooltips support custom width, z-index, and can be disabled when needed.
316
+ </p>
317
+ <div className="flex gap-4 p-4 border rounded-lg">
318
+ <Tooltip
319
+ title="Wide Tooltip"
320
+ description="This tooltip has a custom maximum width of 400 pixels, allowing for longer content without early wrapping."
321
+ maxWidth={400}
322
+ >
323
+ <Button variant="outline">Custom Width</Button>
324
+ </Tooltip>
325
+ <Tooltip title="This tooltip is disabled" isAvailable={false}>
326
+ <Button variant="outline" disabled>Disabled</Button>
327
+ </Tooltip>
328
+ </div>
329
+ </section>
330
+
331
+ <section>
332
+ <h2 className="text-2xl font-semibold mb-3">Accessibility</h2>
333
+ <div className="space-y-3 text-muted-foreground">
334
+ <p>• Tooltips use proper ARIA attributes (role="tooltip", aria-describedby)</p>
335
+ <p>• Keyboard navigation is supported (Escape key closes tooltips)</p>
336
+ <p>• Click-triggered tooltips close on outside clicks</p>
337
+ <p>• Hover tooltips are pointer-events-none to prevent interference</p>
338
+ <p>• Close buttons have proper aria-label for screen readers</p>
339
+ </div>
340
+ </section>
341
+
342
+ <section>
343
+ <h2 className="text-2xl font-semibold mb-3">Best Practices</h2>
344
+ <div className="space-y-3 text-muted-foreground">
345
+ <p>• Use hover tooltips for supplementary information</p>
346
+ <p>• Use click tooltips for more complex or interactive content</p>
347
+ <p>• Keep tooltip content concise and relevant</p>
348
+ <p>• Consider positioning to avoid viewport edges</p>
349
+ <p>• Use removable tooltips sparingly, mainly for persistent information</p>
350
+ <p>• Ensure tooltips don't interfere with other interactive elements</p>
351
+ </div>
352
+ </section>
353
+ </div>
354
+ </div>
355
+ ),
356
+ parameters: {
357
+ docs: {
358
+ description: {
359
+ story: 'Comprehensive documentation and examples for the Tooltip component.',
360
+ },
361
+ },
362
+ },
363
+ }