diff --git a/src/components/Chronology/ChronologyItem.tsx b/src/components/Chronology/ChronologyItem.tsx
new file mode 100644
index 0000000..68f234c
--- /dev/null
+++ b/src/components/Chronology/ChronologyItem.tsx
@@ -0,0 +1,51 @@
+import styles from "styles/Chronology/ChronologyItemDisplay.module.css";
+import {
+ ChronologyItem,
+ ChronologyItemsEvent,
+ } from "queries/chronology/overview";
+
+
+export default function ChronologyItemDisplay(pageProps: ChronologyItem) {
+
+ function generateAnchor(year: number, month: number, day:number, event?: number): string {
+ let result: string = "";
+ result += year;
+ if (month) result += '-' + month;
+ if (day) result += '-' + day;
+ return result;
+ }
+
+ function generateDate(displayed_date: string, year: number, month: number, day:number) {
+ let result: string = "";
+ if (displayed_date) {
+ result += displayed_date;
+ } else {
+ result += year;
+ }
+ if (month) result += '/' + month;
+ if (day) result += '/' + day;
+ return result;
+ }
+
+ return (
+
+
{generateDate(item.attributes.displayed_date, item.attributes.year, item.attributes.month, item.attributes.day)}
+ {item.attributes.events.map((event: ChronologyItemsEvent) => (
+
+
+ {event.translations.length ? event.translations[0].title : ""}
+
+
+ {event.translations.length
+ ? event.translations[0].description
+ : ""}
+ {event.translations.length ? event.translations[0].note : ""}
+
+
+ {event.source.data ? event.source.data.attributes.name : ""}
+
+
+ ))}
+
+ );
+}
diff --git a/src/components/Chronology/ChronologyItemComponent.tsx b/src/components/Chronology/ChronologyItemComponent.tsx
new file mode 100644
index 0000000..f8cbd1e
--- /dev/null
+++ b/src/components/Chronology/ChronologyItemComponent.tsx
@@ -0,0 +1,82 @@
+import styles from "styles/Chronology/ChronologyItemComponent.module.css";
+import {
+ ChronologyItem,
+ ChronologyItemsEvent,
+ ChronologyItemsEventTranslation,
+} from "queries/chronology/overview";
+
+export default function ChronologyItemComponent(pageProps: ChronologyItem) {
+ function generateAnchor(
+ year: number,
+ month: number,
+ day: number,
+ event?: number
+ ): string {
+ let result: string = "";
+ result += year;
+ if (month) result += "-" + month;
+ if (day) result += "-" + day;
+ return result;
+ }
+
+ function generateYear(displayed_date: string, year: number): string {
+ if (displayed_date) {
+ return displayed_date;
+ } else {
+ return year.toString();
+ }
+ }
+
+ function generateDate(month: number, day: number): string {
+ let result: string = "";
+ if (month) result += month.toString().padStart(2, "0");
+ if (day) result += "/" + day.toString().padStart(2, "0");
+ return result;
+ }
+
+ return (
+
+
+ {generateYear(
+ pageProps.attributes.displayed_date,
+ pageProps.attributes.year
+ )}
+
+
+
+ {generateDate(pageProps.attributes.month, pageProps.attributes.day)}
+
+
+
+ {pageProps.attributes.events.map((event: ChronologyItemsEvent) => (
+
+ {event.translations.map(
+ (translation: ChronologyItemsEventTranslation) => (
+ <>
+
{translation.title}
+
1 ? styles.bulletItem : ""}>
+ {translation.description}
+ {translation.note}
+
+ >
+ )
+ )}
+
+
+ {event.source.data
+ ? "(" + event.source.data.attributes.name + ")"
+ : ""}
+
+
+ ))}
+
+
+ );
+}
diff --git a/src/components/Chronology/ChronologyYearComponent.tsx b/src/components/Chronology/ChronologyYearComponent.tsx
new file mode 100644
index 0000000..ed4e4da
--- /dev/null
+++ b/src/components/Chronology/ChronologyYearComponent.tsx
@@ -0,0 +1,23 @@
+import styles from "styles/Chronology/ChronologyYearComponent.module.css";
+import {
+ ChronologyItem
+} from "queries/chronology/overview";
+import ChronologyItemComponent from "components/Chronology/ChronologyItemComponent";
+
+type ChronologyYearComponentProps = {
+ items: ChronologyItem[];
+}
+
+export default function ChronologyYearComponent(props: ChronologyYearComponentProps) {
+ return (
+
+ {props.items.map((item: ChronologyItem, index: number) => (
+
+ ))}
+
+ );
+}
diff --git a/src/pages/chronology/overview.tsx b/src/pages/chronology/overview.tsx
index 6c22034..b8212ac 100644
--- a/src/pages/chronology/overview.tsx
+++ b/src/pages/chronology/overview.tsx
@@ -3,11 +3,14 @@ import ContentPanel from "components/Panels/ContentPanel";
import SubPanel from "components/Panels/SubPanel";
import ReturnButton from "components/Panels/ReturnButton";
import NavOption from "components/Panels/NavOption";
+import ChronologyItemComponent from "components/Chronology/ChronologyItemComponent";
+import ChronologyYearComponent from "components/Chronology/ChronologyYearComponent";
import {
getChronologyItems,
getChronologyEras,
ChronologyItem,
ChronologyEra,
+ ChronologyItemsEvent,
} from "queries/chronology/overview";
type Props = {
@@ -16,26 +19,86 @@ type Props = {
};
export default function ChronologyOverview(props: Props): JSX.Element {
+
+ let previousYear = -1;
+
+ let chronologyItemYearGroups: ChronologyItem[][] = [];
+
+
+ // Group by year the Chronology items
+ props.chronologyItems.map((item: ChronologyItem) => {
+ if (!chronologyItemYearGroups.hasOwnProperty(item.attributes.year)) {
+ chronologyItemYearGroups[item.attributes.year] = [item];
+ } else {
+ chronologyItemYearGroups[item.attributes.year].push(item);
+ }
+ });
+
+ console.log(chronologyItemYearGroups);
+
+
+
return (
<>
+ {props.chronologyEras.map((era: ChronologyEra) => {
+ if (era.id == undefined) console.warn(era);
+ })}
+
- {console.log(props.chronologyEras)}
-
{props.chronologyEras.map((era: ChronologyEra) => (
))}
+
+ {props.chronologyItems.map((item: ChronologyItem) => {
+ if (!item.attributes.year)
+ console.warn("Missing year on ChronologyItem (" + item.id + ")");
+ item.attributes.events.map((event: ChronologyItemsEvent) => {
+ if (!event.source.data) {
+ console.warn(
+ "Missing Source on ChronologyItem (" +
+ item.id +
+ "), Event (" +
+ event.id +
+ ")"
+ );
+ }
+ if (event.translations.length !== 1) {
+ console.warn(
+ "Wrong number of Translation(s) on ChronologyItem (" +
+ item.id +
+ "), Event (" +
+ event.id +
+ ")"
+ );
+ }
+ });
+ })}
+ {chronologyItemYearGroups.map((items: ChronologyItem[], index: number) => {
+ return (
+
+ )
+
+ })}
+
>
);
}
@@ -43,7 +106,7 @@ export default function ChronologyOverview(props: Props): JSX.Element {
export const getStaticProps: GetStaticProps = async (context) => {
return {
props: {
- /*chronologyItems: await getChronologyItems(context.locale),*/
+ chronologyItems: await getChronologyItems(context.locale),
chronologyEras: await getChronologyEras(context.locale),
},
};
diff --git a/src/queries/chronology/overview.ts b/src/queries/chronology/overview.ts
index f222860..978ef83 100644
--- a/src/queries/chronology/overview.ts
+++ b/src/queries/chronology/overview.ts
@@ -2,36 +2,76 @@ import { queryGraphQL } from "queries/helpers";
export type ChronologyItem = {
id: string;
+ attributes: ChronologyItemAttributes;
+};
+
+export type ChronologyItemAttributes = {
year: number;
month: number;
day: number;
- translations: ChronologyItemsTranslation[];
+ displayed_date: string;
+ events: ChronologyItemsEvent[];
+}
+
+export type ChronologyItemsEvent = {
+ id: string;
+ source: Source
+ translations: ChronologyItemsEventTranslation[];
};
-export type ChronologyItemsTranslation = {
+export type ChronologyItemsEventTranslation = {
title: string;
-};
+ description: string;
+ note: string;
+ status: string;
+}
+
+export type Source = {
+ data: {
+ attributes: {
+ name: string;
+ }
+ }
+}
export async function getChronologyItems(
- languages_code: String | undefined
+ language_code: String | undefined
): Promise {
return (
await queryGraphQL(
`
- {
- chronology_items {
- id
- year
- month
- day
- translations(filter: { languages_code: { code: { _eq: "` + languages_code + `" } } }) {
- title
+ {
+ chronologyItems (pagination: {limit: -1}, sort: ["year:asc", "month:asc", "day:asc"]) {
+ data {
+ id
+ attributes {
+ year
+ month
+ day
+ displayed_date
+ events {
+ id
+ source {
+ data {
+ attributes {
+ name
+ }
}
+ }
+ translations(filters: { language: { code: { eq: "` + language_code + `" } } }) {
+ title
+ description
+ note
+ status
+ }
}
+ }
}
- `
+ }
+ }
+ `
)
- ).chronology_items;
+ ).chronologyItems.data;
}
export type ChronologyEra = {
@@ -40,9 +80,9 @@ export type ChronologyEra = {
};
export type ChronologyEraAttributes = {
+ slug: string;
starting_year: number;
ending_year: number;
- slug: string;
title: ChronologyEraTranslation[];
}
@@ -59,7 +99,9 @@ export async function getChronologyEras(
{
chronologyEras {
data {
+ id
attributes {
+ slug
starting_year
ending_year
title (filters: {language: {code: {eq: "` + language_code + `"}}}){
diff --git a/src/styles/Chronology/ChronologyItemComponent.module.css b/src/styles/Chronology/ChronologyItemComponent.module.css
new file mode 100644
index 0000000..d33b4b5
--- /dev/null
+++ b/src/styles/Chronology/ChronologyItemComponent.module.css
@@ -0,0 +1,62 @@
+.chronologyItem {
+ display: grid;
+ grid-template-areas:
+ "year events"
+ "date events"
+ ;
+ grid-column-gap: 1em;
+ place-content: start;
+ grid-template-rows: auto 1fr;
+ grid-template-columns: 4em;
+ margin-bottom: 1.5em;
+}
+
+.chronologyItem:target {
+ background-color: var(--color-main-base);
+ border-radius: 1em;
+ padding: 1em 2em 1em 1.5em;
+}
+
+.chronologyItem > .year {
+ grid-area: year;
+ margin: 0;
+ font-weight: bold;
+}
+
+.chronologyItem > .date {
+ grid-area: date;
+ margin: 0;
+}
+
+.chronologyItem > .events {
+ grid-area: events;
+}
+
+.event {
+ margin-bottom: 1em;
+}
+
+.event > h3 {
+ margin: 0;
+}
+
+.event > p {
+ margin: 0;
+}
+
+.event > .bulletItem::before {
+ content: "⁃";
+ color: var(--color-main-dark);
+ display: inline-block;
+ width: 1em;
+ margin-left: -1em
+}
+
+.event > .bulletItem {
+ margin-top: .5em;
+}
+
+.source {
+ color: var(--color-main-dark);
+ font-size: 80%;
+}
\ No newline at end of file
diff --git a/src/styles/Panels/Panels.module.css b/src/styles/Panels/Panels.module.css
index c65d340..3bc2c70 100644
--- a/src/styles/Panels/Panels.module.css
+++ b/src/styles/Panels/Panels.module.css
@@ -9,6 +9,7 @@
grid-row-gap: 0.5em;
place-content: start center;
scrollbar-width: none;
+ scroll-behavior: smooth;
}
.panel::-webkit-scrollbar {
diff --git a/src/styles/globals.css b/src/styles/globals.css
index 0240cd4..9f91a81 100644
--- a/src/styles/globals.css
+++ b/src/styles/globals.css
@@ -74,4 +74,13 @@ button {
button:hover {
background: var(--color-main-dark);
color: var(--color-main-light);
+}
+
+*::selection {
+ background-color: var(--color-main-dark);
+ color: var(--color-main-light)
+}
+
+*:target {
+ scroll-margin-top: 1em;
}
\ No newline at end of file