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

thisyahlen/chore: update ui for wallet header #9870

Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
cb7a322
chore: update ui for wallet header
thisyahlen-deriv Aug 30, 2023
acf0997
chore: add more styles
thisyahlen-deriv Aug 30, 2023
35b1f41
chore: add more styles v2
thisyahlen-deriv Aug 30, 2023
aca408f
fix: lint errors
thisyahlen-deriv Aug 30, 2023
1d290aa
Merge branch 'master' of github.com:binary-com/deriv-app into thisyah…
thisyahlen-deriv Aug 30, 2023
a4fabe9
Merge branch 'master' of github.com:binary-com/deriv-app into thisyah…
thisyahlen-deriv Aug 30, 2023
58f75eb
chore: split components
thisyahlen-deriv Aug 30, 2023
b1b32d2
chore: split v2
thisyahlen-deriv Aug 30, 2023
856b20b
chore: split v3
thisyahlen-deriv Aug 30, 2023
e9f5595
chore: add svg for header button actions
thisyahlen-deriv Aug 30, 2023
df56d2d
fix: format balance and css styles
thisyahlen-deriv Aug 30, 2023
8bab54d
fix: landing company name uppercase
thisyahlen-deriv Aug 30, 2023
fe307ae
fix: comments
thisyahlen-deriv Aug 30, 2023
0ca28fa
Merge branch 'master' of github.com:thisyahlen-deriv/deriv-app into t…
thisyahlen-deriv Sep 1, 2023
2d64be6
chore: split moreeeee
thisyahlen-deriv Sep 1, 2023
e40cf64
fix: rename css
thisyahlen-deriv Sep 1, 2023
62f3a9c
fix: conflicts
thisyahlen-deriv Sep 1, 2023
1fda954
Merge branch 'master' of github.com:thisyahlen-deriv/deriv-app into t…
thisyahlen-deriv Sep 2, 2023
bce6542
fix: lint styles
thisyahlen-deriv Sep 2, 2023
031e4ba
fix: styles
thisyahlen-deriv Sep 4, 2023
4f0ce22
fix: comments
thisyahlen-deriv Sep 4, 2023
064ea28
fix: comments v3
thisyahlen-deriv Sep 4, 2023
2912dec
fix: comments v4
thisyahlen-deriv Sep 4, 2023
9237894
fix: comments v5
thisyahlen-deriv Sep 4, 2023
7e84dc7
fix: comments
thisyahlen-deriv Sep 4, 2023
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
7 changes: 7 additions & 0 deletions packages/api/src/hooks/useCurrencyConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ const useCurrencyConfig = () => {
code: currency,
/** Currency display code */
display_code: currency === 'UST' ? 'USDT' : currency,
/** Format the balance */
formatBalance: (amount: number) => {
return new Intl.NumberFormat('en-US', {
minimumFractionDigits: 2,
maximumFractionDigits: 2,
}).format(amount);
},
};
});
}, [website_status_data?.website_status?.currencies_config]);
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/hooks/useWalletAccountsList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const useWalletAccountsList = () => {
/** Returns the wallet's currency type. ex: `Demo`, `USD`, etc. */
wallet_currency_type,
/** Landing company shortcode the account belongs to. */
landing_company_name: wallet.landing_company_name?.replace('maltainvest', 'malta'),
landing_company_name: wallet.landing_company_name?.replace('maltainvest', 'malta').toUpperCase(),
thisyahlen-deriv marked this conversation as resolved.
Show resolved Hide resolved
/** Indicating whether the wallet is a maltainvest wallet. */
is_malta_wallet: wallet.landing_company_name === 'malta',
} as const;
Expand Down
19 changes: 19 additions & 0 deletions packages/wallets/src/AppContent.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.app-content {
display: flex;
flex-direction: column;
align-items: center;
gap: 24px;
padding: 40px;
width: 100%;
height: 100%;
align-self: stretch;
background: var(--system-light-7-secondary-background, #f2f3f4);

&__content {
width: 100%;
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 24px;
}
}
17 changes: 8 additions & 9 deletions packages/wallets/src/AppContent.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import React from 'react';
import WalletList from './components/WalletList';
import WalletsCarousel from './components/WalletCarousel';
import IcBrandDerivGo from './public/ic-brand-derivgo.svg';
import './app-content.scss';
import { WalletHeader } from './components';
// import WalletsCarousel from './components/WalletCarousel';
import './AppContent.scss';

const AppContent: React.FC = () => {
return (
<div>
<div className='icon' />
<IcBrandDerivGo width={25} height={25} />
<WalletList />
<WalletsCarousel />
<div className='app-content'>
<div className='app-content__content'>
<WalletHeader />
thisyahlen-deriv marked this conversation as resolved.
Show resolved Hide resolved
</div>
{/* <WalletsCarousel /> */}
</div>
);
};
Expand Down
6 changes: 0 additions & 6 deletions packages/wallets/src/app-content.scss

This file was deleted.

31 changes: 31 additions & 0 deletions packages/wallets/src/components/WalletBalance/WalletBalance.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
.wallet-balance {
&__container {
display: flex;
flex-direction: column;
align-items: flex-end;
}

&__title {
color: var(--system-light-3-less-prominent-text, #999);
text-align: right;

/* desktop/small/S - regular */
font-family: 'IBM Plex Sans';
font-size: 12px;
font-style: normal;
font-weight: 400;
line-height: 18px; /* 150% */
}

&__value {
color: var(--system-light-1-prominent-text, #333);
text-align: right;

/* desktop/subtitle/Sub 1 - bold */
font-family: 'IBM Plex Sans';
font-size: 24px;
font-style: normal;
font-weight: 700;
line-height: 36px; /* 150% */
}
}
20 changes: 20 additions & 0 deletions packages/wallets/src/components/WalletBalance/WalletBalance.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react';
import { useWalletAccountsList } from '@deriv/api';
import './WalletBalance.scss';

const WalletBalance = ({
account,
}: {
account: NonNullable<ReturnType<typeof useWalletAccountsList>['data']>[number];
}) => {
thisyahlen-deriv marked this conversation as resolved.
Show resolved Hide resolved
return (
<div className='wallet-balance__container'>
<div className='wallet-balance__title'>Wallet balance</div>
<div className='wallet-balance__value'>
{account.currency_config?.formatBalance(account?.balance)} {account?.currency}
</div>
</div>
);
};

export default WalletBalance;
1 change: 1 addition & 0 deletions packages/wallets/src/components/WalletBalance/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as WalletBalance } from './WalletBalance';
12 changes: 12 additions & 0 deletions packages/wallets/src/components/WalletCardIcon/WalledCardIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';
import './WalletCardIcon.scss';

const WalletCardIcon: React.FC = () => {
return (
<div className='wallet-card__icon'>
<p> Icon (Placeholder)</p>
</div>
);
};

export default WalletCardIcon;
17 changes: 17 additions & 0 deletions packages/wallets/src/components/WalletCardIcon/WalletCardIcon.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.wallet-card {
&__icon {
display: flex;
width: 128px;
height: 80px;
justify-content: center;
align-items: center;
flex-shrink: 0;
border-radius: 4px;
background: linear-gradient(
90deg,
rgba(131, 58, 180, 1) 0%,
rgba(253, 29, 29, 1) 50%,
rgba(252, 176, 69, 1) 100%
);
}
}
1 change: 1 addition & 0 deletions packages/wallets/src/components/WalletCardIcon/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as WalletCardIcon } from './WalledCardIcon';
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.wallet-currency {
&__title {
color: var(--system-light-1-prominent-text, #333);

/* desktop/subtitle/Sub 2 - bold */
font-family: 'IBM Plex Sans';
font-size: 20px;
font-style: normal;
font-weight: 700;
line-height: 30px; /* 150% */
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';
import { useWalletAccountsList } from '@deriv/api';
import './WalletCurrencyTitle.scss';

type TProps = {
account: NonNullable<ReturnType<typeof useWalletAccountsList>['data']>[number];
};

const WalletCurrencyTitle: React.FC<TProps> = ({ account }) => {
return <div className='wallet-currency__title'>{account.currency_config?.display_code} Wallet</div>;
};

export default WalletCurrencyTitle;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as WalletCurrencyTitle } from './WalletCurrencyTitle';
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.wallet-header {
&__actions {
display: flex;
align-items: center;
gap: 8px;
}

&__button {
display: flex;
height: 32px;
padding: 6px 16px;
justify-content: center;
align-items: center;
gap: 8px;
border-radius: 64px;
border: 1px solid var(--system-light-3-less-prominent-text, #999);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import React from 'react';
import './WalletHeaderActions.scss';
import IcCashierAdd from '../../public/images/ic-cashier-deposit.svg';
import IcCashierWithdrawal from '../../public/images/ic-cashier-withdrawal.svg';
import IcCashierTransfer from '../../public/images/ic-cashier-transfer.svg';
import IcCashierStatement from '../../public/images/ic-cashier-statement.svg';
import { useWalletAccountsList } from '@deriv/api';

const getWalletHeaderButtons = (is_demo: boolean, handleAction?: () => void) => {
const buttons = [
{
name: 'Deposit',
text: is_demo ? 'Reset balance' : 'Deposit',
icon: <IcCashierAdd />,
},
{
name: 'Withdraw',
text: 'Withdraw',
icon: <IcCashierWithdrawal />,
},
{
name: 'Transfer',
text: 'Transfer',
icon: <IcCashierTransfer />,
},
{
name: 'Transactions',
text: 'Transactions',
icon: <IcCashierStatement />,
},
];

// Filter out the "Withdraw" button when is_demo is true
const filteredButtons = is_demo ? buttons.filter(button => button.name !== 'Withdraw') : buttons;

return filteredButtons.map(button => ({
...button,
action: () => handleAction?.(),
}));
};

const WalletHeaderActions = ({
thisyahlen-deriv marked this conversation as resolved.
Show resolved Hide resolved
account,
}: {
account: NonNullable<ReturnType<typeof useWalletAccountsList>['data']>[number];
}) => {
const is_demo = account.is_virtual;
return (
<div className='wallet-header__actions'>
{getWalletHeaderButtons(is_demo).map(button => (
<button key={button.name} className='wallet-header__button' onClick={button.action}>
{button.icon}
</button>
))}
</div>
);
};

export default WalletHeaderActions;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as WalletHeaderActions } from './WalletHeaderActions';
49 changes: 49 additions & 0 deletions packages/wallets/src/components/WalletHeaderList/WalletHeader.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
.wallet-list {
&__card_container {
flex: 1;
display: flex;
padding: 24px;
align-items: flex-start;
width: 100%;
border-radius: 16px;
background: var(--system-light-8-primary-background, #fff);
}

&__content {
flex: 1;
display: flex;
flex-direction: row;
align-items: center;
gap: 24px;
align-self: stretch;
}

&__details-container {
display: flex;
flex: 1;
align-items: center;
gap: 24px;
align-self: stretch;
border-radius: 16px;
}

&__action-container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;
gap: 8px;
flex: 1 0 0;
}

&__elements {
display: flex;
align-items: center;
gap: 8px;
align-self: stretch;
}

&__dropdown {
cursor: pointer;
}
}
44 changes: 44 additions & 0 deletions packages/wallets/src/components/WalletHeaderList/WalletHeader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React from 'react';
import { useWalletAccountsList } from '@deriv/api';
import WalletBalance from '../WalletBalance/WalletBalance';
import WalletCardIcon from '../WalletCardIcon/WalledCardIcon';
import WalletCurrencyTitle from '../WalletCurrencyTitle/WalletCurrencyTitle';
import WalletLandingCompanyBadge from '../WalletLandingCompanyBadge/WalletLandingCompanyBadge';
import WalletHeaderActions from '../WalletHeaderActions/WalletHeaderActions';
import IcDropdown from '../../public/images/ic-dropdown.svg';
import './WalletHeader.scss';

const WalletHeader: React.FC = () => {
const { data } = useWalletAccountsList();

if (!data.length) return <h1>No wallets found</h1>;

return (
<React.Fragment>
{data?.map(account => {
thisyahlen-deriv marked this conversation as resolved.
Show resolved Hide resolved
return (
<div className='wallet-list__card_container' key={account.loginid}>
<div className='wallet-list__content'>
<div className='wallet-list__details-container'>
<WalletCardIcon />
<div className='wallet-list__action-container'>
<div className='wallet-list__elements'>
<WalletCurrencyTitle account={account} />
<WalletLandingCompanyBadge account={account} />
</div>
<WalletHeaderActions account={account} />
</div>
</div>
<WalletBalance account={account} />
<div className='wallet-list__dropdown'>
<IcDropdown />
</div>
</div>
</div>
);
})}
</React.Fragment>
);
};

export default WalletHeader;
1 change: 1 addition & 0 deletions packages/wallets/src/components/WalletHeaderList/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as WalletHeader } from './WalletHeader';
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.wallet-landing-company {
&__badge {
display: flex;
padding: 0px 4px;
justify-content: center;
align-items: center;
gap: 4px;
border-radius: 2px;
border: 1px solid var(--system-light-1-prominent-text, #333);
}
&__name {
color: var(--system-light-1-prominent-text, #333);

/* desktop/extra small/XS - bold */
font-family: 'IBM Plex Sans';
font-size: 10px;
font-style: normal;
font-weight: 700;
line-height: 14px; /* 140% */
}
}
Loading