From 687ae968e10e1738c105fc0538fc29ccb08bfbbf Mon Sep 17 00:00:00 2001 From: Yuqian Yang Date: Sat, 22 Feb 2025 18:11:35 +0800 Subject: feat(services): refactor structure. --- docker/nginx/sites/www/src/main.ts | 47 -------------------------------------- 1 file changed, 47 deletions(-) delete mode 100644 docker/nginx/sites/www/src/main.ts (limited to 'docker/nginx/sites/www/src/main.ts') diff --git a/docker/nginx/sites/www/src/main.ts b/docker/nginx/sites/www/src/main.ts deleted file mode 100644 index 09e8661..0000000 --- a/docker/nginx/sites/www/src/main.ts +++ /dev/null @@ -1,47 +0,0 @@ -import "./style.css"; - -class Emotion { - static opposite_map = new Map(); - - constructor(public readonly name: string) { - } - - get opposite(): Emotion { - return Emotion.opposite_map.get(this)!; - } - - get element(): HTMLDivElement { - return document.querySelector(`.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"; -}); -- cgit v1.2.3