Skip to content

Commit 677db57

Browse files
committed
feat: introduce styled timeline center line
1 parent 336caa0 commit 677db57

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

src/components/Timeline.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.timeline {
2+
position: relative;
3+
}
4+
5+
div.timeline__line {
6+
background-color: black;
7+
width: 0.5rem;
8+
height: 20rem;
9+
margin-inline: auto;
10+
}
11+
12+
.timeline-item {
13+
position: absolute;
14+
}

src/components/Timeline.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
import { TimelineItem, TimelineItemProps } from './TimelineItem';
2+
import './Timeline.css';
23

34
export type TimelineProps = {
45
items: TimelineItemProps[];
56
};
67

78
export function Timeline({ items }: TimelineProps) {
8-
return items.map((item) => <TimelineItem key={item.date.toISOString()} {...item} />);
9+
return (
10+
<div className="timeline">
11+
<div className="timeline__line" />
12+
{items.map((item) => (
13+
<TimelineItem key={item.date.toISOString()} {...item} />
14+
))}
15+
</div>
16+
);
917
}

src/components/TimelineItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export type TimelineItemProps = PropsWithChildren<{
88

99
export function TimelineItem({ className, title, date, children }: TimelineItemProps) {
1010
return (
11-
<div className={className}>
11+
<div className={`${className} timeline-item`}>
1212
<p>{date.toISOString()}</p>
1313
<p>{title}</p>
1414
{children}

0 commit comments

Comments
 (0)