-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from oasisprotocol/ml/wrap-fee-modal
Add fee retain modal warning
- Loading branch information
Showing
21 changed files
with
1,071 additions
and
31 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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.button { | ||
width: auto; | ||
border-radius: 46px; | ||
border: 1px solid transparent; | ||
box-shadow: none; | ||
|
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
.modalOverlay { | ||
position: fixed; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
background: rgba(6, 21, 43, 0.9); | ||
} | ||
|
||
.modal { | ||
position: relative; | ||
background: #fff; | ||
padding: 1.25rem; | ||
width: 100%; | ||
max-width: 675px; | ||
border-radius: 20px; | ||
} | ||
|
||
.modalContent { | ||
padding: 3.5rem 3.5rem 0; | ||
} | ||
|
||
.modalCloseButton { | ||
float: right; | ||
border: none; | ||
background: none; | ||
cursor: pointer; | ||
} | ||
|
||
@media screen and (max-width: 1000px) { | ||
.modal { | ||
max-width: none; | ||
width: 100%; | ||
height: 100vh; | ||
padding: 1.75rem; | ||
overflow: auto; | ||
} | ||
.modalContent { | ||
padding: 1rem; | ||
} | ||
} |
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,37 @@ | ||
import { MouseEvent, FC, PropsWithChildren } from 'react' | ||
import classes from './index.module.css' | ||
import { TimesIcon } from '../icons/TimesIcon.tsx' | ||
|
||
export interface ModalProps { | ||
isOpen: boolean | ||
disableBackdropClick?: boolean | ||
closeModal: (event?: MouseEvent<HTMLElement>) => void | ||
} | ||
|
||
export const Modal: FC<PropsWithChildren<ModalProps>> = ({ | ||
children, | ||
isOpen, | ||
disableBackdropClick, | ||
closeModal, | ||
}) => { | ||
if (!isOpen) { | ||
return null | ||
} | ||
|
||
const handleOverlayClick = () => { | ||
if (!disableBackdropClick) { | ||
closeModal() | ||
} | ||
} | ||
|
||
return ( | ||
<div className={classes.modalOverlay} onClick={handleOverlayClick}> | ||
<div className={classes.modal}> | ||
<button className={classes.modalCloseButton} onClick={closeModal}> | ||
<TimesIcon /> | ||
</button> | ||
<div className={classes.modalContent}>{children}</div> | ||
</div> | ||
</div> | ||
) | ||
} |
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,83 @@ | ||
.wrapFeeWarningModalContent { | ||
display: flex; | ||
flex-direction: column; | ||
|
||
h4 { | ||
color: var(--gray-extra-dark); | ||
} | ||
|
||
p { | ||
color: var(--gray-extra-dark); | ||
|
||
&:first-of-type { | ||
margin-bottom: 1rem; | ||
} | ||
|
||
&:last-of-type { | ||
margin-bottom: 3.125rem; | ||
} | ||
} | ||
} | ||
|
||
.wrapFeeWarningModalLogo { | ||
align-self: center; | ||
margin-bottom: 3.125rem; | ||
} | ||
|
||
.wrapFeeWarningModalInput { | ||
width: 75%; | ||
margin: 0 auto; | ||
} | ||
|
||
.wrapFeeWarningModalActions { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 2.125rem; | ||
margin: 2.5rem auto; | ||
text-align: center; | ||
} | ||
|
||
.wrapFeeWarningModalButton { | ||
min-width: 250px; | ||
} | ||
|
||
.wrapFeeWarningModalButtonText { | ||
font-size: 13px; | ||
} | ||
|
||
.wrapFeeWarningModalFullAmount { | ||
background: none; | ||
border: none; | ||
padding: 0; | ||
font: inherit; | ||
outline: inherit; | ||
color: var(--danger); | ||
text-decoration: underline; | ||
cursor: pointer; | ||
} | ||
|
||
@media screen and (max-width: 1000px) { | ||
.wrapFeeWarningModalContent { | ||
p { | ||
&:last-of-type { | ||
margin-bottom: 2.625rem; | ||
} | ||
} | ||
} | ||
|
||
.wrapFeeWarningModalLogo { | ||
margin-bottom: 2rem; | ||
} | ||
|
||
.wrapFeeWarningModalInput { | ||
width: 100%; | ||
} | ||
|
||
.wrapFeeWarningModalActions { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 1.625rem; | ||
margin: 1.25rem auto; | ||
text-align: center; | ||
} | ||
} |
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,69 @@ | ||
import { FC } from 'react' | ||
import { Modal, ModalProps } from '../Modal' | ||
import { LogoIconRound } from '../icons/LogoIconRound.tsx' | ||
import classes from './index.module.css' | ||
import { Input } from '../Input' | ||
import { Button } from '../Button' | ||
import { useWrapForm } from '../../hooks/useWrapForm.ts' | ||
import { WRAP_FEE_DEDUCTION_MULTIPLIER } from '../../constants/config.ts' | ||
import { BigNumber, utils } from 'ethers' | ||
import { NumberUtils } from '../../utils/number.utils.ts' | ||
|
||
interface WrapFeeWarningModalProps extends Pick<ModalProps, 'isOpen' | 'closeModal'> { | ||
next: (amount: BigNumber) => void | ||
} | ||
|
||
export const WrapFeeWarningModal: FC<WrapFeeWarningModalProps> = ({ isOpen, closeModal, next }) => { | ||
const { | ||
state: { amount, estimatedFee }, | ||
} = useWrapForm() | ||
const estimatedFeeDeduction = estimatedFee.mul(WRAP_FEE_DEDUCTION_MULTIPLIER) | ||
|
||
const roseAmount = NumberUtils.ensureNonNullBigNumber(amount) | ||
const estimatedAmountWithDeductedFees = roseAmount!.sub(estimatedFeeDeduction) | ||
|
||
return ( | ||
<Modal isOpen={isOpen} closeModal={closeModal} disableBackdropClick> | ||
<div className={classes.wrapFeeWarningModalContent}> | ||
<div className={classes.wrapFeeWarningModalLogo}> | ||
<LogoIconRound /> | ||
</div> | ||
|
||
<h4>You have chosen to wrap your entire balance</h4> | ||
|
||
<p> | ||
It is recommended to keep a small amount in your wallet at all times to cover future transactions. | ||
</p> | ||
<p> | ||
Choose if you want to wrap the reduced amount and keep {sum of {WRAP_FEE_DEDUCTION_MULTIPLIER}{' '} | ||
x gas fee - e.g. ‘<b>{utils.formatEther(estimatedFeeDeduction)} ROSE</b>’} in your account, or | ||
continue with the full amount. | ||
</p> | ||
|
||
<Input<string> | ||
className={classes.wrapFeeWarningModalInput} | ||
variant="dark" | ||
disabled | ||
type="text" | ||
label="wROSE" | ||
placeholder="0" | ||
inputMode="decimal" | ||
value={utils.formatEther(estimatedAmountWithDeductedFees)} | ||
/> | ||
|
||
<div className={classes.wrapFeeWarningModalActions}> | ||
<Button | ||
className={classes.wrapFeeWarningModalButton} | ||
onClick={() => next(estimatedAmountWithDeductedFees)} | ||
> | ||
<span className={classes.wrapFeeWarningModalButtonText}>Wrap reduced amount</span> | ||
</Button> | ||
|
||
<button className={classes.wrapFeeWarningModalFullAmount} onClick={() => next(amount!)}> | ||
Continue with full amount | ||
</button> | ||
</div> | ||
</div> | ||
</Modal> | ||
) | ||
} |
Oops, something went wrong.