@sikka/hawa 0.0.2 → 0.0.5
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/.github/workflows/hawa-publish-push.yml +45 -0
- package/.github/workflows/hawa-publish.yml +45 -0
- package/.prettierrc +28 -28
- package/README.md +149 -148
- package/es/index.es.js +1 -0
- package/lib/index.js +1 -0
- package/package.json +62 -47
- package/rollup.config.js +30 -30
- package/src/Assets/images/card-background/1.jpeg +0 -0
- package/src/Assets/images/card-background/10.jpeg +0 -0
- package/src/Assets/images/card-background/11.jpeg +0 -0
- package/src/Assets/images/card-background/12.jpeg +0 -0
- package/src/Assets/images/card-background/13.jpeg +0 -0
- package/src/Assets/images/card-background/14.jpeg +0 -0
- package/src/Assets/images/card-background/15.jpeg +0 -0
- package/src/Assets/images/card-background/16.jpeg +0 -0
- package/src/Assets/images/card-background/17.jpeg +0 -0
- package/src/Assets/images/card-background/18.jpeg +0 -0
- package/src/Assets/images/card-background/19.jpeg +0 -0
- package/src/Assets/images/card-background/2.jpeg +0 -0
- package/src/Assets/images/card-background/20.jpeg +0 -0
- package/src/Assets/images/card-background/21.jpeg +0 -0
- package/src/Assets/images/card-background/22.jpeg +0 -0
- package/src/Assets/images/card-background/23.jpeg +0 -0
- package/src/Assets/images/card-background/24.jpeg +0 -0
- package/src/Assets/images/card-background/25.jpeg +0 -0
- package/src/Assets/images/card-background/3.jpeg +0 -0
- package/src/Assets/images/card-background/4.jpeg +0 -0
- package/src/Assets/images/card-background/5.jpeg +0 -0
- package/src/Assets/images/card-background/6.jpeg +0 -0
- package/src/Assets/images/card-background/7.jpeg +0 -0
- package/src/Assets/images/card-background/8.jpeg +0 -0
- package/src/Assets/images/card-background/9.jpeg +0 -0
- package/src/Assets/images/card-type/amex.png +0 -0
- package/src/Assets/images/card-type/diners.png +0 -0
- package/src/Assets/images/card-type/discover.png +0 -0
- package/src/Assets/images/card-type/mastercard.png +0 -0
- package/src/Assets/images/card-type/troy.png +0 -0
- package/src/Assets/images/card-type/unionpay.png +0 -0
- package/src/Assets/images/card-type/visa.png +0 -0
- package/src/blocks/Account/UserProfile.js +15 -0
- package/src/blocks/Account/UserSettings.js +15 -0
- package/src/blocks/Account/index.js +2 -0
- package/src/blocks/AuthForms/NewPasswordForm.js +24 -0
- package/src/blocks/AuthForms/ResetPasswordForm.js +13 -0
- package/src/blocks/AuthForms/SignInForm.js +55 -0
- package/src/blocks/AuthForms/SignUpForm.js +68 -0
- package/src/{components/Hawa → blocks}/AuthForms/index.js +4 -4
- package/src/blocks/Payment/CreditCardForm.js +31 -0
- package/src/blocks/Payment/Form/CForm.js +328 -0
- package/src/blocks/Payment/Form/Card.js +242 -0
- package/src/blocks/Payment/Gateway/GooglePay.js +251 -0
- package/src/blocks/Payment/Gateway/Payfort.js +90 -0
- package/src/blocks/Payment/Gateway/Paypal.js +138 -0
- package/src/blocks/Payment/Gateway/Wallet.js +149 -0
- package/src/blocks/Payment/PaymentMethod.js +132 -0
- package/src/blocks/Payment/SelectPayment.js +95 -0
- package/src/blocks/Payment/index.js +16 -0
- package/src/index.js +4 -1
- package/src/layout/Box.js +39 -0
- package/src/layout/index.js +1 -0
- package/src/stories/ActionButton.stories.js +53 -0
- package/src/stories/AdaptiveButton.stories.js +80 -80
- package/src/stories/Alert.stories.js +41 -48
- package/src/stories/BlocksStories/AuthForm.stories.js +99 -0
- package/src/stories/BlocksStories/PaymentForm.stories.js +111 -0
- package/src/stories/BlocksStories/UserAccount.stories.js +46 -0
- package/src/stories/CheckBox.stories.js +35 -34
- package/src/stories/GlobalVariables.stories.js +44 -108
- package/src/stories/HawaProvider.stories.js +22 -23
- package/src/stories/InputLabel.stories.js +92 -100
- package/src/stories/Introduction.stories.js +211 -0
- package/src/stories/LayoutStories/Box.stories.js +56 -0
- package/src/stories/RadioSelector.stories.js +69 -69
- package/src/stories/TextField.stories.js +50 -50
- package/src/styles.css +400 -400
- package/src/styles.scss +679 -0
- package/src/themes/HawaProvider.js +87 -0
- package/src/ui/ActionButton.js +40 -0
- package/src/{components/Hawa/AdaptiveButton → ui}/AdaptiveButton.js +252 -254
- package/src/ui/ApplePayButton.js +94 -0
- package/src/{components/Hawa/AutoCompleteField/AutoCompleteField.jsx → ui/AutoCompleteField.js} +32 -33
- package/src/{components/Hawa/Checkbox/Checkbox.jsx → ui/Checkbox.js} +21 -20
- package/src/{components/Hawa/DragDropImages/DragDropImages.jsx → ui/DragDropImages.js} +180 -180
- package/src/ui/GithubButton.js +91 -0
- package/src/ui/GoogleButton.js +83 -0
- package/src/ui/GooglePayButton.js +94 -0
- package/src/{components/Hawa/Hawa.jsx → ui/Hawa.js} +3 -3
- package/src/ui/HawaInputLabel.js +33 -0
- package/src/{components/Hawa/TextArea/TextArea.jsx → ui/HawaTextArea.js} +38 -38
- package/src/ui/HawaTextField.js +118 -0
- package/src/ui/MadaButton.js +94 -0
- package/src/ui/PayPalButton.js +94 -0
- package/src/{components/Hawa/RadioBox/RadioBox.jsx → ui/RadioBox.js} +29 -29
- package/src/{components/Hawa/RadioSelector/RadioSelector.jsx → ui/RadioSelector.js} +51 -51
- package/src/{components/Hawa/Row/Row.jsx → ui/Row.js} +21 -21
- package/src/ui/STCPayButton.js +94 -0
- package/src/{components/Hawa/SelectedField/SelectedField.jsx → ui/SelectedField.js} +46 -46
- package/src/ui/StyledAlert.js +30 -0
- package/src/{components/Hawa/StyledTooltip → ui}/StyledTooltip.js +46 -46
- package/src/{components/Hawa/TabPanel/TabPanel.jsx → ui/TabPanel.js} +37 -37
- package/src/ui/TwitterButton.js +84 -0
- package/src/ui/VisaMasterButton.js +94 -0
- package/src/ui/WalletButton.js +91 -0
- package/src/ui/index.js +22 -0
- package/src/util.js +20 -20
- package/storybook-static/0.54f7e52e.iframe.bundle.js +1 -0
- package/storybook-static/0.f47eb24a4893a96ec307.manager.bundle.js +1 -0
- package/storybook-static/1.95be85dd.iframe.bundle.js +3 -0
- package/storybook-static/{1.7c0dc86d.iframe.bundle.js.LICENSE.txt → 1.95be85dd.iframe.bundle.js.LICENSE.txt} +0 -0
- package/storybook-static/1.95be85dd.iframe.bundle.js.map +1 -0
- package/storybook-static/2.eb601582.iframe.bundle.js +1 -0
- package/storybook-static/{3.592ce28f.iframe.bundle.js → 3.d72f7fac.iframe.bundle.js} +0 -0
- package/storybook-static/4.0fcda1281dc1961dbe94.manager.bundle.js +2 -0
- package/storybook-static/{5.f459d151315e6780c20f.manager.bundle.js.LICENSE.txt → 4.0fcda1281dc1961dbe94.manager.bundle.js.LICENSE.txt} +0 -0
- package/storybook-static/5.63ab4f94d50a3acf080d.manager.bundle.js +1 -0
- package/storybook-static/6.a6d45262f7e98f3f18d3.manager.bundle.js +2 -0
- package/storybook-static/{11.f4e922583ae35da460f3.manager.bundle.js.LICENSE.txt → 6.a6d45262f7e98f3f18d3.manager.bundle.js.LICENSE.txt} +0 -0
- package/storybook-static/{7.3d04765dbf3f1dcd706c.manager.bundle.js → 7.097710753af9a1c41b80.manager.bundle.js} +1 -1
- package/storybook-static/7.ffb0d84b.iframe.bundle.js +1 -0
- package/storybook-static/{8.8e2132ec.iframe.bundle.js → 8.68cd1217.iframe.bundle.js} +2 -2
- package/storybook-static/{8.8e2132ec.iframe.bundle.js.LICENSE.txt → 8.68cd1217.iframe.bundle.js.LICENSE.txt} +0 -0
- package/storybook-static/8.68cd1217.iframe.bundle.js.map +1 -0
- package/storybook-static/8.76c3cbf398692028e834.manager.bundle.js +1 -0
- package/storybook-static/{9.109ea555.iframe.bundle.js → 9.488e3969.iframe.bundle.js} +0 -0
- package/storybook-static/iframe.html +2 -2
- package/storybook-static/index.html +9 -1
- package/storybook-static/main.044648aa.iframe.bundle.js +1 -0
- package/storybook-static/main.ac6e4b72b033097dad76.manager.bundle.js +1 -0
- package/storybook-static/{runtime~main.ffc8677e.iframe.bundle.js → runtime~main.3e280e98.iframe.bundle.js} +1 -1
- package/storybook-static/runtime~main.c8dac23bc753439736f0.manager.bundle.js +1 -0
- package/storybook-static/vendors~main.a697e07137d366f95f76.manager.bundle.js +2 -0
- package/storybook-static/{vendors~main.a935f15a2179a6eff5fd.manager.bundle.js.LICENSE.txt → vendors~main.a697e07137d366f95f76.manager.bundle.js.LICENSE.txt} +6 -12
- package/storybook-static/vendors~main.d75dc38b.iframe.bundle.js +76 -0
- package/storybook-static/{vendors~main.4aa936b1.iframe.bundle.js.LICENSE.txt → vendors~main.d75dc38b.iframe.bundle.js.LICENSE.txt} +3 -45
- package/storybook-static/vendors~main.d75dc38b.iframe.bundle.js.map +1 -0
- package/tools/build-styles.js +17 -0
- package/dist/index.es.js +0 -37
- package/dist/index.js +0 -37
- package/src/components/Hawa/AdaptiveButton/index.js +0 -1
- package/src/components/Hawa/AuthForms/NewPasswordForm.js +0 -23
- package/src/components/Hawa/AuthForms/ResetPasswordForm.js +0 -21
- package/src/components/Hawa/AuthForms/SignInForm.js +0 -25
- package/src/components/Hawa/AuthForms/SignUpForm.js +0 -26
- package/src/components/Hawa/AuthForms/viaFacebook.js +0 -0
- package/src/components/Hawa/AuthForms/viaGithub.js +0 -0
- package/src/components/Hawa/AuthForms/viaGoogle.js +0 -0
- package/src/components/Hawa/AuthForms/viaTwitter.js +0 -0
- package/src/components/Hawa/AutoCompleteField/index.js +0 -1
- package/src/components/Hawa/Box/Box.js +0 -18
- package/src/components/Hawa/Box/index.js +0 -1
- package/src/components/Hawa/Checkbox/index.js +0 -1
- package/src/components/Hawa/DragDropImages/index.js +0 -1
- package/src/components/Hawa/HawaProvider/HawaProvider.js +0 -19
- package/src/components/Hawa/HawaProvider/index.js +0 -1
- package/src/components/Hawa/InputLabel/StyledInputLabel.js +0 -15
- package/src/components/Hawa/InputLabel/index.js +0 -1
- package/src/components/Hawa/RadioBox/index.js +0 -1
- package/src/components/Hawa/RadioSelector/index.js +0 -1
- package/src/components/Hawa/Row/index.js +0 -1
- package/src/components/Hawa/SelectedField/index.js +0 -1
- package/src/components/Hawa/StyledAlert/StyledAlert.js +0 -15
- package/src/components/Hawa/StyledAlert/index.js +0 -1
- package/src/components/Hawa/StyledTooltip/index.js +0 -1
- package/src/components/Hawa/TabPanel/index.js +0 -1
- package/src/components/Hawa/TextArea/index.js +0 -1
- package/src/components/Hawa/TextField/TextField.js +0 -54
- package/src/components/Hawa/TextField/index.js +0 -1
- package/src/components/Hawa/index.js +0 -10
- package/src/stories/AuthForm.stories.js +0 -76
- package/src/stories/Box.stories.js +0 -45
- package/storybook-static/0.12392f0b.iframe.bundle.js +0 -1
- package/storybook-static/0.55b012452099ace2dca6.manager.bundle.js +0 -1
- package/storybook-static/1.0f38715c61c7c3cd11db.manager.bundle.js +0 -1
- package/storybook-static/1.7c0dc86d.iframe.bundle.js +0 -3
- package/storybook-static/1.7c0dc86d.iframe.bundle.js.map +0 -1
- package/storybook-static/10.9f2923a7561bc20fffdb.manager.bundle.js +0 -1
- package/storybook-static/11.f4e922583ae35da460f3.manager.bundle.js +0 -2
- package/storybook-static/12.1415460941f0bdcb8fa8.manager.bundle.js +0 -1
- package/storybook-static/2.ee357266.iframe.bundle.js +0 -1
- package/storybook-static/5.f459d151315e6780c20f.manager.bundle.js +0 -2
- package/storybook-static/6.3bd64d820f3745f262ff.manager.bundle.js +0 -1
- package/storybook-static/7.af56919f.iframe.bundle.js +0 -1
- package/storybook-static/8.8e2132ec.iframe.bundle.js.map +0 -1
- package/storybook-static/8.b541eadfcb9164835dfc.manager.bundle.js +0 -1
- package/storybook-static/9.411ac8e451bbb10926c7.manager.bundle.js +0 -1
- package/storybook-static/main.78b7d418.iframe.bundle.js +0 -1
- package/storybook-static/main.9bb085ebb152f5b19a2a.manager.bundle.js +0 -1
- package/storybook-static/runtime~main.9468098d21070636985f.manager.bundle.js +0 -1
- package/storybook-static/vendors~main.4aa936b1.iframe.bundle.js +0 -3
- package/storybook-static/vendors~main.4aa936b1.iframe.bundle.js.map +0 -1
- package/storybook-static/vendors~main.a935f15a2179a6eff5fd.manager.bundle.js +0 -2
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { createContext } from "react";
|
|
2
|
+
|
|
3
|
+
//make the text color of the action buttons different from the text color of the layout
|
|
4
|
+
export const defaultTheme = {
|
|
5
|
+
borderRadius: 10,
|
|
6
|
+
primaryColor: "blue",
|
|
7
|
+
secondaryColor: "grey",
|
|
8
|
+
// primaryActionColor: '#f72585', //Colors of the buttons
|
|
9
|
+
primaryActionColor: "grey", //Colors of the buttons
|
|
10
|
+
secondaryActionColor: "#4cc9f0", //Colors of the buttons
|
|
11
|
+
layoutColor: "#d3d4d9", //Colors of boxes and cards
|
|
12
|
+
textColor: "black", //Colors of text everywhere
|
|
13
|
+
inputColor: "white", //Color of input fields
|
|
14
|
+
lightBackground: "#FBF5F3", //
|
|
15
|
+
darkBackground: "#0F0E0E",
|
|
16
|
+
margins: 10,
|
|
17
|
+
paddings: 10,
|
|
18
|
+
allBorderRadius: 10,
|
|
19
|
+
actionButton: {
|
|
20
|
+
primary: {
|
|
21
|
+
borderRadius: 10,
|
|
22
|
+
backgroundColor: "#f90900",
|
|
23
|
+
color: "white",
|
|
24
|
+
margin: 10,
|
|
25
|
+
padding: 10
|
|
26
|
+
},
|
|
27
|
+
secondary: {
|
|
28
|
+
borderRadius: 10,
|
|
29
|
+
margin: 10,
|
|
30
|
+
padding: 10,
|
|
31
|
+
backgroundColor: "#FF8811",
|
|
32
|
+
color: "black"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
layout: {
|
|
36
|
+
primary: {
|
|
37
|
+
backgroundColor: "#d3d4d9",
|
|
38
|
+
color: "black",
|
|
39
|
+
margin: 10,
|
|
40
|
+
padding: 10,
|
|
41
|
+
borderRadius: 10
|
|
42
|
+
},
|
|
43
|
+
secondary: {
|
|
44
|
+
backgroundColor: "#001E3C",
|
|
45
|
+
// backgroundColor: "red",
|
|
46
|
+
color: "white",
|
|
47
|
+
margin: 10,
|
|
48
|
+
padding: 10,
|
|
49
|
+
borderRadius: 10
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
inputFields: {
|
|
53
|
+
primary: {
|
|
54
|
+
backgroundColor: "white",
|
|
55
|
+
display: "flex",
|
|
56
|
+
flexDirection: "column",
|
|
57
|
+
alignItems: "flex-start",
|
|
58
|
+
justifyContent: "flex-start",
|
|
59
|
+
borderRadius: 10
|
|
60
|
+
},
|
|
61
|
+
secondary: {
|
|
62
|
+
backgroundColor: "white",
|
|
63
|
+
display: "flex",
|
|
64
|
+
flexDirection: "column",
|
|
65
|
+
alignItems: "flex-start",
|
|
66
|
+
justifyContent: "flex-start",
|
|
67
|
+
borderRadius: 10
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export const ThemeProvider = createContext(defaultTheme);
|
|
73
|
+
|
|
74
|
+
export const HawaProvider = ({ theme, ...props }) => {
|
|
75
|
+
if (props.size === "large") {
|
|
76
|
+
theme = {
|
|
77
|
+
...theme,
|
|
78
|
+
paddings: 20,
|
|
79
|
+
margins: 20
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
return (
|
|
83
|
+
<ThemeProvider.Provider value={theme || defaultTheme}>
|
|
84
|
+
{props.children}
|
|
85
|
+
</ThemeProvider.Provider>
|
|
86
|
+
);
|
|
87
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import Button from "@mui/material/Button";
|
|
2
|
+
import { useContext } from "react";
|
|
3
|
+
import { ThemeProvider } from "../themes/HawaProvider";
|
|
4
|
+
import { styled, darken } from "@mui/material/styles";
|
|
5
|
+
|
|
6
|
+
export const ActionButton = (props) => {
|
|
7
|
+
const theme = useContext(ThemeProvider);
|
|
8
|
+
const currentTheme = Object.keys(theme.actionButton).find(
|
|
9
|
+
(themeName) => themeName.toLowerCase() === props.themeType?.toLowerCase()
|
|
10
|
+
);
|
|
11
|
+
let actionButtonStyle = {};
|
|
12
|
+
|
|
13
|
+
if (currentTheme) {
|
|
14
|
+
actionButtonStyle = {
|
|
15
|
+
...theme.actionButton[currentTheme],
|
|
16
|
+
margin: props.last ? 0 : theme.actionButton[currentTheme].margin,
|
|
17
|
+
marginTop: props.last ? theme.actionButton[currentTheme].margin * 2 : 0,
|
|
18
|
+
"&:hover": {
|
|
19
|
+
backgroundColor: darken(
|
|
20
|
+
theme.actionButton[currentTheme]?.backgroundColor,
|
|
21
|
+
0.1
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
} else {
|
|
26
|
+
actionButtonStyle = {
|
|
27
|
+
backgroundColor: "black",
|
|
28
|
+
color: "white",
|
|
29
|
+
padding: 10,
|
|
30
|
+
marginTop: props.last ? 10 * 2 : 0
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const StyledButton = styled(Button)(({ theme }) => {
|
|
35
|
+
return {
|
|
36
|
+
...actionButtonStyle
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
return <StyledButton {...props}>{props.text}</StyledButton>;
|
|
40
|
+
};
|
|
@@ -1,254 +1,252 @@
|
|
|
1
|
-
import React, { useState, useContext } from "react";
|
|
2
|
-
import Button from "@material
|
|
3
|
-
import Tooltip from "@material
|
|
4
|
-
import { motion } from "framer-motion";
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import { getTextColor } from "
|
|
9
|
-
|
|
10
|
-
const AdaptiveButton = (props) => {
|
|
11
|
-
const { showText } = props;
|
|
12
|
-
const theme = useContext(ThemeProvider);
|
|
13
|
-
const screenSize = {
|
|
14
|
-
width: 1500,
|
|
15
|
-
height: 200
|
|
16
|
-
};
|
|
17
|
-
const [tooltip, setTooltip] = useState(false);
|
|
18
|
-
const [hovered, setHovered] = useState(false);
|
|
19
|
-
//full button
|
|
20
|
-
if (showText) {
|
|
21
|
-
return (
|
|
22
|
-
<motion.div
|
|
23
|
-
transition={{ duration: 0.2 }}
|
|
24
|
-
whileTap={{ scale: 1.2 }}
|
|
25
|
-
whileHover={{
|
|
26
|
-
// backgroundColor: props.hoverColor,
|
|
27
|
-
borderRadius: theme.borderRadius,
|
|
28
|
-
color: "red"
|
|
29
|
-
}}
|
|
30
|
-
onMouseEnter={() => setHovered(true)}
|
|
31
|
-
onMouseLeave={() => setHovered(false)}
|
|
32
|
-
onMouseDown={() => setHovered(true)}
|
|
33
|
-
onMouseUp={() => setHovered(false)}
|
|
34
|
-
onMouseOver={() => setHovered(true)}
|
|
35
|
-
onMouseOut={() => setHovered(false)}
|
|
36
|
-
>
|
|
37
|
-
<Button
|
|
38
|
-
disableRipple
|
|
39
|
-
disabled={props.disabled}
|
|
40
|
-
aria-label={props.buttonLabel}
|
|
41
|
-
color={props.danger ? "secondary" : "primary"}
|
|
42
|
-
onClick={props.handleClick}
|
|
43
|
-
style={{
|
|
44
|
-
backgroundColor: theme.primaryColor,
|
|
45
|
-
borderRadius: theme.borderRadius,
|
|
46
|
-
padding: theme.paddings,
|
|
47
|
-
color: getTextColor(theme.primaryColor)
|
|
48
|
-
// color: hovered
|
|
49
|
-
// ? "#ffffff"
|
|
50
|
-
// : props.danger
|
|
51
|
-
// ? "#f50057"
|
|
52
|
-
// : "var(--blue)"
|
|
53
|
-
}}
|
|
54
|
-
>
|
|
55
|
-
{props.icon}
|
|
56
|
-
{props.showText ? (
|
|
57
|
-
<span style={{ marginLeft: props.icon ? 5 : 0 }}>
|
|
58
|
-
{props.buttonLabel}
|
|
59
|
-
</span>
|
|
60
|
-
) : null}
|
|
61
|
-
</Button>
|
|
62
|
-
</motion.div>
|
|
63
|
-
);
|
|
64
|
-
} else if (props.buttonLabelOnly) {
|
|
65
|
-
return (
|
|
66
|
-
<motion.div
|
|
67
|
-
transition={{ duration: 0.2 }}
|
|
68
|
-
initial={{
|
|
69
|
-
width: "fit-content",
|
|
70
|
-
backgroundColor: props.buttonColor,
|
|
71
|
-
borderRadius: theme.borderRadius
|
|
72
|
-
}}
|
|
73
|
-
whileTap={{ scale: 1.2 }}
|
|
74
|
-
whileHover={{
|
|
75
|
-
backgroundColor: props.hoverColor,
|
|
76
|
-
borderRadius: theme.borderRadius
|
|
77
|
-
}}
|
|
78
|
-
onMouseEnter={() => setHovered(true)}
|
|
79
|
-
onMouseLeave={() => setHovered(false)}
|
|
80
|
-
onMouseDown={() => {
|
|
81
|
-
setHovered(true);
|
|
82
|
-
setTooltip(true);
|
|
83
|
-
}}
|
|
84
|
-
onMouseUp={() => {
|
|
85
|
-
setHovered(false);
|
|
86
|
-
setTooltip(true);
|
|
87
|
-
}}
|
|
88
|
-
onMouseOver={() => {
|
|
89
|
-
setHovered(true);
|
|
90
|
-
setTooltip(true);
|
|
91
|
-
}}
|
|
92
|
-
onMouseOut={() => {
|
|
93
|
-
setHovered(false);
|
|
94
|
-
// setTooltip(true);
|
|
95
|
-
}}
|
|
96
|
-
>
|
|
97
|
-
<Tooltip
|
|
98
|
-
placement={screenSize.width > 400 ? "bottom-center" : "top-center"}
|
|
99
|
-
enterTouchDelay={100}
|
|
100
|
-
title={
|
|
101
|
-
props.hint ? (
|
|
102
|
-
props.hint
|
|
103
|
-
) : (
|
|
104
|
-
<div>
|
|
105
|
-
<div
|
|
106
|
-
style={{
|
|
107
|
-
fontSize: 20,
|
|
108
|
-
fontWeight: 800,
|
|
109
|
-
padding: 10,
|
|
110
|
-
paddingBottom: 5,
|
|
111
|
-
textAlign: "center"
|
|
112
|
-
}}
|
|
113
|
-
>
|
|
114
|
-
{props.hintTitle}
|
|
115
|
-
</div>
|
|
116
|
-
<div
|
|
117
|
-
style={{
|
|
118
|
-
fontSize: 13,
|
|
119
|
-
fontWeight: 100,
|
|
120
|
-
padding: 10,
|
|
121
|
-
textAlign: "center"
|
|
122
|
-
}}
|
|
123
|
-
>
|
|
124
|
-
{props.hintContent}
|
|
125
|
-
</div>
|
|
126
|
-
</div>
|
|
127
|
-
)
|
|
128
|
-
}
|
|
129
|
-
>
|
|
130
|
-
<Button
|
|
131
|
-
disabled={props.disabled}
|
|
132
|
-
size="small"
|
|
133
|
-
disableRipple
|
|
134
|
-
aria-label={props.buttonLabel}
|
|
135
|
-
onClick={props.handleClick}
|
|
136
|
-
color={props.danger ? "secondary" : "primary"}
|
|
137
|
-
style={{
|
|
138
|
-
padding: 10,
|
|
139
|
-
color: hovered
|
|
140
|
-
? "#ffffff"
|
|
141
|
-
: props.danger
|
|
142
|
-
? "#f50057"
|
|
143
|
-
: "var(--blue)"
|
|
144
|
-
}}
|
|
145
|
-
>
|
|
146
|
-
{props.buttonLabel}
|
|
147
|
-
</Button>
|
|
148
|
-
</Tooltip>
|
|
149
|
-
</motion.div>
|
|
150
|
-
);
|
|
151
|
-
} else {
|
|
152
|
-
//icon only
|
|
153
|
-
return (
|
|
154
|
-
<motion.div
|
|
155
|
-
transition={{ duration: 0.2 }}
|
|
156
|
-
initial={{
|
|
157
|
-
width: "fit-content",
|
|
158
|
-
backgroundColor: props.buttonColor,
|
|
159
|
-
borderRadius: theme.borderRadius,
|
|
160
|
-
// padding: 5,
|
|
161
|
-
margin: 5
|
|
162
|
-
}}
|
|
163
|
-
whileTap={{ scale: 1.2 }}
|
|
164
|
-
whileHover={{
|
|
165
|
-
backgroundColor: props.hoverColor,
|
|
166
|
-
borderRadius: theme.borderRadius
|
|
167
|
-
}}
|
|
168
|
-
onMouseEnter={() => setHovered(true)}
|
|
169
|
-
onMouseLeave={() => setHovered(false)}
|
|
170
|
-
onMouseDown={() => {
|
|
171
|
-
setHovered(true);
|
|
172
|
-
setTooltip(true);
|
|
173
|
-
}}
|
|
174
|
-
onMouseUp={() => {
|
|
175
|
-
setHovered(false);
|
|
176
|
-
setTooltip(true);
|
|
177
|
-
}}
|
|
178
|
-
onMouseOver={() => {
|
|
179
|
-
setHovered(true);
|
|
180
|
-
setTooltip(true);
|
|
181
|
-
}}
|
|
182
|
-
onMouseOut={() => {
|
|
183
|
-
setHovered(false);
|
|
184
|
-
// setTooltip(true);
|
|
185
|
-
}}
|
|
186
|
-
>
|
|
187
|
-
<StyledTooltip hintTitle="Example" hintContent="More explaination here">
|
|
188
|
-
<Button
|
|
189
|
-
disabled={props.disabled}
|
|
190
|
-
size="small"
|
|
191
|
-
disableRipple
|
|
192
|
-
aria-label={props.buttonLabel}
|
|
193
|
-
onClick={props.handleClick}
|
|
194
|
-
color={props.danger ? "secondary" : "primary"}
|
|
195
|
-
style={{
|
|
196
|
-
padding: 10,
|
|
197
|
-
color: hovered
|
|
198
|
-
? "#ffffff"
|
|
199
|
-
: props.danger
|
|
200
|
-
? "#f50057"
|
|
201
|
-
: "var(--blue)"
|
|
202
|
-
}}
|
|
203
|
-
>
|
|
204
|
-
{props.icon}
|
|
205
|
-
</Button>
|
|
206
|
-
</StyledTooltip>
|
|
207
|
-
{/* <Tooltip
|
|
208
|
-
placement={screenSize.width > 400 ? "bottom-center" : "top-center"}
|
|
209
|
-
enterTouchDelay={100}
|
|
210
|
-
title={
|
|
211
|
-
props.hint ? (
|
|
212
|
-
props.hint
|
|
213
|
-
) : (
|
|
214
|
-
<div>
|
|
215
|
-
<div
|
|
216
|
-
style={{
|
|
217
|
-
fontSize: 20,
|
|
218
|
-
fontWeight: 800,
|
|
219
|
-
padding: 10,
|
|
220
|
-
paddingBottom: 5,
|
|
221
|
-
textAlign: "center"
|
|
222
|
-
}}
|
|
223
|
-
>
|
|
224
|
-
{props.hintTitle}
|
|
225
|
-
</div>
|
|
226
|
-
<div
|
|
227
|
-
style={{
|
|
228
|
-
fontSize: 13,
|
|
229
|
-
fontWeight: 100,
|
|
230
|
-
padding: 10,
|
|
231
|
-
textAlign: "center"
|
|
232
|
-
}}
|
|
233
|
-
>
|
|
234
|
-
{props.hintContent}
|
|
235
|
-
</div>
|
|
236
|
-
</div>
|
|
237
|
-
)
|
|
238
|
-
}
|
|
239
|
-
>
|
|
240
|
-
|
|
241
|
-
</Tooltip> */}
|
|
242
|
-
</motion.div>
|
|
243
|
-
);
|
|
244
|
-
}
|
|
245
|
-
};
|
|
246
|
-
|
|
247
|
-
AdaptiveButton.propTypes = {
|
|
248
|
-
buttonLabel: PropTypes.string,
|
|
249
|
-
danger: PropTypes.bool,
|
|
250
|
-
disabled: PropTypes.bool,
|
|
251
|
-
showText: PropTypes.bool
|
|
252
|
-
};
|
|
253
|
-
|
|
254
|
-
export default AdaptiveButton;
|
|
1
|
+
import React, { useState, useContext } from "react";
|
|
2
|
+
import Button from "@mui/material/Button";
|
|
3
|
+
import Tooltip from "@mui/material/Tooltip";
|
|
4
|
+
import { motion } from "framer-motion";
|
|
5
|
+
import PropTypes from "prop-types";
|
|
6
|
+
import { ThemeProvider } from "../themes/HawaProvider";
|
|
7
|
+
import { StyledTooltip } from "./StyledTooltip";
|
|
8
|
+
import { getTextColor } from "../util";
|
|
9
|
+
|
|
10
|
+
export const AdaptiveButton = (props) => {
|
|
11
|
+
const { showText } = props;
|
|
12
|
+
const theme = useContext(ThemeProvider);
|
|
13
|
+
const screenSize = {
|
|
14
|
+
width: 1500,
|
|
15
|
+
height: 200
|
|
16
|
+
};
|
|
17
|
+
const [tooltip, setTooltip] = useState(false);
|
|
18
|
+
const [hovered, setHovered] = useState(false);
|
|
19
|
+
//full button
|
|
20
|
+
if (showText) {
|
|
21
|
+
return (
|
|
22
|
+
<motion.div
|
|
23
|
+
transition={{ duration: 0.2 }}
|
|
24
|
+
whileTap={{ scale: 1.2 }}
|
|
25
|
+
whileHover={{
|
|
26
|
+
// backgroundColor: props.hoverColor,
|
|
27
|
+
borderRadius: theme.borderRadius,
|
|
28
|
+
color: "red"
|
|
29
|
+
}}
|
|
30
|
+
onMouseEnter={() => setHovered(true)}
|
|
31
|
+
onMouseLeave={() => setHovered(false)}
|
|
32
|
+
onMouseDown={() => setHovered(true)}
|
|
33
|
+
onMouseUp={() => setHovered(false)}
|
|
34
|
+
onMouseOver={() => setHovered(true)}
|
|
35
|
+
onMouseOut={() => setHovered(false)}
|
|
36
|
+
>
|
|
37
|
+
<Button
|
|
38
|
+
disableRipple
|
|
39
|
+
disabled={props.disabled}
|
|
40
|
+
aria-label={props.buttonLabel}
|
|
41
|
+
color={props.danger ? "secondary" : "primary"}
|
|
42
|
+
onClick={props.handleClick}
|
|
43
|
+
style={{
|
|
44
|
+
backgroundColor: theme.primaryColor,
|
|
45
|
+
borderRadius: theme.borderRadius,
|
|
46
|
+
padding: theme.paddings,
|
|
47
|
+
color: getTextColor(theme.primaryColor)
|
|
48
|
+
// color: hovered
|
|
49
|
+
// ? "#ffffff"
|
|
50
|
+
// : props.danger
|
|
51
|
+
// ? "#f50057"
|
|
52
|
+
// : "var(--blue)"
|
|
53
|
+
}}
|
|
54
|
+
>
|
|
55
|
+
{props.icon}
|
|
56
|
+
{props.showText ? (
|
|
57
|
+
<span style={{ marginLeft: props.icon ? 5 : 0 }}>
|
|
58
|
+
{props.buttonLabel}
|
|
59
|
+
</span>
|
|
60
|
+
) : null}
|
|
61
|
+
</Button>
|
|
62
|
+
</motion.div>
|
|
63
|
+
);
|
|
64
|
+
} else if (props.buttonLabelOnly) {
|
|
65
|
+
return (
|
|
66
|
+
<motion.div
|
|
67
|
+
transition={{ duration: 0.2 }}
|
|
68
|
+
initial={{
|
|
69
|
+
width: "fit-content",
|
|
70
|
+
backgroundColor: props.buttonColor,
|
|
71
|
+
borderRadius: theme.borderRadius
|
|
72
|
+
}}
|
|
73
|
+
whileTap={{ scale: 1.2 }}
|
|
74
|
+
whileHover={{
|
|
75
|
+
backgroundColor: props.hoverColor,
|
|
76
|
+
borderRadius: theme.borderRadius
|
|
77
|
+
}}
|
|
78
|
+
onMouseEnter={() => setHovered(true)}
|
|
79
|
+
onMouseLeave={() => setHovered(false)}
|
|
80
|
+
onMouseDown={() => {
|
|
81
|
+
setHovered(true);
|
|
82
|
+
setTooltip(true);
|
|
83
|
+
}}
|
|
84
|
+
onMouseUp={() => {
|
|
85
|
+
setHovered(false);
|
|
86
|
+
setTooltip(true);
|
|
87
|
+
}}
|
|
88
|
+
onMouseOver={() => {
|
|
89
|
+
setHovered(true);
|
|
90
|
+
setTooltip(true);
|
|
91
|
+
}}
|
|
92
|
+
onMouseOut={() => {
|
|
93
|
+
setHovered(false);
|
|
94
|
+
// setTooltip(true);
|
|
95
|
+
}}
|
|
96
|
+
>
|
|
97
|
+
<Tooltip
|
|
98
|
+
placement={screenSize.width > 400 ? "bottom-center" : "top-center"}
|
|
99
|
+
enterTouchDelay={100}
|
|
100
|
+
title={
|
|
101
|
+
props.hint ? (
|
|
102
|
+
props.hint
|
|
103
|
+
) : (
|
|
104
|
+
<div>
|
|
105
|
+
<div
|
|
106
|
+
style={{
|
|
107
|
+
fontSize: 20,
|
|
108
|
+
fontWeight: 800,
|
|
109
|
+
padding: 10,
|
|
110
|
+
paddingBottom: 5,
|
|
111
|
+
textAlign: "center"
|
|
112
|
+
}}
|
|
113
|
+
>
|
|
114
|
+
{props.hintTitle}
|
|
115
|
+
</div>
|
|
116
|
+
<div
|
|
117
|
+
style={{
|
|
118
|
+
fontSize: 13,
|
|
119
|
+
fontWeight: 100,
|
|
120
|
+
padding: 10,
|
|
121
|
+
textAlign: "center"
|
|
122
|
+
}}
|
|
123
|
+
>
|
|
124
|
+
{props.hintContent}
|
|
125
|
+
</div>
|
|
126
|
+
</div>
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
>
|
|
130
|
+
<Button
|
|
131
|
+
disabled={props.disabled}
|
|
132
|
+
size="small"
|
|
133
|
+
disableRipple
|
|
134
|
+
aria-label={props.buttonLabel}
|
|
135
|
+
onClick={props.handleClick}
|
|
136
|
+
color={props.danger ? "secondary" : "primary"}
|
|
137
|
+
style={{
|
|
138
|
+
padding: 10,
|
|
139
|
+
color: hovered
|
|
140
|
+
? "#ffffff"
|
|
141
|
+
: props.danger
|
|
142
|
+
? "#f50057"
|
|
143
|
+
: "var(--blue)"
|
|
144
|
+
}}
|
|
145
|
+
>
|
|
146
|
+
{props.buttonLabel}
|
|
147
|
+
</Button>
|
|
148
|
+
</Tooltip>
|
|
149
|
+
</motion.div>
|
|
150
|
+
);
|
|
151
|
+
} else {
|
|
152
|
+
//icon only
|
|
153
|
+
return (
|
|
154
|
+
<motion.div
|
|
155
|
+
transition={{ duration: 0.2 }}
|
|
156
|
+
initial={{
|
|
157
|
+
width: "fit-content",
|
|
158
|
+
backgroundColor: props.buttonColor,
|
|
159
|
+
borderRadius: theme.borderRadius,
|
|
160
|
+
// padding: 5,
|
|
161
|
+
margin: 5
|
|
162
|
+
}}
|
|
163
|
+
whileTap={{ scale: 1.2 }}
|
|
164
|
+
whileHover={{
|
|
165
|
+
backgroundColor: props.hoverColor,
|
|
166
|
+
borderRadius: theme.borderRadius
|
|
167
|
+
}}
|
|
168
|
+
onMouseEnter={() => setHovered(true)}
|
|
169
|
+
onMouseLeave={() => setHovered(false)}
|
|
170
|
+
onMouseDown={() => {
|
|
171
|
+
setHovered(true);
|
|
172
|
+
setTooltip(true);
|
|
173
|
+
}}
|
|
174
|
+
onMouseUp={() => {
|
|
175
|
+
setHovered(false);
|
|
176
|
+
setTooltip(true);
|
|
177
|
+
}}
|
|
178
|
+
onMouseOver={() => {
|
|
179
|
+
setHovered(true);
|
|
180
|
+
setTooltip(true);
|
|
181
|
+
}}
|
|
182
|
+
onMouseOut={() => {
|
|
183
|
+
setHovered(false);
|
|
184
|
+
// setTooltip(true);
|
|
185
|
+
}}
|
|
186
|
+
>
|
|
187
|
+
<StyledTooltip hintTitle="Example" hintContent="More explaination here">
|
|
188
|
+
<Button
|
|
189
|
+
disabled={props.disabled}
|
|
190
|
+
size="small"
|
|
191
|
+
disableRipple
|
|
192
|
+
aria-label={props.buttonLabel}
|
|
193
|
+
onClick={props.handleClick}
|
|
194
|
+
color={props.danger ? "secondary" : "primary"}
|
|
195
|
+
style={{
|
|
196
|
+
padding: 10,
|
|
197
|
+
color: hovered
|
|
198
|
+
? "#ffffff"
|
|
199
|
+
: props.danger
|
|
200
|
+
? "#f50057"
|
|
201
|
+
: "var(--blue)"
|
|
202
|
+
}}
|
|
203
|
+
>
|
|
204
|
+
{props.icon}
|
|
205
|
+
</Button>
|
|
206
|
+
</StyledTooltip>
|
|
207
|
+
{/* <Tooltip
|
|
208
|
+
placement={screenSize.width > 400 ? "bottom-center" : "top-center"}
|
|
209
|
+
enterTouchDelay={100}
|
|
210
|
+
title={
|
|
211
|
+
props.hint ? (
|
|
212
|
+
props.hint
|
|
213
|
+
) : (
|
|
214
|
+
<div>
|
|
215
|
+
<div
|
|
216
|
+
style={{
|
|
217
|
+
fontSize: 20,
|
|
218
|
+
fontWeight: 800,
|
|
219
|
+
padding: 10,
|
|
220
|
+
paddingBottom: 5,
|
|
221
|
+
textAlign: "center"
|
|
222
|
+
}}
|
|
223
|
+
>
|
|
224
|
+
{props.hintTitle}
|
|
225
|
+
</div>
|
|
226
|
+
<div
|
|
227
|
+
style={{
|
|
228
|
+
fontSize: 13,
|
|
229
|
+
fontWeight: 100,
|
|
230
|
+
padding: 10,
|
|
231
|
+
textAlign: "center"
|
|
232
|
+
}}
|
|
233
|
+
>
|
|
234
|
+
{props.hintContent}
|
|
235
|
+
</div>
|
|
236
|
+
</div>
|
|
237
|
+
)
|
|
238
|
+
}
|
|
239
|
+
>
|
|
240
|
+
|
|
241
|
+
</Tooltip> */}
|
|
242
|
+
</motion.div>
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
AdaptiveButton.propTypes = {
|
|
248
|
+
buttonLabel: PropTypes.string,
|
|
249
|
+
danger: PropTypes.bool,
|
|
250
|
+
disabled: PropTypes.bool,
|
|
251
|
+
showText: PropTypes.bool
|
|
252
|
+
};
|