Skip to content

Commit

Permalink
wallet-ext: account settings view support multiple accounts (MystenLa…
Browse files Browse the repository at this point in the history
  • Loading branch information
pchrysochoidis authored Feb 15, 2023
1 parent b6be236 commit 77bcada
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 21 deletions.
38 changes: 38 additions & 0 deletions apps/wallet/src/ui/app/components/menu/content/Account.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

import { Copy16 } from '@mysten/icons';

import { useMiddleEllipsis } from '_src/ui/app/hooks';
import { useCopyToClipboard } from '_src/ui/app/hooks/useCopyToClipboard';
import { Heading } from '_src/ui/app/shared/heading';

export type AccountProps = {
address: string;
};

export function Account({ address }: AccountProps) {
const addressShort = useMiddleEllipsis(address);
const copyCallback = useCopyToClipboard(address, {
copySuccessMessage: 'Address copied',
});
return (
<div className="flex flex-nowrap items-center border border-solid border-gray-60 rounded-lg p-5">
<div className="flex-1">
<Heading
mono
weight="semibold"
variant="heading6"
color="steel-dark"
leading="none"
>
{addressShort}
</Heading>
</div>
<Copy16
onClick={copyCallback}
className="transition text-base leading-none text-gray-60 active:text-gray-60 hover:text-hero-darkest cursor-pointer p1"
/>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

import { Account } from './Account';
import { MenuLayout } from './MenuLayout';
import AccountAddress from '_components/account-address';
import { useNextMenuUrl } from '_components/menu/hooks';
import { Text } from '_src/ui/app/shared/text';
import { useAccounts } from '_src/ui/app/hooks/useAccounts';

export function AccountsSettings() {
const backUrl = useNextMenuUrl(true, '/');
const accounts = useAccounts();
return (
<MenuLayout title="Accounts" back={backUrl}>
<div className="flex flex-col gap-3">
<Text color="gray-90" weight="medium" variant="p1">
Address
</Text>
<AccountAddress
mode="faded"
shorten={true}
showLink={false}
copyable
/>
{accounts.map(({ address }) => (
<Account address={address} key={address} />
))}
</div>
</MenuLayout>
);
Expand Down
6 changes: 4 additions & 2 deletions apps/wallet/src/ui/app/components/menu/content/MenuLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ export interface MenuLayoutProps extends PageTitleProps {
export function MenuLayout({ children, ...pageTitleProps }: MenuLayoutProps) {
return (
<>
<PageTitle {...pageTitleProps} />
<div className="flex flex-col justify-items-stretch flex-1 px-2.5 mt-4">
<div className="sticky top-0 bg-white py-4">
<PageTitle {...pageTitleProps} />
</div>
<div className="flex flex-col justify-items-stretch flex-1 px-2.5">
{children}
</div>
</>
Expand Down
2 changes: 1 addition & 1 deletion apps/wallet/src/ui/app/components/menu/content/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function MenuContent() {
return null;
}
return (
<div className="absolute flex flex-col justify-items-stretch inset-0 bg-white pt-4 pb-8 px-2.5 z-50 rounded-tl-20 rounded-tr-20">
<div className="absolute flex flex-col justify-items-stretch inset-0 bg-white pb-8 px-2.5 z-50 rounded-tl-20 rounded-tr-20 overflow-y-auto">
<ErrorBoundary>
<MainLocationContext.Provider value={mainLocation}>
<Routes location={menuUrl || ''}>
Expand Down
1 change: 0 additions & 1 deletion apps/wallet/src/ui/app/shared/text/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const textStyles = cva([], {
subtitleSmallExtra: 'text-subtitleSmallExtra',
caption: 'uppercase text-caption',
captionSmall: 'uppercase text-captionSmall ',
heading4: 'text-heading4',
p1: 'text-p1',
p2: 'text-p2',
p3: 'text-p3',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { useFeature } from '@growthbook/growthbook-react';
import { useMemo } from 'react';

import { Heading } from '../../shared/heading';
import { calculateAPY } from '../calculateAPY';
import { getStakingRewards } from '../getStakingRewards';
import { StakeAmount } from '../home/StakeAmount';
Expand Down Expand Up @@ -157,13 +158,14 @@ export function DelegationDetailCard({
}
>
<div className="flex gap-0.5 items-baseline">
<Text
<Heading
variant="heading4"
weight="semibold"
color="gray-90"
leading="none"
>
{apy}
</Text>
</Heading>

<Text
variant="subtitleSmall"
Expand All @@ -189,13 +191,14 @@ export function DelegationDetailCard({
}
>
<div className="flex gap-0.5 items-baseline">
<Text
<Heading
variant="heading4"
weight="semibold"
color="gray-90"
leading="none"
>
{commission}
</Text>
</Heading>

<Text
variant="subtitleSmall"
Expand Down
6 changes: 4 additions & 2 deletions apps/wallet/src/ui/app/staking/stake/UnstakeForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useEffect } from 'react';

import LoadingIndicator from '../../components/loading/LoadingIndicator';
import { useGasBudgetInMist } from '../../hooks/useGasBudgetInMist';
import { Heading } from '../../shared/heading';
import { Card } from '_app/shared/card';
import { Text } from '_app/shared/text';
import { useFormatCoin } from '_hooks';
Expand Down Expand Up @@ -59,13 +60,14 @@ export function UnStakeForm({
Your Stake
</Text>
<div className="flex gap-0.5 items-end">
<Text
<Heading
variant="heading4"
weight="semibold"
color="steel-darker"
leading="none"
>
{tokenBalance}
</Text>
</Heading>
<Text
variant="bodySmall"
weight="medium"
Expand Down

0 comments on commit 77bcada

Please sign in to comment.