-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: more refined ui flow for extension wallets (#3039)
- Loading branch information
1 parent
cc16ee0
commit 4a1ab16
Showing
6 changed files
with
160 additions
and
89 deletions.
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
src/renderer/features/extension-wallet/components/DropdownOptions.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,79 @@ | ||
import { useUnit } from 'effector-react'; | ||
import { type ReactNode } from 'react'; | ||
|
||
import { WalletType } from '@/shared/core'; | ||
import { useI18n } from '@/shared/i18n'; | ||
import { nonNullable, nullable } from '@/shared/lib/utils'; | ||
import { Icon } from '@/shared/ui'; | ||
import { Dropdown, Label } from '@/shared/ui-kit'; | ||
import { walletIcon } from '../constants'; | ||
import { wallets } from '../model/wallets'; | ||
|
||
import { PairingModal } from './PairingModal'; | ||
|
||
export const DropdownOptions = () => { | ||
const { t } = useI18n(); | ||
const polkadotjsExtension = useUnit(wallets.$polkadotJsExtensionWallet); | ||
const talismanExtension = useUnit(wallets.$talismanExtensionWallet); | ||
const subWalletExtension = useUnit(wallets.$subWalletExtensionWallet); | ||
|
||
const installed: ReactNode[] = []; | ||
const notInstalled: ReactNode[] = []; | ||
|
||
const polkadotOption = ( | ||
<PairingModal extension="polkadot-js" title={t('onboarding.extension.polkadotJsTitle')}> | ||
<Dropdown.Item disabled={nullable(polkadotjsExtension)}> | ||
<Icon name={walletIcon[WalletType.POLKADOT_EXTENSION].icon} size={20} /> | ||
{t('wallets.addPolkadotExtension')} | ||
{nonNullable(polkadotjsExtension) && <Label variant="blue">{t('onboarding.extension.beta')}</Label>} | ||
</Dropdown.Item> | ||
</PairingModal> | ||
); | ||
|
||
const talismanOption = ( | ||
<PairingModal extension="talisman" title={t('onboarding.extension.talismanTitle')}> | ||
<Dropdown.Item disabled={nullable(talismanExtension)}> | ||
<Icon name={walletIcon[WalletType.TALISMAN_EXTENSION].icon} size={20} /> | ||
{t('wallets.addTalismanExtension')} | ||
{nonNullable(talismanExtension) && <Label variant="blue">{t('onboarding.extension.beta')}</Label>} | ||
</Dropdown.Item> | ||
</PairingModal> | ||
); | ||
|
||
const subwallet = ( | ||
<PairingModal extension="subwallet-js" title={t('onboarding.extension.subWalletTitle')}> | ||
<Dropdown.Item disabled={nullable(subWalletExtension)}> | ||
<Icon name={walletIcon[WalletType.SUBWALLET_EXTENSION].icon} size={20} /> | ||
{t('wallets.addSubWalletExtension')} | ||
{nonNullable(subWalletExtension) && <Label variant="blue">{t('onboarding.extension.beta')}</Label>} | ||
</Dropdown.Item> | ||
</PairingModal> | ||
); | ||
|
||
if (nonNullable(polkadotjsExtension)) { | ||
installed.push(polkadotOption); | ||
} else { | ||
notInstalled.push(polkadotOption); | ||
} | ||
|
||
if (nonNullable(talismanExtension)) { | ||
installed.push(talismanOption); | ||
} else { | ||
notInstalled.push(talismanOption); | ||
} | ||
|
||
if (nonNullable(subWalletExtension)) { | ||
installed.push(subwallet); | ||
} else { | ||
notInstalled.push(subwallet); | ||
} | ||
|
||
return ( | ||
<> | ||
{installed} | ||
{notInstalled.length > 0 && ( | ||
<Dropdown.Group label={t('onboarding.extensionNotInstalled')}>{notInstalled}</Dropdown.Group> | ||
)} | ||
</> | ||
); | ||
}; |
56 changes: 56 additions & 0 deletions
56
src/renderer/features/extension-wallet/components/OnboardingCards.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 { useUnit } from 'effector-react'; | ||
|
||
import { TEST_IDS } from '@/shared/constants'; | ||
import { WalletType } from '@/shared/core'; | ||
import { useI18n } from '@/shared/i18n'; | ||
import { nonNullable, nullable } from '@/shared/lib/utils'; | ||
import { WalletOnboardingCard } from '@/shared/ui-entities'; | ||
import { walletIcon } from '../constants'; | ||
import { wallets } from '../model/wallets'; | ||
|
||
import { PairingModal } from './PairingModal'; | ||
|
||
export const OnboardingCards = () => { | ||
const { t } = useI18n(); | ||
const polkadotjsExtension = useUnit(wallets.$polkadotJsExtensionWallet); | ||
const talismanExtension = useUnit(wallets.$talismanExtensionWallet); | ||
const subWalletExtension = useUnit(wallets.$subWalletExtensionWallet); | ||
|
||
return ( | ||
<> | ||
<PairingModal extension="polkadot-js" title={t('onboarding.extension.polkadotJsTitle')}> | ||
<WalletOnboardingCard | ||
beta={nonNullable(polkadotjsExtension)} | ||
disabled={nullable(polkadotjsExtension)} | ||
notInstalled={nullable(polkadotjsExtension)} | ||
title={t('onboarding.welcome.polkadotExtensionTitle')} | ||
description={t('onboarding.welcome.polkadotExtensionDescription')} | ||
iconName={walletIcon[WalletType.POLKADOT_EXTENSION].onboarding} | ||
testId={TEST_IDS.ONBOARDING.POLKADOT_EXTENSION_BUTTON} | ||
/> | ||
</PairingModal> | ||
<PairingModal extension="talisman" title={t('onboarding.extension.talismanTitle')}> | ||
<WalletOnboardingCard | ||
beta={nonNullable(talismanExtension)} | ||
disabled={nullable(talismanExtension)} | ||
notInstalled={nullable(talismanExtension)} | ||
title={t('onboarding.welcome.talismanTitle')} | ||
description={t('onboarding.welcome.talismanDescription')} | ||
iconName={walletIcon[WalletType.TALISMAN_EXTENSION].onboarding} | ||
testId={TEST_IDS.ONBOARDING.TALISMAN_BUTTON} | ||
/> | ||
</PairingModal> | ||
<PairingModal extension="subwallet-js" title={t('onboarding.extension.subWalletTitle')}> | ||
<WalletOnboardingCard | ||
beta={nonNullable(subWalletExtension)} | ||
disabled={nullable(subWalletExtension)} | ||
notInstalled={nullable(subWalletExtension)} | ||
title={t('onboarding.welcome.subWalletTitle')} | ||
description={t('onboarding.welcome.subWalletDescription')} | ||
iconName={walletIcon[WalletType.SUBWALLET_EXTENSION].onboarding} | ||
testId={TEST_IDS.ONBOARDING.SUBWALLET_BUTTON} | ||
/> | ||
</PairingModal> | ||
</> | ||
); | ||
}; |
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
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