-
-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
1,250 additions
and
598 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
packages/components/src/components/Passphrase/EnterOnTrezorButton.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,47 @@ | ||
import { FormattedMessage } from 'react-intl'; | ||
import styled from 'styled-components'; | ||
import { Image } from '../Image/Image'; | ||
import { DeviceModelInternal } from '@trezor/connect'; | ||
import { Card } from '../Card/Card'; | ||
import { Icon } from '../assets/Icon/Icon'; | ||
import { spacingsPx } from '@trezor/theme'; | ||
|
||
const Row = styled.div` | ||
display: flex; | ||
gap: ${spacingsPx.xs}; | ||
align-items: center; | ||
justify-content: space-between; | ||
`; | ||
|
||
interface EnterOnTrezorButtonProps { | ||
submit: (value: string, passphraseOnDevice?: boolean) => void; | ||
isVisible: boolean; | ||
value: string; | ||
deviceModel?: DeviceModelInternal; | ||
} | ||
|
||
export const EnterOnTrezorButton = ({ | ||
submit, | ||
isVisible, | ||
value, | ||
deviceModel, | ||
}: EnterOnTrezorButtonProps) => { | ||
if (!isVisible) return null; | ||
|
||
return ( | ||
<Card | ||
paddingType="small" | ||
onClick={() => submit(value, true)} | ||
data-test="@passphrase/enter-on-device-button" | ||
> | ||
<Row> | ||
{deviceModel && <Image alt="Trezor" image={`TREZOR_${deviceModel}`} height={34} />} | ||
<FormattedMessage | ||
id="TR_ENTER_PASSPHRASE_ON_DEVICE" | ||
defaultMessage="Enter passphrase on Trezor" | ||
/> | ||
<Icon icon="ARROW_RIGHT" /> | ||
</Row> | ||
</Card> | ||
); | ||
}; |
325 changes: 164 additions & 161 deletions
325
packages/components/src/components/Passphrase/PassphraseTypeCard.tsx
Large diffs are not rendered by default.
Oops, something went wrong.
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
38 changes: 28 additions & 10 deletions
38
packages/components/src/components/typography/Heading/Heading.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,17 +1,35 @@ | ||
import styled from 'styled-components'; | ||
|
||
import { typography } from '@trezor/theme'; | ||
import { TypographyStyle, typography } from '@trezor/theme'; | ||
import { FrameProps, TransientFrameProps, withFrameProps } from '../../common/frameProps'; | ||
import { makePropsTransient } from '../../../utils/transientProps'; | ||
|
||
const H1 = styled.h1` | ||
${typography.titleLarge}; | ||
`; | ||
type HeadingProps = TransientFrameProps & { | ||
children: string; | ||
$typographyStyle: TypographyStyle; | ||
}; | ||
|
||
const H2 = styled.h2` | ||
${typography.titleMedium}; | ||
`; | ||
const Heading = styled.h1<HeadingProps>` | ||
${({ $typographyStyle }) => typography[$typographyStyle]}; | ||
const H3 = styled.h3` | ||
${typography.titleSmall}; | ||
${withFrameProps} | ||
`; | ||
|
||
export { H1, H2, H3 }; | ||
type HProps = FrameProps & { | ||
children: React.ReactNode; | ||
}; | ||
|
||
export const H1 = ({ margin, ...props }: HProps) => ( | ||
<Heading as="h1" {...makePropsTransient({ margin })} $typographyStyle="titleLarge" {...props} /> | ||
); | ||
export const H2 = ({ margin, ...props }: HProps) => ( | ||
<Heading | ||
as="h2" | ||
{...makePropsTransient({ margin })} | ||
$typographyStyle="titleMedium" | ||
{...props} | ||
/> | ||
); | ||
export const H3 = ({ margin, ...props }: HProps) => ( | ||
<Heading as="h3" {...makePropsTransient({ margin })} $typographyStyle="titleSmall" {...props} /> | ||
); |
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
32 changes: 31 additions & 1 deletion
32
packages/suite/src/components/suite/layouts/SuiteLayout/utils.ts
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,9 +1,39 @@ | ||
import { createDeviceInstance, selectDevice } from '@suite-common/wallet-core'; | ||
import { useEvent } from 'react-use'; | ||
import { goto } from 'src/actions/suite/routerActions'; | ||
import { useCustomBackends } from 'src/hooks/settings/backends'; | ||
import { useSelector } from 'src/hooks/suite'; | ||
import { useDispatch, useSelector } from 'src/hooks/suite'; | ||
|
||
export const useEnabledBackends = () => { | ||
const enabledNetworks = useSelector(state => state.wallet.settings.enabledNetworks); | ||
const customBackends = useCustomBackends(); | ||
|
||
return customBackends.filter(backend => enabledNetworks.includes(backend.coin)); | ||
}; | ||
|
||
export const useAppShortcuts = () => { | ||
const device = useSelector(selectDevice); | ||
const dispatch = useDispatch(); | ||
|
||
useEvent('keydown', e => { | ||
const modKey = e.metaKey; // CMD or Ctrl key | ||
|
||
// press CMD + P to show PassphraseModal | ||
if (modKey && e.key === 'p' && device) { | ||
dispatch(createDeviceInstance({ device })); | ||
e.preventDefault(); // prevent default behaviour | ||
} | ||
|
||
// press CMD + D to show SwitchDevice | ||
if (modKey && e.key === 'd' && device) { | ||
dispatch( | ||
goto('suite-switch-device', { | ||
params: { | ||
cancelable: true, | ||
}, | ||
}), | ||
); | ||
e.preventDefault(); // prevent default behaviour | ||
} | ||
}); | ||
}; |
43 changes: 27 additions & 16 deletions
43
packages/suite/src/components/suite/modals/ModalSwitcher/DiscoveryLoader.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,26 +1,37 @@ | ||
import styled from 'styled-components'; | ||
import { Spinner } from '@trezor/components'; | ||
import { Translation, Modal } from 'src/components/suite'; | ||
import { H3, Spinner, Text } from '@trezor/components'; | ||
import { Translation } from 'src/components/suite'; | ||
import { CardWithDevice } from 'src/views/suite/SwitchDevice/CardWithDevice'; | ||
import { SwitchDeviceRenderer } from 'src/views/suite/SwitchDevice/SwitchDeviceRenderer'; | ||
import { useSelector } from 'src/hooks/suite'; | ||
import { selectDevice } from '@suite-common/wallet-core'; | ||
|
||
const Expand = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
width: 100%; | ||
justify-content: center; | ||
align-items: center; | ||
margin: 40px 0; | ||
`; | ||
|
||
const StyledModal = styled(Modal)` | ||
width: 360px; | ||
`; | ||
export const DiscoveryLoader = () => { | ||
const device = useSelector(selectDevice); | ||
if (!device) return null; | ||
|
||
export const DiscoveryLoader = () => ( | ||
<StyledModal | ||
heading={<Translation id="TR_COIN_DISCOVERY_IN_PROGRESS" />} | ||
description={<Translation id="TR_TO_FIND_YOUR_ACCOUNTS_AND" />} | ||
data-test="@discovery/loader" | ||
> | ||
<Expand> | ||
<Spinner size={80} isGrey={false} /> | ||
</Expand> | ||
</StyledModal> | ||
); | ||
return ( | ||
<SwitchDeviceRenderer isCancelable={false} data-test="@discovery/loader"> | ||
<CardWithDevice device={device}> | ||
<Expand> | ||
<Spinner size={80} isGrey={false} /> | ||
<H3> | ||
<Translation id="TR_COIN_DISCOVERY_IN_PROGRESS" /> | ||
</H3> | ||
<Text color="textSubdued"> | ||
<Translation id="TR_TO_FIND_YOUR_ACCOUNTS_AND" /> | ||
</Text> | ||
</Expand> | ||
</CardWithDevice> | ||
</SwitchDeviceRenderer> | ||
); | ||
}; |
26 changes: 26 additions & 0 deletions
26
packages/suite/src/components/suite/modals/ModalSwitcher/DiscoveryLoaderLegacy.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,26 @@ | ||
import styled from 'styled-components'; | ||
import { Spinner } from '@trezor/components'; | ||
import { Translation, Modal } from 'src/components/suite'; | ||
|
||
const Expand = styled.div` | ||
display: flex; | ||
width: 100%; | ||
justify-content: center; | ||
margin: 40px 0; | ||
`; | ||
|
||
const StyledModal = styled(Modal)` | ||
width: 360px; | ||
`; | ||
|
||
export const DiscoveryLoaderLegacy = () => ( | ||
<StyledModal | ||
heading={<Translation id="TR_COIN_DISCOVERY_IN_PROGRESS" />} | ||
description={<Translation id="TR_TO_FIND_YOUR_ACCOUNTS_AND" />} | ||
data-test="@discovery/loader" | ||
> | ||
<Expand> | ||
<Spinner size={80} isGrey={false} /> | ||
</Expand> | ||
</StyledModal> | ||
); |
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.