-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Yauheni
committed
Mar 21, 2024
1 parent
49eeaea
commit 739b217
Showing
8 changed files
with
207 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,7 @@ | |
.modalHeader { | ||
margin-bottom: 10px; | ||
} | ||
|
||
.gameDetailsItem { | ||
grid-template-columns: auto 200px; | ||
} |
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
25 changes: 25 additions & 0 deletions
25
frontend/apps/syndote/src/pages/home/reserve-modal/ReserveModal.module.scss
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,25 @@ | ||
.modal { | ||
min-width: 670px; | ||
} | ||
|
||
.container { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 28px; | ||
} | ||
|
||
.text { | ||
font-size: 14px; | ||
} | ||
|
||
.button { | ||
width: 45%; | ||
} | ||
|
||
.modalHeader { | ||
margin-bottom: 10px; | ||
} | ||
|
||
.gameDetailsItem { | ||
grid-template-columns: auto 200px; | ||
} |
48 changes: 48 additions & 0 deletions
48
frontend/apps/syndote/src/pages/home/reserve-modal/ReserveModal.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,48 @@ | ||
import { Modal } from 'components/layout/modal'; | ||
import { Button } from '@gear-js/vara-ui'; | ||
import styles from './ReserveModal.module.scss'; | ||
import { GameDetails } from 'components/layout/game-details'; | ||
import { ReactComponent as VaraSVG } from 'assets/images/icons/vara-coin.svg'; | ||
import { ReactComponent as TVaraSVG } from 'assets/images/icons/tvara-coin.svg'; | ||
import { useAccountDeriveBalancesAll, useApi, useBalanceFormat } from '@gear-js/react-hooks'; | ||
|
||
type Props = { | ||
onReserve: () => void; | ||
onClose: () => void; | ||
}; | ||
|
||
function ReserveModal({ onReserve, onClose }: Props) { | ||
const { isApiReady, api } = useApi(); | ||
const { getFormattedBalance, getFormattedGasValue } = useBalanceFormat(); | ||
const balances = useAccountDeriveBalancesAll(); | ||
const balance = | ||
isApiReady && balances?.freeBalance ? getFormattedBalance(balances.freeBalance.toString()) : undefined; | ||
|
||
const VaraSvg = balance?.unit?.toLowerCase() === 'vara' ? <VaraSVG /> : <TVaraSVG />; | ||
const items = [ | ||
{ | ||
name: 'Required amount of gas required for the game', | ||
value: ( | ||
<> | ||
{VaraSvg} {getFormattedGasValue(api?.blockGasLimit.toNumber() || 0).toFixed()} VARA | ||
</> | ||
), | ||
}, | ||
]; | ||
|
||
return ( | ||
<Modal heading="The reserved gas is exhausted" className={{ header: styles.modalHeader }} onClose={onClose}> | ||
<div className={styles.container}> | ||
<p className={styles.text}> | ||
Please reserve a new gas amount to continue the game. Any unused gas will be refunded upon completion of the | ||
game. If you don't reserve the required amount of gas before the timer expires, you won't be able to continue | ||
playing and can only observe the game in progress. | ||
</p> | ||
<GameDetails items={items} className={{ item: styles.gameDetailsItem }} /> | ||
<Button text="Reserve gas" className={styles.button} onClick={onReserve} /> | ||
</div> | ||
</Modal> | ||
); | ||
} | ||
|
||
export { ReserveModal }; |
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,3 @@ | ||
import { ReserveModal } from './ReserveModal'; | ||
|
||
export { ReserveModal }; |
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