From 8bb2d486f3163e7202a868602204e58d3a73c27c Mon Sep 17 00:00:00 2001 From: JExcellence | Justin Date: Tue, 14 Apr 2026 14:10:22 +0200 Subject: [PATCH] fix: align Timeline labels with marker dots Replace marginTop/paddingTop hacks with fillHeight lines and vertical centering on the content column. Fixes #43. --- packages/core/src/components/Timeline.tsx | 153 +++++++++++++--------- 1 file changed, 93 insertions(+), 60 deletions(-) diff --git a/packages/core/src/components/Timeline.tsx b/packages/core/src/components/Timeline.tsx index 3bd6b677..81866f33 100644 --- a/packages/core/src/components/Timeline.tsx +++ b/packages/core/src/components/Timeline.tsx @@ -34,92 +34,125 @@ const Timeline: React.FC = ({ } }; + const dotSize = size === "xs" ? "8" : size === "s" ? "24" : size === "m" ? "32" : size === "l" ? "40" : "48"; + const isHorizontal = flex.direction === "row"; + + const renderDot = (item: TimelineItem, state: string) => ( + + {item.marker && ( + + {item.marker} + + )} + + ); + + const markerWidth = isHorizontal ? undefined : dotSize; + return ( {items.map((item, index) => { const state = item.state || "default"; const nextState = index < items.length - 1 ? (items[index + 1].state || "default") : state; - + const currentColor = getStateColor(state); const nextColor = getStateColor(nextState); - const isHorizontal = flex.direction === "row"; const gradientToNext = isHorizontal ? `linear-gradient(to right, ${currentColor}, ${nextColor})` : `linear-gradient(to bottom, ${currentColor}, ${nextColor})`; + if (isHorizontal) { + return ( + + + {index !== 0 && ( + + )} + {renderDot(item, state)} + {index !== items.length - 1 && ( + + )} + + + {item.label && ( + {item.label} + )} + {item.description && ( + {item.description} + )} + {item.children} + + + ); + } + + const rowDirection = alignment === "right" ? "row-reverse" : undefined; + const hasContent = item.description || item.children; + return ( - - {/* Marker */} - + + {index !== 0 && ( )} - - {item.marker && ( - - {item.marker} - - )} - + {renderDot(item, state)} {index !== items.length - 1 && ( - + )} - - {/* Content */} - <> - {item.label && ( - {item.label} - )} - {item.description && ( - - {item.description} - - )} - {item.children} - + {item.label && ( + {item.label} + )} + {item.description && ( + {item.description} + )} + {item.children} );