From 4214598fce39f8859775eeefa7846733a6c756b0 Mon Sep 17 00:00:00 2001 From: Fara Woolf Date: Mon, 12 Feb 2024 11:44:22 -0600 Subject: [PATCH] feat: callout, closes #4311 --- src/app/components/error-label.tsx | 1 + .../fees-row/components/fees-row.layout.tsx | 8 ++- src/app/components/info-label.tsx | 28 --------- src/app/components/warning-label.tsx | 32 ---------- .../requesting-tab-closed-error-msg.tsx | 6 +- .../components/ledger-inline-warnings.tsx | 14 ++--- .../connect-ledger-error.layout.tsx | 15 ++--- .../connect-device/connect-ledger-error.tsx | 4 +- .../psbt-request-sighash-warning-label.tsx | 6 +- ...trieve-taproot-to-native-segwit.layout.tsx | 6 +- .../post-condition-mode-warning.tsx | 6 +- ...bitcoin-contract-request-warning-label.tsx | 11 ++-- .../components/testnet-btc-message.tsx | 15 ----- .../form/brc-20/brc20-send-form.tsx | 6 +- .../form/btc/btc-send-form.tsx | 14 +++-- .../form/send-form-confirmation.tsx | 6 +- .../send/sent-summary/brc20-sent-summary.tsx | 7 +-- .../ui/components/callout/callout.stories.tsx | 53 ++++++++++++++++ src/app/ui/components/callout/callout.tsx | 61 +++++++++++++++++++ .../ui/components/callout/callout.utils.tsx | 16 +++++ 20 files changed, 186 insertions(+), 129 deletions(-) delete mode 100644 src/app/components/info-label.tsx delete mode 100644 src/app/components/warning-label.tsx delete mode 100644 src/app/pages/send/send-crypto-asset-form/family/bitcoin/components/testnet-btc-message.tsx create mode 100644 src/app/ui/components/callout/callout.stories.tsx create mode 100644 src/app/ui/components/callout/callout.tsx create mode 100644 src/app/ui/components/callout/callout.utils.tsx diff --git a/src/app/components/error-label.tsx b/src/app/components/error-label.tsx index 8fbd86607f7..00a6537d05f 100644 --- a/src/app/components/error-label.tsx +++ b/src/app/components/error-label.tsx @@ -8,6 +8,7 @@ export function ErrorLabel({ children, ...rest }: FlagProps) { spacing="space.02" color="red.action-primary-default" textStyle="body.02" + textAlign="left" {...rest} > {children} diff --git a/src/app/components/fees-row/components/fees-row.layout.tsx b/src/app/components/fees-row/components/fees-row.layout.tsx index cacf4d43019..48524ed7e17 100644 --- a/src/app/components/fees-row/components/fees-row.layout.tsx +++ b/src/app/components/fees-row/components/fees-row.layout.tsx @@ -3,7 +3,7 @@ import { HStack, HstackProps, styled } from 'leather-styles/jsx'; import { openInNewTab } from '@app/common/utils/open-in-new-tab'; import { SponsoredLabel } from '@app/components/sponsored-label'; -import { WarningLabel } from '@app/components/warning-label'; +import { Callout } from '@app/ui/components/callout/callout'; import { BasicTooltip } from '@app/ui/components/tooltip/basic-tooltip'; import { InfoCircleIcon } from '@app/ui/icons/info-circle-icon'; @@ -42,7 +42,11 @@ export function FeesRowLayout(props: FeesRowLayoutProps) { {feeField} {isSponsored && } - {!meta.error && fieldWarning && {fieldWarning}} + {!meta.error && fieldWarning && ( + + {fieldWarning} + + )} ); } diff --git a/src/app/components/info-label.tsx b/src/app/components/info-label.tsx deleted file mode 100644 index 42ae1a6b2ea..00000000000 --- a/src/app/components/info-label.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import { ReactNode } from 'react'; - -import { Flex, FlexProps, Stack, styled } from 'leather-styles/jsx'; - -interface InfoLabelProps extends FlexProps { - children: ReactNode; - title: string; -} -export function InfoLabel({ children, title, ...rest }: InfoLabelProps) { - return ( - - - {title} - {children} - - - ); -} diff --git a/src/app/components/warning-label.tsx b/src/app/components/warning-label.tsx deleted file mode 100644 index 4f9752c07fa..00000000000 --- a/src/app/components/warning-label.tsx +++ /dev/null @@ -1,32 +0,0 @@ -import { Box, BoxProps, styled } from 'leather-styles/jsx'; - -import { Flag } from '@app/ui/components/flag/flag'; -import { ErrorCircleIcon } from '@app/ui/icons/error-circle-icon'; - -interface WarningLabelProps extends BoxProps { - title?: string; -} -export function WarningLabel({ children, title, ...props }: WarningLabelProps) { - return ( - - } - minHeight="48px" - px="space.04" - py="space.03" - width="100%" - > - {title && ( - - {title} - - )} - - {children} - - - - ); -} diff --git a/src/app/features/errors/requesting-tab-closed-error-msg.tsx b/src/app/features/errors/requesting-tab-closed-error-msg.tsx index 75dca4c32d3..94683a542ac 100644 --- a/src/app/features/errors/requesting-tab-closed-error-msg.tsx +++ b/src/app/features/errors/requesting-tab-closed-error-msg.tsx @@ -1,7 +1,7 @@ import { useState } from 'react'; -import { WarningLabel } from '@app/components/warning-label'; import { useOnOriginTabClose } from '@app/routes/hooks/use-on-tab-closed'; +import { Callout } from '@app/ui/components/callout/callout'; export function RequestingTabClosedWarningMessage() { const [hasTabClosed, setHasTabClosed] = useState(false); @@ -14,8 +14,8 @@ export function RequestingTabClosedWarningMessage() { if (!hasTabClosed) return null; return ( - + The window making this request closed, but you can still broadcast the transaction - + ); } diff --git a/src/app/features/ledger/components/ledger-inline-warnings.tsx b/src/app/features/ledger/components/ledger-inline-warnings.tsx index 26716404138..a728d6629bb 100644 --- a/src/app/features/ledger/components/ledger-inline-warnings.tsx +++ b/src/app/features/ledger/components/ledger-inline-warnings.tsx @@ -2,7 +2,7 @@ import { styled } from 'leather-styles/jsx'; import { SupportedBlockchains } from '@shared/constants'; -import { WarningLabel } from '@app/components/warning-label'; +import { Callout } from '@app/ui/components/callout/callout'; import { Capitalize } from '@app/ui/utils/capitalize'; import { LatestDeviceResponse } from '../utils/generic-ledger-utils'; @@ -19,30 +19,30 @@ interface CommonLedgerInlineWarningsProps extends RequiresChainProp { function OutdatedLedgerAppWarning({ chain }: RequiresChainProp) { return ( - + Latest version of {chain} app required Update on Ledger Live to continue - + ); } function LedgerDeviceLockedWarning({ chain }: RequiresChainProp) { return ( - + Your Ledger is locked. Unlock it and open the {''} {chain} {''} app to continue. - + ); } function LedgerAppClosedWarning({ chain }: RequiresChainProp) { return ( - + The {chain} app appears to be closed on Ledger. Open it to continue. - + ); } diff --git a/src/app/features/ledger/generic-steps/connect-device/connect-ledger-error.layout.tsx b/src/app/features/ledger/generic-steps/connect-device/connect-ledger-error.layout.tsx index a98b2805cb7..870f03076bb 100644 --- a/src/app/features/ledger/generic-steps/connect-device/connect-ledger-error.layout.tsx +++ b/src/app/features/ledger/generic-steps/connect-device/connect-ledger-error.layout.tsx @@ -1,9 +1,8 @@ import { Box, Flex, HStack, Stack, styled } from 'leather-styles/jsx'; -import { ErrorLabel } from '@app/components/error-label'; -import { WarningLabel } from '@app/components/warning-label'; import { ConnectLedgerErr } from '@app/features/ledger/illustrations/ledger-illu-connect-ledger-error'; import { Button } from '@app/ui/components/button/button'; +import { Callout } from '@app/ui/components/callout/callout'; import { Link } from '@app/ui/components/link/link'; import { CircleIcon } from '@app/ui/icons/circle-icon'; @@ -40,13 +39,11 @@ export function ConnectLedgerErrorLayout(props: ConnectLedgerErrorLayoutProps) { We're unable to connect to your Ledger device - {warningText ? ( - - {warningText} - - ) : ( - Unable to connect - )} + + + {warningText ? warningText : 'Unable to connect'} + + diff --git a/src/app/features/ledger/generic-steps/connect-device/connect-ledger-error.tsx b/src/app/features/ledger/generic-steps/connect-device/connect-ledger-error.tsx index 60f98360e79..d9e4849ecb1 100644 --- a/src/app/features/ledger/generic-steps/connect-device/connect-ledger-error.tsx +++ b/src/app/features/ledger/generic-steps/connect-device/connect-ledger-error.tsx @@ -11,8 +11,8 @@ export function ConnectLedgerError() { const latestLedgerError = useLatestLedgerError(); const ledgerNavigate = useLedgerNavigate(); const chain = useLocationState('chain'); - // TODO: here it would be better to use - // the actual app name from LEDGER_APPS_MAP at src/app/features/ledger/utils/generic-ledger-utils.ts + // TODO: here it would be better to use the actual app name from + // LEDGER_APPS_MAP at src/app/features/ledger/utils/generic-ledger-utils.ts const appName = capitalize(chain); return ( diff --git a/src/app/features/psbt-signer/components/psbt-request-sighash-warning-label.tsx b/src/app/features/psbt-signer/components/psbt-request-sighash-warning-label.tsx index 9eb16180a6a..1ff560f6ed9 100644 --- a/src/app/features/psbt-signer/components/psbt-request-sighash-warning-label.tsx +++ b/src/app/features/psbt-signer/components/psbt-request-sighash-warning-label.tsx @@ -1,13 +1,13 @@ -import { WarningLabel } from '@app/components/warning-label'; +import { Callout } from '@app/ui/components/callout/callout'; interface PsbtRequestSighashWarningLabelProps { origin: string; } export function PsbtRequestSighashWarningLabel({ origin }: PsbtRequestSighashWarningLabelProps) { return ( - + The details of this transaction are not guaranteed and could be modified later. Continue only if you trust {origin} - + ); } diff --git a/src/app/features/retrieve-taproot-to-native-segwit/components/retrieve-taproot-to-native-segwit.layout.tsx b/src/app/features/retrieve-taproot-to-native-segwit/components/retrieve-taproot-to-native-segwit.layout.tsx index ede7bd817c5..cbc08026ac3 100644 --- a/src/app/features/retrieve-taproot-to-native-segwit/components/retrieve-taproot-to-native-segwit.layout.tsx +++ b/src/app/features/retrieve-taproot-to-native-segwit/components/retrieve-taproot-to-native-segwit.layout.tsx @@ -1,9 +1,9 @@ import { Flex, styled } from 'leather-styles/jsx'; import { BaseDrawer } from '@app/components/drawer/base-drawer'; -import { WarningLabel } from '@app/components/warning-label'; import { BtcIcon } from '@app/ui/components/avatar-icon/btc-icon'; import { Button } from '@app/ui/components/button/button'; +import { Callout } from '@app/ui/components/callout/callout'; interface RetrieveTaprootToNativeSegwitLayoutProps { isBroadcasting: boolean; @@ -34,11 +34,11 @@ export function RetrieveTaprootToNativeSegwitLayout( This transaction may take upwards of 30 minutes to confirm. {children} - + We recommend you check the URL for each "Uninscribed UTXO" listed above to ensure it displays no inscription. If it does display one, do not proceed with retrieval or you may lose it! - +