Visual improvement to scrollbars and chronology

This commit is contained in:
DrMint 2021-12-25 16:04:03 +01:00
parent 6f37d85c85
commit 99ffb1ccc7
7 changed files with 113 additions and 39 deletions

View File

@ -5,7 +5,14 @@ import {
ChronologyItemsEventTranslation, ChronologyItemsEventTranslation,
} from "queries/chronology/overview"; } from "queries/chronology/overview";
export default function ChronologyItemComponent(pageProps: ChronologyItem) { export type ChronologyItemComponentProps = {
item: ChronologyItem;
displayYear: boolean;
};
export default function ChronologyItemComponent(
props: ChronologyItemComponentProps
) {
function generateAnchor( function generateAnchor(
year: number, year: number,
month: number, month: number,
@ -14,8 +21,8 @@ export default function ChronologyItemComponent(pageProps: ChronologyItem) {
): string { ): string {
let result: string = ""; let result: string = "";
result += year; result += year;
if (month) result += "-" + month; if (month) result += "-" + month.toString().padStart(2, "0");
if (day) result += "-" + day; if (day) result += "-" + day.toString().padStart(2, "0");
return result; return result;
} }
@ -28,9 +35,29 @@ export default function ChronologyItemComponent(pageProps: ChronologyItem) {
} }
function generateDate(month: number, day: number): string { function generateDate(month: number, day: number): string {
let lut = [
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec",
];
let result: string = ""; let result: string = "";
if (month) result += month.toString().padStart(2, "0"); if (month) {
if (day) result += "/" + day.toString().padStart(2, "0"); result += lut[month - 1];
if (day) {
result += " " + day.toString().padStart(2, "0");
}
}
return result; return result;
} }
@ -38,33 +65,47 @@ export default function ChronologyItemComponent(pageProps: ChronologyItem) {
<div <div
className={styles.chronologyItem} className={styles.chronologyItem}
id={generateAnchor( id={generateAnchor(
pageProps.attributes.year, props.item.attributes.year,
pageProps.attributes.month, props.item.attributes.month,
pageProps.attributes.day props.item.attributes.day
)} )}
> >
<p className={styles.year}> {props.displayYear ? (
{generateYear( <p className={styles.year}>
pageProps.attributes.displayed_date, {generateYear(
pageProps.attributes.year props.item.attributes.displayed_date,
)} props.item.attributes.year
</p> )}
</p>
) : (
""
)}
<p className={styles.date}> <p className={styles.date}>
{generateDate(pageProps.attributes.month, pageProps.attributes.day)} {generateDate(props.item.attributes.month, props.item.attributes.day)}
</p> </p>
<div className={styles.events}> <div className={styles.events}>
{pageProps.attributes.events.map((event: ChronologyItemsEvent) => ( {props.item.attributes.events.map((event: ChronologyItemsEvent) => (
<div className={styles.event} key={event.id}> <div className={styles.event} key={event.id}>
{event.translations.map( {event.translations.map(
(translation: ChronologyItemsEventTranslation) => ( (translation: ChronologyItemsEventTranslation) => (
<> <>
<h3>{translation.title}</h3> {translation.title ? <h3>{translation.title}</h3> : ""}
<p className={event.translations.length > 1 ? styles.bulletItem : ""}>
{translation.description} {translation.description ? (
<em> {translation.note}</em> <p
</p> className={
event.translations.length > 1 ? styles.bulletItem : ""
}
>
{translation.description}
</p>
) : (
""
)}
{translation.note ? <em>{"Notes: " + translation.note}</em> : ""}
</> </>
) )
)} )}

View File

@ -10,12 +10,12 @@ type ChronologyYearComponentProps = {
export default function ChronologyYearComponent(props: ChronologyYearComponentProps) { export default function ChronologyYearComponent(props: ChronologyYearComponentProps) {
return ( return (
<div> <div className={styles.chronologyYear} id={props.items.length > 1 ? props.items[0].attributes.year.toString() : undefined}>
{props.items.map((item: ChronologyItem, index: number) => ( {props.items.map((item: ChronologyItem, index: number) => (
<ChronologyItemComponent <ChronologyItemComponent
key={item.id} key={index}
id={item.id} item={item}
attributes={item.attributes} displayYear={index===0}
/> />
))} ))}
</div> </div>

View File

@ -32,11 +32,7 @@ export default function ChronologyOverview(props: Props): JSX.Element {
} else { } else {
chronologyItemYearGroups[item.attributes.year].push(item); chronologyItemYearGroups[item.attributes.year].push(item);
} }
}); });
console.log(chronologyItemYearGroups);
return ( return (
<> <>
@ -77,9 +73,9 @@ export default function ChronologyOverview(props: Props): JSX.Element {
")" ")"
); );
} }
if (event.translations.length !== 1) { if (event.translations.length < 1) {
console.warn( console.warn(
"Wrong number of Translation(s) on ChronologyItem (" + "Missing Translation on ChronologyItem (" +
item.id + item.id +
"), Event (" + "), Event (" +
event.id + event.id +

View File

@ -8,40 +8,40 @@
place-content: start; place-content: start;
grid-template-rows: auto 1fr; grid-template-rows: auto 1fr;
grid-template-columns: 4em; grid-template-columns: 4em;
margin-bottom: 1.5em; padding: 1em 2em;
} }
.chronologyItem:target { .chronologyItem:target {
background-color: var(--color-main-base); background-color: var(--color-main-base);
border-radius: 1em; border-radius: 1em;
padding: 1em 2em 1em 1.5em;
} }
.chronologyItem > .year { .chronologyItem > .year {
grid-area: year; grid-area: year;
margin: 0; margin: 0;
font-weight: bold; font-weight: bold;
font-size: 1.3em;
margin-top: -0.25em;
} }
.chronologyItem > .date { .chronologyItem > .date {
grid-area: date; grid-area: date;
margin: 0; margin: 0;
color: var(--color-main-dark);
font-size: 0.9em;
} }
.chronologyItem > .events { .chronologyItem > .events {
grid-area: events; grid-area: events;
} }
.event {
margin-bottom: 1em;
}
.event > h3 { .event > h3 {
margin: 0; margin: 0;
} }
.event > p { .event > p {
margin: 0; margin: 0;
white-space: break-spaces;
} }
.event > .bulletItem::before { .event > .bulletItem::before {
@ -56,6 +56,10 @@
margin-top: .5em; margin-top: .5em;
} }
.event ~ .event {
margin-top: 1em;
}
.source { .source {
color: var(--color-main-dark); color: var(--color-main-dark);
font-size: 80%; font-size: 80%;

View File

@ -0,0 +1,5 @@
.chronologyYear:target {
background-color: var(--color-main-base);
border-radius: 1em;
padding: 1em 2em 1em 1.5em;
}

View File

@ -1,9 +1,15 @@
.panel { .panel {
padding-top: 5rem; padding-top: 5rem;
scrollbar-width: thin;
border: none;
} }
.panelInside { .panelInside {
max-width: 50rem; max-width: 50rem;
text-align: justify; text-align: justify;
text-justify: inter-word; text-justify: inter-word;
}
.panel::-webkit-scrollbar {
display: unset;
} }

View File

@ -76,11 +76,33 @@ button:hover {
color: var(--color-main-light); color: var(--color-main-light);
} }
/* SCROLLBARS STYLING */
* {
scrollbar-color: var(--color-main-dark) transparent;
}
*::selection { *::selection {
background-color: var(--color-main-dark); background-color: var(--color-main-dark);
color: var(--color-main-light) color: var(--color-main-light);
border-radius: 1em;
} }
*:target { *:target {
scroll-margin-top: 1em; scroll-margin-top: 1em;
}
*::-webkit-scrollbar {
width: 12px; /* width of the entire scrollbar */
}
*::-webkit-scrollbar-track {
background: transparent; /* color of the tracking area */
}
*::-webkit-scrollbar-thumb {
background-color: var(--color-main-dark); /* color of the scroll thumb */
border-radius: 100vmax; /* roundness of the scroll thumb */
border: 3px solid var(--color-main-light); /* creates padding around scroll thumb */
} }