-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #199 from lidofinance/feature/si-1594-ledger-hid-c…
…onnection-via-low-speed-internet Feature/si 1594 ledger hid connection via low speed internet
- Loading branch information
Showing
12 changed files
with
192 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 30 additions & 32 deletions
62
packages/connect-wallet-modal/src/components/Ledger/LedgerConnectionScreen.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,36 @@ | ||
import React from 'react'; | ||
import { | ||
Loader, | ||
Stack, | ||
StackItem, | ||
Text, | ||
useBreakpoint, | ||
} from '@lidofinance/lido-ui'; | ||
import { LedgerImageDefault } from './icons/LedgerImageDefault'; | ||
import { LedgerImageDefaultMobile } from './icons/LedgerImageDefaultMobile'; | ||
import { LedgerScreenContainerStyled } from './styles'; | ||
import React, { FC } from 'react'; | ||
import { Loader } from '@lidofinance/lido-ui'; | ||
import { useLedgerContext } from './hooks'; | ||
import { LedgerModalScreen } from './LedgerModalScreen'; | ||
import { LedgerImageDefaultAdaptive } from './icons/LedgerImageDefaultAdaptive'; | ||
import { LedgerScreenLoadingContainer } from './styles'; | ||
|
||
export const LedgerConnectionScreen = () => { | ||
type LedgerConnectionScreenProps = { | ||
showConnectButton?: boolean; | ||
onClickConnect?: () => void; | ||
}; | ||
|
||
export const LedgerConnectionScreen: FC<LedgerConnectionScreenProps> = ({ | ||
showConnectButton, | ||
onClickConnect, | ||
}) => { | ||
const { isLoadingLedgerLibs } = useLedgerContext(); | ||
|
||
const message = isLoadingLedgerLibs ? ( | ||
<LedgerScreenLoadingContainer> | ||
<Loader size="medium" color="secondary" /> | ||
<div>Loading connector...</div> | ||
</LedgerScreenLoadingContainer> | ||
) : ( | ||
'Please connect your Ledger and launch Ethereum app on your device' | ||
); | ||
|
||
return ( | ||
<LedgerScreenContainerStyled> | ||
<Stack direction="column" spacing="xl" align="center"> | ||
<StackItem> | ||
{useBreakpoint('md') ? ( | ||
<LedgerImageDefaultMobile /> | ||
) : ( | ||
<LedgerImageDefault /> | ||
)} | ||
</StackItem> | ||
<StackItem> | ||
{isLoadingLedgerLibs ? ( | ||
<Loader size="medium" color="secondary" /> | ||
) : ( | ||
<Text color="secondary" size="xs"> | ||
Please connect your Ledger and launch Ethereum app on your device | ||
</Text> | ||
)} | ||
</StackItem> | ||
</Stack> | ||
</LedgerScreenContainerStyled> | ||
<LedgerModalScreen | ||
icon={<LedgerImageDefaultAdaptive />} | ||
message={message} | ||
action={showConnectButton ? 'Connect' : undefined} | ||
onClickAction={showConnectButton ? onClickConnect : undefined} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 15 additions & 44 deletions
59
packages/connect-wallet-modal/src/components/Ledger/LedgerErrorScreen.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,21 @@ | ||
import React, { FC } from 'react'; | ||
import { | ||
Text, | ||
Button, | ||
Stack, | ||
StackItem, | ||
useBreakpoint, | ||
} from '@lidofinance/lido-ui'; | ||
import styled from '@reef-knot/ui-react/styled-wrapper'; | ||
import { LedgerScreenContainerStyled } from './styles'; | ||
import { LedgerImageError } from './icons/LedgerImageError'; | ||
import { LedgerImageErrorMobile } from './icons/LedgerImageErrorMobile'; | ||
import { LedgerModalScreen } from './LedgerModalScreen'; | ||
import { LedgerImageErrorAdaptive } from './icons/LedgerImageErrorAdaptive'; | ||
|
||
const HeadingStyled = styled(Text)` | ||
padding-bottom: 4px; | ||
`; | ||
type LedgerErrorScreenProps = { | ||
message: React.ReactNode; | ||
onClickRetry: () => void; | ||
}; | ||
|
||
export const LedgerErrorScreen: FC<{ message: string; retry: () => void }> = ({ | ||
export const LedgerErrorScreen: FC<LedgerErrorScreenProps> = ({ | ||
message, | ||
retry, | ||
onClickRetry, | ||
}) => ( | ||
<LedgerScreenContainerStyled> | ||
<Stack direction="column" spacing="xl" align="stretch"> | ||
<StackItem> | ||
<Stack direction="column" spacing="xl" align="center"> | ||
<StackItem> | ||
{useBreakpoint('md') ? ( | ||
<LedgerImageErrorMobile /> | ||
) : ( | ||
<LedgerImageError /> | ||
)} | ||
</StackItem> | ||
<StackItem> | ||
<HeadingStyled color="default" size="sm" strong> | ||
Something went wrong | ||
</HeadingStyled> | ||
<Text color="secondary" size="xs"> | ||
{message} | ||
</Text> | ||
</StackItem> | ||
</Stack> | ||
</StackItem> | ||
<StackItem> | ||
<Button variant="ghost" fullwidth onClick={retry}> | ||
Retry | ||
</Button> | ||
</StackItem> | ||
</Stack> | ||
</LedgerScreenContainerStyled> | ||
<LedgerModalScreen | ||
icon={<LedgerImageErrorAdaptive />} | ||
heading="Something went wrong" | ||
message={message} | ||
action="Retry" | ||
onClickAction={onClickRetry} | ||
/> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
packages/connect-wallet-modal/src/components/Ledger/LedgerModalScreen.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import React, { FC } from 'react'; | ||
import { Text, Button, Stack, StackItem } from '@lidofinance/lido-ui'; | ||
import styled from '@reef-knot/ui-react/styled-wrapper'; | ||
import { LedgerScreenContainerStyled } from './styles'; | ||
|
||
const HeadingStyled = styled(Text)` | ||
padding-bottom: 4px; | ||
`; | ||
|
||
type LedgerActionScreenProps = { | ||
icon: React.ReactNode; | ||
heading?: React.ReactNode; | ||
message?: React.ReactNode; | ||
action?: React.ReactNode; | ||
onClickAction?: () => void; | ||
}; | ||
|
||
export const LedgerModalScreen: FC<LedgerActionScreenProps> = ({ | ||
icon, | ||
heading, | ||
message, | ||
action, | ||
onClickAction, | ||
}) => ( | ||
<LedgerScreenContainerStyled> | ||
<Stack direction="column" spacing="xl" align="stretch"> | ||
<StackItem> | ||
<Stack direction="column" spacing="xl" align="center"> | ||
<StackItem>{icon}</StackItem> | ||
<StackItem> | ||
{heading && ( | ||
<HeadingStyled color="default" size="sm" strong> | ||
{heading} | ||
</HeadingStyled> | ||
)} | ||
{message && ( | ||
<Text color="secondary" size="xs"> | ||
{message} | ||
</Text> | ||
)} | ||
</StackItem> | ||
</Stack> | ||
</StackItem> | ||
{action && ( | ||
<StackItem> | ||
<Button variant="ghost" fullwidth onClick={onClickAction}> | ||
{action} | ||
</Button> | ||
</StackItem> | ||
)} | ||
</Stack> | ||
</LedgerScreenContainerStyled> | ||
); |
12 changes: 12 additions & 0 deletions
12
packages/connect-wallet-modal/src/components/Ledger/icons/LedgerImageDefaultAdaptive.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import React from 'react'; | ||
import { useBreakpoint } from '@lidofinance/lido-ui'; | ||
import { LedgerImageDefault } from './LedgerImageDefault'; | ||
import { LedgerImageDefaultMobile } from './LedgerImageDefaultMobile'; | ||
|
||
export const LedgerImageDefaultAdaptive = () => { | ||
return useBreakpoint('md') ? ( | ||
<LedgerImageDefaultMobile /> | ||
) : ( | ||
<LedgerImageDefault /> | ||
); | ||
}; |
12 changes: 12 additions & 0 deletions
12
packages/connect-wallet-modal/src/components/Ledger/icons/LedgerImageErrorAdaptive.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import React from 'react'; | ||
import { useBreakpoint } from '@lidofinance/lido-ui'; | ||
import { LedgerImageError } from './LedgerImageError'; | ||
import { LedgerImageErrorMobile } from './LedgerImageErrorMobile'; | ||
|
||
export const LedgerImageErrorAdaptive = () => { | ||
return useBreakpoint('md') ? ( | ||
<LedgerImageErrorMobile /> | ||
) : ( | ||
<LedgerImageError /> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.