-
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/x-settings): add switch/mint character entry
- Loading branch information
Showing
8 changed files
with
237 additions
and
22 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
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
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
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
97 changes: 97 additions & 0 deletions
97
packages/connect-kit/src/scenes/mint-character-for-dynamic-modal/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 |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import React from "react"; | ||
import { useRefCallback } from "@crossbell/util-hooks"; | ||
import { useUrlComposer } from "@crossbell/ui"; | ||
|
||
import { useAccountCharacter } from "../../hooks"; | ||
import { useDynamicScenesModal, Congrats } from "../../components"; | ||
import { | ||
MintCharacter as Main, | ||
MintCharacterProps as Props, | ||
MintCharacterFormMode, | ||
MintCharacterSceneMode, | ||
} from "../mint-character"; | ||
|
||
export type MintCharacterPropsForDynamicModal = Pick< | ||
Props, | ||
"sceneMode" | "formMode" | ||
> & { | ||
onSuccess?: () => void; | ||
}; | ||
|
||
export function MintCharacterForDynamicModal({ | ||
sceneMode, | ||
formMode, | ||
onSuccess, | ||
}: MintCharacterPropsForDynamicModal) { | ||
const { goTo, updateLast } = useDynamicScenesModal(); | ||
|
||
const onSwitchSceneMode = useRefCallback( | ||
(sceneMode: MintCharacterSceneMode) => { | ||
updateLast({ | ||
kind: "mint-character", | ||
Component: () => ( | ||
<MintCharacterForDynamicModal | ||
formMode={formMode} | ||
sceneMode={sceneMode} | ||
onSuccess={onSuccess} | ||
/> | ||
), | ||
}); | ||
} | ||
); | ||
|
||
const onSwitchFormMode = useRefCallback((formMode: MintCharacterFormMode) => { | ||
updateLast({ | ||
kind: "mint-character", | ||
Component: () => ( | ||
<MintCharacterForDynamicModal | ||
formMode={formMode} | ||
sceneMode={sceneMode} | ||
onSuccess={onSuccess} | ||
/> | ||
), | ||
}); | ||
}); | ||
|
||
return ( | ||
<Main | ||
formMode={formMode} | ||
sceneMode={sceneMode} | ||
onSwitchFormMode={onSwitchFormMode} | ||
onSwitchSceneMode={onSwitchSceneMode} | ||
onSuccess={() => { | ||
if (onSuccess) { | ||
onSuccess(); | ||
} else { | ||
goTo({ | ||
kind: "congrats", | ||
Component: CongratsForMintCharacter, | ||
}); | ||
} | ||
}} | ||
/> | ||
); | ||
} | ||
|
||
function CongratsForMintCharacter() { | ||
const character = useAccountCharacter(); | ||
const urlComposer = useUrlComposer(); | ||
const { hide } = useDynamicScenesModal(); | ||
|
||
return ( | ||
<Congrats | ||
title="Congrats!" | ||
desc="Now you can return into the feed and enjoy Crossbell." | ||
tips="Welcome to new Crossbell" | ||
timeout="15s" | ||
btnText={character ? "Check Character" : "Close"} | ||
onClose={hide} | ||
onClickBtn={() => { | ||
if (character) { | ||
window.open(urlComposer.characterUrl(character), "_blank"); | ||
} | ||
hide(); | ||
}} | ||
/> | ||
); | ||
} |
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
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,23 @@ | ||
import * as React from "react"; | ||
import { SVGProps, Ref, forwardRef } from "react"; | ||
const SvgSettingsAccountOutline = ( | ||
props: SVGProps<SVGSVGElement>, | ||
ref: Ref<SVGSVGElement> | ||
) => ( | ||
<svg | ||
width="1em" | ||
height="1em" | ||
viewBox="0 0 24 24" | ||
fill="none" | ||
xmlns="http://www.w3.org/2000/svg" | ||
ref={ref} | ||
{...props} | ||
> | ||
<path | ||
d="M13.497 12c.819 0 1.515-.287 2.09-.86a2.837 2.837 0 0 0 .863-2.087c0-.819-.287-1.516-.86-2.09a2.837 2.837 0 0 0-2.087-.863c-.819 0-1.515.287-2.09.86a2.837 2.837 0 0 0-.863 2.087c0 .819.286 1.515.86 2.09a2.837 2.837 0 0 0 2.087.863ZM6.5 17.525a9.435 9.435 0 0 1 3.1-2.575 8.326 8.326 0 0 1 3.9-.95c1.383 0 2.683.317 3.9.95a9.435 9.435 0 0 1 3.1 2.575V3.5h-14v14.025ZM6.5 19c-.412 0-.766-.147-1.06-.44A1.445 1.445 0 0 1 5 17.5v-14c0-.413.147-.766.44-1.06.294-.293.647-.44 1.06-.44h14c.413 0 .766.147 1.06.44.293.294.44.647.44 1.06v14c0 .413-.147.766-.44 1.06-.294.293-.647.44-1.06.44h-14Zm-3 3c-.413 0-.766-.147-1.06-.44A1.445 1.445 0 0 1 2 20.5V6.25h1.5V20.5h14.25V22H3.5Zm10-11.5c-.4 0-.742-.142-1.025-.425a1.397 1.397 0 0 1-.425-1.025c0-.4.142-.742.425-1.025A1.397 1.397 0 0 1 13.5 7.6c.4 0 .742.142 1.025.425.283.283.425.625.425 1.025 0 .4-.142.742-.425 1.025a1.397 1.397 0 0 1-1.025.425Zm-4.675 7h9.35a6.051 6.051 0 0 0-2.113-1.488A6.514 6.514 0 0 0 13.5 15.5c-.9 0-1.754.17-2.563.512A6.051 6.051 0 0 0 8.825 17.5Z" | ||
fill="#fff" | ||
/> | ||
</svg> | ||
); | ||
const ForwardRef = forwardRef(SvgSettingsAccountOutline); | ||
export default ForwardRef; |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.