dark/light mode images on wallet pages
This commit is contained in:
parent
f3cc0f9e1d
commit
66ec5d5da8
@ -13,11 +13,12 @@ import { canReceive, canSend, isConfigured } from '@/wallets/common'
|
|||||||
import { SSR } from '@/lib/constants'
|
import { SSR } from '@/lib/constants'
|
||||||
import WalletButtonBar from '@/components/wallet-buttonbar'
|
import WalletButtonBar from '@/components/wallet-buttonbar'
|
||||||
import { useWalletConfigurator } from '@/wallets/config'
|
import { useWalletConfigurator } from '@/wallets/config'
|
||||||
import { useCallback, useMemo } from 'react'
|
import { useCallback, useEffect, useMemo, useState } from 'react'
|
||||||
import { useMe } from '@/components/me'
|
import { useMe } from '@/components/me'
|
||||||
import validateWallet from '@/wallets/validate'
|
import validateWallet from '@/wallets/validate'
|
||||||
import { ValidationError } from 'yup'
|
import { ValidationError } from 'yup'
|
||||||
import { useFormikContext } from 'formik'
|
import { useFormikContext } from 'formik'
|
||||||
|
import useDarkMode from '@/components/dark-mode'
|
||||||
|
|
||||||
export const getServerSideProps = getGetServerSideProps({ authRequired: true })
|
export const getServerSideProps = getGetServerSideProps({ authRequired: true })
|
||||||
|
|
||||||
@ -28,6 +29,8 @@ export default function WalletSettings () {
|
|||||||
const wallet = useWallet(name)
|
const wallet = useWallet(name)
|
||||||
const { me } = useMe()
|
const { me } = useMe()
|
||||||
const { save, detach } = useWalletConfigurator(wallet)
|
const { save, detach } = useWalletConfigurator(wallet)
|
||||||
|
const [dark] = useDarkMode()
|
||||||
|
const [imgSrc, setImgSrc] = useState(wallet?.def.card?.image?.src)
|
||||||
|
|
||||||
const initial = useMemo(() => {
|
const initial = useMemo(() => {
|
||||||
const initial = wallet?.def.fields.reduce((acc, field) => {
|
const initial = wallet?.def.fields.reduce((acc, field) => {
|
||||||
@ -69,12 +72,16 @@ export default function WalletSettings () {
|
|||||||
|
|
||||||
const { card: { image, title, subtitle } } = wallet?.def || { card: {} }
|
const { card: { image, title, subtitle } } = wallet?.def || { card: {} }
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!imgSrc) return
|
||||||
|
// wallet.png <-> wallet-dark.png
|
||||||
|
setImgSrc(dark ? image?.src.replace(/\.([a-z]{3})$/, '-dark.$1') : image?.src)
|
||||||
|
}, [dark])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CenterLayout>
|
<CenterLayout>
|
||||||
{image
|
{image
|
||||||
? typeof image === 'object'
|
? <img alt={title} {...image} src={imgSrc} className='pb-3 px-2 mw-100' />
|
||||||
? <img {...image} alt={title} className='pb-2' />
|
|
||||||
: <img src={image} width='33%' alt={title} className='pb-2' />
|
|
||||||
: <h2 className='pb-2'>{title}</h2>}
|
: <h2 className='pb-2'>{title}</h2>}
|
||||||
<h6 className='text-muted text-center pb-3'><Text>{subtitle}</Text></h6>
|
<h6 className='text-muted text-center pb-3'><Text>{subtitle}</Text></h6>
|
||||||
<Form
|
<Form
|
||||||
|
Loading…
x
Reference in New Issue
Block a user