Skip to content

Commit

Permalink
admin: move theme icon to top left; add icon
Browse files Browse the repository at this point in the history
  • Loading branch information
hrfee committed Dec 24, 2021
1 parent 535a100 commit aedea1b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion html/admin.html
Expand Up @@ -408,6 +408,7 @@ <h1 class="ac" id="telegram-pin"></h1>
</div>
</div>
</span>
<span class="button ~warning" alt="{{ .strings.theme }}" id="button-theme"><i class="ri-sun-line"></i></span>
<div class="page-container">
<div class="mb-1">
<header class="flex flex-wrap items-center justify-between">
Expand All @@ -421,7 +422,6 @@ <h1 class="ac" id="telegram-pin"></h1>
<div class="mb-1">
<div class="text-neutral-700">
<span class="button ~critical !normal mb-1 unfocused" id="logout-button">{{ .strings.logout }}</span>
<span id="button-theme" class="button ~neutral !normal mb-1">{{ .strings.theme }}</span>
</div>
</div>
<div id="tab-invites">
Expand Down
24 changes: 23 additions & 1 deletion ts/admin.ts
Expand Up @@ -10,7 +10,29 @@ import { _get, _post, notificationBox, whichAnimationEvent, toggleLoader } from
import { Updater } from "./modules/update.js";

loadTheme();
(document.getElementById('button-theme') as HTMLSpanElement).onclick = toggleTheme;
const themeButton = document.getElementById('button-theme') as HTMLSpanElement;
const switchThemeIcon = () => {
const icon = themeButton.childNodes[0] as HTMLElement;
if (document.documentElement.classList.contains("dark-theme")) {
icon.classList.add("ri-sun-line");
icon.classList.remove("ri-moon-line");
themeButton.classList.add("~warning");
themeButton.classList.remove("~neutral");
themeButton.classList.remove("!high");
} else {
icon.classList.add("ri-moon-line");
icon.classList.remove("ri-sun-line");
themeButton.classList.add("!high");
themeButton.classList.add("~neutral");
themeButton.classList.remove("~warning");
}
};
themeButton.onclick = () => {
toggleTheme();
switchThemeIcon();
}
switchThemeIcon();


window.lang = new lang(window.langFile as LangFile);
loadLangSelector("admin");
Expand Down

0 comments on commit aedea1b

Please sign in to comment.