From 65ca387f60d0e9cbbdc7f0599e3c56ea0964c8be Mon Sep 17 00:00:00 2001 From: Kieran O'Neill Date: Tue, 27 Aug 2024 11:42:07 +0100 Subject: [PATCH] feat: pre release UI updates (#290) * refactor: rename password lock to credential lock * refactor: decrease size of network badges * refactor: add border radius to network select container * refactor: reposition account page header and fix broken scroll in tab containers * feat: add tab bar control component and use in asset and activity tabs * chore: squash * refactor: replace edit name with edit account and a new edit account modal * refactor: update select modal styles * chore: squash * refactor: remove pills from network select and use concise select * chore: squash * refactor: update inputs to have full border radius * chore: squash * refactor: use new password hook and update new password component to be more dumb * refactor: add amount input and address input hooks and update send asset modal --- .../ARC0300AccountImportModalContent.tsx | 4 +- .../ARC0300AssetAddModalContent.tsx | 6 +- ...egistrationTransactionSendModalContent.tsx | 2 + .../components/AccountItem/AccountItem.tsx | 1 + .../AccountSelect/AccountSelect.tsx | 101 ++++-- .../AccountSelect}/AccountSelectModal.tsx | 32 +- .../components/AccountSelect/index.ts | 2 + .../components/AccountSelect/types/IProps.ts | 8 +- .../types/TAccountSelectModalProps.ts | 21 ++ .../components/AccountSelect/types/index.ts | 1 + .../components/ActivityTab/ActivityTab.tsx | 28 +- .../components/ActivityTab/types/IProps.ts | 3 +- .../components/AddressInput/AddressInput.tsx | 114 +++--- .../components/AddressInput/types/IProps.ts | 21 -- .../components/AddressInput/types/TProps.ts | 23 ++ .../components/AddressInput/types/index.ts | 2 +- .../components/AmountInput/AmountInput.tsx | 141 +++----- .../AmountInput/types/IOnEventOptions.ts | 9 + .../components/AmountInput/types/IProps.ts | 12 +- .../components/AmountInput/types/index.ts | 1 + .../components/AssetSelect/AssetSelect.tsx | 100 +++-- .../AssetSelect}/AssetSelectModal.tsx | 26 +- .../components/AssetSelect/types/IProps.ts | 3 +- .../types/TAssetSelectModalProps.ts} | 9 +- .../components/AssetSelect/types/index.ts | 1 + .../components/AssetsTab/AssetsTab.tsx | 123 +++---- .../components/AssetsTab/types/IProps.ts | 4 +- .../components/CreatePasswordInput/index.ts | 2 - .../CreatePasswordInput/utils/index.ts | 1 - .../CreatePasswordInput/utils/validate.ts | 33 -- .../EditableAccountNameField.tsx | 7 +- .../EnterMnemonicPhraseInput/index.ts | 2 - .../components/GenericInput/GenericInput.tsx | 73 +--- .../components/GenericInput/types/IProps.ts | 5 +- .../GenericTextarea/GenericTextarea.tsx | 73 +--- .../GenericTextarea/types/IProps.ts | 5 +- .../components/IconButton/IconButton.tsx | 31 +- .../components/IconButton/types/IProps.ts | 8 + .../IconButton}/types/index.ts | 0 .../KeyRegistrationTransactionModalBody.tsx | 2 +- src/extension/components/Label/Label.tsx | 15 +- .../components/Label/types/IProps.ts | 4 +- .../MoreInformationAccordion.tsx | 11 +- src/extension/components/NFTsTab/NFTsTab.tsx | 3 +- .../NativeBalance/NativeBalance.tsx | 31 +- .../components/NetworkBadge/NetworkBadge.tsx | 5 +- .../NetworkBadge/utils/parseFontSize/index.ts | 1 + .../utils/parseFontSize/parseFontSize.ts | 16 + .../NetworkSelect/NetworkSelect.tsx | 22 +- .../NetworkSelect/NetworkSelectModal.tsx | 96 ++++- .../components/NetworkSelect/types/IProps.ts | 6 +- .../NewPasswordInput.tsx} | 109 ++---- .../components/NewPasswordInput/index.ts | 2 + .../NewPasswordInput/types/IProps.ts | 13 + .../NewPasswordInput}/types/index.ts | 0 .../PasswordInput/PasswordInput.tsx | 77 ++-- .../components/PasswordInput/hooks/index.ts | 1 - .../PasswordInput/hooks/usePassword.ts | 43 --- .../components/PasswordInput/index.ts | 2 - .../components/PasswordInput/types/IProps.ts | 5 +- .../PasswordInput/types/IUsePasswordState.ts | 13 - .../components/PasswordInput/types/index.ts | 1 - .../components/PasswordInput/utils/index.ts | 1 - .../PasswordInput/utils/validate.ts | 17 - .../ReKeyedAccountBadge.tsx | 12 +- .../SeedPhraseInput.tsx} | 90 ++--- .../components/SeedPhraseInput/index.ts | 3 + .../SeedPhraseInput/types/IProps.ts | 11 + .../components/SeedPhraseInput/types/index.ts | 1 + .../utils/index.ts | 0 .../utils/isPhrasesEmpty.ts | 0 .../utils/validate.ts | 5 +- src/extension/components/Select/Select.tsx | 8 +- .../components/Select/SelectModal.tsx | 38 +- .../components/Select/SelectOption.tsx | 2 +- src/extension/components/Select/index.ts | 2 + .../SettingsLinkItem/SettingsLinkItem.tsx | 7 +- .../SettingsSelectItem/SettingsSelectItem.tsx | 4 +- .../SettingsSessionItem.tsx | 6 +- src/extension/components/SideBar/SideBar.tsx | 8 +- .../TabControlBar/TabControlBar.tsx | 77 ++++ .../components/TabControlBar/index.ts | 2 + .../components/TabControlBar/types/IProps.ts | 11 + .../types/ITabControlBarButtonProps.ts | 8 + .../components/TabControlBar/types/index.ts | 2 + .../WatchAccountBadge/WatchAccountBadge.tsx | 12 +- src/extension/constants/Dimensions.ts | 1 + src/extension/constants/Durations.ts | 12 +- .../accounts/thunks/updateAccountsThunk.ts | 1 - src/extension/features/registration/slice.ts | 15 +- .../registration/types/ISetPasswordPayload.ts | 6 - .../features/registration/types/IState.ts | 2 - .../features/registration/types/index.ts | 1 - .../registration/utils/getInitialState.ts | 1 - src/extension/features/send-assets/slice.ts | 54 +-- .../thunks/createUnsignedTransactionsThunk.ts | 86 ++--- .../thunks/submitTransactionThunk.ts | 34 +- .../ICreateUnsignedTransactionsPayload.ts | 7 + .../send-assets/types/IInitializePayload.ts | 13 + .../types/IInitializeSendAssetPayload.ts | 8 - .../features/send-assets/types/IState.ts | 20 +- .../features/send-assets/types/index.ts | 3 +- .../send-assets/utils/getInitialState.ts | 7 +- .../settings/utils/getInitialState.ts | 4 +- src/extension/hooks/useAddressInput/index.ts | 2 + .../hooks/useAddressInput/types/IOptions.ts | 8 + .../hooks/useAddressInput/types/IState.ts | 17 + .../hooks/useAddressInput/types/index.ts | 2 + .../hooks/useAddressInput/useAddressInput.ts | 63 ++++ src/extension/hooks/useAmountInput/index.ts | 2 + .../hooks/useAmountInput/types/IOptions.ts | 6 + .../hooks/useAmountInput/types/IState.ts | 20 + .../hooks/useAmountInput/types/index.ts | 2 + .../hooks/useAmountInput/useAmountInput.ts | 88 +++++ .../hooks/useGenericInput/types/IOptions.ts | 1 + .../hooks/useGenericInput/types/IState.ts | 9 +- .../hooks/useGenericInput/useGenericInput.ts | 48 ++- .../hooks/useNewPasswordInput/index.ts | 2 + .../useNewPasswordInput/types/IOptions.ts | 6 + .../hooks/useNewPasswordInput/types/IState.ts | 21 ++ .../types/IValidateOptions.ts | 6 + .../hooks/useNewPasswordInput/types/index.ts | 3 + .../useNewPasswordInput.ts | 79 ++++ ...yRegistrationTransactionSendEventModal.tsx | 3 + .../modals/AccountSelectModal/index.ts | 2 - .../modals/AccountSelectModal/types/IProps.ts | 12 - .../modals/AddAssetsModal/AddAssetsModal.tsx | 16 +- .../AddCustomNodeModal/AddCustomNodeModal.tsx | 129 ++----- .../modals/AssetSelectModal/index.ts | 2 - .../AuthenticationModal.tsx | 41 ++- .../modals/ConfirmModal/ConfirmModal.tsx | 26 +- .../ConfirmPasswordModal.tsx | 41 ++- .../EditAccountModal/EditAccountModal.tsx | 233 ++++++++++++ .../modals/EditAccountModal/index.ts | 2 + .../modals/EditAccountModal/types/IProps.ts | 8 + .../modals/EditAccountModal/types/index.ts | 1 + .../modals/EnableModal/EnableModal.tsx | 2 +- .../ManageSessionModal/ManageSessionModal.tsx | 4 +- .../ReKeyAccountModal/ReKeyAccountModal.tsx | 61 +++- ...egistrationImportAccountViaQRCodeModal.tsx | 3 +- .../RemoveAssetsModal/RemoveAssetsModal.tsx | 3 + .../RemovePasskeyModal/RemovePasskeyModal.tsx | 2 + .../ScanQRCodeModal/ScanQRCodeModal.tsx | 7 +- .../modals/SendAssetModal/SendAssetModal.tsx | 341 ++++++++++-------- .../ShareAddressModal/ShareAddressModal.tsx | 22 +- .../SignMessageModal/SignMessageModal.tsx | 7 +- .../ApplicationTransactionContent.tsx | 2 +- .../AssetConfigTransactionContent.tsx | 2 +- .../AssetCreateTransactionContent.tsx | 2 +- .../AssetFreezeTransactionContent.tsx | 2 +- .../AssetTransferTransactionContent.tsx | 2 +- .../AtomicTransactionsContent.tsx | 2 +- .../GroupOfTransactionsContent.tsx | 2 +- .../PaymentTransactionContent.tsx | 2 +- .../SignTransactionsModal.tsx | 3 +- .../pages/AccountPage/AccountPage.tsx | 130 ++++--- .../AddWatchAccountPage.tsx | 126 ++++--- .../AdvancedSettingsPage.tsx | 9 +- src/extension/pages/AssetPage/AssetPage.tsx | 18 +- .../ChangePasswordPage/ChangePasswordPage.tsx | 62 ++-- .../CreateNewAccountPage.tsx | 55 ++- .../CreatePasswordPage/CreatePasswordPage.tsx | 82 +++-- .../ExportAccountPage/ExportAcountPage.tsx | 9 +- .../pages/GetStartedPage/GetStartedPage.tsx | 10 +- .../ImportAccountViaSeedPhrasePage.tsx | 59 ++- .../SecuritySettingsPage.tsx | 76 ++-- .../ViewSeedPhrasePage/ViewSeedPhrasePage.tsx | 1 + src/extension/selectors/accounts/index.ts | 1 + ...SelectActiveAccountTransactionsUpdating.ts | 25 ++ src/extension/selectors/registration/index.ts | 1 - .../useSelectRegistrationScore.ts | 9 - src/extension/selectors/send-assets/index.ts | 7 +- ...useSelectSendAssetAmountInStandardUnits.ts | 10 - .../send-assets/useSelectSendAssetAsset.ts | 17 + .../useSelectSendAssetFromAccount.ts | 30 -- .../send-assets/useSelectSendAssetNote.ts | 10 - .../useSelectSendAssetSelectedAsset.ts | 13 - .../send-assets/useSelectSendAssetSender.ts | 23 ++ .../useSelectSendAssetToAddress.ts | 10 - .../SettingsService/SettingsService.ts | 4 +- src/extension/translations/en.ts | 49 +-- .../types/components/IPropsWithContext.ts | 5 + src/extension/types/components/index.ts | 1 + .../types/modals/IARC0300ModalContentProps.ts | 6 +- .../validateAddressInput.ts | 4 +- .../utils/validateGenericInput/index.ts | 2 + .../types/IOptions.ts | 2 +- .../types/index.ts | 0 .../validateGenericInput.ts} | 12 +- src/extension/utils/validateInput/index.ts | 2 - .../utils/validateNewPasswordInput/index.ts | 2 + .../types/IOptions.ts | 11 + .../validateNewPasswordInput/types/index.ts | 1 + .../validateNewPasswordInput.ts | 34 ++ 194 files changed, 2595 insertions(+), 1823 deletions(-) rename src/extension/{modals/AccountSelectModal => components/AccountSelect}/AccountSelectModal.tsx (92%) create mode 100644 src/extension/components/AccountSelect/types/TAccountSelectModalProps.ts delete mode 100644 src/extension/components/AddressInput/types/IProps.ts create mode 100644 src/extension/components/AddressInput/types/TProps.ts create mode 100644 src/extension/components/AmountInput/types/IOnEventOptions.ts rename src/extension/{modals/AssetSelectModal => components/AssetSelect}/AssetSelectModal.tsx (92%) rename src/extension/{modals/AssetSelectModal/types/IProps.ts => components/AssetSelect/types/TAssetSelectModalProps.ts} (54%) delete mode 100644 src/extension/components/CreatePasswordInput/index.ts delete mode 100644 src/extension/components/CreatePasswordInput/utils/index.ts delete mode 100644 src/extension/components/CreatePasswordInput/utils/validate.ts delete mode 100644 src/extension/components/EnterMnemonicPhraseInput/index.ts create mode 100644 src/extension/components/IconButton/types/IProps.ts rename src/extension/{modals/AccountSelectModal => components/IconButton}/types/index.ts (100%) create mode 100644 src/extension/components/NetworkBadge/utils/parseFontSize/index.ts create mode 100644 src/extension/components/NetworkBadge/utils/parseFontSize/parseFontSize.ts rename src/extension/components/{CreatePasswordInput/CreatePasswordInput.tsx => NewPasswordInput/NewPasswordInput.tsx} (52%) create mode 100644 src/extension/components/NewPasswordInput/index.ts create mode 100644 src/extension/components/NewPasswordInput/types/IProps.ts rename src/extension/{modals/AssetSelectModal => components/NewPasswordInput}/types/index.ts (100%) delete mode 100644 src/extension/components/PasswordInput/hooks/index.ts delete mode 100644 src/extension/components/PasswordInput/hooks/usePassword.ts delete mode 100644 src/extension/components/PasswordInput/types/IUsePasswordState.ts delete mode 100644 src/extension/components/PasswordInput/utils/index.ts delete mode 100644 src/extension/components/PasswordInput/utils/validate.ts rename src/extension/components/{EnterMnemonicPhraseInput/EnterMnemonicPhraseInput.tsx => SeedPhraseInput/SeedPhraseInput.tsx} (69%) create mode 100644 src/extension/components/SeedPhraseInput/index.ts create mode 100644 src/extension/components/SeedPhraseInput/types/IProps.ts create mode 100644 src/extension/components/SeedPhraseInput/types/index.ts rename src/extension/components/{EnterMnemonicPhraseInput => SeedPhraseInput}/utils/index.ts (100%) rename src/extension/components/{EnterMnemonicPhraseInput => SeedPhraseInput}/utils/isPhrasesEmpty.ts (100%) rename src/extension/components/{EnterMnemonicPhraseInput => SeedPhraseInput}/utils/validate.ts (83%) create mode 100644 src/extension/components/TabControlBar/TabControlBar.tsx create mode 100644 src/extension/components/TabControlBar/index.ts create mode 100644 src/extension/components/TabControlBar/types/IProps.ts create mode 100644 src/extension/components/TabControlBar/types/ITabControlBarButtonProps.ts create mode 100644 src/extension/components/TabControlBar/types/index.ts delete mode 100644 src/extension/features/registration/types/ISetPasswordPayload.ts create mode 100644 src/extension/features/send-assets/types/ICreateUnsignedTransactionsPayload.ts create mode 100644 src/extension/features/send-assets/types/IInitializePayload.ts delete mode 100644 src/extension/features/send-assets/types/IInitializeSendAssetPayload.ts create mode 100644 src/extension/hooks/useAddressInput/index.ts create mode 100644 src/extension/hooks/useAddressInput/types/IOptions.ts create mode 100644 src/extension/hooks/useAddressInput/types/IState.ts create mode 100644 src/extension/hooks/useAddressInput/types/index.ts create mode 100644 src/extension/hooks/useAddressInput/useAddressInput.ts create mode 100644 src/extension/hooks/useAmountInput/index.ts create mode 100644 src/extension/hooks/useAmountInput/types/IOptions.ts create mode 100644 src/extension/hooks/useAmountInput/types/IState.ts create mode 100644 src/extension/hooks/useAmountInput/types/index.ts create mode 100644 src/extension/hooks/useAmountInput/useAmountInput.ts create mode 100644 src/extension/hooks/useNewPasswordInput/index.ts create mode 100644 src/extension/hooks/useNewPasswordInput/types/IOptions.ts create mode 100644 src/extension/hooks/useNewPasswordInput/types/IState.ts create mode 100644 src/extension/hooks/useNewPasswordInput/types/IValidateOptions.ts create mode 100644 src/extension/hooks/useNewPasswordInput/types/index.ts create mode 100644 src/extension/hooks/useNewPasswordInput/useNewPasswordInput.ts delete mode 100644 src/extension/modals/AccountSelectModal/index.ts delete mode 100644 src/extension/modals/AccountSelectModal/types/IProps.ts delete mode 100644 src/extension/modals/AssetSelectModal/index.ts create mode 100644 src/extension/modals/EditAccountModal/EditAccountModal.tsx create mode 100644 src/extension/modals/EditAccountModal/index.ts create mode 100644 src/extension/modals/EditAccountModal/types/IProps.ts create mode 100644 src/extension/modals/EditAccountModal/types/index.ts create mode 100644 src/extension/selectors/accounts/useSelectActiveAccountTransactionsUpdating.ts delete mode 100644 src/extension/selectors/registration/useSelectRegistrationScore.ts delete mode 100644 src/extension/selectors/send-assets/useSelectSendAssetAmountInStandardUnits.ts create mode 100644 src/extension/selectors/send-assets/useSelectSendAssetAsset.ts delete mode 100644 src/extension/selectors/send-assets/useSelectSendAssetFromAccount.ts delete mode 100644 src/extension/selectors/send-assets/useSelectSendAssetNote.ts delete mode 100644 src/extension/selectors/send-assets/useSelectSendAssetSelectedAsset.ts create mode 100644 src/extension/selectors/send-assets/useSelectSendAssetSender.ts delete mode 100644 src/extension/selectors/send-assets/useSelectSendAssetToAddress.ts create mode 100644 src/extension/types/components/IPropsWithContext.ts create mode 100644 src/extension/utils/validateGenericInput/index.ts rename src/extension/utils/{validateInput => validateGenericInput}/types/IOptions.ts (82%) rename src/extension/utils/{validateInput => validateGenericInput}/types/index.ts (100%) rename src/extension/utils/{validateInput/validateInput.ts => validateGenericInput/validateGenericInput.ts} (92%) delete mode 100644 src/extension/utils/validateInput/index.ts create mode 100644 src/extension/utils/validateNewPasswordInput/index.ts create mode 100644 src/extension/utils/validateNewPasswordInput/types/IOptions.ts create mode 100644 src/extension/utils/validateNewPasswordInput/types/index.ts create mode 100644 src/extension/utils/validateNewPasswordInput/validateNewPasswordInput.ts diff --git a/src/extension/components/ARC0300AccountImportModalContent/ARC0300AccountImportModalContent.tsx b/src/extension/components/ARC0300AccountImportModalContent/ARC0300AccountImportModalContent.tsx index df672bbc..3e46c78e 100644 --- a/src/extension/components/ARC0300AccountImportModalContent/ARC0300AccountImportModalContent.tsx +++ b/src/extension/components/ARC0300AccountImportModalContent/ARC0300AccountImportModalContent.tsx @@ -12,12 +12,14 @@ import { } from '@chakra-ui/react'; import React, { FC, useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; +import { IoDownloadOutline } from 'react-icons/io5'; import { useDispatch } from 'react-redux'; import { useNavigate } from 'react-router-dom'; // components import AccountItem from '@extension/components/AccountItem'; import Button from '@extension/components/Button'; +import EmptyState from '@extension/components/EmptyState'; // constants import { @@ -73,7 +75,6 @@ import type { import convertPublicKeyToAVMAddress from '@extension/utils/convertPublicKeyToAVMAddress'; import ellipseAddress from '@extension/utils/ellipseAddress'; import flattenAccountImportSchemaToNewAccounts from '@extension/utils/flattenAccountImportSchemaToNewAccounts'; -import EmptyState from '@extension/components/EmptyState'; const ARC0300AccountImportModalContent: FC< IARC0300ModalContentProps @@ -310,6 +311,7 @@ const ARC0300AccountImportModalContent: FC< diff --git a/src/extension/components/AmountInput/types/IOnEventOptions.ts b/src/extension/components/AmountInput/types/IOnEventOptions.ts new file mode 100644 index 00000000..8622b452 --- /dev/null +++ b/src/extension/components/AmountInput/types/IOnEventOptions.ts @@ -0,0 +1,9 @@ +// types +import type { IAssetTypes, INativeCurrency } from '@extension/types'; + +interface IOnEventOptions { + asset: IAssetTypes | INativeCurrency | null; + maximumAmountInAtomicUnits: string; +} + +export default IOnEventOptions; diff --git a/src/extension/components/AmountInput/types/IProps.ts b/src/extension/components/AmountInput/types/IProps.ts index 05d4eff4..baf955fa 100644 --- a/src/extension/components/AmountInput/types/IProps.ts +++ b/src/extension/components/AmountInput/types/IProps.ts @@ -1,3 +1,5 @@ +import type { NumberInputProps } from '@chakra-ui/react'; + // types import type { IAccountWithExtendedProps, @@ -5,17 +7,17 @@ import type { INativeCurrency, INetworkWithTransactionParams, } from '@extension/types'; +import type IOnEventOptions from './IOnEventOptions'; -interface IProps { +interface IProps extends NumberInputProps { account: IAccountWithExtendedProps; asset: IAssetTypes | INativeCurrency; - disabled?: boolean; id?: string; + label?: string; + maximumAmountInAtomicUnits: string; network: INetworkWithTransactionParams; - maximumTransactionAmount: string; - onChange: (value: string) => void; + onMaximumAmountClick: (options: IOnEventOptions) => void; required?: boolean; - value: string | null; } export default IProps; diff --git a/src/extension/components/AmountInput/types/index.ts b/src/extension/components/AmountInput/types/index.ts index f404deed..efd9c847 100644 --- a/src/extension/components/AmountInput/types/index.ts +++ b/src/extension/components/AmountInput/types/index.ts @@ -1 +1,2 @@ +export type { default as IOnEventOptions } from './IOnEventOptions'; export type { default as IProps } from './IProps'; diff --git a/src/extension/components/AssetSelect/AssetSelect.tsx b/src/extension/components/AssetSelect/AssetSelect.tsx index 102a0c94..1ca02b94 100644 --- a/src/extension/components/AssetSelect/AssetSelect.tsx +++ b/src/extension/components/AssetSelect/AssetSelect.tsx @@ -1,30 +1,43 @@ import { - HStack, + Button as ChakraButton, + Icon, Stack, - Tooltip, useDisclosure, VStack, } from '@chakra-ui/react'; -import React, { FC } from 'react'; +import React, { type FC } from 'react'; import { useTranslation } from 'react-i18next'; -import { GoSingleSelect } from 'react-icons/go'; +import { IoChevronDownOutline } from 'react-icons/io5'; // components import AssetItem from '@extension/components/AssetItem'; -import IconButton from '@extension/components/IconButton'; import Label from '@extension/components/Label'; // constants import { DEFAULT_GAP, INPUT_HEIGHT } from '@extension/constants'; +// hooks +import useBorderColor from '@extension/hooks/useBorderColor'; +import useButtonHoverBackgroundColor from '@extension/hooks/useButtonHoverBackgroundColor'; +import useColorModeValue from '@extension/hooks/useColorModeValue'; +import usePrimaryColor from '@extension/hooks/usePrimaryColor'; +import useSubTextColor from '@extension/hooks/useSubTextColor'; + // modals -import AssetSelectModal from '@extension/modals/AssetSelectModal'; +import AssetSelectModal from './AssetSelectModal'; + +// theme +import { theme } from '@extension/theme'; // types import type { IAssetTypes, INativeCurrency } from '@extension/types'; import type { IProps } from './types'; +// utils +import calculateIconSize from '@extension/utils/calculateIconSize'; + const AssetSelect: FC = ({ + _context, assets, disabled = false, label, @@ -34,57 +47,76 @@ const AssetSelect: FC = ({ value, }) => { const { t } = useTranslation(); + // hooks + const borderColor = useBorderColor(); + const buttonHoverBackgroundColor = useButtonHoverBackgroundColor(); + const primaryColorCode = useColorModeValue( + theme.colors.primaryLight['500'], + theme.colors.primaryDark['500'] + ); + const primaryColor = usePrimaryColor(); + const subTextColor = useSubTextColor(); const { isOpen: isAssetSelectModalOpen, onClose: onAssetSelectClose, onOpen: onAssetSelectModalOpen, } = useDisclosure(); // handlers - const handleAssetClick = () => onAssetSelectModalOpen(); - const handleOnAssetSelect = (_value: (IAssetTypes | INativeCurrency)[]) => + const handleOnClick = () => onAssetSelectModalOpen(); + const handleOnSelect = (_value: (IAssetTypes | INativeCurrency)[]) => onSelect(_value[0]); return ( <> {/*asset select modal*/} {/*label*/} - {label && ); diff --git a/src/extension/modals/AssetSelectModal/AssetSelectModal.tsx b/src/extension/components/AssetSelect/AssetSelectModal.tsx similarity index 92% rename from src/extension/modals/AssetSelectModal/AssetSelectModal.tsx rename to src/extension/components/AssetSelect/AssetSelectModal.tsx index f0d0ea08..a9695a2f 100644 --- a/src/extension/modals/AssetSelectModal/AssetSelectModal.tsx +++ b/src/extension/components/AssetSelect/AssetSelectModal.tsx @@ -15,9 +15,13 @@ import { Tooltip, VStack, } from '@chakra-ui/react'; -import React, { FC, useState } from 'react'; +import React, { type FC, useState } from 'react'; import { useTranslation } from 'react-i18next'; -import { IoChevronForward } from 'react-icons/io5'; +import { + IoCheckmarkDoneCircleOutline, + IoCheckmarkOutline, + IoChevronForward, +} from 'react-icons/io5'; // components import AssetItem from '@extension/components/AssetItem'; @@ -47,12 +51,13 @@ import { theme } from '@extension/theme'; // types import type { IAssetTypes, INativeCurrency } from '@extension/types'; -import type { IProps } from './types'; +import type { TAssetSelectModalProps } from './types'; // utils import calculateIconSize from '@extension/utils/calculateIconSize'; -const AssetSelectModal: FC = ({ +const AssetSelectModal: FC = ({ + _context, assets, isOpen, multiple, @@ -148,11 +153,11 @@ const AssetSelectModal: FC = ({ _hover={{ bg: buttonHoverBackgroundColor, }} - borderRadius={0} + borderRadius="full" fontSize="md" h={TAB_ITEM_HEIGHT} justifyContent="start" - key={`asset-select-modal-item-${index}`} + key={`${_context}-asset-select-modal-item-${index}`} onClick={handleOnChange(asset)} px={DEFAULT_GAP / 2} py={0} @@ -259,8 +264,12 @@ const AssetSelectModal: FC = ({ - {/*content*/} - {renderContent()} + {/*body*/} + + + {renderContent()} + + {/*footer*/} @@ -277,6 +286,7 @@ const AssetSelectModal: FC = ({ {multiple && (