Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(faucet): hide login flow for mobile devices #1756

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
172 changes: 98 additions & 74 deletions src/components/Faucet/Hero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,96 +103,120 @@ export default function Hero({
wallet.
</span>
</Text>
<Text as="p">
{!isExtensionActive
? "Install MetaMask for your browser to get started and request ETH."
: !Object.keys(projects).length
? walletLinked === undefined
? "Connect your MetaMask wallet to get started and request ETH."
: walletLinked === WALLET_LINK_TYPE.NO
? "Link your Infura account to get started and request ETH."
: "Select your Infura account to get started and request ETH."
: "Enter your MetaMask wallet address and request ETH."}
</Text>
<div className={styles.actions}>
{!!Object.keys(projects).length && (
<div className={styles.inputCont}>
<Input
label="Wallet address"
disabled={isLoading}
value={inputValue}
placeholder="ex. 0x or ENS"
onChange={handleOnInputChange}
/>
{isLimitedUserPlan && (
<p className={styles.caption}>
The amount of {network === "linea" && "Linea Sepolia"}
{network === "sepolia" && "Sepolia"} ETH you'll get is
determined by your address's Ethereum Mainnet activity to ensure
fair and bot-free distribution.
</p>
{isExtensionActive ? (
<>
<Text as="p">
{!isExtensionActive
? "Install MetaMask for your browser to get started and request ETH."
: !Object.keys(projects).length
? walletLinked === undefined
? "Connect your MetaMask wallet to get started and request ETH."
: walletLinked === WALLET_LINK_TYPE.NO
? "Link your Infura account to get started and request ETH."
: "Select your Infura account to get started and request ETH."
: "Enter your MetaMask wallet address and request ETH."}
</Text>
<div className={styles.actions}>
{!!Object.keys(projects).length && (
<div className={styles.inputCont}>
<Input
label="Wallet address"
disabled={isLoading}
value={inputValue}
placeholder="ex. 0x or ENS"
onChange={handleOnInputChange}
/>
{isLimitedUserPlan && (
<p className={styles.caption}>
The amount of {network === "linea" && "Linea Sepolia"}
{network === "sepolia" && "Sepolia"} ETH you'll get is
determined by your address's Ethereum Mainnet activity to ensure
fair and bot-free distribution.
</p>
)}
</div>
)}
</div>
)}
<div
className={clsx(
!!Object.keys(projects).length && styles.alignedButtons,
)}
>
{!isExtensionActive ? (
<Button
testId="hero-cta-install-metamask"
className={styles.button}
onClick={handleConnectWallet}
<div
className={clsx(
!!Object.keys(projects).length && styles.alignedButtons,
)}
>
Install MetaMask
</Button>
) : !Object.keys(projects).length ? (
<>
{walletLinked === undefined && (
{!isExtensionActive ? (
<Button
testId="hero-cta-connect-metamask"
testId="hero-cta-install-metamask"
className={styles.button}
onClick={handleConnectWallet}
isLoading={isWalletLinking}
>
Connect MetaMask
</Button>
)}
{walletLinked === WALLET_LINK_TYPE.NO && (
<Button
testId="hero-cta-link-infura-account"
className={styles.button}
onClick={handleLinkWallet}
isLoading={isWalletLinking}
>
Link Infura Account
Install MetaMask
</Button>
)}
{walletLinked === WALLET_LINK_TYPE.MULTIPLE && (
) : !Object.keys(projects).length ? (
<>
{walletLinked === undefined && (
<Button
testId="hero-cta-connect-metamask"
className={styles.button}
onClick={handleConnectWallet}
isLoading={isWalletLinking}
>
Connect MetaMask
</Button>
)}
{walletLinked === WALLET_LINK_TYPE.NO && (
<Button
testId="hero-cta-link-infura-account"
className={styles.button}
onClick={handleLinkWallet}
isLoading={isWalletLinking}
>
Link Infura Account
</Button>
)}
{walletLinked === WALLET_LINK_TYPE.MULTIPLE && (
<Button
testId="hero-cta-select-infura-account"
className={styles.button}
onClick={handleLinkWallet}
isLoading={isWalletLinking}
>
Select Infura Account
</Button>
)}
</>
) : (
<Button
testId="hero-cta-select-infura-account"
testId="hero-cta-request-eth"
isLoading={isLoading}
disabled={!inputValue}
className={styles.button}
onClick={handleLinkWallet}
isLoading={isWalletLinking}
onClick={handleRequestEth}
>
Select Infura Account
Request ETH
</Button>
)}
</>
) : (
</div>
</div>
</>
) : (
<>
<div className={styles.heroDesktopContent}>
<Text as="p">
Install MetaMask for your browser to get started and request ETH.
</Text>
<Button
testId="hero-cta-request-eth"
isLoading={isLoading}
disabled={!inputValue}
testId="hero-cta-install-metamask"
className={styles.button}
onClick={handleRequestEth}
onClick={handleConnectWallet}
>
Request ETH
Install MetaMask
</Button>
)}
</div>
</div>
</div>
<div className={styles.heroMobileContent}>
<Text as="p">
Please open the application on desktop to get started and request ETH
</Text>
</div>
</>
)}
</div>
);
}
17 changes: 17 additions & 0 deletions src/components/Faucet/hero.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,20 @@
}
}
}


.heroDesktopContent {
display: block;

@media screen and (max-width: 996px) {
display: none;
}
}

.heroMobileContent {
display: none;

@media screen and (max-width: 996px) {
display: block;
}
}
2 changes: 2 additions & 0 deletions src/components/NavbarWallet/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ const NavbarWalletComponent: FC = ({
const NavbarWallet = (props) => {
const [ldReady, setLdReady] = useState(false);
const [loginEnabled, setLoginEnabled] = useState(false);
const { sdk } = useContext(MetamaskProviderContext);

useEffect(() => {
ldClient.waitUntilReady().then(() => {
Expand All @@ -248,6 +249,7 @@ const NavbarWallet = (props) => {

return (
ldReady &&
sdk.isExtensionActive() &&
loginEnabled && (
<BrowserOnly>{() => <NavbarWalletComponent {...props} />}</BrowserOnly>
)
Expand Down
Loading