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 9 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
14 changes: 8 additions & 6 deletions packages/wallets/src/AppContent.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import React from 'react';
import { DesktopWalletsList } from './components';
// import WalletsCarousel from './components/WalletCarousel';
import { DesktopWalletsList, WalletsCarousel } from './components';
import './AppContent.scss';

const AppContent: React.FC = () => {
const mobile_width = 768;

//Temporary solution until we have a proper mobile view
const is_mobile = window.innerWidth <= mobile_width;
thisyahlen-deriv marked this conversation as resolved.
Show resolved Hide resolved
if (is_mobile) return <WalletsCarousel />;

return (
<div className='wallets-app'>
<div className='wallets-app__content'>
<DesktopWalletsList />
</div>
{/* <WalletsCarousel /> */}
<div className='wallets-app__content'>{!is_mobile && <DesktopWalletsList />}</div>
</div>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react';
import { useWalletAccountsList } from '@deriv/api';
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, active_index, indexes, setActiveIndex }) => {
return (
<div className='wallets-progress-bar'>
{indexes.map(st => {
thisyahlen-deriv marked this conversation as resolved.
Show resolved Hide resolved
const is_active = st === active_index;

const barClassName = is_active ? 'wallets-progress-bar-active' : 'wallets-progress-bar-inactive';
thisyahlen-deriv marked this conversation as resolved.
Show resolved Hide resolved
return (
<div
key={`progress-bar__${st}`}
onClick={() => setActiveIndex(st)}
className={`${barClassName} ${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
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.

Original file line number Diff line number Diff line change
@@ -1,51 +1,14 @@
import React, { useState } from 'react';
import useEmblaCarousel from 'embla-carousel-react';
import { useWalletAccountsList } from '@deriv/api';
import React from 'react';
import { useActiveWalletAccount } from '@deriv/api';
import AccountsList from '../AccountsList';
import { WalletsCarouselContent } from '../WalletsCarouselContent';

const WalletsCarousel = () => {
const [emblaRef, emblaApi] = useEmblaCarousel({ skipSnaps: true, containScroll: false });
const [active_index, setActiveIndex] = useState(0);
const { data: wallet_accounts_list } = useWalletAccountsList();

React.useEffect(() => {
emblaApi?.scrollTo(active_index);
}, [active_index, emblaApi]);

React.useEffect(() => {
emblaApi?.on('select', () => {
const scroll_snap_index = emblaApi.selectedScrollSnap();
setActiveIndex(scroll_snap_index);
});
}, [emblaApi]);

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

const WalletsCarousel: React.FC = () => {
const { data: active_wallet } = useActiveWalletAccount();
return (
<React.Fragment>
<div className='wallets-carousel' ref={emblaRef}>
<section className='wallets-carousel__container'>
{wallet_accounts_list.map(wallet => (
<div className='wallet-card' key={wallet.loginid}>
<div className='wallet-card__data'>
<div className='wallets-card__data__details'>
<h1>{wallet.currency}</h1>
<div className='wallets-card__data__details-balance'>
<p>{wallet.currency} Wallet</p>
<h3>
{wallet.balance} {wallet.currency}
</h3>
</div>
</div>
<div className='wallets-card__data__landing-company'>
<p>{wallet.landing_company_name}</p>
</div>
</div>
</div>
))}
</section>
</div>
<AccountsList data={wallet_accounts_list[active_index]} />
<WalletsCarouselContent />
<AccountsList data={active_wallet} />
</React.Fragment>
);
};
Expand Down
Loading