From 3ad313e39057234d66a400b9c9b3e5cd9f29efb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Boduro=C4=9Flu?= <80620802+burakboduroglu@users.noreply.github.com> Date: Mon, 13 Jul 2026 09:37:44 +0300 Subject: [PATCH] =?UTF-8?q?style:=20=F0=9F=92=84=20redesign=20authenticate?= =?UTF-8?q?d=20sidebar=20shell?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - move authenticated navigation into a full-height sidebar shell - add sidebar account dropdown with role label, theme, language, and logout actions - tune dark theme tokens and sidebar nav states for a denser dashboard look --- src/components/layout/app-shell.tsx | 90 ++++++++++++++++------- src/components/layout/side-nav.tsx | 13 ++-- src/components/layout/sidebar-account.tsx | 89 ++++++++++++++++++++++ src/index.css | 61 ++++++++------- 4 files changed, 195 insertions(+), 58 deletions(-) create mode 100644 src/components/layout/sidebar-account.tsx diff --git a/src/components/layout/app-shell.tsx b/src/components/layout/app-shell.tsx index 02cac6e..3b1afa3 100644 --- a/src/components/layout/app-shell.tsx +++ b/src/components/layout/app-shell.tsx @@ -1,10 +1,11 @@ import type { ParentProps } from "solid-js"; -import { useLocation } from "@tanstack/solid-router"; -import { Show } from "solid-js"; +import { Link, useLocation, useNavigate } from "@tanstack/solid-router"; +import { Show, createSignal } from "solid-js"; import { NavBar } from "@/components/layout/nav-bar"; import { SideNav } from "@/components/layout/side-nav"; +import { SidebarAccount } from "@/components/layout/sidebar-account"; import { Button } from "@/components/ui/button"; -import { IconChevronLeft, IconChevronRight } from "@/components/ui/icons"; +import { IconChevronLeft, IconChevronRight, IconMenu } from "@/components/ui/icons"; import { useAuth } from "@/stores/auth-context"; import { usePreferences, useT } from "@/stores/preferences-context"; import { cn } from "@/lib/cn"; @@ -16,68 +17,107 @@ export function AppShell(props: ParentProps) { const auth = useAuth(); const prefs = usePreferences(); const t = useT(); + const navigate = useNavigate(); + const [mobileOpen, setMobileOpen] = createSignal(false); const collapsed = () => prefs.sidebarCollapsed(); const location = useLocation(); const wide = () => location().pathname.startsWith("/exam-room/"); + const logout = async () => { + await auth.logout(); + void navigate({ to: "/login" }); + }; return ( -
- +
+ + + + + +
+ +
+ +
+
+ setMobileOpen(false)} /> +
+ + +
+ +
-
+
{props.children}
diff --git a/src/components/layout/side-nav.tsx b/src/components/layout/side-nav.tsx index 45f4ac5..fc4b97f 100644 --- a/src/components/layout/side-nav.tsx +++ b/src/components/layout/side-nav.tsx @@ -63,18 +63,21 @@ function NavLink(props: { title={t(props.item.labelKey)} aria-current={active() ? "page" : undefined} class={cn( - "group relative flex h-10 w-full items-center rounded-lg text-sm font-medium outline-none", + "group relative flex h-10 w-full items-center rounded-xl text-sm font-medium outline-none", "transition-all duration-150", props.collapsed ? "justify-center px-0" : "gap-2 px-2", active() - ? "bg-primary/10 text-primary shadow-sm ring-1 ring-primary/15" - : "text-sidebar-foreground/80 hover:bg-muted/60 hover:text-foreground", + ? "bg-primary/10 text-primary shadow-sm ring-1 ring-primary/20" + : "text-sidebar-foreground/75 hover:bg-muted/70 hover:text-foreground", )} > + + + diff --git a/src/components/layout/sidebar-account.tsx b/src/components/layout/sidebar-account.tsx new file mode 100644 index 0000000..1a84322 --- /dev/null +++ b/src/components/layout/sidebar-account.tsx @@ -0,0 +1,89 @@ +import { useNavigate } from "@tanstack/solid-router"; +import { Show } from "solid-js"; +import type { User } from "@/api/types"; +import type { MessageKey } from "@/i18n/messages"; +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuSeparator, + DropdownMenuTrigger, +} from "@/components/ui/dropdown-menu"; +import { IconChevronRight, IconGlobe, IconLogout, IconMoon, IconSun } from "@/components/ui/icons"; +import { useAuth } from "@/stores/auth-context"; +import { usePreferences, useT } from "@/stores/preferences-context"; +import { cn } from "@/lib/cn"; + +function initials(value: string) { + const parts = value.trim().split(/\s+/).filter(Boolean); + if (parts.length === 0) return "H"; + if (parts.length === 1) return parts[0]!.slice(0, 2).toLocaleUpperCase("tr-TR"); + return `${parts[0]![0] ?? ""}${parts[1]![0] ?? ""}`.toLocaleUpperCase("tr-TR"); +} + +function displayName(user: User) { + return [user.name, user.surname].filter(Boolean).join(" ").trim() || user.username; +} + +export function SidebarAccount(props: { collapsed?: boolean; onLogout: () => void | Promise }) { + const auth = useAuth(); + const prefs = usePreferences(); + const t = useT(); + const navigate = useNavigate(); + + return ( + + {(u) => { + const name = () => displayName(u()); + return ( +
+ + + + {initials(name())} + + + + {name()} + {t(`role.${u().role}` as MessageKey)} + + + + + + + void navigate({ to: "/profile" })}> + {t("profile.edit")} + + prefs.toggleTheme()}> + }> + + + {t("theme.toggle")} + {prefs.theme() === "dark" ? t("theme.dark") : t("theme.light")} + + prefs.setLocale(prefs.locale() === "tr" ? "en" : "tr")}> + + {t("lang.label")} + {prefs.locale() === "tr" ? "TR" : "EN"} + + + void props.onLogout()}> + + {t("nav.logout")} + + + +
+ ); + }} +
+ ); +} diff --git a/src/index.css b/src/index.css index 89e2fe5..43ba71d 100644 --- a/src/index.css +++ b/src/index.css @@ -38,34 +38,34 @@ } [data-kb-theme="dark"] { - --background: 168 28% 7%; - --foreground: 150 20% 96%; - --card: 168 24% 10%; - --card-foreground: 150 20% 96%; - --popover: 168 24% 10%; - --popover-foreground: 150 20% 96%; - --primary: 158 65% 48%; - --primary-foreground: 168 40% 8%; - --secondary: 168 18% 16%; - --secondary-foreground: 150 15% 92%; - --muted: 168 16% 14%; - --muted-foreground: 160 10% 62%; - --accent: 168 22% 16%; - --accent-foreground: 158 60% 70%; - --destructive: 0 62% 45%; + --background: 220 9% 6%; + --foreground: 220 12% 92%; + --card: 220 8% 9%; + --card-foreground: 220 12% 92%; + --popover: 220 8% 11%; + --popover-foreground: 220 12% 92%; + --primary: 220 88% 62%; + --primary-foreground: 220 20% 98%; + --secondary: 220 7% 15%; + --secondary-foreground: 220 10% 88%; + --muted: 220 7% 13%; + --muted-foreground: 220 7% 62%; + --accent: 220 9% 17%; + --accent-foreground: 220 15% 96%; + --destructive: 0 70% 58%; --destructive-foreground: 0 0% 98%; - --border: 168 14% 18%; - --input: 168 14% 18%; - --ring: 158 65% 48%; - --success: 152 55% 45%; - --warning: 38 90% 55%; + --border: 220 8% 18%; + --input: 220 8% 18%; + --ring: 220 88% 62%; + --success: 128 48% 55%; + --warning: 38 90% 56%; --info: 210 80% 60%; - --surface-elevated: 168 22% 12%; - --sidebar: 168 30% 8%; - --sidebar-foreground: 150 15% 90%; - --hero-from: 168 30% 12%; - --hero-to: 190 25% 12%; - --glow: 158 65% 40%; + --surface-elevated: 220 8% 12%; + --sidebar: 220 10% 4%; + --sidebar-foreground: 220 10% 86%; + --hero-from: 220 10% 13%; + --hero-to: 220 8% 10%; + --glow: 220 88% 54%; } * { @@ -79,8 +79,8 @@ body { @apply min-h-screen bg-background font-sans text-foreground antialiased; background-image: - radial-gradient(ellipse 80% 50% at 10% -10%, hsl(var(--glow) / 0.12), transparent), - radial-gradient(ellipse 60% 40% at 100% 0%, hsl(var(--info) / 0.06), transparent); + radial-gradient(ellipse 80% 50% at 10% -10%, hsl(var(--glow) / 0.10), transparent), + radial-gradient(ellipse 60% 40% at 100% 0%, hsl(var(--info) / 0.05), transparent); background-attachment: fixed; } @@ -98,6 +98,11 @@ @apply rounded-lg border bg-card text-card-foreground shadow-sm; } + [data-kb-theme="dark"] .surface-card { + @apply shadow-none; + background: linear-gradient(180deg, hsl(var(--card) / 0.98), hsl(var(--card) / 0.92)); + } + .hero-panel { background: linear-gradient(135deg, hsl(var(--hero-from)), hsl(var(--hero-to))); }