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

Basin UI - Fix home height + Fix connect wallet disabled #723

Merged
merged 2 commits into from
Dec 14, 2023
Merged
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
20 changes: 20 additions & 0 deletions projects/dex-ui/src/components/ConnectWalletButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { ConnectKitButton } from "connectkit";
import React, { ComponentProps } from "react";
import { Button } from "src/components/Swap/Button";
import { useAccount } from "wagmi";

type ActionWalletButtonProps = ComponentProps<typeof Button>;

export const ActionWalletButton = (props: ActionWalletButtonProps) => {
const { address } = useAccount();

return !address ? (
<ConnectKitButton.Custom>
{({ show }) => {
return <Button onClick={show} label="Connect Wallet" />;
}}
</ConnectKitButton.Custom>
) : (
<Button {...props} />
);
Space-Bean marked this conversation as resolved.
Show resolved Hide resolved
};
3 changes: 2 additions & 1 deletion projects/dex-ui/src/components/Liquidity/AddLiquidity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { useWellReserves } from "src/wells/useWellReserves";
import { Checkbox } from "../Checkbox";
import { size } from "src/breakpoints";
import { LoadingTemplate } from "src/components/LoadingTemplate";
import { ActionWalletButton } from "../ConnectWalletButton";

type BaseAddLiquidityProps = {
slippage: number;
Expand Down Expand Up @@ -403,7 +404,7 @@ const AddLiquidityContent = ({ well, slippage, slippageSettingsClickHandler, han
return null;
})}
<ButtonWrapper>
<AddLiquidityButton
<ActionWalletButton
disabled={!addLiquidityButtonEnabled}
loading={false}
label={`${buttonLabel} →`}
Expand Down
4 changes: 2 additions & 2 deletions projects/dex-ui/src/components/Liquidity/RemoveLiquidity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { size } from "src/breakpoints";
import { displayTokenSymbol } from "src/utils/format";
import { LoadingTemplate } from "../LoadingTemplate";
import { useLPPositionSummary } from "src/tokens/useLPPositionSummary";
import { ActionWalletButton } from "../ConnectWalletButton";

type BaseRemoveLiquidityProps = {
slippage: number;
Expand Down Expand Up @@ -416,9 +417,8 @@ const RemoveLiquidityContent = ({ well, slippage, slippageSettingsClickHandler,
/>
</ButtonWrapper>
)}

<ButtonWrapper>
<Button
<ActionWalletButton
disabled={!removeLiquidityButtonEnabled}
label={buttonLabel}
onClick={removeLiquidityButtonClickHandler}
Expand Down
7 changes: 3 additions & 4 deletions projects/dex-ui/src/components/Swap/SwapRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import { useAllTokensBalance } from "src/tokens/useAllTokenBalance";
import { useSwapBuilder } from "./useSwapBuilder";
import { useAccount } from "wagmi";
import { Quote, QuoteResult } from "@beanstalk/sdk/Wells";
import { Button } from "./Button";
import { Log } from "src/utils/logger";
import { useSearchParams } from "react-router-dom";
import { TransactionToast } from "../TxnToast/TransactionToast";
import QuoteDetails from "../Liquidity/QuoteDetails";
import { getPrice } from "src/utils/price/usePrice";
import useSdk from "src/utils/sdk/useSdk";
import { size } from "src/breakpoints";
import { ActionWalletButton } from "src/components/ConnectWalletButton";

const NULL_ADDRESS = "0x0000000000000000000000000000000000000000";

Expand Down Expand Up @@ -320,15 +320,14 @@ export const SwapRoot = () => {
};

const getLabel = useCallback(() => {
if (!account) return "Connect Wallet";
if (!inAmount && !outAmount) return "Enter Amount";
if (inToken.address === outToken.address) return "Select different output token";
if (inAmount?.eq(TokenValue.ZERO) && outAmount?.eq(TokenValue.ZERO)) return "Enter Amount";
if (!hasEnoughBalance) return "Insufficient Balance";
if (needsApproval) return "Approve";

return "Swap";
}, [account, hasEnoughBalance, inAmount, needsApproval, outAmount, inToken, outToken]);
}, [hasEnoughBalance, inAmount, needsApproval, outAmount, inToken, outToken]);

if (Object.keys(tokens).length === 0)
return <Container>There are no tokens. Please check you are connected to the right network.</Container>;
Expand Down Expand Up @@ -375,7 +374,7 @@ export const SwapRoot = () => {
tokenPrices={prices}
/>
<SwapButtonContainer data-trace="true">
<Button label={getLabel()} disabled={!buttonEnabled} onClick={handleButtonClick} loading={txLoading} />
<ActionWalletButton label={getLabel()} disabled={!buttonEnabled} onClick={handleButtonClick} loading={txLoading} />
</SwapButtonContainer>
</Container>
);
Expand Down
6 changes: 5 additions & 1 deletion projects/dex-ui/src/pages/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ const InfoContainer = styled.div`
gap: 8px;
box-sizing: border-box;
height: 100%;

${mediaQuery.sm.up} {
padding-top: min(25%, 185px);
justify-content: flex-start
Expand Down Expand Up @@ -292,6 +292,10 @@ const AccordionContainer = styled.div`
gap: 24px;
width: 100%;

${mediaQuery.sm.up} {
padding-bottom: 150px;
}

/// Tablet
${mediaQuery.md.only} {
width: 100%;
Expand Down