✨ redesign exam page filter toolbar & add Option B visual animations
Browse files at this commit0ba7cdb08428add7003b76ac390f7d8ee4790bbbParent: 02f8667- feat
- ✨ redesign exam page filter toolbar & add Option B visual animations
13 changed files +329 -38
- src/components/events/event-card.tsx +1 -1
- src/components/exams/exam-room-ws.tsx +2 -0
- src/components/notes/note-card.tsx +1 -1
- src/components/notes/note-import-panel.tsx +2 -0
- src/components/ui/empty-state.tsx +46 -6
- src/components/ui/icons.tsx +17 -0
- src/i18n/messages.ts +3 -0
- src/index.css +29 -1
- src/lib/__tests__/confetti.test.ts +8 -0
- src/lib/confetti.ts +126 -0
- src/pages/dashboard-page.tsx +1 -1
- src/pages/exams-page.tsx +45 -20
- src/pages/pomodoro-page.tsx +48 -8
src/components/events/event-card.tsxmodified+1 -1
| @@ -38,7 +38,7 @@ export function EventCard(props: { event: Event }) { | |||
| 38 | 38 | ||
| 39 | return ( | 39 | return ( |
| 40 | <Link to="/events/$id" params={{ id: props.event.id }} class="group block h-full"> | 40 | <Link to="/events/$id" params={{ id: props.event.id }} class="group block h-full"> |
| 41 | - <article class="data-shell flex h-full min-h-40 flex-col overflow-hidden transition-colors group-hover:border-primary/35"> | 41 | + <article class="data-shell flex h-full min-h-40 flex-col overflow-hidden card-lift group-hover:border-primary/35"> |
| 42 | <div class="flex flex-1 flex-col p-3"> | 42 | <div class="flex flex-1 flex-col p-3"> |
| 43 | <div class="mb-2 flex items-start justify-between gap-2"> | 43 | <div class="mb-2 flex items-start justify-between gap-2"> |
| 44 | <h3 class="line-clamp-2 min-w-0 flex-1 font-display text-base font-semibold leading-snug group-hover:text-primary"> | 44 | <h3 class="line-clamp-2 min-w-0 flex-1 font-display text-base font-semibold leading-snug group-hover:text-primary"> |
src/components/exams/exam-room-ws.tsxmodified+2 -0
| @@ -20,6 +20,7 @@ import { PageSpinner } from "@/components/ui/page-spinner"; | |||
| 20 | import { Textarea } from "@/components/ui/textarea"; | 20 | import { Textarea } from "@/components/ui/textarea"; |
| 21 | import { cn } from "@/lib/cn"; | 21 | import { cn } from "@/lib/cn"; |
| 22 | import { createNow } from "@/lib/create-now"; | 22 | import { createNow } from "@/lib/create-now"; |
| 23 | +import { triggerConfetti } from "@/lib/confetti"; | ||
| 23 | import { formatDateTime } from "@/lib/format"; | 24 | import { formatDateTime } from "@/lib/format"; |
| 24 | import { formatBytes, maxUploadBytes } from "@/lib/upload-limits"; | 25 | import { formatBytes, maxUploadBytes } from "@/lib/upload-limits"; |
| 25 | import { usePreferences, useT } from "@/stores/preferences-context"; | 26 | import { usePreferences, useT } from "@/stores/preferences-context"; |
| @@ -287,6 +288,7 @@ export function ExamRoomWS(props: { exam: Exam }) { | |||
| 287 | const next = await getExamAttempt(props.exam.id); | 288 | const next = await getExamAttempt(props.exam.id); |
| 288 | setAttempt(next); | 289 | setAttempt(next); |
| 289 | } | 290 | } |
| 291 | + triggerConfetti(); | ||
| 290 | } catch (err) { | 292 | } catch (err) { |
| 291 | setError(formatApiError(err, locale())); | 293 | setError(formatApiError(err, locale())); |
| 292 | } finally { | 294 | } finally { |
src/components/notes/note-card.tsxmodified+1 -1
| @@ -24,7 +24,7 @@ export function NoteCard(props: { | |||
| 24 | <article | 24 | <article |
| 25 | role="button" | 25 | role="button" |
| 26 | tabindex="0" | 26 | tabindex="0" |
| 27 | - class="group flex h-full min-h-72 cursor-pointer flex-col overflow-hidden rounded-2xl border border-amber-200/70 bg-card shadow-sm transition-all hover:-translate-y-0.5 hover:border-amber-400/60 hover:shadow-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring dark:border-amber-500/20" | 27 | + class="group flex h-full min-h-72 cursor-pointer flex-col overflow-hidden rounded-2xl border border-amber-200/70 bg-card shadow-sm card-lift hover:border-amber-400/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring dark:border-amber-500/20" |
| 28 | onClick={() => props.onOpen(props.note)} | 28 | onClick={() => props.onOpen(props.note)} |
| 29 | onKeyDown={(event) => { | 29 | onKeyDown={(event) => { |
| 30 | if (event.key === "Enter" || event.key === " ") { | 30 | if (event.key === "Enter" || event.key === " ") { |
src/components/notes/note-import-panel.tsxmodified+2 -0
| @@ -5,6 +5,7 @@ import { Input } from "@/components/ui/input"; | |||
| 5 | import { Label } from "@/components/ui/label"; | 5 | import { Label } from "@/components/ui/label"; |
| 6 | import { Textarea } from "@/components/ui/textarea"; | 6 | import { Textarea } from "@/components/ui/textarea"; |
| 7 | import { processImportedText } from "@/lib/note-importer"; | 7 | import { processImportedText } from "@/lib/note-importer"; |
| 8 | +import { triggerConfetti } from "@/lib/confetti"; | ||
| 8 | import { formatBytes } from "@/lib/upload-limits"; | 9 | import { formatBytes } from "@/lib/upload-limits"; |
| 9 | import { useT } from "@/stores/preferences-context"; | 10 | import { useT } from "@/stores/preferences-context"; |
| 10 | 11 | ||
| @@ -60,6 +61,7 @@ export function NoteImportPanel(props: { | |||
| 60 | const handleApply = () => { | 61 | const handleApply = () => { |
| 61 | const title = importedTitle().trim() || "Imported Note"; | 62 | const title = importedTitle().trim() || "Imported Note"; |
| 62 | const content = importedMarkdown(); | 63 | const content = importedMarkdown(); |
| 64 | + triggerConfetti(); | ||
| 63 | props.onImport(title, content); | 65 | props.onImport(title, content); |
| 64 | }; | 66 | }; |
| 65 | 67 | ||
src/components/ui/empty-state.tsxmodified+46 -6
| @@ -1,23 +1,63 @@ | |||
| 1 | import { Show } from "solid-js"; | 1 | import { Show } from "solid-js"; |
| 2 | import { cn } from "@/lib/cn"; | 2 | import { cn } from "@/lib/cn"; |
| 3 | 3 | ||
| 4 | -/** Clean dashed empty panel. */ | 4 | +export type EmptyStateKind = "default" | "notes" | "exams" | "events" | "courses"; |
| 5 | + | ||
| 6 | +/** Clean dashed empty panel with animated vector illustrations. */ | ||
| 5 | export function EmptyState(props: { | 7 | export function EmptyState(props: { |
| 6 | title: string; | 8 | title: string; |
| 7 | description?: string; | 9 | description?: string; |
| 10 | + kind?: EmptyStateKind; | ||
| 8 | class?: string; | 11 | class?: string; |
| 9 | }) { | 12 | }) { |
| 13 | + const kind = () => props.kind ?? "default"; | ||
| 14 | + | ||
| 10 | return ( | 15 | return ( |
| 11 | <div | 16 | <div |
| 12 | class={cn( | 17 | class={cn( |
| 13 | - "flex min-h-[10rem] flex-col items-center justify-center gap-1.5 rounded-2xl border border-dashed border-border/70 bg-muted/20 px-6 py-8 text-center", | 18 | + "flex min-h-[12rem] flex-col items-center justify-center gap-3 rounded-2xl border border-dashed border-border/70 bg-muted/15 px-6 py-8 text-center transition-all duration-300", |
| 14 | props.class, | 19 | props.class, |
| 15 | )} | 20 | )} |
| 16 | > | 21 | > |
| 17 | - <p class="text-sm font-semibold text-foreground">{props.title}</p> | 22 | + <div class="relative flex h-16 w-16 items-center justify-center rounded-2xl border border-primary/20 bg-primary/10 text-primary shadow-inner animate-float"> |
| 18 | - <Show when={props.description}> | 23 | + <Show when={kind() === "notes"}> |
| 19 | - <p class="max-w-sm text-xs leading-relaxed text-muted-foreground">{props.description}</p> | 24 | + <svg class="h-8 w-8 text-primary" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"> |
| 20 | - </Show> | 25 | + <path d="M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H20v20H6.5a2.5 2.5 0 0 1-2.5-2.5Z" /> |
| 26 | + <path d="M6 6h10" /> | ||
| 27 | + <path d="M6 10h8" /> | ||
| 28 | + <circle cx="18" cy="18" r="2.5" class="fill-primary/20 stroke-primary" /> | ||
| 29 | + </svg> | ||
| 30 | + </Show> | ||
| 31 | + <Show when={kind() === "exams"}> | ||
| 32 | + <svg class="h-8 w-8 text-primary" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"> | ||
| 33 | + <path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" /> | ||
| 34 | + <polyline points="14 2 14 8 20 8" /> | ||
| 35 | + <path d="m9 15 2 2 4-4" /> | ||
| 36 | + </svg> | ||
| 37 | + </Show> | ||
| 38 | + <Show when={kind() === "events"}> | ||
| 39 | + <svg class="h-8 w-8 text-primary" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"> | ||
| 40 | + <rect width="18" height="18" x="3" y="4" rx="2" ry="2" /> | ||
| 41 | + <line x1="16" x2="16" y1="2" y2="6" /> | ||
| 42 | + <line x1="8" x2="8" y1="2" y2="6" /> | ||
| 43 | + <line x1="3" x2="21" y1="10" y2="10" /> | ||
| 44 | + <path d="m9 16 2 2 4-4" /> | ||
| 45 | + </svg> | ||
| 46 | + </Show> | ||
| 47 | + <Show when={kind() === "default" || kind() === "courses"}> | ||
| 48 | + <svg class="h-8 w-8 text-primary" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"> | ||
| 49 | + <path d="M22 10v6M2 10l10-5 10 5-10 5z" /> | ||
| 50 | + <path d="M6 12v5c3 3 9 3 12 0v-5" /> | ||
| 51 | + </svg> | ||
| 52 | + </Show> | ||
| 53 | + </div> | ||
| 54 | + | ||
| 55 | + <div class="space-y-1"> | ||
| 56 | + <p class="text-sm font-semibold text-foreground">{props.title}</p> | ||
| 57 | + <Show when={props.description}> | ||
| 58 | + <p class="max-w-sm text-xs leading-relaxed text-muted-foreground">{props.description}</p> | ||
| 59 | + </Show> | ||
| 60 | + </div> | ||
| 21 | </div> | 61 | </div> |
| 22 | ); | 62 | ); |
| 23 | } | 63 | } |
src/components/ui/icons.tsxmodified+17 -0
| @@ -623,3 +623,20 @@ export function IconUploadCloud(props: IconProps) { | |||
| 623 | </Svg> | 623 | </Svg> |
| 624 | ); | 624 | ); |
| 625 | } | 625 | } |
| 626 | + | ||
| 627 | +export function IconFilter(props: IconProps) { | ||
| 628 | + return ( | ||
| 629 | + <Svg {...props}> | ||
| 630 | + <polygon points="22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3" /> | ||
| 631 | + </Svg> | ||
| 632 | + ); | ||
| 633 | +} | ||
| 634 | + | ||
| 635 | +export function IconRotateCcw(props: IconProps) { | ||
| 636 | + return ( | ||
| 637 | + <Svg {...props}> | ||
| 638 | + <path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" /> | ||
| 639 | + <path d="M3 3v5h5" /> | ||
| 640 | + </Svg> | ||
| 641 | + ); | ||
| 642 | +} | ||
src/i18n/messages.tsmodified+3 -0
| @@ -101,6 +101,7 @@ export type MessageKey = | |||
| 101 | | "common.creator" | 101 | | "common.creator" |
| 102 | | "common.searchPlaceholder" | 102 | | "common.searchPlaceholder" |
| 103 | | "common.all" | 103 | | "common.all" |
| 104 | + | "common.resetFilters" | ||
| 104 | | "common.saveAttendance" | 105 | | "common.saveAttendance" |
| 105 | | "common.created" | 106 | | "common.created" |
| 106 | | "common.deleted" | 107 | | "common.deleted" |
| @@ -833,6 +834,7 @@ const en: Dict = { | |||
| 833 | "common.creator": "Created by", | 834 | "common.creator": "Created by", |
| 834 | "common.searchPlaceholder": "Search…", | 835 | "common.searchPlaceholder": "Search…", |
| 835 | "common.all": "All", | 836 | "common.all": "All", |
| 837 | + "common.resetFilters": "Reset filters", | ||
| 836 | "common.saveAttendance": "Save my attendance", | 838 | "common.saveAttendance": "Save my attendance", |
| 837 | "common.created": "Created.", | 839 | "common.created": "Created.", |
| 838 | "common.deleted": "Deleted.", | 840 | "common.deleted": "Deleted.", |
| @@ -1577,6 +1579,7 @@ const tr: Dict = { | |||
| 1577 | "common.creator": "Oluşturan", | 1579 | "common.creator": "Oluşturan", |
| 1578 | "common.searchPlaceholder": "Ara…", | 1580 | "common.searchPlaceholder": "Ara…", |
| 1579 | "common.all": "Tümü", | 1581 | "common.all": "Tümü", |
| 1582 | + "common.resetFilters": "Sıfırla", | ||
| 1580 | "common.saveAttendance": "Yoklamamı kaydet", | 1583 | "common.saveAttendance": "Yoklamamı kaydet", |
| 1581 | "common.created": "Oluşturuldu.", | 1584 | "common.created": "Oluşturuldu.", |
| 1582 | "common.deleted": "Silindi.", | 1585 | "common.deleted": "Silindi.", |
src/index.cssmodified+29 -1
| @@ -255,17 +255,45 @@ | |||
| 255 | @apply rounded-xl h-11 px-5 font-medium active:scale-[0.97] transition-transform duration-150; | 255 | @apply rounded-xl h-11 px-5 font-medium active:scale-[0.97] transition-transform duration-150; |
| 256 | } | 256 | } |
| 257 | 257 | ||
| 258 | + .tactile-press { | ||
| 259 | + @apply active:scale-[0.97] transition-transform duration-150; | ||
| 260 | + } | ||
| 261 | + | ||
| 262 | + .card-lift { | ||
| 263 | + @apply transition-all duration-200 ease-out hover:-translate-y-1 hover:shadow-xl hover:shadow-primary/[0.05]; | ||
| 264 | + } | ||
| 265 | + | ||
| 258 | @keyframes dashboard-jiggle { | 266 | @keyframes dashboard-jiggle { |
| 259 | 0%, 100% { transform: rotate(-0.4deg) translateY(0); } | 267 | 0%, 100% { transform: rotate(-0.4deg) translateY(0); } |
| 260 | 50% { transform: rotate(0.4deg) translateY(-1px); } | 268 | 50% { transform: rotate(0.4deg) translateY(-1px); } |
| 261 | } | 269 | } |
| 262 | 270 | ||
| 271 | + @keyframes pulse-glow { | ||
| 272 | + 0%, 100% { opacity: 0.9; transform: scale(1); filter: drop-shadow(0 0 12px rgba(59, 130, 246, 0.4)); } | ||
| 273 | + 50% { opacity: 1; transform: scale(1.02); filter: drop-shadow(0 0 24px rgba(59, 130, 246, 0.7)); } | ||
| 274 | + } | ||
| 275 | + | ||
| 276 | + @keyframes float-gentle { | ||
| 277 | + 0%, 100% { transform: translateY(0px); } | ||
| 278 | + 50% { transform: translateY(-6px); } | ||
| 279 | + } | ||
| 280 | + | ||
| 263 | .dashboard-jiggle { | 281 | .dashboard-jiggle { |
| 264 | animation: dashboard-jiggle 180ms ease-in-out infinite; | 282 | animation: dashboard-jiggle 180ms ease-in-out infinite; |
| 265 | } | 283 | } |
| 266 | 284 | ||
| 285 | + .animate-pulse-glow { | ||
| 286 | + animation: pulse-glow 3s ease-in-out infinite; | ||
| 287 | + } | ||
| 288 | + | ||
| 289 | + .animate-float { | ||
| 290 | + animation: float-gentle 4s ease-in-out infinite; | ||
| 291 | + } | ||
| 292 | + | ||
| 267 | @media (prefers-reduced-motion: reduce) { | 293 | @media (prefers-reduced-motion: reduce) { |
| 268 | - .dashboard-jiggle { | 294 | + .dashboard-jiggle, |
| 295 | + .animate-pulse-glow, | ||
| 296 | + .animate-float { | ||
| 269 | animation: none; | 297 | animation: none; |
| 270 | } | 298 | } |
| 271 | } | 299 | } |
src/lib/__tests__/confetti.test.tsadded+8 -0
| @@ -0,0 +1,8 @@ | |||
| 1 | +import { describe, expect, it } from "vitest"; | ||
| 2 | +import { triggerConfetti } from "../confetti"; | ||
| 3 | + | ||
| 4 | +describe("triggerConfetti", () => { | ||
| 5 | + it("safely handles server-side / node environment without window object", () => { | ||
| 6 | + expect(() => triggerConfetti({ particleCount: 10 })).not.toThrow(); | ||
| 7 | + }); | ||
| 8 | +}); | ||
src/lib/confetti.tsadded+126 -0
| @@ -0,0 +1,126 @@ | |||
| 1 | +/** | ||
| 2 | + * Ultra-lightweight zero-dependency confetti particle burst utility. | ||
| 3 | + * Renders celebratory particle effects on an overlay canvas with auto-cleanup. | ||
| 4 | + */ | ||
| 5 | +export function triggerConfetti(options?: { | ||
| 6 | + particleCount?: number; | ||
| 7 | + durationMs?: number; | ||
| 8 | + colors?: string[]; | ||
| 9 | +}) { | ||
| 10 | + if (typeof window === "undefined") return; | ||
| 11 | + if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) return; | ||
| 12 | + | ||
| 13 | + const count = options?.particleCount ?? 60; | ||
| 14 | + const duration = options?.durationMs ?? 2500; | ||
| 15 | + const colors = options?.colors ?? [ | ||
| 16 | + "#3b82f6", // blue | ||
| 17 | + "#ec4899", // pink | ||
| 18 | + "#8b5cf6", // purple | ||
| 19 | + "#10b981", // green | ||
| 20 | + "#f59e0b", // amber | ||
| 21 | + "#6366f1", // indigo | ||
| 22 | + ]; | ||
| 23 | + | ||
| 24 | + const canvas = document.createElement("canvas"); | ||
| 25 | + canvas.style.position = "fixed"; | ||
| 26 | + canvas.style.top = "0"; | ||
| 27 | + canvas.style.left = "0"; | ||
| 28 | + canvas.style.width = "100vw"; | ||
| 29 | + canvas.style.height = "100vh"; | ||
| 30 | + canvas.style.pointerEvents = "none"; | ||
| 31 | + canvas.style.zIndex = "99999"; | ||
| 32 | + document.body.appendChild(canvas); | ||
| 33 | + | ||
| 34 | + const ctx = canvas.getContext("2d"); | ||
| 35 | + if (!ctx) { | ||
| 36 | + canvas.remove(); | ||
| 37 | + return; | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + const dpr = Math.min(window.devicePixelRatio || 1, 2); | ||
| 41 | + const width = window.innerWidth; | ||
| 42 | + const height = window.innerHeight; | ||
| 43 | + canvas.width = width * dpr; | ||
| 44 | + canvas.height = height * dpr; | ||
| 45 | + ctx.scale(dpr, dpr); | ||
| 46 | + | ||
| 47 | + type Particle = { | ||
| 48 | + x: number; | ||
| 49 | + y: number; | ||
| 50 | + vx: number; | ||
| 51 | + vy: number; | ||
| 52 | + size: number; | ||
| 53 | + color: string; | ||
| 54 | + rotation: number; | ||
| 55 | + vRot: number; | ||
| 56 | + opacity: number; | ||
| 57 | + shape: "square" | "circle"; | ||
| 58 | + }; | ||
| 59 | + | ||
| 60 | + const particles: Particle[] = []; | ||
| 61 | + const startX = width / 2; | ||
| 62 | + const startY = height * 0.4; | ||
| 63 | + | ||
| 64 | + for (let i = 0; i < count; i += 1) { | ||
| 65 | + const angle = Math.random() * Math.PI * 2; | ||
| 66 | + const speed = Math.random() * 12 + 6; | ||
| 67 | + particles.push({ | ||
| 68 | + x: startX, | ||
| 69 | + y: startY, | ||
| 70 | + vx: Math.cos(angle) * speed, | ||
| 71 | + vy: Math.sin(angle) * speed - 4, | ||
| 72 | + size: Math.random() * 8 + 5, | ||
| 73 | + color: colors[Math.floor(Math.random() * colors.length)], | ||
| 74 | + rotation: Math.random() * Math.PI * 2, | ||
| 75 | + vRot: (Math.random() - 0.5) * 0.2, | ||
| 76 | + opacity: 1, | ||
| 77 | + shape: Math.random() > 0.4 ? "square" : "circle", | ||
| 78 | + }); | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + let animationId: number; | ||
| 82 | + const startTime = performance.now(); | ||
| 83 | + | ||
| 84 | + const render = (now: number) => { | ||
| 85 | + const elapsed = now - startTime; | ||
| 86 | + if (elapsed >= duration) { | ||
| 87 | + cancelAnimationFrame(animationId); | ||
| 88 | + canvas.remove(); | ||
| 89 | + return; | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + ctx.clearRect(0, 0, width, height); | ||
| 93 | + | ||
| 94 | + const progress = elapsed / duration; | ||
| 95 | + const fadeOut = progress > 0.7 ? (1 - progress) / 0.3 : 1; | ||
| 96 | + | ||
| 97 | + for (const p of particles) { | ||
| 98 | + p.x += p.vx; | ||
| 99 | + p.y += p.vy; | ||
| 100 | + p.vy += 0.3; // gravity | ||
| 101 | + p.vx *= 0.98; // drag | ||
| 102 | + p.vy *= 0.98; | ||
| 103 | + p.rotation += p.vRot; | ||
| 104 | + | ||
| 105 | + ctx.save(); | ||
| 106 | + ctx.globalAlpha = p.opacity * fadeOut; | ||
| 107 | + ctx.translate(p.x, p.y); | ||
| 108 | + ctx.rotate(p.rotation); | ||
| 109 | + ctx.fillStyle = p.color; | ||
| 110 | + | ||
| 111 | + if (p.shape === "circle") { | ||
| 112 | + ctx.beginPath(); | ||
| 113 | + ctx.arc(0, 0, p.size / 2, 0, Math.PI * 2); | ||
| 114 | + ctx.fill(); | ||
| 115 | + } else { | ||
| 116 | + ctx.fillRect(-p.size / 2, -p.size / 2, p.size, p.size * 0.7); | ||
| 117 | + } | ||
| 118 | + | ||
| 119 | + ctx.restore(); | ||
| 120 | + } | ||
| 121 | + | ||
| 122 | + animationId = requestAnimationFrame(render); | ||
| 123 | + }; | ||
| 124 | + | ||
| 125 | + animationId = requestAnimationFrame(render); | ||
| 126 | +} | ||
src/pages/dashboard-page.tsxmodified+1 -1
| @@ -643,7 +643,7 @@ function PortalCard(props: { | |||
| 643 | 643 | ||
| 644 | const cardClass = () => | 644 | const cardClass = () => |
| 645 | cn( | 645 | cn( |
| 646 | - "group relative flex min-h-[6rem] items-start gap-3.5 overflow-hidden rounded-2xl border border-black/[0.06] dark:border-white/[0.08] bg-card p-4 shadow-apple transition-all duration-200 hover:shadow-apple-hover hover:border-primary/40 sm:min-h-[6.5rem]", | 646 | + "group relative flex min-h-[6rem] items-start gap-3.5 overflow-hidden rounded-2xl border border-black/[0.06] dark:border-white/[0.08] bg-card p-4 shadow-apple card-lift hover:shadow-apple-hover hover:border-primary/40 sm:min-h-[6.5rem]", |
| 647 | !props.editing && "active:scale-[0.98]", | 647 | !props.editing && "active:scale-[0.98]", |
| 648 | props.editing && "cursor-grab select-none border-dashed border-primary/50 bg-primary/[0.03]", | 648 | props.editing && "cursor-grab select-none border-dashed border-primary/50 bg-primary/[0.03]", |
| 649 | props.editing && !props.dragging && "dashboard-jiggle", | 649 | props.editing && !props.dragging && "dashboard-jiggle", |
src/pages/exams-page.tsxmodified+45 -20
| @@ -17,7 +17,7 @@ import { Alert } from "@/components/ui/alert"; | |||
| 17 | import { Badge } from "@/components/ui/badge"; | 17 | import { Badge } from "@/components/ui/badge"; |
| 18 | import { Button } from "@/components/ui/button"; | 18 | import { Button } from "@/components/ui/button"; |
| 19 | import { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; | 19 | import { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; |
| 20 | -import { IconCheck, IconEdit, IconEye, IconPlus } from "@/components/ui/icons"; | 20 | +import { IconCheck, IconEdit, IconEye, IconPlus, IconRotateCcw } from "@/components/ui/icons"; |
| 21 | import { Select } from "@/components/ui/select"; | 21 | import { Select } from "@/components/ui/select"; |
| 22 | import { SidePanel } from "@/components/ui/side-panel"; | 22 | import { SidePanel } from "@/components/ui/side-panel"; |
| 23 | import { TableRowActions } from "@/components/ui/table-row-actions"; | 23 | import { TableRowActions } from "@/components/ui/table-row-actions"; |
| @@ -52,7 +52,6 @@ function ExamsContent() { | |||
| 52 | const now = createNow(); | 52 | const now = createNow(); |
| 53 | const [statusFilter, setStatusFilter] = createSignal<ExamDisplayStatus | "all">("all"); | 53 | const [statusFilter, setStatusFilter] = createSignal<ExamDisplayStatus | "all">("all"); |
| 54 | const [courseFilter, setCourseFilter] = createSignal("all"); | 54 | const [courseFilter, setCourseFilter] = createSignal("all"); |
| 55 | - const [showMoreFilters, setShowMoreFilters] = createSignal(false); | ||
| 56 | const [createOpen, setCreateOpen] = createSignal(false); | 55 | const [createOpen, setCreateOpen] = createSignal(false); |
| 57 | const [selectedCourseId, setSelectedCourseId] = createSignal(""); | 56 | const [selectedCourseId, setSelectedCourseId] = createSignal(""); |
| 58 | const [editingExam, setEditingExam] = createSignal<Exam | null>(null); | 57 | const [editingExam, setEditingExam] = createSignal<Exam | null>(null); |
| @@ -298,27 +297,53 @@ function ExamsContent() { | |||
| 298 | empty={t("exams.empty")} | 297 | empty={t("exams.empty")} |
| 299 | onRowClick={(exam) => void navigate({ to: "/exams/$id", params: { id: exam.id } })} | 298 | onRowClick={(exam) => void navigate({ to: "/exams/$id", params: { id: exam.id } })} |
| 300 | filters={ | 299 | filters={ |
| 301 | - <> | 300 | + <div class="flex flex-wrap items-center gap-2.5"> |
| 302 | - <Select class="h-9 w-full rounded-sm sm:w-40" value={statusFilter()} onChange={(event) => setStatusFilter(event.currentTarget.value as ExamDisplayStatus | "all")}> | 301 | + <div class="flex h-11 items-center gap-2 rounded-xl border border-black/[0.08] dark:border-white/[0.12] bg-card px-3 py-1.5 text-xs shadow-sm"> |
| 303 | - <option value="all">{t("common.all")}</option> | 302 | + <span class="font-semibold uppercase tracking-wider text-muted-foreground text-[11px]">{t("attempt.status")}:</span> |
| 304 | - <option value="submitted">{t("attempt.submitted")}</option> | 303 | + <select |
| 305 | - <option value="expired">{t("attempt.expired")}</option> | 304 | + class="bg-transparent font-medium text-foreground outline-none cursor-pointer text-xs" |
| 306 | - <option value="draft">{t("exams.draft")}</option> | 305 | + value={statusFilter()} |
| 307 | - <option value="upcoming">{t("exams.upcoming")}</option> | 306 | + onChange={(event) => setStatusFilter(event.currentTarget.value as ExamDisplayStatus | "all")} |
| 308 | - <option value="active">{t("exams.active")}</option> | 307 | + > |
| 309 | - <option value="finished">{t("exams.finished")}</option> | 308 | + <option value="all">{t("common.all")}</option> |
| 310 | - <option value="unscheduled">{t("exams.unscheduled")}</option> | 309 | + <option value="active">{t("exams.active")}</option> |
| 311 | - </Select> | 310 | + <option value="upcoming">{t("exams.upcoming")}</option> |
| 312 | - <Show when={showMoreFilters()}> | 311 | + <option value="submitted">{t("attempt.submitted")}</option> |
| 313 | - <Select class="h-9 w-full rounded-sm sm:w-52" value={courseFilter()} onChange={(event) => setCourseFilter(event.currentTarget.value)}> | 312 | + <option value="expired">{t("attempt.expired")}</option> |
| 313 | + <option value="draft">{t("exams.draft")}</option> | ||
| 314 | + <option value="finished">{t("exams.finished")}</option> | ||
| 315 | + <option value="unscheduled">{t("exams.unscheduled")}</option> | ||
| 316 | + </select> | ||
| 317 | + </div> | ||
| 318 | + | ||
| 319 | + <div class="flex h-11 items-center gap-2 rounded-xl border border-black/[0.08] dark:border-white/[0.12] bg-card px-3 py-1.5 text-xs shadow-sm"> | ||
| 320 | + <span class="font-semibold uppercase tracking-wider text-muted-foreground text-[11px]">{t("nav.courses")}:</span> | ||
| 321 | + <select | ||
| 322 | + class="max-w-[12rem] truncate bg-transparent font-medium text-foreground outline-none cursor-pointer text-xs" | ||
| 323 | + value={courseFilter()} | ||
| 324 | + onChange={(event) => setCourseFilter(event.currentTarget.value)} | ||
| 325 | + > | ||
| 314 | <option value="all">{t("common.all")}</option> | 326 | <option value="all">{t("common.all")}</option> |
| 315 | <For each={visibleCourses()}>{(course) => <option value={course.id}>{course.title}</option>}</For> | 327 | <For each={visibleCourses()}>{(course) => <option value={course.id}>{course.title}</option>}</For> |
| 316 | - </Select> | 328 | + </select> |
| 329 | + </div> | ||
| 330 | + | ||
| 331 | + <Show when={statusFilter() !== "all" || courseFilter() !== "all"}> | ||
| 332 | + <Button | ||
| 333 | + type="button" | ||
| 334 | + variant="ghost" | ||
| 335 | + size="sm" | ||
| 336 | + class="h-11 rounded-xl px-3 text-xs font-medium text-muted-foreground hover:text-foreground tactile-press" | ||
| 337 | + onClick={() => { | ||
| 338 | + setStatusFilter("all"); | ||
| 339 | + setCourseFilter("all"); | ||
| 340 | + }} | ||
| 341 | + > | ||
| 342 | + <IconRotateCcw class="h-3.5 w-3.5 mr-1" /> | ||
| 343 | + {t("common.resetFilters")} | ||
| 344 | + </Button> | ||
| 317 | </Show> | 345 | </Show> |
| 318 | - <Button type="button" variant="outline" size="sm" class="h-9 rounded-sm" onClick={() => setShowMoreFilters((value) => !value)}> | 346 | + </div> |
| 319 | - {showMoreFilters() ? t("common.lessFilters") : t("common.moreFilters")} | ||
| 320 | - </Button> | ||
| 321 | - </> | ||
| 322 | } | 347 | } |
| 323 | /> | 348 | /> |
| 324 | </Suspense> | 349 | </Suspense> |
src/pages/pomodoro-page.tsxmodified+48 -8
| @@ -14,6 +14,8 @@ import { IconCheck, IconClock } from "@/components/ui/icons"; | |||
| 14 | import { PageSpinner } from "@/components/ui/page-spinner"; | 14 | import { PageSpinner } from "@/components/ui/page-spinner"; |
| 15 | import { createFlash } from "@/lib/flash"; | 15 | import { createFlash } from "@/lib/flash"; |
| 16 | import { createNow } from "@/lib/create-now"; | 16 | import { createNow } from "@/lib/create-now"; |
| 17 | +import { triggerConfetti } from "@/lib/confetti"; | ||
| 18 | +import { cn } from "@/lib/cn"; | ||
| 17 | import { formatDateTime, formatDurationClock } from "@/lib/format"; | 19 | import { formatDateTime, formatDurationClock } from "@/lib/format"; |
| 18 | import { usePreferences, useT } from "@/stores/preferences-context"; | 20 | import { usePreferences, useT } from "@/stores/preferences-context"; |
| 19 | 21 | ||
| @@ -76,6 +78,9 @@ function PomodoroContent() { | |||
| 76 | await action(); | 78 | await action(); |
| 77 | await refetch(); | 79 | await refetch(); |
| 78 | setFlash(ok); | 80 | setFlash(ok); |
| 81 | + if (action === postPomodoroFinish) { | ||
| 82 | + triggerConfetti(); | ||
| 83 | + } | ||
| 79 | } catch (err) { | 84 | } catch (err) { |
| 80 | setError(formatApiError(err)); | 85 | setError(formatApiError(err)); |
| 81 | } finally { | 86 | } finally { |
| @@ -83,6 +88,18 @@ function PomodoroContent() { | |||
| 83 | } | 88 | } |
| 84 | }; | 89 | }; |
| 85 | 90 | ||
| 91 | + const progressPercent = createMemo(() => { | ||
| 92 | + const dur = runningDuration(); | ||
| 93 | + if (!dur) return 0; | ||
| 94 | + const targetMs = 25 * 60 * 1000; | ||
| 95 | + return Math.min(1, dur / targetMs); | ||
| 96 | + }); | ||
| 97 | + | ||
| 98 | + const dashOffset = createMemo(() => { | ||
| 99 | + const circumference = 339.29; // 2 * pi * 54 | ||
| 100 | + return circumference * (1 - progressPercent()); | ||
| 101 | + }); | ||
| 102 | + | ||
| 86 | return ( | 103 | return ( |
| 87 | <div class="space-y-6"> | 104 | <div class="space-y-6"> |
| 88 | <PageHeader | 105 | <PageHeader |
| @@ -118,23 +135,46 @@ function PomodoroContent() { | |||
| 118 | </Badge> | 135 | </Badge> |
| 119 | </div> | 136 | </div> |
| 120 | 137 | ||
| 121 | - <div class="grid gap-4 p-5 md:grid-cols-[minmax(0,1fr)_auto] md:items-end"> | 138 | + <div class="grid gap-6 p-6 md:grid-cols-[minmax(0,1fr)_auto] md:items-center"> |
| 122 | - <div> | 139 | + <div class="flex flex-col sm:flex-row items-center gap-6"> |
| 123 | - <p class="text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground">{running() ? t("pomodoro.current") : t("pomodoro.total")}</p> | 140 | + <div class="relative flex h-36 w-36 shrink-0 items-center justify-center"> |
| 124 | - <p class="mono mt-3 text-6xl font-semibold leading-none tracking-tight tabular-nums sm:text-7xl"> | 141 | + <svg class="h-full w-full -rotate-90 transform" viewBox="0 0 120 120"> |
| 125 | - {formatDurationClock(running() ? runningDuration() : log()?.total_focus_ms)} | 142 | + <circle cx="60" cy="60" r="54" class="stroke-muted/40" stroke-width="8" fill="none" /> |
| 126 | - </p> | 143 | + <circle |
| 144 | + cx="60" | ||
| 145 | + cy="60" | ||
| 146 | + r="54" | ||
| 147 | + class={cn("stroke-primary transition-all duration-1000 ease-linear", running() && "animate-pulse-glow")} | ||
| 148 | + stroke-width="8" | ||
| 149 | + stroke-dasharray="339.29" | ||
| 150 | + stroke-dashoffset={running() ? dashOffset() : 0} | ||
| 151 | + stroke-linecap="round" | ||
| 152 | + fill="none" | ||
| 153 | + /> | ||
| 154 | + </svg> | ||
| 155 | + <span class="absolute text-center"> | ||
| 156 | + <IconClock class={cn("h-7 w-7 mx-auto text-primary", running() && "animate-pulse")} /> | ||
| 157 | + </span> | ||
| 158 | + </div> | ||
| 159 | + | ||
| 160 | + <div> | ||
| 161 | + <p class="text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground">{running() ? t("pomodoro.current") : t("pomodoro.total")}</p> | ||
| 162 | + <p class="mono mt-2 text-5xl font-semibold leading-none tracking-tight tabular-nums sm:text-6xl"> | ||
| 163 | + {formatDurationClock(running() ? runningDuration() : log()?.total_focus_ms)} | ||
| 164 | + </p> | ||
| 165 | + </div> | ||
| 127 | </div> | 166 | </div> |
| 167 | + | ||
| 128 | <Show | 168 | <Show |
| 129 | when={running()} | 169 | when={running()} |
| 130 | fallback={ | 170 | fallback={ |
| 131 | - <Button type="button" size="sm" class="h-12 min-w-[10rem] rounded-xl text-base" disabled={pending()} onClick={() => void run(postPomodoroStart, t("pomodoro.started"))}> | 171 | + <Button type="button" size="sm" class="h-12 min-w-[10rem] rounded-xl text-base tactile-press" disabled={pending()} onClick={() => void run(postPomodoroStart, t("pomodoro.started"))}> |
| 132 | <IconClock class="h-4 w-4" /> | 172 | <IconClock class="h-4 w-4" /> |
| 133 | {t("pomodoro.start")} | 173 | {t("pomodoro.start")} |
| 134 | </Button> | 174 | </Button> |
| 135 | } | 175 | } |
| 136 | > | 176 | > |
| 137 | - <Button type="button" size="sm" variant="outline" class="h-12 min-w-[10rem] rounded-xl text-base" disabled={pending()} onClick={() => void run(postPomodoroFinish, t("pomodoro.finished"))}> | 177 | + <Button type="button" size="sm" variant="outline" class="h-12 min-w-[10rem] rounded-xl text-base tactile-press" disabled={pending()} onClick={() => void run(postPomodoroFinish, t("pomodoro.finished"))}> |
| 138 | <IconCheck class="h-4 w-4" /> | 178 | <IconCheck class="h-4 w-4" /> |
| 139 | {t("pomodoro.finish")} | 179 | {t("pomodoro.finish")} |
| 140 | </Button> | 180 | </Button> |