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

Niloofar/ Mobile SideMenu #131

Merged
merged 6 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@babel/preset-env": "^7.24.5",
"@deriv-com/api-hooks": "^1.1.2",
"@deriv-com/translations": "^1.2.4",
"@deriv-com/ui": "^1.28.2",
"@deriv-com/ui": "^1.28.3",
"@deriv-com/utils": "^0.0.25",
"@deriv/deriv-api": "^1.0.15",
"@deriv/quill-design": "^1.2.24",
Expand Down
97 changes: 46 additions & 51 deletions src/components/AppHeader/MobileMenu/MenuContent.tsx
Original file line number Diff line number Diff line change
@@ -1,71 +1,66 @@
import { useState } from 'react';
import { MenuItem, Submenu, Text, useDevice } from '@deriv-com/ui';
import clsx from 'clsx';
import { MenuItem, Text, useDevice } from '@deriv-com/ui';
import { PlatformSwitcher } from '../PlatformSwitcher';
import { MobileMenuConfig, TSubmenuSection } from './MobileMenuConfig';
import { SubmenuContent } from './SubmenuContent';
import { MobileMenuConfig } from './MobileMenuConfig';

export const MenuContent = () => {
const [isSubmenuOpen, setIsSubmenuOpen] = useState(false);
const [renderSubmenuFor, setRenderSubmenuFor] = useState<TSubmenuSection>('accountSettings');
const { isMobile } = useDevice();

const data = MobileMenuConfig().menuConfig;
const textSize = isMobile ? 'md' : 'sm';

return (
<div className='flex flex-col h-full'>
{!isSubmenuOpen && (
<div className='flex items-center justify-center h-28 border-b border-[#f2f3f4]'>
<PlatformSwitcher />
</div>
)}
<div className='flex items-center justify-center h-28 border-b border-[#f2f3f4]'>
<PlatformSwitcher />
</div>

<div className='relative h-full pt-4'>
{data.map((item, index) => (
<div className='pl-[4.8rem] pr-[1.6rem] border-b border-[#f2f3f4]' key={index}>
{item.map(({ LeftComponent, RightComponent, as, href, label, onClick, submenu }) => {
const textSize = isMobile ? 'md' : 'sm';
{MobileMenuConfig().map((item, index) => {
const removeBorderBottom = item.find(({ removeBorderBottom }) => removeBorderBottom);

if (as === 'a') {
return (
<div
className={clsx('pl-[4.8rem] pr-[1.6rem]', {
'border-b border-[#f2f3f4]': !removeBorderBottom,
})}
key={index}
>
{item.map(({ LeftComponent, RightComponent, as, href, label, onClick, target }) => {
if (as === 'a') {
return (
<MenuItem
as='a'
className='h-[5.6rem]'
disableHover
href={href}
key={label}
leftComponent={
<LeftComponent className='mr-[1.6rem]' height={16} width={16} />
}
target={target}
>
<Text size={textSize}>{label}</Text>
</MenuItem>
);
}
return (
<MenuItem
as='a'
className='h-[5.6rem]'
as='button'
className='w-full h-[5.6rem]'
disableHover
href={href}
key={label}
leftComponent={<LeftComponent className='mr-[1.6rem]' height={16} width={16} />}
leftComponent={<LeftComponent className='mr-[1.6rem]' iconSize='xs' />}
onClick={onClick}
rightComponent={RightComponent}
>
<Text size={textSize}>{label}</Text>
<Text className='mr-auto' size={textSize}>
{label}
</Text>
</MenuItem>
);
}
return (
<MenuItem
as='button'
className='w-full h-[5.6rem]'
disableHover
key={label}
leftComponent={<LeftComponent className='mr-[1.6rem]' iconSize='xs' />}
onClick={() => {
if (submenu) {
setRenderSubmenuFor(submenu);
setIsSubmenuOpen(true);
} else onClick?.();
}}
rightComponent={RightComponent}
>
<Text className='mr-auto' size={textSize}>
{label}
</Text>
</MenuItem>
);
})}
</div>
))}

<Submenu className='overflow-y-auto z-10' isOpen={isSubmenuOpen}>
<SubmenuContent onBackClick={() => setIsSubmenuOpen(false)} renderContentFor={renderSubmenuFor} />
</Submenu>
})}
</div>
);
})}
</div>
</div>
);
Expand Down
Loading
Loading