From 81baf285a9b80f7d92608a6216a6297cd65310dc Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Tue, 26 Mar 2024 16:09:04 -0500 Subject: [PATCH] better alignment of motion timeline segments --- .../components/timeline/EventReviewTimeline.tsx | 2 +- web/src/components/timeline/EventSegment.tsx | 10 +++++----- web/src/components/timeline/MotionSegment.tsx | 16 ++++++++-------- web/src/components/timeline/SummaryTimeline.tsx | 2 +- web/src/components/timeline/segment-metadata.tsx | 4 ++-- web/src/hooks/use-camera-activity.ts | 2 +- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/web/src/components/timeline/EventReviewTimeline.tsx b/web/src/components/timeline/EventReviewTimeline.tsx index 56f2f64722..bccf43cd21 100644 --- a/web/src/components/timeline/EventReviewTimeline.tsx +++ b/web/src/components/timeline/EventReviewTimeline.tsx @@ -166,7 +166,7 @@ export function EventReviewTimeline({ // Generate segments for the timeline const generateSegments = useCallback(() => { - const segmentCount = timelineDuration / segmentDuration; + const segmentCount = Math.ceil(timelineDuration / segmentDuration); return Array.from({ length: segmentCount }, (_, index) => { const segmentTime = timelineStartAligned - index * segmentDuration; diff --git a/web/src/components/timeline/EventSegment.tsx b/web/src/components/timeline/EventSegment.tsx index 9fa2d025de..ab8f30157b 100644 --- a/web/src/components/timeline/EventSegment.tsx +++ b/web/src/components/timeline/EventSegment.tsx @@ -139,7 +139,7 @@ export function EventSegment({ // eslint-disable-next-line react-hooks/exhaustive-deps }, [showMinimap, isFirstSegmentInMinimap, events, segmentDuration]); - const segmentClasses = `h-2 relative w-full ${ + const segmentClasses = `h-[8px] relative w-full ${ showMinimap ? isInMinimapRange ? "bg-secondary-highlight" @@ -149,7 +149,7 @@ export function EventSegment({ : "" } ${ isFirstSegmentInMinimap || isLastSegmentInMinimap - ? "relative h-2 border-b-2 border-neutral-600" + ? "relative h-[8px] border-b-2 border-neutral-600" : "" }`; @@ -230,16 +230,16 @@ export function EventSegment({ {severityValue === displaySeverityType && ( -
+
diff --git a/web/src/components/timeline/MotionSegment.tsx b/web/src/components/timeline/MotionSegment.tsx index 279f69a9ae..c7b30b7414 100644 --- a/web/src/components/timeline/MotionSegment.tsx +++ b/web/src/components/timeline/MotionSegment.tsx @@ -144,7 +144,7 @@ export function MotionSegment({ // eslint-disable-next-line react-hooks/exhaustive-deps }, [showMinimap, isFirstSegmentInMinimap, events, segmentDuration]); - const segmentClasses = `h-2 relative w-full ${ + const segmentClasses = `h-[8px] relative w-full ${ showMinimap ? isInMinimapRange ? "bg-secondary-highlight" @@ -154,7 +154,7 @@ export function MotionSegment({ : "" } ${ isFirstSegmentInMinimap || isLastSegmentInMinimap - ? "relative h-2 border-b-2 border-gray-500" + ? "relative h-[8px] border-b-2 border-gray-500" : "" }`; @@ -223,9 +223,9 @@ export function MotionSegment({ )} -
-
-
+
+
+
-
+
0) { return ( -
+
{ - const segmentCount = reviewTimelineDuration / segmentDuration; + const segmentCount = Math.ceil(reviewTimelineDuration / segmentDuration); if (segmentHeight) { return Array.from({ length: segmentCount }, (_, index) => { diff --git a/web/src/components/timeline/segment-metadata.tsx b/web/src/components/timeline/segment-metadata.tsx index a0f3031751..349f56276d 100644 --- a/web/src/components/timeline/segment-metadata.tsx +++ b/web/src/components/timeline/segment-metadata.tsx @@ -59,7 +59,7 @@ export function MinimapBounds({ export function Tick({ timestamp, timestampSpread }: TickSegmentProps) { return (
-
+
+
{!isFirstSegmentInMinimap && !isLastSegmentInMinimap && (
{ - if (!motionData || !reviewItems) { + if (!motionData || !reviewItems || !motionData) { return; }