Skip to content

Commit ffc56db

Browse files
feat: add responsiveness to timeline component
1 parent 6f07184 commit ffc56db

File tree

2 files changed

+43
-4
lines changed

2 files changed

+43
-4
lines changed

src/components/Timeline.astro

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ type Props = {
1010
const { elements, shortSpine = false } = Astro.props;
1111
1212
const spineHeight = shortSpine ? "100%" : "calc(100% + var(--size-height-divider) + (2 * var(--size-gutter-massive)))";
13+
const displayTriangle = shortSpine ? "none" : "absolute";
1314
---
1415

1516
<div class="timeline">
@@ -25,7 +26,7 @@ const spineHeight = shortSpine ? "100%" : "calc(100% + var(--size-height-divider
2526
</ol>
2627
</div>
2728

28-
<style define:vars={{ spineHeight }}>
29+
<style define:vars={{ spineHeight, displayTriangle }}>
2930
.timeline {
3031
position: relative;
3132
}
@@ -65,7 +66,6 @@ const spineHeight = shortSpine ? "100%" : "calc(100% + var(--size-height-divider
6566
flex-direction: column;
6667
box-sizing: border-box;
6768
padding: 1rem;
68-
/* background: #fcfaf3; */
6969
background: var(--color-overlay);
7070
width: 45%;
7171
box-shadow: 0px 15px 30px -15px rgba(0, 0, 0, 0.5);
@@ -86,7 +86,39 @@ const spineHeight = shortSpine ? "100%" : "calc(100% + var(--size-height-divider
8686
z-index: 5; /* above spine */
8787
}
8888

89-
ol li:nth-child(even) {
90-
align-self: flex-end;
89+
@media screen and (min-width: 1025px) {
90+
ol li:nth-child(even) {
91+
align-self: flex-end;
92+
}
93+
}
94+
95+
@media screen and (max-width: 1025px) {
96+
li::after {
97+
left: 90%;
98+
}
99+
100+
.timeline::before {
101+
left: 90%;
102+
}
103+
104+
.timeline::after {
105+
content: "";
106+
width: 20px;
107+
aspect-ratio: 1;
108+
clip-path: polygon(0 0, 50% 100%, 100% 0);
109+
background-color: var(--color-primary);
110+
left: calc(90% - 10px);
111+
bottom: calc(-1 * (5px + var(--size-height-divider) + (2 * var(--size-gutter-massive))));
112+
position: var(--displayTriangle);
113+
z-index: 3; /* above potential dividers */
114+
}
115+
116+
li {
117+
width: 85%;
118+
}
119+
120+
li:not(:last-child) {
121+
margin-bottom: 4rem;
122+
}
91123
}
92124
</style>

src/layouts/sections/FormationSection.astro

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,11 @@ const formationData = timelineCollection
3939
column-gap: 1.5rem;
4040
grid-template-columns: 60% 40%;
4141
}
42+
43+
@media screen and (max-width: 1025px) {
44+
section {
45+
grid-template-columns: 100%;
46+
row-gap: 1rem;
47+
}
48+
}
4249
</style>

0 commit comments

Comments
 (0)