diff --git a/src/components/events/event-card.tsx b/src/components/events/event-card.tsx index 5f44bc1..04210d3 100644 --- a/src/components/events/event-card.tsx +++ b/src/components/events/event-card.tsx @@ -38,7 +38,7 @@ export function EventCard(props: { event: Event }) { return ( -
+

diff --git a/src/components/exams/exam-room-ws.tsx b/src/components/exams/exam-room-ws.tsx index 8ae6246..2c47366 100644 --- a/src/components/exams/exam-room-ws.tsx +++ b/src/components/exams/exam-room-ws.tsx @@ -20,6 +20,7 @@ import { PageSpinner } from "@/components/ui/page-spinner"; import { Textarea } from "@/components/ui/textarea"; import { cn } from "@/lib/cn"; import { createNow } from "@/lib/create-now"; +import { triggerConfetti } from "@/lib/confetti"; import { formatDateTime } from "@/lib/format"; import { formatBytes, maxUploadBytes } from "@/lib/upload-limits"; import { usePreferences, useT } from "@/stores/preferences-context"; @@ -287,6 +288,7 @@ export function ExamRoomWS(props: { exam: Exam }) { const next = await getExamAttempt(props.exam.id); setAttempt(next); } + triggerConfetti(); } catch (err) { setError(formatApiError(err, locale())); } finally { diff --git a/src/components/notes/note-card.tsx b/src/components/notes/note-card.tsx index 92a93ad..bd20abb 100644 --- a/src/components/notes/note-card.tsx +++ b/src/components/notes/note-card.tsx @@ -24,7 +24,7 @@ export function NoteCard(props: {
props.onOpen(props.note)} onKeyDown={(event) => { if (event.key === "Enter" || event.key === " ") { diff --git a/src/components/notes/note-import-panel.tsx b/src/components/notes/note-import-panel.tsx index 96e1d38..83a1af5 100644 --- a/src/components/notes/note-import-panel.tsx +++ b/src/components/notes/note-import-panel.tsx @@ -5,6 +5,7 @@ import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Textarea } from "@/components/ui/textarea"; import { processImportedText } from "@/lib/note-importer"; +import { triggerConfetti } from "@/lib/confetti"; import { formatBytes } from "@/lib/upload-limits"; import { useT } from "@/stores/preferences-context"; @@ -60,6 +61,7 @@ export function NoteImportPanel(props: { const handleApply = () => { const title = importedTitle().trim() || "Imported Note"; const content = importedMarkdown(); + triggerConfetti(); props.onImport(title, content); }; diff --git a/src/components/ui/empty-state.tsx b/src/components/ui/empty-state.tsx index 59f4cd0..d63b2b2 100644 --- a/src/components/ui/empty-state.tsx +++ b/src/components/ui/empty-state.tsx @@ -1,23 +1,63 @@ import { Show } from "solid-js"; import { cn } from "@/lib/cn"; -/** Clean dashed empty panel. */ +export type EmptyStateKind = "default" | "notes" | "exams" | "events" | "courses"; + +/** Clean dashed empty panel with animated vector illustrations. */ export function EmptyState(props: { title: string; description?: string; + kind?: EmptyStateKind; class?: string; }) { + const kind = () => props.kind ?? "default"; + return (
-

{props.title}

- -

{props.description}

-
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+

{props.title}

+ +

{props.description}

+
+
); } diff --git a/src/components/ui/icons.tsx b/src/components/ui/icons.tsx index 37f04d7..f37ea4c 100644 --- a/src/components/ui/icons.tsx +++ b/src/components/ui/icons.tsx @@ -623,3 +623,20 @@ export function IconUploadCloud(props: IconProps) { ); } + +export function IconFilter(props: IconProps) { + return ( + + + + ); +} + +export function IconRotateCcw(props: IconProps) { + return ( + + + + + ); +} diff --git a/src/i18n/messages.ts b/src/i18n/messages.ts index 5b074c1..386355b 100644 --- a/src/i18n/messages.ts +++ b/src/i18n/messages.ts @@ -101,6 +101,7 @@ export type MessageKey = | "common.creator" | "common.searchPlaceholder" | "common.all" + | "common.resetFilters" | "common.saveAttendance" | "common.created" | "common.deleted" @@ -833,6 +834,7 @@ const en: Dict = { "common.creator": "Created by", "common.searchPlaceholder": "Search…", "common.all": "All", + "common.resetFilters": "Reset filters", "common.saveAttendance": "Save my attendance", "common.created": "Created.", "common.deleted": "Deleted.", @@ -1577,6 +1579,7 @@ const tr: Dict = { "common.creator": "Oluşturan", "common.searchPlaceholder": "Ara…", "common.all": "Tümü", + "common.resetFilters": "Sıfırla", "common.saveAttendance": "Yoklamamı kaydet", "common.created": "Oluşturuldu.", "common.deleted": "Silindi.", diff --git a/src/index.css b/src/index.css index 6540118..3fdaef1 100644 --- a/src/index.css +++ b/src/index.css @@ -255,17 +255,45 @@ @apply rounded-xl h-11 px-5 font-medium active:scale-[0.97] transition-transform duration-150; } + .tactile-press { + @apply active:scale-[0.97] transition-transform duration-150; + } + + .card-lift { + @apply transition-all duration-200 ease-out hover:-translate-y-1 hover:shadow-xl hover:shadow-primary/[0.05]; + } + @keyframes dashboard-jiggle { 0%, 100% { transform: rotate(-0.4deg) translateY(0); } 50% { transform: rotate(0.4deg) translateY(-1px); } } + @keyframes pulse-glow { + 0%, 100% { opacity: 0.9; transform: scale(1); filter: drop-shadow(0 0 12px rgba(59, 130, 246, 0.4)); } + 50% { opacity: 1; transform: scale(1.02); filter: drop-shadow(0 0 24px rgba(59, 130, 246, 0.7)); } + } + + @keyframes float-gentle { + 0%, 100% { transform: translateY(0px); } + 50% { transform: translateY(-6px); } + } + .dashboard-jiggle { animation: dashboard-jiggle 180ms ease-in-out infinite; } + .animate-pulse-glow { + animation: pulse-glow 3s ease-in-out infinite; + } + + .animate-float { + animation: float-gentle 4s ease-in-out infinite; + } + @media (prefers-reduced-motion: reduce) { - .dashboard-jiggle { + .dashboard-jiggle, + .animate-pulse-glow, + .animate-float { animation: none; } } diff --git a/src/lib/__tests__/confetti.test.ts b/src/lib/__tests__/confetti.test.ts new file mode 100644 index 0000000..5552d83 --- /dev/null +++ b/src/lib/__tests__/confetti.test.ts @@ -0,0 +1,8 @@ +import { describe, expect, it } from "vitest"; +import { triggerConfetti } from "../confetti"; + +describe("triggerConfetti", () => { + it("safely handles server-side / node environment without window object", () => { + expect(() => triggerConfetti({ particleCount: 10 })).not.toThrow(); + }); +}); diff --git a/src/lib/confetti.ts b/src/lib/confetti.ts new file mode 100644 index 0000000..ba4b275 --- /dev/null +++ b/src/lib/confetti.ts @@ -0,0 +1,126 @@ +/** + * Ultra-lightweight zero-dependency confetti particle burst utility. + * Renders celebratory particle effects on an overlay canvas with auto-cleanup. + */ +export function triggerConfetti(options?: { + particleCount?: number; + durationMs?: number; + colors?: string[]; +}) { + if (typeof window === "undefined") return; + if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) return; + + const count = options?.particleCount ?? 60; + const duration = options?.durationMs ?? 2500; + const colors = options?.colors ?? [ + "#3b82f6", // blue + "#ec4899", // pink + "#8b5cf6", // purple + "#10b981", // green + "#f59e0b", // amber + "#6366f1", // indigo + ]; + + const canvas = document.createElement("canvas"); + canvas.style.position = "fixed"; + canvas.style.top = "0"; + canvas.style.left = "0"; + canvas.style.width = "100vw"; + canvas.style.height = "100vh"; + canvas.style.pointerEvents = "none"; + canvas.style.zIndex = "99999"; + document.body.appendChild(canvas); + + const ctx = canvas.getContext("2d"); + if (!ctx) { + canvas.remove(); + return; + } + + const dpr = Math.min(window.devicePixelRatio || 1, 2); + const width = window.innerWidth; + const height = window.innerHeight; + canvas.width = width * dpr; + canvas.height = height * dpr; + ctx.scale(dpr, dpr); + + type Particle = { + x: number; + y: number; + vx: number; + vy: number; + size: number; + color: string; + rotation: number; + vRot: number; + opacity: number; + shape: "square" | "circle"; + }; + + const particles: Particle[] = []; + const startX = width / 2; + const startY = height * 0.4; + + for (let i = 0; i < count; i += 1) { + const angle = Math.random() * Math.PI * 2; + const speed = Math.random() * 12 + 6; + particles.push({ + x: startX, + y: startY, + vx: Math.cos(angle) * speed, + vy: Math.sin(angle) * speed - 4, + size: Math.random() * 8 + 5, + color: colors[Math.floor(Math.random() * colors.length)], + rotation: Math.random() * Math.PI * 2, + vRot: (Math.random() - 0.5) * 0.2, + opacity: 1, + shape: Math.random() > 0.4 ? "square" : "circle", + }); + } + + let animationId: number; + const startTime = performance.now(); + + const render = (now: number) => { + const elapsed = now - startTime; + if (elapsed >= duration) { + cancelAnimationFrame(animationId); + canvas.remove(); + return; + } + + ctx.clearRect(0, 0, width, height); + + const progress = elapsed / duration; + const fadeOut = progress > 0.7 ? (1 - progress) / 0.3 : 1; + + for (const p of particles) { + p.x += p.vx; + p.y += p.vy; + p.vy += 0.3; // gravity + p.vx *= 0.98; // drag + p.vy *= 0.98; + p.rotation += p.vRot; + + ctx.save(); + ctx.globalAlpha = p.opacity * fadeOut; + ctx.translate(p.x, p.y); + ctx.rotate(p.rotation); + ctx.fillStyle = p.color; + + if (p.shape === "circle") { + ctx.beginPath(); + ctx.arc(0, 0, p.size / 2, 0, Math.PI * 2); + ctx.fill(); + } else { + ctx.fillRect(-p.size / 2, -p.size / 2, p.size, p.size * 0.7); + } + + ctx.restore(); + } + + animationId = requestAnimationFrame(render); + }; + + animationId = requestAnimationFrame(render); +} diff --git a/src/pages/dashboard-page.tsx b/src/pages/dashboard-page.tsx index 61c2ee5..a0b45a5 100644 --- a/src/pages/dashboard-page.tsx +++ b/src/pages/dashboard-page.tsx @@ -643,7 +643,7 @@ function PortalCard(props: { const cardClass = () => cn( - "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]", + "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]", !props.editing && "active:scale-[0.98]", props.editing && "cursor-grab select-none border-dashed border-primary/50 bg-primary/[0.03]", props.editing && !props.dragging && "dashboard-jiggle", diff --git a/src/pages/exams-page.tsx b/src/pages/exams-page.tsx index 4aa6b38..d5429f4 100644 --- a/src/pages/exams-page.tsx +++ b/src/pages/exams-page.tsx @@ -17,7 +17,7 @@ import { Alert } from "@/components/ui/alert"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; -import { IconCheck, IconEdit, IconEye, IconPlus } from "@/components/ui/icons"; +import { IconCheck, IconEdit, IconEye, IconPlus, IconRotateCcw } from "@/components/ui/icons"; import { Select } from "@/components/ui/select"; import { SidePanel } from "@/components/ui/side-panel"; import { TableRowActions } from "@/components/ui/table-row-actions"; @@ -52,7 +52,6 @@ function ExamsContent() { const now = createNow(); const [statusFilter, setStatusFilter] = createSignal("all"); const [courseFilter, setCourseFilter] = createSignal("all"); - const [showMoreFilters, setShowMoreFilters] = createSignal(false); const [createOpen, setCreateOpen] = createSignal(false); const [selectedCourseId, setSelectedCourseId] = createSignal(""); const [editingExam, setEditingExam] = createSignal(null); @@ -298,27 +297,53 @@ function ExamsContent() { empty={t("exams.empty")} onRowClick={(exam) => void navigate({ to: "/exams/$id", params: { id: exam.id } })} filters={ - <> - - - setStatusFilter(event.currentTarget.value as ExamDisplayStatus | "all")} + > + + + + + + + + + +

+ +
+ {t("nav.courses")}: + + +
+ + + - - +
} /> diff --git a/src/pages/pomodoro-page.tsx b/src/pages/pomodoro-page.tsx index 4099af9..7b6d216 100644 --- a/src/pages/pomodoro-page.tsx +++ b/src/pages/pomodoro-page.tsx @@ -14,6 +14,8 @@ import { IconCheck, IconClock } from "@/components/ui/icons"; import { PageSpinner } from "@/components/ui/page-spinner"; import { createFlash } from "@/lib/flash"; import { createNow } from "@/lib/create-now"; +import { triggerConfetti } from "@/lib/confetti"; +import { cn } from "@/lib/cn"; import { formatDateTime, formatDurationClock } from "@/lib/format"; import { usePreferences, useT } from "@/stores/preferences-context"; @@ -76,6 +78,9 @@ function PomodoroContent() { await action(); await refetch(); setFlash(ok); + if (action === postPomodoroFinish) { + triggerConfetti(); + } } catch (err) { setError(formatApiError(err)); } finally { @@ -83,6 +88,18 @@ function PomodoroContent() { } }; + const progressPercent = createMemo(() => { + const dur = runningDuration(); + if (!dur) return 0; + const targetMs = 25 * 60 * 1000; + return Math.min(1, dur / targetMs); + }); + + const dashOffset = createMemo(() => { + const circumference = 339.29; // 2 * pi * 54 + return circumference * (1 - progressPercent()); + }); + return (
-
-
-

{running() ? t("pomodoro.current") : t("pomodoro.total")}

-

- {formatDurationClock(running() ? runningDuration() : log()?.total_focus_ms)} -

+
+
+
+ + + + + + + +
+ +
+

{running() ? t("pomodoro.current") : t("pomodoro.total")}

+

+ {formatDurationClock(running() ? runningDuration() : log()?.total_focus_ms)} +

+
+ void run(postPomodoroStart, t("pomodoro.started"))}> + } > -