From b51197b9efe7296fd72cd6082f43e058b89ec075 Mon Sep 17 00:00:00 2001 From: Sweetbread Date: Thu, 5 Mar 2026 19:15:24 +0300 Subject: [PATCH] feat: add chats dropdown menu --- static/script.js | 46 +++++++++++++++++++++++++++++ static/style.scss | 60 ++++++++++++++++++++++++++++++++++++++ templates/tmpl/_header.htm | 1 + templates/tmpl/_menu.htm | 23 ++++++++++++++- 4 files changed, 129 insertions(+), 1 deletion(-) diff --git a/static/script.js b/static/script.js index ccb0115..043a55e 100644 --- a/static/script.js +++ b/static/script.js @@ -117,3 +117,49 @@ function checkkey(e) { else if (keycode == 39) { next(); } else if (keycode == 27) { dropdown_hide(); } } + + +function chatsDropdownMenu() { + return { + items: ["IRC", "Matrix", "Discord", "Telegram"], + currentIndex: 0, + isOpen: false, + intervalId: null, + + init() { + console.debug("init"); + this.startRotation(); + }, + + startRotation() { + if (this.intervalId != null) { + console.debug("Already started"); + } else { + this.intervalId = setInterval(() => { + this.currentIndex = (this.currentIndex + 1) % this.items.length; + }, 3000); + console.debug("start"); + } + }, + + stopRotation() { + clearInterval(this.intervalId); + this.intervalId = null; + console.debug("stop"); + }, + + pause() { + this.stopRotation(); + this.isOpen = true; + }, + resume() { + this.startRotation(); + this.isOpen = false; + }, + get listItems() { + const current = this.items[this.currentIndex]; + const others = this.items.filter((_, i) => i !== this.currentIndex); + return [current, ...others]; + } + } +} diff --git a/static/style.scss b/static/style.scss index acb7c12..54e25f9 100644 --- a/static/style.scss +++ b/static/style.scss @@ -155,6 +155,66 @@ body { } } +#chats-dropdown { + position: relative; + width: 250px; + cursor: pointer; + + .wrapper { + position: relative; + height: 40px; + /* overflow: hidden; */ + border: 1px solid #ccc; + border-radius: 6px; + background: #fff; + } + .header, + .list { + position: absolute; + left: 0; + width: 100%; + margin: 0; + padding: 8px 12px; + background: #fff; + transition: transform 0.25s ease, opacity 0.2s ease; + list-style: none; + } + .header { + top: 0; + transform: translateY(0); + opacity: 1; + z-index: 2; + + &.hide { + transform: translateY(100%); + opacity: 0; + } + } + .list { + top: 0; + transform: translateY(-100%); + opacity: 0; + z-index: 1; + padding: 0; + + &.show { + transform: translateY(0); + opacity: 1; + } + } + .list li { + padding: 8px 12px; + border-bottom: 1px solid #f0f0f0; + + &:last-child { + border-bottom: none; + } + &:hover { + background-color: #e9e9e9; + } + } +} + /* ARTICLE */ #article { diff --git a/templates/tmpl/_header.htm b/templates/tmpl/_header.htm index bf72471..d160585 100644 --- a/templates/tmpl/_header.htm +++ b/templates/tmpl/_header.htm @@ -8,4 +8,5 @@ + diff --git a/templates/tmpl/_menu.htm b/templates/tmpl/_menu.htm index d3fa582..46e1938 100644 --- a/templates/tmpl/_menu.htm +++ b/templates/tmpl/_menu.htm @@ -18,7 +18,28 @@ {{ _('menu:forum') }} {{ _('menu:wiki') }} Git - + +
+ +
+
+
+ +
    + +
+
+
+