Skip to content

Commit

Permalink
nedgrader opentelemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
ssaegrov committed Dec 16, 2024
1 parent f1a20db commit 9b4d0e3
Show file tree
Hide file tree
Showing 3 changed files with 436 additions and 656 deletions.
32 changes: 20 additions & 12 deletions app/components/jul/Adventslys.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,36 @@ export function Adventslys() {
const [forsteAdventDato, andreAdventDato, tredjeAdventDato, fjerdeAdventDato] =
hentAdventsDatoer(aar);

const erForsteAdvent = dagensDato >= forsteAdventDato && dagensDato < andreAdventDato;
const erAndreAdvent = dagensDato >= andreAdventDato && dagensDato < tredjeAdventDato;
const erTredjeAdvent = dagensDato >= tredjeAdventDato && dagensDato < fjerdeAdventDato;
const erFjerdeAdvent = dagensDato >= fjerdeAdventDato;
const harTent = {
forsteLys: dagensDato >= forsteAdventDato,
andreLys: dagensDato >= andreAdventDato,
tredjeLys: dagensDato >= tredjeAdventDato,
fjerdeLys: dagensDato >= fjerdeAdventDato,
};

return (
<div
className={classnames(styles.container, {
[styles.forsteAdvent]: erForsteAdvent,
[styles.andreAdvent]: erAndreAdvent,
[styles.tredjeAdvent]: erTredjeAdvent,
[styles.fjerdeAdvent]: erFjerdeAdvent,
[styles.forsteAdvent]: harTent.forsteLys && !harTent.andreLys,
[styles.andreAdvent]: harTent.andreLys && !harTent.tredjeLys,
[styles.tredjeAdvent]: harTent.tredjeLys && !harTent.fjerdeLys,
[styles.fjerdeAdvent]: harTent.fjerdeLys,
})}
>
{erAndreAdvent ? <CandleMeltSvg /> : erForsteAdvent ? <CandleLightMeltSvg /> : <CandleSvg />}
{erTredjeAdvent ? <CandleMeltSvg /> : erAndreAdvent ? <CandleLightMeltSvg /> : <CandleSvg />}
{erFjerdeAdvent ? <CandleMeltSvg /> : erTredjeAdvent ? <CandleLightMeltSvg /> : <CandleSvg />}
{erFjerdeAdvent ? <CandleLightMeltSvg /> : <CandleSvg />}
{hentLysSvg(harTent.forsteLys, harTent.andreLys)}
{hentLysSvg(harTent.andreLys, harTent.tredjeLys)}
{hentLysSvg(harTent.tredjeLys, harTent.fjerdeLys)}
{hentLysSvg(harTent.fjerdeLys, false)}
</div>
);
}

function hentLysSvg(erTent: boolean, harSmeltet: boolean) {
if (harSmeltet) return <CandleMeltSvg />;
if (erTent) return <CandleLightMeltSvg />;
return <CandleSvg />;
}

function hentAdventsDatoer(aar: number) {
const julemorgen = new Date(aar, 11, 25);
const julemorgenDag = julemorgen.getDay(); // Day of the week for Christmas (0 = Sunday, 6 = Saturday)
Expand Down
Loading

0 comments on commit 9b4d0e3

Please sign in to comment.