Skip to content

Commit 78d1eae

Browse files
committed
Fix qs builder issues
1 parent 6bf78f6 commit 78d1eae

File tree

24 files changed

+375
-82
lines changed

24 files changed

+375
-82
lines changed

src/pages/quickstart/NavigationOverlay/NavigationFlow.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,19 @@ import Button from '@site/src/components/elements/buttons/button'
88
import SvgStar from '@site/static/img/icons/star.svg'
99
import Shape from '@site/static/img/shapes/intro-cards/shape.svg'
1010
import styles from './NavigationOverlay.module.css'
11-
import { METAMASK_SDK, EMBEDDED_WALLETS } from '../builder/choices'
11+
import { METAMASK_SDK, EMBEDDED_WALLETS, YES, NO } from '../builder/choices'
1212

1313
interface NavigationOption {
1414
id: string
1515
title: string
1616
description: string
1717
product?: string
1818
link?: string
19+
walletAggregatorOnly?: string
1920
}
2021

2122
interface NavigationFlowProps {
22-
onSelect: (product: string) => void
23+
onSelect: (options: { product: string; walletAggregatorOnly?: string }) => void
2324
}
2425

2526
const navigationOptions: NavigationOption[] = [
@@ -34,12 +35,14 @@ const navigationOptions: NavigationOption[] = [
3435
title: 'I want to create wallets inside my dapp',
3536
description: 'Embedded Wallets SDK',
3637
product: EMBEDDED_WALLETS,
38+
walletAggregatorOnly: NO,
3739
},
3840
{
3941
id: 'embedded-wallets-2',
4042
title: 'I want a wallet aggregator for my dapp',
4143
description: 'Embedded Wallets SDK',
4244
product: EMBEDDED_WALLETS,
45+
walletAggregatorOnly: YES,
4346
},
4447
{
4548
id: 'delegation-toolkit-1',
@@ -67,7 +70,13 @@ const NavigationFlow: React.FC<NavigationFlowProps> = ({ onSelect }) => {
6770

6871
const handleOptionSelect = (option: NavigationOption) => {
6972
if (option.product) {
70-
onSelect(option.product)
73+
const options: { product: string; walletAggregatorOnly?: string } = {
74+
product: option.product,
75+
}
76+
if (option.walletAggregatorOnly !== undefined) {
77+
options.walletAggregatorOnly = option.walletAggregatorOnly
78+
}
79+
onSelect(options)
7180
} else if (option.link) {
7281
window.location.href = option.link
7382
}

src/pages/quickstart/NavigationOverlay/NavigationOverlay.module.css

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Overlay Container - Full layover covering entire builder */
1+
/* Overlay Container - Covers builder area only */
22
.overlayContainer {
33
position: absolute;
44
inset: 0;
@@ -19,7 +19,6 @@ html[data-theme='dark'] .overlayContainer {
1919
overflow-y: auto;
2020
display: flex;
2121
flex-direction: column;
22-
margin-top: 6rem;
2322
}
2423

2524
/* Tablet and up */

src/pages/quickstart/NavigationOverlay/index.tsx

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,50 @@
11
import React, { useState } from 'react'
22
import styles from './NavigationOverlay.module.css'
33
import NavigationFlow from './NavigationFlow'
4+
import { getWindowLocation } from '../../../theme/URLParams'
5+
import { METAMASK_SDK, EMBEDDED_WALLETS, YES, NO } from '../builder/choices'
46

57
interface NavigationOverlayProps {
68
onClose: () => void
7-
onSelect: (product: string) => void
9+
onSelect: (options: { product: string; walletAggregatorOnly?: string }) => void
10+
}
11+
12+
// Check if there are relevant URL params (for close button visibility)
13+
const hasRelevantURLParams = () => {
14+
const url = new URL(getWindowLocation())
15+
const relevantParams = ['product', 'framework', 'walletAggregatorOnly']
16+
return relevantParams.some(param => url.searchParams.has(param))
17+
}
18+
19+
const validateURLParams = () => {
20+
const url = new URL(getWindowLocation())
21+
const product = url.searchParams.get('product')
22+
const walletAggregatorOnly = url.searchParams.get('walletAggregatorOnly')
23+
24+
// Must have at least a product parameter to be valid
25+
if (!product) return false
26+
27+
// Validate product parameter
28+
const validProducts = [METAMASK_SDK, EMBEDDED_WALLETS]
29+
if (!validProducts.includes(product)) return false
30+
31+
// If we have walletAggregatorOnly, validate its value
32+
if (walletAggregatorOnly && ![YES, NO].includes(walletAggregatorOnly)) return false
33+
34+
return true
835
}
936

1037
const NavigationOverlay: React.FC<NavigationOverlayProps> = ({ onClose, onSelect }) => {
38+
const canClose = hasRelevantURLParams() && validateURLParams()
39+
1140
return (
1241
<div className={styles.overlayContainer}>
1342
<div className={styles.overlayContent}>
43+
{canClose && (
44+
<button className={styles.closeButton} onClick={onClose}>
45+
46+
</button>
47+
)}
1448
<NavigationFlow onSelect={onSelect} />
1549
</div>
1650
</div>

src/pages/quickstart/builder/choices.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,8 @@ export const TOGGLE: DisplayChoice[] = [
4343
{ key: NO, displayName: 'No' },
4444
{ key: YES, displayName: 'Yes' },
4545
]
46+
47+
export const WALLET_AGGREGATOR_TOGGLE: DisplayChoice[] = [
48+
{ key: NO, displayName: 'Social Logins' },
49+
{ key: YES, displayName: 'Wallet Aggregator' },
50+
]

src/pages/quickstart/builder/embedded-wallets/angular/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import { ReplaceFileAggregator } from '../../../utils'
33
import getSteps from './steps'
44

55
const framework = {
6-
build({ filenames, files, steps }) {
6+
build({ filenames, files, steps, ...values }) {
77
const replacementAggregator = new ReplaceFileAggregator()
8-
getSteps(steps, files, replacementAggregator)
8+
getSteps(steps, files, replacementAggregator, values)
99
filenames.push(qsFileLinks.EW_ANGULAR_APP_COMPONENT_TS)
1010
filenames.push(qsFileLinks.EW_ANGULAR_PACKAGE_JSON)
1111
filenames.push(qsFileLinks.EW_ANGULAR_APP_COMPONENT_HTML)

src/pages/quickstart/builder/embedded-wallets/angular/stepContent/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import * as login from './login.mdx'
55
import * as logout from './logout.mdx'
66
import * as blockchainCalls from './blockchainCalls.mdx'
77
import * as registerApp from '../../../../commonSteps/registerApp.mdx'
8+
import * as walletAggregatorOnly from '../../../../commonSteps/walletAggregatorOnly.mdx'
89
import * as installation from './installation.mdx'
910
import * as config from './config.mdx'
1011
import { toSteps } from '../../../../utils'
@@ -16,6 +17,7 @@ const STEPS = toSteps({
1617
initialization,
1718
config,
1819
registerApp,
20+
walletAggregatorOnly,
1921
blockchainCalls,
2022
login,
2123
logout,

src/pages/quickstart/builder/embedded-wallets/angular/steps.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import qsFileLinks from '../../../../../utils/qs-file-links.json'
22
import STEPS from './stepContent'
3+
import { YES } from '../../choices'
34

4-
export default function getSteps(steps, files, replacementAggregator) {
5+
export default function getSteps(steps, files, replacementAggregator, values = {}) {
56
steps.push(
67
{
78
...STEPS.angularQuickStart,
@@ -34,7 +35,22 @@ export default function getSteps(steps, files, replacementAggregator) {
3435
files[qsFileLinks.EW_ANGULAR_APP_COMPONENT_TS],
3536
'Dashboard Registration'
3637
),
37-
},
38+
}
39+
)
40+
41+
// Add wallet aggregator only step if enabled
42+
if (values.walletAggregatorOnly === YES) {
43+
steps.push({
44+
...STEPS.walletAggregatorOnly,
45+
pointer: replacementAggregator.highlightRange(
46+
qsFileLinks.EW_ANGULAR_APP_COMPONENT_TS,
47+
files[qsFileLinks.EW_ANGULAR_APP_COMPONENT_TS],
48+
'Wallet Aggregator Configuration'
49+
),
50+
})
51+
}
52+
53+
steps.push(
3854
{
3955
...STEPS.config,
4056
pointer: replacementAggregator.highlightRange(

src/pages/quickstart/builder/embedded-wallets/nextjs/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import { ReplaceFileAggregator } from '../../../utils'
33
import getSteps from './steps'
44

55
const framework = {
6-
build({ filenames, files, steps }) {
6+
build({ filenames, files, steps, ...values }) {
77
const replacementAggregator = new ReplaceFileAggregator()
8-
getSteps(steps, files, replacementAggregator)
8+
getSteps(steps, files, replacementAggregator, values)
99
filenames.push(qsFileLinks.EW_NEXTJS_LAYOUT_TSX)
1010
filenames.push(qsFileLinks.EW_NEXTJS_PAGE_TSX)
1111
filenames.push(qsFileLinks.EW_NEXTJS_COMPONENTS_PROVIDER_TSX)

src/pages/quickstart/builder/embedded-wallets/nextjs/stepContent/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as logout from '../../react/stepContent/logout.mdx'
44
import * as setupWeb3AuthProvider from '../../react/stepContent/setupWeb3AuthProvider.mdx'
55
import * as wagmiCalls from '../../react/stepContent/wagmiCalls.mdx'
66
import * as registerApp from '../../../../commonSteps/registerApp.mdx'
7+
import * as walletAggregatorOnly from '../../../../commonSteps/walletAggregatorOnly.mdx'
78
import * as installation from '../../react/stepContent/installation.mdx'
89
import * as config from '../../react/stepContent/config.mdx'
910
import * as setupWagmiProvider from '../../react/stepContent/setupWagmiProvider.mdx'
@@ -15,6 +16,7 @@ const STEPS = toSteps({
1516
config,
1617
setupWagmiProvider,
1718
registerApp,
19+
walletAggregatorOnly,
1820
wagmiCalls,
1921
login,
2022
logout,

src/pages/quickstart/builder/embedded-wallets/nextjs/steps.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import qsFileLinks from '../../../../../utils/qs-file-links.json'
22
import STEPS from './stepContent'
3+
import { YES } from '../../choices'
34

4-
export default function getSteps(steps, files, replacementAggregator) {
5+
export default function getSteps(steps, files, replacementAggregator, values = {}) {
56
steps.push(
67
{
78
...STEPS.nextjsQuickStart,
@@ -26,7 +27,22 @@ export default function getSteps(steps, files, replacementAggregator) {
2627
files[qsFileLinks.EW_NEXTJS_COMPONENTS_PROVIDER_TSX],
2728
'Dashboard Registration'
2829
),
29-
},
30+
}
31+
)
32+
33+
// Add wallet aggregator only step if enabled
34+
if (values.walletAggregatorOnly === YES) {
35+
steps.push({
36+
...STEPS.walletAggregatorOnly,
37+
pointer: replacementAggregator.highlightRange(
38+
qsFileLinks.EW_NEXTJS_COMPONENTS_PROVIDER_TSX,
39+
files[qsFileLinks.EW_NEXTJS_COMPONENTS_PROVIDER_TSX],
40+
'Wallet Aggregator Configuration'
41+
),
42+
})
43+
}
44+
45+
steps.push(
3046
{
3147
...STEPS.config,
3248
pointer: replacementAggregator.highlightRange(

0 commit comments

Comments
 (0)