Skip to content

Commit 8c0bfe9

Browse files
authored
Refactor wallet guide links into own component (#2621)
1 parent 654af65 commit 8c0bfe9

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

wallets/client/components/form/index.js

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@ import CancelButton from '@/components/cancel-button'
88
import Text from '@/components/text'
99
import Info from '@/components/info'
1010
import { useFormState, useMaxSteps, useNext, useStepIndex } from '@/components/multi-step-form'
11-
import { isTemplate, isWallet, protocolDisplayName, protocolFormId, protocolLogName, walletGuideUrl, walletLud16Domain } from '@/wallets/lib/util'
12-
import { WalletLayout, WalletLayoutHeader, WalletLayoutImageOrName, WalletLogs } from '@/wallets/client/components'
11+
import { isTemplate, isWallet, protocolDisplayName, protocolFormId, protocolLogName, walletLud16Domain } from '@/wallets/lib/util'
12+
import { WalletGuide, WalletLayout, WalletLayoutHeader, WalletLayoutImageOrName, WalletLogs } from '@/wallets/client/components'
1313
import { TemplateLogsProvider, useTestSendPayment, useWalletLogger, useTestCreateInvoice, useWalletSupport } from '@/wallets/client/hooks'
1414
import ArrowRight from '@/svgs/arrow-right-s-fill.svg'
15-
import InfoIcon from '@/svgs/information-fill.svg'
16-
import Link from 'next/link'
1715
import { useFormikContext } from 'formik'
1816

1917
import { WalletMultiStepFormContextProvider, Step, useWallet, useWalletProtocols, useProtocol, useProtocolForm } from './hooks'
@@ -40,20 +38,13 @@ export function WalletMultiStepForm ({ wallet }) {
4038
].filter(Boolean),
4139
[support])
4240

43-
const guideUrl = walletGuideUrl(wallet.name)
44-
4541
return (
4642
<WalletLayout>
4743
<div className={styles.form}>
4844
<WalletLayoutHeader>
4945
<WalletLayoutImageOrName name={wallet.name} maxHeight='80px' />
5046
</WalletLayoutHeader>
51-
{guideUrl && (
52-
<Link href={guideUrl} className='text-center text-reset fw-bold text-underline' target='_blank' rel='noreferrer'>
53-
<InfoIcon width={18} height={18} className='mx-1' />
54-
guide
55-
</Link>
56-
)}
47+
<WalletGuide name={wallet.name} />
5748
<WalletMultiStepFormContextProvider wallet={wallet} initial={initial} steps={steps}>
5849
{steps.map(step => {
5950
// WalletForm is aware of the current step via hooks

wallets/client/components/layout.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import Layout from '@/components/layout'
22
import { useWalletImage } from '@/wallets/client/hooks'
3-
import { walletDisplayName } from '@/wallets/lib/util'
3+
import { walletDisplayName, walletGuideUrl } from '@/wallets/lib/util'
44
import Link from 'next/link'
5+
import InfoIcon from '@/svgs/information-fill.svg'
56

67
export function WalletLayout ({ children }) {
78
// TODO(wallet-v2): py-5 doesn't work, I think it gets overriden by the layout class
@@ -56,3 +57,15 @@ export function WalletLayoutImageOrName ({ name, maxHeight = '50px' }) {
5657
</div>
5758
)
5859
}
60+
61+
export function WalletGuide ({ name }) {
62+
const guideUrl = walletGuideUrl(name)
63+
if (!guideUrl) return null
64+
65+
return (
66+
<Link href={guideUrl} className='text-center text-reset fw-bold text-underline' target='_blank' rel='noreferrer'>
67+
<InfoIcon width={18} height={18} className='mx-1' />
68+
guide
69+
</Link>
70+
)
71+
}

0 commit comments

Comments
 (0)