forked from gear-foundation/dapps
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Varaman: change game over modal varaman
- Loading branch information
Showing
5 changed files
with
98 additions
and
56 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import * as Dialog from '@radix-ui/react-dialog'; | ||
import { ReactNode } from 'react'; | ||
// import { CrossIcon } from '@/assets/images'; | ||
|
||
export function Modal({ | ||
open, | ||
onOpenChange, | ||
children, | ||
}: { | ||
open?: boolean; | ||
onOpenChange?: (open: boolean) => void; | ||
children: ReactNode; | ||
}) { | ||
return ( | ||
<Dialog.Root open={open} onOpenChange={onOpenChange}> | ||
{children} | ||
</Dialog.Root> | ||
); | ||
} | ||
|
||
function ModalContent({ children }: { children: ReactNode }) { | ||
return ( | ||
<Dialog.Portal> | ||
<Dialog.Overlay className="fixed inset-0 bg-black/50 data-[state=closed]:animate-[dialog-overlay-hide_200ms] data-[state=open]:animate-[dialog-overlay-show_200ms] backdrop-blur-lg" /> | ||
<Dialog.Content className="fixed left-1/2 top-1/2 w-full max-w-md -translate-x-1/2 -translate-y-1/2 rounded-md bg-white p-8 text-gray-900 shadow data-[state=closed]:animate-[dialog-content-hide_200ms] data-[state=open]:animate-[dialog-content-show_200ms]"> | ||
{children} | ||
</Dialog.Content> | ||
</Dialog.Portal> | ||
); | ||
} | ||
|
||
Modal.Button = Dialog.Trigger; | ||
Modal.Close = Dialog.Close; | ||
Modal.Content = ModalContent; |
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
56 changes: 29 additions & 27 deletions
56
frontend/apps/vara-man/src/feature/tournament-game/components/modals/game-play-again.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,35 +1,37 @@ | ||
|
||
|
||
import { Modal } from '@/components'; | ||
import { Modal } from '@/components/ui/modal/modal2'; | ||
import { COINS } from '@/feature/game/consts'; | ||
import { Button } from '@gear-js/vara-ui'; | ||
import { useAtom } from 'jotai'; | ||
|
||
type GamePlayAgainModalProps = { | ||
setIsOpenPlayAgain: (_: boolean) => void | ||
restartGame: () => void | ||
} | ||
setIsOpenPlayAgain: (_: boolean) => void; | ||
restartGame: () => void; | ||
}; | ||
|
||
export const GamePlayAgainModal = ({ setIsOpenPlayAgain, restartGame }: GamePlayAgainModalProps) => { | ||
const [, setCoins] = useAtom(COINS) | ||
const [, setCoins] = useAtom(COINS); | ||
|
||
return ( | ||
<Modal onClose={() => null}> | ||
<div className='flex flex-col items-center'> | ||
<h2 className='typo-h2' >Game over</h2> | ||
<div className="flex flex-col gap-5 mt-5"> | ||
<p className="text-[#555756]"> | ||
You're doing great, keep it up! | ||
</p> | ||
<div className="flex gap-10"> | ||
<Button text="Play Again" className="w-full" onClick={() => { | ||
setIsOpenPlayAgain(false) | ||
restartGame() | ||
setCoins({ gold: 0, silver: 0 }) | ||
}} /> | ||
</div> | ||
</div> | ||
</div> | ||
</Modal> | ||
) | ||
} | ||
return ( | ||
<Modal open={true}> | ||
<Modal.Content> | ||
<div className="flex flex-col items-center"> | ||
<h2 className="typo-h2">Game over</h2> | ||
<div className="flex flex-col gap-5 mt-5"> | ||
<p className="text-[#555756]">You're doing great, keep it up!</p> | ||
<div className="flex gap-10"> | ||
<Button | ||
text="Play Again" | ||
className="w-full" | ||
onClick={() => { | ||
setIsOpenPlayAgain(false); | ||
restartGame(); | ||
setCoins({ gold: 0, silver: 0 }); | ||
}} | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
</Modal.Content> | ||
</Modal> | ||
); | ||
}; |
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