Skip to content

Commit

Permalink
refactor: update responsive overlay and improve dashboard layout
Browse files Browse the repository at this point in the history
- Removed ResponsiveOverlay component.
- Added ResetMiniNavOnResize component to handle mini nav visibility.
- Updated dashboard layout to conditionally render navigation components.
- Adjusted main content padding and enhanced layout styles.
  • Loading branch information
cswni committed Nov 18, 2024
1 parent 6748b7d commit bce9ca3
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 61 deletions.
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default function App() {
<SettingsDrawer />
<ProgressBar />
<Router />
{/*<ResponsiveOverlay />*/}
<ResponsiveOverlay />
</SnackbarProvider>
</MotionLazy>
</ThemeProvider>
Expand Down
28 changes: 28 additions & 0 deletions src/components/responsive-overlay/ResetMiniNavOnResize.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { useState, useEffect } from 'react';
import {useSettingsContext} from "@src/components/settings";

const ResetMiniNavOnResize = () => {
const [isSmallScreen, setIsSmallScreen] = useState(false);
const settings = useSettingsContext();

useEffect(() => {
const handleResize = () => {
setIsSmallScreen(window.innerWidth < 1200);
};

window.addEventListener('resize', handleResize);
handleResize();

return () => window.removeEventListener('resize', handleResize);
}, []);

if(isSmallScreen && settings.themeLayout === 'mini') {
settings.onUpdate('themeLayout', 'vertical');
}

if (!isSmallScreen) {
return null;
}
};

export default ResetMiniNavOnResize;
52 changes: 0 additions & 52 deletions src/components/responsive-overlay/ResponsiveOverlay.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/components/responsive-overlay/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default as ResponsiveOverlay } from './ResponsiveOverlay.tsx';
export { default as ResponsiveOverlay } from './ResetMiniNavOnResize.tsx';
13 changes: 10 additions & 3 deletions src/layouts/dashboard/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,23 @@ export default function DashboardLayout({ children }: Props) {
return (
<>
<Header onOpenNav={nav.onTrue} />

<Box
sx={{
minHeight: 1,
display: 'flex',
flexDirection: { xs: 'column', md: 'row' },
}}
>
{renderNavVertical}

{
lgUp
? renderNavVertical
: (
<NavVertical
openNav={nav.value}
onCloseNav={nav.onFalse}
/>
)
}
<Main>{children}</Main>
</Box>
</>
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/dashboard/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function Main({ children, sx, ...other }: BoxProps) {
<Box
component="main"
sx={{
padding: 5,
padding: '0px 5px',
transition: 'all 0.7s ease',
flexGrow: 1,
minHeight: 1,
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/dashboard/nav-mini.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default function NavMini() {
sx={{
flexShrink: { lg: 0 },
width: { lg: NAV.W_MINI },
backgroundColor: '#1E1F22'
backgroundColor: '#1E1F22',
}}
>
<Stack
Expand Down
20 changes: 18 additions & 2 deletions src/layouts/dashboard/nav-vertical.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { useNavData } from './config-navigation';
import { AccountPopover, NotificationsPopover, Searchbar } from '../_common';
import { NavToggleButton } from '../_common';
import {NAV} from "@src/layouts/config-layout.ts";
import NavMini from "@src/layouts/dashboard/nav-mini.tsx";
// ----------------------------------------------------------------------

type Props = {
Expand Down Expand Up @@ -150,11 +151,26 @@ export default function NavVertical({ openNav, onCloseNav}: Props) {
onClose={onCloseNav}
PaperProps={{
sx: {
width: NAV.W_VERTICAL,
width: NAV.W_VERTICAL + NAV.W_MINI,
},
}}
>
{renderContent}
<Stack direction={'row'} sx={{

}}>
<Box sx={{
width: NAV.W_MINI,
}}>
<NavMini />
</Box>
<Box sx={{
width: NAV.W_VERTICAL,
}}>
{renderContent}
</Box>

</Stack>

</Drawer>
)}
<LoginModal open={loginModalOpen} onClose={handleCloseModal} />
Expand Down

0 comments on commit bce9ca3

Please sign in to comment.