Skip to content

Commit 19e4025

Browse files
feat: add base formation section
1 parent ddaf034 commit 19e4025

File tree

6 files changed

+187
-0
lines changed

6 files changed

+187
-0
lines changed

src/components/Timeline.astro

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
---
2+
type Props = {
3+
elements: {
4+
text: string;
5+
title: string;
6+
}[];
7+
};
8+
9+
const { elements } = Astro.props;
10+
---
11+
12+
<div class="timeline">
13+
<ol>
14+
{
15+
elements.map((element) => (
16+
<li>
17+
<h6>{element.title}</h6>
18+
<p>{element.text}</p>
19+
</li>
20+
))
21+
}
22+
</ol>
23+
</div>
24+
25+
<style>
26+
.timeline {
27+
position: relative;
28+
}
29+
30+
h6 {
31+
margin-top: 0;
32+
}
33+
34+
p {
35+
font-size: 15px;
36+
}
37+
38+
ol {
39+
list-style: none;
40+
margin: 0;
41+
padding: 0;
42+
43+
display: flex;
44+
flex-direction: column;
45+
gap: var(--timeline-gap);
46+
}
47+
48+
/* spine of the timeline */
49+
.timeline::before {
50+
content: "";
51+
width: 4px;
52+
height: 200%; /* TODO: find better solution to span spine over the sections */
53+
position: absolute;
54+
left: 50%;
55+
transform: translateX(-50%);
56+
background-color: var(--color-primary);
57+
z-index: 3; /* above potential dividers */
58+
}
59+
60+
li {
61+
display: flex;
62+
flex-direction: column;
63+
box-sizing: border-box;
64+
padding: 1rem;
65+
background: #fcfaf3;
66+
width: 45%;
67+
box-shadow: 0px 15px 30px -25px rgba(0, 0, 0, 0.5);
68+
}
69+
70+
li::after {
71+
content: "";
72+
width: 20px;
73+
height: 20px;
74+
border-radius: 50%;
75+
border-width: 4px;
76+
border-style: solid;
77+
border-color: var(--color-primary);
78+
background: var(--color-white);
79+
position: absolute;
80+
left: 50%;
81+
transform: translateX(-50%);
82+
z-index: 5; /* above spine */
83+
}
84+
85+
ol li:nth-child(even) {
86+
align-self: flex-end;
87+
}
88+
</style>

src/content.config.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,22 @@ const galleriesCollection = defineCollection({
138138
),
139139
});
140140

141+
const formationCollection = defineCollection({
142+
loader: i18nContentLoader({ pattern: "**/[^_]*.yaml", base: "./src/content/formation" }),
143+
schema: extendI18nLoaderSchema(
144+
z.object({
145+
items: localized(
146+
z.array(
147+
z.object({
148+
title: z.string(),
149+
text: z.string(),
150+
}),
151+
),
152+
),
153+
}),
154+
),
155+
});
156+
141157
export const collections = {
142158
navigation: navigationCollection,
143159
pages: pagesCollection,
@@ -148,4 +164,5 @@ export const collections = {
148164
technologies: technologiesCollection,
149165
team: teamCollection,
150166
galleries: galleriesCollection,
167+
formation: formationCollection,
151168
};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
items:
2+
de:
3+
- title: Lorem
4+
text: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
5+
- title: Lorem
6+
text: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
7+
en:
8+
- title: Lorem
9+
text: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
10+
- title: Lorem
11+
text: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod

src/content/formation/office.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
items:
2+
de:
3+
- title: Lorem
4+
text: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
5+
- title: Lorem
6+
text: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
7+
en:
8+
- title: Lorem
9+
text: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
10+
- title: Lorem
11+
text: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod

src/content/pages/de/past/formation.mdx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,22 @@
22
path: entstehung
33
title: Entstehung
44
---
5+
6+
import FormationSection from "../../../../layouts/sections/FormationSection.astro";
7+
import Divider from "../../../../components/Divider.astro";
8+
9+
<FormationSection class="spotlight" key="founding">
10+
<h2 name="title">Gründung</h2>
11+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
12+
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
13+
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum
14+
</FormationSection>
15+
16+
<Divider firstSegmentColor="var(--color-white)" fixAntialiasingBottom />
17+
18+
<FormationSection class="white-background" key="office">
19+
<h2 name="title">Erstes Büro</h2>
20+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
21+
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
22+
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum
23+
</FormationSection>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
import { currentLocale } from "astro-nanostores-i18n:runtime";
3+
import Timeline from "../../components/Timeline.astro";
4+
import { getCollection } from "astro:content";
5+
6+
type Props = {
7+
key: string;
8+
class?: string;
9+
};
10+
11+
const { key, class: className } = Astro.props;
12+
13+
const locale = currentLocale.get();
14+
15+
const timelineCollection = await getCollection("formation", (entry) => entry.data.locale === locale);
16+
17+
const formationData = timelineCollection
18+
.filter((t) => t.id.includes(key))
19+
.flatMap((t) => {
20+
if (Array.isArray(t.data.items)) {
21+
return t.data.items.map((item) => ({ ...item }));
22+
}
23+
return [];
24+
});
25+
---
26+
27+
<section class:list={[className]}>
28+
<div>
29+
<slot name="title" />
30+
<slot />
31+
</div>
32+
<Timeline elements={formationData} />
33+
</section>
34+
35+
<style>
36+
section {
37+
display: grid;
38+
column-gap: 1.5rem;
39+
grid-template-columns: 60% 40%;
40+
}
41+
</style>

0 commit comments

Comments
 (0)