@yusufalperendumlu/component-library 0.0.4 → 0.0.6
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/dist/cjs/index.css +1 -1
- package/dist/cjs/index.css.map +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.css +1 -1
- package/dist/esm/index.css.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +65 -7
- package/dist/tailwind.css +1 -1
- package/eslint.config.js +23 -0
- package/jest.config.ts +13 -0
- package/package.json +20 -14
- package/prettier.config.js +84 -0
- package/src/components/Autocomplete/Autocomplete.stories.tsx +65 -0
- package/src/components/Autocomplete/Autocomplete.tsx +127 -0
- package/src/components/Autocomplete/Autocomplete.types.ts +14 -0
- package/src/components/Autocomplete/index.ts +3 -0
- package/src/components/Button/Button.stories.tsx +12 -2
- package/src/components/Button/Button.tsx +55 -38
- package/src/components/Button/Button.types.ts +7 -0
- package/src/components/Button/index.ts +3 -3
- package/src/components/Dialog/Dialog.stories.tsx +102 -0
- package/src/components/Dialog/Dialog.tsx +90 -0
- package/src/components/Dialog/Dialog.types.ts +7 -0
- package/src/components/Dialog/index.ts +3 -0
- package/src/components/Input/Input.stories.tsx +34 -0
- package/src/components/Input/Input.tsx +31 -9
- package/src/components/Input/Input.types.ts +6 -0
- package/src/components/Input/index.ts +3 -0
- package/src/components/Table/Table.stories.tsx +53 -0
- package/src/components/Table/Table.tsx +104 -0
- package/src/components/Table/Table.types.ts +13 -0
- package/src/components/Table/index.ts +3 -0
- package/src/components/index.ts +5 -2
- package/src/index.ts +3 -3
- package/src/tests/Autocomplete.test.tsx +81 -0
- package/src/tests/Button.test.tsx +36 -25
- package/src/tests/Dialog.test.tsx +86 -0
- package/src/tests/Input.test.tsx +42 -0
- package/src/tests/Table.test.tsx +55 -0
- package/src/tests/styleMock.ts +1 -1
- package/tailwind.config.js +6 -1
- package/tsconfig.json +6 -2
- package/src/components/Input/index.tsx +0 -3
package/dist/index.d.ts
CHANGED
@@ -1,16 +1,74 @@
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
2
1
|
import React$1 from 'react';
|
2
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
3
3
|
|
4
|
-
type
|
4
|
+
type Option = {
|
5
|
+
id: number;
|
6
|
+
name: string;
|
7
|
+
};
|
8
|
+
interface AutocompleteProps {
|
9
|
+
options: Option[];
|
10
|
+
selected: Option[];
|
11
|
+
setSelected: (options: Option[]) => void;
|
12
|
+
placeholder?: string;
|
13
|
+
showChosen?: boolean;
|
14
|
+
label?: string;
|
5
15
|
className?: string;
|
6
|
-
|
16
|
+
}
|
17
|
+
|
18
|
+
declare const Autocomplete: React$1.FC<AutocompleteProps>;
|
19
|
+
|
20
|
+
type IButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
|
21
|
+
className?: string;
|
22
|
+
variant: 'primary' | 'secondary' | 'outline' | 'danger';
|
23
|
+
size?: 'small' | 'medium' | 'large';
|
24
|
+
border?: 'primary' | 'secondary' | 'outline' | 'danger';
|
7
25
|
title: string;
|
8
26
|
};
|
9
|
-
declare const Button: ({ variant, title, ...props }: IButtonProps) => react_jsx_runtime.JSX.Element;
|
10
27
|
|
11
|
-
|
28
|
+
declare const Button: ({ variant, size, border, title, className, ...props }: IButtonProps) => react_jsx_runtime.JSX.Element;
|
29
|
+
|
30
|
+
type DialogProps = {
|
31
|
+
isOpen: boolean;
|
32
|
+
onClose: () => void;
|
33
|
+
children: React.ReactNode;
|
34
|
+
className?: string;
|
35
|
+
showCloseIcon?: boolean;
|
36
|
+
};
|
37
|
+
|
38
|
+
declare const Dialog: React$1.FC<DialogProps> & {
|
39
|
+
Header: React$1.FC<{
|
40
|
+
children: React$1.ReactNode;
|
41
|
+
}>;
|
42
|
+
Body: React$1.FC<{
|
43
|
+
children: React$1.ReactNode;
|
44
|
+
}>;
|
45
|
+
Footer: React$1.FC<{
|
46
|
+
children: React$1.ReactNode;
|
47
|
+
}>;
|
48
|
+
};
|
49
|
+
|
50
|
+
type InputProps = React.InputHTMLAttributes<HTMLInputElement> & {
|
51
|
+
className?: string;
|
12
52
|
placeholder?: string;
|
53
|
+
type: string;
|
54
|
+
label?: string;
|
13
55
|
};
|
14
|
-
declare const Input: React.FC<InputProps>;
|
15
56
|
|
16
|
-
|
57
|
+
declare const Input: React$1.FC<InputProps>;
|
58
|
+
|
59
|
+
interface TableColumn<T> {
|
60
|
+
key: keyof T;
|
61
|
+
label: string;
|
62
|
+
sortable?: boolean;
|
63
|
+
render?: (value: any, row: T) => React.ReactNode;
|
64
|
+
}
|
65
|
+
interface TableProps<T> {
|
66
|
+
columns: TableColumn<T>[];
|
67
|
+
data: T[];
|
68
|
+
onRowClick?: (row: T) => void;
|
69
|
+
className?: string;
|
70
|
+
}
|
71
|
+
|
72
|
+
declare function Table<T extends Record<string, any>>({ columns, data, onRowClick, className, }: TableProps<T>): react_jsx_runtime.JSX.Element;
|
73
|
+
|
74
|
+
export { Autocomplete, Button, Dialog, Input, Table };
|
package/dist/tailwind.css
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
/*
|
2
2
|
! tailwindcss v3.4.1 | MIT License | https://tailwindcss.com
|
3
|
-
*/*,:after,:before{border:0 solid #e5e7eb;box-sizing:border-box}:after,:before{--tw-content:""}:host,html{-webkit-text-size-adjust:100%;font-feature-settings:normal;-webkit-tap-highlight-color:transparent;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-variation-settings:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4}body{line-height:inherit;margin:0}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-feature-settings:normal;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em;font-variation-settings:normal}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}button,input,optgroup,select,textarea{font-feature-settings:inherit;color:inherit;font-family:inherit;font-size:100%;font-variation-settings:inherit;font-weight:inherit;line-height:inherit;margin:0;padding:0}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{color:#9ca3af;opacity:1}input::placeholder,textarea::placeholder{color:#9ca3af;opacity:1}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}[hidden]{display:none}*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.mt-4{margin-top:1rem}.rounded-lg{border-radius:.5rem}.border-2{border-width:2px}.border-blue-600{--tw-border-opacity:1;border-color:rgb(37 99 235/var(--tw-border-opacity))}.bg-blue-500{--tw-bg-opacity:1;background-color:rgb(59 130 246/var(--tw-bg-opacity))}.bg-gray-200{--tw-bg-opacity:1;background-color:rgb(229 231 235/var(--tw-bg-opacity))}.bg-green-500{--tw-bg-opacity:1;background-color:rgb(34 197 94/var(--tw-bg-opacity))}.px-4{padding-left:1rem;padding-right:1rem}.py-2{padding-bottom:.5rem;padding-top:.5rem}.text-gray-800{--tw-text-opacity:1;color:rgb(31 41 55/var(--tw-text-opacity))}.text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}.transition-all{transition-duration:.15s;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1)}.duration-300{transition-duration:.3s}.ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}.hover\:bg-blue-600:hover{--tw-bg-opacity:1;background-color:rgb(37 99 235/var(--tw-bg-opacity))}.hover\:bg-green-600:hover{--tw-bg-opacity:1;background-color:rgb(22 163 74/var(--tw-bg-opacity))}
|
3
|
+
*/*,:after,:before{border:0 solid #e5e7eb;box-sizing:border-box}:after,:before{--tw-content:""}:host,html{-webkit-text-size-adjust:100%;font-feature-settings:normal;-webkit-tap-highlight-color:transparent;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-variation-settings:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4}body{line-height:inherit;margin:0}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-feature-settings:normal;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em;font-variation-settings:normal}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}button,input,optgroup,select,textarea{font-feature-settings:inherit;color:inherit;font-family:inherit;font-size:100%;font-variation-settings:inherit;font-weight:inherit;line-height:inherit;margin:0;padding:0}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{color:#9ca3af;opacity:1}input::placeholder,textarea::placeholder{color:#9ca3af;opacity:1}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}[hidden]{display:none}*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.container{width:100%}@media (min-width:640px){.container{max-width:640px}}@media (min-width:768px){.container{max-width:768px}}@media (min-width:1024px){.container{max-width:1024px}}@media (min-width:1280px){.container{max-width:1280px}}@media (min-width:1536px){.container{max-width:1536px}}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.inset-0{inset:0}.right-4{right:1rem}.top-5{top:1.25rem}.z-10{z-index:10}.z-50{z-index:50}.mx-auto{margin-left:auto;margin-right:auto}.mb-1{margin-bottom:.25rem}.mb-4{margin-bottom:1rem}.ml-1{margin-left:.25rem}.mr-2{margin-right:.5rem}.mt-1{margin-top:.25rem}.mt-10{margin-top:2.5rem}.mt-2{margin-top:.5rem}.mt-4{margin-top:1rem}.block{display:block}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.h-3{height:.75rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.max-h-60{max-height:15rem}.min-h-\[42px\]{min-height:42px}.w-1\/2{width:50%}.w-3{width:.75rem}.w-5{width:1.25rem}.w-6{width:1.5rem}.w-fit{width:-moz-fit-content;width:fit-content}.w-full{width:100%}.min-w-\[160px\]{min-width:160px}.min-w-\[70px\]{min-width:70px}.min-w-full{min-width:100%}.max-w-md{max-width:28rem}.flex-1{flex:1 1 0%}.table-fixed{table-layout:fixed}.cursor-pointer{cursor:pointer}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.gap-1{gap:.25rem}.gap-2{gap:.5rem}.overflow-auto{overflow:auto}.overflow-y-auto{overflow-y:auto}.whitespace-nowrap{white-space:nowrap}.rounded{border-radius:.25rem}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.border{border-width:1px}.border-b{border-bottom-width:1px}.border-b-2{border-bottom-width:2px}.border-t{border-top-width:1px}.border-none{border-style:none}.border-\[\#424242\]{--tw-border-opacity:1;border-color:rgb(66 66 66/var(--tw-border-opacity))}.border-\[\#5876EE\]{--tw-border-opacity:1;border-color:rgb(88 118 238/var(--tw-border-opacity))}.border-\[\#BDC311\]{--tw-border-opacity:1;border-color:rgb(189 195 17/var(--tw-border-opacity))}.border-\[\#FF0000\]{--tw-border-opacity:1;border-color:rgb(255 0 0/var(--tw-border-opacity))}.border-zinc-200{--tw-border-opacity:1;border-color:rgb(228 228 231/var(--tw-border-opacity))}.border-zinc-700{--tw-border-opacity:1;border-color:rgb(63 63 70/var(--tw-border-opacity))}.bg-\[\#1D1B1D\]{--tw-bg-opacity:1;background-color:rgb(29 27 29/var(--tw-bg-opacity))}.bg-\[\#424242\]{--tw-bg-opacity:1;background-color:rgb(66 66 66/var(--tw-bg-opacity))}.bg-\[\#5876EE\]{--tw-bg-opacity:1;background-color:rgb(88 118 238/var(--tw-bg-opacity))}.bg-\[\#BDC311\]{--tw-bg-opacity:1;background-color:rgb(189 195 17/var(--tw-bg-opacity))}.bg-\[\#FF0000\]{--tw-bg-opacity:1;background-color:rgb(255 0 0/var(--tw-bg-opacity))}.bg-black\/50{background-color:rgba(0,0,0,.5)}.bg-green-500{--tw-bg-opacity:1;background-color:rgb(34 197 94/var(--tw-bg-opacity))}.bg-transparent{background-color:transparent}.bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity))}.bg-zinc-900{--tw-bg-opacity:1;background-color:rgb(24 24 27/var(--tw-bg-opacity))}.p-2{padding:.5rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-4{padding-left:1rem;padding-right:1rem}.px-5{padding-left:1.25rem;padding-right:1.25rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.py-1{padding-bottom:.25rem;padding-top:.25rem}.py-2{padding-bottom:.5rem;padding-top:.5rem}.py-3{padding-bottom:.75rem;padding-top:.75rem}.py-4{padding-bottom:1rem;padding-top:1rem}.text-left{text-align:left}.font-inter{font-family:Inter,sans-serif}.text-base{font-size:1rem;line-height:1.5rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xs{font-size:.75rem;line-height:1rem}.font-\[12px\]{font-weight:12px}.font-light{font-weight:300}.font-medium{font-weight:500}.font-semibold{font-weight:600}.text-\[\#424242\]{--tw-text-opacity:1;color:rgb(66 66 66/var(--tw-text-opacity))}.text-\[\#5876EE\]{--tw-text-opacity:1;color:rgb(88 118 238/var(--tw-text-opacity))}.text-\[\#FF0000\]{--tw-text-opacity:1;color:rgb(255 0 0/var(--tw-text-opacity))}.text-black{--tw-text-opacity:1;color:rgb(0 0 0/var(--tw-text-opacity))}.text-blue-400{--tw-text-opacity:1;color:rgb(96 165 250/var(--tw-text-opacity))}.text-gray-600{--tw-text-opacity:1;color:rgb(75 85 99/var(--tw-text-opacity))}.text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}.text-zinc-100{--tw-text-opacity:1;color:rgb(244 244 245/var(--tw-text-opacity))}.text-zinc-500{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity))}.text-zinc-900{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity))}.underline{text-decoration-line:underline}.shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color)}.shadow-lg,.shadow-md{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.shadow-md{--tw-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -2px rgba(0,0,0,.1);--tw-shadow-colored:0 4px 6px -1px var(--tw-shadow-color),0 2px 4px -2px var(--tw-shadow-color)}.outline-none{outline:2px solid transparent;outline-offset:2px}.outline{outline-style:solid}.ring-\[\#5876EE\]{--tw-ring-opacity:1;--tw-ring-color:rgb(88 118 238/var(--tw-ring-opacity))}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.transition-all{transition-duration:.15s;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1)}.transition-colors{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1)}.duration-200{transition-duration:.2s}.duration-300{transition-duration:.3s}.ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}.placeholder\:text-\[\#3f3f3f\]::-moz-placeholder{--tw-text-opacity:1;color:rgb(63 63 63/var(--tw-text-opacity))}.placeholder\:text-\[\#3f3f3f\]::placeholder{--tw-text-opacity:1;color:rgb(63 63 63/var(--tw-text-opacity))}.focus-within\:ring-2:focus-within{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.hover\:bg-\[\#4a66d9\]:hover{--tw-bg-opacity:1;background-color:rgb(74 102 217/var(--tw-bg-opacity))}.hover\:bg-\[\#E2E2E2\]:hover{--tw-bg-opacity:1;background-color:rgb(226 226 226/var(--tw-bg-opacity))}.hover\:bg-\[\#FF0000\]:hover{--tw-bg-opacity:1;background-color:rgb(255 0 0/var(--tw-bg-opacity))}.hover\:bg-\[\#a8b00e\]:hover{--tw-bg-opacity:1;background-color:rgb(168 176 14/var(--tw-bg-opacity))}.hover\:bg-\[\#d40000\]:hover{--tw-bg-opacity:1;background-color:rgb(212 0 0/var(--tw-bg-opacity))}.hover\:bg-\[\#f5f5f5\]:hover{--tw-bg-opacity:1;background-color:rgb(245 245 245/var(--tw-bg-opacity))}.hover\:bg-gray-100:hover{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity))}.hover\:bg-green-600:hover{--tw-bg-opacity:1;background-color:rgb(22 163 74/var(--tw-bg-opacity))}.hover\:text-gray-200:hover{--tw-text-opacity:1;color:rgb(229 231 235/var(--tw-text-opacity))}.hover\:text-gray-800:hover{--tw-text-opacity:1;color:rgb(31 41 55/var(--tw-text-opacity))}.hover\:text-zinc-900:hover{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity))}.focus\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-50:disabled{opacity:.5}.disabled\:hover\:bg-transparent:hover:disabled{background-color:transparent}.disabled\:hover\:text-inherit:hover:disabled{color:inherit}:is(.dark .dark\:border-zinc-700){--tw-border-opacity:1;border-color:rgb(63 63 70/var(--tw-border-opacity))}:is(.dark .dark\:bg-\[\#424242\]){--tw-bg-opacity:1;background-color:rgb(66 66 66/var(--tw-bg-opacity))}:is(.dark .dark\:bg-zinc-800){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity))}:is(.dark .dark\:text-white){--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}:is(.dark .dark\:text-zinc-400){--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity))}:is(.dark .dark\:hover\:text-white:hover){--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}
|
package/eslint.config.js
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
import js from '@eslint/js';
|
2
|
+
import globals from 'globals';
|
3
|
+
import reactHooks from 'eslint-plugin-react-hooks';
|
4
|
+
import reactRefresh from 'eslint-plugin-react-refresh';
|
5
|
+
import tseslint from 'typescript-eslint';
|
6
|
+
import { globalIgnores } from 'eslint/config';
|
7
|
+
|
8
|
+
export default tseslint.config([
|
9
|
+
globalIgnores(['dist']),
|
10
|
+
{
|
11
|
+
files: ['**/*.{ts,tsx}'],
|
12
|
+
extends: [
|
13
|
+
js.configs.recommended,
|
14
|
+
tseslint.configs.recommended,
|
15
|
+
reactHooks.configs['recommended-latest'],
|
16
|
+
reactRefresh.configs.vite,
|
17
|
+
],
|
18
|
+
languageOptions: {
|
19
|
+
ecmaVersion: 2020,
|
20
|
+
globals: globals.browser,
|
21
|
+
},
|
22
|
+
},
|
23
|
+
]);
|
package/jest.config.ts
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
import type { Config } from "jest";
|
2
|
+
|
3
|
+
const config: Config = {
|
4
|
+
testEnvironment: "jsdom",
|
5
|
+
transform: {
|
6
|
+
"^.+\\.tsx?$": "ts-jest",
|
7
|
+
},
|
8
|
+
moduleNameMapper: {
|
9
|
+
"\\.(css|less|scss|sass)$": "identity-obj-proxy",
|
10
|
+
},
|
11
|
+
};
|
12
|
+
|
13
|
+
export default config;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@yusufalperendumlu/component-library",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.6",
|
4
4
|
"main": "dist/cjs/index.js",
|
5
5
|
"module": "dist/esm/index.js",
|
6
6
|
"types": "dist/index.d.ts",
|
@@ -14,17 +14,12 @@
|
|
14
14
|
"test": "jest --watchAll --verbose",
|
15
15
|
"clean": "rm -rf dist",
|
16
16
|
"storybook": "storybook dev -p 6006",
|
17
|
-
"build-storybook": "storybook build"
|
18
|
-
|
19
|
-
|
20
|
-
"
|
21
|
-
"
|
22
|
-
"
|
23
|
-
"<rootDir>/src/tests/styleMock.ts"
|
24
|
-
],
|
25
|
-
"moduleNameMapper": {
|
26
|
-
"\\.(css|less|scss|sass)$": "/src/tests/styleMock.ts"
|
27
|
-
}
|
17
|
+
"build-storybook": "storybook build",
|
18
|
+
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
|
19
|
+
"lint:fix": "eslint . --ext .js,.jsx,.ts,.tsx --fix",
|
20
|
+
"format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,md,css,scss}\"",
|
21
|
+
"format:check": "prettier --check \"**/*.{js,jsx,ts,tsx,json,md,css,scss}\"",
|
22
|
+
"check": "npm run type-check && npm run lint && npm run format:check"
|
28
23
|
},
|
29
24
|
"author": "",
|
30
25
|
"license": "MIT",
|
@@ -41,7 +36,6 @@
|
|
41
36
|
"@storybook/addon-docs": "8.0.0",
|
42
37
|
"@storybook/builder-vite": "^9.0.18",
|
43
38
|
"@storybook/react-vite": "^9.0.18",
|
44
|
-
"@tailwindcss/postcss": "^4.11.1",
|
45
39
|
"@testing-library/dom": "^10.4.0",
|
46
40
|
"@testing-library/jest-dom": "^6.6.3",
|
47
41
|
"@testing-library/react": "^16.3.0",
|
@@ -49,12 +43,23 @@
|
|
49
43
|
"@types/jest": "^30.0.0",
|
50
44
|
"@types/react": "18.2.14",
|
51
45
|
"@types/react-dom": "18.2.7",
|
46
|
+
"@typescript-eslint/eslint-plugin": "^8.38.0",
|
47
|
+
"@typescript-eslint/parser": "^8.38.0",
|
52
48
|
"autoprefixer": "10.4.15",
|
53
49
|
"babel-loader": "^10.0.0",
|
50
|
+
"eslint": "^9.31.0",
|
51
|
+
"eslint-config-prettier": "^10.1.8",
|
52
|
+
"eslint-plugin-import": "^2.32.0",
|
53
|
+
"eslint-plugin-jsx-a11y": "^6.10.2",
|
54
|
+
"eslint-plugin-prettier": "^5.5.3",
|
55
|
+
"eslint-plugin-react": "^7.37.5",
|
56
|
+
"eslint-plugin-react-hooks": "^5.2.0",
|
57
|
+
"identity-obj-proxy": "^3.0.0",
|
54
58
|
"jest": "^30.0.5",
|
55
59
|
"jest-environment-jsdom": "^30.0.5",
|
56
|
-
"postcss": "8.
|
60
|
+
"postcss": "^8.5.6",
|
57
61
|
"postcss-loader": "^8.1.1",
|
62
|
+
"prettier": "^3.6.2",
|
58
63
|
"react": "18.2.0",
|
59
64
|
"react-dom": "18.2.0",
|
60
65
|
"storybook": "9.0.18",
|
@@ -70,6 +75,7 @@
|
|
70
75
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
71
76
|
"class-variance-authority": "^0.7.1",
|
72
77
|
"clsx": "^2.1.1",
|
78
|
+
"react-icons": "^5.5.0",
|
73
79
|
"rollup": "^4.45.1",
|
74
80
|
"rollup-plugin-dts": "^6.2.1",
|
75
81
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
@@ -0,0 +1,84 @@
|
|
1
|
+
export default {
|
2
|
+
// Print width
|
3
|
+
printWidth: 80,
|
4
|
+
|
5
|
+
// Tab width
|
6
|
+
tabWidth: 2,
|
7
|
+
|
8
|
+
// Use spaces instead of tabs
|
9
|
+
useTabs: false,
|
10
|
+
|
11
|
+
// Add semicolons at the end of statements
|
12
|
+
semi: true,
|
13
|
+
|
14
|
+
// Use single quotes instead of double quotes
|
15
|
+
singleQuote: true,
|
16
|
+
|
17
|
+
// Use single quotes in JSX
|
18
|
+
jsxSingleQuote: true,
|
19
|
+
|
20
|
+
// Add trailing commas where valid in ES5
|
21
|
+
trailingComma: "es5",
|
22
|
+
|
23
|
+
// Add spaces between brackets in object literals
|
24
|
+
bracketSpacing: true,
|
25
|
+
|
26
|
+
// Put the > of a multi-line JSX element at the end of the last line
|
27
|
+
bracketSameLine: false,
|
28
|
+
|
29
|
+
// Include parentheses around a sole arrow function parameter
|
30
|
+
arrowParens: "avoid",
|
31
|
+
|
32
|
+
// End of line character
|
33
|
+
endOfLine: "lf",
|
34
|
+
|
35
|
+
// Format embedded code if Prettier can identify it
|
36
|
+
embeddedLanguageFormatting: "auto",
|
37
|
+
|
38
|
+
// Respect existing line breaks
|
39
|
+
htmlWhitespaceSensitivity: "css",
|
40
|
+
|
41
|
+
// Insert Pragma
|
42
|
+
insertPragma: false,
|
43
|
+
|
44
|
+
// Require pragma
|
45
|
+
requirePragma: false,
|
46
|
+
|
47
|
+
// Use single quotes in JSX
|
48
|
+
jsxSingleQuote: true,
|
49
|
+
|
50
|
+
// Quote props only when necessary
|
51
|
+
quoteProps: "as-needed",
|
52
|
+
|
53
|
+
// Prose wrap
|
54
|
+
proseWrap: "preserve",
|
55
|
+
|
56
|
+
// Range start
|
57
|
+
rangeStart: 0,
|
58
|
+
|
59
|
+
// Range end
|
60
|
+
rangeEnd: Infinity,
|
61
|
+
|
62
|
+
// Overrides for specific file types
|
63
|
+
overrides: [
|
64
|
+
{
|
65
|
+
files: "*.json",
|
66
|
+
options: {
|
67
|
+
printWidth: 100,
|
68
|
+
},
|
69
|
+
},
|
70
|
+
{
|
71
|
+
files: "*.md",
|
72
|
+
options: {
|
73
|
+
printWidth: 100,
|
74
|
+
proseWrap: "always",
|
75
|
+
},
|
76
|
+
},
|
77
|
+
{
|
78
|
+
files: "*.yml",
|
79
|
+
options: {
|
80
|
+
singleQuote: false,
|
81
|
+
},
|
82
|
+
},
|
83
|
+
],
|
84
|
+
};
|
@@ -0,0 +1,65 @@
|
|
1
|
+
import React, { useState } from "react";
|
2
|
+
import { Meta, StoryObj } from "@storybook/react";
|
3
|
+
|
4
|
+
import Autocomplete from "./Autocomplete";
|
5
|
+
|
6
|
+
const meta: Meta<typeof Autocomplete> = {
|
7
|
+
title: "Components/Autocomplete",
|
8
|
+
component: Autocomplete,
|
9
|
+
tags: ["autodocs"],
|
10
|
+
argTypes: {
|
11
|
+
placeholder: { control: "text" },
|
12
|
+
className: { control: false },
|
13
|
+
},
|
14
|
+
};
|
15
|
+
|
16
|
+
export default meta;
|
17
|
+
type Story = StoryObj<typeof Autocomplete>;
|
18
|
+
|
19
|
+
const sampleOptions = [
|
20
|
+
{ id: 1, name: "JavaScript" },
|
21
|
+
{ id: 2, name: "TypeScript" },
|
22
|
+
{ id: 3, name: "Python" },
|
23
|
+
{ id: 4, name: "Rust" },
|
24
|
+
{ id: 5, name: "Go" },
|
25
|
+
{ id: 6, name: "Java" },
|
26
|
+
];
|
27
|
+
|
28
|
+
export const Default: Story = {
|
29
|
+
render: (args) => {
|
30
|
+
const [selected, setSelected] = useState<typeof sampleOptions>([]);
|
31
|
+
|
32
|
+
return (
|
33
|
+
<div className="max-w-md mx-auto mt-10">
|
34
|
+
<Autocomplete
|
35
|
+
{...args}
|
36
|
+
options={sampleOptions}
|
37
|
+
selected={selected}
|
38
|
+
setSelected={setSelected}
|
39
|
+
showChosen={false}
|
40
|
+
placeholder="Choose a language"
|
41
|
+
label="Choose a language"
|
42
|
+
/>
|
43
|
+
</div>
|
44
|
+
);
|
45
|
+
},
|
46
|
+
};
|
47
|
+
|
48
|
+
export const WithChosen: Story = {
|
49
|
+
render: (args) => {
|
50
|
+
const [selected, setSelected] = useState<typeof sampleOptions>([]);
|
51
|
+
|
52
|
+
return (
|
53
|
+
<div className="max-w-md mx-auto mt-10">
|
54
|
+
<Autocomplete
|
55
|
+
{...args}
|
56
|
+
options={sampleOptions}
|
57
|
+
selected={selected}
|
58
|
+
setSelected={setSelected}
|
59
|
+
placeholder="Choose languages"
|
60
|
+
showChosen
|
61
|
+
/>
|
62
|
+
</div>
|
63
|
+
);
|
64
|
+
},
|
65
|
+
};
|
@@ -0,0 +1,127 @@
|
|
1
|
+
import clsx from 'clsx';
|
2
|
+
import React, { useState, useRef, useEffect } from 'react';
|
3
|
+
import { IoMdArrowDropdown } from 'react-icons/io';
|
4
|
+
|
5
|
+
import { Option } from './Autocomplete.types';
|
6
|
+
import { AutocompleteProps } from './Autocomplete.types';
|
7
|
+
|
8
|
+
const Autocomplete: React.FC<AutocompleteProps> = ({
|
9
|
+
options,
|
10
|
+
selected,
|
11
|
+
setSelected,
|
12
|
+
placeholder,
|
13
|
+
showChosen = false,
|
14
|
+
label,
|
15
|
+
className,
|
16
|
+
}) => {
|
17
|
+
const [query, setQuery] = useState('');
|
18
|
+
const [isOpen, setIsOpen] = useState(false);
|
19
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
20
|
+
|
21
|
+
const filteredOptions = options.filter(
|
22
|
+
option =>
|
23
|
+
option.name.toLowerCase().includes(query.toLowerCase()) &&
|
24
|
+
(!showChosen || !selected.find(s => s.id === option.id))
|
25
|
+
);
|
26
|
+
|
27
|
+
const handleSelect = (option: Option) => {
|
28
|
+
if (showChosen) {
|
29
|
+
setSelected([...selected, option]);
|
30
|
+
} else {
|
31
|
+
setSelected([option]);
|
32
|
+
setIsOpen(false);
|
33
|
+
}
|
34
|
+
setQuery('');
|
35
|
+
};
|
36
|
+
|
37
|
+
const handleRemove = (option: Option) => {
|
38
|
+
setSelected(selected.filter(s => s.id !== option.id));
|
39
|
+
};
|
40
|
+
|
41
|
+
const handleClickOutside = (event: MouseEvent) => {
|
42
|
+
if (
|
43
|
+
containerRef.current &&
|
44
|
+
!containerRef.current.contains(event.target as Node)
|
45
|
+
) {
|
46
|
+
setIsOpen(false);
|
47
|
+
}
|
48
|
+
};
|
49
|
+
|
50
|
+
useEffect(() => {
|
51
|
+
document.addEventListener('mousedown', handleClickOutside);
|
52
|
+
return () => document.removeEventListener('mousedown', handleClickOutside);
|
53
|
+
}, []);
|
54
|
+
|
55
|
+
return (
|
56
|
+
<div ref={containerRef} className={clsx('relative w-full', className)}>
|
57
|
+
{label && (
|
58
|
+
<label className='mb-1 text-sm text-black dark:text-white'>
|
59
|
+
{label}
|
60
|
+
</label>
|
61
|
+
)}
|
62
|
+
<div className='flex flex-wrap gap-1 border rounded-md p-2 min-h-[42px] items-center focus-within:ring-2 ring-[#5876EE]'>
|
63
|
+
{showChosen ? (
|
64
|
+
selected.map(option => (
|
65
|
+
<span
|
66
|
+
key={option.id}
|
67
|
+
className='flex items-center gap-1 bg-[#5876EE] text-white px-2 py-1 rounded text-xs'
|
68
|
+
>
|
69
|
+
{option.name}
|
70
|
+
<button
|
71
|
+
type='button'
|
72
|
+
onClick={() => handleRemove(option)}
|
73
|
+
className='ml-1 text-white hover:text-gray-200'
|
74
|
+
>
|
75
|
+
×
|
76
|
+
</button>
|
77
|
+
</span>
|
78
|
+
))
|
79
|
+
) : (
|
80
|
+
<>
|
81
|
+
{selected[0] && (
|
82
|
+
<span className='text-sm text-black dark:text-white mr-2'>
|
83
|
+
{selected[0].name}
|
84
|
+
</span>
|
85
|
+
)}
|
86
|
+
</>
|
87
|
+
)}
|
88
|
+
|
89
|
+
<input
|
90
|
+
type='text'
|
91
|
+
className='flex-1 outline-none border-none text-sm bg-transparent'
|
92
|
+
placeholder={!selected.length || showChosen ? placeholder : ''}
|
93
|
+
value={query}
|
94
|
+
onChange={e => {
|
95
|
+
setQuery(e.target.value);
|
96
|
+
setIsOpen(true);
|
97
|
+
}}
|
98
|
+
onFocus={() => setIsOpen(true)}
|
99
|
+
/>
|
100
|
+
|
101
|
+
<button
|
102
|
+
type='button'
|
103
|
+
className='text-gray-600 hover:text-gray-800'
|
104
|
+
onClick={() => setIsOpen(!isOpen)}
|
105
|
+
>
|
106
|
+
<IoMdArrowDropdown className='w-6 h-6' />
|
107
|
+
</button>
|
108
|
+
</div>
|
109
|
+
|
110
|
+
{isOpen && filteredOptions.length > 0 && (
|
111
|
+
<ul className='absolute z-10 mt-1 w-full max-h-60 overflow-y-auto bg-white border rounded-md shadow-md'>
|
112
|
+
{filteredOptions.map(option => (
|
113
|
+
<li
|
114
|
+
key={option.id}
|
115
|
+
className='cursor-pointer px-4 py-2 hover:bg-gray-100 text-sm'
|
116
|
+
onClick={() => handleSelect(option)}
|
117
|
+
>
|
118
|
+
{option.name}
|
119
|
+
</li>
|
120
|
+
))}
|
121
|
+
</ul>
|
122
|
+
)}
|
123
|
+
</div>
|
124
|
+
);
|
125
|
+
};
|
126
|
+
|
127
|
+
export default Autocomplete;
|
@@ -0,0 +1,14 @@
|
|
1
|
+
export type Option = {
|
2
|
+
id: number;
|
3
|
+
name: string;
|
4
|
+
};
|
5
|
+
|
6
|
+
export interface AutocompleteProps {
|
7
|
+
options: Option[];
|
8
|
+
selected: Option[];
|
9
|
+
setSelected: (options: Option[]) => void;
|
10
|
+
placeholder?: string;
|
11
|
+
showChosen?: boolean;
|
12
|
+
label?: string;
|
13
|
+
className?: string;
|
14
|
+
}
|
@@ -21,15 +21,25 @@ type Story = StoryObj<typeof Button>;
|
|
21
21
|
|
22
22
|
export const Primary: Story = {
|
23
23
|
args: {
|
24
|
-
title: "
|
24
|
+
title: "Login",
|
25
25
|
variant: "primary",
|
26
|
+
size: "small",
|
26
27
|
},
|
27
28
|
};
|
28
29
|
|
29
30
|
export const Secondary: Story = {
|
30
31
|
args: {
|
31
|
-
title: "
|
32
|
+
title: "Show history",
|
32
33
|
variant: "secondary",
|
34
|
+
size: "small",
|
35
|
+
},
|
36
|
+
};
|
37
|
+
|
38
|
+
export const Outline: Story = {
|
39
|
+
args: {
|
40
|
+
title: "Cancel",
|
41
|
+
variant: "danger",
|
42
|
+
size: "small",
|
33
43
|
},
|
34
44
|
};
|
35
45
|
|
@@ -1,38 +1,55 @@
|
|
1
|
-
import
|
2
|
-
import
|
3
|
-
import
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
1
|
+
import { cva } from 'class-variance-authority';
|
2
|
+
import clsx from 'clsx';
|
3
|
+
import React from 'react';
|
4
|
+
|
5
|
+
import { IButtonProps } from './Button.types';
|
6
|
+
|
7
|
+
const buttonVariants = cva(
|
8
|
+
'outline-none min-w-[70px] font-inter transition-all font-[12px] px-4 py-2 gap-2 rounded-md duration-300 ease-in-out disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent disabled:hover:text-inherit',
|
9
|
+
{
|
10
|
+
variants: {
|
11
|
+
variant: {
|
12
|
+
primary: 'bg-[#5876EE] text-white shadow-xs hover:bg-[#4a66d9]',
|
13
|
+
secondary: 'bg-[#BDC311] text-[#424242] shadow-xs hover:bg-[#a8b00e]',
|
14
|
+
outline: 'bg-transparent shadow-xs hover:bg-[#f5f5f5]',
|
15
|
+
danger: 'bg-[#FF0000] text-white shadow-xs hover:bg-[#d40000]',
|
16
|
+
},
|
17
|
+
size: {
|
18
|
+
small: 'w-fit px-3 text-sm',
|
19
|
+
medium: 'w-1/2 px-4 text-base',
|
20
|
+
large: 'w-full px-5 text-lg',
|
21
|
+
},
|
22
|
+
border: {
|
23
|
+
primary: 'border border-[#5876EE] hover:bg-[#4a66d9]',
|
24
|
+
secondary: 'border border-[#BDC311] hover:bg-[#a8b00e]',
|
25
|
+
outline:
|
26
|
+
'border border-[#424242] hover:bg-[#E2E2E2] dark:border-[#E2E2E2',
|
27
|
+
danger: 'border border-[#FF0000] text-[#FF0000] hover:bg-[#FF0000]',
|
28
|
+
},
|
29
|
+
},
|
30
|
+
defaultVariants: {
|
31
|
+
variant: 'primary',
|
32
|
+
size: 'medium',
|
33
|
+
},
|
34
|
+
}
|
35
|
+
);
|
36
|
+
|
37
|
+
const Button = ({
|
38
|
+
variant,
|
39
|
+
size,
|
40
|
+
border,
|
41
|
+
title,
|
42
|
+
className,
|
43
|
+
...props
|
44
|
+
}: IButtonProps) => {
|
45
|
+
return (
|
46
|
+
<button
|
47
|
+
className={clsx(buttonVariants({ variant, size, border }), className)}
|
48
|
+
{...props}
|
49
|
+
>
|
50
|
+
{title}
|
51
|
+
</button>
|
52
|
+
);
|
53
|
+
};
|
54
|
+
|
55
|
+
export default Button;
|
@@ -0,0 +1,7 @@
|
|
1
|
+
export type IButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
|
2
|
+
className?: string;
|
3
|
+
variant: 'primary' | 'secondary' | 'outline' | 'danger';
|
4
|
+
size?: 'small' | 'medium' | 'large';
|
5
|
+
border?: 'primary' | 'secondary' | 'outline' | 'danger';
|
6
|
+
title: string;
|
7
|
+
};
|
@@ -1,3 +1,3 @@
|
|
1
|
-
import Button from
|
2
|
-
|
3
|
-
export default Button;
|
1
|
+
import Button from './Button';
|
2
|
+
|
3
|
+
export default Button;
|