From f9872a0e07169976401dce1a68b6d52be3033f49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Boduro=C4=9Flu?= <80620802+burakboduroglu@users.noreply.github.com> Date: Tue, 28 Jul 2026 13:17:16 +0300 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=A8=20Knowvio-style=20role-bas?= =?UTF-8?q?ed=20dashboard,=20sidebar,=20and=20theme=20-=20rebuild=20dashbo?= =?UTF-8?q?ard-page=20as=20a=20role-scoped=20board:=20Highlights=20stat=20?= =?UTF-8?q?cards=20=20=20with=20real-data=20sparklines,=20Progress=20overv?= =?UTF-8?q?iew=20(course=20averages=20/=20class=20=20=20sizes),=20attendan?= =?UTF-8?q?ce=20&=20workload=20split=20donuts,=20and=20an=20Upcoming=20Dea?= =?UTF-8?q?dlines=20=20=20DataTable=20merging=20exams/events/homework/appo?= =?UTF-8?q?intments=20-=20restore=20chart-area-trend/bar/progress-ring,=20?= =?UTF-8?q?i18n=20their=20empty=20states,=20=20=20drop=20unused=20chart-me?= =?UTF-8?q?tric-cards=20-=20add=20role-aware=20fetches=20(admin/manager=20?= =?UTF-8?q?reach=20exams+homework),=20a=20=20=20bottom-center=20Refresh=20?= =?UTF-8?q?that=20refetches=20all=20resources,=20and=20a=20Soru=20Havuzu?= =?UTF-8?q?=20=20=20(question=20bank)=20quick=20panel=20-=20simplify=20sid?= =?UTF-8?q?ebar=20to=20the=20curated=20primary=20items=20+=20Messages=20un?= =?UTF-8?q?read=20badge;=20=20=20drop=20the=20guide=20card=20and=20in-side?= =?UTF-8?q?bar=20theme=20toggle=20-=20add=20a=20header=20back=20button;=20?= =?UTF-8?q?unify=20top-bar=20action=20buttons=20as=20bordered=20-=20rebran?= =?UTF-8?q?d=20accent=20to=20Knowvio=20orange=20and=20adopt=20Space=20Grot?= =?UTF-8?q?esk=20+=20Inter=20fonts=20-=20update=20dashboard-design=20skill?= =?UTF-8?q?=20+=20ui=20tokens=20to=20allow=20real-data=20charts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .claude/skills/dashboard-design/SKILL.md | 27 +- .codex/skills/dashboard-design/SKILL.md | 27 +- bun.lock | 6 + docs/ui/ui-redesign-tokens.md | 20 +- package.json | 2 + src/components/layout/app-shell.tsx | 70 +- src/components/layout/notification-center.tsx | 4 +- src/components/layout/side-nav.tsx | 193 +- src/components/ui/chart-area-trend.tsx | 6 +- src/components/ui/chart-bar.tsx | 6 +- src/components/ui/chart-metric-cards.tsx | 72 - src/components/ui/chart-progress-ring.tsx | 6 +- src/i18n/messages.ts | 412 ++++- src/index.css | 32 +- src/index.tsx | 2 + src/pages/dashboard-page.tsx | 1572 ++++------------- 16 files changed, 956 insertions(+), 1501 deletions(-) delete mode 100644 src/components/ui/chart-metric-cards.tsx diff --git a/.claude/skills/dashboard-design/SKILL.md b/.claude/skills/dashboard-design/SKILL.md index f0f8cc1..336fa01 100644 --- a/.claude/skills/dashboard-design/SKILL.md +++ b/.claude/skills/dashboard-design/SKILL.md @@ -1,6 +1,6 @@ --- name: dashboard-design -description: Rules for the hezarfen_frontend dashboard/homepage — a read-only status board (no mutations), monochrome palette with semantic-only status color, portal-card layout, grid, and role scoping. Load before editing src/pages/dashboard-page.tsx or the homepage. +description: Rules for the hezarfen_frontend dashboard/homepage — a read-only board (no mutations), Knowvio-style stat cards + real-data charts + deadlines table, and role scoping. Load before editing src/pages/dashboard-page.tsx or the homepage. --- # Dashboard / homepage design @@ -8,13 +8,22 @@ description: Rules for the hezarfen_frontend dashboard/homepage — a read-only Reference: `src/pages/dashboard-page.tsx`. The homepage is a **read-only status board**, not a marketing landing or action hub. - **No mutations:** no create/edit/delete buttons, no primary CTAs that open forms. Links only navigate to existing list/detail routes. -- **Palette:** monochrome / grayscale surfaces (border, card, muted). No decorative color accents, gradients, activity charts, or multi-tone portal cards. **Semantic color only** for status (active / today / soon / danger). +- **Charts are allowed, on real data only.** The homepage follows the Knowvio-style + layout: a Highlights stat-card row, a Progress-overview chart, an Activity/attendance + split, and an Upcoming-deadlines table. Charts use the `Chart*` components in + `src/components/ui/` (accent = `hsl(var(--primary))`, semantic tints for status). + **Every chart/stat must be backed by a live API field** — no fabricated trends, + streak counters, or `+%` delta badges the backend can't produce. Hide a panel when + its data source is empty for the current role rather than faking it. - **Layout order (top → bottom):** 1. Compact header — greeting, role chip (neutral), date. - 2. Role-scoped **workspace portal cards** (section links with optional counts). - 3. **Needs attention** + **Upcoming** side by side on `lg+`, stacked on mobile. -- **Portal cards:** horizontal dense rows — icon | title + short desc | optional count. On desktop, title and count share one line as `Title | 12` (pipe separator, mono tabular count). No separate KPI strip repeating the same numbers. -- **Grid:** `1` col mobile → `2` sm → `3` lg → `4` xl. Equal-ish min height; avoid uneven multi-line stat stacks. -- **Role scoping:** card set matches nav/role matrix (student personal tools; teacher teaching tools; manager+ management; admin gets staff-work + users, not personal `/work`). Optional min-role badge is muted/neutral, not rainbow. -- **Attention list:** active / today / soon exams and events only; rows navigate to detail. Empty state is plain text, not a create CTA. -- Do not reintroduce guide marketing blocks, vanity charts, or redundant bottom KPI tiles. + 2. **Highlights** — role-scoped stat cards (icon + label + mono value). + 3. **Progress overview** chart + **Activity split** on `lg+`. + 4. **Upcoming deadlines** `DataTable` (exams / events / homework / appointments). + 5. Optional role-scoped workspace links / recent list. +- **Grid:** stat row `1 → 2 sm → 4 lg`; charts `lg:grid-cols-3` (progress spans 2). +- **Role scoping:** stat/chart set matches nav/role matrix (student personal tools + + marks/attendance; teacher teaching tools; manager+ management; parent children/meals). + Show only panels whose data exists for the role. +- **Deadlines table:** active / today / soon items only, semantic status badge, rows + navigate to detail. Empty state is plain text, not a create CTA. diff --git a/.codex/skills/dashboard-design/SKILL.md b/.codex/skills/dashboard-design/SKILL.md index f0f8cc1..336fa01 100644 --- a/.codex/skills/dashboard-design/SKILL.md +++ b/.codex/skills/dashboard-design/SKILL.md @@ -1,6 +1,6 @@ --- name: dashboard-design -description: Rules for the hezarfen_frontend dashboard/homepage — a read-only status board (no mutations), monochrome palette with semantic-only status color, portal-card layout, grid, and role scoping. Load before editing src/pages/dashboard-page.tsx or the homepage. +description: Rules for the hezarfen_frontend dashboard/homepage — a read-only board (no mutations), Knowvio-style stat cards + real-data charts + deadlines table, and role scoping. Load before editing src/pages/dashboard-page.tsx or the homepage. --- # Dashboard / homepage design @@ -8,13 +8,22 @@ description: Rules for the hezarfen_frontend dashboard/homepage — a read-only Reference: `src/pages/dashboard-page.tsx`. The homepage is a **read-only status board**, not a marketing landing or action hub. - **No mutations:** no create/edit/delete buttons, no primary CTAs that open forms. Links only navigate to existing list/detail routes. -- **Palette:** monochrome / grayscale surfaces (border, card, muted). No decorative color accents, gradients, activity charts, or multi-tone portal cards. **Semantic color only** for status (active / today / soon / danger). +- **Charts are allowed, on real data only.** The homepage follows the Knowvio-style + layout: a Highlights stat-card row, a Progress-overview chart, an Activity/attendance + split, and an Upcoming-deadlines table. Charts use the `Chart*` components in + `src/components/ui/` (accent = `hsl(var(--primary))`, semantic tints for status). + **Every chart/stat must be backed by a live API field** — no fabricated trends, + streak counters, or `+%` delta badges the backend can't produce. Hide a panel when + its data source is empty for the current role rather than faking it. - **Layout order (top → bottom):** 1. Compact header — greeting, role chip (neutral), date. - 2. Role-scoped **workspace portal cards** (section links with optional counts). - 3. **Needs attention** + **Upcoming** side by side on `lg+`, stacked on mobile. -- **Portal cards:** horizontal dense rows — icon | title + short desc | optional count. On desktop, title and count share one line as `Title | 12` (pipe separator, mono tabular count). No separate KPI strip repeating the same numbers. -- **Grid:** `1` col mobile → `2` sm → `3` lg → `4` xl. Equal-ish min height; avoid uneven multi-line stat stacks. -- **Role scoping:** card set matches nav/role matrix (student personal tools; teacher teaching tools; manager+ management; admin gets staff-work + users, not personal `/work`). Optional min-role badge is muted/neutral, not rainbow. -- **Attention list:** active / today / soon exams and events only; rows navigate to detail. Empty state is plain text, not a create CTA. -- Do not reintroduce guide marketing blocks, vanity charts, or redundant bottom KPI tiles. + 2. **Highlights** — role-scoped stat cards (icon + label + mono value). + 3. **Progress overview** chart + **Activity split** on `lg+`. + 4. **Upcoming deadlines** `DataTable` (exams / events / homework / appointments). + 5. Optional role-scoped workspace links / recent list. +- **Grid:** stat row `1 → 2 sm → 4 lg`; charts `lg:grid-cols-3` (progress spans 2). +- **Role scoping:** stat/chart set matches nav/role matrix (student personal tools + + marks/attendance; teacher teaching tools; manager+ management; parent children/meals). + Show only panels whose data exists for the role. +- **Deadlines table:** active / today / soon items only, semantic status badge, rows + navigate to detail. Empty state is plain text, not a create CTA. diff --git a/bun.lock b/bun.lock index 3ab49c2..2529386 100644 --- a/bun.lock +++ b/bun.lock @@ -5,6 +5,8 @@ "": { "name": "hezarfen-frontend", "dependencies": { + "@fontsource-variable/inter": "^5.3.0", + "@fontsource-variable/space-grotesk": "^5.3.0", "@kobalte/core": "^0.13.12", "@tanstack/solid-router": "^1.170.18", "@tanstack/solid-table": "^8.21.3", @@ -162,6 +164,10 @@ "@floating-ui/utils": ["@floating-ui/utils@0.2.12", "", {}, "sha512-HpCo8tmWzLVad5s2d19EhAz5zqrrQ6s69qd6moPMQvkOuSwDT1YgRfWSVuc4ennqrgv3OHppiOGMQ7oC13yIww=="], + "@fontsource-variable/inter": ["@fontsource-variable/inter@5.3.0", "", {}, "sha512-OupL48va4JNofb97w6NYeF9S7W/kHNKM0Er8Dem5nqi4jeOLrVJDoE8tZEpnMJmtkvNbB1EIPPwHcdkF6b1oUA=="], + + "@fontsource-variable/space-grotesk": ["@fontsource-variable/space-grotesk@5.3.0", "", {}, "sha512-2IxmvfB08i9vnGB3Ym/AXvhRE+8XOjWMXIyDum03c+tPwH0FUoMNQfGpU8NXPxjbws0Vvss3AH0Zqt4oJBBAdw=="], + "@internationalized/number": ["@internationalized/number@3.6.7", "", { "dependencies": { "@swc/helpers": "^0.5.0" } }, "sha512-3ji1fcrT+FPAK86UqEhB/psHixYo6niWPJtt7+qRaYFynt/BaJG8GhAPimtWUpEiVSTq8ZM8L5psMxGquiB/Vg=="], "@jridgewell/gen-mapping": ["@jridgewell/gen-mapping@0.3.13", "", { "dependencies": { "@jridgewell/sourcemap-codec": "^1.5.0", "@jridgewell/trace-mapping": "^0.3.24" } }, "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA=="], diff --git a/docs/ui/ui-redesign-tokens.md b/docs/ui/ui-redesign-tokens.md index 2d595bc..20d2cbd 100644 --- a/docs/ui/ui-redesign-tokens.md +++ b/docs/ui/ui-redesign-tokens.md @@ -4,8 +4,9 @@ Dense school admin UI with Apple HIG-inspired grouped surfaces: neutral grouped backgrounds, subtle borders, translucent overlays, one blue accent for -interactive chrome only. Dashboard and overview surfaces stay grayscale; color -is reserved for semantic status (success / warning / danger / info). +interactive chrome only. Surfaces stay neutral; color is reserved for the blue +accent, dashboard charts (see "Charts" below), and semantic status (success / +warning / danger / info). ## Color @@ -85,7 +86,7 @@ Reference page: `src/pages/admin-users-page.tsx`. Implemented: -- grouped accordion sidebar with active category auto-open +- fixed single-level role sidebar with one neutral raised active row - compact stat row on top of users page - dense sticky data table styling via `.data-table` - centered row action dropdowns via `TableRowActions` @@ -132,9 +133,20 @@ Reference implementation: `src/pages/dashboard-page.tsx`. - Status uses semantic color only (dot + small badge): active (emerald), today (amber), soon (muted). - Empty states are plain text — never “create exam/event” CTAs. +### Charts (Knowvio-style dashboard) + +- The homepage uses the `Chart*` components in `src/components/ui/` (area trend, + bar, progress ring) for a Highlights stat row + Progress-overview + Activity split, + plus a `DataTable` of upcoming deadlines. Accent = `hsl(var(--primary))`; status + tints stay semantic (emerald/amber/rose/muted). +- **Real data only:** every chart/stat maps to a live API field. No fabricated daily + trends, streak counters, or `+%` delta badges. Hide a panel when its source is empty + for the current role. + ### Out of scope for dashboard -- Activity bar charts, multi-color portal accents, guide/marketing footers, create shortcuts, redundant summary KPI tiles under the portal grid. +- Guide/marketing footers, create shortcuts, promotional/upgrade cards. +- Drag/drop ordering, fabricated trends / streaks, `+%` deltas, manual refresh controls. ## Current Implementation Notes diff --git a/package.json b/package.json index f4baa14..0c96a58 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,8 @@ "prepare": "git config core.hooksPath .githooks 2>/dev/null || true" }, "dependencies": { + "@fontsource-variable/inter": "^5.3.0", + "@fontsource-variable/space-grotesk": "^5.3.0", "@kobalte/core": "^0.13.12", "@tanstack/solid-router": "^1.170.18", "@tanstack/solid-table": "^8.21.3", diff --git a/src/components/layout/app-shell.tsx b/src/components/layout/app-shell.tsx index c69c8a7..52fc324 100644 --- a/src/components/layout/app-shell.tsx +++ b/src/components/layout/app-shell.tsx @@ -6,18 +6,19 @@ import { CommandPalette } from "@/components/layout/command-palette"; import { MobileTabBar } from "@/components/layout/mobile-tab-bar"; import { NavBar } from "@/components/layout/nav-bar"; import { NotificationCenter } from "@/components/layout/notification-center"; -import { RightNav } from "@/components/layout/right-nav"; +import { routeNavItem } from "@/components/layout/nav-items"; +import { ShellMessagesButton } from "@/components/layout/shell-messages-button"; import { SideNav } from "@/components/layout/side-nav"; import { SidebarAccount } from "@/components/layout/sidebar-account"; import { Button } from "@/components/ui/button"; -import { IconBotSquare, IconPanelLeft, IconSearch, IconX } from "@/components/ui/icons"; +import { IconBotSquare, IconChevronLeft, IconPanelLeft, IconSearch, IconX } from "@/components/ui/icons"; import { Toaster } from "@/components/ui/toast"; import { useAuth } from "@/stores/auth-context"; import { ShellFeedProvider } from "@/stores/shell-feed-context"; import { usePreferences, useT } from "@/stores/preferences-context"; import { cn } from "@/lib/cn"; -const SIDEBAR_EXPANDED = "w-52 2xl:w-56"; +const SIDEBAR_EXPANDED = "w-60"; const SIDEBAR_COLLAPSED = "w-16"; export function AppShell(props: ParentProps) { @@ -34,35 +35,8 @@ export function AppShell(props: ParentProps) { const wide = () => location().pathname.startsWith("/exam-room/") || location().searchStr.includes("answerUser=") || location().pathname === "/messages"; const fullScreen = () => location().pathname.startsWith("/exam-room/"); const routeLabel = createMemo(() => { - const path = location().pathname; - if (path === "/") return t("nav.home"); - if (path === "/notes") return `${t("nav.group.grades")} / ${t("nav.notes")}`; - if (path === "/messages") return `${t("nav.group.community")} / ${t("nav.messages")}`; - if (path === "/marks") return `${t("nav.group.classes")} / ${t("nav.marks")}`; - if (path === "/attendance") return `${t("nav.group.classes")} / ${t("nav.attendance")}`; - if (path === "/pomodoro") return `${t("nav.group.classes")} / ${t("nav.pomodoro")}`; - if (path === "/courses" || path.startsWith("/courses/")) return `${t("nav.group.classes")} / ${t("nav.courses")}`; - if (path === "/studies") return `${t("nav.group.classes")} / ${t("nav.studies")}`; - if (path === "/clubs") return `${t("nav.group.classes")} / ${t("nav.clubs")}`; - if (path === "/homework" || path.startsWith("/homework/")) return `${t("nav.group.classes")} / ${t("nav.homework")}`; - if (path === "/events" || path.startsWith("/events/")) return `${t("nav.group.classes")} / ${t("nav.events")}`; - if (path === "/exams" || path.startsWith("/exams/")) return `${t("nav.group.classes")} / ${t("nav.exams")}`; - if (path === "/question-bank") return `${t("nav.group.classes")} / ${t("nav.questionBank")}`; - if (path === "/calendar") return `${t("nav.group.classes")} / ${t("nav.calendar")}`; - if (path === "/appointments") return `${t("nav.group.classes")} / ${t("nav.appointments")}`; - if (path === "/students") return `${t("nav.group.students")} / ${t("nav.myStudents")}`; - if (path === "/questions" || path.startsWith("/questions/")) return `${t("nav.group.community")} / ${t("pool.title")}`; - if (path.startsWith("/exam-room/")) return t("nav.exams"); - if (path === "/work") return `${t("nav.group.reports")} / ${t("nav.work")}`; - if (path === "/management/student-marks") return `${t("nav.group.classes")} / ${t("nav.studentMarks")}`; - if (path === "/management/student-attendance") return `${t("nav.group.reports")} / ${t("nav.studentAttendance")}`; - if (path === "/management/pomodoros") return `${t("nav.group.reports")} / ${t("nav.studentPomodoro")}`; - if (path === "/management/staff-work") return `${t("nav.group.reports")} / ${t("nav.staffWork")}`; - if (path === "/management/settings") return `${t("nav.group.settings")} / ${t("nav.settings")}`; - if (path === "/management/terms") return `${t("nav.group.settings")} / ${t("nav.terms")}`; - if (path === "/admin/users") return `${t("nav.admin")} / ${t("nav.users")}`; - if (path === "/guide") return t("nav.guide"); - return path; + const item = routeNavItem(location().pathname, auth.user()?.role); + return item ? t(item.labelKey) : location().pathname; }); const logout = async () => { await auth.logout(); @@ -157,18 +131,27 @@ export function AppShell(props: ParentProps) {
-
-
-
- {routeLabel()} -
+
+
+ + + + {routeLabel()}
-
+
-
+
+ - @@ -200,10 +184,6 @@ export function AppShell(props: ParentProps) { {props.children}
- - - - {/* MobileTabBar stays inside the provider — it is a shell surface, so a useShellFeed() badge there must not throw. */} diff --git a/src/components/layout/notification-center.tsx b/src/components/layout/notification-center.tsx index 902c1d3..b953500 100644 --- a/src/components/layout/notification-center.tsx +++ b/src/components/layout/notification-center.tsx @@ -200,8 +200,8 @@ export function NotificationCenter() { void; - standalone?: boolean; -}) { - const t = useT(); - const pathname = useRouterState({ select: (s) => s.location.pathname }); - const active = () => pathActive(pathname(), props.item.to, props.item.exact); - - return ( - props.onNavigate?.()} - title={t(props.item.labelKey)} - aria-current={active() ? "page" : undefined} - class={cn( - "relative flex h-9 w-full items-center rounded-md outline-hidden transition-colors duration-150 active:scale-[0.98] 2xl:h-9", - props.standalone ? "text-sm font-semibold" : "text-[13px] font-medium", - props.collapsed ? "mx-auto h-9 w-9 justify-center px-0" : props.standalone ? "gap-2.5 px-2.5" : "gap-2 px-2.5", - active() - ? props.standalone - ? "bg-primary/12 font-semibold text-primary dark:bg-white/9 dark:text-white" - : "font-semibold text-primary dark:text-white" - : "text-sidebar-foreground/80 hover:bg-secondary hover:text-foreground dark:text-white/86 dark:hover:bg-white/[0.07] dark:hover:text-white", - )} - > - - {t(props.item.labelKey)} - - ); -} +const MESSAGES_ITEM: NavItem = { id: "messages", to: "/messages", labelKey: "nav.messages", Icon: IconMessage }; export function SideNav(props: { onNavigate?: () => void; collapsed?: boolean }) { const auth = useAuth(); const t = useT(); - const pathname = useRouterState({ select: (s) => s.location.pathname }); - const role = () => auth.user()?.role; - - const visibleGroups = createMemo(() => visibleNavGroups(role())); - const activeGroupId = createMemo( - () => - visibleGroups().find((group) => group.items.some((item) => pathActive(pathname(), item.to, item.exact)))?.id ?? - "", - ); - const [openGroups, setOpenGroups] = createSignal>({}); + const feed = useShellFeed(); + const pathname = useRouterState({ select: (state) => state.location.pathname }); - const isOpen = (groupId: string) => openGroups()[groupId] === true; - - const toggleGroup = (groupId: string) => { - setOpenGroups((current) => ({ ...current, [groupId]: !current[groupId] })); + // Curated set: the role's primary items (same source as the mobile tab bar) plus + // Messages. Everything else stays reachable via the ⌘K command palette. + const items = (): NavItem[] => { + const primary = primaryNavItems(auth.user()?.role); + return primary.some((i) => i.id === "messages") ? primary : [...primary, MESSAGES_ITEM]; }; - - createEffect(() => { - const active = activeGroupId(); - if (!active) return; - setOpenGroups((current) => (current[active] ? current : { ...current, [active]: true })); - }); + const unread = () => feed.unreadMessages().total; + const badgeFor = (item: NavItem) => (item.id === "messages" ? unread() : 0); return (