1
Fork 0

Add the BigDate component.

This commit is contained in:
Bauke 2023-06-04 12:18:23 +02:00
parent a89c43efd2
commit 5969b023bb
Signed by: Bauke
GPG Key ID: C1C0F29952BCF558
2 changed files with 33 additions and 0 deletions

View File

@ -0,0 +1,28 @@
// Third-party imports.
import {Component} from "preact";
// First-party imports.
import {type SharedProps} from "./shared.js";
export class BigDate extends Component<SharedProps> {
render() {
const {today} = this.props;
const date = [
["year", today.date.getFullYear().toString()],
["month", today.paddedMonth()],
["day", today.paddedDay()],
]
.map(([name, value]) => <span class={name}>{value}</span>)
// Add a dash between each part of the date.
// eslint-disable-next-line unicorn/no-array-reduce
.reduce((accumulator, current) => (
<>
{accumulator}
<span class="dash">-</span>
{current}
</>
));
return <h1 class="big-date">{date}</h1>;
}
}

View File

@ -0,0 +1,5 @@
import {type DateWrapper} from "../date/date.js";
export type SharedProps = {
today: DateWrapper;
};