diff --git a/apps/web/components/timeline-view.tsx b/apps/web/components/timeline-view.tsx index ce5d512a..7e509ab9 100644 --- a/apps/web/components/timeline-view.tsx +++ b/apps/web/components/timeline-view.tsx @@ -1,6 +1,7 @@ "use client" import { useState, useEffect, useRef, useCallback } from "react" +import { AnimatePresence, motion } from "motion/react" import type { DocumentsWithMemoriesResponseSchema } from "@repo/validation/api" import type { z } from "zod" import { cn } from "@lib/utils" @@ -194,6 +195,7 @@ function TimelineCard({ isSelected = false, onToggleSelection, indent = false, + isLast = false, }: { doc: DocumentWithMemories onOpenDocument: (doc: DocumentWithMemories) => void @@ -201,6 +203,7 @@ function TimelineCard({ isSelected?: boolean onToggleSelection?: (doc: DocumentWithMemories) => void indent?: boolean + isLast?: boolean }) { const preview = getPreviewText(doc) const typeLabel = doc.type @@ -221,10 +224,11 @@ function TimelineCard({ - {isExpanded && ( -
- {group.docs.map((doc) => ( - { - if (doc.id) onToggleSelection?.(doc.id) - }} - indent - /> - ))} -
- )} + + {isExpanded && ( + + {group.docs.map((doc, index) => ( + + { + if (doc.id) onToggleSelection?.(doc.id) + }} + indent + isLast={index === group.docs.length - 1} + /> + + ))} + + )} + ) } @@ -506,57 +534,121 @@ export function TimelineView({ return (
- {periodGroups.map((period) => ( -
-
- - {period.label} - -
+ {periodGroups.map((period, periodIndex) => { + const periodHasExpandedGroup = period.typeGroups.some((group) => + expandedGroups.has(`${period.label}::${group.categoryInfo.key}`), + ) -
- {period.typeGroups.map((group) => { - const expandKey = `${period.label}::${group.categoryInfo.key}` + return ( +
+
+ + {period.label} + +
- if (group.docs.length === 1) { - const doc = group.docs[0] - if (!doc) return null +
+
+ + + + {periodHasExpandedGroup && ( + + )} + + + +
+ +
+ {period.typeGroups.map((group) => { + const expandKey = `${period.label}::${group.categoryInfo.key}` + + if (group.docs.length === 1) { + const doc = group.docs[0] + if (!doc) return null + + return ( + + ) + } return ( - toggleGroup(expandKey)} onOpenDocument={onOpenDocument} isSelectionMode={isSelectionMode} - isSelected={ - doc.id ? selectedDocumentIds.has(doc.id) : false - } - onToggleSelection={handleTimelineCardSelection} + selectedDocumentIds={selectedDocumentIds} + onToggleSelection={onToggleSelection} /> ) - } - - return ( - toggleGroup(expandKey)} - onOpenDocument={onOpenDocument} - isSelectionMode={isSelectionMode} - selectedDocumentIds={selectedDocumentIds} - onToggleSelection={onToggleSelection} - /> - ) - })} + })} +
-
- ))} + ) + })}