From df707fe29b8b218f8726dc166a66c6dabdb83f8c Mon Sep 17 00:00:00 2001 From: bipproduction Date: Mon, 9 Feb 2026 11:24:34 +0800 Subject: [PATCH] feat: implement dark/light mode toggle across dashboard and profile --- src/.well-known/assetlinks.json | 20 +++++----- src/components/ColorSchemeToggle.tsx | 34 ++++++++++++++++ src/frontend.tsx | 2 +- src/index.css | 2 +- src/index.ts | 8 ++-- src/manifest.json | 30 +++++++------- src/routes/dashboard/index.tsx | 35 +++++++---------- src/routes/dashboard/route.tsx | 50 ++++++++++++++---------- src/routes/profile/edit.tsx | 17 ++++---- src/routes/profile/index.tsx | 58 ++++++++++++---------------- src/sw.js | 41 ++++++++++---------- src/vite.ts | 10 ++++- 12 files changed, 167 insertions(+), 140 deletions(-) create mode 100644 src/components/ColorSchemeToggle.tsx diff --git a/src/.well-known/assetlinks.json b/src/.well-known/assetlinks.json index 0826ec7..4b1cfdd 100644 --- a/src/.well-known/assetlinks.json +++ b/src/.well-known/assetlinks.json @@ -1,12 +1,12 @@ [ - { - "relation": ["delegate_permission/common.handle_all_urls"], - "target": { - "namespace": "android_app", - "package_name": "com.example.makuro", - "sha256_cert_fingerprints": [ - "00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00" - ] - } - } + { + "relation": ["delegate_permission/common.handle_all_urls"], + "target": { + "namespace": "android_app", + "package_name": "com.example.makuro", + "sha256_cert_fingerprints": [ + "00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00" + ] + } + } ] diff --git a/src/components/ColorSchemeToggle.tsx b/src/components/ColorSchemeToggle.tsx new file mode 100644 index 0000000..f246a0f --- /dev/null +++ b/src/components/ColorSchemeToggle.tsx @@ -0,0 +1,34 @@ +import { + ActionIcon, + Group, + rem, + useComputedColorScheme, + useMantineColorScheme, +} from "@mantine/core"; +import { IconMoon, IconSun } from "@tabler/icons-react"; + +export function ColorSchemeToggle() { + const { setColorScheme } = useMantineColorScheme(); + const computedColorScheme = useComputedColorScheme("light", { + getInitialValueInEffect: true, + }); + + return ( + + + setColorScheme(computedColorScheme === "light" ? "dark" : "light") + } + variant="default" + size="lg" + aria-label="Toggle color scheme" + > + {computedColorScheme === "light" ? ( + + ) : ( + + )} + + + ); +} diff --git a/src/frontend.tsx b/src/frontend.tsx index 89de9e8..0d526f2 100644 --- a/src/frontend.tsx +++ b/src/frontend.tsx @@ -56,7 +56,7 @@ const app = ( }); }} > - + diff --git a/src/index.css b/src/index.css index 2734ce9..60f2c28 100644 --- a/src/index.css +++ b/src/index.css @@ -21,4 +21,4 @@ body { place-items: center; min-width: 320px; min-height: 100vh; -} */ \ No newline at end of file +} */ diff --git a/src/index.ts b/src/index.ts index 373e283..0220ce2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -171,8 +171,8 @@ if (!isProduction) { const file = Bun.file(filePath); return new Response(file, { headers: { - "Vary": "Accept-Encoding", - } + Vary: "Accept-Encoding", + }, }); } @@ -181,8 +181,8 @@ if (!isProduction) { if (fs.existsSync(indexHtml)) { return new Response(Bun.file(indexHtml), { headers: { - "Vary": "Accept-Encoding", - } + Vary: "Accept-Encoding", + }, }); } diff --git a/src/manifest.json b/src/manifest.json index 6878560..7bd4543 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,17 +1,17 @@ { - "name": "Makuro Base Template", - "short_name": "Makuro", - "description": "A high-performance full-stack React template", - "start_url": "/", - "display": "standalone", - "background_color": "#1a1a1a", - "theme_color": "#f3d5a3", - "icons": [ - { - "src": "/logo.svg", - "sizes": "any", - "type": "image/svg+xml", - "purpose": "any maskable" - } - ] + "name": "Makuro Base Template", + "short_name": "Makuro", + "description": "A high-performance full-stack React template", + "start_url": "/", + "display": "standalone", + "background_color": "#1a1a1a", + "theme_color": "#f3d5a3", + "icons": [ + { + "src": "/logo.svg", + "sizes": "any", + "type": "image/svg+xml", + "purpose": "any maskable" + } + ] } diff --git a/src/routes/dashboard/index.tsx b/src/routes/dashboard/index.tsx index b60d570..0fa056c 100644 --- a/src/routes/dashboard/index.tsx +++ b/src/routes/dashboard/index.tsx @@ -56,7 +56,11 @@ function DashboardComponent() { return ( - + <Title + order={1} + ta="center" + className=" text-blue-600 p-4 rounded-lg mt-10 shadow-lg" + > Dashboard Overview @@ -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)" }} > @@ -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()}
- + {snap.user?.name} @@ -104,23 +107,17 @@ function DashboardComponent() { {/* Stats Grid */} {statsData.map((stat, index) => ( - + {stat.title} - + {stat.value} - {stat.icon} + {stat.icon} ))} @@ -128,13 +125,7 @@ function DashboardComponent() { - + System Performance @@ -171,7 +162,7 @@ function DashboardComponent() { - + Server Status diff --git a/src/routes/dashboard/route.tsx b/src/routes/dashboard/route.tsx index 8fc6615..975d26e 100644 --- a/src/routes/dashboard/route.tsx +++ b/src/routes/dashboard/route.tsx @@ -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" > @@ -122,24 +125,24 @@ function DashboardLayout() { onClick={toggleMobile} hiddenFrom="sm" size="sm" - color="#f3d5a3" /> + + ADMIN - + PANEL @@ -147,6 +150,8 @@ function DashboardLayout() { + +
- + {snap.user?.name} + Administrator
+ {snap.user?.name?.charAt(0)} @@ -184,6 +193,7 @@ function DashboardLayout() { Akun + @@ -192,6 +202,7 @@ function DashboardLayout() { > Profil Saya + @@ -204,6 +215,7 @@ function DashboardLayout() { Bahaya + @@ -237,6 +248,7 @@ function DashboardLayout() { { navigate({ to: item.to }); + if (mobileOpened) toggleMobile(); }} leftSection={ @@ -254,20 +266,15 @@ function DashboardLayout() { } rightSection={} 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() { + - + diff --git a/src/routes/profile/edit.tsx b/src/routes/profile/edit.tsx index 022fd1d..1ec3b2c 100644 --- a/src/routes/profile/edit.tsx +++ b/src/routes/profile/edit.tsx @@ -71,7 +71,7 @@ function EditProfile() { - + <Title order={1} c="orange.6"> Edit Profil @@ -88,14 +88,13 @@ function EditProfile() { - +
@@ -104,10 +103,9 @@ function EditProfile() { placeholder="Masukkan nama lengkap Anda" {...form.getInputProps("name")} styles={{ - label: { color: "#fbf0df", marginBottom: 8 }, + label: { marginBottom: 8 }, input: { - backgroundColor: "rgba(0,0,0,0.2)", - color: "#fbf0df", + backgroundColor: "var(--mantine-color-default-soft)", }, }} /> @@ -116,10 +114,9 @@ function EditProfile() { placeholder="https://example.com/photo.jpg" {...form.getInputProps("image")} styles={{ - label: { color: "#fbf0df", marginBottom: 8 }, + label: { marginBottom: 8 }, input: { - backgroundColor: "rgba(0,0,0,0.2)", - color: "#fbf0df", + backgroundColor: "var(--mantine-color-default-soft)", }, }} /> diff --git a/src/routes/profile/index.tsx b/src/routes/profile/index.tsx index e67b696..13c1330 100644 --- a/src/routes/profile/index.tsx +++ b/src/routes/profile/index.tsx @@ -34,6 +34,7 @@ import { import { createFileRoute, useNavigate } from "@tanstack/react-router"; import { useState } from "react"; import { useSnapshot } from "valtio"; +import { ColorSchemeToggle } from "@/components/ColorSchemeToggle"; import { protectedRouteMiddleware } from "@/middleware/authMiddleware"; import { authClient } from "@/utils/auth-client"; import { authStore } from "../../store/auth"; @@ -92,25 +93,22 @@ function Profile() { withBorder p="md" radius="md" - bg="rgba(251, 240, 223, 0.03)" - style={{ border: "1px solid rgba(251, 240, 223, 0.1)" }} + style={{ border: "1px solid var(--mantine-color-default-border)" }} > - + {label} - + {value || "N/A"} {copyable && value && ( @@ -145,7 +143,7 @@ function Profile() { {/* Header Section */} - + <Title order={1} c="orange.6"> Profil Saya @@ -153,6 +151,7 @@ function Profile() { + {snap.user?.role === "admin" && (