@kivid/native-components 1.0.0-alpha.6 → 1.0.0-alpha.8
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/commonjs/components/Avatar/index.js +5 -4
- package/dist/commonjs/components/Avatar/index.js.map +1 -1
- package/dist/commonjs/components/ChatBubble/assets/class-variants.js +6 -6
- package/dist/commonjs/components/ChatBubble/assets/class-variants.js.map +1 -1
- package/dist/commonjs/components/ChatBubble/components/ChatBubbleSeal/index.js +5 -5
- package/dist/commonjs/components/ChatBubble/components/ChatBubbleSeal/index.js.map +1 -1
- package/dist/commonjs/components/ChatBubble/components/ChatBubbleText/index.js +4 -4
- package/dist/commonjs/components/ChatBubble/components/ChatBubbleText/index.js.map +1 -1
- package/dist/commonjs/components/ChatBubble/{context.js → contexts/ChatBubbleContext/index.js} +1 -1
- package/dist/commonjs/components/ChatBubble/contexts/ChatBubbleContext/index.js.map +1 -0
- package/dist/commonjs/components/ChatBubble/contexts/ChatBubbleContext/types.js +6 -0
- package/dist/commonjs/components/ChatBubble/contexts/ChatBubbleContext/types.js.map +1 -0
- package/dist/commonjs/components/ChatBubble/contexts/index.js +17 -0
- package/dist/commonjs/components/ChatBubble/contexts/index.js.map +1 -0
- package/dist/commonjs/components/ChatBubble/index.js +10 -9
- package/dist/commonjs/components/ChatBubble/index.js.map +1 -1
- package/dist/commonjs/components/IconButton/assets/class-variants.js +82 -0
- package/dist/commonjs/components/IconButton/assets/class-variants.js.map +1 -0
- package/dist/commonjs/components/IconButton/assets/design-system-showcase.js +119 -0
- package/dist/commonjs/components/IconButton/assets/design-system-showcase.js.map +1 -0
- package/dist/commonjs/components/IconButton/enums.js +33 -0
- package/dist/commonjs/components/IconButton/enums.js.map +1 -0
- package/dist/commonjs/components/IconButton/index.js +108 -0
- package/dist/commonjs/components/IconButton/index.js.map +1 -0
- package/dist/commonjs/components/IconButton/types.js +6 -0
- package/dist/commonjs/components/IconButton/types.js.map +1 -0
- package/dist/commonjs/components/ListButton/assets/class-variants.js +2 -10
- package/dist/commonjs/components/ListButton/assets/class-variants.js.map +1 -1
- package/dist/commonjs/components/ListButton/assets/design-system-showcase.js +424 -0
- package/dist/commonjs/components/ListButton/assets/design-system-showcase.js.map +1 -0
- package/dist/commonjs/components/ListButton/enums/index.js +0 -11
- package/dist/commonjs/components/ListButton/enums/index.js.map +1 -1
- package/dist/commonjs/components/ListButton/index.js +41 -36
- package/dist/commonjs/components/ListButton/index.js.map +1 -1
- package/dist/commonjs/components/OtpInput/assets/class-variant.js +1 -1
- package/dist/commonjs/components/OtpInput/assets/class-variant.js.map +1 -1
- package/dist/commonjs/components/OtpInput/components/InformationStatus/index.js +13 -11
- package/dist/commonjs/components/OtpInput/components/InformationStatus/index.js.map +1 -1
- package/dist/commonjs/components/OtpInput/enums/index.js +7 -8
- package/dist/commonjs/components/OtpInput/enums/index.js.map +1 -1
- package/dist/commonjs/components/OtpInput/index.js +66 -101
- package/dist/commonjs/components/OtpInput/index.js.map +1 -1
- package/dist/commonjs/components/PasswordInput/index.js +42 -0
- package/dist/commonjs/components/PasswordInput/index.js.map +1 -0
- package/dist/commonjs/components/PasswordInput/types.js +6 -0
- package/dist/commonjs/components/PasswordInput/types.js.map +1 -0
- package/dist/commonjs/components/TextInput/index.js +14 -3
- package/dist/commonjs/components/TextInput/index.js.map +1 -1
- package/dist/commonjs/components/Tooltip/index.js +44 -5
- package/dist/commonjs/components/Tooltip/index.js.map +1 -1
- package/dist/commonjs/components/index.js +33 -0
- package/dist/commonjs/components/index.js.map +1 -1
- package/dist/commonjs/iconography/Icons/index.js +1 -1
- package/dist/commonjs/iconography/Icons/index.js.map +1 -1
- package/dist/module/components/Avatar/index.js +5 -4
- package/dist/module/components/Avatar/index.js.map +1 -1
- package/dist/module/components/ChatBubble/assets/class-variants.js +6 -6
- package/dist/module/components/ChatBubble/assets/class-variants.js.map +1 -1
- package/dist/module/components/ChatBubble/components/ChatBubbleSeal/index.js +4 -4
- package/dist/module/components/ChatBubble/components/ChatBubbleSeal/index.js.map +1 -1
- package/dist/module/components/ChatBubble/components/ChatBubbleText/index.js +5 -4
- package/dist/module/components/ChatBubble/components/ChatBubbleText/index.js.map +1 -1
- package/dist/module/components/ChatBubble/{context.js → contexts/ChatBubbleContext/index.js} +1 -1
- package/dist/module/components/ChatBubble/contexts/ChatBubbleContext/index.js.map +1 -0
- package/dist/module/components/ChatBubble/contexts/ChatBubbleContext/types.js +4 -0
- package/dist/module/components/ChatBubble/contexts/ChatBubbleContext/types.js.map +1 -0
- package/dist/module/components/ChatBubble/contexts/index.js +4 -0
- package/dist/module/components/ChatBubble/contexts/index.js.map +1 -0
- package/dist/module/components/ChatBubble/index.js +9 -8
- package/dist/module/components/ChatBubble/index.js.map +1 -1
- package/dist/module/components/IconButton/assets/class-variants.js +79 -0
- package/dist/module/components/IconButton/assets/class-variants.js.map +1 -0
- package/dist/module/components/IconButton/assets/design-system-showcase.js +115 -0
- package/dist/module/components/IconButton/assets/design-system-showcase.js.map +1 -0
- package/dist/module/components/IconButton/enums.js +29 -0
- package/dist/module/components/IconButton/enums.js.map +1 -0
- package/dist/module/components/IconButton/index.js +103 -0
- package/dist/module/components/IconButton/index.js.map +1 -0
- package/dist/module/components/IconButton/types.js +4 -0
- package/dist/module/components/IconButton/types.js.map +1 -0
- package/dist/module/components/ListButton/assets/class-variants.js +2 -10
- package/dist/module/components/ListButton/assets/class-variants.js.map +1 -1
- package/dist/module/components/ListButton/assets/design-system-showcase.js +420 -0
- package/dist/module/components/ListButton/assets/design-system-showcase.js.map +1 -0
- package/dist/module/components/ListButton/enums/index.js +0 -1
- package/dist/module/components/ListButton/enums/index.js.map +1 -1
- package/dist/module/components/ListButton/index.js +44 -39
- package/dist/module/components/ListButton/index.js.map +1 -1
- package/dist/module/components/OtpInput/assets/class-variant.js +1 -1
- package/dist/module/components/OtpInput/assets/class-variant.js.map +1 -1
- package/dist/module/components/OtpInput/components/InformationStatus/index.js +15 -13
- package/dist/module/components/OtpInput/components/InformationStatus/index.js.map +1 -1
- package/dist/module/components/OtpInput/enums/index.js +6 -7
- package/dist/module/components/OtpInput/enums/index.js.map +1 -1
- package/dist/module/components/OtpInput/index.js +66 -101
- package/dist/module/components/OtpInput/index.js.map +1 -1
- package/dist/module/components/PasswordInput/index.js +37 -0
- package/dist/module/components/PasswordInput/index.js.map +1 -0
- package/dist/module/components/PasswordInput/types.js +4 -0
- package/dist/module/components/PasswordInput/types.js.map +1 -0
- package/dist/module/components/TextInput/index.js +14 -3
- package/dist/module/components/TextInput/index.js.map +1 -1
- package/dist/module/components/Tooltip/index.js +45 -6
- package/dist/module/components/Tooltip/index.js.map +1 -1
- package/dist/module/components/index.js +3 -0
- package/dist/module/components/index.js.map +1 -1
- package/dist/module/iconography/Icons/index.js +2 -2
- package/dist/module/iconography/Icons/index.js.map +1 -1
- package/dist/typescript/components/Avatar/types.d.ts +1 -0
- package/dist/typescript/components/ChatBubble/assets/class-variants.d.ts +1 -1
- package/dist/typescript/components/ChatBubble/components/ChatBubbleSeal/types.d.ts +1 -1
- package/dist/typescript/components/ChatBubble/components/ChatBubbleText/types.d.ts +1 -1
- package/dist/typescript/components/ChatBubble/contexts/ChatBubbleContext/index.d.ts +3 -0
- package/dist/typescript/components/ChatBubble/contexts/ChatBubbleContext/types.d.ts +6 -0
- package/dist/typescript/components/ChatBubble/contexts/index.d.ts +1 -0
- package/dist/typescript/components/ChatBubble/types.d.ts +2 -2
- package/dist/typescript/components/IconButton/assets/class-variants.d.ts +8 -0
- package/dist/typescript/components/IconButton/assets/design-system-showcase.d.ts +17 -0
- package/dist/typescript/components/IconButton/enums.d.ts +22 -0
- package/dist/typescript/components/IconButton/index.d.ts +2 -0
- package/dist/typescript/components/IconButton/types.d.ts +15 -0
- package/dist/typescript/components/ListButton/assets/class-variants.d.ts +1 -4
- package/dist/typescript/components/ListButton/assets/design-system-showcase.d.ts +14 -0
- package/dist/typescript/components/ListButton/enums/index.d.ts +0 -1
- package/dist/typescript/components/ListButton/types.d.ts +7 -5
- package/dist/typescript/components/OtpInput/components/InformationStatus/types.d.ts +2 -2
- package/dist/typescript/components/OtpInput/enums/index.d.ts +2 -3
- package/dist/typescript/components/OtpInput/index.d.ts +1 -1
- package/dist/typescript/components/OtpInput/types.d.ts +4 -4
- package/dist/typescript/components/PasswordInput/index.d.ts +2 -0
- package/dist/typescript/components/PasswordInput/types.d.ts +3 -0
- package/dist/typescript/components/TextInput/index.d.ts +1 -1
- package/dist/typescript/components/TextInput/types.d.ts +3 -0
- package/dist/typescript/components/Tooltip/components/Content/types.d.ts +1 -0
- package/dist/typescript/components/Tooltip/types.d.ts +2 -1
- package/dist/typescript/components/index.d.ts +6 -0
- package/package.json +5 -5
- package/src/components/Avatar/index.tsx +4 -4
- package/src/components/Avatar/types.ts +1 -0
- package/src/components/ChatBubble/assets/class-variants.ts +6 -6
- package/src/components/ChatBubble/components/ChatBubbleSeal/index.tsx +5 -4
- package/src/components/ChatBubble/components/ChatBubbleSeal/types.ts +1 -1
- package/src/components/ChatBubble/components/ChatBubbleText/index.tsx +4 -3
- package/src/components/ChatBubble/components/ChatBubbleText/types.ts +1 -1
- package/src/components/ChatBubble/{context.tsx → contexts/ChatBubbleContext/index.tsx} +1 -10
- package/src/components/ChatBubble/contexts/ChatBubbleContext/types.ts +11 -0
- package/src/components/ChatBubble/contexts/index.ts +1 -0
- package/src/components/ChatBubble/index.tsx +12 -10
- package/src/components/ChatBubble/types.ts +2 -3
- package/src/components/IconButton/assets/class-variants.ts +126 -0
- package/src/components/IconButton/assets/design-system-showcase.ts +246 -0
- package/src/components/IconButton/enums.ts +26 -0
- package/src/components/IconButton/index.tsx +124 -0
- package/src/components/IconButton/types.ts +22 -0
- package/src/components/ListButton/assets/class-variants.ts +2 -11
- package/src/components/ListButton/assets/design-system-showcase.ts +502 -0
- package/src/components/ListButton/enums/index.ts +0 -1
- package/src/components/ListButton/index.tsx +44 -41
- package/src/components/ListButton/types.ts +7 -5
- package/src/components/OtpInput/assets/class-variant.ts +1 -1
- package/src/components/OtpInput/components/InformationStatus/index.tsx +15 -14
- package/src/components/OtpInput/components/InformationStatus/types.ts +2 -2
- package/src/components/OtpInput/enums/index.ts +1 -2
- package/src/components/OtpInput/index.tsx +77 -136
- package/src/components/OtpInput/types.ts +4 -4
- package/src/components/PasswordInput/index.tsx +37 -0
- package/src/components/PasswordInput/types.ts +4 -0
- package/src/components/TextInput/index.tsx +17 -3
- package/src/components/TextInput/types.ts +3 -0
- package/src/components/Tooltip/components/Content/types.ts +1 -0
- package/src/components/Tooltip/index.tsx +57 -5
- package/src/components/Tooltip/types.ts +2 -1
- package/src/components/index.ts +8 -0
- package/src/iconography/Icons/index.tsx +2 -3
- package/dist/commonjs/components/ChatBubble/context.js.map +0 -1
- package/dist/commonjs/components/ListButton/enums/icon-color.js +0 -18
- package/dist/commonjs/components/ListButton/enums/icon-color.js.map +0 -1
- package/dist/module/components/ChatBubble/context.js.map +0 -1
- package/dist/module/components/ListButton/enums/icon-color.js +0 -14
- package/dist/module/components/ListButton/enums/icon-color.js.map +0 -1
- package/dist/typescript/components/ChatBubble/context.d.ts +0 -8
- package/dist/typescript/components/ListButton/enums/icon-color.d.ts +0 -10
- package/src/components/ListButton/enums/icon-color.ts +0 -10
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { cva } from "class-variance-authority";
|
|
2
|
+
import {
|
|
3
|
+
IconButtonCornersEnum,
|
|
4
|
+
IconButtonSizeEnum,
|
|
5
|
+
IconButtonVariantEnum,
|
|
6
|
+
} from "../enums";
|
|
7
|
+
|
|
8
|
+
const buttonVariants = cva(
|
|
9
|
+
[
|
|
10
|
+
"flex flex-row items-center justify-center max-w-fit",
|
|
11
|
+
"disabled:cursor-not-allowed",
|
|
12
|
+
"relative overflow-hidden",
|
|
13
|
+
],
|
|
14
|
+
{
|
|
15
|
+
variants: {
|
|
16
|
+
variant: {
|
|
17
|
+
[IconButtonVariantEnum.GRAPE]: [
|
|
18
|
+
"bg-grape-500",
|
|
19
|
+
"disabled:bg-grape-500 disabled:opacity-30",
|
|
20
|
+
],
|
|
21
|
+
[IconButtonVariantEnum.JAVA]: [
|
|
22
|
+
"bg-java-500",
|
|
23
|
+
"disabled:bg-java-500 disabled:opacity-30",
|
|
24
|
+
],
|
|
25
|
+
[IconButtonVariantEnum.PEAR]: [
|
|
26
|
+
"bg-pear-500",
|
|
27
|
+
"disabled:bg-pear-500 disabled:opacity-30",
|
|
28
|
+
],
|
|
29
|
+
[IconButtonVariantEnum.TANGERINE]: [
|
|
30
|
+
"bg-tangerine-500",
|
|
31
|
+
"disabled:bg-tangerine-500 disabled:opacity-30",
|
|
32
|
+
],
|
|
33
|
+
[IconButtonVariantEnum.PITAYA]: [
|
|
34
|
+
"bg-pitaya-500 border border-pitaya-500",
|
|
35
|
+
"disabled:bg-pitaya-500 disabled:opacity-30",
|
|
36
|
+
],
|
|
37
|
+
[IconButtonVariantEnum.BLACKBERRY]: [
|
|
38
|
+
"bg-blackberry-500",
|
|
39
|
+
"disabled:bg-blackberry-500 disabled:opacity-30",
|
|
40
|
+
],
|
|
41
|
+
[IconButtonVariantEnum.CHIA]: [
|
|
42
|
+
"bg-chia-700",
|
|
43
|
+
"disabled:bg-chia-700 disabled:opacity-30",
|
|
44
|
+
],
|
|
45
|
+
[IconButtonVariantEnum.OUTLINE]: [
|
|
46
|
+
"bg-chia-100 border-100 border-chia-400",
|
|
47
|
+
"disabled:bg-chia-200 disabled:opacity-50",
|
|
48
|
+
],
|
|
49
|
+
[IconButtonVariantEnum.GHOST]: [
|
|
50
|
+
"bg-transparent",
|
|
51
|
+
"disabled:opacity-30",
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
size: {
|
|
55
|
+
[IconButtonSizeEnum.SMALL]: "px-400 py-300",
|
|
56
|
+
[IconButtonSizeEnum.MEDIUM]: "px-500 py-400",
|
|
57
|
+
[IconButtonSizeEnum.LARGE]: "px-600 py-400",
|
|
58
|
+
[IconButtonSizeEnum.XLARGE]: "px-700 py-500",
|
|
59
|
+
[IconButtonSizeEnum.XXLARGE]: "px-800 py-600",
|
|
60
|
+
},
|
|
61
|
+
corners: {
|
|
62
|
+
[IconButtonCornersEnum.SMALL]: "rounded-500",
|
|
63
|
+
[IconButtonCornersEnum.MEDIUM]: "rounded-700",
|
|
64
|
+
},
|
|
65
|
+
selected: {
|
|
66
|
+
true: "",
|
|
67
|
+
false: "",
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
compoundVariants: [
|
|
71
|
+
{
|
|
72
|
+
variant: IconButtonVariantEnum.GRAPE,
|
|
73
|
+
selected: true,
|
|
74
|
+
className: "bg-grape-600",
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
variant: IconButtonVariantEnum.JAVA,
|
|
78
|
+
selected: true,
|
|
79
|
+
className: "bg-java-600",
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
variant: IconButtonVariantEnum.PEAR,
|
|
83
|
+
selected: true,
|
|
84
|
+
className: "bg-pear-600",
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
variant: IconButtonVariantEnum.TANGERINE,
|
|
88
|
+
selected: true,
|
|
89
|
+
className: "bg-tangerine-600",
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
variant: IconButtonVariantEnum.BLACKBERRY,
|
|
93
|
+
selected: true,
|
|
94
|
+
className: "bg-blackberry-600",
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
variant: IconButtonVariantEnum.CHIA,
|
|
98
|
+
selected: true,
|
|
99
|
+
className: "bg-chia-600",
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
variant: IconButtonVariantEnum.OUTLINE,
|
|
103
|
+
selected: true,
|
|
104
|
+
className: "bg-outline-600",
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
variant: IconButtonVariantEnum.PITAYA,
|
|
108
|
+
selected: true,
|
|
109
|
+
className: "bg-pitaya-600",
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
variant: IconButtonVariantEnum.GHOST,
|
|
113
|
+
selected: true,
|
|
114
|
+
className: "bg-grape-100 border-100 border-grape-300",
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
defaultVariants: {
|
|
118
|
+
variant: IconButtonVariantEnum.GRAPE,
|
|
119
|
+
size: IconButtonSizeEnum.MEDIUM,
|
|
120
|
+
corners: IconButtonCornersEnum.MEDIUM,
|
|
121
|
+
selected: false,
|
|
122
|
+
},
|
|
123
|
+
}
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
export { buttonVariants };
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import {
|
|
2
|
+
IconButtonCornersEnum,
|
|
3
|
+
IconButtonSizeEnum,
|
|
4
|
+
IconButtonVariantEnum,
|
|
5
|
+
} from "../enums";
|
|
6
|
+
|
|
7
|
+
interface DesignSystemShowcaseItem {
|
|
8
|
+
size: IconButtonSizeEnum;
|
|
9
|
+
variant: IconButtonVariantEnum;
|
|
10
|
+
corners: IconButtonCornersEnum;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
selected?: boolean;
|
|
13
|
+
loading?: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface DesignSystemShowcaseButtonProps {
|
|
17
|
+
title: string;
|
|
18
|
+
buttons: {
|
|
19
|
+
[key: string]: DesignSystemShowcaseItem[];
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const makeVariantSet = (
|
|
24
|
+
size: IconButtonSizeEnum,
|
|
25
|
+
variant: IconButtonVariantEnum
|
|
26
|
+
): DesignSystemShowcaseItem[] => [
|
|
27
|
+
{ size, variant, corners: IconButtonCornersEnum.MEDIUM },
|
|
28
|
+
{ size, variant, corners: IconButtonCornersEnum.MEDIUM, selected: true },
|
|
29
|
+
{ size, variant, corners: IconButtonCornersEnum.MEDIUM, disabled: true },
|
|
30
|
+
{ size, variant, corners: IconButtonCornersEnum.MEDIUM, loading: true },
|
|
31
|
+
{ size, variant, corners: IconButtonCornersEnum.SMALL },
|
|
32
|
+
{ size, variant, corners: IconButtonCornersEnum.SMALL, selected: true },
|
|
33
|
+
{ size, variant, corners: IconButtonCornersEnum.SMALL, disabled: true },
|
|
34
|
+
{ size, variant, corners: IconButtonCornersEnum.SMALL, loading: true },
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
export const designSystemShowcase: Record<
|
|
38
|
+
IconButtonSizeEnum,
|
|
39
|
+
DesignSystemShowcaseButtonProps
|
|
40
|
+
> = {
|
|
41
|
+
[IconButtonSizeEnum.SMALL]: {
|
|
42
|
+
title: "Small Size",
|
|
43
|
+
buttons: {
|
|
44
|
+
[IconButtonVariantEnum.GRAPE]: makeVariantSet(
|
|
45
|
+
IconButtonSizeEnum.SMALL,
|
|
46
|
+
IconButtonVariantEnum.GRAPE
|
|
47
|
+
),
|
|
48
|
+
[IconButtonVariantEnum.JAVA]: makeVariantSet(
|
|
49
|
+
IconButtonSizeEnum.SMALL,
|
|
50
|
+
IconButtonVariantEnum.JAVA
|
|
51
|
+
),
|
|
52
|
+
[IconButtonVariantEnum.PEAR]: makeVariantSet(
|
|
53
|
+
IconButtonSizeEnum.SMALL,
|
|
54
|
+
IconButtonVariantEnum.PEAR
|
|
55
|
+
),
|
|
56
|
+
[IconButtonVariantEnum.TANGERINE]: makeVariantSet(
|
|
57
|
+
IconButtonSizeEnum.SMALL,
|
|
58
|
+
IconButtonVariantEnum.TANGERINE
|
|
59
|
+
),
|
|
60
|
+
[IconButtonVariantEnum.PITAYA]: makeVariantSet(
|
|
61
|
+
IconButtonSizeEnum.SMALL,
|
|
62
|
+
IconButtonVariantEnum.PITAYA
|
|
63
|
+
),
|
|
64
|
+
[IconButtonVariantEnum.BLACKBERRY]: makeVariantSet(
|
|
65
|
+
IconButtonSizeEnum.SMALL,
|
|
66
|
+
IconButtonVariantEnum.BLACKBERRY
|
|
67
|
+
),
|
|
68
|
+
[IconButtonVariantEnum.CHIA]: makeVariantSet(
|
|
69
|
+
IconButtonSizeEnum.SMALL,
|
|
70
|
+
IconButtonVariantEnum.CHIA
|
|
71
|
+
),
|
|
72
|
+
[IconButtonVariantEnum.OUTLINE]: makeVariantSet(
|
|
73
|
+
IconButtonSizeEnum.SMALL,
|
|
74
|
+
IconButtonVariantEnum.OUTLINE
|
|
75
|
+
),
|
|
76
|
+
[IconButtonVariantEnum.GHOST]: makeVariantSet(
|
|
77
|
+
IconButtonSizeEnum.SMALL,
|
|
78
|
+
IconButtonVariantEnum.GHOST
|
|
79
|
+
),
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
[IconButtonSizeEnum.MEDIUM]: {
|
|
83
|
+
title: "Medium Size",
|
|
84
|
+
buttons: {
|
|
85
|
+
[IconButtonVariantEnum.GRAPE]: makeVariantSet(
|
|
86
|
+
IconButtonSizeEnum.MEDIUM,
|
|
87
|
+
IconButtonVariantEnum.GRAPE
|
|
88
|
+
),
|
|
89
|
+
[IconButtonVariantEnum.JAVA]: makeVariantSet(
|
|
90
|
+
IconButtonSizeEnum.MEDIUM,
|
|
91
|
+
IconButtonVariantEnum.JAVA
|
|
92
|
+
),
|
|
93
|
+
[IconButtonVariantEnum.PEAR]: makeVariantSet(
|
|
94
|
+
IconButtonSizeEnum.MEDIUM,
|
|
95
|
+
IconButtonVariantEnum.PEAR
|
|
96
|
+
),
|
|
97
|
+
[IconButtonVariantEnum.TANGERINE]: makeVariantSet(
|
|
98
|
+
IconButtonSizeEnum.MEDIUM,
|
|
99
|
+
IconButtonVariantEnum.TANGERINE
|
|
100
|
+
),
|
|
101
|
+
[IconButtonVariantEnum.PITAYA]: makeVariantSet(
|
|
102
|
+
IconButtonSizeEnum.MEDIUM,
|
|
103
|
+
IconButtonVariantEnum.PITAYA
|
|
104
|
+
),
|
|
105
|
+
[IconButtonVariantEnum.BLACKBERRY]: makeVariantSet(
|
|
106
|
+
IconButtonSizeEnum.MEDIUM,
|
|
107
|
+
IconButtonVariantEnum.BLACKBERRY
|
|
108
|
+
),
|
|
109
|
+
[IconButtonVariantEnum.CHIA]: makeVariantSet(
|
|
110
|
+
IconButtonSizeEnum.MEDIUM,
|
|
111
|
+
IconButtonVariantEnum.CHIA
|
|
112
|
+
),
|
|
113
|
+
[IconButtonVariantEnum.OUTLINE]: makeVariantSet(
|
|
114
|
+
IconButtonSizeEnum.MEDIUM,
|
|
115
|
+
IconButtonVariantEnum.OUTLINE
|
|
116
|
+
),
|
|
117
|
+
[IconButtonVariantEnum.GHOST]: makeVariantSet(
|
|
118
|
+
IconButtonSizeEnum.MEDIUM,
|
|
119
|
+
IconButtonVariantEnum.GHOST
|
|
120
|
+
),
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
[IconButtonSizeEnum.LARGE]: {
|
|
124
|
+
title: "Large Size",
|
|
125
|
+
buttons: {
|
|
126
|
+
[IconButtonVariantEnum.GRAPE]: makeVariantSet(
|
|
127
|
+
IconButtonSizeEnum.LARGE,
|
|
128
|
+
IconButtonVariantEnum.GRAPE
|
|
129
|
+
),
|
|
130
|
+
[IconButtonVariantEnum.JAVA]: makeVariantSet(
|
|
131
|
+
IconButtonSizeEnum.LARGE,
|
|
132
|
+
IconButtonVariantEnum.JAVA
|
|
133
|
+
),
|
|
134
|
+
[IconButtonVariantEnum.PEAR]: makeVariantSet(
|
|
135
|
+
IconButtonSizeEnum.LARGE,
|
|
136
|
+
IconButtonVariantEnum.PEAR
|
|
137
|
+
),
|
|
138
|
+
[IconButtonVariantEnum.TANGERINE]: makeVariantSet(
|
|
139
|
+
IconButtonSizeEnum.LARGE,
|
|
140
|
+
IconButtonVariantEnum.TANGERINE
|
|
141
|
+
),
|
|
142
|
+
[IconButtonVariantEnum.PITAYA]: makeVariantSet(
|
|
143
|
+
IconButtonSizeEnum.LARGE,
|
|
144
|
+
IconButtonVariantEnum.PITAYA
|
|
145
|
+
),
|
|
146
|
+
[IconButtonVariantEnum.BLACKBERRY]: makeVariantSet(
|
|
147
|
+
IconButtonSizeEnum.LARGE,
|
|
148
|
+
IconButtonVariantEnum.BLACKBERRY
|
|
149
|
+
),
|
|
150
|
+
[IconButtonVariantEnum.CHIA]: makeVariantSet(
|
|
151
|
+
IconButtonSizeEnum.LARGE,
|
|
152
|
+
IconButtonVariantEnum.CHIA
|
|
153
|
+
),
|
|
154
|
+
[IconButtonVariantEnum.OUTLINE]: makeVariantSet(
|
|
155
|
+
IconButtonSizeEnum.LARGE,
|
|
156
|
+
IconButtonVariantEnum.OUTLINE
|
|
157
|
+
),
|
|
158
|
+
[IconButtonVariantEnum.GHOST]: makeVariantSet(
|
|
159
|
+
IconButtonSizeEnum.LARGE,
|
|
160
|
+
IconButtonVariantEnum.GHOST
|
|
161
|
+
),
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
[IconButtonSizeEnum.XLARGE]: {
|
|
165
|
+
title: "XLarge Size",
|
|
166
|
+
buttons: {
|
|
167
|
+
[IconButtonVariantEnum.GRAPE]: makeVariantSet(
|
|
168
|
+
IconButtonSizeEnum.XLARGE,
|
|
169
|
+
IconButtonVariantEnum.GRAPE
|
|
170
|
+
),
|
|
171
|
+
[IconButtonVariantEnum.JAVA]: makeVariantSet(
|
|
172
|
+
IconButtonSizeEnum.XLARGE,
|
|
173
|
+
IconButtonVariantEnum.JAVA
|
|
174
|
+
),
|
|
175
|
+
[IconButtonVariantEnum.PEAR]: makeVariantSet(
|
|
176
|
+
IconButtonSizeEnum.XLARGE,
|
|
177
|
+
IconButtonVariantEnum.PEAR
|
|
178
|
+
),
|
|
179
|
+
[IconButtonVariantEnum.TANGERINE]: makeVariantSet(
|
|
180
|
+
IconButtonSizeEnum.XLARGE,
|
|
181
|
+
IconButtonVariantEnum.TANGERINE
|
|
182
|
+
),
|
|
183
|
+
[IconButtonVariantEnum.PITAYA]: makeVariantSet(
|
|
184
|
+
IconButtonSizeEnum.XLARGE,
|
|
185
|
+
IconButtonVariantEnum.PITAYA
|
|
186
|
+
),
|
|
187
|
+
[IconButtonVariantEnum.BLACKBERRY]: makeVariantSet(
|
|
188
|
+
IconButtonSizeEnum.XLARGE,
|
|
189
|
+
IconButtonVariantEnum.BLACKBERRY
|
|
190
|
+
),
|
|
191
|
+
[IconButtonVariantEnum.CHIA]: makeVariantSet(
|
|
192
|
+
IconButtonSizeEnum.XLARGE,
|
|
193
|
+
IconButtonVariantEnum.CHIA
|
|
194
|
+
),
|
|
195
|
+
[IconButtonVariantEnum.OUTLINE]: makeVariantSet(
|
|
196
|
+
IconButtonSizeEnum.XLARGE,
|
|
197
|
+
IconButtonVariantEnum.OUTLINE
|
|
198
|
+
),
|
|
199
|
+
[IconButtonVariantEnum.GHOST]: makeVariantSet(
|
|
200
|
+
IconButtonSizeEnum.XLARGE,
|
|
201
|
+
IconButtonVariantEnum.GHOST
|
|
202
|
+
),
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
[IconButtonSizeEnum.XXLARGE]: {
|
|
206
|
+
title: "2x Large Size",
|
|
207
|
+
buttons: {
|
|
208
|
+
[IconButtonVariantEnum.GRAPE]: makeVariantSet(
|
|
209
|
+
IconButtonSizeEnum.XXLARGE,
|
|
210
|
+
IconButtonVariantEnum.GRAPE
|
|
211
|
+
),
|
|
212
|
+
[IconButtonVariantEnum.JAVA]: makeVariantSet(
|
|
213
|
+
IconButtonSizeEnum.XXLARGE,
|
|
214
|
+
IconButtonVariantEnum.JAVA
|
|
215
|
+
),
|
|
216
|
+
[IconButtonVariantEnum.PEAR]: makeVariantSet(
|
|
217
|
+
IconButtonSizeEnum.XXLARGE,
|
|
218
|
+
IconButtonVariantEnum.PEAR
|
|
219
|
+
),
|
|
220
|
+
[IconButtonVariantEnum.TANGERINE]: makeVariantSet(
|
|
221
|
+
IconButtonSizeEnum.XXLARGE,
|
|
222
|
+
IconButtonVariantEnum.TANGERINE
|
|
223
|
+
),
|
|
224
|
+
[IconButtonVariantEnum.PITAYA]: makeVariantSet(
|
|
225
|
+
IconButtonSizeEnum.XXLARGE,
|
|
226
|
+
IconButtonVariantEnum.PITAYA
|
|
227
|
+
),
|
|
228
|
+
[IconButtonVariantEnum.BLACKBERRY]: makeVariantSet(
|
|
229
|
+
IconButtonSizeEnum.XXLARGE,
|
|
230
|
+
IconButtonVariantEnum.BLACKBERRY
|
|
231
|
+
),
|
|
232
|
+
[IconButtonVariantEnum.CHIA]: makeVariantSet(
|
|
233
|
+
IconButtonSizeEnum.XXLARGE,
|
|
234
|
+
IconButtonVariantEnum.CHIA
|
|
235
|
+
),
|
|
236
|
+
[IconButtonVariantEnum.OUTLINE]: makeVariantSet(
|
|
237
|
+
IconButtonSizeEnum.XXLARGE,
|
|
238
|
+
IconButtonVariantEnum.OUTLINE
|
|
239
|
+
),
|
|
240
|
+
[IconButtonVariantEnum.GHOST]: makeVariantSet(
|
|
241
|
+
IconButtonSizeEnum.XXLARGE,
|
|
242
|
+
IconButtonVariantEnum.GHOST
|
|
243
|
+
),
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
} as const;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { CornersEnum, SizeEnum } from "../../enums";
|
|
2
|
+
|
|
3
|
+
export enum IconButtonVariantEnum {
|
|
4
|
+
GRAPE = "grape",
|
|
5
|
+
JAVA = "java",
|
|
6
|
+
PEAR = "pear",
|
|
7
|
+
TANGERINE = "tangerine",
|
|
8
|
+
PITAYA = "pitaya",
|
|
9
|
+
BLACKBERRY = "blackberry",
|
|
10
|
+
CHIA = "chia",
|
|
11
|
+
OUTLINE = "outline",
|
|
12
|
+
GHOST = "ghost",
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export enum IconButtonSizeEnum {
|
|
16
|
+
SMALL = SizeEnum.SMALL,
|
|
17
|
+
MEDIUM = SizeEnum.MEDIUM,
|
|
18
|
+
LARGE = SizeEnum.LARGE,
|
|
19
|
+
XLARGE = SizeEnum.XLARGE,
|
|
20
|
+
XXLARGE = SizeEnum.XXLARGE,
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export enum IconButtonCornersEnum {
|
|
24
|
+
SMALL = CornersEnum.SMALL,
|
|
25
|
+
MEDIUM = CornersEnum.MEDIUM,
|
|
26
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { Animated, GestureResponderEvent, Pressable, View } from "react-native";
|
|
2
|
+
import type { IconButtonProps } from "./types";
|
|
3
|
+
import {
|
|
4
|
+
buttonVariants,
|
|
5
|
+
} from "./assets/class-variants";
|
|
6
|
+
import { merge } from "@kivid/tailwind-preset";
|
|
7
|
+
import { useRef } from "react";
|
|
8
|
+
import { LoadingDotsVariant } from "../LoadingDots/types";
|
|
9
|
+
import LoadingDots from "../LoadingDots";
|
|
10
|
+
import { IconButtonCornersEnum, IconButtonSizeEnum, IconButtonVariantEnum } from "./enums";
|
|
11
|
+
|
|
12
|
+
export function IconButton(props: IconButtonProps) {
|
|
13
|
+
const {
|
|
14
|
+
icon,
|
|
15
|
+
loading = false,
|
|
16
|
+
variant = IconButtonVariantEnum.GRAPE,
|
|
17
|
+
size = IconButtonSizeEnum.SMALL,
|
|
18
|
+
corners = IconButtonCornersEnum.SMALL,
|
|
19
|
+
disabled = false,
|
|
20
|
+
className,
|
|
21
|
+
accessibilityLabel,
|
|
22
|
+
selected = false,
|
|
23
|
+
onPressIn,
|
|
24
|
+
onPressOut,
|
|
25
|
+
...rest
|
|
26
|
+
} = props;
|
|
27
|
+
|
|
28
|
+
const animatedValue = useRef(new Animated.Value(1)).current;
|
|
29
|
+
|
|
30
|
+
const loadingDotsVariantsMap: Record<IconButtonVariantEnum, LoadingDotsVariant> = {
|
|
31
|
+
[IconButtonVariantEnum.GRAPE]: "light",
|
|
32
|
+
[IconButtonVariantEnum.JAVA]: "light",
|
|
33
|
+
[IconButtonVariantEnum.PEAR]: "light",
|
|
34
|
+
[IconButtonVariantEnum.TANGERINE]: "light",
|
|
35
|
+
[IconButtonVariantEnum.PITAYA]: "light",
|
|
36
|
+
[IconButtonVariantEnum.BLACKBERRY]: "light",
|
|
37
|
+
[IconButtonVariantEnum.CHIA]: "light",
|
|
38
|
+
[IconButtonVariantEnum.OUTLINE]: "dark",
|
|
39
|
+
[IconButtonVariantEnum.GHOST]: "dark",
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const mappedLoadingStyleBySize: Record<IconButtonSizeEnum, number> = {
|
|
43
|
+
[IconButtonSizeEnum.SMALL]: 24,
|
|
44
|
+
[IconButtonSizeEnum.MEDIUM]: 24,
|
|
45
|
+
[IconButtonSizeEnum.LARGE]: 32,
|
|
46
|
+
[IconButtonSizeEnum.XLARGE]: 32,
|
|
47
|
+
[IconButtonSizeEnum.XXLARGE]: 32,
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const handlePressIn = (event: GestureResponderEvent) => {
|
|
51
|
+
Animated.timing(animatedValue, {
|
|
52
|
+
toValue: 0.7,
|
|
53
|
+
duration: 100,
|
|
54
|
+
useNativeDriver: true,
|
|
55
|
+
}).start();
|
|
56
|
+
|
|
57
|
+
onPressIn?.(event);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const handlePressOut = (event: GestureResponderEvent) => {
|
|
61
|
+
Animated.timing(animatedValue, {
|
|
62
|
+
toValue: 1,
|
|
63
|
+
duration: 100,
|
|
64
|
+
useNativeDriver: true,
|
|
65
|
+
}).start();
|
|
66
|
+
|
|
67
|
+
onPressOut?.(event);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
function renderContent() {
|
|
71
|
+
if (loading) {
|
|
72
|
+
return (
|
|
73
|
+
<LoadingDots
|
|
74
|
+
variant={loadingDotsVariantsMap[variant]}
|
|
75
|
+
lottieViewStyle={{
|
|
76
|
+
width: mappedLoadingStyleBySize[size],
|
|
77
|
+
height: mappedLoadingStyleBySize[size],
|
|
78
|
+
}}
|
|
79
|
+
/>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<>
|
|
85
|
+
{icon}
|
|
86
|
+
</>
|
|
87
|
+
)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<Animated.View
|
|
92
|
+
style={{
|
|
93
|
+
opacity: animatedValue,
|
|
94
|
+
}}
|
|
95
|
+
>
|
|
96
|
+
<Pressable
|
|
97
|
+
className={merge(
|
|
98
|
+
buttonVariants({
|
|
99
|
+
variant,
|
|
100
|
+
size,
|
|
101
|
+
corners,
|
|
102
|
+
selected,
|
|
103
|
+
}),
|
|
104
|
+
className
|
|
105
|
+
)}
|
|
106
|
+
disabled={disabled}
|
|
107
|
+
accessibilityRole="button"
|
|
108
|
+
accessibilityState={{
|
|
109
|
+
disabled: disabled,
|
|
110
|
+
selected: selected,
|
|
111
|
+
busy: loading,
|
|
112
|
+
}}
|
|
113
|
+
pointerEvents={loading || disabled ? "none" : "auto"}
|
|
114
|
+
onPressIn={handlePressIn}
|
|
115
|
+
onPressOut={handlePressOut}
|
|
116
|
+
{...rest}
|
|
117
|
+
>
|
|
118
|
+
<View className="flex items-center">
|
|
119
|
+
{renderContent()}
|
|
120
|
+
</View>
|
|
121
|
+
</Pressable>
|
|
122
|
+
</Animated.View>
|
|
123
|
+
);
|
|
124
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { VariantProps } from "class-variance-authority";
|
|
2
|
+
import type { buttonVariants } from "./assets/class-variants";
|
|
3
|
+
import { PressableProps } from "react-native";
|
|
4
|
+
import {
|
|
5
|
+
IconButtonCornersEnum,
|
|
6
|
+
IconButtonSizeEnum,
|
|
7
|
+
IconButtonVariantEnum,
|
|
8
|
+
} from "./enums";
|
|
9
|
+
|
|
10
|
+
export interface IconButtonProps
|
|
11
|
+
extends PressableProps,
|
|
12
|
+
VariantProps<typeof buttonVariants> {
|
|
13
|
+
selected?: boolean;
|
|
14
|
+
icon: React.ReactNode;
|
|
15
|
+
loading?: boolean;
|
|
16
|
+
variant?: IconButtonVariantEnum;
|
|
17
|
+
size?: IconButtonSizeEnum;
|
|
18
|
+
corners?: IconButtonCornersEnum;
|
|
19
|
+
className?: string;
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
accessibilityLabel: string;
|
|
22
|
+
}
|
|
@@ -4,7 +4,7 @@ import { SizeEnum, CornersEnum } from "../../../enums";
|
|
|
4
4
|
|
|
5
5
|
const buttonVariants = cva(
|
|
6
6
|
[
|
|
7
|
-
"flex flex-row items-center justify-
|
|
7
|
+
"flex flex-row items-center justify-between",
|
|
8
8
|
"font-bold",
|
|
9
9
|
"disabled:cursor-not-allowed",
|
|
10
10
|
"relative overflow-hidden",
|
|
@@ -75,13 +75,4 @@ const textVariants = cva("", {
|
|
|
75
75
|
},
|
|
76
76
|
});
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
variants: {
|
|
80
|
-
showChevronIcon: {
|
|
81
|
-
true: "flex-1",
|
|
82
|
-
false: "",
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
export { buttonVariants, textVariants, iconButtonVariants };
|
|
78
|
+
export { buttonVariants, textVariants };
|