Skip to content

Commit

Permalink
Add light and darkmode toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
fabian-emilius committed Jul 30, 2024
1 parent 8fbfc40 commit c65d7ca
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
align-items: center;
text-decoration: none;
font-size: var(--mantine-font-size-sm);
color: light-dark(var(--mantine-color-gray-7), var(--mantine-color-dark-1));
color: light-dark(var(--mantine-color-gray-6), var(--mantine-color-dark-2));
padding: var(--mantine-spacing-xs) var(--mantine-spacing-sm);
border-radius: var(--mantine-radius-sm);
font-weight: 500;
margin-bottom: 5px;

&[data-active], &:hover {
background-color: var(--mantine-primary-color-filled);
color: var(--mantine-primary-color-light-color);
color: var(--mantine-primary-color-0);

.linkIcon {
color: var(--mantine-primary-color-light-color);
color: var(--mantine-primary-color-0);
}
}
}
Expand Down
25 changes: 19 additions & 6 deletions client/src/app/layout/AuthenticatedArea/AuthenticatedArea.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { PropsWithChildren, Suspense, useEffect } from 'react'
import { AppShell, Burger, Center, Group, Loader } from '@mantine/core'
import React, { PropsWithChildren, Suspense, useEffect } from 'react'
import { ActionIcon, AppShell, Burger, Center, Group, Loader, Space, Stack, useMantineColorScheme } from '@mantine/core'
import * as classes from './AuthenticatedArea.module.css'
import { Link, useLocation } from 'react-router-dom'
import { useDisclosure } from '@mantine/hooks'
import {
FolderSimplePlus,
Kanban,
Kanban, Moon,
NewspaperClipping,
PaperPlaneTilt,
Scroll,
SignOut,
SignOut, Sun,
User,
} from 'phosphor-react'
import { useIsSmallerBreakpoint } from '../../../hooks/theme'
Expand Down Expand Up @@ -69,7 +69,9 @@ const AuthenticatedArea = (props: PropsWithChildren<IAuthenticatedAreaProps>) =>
requiredGroups,
} = props

const { colorScheme, toggleColorScheme } = useMantineColorScheme();
const [opened, { toggle }] = useDisclosure()

const location = useLocation()
const showHeader = useIsSmallerBreakpoint('md') || collapseNavigation
const auth = useAuthenticationContext()
Expand Down Expand Up @@ -106,7 +108,19 @@ const AuthenticatedArea = (props: PropsWithChildren<IAuthenticatedAreaProps>) =>
</AppShell.Header>

<AppShell.Navbar p='md'>
<AppShell.Section grow my='md'>
<AppShell.Section grow mb='md'>
<Stack justify='flex-end'>
<ActionIcon
variant="outline"
color={colorScheme === 'dark' ? 'yellow' : 'pale-purple'}
onClick={() => toggleColorScheme()}
title="Toggle color scheme"
ml='auto'
>
{colorScheme === 'dark' ? <Sun size="1.1rem" /> : <Moon size="1.1rem" />}
</ActionIcon>
</Stack>
<Space h="md" />
{links
.filter(
(item) => !item.roles || item.roles.some((role) => auth.user?.groups.includes(role)),
Expand All @@ -132,7 +146,6 @@ const AuthenticatedArea = (props: PropsWithChildren<IAuthenticatedAreaProps>) =>
<User className={classes.linkIcon} size={32} />
<span>My Information</span>
</Link>*/}

<Link to='/logout' className={classes.link}>
<SignOut className={classes.linkIcon} size={32} />
<span>Logout</span>
Expand Down

0 comments on commit c65d7ca

Please sign in to comment.