diff --git a/src/components/ui/chart-bar.tsx b/src/components/ui/chart-bar.tsx new file mode 100644 index 0000000..94069e9 --- /dev/null +++ b/src/components/ui/chart-bar.tsx @@ -0,0 +1,96 @@ +import { For, Show, createSignal, type Component } from "solid-js"; +import { cn } from "@/lib/cn"; + +export type ChartBarItem = { + id: string; + label: string; + value: number; + max?: number; + formattedValue?: string; + colorClass?: string; +}; + +export type ChartBarProps = { + title?: string; + subtitle?: string; + items: ChartBarItem[]; + maxScale?: number; + class?: string; +}; + +export const ChartBar: Component = (props) => { + const [hoveredId, setHoveredId] = createSignal(null); + + const maxValue = () => { + if (props.maxScale != null && props.maxScale > 0) return props.maxScale; + const itemMax = Math.max(...props.items.map((i) => i.value), 1); + return itemMax; + }; + + return ( +
+ +
+
+

{props.title}

+ +

{props.subtitle}

+
+
+
+
+ + 0} + fallback={ +
+ Grafik için henüz yeterli veri bulunmuyor +
+ } + > +
+ + {(item) => { + const pct = () => Math.min(100, Math.max(0, (item.value / maxValue()) * 100)); + const isHovered = () => hoveredId() === item.id; + + return ( +
setHoveredId(item.id)} + onMouseLeave={() => setHoveredId(null)} + > +
+ + {item.label} + + + {item.formattedValue ?? item.value} + +
+ +
+
+
+ + +
+ {item.label}: {item.formattedValue ?? item.value} ({Math.round(pct())}%) +
+
+
+ ); + }} + +
+ +
+ ); +}; diff --git a/src/components/ui/chart-progress-ring.tsx b/src/components/ui/chart-progress-ring.tsx new file mode 100644 index 0000000..00d7e81 --- /dev/null +++ b/src/components/ui/chart-progress-ring.tsx @@ -0,0 +1,83 @@ +import { For, Show, type Component } from "solid-js"; +import { cn } from "@/lib/cn"; + +export type ProgressRingSegment = { + id: string; + label: string; + value: number; + colorClass: string; +}; + +export type ChartProgressRingProps = { + title?: string; + subtitle?: string; + valueText?: string; + subtext?: string; + segments: ProgressRingSegment[]; + total?: number; + class?: string; +}; + +export const ChartProgressRing: Component = (props) => { + const calculatedTotal = () => props.total ?? props.segments.reduce((acc, s) => acc + s.value, 0); + + return ( +
+ +
+
+

{props.title}

+ +

{props.subtitle}

+
+
+
+
+ +
+ {/* Total Stat Highlight */} +
+ + {props.valueText ?? calculatedTotal()} + + + {props.subtext} + +
+ + {/* Multi-Segmented Progress Gauge Bar */} +
+ + {(segment) => { + const pct = () => (calculatedTotal() > 0 ? (segment.value / calculatedTotal()) * 100 : 0); + return ( + 0}> +
+ + ); + }} + +
+ + {/* Legend Grid */} +
+ + {(segment) => ( +
+
+ + {segment.label} +
+ {segment.value} +
+ )} +
+
+
+
+ ); +}; diff --git a/src/components/ui/icons.tsx b/src/components/ui/icons.tsx index b93e45d..1759ce9 100644 --- a/src/components/ui/icons.tsx +++ b/src/components/ui/icons.tsx @@ -652,3 +652,11 @@ export function IconRotateCcw(props: IconProps) { ); } + +export function IconChevronUp(props: IconProps) { + return ( + + + + ); +} diff --git a/src/i18n/messages.ts b/src/i18n/messages.ts index b8ff40f..15ebb36 100644 --- a/src/i18n/messages.ts +++ b/src/i18n/messages.ts @@ -1624,7 +1624,7 @@ const tr: Dict = { "nav.courses": "Ders", "nav.studies": "Etüt", "nav.clubs": "Kulüp", - "nav.marks": "Notlar", + "nav.marks": "Karnem", "nav.messages": "Mesajlar", "nav.pomodoro": "Pomodoro", "nav.attendance": "Yoklama", diff --git a/src/pages/dashboard-page.tsx b/src/pages/dashboard-page.tsx index 5a1b322..651f621 100644 --- a/src/pages/dashboard-page.tsx +++ b/src/pages/dashboard-page.tsx @@ -18,6 +18,8 @@ import { IconCalendar, IconCalendarDays, IconChart, + IconChevronDown, + IconChevronUp, IconClock, IconClipboardCheck, IconExam, @@ -28,6 +30,8 @@ import { } from "@/components/ui/icons"; import { PaginationControls } from "@/components/ui/pagination-controls"; import { PageSpinner } from "@/components/ui/page-spinner"; +import { ChartBar, type ChartBarItem } from "@/components/ui/chart-bar"; +import { ChartProgressRing, type ProgressRingSegment } from "@/components/ui/chart-progress-ring"; import type { MessageKey } from "@/i18n/messages"; import { cn } from "@/lib/cn"; import { createNow } from "@/lib/create-now"; @@ -440,8 +444,50 @@ function DashboardContent() { return attention().slice(start, start + ATTENTION_LIMIT); }); - createEffect(() => { - if (attentionPage() >= attentionTotalPages()) setAttentionPage(attentionTotalPages() - 1); + const courseMarkItems = createMemo(() => { + const list = marks()?.courses ?? []; + return list.map((c) => ({ + id: c.course.id, + label: c.course.title, + value: c.average ?? 0, + max: 100, + formattedValue: c.average != null ? `${Math.round(c.average * 10) / 10}` : "—", + colorClass: (c.average ?? 0) >= 70 ? "bg-emerald-500" : (c.average ?? 0) >= 50 ? "bg-amber-500" : "bg-rose-500", + })); + }); + + const scheduleTimeItems = createMemo(() => { + const items = attention(); + const activeCount = items.filter((i) => i.status === "active").length; + const todayCount = items.filter((i) => i.status === "today").length; + const soonCount = items.filter((i) => i.status === "soon").length; + return [ + { id: "active", label: "Aktif Program", value: activeCount, colorClass: "bg-emerald-500" }, + { id: "today", label: "Bugünkü Sınav / Etkinlik", value: todayCount, colorClass: "bg-amber-500" }, + { id: "soon", label: "Yakında (7 Gün İçi)", value: soonCount, colorClass: "bg-indigo-500" }, + ]; + }); + + const scheduleSegments = createMemo(() => { + const items = attention(); + const active = items.filter((i) => i.status === "active").length; + const today = items.filter((i) => i.status === "today").length; + const soon = items.filter((i) => i.status === "soon").length; + return [ + { id: "active", label: "Aktif", value: active, colorClass: "bg-emerald-500" }, + { id: "today", label: "Bugün", value: today, colorClass: "bg-amber-500" }, + { id: "soon", label: "Yakında", value: soon, colorClass: "bg-indigo-500" }, + ]; + }); + + const [showAllPortals, setShowAllPortals] = createSignal(false); + + const displayPortalCards = createMemo(() => { + const cards = orderedPortalCards(); + if (editingPortalOrder() || showAllPortals() || cards.length <= 8) { + return cards; + } + return cards.slice(0, 8); }); return ( @@ -471,6 +517,39 @@ function DashboardContent() {
}>
+ + {/* Visual Analytics Panel (Swapped to Top) */} + +
+ 0} + fallback={ + + } + > + + + + +
+
+ + {/* Workspace Portal Cards (Expandable after 2 rows) */}

@@ -488,13 +567,13 @@ function DashboardContent() {

- + {(card, index) => ( moveCardByDelta(card.to, -1)} onMoveRight={() => moveCardByDelta(card.to, 1)} dragging={draggingPortal() === card.to} @@ -522,6 +601,23 @@ function DashboardContent() { )}
+ + 8 && !editingPortalOrder()}> +
+ +
+