am-shared-assets 0.0.2
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/.gitlab-ci.yml +31 -0
- package/.storybook/main.ts +17 -0
- package/.storybook/preview.ts +22 -0
- package/.storybook/vitest.setup.ts +7 -0
- package/Dockerfile +36 -0
- package/README.md +73 -0
- package/docker-compose.yml +12 -0
- package/eslint.config.js +23 -0
- package/index.html +13 -0
- package/package.json +61 -0
- package/postcss.config.js +6 -0
- package/public/vite.svg +1 -0
- package/src/App.tsx +8 -0
- package/src/components/Alert.tsx +194 -0
- package/src/components/Badge.tsx +48 -0
- package/src/components/Button.tsx +137 -0
- package/src/components/Chip.tsx +139 -0
- package/src/components/Input.tsx +137 -0
- package/src/components/Radio.tsx +89 -0
- package/src/components/RangeSlider.tsx +106 -0
- package/src/components/Select.tsx +13 -0
- package/src/components/Switch.tsx +76 -0
- package/src/components/Tooltip.tsx +111 -0
- package/src/icons/components/AddIcon.tsx +27 -0
- package/src/icons/components/ArrowDownIcon.tsx +25 -0
- package/src/icons/components/ArrowRightIcon.tsx +37 -0
- package/src/icons/components/BagIcon.tsx +25 -0
- package/src/icons/components/BoxIcon.tsx +43 -0
- package/src/icons/components/BoxTimeIcon.tsx +47 -0
- package/src/icons/components/CardTickIcon.tsx +54 -0
- package/src/icons/components/CardsIcon.tsx +48 -0
- package/src/icons/components/CategoryIcon.tsx +37 -0
- package/src/icons/components/ChevronBottomIcon.tsx +22 -0
- package/src/icons/components/ChevronLeftIcon.tsx +29 -0
- package/src/icons/components/ChevronRightIcon.tsx +29 -0
- package/src/icons/components/ChevronTopIcon.tsx +29 -0
- package/src/icons/components/CloseCircleIcon.tsx +25 -0
- package/src/icons/components/CloseIcon.tsx +29 -0
- package/src/icons/components/DislikeIcon.tsx +32 -0
- package/src/icons/components/EditIcon.tsx +39 -0
- package/src/icons/components/HeartIcon.tsx +28 -0
- package/src/icons/components/HomeIcon.tsx +19 -0
- package/src/icons/components/InfoIcon.tsx +25 -0
- package/src/icons/components/LikeIcon.tsx +32 -0
- package/src/icons/components/MessageIcon.tsx +50 -0
- package/src/icons/components/MoneyIcon.tsx +57 -0
- package/src/icons/components/MoreIcon.tsx +33 -0
- package/src/icons/components/OutlineTickCircleIcon.tsx +35 -0
- package/src/icons/components/RotateBoxIcon.tsx +56 -0
- package/src/icons/components/RotateInfoIcon.tsx +34 -0
- package/src/icons/components/SearchIcon.tsx +35 -0
- package/src/icons/components/SettingIcon.tsx +69 -0
- package/src/icons/components/ShareIcon.tsx +37 -0
- package/src/icons/components/ShopIcon.tsx +56 -0
- package/src/icons/components/ShoppingCartIcon.tsx +53 -0
- package/src/icons/components/SpinnerIcon.tsx +25 -0
- package/src/icons/components/StarIcon.tsx +29 -0
- package/src/icons/components/TickCircleIcon.tsx +25 -0
- package/src/icons/components/TrashIcon.tsx +56 -0
- package/src/icons/components/TruckIcon.tsx +51 -0
- package/src/icons/components/UserIcon.tsx +29 -0
- package/src/icons/components/WalletCheckIcon.tsx +52 -0
- package/src/icons/components/WarningIcon.tsx +19 -0
- package/src/icons/index.ts +83 -0
- package/src/index.css +36 -0
- package/src/index.ts +2 -0
- package/src/main.tsx +10 -0
- package/src/stories/Alert.stories.ts +22 -0
- package/src/stories/Badge.stories.tsx +20 -0
- package/src/stories/Button.stories.tsx +108 -0
- package/src/stories/Chip.stories.ts +20 -0
- package/src/stories/Configure.mdx +364 -0
- package/src/stories/IconGallery.stories.tsx +99 -0
- package/src/stories/Input.stories.ts +21 -0
- package/src/stories/Radio.stories.tsx +21 -0
- package/src/stories/RangeSlider.stories.tsx +68 -0
- package/src/stories/Select.stories.ts +21 -0
- package/src/stories/Switch.stories.tsx +21 -0
- package/src/stories/Tooltip.stories.ts +20 -0
- package/src/stories/assets/accessibility.png +0 -0
- package/src/stories/assets/accessibility.svg +1 -0
- package/src/stories/assets/addon-library.png +0 -0
- package/src/stories/assets/assets.png +0 -0
- package/src/stories/assets/avif-test-image.avif +0 -0
- package/src/stories/assets/context.png +0 -0
- package/src/stories/assets/discord.svg +1 -0
- package/src/stories/assets/docs.png +0 -0
- package/src/stories/assets/figma-plugin.png +0 -0
- package/src/stories/assets/fonts/woff/IRANSansXFaNum-Bold.woff +0 -0
- package/src/stories/assets/fonts/woff/IRANSansXFaNum-DemiBold.woff +0 -0
- package/src/stories/assets/fonts/woff/IRANSansXFaNum-Medium.woff +0 -0
- package/src/stories/assets/fonts/woff/IRANSansXFaNum-Regular.woff +0 -0
- package/src/stories/assets/fonts/woff2/IRANSansXFaNum-Bold.woff2 +0 -0
- package/src/stories/assets/fonts/woff2/IRANSansXFaNum-DemiBold.woff2 +0 -0
- package/src/stories/assets/fonts/woff2/IRANSansXFaNum-Medium.woff2 +0 -0
- package/src/stories/assets/fonts/woff2/IRANSansXFaNum-Regular.woff2 +0 -0
- package/src/stories/assets/github.svg +1 -0
- package/src/stories/assets/share.png +0 -0
- package/src/stories/assets/styling.png +0 -0
- package/src/stories/assets/testing.png +0 -0
- package/src/stories/assets/theming.png +0 -0
- package/src/stories/assets/tutorials.svg +1 -0
- package/src/stories/assets/youtube.svg +1 -0
- package/tailwind.config.js +165 -0
- package/tsconfig.app.json +28 -0
- package/tsconfig.json +7 -0
- package/tsconfig.node.json +26 -0
- package/vite.config.ts +38 -0
- package/vitest.shims.d.ts +1 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import clsx from "clsx";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
const sizes = {
|
|
5
|
+
sm: "h-8 text-xs px-3",
|
|
6
|
+
md: "h-10 text-sm px-4",
|
|
7
|
+
lg: "h-12 text-base px-6",
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const textColors: { [key: string]: string } = {
|
|
11
|
+
white: "text-white",
|
|
12
|
+
black: "text-default-900",
|
|
13
|
+
default: "text-default-900",
|
|
14
|
+
primary: "text-base-primary",
|
|
15
|
+
secondary: "text-base-secondary",
|
|
16
|
+
success: "text-base-success",
|
|
17
|
+
warning: "text-base-warning",
|
|
18
|
+
danger: "text-base-danger",
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const bgColors: { [key: string]: string } = {
|
|
22
|
+
default: "bg-default-300",
|
|
23
|
+
primary: "bg-base-primary",
|
|
24
|
+
secondary: "bg-base-secondary",
|
|
25
|
+
success: "bg-base-success",
|
|
26
|
+
warning: "bg-base-warning",
|
|
27
|
+
danger: "bg-base-danger",
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const borderColors: { [key: string]: string } = {
|
|
31
|
+
default: "border-default-300",
|
|
32
|
+
primary: "border-base-primary",
|
|
33
|
+
secondary: "border-base-secondary",
|
|
34
|
+
success: "border-base-success",
|
|
35
|
+
warning: "border-base-warning",
|
|
36
|
+
danger: "border-base-danger",
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const bgFlatColors: { [key: string]: string } = {
|
|
40
|
+
default: "bg-default-100",
|
|
41
|
+
primary: "bg-primary-100",
|
|
42
|
+
secondary: "bg-secondary-100",
|
|
43
|
+
success: "bg-success-100",
|
|
44
|
+
warning: "bg-warning-100",
|
|
45
|
+
danger: "bg-danger-100",
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const radiuses = {
|
|
49
|
+
none: "rounded-none",
|
|
50
|
+
sm: "rounded-sm",
|
|
51
|
+
md: "rounded-md",
|
|
52
|
+
lg: "rounded-lg",
|
|
53
|
+
full: "rounded-full",
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const variantFunc = (variant: string, color: string, textColor: string) => {
|
|
57
|
+
let style = "";
|
|
58
|
+
|
|
59
|
+
switch (variant) {
|
|
60
|
+
case "solid":
|
|
61
|
+
style = `${bgColors[color]} ${textColors[textColor]}`;
|
|
62
|
+
break;
|
|
63
|
+
case "bordered":
|
|
64
|
+
style = `border-2 ${borderColors[color]} ${textColors[color]}`;
|
|
65
|
+
break;
|
|
66
|
+
case "light":
|
|
67
|
+
style = textColors[color];
|
|
68
|
+
break;
|
|
69
|
+
case "flat":
|
|
70
|
+
style = `${bgFlatColors[color]} ${textColors[color]}`;
|
|
71
|
+
break;
|
|
72
|
+
case "faded":
|
|
73
|
+
style = `border-2 ${borderColors["default"]} ${bgFlatColors["default"]} ${textColors[color]}`;
|
|
74
|
+
break;
|
|
75
|
+
case "shadow":
|
|
76
|
+
style = `shadow-lg ${bgColors[color]} ${textColors[textColor]}`;
|
|
77
|
+
break;
|
|
78
|
+
default:
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return style;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export interface ButtonProps {
|
|
86
|
+
variant?: "solid" | "bordered" | "light" | "flat" | "faded" | "shadow";
|
|
87
|
+
color?:
|
|
88
|
+
| "default"
|
|
89
|
+
| "primary"
|
|
90
|
+
| "secondary"
|
|
91
|
+
| "success"
|
|
92
|
+
| "warning"
|
|
93
|
+
| "danger";
|
|
94
|
+
textColor?: "black" | "white";
|
|
95
|
+
size?: "sm" | "md" | "lg";
|
|
96
|
+
rounded?: "none" | "sm" | "md" | "lg" | "full";
|
|
97
|
+
label?: string;
|
|
98
|
+
icon?: ReactNode;
|
|
99
|
+
iconPosition?: "right" | "left";
|
|
100
|
+
width?: "full" | "auto";
|
|
101
|
+
onClick?: () => void;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export const Button = ({
|
|
105
|
+
variant = "solid",
|
|
106
|
+
color = "default",
|
|
107
|
+
textColor = "black",
|
|
108
|
+
size = "md",
|
|
109
|
+
rounded = "none",
|
|
110
|
+
label,
|
|
111
|
+
icon,
|
|
112
|
+
iconPosition = "left",
|
|
113
|
+
width = "auto",
|
|
114
|
+
onClick,
|
|
115
|
+
}: ButtonProps) => {
|
|
116
|
+
const cls = clsx(
|
|
117
|
+
width === "full" ? "w-full" : "w-auto",
|
|
118
|
+
iconPosition === "right" ? "flex-row" : "flex-row-reverse",
|
|
119
|
+
radiuses[rounded],
|
|
120
|
+
sizes[size],
|
|
121
|
+
variantFunc(variant, color, textColor),
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
return (
|
|
125
|
+
<button
|
|
126
|
+
type="button"
|
|
127
|
+
className={
|
|
128
|
+
"flex items-center justify-center gap-2 font-semibold transition-all duration-300 " +
|
|
129
|
+
cls
|
|
130
|
+
}
|
|
131
|
+
onClick={onClick}
|
|
132
|
+
>
|
|
133
|
+
{icon}
|
|
134
|
+
{label && <p>{label}</p>}
|
|
135
|
+
</button>
|
|
136
|
+
);
|
|
137
|
+
};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import clsx from "clsx";
|
|
2
|
+
|
|
3
|
+
const sizes = {
|
|
4
|
+
sm: "h-6 text-xs",
|
|
5
|
+
md: "h-7 text-sm",
|
|
6
|
+
lg: "h-8 text-base",
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const radiuses = {
|
|
10
|
+
none: "rounded-none",
|
|
11
|
+
sm: "rounded-sm",
|
|
12
|
+
md: "rounded-md",
|
|
13
|
+
lg: "rounded-lg",
|
|
14
|
+
full: "rounded-full",
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const bgColors: { [key: string]: string } = {
|
|
18
|
+
default: "bg-default-200",
|
|
19
|
+
primary: "bg-base-primary",
|
|
20
|
+
secondary: "bg-base-secondary",
|
|
21
|
+
success: "bg-base-success",
|
|
22
|
+
warning: "bg-base-warning",
|
|
23
|
+
danger: "bg-base-danger",
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const textColors: { [key: string]: string } = {
|
|
27
|
+
white: "text-content-1",
|
|
28
|
+
black: "text-layout-fg",
|
|
29
|
+
default: "text-layout-fg",
|
|
30
|
+
primary: "text-base-primary",
|
|
31
|
+
secondary: "text-base-secondary",
|
|
32
|
+
success: "text-base-success",
|
|
33
|
+
warning: "text-base-warning",
|
|
34
|
+
danger: "text-base-danger",
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const borderColors: { [key: string]: string } = {
|
|
38
|
+
default: "border-default-200",
|
|
39
|
+
primary: "border-base-primary",
|
|
40
|
+
secondary: "border-base-secondary",
|
|
41
|
+
success: "border-base-success",
|
|
42
|
+
warning: "border-base-warning",
|
|
43
|
+
danger: "border-base-danger",
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const bgFlatColors: { [key: string]: string } = {
|
|
47
|
+
default: "bg-default-200",
|
|
48
|
+
primary: "bg-primary-100",
|
|
49
|
+
secondary: "bg-secondary-100",
|
|
50
|
+
success: "bg-success-100",
|
|
51
|
+
warning: "bg-warning-100",
|
|
52
|
+
danger: "bg-danger-100",
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const dotColors: { [key: string]: string } = {
|
|
56
|
+
default: "bg-default-400",
|
|
57
|
+
primary: "bg-base-primary",
|
|
58
|
+
secondary: "bg-base-secondary",
|
|
59
|
+
success: "bg-base-success",
|
|
60
|
+
warning: "bg-base-warning",
|
|
61
|
+
danger: "bg-base-danger",
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const variantFunc = (variant: string, color: string, textColor: string) => {
|
|
65
|
+
let style = "";
|
|
66
|
+
|
|
67
|
+
switch (variant) {
|
|
68
|
+
case "solid":
|
|
69
|
+
style = `${bgColors[color]} ${textColors[textColor]}`;
|
|
70
|
+
break;
|
|
71
|
+
case "bordered":
|
|
72
|
+
style = `border-2 ${borderColors[color]} ${textColors[color]}`;
|
|
73
|
+
break;
|
|
74
|
+
case "light":
|
|
75
|
+
style = textColors[color];
|
|
76
|
+
break;
|
|
77
|
+
case "flat":
|
|
78
|
+
style = `${bgFlatColors[color]} ${textColors[color]}`;
|
|
79
|
+
break;
|
|
80
|
+
case "faded":
|
|
81
|
+
style = `border-2 ${borderColors["default"]} bg-default-100 ${textColors[color]}`;
|
|
82
|
+
break;
|
|
83
|
+
case "shadow":
|
|
84
|
+
style = `shadow-lg ${bgColors[color]} ${textColors[textColor]}`;
|
|
85
|
+
break;
|
|
86
|
+
case "dot":
|
|
87
|
+
style = `border-2 ${borderColors["default"]} ${textColors["black"]}`;
|
|
88
|
+
break;
|
|
89
|
+
default:
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return style;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
interface IChipProps {
|
|
97
|
+
variant?:
|
|
98
|
+
| "solid"
|
|
99
|
+
| "bordered"
|
|
100
|
+
| "light"
|
|
101
|
+
| "flat"
|
|
102
|
+
| "faded"
|
|
103
|
+
| "shadow"
|
|
104
|
+
| "dot";
|
|
105
|
+
color?:
|
|
106
|
+
| "default"
|
|
107
|
+
| "primary"
|
|
108
|
+
| "secondary"
|
|
109
|
+
| "success"
|
|
110
|
+
| "warning"
|
|
111
|
+
| "danger";
|
|
112
|
+
textColor?: "black" | "white";
|
|
113
|
+
size?: "sm" | "md" | "lg";
|
|
114
|
+
rounded?: "none" | "sm" | "md" | "lg" | "full";
|
|
115
|
+
label?: string;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const Chip = ({
|
|
119
|
+
variant = "solid",
|
|
120
|
+
color = "default",
|
|
121
|
+
textColor = "black",
|
|
122
|
+
label,
|
|
123
|
+
size = "md",
|
|
124
|
+
rounded = "none",
|
|
125
|
+
}: IChipProps) => {
|
|
126
|
+
const cls = clsx(
|
|
127
|
+
radiuses[rounded],
|
|
128
|
+
sizes[size],
|
|
129
|
+
variantFunc(variant, color, textColor)
|
|
130
|
+
);
|
|
131
|
+
return (
|
|
132
|
+
<div className={`w-fit flex items-center justify-center gap-1 px-2 ${cls}`}>
|
|
133
|
+
<p>{label}</p>
|
|
134
|
+
{variant === "dot" && <div className={`size-2 rounded-full ${dotColors[color]}`}></div>}
|
|
135
|
+
</div>
|
|
136
|
+
);
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
export default Chip;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import clsx from "clsx";
|
|
2
|
+
|
|
3
|
+
const sizes = {
|
|
4
|
+
sm: "h-8 py-1",
|
|
5
|
+
lg: "h-10 py-2",
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const labelColors: { [key: string]: string } = {
|
|
9
|
+
default: "text-default-600",
|
|
10
|
+
primary: "text-base-primary",
|
|
11
|
+
success: "text-base-success",
|
|
12
|
+
warning: "text-base-warning",
|
|
13
|
+
danger: "text-base-danger",
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const textColors: { [key: string]: string } = {
|
|
17
|
+
primary: "text-base-primary hover:text-base-primary",
|
|
18
|
+
success: "text-base-success hover:text-base-success",
|
|
19
|
+
warning: "text-base-warning hover:text-base-warning",
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const flatBgColors: { [key: string]: string } = {
|
|
23
|
+
default: "bg-default-100 hover:bg-default-200",
|
|
24
|
+
primary: "bg-primary-100 hover:bg-primary-50",
|
|
25
|
+
success: "bg-success-100 hover:bg-success-50",
|
|
26
|
+
warning: "bg-warning-100 hover:bg-warning-50",
|
|
27
|
+
danger: "bg-danger-100 hover:bg-danger-50",
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const focusedState: { [key: string]: string } = {
|
|
31
|
+
default: "focus:bg-transparent focus:border focus:border-layout-fg",
|
|
32
|
+
primary: "focus:bg-transparent focus:border focus:border-base-primary",
|
|
33
|
+
success: "focus:bg-transparent focus:border focus:border-base-success",
|
|
34
|
+
warning: "focus:bg-transparent focus:border focus:border-base-warning",
|
|
35
|
+
danger: "focus:bg-transparent focus:border focus:border-base-danger",
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const fadedBorderColors: { [key: string]: string } = {
|
|
39
|
+
default: "hover:border-default-400",
|
|
40
|
+
primary: "hover:border-base-primary",
|
|
41
|
+
success: "hover:border-base-success",
|
|
42
|
+
warning: "hover:border-base-warning",
|
|
43
|
+
danger: "hover:border-base-danger",
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const radiuses = {
|
|
47
|
+
sm: "rounded-sm",
|
|
48
|
+
full: "rounded-full",
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const variantFunc = (variant: string, color: string, hasError: boolean) => {
|
|
52
|
+
let style = "";
|
|
53
|
+
|
|
54
|
+
if (hasError)
|
|
55
|
+
return (style =
|
|
56
|
+
"bg-danger-100 hover:bg-danger-50 focus:bg-transparent focus:border focus:border-base-danger");
|
|
57
|
+
|
|
58
|
+
switch (variant) {
|
|
59
|
+
case "flat":
|
|
60
|
+
style = `${flatBgColors[color]} ${focusedState[color]} ${textColors[color]} focus:text-layout-fg`;
|
|
61
|
+
break;
|
|
62
|
+
case "bordered":
|
|
63
|
+
style = `bg-transparent border border-default-200 hover:border-default-400 ${focusedState[color]}`;
|
|
64
|
+
break;
|
|
65
|
+
case "faded":
|
|
66
|
+
style = `border border-default-200 bg-default-100 hover:bg-default-200 ${fadedBorderColors[color]} ${focusedState[color]}`;
|
|
67
|
+
break;
|
|
68
|
+
default:
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return style;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
interface IInputProps {
|
|
76
|
+
id: string | number;
|
|
77
|
+
label?: string;
|
|
78
|
+
required?: boolean;
|
|
79
|
+
value?: string;
|
|
80
|
+
onChange?: (value: string) => void;
|
|
81
|
+
placeHolder?: string;
|
|
82
|
+
variant?: "flat" | "bordered" | "faded";
|
|
83
|
+
color?: "default" | "primary" | "success" | "warning" | "danger";
|
|
84
|
+
size?: "sm" | "lg";
|
|
85
|
+
rounded?: "sm" | "full";
|
|
86
|
+
description?: string;
|
|
87
|
+
errorMsg?: string;
|
|
88
|
+
hasError?: boolean;
|
|
89
|
+
}
|
|
90
|
+
const Input = ({
|
|
91
|
+
id,
|
|
92
|
+
label,
|
|
93
|
+
required = false,
|
|
94
|
+
value,
|
|
95
|
+
onChange,
|
|
96
|
+
placeHolder,
|
|
97
|
+
variant = "flat",
|
|
98
|
+
color = "default",
|
|
99
|
+
size = "sm",
|
|
100
|
+
rounded = "sm",
|
|
101
|
+
description = "",
|
|
102
|
+
errorMsg = "",
|
|
103
|
+
hasError = false,
|
|
104
|
+
}: IInputProps) => {
|
|
105
|
+
const cls = clsx(
|
|
106
|
+
sizes[size],
|
|
107
|
+
radiuses[rounded],
|
|
108
|
+
variantFunc(variant, color, hasError),
|
|
109
|
+
);
|
|
110
|
+
return (
|
|
111
|
+
<div className="flex flex-col">
|
|
112
|
+
{label && (
|
|
113
|
+
<label
|
|
114
|
+
htmlFor={`${id}`}
|
|
115
|
+
className={`text-xs mb-2 ${hasError ? "text-base-danger" : labelColors[color]}`}
|
|
116
|
+
>
|
|
117
|
+
{label}
|
|
118
|
+
{required && <span className="text-base-danger text-sm">*</span>}
|
|
119
|
+
</label>
|
|
120
|
+
)}
|
|
121
|
+
<input
|
|
122
|
+
id={`${id}`}
|
|
123
|
+
type="text"
|
|
124
|
+
value={value}
|
|
125
|
+
onChange={(e) => onChange && onChange(e.target.value)}
|
|
126
|
+
placeholder={placeHolder}
|
|
127
|
+
className={`${cls} w-full px-3 text-sm transition-all duration-200 outline-none`}
|
|
128
|
+
/>
|
|
129
|
+
{description && !errorMsg && (
|
|
130
|
+
<p className="mt-1 text-xs text-default-400">{description}</p>
|
|
131
|
+
)}
|
|
132
|
+
{errorMsg && <p className="mt-1 mr-1 text-xs text-base-danger">{errorMsg}</p>}
|
|
133
|
+
</div>
|
|
134
|
+
);
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
export default Input;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import clsx from "clsx";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
const sizes = {
|
|
5
|
+
sm: "size-4 min-w-4 p-[3px]",
|
|
6
|
+
md: "size-5 min-w-5 p-1",
|
|
7
|
+
lg: "size-6 min-w-6 p-[5px]",
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const radioBorderColor = {
|
|
11
|
+
primary: "border-base-primary",
|
|
12
|
+
secondary: "border-base-secondary",
|
|
13
|
+
success: "border-base-success",
|
|
14
|
+
warning: "border-base-warning",
|
|
15
|
+
danger: "border-base-danger",
|
|
16
|
+
neutral: "border-default-500",
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const radioBgColor = {
|
|
20
|
+
primary: "bg-base-primary",
|
|
21
|
+
secondary: "bg-base-secondary",
|
|
22
|
+
success: "bg-base-success",
|
|
23
|
+
warning: "bg-base-warning",
|
|
24
|
+
danger: "bg-base-danger",
|
|
25
|
+
neutral: "bg-default-500",
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
interface IRadioProps {
|
|
29
|
+
name: string;
|
|
30
|
+
value?: string;
|
|
31
|
+
checked: boolean;
|
|
32
|
+
disabled?: boolean;
|
|
33
|
+
onChange?: (value: string) => void;
|
|
34
|
+
size?: "sm" | "md" | "lg";
|
|
35
|
+
color?:
|
|
36
|
+
| "primary"
|
|
37
|
+
| "secondary"
|
|
38
|
+
| "success"
|
|
39
|
+
| "warning"
|
|
40
|
+
| "danger"
|
|
41
|
+
| "neutral";
|
|
42
|
+
children?: ReactNode;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const Radio = ({
|
|
46
|
+
name,
|
|
47
|
+
value,
|
|
48
|
+
checked,
|
|
49
|
+
disabled = false,
|
|
50
|
+
onChange,
|
|
51
|
+
size = "md",
|
|
52
|
+
color = "primary",
|
|
53
|
+
children,
|
|
54
|
+
}: IRadioProps) => {
|
|
55
|
+
const cls = clsx(
|
|
56
|
+
sizes[size],
|
|
57
|
+
checked
|
|
58
|
+
? radioBorderColor[color]
|
|
59
|
+
: "border-base-default hover:bg-default-100 transition-all duration-200",
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<label
|
|
64
|
+
className={`flex items-center gap-2 ${disabled ? "opacity-50" : "cursor-pointer"}`}
|
|
65
|
+
>
|
|
66
|
+
<input
|
|
67
|
+
name={name}
|
|
68
|
+
type="radio"
|
|
69
|
+
value={value}
|
|
70
|
+
checked={checked}
|
|
71
|
+
onChange={(e) => onChange && onChange(e.target.value)}
|
|
72
|
+
disabled={disabled}
|
|
73
|
+
style={{ display: "none" }}
|
|
74
|
+
/>
|
|
75
|
+
<div
|
|
76
|
+
className={`flex justify-center items-center rounded-full border-2 ${cls}`}
|
|
77
|
+
>
|
|
78
|
+
{checked && (
|
|
79
|
+
<span
|
|
80
|
+
className={`block w-full h-full rounded-full ${radioBgColor[color]}`}
|
|
81
|
+
/>
|
|
82
|
+
)}
|
|
83
|
+
</div>
|
|
84
|
+
<div>{children}</div>
|
|
85
|
+
</label>
|
|
86
|
+
);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export default Radio;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { Slider } from "@mui/material";
|
|
2
|
+
import type { Dispatch, SetStateAction } from "react";
|
|
3
|
+
import Tooltip from "./Tooltip";
|
|
4
|
+
|
|
5
|
+
const colors: { [key: string]: string } = {
|
|
6
|
+
foreground: "#000000",
|
|
7
|
+
primary: "#112E62",
|
|
8
|
+
secondary: "#C59C4E",
|
|
9
|
+
success: "#17C964",
|
|
10
|
+
warning: "#F5A524",
|
|
11
|
+
danger: "#F31260",
|
|
12
|
+
};
|
|
13
|
+
const shadowColors: { [key: string]: string } = {
|
|
14
|
+
foreground: "#A1A1AA",
|
|
15
|
+
primary: "#D6E0F3",
|
|
16
|
+
secondary: "#EEE1C9",
|
|
17
|
+
success: "#d1f4e0",
|
|
18
|
+
warning: "#fdedd3",
|
|
19
|
+
danger: "#fdd0df",
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
interface IRangeSliderProps {
|
|
23
|
+
value: number | number[];
|
|
24
|
+
setValue: Dispatch<SetStateAction<any>>;
|
|
25
|
+
min?: number;
|
|
26
|
+
max?: number;
|
|
27
|
+
step?: number;
|
|
28
|
+
color?:
|
|
29
|
+
| "foreground"
|
|
30
|
+
| "primary"
|
|
31
|
+
| "secondary"
|
|
32
|
+
| "success"
|
|
33
|
+
| "warning"
|
|
34
|
+
| "danger";
|
|
35
|
+
tooltipColor?:
|
|
36
|
+
| "default"
|
|
37
|
+
| "primary"
|
|
38
|
+
| "secondary"
|
|
39
|
+
| "success"
|
|
40
|
+
| "warning"
|
|
41
|
+
| "danger";
|
|
42
|
+
tooltipTextColor?: "white" | "black";
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export const RangeSlider = ({
|
|
46
|
+
value,
|
|
47
|
+
setValue,
|
|
48
|
+
min = 0,
|
|
49
|
+
max = 100,
|
|
50
|
+
step = 1,
|
|
51
|
+
color = "primary",
|
|
52
|
+
tooltipColor = "primary",
|
|
53
|
+
tooltipTextColor = "white",
|
|
54
|
+
}: IRangeSliderProps) => {
|
|
55
|
+
return (
|
|
56
|
+
<Slider
|
|
57
|
+
value={value}
|
|
58
|
+
min={min}
|
|
59
|
+
max={max}
|
|
60
|
+
step={step}
|
|
61
|
+
onChange={(_, newValue) => {
|
|
62
|
+
setValue(newValue);
|
|
63
|
+
// if (typeof newValue !== "number") setSliderValue(newValue);
|
|
64
|
+
}}
|
|
65
|
+
onChangeCommitted={(_, newValue) => {
|
|
66
|
+
// if (typeof newValue !== "number") handleChooseRange(newValue);
|
|
67
|
+
}}
|
|
68
|
+
valueLabelFormat={(value) => (
|
|
69
|
+
<Tooltip
|
|
70
|
+
color={tooltipColor}
|
|
71
|
+
textColor={tooltipTextColor}
|
|
72
|
+
label={`${value.toLocaleString()}`}
|
|
73
|
+
/>
|
|
74
|
+
)}
|
|
75
|
+
valueLabelDisplay="auto"
|
|
76
|
+
sx={{
|
|
77
|
+
width: "100%",
|
|
78
|
+
height: "4px",
|
|
79
|
+
borderRadius: "8px",
|
|
80
|
+
color: "#D4D4D8",
|
|
81
|
+
"& .MuiSlider-thumb": {
|
|
82
|
+
width: "16px",
|
|
83
|
+
height: "16px",
|
|
84
|
+
border: "2px solid",
|
|
85
|
+
borderColor: colors[color],
|
|
86
|
+
color: "#fff",
|
|
87
|
+
},
|
|
88
|
+
"& .MuiSlider-thumb.Mui-focusVisible": {
|
|
89
|
+
boxShadow: `0 0 0 4px ${shadowColors[color]}`,
|
|
90
|
+
},
|
|
91
|
+
"& .MuiSlider-thumb.Mui-active": {
|
|
92
|
+
boxShadow: `0 0 0 4px ${shadowColors[color]}`,
|
|
93
|
+
},
|
|
94
|
+
"& .MuiSlider-thumb:hover": {
|
|
95
|
+
boxShadow: `0 0 0 4px ${shadowColors[color]}`,
|
|
96
|
+
},
|
|
97
|
+
"& .MuiSlider-track": {
|
|
98
|
+
color: colors[color],
|
|
99
|
+
},
|
|
100
|
+
"& .MuiSlider-valueLabel": {
|
|
101
|
+
backgroundColor: "transparent",
|
|
102
|
+
},
|
|
103
|
+
}}
|
|
104
|
+
/>
|
|
105
|
+
);
|
|
106
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const Select = () => {
|
|
2
|
+
return (
|
|
3
|
+
<div className="w-[328px] p-2 rounded-sm bg-content-1 shadow-[0px_1px_2px_0px_#0000000F,0px_1px_3px_0px_#0000001A]">
|
|
4
|
+
<div className="flex flex-col gap-1">
|
|
5
|
+
{new Array(10).fill({}).map((_,i) => (
|
|
6
|
+
<div className="w-full h-8 py-1.5 px-2 text-sm rounded-sm hover:bg-content-2 cursor-pointer">متن</div>
|
|
7
|
+
))}
|
|
8
|
+
</div>
|
|
9
|
+
</div>
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default Select;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import clsx from "clsx";
|
|
2
|
+
|
|
3
|
+
const sizes = {
|
|
4
|
+
sm: "min-w-10 min-h-6",
|
|
5
|
+
md: "min-w-12 min-h-7",
|
|
6
|
+
lg: "min-w-14 min-h-8",
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const colors: { [key: string]: string } = {
|
|
10
|
+
default: "bg-default-400",
|
|
11
|
+
primary: "bg-layout-focus",
|
|
12
|
+
secondary: "bg-base-secondary",
|
|
13
|
+
success: "bg-base-success",
|
|
14
|
+
warning: "bg-base-warning",
|
|
15
|
+
danger: "bg-base-danger",
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
interface ISwitchProps {
|
|
19
|
+
enabled: boolean;
|
|
20
|
+
onChange: () => void;
|
|
21
|
+
label?: string;
|
|
22
|
+
labelPosition?: "right" | "left";
|
|
23
|
+
size?: "sm" | "md" | "lg";
|
|
24
|
+
color?:
|
|
25
|
+
| "default"
|
|
26
|
+
| "primary"
|
|
27
|
+
| "secondary"
|
|
28
|
+
| "success"
|
|
29
|
+
| "warning"
|
|
30
|
+
| "danger";
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
}
|
|
33
|
+
const Switch = ({
|
|
34
|
+
enabled,
|
|
35
|
+
onChange,
|
|
36
|
+
label,
|
|
37
|
+
labelPosition = "left",
|
|
38
|
+
size = "md",
|
|
39
|
+
color = "default",
|
|
40
|
+
disabled = false,
|
|
41
|
+
}: ISwitchProps) => {
|
|
42
|
+
const cls = clsx(
|
|
43
|
+
labelPosition === "left" ? "flex-row" : "flex-row-reverse",
|
|
44
|
+
disabled && "opacity-50",
|
|
45
|
+
);
|
|
46
|
+
const buttonCls = clsx(
|
|
47
|
+
sizes[size],
|
|
48
|
+
enabled ? colors[color] : "bg-default-700",
|
|
49
|
+
disabled && "cursor-auto",
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<div className={`flex items-center gap-2 ${cls}`}>
|
|
54
|
+
<button
|
|
55
|
+
onClick={onChange}
|
|
56
|
+
className={`relative rounded-full transition-colors duration-300 p-1 ${buttonCls}`}
|
|
57
|
+
disabled={disabled}
|
|
58
|
+
>
|
|
59
|
+
<span
|
|
60
|
+
className={`
|
|
61
|
+
block h-[calc(100%-8px)] aspect-square rounded-full bg-content-1
|
|
62
|
+
transition-all duration-300 shadow-[0px_0px_1px_0px_#0000004D,0px_2px_10px_0px_#0000000F,0px_0px_5px_0px_#00000005]
|
|
63
|
+
absolute top-1 left-1 ${enabled && "translate-x-full"}
|
|
64
|
+
`}
|
|
65
|
+
/>
|
|
66
|
+
</button>
|
|
67
|
+
{label && (
|
|
68
|
+
<p className={`text-default-600 ${size === "sm" && "text-sm"}`}>
|
|
69
|
+
{label}
|
|
70
|
+
</p>
|
|
71
|
+
)}
|
|
72
|
+
</div>
|
|
73
|
+
);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export default Switch;
|