fix(style): fix missposition theme checkbox
This commit is contained in:
parent
fd0c223877
commit
322ab9fa53
4 changed files with 62 additions and 32 deletions
|
@ -12,9 +12,18 @@ Don't judge me
|
||||||
|
|
||||||
<!-- theme -->
|
<!-- theme -->
|
||||||
<script>
|
<script>
|
||||||
window.theme = document.querySelector('input[name=theme]');
|
window.themeCheckboxes = ["theme", "themeSidebar"];
|
||||||
theme.checked = document.documentElement.getAttribute('data-theme') === 'dark';
|
|
||||||
|
|
||||||
|
themeCheckboxes.forEach(checkbox => {
|
||||||
|
const theme = document.querySelector(`input[name=${checkbox}]`);
|
||||||
|
|
||||||
|
theme.addEventListener('change', function () {
|
||||||
|
applyTheme(theme.checked ? 'dark' : 'light');
|
||||||
|
console.log(theme)
|
||||||
|
})
|
||||||
|
|
||||||
|
theme.checked = document.documentElement.getAttribute('data-theme') === 'dark';
|
||||||
|
})
|
||||||
window.applyTheme = function (theme) {
|
window.applyTheme = function (theme) {
|
||||||
document.documentElement.setAttribute('data-theme', theme);
|
document.documentElement.setAttribute('data-theme', theme);
|
||||||
|
|
||||||
|
@ -29,10 +38,6 @@ Don't judge me
|
||||||
|
|
||||||
window.sessionStorage.setItem('theme', theme)
|
window.sessionStorage.setItem('theme', theme)
|
||||||
}
|
}
|
||||||
|
|
||||||
theme.addEventListener('change', function () {
|
|
||||||
applyTheme(theme.checked ? 'dark' : 'light')
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- sidebar -->
|
<!-- sidebar -->
|
||||||
|
@ -54,7 +59,10 @@ Don't judge me
|
||||||
theme_session = window.sessionStorage.getItem('theme')
|
theme_session = window.sessionStorage.getItem('theme')
|
||||||
if (theme_session !== null) {
|
if (theme_session !== null) {
|
||||||
applyTheme(theme_session);
|
applyTheme(theme_session);
|
||||||
window.theme.checked = theme_session === 'dark'
|
|
||||||
|
themeCheckboxes.forEach(checkbox => {
|
||||||
|
document.querySelector(`input[name=${checkbox}]`).checked = theme_session === 'dark'
|
||||||
|
})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
<span class="uk-text-small uk-text-muted"> | Version: </span>
|
<span class="uk-text-small uk-text-muted"> | Version: </span>
|
||||||
<a href="https://git.gnous.eu/gnouseu/gnousdoteu/src/commit/{% version 'long' %}" target="_blank" class="uk-text-small uk-button-link">{% version 'short' %}</a>
|
<a href="https://git.gnous.eu/gnouseu/gnousdoteu/src/commit/{% version 'long' %}" target="_blank" class="uk-text-small uk-button-link">{% version 'short' %}</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="uk-float-right">
|
<div class="uk-float-right uk-visible@s">
|
||||||
<label class="uk-switch need-js" for="themeSwitcher">
|
<label class="uk-switch need-js" for="themeSwitcher">
|
||||||
<input type="checkbox" id="themeSwitcher" name="theme">
|
<input type="checkbox" id="themeSwitcher" name="theme">
|
||||||
<span class="uk-switch-slider"></span>
|
<span class="uk-switch-slider"></span>
|
||||||
|
|
|
@ -14,42 +14,64 @@
|
||||||
<li>
|
<li>
|
||||||
<a href="{% url 'gnous_eu:index' %}"
|
<a href="{% url 'gnous_eu:index' %}"
|
||||||
class="uk-text-bolder"
|
class="uk-text-bolder"
|
||||||
{% if request.resolver_match.url_name == 'index' %} style="text-decoration: underline" {% endif %}>
|
{% if request.resolver_match.url_name == 'index' %}
|
||||||
|
style="text-decoration: underline" {% endif %}>
|
||||||
<span class="uk-margin-small-right uk-icon" data-uk-icon="world"></span> {% trans "Accueil" %}
|
<span class="uk-margin-small-right uk-icon" data-uk-icon="world"></span> {% trans "Accueil" %}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="{% url 'gnous_eu:services' %}"
|
<a href="{% url 'gnous_eu:services' %}"
|
||||||
class="uk-text-bolder"
|
class="uk-text-bolder"
|
||||||
{% if request.resolver_match.url_name == 'services' %} style="text-decoration: underline" {% endif %}>
|
{% if request.resolver_match.url_name == 'services' %}
|
||||||
|
style="text-decoration: underline" {% endif %}>
|
||||||
<span class="uk-margin-small-right uk-icon" data-uk-icon="grid"></span> {% trans "Services" %}
|
<span class="uk-margin-small-right uk-icon" data-uk-icon="grid"></span> {% trans "Services" %}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="{% url 'gnous_eu:about' %}"
|
<a href="{% url 'gnous_eu:about' %}"
|
||||||
class="uk-text-bolder"
|
class="uk-text-bolder"
|
||||||
{% if request.resolver_match.url_name == 'about' %} style="text-decoration: underline" {% endif %}>
|
{% if request.resolver_match.url_name == 'about' %}
|
||||||
|
style="text-decoration: underline" {% endif %}>
|
||||||
<span class="uk-margin-small-right uk-icon" data-uk-icon="info"></span> {% trans "À propos" %}
|
<span class="uk-margin-small-right uk-icon" data-uk-icon="info"></span> {% trans "À propos" %}
|
||||||
</a>
|
</a>
|
||||||
<a href="{% url 'gnous_eu:tips' %}"
|
<a href="{% url 'gnous_eu:tips' %}"
|
||||||
class="uk-text-bolder"
|
class="uk-text-bolder"
|
||||||
{% if request.resolver_match.url_name == 'tips' %} style="text-decoration: underline" {% endif %}>
|
{% if request.resolver_match.url_name == 'tips' %}
|
||||||
|
style="text-decoration: underline" {% endif %}>
|
||||||
<span class="uk-margin-small-right uk-icon" data-uk-icon="credit-card"></span> {% trans "Donner" %}
|
<span class="uk-margin-small-right uk-icon" data-uk-icon="credit-card"></span> {% trans "Donner" %}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="uk-nav-divider"></li>
|
<li class="uk-nav-divider"></li>
|
||||||
<li>
|
<li>
|
||||||
|
<div class="uk-flex-between uk-flex">
|
||||||
|
<div>
|
||||||
<form action="{% url 'set_language' %}" method="post" name="languageForm2">
|
<form action="{% url 'set_language' %}" method="post" name="languageForm2">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{% get_current_language as LANGUAGE_CODE %}
|
{% get_current_language as LANGUAGE_CODE %}
|
||||||
{% if LANGUAGE_CODE == 'en' %}
|
{% if LANGUAGE_CODE == 'en' %}
|
||||||
<img src="{% static 'images/icons/fr.svg' %}" alt="en" onclick="window.document.languageForm2.submit()" width="18">
|
<img src="{% static 'images/icons/fr.svg' %}" alt="en"
|
||||||
|
onclick="window.document.languageForm2.submit()" width="18">
|
||||||
<input type="hidden" name="language" value="fr">
|
<input type="hidden" name="language" value="fr">
|
||||||
{% else %}
|
{% else %}
|
||||||
<img src="{% static 'images/icons/en.svg' %}" alt="fr" onclick="window.document.languageForm2.submit()" width="18">
|
<img src="{% static 'images/icons/en.svg' %}" alt="fr"
|
||||||
|
onclick="window.document.languageForm2.submit()" width="18">
|
||||||
<input type="hidden" name="language" value="en">
|
<input type="hidden" name="language" value="en">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</form>
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label class="uk-switch need-js" for="themeSwitcherSidebar">
|
||||||
|
<input type="checkbox" id="themeSwitcherSidebar" name="themeSidebar">
|
||||||
|
<span class="uk-switch-slider"></span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue