Feat: moved admin panel to layout

This commit is contained in:
2025-01-24 15:54:42 +03:00
parent 2a9a49c5ec
commit 352e191eab
2 changed files with 42 additions and 30 deletions

41
src/app/admin/layout.tsx Normal file
View File

@@ -0,0 +1,41 @@
"use client";
import { ActionIcon, AppShell, Burger, Flex, Group, Skeleton, useMantineColorScheme } from "@mantine/core";
import { useDisclosure } from "@mantine/hooks";
import { LuMoon, LuSun } from "react-icons/lu";
const AdminLayout = ({
children,
}: Readonly<{
children: React.ReactNode;
}>) => {
const [opened, { toggle }] = useDisclosure();
const { setColorScheme, colorScheme } = useMantineColorScheme();
const changeColorScheme = () => {
setColorScheme(colorScheme === "light" ? "dark" : "light");
};
return (
<AppShell header={{ height: 60 }} navbar={{ width: 300, breakpoint: "sm", collapsed: { mobile: !opened } }}>
<AppShell.Header>
<Flex h="100%" px="md" justify="space-between" align="center">
<Group h="100%">
<Burger opened={opened} onClick={toggle} size="sm" hiddenFrom="sm" />
<div>Logo</div>
</Group>
<ActionIcon onClick={changeColorScheme} variant="default" size="md" aria-label="Toggle color scheme">
{colorScheme === "light" ? <LuMoon /> : <LuSun />}
</ActionIcon>
</Flex>
</AppShell.Header>
<AppShell.Navbar p="md">
{Array(15)
.fill(0)
.map((_, index) => (
<Skeleton key={index} h={28} mt="sm" animate={false} />
))}
</AppShell.Navbar>
<AppShell.Main>{children}</AppShell.Main>
</AppShell>
);
};
export default AdminLayout;

View File

@@ -1,35 +1,6 @@
"use client";
import { ActionIcon, AppShell, Burger, Flex, Group, Skeleton, useMantineColorScheme } from "@mantine/core";
import { useDisclosure } from "@mantine/hooks";
import { LuMoon, LuSun } from "react-icons/lu";
const PanelPage = () => {
const [opened, { toggle }] = useDisclosure();
const { setColorScheme, colorScheme } = useMantineColorScheme();
const changeColorScheme = () => {
setColorScheme(colorScheme === "light" ? "dark" : "light");
};
return (
<AppShell header={{ height: 60 }} navbar={{ width: 300, breakpoint: "sm", collapsed: { mobile: !opened } }}>
<AppShell.Header>
<Flex h="100%" px="md" justify="space-between" align="center">
<Group h="100%">
<Burger opened={opened} onClick={toggle} size="sm" hiddenFrom="sm" />
<div>Logo</div>
</Group>
<ActionIcon onClick={changeColorScheme} variant="default" size="md" aria-label="Toggle color scheme">
{colorScheme === "light" ? <LuMoon /> : <LuSun />}
</ActionIcon>
</Flex>
</AppShell.Header>
<AppShell.Navbar p="md">
{Array(15)
.fill(0)
.map((_, index) => (
<Skeleton key={index} h={28} mt="sm" animate={false} />
))}
</AppShell.Navbar>
</AppShell>
);
return <div>Panel</div>;
};
export default PanelPage;