-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(connect-kit): lazy load
upgrade-account-modal
- Loading branch information
Showing
3 changed files
with
106 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 4 additions & 94 deletions
98
packages/connect-kit/src/scenes/for-upgrade-account/select-options/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,97 +1,7 @@ | ||
import React from "react"; | ||
import { useAccount } from "wagmi"; | ||
import { useRefCallback } from "@crossbell/util-hooks"; | ||
|
||
import { | ||
WalletIcon, | ||
EmailIcon, | ||
OptionList, | ||
OptionListItem, | ||
DynamicScenesHeader, | ||
DynamicScenesContainer, | ||
BottomTips, | ||
useDynamicScenesModal, | ||
} from "../../../components"; | ||
import { createLazyDynamicScene } from "../../../components"; | ||
|
||
import { ConnectKindDifferences } from "../../connect-kind-differences"; | ||
import { SelectWalletToConnect } from "../select-wallet-to-connect"; | ||
import { ConfirmUpgrade } from "../confirm-upgrade"; | ||
|
||
import styles from "./index.module.css"; | ||
|
||
export type SelectOptionsProps = { | ||
onCancel?: () => void; | ||
}; | ||
|
||
export function SelectOptions({ onCancel }: SelectOptionsProps) { | ||
const { goTo, hide } = useDynamicScenesModal(); | ||
const { isConnected } = useAccount(); | ||
|
||
const onSelectDifferences = useRefCallback(() => { | ||
goTo({ | ||
kind: "connect-kind-differences", | ||
Component: ConnectKindDifferences, | ||
}); | ||
}); | ||
|
||
const onSelectWallet = useRefCallback(() => { | ||
if (isConnected) { | ||
goTo({ | ||
kind: "confirm-upgrade", | ||
Component: () => <ConfirmUpgrade scene="confirm" />, | ||
}); | ||
} else { | ||
goTo({ | ||
kind: "select-wallet-to-connect", | ||
Component: SelectWalletToConnect, | ||
}); | ||
} | ||
}); | ||
|
||
return ( | ||
<DynamicScenesContainer | ||
padding="0 24px 18px" | ||
header={<DynamicScenesHeader title="Upgrade Account" />} | ||
> | ||
<div data-animation="scale-fade-in"> | ||
<p className={styles.tips}> | ||
{`Email account can't mint because a wallet is required to keep your assets. `} | ||
<a | ||
className={styles.tipsBtn} | ||
href="https://crossbell-io-updates.xlog.app/Weekly-Updates-2023%2F02%2F06" | ||
target="_blank" | ||
rel="noreferrer" | ||
> | ||
Learn More | ||
</a> | ||
</p> | ||
<OptionList> | ||
<OptionListItem | ||
color="green" | ||
onClick={onSelectWallet} | ||
className={styles.item} | ||
> | ||
Upgrade to Wallet | ||
<WalletIcon className={styles.walletIcon} /> | ||
</OptionListItem> | ||
|
||
<OptionListItem | ||
color="gray" | ||
onClick={onCancel ?? hide} | ||
className={styles.item} | ||
> | ||
Keep Email Login | ||
<EmailIcon className={styles.emailIcon} /> | ||
</OptionListItem> | ||
</OptionList> | ||
|
||
<BottomTips | ||
className={styles.differenceBtn} | ||
onClick={onSelectDifferences} | ||
> | ||
What’s the difference | ||
</BottomTips> | ||
</div> | ||
</DynamicScenesContainer> | ||
); | ||
} | ||
export const SelectOptions = createLazyDynamicScene( | ||
React.lazy(() => import("./lazy")) | ||
); |
97 changes: 97 additions & 0 deletions
97
packages/connect-kit/src/scenes/for-upgrade-account/select-options/lazy.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import React from "react"; | ||
import { useAccount } from "wagmi"; | ||
import { useRefCallback } from "@crossbell/util-hooks"; | ||
|
||
import { | ||
WalletIcon, | ||
EmailIcon, | ||
OptionList, | ||
OptionListItem, | ||
DynamicScenesHeader, | ||
DynamicScenesContainer, | ||
BottomTips, | ||
useDynamicScenesModal, | ||
} from "../../../components"; | ||
|
||
import { ConnectKindDifferences } from "../../connect-kind-differences"; | ||
import { SelectWalletToConnect } from "../select-wallet-to-connect"; | ||
import { ConfirmUpgrade } from "../confirm-upgrade"; | ||
|
||
import styles from "./index.module.css"; | ||
|
||
export type SelectOptionsProps = { | ||
onCancel?: () => void; | ||
}; | ||
|
||
export default function SelectOptions({ onCancel }: SelectOptionsProps) { | ||
const { goTo, hide } = useDynamicScenesModal(); | ||
const { isConnected } = useAccount(); | ||
|
||
const onSelectDifferences = useRefCallback(() => { | ||
goTo({ | ||
kind: "connect-kind-differences", | ||
Component: ConnectKindDifferences, | ||
}); | ||
}); | ||
|
||
const onSelectWallet = useRefCallback(() => { | ||
if (isConnected) { | ||
goTo({ | ||
kind: "confirm-upgrade", | ||
Component: () => <ConfirmUpgrade scene="confirm" />, | ||
}); | ||
} else { | ||
goTo({ | ||
kind: "select-wallet-to-connect", | ||
Component: SelectWalletToConnect, | ||
}); | ||
} | ||
}); | ||
|
||
return ( | ||
<DynamicScenesContainer | ||
padding="0 24px 18px" | ||
header={<DynamicScenesHeader title="Upgrade Account" />} | ||
> | ||
<div data-animation="scale-fade-in"> | ||
<p className={styles.tips}> | ||
{`Email account can't mint because a wallet is required to keep your assets. `} | ||
<a | ||
className={styles.tipsBtn} | ||
href="https://crossbell-io-updates.xlog.app/Weekly-Updates-2023%2F02%2F06" | ||
target="_blank" | ||
rel="noreferrer" | ||
> | ||
Learn More | ||
</a> | ||
</p> | ||
<OptionList> | ||
<OptionListItem | ||
color="green" | ||
onClick={onSelectWallet} | ||
className={styles.item} | ||
> | ||
Upgrade to Wallet | ||
<WalletIcon className={styles.walletIcon} /> | ||
</OptionListItem> | ||
|
||
<OptionListItem | ||
color="gray" | ||
onClick={onCancel ?? hide} | ||
className={styles.item} | ||
> | ||
Keep Email Login | ||
<EmailIcon className={styles.emailIcon} /> | ||
</OptionListItem> | ||
</OptionList> | ||
|
||
<BottomTips | ||
className={styles.differenceBtn} | ||
onClick={onSelectDifferences} | ||
> | ||
What’s the difference | ||
</BottomTips> | ||
</div> | ||
</DynamicScenesContainer> | ||
); | ||
} |
4a6dd29
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
crossbell-universe – ./
crossbell-universe-git-main-crossbell.vercel.app
crossbell-universe-crossbell.vercel.app
crossbell-dev.vercel.app