@nearform/quantum 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 (59) hide show
  1. package/.commitlintrc +5 -0
  2. package/.editorconfig +6 -0
  3. package/.eslintrc +11 -0
  4. package/.github/ISSUE_TEMPLATE/component-issue-template.md +13 -0
  5. package/.github/ISSUE_TEMPLATE/tailwind-config-customisation-issue.md +11 -0
  6. package/.github/dependabot.yml +10 -0
  7. package/.github/workflows/check-linked-issues.yml +20 -0
  8. package/.github/workflows/ci.yml +31 -0
  9. package/.github/workflows/deploy-github-pages.yml +44 -0
  10. package/.github/workflows/notify-release.yml +19 -0
  11. package/.github/workflows/release.yml +29 -0
  12. package/.husky/commit-msg +4 -0
  13. package/.husky/pre-commit +4 -0
  14. package/.nvmrc +1 -0
  15. package/.prettierrc +6 -0
  16. package/.storybook/main.ts +34 -0
  17. package/.storybook/manager.ts +6 -0
  18. package/.storybook/preview.ts +21 -0
  19. package/.storybook/theme.ts +6 -0
  20. package/.svg-to-tsrc +18 -0
  21. package/README.md +32 -0
  22. package/dist/global.css +678 -0
  23. package/dist/global.css.map +1 -0
  24. package/dist/index.d.ts +137 -0
  25. package/dist/index.js +3537 -0
  26. package/dist/index.js.map +1 -0
  27. package/index.js +0 -0
  28. package/package.json +68 -0
  29. package/postcss.config.js +3 -0
  30. package/src/assets/build/check.icon.tsx +16 -0
  31. package/src/assets/build/minus.icon.tsx +14 -0
  32. package/src/assets/build/radioselected.icon.tsx +7 -0
  33. package/src/assets/index.ts +3 -0
  34. package/src/assets/svg-icons/check.svg +5 -0
  35. package/src/assets/svg-icons/minus.svg +5 -0
  36. package/src/assets/svg-icons/radio-selected.svg +5 -0
  37. package/src/colors.ts +164 -0
  38. package/src/components/Button/index.tsx +72 -0
  39. package/src/components/Checkbox/index.tsx +32 -0
  40. package/src/components/Label/index.tsx +26 -0
  41. package/src/components/Radio/RadioGroup.tsx +20 -0
  42. package/src/components/Radio/RadioGroupItem.tsx +26 -0
  43. package/src/components/Radio/index.tsx +2 -0
  44. package/src/global.css +4 -0
  45. package/src/index.ts +2 -0
  46. package/src/lib/utils.ts +6 -0
  47. package/stories/Button/Button.stories.tsx +74 -0
  48. package/stories/Checkbox/CheckBox.example.tsx +16 -0
  49. package/stories/Checkbox/Checkbox.stories.ts +42 -0
  50. package/stories/Colors.mdx +49 -0
  51. package/stories/Label/Label.example.tsx +20 -0
  52. package/stories/Label/Label.stories.ts +27 -0
  53. package/stories/Radio/Radio.example.tsx +39 -0
  54. package/stories/Radio/Radio.stories.ts +32 -0
  55. package/stories/global.css +6 -0
  56. package/stories/tailwind.config.js +5 -0
  57. package/tailwind.config.js +47 -0
  58. package/tsconfig.json +14 -0
  59. package/tsup.config.ts +8 -0
package/package.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "@nearform/quantum",
3
+ "version": "0.0.1",
4
+ "description": "Component library based on the Quantum Design System",
5
+ "main": "dist/index.js",
6
+ "scripts": {
7
+ "build": "tsup",
8
+ "lint": "eslint .",
9
+ "test": "echo \"Error: no test specified\" && exit 0",
10
+ "prepare": "husky install",
11
+ "storybook": "storybook dev -p 6006",
12
+ "build-storybook": "storybook build"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/nearform/quantum.git"
17
+ },
18
+ "keywords": [],
19
+ "author": "",
20
+ "license": "ISC",
21
+ "bugs": {
22
+ "url": "https://github.com/nearform/quantum/issues"
23
+ },
24
+ "homepage": "https://github.com/nearform/quantum#readme",
25
+ "lint-staged": {
26
+ "*.{js,jsx}": "eslint --cache --fix"
27
+ },
28
+ "devDependencies": {
29
+ "@commitlint/cli": "^18.0.0",
30
+ "@commitlint/config-conventional": "^18.0.0",
31
+ "@storybook/addon-essentials": "^7.5.1",
32
+ "@storybook/addon-interactions": "^7.5.1",
33
+ "@storybook/addon-links": "^7.5.1",
34
+ "@storybook/addon-onboarding": "^1.0.8",
35
+ "@storybook/blocks": "^7.5.1",
36
+ "@storybook/react": "^7.5.1",
37
+ "@storybook/react-vite": "^7.5.1",
38
+ "@storybook/testing-library": "^0.2.2",
39
+ "autoprefixer": "^10.4.16",
40
+ "eslint": "^8.52.0",
41
+ "eslint-config-prettier": "^9.0.0",
42
+ "eslint-plugin-prettier": "^5.0.1",
43
+ "eslint-plugin-storybook": "^0.6.15",
44
+ "husky": "^8.0.3",
45
+ "lint-staged": "^15.0.2",
46
+ "prettier": "^3.0.3",
47
+ "react": "^18.2.0",
48
+ "react-dom": "^18.2.0",
49
+ "storybook": "^7.5.1",
50
+ "storybook-tailwind-dark-mode": "^1.0.22",
51
+ "tailwindcss": "^3.3.3",
52
+ "tsup": "^7.2.0",
53
+ "typescript": "^5.2.2"
54
+ },
55
+ "eslintConfig": {
56
+ "extends": [
57
+ "plugin:storybook/recommended"
58
+ ]
59
+ },
60
+ "dependencies": {
61
+ "@radix-ui/react-checkbox": "^1.0.4",
62
+ "@radix-ui/react-label": "^2.0.2",
63
+ "@radix-ui/react-radio-group": "^1.1.3",
64
+ "class-variance-authority": "^0.7.0",
65
+ "clsx": "^2.0.0",
66
+ "tailwind-merge": "^1.14.0"
67
+ }
68
+ }
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ plugins: [require('tailwindcss')(), require('autoprefixer')()]
3
+ }
@@ -0,0 +1,16 @@
1
+ /* 🤖 this file was generated by svg-to-ts */
2
+ export const Check = (props: any) => (
3
+ <svg
4
+ viewBox="0 0 24 24"
5
+ fill="none"
6
+ xmlns="http://www.w3.org/2000/svg"
7
+ {...props}
8
+ >
9
+ <g id="check">
10
+ <path
11
+ id="Vector"
12
+ d="M9.72648 17.5L9.72217 17.5C9.60611 17.5005 9.4852 17.4519 9.38785 17.3489L4.66647 12.3507C4.66633 12.3506 4.6662 12.3504 4.66607 12.3503C4.6169 12.2978 4.57557 12.233 4.54633 12.1585L4.08221 12.3408L4.54633 12.1585C4.517 12.0838 4.50096 12.0022 4.50004 11.9186C4.49817 11.748 4.55898 11.5911 4.65755 11.481C4.75482 11.3723 4.87789 11.3197 4.99627 11.3182C5.11455 11.3166 5.23805 11.3658 5.33701 11.4712L5.33813 11.4724L9.36492 15.7335L9.72855 16.1183L10.0919 15.7333L18.6614 6.65376L18.662 6.65306C18.7612 6.54761 18.8849 6.4984 19.0033 6.50004C19.1219 6.50168 19.2451 6.55443 19.3425 6.66337C19.4412 6.77376 19.5019 6.93091 19.5 7.10171C19.498 7.27229 19.4337 7.42694 19.3334 7.53385C19.3333 7.53398 19.3332 7.5341 19.3331 7.53423L10.0608 17.3489C9.96345 17.4519 9.84254 17.5005 9.72648 17.5Z"
13
+ />
14
+ </g>
15
+ </svg>
16
+ )
@@ -0,0 +1,14 @@
1
+ /* 🤖 this file was generated by svg-to-ts */
2
+ export const Minus = (props: any) => (
3
+ <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" {...props}>
4
+ <g id="minus">
5
+ <path
6
+ id="Vector"
7
+ d="M19 12L5 12"
8
+ strokeWidth="inherit"
9
+ strokeLinecap="round"
10
+ strokeLinejoin="round"
11
+ />
12
+ </g>
13
+ </svg>
14
+ )
@@ -0,0 +1,7 @@
1
+ export const RadioSelected = (props: any) => (
2
+ <svg xmlns="http://www.w3.org/2000/svg" {...props} viewBox="0 0 20 20">
3
+ <g id="State=Selected">
4
+ <circle id="Ellipse 1" cx={10} cy={10} r={4} />
5
+ </g>
6
+ </svg>
7
+ )
@@ -0,0 +1,3 @@
1
+ export * from './build/check.icon'
2
+ export * from './build/minus.icon'
3
+ export * from './build/radioselected.icon'
@@ -0,0 +1,5 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <g id="check">
3
+ <path id="Vector" d="M9.72648 17.5L9.72217 17.5C9.60611 17.5005 9.4852 17.4519 9.38785 17.3489L4.66647 12.3507C4.66633 12.3506 4.6662 12.3504 4.66607 12.3503C4.6169 12.2978 4.57557 12.233 4.54633 12.1585L4.08221 12.3408L4.54633 12.1585C4.517 12.0838 4.50096 12.0022 4.50004 11.9186C4.49817 11.748 4.55898 11.5911 4.65755 11.481C4.75482 11.3723 4.87789 11.3197 4.99627 11.3182C5.11455 11.3166 5.23805 11.3658 5.33701 11.4712L5.33813 11.4724L9.36492 15.7335L9.72855 16.1183L10.0919 15.7333L18.6614 6.65376L18.662 6.65306C18.7612 6.54761 18.8849 6.4984 19.0033 6.50004C19.1219 6.50168 19.2451 6.55443 19.3425 6.66337C19.4412 6.77376 19.5019 6.93091 19.5 7.10171C19.498 7.27229 19.4337 7.42694 19.3334 7.53385C19.3333 7.53398 19.3332 7.5341 19.3331 7.53423L10.0608 17.3489C9.96345 17.4519 9.84254 17.5005 9.72648 17.5Z" fill="#111928" stroke="#111928"/>
4
+ </g>
5
+ </svg>
@@ -0,0 +1,5 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <g id="minus">
3
+ <path id="Vector" d="M19 12L5 12" stroke="#111928" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
4
+ </g>
5
+ </svg>
@@ -0,0 +1,5 @@
1
+ <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <g id="State=Selected">
3
+ <circle id="Ellipse 1" cx="10" cy="10" r="4" fill="white"/>
4
+ </g>
5
+ </svg>
package/src/colors.ts ADDED
@@ -0,0 +1,164 @@
1
+ export const colors = {
2
+ grey: {
3
+ 50: '#F9FAFB',
4
+ 100: '#F3F4F6',
5
+ 200: '#E5E7EB',
6
+ 300: '#D1D5DB',
7
+ 400: '#9CA3AF',
8
+ 500: '#6B7280',
9
+ 600: '#4B5563',
10
+ 700: '#374151',
11
+ 800: '#1F2A37',
12
+ 900: '#111928'
13
+ },
14
+ blue: {
15
+ 50: '#F5FAFF',
16
+ 100: '#E1EFFE',
17
+ 200: '#C3DDFD',
18
+ 300: '#A4CAFE',
19
+ 400: '#76A9FA',
20
+ 500: '#3F83F8',
21
+ 600: '#2165E3',
22
+ 700: '#1A56DB',
23
+ 800: '#1E429F',
24
+ 900: '#233876'
25
+ },
26
+ red: {
27
+ 50: '#FDF2F2',
28
+ 100: '#FDE8E8',
29
+ 200: '#FBD5D5',
30
+ 300: '#F8B4B4',
31
+ 400: '#F98080',
32
+ 500: '#F05252',
33
+ 600: '#E02424',
34
+ 700: '#C81E1E',
35
+ 800: '#9B1C1C',
36
+ 900: '#771D1D'
37
+ },
38
+ orange: {
39
+ 50: '#FFF8F1',
40
+ 100: '#FEECDC',
41
+ 200: '#FCD9BD',
42
+ 300: '#FDBA8C',
43
+ 400: '#FF8A4C',
44
+ 500: '#FF5A1F',
45
+ 600: '#D03801',
46
+ 700: '#B43403',
47
+ 800: '#8A2C0D',
48
+ 900: '#771D1D'
49
+ },
50
+ yellow: {
51
+ 50: '#FDFDEA',
52
+ 100: '#FDF6B2',
53
+ 200: '#FCE96A',
54
+ 300: '#FACA15',
55
+ 400: '#E3A008',
56
+ 500: '#C27803',
57
+ 600: '#9F580A',
58
+ 700: '#8E4B10',
59
+ 800: '#723B13',
60
+ 900: '#633112'
61
+ },
62
+ green: {
63
+ 50: '#F3FAF7',
64
+ 100: '#DEF7EC',
65
+ 200: '#BCF0DA',
66
+ 300: '#84E1BC',
67
+ 400: '#31C48D',
68
+ 500: '#0E9F6E',
69
+ 600: '#057A55',
70
+ 700: '#046C4E',
71
+ 800: '#03543F',
72
+ 900: '#014737'
73
+ },
74
+ teal: {
75
+ 50: '#EDFAFA',
76
+ 100: '#D5F5F6',
77
+ 200: '#AFECEF',
78
+ 300: '#7EDCE2',
79
+ 400: '#16BDCA',
80
+ 500: '#0694A2',
81
+ 600: '#047481',
82
+ 700: '#036672',
83
+ 800: '#05505C',
84
+ 900: '#014451'
85
+ },
86
+ indigo: {
87
+ 50: '#F0F5FF',
88
+ 100: '#E5EDFF',
89
+ 200: '#CDDBFE',
90
+ 300: '#B4C6FC',
91
+ 400: '#8DA2FB',
92
+ 500: '#6875F5',
93
+ 600: '#5850EC',
94
+ 700: '#5145CD',
95
+ 800: '#42389D',
96
+ 900: '#362F78'
97
+ },
98
+ purple: {
99
+ 50: '#F6F5FF',
100
+ 100: '#EDEBFE',
101
+ 200: '#DCD7FE',
102
+ 300: '#CABFFD',
103
+ 400: '#AC94FA',
104
+ 500: '#9061F9',
105
+ 600: '#7E3AF2',
106
+ 700: '#6C2BD9',
107
+ 800: '#5521B5',
108
+ 900: '#4A1D96'
109
+ },
110
+ pink: {
111
+ 50: '#FFF6F9',
112
+ 100: '#FFF1F5',
113
+ 200: '#FFE8EE',
114
+ 300: '#FFD9E3',
115
+ 400: '#FFBFD0',
116
+ 500: '#FF9DB7',
117
+ 600: '#FB7A9C',
118
+ 700: '#D95477',
119
+ 800: '#A02042',
120
+ 900: '#731837'
121
+ }
122
+ };
123
+
124
+ export default {
125
+ transparent: 'transparent',
126
+ current: 'currentColor',
127
+ primary: colors.blue,
128
+ secondary: colors.pink,
129
+ foreground: {
130
+ DEFAULT: colors.grey['900'],
131
+ muted: colors.grey['500'],
132
+ subtle: colors.grey['400'],
133
+ inverse: '#FFF'
134
+ },
135
+ accent: {
136
+ DEFAULT: colors.blue['700'],
137
+ hover: colors.grey['900'],
138
+ focus: '#000'
139
+ },
140
+ border: {
141
+ DEFAULT: colors.grey['300'],
142
+ hover: colors.grey['400'],
143
+ subtle: colors.grey['200']
144
+ },
145
+ feedback: {
146
+ green: colors.green['400'],
147
+ yellow: colors.yellow['300'],
148
+ orange: colors.orange['400'],
149
+ red: colors.red['600']
150
+ },
151
+ button: {
152
+ active: colors.blue['700'],
153
+ hover: colors.grey['900'],
154
+ focus: '#000',
155
+ disabled: colors.purple['50']
156
+ },
157
+ white: {
158
+ DEFAULT: '#fff'
159
+ },
160
+ black: {
161
+ DEFAULT: '#000'
162
+ },
163
+ ...colors
164
+ };
@@ -0,0 +1,72 @@
1
+ import * as React from 'react'
2
+ import { Slot } from '@radix-ui/react-slot'
3
+ import { cva, type VariantProps } from 'class-variance-authority'
4
+
5
+ import { cn } from '@/lib/utils'
6
+
7
+ const buttonVariants = cva(
8
+ 'inline-flex items-center justify-center whitespace-nowrap rounded-lg transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none border-2',
9
+ {
10
+ variants: {
11
+ variant: {
12
+ primary:
13
+ 'bg-button-active border-button-active text-white ' +
14
+ 'hover:bg-button-hover hover:border-button-hover ' +
15
+ 'focus:bg-button-focus focus:border-button-focus ' +
16
+ 'disabled:bg-button-disabled disabled:text-foreground-subtle disabled:border-button-disabled',
17
+ secondary:
18
+ 'bg-white text-grey-900 border-border ' +
19
+ 'hover:bg-button-disabled hover:border-border ' +
20
+ 'focus:bg-primary-50 focus:border-foreground-muted ' +
21
+ 'disabled:bg-button-disabled disabled:border-border-subtle disabled:text-foreground-subtle',
22
+ tertiary:
23
+ 'bg-transparent border-transparent text-foreground ' +
24
+ 'hover:bg-purple-50 hover:border-purple-50 ' +
25
+ 'focus:bg-blue-50 focus:border-blue-50 ' +
26
+ 'disabled:text-foreground-subtle',
27
+ success:
28
+ 'bg-green-400 border-green-400 text-black ' +
29
+ 'hover:bg-green-500 hover:border-green-500 ' +
30
+ 'focus:bg-green-600 focus:border-green-600 ' +
31
+ 'disabled:bg-button-disabled disabled:border-button-disabled disabled:text-foreground-subtle',
32
+ danger:
33
+ 'bg-red-600 border-red-600 text-white ' +
34
+ 'hover:bg-red-700 hover:border-red-700 ' +
35
+ 'focus:bg-red-800 focus:border-red-800 ' +
36
+ 'disabled:bg-button-disabled disabled:border-button-disabled disabled:text-foreground-subtle',
37
+ },
38
+ size: {
39
+ lg: 'px-4 py-3 text-base',
40
+ md: 'p-2.5 text-sm',
41
+ sm: 'px-2.5 py-2 text-sm',
42
+ xs: 'px-2 py-2.5 text-xs',
43
+ }
44
+ },
45
+ defaultVariants: {
46
+ variant: 'primary',
47
+ size: 'md'
48
+ }
49
+ }
50
+ )
51
+
52
+ export interface ButtonProps
53
+ extends React.ButtonHTMLAttributes<HTMLButtonElement>,
54
+ VariantProps<typeof buttonVariants> {
55
+ asChild?: boolean
56
+ }
57
+
58
+ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
59
+ ({ className, variant, size, asChild = false, ...props }, ref) => {
60
+ const Comp = asChild ? Slot : 'button'
61
+ return (
62
+ <Comp
63
+ className={cn(buttonVariants({ variant, size, className }))}
64
+ ref={ref}
65
+ {...props}
66
+ />
67
+ )
68
+ }
69
+ )
70
+ Button.displayName = 'Button'
71
+
72
+ export { Button, buttonVariants }
@@ -0,0 +1,32 @@
1
+ import * as React from 'react'
2
+ import * as CheckboxPrimitive from '@radix-ui/react-checkbox'
3
+ import { cn } from '@/lib/utils'
4
+ import { Check, Minus } from '@/assets/index'
5
+
6
+ const Checkbox = React.forwardRef<
7
+ React.ElementRef<typeof CheckboxPrimitive.Root>,
8
+ React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
9
+ >(({ className, ...props }, ref) => (
10
+ <CheckboxPrimitive.Root
11
+ ref={ref}
12
+ className={cn(
13
+ 'peer h-5 w-5 p-0.5 shrink-0 gap-0 rounded border border-border-default data-[state=checked]:border-blue-600 data-[state=checked]:bg-blue-600 data-[state=checked]:text-foreground-inverse data-[state=indeterminate]:border-blue-600 data-[state=indeterminate]:bg-blue-600 data-[state=indeterminate]:text-foreground-inverse',
14
+ className
15
+ )}
16
+ {...props}
17
+ >
18
+ <CheckboxPrimitive.Indicator
19
+ className={cn('flex items-center justify-center text-inherit')}
20
+ >
21
+ {(props.checked === true || props.checked === undefined) && (
22
+ <Check className="text-inherit stroke-current stroke-1 fill-current" />
23
+ )}
24
+ {props.checked === 'indeterminate' && (
25
+ <Minus className="text-inherit stroke-current stroke-3 fill-current" />
26
+ )}
27
+ </CheckboxPrimitive.Indicator>
28
+ </CheckboxPrimitive.Root>
29
+ ))
30
+ Checkbox.displayName = CheckboxPrimitive.Root.displayName
31
+
32
+ export { Checkbox }
@@ -0,0 +1,26 @@
1
+ 'use client'
2
+
3
+ import * as React from 'react'
4
+ import * as LabelPrimitive from '@radix-ui/react-label'
5
+ import type { LabelProps } from '@radix-ui/react-label'
6
+ import { cva, type VariantProps } from 'class-variance-authority'
7
+
8
+ import { cn } from '@/lib/utils'
9
+
10
+ const labelVariants = cva(
11
+ 'text-sm font-medium leading-normal peer-disabled:cursor-not-allowed peer-disabled:opacity-70 dark:text-foreground-inverse'
12
+ )
13
+ const Label = React.forwardRef<
14
+ React.ElementRef<typeof LabelPrimitive.Root>,
15
+ React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
16
+ VariantProps<typeof labelVariants>
17
+ >(({ className, ...props }, ref) => (
18
+ <LabelPrimitive.Root
19
+ ref={ref}
20
+ className={cn(labelVariants(), className)}
21
+ {...props}
22
+ />
23
+ ))
24
+ Label.displayName = LabelPrimitive.Root.displayName
25
+
26
+ export { Label, LabelProps }
@@ -0,0 +1,20 @@
1
+ import * as React from 'react'
2
+ import * as RadioGroupPrimitive from '@radix-ui/react-radio-group'
3
+
4
+ import { cn } from '@/lib/utils'
5
+
6
+ const RadioGroup = React.forwardRef<
7
+ React.ElementRef<typeof RadioGroupPrimitive.Root>,
8
+ React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root>
9
+ >(({ className, ...props }, ref) => {
10
+ return (
11
+ <RadioGroupPrimitive.Root
12
+ className={cn('grid gap-2', className)}
13
+ {...props}
14
+ ref={ref}
15
+ />
16
+ )
17
+ })
18
+ RadioGroup.displayName = RadioGroupPrimitive.Root.displayName
19
+
20
+ export { RadioGroup }
@@ -0,0 +1,26 @@
1
+ import * as React from 'react'
2
+ import * as RadioGroupPrimitive from '@radix-ui/react-radio-group'
3
+ import { cn } from '@/lib/utils'
4
+ import { RadioSelected } from '@/assets'
5
+ const RadioGroupItem = React.forwardRef<
6
+ React.ElementRef<typeof RadioGroupPrimitive.Item>,
7
+ React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item>
8
+ >(({ className, children, ...props }, ref) => {
9
+ return (
10
+ <RadioGroupPrimitive.Item
11
+ ref={ref}
12
+ className={cn(
13
+ 'h-5 w-5 rounded-full border-[0.67px] border-border-default bg-grey-50 disabled:opacity-50 data-[state=checked]:border-primary-600 data-[state=checked]:bg-primary-600 text-foreground-inverse',
14
+ className
15
+ )}
16
+ {...props}
17
+ >
18
+ <RadioGroupPrimitive.Indicator className="flex items-center justify-center">
19
+ <RadioSelected className="text-inherit stroke-current stroke-1 fill-current" />
20
+ </RadioGroupPrimitive.Indicator>
21
+ </RadioGroupPrimitive.Item>
22
+ )
23
+ })
24
+ RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName
25
+
26
+ export { RadioGroupItem as Radio }
@@ -0,0 +1,2 @@
1
+ export { RadioGroup } from './RadioGroup'
2
+ export { Radio } from './RadioGroupItem'
package/src/global.css ADDED
@@ -0,0 +1,4 @@
1
+ @import url('https://fonts.googleapis.com/css2?family=Inter&display=swap');
2
+ @tailwind base;
3
+ @tailwind components;
4
+ @tailwind utilities;
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { colors } from './colors'
2
+ export * from './components/Button'
@@ -0,0 +1,6 @@
1
+ import { clsx, type ClassValue } from 'clsx'
2
+ import { twMerge } from 'tailwind-merge'
3
+
4
+ export function cn(...inputs: ClassValue[]) {
5
+ return twMerge(clsx(inputs))
6
+ }
@@ -0,0 +1,74 @@
1
+ import type { Meta, StoryObj } from '@storybook/react'
2
+ import { Button } from '@/components/Button'
3
+
4
+ // More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
5
+ const meta = {
6
+ title: 'Components/Button',
7
+ component: Button,
8
+ parameters: {
9
+ // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/react/configure/story-layout
10
+ layout: 'centered',
11
+ controls: {
12
+ hideNoControlsWarning: true
13
+ }
14
+ },
15
+ args: {
16
+ children: 'Button Text',
17
+ size: 'md',
18
+ },
19
+ argTypes: {
20
+ variant: {
21
+ control: 'radio',
22
+ options: ['primary', 'secondary', 'tertiary', 'success', 'danger']
23
+ },
24
+ size: {
25
+ control: 'radio',
26
+ options: ['xs', 'sm', 'md', 'lg']
27
+ },
28
+ disabled: {
29
+ control: 'boolean'
30
+ },
31
+ asChild: {
32
+ table: {
33
+ disable: true
34
+ }
35
+ }
36
+ },
37
+ // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/react/writing-docs/autodocs
38
+ tags: ['autodocs']
39
+ // More on argTypes: https://storybook.js.org/docs/react/api/argtypes
40
+ } satisfies Meta<typeof Button>
41
+
42
+ export default meta
43
+ type Story = StoryObj<typeof meta>
44
+
45
+ // More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
46
+ export const Primary: Story = {
47
+ args: {
48
+ variant: 'primary',
49
+ },
50
+ }
51
+
52
+ export const Secondary: Story = {
53
+ args: {
54
+ variant: 'secondary',
55
+ },
56
+ }
57
+
58
+ export const Tertiary: Story = {
59
+ args: {
60
+ variant: 'tertiary',
61
+ },
62
+ }
63
+
64
+ export const Success: Story = {
65
+ args: {
66
+ variant: 'success',
67
+ },
68
+ }
69
+
70
+ export const Danger: Story = {
71
+ args: {
72
+ variant: 'danger',
73
+ },
74
+ }
@@ -0,0 +1,16 @@
1
+ import { Checkbox } from '@/components/Checkbox'
2
+ import { CheckboxProps } from '@radix-ui/react-checkbox'
3
+ import { useState } from 'react'
4
+ export const CheckboxDemo = ({
5
+ checked
6
+ }: {
7
+ checked: CheckboxProps['checked']
8
+ }): JSX.Element => {
9
+ const [check, setCheck] = useState<typeof checked>(checked)
10
+ const handleOnCheckChanged = () => {
11
+ if (check !== 'indeterminate') {
12
+ setCheck(!check)
13
+ }
14
+ }
15
+ return <Checkbox checked={check} onCheckedChange={handleOnCheckChanged} />
16
+ }
@@ -0,0 +1,42 @@
1
+ import type { Meta, StoryObj } from '@storybook/react'
2
+
3
+ import { CheckboxDemo } from './CheckBox.example'
4
+
5
+ // More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
6
+ const meta = {
7
+ title: 'Components/Checkbox',
8
+ component: CheckboxDemo,
9
+ parameters: {
10
+ // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/react/configure/story-layout
11
+ layout: 'centered'
12
+ },
13
+ // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/react/writing-docs/autodocs
14
+ tags: ['autodocs'],
15
+ argTypes: {
16
+ checked: {
17
+ options: [true, false, 'indeterminate'],
18
+ control: { type: 'radio' }
19
+ }
20
+ }
21
+ // More on argTypes: https://storybook.js.org/docs/react/api/argtypes
22
+ } satisfies Meta<typeof CheckboxDemo>
23
+
24
+ export default meta
25
+ type Story = StoryObj<typeof meta>
26
+
27
+ // More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
28
+ export const CheckBoxUnchecked: Story = {
29
+ args: {
30
+ checked: false
31
+ }
32
+ }
33
+ export const CheckBoxChecked: Story = {
34
+ args: {
35
+ checked: true
36
+ }
37
+ }
38
+ export const CheckBoxIndeterminate: Story = {
39
+ args: {
40
+ checked: 'indeterminate'
41
+ }
42
+ }