From 090ae4455c4d9da27c4b97a2377b4f6389d19124 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?U=C4=9Fur=20Eren?= Date: Wed, 2 Oct 2024 11:19:38 +0300 Subject: [PATCH] feat: Account selection modal --- .../components/SelectAccountModal/index.tsx | 68 +++++++++++++++++++ client/src/hooks/useModal.ts | 2 + client/src/pages/Swap.tsx | 8 ++- client/src/state/application.ts | 1 + client/src/theme/components/icons.tsx | 20 ++++++ 5 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 client/src/components/SelectAccountModal/index.tsx diff --git a/client/src/components/SelectAccountModal/index.tsx b/client/src/components/SelectAccountModal/index.tsx new file mode 100644 index 0000000..7d3a98b --- /dev/null +++ b/client/src/components/SelectAccountModal/index.tsx @@ -0,0 +1,68 @@ +import { useCloseModal, useSelectAccountModal } from 'src/hooks/useModal' +import { ThemedText } from 'src/theme/components' +import { RevolutLogo, VenmoLogo } from 'src/theme/components/icons' +import styled from 'styled-components' + +import { PrimaryButton } from '../Button' +import { Column, Row } from '../Flex' +import Content from '../Modal/Content' +import Overlay from '../Modal/Overlay' +import Portal from '../Portal' + +const AccountButtons = styled(Column)` + width: 100%; +` + +const StyledAccountModal = styled(Row)` + width: 100%; + justify-content: space-between; + padding: 16px; + background-color: ${({ theme }) => theme.bg3}; + color: ${({ theme }) => theme.neutral1}; + border: none; + border-radius: 12px; + cursor: pointer; +` + +interface AccountButtonProps extends React.ButtonHTMLAttributes { + Logo: React.FC> + name: string + currencies: string[] +} + +const AccountButton = ({ Logo, name, currencies, ...props }: AccountButtonProps) => { + return ( + + + + + {name} + + + {currencies.join(', ')} + + ) +} + +export default function SelectAccountModal() { + // modal + const [isOpen] = useSelectAccountModal() + const close = useCloseModal() + + if (!isOpen) return null + + return ( + + + + + + + + Register new account + + + + + ) +} diff --git a/client/src/hooks/useModal.ts b/client/src/hooks/useModal.ts index ef3eb37..5bbe47e 100644 --- a/client/src/hooks/useModal.ts +++ b/client/src/hooks/useModal.ts @@ -27,3 +27,5 @@ export const useWalletConnectModal = () => useModal(ModalType.WALLET_CONNECT) export const useWalletOverviewModal = () => useModal(ModalType.WALLET_OVERVIEW) export const useProofGenerationModal = () => useModal(ModalType.PROOF_GENERATION) + +export const useSelectAccountModal = () => useModal(ModalType.SELECT_ACCOUNT) diff --git a/client/src/pages/Swap.tsx b/client/src/pages/Swap.tsx index fe07039..5a741b9 100644 --- a/client/src/pages/Swap.tsx +++ b/client/src/pages/Swap.tsx @@ -4,7 +4,9 @@ import { ChipButton } from 'src/components/ChipButton' import { CurrencyButton } from 'src/components/CurrencyButton' import { Column, Row } from 'src/components/Flex' import { CurrencyInput } from 'src/components/Input' +import SelectAccountModal from 'src/components/SelectAccountModal' import { FIAT_CURRENCIES, TOKEN_CURRENCIES } from 'src/constants/currencies' +import { useSelectAccountModal } from 'src/hooks/useModal' import { ThemedText } from 'src/theme/components' import { ChevronDown } from 'src/theme/components/icons' import { styled } from 'styled-components' @@ -79,6 +81,8 @@ export default function SwapPage() { const [inputSendValue, setInputSendValue] = useState('') const [inputReceiveValue, setInputReceiveValue] = useState('') + const [, toggleSelectAccountModal] = useSelectAccountModal() + const handleReceiveChange = (event: ChangeEvent) => { const inputValue = event.target.value const numericValue = inputValue.replace(/[^0-9]/g, '') @@ -129,7 +133,7 @@ export default function SwapPage() { From - + Select account @@ -138,6 +142,8 @@ export default function SwapPage() { Enter amount + + ) } diff --git a/client/src/state/application.ts b/client/src/state/application.ts index 73c8d98..2886889 100644 --- a/client/src/state/application.ts +++ b/client/src/state/application.ts @@ -6,6 +6,7 @@ export enum ModalType { WALLET_CONNECT, WALLET_OVERVIEW, PROOF_GENERATION, + SELECT_ACCOUNT, } export type ApplicationSlice = State & Actions diff --git a/client/src/theme/components/icons.tsx b/client/src/theme/components/icons.tsx index 93f9ae0..ea4304d 100644 --- a/client/src/theme/components/icons.tsx +++ b/client/src/theme/components/icons.tsx @@ -149,3 +149,23 @@ export const LockClosed = (props: SVGProps) => ( /> ) + +export const RevolutLogo = (props: SVGProps) => ( + + + +) + +export const VenmoLogo = (props: SVGProps) => ( + + + +)