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 1 commit
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
40 changes: 40 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"prism-react-renderer": "^2.1.0",
"react": "^18.0.0",
"react-alert": "^7.0.3",
"react-device-detect": "^2.2.3",
"react-dom": "^18.0.0",
"react-dropdown-select": "^4.11.2",
"react-modal": "^3.16.1",
Expand Down
182 changes: 95 additions & 87 deletions src/components/Faucet/Hero.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useContext, useEffect, useState } from "react";
import { BrowserView, MobileView } from "react-device-detect";
import Text from "@site/src/components/Text";
import Button from "@site/src/components/Button";
import Input from "@site/src/components/Input";
Expand Down Expand Up @@ -103,96 +104,103 @@ 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>
)}
</div>
)}
<div
className={clsx(
!!Object.keys(projects).length && styles.alignedButtons,
)}
>
{!isExtensionActive ? (
<Button
testId="hero-cta-install-metamask"
className={styles.button}
onClick={handleConnectWallet}
>
Install MetaMask
</Button>
) : !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>
<BrowserView>
<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>
)}
{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-request-eth"
isLoading={isLoading}
disabled={!inputValue}
className={styles.button}
onClick={handleRequestEth}
>
Request ETH
</Button>
</div>
)}
<div
className={clsx(
!!Object.keys(projects).length && styles.alignedButtons,
)}
>
{!isExtensionActive ? (
<Button
testId="hero-cta-install-metamask"
className={styles.button}
onClick={handleConnectWallet}
>
Install MetaMask
</Button>
) : !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-request-eth"
isLoading={isLoading}
disabled={!inputValue}
className={styles.button}
onClick={handleRequestEth}
>
Request ETH
</Button>
)}
</div>
</div>
</div>
</BrowserView>
<MobileView>
<Text as="p">
Please open the application on desktop to get started and request ETH
</Text>
</MobileView>
</div>
);
}
2 changes: 2 additions & 0 deletions src/components/NavbarWallet/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useEffect, useState, useRef, FC, useContext } from "react";
import { isBrowser } from "react-device-detect";
import ldClient from "launchdarkly";
import clsx from "clsx";
import Button from "@site/src/components/Button";
Expand Down Expand Up @@ -248,6 +249,7 @@ const NavbarWallet = (props) => {

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