-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: antondlr <[email protected]>
- Loading branch information
Showing
10 changed files
with
540 additions
and
64 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,4 @@ | ||
'use client'; | ||
'use client' | ||
|
||
import axios from 'axios' | ||
import { useRouter } from 'next/navigation' | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import Link, { LinkProps } from 'next/link' | ||
import { FC } from 'react' | ||
import Typography, { TypographyProps } from '../Typography/Typography' | ||
|
||
export interface ExternalLinkProps | ||
extends Omit<LinkProps, 'as'>, | ||
Omit<TypographyProps, 'children' | 'as'> { | ||
text: string | ||
} | ||
|
||
const ExternalLink: FC<ExternalLinkProps> = ({ | ||
href, | ||
text, | ||
color = 'text-dark400', | ||
type = 'text-caption1', | ||
...props | ||
}) => { | ||
return ( | ||
<div> | ||
<Link href={href} target='_blank' passHref> | ||
<div className='flex space-x-2 items-center'> | ||
<Typography color={color} type={type} className='underline' {...props}> | ||
{text} | ||
</Typography> | ||
<i className='text-dark400 text-caption1 bi-box-arrow-up-right' /> | ||
</div> | ||
</Link> | ||
</div> | ||
) | ||
} | ||
|
||
export default ExternalLink |
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,74 @@ | ||
import { FC, ReactNode } from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
import { useRecoilState } from 'recoil' | ||
import useWalletConnection from '../../hooks/useWalletConnection' | ||
import { isWalletConnectModal } from '../../recoil/atoms' | ||
import Button, { ButtonFace } from '../Button/Button' | ||
import Typography, { TypographyType } from '../Typography/Typography' | ||
|
||
export interface WalletActionBtnProps { | ||
children: ReactNode | ||
textSize?: TypographyType | undefined | ||
isSufficientBalance?: boolean | ||
} | ||
|
||
const WalletActionBtn: FC<WalletActionBtnProps> = ({ | ||
children, | ||
textSize, | ||
isSufficientBalance = true, | ||
}) => { | ||
const { t } = useTranslation() | ||
const { isConnected, isValidNetwork, switchNetwork } = useWalletConnection() | ||
const [isOpen, setIsOpen] = useRecoilState(isWalletConnectModal) | ||
const openModal = () => setIsOpen(true) | ||
|
||
const renderButton = () => { | ||
switch (true) { | ||
case !isConnected: | ||
return ( | ||
<Button | ||
className='w-full h-full' | ||
isLoading={isOpen} | ||
onClick={openModal} | ||
type={ButtonFace.SECONDARY} | ||
> | ||
<Typography color='text-white' type={textSize} darkMode='dark:text-white'> | ||
{t('connect')} | ||
</Typography> | ||
</Button> | ||
) | ||
case !isValidNetwork: | ||
return ( | ||
<Button className='w-full h-full' onClick={switchNetwork} type={ButtonFace.ERROR}> | ||
<Typography | ||
color='text-error' | ||
type={textSize} | ||
darkMode='dark:text-error' | ||
className='break-keep whitespace-nowrap' | ||
> | ||
{t('switchNetwork')} | ||
</Typography> | ||
</Button> | ||
) | ||
case !isSufficientBalance: | ||
return ( | ||
<Button className='w-full h-full' isDisabled type={ButtonFace.ERROR}> | ||
<Typography | ||
color='text-error' | ||
type={textSize} | ||
darkMode='dark:text-error' | ||
className='break-keep whitespace-nowrap' | ||
> | ||
{t('insufficientFunds')} | ||
</Typography> | ||
</Button> | ||
) | ||
default: | ||
return children | ||
} | ||
} | ||
|
||
return renderButton() | ||
} | ||
|
||
export default WalletActionBtn |
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
Oops, something went wrong.