diff options
author | Yuqian Yang <crupest@crupest.life> | 2025-02-24 02:18:20 +0800 |
---|---|---|
committer | Yuqian Yang <crupest@crupest.life> | 2025-02-26 02:21:41 +0800 |
commit | 0c885ba1bf30ce8308880f926be85b6f5a499fa6 (patch) | |
tree | 25f42a9386f760c9d7d47d9b154e4a0089e49dff /services/docker/nginx/sites/www/src/main.ts | |
parent | dc7b27c713351066e20947ea6d1adb80aeb68d9f (diff) | |
download | crupest-0c885ba1bf30ce8308880f926be85b6f5a499fa6.tar.gz crupest-0c885ba1bf30ce8308880f926be85b6f5a499fa6.tar.bz2 crupest-0c885ba1bf30ce8308880f926be85b6f5a499fa6.zip |
feat(www): YEAH!
Diffstat (limited to 'services/docker/nginx/sites/www/src/main.ts')
-rw-r--r-- | services/docker/nginx/sites/www/src/main.ts | 47 |
1 files changed, 0 insertions, 47 deletions
diff --git a/services/docker/nginx/sites/www/src/main.ts b/services/docker/nginx/sites/www/src/main.ts deleted file mode 100644 index 09e8661..0000000 --- a/services/docker/nginx/sites/www/src/main.ts +++ /dev/null @@ -1,47 +0,0 @@ -import "./style.css"; - -class Emotion { - static opposite_map = new Map<Emotion, Emotion>(); - - constructor(public readonly name: string) { - } - - get opposite(): Emotion { - return Emotion.opposite_map.get(this)!; - } - - get element(): HTMLDivElement { - return document.querySelector<HTMLDivElement>(`.slogan.${this.name}`)! - } - - get elementHeight(): number { - return this.element.clientHeight; - } - - apply() { - localStorage.setItem(emotionKey, this.name); - document.body.dataset.emotion = this.name; - document.body.style.paddingTop = `${this.elementHeight}px`; - } -} - -const happy = new Emotion("happy") -const angry = new Emotion("angry") -Emotion.opposite_map.set(happy, angry) -Emotion.opposite_map.set(angry, happy) - -const emotionKey = "emotion"; -const savedEmotionName = localStorage.getItem(emotionKey) ?? happy.name; - -for (const emotion of [happy, angry]) { - if (emotion.name == savedEmotionName) { - emotion.apply(); - } - emotion.element.addEventListener("click", () => { - emotion.opposite.apply(); - }); -} - -setTimeout(() => { - document.body.style.transition = "padding-top 0.8s"; -}); |