-
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
delete-character
scene
- Loading branch information
Showing
7 changed files
with
239 additions
and
11 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
55 changes: 55 additions & 0 deletions
55
packages/connect-kit/src/scenes/for-dynamic-modal/delete-character/index.module.css
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,55 @@ | ||
.tips { | ||
color: #49454f; | ||
font-weight: 400; | ||
font-size: 14px; | ||
text-align: center; | ||
margin: 10px 0 22px; | ||
} | ||
|
||
.list { | ||
margin-top: 12px; | ||
width: 100%; | ||
} | ||
|
||
.item { | ||
justify-content: center; | ||
font-weight: 500; | ||
height: 64px; | ||
position: relative; | ||
overflow: hidden; | ||
z-index: 0; | ||
} | ||
|
||
.deleteProgress { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
right: 0; | ||
bottom: 0; | ||
background: #000; | ||
z-index: -1; | ||
transform: translateX(-100%); | ||
transition: 3s transform linear; | ||
--is-active: false; | ||
} | ||
|
||
.delete:active .deleteProgress, | ||
.deleting .deleteProgress { | ||
transform: translateX(0); | ||
--is-active: true; | ||
} | ||
|
||
.heartImgContainer { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
height: 183px; | ||
width: 100%; | ||
margin-bottom: -24px; | ||
} | ||
|
||
.heartImg { | ||
width: 120px; | ||
height: 120px; | ||
object-fit: contain; | ||
} |
116 changes: 116 additions & 0 deletions
116
packages/connect-kit/src/scenes/for-dynamic-modal/delete-character/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,116 @@ | ||
import React from "react"; | ||
import classNames from "classnames"; | ||
import { usePreloadImgs, useRefCallback } from "@crossbell/util-hooks"; | ||
import { LoadingOverlay, useWeb2Url } from "@crossbell/ui"; | ||
|
||
import { | ||
DynamicScenesHeader, | ||
DynamicScenesContainer, | ||
OptionList, | ||
OptionListItem, | ||
useDynamicScenesModal, | ||
Congrats, | ||
} from "../../../components"; | ||
import { useDeleteCharacter } from "../../../hooks"; | ||
|
||
import styles from "./index.module.css"; | ||
|
||
const heartImgIPFS = | ||
"ipfs://bafkreiggl5dvgdoak4grhokwyam3zp3ohecaede4rgbop2jupnbgqjb7bi"; | ||
|
||
export type DeleteCharacterProps = { | ||
characterId: number; | ||
afterDelete?: () => void; | ||
onCancel?: () => void; | ||
}; | ||
|
||
export function DeleteCharacter({ | ||
characterId, | ||
onCancel, | ||
}: DeleteCharacterProps) { | ||
const { goBack, updateLast } = useDynamicScenesModal(); | ||
const heartUrl = useWeb2Url(heartImgIPFS); | ||
const { mutate, isLoading } = useDeleteCharacter({ | ||
onSuccess() { | ||
updateLast({ | ||
kind: "deleted-congrats", | ||
Component: DeletedCongrats, | ||
}); | ||
}, | ||
}); | ||
|
||
usePreloadImgs([heartUrl]); | ||
|
||
const deleteCharacter = useRefCallback(() => mutate({ characterId })); | ||
|
||
return ( | ||
<DynamicScenesContainer | ||
padding="0 24px 24px" | ||
header={<DynamicScenesHeader title="Delete Character" />} | ||
> | ||
<LoadingOverlay visible={isLoading} /> | ||
|
||
<p className={styles.tips}> | ||
Your data including your character and feed will be permanently deleted | ||
except your wallet. Press the button to proceed with the deletion | ||
</p> | ||
|
||
<OptionList className={styles.list}> | ||
<OptionListItem | ||
className={classNames( | ||
styles.item, | ||
styles.delete, | ||
isLoading && styles.deleting | ||
)} | ||
color="red" | ||
> | ||
<div | ||
className={styles.deleteProgress} | ||
onTransitionEnd={({ currentTarget }) => { | ||
const isActive = | ||
getComputedStyle(currentTarget) | ||
.getPropertyValue("--is-active") | ||
.trim() === "true"; | ||
|
||
if (isActive) { | ||
deleteCharacter(); | ||
} | ||
}} | ||
/> | ||
Press to Delete | ||
</OptionListItem> | ||
<OptionListItem | ||
className={styles.item} | ||
color="gray" | ||
onClick={onCancel ?? goBack} | ||
> | ||
Cancel | ||
</OptionListItem> | ||
</OptionList> | ||
</DynamicScenesContainer> | ||
); | ||
} | ||
|
||
function DeletedCongrats() { | ||
const { hide } = useDynamicScenesModal(); | ||
const heartUrl = useWeb2Url(heartImgIPFS); | ||
|
||
return ( | ||
<Congrats | ||
title="Deleted!" | ||
desc="You have deleted your character, take care and see you next time!" | ||
tips="Delete Character" | ||
timeout="15s" | ||
btnText="" | ||
onClose={hide} | ||
illustration={ | ||
<div className={styles.heartImgContainer}> | ||
<img className={styles.heartImg} src={heartUrl} alt="Heart" /> | ||
</div> | ||
} | ||
onClickBtn={() => { | ||
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