Fix admin theme switcher issue (#2719)

This commit is contained in:
Adam Daley authored and GitHub committed 2025-05-08 10:14:40 +01:00
1 parent 5a872a656d
commit e85d3e6f5b
3 files changed
+9 -9

No files matched your search

@@ -30,7 +30,7 @@ document.addEventListener('DOMContentLoaded', () => {
element.addEventListener('click', event => {
event.preventDefault();
localStorage.setItem('theme', element.getAttribute('href').split('=')[1]);
document.body.setAttribute("data-bs-theme", localStorage.getItem('theme'))
document.documentElement.setAttribute("data-bs-theme", localStorage.getItem('theme'))
});
});
@@ -4,7 +4,7 @@
{% set company = guest.system_company %}
<!DOCTYPE html>
<html lang="">
<html lang="" data-bs-theme="dark">
<head>
<title>{% block meta_title %}{% endblock %} - {{ company.name }}</title>
@@ -25,12 +25,12 @@
{% block head %}{% endblock %}
</head>
<body data-bs-theme="dark">
<body>
<script>
if (localStorage.getItem('theme') === 'dark') {
document.body.setAttribute("data-bs-theme", localStorage.getItem('theme'));
document.documentElement.setAttribute("data-bs-theme", localStorage.getItem('theme'));
} else {
document.body.removeAttribute("data-bs-theme");
document.documentElement.removeAttribute("data-bs-theme");
}
{% if not admin %}
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<html lang="en" data-bs-theme="dark">
<head>
<title>{% block meta_title %}{% endblock %}</title>
<meta charset="UTF-8">
@@ -16,12 +16,12 @@
{{ encore_entry_script_tags('fossbilling') }}
</head>
<body class="border-top-wide border-primary d-flex flex-column" data-bs-theme="dark">
<body class="border-top-wide border-primary d-flex flex-column">
<script>
if (localStorage.getItem('theme') === 'dark') {
document.body.setAttribute("data-bs-theme", localStorage.getItem('theme'));
document.documentElement.setAttribute("data-bs-theme", localStorage.getItem('theme'));
} else {
document.body.removeAttribute("data-bs-theme");
document.documentElement.removeAttribute("data-bs-theme");
}
</script>