catchup-library-web 1.0.0
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/README.md +70 -0
- package/dist/index.d.mts +55 -0
- package/dist/index.d.ts +55 -0
- package/dist/index.js +674 -0
- package/dist/index.mjs +641 -0
- package/package.json +24 -0
- package/src/components/buttons/ApproveButton.tsx +87 -0
- package/src/components/buttons/CancelButton.tsx +102 -0
- package/src/components/buttons/CreateButton.tsx +87 -0
- package/src/components/buttons/DeleteButton.tsx +95 -0
- package/src/components/buttons/PrimaryButton.tsx +88 -0
- package/src/components/buttons/SecondaryButton.tsx +94 -0
- package/src/components/images/BaseImage.tsx +93 -0
- package/src/components/loading/BaseLoading.tsx +50 -0
- package/src/index.ts +10 -0
- package/src/properties/ButtonProperties.ts +9 -0
- package/src/properties/CommonProperties.ts +4 -0
- package/src/properties/ImageProperties.ts +17 -0
- package/src/properties/LoadingProperties.ts +7 -0
- package/tsconfig.json +16 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import BaseImage from "../images/BaseImage";
|
|
3
|
+
import BaseLoading from "../loading/BaseLoading";
|
|
4
|
+
import { IButtonProps } from "../../properties/ButtonProperties";
|
|
5
|
+
|
|
6
|
+
const ApproveButton = ({
|
|
7
|
+
title,
|
|
8
|
+
size,
|
|
9
|
+
onClick,
|
|
10
|
+
disabled,
|
|
11
|
+
iconPosition,
|
|
12
|
+
textOnly,
|
|
13
|
+
iconOnly,
|
|
14
|
+
}: IButtonProps) => {
|
|
15
|
+
const [loading, setLoading] = useState(false);
|
|
16
|
+
|
|
17
|
+
const internalOnClick = async () => {
|
|
18
|
+
if (loading) return;
|
|
19
|
+
if (disabled) return;
|
|
20
|
+
setLoading(true);
|
|
21
|
+
await onClick();
|
|
22
|
+
setLoading(false);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
let currentWidthClassName;
|
|
26
|
+
let currentHeightClassName;
|
|
27
|
+
let currentLoadingSize;
|
|
28
|
+
if (size === "small") {
|
|
29
|
+
currentWidthClassName = "w-32";
|
|
30
|
+
currentHeightClassName = "h-8";
|
|
31
|
+
currentLoadingSize = 14;
|
|
32
|
+
} else if (size === "medium") {
|
|
33
|
+
currentWidthClassName = "w-32";
|
|
34
|
+
currentHeightClassName = "h-10";
|
|
35
|
+
currentLoadingSize = 16;
|
|
36
|
+
} else if (size === "large") {
|
|
37
|
+
currentWidthClassName = "w-32";
|
|
38
|
+
currentHeightClassName = "h-12";
|
|
39
|
+
currentLoadingSize = 18;
|
|
40
|
+
} else if (size === "unlimited") {
|
|
41
|
+
currentLoadingSize = 14;
|
|
42
|
+
currentHeightClassName = "h-8";
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<button
|
|
47
|
+
className={`border border-catchup-green bg-catchup-green text-catchup-white rounded-catchup-button ${
|
|
48
|
+
loading
|
|
49
|
+
? ""
|
|
50
|
+
: disabled
|
|
51
|
+
? "opacity-50"
|
|
52
|
+
: "hover:bg-catchup-hover-green active:bg-catchup-green"
|
|
53
|
+
} transition duration-300 ${currentWidthClassName} ${currentHeightClassName}`}
|
|
54
|
+
onClick={internalOnClick}
|
|
55
|
+
>
|
|
56
|
+
{loading ? (
|
|
57
|
+
<BaseLoading
|
|
58
|
+
height={currentLoadingSize}
|
|
59
|
+
width={currentLoadingSize}
|
|
60
|
+
primaryColor="#ffffff"
|
|
61
|
+
secondaryColor="#ffffff"
|
|
62
|
+
/>
|
|
63
|
+
) : (
|
|
64
|
+
<div className="flex flex-row justify-center items-center gap-x-2 px-4">
|
|
65
|
+
{iconPosition === "left" ? (
|
|
66
|
+
<BaseImage
|
|
67
|
+
src="/icons/primary-button-arrow-left.png"
|
|
68
|
+
alt="arrow-left"
|
|
69
|
+
size="xsmall"
|
|
70
|
+
/>
|
|
71
|
+
) : null}
|
|
72
|
+
{iconOnly ? null : <p className="">{title}</p>}
|
|
73
|
+
|
|
74
|
+
{textOnly || iconPosition === "left" ? null : (
|
|
75
|
+
<BaseImage
|
|
76
|
+
src="/icons/primary-button-arrow-right.png"
|
|
77
|
+
alt="arrow-right"
|
|
78
|
+
size="xsmall"
|
|
79
|
+
/>
|
|
80
|
+
)}
|
|
81
|
+
</div>
|
|
82
|
+
)}
|
|
83
|
+
</button>
|
|
84
|
+
);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export default ApproveButton;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import BaseImage from "../images/BaseImage";
|
|
3
|
+
import BaseLoading from "../loading/BaseLoading";
|
|
4
|
+
import { IButtonProps } from "../../properties/ButtonProperties";
|
|
5
|
+
|
|
6
|
+
const CancelButton = ({
|
|
7
|
+
title,
|
|
8
|
+
size,
|
|
9
|
+
onClick,
|
|
10
|
+
disabled,
|
|
11
|
+
iconPosition,
|
|
12
|
+
textOnly,
|
|
13
|
+
iconOnly,
|
|
14
|
+
}: IButtonProps) => {
|
|
15
|
+
const [loading, setLoading] = useState(false);
|
|
16
|
+
const [isHovered, setIsHovered] = useState(false);
|
|
17
|
+
|
|
18
|
+
const internalOnClick = async () => {
|
|
19
|
+
if (loading) return;
|
|
20
|
+
if (disabled) return;
|
|
21
|
+
setLoading(true);
|
|
22
|
+
await onClick();
|
|
23
|
+
setLoading(false);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
let currentWidthClassName;
|
|
27
|
+
let currentHeightClassName;
|
|
28
|
+
let currentLoadingSize;
|
|
29
|
+
if (size === "small") {
|
|
30
|
+
currentWidthClassName = "w-32";
|
|
31
|
+
currentHeightClassName = "h-8";
|
|
32
|
+
currentLoadingSize = 14;
|
|
33
|
+
} else if (size === "medium") {
|
|
34
|
+
currentWidthClassName = "w-32";
|
|
35
|
+
currentHeightClassName = "h-10";
|
|
36
|
+
currentLoadingSize = 16;
|
|
37
|
+
} else if (size === "large") {
|
|
38
|
+
currentWidthClassName = "w-32";
|
|
39
|
+
currentHeightClassName = "h-12";
|
|
40
|
+
currentLoadingSize = 18;
|
|
41
|
+
} else if (size === "unlimited") {
|
|
42
|
+
currentLoadingSize = 14;
|
|
43
|
+
currentHeightClassName = "h-8";
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<button
|
|
48
|
+
className={`border border-catchup-gray-400 bg-catchup-white text-catchup-gray-600 rounded-catchup-button ${
|
|
49
|
+
loading
|
|
50
|
+
? ""
|
|
51
|
+
: disabled
|
|
52
|
+
? "opacity-50"
|
|
53
|
+
: "hover:bg-catchup-gray-400 hover:text-catchup-white hover:border-catchup-gray-400 active:bg-catchup-gray-500 active:border-catchup-gray-500 active:text-catchup-white"
|
|
54
|
+
} transition duration-300 ${currentWidthClassName} ${currentHeightClassName}`}
|
|
55
|
+
onClick={internalOnClick}
|
|
56
|
+
onMouseEnter={() => {
|
|
57
|
+
setIsHovered(true);
|
|
58
|
+
}}
|
|
59
|
+
onMouseLeave={() => {
|
|
60
|
+
setIsHovered(false);
|
|
61
|
+
}}
|
|
62
|
+
>
|
|
63
|
+
{loading ? (
|
|
64
|
+
<BaseLoading
|
|
65
|
+
height={currentLoadingSize}
|
|
66
|
+
width={currentLoadingSize}
|
|
67
|
+
primaryColor="#55777f"
|
|
68
|
+
secondaryColor="#55777f"
|
|
69
|
+
/>
|
|
70
|
+
) : (
|
|
71
|
+
<div className="flex flex-row justify-center items-center gap-x-2">
|
|
72
|
+
{iconPosition === "left" ? (
|
|
73
|
+
<BaseImage
|
|
74
|
+
src={`${
|
|
75
|
+
isHovered
|
|
76
|
+
? "/icons/cancel-button-arrow-left-white.png"
|
|
77
|
+
: "/icons/cancel-button-arrow-left.png"
|
|
78
|
+
}`}
|
|
79
|
+
alt="arrow-left"
|
|
80
|
+
size="xsmall"
|
|
81
|
+
/>
|
|
82
|
+
) : null}
|
|
83
|
+
{iconOnly ? null : <p className="">{title}</p>}
|
|
84
|
+
|
|
85
|
+
{textOnly || iconPosition === "left" ? null : (
|
|
86
|
+
<BaseImage
|
|
87
|
+
src={`${
|
|
88
|
+
isHovered
|
|
89
|
+
? "/icons/cancel-button-arrow-left-white.png"
|
|
90
|
+
: "/icons/cancel-button-arrow-left.png"
|
|
91
|
+
}`}
|
|
92
|
+
alt="arrow-left"
|
|
93
|
+
size="xsmall"
|
|
94
|
+
/>
|
|
95
|
+
)}
|
|
96
|
+
</div>
|
|
97
|
+
)}
|
|
98
|
+
</button>
|
|
99
|
+
);
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export default CancelButton;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import BaseImage from "../images/BaseImage";
|
|
3
|
+
import BaseLoading from "../loading/BaseLoading";
|
|
4
|
+
import { IButtonProps } from "../../properties/ButtonProperties";
|
|
5
|
+
|
|
6
|
+
const CreateButton = ({
|
|
7
|
+
title,
|
|
8
|
+
size,
|
|
9
|
+
onClick,
|
|
10
|
+
disabled,
|
|
11
|
+
iconPosition,
|
|
12
|
+
textOnly,
|
|
13
|
+
iconOnly,
|
|
14
|
+
}: IButtonProps) => {
|
|
15
|
+
const [loading, setLoading] = useState(false);
|
|
16
|
+
|
|
17
|
+
const internalOnClick = async () => {
|
|
18
|
+
if (loading) return;
|
|
19
|
+
if (disabled) return;
|
|
20
|
+
setLoading(true);
|
|
21
|
+
await onClick();
|
|
22
|
+
setLoading(false);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
let currentWidthClassName;
|
|
26
|
+
let currentHeightClassName;
|
|
27
|
+
let currentLoadingSize;
|
|
28
|
+
if (size === "small") {
|
|
29
|
+
currentWidthClassName = "w-32";
|
|
30
|
+
currentHeightClassName = "h-8";
|
|
31
|
+
currentLoadingSize = 14;
|
|
32
|
+
} else if (size === "medium") {
|
|
33
|
+
currentWidthClassName = "w-32";
|
|
34
|
+
currentHeightClassName = "h-10";
|
|
35
|
+
currentLoadingSize = 16;
|
|
36
|
+
} else if (size === "large") {
|
|
37
|
+
currentWidthClassName = "w-32";
|
|
38
|
+
currentHeightClassName = "h-12";
|
|
39
|
+
currentLoadingSize = 18;
|
|
40
|
+
} else if (size === "unlimited") {
|
|
41
|
+
currentLoadingSize = 14;
|
|
42
|
+
currentHeightClassName = "h-8";
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<button
|
|
47
|
+
className={`border border-catchup-blue-500 bg-catchup-blue-500 text-catchup-white rounded-catchup-button ${
|
|
48
|
+
loading
|
|
49
|
+
? ""
|
|
50
|
+
: disabled
|
|
51
|
+
? "opacity-50"
|
|
52
|
+
: "hover:bg-catchup-blue-700 active:bg-catchup-blue-500"
|
|
53
|
+
} transition duration-300 ${currentWidthClassName} ${currentHeightClassName}`}
|
|
54
|
+
onClick={internalOnClick}
|
|
55
|
+
>
|
|
56
|
+
{loading ? (
|
|
57
|
+
<BaseLoading
|
|
58
|
+
height={currentLoadingSize}
|
|
59
|
+
width={currentLoadingSize}
|
|
60
|
+
primaryColor="#ffffff"
|
|
61
|
+
secondaryColor="#ffffff"
|
|
62
|
+
/>
|
|
63
|
+
) : (
|
|
64
|
+
<div className="flex flex-row justify-center items-center gap-x-2 px-4">
|
|
65
|
+
{iconPosition === "left" ? (
|
|
66
|
+
<BaseImage
|
|
67
|
+
src="/icons/primary-button-create-white.png"
|
|
68
|
+
alt="create"
|
|
69
|
+
size="xsmall"
|
|
70
|
+
/>
|
|
71
|
+
) : null}
|
|
72
|
+
|
|
73
|
+
{iconOnly ? null : <p className="">{title}</p>}
|
|
74
|
+
{textOnly || iconPosition === "left" ? null : (
|
|
75
|
+
<BaseImage
|
|
76
|
+
src="/icons/primary-button-create-white.png"
|
|
77
|
+
alt="create"
|
|
78
|
+
size="xsmall"
|
|
79
|
+
/>
|
|
80
|
+
)}
|
|
81
|
+
</div>
|
|
82
|
+
)}
|
|
83
|
+
</button>
|
|
84
|
+
);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export default CreateButton;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import BaseImage from "../images/BaseImage";
|
|
3
|
+
import BaseLoading from "../loading/BaseLoading";
|
|
4
|
+
import { IButtonProps } from "../../properties/ButtonProperties";
|
|
5
|
+
|
|
6
|
+
const DeleteButton = ({
|
|
7
|
+
title,
|
|
8
|
+
size,
|
|
9
|
+
onClick,
|
|
10
|
+
disabled,
|
|
11
|
+
iconPosition,
|
|
12
|
+
textOnly,
|
|
13
|
+
iconOnly,
|
|
14
|
+
}: IButtonProps) => {
|
|
15
|
+
const [loading, setLoading] = useState(false);
|
|
16
|
+
const [isHovered, setIsHovered] = useState(false);
|
|
17
|
+
|
|
18
|
+
const internalOnClick = async () => {
|
|
19
|
+
if (loading) return;
|
|
20
|
+
if (disabled) return;
|
|
21
|
+
setLoading(true);
|
|
22
|
+
await onClick();
|
|
23
|
+
setLoading(false);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
let currentWidthClassName;
|
|
27
|
+
let currentHeightClassName;
|
|
28
|
+
let currentLoadingSize;
|
|
29
|
+
if (size === "small") {
|
|
30
|
+
currentWidthClassName = "w-32";
|
|
31
|
+
currentHeightClassName = "h-8";
|
|
32
|
+
currentLoadingSize = 14;
|
|
33
|
+
} else if (size === "medium") {
|
|
34
|
+
currentWidthClassName = "w-32";
|
|
35
|
+
currentHeightClassName = "h-10";
|
|
36
|
+
currentLoadingSize = 16;
|
|
37
|
+
} else if (size === "large") {
|
|
38
|
+
currentWidthClassName = "w-32";
|
|
39
|
+
currentHeightClassName = "h-12";
|
|
40
|
+
currentLoadingSize = 18;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<button
|
|
45
|
+
className={`border border-catchup-red bg-catchup-white text-catchup-red rounded-catchup-button ${
|
|
46
|
+
loading
|
|
47
|
+
? ""
|
|
48
|
+
: disabled
|
|
49
|
+
? "opacity-50"
|
|
50
|
+
: "hover:bg-catchup-red hover:text-catchup-white hover:border-catchup-red active:bg-catchup-red active:hover:border-catchup-red active:text-catchup-white active:opacity-80"
|
|
51
|
+
} transition duration-300 ${currentWidthClassName} ${currentHeightClassName}`}
|
|
52
|
+
onClick={internalOnClick}
|
|
53
|
+
onMouseEnter={() => {
|
|
54
|
+
setIsHovered(true);
|
|
55
|
+
}}
|
|
56
|
+
onMouseLeave={() => {
|
|
57
|
+
setIsHovered(false);
|
|
58
|
+
}}
|
|
59
|
+
>
|
|
60
|
+
{loading ? (
|
|
61
|
+
<BaseLoading
|
|
62
|
+
height={currentLoadingSize}
|
|
63
|
+
width={currentLoadingSize}
|
|
64
|
+
primaryColor="#55777f"
|
|
65
|
+
secondaryColor="#55777f"
|
|
66
|
+
/>
|
|
67
|
+
) : (
|
|
68
|
+
<div className="flex flex-row justify-center items-center gap-x-2">
|
|
69
|
+
{iconPosition === "left" ? (
|
|
70
|
+
<BaseImage
|
|
71
|
+
src={`${
|
|
72
|
+
isHovered ? "/icons/remove-white.png" : "/icons/remove-red.png"
|
|
73
|
+
}`}
|
|
74
|
+
alt="remove-white"
|
|
75
|
+
size="xsmall"
|
|
76
|
+
/>
|
|
77
|
+
) : null}
|
|
78
|
+
{iconOnly ? null : <p className="">{title}</p>}
|
|
79
|
+
|
|
80
|
+
{textOnly || iconPosition === "left" ? null : (
|
|
81
|
+
<BaseImage
|
|
82
|
+
src={`${
|
|
83
|
+
isHovered ? "/icons/remove-white.png" : "/icons/remove-red.png"
|
|
84
|
+
}`}
|
|
85
|
+
alt="remove-white"
|
|
86
|
+
size="xsmall"
|
|
87
|
+
/>
|
|
88
|
+
)}
|
|
89
|
+
</div>
|
|
90
|
+
)}
|
|
91
|
+
</button>
|
|
92
|
+
);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export default DeleteButton;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import BaseImage from "../images/BaseImage";
|
|
3
|
+
import BaseLoading from "../loading/BaseLoading";
|
|
4
|
+
import { IButtonProps } from "../../properties/ButtonProperties";
|
|
5
|
+
|
|
6
|
+
const PrimaryButton = ({
|
|
7
|
+
title,
|
|
8
|
+
size,
|
|
9
|
+
onClick,
|
|
10
|
+
disabled,
|
|
11
|
+
iconPosition,
|
|
12
|
+
textOnly,
|
|
13
|
+
iconOnly,
|
|
14
|
+
}: IButtonProps) => {
|
|
15
|
+
const [loading, setLoading] = useState(false);
|
|
16
|
+
|
|
17
|
+
const internalOnClick = async () => {
|
|
18
|
+
if (loading) return;
|
|
19
|
+
if (disabled) return;
|
|
20
|
+
setLoading(true);
|
|
21
|
+
await onClick();
|
|
22
|
+
setLoading(false);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
let currentWidthClassName;
|
|
26
|
+
let currentHeightClassName;
|
|
27
|
+
let currentLoadingSize;
|
|
28
|
+
if (size === "small") {
|
|
29
|
+
currentWidthClassName = "w-32";
|
|
30
|
+
currentHeightClassName = "h-8";
|
|
31
|
+
currentLoadingSize = 14;
|
|
32
|
+
} else if (size === "medium") {
|
|
33
|
+
currentWidthClassName = "w-32";
|
|
34
|
+
currentHeightClassName = "h-10";
|
|
35
|
+
currentLoadingSize = 16;
|
|
36
|
+
} else if (size === "large") {
|
|
37
|
+
currentWidthClassName = "w-32";
|
|
38
|
+
currentHeightClassName = "h-12";
|
|
39
|
+
currentLoadingSize = 18;
|
|
40
|
+
} else if (size === "unlimited") {
|
|
41
|
+
currentLoadingSize = 14;
|
|
42
|
+
currentHeightClassName = "h-8";
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<button
|
|
47
|
+
className={`border border-catchup-blue-500 bg-catchup-blue-500 text-catchup-white rounded-catchup-button ${
|
|
48
|
+
loading
|
|
49
|
+
? ""
|
|
50
|
+
: disabled
|
|
51
|
+
? "opacity-50"
|
|
52
|
+
: "hover:bg-catchup-blue-700 active:bg-catchup-blue-500"
|
|
53
|
+
} transition duration-300 ${currentWidthClassName} ${currentHeightClassName}`}
|
|
54
|
+
onClick={internalOnClick}
|
|
55
|
+
>
|
|
56
|
+
{loading ? (
|
|
57
|
+
<BaseLoading
|
|
58
|
+
height={currentLoadingSize}
|
|
59
|
+
width={currentLoadingSize}
|
|
60
|
+
primaryColor="#ffffff"
|
|
61
|
+
secondaryColor="#ffffff"
|
|
62
|
+
/>
|
|
63
|
+
) : (
|
|
64
|
+
<div className="flex flex-row justify-center items-center gap-x-2 px-4">
|
|
65
|
+
{iconPosition === "left" ? (
|
|
66
|
+
<BaseImage
|
|
67
|
+
src="/icons/new/primary-button-arrow-left.png"
|
|
68
|
+
alt="arrow-left"
|
|
69
|
+
size="xsmall"
|
|
70
|
+
/>
|
|
71
|
+
) : null}
|
|
72
|
+
|
|
73
|
+
{iconOnly ? null : <p className="">{title}</p>}
|
|
74
|
+
|
|
75
|
+
{textOnly || iconPosition === "left" ? null : (
|
|
76
|
+
<BaseImage
|
|
77
|
+
src="/icons/primary-button-arrow-right.png"
|
|
78
|
+
alt="arrow-right"
|
|
79
|
+
size="xsmall"
|
|
80
|
+
/>
|
|
81
|
+
)}
|
|
82
|
+
</div>
|
|
83
|
+
)}
|
|
84
|
+
</button>
|
|
85
|
+
);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export default PrimaryButton;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import BaseImage from "../images/BaseImage";
|
|
3
|
+
import BaseLoading from "../loading/BaseLoading";
|
|
4
|
+
import { IButtonProps } from "../../properties/ButtonProperties";
|
|
5
|
+
|
|
6
|
+
const SecondaryButton = ({
|
|
7
|
+
title,
|
|
8
|
+
size,
|
|
9
|
+
onClick,
|
|
10
|
+
disabled,
|
|
11
|
+
iconPosition,
|
|
12
|
+
textOnly,
|
|
13
|
+
iconOnly,
|
|
14
|
+
}: IButtonProps) => {
|
|
15
|
+
const [loading, setLoading] = useState(false);
|
|
16
|
+
const [isHovered, setIsHovered] = useState(false);
|
|
17
|
+
|
|
18
|
+
const internalOnClick = async () => {
|
|
19
|
+
if (loading) return;
|
|
20
|
+
if (disabled) return;
|
|
21
|
+
setLoading(true);
|
|
22
|
+
await onClick();
|
|
23
|
+
setLoading(false);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
let currentWidthClassName;
|
|
27
|
+
let currentHeightClassName;
|
|
28
|
+
let currentLoadingSize;
|
|
29
|
+
if (size === "small") {
|
|
30
|
+
currentWidthClassName = "w-32";
|
|
31
|
+
currentHeightClassName = "h-8";
|
|
32
|
+
currentLoadingSize = 14;
|
|
33
|
+
} else if (size === "medium") {
|
|
34
|
+
currentWidthClassName = "w-32";
|
|
35
|
+
currentHeightClassName = "h-10";
|
|
36
|
+
currentLoadingSize = 16;
|
|
37
|
+
} else if (size === "large") {
|
|
38
|
+
currentWidthClassName = "w-32";
|
|
39
|
+
currentHeightClassName = "h-12";
|
|
40
|
+
currentLoadingSize = 18;
|
|
41
|
+
} else if (size === "unlimited") {
|
|
42
|
+
currentLoadingSize = 14;
|
|
43
|
+
currentHeightClassName = "h-8";
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<button
|
|
48
|
+
className={`border border-catchup-gray-400 bg-catchup-white text-catchup-gray-600 rounded-catchup-button ${
|
|
49
|
+
loading
|
|
50
|
+
? ""
|
|
51
|
+
: disabled
|
|
52
|
+
? "opacity-50"
|
|
53
|
+
: "hover:bg-catchup-gray-400 hover:text-catchup-white hover:border-catchup-gray-400 active:bg-catchup-gray-500 active:border-catchup-gray-500 active:text-catchup-white"
|
|
54
|
+
} transition duration-300 ${currentWidthClassName} ${currentHeightClassName}`}
|
|
55
|
+
onClick={internalOnClick}
|
|
56
|
+
onMouseEnter={() => {
|
|
57
|
+
setIsHovered(true);
|
|
58
|
+
}}
|
|
59
|
+
onMouseLeave={() => {
|
|
60
|
+
setIsHovered(false);
|
|
61
|
+
}}
|
|
62
|
+
>
|
|
63
|
+
{loading ? (
|
|
64
|
+
<BaseLoading
|
|
65
|
+
height={currentLoadingSize}
|
|
66
|
+
width={currentLoadingSize}
|
|
67
|
+
primaryColor="#55777f"
|
|
68
|
+
secondaryColor="#55777f"
|
|
69
|
+
/>
|
|
70
|
+
) : (
|
|
71
|
+
<div className="flex flex-row justify-center items-center gap-x-2 px-4">
|
|
72
|
+
{iconPosition === "left" ? (
|
|
73
|
+
<BaseImage
|
|
74
|
+
src="/icons/new/secondary-button-arrow-left.png"
|
|
75
|
+
alt="arrow-left"
|
|
76
|
+
size="xsmall"
|
|
77
|
+
/>
|
|
78
|
+
) : null}
|
|
79
|
+
{iconOnly ? null : <p className="">{title}</p>}
|
|
80
|
+
|
|
81
|
+
{textOnly || iconPosition === "left" ? null : (
|
|
82
|
+
<BaseImage
|
|
83
|
+
src="/icons/secondary-button-arrow-right.png"
|
|
84
|
+
alt="arrow-right"
|
|
85
|
+
size="xsmall"
|
|
86
|
+
/>
|
|
87
|
+
)}
|
|
88
|
+
</div>
|
|
89
|
+
)}
|
|
90
|
+
</button>
|
|
91
|
+
);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export default SecondaryButton;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import BaseLoading from "../loading/BaseLoading";
|
|
3
|
+
import { IBaseImageProps } from "../../properties/ImageProperties";
|
|
4
|
+
|
|
5
|
+
const BaseImage = (props: IBaseImageProps) => {
|
|
6
|
+
const {
|
|
7
|
+
ref,
|
|
8
|
+
size,
|
|
9
|
+
className,
|
|
10
|
+
widthClassName,
|
|
11
|
+
heightClassName,
|
|
12
|
+
src,
|
|
13
|
+
alt,
|
|
14
|
+
showLoading,
|
|
15
|
+
onLoad,
|
|
16
|
+
onClick,
|
|
17
|
+
dataToolTipId,
|
|
18
|
+
dataToolTipContent,
|
|
19
|
+
dataToolTipPlace,
|
|
20
|
+
dataToolTipVariant,
|
|
21
|
+
dataToolTipHTML,
|
|
22
|
+
} = props;
|
|
23
|
+
const [loading, setLoading] = useState(false);
|
|
24
|
+
|
|
25
|
+
const handleOnClick = (e: any) => {
|
|
26
|
+
e.preventDefault();
|
|
27
|
+
if (showLoading) {
|
|
28
|
+
setLoading(true);
|
|
29
|
+
onClick && onClick(e);
|
|
30
|
+
setLoading(false);
|
|
31
|
+
} else {
|
|
32
|
+
onClick && onClick(e);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
if (!src) return null;
|
|
37
|
+
|
|
38
|
+
let currentClassName;
|
|
39
|
+
let currentWidthClassName;
|
|
40
|
+
let currentHeightClassName;
|
|
41
|
+
if (size === "xsmall") {
|
|
42
|
+
currentWidthClassName = "w-4";
|
|
43
|
+
currentHeightClassName = "h-4";
|
|
44
|
+
} else if (size === "small") {
|
|
45
|
+
currentWidthClassName = "w-6";
|
|
46
|
+
currentHeightClassName = "h-6";
|
|
47
|
+
} else if (size === "medium") {
|
|
48
|
+
currentWidthClassName = "w-8";
|
|
49
|
+
currentHeightClassName = "h-8";
|
|
50
|
+
} else if (size === "large") {
|
|
51
|
+
currentWidthClassName = "w-10";
|
|
52
|
+
currentHeightClassName = "h-10";
|
|
53
|
+
} else if (size === "xlarge") {
|
|
54
|
+
currentWidthClassName = "w-12";
|
|
55
|
+
currentHeightClassName = "h-12";
|
|
56
|
+
} else if (size === "2xlarge") {
|
|
57
|
+
currentWidthClassName = "w-14";
|
|
58
|
+
currentHeightClassName = "h-14";
|
|
59
|
+
} else if (size === "3xlarge") {
|
|
60
|
+
currentWidthClassName = "w-16";
|
|
61
|
+
currentHeightClassName = "h-16";
|
|
62
|
+
} else if (size === "custom") {
|
|
63
|
+
currentClassName = className;
|
|
64
|
+
currentWidthClassName = widthClassName;
|
|
65
|
+
currentHeightClassName = heightClassName;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return loading ? (
|
|
69
|
+
<BaseLoading size="small" primaryColor="#57C2D3" secondaryColor="#57C2D3" />
|
|
70
|
+
) : (
|
|
71
|
+
<div
|
|
72
|
+
className={`${currentWidthClassName ? currentWidthClassName : ""} ${
|
|
73
|
+
currentHeightClassName ? currentHeightClassName : ""
|
|
74
|
+
} ${currentClassName ? currentClassName : ""} cursor-pointer`}
|
|
75
|
+
onClick={handleOnClick}
|
|
76
|
+
>
|
|
77
|
+
<img
|
|
78
|
+
ref={ref}
|
|
79
|
+
className="w-full"
|
|
80
|
+
src={src}
|
|
81
|
+
alt={alt}
|
|
82
|
+
onLoad={onLoad}
|
|
83
|
+
data-tooltip-id={dataToolTipId}
|
|
84
|
+
data-tooltip-content={dataToolTipContent}
|
|
85
|
+
data-tooltip-place={dataToolTipPlace}
|
|
86
|
+
data-tooltip-variant={dataToolTipVariant}
|
|
87
|
+
data-tooltip-html={dataToolTipHTML}
|
|
88
|
+
/>
|
|
89
|
+
</div>
|
|
90
|
+
);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export default BaseImage;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Oval } from "react-loader-spinner";
|
|
2
|
+
import { IBaseLoadingProps } from "../../properties/LoadingProperties";
|
|
3
|
+
|
|
4
|
+
const BaseLoading = ({
|
|
5
|
+
height,
|
|
6
|
+
width,
|
|
7
|
+
size,
|
|
8
|
+
primaryColor,
|
|
9
|
+
secondaryColor,
|
|
10
|
+
}: IBaseLoadingProps) => {
|
|
11
|
+
let currentHeight;
|
|
12
|
+
let currentWidth;
|
|
13
|
+
|
|
14
|
+
if (size === "small") {
|
|
15
|
+
currentHeight = 18;
|
|
16
|
+
currentWidth = 18;
|
|
17
|
+
} else if (size === "medium") {
|
|
18
|
+
currentHeight = 48;
|
|
19
|
+
currentWidth = 48;
|
|
20
|
+
} else if (size === "large") {
|
|
21
|
+
currentHeight = 72;
|
|
22
|
+
currentWidth = 72;
|
|
23
|
+
} else if (size === "xlarge") {
|
|
24
|
+
currentHeight = 96;
|
|
25
|
+
currentWidth = 96;
|
|
26
|
+
} else {
|
|
27
|
+
currentHeight = height;
|
|
28
|
+
currentWidth = width;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// px-4 py-2
|
|
32
|
+
return (
|
|
33
|
+
<div className="flex justify-center items-center">
|
|
34
|
+
<Oval
|
|
35
|
+
height={currentHeight}
|
|
36
|
+
width={currentWidth}
|
|
37
|
+
wrapperStyle={{}}
|
|
38
|
+
wrapperClass=""
|
|
39
|
+
visible={true}
|
|
40
|
+
ariaLabel="oval-loading"
|
|
41
|
+
color={primaryColor}
|
|
42
|
+
secondaryColor={secondaryColor}
|
|
43
|
+
strokeWidth={2}
|
|
44
|
+
strokeWidthSecondary={2}
|
|
45
|
+
/>
|
|
46
|
+
</div>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default BaseLoading;
|