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 | 046c71c4c282b7c9dce781c8a1f31c68a1515854 (patch) | |
tree | 48e72e89b22c569d716bf66e746ed4a8a0fbfd98 /services/docker/nginx/sites/www/src/main.ts | |
parent | 471cacdd706002df81f5bee03729b8fca6c98f37 (diff) | |
download | crupest-046c71c4c282b7c9dce781c8a1f31c68a1515854.tar.gz crupest-046c71c4c282b7c9dce781c8a1f31c68a1515854.tar.bz2 crupest-046c71c4c282b7c9dce781c8a1f31c68a1515854.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"; -}); |