feat(deps): sprinkle @formkit/auto-animate on rail lists
Adds smooth fade+slide animations when list items enter/leave on the three highest-visibility realtime surfaces: - alert-rail.tsx — socket-driven alerts appearing / dismissed. - my-reminders-rail.tsx — reminders completed / arriving via realtime. - notes-list.tsx — notes added / edited / deleted. One-line `useAutoAnimate()` hook per site, no CSS, ~2kb gzip. Replaces the jarring "row just appears/disappears" pattern with a per-item transition. Skipped on pipeline-board (kanban) — combining auto-animate with @dnd-kit's SortableContext causes double-animation glitches because both libraries fight to animate the same layout shift. Verified: tsc clean, vitest 1293/1293 pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
import Link from 'next/link';
|
||||
import { ArrowRight } from 'lucide-react';
|
||||
import { useAutoAnimate } from '@formkit/auto-animate/react';
|
||||
|
||||
import { useUIStore } from '@/stores/ui-store';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
@@ -18,6 +19,11 @@ export function AlertRail() {
|
||||
const visible = alerts.slice(0, 5);
|
||||
const overflow = Math.max(alerts.length - visible.length, 0);
|
||||
|
||||
// Smooth enter/leave for alerts as new ones arrive via socket realtime
|
||||
// and stale ones get dismissed — replaces the jarring "card just
|
||||
// appears/disappears" with a subtle fade+slide.
|
||||
const [animateRef] = useAutoAnimate<HTMLDivElement>();
|
||||
|
||||
return (
|
||||
<section
|
||||
data-testid="alert-rail"
|
||||
@@ -47,7 +53,7 @@ export function AlertRail() {
|
||||
) : visible.length === 0 ? (
|
||||
<AlertCardEmpty />
|
||||
) : (
|
||||
<div className="space-y-2">
|
||||
<div ref={animateRef} className="space-y-2">
|
||||
{visible.map((a) => (
|
||||
<AlertCard key={a.id} alert={a} />
|
||||
))}
|
||||
|
||||
@@ -5,6 +5,7 @@ import { useParams } from 'next/navigation';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { formatDistanceToNowStrict, isAfter, isBefore } from 'date-fns';
|
||||
import { AlarmClock, ChevronRight } from 'lucide-react';
|
||||
import { useAutoAnimate } from '@formkit/auto-animate/react';
|
||||
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
@@ -58,6 +59,10 @@ export function MyRemindersRail() {
|
||||
.slice(0, 6);
|
||||
const overdueCount = items.filter((r) => isBefore(new Date(r.dueAt), now)).length;
|
||||
|
||||
// Smooth animation when reminders complete / get dismissed / arrive
|
||||
// via socket realtime.
|
||||
const [animateRef] = useAutoAnimate<HTMLUListElement>();
|
||||
|
||||
function hrefFor(r: ReminderRow): string {
|
||||
if (r.interestId) return `/${portSlug}/interests/${r.interestId}`;
|
||||
if (r.clientId) return `/${portSlug}/clients/${r.clientId}`;
|
||||
@@ -105,7 +110,7 @@ export function MyRemindersRail() {
|
||||
All caught up - no reminders.
|
||||
</p>
|
||||
) : (
|
||||
<ul className="space-y-1">
|
||||
<ul ref={animateRef} className="space-y-1">
|
||||
{sorted.map((r) => {
|
||||
const due = new Date(r.dueAt);
|
||||
const isOverdue = isBefore(due, now);
|
||||
|
||||
@@ -4,6 +4,7 @@ import { useState } from 'react';
|
||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import { formatDistanceToNow } from 'date-fns';
|
||||
import { Lock, Pencil, Trash2, Send, Loader2 } from 'lucide-react';
|
||||
import { useAutoAnimate } from '@formkit/auto-animate/react';
|
||||
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Textarea } from '@/components/ui/textarea';
|
||||
@@ -133,6 +134,10 @@ export function NotesList({ entityType, entityId, currentUserId, aggregate }: No
|
||||
const listEndpoint = aggregateOn ? `${baseEndpoint}?aggregate=true` : baseEndpoint;
|
||||
const queryKey = [entityType, entityId, 'notes', aggregateOn ? 'aggregated' : 'own'];
|
||||
|
||||
// Smooth animation when notes are added / edited / deleted — replaces
|
||||
// the abrupt re-render with a per-row fade/slide.
|
||||
const [animateRef] = useAutoAnimate<HTMLDivElement>();
|
||||
|
||||
const { data: notes = [], isLoading } = useQuery<Note[]>({
|
||||
queryKey,
|
||||
queryFn: () => apiFetch<{ data: Note[] }>(listEndpoint).then((r) => r.data),
|
||||
@@ -241,7 +246,7 @@ export function NotesList({ entityType, entityId, currentUserId, aggregate }: No
|
||||
) : notes.length === 0 ? (
|
||||
<div className="text-center py-8 text-muted-foreground">No notes yet</div>
|
||||
) : (
|
||||
<div className="space-y-3">
|
||||
<div ref={animateRef} className="space-y-3">
|
||||
{(groupBySource ? sortByGroup(notes) : notes).map((note) => (
|
||||
<div key={note.id} className="flex gap-3 p-3 rounded-lg border bg-card">
|
||||
<Avatar className="h-8 w-8 shrink-0">
|
||||
|
||||
Reference in New Issue
Block a user