@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.
- package/.storybook/main.ts +20 -0
- package/.storybook/preview.ts +18 -0
- package/.storybook/vitest.setup.ts +7 -0
- package/README.md +69 -0
- package/components.json +21 -0
- package/eslint.config.js +26 -0
- package/index.html +13 -0
- package/package.json +57 -0
- package/public/vite.svg +1 -0
- package/src/App.css +42 -0
- package/src/App.tsx +11 -0
- package/src/assets/react.svg +1 -0
- package/src/components/atoms/button/button.stories.tsx +222 -0
- package/src/components/atoms/button/button.test.tsx +78 -0
- package/src/components/atoms/button/index.tsx +80 -0
- package/src/components/atoms/checkbox/checkbox.stories.tsx +314 -0
- package/src/components/atoms/checkbox/checkbox.test.tsx +278 -0
- package/src/components/atoms/checkbox/index.tsx +103 -0
- package/src/components/atoms/chip/chip.stories.tsx +317 -0
- package/src/components/atoms/chip/chip.test.tsx +300 -0
- package/src/components/atoms/chip/index.tsx +114 -0
- package/src/components/atoms/input/index.tsx +27 -0
- package/src/components/atoms/link/index.tsx +79 -0
- package/src/components/atoms/link/link.stories.tsx +159 -0
- package/src/components/atoms/link/link.test.tsx +176 -0
- package/src/components/atoms/radiobutton/index.tsx +103 -0
- package/src/components/atoms/radiobutton/radiobutton.stories.tsx +314 -0
- package/src/components/atoms/radiobutton/radiobutton.test.tsx +245 -0
- package/src/components/atoms/tag/index.tsx +196 -0
- package/src/components/atoms/tag/tag.stories.tsx +281 -0
- package/src/components/atoms/tag/tag.test.tsx +282 -0
- package/src/components/atoms/typography/index.tsx +62 -0
- package/src/components/atoms/typography/typography.stories.tsx +214 -0
- package/src/components/atoms/typography/typography.test.tsx +187 -0
- package/src/components/index.tsx +17 -0
- package/src/components/molecules/announcement/announcement.stories.tsx +277 -0
- package/src/components/molecules/announcement/announcement.test.tsx +354 -0
- package/src/components/molecules/announcement/index.tsx +200 -0
- package/src/components/molecules/notification-alert/index.tsx +293 -0
- package/src/components/molecules/notification-alert/notification-alert.stories.tsx +418 -0
- package/src/components/molecules/notification-alert/notification-alert.test.tsx +454 -0
- package/src/components/molecules/popover/index.tsx +175 -0
- package/src/components/molecules/popover/popover.stories.tsx +241 -0
- package/src/components/molecules/popover/popover.test.tsx +191 -0
- package/src/components/molecules/textfield/index.tsx +154 -0
- package/src/components/molecules/textfield/textfield.stories.tsx +168 -0
- package/src/components/molecules/textfield/textfield.test.tsx +157 -0
- package/src/components/molecules/tooltip/index.tsx +263 -0
- package/src/components/molecules/tooltip/tooltip.stories.tsx +363 -0
- package/src/components/molecules/tooltip/tooltip.test.tsx +468 -0
- package/src/components/organisms/dialog/dialog.stories.tsx +522 -0
- package/src/components/organisms/dialog/dialog.test.tsx +525 -0
- package/src/components/organisms/dialog/index.tsx +233 -0
- package/src/components/organisms/dropdown/dropdown.stories.tsx +529 -0
- package/src/components/organisms/dropdown/dropdown.test.tsx +390 -0
- package/src/components/organisms/dropdown/index.tsx +624 -0
- package/src/index.css +184 -0
- package/src/lib/color-utils.ts +94 -0
- package/src/lib/utils.ts +6 -0
- package/src/main.tsx +10 -0
- package/src/stories/Colors.stories.tsx +107 -0
- package/src/stories/Shadows.stories.tsx +110 -0
- package/src/stories/Spacing.stories.tsx +121 -0
- package/src/stories/Typography.stories.tsx +197 -0
- package/src/vite-env.d.ts +1 -0
- package/tsconfig.app.json +33 -0
- package/tsconfig.json +13 -0
- package/tsconfig.node.json +25 -0
- package/vite.config.ts +43 -0
- package/vitest.config.ts +15 -0
- package/vitest.shims.d.ts +1 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { StorybookConfig } from '@storybook/react-vite';
|
|
2
|
+
|
|
3
|
+
const config: StorybookConfig = {
|
|
4
|
+
"stories": [
|
|
5
|
+
"../src/**/*.mdx",
|
|
6
|
+
"../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"
|
|
7
|
+
],
|
|
8
|
+
"addons": [
|
|
9
|
+
"@chromatic-com/storybook",
|
|
10
|
+
"@storybook/addon-docs",
|
|
11
|
+
"@storybook/addon-onboarding",
|
|
12
|
+
"@storybook/addon-a11y",
|
|
13
|
+
"@storybook/addon-vitest"
|
|
14
|
+
],
|
|
15
|
+
"framework": {
|
|
16
|
+
"name": "@storybook/react-vite",
|
|
17
|
+
"options": {}
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
export default config;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Preview } from '@storybook/react-vite'
|
|
2
|
+
import '../src/index.css'
|
|
3
|
+
|
|
4
|
+
const preview: Preview = {
|
|
5
|
+
parameters: {
|
|
6
|
+
controls: {
|
|
7
|
+
matchers: {
|
|
8
|
+
color: /(background|color)$/i,
|
|
9
|
+
date: /Date$/i,
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
a11y: {
|
|
13
|
+
test: 'todo',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default preview
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as a11yAddonAnnotations from "@storybook/addon-a11y/preview";
|
|
2
|
+
import { setProjectAnnotations } from '@storybook/react-vite';
|
|
3
|
+
import * as projectAnnotations from './preview';
|
|
4
|
+
|
|
5
|
+
// This is an important step to apply the right configuration when testing your stories.
|
|
6
|
+
// More info at: https://storybook.js.org/docs/api/portable-stories/portable-stories-vitest#setprojectannotations
|
|
7
|
+
setProjectAnnotations([a11yAddonAnnotations, projectAnnotations]);
|
package/README.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# React + TypeScript + Vite
|
|
2
|
+
|
|
3
|
+
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
|
4
|
+
|
|
5
|
+
Currently, two official plugins are available:
|
|
6
|
+
|
|
7
|
+
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) for Fast Refresh
|
|
8
|
+
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
|
|
9
|
+
|
|
10
|
+
## Expanding the ESLint configuration
|
|
11
|
+
|
|
12
|
+
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
|
|
13
|
+
|
|
14
|
+
```js
|
|
15
|
+
export default tseslint.config([
|
|
16
|
+
globalIgnores(['dist']),
|
|
17
|
+
{
|
|
18
|
+
files: ['**/*.{ts,tsx}'],
|
|
19
|
+
extends: [
|
|
20
|
+
// Other configs...
|
|
21
|
+
|
|
22
|
+
// Remove tseslint.configs.recommended and replace with this
|
|
23
|
+
...tseslint.configs.recommendedTypeChecked,
|
|
24
|
+
// Alternatively, use this for stricter rules
|
|
25
|
+
...tseslint.configs.strictTypeChecked,
|
|
26
|
+
// Optionally, add this for stylistic rules
|
|
27
|
+
...tseslint.configs.stylisticTypeChecked,
|
|
28
|
+
|
|
29
|
+
// Other configs...
|
|
30
|
+
],
|
|
31
|
+
languageOptions: {
|
|
32
|
+
parserOptions: {
|
|
33
|
+
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
|
34
|
+
tsconfigRootDir: import.meta.dirname,
|
|
35
|
+
},
|
|
36
|
+
// other options...
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
])
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
|
|
43
|
+
|
|
44
|
+
```js
|
|
45
|
+
// eslint.config.js
|
|
46
|
+
import reactX from 'eslint-plugin-react-x'
|
|
47
|
+
import reactDom from 'eslint-plugin-react-dom'
|
|
48
|
+
|
|
49
|
+
export default tseslint.config([
|
|
50
|
+
globalIgnores(['dist']),
|
|
51
|
+
{
|
|
52
|
+
files: ['**/*.{ts,tsx}'],
|
|
53
|
+
extends: [
|
|
54
|
+
// Other configs...
|
|
55
|
+
// Enable lint rules for React
|
|
56
|
+
reactX.configs['recommended-typescript'],
|
|
57
|
+
// Enable lint rules for React DOM
|
|
58
|
+
reactDom.configs.recommended,
|
|
59
|
+
],
|
|
60
|
+
languageOptions: {
|
|
61
|
+
parserOptions: {
|
|
62
|
+
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
|
63
|
+
tsconfigRootDir: import.meta.dirname,
|
|
64
|
+
},
|
|
65
|
+
// other options...
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
])
|
|
69
|
+
```
|
package/components.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema.json",
|
|
3
|
+
"style": "new-york",
|
|
4
|
+
"rsc": false,
|
|
5
|
+
"tsx": true,
|
|
6
|
+
"tailwind": {
|
|
7
|
+
"config": "",
|
|
8
|
+
"css": "src/index.css",
|
|
9
|
+
"baseColor": "neutral",
|
|
10
|
+
"cssVariables": true,
|
|
11
|
+
"prefix": ""
|
|
12
|
+
},
|
|
13
|
+
"aliases": {
|
|
14
|
+
"components": "@/components",
|
|
15
|
+
"utils": "@/lib/utils",
|
|
16
|
+
"ui": "@/components/ui",
|
|
17
|
+
"lib": "@/lib",
|
|
18
|
+
"hooks": "@/hooks"
|
|
19
|
+
},
|
|
20
|
+
"iconLibrary": "lucide"
|
|
21
|
+
}
|
package/eslint.config.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// For more info, see https://github.com/storybookjs/eslint-plugin-storybook#configuration-flat-config-format
|
|
2
|
+
import storybook from "eslint-plugin-storybook";
|
|
3
|
+
|
|
4
|
+
import js from '@eslint/js'
|
|
5
|
+
import globals from 'globals'
|
|
6
|
+
import reactHooks from 'eslint-plugin-react-hooks'
|
|
7
|
+
import reactRefresh from 'eslint-plugin-react-refresh'
|
|
8
|
+
import tseslint from 'typescript-eslint'
|
|
9
|
+
import { globalIgnores } from 'eslint/config'
|
|
10
|
+
|
|
11
|
+
export default tseslint.config([
|
|
12
|
+
{ ignores: ['dist', 'coverage/**', 'storybook-static/**'] },
|
|
13
|
+
{
|
|
14
|
+
files: ['**/*.{ts,tsx}'],
|
|
15
|
+
extends: [
|
|
16
|
+
js.configs.recommended,
|
|
17
|
+
tseslint.configs.recommended,
|
|
18
|
+
reactHooks.configs['recommended-latest'],
|
|
19
|
+
reactRefresh.configs.vite,
|
|
20
|
+
],
|
|
21
|
+
languageOptions: {
|
|
22
|
+
ecmaVersion: 2020,
|
|
23
|
+
globals: globals.browser,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
], storybook.configs["flat/recommended"]);
|
package/index.html
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>Vite + React + TS</title>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<div id="root"></div>
|
|
11
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@yuno-payments/dashboard-design-system",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "vite",
|
|
7
|
+
"build": "tsc -b && vite build",
|
|
8
|
+
"lint": "eslint .",
|
|
9
|
+
"preview": "vite preview",
|
|
10
|
+
"storybook": "storybook dev -p 6006",
|
|
11
|
+
"build-storybook": "storybook build",
|
|
12
|
+
"test": "vitest run",
|
|
13
|
+
"publish": "npm publish --access public"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@radix-ui/react-slot": "^1.2.3",
|
|
17
|
+
"@tailwindcss/vite": "^4.1.12",
|
|
18
|
+
"class-variance-authority": "^0.7.1",
|
|
19
|
+
"clsx": "^2.1.1",
|
|
20
|
+
"lucide-react": "^0.542.0",
|
|
21
|
+
"react": "^19.1.1",
|
|
22
|
+
"react-dom": "^19.1.1",
|
|
23
|
+
"tailwind-merge": "^3.3.1",
|
|
24
|
+
"tailwindcss": "^4.1.12"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@chromatic-com/storybook": "^4.1.1",
|
|
28
|
+
"@eslint/js": "^9.33.0",
|
|
29
|
+
"@storybook/addon-a11y": "^9.1.3",
|
|
30
|
+
"@storybook/addon-docs": "^9.1.3",
|
|
31
|
+
"@storybook/addon-onboarding": "^9.1.3",
|
|
32
|
+
"@storybook/addon-vitest": "^9.1.3",
|
|
33
|
+
"@storybook/react-vite": "^9.1.3",
|
|
34
|
+
"@testing-library/jest-dom": "^6.8.0",
|
|
35
|
+
"@testing-library/react": "^16.3.0",
|
|
36
|
+
"@types/node": "^24.3.0",
|
|
37
|
+
"@types/react": "^19.1.10",
|
|
38
|
+
"@types/react-dom": "^19.1.7",
|
|
39
|
+
"@vitejs/plugin-react": "^5.0.0",
|
|
40
|
+
"@vitest/browser": "^3.2.4",
|
|
41
|
+
"@vitest/coverage-v8": "^3.2.4",
|
|
42
|
+
"eslint": "^9.33.0",
|
|
43
|
+
"eslint-plugin-react-hooks": "^5.2.0",
|
|
44
|
+
"eslint-plugin-react-refresh": "^0.4.20",
|
|
45
|
+
"eslint-plugin-storybook": "^9.1.3",
|
|
46
|
+
"globals": "^16.3.0",
|
|
47
|
+
"jsdom": "^26.1.0",
|
|
48
|
+
"playwright": "^1.55.0",
|
|
49
|
+
"storybook": "^9.1.3",
|
|
50
|
+
"tw-animate-css": "^1.3.7",
|
|
51
|
+
"typescript": "~5.8.3",
|
|
52
|
+
"typescript-eslint": "^8.39.1",
|
|
53
|
+
"vite": "^7.1.2",
|
|
54
|
+
"vite-tsconfig-paths": "^5.1.4",
|
|
55
|
+
"vitest": "^3.2.4"
|
|
56
|
+
}
|
|
57
|
+
}
|
package/public/vite.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
package/src/App.css
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#root {
|
|
2
|
+
max-width: 1280px;
|
|
3
|
+
margin: 0 auto;
|
|
4
|
+
padding: 2rem;
|
|
5
|
+
text-align: center;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.logo {
|
|
9
|
+
height: 6em;
|
|
10
|
+
padding: 1.5em;
|
|
11
|
+
will-change: filter;
|
|
12
|
+
transition: filter 300ms;
|
|
13
|
+
}
|
|
14
|
+
.logo:hover {
|
|
15
|
+
filter: drop-shadow(0 0 2em #646cffaa);
|
|
16
|
+
}
|
|
17
|
+
.logo.react:hover {
|
|
18
|
+
filter: drop-shadow(0 0 2em #61dafbaa);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@keyframes logo-spin {
|
|
22
|
+
from {
|
|
23
|
+
transform: rotate(0deg);
|
|
24
|
+
}
|
|
25
|
+
to {
|
|
26
|
+
transform: rotate(360deg);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
31
|
+
a:nth-of-type(2) .logo {
|
|
32
|
+
animation: logo-spin infinite 20s linear;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.card {
|
|
37
|
+
padding: 2em;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.read-the-docs {
|
|
41
|
+
color: #888;
|
|
42
|
+
}
|
package/src/App.tsx
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite'
|
|
2
|
+
import { Plus, ArrowRight, Download, Trash2, Settings } from 'lucide-react'
|
|
3
|
+
import { Button } from './index'
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof Button> = {
|
|
6
|
+
title: 'Atoms/Button',
|
|
7
|
+
component: Button,
|
|
8
|
+
parameters: {
|
|
9
|
+
layout: 'centered',
|
|
10
|
+
},
|
|
11
|
+
tags: ['autodocs'],
|
|
12
|
+
argTypes: {
|
|
13
|
+
children: {
|
|
14
|
+
control: 'text',
|
|
15
|
+
description: 'Button text content',
|
|
16
|
+
},
|
|
17
|
+
variant: {
|
|
18
|
+
control: 'select',
|
|
19
|
+
options: ['default', 'destructive', 'outline', 'secondary', 'ghost', 'link'],
|
|
20
|
+
description: 'Button visual variant',
|
|
21
|
+
},
|
|
22
|
+
size: {
|
|
23
|
+
control: 'select',
|
|
24
|
+
options: ['default', 'sm', 'lg', 'icon'],
|
|
25
|
+
description: 'Button size variant',
|
|
26
|
+
},
|
|
27
|
+
disabled: {
|
|
28
|
+
control: 'boolean',
|
|
29
|
+
description: 'Whether the button is disabled',
|
|
30
|
+
},
|
|
31
|
+
asChild: {
|
|
32
|
+
control: 'boolean',
|
|
33
|
+
description: 'Render as child component using Radix Slot',
|
|
34
|
+
},
|
|
35
|
+
label: {
|
|
36
|
+
control: 'text',
|
|
37
|
+
description: 'Alternative to children prop',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export default meta
|
|
43
|
+
type Story = StoryObj<typeof meta>
|
|
44
|
+
|
|
45
|
+
export const Default: Story = {
|
|
46
|
+
args: {
|
|
47
|
+
children: 'Default Button',
|
|
48
|
+
variant: 'default',
|
|
49
|
+
size: 'default',
|
|
50
|
+
disabled: false,
|
|
51
|
+
},
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const Destructive: Story = {
|
|
55
|
+
args: {
|
|
56
|
+
children: 'Delete',
|
|
57
|
+
variant: 'destructive',
|
|
58
|
+
startIcon: <Trash2 />,
|
|
59
|
+
},
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export const Outline: Story = {
|
|
63
|
+
args: {
|
|
64
|
+
children: 'Outline Button',
|
|
65
|
+
variant: 'outline',
|
|
66
|
+
},
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export const Secondary: Story = {
|
|
70
|
+
args: {
|
|
71
|
+
children: 'Secondary Button',
|
|
72
|
+
variant: 'secondary',
|
|
73
|
+
},
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export const Ghost: Story = {
|
|
77
|
+
args: {
|
|
78
|
+
children: 'Ghost Button',
|
|
79
|
+
variant: 'ghost',
|
|
80
|
+
},
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export const Link: Story = {
|
|
84
|
+
args: {
|
|
85
|
+
children: 'Link Button',
|
|
86
|
+
variant: 'link',
|
|
87
|
+
},
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export const WithStartIcon: Story = {
|
|
91
|
+
args: {
|
|
92
|
+
children: 'Download',
|
|
93
|
+
startIcon: <Download />,
|
|
94
|
+
},
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export const WithEndIcon: Story = {
|
|
98
|
+
args: {
|
|
99
|
+
children: 'Continue',
|
|
100
|
+
endIcon: <ArrowRight />,
|
|
101
|
+
},
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export const WithBothIcons: Story = {
|
|
105
|
+
args: {
|
|
106
|
+
children: 'Settings',
|
|
107
|
+
startIcon: <Settings />,
|
|
108
|
+
endIcon: <ArrowRight />,
|
|
109
|
+
},
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export const IconOnly: Story = {
|
|
113
|
+
args: {
|
|
114
|
+
size: 'icon',
|
|
115
|
+
children: <Plus />,
|
|
116
|
+
'aria-label': 'Add item',
|
|
117
|
+
},
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export const Disabled: Story = {
|
|
121
|
+
args: {
|
|
122
|
+
children: 'Disabled Button',
|
|
123
|
+
disabled: true,
|
|
124
|
+
},
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export const Sizes: Story = {
|
|
128
|
+
render: () => (
|
|
129
|
+
<div className="space-y-4">
|
|
130
|
+
<div className="space-y-2">
|
|
131
|
+
<h3 className="text-lg font-semibold">Small Size</h3>
|
|
132
|
+
<div className="space-x-4">
|
|
133
|
+
<Button size="sm">Small Default</Button>
|
|
134
|
+
<Button size="sm" variant="outline">Small Outline</Button>
|
|
135
|
+
<Button size="sm" startIcon={<Plus />}>Small with Icon</Button>
|
|
136
|
+
</div>
|
|
137
|
+
</div>
|
|
138
|
+
|
|
139
|
+
<div className="space-y-2">
|
|
140
|
+
<h3 className="text-lg font-semibold">Default Size</h3>
|
|
141
|
+
<div className="space-x-4">
|
|
142
|
+
<Button size="default">Default Size</Button>
|
|
143
|
+
<Button size="default" variant="outline">Default Outline</Button>
|
|
144
|
+
<Button size="default" startIcon={<Plus />}>Default with Icon</Button>
|
|
145
|
+
</div>
|
|
146
|
+
</div>
|
|
147
|
+
|
|
148
|
+
<div className="space-y-2">
|
|
149
|
+
<h3 className="text-lg font-semibold">Large Size</h3>
|
|
150
|
+
<div className="space-x-4">
|
|
151
|
+
<Button size="lg">Large Size</Button>
|
|
152
|
+
<Button size="lg" variant="outline">Large Outline</Button>
|
|
153
|
+
<Button size="lg" startIcon={<Plus />}>Large with Icon</Button>
|
|
154
|
+
</div>
|
|
155
|
+
</div>
|
|
156
|
+
|
|
157
|
+
<div className="space-y-2">
|
|
158
|
+
<h3 className="text-lg font-semibold">Icon Only</h3>
|
|
159
|
+
<div className="space-x-4">
|
|
160
|
+
<Button size="icon"><Plus /></Button>
|
|
161
|
+
<Button size="icon" variant="outline"><Settings /></Button>
|
|
162
|
+
<Button size="icon" variant="destructive"><Trash2 /></Button>
|
|
163
|
+
</div>
|
|
164
|
+
</div>
|
|
165
|
+
</div>
|
|
166
|
+
),
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export const AllVariants: Story = {
|
|
170
|
+
render: () => (
|
|
171
|
+
<div className="space-y-6">
|
|
172
|
+
<div>
|
|
173
|
+
<h3 className="text-lg font-semibold mb-4">Default Buttons</h3>
|
|
174
|
+
<div className="space-y-2">
|
|
175
|
+
<div className="space-x-4">
|
|
176
|
+
<Button variant="default">Default</Button>
|
|
177
|
+
<Button variant="destructive">Destructive</Button>
|
|
178
|
+
<Button variant="outline">Outline</Button>
|
|
179
|
+
<Button variant="secondary">Secondary</Button>
|
|
180
|
+
<Button variant="ghost">Ghost</Button>
|
|
181
|
+
<Button variant="link">Link</Button>
|
|
182
|
+
</div>
|
|
183
|
+
</div>
|
|
184
|
+
</div>
|
|
185
|
+
|
|
186
|
+
<div>
|
|
187
|
+
<h3 className="text-lg font-semibold mb-4">Buttons with Icons</h3>
|
|
188
|
+
<div className="space-y-2">
|
|
189
|
+
<div className="space-x-4">
|
|
190
|
+
<Button startIcon={<Download />}>Download</Button>
|
|
191
|
+
<Button variant="outline" endIcon={<ArrowRight />}>Continue</Button>
|
|
192
|
+
<Button variant="destructive" startIcon={<Trash2 />}>Delete</Button>
|
|
193
|
+
<Button variant="secondary" startIcon={<Settings />} endIcon={<ArrowRight />}>Settings</Button>
|
|
194
|
+
</div>
|
|
195
|
+
</div>
|
|
196
|
+
</div>
|
|
197
|
+
|
|
198
|
+
<div>
|
|
199
|
+
<h3 className="text-lg font-semibold mb-4">Different Sizes</h3>
|
|
200
|
+
<div className="space-y-2">
|
|
201
|
+
<div className="space-x-4 flex items-center">
|
|
202
|
+
<Button size="sm">Small</Button>
|
|
203
|
+
<Button size="default">Default</Button>
|
|
204
|
+
<Button size="lg">Large</Button>
|
|
205
|
+
<Button size="icon"><Plus /></Button>
|
|
206
|
+
</div>
|
|
207
|
+
</div>
|
|
208
|
+
</div>
|
|
209
|
+
|
|
210
|
+
<div>
|
|
211
|
+
<h3 className="text-lg font-semibold mb-4">Disabled States</h3>
|
|
212
|
+
<div className="space-y-2">
|
|
213
|
+
<div className="space-x-4">
|
|
214
|
+
<Button disabled>Disabled Default</Button>
|
|
215
|
+
<Button variant="outline" disabled>Disabled Outline</Button>
|
|
216
|
+
<Button variant="destructive" disabled startIcon={<Trash2 />}>Disabled Destructive</Button>
|
|
217
|
+
</div>
|
|
218
|
+
</div>
|
|
219
|
+
</div>
|
|
220
|
+
</div>
|
|
221
|
+
),
|
|
222
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { describe, it, expect, vi } from 'vitest'
|
|
2
|
+
import * as React from 'react'
|
|
3
|
+
import { createRoot } from 'react-dom/client'
|
|
4
|
+
import { act } from 'react-dom/test-utils'
|
|
5
|
+
import { Button } from './index'
|
|
6
|
+
|
|
7
|
+
function render(ui: React.ReactElement) {
|
|
8
|
+
const container = document.createElement('div')
|
|
9
|
+
document.body.appendChild(container)
|
|
10
|
+
const root = createRoot(container)
|
|
11
|
+
act(() => {
|
|
12
|
+
root.render(ui)
|
|
13
|
+
})
|
|
14
|
+
return { container, root }
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function getByRole(container: HTMLElement, role: string) {
|
|
18
|
+
const el = Array.from(container.querySelectorAll('*')).find((n) => n.getAttribute('role') === role || n.tagName.toLowerCase() === role)
|
|
19
|
+
if (!el) throw new Error(`Element with role ${role} not found`)
|
|
20
|
+
return el as HTMLElement
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
describe('Button', () => {
|
|
24
|
+
it('renders children', () => {
|
|
25
|
+
const { container } = render(<Button>Test Button</Button>)
|
|
26
|
+
expect(container.textContent).toContain('Test Button')
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it('renders label when children not provided', () => {
|
|
30
|
+
const { container } = render(<Button label="Label" />)
|
|
31
|
+
expect(container.textContent).toContain('Label')
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
it('calls onClick', () => {
|
|
35
|
+
const onClick = vi.fn()
|
|
36
|
+
const { container } = render(<Button onClick={onClick}>Click</Button>)
|
|
37
|
+
const btn = getByRole(container, 'button') as HTMLButtonElement
|
|
38
|
+
act(() => {
|
|
39
|
+
btn.click()
|
|
40
|
+
})
|
|
41
|
+
expect(onClick).toHaveBeenCalledTimes(1)
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
it('disabled prevents click', () => {
|
|
45
|
+
const onClick = vi.fn()
|
|
46
|
+
const { container } = render(<Button disabled onClick={onClick}>Disabled</Button>)
|
|
47
|
+
const btn = getByRole(container, 'button') as HTMLButtonElement
|
|
48
|
+
act(() => {
|
|
49
|
+
btn.click()
|
|
50
|
+
})
|
|
51
|
+
expect(onClick).toHaveBeenCalledTimes(0)
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
it('applies outline variant', () => {
|
|
55
|
+
const { container } = render(<Button variant="outline">Outlined</Button>)
|
|
56
|
+
const btn = getByRole(container, 'button')
|
|
57
|
+
expect(btn.className).toMatch(/border/)
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
it('applies secondary variant classes', () => {
|
|
61
|
+
const { container } = render(<Button variant="secondary">Secondary</Button>)
|
|
62
|
+
const btn = getByRole(container, 'button')
|
|
63
|
+
expect(btn.className).toMatch(/bg-secondary/)
|
|
64
|
+
expect(btn.className).toMatch(/text-secondary-foreground/)
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
it('applies destructive variant classes', () => {
|
|
68
|
+
const { container } = render(<Button variant="destructive">Danger</Button>)
|
|
69
|
+
const btn = getByRole(container, 'button')
|
|
70
|
+
expect(btn.className).toMatch(/bg-destructive/)
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
it('renders icons when provided', () => {
|
|
74
|
+
const Icon = () => <span data-testid="icon">i</span>
|
|
75
|
+
const { container } = render(<Button startIcon={<Icon />} endIcon={<Icon />}>Label</Button>)
|
|
76
|
+
expect(container.querySelectorAll('[data-testid="icon"]').length).toBe(2)
|
|
77
|
+
})
|
|
78
|
+
})
|