Skip to content

Commit

Permalink
Wallet send sui redesign (MystenLabs#4018)
Browse files Browse the repository at this point in the history
* steps and coin select

* wip

* wip

* send coin

* fix receipt cta

* lint

* steps and coin select

* wip

* wip

* send coin

* fix receipt cta

* lint

* rebase and feedback update

* rebase and feedback update

* icons update

* remove unused css

* fixed typo

* update

* upate

* feedback update

* rename component

* update

* remove touched
  • Loading branch information
Jibz1 authored Aug 18, 2022
1 parent df9a941 commit 1f6ce84
Show file tree
Hide file tree
Showing 39 changed files with 1,428 additions and 293 deletions.
Binary file modified wallet/font-icons/output/sui-icons.eot
Binary file not shown.
22 changes: 12 additions & 10 deletions wallet/font-icons/output/sui-icons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@
.sui-icons-nfts:before { content: "\ea0f"; }
.sui-icons-percentage-polygon:before { content: "\ea10"; }
.sui-icons-person:before { content: "\ea11"; }
.sui-icons-sui-chevron-right:before { content: "\ea12"; }
.sui-icons-sui-logo-icon:before { content: "\ea13"; }
.sui-icons-sui-logo-txt:before { content: "\ea14"; }
.sui-icons-tokens:before { content: "\ea15"; }
.sui-icons-version-icon:before { content: "\ea16"; }
.sui-icons-search:before { content: "\ea12"; }
.sui-icons-sui-chevron-right:before { content: "\ea13"; }
.sui-icons-sui-logo-icon:before { content: "\ea14"; }
.sui-icons-sui-logo-txt:before { content: "\ea15"; }
.sui-icons-tokens:before { content: "\ea16"; }
.sui-icons-version-icon:before { content: "\ea17"; }

$sui-icons-Buy: "\ea01";
$sui-icons-Info: "\ea02";
Expand All @@ -55,9 +56,10 @@ $sui-icons-logout: "\ea0e";
$sui-icons-nfts: "\ea0f";
$sui-icons-percentage-polygon: "\ea10";
$sui-icons-person: "\ea11";
$sui-icons-sui-chevron-right: "\ea12";
$sui-icons-sui-logo-icon: "\ea13";
$sui-icons-sui-logo-txt: "\ea14";
$sui-icons-tokens: "\ea15";
$sui-icons-version-icon: "\ea16";
$sui-icons-search: "\ea12";
$sui-icons-sui-chevron-right: "\ea13";
$sui-icons-sui-logo-icon: "\ea14";
$sui-icons-sui-logo-txt: "\ea15";
$sui-icons-tokens: "\ea16";
$sui-icons-version-icon: "\ea17";

13 changes: 8 additions & 5 deletions wallet/font-icons/output/sui-icons.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions wallet/font-icons/output/sui-icons.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright (c) 2022, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

export enum SuiIcons {
Buy = "sui-icons-Buy",
Info = "sui-icons-Info",
Expand All @@ -19,13 +18,14 @@ export enum SuiIcons {
Nfts = "sui-icons-nfts",
PercentagePolygon = "sui-icons-percentage-polygon",
Person = "sui-icons-person",
Search = "sui-icons-search",
SuiChevronRight = "sui-icons-sui-chevron-right",
SuiLogoIcon = "sui-icons-sui-logo-icon",
SuiLogoTxt = "sui-icons-sui-logo-txt",
Tokens = "sui-icons-tokens",
VersionIcon = "sui-icons-version-icon"
}

export type SuiIconsClassname = "sui-icons-Buy" | "sui-icons-Info" | "sui-icons-Preview" | "sui-icons-apps" | "sui-icons-arrow-left" | "sui-icons-arrow-right" | "sui-icons-checkmark" | "sui-icons-clipboard" | "sui-icons-close" | "sui-icons-coins" | "sui-icons-globe" | "sui-icons-hand-coins" | "sui-icons-history" | "sui-icons-logout" | "sui-icons-nfts" | "sui-icons-percentage-polygon" | "sui-icons-person" | "sui-icons-sui-chevron-right" | "sui-icons-sui-logo-icon" | "sui-icons-sui-logo-txt" | "sui-icons-tokens" | "sui-icons-version-icon"
export type SuiIconsIcon = "Buy" | "Info" | "Preview" | "apps" | "arrow-left" | "arrow-right" | "checkmark" | "clipboard" | "close" | "coins" | "globe" | "hand-coins" | "history" | "logout" | "nfts" | "percentage-polygon" | "person" | "sui-chevron-right" | "sui-logo-icon" | "sui-logo-txt" | "tokens" | "version-icon"
export const SuiIconsPrefix = "sui-icons-"
export type SuiIconsClassname = "sui-icons-Buy" | "sui-icons-Info" | "sui-icons-Preview" | "sui-icons-apps" | "sui-icons-arrow-left" | "sui-icons-arrow-right" | "sui-icons-checkmark" | "sui-icons-clipboard" | "sui-icons-close" | "sui-icons-coins" | "sui-icons-globe" | "sui-icons-hand-coins" | "sui-icons-history" | "sui-icons-logout" | "sui-icons-nfts" | "sui-icons-percentage-polygon" | "sui-icons-person" | "sui-icons-search" | "sui-icons-sui-chevron-right" | "sui-icons-sui-logo-icon" | "sui-icons-sui-logo-txt" | "sui-icons-tokens" | "sui-icons-version-icon"
export type SuiIconsIcon = "Buy" | "Info" | "Preview" | "apps" | "arrow-left" | "arrow-right" | "checkmark" | "clipboard" | "close" | "coins" | "globe" | "hand-coins" | "history" | "logout" | "nfts" | "percentage-polygon" | "person" | "search" | "sui-chevron-right" | "sui-logo-icon" | "sui-logo-txt" | "tokens" | "version-icon"
export const SuiIconsPrefix = "sui-icons-"
Binary file modified wallet/font-icons/output/sui-icons.ttf
Binary file not shown.
Binary file modified wallet/font-icons/output/sui-icons.woff
Binary file not shown.
Binary file modified wallet/font-icons/output/sui-icons.woff2
Binary file not shown.
3 changes: 3 additions & 0 deletions wallet/font-icons/svgs/search.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
@use '_utils';
@use '_variables' as v;
@use '_values/colors';

.content {
display: flex;
flex-flow: column nowrap;
flex: 1;
align-self: stretch;
margin: 10px 0;

.coin-label {
font-weight: 600;
width: 86%;
}

.chevron {
i {
font-size: 10px;
color: colors.$gray-65;
font-weight: 200;
}
}

.coin-list {
.selector-content {
margin-top: 25px;
height: 100%;
}

.coin-detail {
margin-top: 20px;
height: 63px;
border-radius: 6px;
display: flex;
justify-content: space-between;
align-items: center;
width: 100%;
border-bottom: 1px solid colors.$gray-45;
cursor: pointer;
gap: 10px;
transition: all 0.2s ease-in-out;

&:hover {
&::after {
background-color: #6fbcf01a;
position: absolute;
content: '';
left: 10px;
width: calc(100% - 20px);
height: 63px;
}
}

.coin-label {
@include utils.typography('table/text-lg');

width: 55%;
display: flex;
flex-direction: column;
color: colors.$gray-100;
gap: 4px;
font-weight: 600;

span {
color: colors.$gray-65;
}
}

.coin-amount {
@include utils.typography('table/text-lg');

line-height: 17px;
}

.coin-icon {
color: colors.$sui-blue;
background-color: colors.$gray-40;
width: 30px;
height: 30px;
border-radius: 30px;
display: inline-flex;
justify-content: center;
align-items: center;

i {
font-size: 18px;
color: colors.$sui-blue;
}
}
}
}
}

.select-coin {
height: 80px;
display: flex;
flex-direction: column;
align-items: flex-start;
background-color: colors.$white;
box-shadow: 0 1px 2px colors.$shadow-color;
border: 1px solid colors.$gray-50;
border-radius: 10px;
}

.coin {
@include utils.typography('table/text-lg');

text-decoration: none;
padding: 0 14px;
line-height: 17px;
width: 100%;
height: 100%;
color: colors.$gray-100;
display: flex;
align-items: center;
gap: 10px;
cursor: pointer;

.sui-icon {
color: colors.$sui-blue;
background-color: colors.$gray-40;
width: 24px;
height: 24px;
border-radius: 30px;
display: inline-flex;
justify-content: center;
align-items: center;
}
}

.coin-symbol {
@include utils.typography('table/text-xs');

color: colors.$gray-70;
}

.coin-balance {
@include utils.typography('table/text-lg');

color: colors.$gray-100;
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
padding: 0 14px;
width: 100%;
height: 100%;
background-color: colors.$gray-40;
}
125 changes: 125 additions & 0 deletions wallet/src/ui/app/components/active-coins-card/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
// Copyright (c) 2022, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

import { useMemo, useCallback } from 'react';
import { useIntl } from 'react-intl';
import { useNavigate, Link } from 'react-router-dom';

import Icon, { SuiIcons } from '_components/icon';
import { useAppSelector } from '_hooks';
import { accountAggregateBalancesSelector } from '_redux/slices/account';
import {
GAS_TYPE_ARG,
SUPPORTED_COINS_LIST,
} from '_redux/slices/sui-objects/Coin';
import { balanceFormatOptions } from '_shared/formatting';

import st from './ActiveCoinsCard.module.scss';

// Get all the coins that are available in the account.
// default coin type is GAS_TYPE_ARG unless specified in props
// create a list of coins that are available in the account
function ActiveCoinsCard({
activeCoinType = GAS_TYPE_ARG,
showActiveCoin = true,
}: {
activeCoinType: string;
showActiveCoin?: boolean;
}) {
const intl = useIntl();
const aggregateBalances = useAppSelector(accountAggregateBalancesSelector);

const coins = useMemo(() => {
return SUPPORTED_COINS_LIST.map((coin) => {
const balance = intl.formatNumber(
BigInt(aggregateBalances[coin.coinType] || 0),
balanceFormatOptions
);
return {
...coin,
balance,
};
});
}, [aggregateBalances, intl]);

const activeCoin = useMemo(() => {
return coins.filter((coin) => coin.coinType === activeCoinType)[0];
}, [activeCoinType, coins]);

const IconName = activeCoin.coinIconName;

const SelectedCoinCard = (
<div className={st.selectCoin}>
<Link
to={`/send/select?${new URLSearchParams({
type: activeCoinType,
}).toString()}`}
className={st.coin}
>
<div className={st.suiIcon}>
<Icon icon={IconName} />
</div>
<div className={st.coinLabel}>
{activeCoin.coinName}{' '}
<span className={st.coinSymbol}>
{activeCoin.coinSymbol}
</span>
</div>
<div className={st.chevron}>
<Icon icon={SuiIcons.SuiChevronRight} />
</div>
</Link>
<div className={st.coinBalance}>
<div className={st.coinBalanceLabel}>Total Available</div>
<div className={st.coinBalanceValue}>
{activeCoin.balance} {activeCoin.coinSymbol}
</div>
</div>
</div>
);

const navigate = useNavigate();

const changeConType = useCallback(
(event: React.MouseEvent<HTMLDivElement>) => {
const cointype = event.currentTarget.dataset.cointype as string;
navigate(
`/send?${new URLSearchParams({
type: cointype,
}).toString()}`
);
},
[navigate]
);

const CoinListCard = (
<div className={st.coinList}>
{coins.map((coin, index) => (
<div
className={st.coinDetail}
key={index}
onClick={changeConType}
data-cointype={coin.coinType}
>
<div className={st.coinIcon}>
<Icon icon={coin.coinIconName} />
</div>
<div className={st.coinLabel}>
{coin.coinName} <span>{coin.coinSymbol}</span>
</div>
<div className={st.coinAmount}>
{coin.balance} <span>{coin.coinSymbol}</span>
</div>
</div>
))}
</div>
);

return (
<div className={st.content}>
{showActiveCoin ? SelectedCoinCard : CoinListCard}
</div>
);
}

export default ActiveCoinsCard;
Loading

0 comments on commit 1f6ce84

Please sign in to comment.