11import { ListTodoIcon } from "lucide-react" ;
2+ // Motion state updates animate only the decorative completion fill:
3+ // https://motion.dev/docs/react-animation
4+ // https://motion.dev/docs/react-use-reduced-motion
5+ import { motion , useReducedMotion } from "motion/react" ;
26import { memo , type ComponentProps } from "react" ;
37
48import { formatDuration } from "../../session-logic" ;
@@ -35,6 +39,7 @@ function TaskSegments({
3539 readonly className ?: string ;
3640 readonly steps : readonly ComposerTaskStep [ ] ;
3741} ) {
42+ const reduceMotion = useReducedMotion ( ) ;
3843 if ( steps . length <= 1 || steps . length > MAX_TASK_SEGMENTS ) return null ;
3944
4045 return (
@@ -43,14 +48,18 @@ function TaskSegments({
4348 < span
4449 key = { key }
4550 className = { cn (
46- "h-[3px] min-w-0 flex-1 rounded-full" ,
47- step . status === "completed"
48- ? "bg-success"
49- : step . status === "inProgress"
50- ? "bg-primary"
51- : "bg-muted-foreground/25" ,
51+ "relative h-[3px] min-w-0 flex-1 overflow-hidden rounded-full" ,
52+ step . status === "inProgress" ? "bg-primary" : "bg-muted-foreground/25" ,
5253 ) }
53- />
54+ >
55+ < motion . span
56+ className = "absolute inset-0 origin-left bg-success"
57+ // History opens at its real state; only subsequent progress changes animate.
58+ initial = { false }
59+ animate = { { scaleX : step . status === "completed" ? 1 : 0 } }
60+ transition = { { type : "tween" , duration : reduceMotion ? 0 : 0.18 , ease : "easeOut" } }
61+ />
62+ </ span >
5463 ) ) }
5564 </ span >
5665 ) ;
0 commit comments