From c1a23faf1fb82c4cc58361aa45172bb2b0ff2c70 Mon Sep 17 00:00:00 2001
From: IceToast <54889359+IceToast@users.noreply.github.com>
Date: Thu, 26 Jan 2023 02:43:16 +0100
Subject: [PATCH] fix: #277 #272
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* fix: 🐛 Add Menu component as parent
* refactor: popover -> menu
Co-authored-by: IceToast <>
Co-authored-by: dicedtomato <35403473+diced@users.noreply.github.com>
---
src/components/Layout.tsx | 202 +++++++++++++-------------------------
1 file changed, 66 insertions(+), 136 deletions(-)
diff --git a/src/components/Layout.tsx b/src/components/Layout.tsx
index 0c75525..f858100 100644
--- a/src/components/Layout.tsx
+++ b/src/components/Layout.tsx
@@ -4,7 +4,6 @@ import {
Box,
Burger,
Button,
- Group,
Header,
Image,
MediaQuery,
@@ -12,14 +11,11 @@ import {
Navbar,
NavLink,
Paper,
- Popover,
ScrollArea,
Select,
- Stack,
Text,
Title,
Tooltip,
- UnstyledButton,
useMantineTheme,
} from '@mantine/core';
import { useClipboard } from '@mantine/hooks';
@@ -56,61 +52,6 @@ import {
} from './icons';
import { friendlyThemeName, themes } from './Theming';
-function MenuItemLink(props) {
- return (
-
-
-
- );
-}
-
-function MenuItem(props) {
- return (
- ({
- display: 'block',
- width: '100%',
- padding: 5,
- borderRadius: theme.radius.sm,
- color: props.color
- ? theme.fn.themeColor(props.color, theme.colorScheme === 'dark' ? 5 : 7)
- : theme.colorScheme === 'dark'
- ? theme.colors.dark[0]
- : theme.black,
- '&:hover': !props.noClick
- ? {
- backgroundColor: props.color
- ? theme.fn.rgba(
- theme.fn.themeColor(props.color, theme.colorScheme === 'dark' ? 9 : 0),
- theme.colorScheme === 'dark' ? 0.2 : 1
- )
- : theme.colorScheme === 'dark'
- ? theme.fn.rgba(theme.colors.dark[3], 0.35)
- : theme.colors.gray[0],
- }
- : null,
- })}
- {...props}
- >
-
- ({
- marginRight: theme.spacing.xs / 4,
- paddingLeft: theme.spacing.xs / 2,
-
- '& *': {
- display: 'block',
- },
- })}
- >
- {props.icon}
-
- {props.children}
-
-
- );
-}
-
export type NavbarItems = {
icon: React.ReactNode;
text: string;
@@ -198,7 +139,6 @@ export default function Layout({ children, props }) {
const [systemTheme, setSystemTheme] = useState(user.systemTheme ?? 'system');
const version = useVersion();
const [opened, setOpened] = useState(false); // navigation open
- const [open, setOpen] = useState(false); // manage acc dropdown
const avatar = user?.avatar ?? null;
const router = useRouter();
@@ -375,11 +315,10 @@ export default function Layout({ children, props }) {
{title}
- setOpen(false)}>
-
+
-
-
-
-
- {user.username} ({user.id}){' '}
- {user.administrator && user.username !== 'administrator' ? '(Administrator)' : ''}
-
- } href='/dashboard/manage'>
- Manage Account
-
- }
- onClick={() => {
- setOpen(false);
- openCopyToken();
- }}
- >
- Copy Token
-
- }
- onClick={() => {
- setOpen(false);
- openResetToken();
- }}
- color='red'
- >
- Reset Token
-
- } href='/auth/logout' color='red'>
- Logout
-
-
- <>
- {oauth_providers
- .filter((x) =>
- user.oauth
- ?.map(({ provider }) => provider.toLowerCase())
- .includes(x.name.toLowerCase())
- )
- .map(({ name, Icon }, i) => (
- <>
- }
- >
- Logged in with {capitalize(name)}
-
- >
- ))}
- {oauth_providers.filter((x) =>
+
+
+
+ {user.username} ({user.id}){' '}
+ {user.administrator && user.username !== 'administrator' ? '(Administrator)' : ''}
+
+ } href='/dashboard/manage'>
+ Manage Account
+
+ }
+ onClick={() => {
+ openCopyToken();
+ }}
+ >
+ Copy Token
+
+ }
+ onClick={() => {
+ openResetToken();
+ }}
+ color='red'
+ >
+ Reset Token
+
+ } href='/auth/logout' color='red'>
+ Logout
+
+
+ <>
+ {oauth_providers
+ .filter((x) =>
user.oauth
?.map(({ provider }) => provider.toLowerCase())
.includes(x.name.toLowerCase())
- ).length ? (
-
- ) : null}
- >
- }>
-
-
-
+ )
+ .map(({ name, Icon }, i) => (
+ <>
+ }
+ >
+ Logged in with {capitalize(name)}
+
+ >
+ ))}
+ {oauth_providers.filter((x) =>
+ user.oauth?.map(({ provider }) => provider.toLowerCase()).includes(x.name.toLowerCase())
+ ).length ? (
+
+ ) : null}
+ >
+ }>
+