Skip to content

Commit

Permalink
Fix experiences really spanning multiple rows as they should
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaschlegel committed Oct 11, 2024
1 parent b4e69c5 commit 1be61c5
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions app/cv/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@ const CvPage = async () => {
const years = [];
const startYear = startDate.getFullYear();
const endYear = endDate.getFullYear();

for (let year = startYear; year <= endYear; year++) {
years.push(year);
allYearsSet.add(year);
}

return years;
};

Expand Down Expand Up @@ -135,6 +137,7 @@ const CvPage = async () => {
educationTimeline[year] = [];
});

// Assigning layers to ensure no overlap in a given year
const assignLayers = (entries: Entry[], timeline: ColumnTimeline) => {
entries.forEach((entry) => {
entry.years.forEach((year) => {
Expand All @@ -147,6 +150,7 @@ const CvPage = async () => {
return entriesInYear.some((e) => e.layer === checkLayer);
};

// Find an available layer (row) for the entry in that year
while (yearEntries && isLayerOccupied(layer, yearEntries)) {
layer++;
}
Expand Down Expand Up @@ -217,15 +221,10 @@ const CvPage = async () => {
{sortedWorkEntries.map((entry) => {
const startYear = entry.startDate.getFullYear();
const endYear = entry.endDate.getFullYear();
const rowStart =
(yearRowStart[startYear] ?? 0) +
(workTimeline[startYear]?.find((e) => e.entry.id === entry.id)
?.layer ?? 0);
const rowStart = yearRowStart[endYear];
const rowEnd =
(yearRowStart[endYear] ?? 0) +
(workTimeline[endYear]?.find((e) => e.entry.id === entry.id)
?.layer ?? 0) +
1;
(yearRowStart[startYear] ?? 0) +
(totalLayersPerYear[startYear] ?? 0);

return (
<div
Expand Down Expand Up @@ -256,14 +255,10 @@ const CvPage = async () => {
{sortedEducationEntries.map((entry) => {
const startYear = entry.startDate.getFullYear();
const endYear = entry.endDate.getFullYear();
const startLayer =
educationTimeline[startYear]?.find((e) => e.entry.id === entry.id)
?.layer ?? 0;
const rowStart = (yearRowStart[startYear] ?? 0) + startLayer;
const endLayer =
educationTimeline[endYear]?.find((e) => e.entry.id === entry.id)
?.layer ?? 0;
const rowEnd = (yearRowStart[endYear] ?? 0) + endLayer + 1;
const rowStart = yearRowStart[endYear];
const rowEnd =
(yearRowStart[startYear] ?? 0) +
(totalLayersPerYear[startYear] ?? 0);

return (
<div
Expand All @@ -290,7 +285,7 @@ const CvPage = async () => {
);
})}

{/* Iterate over each year */}
{/* Render publications */}
{allYears.map((year) => {
const yearPublications = publications.filter(
(pub) => parseDate(pub.date).getFullYear() === year,
Expand Down

0 comments on commit 1be61c5

Please sign in to comment.