From 46e6f2f5accbc8713e3a40b4263d97ea1a407512 Mon Sep 17 00:00:00 2001 From: nzambello Date: Sat, 18 Feb 2023 21:54:57 +0100 Subject: [PATCH] refactor: root nav with navlink --- app/root.tsx | 239 +++++++++------------------------------------------ 1 file changed, 43 insertions(+), 196 deletions(-) diff --git a/app/root.tsx b/app/root.tsx index 301775e..e163251 100644 --- a/app/root.tsx +++ b/app/root.tsx @@ -33,7 +33,8 @@ import { Box, Group, UnstyledButton, - ThemeIcon + ThemeIcon, + NavLink } from '@mantine/core'; import { useColorScheme, useLocalStorage } from '@mantine/hooks'; import { StylesPlaceholder } from '@mantine/remix'; @@ -102,7 +103,6 @@ function Document({ }) { const preferredColorScheme = useColorScheme(); const toggleColorScheme = (value?: ColorScheme) => { - console.log(value); setColorScheme(value || (colorScheme === 'dark' ? 'light' : 'dark')); }; @@ -248,230 +248,77 @@ function Layout({ children }: React.PropsWithChildren<{}>) { {user && ( - ({ - display: 'block', - width: '100%', - padding: theme.spacing.xs, - borderRadius: theme.radius.sm, - color: - theme.colorScheme === 'dark' - ? theme.colors.dark[0] - : theme.black, - - '&:hover': { - backgroundColor: - theme.colorScheme === 'dark' - ? theme.colors.dark[6] - : theme.colors.gray[0] - } - })} - > - + label="Home" + icon={ - - - Home - - - - + ({ - display: 'block', - width: '100%', - padding: theme.spacing.xs, - borderRadius: theme.radius.sm, - color: - theme.colorScheme === 'dark' - ? theme.colors.dark[0] - : theme.black, - - '&:hover': { - backgroundColor: - theme.colorScheme === 'dark' - ? theme.colors.dark[6] - : theme.colors.gray[0] - } - })} - > - + label="Time entries" + icon={ - - - Time entries - - - - + ({ - display: 'block', - width: '100%', - padding: theme.spacing.xs, - borderRadius: theme.radius.sm, - color: - theme.colorScheme === 'dark' - ? theme.colors.dark[0] - : theme.black, - - '&:hover': { - backgroundColor: - theme.colorScheme === 'dark' - ? theme.colors.dark[6] - : theme.colors.gray[0] - } - })} - > - + label="Projects" + icon={ - - - Projects - - - - + ({ - display: 'block', - width: '100%', - padding: theme.spacing.xs, - borderRadius: theme.radius.sm, - color: - theme.colorScheme === 'dark' - ? theme.colors.dark[0] - : theme.black, - - '&:hover': { - backgroundColor: - theme.colorScheme === 'dark' - ? theme.colors.dark[6] - : theme.colors.gray[0] - } - })} - > - + label="Report" + icon={ - - - Report - - - - + ({ - display: 'block', - width: '100%', - padding: theme.spacing.xs, - borderRadius: theme.radius.sm, - color: - theme.colorScheme === 'dark' - ? theme.colors.dark[0] - : theme.black, - - '&:hover': { - backgroundColor: - theme.colorScheme === 'dark' - ? theme.colors.dark[6] - : theme.colors.gray[0] - } - })} - > - + label="Import/Export" + icon={ - - - Import/Export - - - - + ({ - display: 'block', - width: '100%', - padding: theme.spacing.xs, - borderRadius: theme.radius.sm, - color: - theme.colorScheme === 'dark' - ? theme.colors.dark[0] - : theme.black, - - '&:hover': { - backgroundColor: - theme.colorScheme === 'dark' - ? theme.colors.dark[6] - : theme.colors.gray[0] - } - })} - > - + label="Statistics" + icon={ - - - Statistics - - - + } + variant="light" + active={location.pathname.includes('/statistics')} + /> )} {user && (