50 lines
1.9 KiB
TypeScript
50 lines
1.9 KiB
TypeScript
import { type Component, For, createMemo } from "solid-js";
|
|
import { store, getCombinedScore, matchesFilter } from "@/store";
|
|
import { TaskCard } from "@/components/TaskCard";
|
|
import { useDelayedSort } from "@/hooks/useDelayedSort";
|
|
import { useTaskListAutoAnimate } from "@/hooks/useTaskListAutoAnimate";
|
|
|
|
export const PriorityView: Component = () => {
|
|
const sourceTasks = createMemo(() => store.tasks.filter(t => !t.deletedAt && matchesFilter(t)));
|
|
|
|
const { displayedTasks, shakingTaskIds } = useDelayedSort(
|
|
sourceTasks,
|
|
(a, b) => {
|
|
if (a.completed !== b.completed) return a.completed ? 1 : -1;
|
|
return getCombinedScore(b) - getCombinedScore(a);
|
|
},
|
|
300
|
|
);
|
|
|
|
let listRef: HTMLDivElement | undefined;
|
|
useTaskListAutoAnimate(() => listRef);
|
|
|
|
return (
|
|
<div class="space-y-6">
|
|
<header>
|
|
<h2 class="text-3xl font-bold tracking-tight">Priority</h2>
|
|
<p class="text-muted-foreground mt-1 text-lg">Your tasks ordered by priority.</p>
|
|
</header>
|
|
|
|
<div class="grid grid-cols-1 gap-3 w-full" ref={listRef}>
|
|
<For each={displayedTasks()}>
|
|
{(task) => (
|
|
<div class="w-full min-w-0">
|
|
<TaskCard task={task} isShaking={shakingTaskIds().includes(task.id)} />
|
|
</div>
|
|
)}
|
|
</For>
|
|
</div>
|
|
|
|
{displayedTasks().length === 0 && (
|
|
<div class="flex flex-col items-center justify-center py-20 text-center">
|
|
<div class="w-16 h-16 bg-muted rounded-full flex items-center justify-center mb-4">
|
|
<span class="text-2xl">🎯</span>
|
|
</div>
|
|
<p class="text-muted-foreground">Focus sharp. No high-priority tasks yet.</p>
|
|
</div>
|
|
)}
|
|
</div>
|
|
);
|
|
};
|