Skip to content

Commit

Permalink
feat: introduce styled timeline center line
Browse files Browse the repository at this point in the history
  • Loading branch information
stampaaaron committed Jan 11, 2023
1 parent 336caa0 commit 677db57
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
14 changes: 14 additions & 0 deletions src/components/Timeline.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.timeline {
position: relative;
}

div.timeline__line {
background-color: black;
width: 0.5rem;
height: 20rem;
margin-inline: auto;
}

.timeline-item {
position: absolute;
}
10 changes: 9 additions & 1 deletion src/components/Timeline.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import { TimelineItem, TimelineItemProps } from './TimelineItem';
import './Timeline.css';

export type TimelineProps = {
items: TimelineItemProps[];
};

export function Timeline({ items }: TimelineProps) {
return items.map((item) => <TimelineItem key={item.date.toISOString()} {...item} />);
return (
<div className="timeline">
<div className="timeline__line" />
{items.map((item) => (
<TimelineItem key={item.date.toISOString()} {...item} />
))}
</div>
);
}
2 changes: 1 addition & 1 deletion src/components/TimelineItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export type TimelineItemProps = PropsWithChildren<{

export function TimelineItem({ className, title, date, children }: TimelineItemProps) {
return (
<div className={className}>
<div className={`${className} timeline-item`}>
<p>{date.toISOString()}</p>
<p>{title}</p>
{children}
Expand Down

0 comments on commit 677db57

Please sign in to comment.