mirror of
https://github.com/bunkerity/bunkerweb
synced 2026-05-24 09:28:37 +00:00
Refactor theme toggle implementation in JavaScript and HTML for improved clarity and functionality
This commit is contained in:
parent
10a19fc72c
commit
4846000ad4
2 changed files with 5 additions and 2 deletions
|
|
@ -450,6 +450,7 @@ $(document).ready(() => {
|
|||
// If endpoint is "setup", ignore the theme change
|
||||
if (window.location.pathname.includes("/setup")) return;
|
||||
|
||||
$themeSelector = $("#theme-toggle");
|
||||
const darkMode = $(this).prop("checked");
|
||||
if (darkMode) {
|
||||
$("html")
|
||||
|
|
@ -467,6 +468,7 @@ $(document).ready(() => {
|
|||
$(".dark-mode-toggle-icon").removeClass("bx-sun").addClass("bx-moon");
|
||||
$("[alt='BunkerWeb logo']").attr("src", $("#bw-logo-white").val());
|
||||
$("[alt='User Avatar']").attr("src", $("#avatar-url-white").val());
|
||||
$themeSelector.find("option[value='dark']").prop("selected", true);
|
||||
} else {
|
||||
$("html")
|
||||
.removeClass("dark-style dark")
|
||||
|
|
@ -483,6 +485,7 @@ $(document).ready(() => {
|
|||
$(".dark-mode-toggle-icon").removeClass("bx-moon").addClass("bx-sun");
|
||||
$("[alt='BunkerWeb logo']").attr("src", $("#bw-logo").val());
|
||||
$("[alt='User Avatar']").attr("src", $("#avatar-url").val());
|
||||
$themeSelector.find("option[value='light']").prop("selected", true);
|
||||
}
|
||||
|
||||
$("#theme").val(darkMode ? "dark" : "light");
|
||||
|
|
|
|||
|
|
@ -173,14 +173,14 @@
|
|||
<div class="col-md-6">
|
||||
<!-- Theme -->
|
||||
<div class="card position-relative">
|
||||
<i class='bx bx-{% if theme == 'light' %}sun{% else %}moon{% endif %} bx-sm position-absolute top-0 end-0 m-3'></i>
|
||||
<i class='bx bx-{% if theme == 'light' %}sun{% else %}moon{% endif %} bx-sm position-absolute top-0 end-0 m-3 dark-mode-toggle-icon'></i>
|
||||
<h5 class="card-header">Change Theme</h5>
|
||||
<div class="card-body pb-4">
|
||||
<form method="POST" action="{{ profile_url }}/edit">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
|
||||
<div class="row g-3">
|
||||
<div class="col-md-12 form-floating">
|
||||
<select class="form-select" id="theme" name="theme">
|
||||
<select class="form-select" id="theme-toggle" name="theme">
|
||||
<option value="light" {% if theme == "light" %}selected{% endif %}>Light</option>
|
||||
<option value="dark" {% if theme == "dark" %}selected{% endif %}>Dark</option>
|
||||
</select>
|
||||
|
|
|
|||
Loading…
Reference in a new issue