diff --git a/pages/settings/wallets/index.js b/pages/settings/wallets/index.js index a8330c83..95e9a6eb 100644 --- a/pages/settings/wallets/index.js +++ b/pages/settings/wallets/index.js @@ -7,6 +7,11 @@ import { useCallback, useState } from 'react' import { useIsClient } from '@/components/use-client' import WalletCard from '@/components/wallet-card' import { useToast } from '@/components/toast' +import BootstrapForm from 'react-bootstrap/Form' +import RecvIcon from '@/svgs/arrow-left-down-line.svg' +import SendIcon from '@/svgs/arrow-right-up-line.svg' +import { useRouter } from 'next/router' +import { supportsReceive, supportsSend } from '@/wallets/common' export const getServerSideProps = getGetServerSideProps({ authRequired: true }) @@ -17,6 +22,12 @@ export default function Wallet ({ ssrData }) { const [sourceIndex, setSourceIndex] = useState(null) const [targetIndex, setTargetIndex] = useState(null) + const router = useRouter() + const [filter, setFilter] = useState({ + send: router.query.send === 'true', + receive: router.query.receive === 'true' + }) + const reorder = useCallback(async (sourceIndex, targetIndex) => { const newOrder = [...wallets.filter(w => w.config?.enabled)] const [source] = newOrder.splice(sourceIndex, 1) @@ -65,6 +76,13 @@ export default function Wallet ({ ssrData }) { } }, [sourceIndex, reorder, onReorderError]) + const onFilterChange = useCallback((key) => { + return e => { + setFilter(old => ({ ...old, [key]: e.target.checked })) + router.replace({ query: { ...router.query, [key]: e.target.checked } }, undefined, { shallow: true }) + } + }, [router]) + return (
@@ -76,33 +94,52 @@ export default function Wallet ({ ssrData }) {
- {wallets.map((w, i) => { - const draggable = isClient && w.config?.enabled +
+ receive} + onChange={onFilterChange('receive')} + checked={filter.receive} + /> + send} + onChange={onFilterChange('send')} + checked={filter.send} + /> +
+ {wallets + .filter(w => { + return (!filter.send || (filter.send && supportsSend(w))) && + (!filter.receive || (filter.receive && supportsReceive(w))) + }) + .map((w, i) => { + const draggable = isClient && w.config?.enabled - return ( -
- -
- ) - } - )} + suppressHydrationWarning + > + +
+ ) + } + )} diff --git a/styles/wallet.module.css b/styles/wallet.module.css index f968297f..a4c28752 100644 --- a/styles/wallet.module.css +++ b/styles/wallet.module.css @@ -1,10 +1,34 @@ .walletGrid { display: grid; - grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); + grid-template-columns: repeat(auto-fill, 160px); grid-gap: 20px; - justify-items: center; - align-items: center; - margin-top: 3rem; + padding: 20px 0; + justify-content: center; +} + +@media (max-width: 440px) { + .walletGrid { + grid-template-columns: repeat(auto-fill, 140px); + grid-gap: 15px; + } + .card { + width: 140px; + } +} + +@media (max-width: 330px) { + .walletGrid { + grid-template-columns: 100%; + } + .walletGrid > * { + justify-self: center; + } +} + +.walletFilters { + grid-column: 1 / -1; + margin-left: 0.2rem; + user-select: none; } .drag { @@ -17,7 +41,8 @@ .card { width: 160px; - height: 180px; + max-width: 100%; + aspect-ratio: 160 / 180; } .indicators {