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 5 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
104 changes: 57 additions & 47 deletions src/components/AppHeader/MobileMenu/MenuContent.tsx
Original file line number Diff line number Diff line change
@@ -1,71 +1,81 @@
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 [isSubmenuOpen, setIsSubmenuOpen] = useState(false);
// const [renderSubmenuFor, setRenderSubmenuFor] = useState<TSubmenuSection>('accountSettings');
const { isMobile } = useDevice();
const textSize = isMobile ? 'md' : 'sm';

const data = MobileMenuConfig().menuConfig;

return (
<div className='flex flex-col h-full'>
{!isSubmenuOpen && (
<div className='flex items-center justify-center h-28 border-b border-[#f2f3f4]'>
<PlatformSwitcher />
</div>
)}
{/* {!isSubmenuOpen && ( */}
<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';
{data.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, 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={() => {
// if (submenu) {
// setRenderSubmenuFor(submenu);
// setIsSubmenuOpen(true);
// } else 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>
))}
})}
</div>
);
})}

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