Skip to content

Commit

Permalink
[TRAH] Aizad/TRAH-2627/Currency Switcher Modal for responsive (binary…
Browse files Browse the repository at this point in the history
…-com#12827)

* chore: Added currency switcher modal on mobile:
- added modal id inside of AppContent
- change ModalStepWrapper to Modal
- change tailwind classes for Modal to accommodate responsive view

* fix: made some changes to the tailwind classes to make the modal responsive

* fix: made the loader full width for responsive
  • Loading branch information
aizad-deriv committed Jan 9, 2024
1 parent c25a209 commit fcc3354
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 24 deletions.
3 changes: 2 additions & 1 deletion packages/tradershub/src/AppContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import React from 'react';
import { Router } from './routes';

const AppContent = () => (
<div className='font-sans max-w-[1232px] mx-auto pt-400 lg:pt-2500 lg:px-50'>
<div className='font-sans max-w-[1232px] mx-auto lg:pt-2500 lg:px-50'>
<div className='z-10' id='v2_modal_show_header_root' />
<Router />
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,6 @@ const CurrencySwitcher = () => {

const iconCurrency = isDemo ? 'virtual' : activeAccount?.currency ?? 'virtual';

const renderButton = () => {
return (
<Button
className='py-900 rounded-200 border-sm border-system-light-less-prominent-text'
colorStyle='black'
fullWidth
variant='secondary'
>
Add or manage account
</Button>
);
};

if (!isSuccess) return <CurrencySwitcherLoader />;

return (
Expand All @@ -89,11 +76,20 @@ const CurrencySwitcher = () => {
onClick={() => {
show(
<Modal>
<Modal.Header title='Select account' titleClassName='text-typography-default' />
<Modal.Content className='overflow-y-scroll'>
<Modal.Header title='Select account' titleClassName='text-[14px] sm:text-[16px]' />
<Modal.Content>
<TradingAccountsList />
</Modal.Content>
<Modal.Footer>{renderButton()}</Modal.Footer>
<Modal.Footer className='grid-cols-1'>
<Button
className='py-900 rounded-200 border-sm border-system-light-less-prominent-text'
colorStyle='black'
fullWidth
variant='secondary'
>
Add or manage account
</Button>
</Modal.Footer>
</Modal>
);
}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';

const CurrencySwitcherLoader = () => (
<div className='flex items-center justify-between border-solid gap-800 h-3600 p-800 rounded-400 border-sm border-system-light-active-background shrink-0'>
<div className='flex items-center justify-between border-solid gap-800 h-3600 p-800 rounded-400 border-sm border-system-light-active-background w-full lg:w-auto'>
<div className='rounded-full animate-pulse bg-solid-slate-100 w-2000 h-2000 rounded-1500' />
<div className='space-y-500'>
<div className='grow space-y-500'>
<div className='animate-pulse bg-solid-slate-100 w-2500 h-500 rounded-200' />
<div className='animate-pulse bg-solid-slate-100 w-5000 h-500 rounded-200' />
</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/tradershub/src/components/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const Modal = ({ children, className }: TModal) => {
return (
<div
className={qtMerge(
'flex flex-col h-screen w-screen bg-background-primary-base lg:mx-auto lg:h-full lg:w-full lg:rounded-400',
'flex flex-col h-[calc(100vh-40px)] w-screen bg-system-light-primary-background lg:mx-auto lg:h-full lg:w-full lg:rounded-400',
className
)}
>
Expand Down
2 changes: 1 addition & 1 deletion packages/tradershub/src/components/Modal/ModalContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { TModalComponents } from './Modal';
* @returns {JSX.Element} The ModalContent component.
*/
const ModalContent = ({ children, className }: TModalComponents) => (
<div className={qtMerge('flex-grow p-400 lg:flex-none', className)}>{children}</div>
<div className={qtMerge('flex-grow overflow-y-auto p-400 lg:flex-none', className)}>{children}</div>
);

export default ModalContent;
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ const TradingAccountsList = () => {
const { switchAccount } = useAuthorize();

return (
<div className='flex w-[500px] h-[350px] flex-col items-center rounded-400 bg-system-light-primary-background'>
<div className='flex flex-col items-start self-stretch flex-1 p-400 gap-200'>
<div className='lg:w-[500px] lg:h-[350px] rounded-400'>
<div className='flex flex-col items-start self-stretch p-400 gap-200'>
{tradingAccountsList
?.filter(account => !account.is_virtual)
.map(account => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const TradersHubRoute = () => {
<TotalAssets />
</div>
<ContentSwitcher>
<ContentSwitcher.HeaderList list={['Options & Multiplier', 'CFDs']} />
<ContentSwitcher.HeaderList list={['Options & Multipliers', 'CFDs']} />
<ContentSwitcher.PanelContainer>
<OptionsAndMultipliersSection />
</ContentSwitcher.PanelContainer>
Expand Down

0 comments on commit fcc3354

Please sign in to comment.