Skip to content

Commit

Permalink
fix: close ledger sheet in request keys flow
Browse files Browse the repository at this point in the history
  • Loading branch information
alter-eggo committed Dec 18, 2024
1 parent e618ccf commit ed39244
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useNavigate } from 'react-router-dom';

import { styled } from 'leather-styles/jsx';
import { HStack, styled } from 'leather-styles/jsx';

import type { Blockchain } from '@leather.io/models';
import { Button, LedgerIcon } from '@leather.io/ui';
Expand All @@ -27,16 +27,11 @@ export function ConnectLedgerButton({ chain }: ConnectLedgerButtonProps) {
};

return (
<Button
display="flex"
alignItems="center"
variant="outline"
size="sm"
gap="space.02"
onClick={onClick}
>
<LedgerIcon />
<styled.span textStyle="label.02">Connect&nbsp;{capitalize(chain)}</styled.span>
<Button variant="outline" size="sm" onClick={onClick}>
<HStack gap="space.02">
<LedgerIcon />
<styled.span textStyle="label.02">Connect&nbsp;{capitalize(chain)}</styled.span>
</HStack>
</Button>
);
}
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
import { Outlet } from 'react-router-dom';
import { Outlet, useNavigate } from 'react-router-dom';

import { Sheet, SheetHeader } from '@leather.io/ui';

import { RouteUrls } from '@shared/route-urls';

import { useScrollLock } from '@app/common/hooks/use-scroll-lock';

import { useLedgerNavigate } from '../../hooks/use-ledger-navigate';
import { LedgerRequestKeysContext, LedgerRequestKeysProvider } from './ledger-request-keys.context';

interface RequestKeysFlowProps {
context: LedgerRequestKeysContext;
isActionCancellableByUser: boolean;
}
export function RequestKeysFlow({ context, isActionCancellableByUser }: RequestKeysFlowProps) {
const ledgerNavigate = useLedgerNavigate();
useScrollLock(true);

const onCancelConnectLedger = ledgerNavigate.cancelLedgerAction;
const navigate = useNavigate();

return (
<LedgerRequestKeysProvider value={context}>
<Sheet
isShowing
header={<SheetHeader />}
onClose={isActionCancellableByUser ? onCancelConnectLedger : undefined}
onClose={isActionCancellableByUser ? () => navigate(RouteUrls.Home) : undefined}
>
<Outlet />
</Sheet>
Expand Down

0 comments on commit ed39244

Please sign in to comment.