From 4ac86a90973e8c52358983df1c7afe673080949d Mon Sep 17 00:00:00 2001 From: Rodolfo Ruiz Date: Tue, 12 Aug 2025 17:13:24 -0600 Subject: [PATCH] chore: show icons only when collapsed --- public/Expand.png | Bin 0 -> 290 bytes public/MiniLogo.png | Bin 0 -> 1151 bytes src/components/AppHeader.jsx | 13 +- src/components/Footer.jsx | 2 +- src/components/MenuDrawer.jsx | 243 +++++++++++++++++++++++++--------- 5 files changed, 188 insertions(+), 70 deletions(-) create mode 100644 public/Expand.png create mode 100644 public/MiniLogo.png diff --git a/public/Expand.png b/public/Expand.png new file mode 100644 index 0000000000000000000000000000000000000000..2ca8b20aa670a4c617cdb7a51dbdc1ef86317ebe GIT binary patch literal 290 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VXMsm#F#`j)FbFd;%$g$s6l5$8 za(7}_cTVOdki(Mh=2;WpzD-~5Ry9*A%IQd{-w+xDQ@8h7QczyDkL( zP{j6yK@0kqtE@b=YsM^g#W!!}JiD%2IZf<+#si6IOMl+4T;Uur;n1I(CMD|L&%6ug z)iS+F|JfpQrZUV~OHcDeLW!oxl{m@x3WNJi&654QR(*F+mO93?)Pcu`iFewe%rH$w i*QrW^p{Ka6G98~gXA-lhT~&3qIO3S0R~}^Pks+ zCb%vk2B8%R8id7UVrG+`8gy~~vK58r*g<3Tg-tR$*5`($%SPXz$eRxe194*(L}JKU z`P?ZWU(rt&X%V0Y&U%zDJ@T}PJHYxZ*8zj+yggf+N2ifP(j^r>kC;LHEoQg15oN zV+u1jDKnk7{bsaZmFG*ammfGO1GT}+o2JTRMRV@tB28dT zibheC@usDjoMc4u7|yQo%;#_~`2E>t@woA$iIkWq7XL0#9<`F_Zk?mzMEg&XfW#Ae z^ku$-(K{6isgimUqVew@Cf=S$ciY_fG?PzVFNYY<{jvAl%1H5=G5)kv-FI%1bQ*Qz z!XH>0KfFl1)sJ?!PZ{K!Qms*p?^ok`r9Lyfzx(<73J;{=RQKod*1lNzKZ4PYlCB<6_jm7E)@Tk`oylh?Z2HN&*&Y zPI(|2l*<-k4doOeTQZJ*dlq?~apsW{4dMIB`}Mg@<)o1%C?l4U>5Y89NR@qO7@WII zO06zpA%o&j!ufL6A*HW$Z>8^>V9Qv=oA~( zgQkR7n{`JmipWW6_0uKvmqmAF#F0G@o!e->tu=eNN4#4SZIbDwagw${GuPEtDwSzVm#Cxc4#mRvM Rs2czP002ovPDHLkV1k;|AOQdX literal 0 HcmV?d00001 diff --git a/src/components/AppHeader.jsx b/src/components/AppHeader.jsx index 114eab5..45e3f74 100644 --- a/src/components/AppHeader.jsx +++ b/src/components/AppHeader.jsx @@ -1,9 +1,7 @@ import { useState } from 'react'; -import fendiLogo from '/favicon.png' import { AppBar, Toolbar, Typography, IconButton, Box, Avatar } from '@mui/material'; import MenuDrawer from './MenuDrawer'; -import MenuIcon from '@mui/icons-material/Menu'; import { useAuth } from '../context/AuthContext'; import { useNavigate } from 'react-router-dom'; @@ -15,7 +13,7 @@ export default function AppHeader({ zone = 'public', onSelectMenuItem }) { private: '#40120EFF', }; - const [menuOpen, setMenuOpen] = useState(false); + const [drawerExpanded, setDrawerExpanded] = useState(true); const { user, logout } = useAuth(); const isPrivate = zone === 'private'; @@ -33,11 +31,6 @@ export default function AppHeader({ zone = 'public', onSelectMenuItem }) { fontSize: { xs: '0.75rem', md: '1rem' }, }} > - - setMenuOpen(true)}> - - - {/* Login button only visible for public zone */} {isPublic && !user && ( @@ -60,8 +53,8 @@ export default function AppHeader({ zone = 'public', onSelectMenuItem }) { {/* Rendering the Drawer */} setMenuOpen(false)} + open={drawerExpanded} + onClose={() => setDrawerExpanded(false)} onSelect={onSelectMenuItem} // pass handler from App /> diff --git a/src/components/Footer.jsx b/src/components/Footer.jsx index 1c99357..e543fdb 100644 --- a/src/components/Footer.jsx +++ b/src/components/Footer.jsx @@ -1,5 +1,5 @@ import { Box, Typography } from '@mui/material'; -import fendiLogo from '/logo.png' +import fendiLogo from '/Logo.png' export default function Footer({ zone = 'public' }) { const bgColor = { diff --git a/src/components/MenuDrawer.jsx b/src/components/MenuDrawer.jsx index f739b2f..1ee86e5 100644 --- a/src/components/MenuDrawer.jsx +++ b/src/components/MenuDrawer.jsx @@ -1,12 +1,26 @@ -import { Drawer, List, ListItem, ListItemText, ListItemIcon, Typography, Box, useMediaQuery, InputBase } from '@mui/material'; +import { + Drawer, + List, + ListItem, + ListItemText, + ListItemIcon, + IconButton, + Box, + useMediaQuery, + InputBase, + Tooltip, + Divider +} from '@mui/material'; +import { useTheme } from '@mui/material/styles'; +import { useEffect, useMemo, useState } from 'react'; import { useAuth } from '../context/AuthContext'; import ExitToAppIcon from '@mui/icons-material/ExitToApp'; - +// ---- Menu options (unchanged) ---- const menuOptions = { public: [ - { text: 'Dashboard', icon: Dashboard}, + { text: 'Dashboard', icon: Dashboard }, { text: 'Logout', icon: }, ], restricted: [], @@ -24,72 +38,183 @@ const menuOptions = { ], }; -export default function MenuDrawer({ zone = 'public', open, onClose, onSelect }) { - const isMobile = useMediaQuery('(max-width:900px)'); - const items = menuOptions[zone]; +// Mini‑variant sizes +const OPEN_WIDTH = 300; +const MINI_WIDTH = 72; +export default function MenuDrawer({ zone = 'public', open, onClose, onSelect }) { + const theme = useTheme(); + const isMobile = useMediaQuery('(max-width:900px)'); + const items = useMemo(() => menuOptions[zone] ?? [], [zone]); const { logout } = useAuth(); + // Collapsed state is only meaningful on desktop (permanent drawer) + const [collapsed, setCollapsed] = useState(false); + + // Interpret parent "open" prop: + // - Mobile (temporary): open controls visibility + // - Desktop (permanent): open=true => expanded, open=false => collapsed + useEffect(() => { + if (!isMobile) { + setCollapsed(!open); + } + }, [open, isMobile]); + + const paperWidth = isMobile ? OPEN_WIDTH : (collapsed ? MINI_WIDTH : OPEN_WIDTH); + return ( - - - Dream Views + }} + > + {/* Header */} + + {/* Expanded - default */} + {!collapsed && ( + + Dream Views - - - - - - {items.map(({ text, icon }, index) => ( - { - onClose(); // Close drawer - onSelect?.(text); // Notify parent of selected item - - if (text === 'Logout') { - logout(); // cerrar sesión y redirigir - } else { - onSelect?.(text); // navegar al resto de vistas - } - }}> - - {icon} - - - ))} + + )} + + + {/* Collapsed */} + {collapsed && ( + + Dream Views + + )} + + {/* Items */} + + {items.map(({ text, icon }, index) => { + // Default items + return ( + + { + if (isMobile) onClose?.(); + if (text === 'Logout') { + logout(); + } else { + onSelect?.(text); + } + }} + sx={{ + px: collapsed ? 1 : 2, + minHeight: 44, + cursor: 'pointer', + justifyContent: collapsed ? 'center' : 'flex-start', + width: collapsed ? 50 : '100%', + }} + > + + {icon} + + {!collapsed && ( + + )} + + + ); + })} + + + setCollapsed((c) => !c)} sx={{ + backgroundColor: 'transparent', + color: 'transparent', + '&:hover': { + backgroundColor: '#fff4ec', + borderColor: 'transparent' + }, + borderRadius: 0, + marginLeft: 1, + width: 40, + height: 40, + }}> + {collapsed + + ); }