forge
Explore
Log in

Don't you dare go Hollow

✨ dashboard visual analytics and expandable workspace grid

Browse files at this commit

f77a16476496bd1be08aa12069ca6e2af2b96c16Burak BoduroğluParent: 1e8b8f9
  • feat
    • ✨ dashboard visual analytics and expandable workspace grid
Show full message
feat: ✨ dashboard visual analytics and expandable workspace grid

- add reusable ChartBar and ChartProgressRing visual analytics components under src/components/ui/

- update dashboard-page.tsx with top visual analytics panel and 2-row expandable workspace portal cards grid

- update Turkish i18n key for nav.marks to Karnem for student report card routing clarity

- export IconChevronUp in src/components/ui/icons.tsx for smooth disclosure toggles
src/components/ui/chart-bar.tsxadded+96 -0
@@ -0,0 +1,96 @@
1+import { For, Show, createSignal, type Component } from "solid-js";
2+import { cn } from "@/lib/cn";
3+
4+export type ChartBarItem = {
5+ id: string;
6+ label: string;
7+ value: number;
8+ max?: number;
9+ formattedValue?: string;
10+ colorClass?: string;
11+};
12+
13+export type ChartBarProps = {
14+ title?: string;
15+ subtitle?: string;
16+ items: ChartBarItem[];
17+ maxScale?: number;
18+ class?: string;
19+};
20+
21+export const ChartBar: Component<ChartBarProps> = (props) => {
22+ const [hoveredId, setHoveredId] = createSignal<string | null>(null);
23+
24+ const maxValue = () => {
25+ if (props.maxScale != null && props.maxScale > 0) return props.maxScale;
26+ const itemMax = Math.max(...props.items.map((i) => i.value), 1);
27+ return itemMax;
28+ };
29+
30+ return (
31+ <div class={cn("flex flex-col gap-3.5 rounded-3xl border border-border/60 bg-card/60 p-4 sm:p-5 dark:border-white/[0.08] dark:bg-card/40 shadow-sm backdrop-blur-sm", props.class)}>
32+ <Show when={props.title}>
33+ <div class="flex items-center justify-between gap-2 border-b border-border/40 pb-3">
34+ <div>
35+ <h3 class="text-sm font-semibold tracking-tight text-foreground">{props.title}</h3>
36+ <Show when={props.subtitle}>
37+ <p class="text-xs text-muted-foreground mt-0.5">{props.subtitle}</p>
38+ </Show>
39+ </div>
40+ </div>
41+ </Show>
42+
43+ <Show
44+ when={props.items.length > 0}
45+ fallback={
46+ <div class="flex h-32 items-center justify-center rounded-2xl border border-dashed border-border/60 bg-muted/20 text-xs text-muted-foreground">
47+ Grafik için henüz yeterli veri bulunmuyor
48+ </div>
49+ }
50+ >
51+ <div class="space-y-3 pt-1">
52+ <For each={props.items}>
53+ {(item) => {
54+ const pct = () => Math.min(100, Math.max(0, (item.value / maxValue()) * 100));
55+ const isHovered = () => hoveredId() === item.id;
56+
57+ return (
58+ <div
59+ class="group relative space-y-1.5"
60+ onMouseEnter={() => setHoveredId(item.id)}
61+ onMouseLeave={() => setHoveredId(null)}
62+ >
63+ <div class="flex items-center justify-between text-xs">
64+ <span class="font-medium text-foreground/90 truncate max-w-[70%]">
65+ {item.label}
66+ </span>
67+ <span class="font-mono text-xs font-semibold tabular-nums text-foreground">
68+ {item.formattedValue ?? item.value}
69+ </span>
70+ </div>
71+
72+ <div class="relative h-2.5 w-full overflow-hidden rounded-full bg-muted/60 dark:bg-muted/40">
73+ <div
74+ class={cn(
75+ "h-full rounded-full transition-all duration-500 ease-out",
76+ item.colorClass ?? "bg-primary",
77+ isHovered() && "brightness-110 shadow-sm",
78+ )}
79+ style={{ width: `${pct()}%` }}
80+ />
81+ </div>
82+
83+ <Show when={isHovered()}>
84+ <div class="absolute -top-7 right-0 z-20 rounded-lg bg-popover px-2.5 py-1 text-[11px] font-medium text-popover-foreground shadow-md border border-border">
85+ {item.label}: {item.formattedValue ?? item.value} ({Math.round(pct())}%)
86+ </div>
87+ </Show>
88+ </div>
89+ );
90+ }}
91+ </For>
92+ </div>
93+ </Show>
94+ </div>
95+ );
96+};
src/components/ui/chart-progress-ring.tsxadded+83 -0
@@ -0,0 +1,83 @@
1+import { For, Show, type Component } from "solid-js";
2+import { cn } from "@/lib/cn";
3+
4+export type ProgressRingSegment = {
5+ id: string;
6+ label: string;
7+ value: number;
8+ colorClass: string;
9+};
10+
11+export type ChartProgressRingProps = {
12+ title?: string;
13+ subtitle?: string;
14+ valueText?: string;
15+ subtext?: string;
16+ segments: ProgressRingSegment[];
17+ total?: number;
18+ class?: string;
19+};
20+
21+export const ChartProgressRing: Component<ChartProgressRingProps> = (props) => {
22+ const calculatedTotal = () => props.total ?? props.segments.reduce((acc, s) => acc + s.value, 0);
23+
24+ return (
25+ <div class={cn("flex flex-col gap-3.5 rounded-3xl border border-border/60 bg-card/60 p-4 sm:p-5 dark:border-white/[0.08] dark:bg-card/40 shadow-sm backdrop-blur-sm", props.class)}>
26+ <Show when={props.title}>
27+ <div class="flex items-center justify-between gap-2 border-b border-border/40 pb-3">
28+ <div>
29+ <h3 class="text-sm font-semibold tracking-tight text-foreground">{props.title}</h3>
30+ <Show when={props.subtitle}>
31+ <p class="text-xs text-muted-foreground mt-0.5">{props.subtitle}</p>
32+ </Show>
33+ </div>
34+ </div>
35+ </Show>
36+
37+ <div class="flex flex-col justify-between gap-4 py-1">
38+ {/* Total Stat Highlight */}
39+ <div class="flex items-baseline gap-2">
40+ <span class="font-mono text-3xl font-bold tracking-tight text-foreground">
41+ {props.valueText ?? calculatedTotal()}
42+ </span>
43+ <Show when={props.subtext}>
44+ <span class="text-xs font-medium text-muted-foreground">{props.subtext}</span>
45+ </Show>
46+ </div>
47+
48+ {/* Multi-Segmented Progress Gauge Bar */}
49+ <div class="flex h-3.5 w-full overflow-hidden rounded-full bg-muted/60 dark:bg-muted/40 p-0.5 border border-border/40">
50+ <For each={props.segments}>
51+ {(segment) => {
52+ const pct = () => (calculatedTotal() > 0 ? (segment.value / calculatedTotal()) * 100 : 0);
53+ return (
54+ <Show when={pct() > 0}>
55+ <div
56+ class={cn("h-full rounded-full transition-all duration-500 ease-out", segment.colorClass)}
57+ style={{ width: `${pct()}%` }}
58+ title={`${segment.label}: ${segment.value} (${Math.round(pct())}%)`}
59+ />
60+ </Show>
61+ );
62+ }}
63+ </For>
64+ </div>
65+
66+ {/* Legend Grid */}
67+ <div class="grid grid-cols-2 gap-2 pt-1 sm:grid-cols-2">
68+ <For each={props.segments}>
69+ {(segment) => (
70+ <div class="flex items-center justify-between rounded-xl border border-border/40 bg-muted/30 px-3 py-2 text-xs">
71+ <div class="flex items-center gap-2 truncate">
72+ <span class={cn("h-2.5 w-2.5 shrink-0 rounded-full", segment.colorClass)} />
73+ <span class="truncate font-medium text-muted-foreground">{segment.label}</span>
74+ </div>
75+ <span class="font-mono font-semibold text-foreground ml-2">{segment.value}</span>
76+ </div>
77+ )}
78+ </For>
79+ </div>
80+ </div>
81+ </div>
82+ );
83+};
src/components/ui/icons.tsxmodified+8 -0
@@ -652,3 +652,11 @@ export function IconRotateCcw(props: IconProps) {
652 </Svg>652 </Svg>
653 );653 );
654 }654 }
655+
656+export function IconChevronUp(props: IconProps) {
657+ return (
658+ <Svg {...props}>
659+ <path d="m18 15-6-6-6 6" />
660+ </Svg>
661+ );
662+}
src/i18n/messages.tsmodified+1 -1
@@ -1624,7 +1624,7 @@ const tr: Dict = {
1624 "nav.courses": "Ders",1624 "nav.courses": "Ders",
1625 "nav.studies": "Etüt",1625 "nav.studies": "Etüt",
1626 "nav.clubs": "Kulüp",1626 "nav.clubs": "Kulüp",
1627- "nav.marks": "Notlar",1627+ "nav.marks": "Karnem",
1628 "nav.messages": "Mesajlar",1628 "nav.messages": "Mesajlar",
1629 "nav.pomodoro": "Pomodoro",1629 "nav.pomodoro": "Pomodoro",
1630 "nav.attendance": "Yoklama",1630 "nav.attendance": "Yoklama",
src/pages/dashboard-page.tsxmodified+100 -4
@@ -18,6 +18,8 @@ import {
18 IconCalendar,18 IconCalendar,
19 IconCalendarDays,19 IconCalendarDays,
20 IconChart,20 IconChart,
21+ IconChevronDown,
22+ IconChevronUp,
21 IconClock,23 IconClock,
22 IconClipboardCheck,24 IconClipboardCheck,
23 IconExam,25 IconExam,
@@ -28,6 +30,8 @@ import {
28 } from "@/components/ui/icons";30 } from "@/components/ui/icons";
29 import { PaginationControls } from "@/components/ui/pagination-controls";31 import { PaginationControls } from "@/components/ui/pagination-controls";
30 import { PageSpinner } from "@/components/ui/page-spinner";32 import { PageSpinner } from "@/components/ui/page-spinner";
33+import { ChartBar, type ChartBarItem } from "@/components/ui/chart-bar";
34+import { ChartProgressRing, type ProgressRingSegment } from "@/components/ui/chart-progress-ring";
31 import type { MessageKey } from "@/i18n/messages";35 import type { MessageKey } from "@/i18n/messages";
32 import { cn } from "@/lib/cn";36 import { cn } from "@/lib/cn";
33 import { createNow } from "@/lib/create-now";37 import { createNow } from "@/lib/create-now";
@@ -440,8 +444,50 @@ function DashboardContent() {
440 return attention().slice(start, start + ATTENTION_LIMIT);444 return attention().slice(start, start + ATTENTION_LIMIT);
441 });445 });
442 446
443- createEffect(() => {447+ const courseMarkItems = createMemo<ChartBarItem[]>(() => {
444- if (attentionPage() >= attentionTotalPages()) setAttentionPage(attentionTotalPages() - 1);448+ const list = marks()?.courses ?? [];
449+ return list.map((c) => ({
450+ id: c.course.id,
451+ label: c.course.title,
452+ value: c.average ?? 0,
453+ max: 100,
454+ formattedValue: c.average != null ? `${Math.round(c.average * 10) / 10}` : "—",
455+ colorClass: (c.average ?? 0) >= 70 ? "bg-emerald-500" : (c.average ?? 0) >= 50 ? "bg-amber-500" : "bg-rose-500",
456+ }));
457+ });
458+
459+ const scheduleTimeItems = createMemo<ChartBarItem[]>(() => {
460+ const items = attention();
461+ const activeCount = items.filter((i) => i.status === "active").length;
462+ const todayCount = items.filter((i) => i.status === "today").length;
463+ const soonCount = items.filter((i) => i.status === "soon").length;
464+ return [
465+ { id: "active", label: "Aktif Program", value: activeCount, colorClass: "bg-emerald-500" },
466+ { id: "today", label: "Bugünkü Sınav / Etkinlik", value: todayCount, colorClass: "bg-amber-500" },
467+ { id: "soon", label: "Yakında (7 Gün İçi)", value: soonCount, colorClass: "bg-indigo-500" },
468+ ];
469+ });
470+
471+ const scheduleSegments = createMemo<ProgressRingSegment[]>(() => {
472+ const items = attention();
473+ const active = items.filter((i) => i.status === "active").length;
474+ const today = items.filter((i) => i.status === "today").length;
475+ const soon = items.filter((i) => i.status === "soon").length;
476+ return [
477+ { id: "active", label: "Aktif", value: active, colorClass: "bg-emerald-500" },
478+ { id: "today", label: "Bugün", value: today, colorClass: "bg-amber-500" },
479+ { id: "soon", label: "Yakında", value: soon, colorClass: "bg-indigo-500" },
480+ ];
481+ });
482+
483+ const [showAllPortals, setShowAllPortals] = createSignal(false);
484+
485+ const displayPortalCards = createMemo(() => {
486+ const cards = orderedPortalCards();
487+ if (editingPortalOrder() || showAllPortals() || cards.length <= 8) {
488+ return cards;
489+ }
490+ return cards.slice(0, 8);
445 });491 });
446 492
447 return (493 return (
@@ -471,6 +517,39 @@ function DashboardContent() {
471 517
472 <Show when={!loading()} fallback={<div class="px-4 py-8"><PageSpinner /></div>}>518 <Show when={!loading()} fallback={<div class="px-4 py-8"><PageSpinner /></div>}>
473 <div class="space-y-5 bg-muted/10 px-4 py-4 sm:px-5 sm:py-5 dark:bg-black/40">519 <div class="space-y-5 bg-muted/10 px-4 py-4 sm:px-5 sm:py-5 dark:bg-black/40">
520+
521+ {/* Visual Analytics Panel (Swapped to Top) */}
522+ <Show when={role() !== "parent"}>
523+ <section class="grid grid-cols-1 gap-5 lg:grid-cols-2" aria-label="Görsel Analiz ve Raporlar">
524+ <Show
525+ when={role() === "student" && courseMarkItems().length > 0}
526+ fallback={
527+ <ChartBar
528+ title="Sınav & Zaman Çizelgesi Dağılımı"
529+ subtitle="Aktif, bugün ve 7 gün içerisindeki program yoğunluğu"
530+ items={scheduleTimeItems()}
531+ />
532+ }
533+ >
534+ <ChartBar
535+ title="Ders Başarı & Not Analizi"
536+ subtitle="Kayıtlı ders bazında başarı puanları"
537+ items={courseMarkItems()}
538+ maxScale={100}
539+ />
540+ </Show>
541+
542+ <ChartProgressRing
543+ title="Program & Takip Analizi"
544+ valueText={`${attention().length}`}
545+ subtext="yaklaşan ve aktif kayıt"
546+ subtitle="Durum bazlı zaman çizelgesi oransal göstergesi"
547+ segments={scheduleSegments()}
548+ />
549+ </section>
550+ </Show>
551+
552+ {/* Workspace Portal Cards (Expandable after 2 rows) */}
474 <section class="space-y-2.5 rounded-3xl border border-border/60 bg-card/60 p-3 sm:p-4 dark:border-white/[0.08] dark:bg-card/40 shadow-sm" aria-labelledby="dash-sections">553 <section class="space-y-2.5 rounded-3xl border border-border/60 bg-card/60 p-3 sm:p-4 dark:border-white/[0.08] dark:bg-card/40 shadow-sm" aria-labelledby="dash-sections">
475 <div class="flex items-center justify-between gap-3">554 <div class="flex items-center justify-between gap-3">
476 <h2 id="dash-sections" class="text-sm font-semibold tracking-tight text-foreground">555 <h2 id="dash-sections" class="text-sm font-semibold tracking-tight text-foreground">
@@ -488,13 +567,13 @@ function DashboardContent() {
488 </div>567 </div>
489 </div>568 </div>
490 <div class="grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">569 <div class="grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
491- <For each={orderedPortalCards()}>570+ <For each={displayPortalCards()}>
492 {(card, index) => (571 {(card, index) => (
493 <PortalCard572 <PortalCard
494 card={card}573 card={card}
495 editing={editingPortalOrder()}574 editing={editingPortalOrder()}
496 isFirst={index() === 0}575 isFirst={index() === 0}
497- isLast={index() === orderedPortalCards().length - 1}576+ isLast={index() === displayPortalCards().length - 1}
498 onMoveLeft={() => moveCardByDelta(card.to, -1)}577 onMoveLeft={() => moveCardByDelta(card.to, -1)}
499 onMoveRight={() => moveCardByDelta(card.to, 1)}578 onMoveRight={() => moveCardByDelta(card.to, 1)}
500 dragging={draggingPortal() === card.to}579 dragging={draggingPortal() === card.to}
@@ -522,6 +601,23 @@ function DashboardContent() {
522 )}601 )}
523 </For>602 </For>
524 </div>603 </div>
604+
605+ <Show when={orderedPortalCards().length > 8 && !editingPortalOrder()}>
606+ <div class="flex justify-center pt-2">
607+ <Button
608+ type="button"
609+ variant="outline"
610+ size="sm"
611+ class="h-8 rounded-full border-border/70 bg-background/80 px-4 text-xs font-medium text-foreground shadow-sm transition-all duration-200 hover:border-primary/50 hover:bg-card hover:shadow"
612+ onClick={() => setShowAllPortals((v) => !v)}
613+ >
614+ <span>{showAllPortals() ? "Daha az göster" : "Daha fazla göster"}</span>
615+ <Show when={showAllPortals()} fallback={<IconChevronDown class="h-3.5 w-3.5 text-muted-foreground ml-1" />}>
616+ <IconChevronUp class="h-3.5 w-3.5 text-muted-foreground ml-1" />
617+ </Show>
618+ </Button>
619+ </div>
620+ </Show>
525 </section>621 </section>
526 622
527 <Show when={role() !== "parent"}>623 <Show when={role() !== "parent"}>