diff --git a/src/features/ui/components/pocket-wallet.tsx b/src/features/ui/components/pocket-wallet.tsx new file mode 100644 index 000000000..ddb4b1b44 --- /dev/null +++ b/src/features/ui/components/pocket-wallet.tsx @@ -0,0 +1,85 @@ +import arrowsDiagonalIcon from '@tabler/icons/outline/arrows-diagonal-2.svg'; +import arrowsDiagonalMinimizeIcon from '@tabler/icons/outline/arrows-diagonal-minimize.svg'; +import eyeClosedIcon from '@tabler/icons/outline/eye-closed.svg'; +import eyeIcon from '@tabler/icons/outline/eye.svg'; +import walletIcon from '@tabler/icons/outline/wallet.svg'; +import { useEffect, useState } from 'react'; +import { defineMessages, useIntl } from 'react-intl'; + +import Button from 'soapbox/components/ui/button.tsx'; +import HStack from 'soapbox/components/ui/hstack.tsx'; +import Icon from 'soapbox/components/ui/icon.tsx'; +import Stack from 'soapbox/components/ui/stack.tsx'; +import Text from 'soapbox/components/ui/text.tsx'; +import Balance from 'soapbox/features/wallet/components/balance.tsx'; +import { useWallet } from 'soapbox/features/zap/hooks/useHooks.ts'; + +const messages = defineMessages({ + wallet: { id: 'wallet.title', defaultMessage: 'Wallet' }, + balance: { id: 'wallet.sats', defaultMessage: '{amount} sats' }, + withdraw: { id: 'wallet.button.withdraw', defaultMessage: 'Withdraw' }, + mint: { id: 'wallet.button.mint', defaultMessage: 'Mint' }, +}); + +const PocketWallet = () => { + const intl = useIntl(); + const { wallet } = useWallet(); + + const [expanded, setExpanded] = useState(false); + const [eyeClosed, setEyeClosed] = useState(() => { + const storedData = localStorage.getItem('soapbox:wallet:eye'); + return storedData ? JSON.parse(storedData) : false; + }); + + useEffect(() => { + localStorage.setItem('soapbox:wallet:eye', JSON.stringify(eyeClosed)); + }, [eyeClosed]); + + return ( + + + + + + {intl.formatMessage(messages.wallet)} + + + + + {!expanded && <> + { eyeClosed ? + + + + + + + + + : + {intl.formatMessage(messages.balance, { amount: wallet?.balance })} + } + + + } + + + + + + + + {expanded && + + } + + + ); + +}; + +export default PocketWallet; \ No newline at end of file diff --git a/src/features/ui/util/async-components.ts b/src/features/ui/util/async-components.ts index 280a9c57e..1db53d6a1 100644 --- a/src/features/ui/util/async-components.ts +++ b/src/features/ui/util/async-components.ts @@ -186,4 +186,5 @@ export const WalletMints = lazy(() => import('soapbox/features/wallet/components export const WalletTransactions = lazy(() => import('soapbox/features/wallet/components/wallet-transactions.tsx')); export const StreakModal = lazy(() => import('soapbox/features/ui/components/modals/streak-modal.tsx')); export const FollowsTimeline = lazy(() => import('soapbox/features/home-timeline/follows-timeline.tsx')); -export const CommunityTimeline = lazy(() => import('soapbox/features/home-timeline/community-timeline.tsx')); \ No newline at end of file +export const CommunityTimeline = lazy(() => import('soapbox/features/home-timeline/community-timeline.tsx')); +export const PocketWallet = lazy(() => import('soapbox/features/ui/components/pocket-wallet.tsx')); \ No newline at end of file diff --git a/src/features/wallet/index.tsx b/src/features/wallet/index.tsx index b3b14badc..5648c5c61 100644 --- a/src/features/wallet/index.tsx +++ b/src/features/wallet/index.tsx @@ -69,7 +69,7 @@ const Wallet = () => { - + {hasTransactions &&