From 5438ba8dc8ffd3adedef6e76b40b0ea6331ff4ea Mon Sep 17 00:00:00 2001 From: Kamil Pyszkowski Date: Thu, 5 Dec 2024 14:51:19 +0100 Subject: [PATCH] Make conection rejected alert status of info --- .../ConnectWalletModal/ConnectWalletAlert.tsx | 29 ++++++++++++++----- .../components/ConnectWalletModal/index.tsx | 4 +-- dapp/src/components/shared/Alert.tsx | 2 +- .../contexts/WalletConnectionAlertContext.tsx | 12 ++------ dapp/src/theme/Alert.ts | 5 ++++ dapp/src/theme/Modal.ts | 10 +++---- 6 files changed, 37 insertions(+), 25 deletions(-) diff --git a/dapp/src/components/ConnectWalletModal/ConnectWalletAlert.tsx b/dapp/src/components/ConnectWalletModal/ConnectWalletAlert.tsx index 553d9ff56..127b7cead 100644 --- a/dapp/src/components/ConnectWalletModal/ConnectWalletAlert.tsx +++ b/dapp/src/components/ConnectWalletModal/ConnectWalletAlert.tsx @@ -1,5 +1,5 @@ import React from "react" -import { Box, Link, VStack } from "@chakra-ui/react" +import { AlertStatus, Box, Link, VStack } from "@chakra-ui/react" import { AnimatePresence, Variants, motion } from "framer-motion" import { EXTERNAL_HREF } from "#/constants" import { @@ -18,6 +18,15 @@ export enum ConnectionAlert { Default = "DEFAULT", } +type ConnectionAlerts = Record< + ConnectionAlert, + { + title: string + description?: React.ReactNode + status?: AlertStatus + } +> + function ContactSupport() { return ( @@ -36,10 +45,10 @@ function ContactSupport() { ) } -const CONNECTION_ALERTS = { +const CONNECTION_ALERTS: ConnectionAlerts = { [ConnectionAlert.Rejected]: { - title: "Wallet connection rejected.", - description: "If you encountered an error, please try again.", + title: "Please connect your wallet to start using Acre", + status: "info", }, [ConnectionAlert.NotSupported]: { title: "Not supported.", @@ -66,10 +75,12 @@ const collapseVariants: Variants = { expanded: { height: "auto" }, } -type ConnectWalletAlertProps = AlertProps & { type?: ConnectionAlert } +type ConnectWalletAlertProps = Omit & { + type?: ConnectionAlert +} export default function ConnectWalletAlert(props: ConnectWalletAlertProps) { - const { type, status, ...restProps } = props + const { type, ...restProps } = props const data = type ? CONNECTION_ALERTS[type] : undefined @@ -85,11 +96,13 @@ export default function ConnectWalletAlert(props: ConnectWalletAlertProps) { overflow="hidden" w="full" > - + {data.title} - {data.description} + {data.description && ( + {data.description} + )} diff --git a/dapp/src/components/ConnectWalletModal/index.tsx b/dapp/src/components/ConnectWalletModal/index.tsx index 1653d1e11..23404c9b9 100644 --- a/dapp/src/components/ConnectWalletModal/index.tsx +++ b/dapp/src/components/ConnectWalletModal/index.tsx @@ -30,7 +30,7 @@ export function ConnectWalletModalBase({ })) const [selectedConnectorId, setSelectedConnectorId] = useState() - const { type, status, resetConnectionAlert } = useWalletConnectionAlert() + const { type, resetConnectionAlert } = useWalletConnectionAlert() const isSignedMessage = useIsSignedMessage() const handleButtonOnClick = (connector: OrangeKitConnector) => { @@ -59,7 +59,7 @@ export function ConnectWalletModalBase({ {`Select your ${isEmbed ? "account" : "wallet"}`} - + {enabledConnectors.map((connector) => ( void + setConnectionAlert: (type: ConnectionAlert) => void resetConnectionAlert: () => void } @@ -20,17 +18,14 @@ export function WalletConnectionAlertContextProvider({ children: React.ReactNode }): React.ReactElement { const [type, setType] = useState() - const [status, setStatus] = useState("error") const resetConnectionAlert = useCallback(() => { setType(undefined) - setStatus("error") }, [setType]) const setConnectionAlert = useCallback( - (connectionAlert: ConnectionAlert, alertStatus: AlertStatus = "error") => { + (connectionAlert: ConnectionAlert) => { setType(connectionAlert) - setStatus(alertStatus) }, [setType], ) @@ -39,11 +34,10 @@ export function WalletConnectionAlertContextProvider({ useMemo( () => ({ type, - status, setConnectionAlert, resetConnectionAlert, }), - [resetConnectionAlert, setConnectionAlert, status, type], + [resetConnectionAlert, setConnectionAlert, type], ) return ( diff --git a/dapp/src/theme/Alert.ts b/dapp/src/theme/Alert.ts index 005dbb32f..905c63e97 100644 --- a/dapp/src/theme/Alert.ts +++ b/dapp/src/theme/Alert.ts @@ -15,6 +15,11 @@ const baseStyle = multiStyleConfig.definePartsStyle({ p: 4, rounded: "xl", }, + title: { + fontWeight: "semibold", + mr: 0, + }, + description: { fontWeight: "medium", textAlign: "start", diff --git a/dapp/src/theme/Modal.ts b/dapp/src/theme/Modal.ts index bab2047b2..31c36fd29 100644 --- a/dapp/src/theme/Modal.ts +++ b/dapp/src/theme/Modal.ts @@ -38,8 +38,8 @@ const baseStyleHeader = defineStyle({ fontSize: "xl", lineHeight: "xl", fontWeight: "bold", - pt: { sm: 10 }, - px: { sm: 10 }, + pt: { sm: 8 }, + px: { sm: 8 }, pb: 8, }) @@ -51,15 +51,15 @@ const baseStyleBody = defineStyle({ alignItems: "center", gap: 6, pt: 0, - px: { base: 0, sm: 10 }, - pb: { base: 0, sm: 10 }, + px: { base: 0, sm: 8 }, + pb: { base: 0, sm: 8 }, }) const baseStyleFooter = defineStyle({ flexDirection: "column", gap: 6, px: { base: 0, sm: 8 }, - pb: { base: 0, sm: 10 }, + pb: { base: 0, sm: 8 }, }) const multiStyleConfig = createMultiStyleConfigHelpers(parts.keys)