diff --git a/src/components/Button/button.module.scss b/src/components/Button/button.module.scss index 4c54487586c..b92f953d68a 100644 --- a/src/components/Button/button.module.scss +++ b/src/components/Button/button.module.scss @@ -1,14 +1,16 @@ :root[data-theme="dark"] { - --button-background-color: #1098fc; + --button-primary-background-color: #1098fc; + --button-secondary-background-color: transparent; --button-color: #141618; - --button-hover-background-color: #26a2fc; + --button-hover-background-color: #036ab5; --button-hover-shadow: 0px 2px 8px 0px rgba(16, 152, 252, 0.4); --button-active-background-color: #3baafd; --button-danger: #e88f97 } :root[data-theme="light"] { - --button-background-color: #0376c9; + --button-primary-background-color: #0376c9; + --button-secondary-background-color: transparent; --button-color: #ffffff; --button-hover-background-color: #036ab5; --button-hover-shadow: 0px 2px 8px 0px rgba(3, 118, 201, 0.2); @@ -33,7 +35,6 @@ a.button { .button { color: var(--button-color); - background-color: var(--button-background-color); border: none; padding: 0 16px; height: 48px; @@ -47,6 +48,19 @@ a.button { align-items: center; min-width: 145px; + &.primary { + background-color: var(--button-primary-background-color); + } + + &.secondary { + border: 1px solid rgba(3, 118, 201, 1); + --button-color: rgba(3, 118, 201, 1); + background-color: var(--button-secondary-background-color); + &:hover { + --button-color: #141618 + } + } + &:hover { background-color: var(--button-hover-background-color); box-shadow: var(--button-hover-shadow); @@ -78,6 +92,14 @@ a.button { pointer-events: none; } + &.nowrap { + white-space: nowrap; + } + + &.textLight { + color: #ffffff; + } + .isLoading { animation: spinner-infinite 1.2s linear infinite; } diff --git a/src/components/Button/index.tsx b/src/components/Button/index.tsx index f2c1d1d4e4e..3178f1ddc22 100644 --- a/src/components/Button/index.tsx +++ b/src/components/Button/index.tsx @@ -14,6 +14,9 @@ interface IButton { target?: string; thin?: boolean; type?: "default" | "danger"; + variant?: "primary" | "secondary"; + wrapText?: boolean; + textColor?: "dark" | "light", } export const Button = ({ @@ -26,11 +29,17 @@ export const Button = ({ target = "_blank", thin = false, type = "default", + variant="primary", + wrapText = true, + textColor = "dark" }: IButton) => { const buttonRootClass = clsx( styles.button, thin && styles.thin, type === "danger" && styles.danger, + variant === "primary" ? styles.primary : styles.secondary, + !wrapText && styles.nowrap, + textColor === "light" && styles.textLight, className, ); const isLoadingChild = !isLoading ? ( diff --git a/src/components/NavbarWallet/index.tsx b/src/components/NavbarWallet/index.tsx index 260bd5d6c20..ae70b4c5b7e 100644 --- a/src/components/NavbarWallet/index.tsx +++ b/src/components/NavbarWallet/index.tsx @@ -69,6 +69,7 @@ const NavbarWalletComponent: FC = ({ thin onClick={metaMaskWalletIdConnectHandler} className={styles.navbarButton} + textColor="light" > {!isExtensionActive ? "Install MetaMask" : "Connect MetaMask"} diff --git a/src/components/ParserOpenRPC/ProjectsBox/index.tsx b/src/components/ParserOpenRPC/ProjectsBox/index.tsx index a1ab614ceff..52f2713165d 100644 --- a/src/components/ParserOpenRPC/ProjectsBox/index.tsx +++ b/src/components/ParserOpenRPC/ProjectsBox/index.tsx @@ -3,7 +3,7 @@ import ldClient from "launchdarkly"; import { MetamaskProviderContext } from "@site/src/theme/Root"; import Select from "react-dropdown-select"; import Button from "@site/src/components/Button"; -import styles from "./styles.module.css"; +import styles from "./styles.module.scss"; import { WALLET_LINK_TYPE } from "@site/src/components/AuthLogin/AuthModal"; const LOGIN_FF = "mm-unified-login"; @@ -15,6 +15,7 @@ const ProjectsBox = () => { walletLinked, metaMaskWalletIdConnectHandler, walletLinkUrl, + setUserAPIKey, } = useContext(MetamaskProviderContext); const options = Object.keys(projects).map((v) => ({ value: v, @@ -25,6 +26,12 @@ const ProjectsBox = () => { ); const [ldReady, setLdReady] = useState(false); const [loginEnabled, setLoginEnabled] = useState(false); + const [isWalletLinking, setIsWalletLinking] = useState(false); + + const metaMaskWalletConnectionHandler = () => { + setIsWalletLinking(true); + metaMaskWalletIdConnectHandler(); + } useEffect(() => { ldClient.waitUntilReady().then(() => { @@ -41,9 +48,24 @@ const ProjectsBox = () => { }, []); useEffect(() => { - if (!currentProject.length && options[0]) setCurrentProject([options[0]]); + if (!currentProject.length && options[0]) { + setCurrentProject([options[0]]); + setUserAPIKey(options[0].value); + } }, [projects]); + useEffect(() => { + if (options?.length > 0) { + setUserAPIKey(options[0].value); + } + }, [options.length]); + + useEffect(() => { + if (walletLinked) { + setIsWalletLinking(false); + } + }, [walletLinked]) + return ( ldReady && loginEnabled && ( @@ -57,14 +79,17 @@ const ProjectsBox = () => { searchable={false} options={options} values={currentProject} - onChange={(value) => setCurrentProject(value)} + onChange={(value) => { + setCurrentProject(value); + setUserAPIKey(value[0].value); + }} contentRenderer={({ state }) => { return (
{state.values.map((item) => (
-
{item.label}
-
{item.value}
+
{item.label}
+
{item.value}
))}
@@ -75,12 +100,12 @@ const ProjectsBox = () => {
{options.map((option) => (
methods.addItem(option)} > -
{option.label}
-
{option.value}
+
{option.label}
+
{option.value}
))}
@@ -92,13 +117,17 @@ const ProjectsBox = () => { {walletLinked === undefined && ( <>
- Connect your MetaMask wallet to start sending requests to your - Infura API keys. + {isWalletLinking ? + "Don’t close or exit this page. Please continue connecting on your extension." : + "Connect your MetaMask wallet to start sending requests to your Infura API keys." + }
@@ -112,7 +141,8 @@ const ProjectsBox = () => {