Skip to content

Commit

Permalink
chore: cleanup LedgerConnectionStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
0xKheops committed Dec 20, 2024
1 parent e5cb227 commit 1bb49c0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ export const ConnectLedgerEthereum: FC<{

return (
<ConnectLedgerBase
isReadyCheck={isReadyCheck}
appName="Ethereum"
onReadyChanged={onReadyChanged}
className={className}
isReadyCheck={isReadyCheck}
onReadyChanged={onReadyChanged}
/>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ export const ConnectLedgerSubstrateGeneric: FC<{

return (
<ConnectLedgerBase
isReadyCheck={isReadyCheck}
appName={legacyAppName ? "Polkadot Migration" : "Polkadot"}
onReadyChanged={onReadyChanged}
className={className}
isReadyCheck={isReadyCheck}
onReadyChanged={onReadyChanged}
/>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ export const ConnectLedgerSubstrateLegacy: FC<{

return (
<ConnectLedgerBase
isReadyCheck={isReadyCheck}
appName={app?.name ?? "Unknown App"}
onReadyChanged={onReadyChanged}
className={className}
isReadyCheck={isReadyCheck}
onReadyChanged={onReadyChanged}
/>
)
}
30 changes: 2 additions & 28 deletions apps/extension/src/ui/domains/Account/LedgerConnectionStatus.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { CheckCircleIcon, LoaderIcon, XCircleIcon } from "@talismn/icons"
import { classNames } from "@talismn/util"
import { FC, ReactNode, useEffect, useState } from "react"
import { useTranslation } from "react-i18next"

import { LedgerStatus } from "@ui/hooks/ledger/common"
Expand Down Expand Up @@ -32,47 +31,22 @@ const wrapStrong = (text: string) => {
})
}

const Container: FC<{ className?: string; onClick?: () => void; children?: ReactNode }> = ({
className,
onClick,
children,
}) => {
if (onClick)
return (
<button type="button" onClick={onClick} className={className}>
{children}
</button>
)
else return <div className={className}>{children}</div>
}

// TODO cleanup unused properties
export const LedgerConnectionStatus = ({
status,
message,
requiresManualRetry,
hideOnSuccess = false,
className,
onRetryClick,
}: LedgerConnectionStatusProps) => {
const { t } = useTranslation()
const [hide, setHide] = useState<boolean>(false)

useEffect(() => {
if (status === "ready" && hideOnSuccess) setTimeout(() => setHide(true), 1000)
}, [status, hideOnSuccess])

if (!status || status === "unknown") return null

return (
<Container
<div
className={classNames(
"text-body-secondary bg-grey-850 flex h-28 w-full items-center gap-4 rounded-sm p-8",
hide && "invisible",
requiresManualRetry && "hover:bg-grey-800",
className,
)}
onClick={requiresManualRetry ? onRetryClick : undefined}
>
{status === "ready" && (
<CheckCircleIcon className="text-alert-success min-w-[1em] shrink-0 text-[2rem]" />
Expand All @@ -96,6 +70,6 @@ export const LedgerConnectionStatus = ({
{t("Retry")}
</button>
)}
</Container>
</div>
)
}

0 comments on commit 1bb49c0

Please sign in to comment.