-
-
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
23 changed files
with
784 additions
and
333 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
packages/components/src/components/HotkeyBadge/HotkeyBadge.stories.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,20 @@ | ||
import { Meta, StoryObj } from '@storybook/react'; | ||
import { HotkeyBadge as HotkeyBadgeComponent, HotkeyBadgeProps } from './HotkeyBadge'; | ||
|
||
const meta: Meta = { | ||
title: 'Form/HotkeyBadge', | ||
component: HotkeyBadgeComponent, | ||
} as Meta; | ||
export default meta; | ||
|
||
const Component = ({ children, ...args }: HotkeyBadgeProps) => { | ||
return <HotkeyBadgeComponent {...args}>{children}</HotkeyBadgeComponent>; | ||
}; | ||
|
||
export const HotkeyBadge: StoryObj<HotkeyBadgeProps> = { | ||
render: Component, | ||
args: { | ||
children: 'CMD + P', | ||
isActive: true, | ||
}, | ||
}; |
56 changes: 56 additions & 0 deletions
56
packages/components/src/components/HotkeyBadge/HotkeyBadge.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,56 @@ | ||
import { | ||
Elevation, | ||
borders, | ||
mapElevationToBackground, | ||
spacingsPx, | ||
typography, | ||
} from '@trezor/theme'; | ||
import styled from 'styled-components'; | ||
import { ElevationDown, useElevation } from '../ElevationContext/ElevationContext'; | ||
|
||
export const Container = styled.div<{ $elevation: Elevation; $isActive: boolean }>` | ||
display: flex; | ||
gap: ${spacingsPx.xxs}; | ||
align-items: center; | ||
justify-content: center; | ||
background: ${mapElevationToBackground}; | ||
border-radius: ${borders.radii.xs}; | ||
color: ${({ theme }) => theme.textSubdued}; | ||
opacity: ${({ $isActive }) => ($isActive ? 1 : 0.5)}; | ||
user-select: none; | ||
padding: 0 ${spacingsPx.xxs}; | ||
${typography.label} | ||
position: relative; | ||
`; | ||
|
||
export interface HotkeyBadgeProps { | ||
isActive?: boolean; | ||
children: string; | ||
} | ||
const Component = ({ isActive = true, children }: HotkeyBadgeProps) => { | ||
const { elevation } = useElevation(); | ||
console.log('______elevation', elevation); | ||
|
||
const isMac = navigator.userAgent.includes('Macintosh'); | ||
|
||
const split = children.split(/(\+)/g).map(x => x.trim()); | ||
const hotkeyReplaces: Record<string, string> = { | ||
MOD: isMac ? '⌘' : 'CTRL', | ||
}; | ||
|
||
return ( | ||
<Container $elevation={elevation} $isActive={isActive}> | ||
{split.map(hotkey => ( | ||
<span>{hotkeyReplaces[hotkey] || hotkey}</span> | ||
))} | ||
</Container> | ||
); | ||
}; | ||
|
||
export const HotkeyBadge = (props: HotkeyBadgeProps) => { | ||
return ( | ||
<ElevationDown> | ||
<Component {...props} /> | ||
</ElevationDown> | ||
); | ||
}; |
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
19 changes: 18 additions & 1 deletion
19
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,26 @@ | ||
import { createDeviceInstance, selectDevice } from '@suite-common/wallet-core'; | ||
import { useEvent } from 'react-use'; | ||
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 Print dialog | ||
} | ||
}); | ||
}; |
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.