Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
522d481
style(tangle-dapp): Design changes in jam meeting
yuri-xyz Nov 20, 2024
23fccf0
style(tangle-dapp): Improve design consistency
yuri-xyz Nov 20, 2024
cb518e8
style(tangle-dapp): Improve table design consistency
yuri-xyz Nov 21, 2024
e5c515a
style(tangle-dapp): Continue improving table design consistency
yuri-xyz Nov 21, 2024
e6b7109
Merge branch 'develop' into yuri/design-jam-changes
yuri-xyz Nov 21, 2024
0de113f
style(tangle-dapp): Use table variants
yuri-xyz Nov 21, 2024
f518cf0
style(tangle-dapp): Fix more design details
yuri-xyz Nov 21, 2024
1c4ac87
style(tangle-dapp): Consistent containers
yuri-xyz Nov 22, 2024
5b1eb03
style(tangle-dapp): Improve wallet connection card
yuri-xyz Nov 22, 2024
56b12a5
style(tangle-dapp): Small improvements
yuri-xyz Nov 22, 2024
fb09d69
style(tangle-dapp): Remove breadcrumbs as not useful
yuri-xyz Nov 22, 2024
b67afd9
Merge branch 'develop' into yuri/design-jam-changes
yuri-xyz Nov 22, 2024
3eb020f
style(tangle-dapp): More fixes
yuri-xyz Nov 23, 2024
f9bac33
style(tangle-dapp): Fix connect wallet responsiveness
yuri-xyz Nov 23, 2024
c77c33a
style(tangle-dapp): Theme fixes
yuri-xyz Nov 23, 2024
8f57947
style(tangle-dapp): Improve colors
yuri-xyz Nov 23, 2024
9813bfb
fix(tangle-dapp): Fix sidebar toggle bug
yuri-xyz Nov 23, 2024
21fd882
refactor(tangle-dapp): Minor changes
yuri-xyz Nov 24, 2024
7a1b385
refactor(tangle-dapp): Reuse `Card` component
yuri-xyz Nov 24, 2024
3e19f87
style(tangle-dapp): Improve bg color consistency
yuri-xyz Nov 24, 2024
5a6764f
style(tangle-dapp): Fix modal input backgrounds
yuri-xyz Nov 24, 2024
5c7cef6
fix(tangle-dapp): Fix connect wallet content not shown in mobile
yuri-xyz Nov 24, 2024
13177c0
fix(tangle-dapp): Final fixes
yuri-xyz Nov 25, 2024
1fd6403
ci(tangle-dapp): Fix build error
yuri-xyz Nov 25, 2024
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
24 changes: 13 additions & 11 deletions apps/tangle-dapp/app/bridge/AmountAndTokenInput.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
'use client';

import { makeExplorerUrl } from '@webb-tools/api-provider-environment/transaction/utils';
import { Modal, ModalContent, useModal } from '@webb-tools/webb-ui-components';
import {
EMPTY_VALUE_PLACEHOLDER,
Modal,
ModalContent,
useModal,
} from '@webb-tools/webb-ui-components';
import ChainOrTokenButton from '@webb-tools/webb-ui-components/components/buttons/ChainOrTokenButton';
import SkeletonLoader from '@webb-tools/webb-ui-components/components/SkeletonLoader';
import { Typography } from '@webb-tools/webb-ui-components/typography/Typography';
Expand Down Expand Up @@ -134,10 +139,11 @@ const AmountAndTokenInput: FC = () => {
}, [tokenBalances, selectedToken.id]);

return (
<div className="relative">
<div className="flex flex-col gap-2 justify-center items-end">
<div
className={twMerge(
'w-full flex items-center gap-2 bg-mono-20 dark:bg-mono-170 rounded-lg pr-4',
'w-full flex items-center gap-2 rounded-lg pr-4',
'bg-mono-20 dark:bg-mono-180',
isAmountInputError && 'border border-red-70 dark:border-red-50',
)}
>
Expand All @@ -150,7 +156,7 @@ const AmountAndTokenInput: FC = () => {
isFullWidth: true,
}}
placeholder=""
wrapperClassName="!pr-0 !border-0"
wrapperClassName="!pr-0 !border-0 dark:bg-mono-180"
max={balance ? convertDecimalToBn(balance, decimals) : null}
maxErrorMessage="Insufficient balance"
min={minAmount ? convertDecimalToBn(minAmount, decimals) : null}
Expand All @@ -159,15 +165,14 @@ const AmountAndTokenInput: FC = () => {
setErrorMessage={(error) =>
setIsAmountInputError(error ? true : false)
}
errorMessageClassName="absolute left-0 bottom-[-24px] !text-[14px] !leading-[21px]"
/>

{/* Token Selector */}
<ChainOrTokenButton
value={selectedToken.symbol}
iconType="token"
onClick={openTokenModal}
className="w-[130px] border-0 px-3 bg-mono-40 dark:bg-mono-140"
className="min-w-[130px]"
status="success"
/>
</div>
Expand All @@ -178,14 +183,11 @@ const AmountAndTokenInput: FC = () => {
className="w-[100px] absolute right-0 bottom-[-24px]"
/>
) : (
<Typography
variant="body2"
className="absolute right-0 bottom-[-24px] text-mono-120 dark:text-mono-100"
>
<Typography variant="body2">
Balance:{' '}
{selectedAssetBalance !== null
? `${selectedAssetBalance.toString()} ${selectedToken.symbol}`
: 'N/A'}
: EMPTY_VALUE_PLACEHOLDER}
</Typography>
)}

Expand Down
77 changes: 39 additions & 38 deletions apps/tangle-dapp/app/bridge/BridgeContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use client';

import { Card } from '@webb-tools/webb-ui-components';
import Button from '@webb-tools/webb-ui-components/components/buttons/Button';
import { FC, useState } from 'react';
import { twMerge } from 'tailwind-merge';
Expand All @@ -14,9 +15,9 @@ import ChainSelectors from './ChainSelectors';
import FeeDetails from './FeeDetails';
import useActionButton from './hooks/useActionButton';

interface BridgeContainerProps {
type BridgeContainerProps = {
className?: string;
}
};

const BridgeContainer: FC<BridgeContainerProps> = ({ className }) => {
const {
Expand Down Expand Up @@ -46,50 +47,50 @@ const BridgeContainer: FC<BridgeContainerProps> = ({ className }) => {

return (
<>
<div
<Card
withShadow
className={twMerge(
'max-w-[640px] min-h-[580px] bg-mono-0 dark:bg-mono-190 p-5 md:p-8 rounded-xl',
'shadow-webb-lg dark:shadow-webb-lg-dark',
'flex flex-col',
'flex flex-col gap-7 w-full max-w-[590px]',
className,
)}
>
<div className="flex flex-col justify-between flex-1">
<div className="flex flex-col gap-10">
<ChainSelectors />

<AmountAndTokenInput />
<div className="flex flex-col gap-7">
<ChainSelectors />

<AddressInput
id="bridge-destination-address-input"
type={
isEVMChain(selectedDestinationChain)
? AddressType.EVM
: AddressType.Substrate
}
title="Recipient Address"
wrapperOverrides={{ isFullWidth: true }}
value={destinationAddress}
setValue={setDestinationAddress}
setErrorMessage={(error) =>
setIsAddressInputError(error ? true : false)
}
/>
<AmountAndTokenInput />

{!hideFeeDetails && <FeeDetails />}
</div>
<AddressInput
id="bridge-destination-address-input"
type={
isEVMChain(selectedDestinationChain)
? AddressType.EVM
: AddressType.Substrate
}
title="Recipient Address"
wrapperOverrides={{
isFullWidth: true,
wrapperClassName: 'dark:bg-mono-180',
}}
value={destinationAddress}
setValue={setDestinationAddress}
setErrorMessage={(error) =>
setIsAddressInputError(error ? true : false)
}
/>

<Button
isFullWidth
isDisabled={isDisabled}
isLoading={isLoading}
onClick={buttonAction}
loadingText={buttonLoadingText}
>
{buttonText}
</Button>
{!hideFeeDetails && <FeeDetails />}
</div>
</div>

<Button
isFullWidth
isDisabled={isDisabled}
isLoading={isLoading}
onClick={buttonAction}
loadingText={buttonLoadingText}
>
{buttonText}
</Button>
</Card>

<BridgeConfirmationModal
isOpen={isConfirmModalOpen}
Expand Down
12 changes: 5 additions & 7 deletions apps/tangle-dapp/app/bridge/ChainSelectors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const ChainSelectors: FC = () => {
return (
<div className="flex flex-col md:flex-row justify-center md:justify-between items-center md:items-end md:gap-3">
{/* Source Chain Selector */}
<div className="flex flex-col gap-2 w-full">
<div className="flex flex-col gap-2 flex-1">
<Label
className="text-mono-120 dark:text-mono-120 font-bold"
htmlFor="bridge-source-chain-selector"
Expand All @@ -100,23 +100,22 @@ const ChainSelectors: FC = () => {

<ChainOrTokenButton
value={selectedSourceChain.name}
textClassName="text-xl"
className="w-full !p-4 bg-mono-20 dark:bg-mono-170 border-0 hover:bg-mono-20 dark:hover:bg-mono-170 text-nowrap"
className="w-full min-h-[72px] dark:bg-mono-180"
iconType="chain"
onClick={openSourceChainModal}
disabled={sourceChainOptions.length <= 1}
/>
</div>

<div
className="cursor-pointer px-1 pt-5 md:pt-0 md:pb-5"
className="flex-shrink cursor-pointer px-1 pt-5 md:pt-0 md:pb-5"
onClick={onSwitchChains}
>
<ArrowRight size="lg" className="rotate-90 md:rotate-0" />
</div>

{/* Destination Chain Selector */}
<div className="flex flex-col gap-2 w-full">
<div className="flex flex-col gap-2 flex-1">
<Label
className="text-mono-120 dark:text-mono-120 font-bold"
htmlFor="bridge-destination-chain-selector"
Expand All @@ -126,8 +125,7 @@ const ChainSelectors: FC = () => {

<ChainOrTokenButton
value={selectedDestinationChain.name}
textClassName="text-xl"
className="w-full !p-4 bg-mono-20 dark:bg-mono-170 border-0 hover:bg-mono-20 dark:hover:bg-mono-170 text-nowrap"
className="w-full min-h-[72px] dark:bg-mono-180"
iconType="chain"
onClick={openDestinationChainModal}
disabled={destinationChainOptions.length <= 1}
Expand Down
16 changes: 13 additions & 3 deletions apps/tangle-dapp/app/bridge/FeeDetails.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use client';

import { EMPTY_VALUE_PLACEHOLDER } from '@webb-tools/webb-ui-components';
import FeeDetailsCmp from '@webb-tools/webb-ui-components/components/FeeDetails';
import type { FeeItem } from '@webb-tools/webb-ui-components/components/FeeDetails/types';
import { Typography } from '@webb-tools/webb-ui-components/typography/Typography';
Expand Down Expand Up @@ -93,7 +94,9 @@ const FeeValueCmp: FC<{ fee: Decimal | null; symbol: string }> = ({
}) => {
return (
<Typography variant="body1" className="!text-mono-200 dark:!text-mono-0">
{fee ? `${fee.toDecimalPlaces(5).toString()} ${symbol}` : 'N/A'}
{fee
? `${fee.toDecimalPlaces(5).toString()} ${symbol}`
: EMPTY_VALUE_PLACEHOLDER}
</Typography>
);
};
Expand All @@ -104,9 +107,16 @@ function formatTotalAmount(
const symbolTotals: Record<string, Decimal> = {};

for (const [, item] of Object.entries(feeItems)) {
if (item === null) continue;
if (item === null) {
continue;
}

const { amount, symbol } = item;
if (!amount) continue;

if (!amount) {
continue;
}

symbolTotals[symbol] = (symbolTotals[symbol] ?? new Decimal(0)).plus(
amount,
);
Expand Down
8 changes: 5 additions & 3 deletions apps/tangle-dapp/app/bridge/hooks/useActionButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,11 @@ export default function useActionButton({
]);

const buttonLoadingText = useMemo(() => {
if (isRequiredToConnectWallet || isSelectedNetworkAndSourceChainMismatch)
return 'Connecting...';
if (isTransferring) return 'Transferring...';
if (isRequiredToConnectWallet || isSelectedNetworkAndSourceChainMismatch) {
return 'Connecting';
} else if (isTransferring) {
return 'Transferring';
}
}, [
isRequiredToConnectWallet,
isSelectedNetworkAndSourceChainMismatch,
Expand Down
4 changes: 2 additions & 2 deletions apps/tangle-dapp/app/bridge/lib/balance/substrate.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ApiPromise } from '@polkadot/api';
import Decimal from 'decimal.js';

import { calculateTransferrableBalance } from '../../../../utils/polkadot/balance';
import { calculateTransferableBalance } from '../../../../utils/polkadot/balance';

export async function getSubstrateNativeTransferable(params?: {
api: ApiPromise;
Expand All @@ -10,7 +10,7 @@ export async function getSubstrateNativeTransferable(params?: {
if (!params) return null;
const { api, accAddress } = params;
const accInfo = (await api.query.system.account(accAddress)).data;
const transferable = calculateTransferrableBalance(accInfo);
const transferable = calculateTransferableBalance(accInfo);

// Convert to the right format based on the chain's decimals
return new Decimal(transferable.toString()).div(
Expand Down
39 changes: 1 addition & 38 deletions apps/tangle-dapp/app/bridge/page.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
import {
ExchangeFunds,
TokenSwapLineIcon,
WalletLineIcon,
} from '@webb-tools/icons';
import { OnboardingPageKey } from '@webb-tools/tangle-shared-ui/constants';
import { TANGLE_DOCS_URL } from '@webb-tools/webb-ui-components';
import { Metadata } from 'next';
import { FC } from 'react';

import OnboardingItem from '../../components/OnboardingModal/OnboardingItem';
import OnboardingModal from '../../components/OnboardingModal/OnboardingModal';
import createPageMetadata from '../../utils/createPageMetadata';
import BridgeContainer from './BridgeContainer';

Expand All @@ -18,35 +9,7 @@ export const metadata: Metadata = createPageMetadata({
});

const Bridge: FC = () => {
return (
<div>
<OnboardingModal
title="Get Started with Bridging"
pageKey={OnboardingPageKey.BRIDGE}
learnMoreHref={TANGLE_DOCS_URL}
>
<OnboardingItem
Icon={WalletLineIcon}
title="Connect EVM or Substrate Wallet"
description="Connect your EVM or Substrate wallet depending on the intended source chain. For example, if bridging in assets from Ethereum, connect your MetaMask or EVM-based wallet."
/>

<OnboardingItem
Icon={ExchangeFunds}
title="Bridge EVM Assets"
description="Select source and destination chains, amount, and the recipient account's address to bridge in your EVM-based assets into Tangle to start restaking."
/>

<OnboardingItem
Icon={TokenSwapLineIcon}
title="Restake Your Assets"
description="After bridging, use the restake page to leverage your bridged assets in restaking in order to earn yield and help secure and power Blueprint services on Tangle."
/>
</OnboardingModal>

<BridgeContainer className="mx-auto" />
</div>
);
return <BridgeContainer className="mx-auto" />;
};

export default Bridge;
21 changes: 12 additions & 9 deletions apps/tangle-dapp/app/claim/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Card, CardVariant } from '@webb-tools/webb-ui-components';
import { Divider } from '@webb-tools/webb-ui-components/components/Divider';
import { AppTemplate } from '@webb-tools/webb-ui-components/containers/AppTemplate';
import FAQSection from '@webb-tools/webb-ui-components/containers/FAQSection';
Expand All @@ -19,17 +20,19 @@ export const metadata: Metadata = createPageMetadata({

const Layout: FC<PropsWithChildren> = ({ children }) => {
return (
<AppTemplate.Root className="bg-glass dark:bg-glass_dark">
{children}
<AppTemplate.Root className="border-none p-0 rounded-none">
<Card variant={CardVariant.GLASS} className="space-y-4 py-8">
{children}

<Divider className="my-16 bg-mono-180 dark:bg-mono-120" />
<Divider className="my-16 bg-mono-180 dark:bg-mono-120" />

<AppTemplate.Content>
<FAQSection
items={faqItems}
answerClassName="[&_a:hover]:text-mono-100 [&_a]:underline"
/>
</AppTemplate.Content>
<AppTemplate.Content className="w-full">
<FAQSection
items={faqItems}
answerClassName="[&_a:hover]:text-mono-100 [&_a]:underline"
/>
</AppTemplate.Content>
</Card>
</AppTemplate.Root>
);
};
Expand Down
Loading