-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
Showing
19 changed files
with
303 additions
and
24 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,56 @@ | ||
import Button from '@components/theme/Button'; | ||
import Text from '@components/theme/Text'; | ||
import { EFontWeight, ETextAlign, ETextType } from '@components/theme/Text/Text.enum'; | ||
import * as stylex from '@stylexjs/stylex'; | ||
import { FC } from 'react'; | ||
import { EColor, ESize } from 'styles/theme.enum'; | ||
import { colors } from '../../../../styles/theme.stylex'; | ||
|
||
const SM = '@media only screen and (min-width: 600px)'; | ||
|
||
const styles = stylex.create({ | ||
container: { | ||
display: 'flex', | ||
flexDirection: 'column', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
transform: { | ||
default: 'scale(0.9)', | ||
[SM]: 'scale(1)' | ||
} | ||
}, | ||
text: { | ||
display: 'flex', | ||
flexDirection: 'column', | ||
justifyContent: 'center', | ||
alignItems: 'center' | ||
}, | ||
button: { | ||
marginTop: '32px', | ||
color: colors.lightBlue | ||
} | ||
}); | ||
|
||
const cloneCmd = 'npx create-nextjs-dapp'; | ||
|
||
const CTA: FC = () => { | ||
return ( | ||
<div {...stylex.props(styles.container)}> | ||
<Text | ||
type={ETextType.h2} | ||
size={ESize.s} | ||
color={EColor.gray} | ||
weight={EFontWeight.regular} | ||
align={ETextAlign.center} | ||
style={styles.text} | ||
> | ||
Start coding is easy as | ||
<Button style={styles.button} valueToCopy={cloneCmd + '@latest'}> | ||
{cloneCmd} | ||
</Button> | ||
</Text> | ||
</div> | ||
); | ||
}; | ||
|
||
export { CTA }; |
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 @@ | ||
export { CTA as default } from './CTA'; |
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
File renamed without changes.
42 changes: 42 additions & 0 deletions
42
packages/stylex/app/_components/navbar/WalletButton/WalletButton.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,42 @@ | ||
'use client'; | ||
|
||
import Button from '@components/theme/Button'; | ||
import { WALLETS } from '@contexts/Web3Context/Web3Context.variables'; | ||
import useWeb3 from '@hooks/useWeb3'; | ||
import Address from '@models/Address'; | ||
import * as stylex from '@stylexjs/stylex'; | ||
import { FC } from 'react'; | ||
import { MdOutlineAccountBalanceWallet } from 'react-icons/md'; | ||
import { colors } from '../../../../styles/theme.stylex'; | ||
import WalletModal from '../WalletModal'; | ||
import { IWalletButton } from './WalletButton.type'; | ||
|
||
const styles = stylex.create({ | ||
button: { | ||
color: colors.lightBlue | ||
} | ||
}); | ||
|
||
const WalletButton: FC<IWalletButton> = () => { | ||
const { connectWallet, accounts, setIsWalletModalOpen, isWalletModalOpen } = useWeb3(); | ||
|
||
const address = accounts[0]?.address; | ||
const ens = accounts[0]?.ens; | ||
|
||
const isWalletConnected = !!address; | ||
|
||
return ( | ||
<> | ||
<WalletModal isOpen={isWalletModalOpen} onClose={() => setIsWalletModalOpen(false)} /> | ||
<Button | ||
onClick={isWalletConnected ? () => setIsWalletModalOpen(true) : () => connectWallet(WALLETS.blocknative)} | ||
icon={<MdOutlineAccountBalanceWallet size={28} />} | ||
style={styles.button} | ||
> | ||
{isWalletConnected ? ens?.name || Address.from(address)?.truncate() : 'Connect Wallet'} | ||
</Button> | ||
</> | ||
); | ||
}; | ||
|
||
export { WalletButton }; |
4 changes: 4 additions & 0 deletions
4
packages/stylex/app/_components/navbar/WalletButton/WalletButton.type.ts
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,4 @@ | ||
|
||
interface IWalletButton {} | ||
|
||
export type { IWalletButton } |
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 @@ | ||
export { WalletButton as default } from './WalletButton'; |
126 changes: 126 additions & 0 deletions
126
packages/stylex/app/_components/navbar/WalletModal/WalletModal.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,126 @@ | ||
'use client'; | ||
|
||
import Portal from '@components/Portal'; | ||
import Text from '@components/theme/Text'; | ||
import { EFontWeight, ETextAlign } from '@components/theme/Text/Text.enum'; | ||
import useWeb3 from '@hooks/useWeb3'; | ||
import * as stylex from '@stylexjs/stylex'; | ||
import { FC, useEffect, useState } from 'react'; | ||
import { ESize } from 'styles/theme.enum'; | ||
import { colors, spacing } from '../../../../styles/theme.stylex'; | ||
import { IWalletModal } from './WalletModal.type'; | ||
|
||
const styles = stylex.create({ | ||
bgButton: { | ||
position: 'fixed', | ||
inset: 0, | ||
zIndex: 900, | ||
backgroundColor: colors.black, | ||
opacity: 0.0, | ||
transition: 'opacity 0.3s ease-in-out', | ||
border: 'none' | ||
}, | ||
bgButtonVisible: { | ||
opacity: 0.5 | ||
}, | ||
modalContainer: { | ||
display: 'flex', | ||
flexDirection: 'column', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
position: 'fixed', | ||
zIndex: 901, | ||
transition: 'opacity 0.3s ease-in-out', | ||
top: '50%', | ||
left: '50%', | ||
transform: 'translate(-50%, -50%)', | ||
width: 500, | ||
height: 'auto', | ||
opacity: 0, | ||
padding: { | ||
default: spacing['2xs'], | ||
'@media (min-width: 900px)': spacing.s | ||
}, | ||
borderRadius: '13px', | ||
background: colors.darkGradient, | ||
border: '1px solid', | ||
borderColor: colors.darkGray, | ||
boxShadow: '0px 5px 20px 10px #12131450' | ||
}, | ||
modalContainerVisible: { | ||
opacity: 1 | ||
}, | ||
button: { | ||
border: 'none', | ||
height: 80, | ||
width: '100%', | ||
display: 'flex', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
borderRadius: 8, | ||
backgroundColor: { | ||
default: colors.transparentGray, | ||
':hover': colors.lessTransparentGray | ||
}, | ||
padding: '0 20px', | ||
cursor: 'pointer', | ||
transition: 'all 0.3s ease-in-out' | ||
} | ||
}); | ||
|
||
const WalletModal: FC<IWalletModal> = ({ isOpen = false, onClose = () => {} }) => { | ||
const { disconnectWallet } = useWeb3(); | ||
|
||
const [isModalVisible, setIsModalVisible] = useState<boolean>(false); | ||
|
||
useEffect(() => { | ||
if (isOpen) { | ||
const timeout = setTimeout(() => { | ||
document.body.style.overflow = 'hidden'; | ||
setIsModalVisible(true); | ||
}, 10); | ||
|
||
return () => clearTimeout(timeout); | ||
} else { | ||
const timeout = setTimeout(() => { | ||
document.body.style.overflow = 'visible'; | ||
document.body.style.overflowX = 'hidden'; | ||
|
||
setIsModalVisible(false); | ||
}, 400); | ||
|
||
return () => clearTimeout(timeout); | ||
} | ||
}, [isOpen]); | ||
|
||
const handleDisconnectWallet = () => { | ||
onClose(); | ||
|
||
setTimeout(() => { | ||
disconnectWallet(); | ||
}, 300); | ||
}; | ||
|
||
if (!isOpen && !isModalVisible) { | ||
return <></>; | ||
} | ||
|
||
return ( | ||
<Portal selector='body'> | ||
<button | ||
{...stylex.props(styles.bgButton, isModalVisible && isOpen ? styles.bgButtonVisible : {})} | ||
onClick={onClose} | ||
/> | ||
|
||
<div {...stylex.props(styles.modalContainer, isModalVisible && isOpen ? styles.modalContainerVisible : {})}> | ||
<button onClick={() => handleDisconnectWallet()} {...stylex.props(styles.button)}> | ||
<Text size={ESize.l} weight={EFontWeight.bold} align={ETextAlign.center}> | ||
Disconnect Wallet | ||
</Text> | ||
</button> | ||
</div> | ||
</Portal> | ||
); | ||
}; | ||
|
||
export { WalletModal }; |
8 changes: 8 additions & 0 deletions
8
packages/stylex/app/_components/navbar/WalletModal/WalletModal.type.ts
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,8 @@ | ||
import { ReactNode } from 'react'; | ||
|
||
interface IWalletModal { | ||
isOpen: boolean; | ||
onClose: () => void; | ||
} | ||
|
||
export type { IWalletModal }; |
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 @@ | ||
export { WalletModal as default } from './WalletModal'; |
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.