From 9a8991aa7f9139a6fbd01f8a2eb277a2017e05b3 Mon Sep 17 00:00:00 2001 From: DrMint <29893320+DrMint@users.noreply.github.com> Date: Mon, 27 May 2024 15:08:19 +0200 Subject: [PATCH] New design for timeline --- src/pages/[locale]/api/timeline/partial.astro | 53 ++++++++++----- .../timeline/_components/TimelineEvent.astro | 66 ++++++++++++------- .../TimelineEventTranslation.astro | 33 ---------- .../TimelineLanguageOverride.astro | 11 ++-- .../timeline/_components/TimelineNote.astro | 14 +++- .../_components/TimelineSourcesButton.astro | 21 +++--- .../timeline/_components/TimelineYear.astro | 46 +++++++++---- 7 files changed, 143 insertions(+), 101 deletions(-) delete mode 100644 src/pages/[locale]/timeline/_components/TimelineEventTranslation.astro diff --git a/src/pages/[locale]/api/timeline/partial.astro b/src/pages/[locale]/api/timeline/partial.astro index 77b328e..bacdd62 100644 --- a/src/pages/[locale]/api/timeline/partial.astro +++ b/src/pages/[locale]/api/timeline/partial.astro @@ -1,6 +1,7 @@ --- +import Card from "components/Card.astro"; import MasoTarget from "components/Maso/MasoTarget.astro"; -import TimelineEventTranslation from "pages/[locale]/timeline/_components/TimelineEventTranslation.astro"; +import RichText from "components/RichText/RichText.astro"; import TimelineLanguageOverride from "pages/[locale]/timeline/_components/TimelineLanguageOverride.astro"; import TimelineNote from "pages/[locale]/timeline/_components/TimelineNote.astro"; import TimelineSourcesButton from "pages/[locale]/timeline/_components/TimelineSourcesButton.astro"; @@ -32,20 +33,25 @@ const { title, description, notes, credits } = getLocalizedMatch(translations); {/* ------------------------------------------- HTML ------------------------------------------- */} -
- -
- - {notes && } - language)} - currentLang={lang} - credits={credits} - getPartialUrl={(locale) => - getLocalizedUrl(`/api/timeline/partial?id=${id}&index=${index}&lang=${locale}`)} - /> + +
+
+ {title &&

{title}

} + {description && } +
+
+ + {notes && } + language)} + currentLang={lang} + credits={credits} + getPartialUrl={(locale) => + getLocalizedUrl(`/api/timeline/partial?id=${id}&index=${index}&lang=${locale}`)} + /> +
-
+ {/* ------------------------------------------- CSS -------------------------------------------- */} @@ -55,12 +61,27 @@ const { title, description, notes, credits } = getLocalizedMatch(translations); display: flex; flex-direction: column; gap: 1em; + padding: 1em; + + & > #content { + padding-left: 0.9em; + padding-right: 1.2em; + padding-top: 0.5em; + + display: flex; + flex-direction: column; + gap: 0.5em; + + & > h4 { + line-height: 1.2; + max-width: 35rem; + } + } & > #bottom { display: flex; place-items: start; - gap: 0.3em; - font-size: 85%; + gap: 0.4em; } } diff --git a/src/pages/[locale]/timeline/_components/TimelineEvent.astro b/src/pages/[locale]/timeline/_components/TimelineEvent.astro index 3c4f182..e1d651b 100644 --- a/src/pages/[locale]/timeline/_components/TimelineEvent.astro +++ b/src/pages/[locale]/timeline/_components/TimelineEvent.astro @@ -8,23 +8,35 @@ interface Props { displayDate: boolean; } -const { event, displayDate } = Astro.props; +const { + event, + event: { date, events }, + displayDate, +} = Astro.props; const { formatTimelineDate, t } = await getI18n(Astro.locals.currentLocale); const displayedDate = - !event.date.month && !event.date.day - ? t("timeline.year.during", { year: formatTimelineDate(event.date) }) - : formatTimelineDate(event.date); + !date.month && !date.day + ? t("timeline.year.during", { year: formatTimelineDate(date) }) + : formatTimelineDate(date); + +const multiple = displayDate && events.length > 1; --- {/* ------------------------------------------- HTML ------------------------------------------- */}
- {displayDate &&

{displayedDate}

} + { + displayDate && ( +

+ {displayedDate} +

+ ) + } -
+
{ - event.events.map((_, index) => ( + events.map((_, index) => ( .event-container { - &:has(h3) > div { - border-left: 1px solid var(--color-base-600); - padding-left: 1em; - padding-block: 1em; - } - - & > div { - display: flex; - flex-direction: column; - gap: 2em; - } - & > h3 { - padding-bottom: 0.3em; - padding-inline: 0.2em; - color: var(--color-base-700); - border-bottom: 1px solid var(--color-base-600); - width: fit-content; + color: var(--color-base-600); + line-height: 2; + margin-bottom: 0.1em; + margin-left: 16px; + + &.multiple { + margin-left: 16px; + } + } + + & > .date-container { + display: flex; + align-items: start; + flex-direction: column; + gap: 1em; + + &.multiple { + border-left: 1px solid; + border-top: 1px solid; + border-color: var(--color-base-450); + border-radius: calc(26px); + padding: 1em; + } } } diff --git a/src/pages/[locale]/timeline/_components/TimelineEventTranslation.astro b/src/pages/[locale]/timeline/_components/TimelineEventTranslation.astro deleted file mode 100644 index d67461f..0000000 --- a/src/pages/[locale]/timeline/_components/TimelineEventTranslation.astro +++ /dev/null @@ -1,33 +0,0 @@ ---- -import RichText from "components/RichText/RichText.astro"; -import type { RichTextContent } from "src/shared/payload/payload-sdk"; - -interface Props { - title?: string | undefined; - description?: RichTextContent | undefined; -} - -const { title, description } = Astro.props; ---- - -{/* ------------------------------------------- HTML ------------------------------------------- */} - -
- {title &&

{title}

} - {description && } -
- -{/* ------------------------------------------- CSS -------------------------------------------- */} - - diff --git a/src/pages/[locale]/timeline/_components/TimelineLanguageOverride.astro b/src/pages/[locale]/timeline/_components/TimelineLanguageOverride.astro index 0334740..39f753d 100644 --- a/src/pages/[locale]/timeline/_components/TimelineLanguageOverride.astro +++ b/src/pages/[locale]/timeline/_components/TimelineLanguageOverride.astro @@ -35,25 +35,28 @@ const { t } = await getI18n(Astro.locals.currentLocale); {credits.length > 0 && }
-
+
+ {/* ------------------------------------------- CSS -------------------------------------------- */} diff --git a/src/pages/[locale]/timeline/_components/TimelineSourcesButton.astro b/src/pages/[locale]/timeline/_components/TimelineSourcesButton.astro index 61088f5..777d393 100644 --- a/src/pages/[locale]/timeline/_components/TimelineSourcesButton.astro +++ b/src/pages/[locale]/timeline/_components/TimelineSourcesButton.astro @@ -20,7 +20,7 @@ const { t } = await getI18n(Astro.locals.currentLocale); sources.length === 0 ? (
-

{t("timeline.eventFooter.sources", { count: sources.length })}

+

{t("timeline.eventFooter.sources", { count: sources.length })}

) : ( @@ -29,10 +29,10 @@ const { t } = await getI18n(Astro.locals.currentLocale); ))}
-
+
+

{t("timeline.eventFooter.sources", { count: sources.length })}

+ ) } @@ -40,11 +40,16 @@ const { t } = await getI18n(Astro.locals.currentLocale); {/* ------------------------------------------- CSS -------------------------------------------- */}