diff --git a/frontend/src/components/DoubleNavbar.module.css b/frontend/src/components/Appshell.module.css similarity index 74% rename from frontend/src/components/DoubleNavbar.module.css rename to frontend/src/components/Appshell.module.css index 195348f..d9afaf2 100644 --- a/frontend/src/components/DoubleNavbar.module.css +++ b/frontend/src/components/Appshell.module.css @@ -21,11 +21,6 @@ flex: 1; } - .collapseButton { - margin-top: auto; /* Hace que el botón se empuje hacia abajo */ - margin-bottom: 16px; /* ← Agrega separación del borde inferior */ - - } .aside { flex: 0 0 60px; @@ -41,7 +36,12 @@ background-color: light-dark(var(--mantine-color-gray-0), var(--mantine-color-dark-6)); } + .topSection { + padding-top: 12px; /* o la cantidad que desees */ + } + .mainLink { + width: 44px; height: 44px; border-radius: var(--mantine-radius-md); @@ -63,27 +63,9 @@ } } - .title { - font-family: - Greycliff CF, - var(--mantine-font-family); - margin-bottom: var(--mantine-spacing-xl); - background-color: var(--mantine-color-body); - padding: var(--mantine-spacing-md); - padding-top: 18px; - height: 60px; - border-bottom: 1px solid light-dark(var(--mantine-color-gray-3), var(--mantine-color-dark-7)); - } + - .logo { - width: 100%; - display: flex; - justify-content: center; - height: 60px; - padding-top: var(--mantine-spacing-md); - border-bottom: 1px solid light-dark(var(--mantine-color-gray-3), var(--mantine-color-dark-7)); - margin-bottom: var(--mantine-spacing-xl); - } + .link { display: block; diff --git a/frontend/src/components/Appshell_collapse.tsx b/frontend/src/components/Appshell_collapse.tsx index f617812..4ef5c88 100644 --- a/frontend/src/components/Appshell_collapse.tsx +++ b/frontend/src/components/Appshell_collapse.tsx @@ -1,41 +1,183 @@ -import { useDisclosure } from '@mantine/hooks'; -import { AppShell, Burger, Group, Skeleton } from '@mantine/core'; +import { + IconCalendarStats, + IconDeviceDesktopAnalytics, + IconFingerprint, + IconGauge, + IconHome2, + IconSettings, + IconUser, + IconArrowBarLeft, + IconArrowBarRight, + } from '@tabler/icons-react'; + + import { + AppShell, + Burger, + Group, + Skeleton, + Tooltip, + UnstyledButton, + ActionIcon, + Title, + } from '@mantine/core'; + + import { useDisclosure, useMediaQuery } from '@mantine/hooks'; + import { useEffect, useMemo, useState } from 'react'; + import { Link, useLocation } from 'react-router-dom'; + import classes from './Appshell.module.css'; + + const mainLinksdata = [ + { icon: IconHome2, label: 'Home' }, + { icon: IconGauge, label: 'Dashboard' }, + { icon: IconDeviceDesktopAnalytics, label: 'Analytics' }, + { icon: IconCalendarStats, label: 'Releases' }, + { icon: IconUser, label: 'Account' }, + { icon: IconFingerprint, label: 'Security' }, + { icon: IconSettings, label: 'Settings' }, + ]; + + const submenuLinks = { + Home: [ + { label: 'Inicio', to: '/' }, + { label: 'Consulta Api', to: '/Consulta_API' }, + { label: 'Prueba_appshell', to: '/prueba_appshell' }, + ], + Dashboard: [ + { label: 'Resumen', to: '/dashboard/resumen' }, + { label: 'Estadísticas', to: '/dashboard/estadisticas' }, + { label: 'Usuarios', to: '/dashboard/usuarios' }, + ], + Analytics: [ + { label: 'Conversiones', to: '/analytics/conversiones' }, + { label: 'Tráfico', to: '/analytics/trafico' }, + { label: 'Tendencias', to: '/analytics/tendencias' }, + ], + Releases: [ + { label: 'Notas de versión', to: '/releases/notas-de-version' }, + { label: 'Historial', to: '/releases/historial' }, + ], + Account: [ + { label: 'Perfil', to: '/account/perfil' }, + { label: 'Suscripciones', to: '/account/suscripciones' }, + ], + Security: [ + { label: 'Contraseña', to: '/security/contraseña' }, + { label: '2FA', to: '/security/2fa' }, + ], + Settings: [ + { label: 'Preferencias', to: '/settings/preferencias' }, + { label: 'Notificaciones', to: '/settings/notificaciones' }, + ], + }; + + export function AppShellWithMenu() { + const location = useLocation(); + const isMobile = useMediaQuery('(max-width: 768px)'); + const [mobileOpened, { toggle: toggleMobile, close: closeMobile }] = useDisclosure(false); + const [desktopOpened, { toggle: toggleDesktop, open: openDesktop }] = useDisclosure(true); + const isCollapsed = useMemo(() => (isMobile ? !mobileOpened : !desktopOpened), [isMobile, mobileOpened, desktopOpened]); + + const [manualActiveTab, setManualActiveTab] = useState(null); + + const matchedMain = Object.entries(submenuLinks).find(([mainKey, items]) => + items.some((item) => location.pathname.startsWith(item.to)) + ); + + const routeBasedActive = matchedMain?.[0] ?? 'Home'; + const active = manualActiveTab ?? routeBasedActive; + const activeLink = submenuLinks[active as keyof typeof submenuLinks]?.find((item) => location.pathname === item.to)?.label ?? ''; + + const mainLinks = mainLinksdata.map((link) => ( + + { + setManualActiveTab(link.label); + if (isMobile) closeMobile(); + }} + className={classes.mainLink} + data-active={link.label === active || undefined} + > + + + + )); + + const links = (submenuLinks[active as keyof typeof submenuLinks] || []).map((item) => ( + { + if (isMobile) closeMobile(); + }} + > + {item.label} + + )); + + useEffect(() => { + setManualActiveTab(null); + }, [location.pathname]); + + useEffect(() => { + if (!isMobile) openDesktop(); + }, [isMobile, openDesktop]); + + return ( + + + {/* Header */} + + + + + + Logo + + -export function CollapseDesktop() { - const [mobileOpened, { toggle: toggleMobile }] = useDisclosure(); - const [desktopOpened, { toggle: toggleDesktop }] = useDisclosure(true); + {/* Navbar */} - return ( - - - - - - Logo - - - - Navbar - {Array(15) - .fill(0) - .map((_, index) => ( - - ))} - - Main - - ); -} \ No newline at end of file + +
+
+
+ + {mainLinks} +
+ +
+
+ {!isCollapsed && {active}} + {links} +
+
+
+ + {/* Main Content */} + + + {/* Aquí va el contenido principal */} + Main Content + +
+ ); + } + \ No newline at end of file diff --git a/frontend/src/components/DoubleNavbar.tsx b/frontend/src/components/DoubleNavbar.tsx deleted file mode 100644 index 84c07d6..0000000 --- a/frontend/src/components/DoubleNavbar.tsx +++ /dev/null @@ -1,170 +0,0 @@ -import { - IconCalendarStats, - IconDeviceDesktopAnalytics, - IconFingerprint, - IconGauge, - IconHome2, - IconSettings, - IconUser, - IconArrowBarLeft, - IconArrowBarRight, -} from '@tabler/icons-react'; -import { - Title, - Tooltip, - UnstyledButton, - ActionIcon, -} from '@mantine/core'; -import { useDisclosure, useMediaQuery } from '@mantine/hooks'; -import { Link, useLocation } from 'react-router-dom'; -import { useEffect, useMemo, useState } from 'react'; -import classes from './DoubleNavbar.module.css'; - -const mainLinksdata = [ - { icon: IconHome2, label: 'Home' }, - { icon: IconGauge, label: 'Dashboard' }, - { icon: IconDeviceDesktopAnalytics, label: 'Analytics' }, - { icon: IconCalendarStats, label: 'Releases' }, - { icon: IconUser, label: 'Account' }, - { icon: IconFingerprint, label: 'Security' }, - { icon: IconSettings, label: 'Settings' }, -]; - -const submenuLinks: Record = { - Home: [ - { label: 'Inicio', to: '/' }, - { label: 'Consulta Api', to: '/Consulta_API' }, - { label: 'Prueba_appshell', to: '/prueba_appshell' }, - ], - Dashboard: [ - { label: 'Resumen', to: '/dashboard/resumen' }, - { label: 'Estadísticas', to: '/dashboard/estadisticas' }, - { label: 'Usuarios', to: '/dashboard/usuarios' }, - ], - Analytics: [ - { label: 'Conversiones', to: '/analytics/conversiones' }, - { label: 'Tráfico', to: '/analytics/trafico' }, - { label: 'Tendencias', to: '/analytics/tendencias' }, - ], - Releases: [ - { label: 'Notas de versión', to: '/releases/notas-de-version' }, - { label: 'Historial', to: '/releases/historial' }, - ], - Account: [ - { label: 'Perfil', to: '/account/perfil' }, - { label: 'Suscripciones', to: '/account/suscripciones' }, - ], - Security: [ - { label: 'Contraseña', to: '/security/contraseña' }, - { label: '2FA', to: '/security/2fa' }, - ], - Settings: [ - { label: 'Preferencias', to: '/settings/preferencias' }, - { label: 'Notificaciones', to: '/settings/notificaciones' }, - ], -}; - -export function DoubleNavbar() { - const location = useLocation(); - const isMobile = useMediaQuery('(max-width: 768px)'); - - const [mobileOpened, { toggle: toggleMobile, close: closeMobile }] = useDisclosure(false); - const [desktopOpened, { toggle: toggleDesktop, open: openDesktop }] = useDisclosure(true); - - const isCollapsed = useMemo(() => (isMobile ? !mobileOpened : !desktopOpened), [isMobile, mobileOpened, desktopOpened]); - - const [manualActiveTab, setManualActiveTab] = useState(null); - - const matchedMain = Object.entries(submenuLinks).find(([mainKey, items]) => - items.some((item) => location.pathname.startsWith(item.to)) - ); - - const routeBasedActive = matchedMain?.[0] ?? 'Home'; - const active = manualActiveTab ?? routeBasedActive; - - const activeLink = - submenuLinks[active]?.find((item) => location.pathname === item.to)?.label ?? ''; - - const mainLinks = mainLinksdata.map((link) => ( - - { - setManualActiveTab(link.label); - if (isMobile) closeMobile(); - }} - className={classes.mainLink} - data-active={link.label === active || undefined} - > - - - - )); - - const links = (submenuLinks[active] || []).map((item) => ( - { - if (isMobile) closeMobile(); - }} - > - {item.label} - - )); - - // Restaurar pestaña al cambiar ruta (opcional pero útil) - useEffect(() => { - setManualActiveTab(null); - }, [location.pathname]); - - // Abrir navbar de escritorio si cambia a pantalla grande - useEffect(() => { - if (!isMobile) openDesktop(); - }, [isMobile, openDesktop]); - - return ( - - ); -} diff --git a/frontend/src/pages/404.tsx b/frontend/src/pages/404.tsx index dbf8d31..bafada4 100644 --- a/frontend/src/pages/404.tsx +++ b/frontend/src/pages/404.tsx @@ -1,16 +1,12 @@ import { Box, Title, Text, Button, Group, Stack, Image, Center } from '@mantine/core'; import { IconArrowLeft } from '@tabler/icons-react'; import { Link } from 'react-router-dom'; -import { DoubleNavbar } from '../components/DoubleNavbar'; // Ajusta ruta si es necesario import { MantineCardWithShader } from '../components/HoloShader'; // Ajusta ruta si es necesario export function Error_404() { return ( - - - diff --git a/frontend/src/pages/Consulta_api.tsx b/frontend/src/pages/Consulta_api.tsx index 76294d1..51e17a0 100644 --- a/frontend/src/pages/Consulta_api.tsx +++ b/frontend/src/pages/Consulta_api.tsx @@ -9,7 +9,6 @@ import { Badge, Group, } from '@mantine/core'; -import { DoubleNavbar } from '../components/DoubleNavbar'; import { MetodoSelect } from '../components/MetodoSelect'; // 👈 Importación del nuevo componente import { useEffect } from 'react'; @@ -88,7 +87,6 @@ export function Consulta_API() { return ( -
diff --git a/frontend/src/pages/Home.page.tsx b/frontend/src/pages/Home.page.tsx index 756be52..a4be09b 100644 --- a/frontend/src/pages/Home.page.tsx +++ b/frontend/src/pages/Home.page.tsx @@ -2,7 +2,6 @@ import { ColorSchemeToggle } from '../components/ColorSchemeToggle/ColorSchemeTo import { Welcome } from '../components/Welcome/Welcome'; import MiBoton from '../components/botoncito'; import { Center, Box } from '@mantine/core'; -import { DoubleNavbar } from '../components/DoubleNavbar'; import { MantineCardWithShader } from '../components/HoloShader'; @@ -11,14 +10,7 @@ import { MantineCardWithShader } from '../components/HoloShader'; export function HomePage() { return ( - {/* Sidebar fijo a la izquierda */} - {/* Contenido principal */} - - - - - ); } \ No newline at end of file diff --git a/frontend/src/pages/Prueba_appshell.tsx b/frontend/src/pages/Prueba_appshell.tsx index 3f684b7..8711e99 100644 --- a/frontend/src/pages/Prueba_appshell.tsx +++ b/frontend/src/pages/Prueba_appshell.tsx @@ -2,13 +2,12 @@ import { ColorSchemeToggle } from '../components/ColorSchemeToggle/ColorSchemeTo import { Welcome } from '../components/Welcome/Welcome'; import MiBoton from '../components/botoncito'; import { Center, Box } from '@mantine/core'; -import { DoubleNavbar } from '../components/DoubleNavbar'; import { MantineCardWithShader } from '../components/HoloShader'; -import { CollapseDesktop } from '../components/Appshell_collapse'; +import {AppShellWithMenu } from '../components/Appshell_collapse'; export function Prueba_appshell() { return ( - + ); } \ No newline at end of file