feat: implement dark/light mode toggle across dashboard and profile

This commit is contained in:
bipproduction
2026-02-09 11:24:34 +08:00
parent 5ed9637a88
commit df707fe29b
12 changed files with 167 additions and 140 deletions

View File

@@ -56,7 +56,11 @@ function DashboardComponent() {
return (
<Container size="lg" py="xl">
<Title order={1} ta="center" className=" text-blue-600 p-4 rounded-lg mt-10 shadow-lg">
<Title
order={1}
ta="center"
className=" text-blue-600 p-4 rounded-lg mt-10 shadow-lg"
>
Dashboard Overview
</Title>
@@ -66,8 +70,7 @@ function DashboardComponent() {
p="xl"
radius="md"
mb="xl"
bg="rgba(251, 240, 223, 0.05)"
style={{ border: "1px solid rgba(251, 240, 223, 0.1)" }}
style={{ border: "1px solid var(--mantine-color-default-border)" }}
>
<Group justify="space-between">
<Group>
@@ -77,14 +80,14 @@ function DashboardComponent() {
radius="xl"
style={{
cursor: "pointer",
border: "2px solid rgba(251, 240, 223, 0.3)",
border: "2px solid var(--mantine-color-orange-filled)",
}}
onClick={() => navigate({ to: "/profile" })}
>
{snap.user?.name?.charAt(0).toUpperCase()}
</Avatar>
<div>
<Text size="lg" fw={600} c="#fbf0df">
<Text size="lg" fw={600}>
{snap.user?.name}
</Text>
<Text c="dimmed" size="sm">
@@ -104,23 +107,17 @@ function DashboardComponent() {
{/* Stats Grid */}
<SimpleGrid cols={{ base: 1, sm: 2, md: 4 }} spacing="lg" mb="xl">
{statsData.map((stat, index) => (
<Card
key={index.toString()}
withBorder
p="lg"
radius="md"
bg="rgba(251, 240, 223, 0.05)"
>
<Card key={index.toString()} withBorder p="lg" radius="md">
<Group justify="space-between">
<Box>
<Text size="sm" c="dimmed">
{stat.title}
</Text>
<Text size="lg" fw={700} c="#fbf0df">
<Text size="lg" fw={700}>
{stat.value}
</Text>
</Box>
<Box c="#f3d5a3">{stat.icon}</Box>
<Box c="orange.6">{stat.icon}</Box>
</Group>
</Card>
))}
@@ -128,13 +125,7 @@ function DashboardComponent() {
<Grid gutter="lg">
<Grid.Col span={{ base: 12, md: 8 }}>
<Card
withBorder
p="lg"
radius="md"
mb="lg"
bg="rgba(251, 240, 223, 0.05)"
>
<Card withBorder p="lg" radius="md" mb="lg">
<Title order={3} mb="md">
System Performance
</Title>
@@ -171,7 +162,7 @@ function DashboardComponent() {
</Grid.Col>
<Grid.Col span={{ base: 12, md: 4 }}>
<Card withBorder p="lg" radius="md" bg="rgba(251, 240, 223, 0.05)">
<Card withBorder p="lg" radius="md">
<Title order={3} mb="md">
Server Status
</Title>

View File

@@ -30,6 +30,7 @@ import {
useNavigate,
} from "@tanstack/react-router";
import { useSnapshot } from "valtio";
import { ColorSchemeToggle } from "@/components/ColorSchemeToggle";
import { authClient } from "@/utils/auth-client";
import { authStore } from "../../store/auth";
@@ -101,7 +102,9 @@ function DashboardLayout() {
header={{ height: 70 }}
navbar={{
width: 280,
breakpoint: "sm",
collapsed: { mobile: !mobileOpened, desktop: !desktopOpened },
}}
padding="md"
@@ -109,10 +112,10 @@ function DashboardLayout() {
transitionTimingFunction="ease"
>
<AppShell.Header
bg="rgba(26, 26, 26, 0.8)"
style={{
backdropFilter: "blur(10px)",
borderBottom: "1px solid rgba(251, 240, 223, 0.1)",
borderBottom: "1px solid var(--mantine-color-default-border)",
}}
>
<Group h="100%" px="md" justify="space-between">
@@ -122,24 +125,24 @@ function DashboardLayout() {
onClick={toggleMobile}
hiddenFrom="sm"
size="sm"
color="#f3d5a3"
/>
<Burger
opened={desktopOpened}
onClick={toggleDesktop}
visibleFrom="sm"
size="sm"
color="#f3d5a3"
/>
<Box visibleFrom="xs" ml="xs">
<Text
fw={800}
size="xl"
c="#f3d5a3"
c="orange.6"
style={{ letterSpacing: "-0.5px" }}
>
ADMIN
<Text span c="#fbf0df">
<Text span c="var(--mantine-color-text)">
PANEL
</Text>
</Text>
@@ -147,6 +150,8 @@ function DashboardLayout() {
</Group>
<Group gap="md">
<ColorSchemeToggle />
<Menu
shadow="md"
width={200}
@@ -158,24 +163,28 @@ function DashboardLayout() {
gap="xs"
style={{ cursor: "pointer" }}
p="xs"
hover-bg="rgba(255,255,255,0.05)"
className="hover:bg-gray-50 dark:hover:bg-white/5 rounded-md"
>
<div
style={{ textAlign: "right" }}
className="visible-from-sm"
>
<Text size="sm" fw={600} c="#fbf0df">
<Text size="sm" fw={600}>
{snap.user?.name}
</Text>
<Text size="xs" c="dimmed">
Administrator
</Text>
</div>
<Avatar
src={snap.user?.image}
radius="xl"
size="md"
style={{ border: "2px solid #f3d5a3" }}
style={{
border: "2px solid var(--mantine-color-orange-filled)",
}}
>
{snap.user?.name?.charAt(0)}
</Avatar>
@@ -184,6 +193,7 @@ function DashboardLayout() {
<Menu.Dropdown>
<Menu.Label>Akun</Menu.Label>
<Menu.Item
leftSection={
<IconUser style={{ width: rem(14), height: rem(14) }} />
@@ -192,6 +202,7 @@ function DashboardLayout() {
>
Profil Saya
</Menu.Item>
<Menu.Item
leftSection={
<IconSettings style={{ width: rem(14), height: rem(14) }} />
@@ -204,6 +215,7 @@ function DashboardLayout() {
<Menu.Divider />
<Menu.Label>Bahaya</Menu.Label>
<Menu.Item
color="red"
leftSection={
@@ -221,8 +233,7 @@ function DashboardLayout() {
<AppShell.Navbar
p="md"
bg="rgba(20, 20, 20, 1)"
style={{ borderRight: "1px solid rgba(251, 240, 223, 0.1)" }}
style={{ borderRight: "1px solid var(--mantine-color-default-border)" }}
>
<AppShell.Section grow component={ScrollArea} mx="-md" px="md">
<Stack gap="xs" mt="md">
@@ -237,6 +248,7 @@ function DashboardLayout() {
<NavLink
onClick={() => {
navigate({ to: item.to });
if (mobileOpened) toggleMobile();
}}
leftSection={
@@ -254,20 +266,15 @@ function DashboardLayout() {
}
rightSection={<IconChevronRight size="0.8rem" stroke={1.5} />}
active={isActive(item.to)}
variant="filled"
variant="light"
color="orange"
styles={{
root: {
borderRadius: rem(8),
marginBottom: rem(4),
backgroundColor: isActive(item.to)
? "rgba(243, 213, 163, 0.1)"
: "transparent",
color: isActive(item.to) ? "#f3d5a3" : "#fbf0df",
"&:hover": {
backgroundColor: "rgba(243, 213, 163, 0.05)",
},
},
label: {
fontSize: rem(14),
},
@@ -279,7 +286,7 @@ function DashboardLayout() {
</AppShell.Section>
<AppShell.Section
style={{ borderTop: "1px solid rgba(251, 240, 223, 0.1)" }}
style={{ borderTop: "1px solid var(--mantine-color-default-border)" }}
pt="md"
>
<NavLink
@@ -292,6 +299,7 @@ function DashboardLayout() {
}
styles={{ root: { borderRadius: rem(8) } }}
/>
<NavLink
label="Keluar"
onClick={handleLogout}
@@ -308,7 +316,7 @@ function DashboardLayout() {
</AppShell.Section>
</AppShell.Navbar>
<AppShell.Main bg="rgba(15, 15, 15, 1)">
<AppShell.Main>
<Box p="lg" style={{ minHeight: "calc(100vh - 100px)" }}>
<Outlet />
</Box>