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: add styles to wallet card carousel #9957

Merged
Show file tree
Hide file tree
Changes from 14 commits
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
2 changes: 1 addition & 1 deletion packages/api/src/hooks/useVerifyEmail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ type TPayload = Parameters<ReturnType<typeof useRequest<'verify_email'>>['mutate
/** A custom hook for verifying email address */
const useVerifyEmail = () => {
const { mutate: _mutate, ...rest } = useRequest('verify_email');

const mutate = useCallback((payload: TPayload) => _mutate({ payload }), [_mutate]);

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@ describe('Barriers', () => {
const key_to_remove = BARRIERS_KEYS.TAKE_PROFIT;
Barriers.removeBarrier(barriers, key_to_remove);
expect(barriers.find(barrier => barrier.key === key_to_remove)).toBeUndefined();
expect(barriers.length).toEqual(2);
expect(barriers).toHaveLength(2);
});
it('should not remove any barriers if the key is not found', () => {
Barriers.removeBarrier(barriers, BARRIERS_KEYS.STOP_LOSS);
expect(barriers.length).toEqual(3);
expect(barriers).toHaveLength(3);
});
it('should not modify the barriers array if it is empty', () => {
const key_to_remove = BARRIERS_KEYS.STOP_OUT;
const empty_barriers = [] as Barriers.TBarrier[];
Barriers.removeBarrier(empty_barriers, key_to_remove);
expect(empty_barriers.length).toEqual(0);
expect(empty_barriers).toHaveLength(0);
});
});
});
4 changes: 3 additions & 1 deletion packages/wallets/src/AppContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import './AppContent.scss';
const AppContent: React.FC = () => {
const { is_mobile } = useDevice();

if (is_mobile) return <WalletsCarousel />;

return (
<div className='wallets-app'>
<div className='wallets-app__content'>{is_mobile ? <WalletsCarousel /> : <DesktopWalletsList />}</div>
thisyahlen-deriv marked this conversation as resolved.
Show resolved Hide resolved
<div className='wallets-app__content'>{!is_mobile && <DesktopWalletsList />}</div>
</div>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import React from 'react';
import { useWalletAccountsList } from '@deriv/api';
import './AccountsList.scss';
import { useActiveWalletAccount } from '@deriv/api';

type TAccountsListProps = {
data: ReturnType<typeof useWalletAccountsList>['data'][number];
data: ReturnType<typeof useActiveWalletAccount>['data'];
};

const AccountsList = ({ data }: TAccountsListProps) => {
return <div className='wallets-accounts-list'>{data.loginid}</div>;
return <div className='wallets-accounts-list'>{data?.loginid}</div>;
};

export default AccountsList;
24 changes: 24 additions & 0 deletions packages/wallets/src/components/ProgressBar/ProgressBar.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.wallets-progress-bar {
display: flex;
justify-content: center;
cursor: pointer;

&-active {
width: 2.5rem;
height: 0.8rem;
background-color: #ff444f;
border-radius: 1rem;
}

&-inactive {
width: 0.8rem;
height: 0.8rem;
margin: 0 0.4rem;
border-radius: 50%;
background-color: #c2c2c2;
}

&-transition {
transition: all 0.24s linear;
}
}
30 changes: 30 additions & 0 deletions packages/wallets/src/components/ProgressBar/ProgressBar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from 'react';
import './ProgressBar.scss';

type TProps = {
is_transition?: boolean;
active_index: number;
indexes: Array<number>;
setActiveIndex: React.Dispatch<React.SetStateAction<number>>;
};

const ProgressBar: React.FC<TProps> = ({ is_transition = 'true', active_index, indexes, setActiveIndex }) => {
return (
<div className='wallets-progress-bar'>
{indexes.map(idx => {
const is_active = idx === active_index;

const bar_classname = is_active ? 'wallets-progress-bar-active' : 'wallets-progress-bar-inactive';
return (
<div
key={`progress-bar__${idx}`}
onClick={() => setActiveIndex(idx)}
className={`${bar_classname} ${is_transition ? 'wallets-progress-bar-transition' : ''}`}
/>
);
})}
</div>
);
};

export default ProgressBar;
1 change: 1 addition & 0 deletions packages/wallets/src/components/ProgressBar/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as ProgressBar } from './ProgressBar';
45 changes: 45 additions & 0 deletions packages/wallets/src/components/WalletCard/WalletCard.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
.wallets-card {
display: flex;
flex-direction: column;
align-items: center;

&__data {
width: 24rem;
height: 14.4rem;
border-radius: 8px;
background-color: rgb(242, 200, 200);
position: relative;

&__details {
display: flex;
width: 100%;
height: 100%;
padding: 1.6rem;
flex-direction: column;
justify-content: space-between;
align-items: flex-start;

&-icon {
width: 3.2rem;
height: 3.2rem;
}

&-balance {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 0.4rem;
}

&-landing_company {
display: flex;
justify-content: flex-end;
align-items: flex-start;
gap: 0.4rem;
position: absolute;
right: 1.6rem;
top: 1.6rem;
}
}
}
}
34 changes: 34 additions & 0 deletions packages/wallets/src/components/WalletCard/WalletCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from 'react';
import { useWalletAccountsList } from '@deriv/api';
import { WalletListCardBadge } from '../WalletListCardBadge';
import './WalletCard.scss';

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

const WalletCard: React.FC<TProps> = ({ account }) => {
return (
<div className='wallets-card' key={account.loginid}>
<div className='wallets-card__data'>
<div className='wallets-card__data__details'>
<div className='wallets-card__data__details-icon'>
<p>{account.currency}</p>
</div>

<div className='wallets-card__data__details-balance'>
<p>{account.currency} Wallet</p>
<p>
{account.display_balance} {account.currency}
</p>
</div>
<div className='wallets-card__data__details-landing_company'>
{account?.landing_company_name && <WalletListCardBadge label={account?.landing_company_name} />}
</div>
</div>
</div>
</div>
);
};

export default WalletCard;
1 change: 1 addition & 0 deletions packages/wallets/src/components/WalletCard/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as WalletCard } from './WalletCard';
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,51 @@
border: 1px solid var(--system-light-3-less-prominent-text, #999);
}
}

.wallets-mobile-actions {
display: flex;
flex-direction: row;
align-items: center;
cursor: pointer;
min-width: 5.6rem;

&__container {
display: flex;
padding: 0rem 1.6rem;
justify-content: center;
align-items: center;
gap: 0.8rem;
align-self: stretch;
}

&-content {
display: flex;
width: 7rem;
flex-direction: column;
align-items: center;
gap: 0.4rem;

&-icon {
display: flex;
width: 3.5rem;
height: 3.5rem;
padding: 0.8rem;
justify-content: center;
align-items: center;
border-radius: 16px;
border: 1px solid var(--system-light-5-active-background, #d6dadb);
}

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

/* mobile/extra small/XS - regular */
font-family: 'IBM Plex Sans';
font-size: 1rem;
font-style: normal;
font-weight: 400;
line-height: 1.2rem; /* 150% */
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { useWalletAccountsList } from '@deriv/api';
import { useActiveWalletAccount, useWalletAccountsList } from '@deriv/api';
import IcCashierAdd from '../../public/images/ic-cashier-deposit.svg';
import IcCashierStatement from '../../public/images/ic-cashier-statement.svg';
import IcCashierTransfer from '../../public/images/ic-cashier-transfer.svg';
Expand Down Expand Up @@ -40,14 +40,39 @@ const getWalletHeaderButtons = (is_demo: boolean, handleAction?: () => void) =>
};

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

const WalletListCardIActions: React.FC<TProps> = ({ account }) => {
const is_demo = account.is_virtual;
const WalletListCardIActions: React.FC<TProps> = ({ account, is_desktop_wallet = true }) => {
thisyahlen-deriv marked this conversation as resolved.
Show resolved Hide resolved
thisyahlen-deriv marked this conversation as resolved.
Show resolved Hide resolved
const { data: active_wallet } = useActiveWalletAccount();
const is_demo = !!active_wallet?.is_virtual;

if (!is_desktop_wallet)
return (
<div className='wallets-mobile-actions__container'>
<div className='wallets-mobile-actions'>
{getWalletHeaderButtons(is_demo).map(button => (
<React.Fragment key={button.name}>
<div className='wallets-mobile-actions-content'>
<button
key={button.name}
className='wallets-mobile-actions-content-icon'
onClick={button.action}
>
{button.icon}
</button>
<div className='wallets-mobile-actions-content-text'>{button.text}</div>
</div>
</React.Fragment>
))}
</div>
</div>
);

return (
<div className='wallets-header__actions'>
{getWalletHeaderButtons(is_demo).map(button => (
{getWalletHeaderButtons(!!account?.is_virtual).map(button => (
<button key={button.name} className='wallets-header__button' onClick={button.action}>
{button.icon}
</button>
Expand Down

This file was deleted.

Loading