From 323879c452fb010bdff33a756b5d2067ca876d44 Mon Sep 17 00:00:00 2001 From: Shubham Gupta Date: Fri, 4 Oct 2024 13:56:04 +0530 Subject: [PATCH] ui: Update buttons styles --- src/assets/completeRecoveryIcon.svg | 2 +- src/components/Button.tsx | 95 ++++++++++++++----- src/components/ConfigureGuardians.tsx | 13 ++- src/components/ConnectWallets.tsx | 2 +- src/components/EnableSafeModule.tsx | 2 +- src/components/FlowsInfoCard.tsx | 3 +- src/components/GuardianSetup.tsx | 2 +- src/components/Navbar.tsx | 24 +---- src/components/RequestedRecoveries.tsx | 12 ++- src/components/WalletActions.tsx | 2 + .../burnerWallet/ConfigureGuardians.tsx | 12 ++- src/components/burnerWallet/GuardianSetup.tsx | 4 +- .../burnerWallet/RequestedRecoveries.tsx | 19 ++-- src/pages/burnerWalletFlow.tsx | 3 +- src/pages/landingPage.tsx | 2 +- src/theme.tsx | 5 +- 16 files changed, 128 insertions(+), 74 deletions(-) diff --git a/src/assets/completeRecoveryIcon.svg b/src/assets/completeRecoveryIcon.svg index 045ce27..d762c8e 100644 --- a/src/assets/completeRecoveryIcon.svg +++ b/src/assets/completeRecoveryIcon.svg @@ -1,6 +1,6 @@ - + diff --git a/src/components/Button.tsx b/src/components/Button.tsx index 3d7fcd4..6fd0f24 100644 --- a/src/components/Button.tsx +++ b/src/components/Button.tsx @@ -5,47 +5,96 @@ type CustomButtonProps = { endIcon?: ReactNode; loading?: boolean; filled?: boolean; // Add the filled prop + variant?: "text" | "outlined" | "contained"; } & React.ComponentPropsWithoutRef<"button">; // Ensure compatibility with standard button props export function Button({ children, endIcon, loading, - filled = false, + variant = "text", ...buttonProps }: CustomButtonProps) { const theme = useTheme(); + const getStyles = () => { + switch (variant) { + case "text": + return { + color: theme.palette.text.primary, // Set text color based on filled prop + ":hover": { + // backgroundColor: filled ? "#FD4BA1" : "#E0F6FF", // Background color on hover + }, + ":focus": { + outline: "none", // Remove outline on focus + }, + ":active": { + outline: "none", // Remove outline on active + }, + ":disabled": { + backgroundColor: "#FAC5DF", + color: "#ffffff", + }, + }; + + case "outlined": + return { + color: theme.palette.text.primary, // Set text color based on filled prop + background: theme.palette.background.default, // Set text color based on filled prop + ":hover": { + // backgroundColor: filled ? "#FD4BA1" : "#E0F6FF", // Background color on hover + }, + ":focus": { + outline: "none", // Remove outline on focus + }, + ":active": { + outline: "none", // Remove outline on active + }, + ":disabled": { + backgroundColor: "#FAC5DF", + color: "#ffffff", + }, + }; + + case "contained": + return { + color: 'white', // Set text color based on filled prop + background: theme.palette.primary.main, // Set text color based on filled prop + ":hover": { + // backgroundColor: filled ? "#FD4BA1" : "#E0F6FF", // Background color on hover + }, + ":focus": { + outline: "none", // Remove outline on focus + }, + ":active": { + outline: "none", // Remove outline on active + }, + ":disabled": { + backgroundColor: "#FAC5DF", + color: "#ffffff", + }, + }; + + default: + break; + } + }; + return ( : endIcon} disabled={loading || buttonProps.disabled} - {...buttonProps} > {children} diff --git a/src/components/ConfigureGuardians.tsx b/src/components/ConfigureGuardians.tsx index 80774cc..43fb8c9 100644 --- a/src/components/ConfigureGuardians.tsx +++ b/src/components/ConfigureGuardians.tsx @@ -81,16 +81,20 @@ const AddGuardianModal = ({ /> - @@ -216,6 +220,7 @@ const ConfigureGuardians = () => { > @@ -268,6 +274,7 @@ const ConfigureGuardians = () => { diff --git a/src/components/GuardianSetup.tsx b/src/components/GuardianSetup.tsx index afb0457..902f5de 100644 --- a/src/components/GuardianSetup.tsx +++ b/src/components/GuardianSetup.tsx @@ -379,7 +379,7 @@ const GuardianSetup = () => { disabled={!guardianEmail || loading} loading={loading} onClick={configureRecoveryAndRequestGuardian} - filled={true} + variant={"contained"} > Configure Recovery & Request Guardian diff --git a/src/components/Navbar.tsx b/src/components/Navbar.tsx index bd3e438..ed37986 100644 --- a/src/components/Navbar.tsx +++ b/src/components/Navbar.tsx @@ -129,23 +129,13 @@ const MobileNav = ({ style={{ marginTop: "auto", marginBottom: "2rem" }} > ); @@ -273,6 +277,7 @@ const RequestedRecoveries = () => { > ) : null} +
{getButtonComponent()}
diff --git a/src/components/WalletActions.tsx b/src/components/WalletActions.tsx index a59d2b3..5adab9b 100644 --- a/src/components/WalletActions.tsx +++ b/src/components/WalletActions.tsx @@ -21,6 +21,7 @@ const WalletActions = () => { > @@ -92,7 +96,7 @@ const AddGuardianModal = ({ onClick={handleAddGuardian} disabled={isAddGuardianLoading} loading={isAddGuardianLoading} - filled={true} + variant={"contained"} > Add Guardian @@ -220,6 +224,7 @@ const ConfigureGuardians = () => { > @@ -272,6 +277,7 @@ const ConfigureGuardians = () => { @@ -463,7 +463,7 @@ const GuardianSetup = () => { // await new Promise((resolve) => setTimeout(resolve, 10000)); // 5000 ms = 5 seconds configureRecoveryAndRequestGuardian(); }} - filled={true} + variant={"contained"} > Create burner wallet diff --git a/src/components/burnerWallet/RequestedRecoveries.tsx b/src/components/burnerWallet/RequestedRecoveries.tsx index 93c4520..9213ec1 100644 --- a/src/components/burnerWallet/RequestedRecoveries.tsx +++ b/src/components/burnerWallet/RequestedRecoveries.tsx @@ -3,9 +3,7 @@ import { useCallback, useContext, useEffect, useRef, useState } from "react"; import toast from "react-hot-toast"; import { useNavigate } from "react-router-dom"; import { readContract } from "wagmi/actions"; -import { - universalEmailRecoveryModule, -} from "../../../contracts.base-sepolia.json"; +import { universalEmailRecoveryModule } from "../../../contracts.base-sepolia.json"; import { safeAbi } from "../../abi/Safe"; import { abi as universalEmailRecoveryModuleAbi } from "../../abi/UniversalEmailRecoveryModule.json"; import { StepsContext } from "../../App"; @@ -235,7 +233,11 @@ const RequestedRecoveries = () => { switch (buttonState) { case BUTTON_STATES.TRIGGER_RECOVERY: return ( - ); @@ -244,6 +246,7 @@ const RequestedRecoveries = () => { ); @@ -282,10 +285,11 @@ const RequestedRecoveries = () => { > @@ -370,18 +374,19 @@ const RequestedRecoveries = () => { margin: "auto", }} > -
{getButtonComponent()}
{buttonState === BUTTON_STATES.COMPLETE_RECOVERY ? (
) : null} +
{getButtonComponent()}
diff --git a/src/pages/burnerWalletFlow.tsx b/src/pages/burnerWalletFlow.tsx index 6e946cd..4e4331a 100644 --- a/src/pages/burnerWalletFlow.tsx +++ b/src/pages/burnerWalletFlow.tsx @@ -62,7 +62,6 @@ const BurnerWalletFlow = () => { }; }, []); - const renderBody = () => { switch (stepsContext?.step) { // Step to create a new safe and install the universal email recovery module. This step requires guardian emails before the recovery module can be installed @@ -131,11 +130,13 @@ const BurnerWalletFlow = () => {