Skip to content

Commit e727643

Browse files
Show event according years
1 parent c558246 commit e727643

3 files changed

Lines changed: 29 additions & 11 deletions

File tree

components/TimeHistory/TimeHistory.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ const TimeHistory = ({
105105
}px`,
106106
}}
107107
>
108-
<TimeSpanBar {...item} />
108+
<TimeSpanBar {...item} yearWidth={yearWidth} />
109109
</div>
110110
))}
111111
</div>

components/TimeSpanBar/TimeSpanBar.module.css

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,18 @@
33
display: grid;
44
font-family: sans-serif;
55
grid-template-areas:
6-
"start start"
76
"header header"
87
"events events"
98
"end end";
109
}
1110

1211
.header {
12+
display: flex;
13+
flex-direction: row;
1314
font-size: 16px;
1415
font-weight: 600;
1516
grid-area: header;
16-
margin: 12px 4px;
17+
margin: 0;
1718
}
1819

1920
.content {
@@ -60,14 +61,17 @@
6061
gap: 4px;
6162
align-items: top;
6263
overflow: scroll;
64+
height: 100px;
6365
}
6466

6567
.event {
6668
box-shadow: inset 0 0 10px 0 rgba(0, 0, 0, 0.1);
67-
height: 90%;
69+
background-color: #fff;
70+
height: 100px;
6871
overflow-y: scroll;
6972
font-size: 0.5em;
7073
min-width: 80px;
74+
position: absolute;
7175
}
7276

7377
.eventDate {

components/TimeSpanBar/TimeSpanBar.tsx

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export interface TimeSpanBarProps {
2727
}[];
2828
header: string;
2929
image: string;
30+
yearWidth: number;
3031
}
3132

3233
const formatDate = (date: Date) => {
@@ -43,17 +44,30 @@ const TimeSpanBar = ({
4344
events,
4445
header,
4546
image,
47+
yearWidth,
4648
}: TimeSpanBarProps) => {
49+
const duration = end.date.getFullYear() - start.date.getFullYear();
50+
4751
return (
4852
<div className={classes.component}>
49-
<h3 className={classes.header}>{header}</h3>
50-
<div className={classes.start}>
51-
<div className={classes.label}></div>
52-
<div className={classes.date}>{formatDate(start.date)}</div>
53-
</div>
54-
<div className={classes.events}>
53+
<h3 className={classes.header}>
54+
<div className={classes.start}>
55+
<div className={classes.label}></div>
56+
<div className={classes.date}>{formatDate(start.date)}</div>
57+
</div>
58+
{header}
59+
</h3>
60+
<div className={classes.events} style={{ width: duration * yearWidth }}>
5561
{events.map((event, index) => (
56-
<div className={classes.event} key={index}>
62+
<div
63+
className={classes.event}
64+
key={index}
65+
style={{
66+
left:
67+
(event.info.date.getFullYear() - start.date.getFullYear()) *
68+
yearWidth,
69+
}}
70+
>
5771
<div className={classes.eventDate}>
5872
{formatDate(event.info.date)}
5973
</div>

0 commit comments

Comments
 (0)