forge
Explore
Log in

Don't you dare go Hollow

💄 redesign authenticated sidebar shell

Browse files at this commit

3ad313e39057234d66a400b9c9b3e5cd9f29efb6Burak BoduroğluParent: 40d23c9
  • style
    • 💄 redesign authenticated sidebar shell
Show full message
style: 💄 redesign authenticated sidebar shell

- 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.tsxmodified+65 -25
@@ -1,10 +1,11 @@
11 import type { ParentProps } from "solid-js";
2-import { useLocation } from "@tanstack/solid-router";
3-import { Show } from "solid-js";
2+import { Link, useLocation, useNavigate } from "@tanstack/solid-router";
3+import { Show, createSignal } from "solid-js";
44 import { NavBar } from "@/components/layout/nav-bar";
55 import { SideNav } from "@/components/layout/side-nav";
6+import { SidebarAccount } from "@/components/layout/sidebar-account";
67 import { Button } from "@/components/ui/button";
7-import { IconChevronLeft, IconChevronRight } from "@/components/ui/icons";
8+import { IconChevronLeft, IconChevronRight, IconMenu } from "@/components/ui/icons";
89 import { useAuth } from "@/stores/auth-context";
910 import { usePreferences, useT } from "@/stores/preferences-context";
1011 import { cn } from "@/lib/cn";
@@ -16,68 +17,107 @@ export function AppShell(props: ParentProps) {
1617 const auth = useAuth();
1718 const prefs = usePreferences();
1819 const t = useT();
20+ const navigate = useNavigate();
21+ const [mobileOpen, setMobileOpen] = createSignal(false);
1922 const collapsed = () => prefs.sidebarCollapsed();
2023 const location = useLocation();
2124 const wide = () => location().pathname.startsWith("/exam-room/");
25+ const logout = async () => {
26+ await auth.logout();
27+ void navigate({ to: "/login" });
28+ };
2229
2330 return (
24- <div class="min-h-screen">
25- <NavBar />
31+ <div class="min-h-screen bg-background text-foreground">
32+ <Show when={!auth.user()}>
33+ <NavBar />
34+ </Show>
35+ <Show when={auth.user()}>
36+ <Button
37+ type="button"
38+ variant="outline"
39+ size="sm"
40+ class="fixed left-3 top-3 z-40 h-10 w-10 rounded-xl bg-background/90 px-0 shadow-sm backdrop-blur lg:hidden"
41+ aria-label={t("nav.menu")}
42+ onClick={() => setMobileOpen(true)}
43+ >
44+ <IconMenu class="h-5 w-5" />
45+ </Button>
46+ </Show>
2647 <div class="flex w-full">
2748 <Show when={auth.user()}>
2849 <aside
2950 class={cn(
30- "sticky top-14 z-30 hidden h-[calc(100vh-3.5rem)] shrink-0 border-r border-border/70 bg-sidebar/95 shadow-[inset_-1px_0_0_hsl(var(--border)/0.35)] backdrop-blur lg:flex lg:flex-col",
51+ "sticky top-0 z-30 hidden h-screen shrink-0 border-r border-border/80 bg-sidebar shadow-[inset_-1px_0_0_hsl(var(--border)/0.45)] lg:flex lg:flex-col",
3152 collapsed() ? SIDEBAR_COLLAPSED : SIDEBAR_EXPANDED,
3253 )}
3354 >
3455 <div
3556 class={cn(
36- "flex h-14 shrink-0 items-center border-b border-border/70",
57+ "flex h-16 shrink-0 items-center gap-2 border-b border-border/70",
3758 collapsed() ? "justify-center px-2" : "px-3",
3859 )}
3960 >
61+ <Link to="/" class={cn("flex min-w-0 flex-1 items-center gap-2", collapsed() && "hidden")}>
62+ <span class="flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-primary text-sm font-black text-primary-foreground shadow-sm">
63+ H
64+ </span>
65+ <span class="truncate font-display text-lg font-semibold tracking-tight">{t("app.name")}</span>
66+ </Link>
4067 <Button
4168 type="button"
4269 variant="ghost"
4370 size="sm"
4471 class={cn(
45- "h-9 rounded-lg text-muted-foreground hover:bg-muted/60 hover:text-foreground",
46- collapsed() ? "w-9 justify-center px-0" : "w-full justify-between px-3",
72+ "h-9 rounded-xl text-muted-foreground hover:bg-muted/70 hover:text-foreground",
73+ collapsed() ? "w-9 justify-center px-0" : "w-9 shrink-0 justify-center px-0",
4774 )}
4875 aria-label={collapsed() ? t("nav.expand") : t("nav.collapse")}
4976 title={collapsed() ? t("nav.expand") : t("nav.collapse")}
5077 onClick={() => prefs.toggleSidebar()}
5178 >
52- <Show when={!collapsed()}>
53- <span class="text-xs font-medium">{t("nav.collapse")}</span>
54- </Show>
5579 <Show when={collapsed()} fallback={<IconChevronLeft class="h-4 w-4 shrink-0" />}>
5680 <IconChevronRight class="h-4 w-4 shrink-0" />
5781 </Show>
5882 </Button>
5983 </div>
6084
61- {/* Nav fills remaining height; guide is pinned above footer inside SideNav */}
62- <div class="min-h-0 flex-1 overflow-y-auto overflow-x-hidden pt-3 pb-1">
85+ <div class="min-h-0 flex-1 overflow-y-auto overflow-x-hidden py-4">
6386 <SideNav collapsed={collapsed()} />
6487 </div>
6588
66- <div
67- class={cn(
68- "shrink-0 border-t border-border",
69- collapsed() ? "hidden" : "flex items-center justify-center px-3 py-2",
70- )}
71- >
72- <p class="text-center text-[11px] leading-relaxed text-muted-foreground">
73- {t("app.workspace")}
74- </p>
75- </div>
89+ <SidebarAccount collapsed={collapsed()} onLogout={logout} />
7690 </aside>
7791 </Show>
7892
93+ <Show when={mobileOpen() && auth.user()}>
94+ <div class="fixed inset-0 z-50 lg:hidden">
95+ <button
96+ type="button"
97+ class="absolute inset-0 bg-black/60 backdrop-blur-sm"
98+ aria-label={t("nav.close")}
99+ onClick={() => setMobileOpen(false)}
100+ />
101+ <aside class="absolute inset-y-0 left-0 flex w-72 max-w-[85vw] flex-col border-r border-border bg-sidebar shadow-soft">
102+ <div class="flex h-16 shrink-0 items-center justify-between border-b border-border px-4">
103+ <Link to="/" class="flex items-center gap-2" onClick={() => setMobileOpen(false)}>
104+ <span class="flex h-9 w-9 items-center justify-center rounded-xl bg-primary text-sm font-black text-primary-foreground">H</span>
105+ <span class="font-display text-lg font-semibold">{t("app.name")}</span>
106+ </Link>
107+ <Button type="button" variant="ghost" size="sm" onClick={() => setMobileOpen(false)}>
108+ {t("nav.close")}
109+ </Button>
110+ </div>
111+ <div class="min-h-0 flex-1 overflow-y-auto py-4">
112+ <SideNav onNavigate={() => setMobileOpen(false)} />
113+ </div>
114+ <SidebarAccount onLogout={logout} />
115+ </aside>
116+ </div>
117+ </Show>
118+
79119 <main class="min-w-0 flex-1">
80- <div class={cn("mx-auto w-full px-4 py-6 sm:px-6 lg:px-8 lg:py-8", wide() ? "max-w-none" : "max-w-[1200px]") }>
120+ <div class={cn("mx-auto w-full px-4 py-6 sm:px-6 lg:px-8 lg:py-5", wide() ? "max-w-none" : "max-w-[1200px]") }>
81121 {props.children}
82122 </div>
83123 </main>
src/components/layout/side-nav.tsxmodified+8 -5
@@ -63,18 +63,21 @@ function NavLink(props: {
6363 title={t(props.item.labelKey)}
6464 aria-current={active() ? "page" : undefined}
6565 class={cn(
66- "group relative flex h-10 w-full items-center rounded-lg text-sm font-medium outline-none",
66+ "group relative flex h-10 w-full items-center rounded-xl text-sm font-medium outline-none",
6767 "transition-all duration-150",
6868 props.collapsed ? "justify-center px-0" : "gap-2 px-2",
6969 active()
70- ? "bg-primary/10 text-primary shadow-sm ring-1 ring-primary/15"
71- : "text-sidebar-foreground/80 hover:bg-muted/60 hover:text-foreground",
70+ ? "bg-primary/10 text-primary shadow-sm ring-1 ring-primary/20"
71+ : "text-sidebar-foreground/75 hover:bg-muted/70 hover:text-foreground",
7272 )}
7373 >
74+ <Show when={active() && !props.collapsed}>
75+ <span class="absolute left-0 top-1/2 h-5 w-0.5 -translate-y-1/2 rounded-full bg-primary" />
76+ </Show>
7477 <span
7578 class={cn(
76- "inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md transition-colors",
77- active() ? "bg-primary text-primary-foreground shadow-sm" : "text-muted-foreground group-hover:bg-background/50 group-hover:text-foreground",
79+ "inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg transition-colors",
80+ active() ? "bg-primary text-primary-foreground shadow-sm" : "text-muted-foreground group-hover:bg-background/60 group-hover:text-foreground",
7881 )}
7982 >
8083 <props.item.Icon class="h-4 w-4" />
src/components/layout/sidebar-account.tsxadded+89 -0
@@ -0,0 +1,89 @@
1+import { useNavigate } from "@tanstack/solid-router";
2+import { Show } from "solid-js";
3+import type { User } from "@/api/types";
4+import type { MessageKey } from "@/i18n/messages";
5+import {
6+ DropdownMenu,
7+ DropdownMenuContent,
8+ DropdownMenuItem,
9+ DropdownMenuSeparator,
10+ DropdownMenuTrigger,
11+} from "@/components/ui/dropdown-menu";
12+import { IconChevronRight, IconGlobe, IconLogout, IconMoon, IconSun } from "@/components/ui/icons";
13+import { useAuth } from "@/stores/auth-context";
14+import { usePreferences, useT } from "@/stores/preferences-context";
15+import { cn } from "@/lib/cn";
16+
17+function initials(value: string) {
18+ const parts = value.trim().split(/\s+/).filter(Boolean);
19+ if (parts.length === 0) return "H";
20+ if (parts.length === 1) return parts[0]!.slice(0, 2).toLocaleUpperCase("tr-TR");
21+ return `${parts[0]![0] ?? ""}${parts[1]![0] ?? ""}`.toLocaleUpperCase("tr-TR");
22+}
23+
24+function displayName(user: User) {
25+ return [user.name, user.surname].filter(Boolean).join(" ").trim() || user.username;
26+}
27+
28+export function SidebarAccount(props: { collapsed?: boolean; onLogout: () => void | Promise<void> }) {
29+ const auth = useAuth();
30+ const prefs = usePreferences();
31+ const t = useT();
32+ const navigate = useNavigate();
33+
34+ return (
35+ <Show when={auth.user()}>
36+ {(u) => {
37+ const name = () => displayName(u());
38+ return (
39+ <div class={cn("shrink-0 border-t border-border/80 p-3", props.collapsed && "px-2")}>
40+ <DropdownMenu placement="right-end" gutter={8}>
41+ <DropdownMenuTrigger
42+ class={cn(
43+ "flex w-full items-center rounded-xl border border-border/80 bg-muted/35 text-left outline-none transition-colors",
44+ "hover:bg-muted/60 focus-visible:ring-2 focus-visible:ring-ring data-[expanded]:bg-muted/70",
45+ props.collapsed ? "h-11 justify-center px-0" : "gap-3 p-2",
46+ )}
47+ aria-label={t("nav.account")}
48+ >
49+ <span class="flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-primary text-xs font-bold text-primary-foreground">
50+ {initials(name())}
51+ </span>
52+ <Show when={!props.collapsed}>
53+ <span class="min-w-0 flex-1">
54+ <span class="block truncate text-sm font-semibold">{name()}</span>
55+ <span class="block truncate text-xs text-muted-foreground">{t(`role.${u().role}` as MessageKey)}</span>
56+ </span>
57+ <IconChevronRight class="h-4 w-4 text-muted-foreground" />
58+ </Show>
59+ </DropdownMenuTrigger>
60+
61+ <DropdownMenuContent class="w-52 rounded-xl border-border/80 bg-popover p-1.5 shadow-soft">
62+ <DropdownMenuItem class="rounded-lg" onSelect={() => void navigate({ to: "/profile" })}>
63+ <span>{t("profile.edit")}</span>
64+ </DropdownMenuItem>
65+ <DropdownMenuItem class="rounded-lg" onSelect={() => prefs.toggleTheme()}>
66+ <Show when={prefs.theme() === "dark"} fallback={<IconSun class="h-4 w-4 shrink-0" />}>
67+ <IconMoon class="h-4 w-4 shrink-0" />
68+ </Show>
69+ <span class="min-w-0 flex-1">{t("theme.toggle")}</span>
70+ <span class="text-xs text-muted-foreground">{prefs.theme() === "dark" ? t("theme.dark") : t("theme.light")}</span>
71+ </DropdownMenuItem>
72+ <DropdownMenuItem class="rounded-lg" onSelect={() => prefs.setLocale(prefs.locale() === "tr" ? "en" : "tr")}>
73+ <IconGlobe class="h-4 w-4 shrink-0" />
74+ <span class="min-w-0 flex-1">{t("lang.label")}</span>
75+ <span class="text-xs text-muted-foreground">{prefs.locale() === "tr" ? "TR" : "EN"}</span>
76+ </DropdownMenuItem>
77+ <DropdownMenuSeparator />
78+ <DropdownMenuItem destructive class="rounded-lg" onSelect={() => void props.onLogout()}>
79+ <IconLogout class="h-4 w-4 shrink-0" />
80+ <span>{t("nav.logout")}</span>
81+ </DropdownMenuItem>
82+ </DropdownMenuContent>
83+ </DropdownMenu>
84+ </div>
85+ );
86+ }}
87+ </Show>
88+ );
89+}
src/index.cssmodified+33 -28
@@ -38,34 +38,34 @@
3838 }
3939
4040 [data-kb-theme="dark"] {
41- --background: 168 28% 7%;
42- --foreground: 150 20% 96%;
43- --card: 168 24% 10%;
44- --card-foreground: 150 20% 96%;
45- --popover: 168 24% 10%;
46- --popover-foreground: 150 20% 96%;
47- --primary: 158 65% 48%;
48- --primary-foreground: 168 40% 8%;
49- --secondary: 168 18% 16%;
50- --secondary-foreground: 150 15% 92%;
51- --muted: 168 16% 14%;
52- --muted-foreground: 160 10% 62%;
53- --accent: 168 22% 16%;
54- --accent-foreground: 158 60% 70%;
55- --destructive: 0 62% 45%;
41+ --background: 220 9% 6%;
42+ --foreground: 220 12% 92%;
43+ --card: 220 8% 9%;
44+ --card-foreground: 220 12% 92%;
45+ --popover: 220 8% 11%;
46+ --popover-foreground: 220 12% 92%;
47+ --primary: 220 88% 62%;
48+ --primary-foreground: 220 20% 98%;
49+ --secondary: 220 7% 15%;
50+ --secondary-foreground: 220 10% 88%;
51+ --muted: 220 7% 13%;
52+ --muted-foreground: 220 7% 62%;
53+ --accent: 220 9% 17%;
54+ --accent-foreground: 220 15% 96%;
55+ --destructive: 0 70% 58%;
5656 --destructive-foreground: 0 0% 98%;
57- --border: 168 14% 18%;
58- --input: 168 14% 18%;
59- --ring: 158 65% 48%;
60- --success: 152 55% 45%;
61- --warning: 38 90% 55%;
57+ --border: 220 8% 18%;
58+ --input: 220 8% 18%;
59+ --ring: 220 88% 62%;
60+ --success: 128 48% 55%;
61+ --warning: 38 90% 56%;
6262 --info: 210 80% 60%;
63- --surface-elevated: 168 22% 12%;
64- --sidebar: 168 30% 8%;
65- --sidebar-foreground: 150 15% 90%;
66- --hero-from: 168 30% 12%;
67- --hero-to: 190 25% 12%;
68- --glow: 158 65% 40%;
63+ --surface-elevated: 220 8% 12%;
64+ --sidebar: 220 10% 4%;
65+ --sidebar-foreground: 220 10% 86%;
66+ --hero-from: 220 10% 13%;
67+ --hero-to: 220 8% 10%;
68+ --glow: 220 88% 54%;
6969 }
7070
7171 * {
@@ -79,8 +79,8 @@
7979 body {
8080 @apply min-h-screen bg-background font-sans text-foreground antialiased;
8181 background-image:
82- radial-gradient(ellipse 80% 50% at 10% -10%, hsl(var(--glow) / 0.12), transparent),
83- radial-gradient(ellipse 60% 40% at 100% 0%, hsl(var(--info) / 0.06), transparent);
82+ radial-gradient(ellipse 80% 50% at 10% -10%, hsl(var(--glow) / 0.10), transparent),
83+ radial-gradient(ellipse 60% 40% at 100% 0%, hsl(var(--info) / 0.05), transparent);
8484 background-attachment: fixed;
8585 }
8686
@@ -98,6 +98,11 @@
9898 @apply rounded-lg border bg-card text-card-foreground shadow-sm;
9999 }
100100
101+ [data-kb-theme="dark"] .surface-card {
102+ @apply shadow-none;
103+ background: linear-gradient(180deg, hsl(var(--card) / 0.98), hsl(var(--card) / 0.92));
104+ }
105+
101106 .hero-panel {
102107 background: linear-gradient(135deg, hsl(var(--hero-from)), hsl(var(--hero-to)));
103108 }