996c0107c9
* Updated flowbite to 4.x * Start revamping styles * Remove unused GraphQL code * Make some templates more robuts
100 lines
5.3 KiB
HTML
100 lines
5.3 KiB
HTML
{% load django_htmx %}
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
{% load static %}
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta name="description" content="Self-hosted time-tracker." />
|
|
<meta name="keywords" content="time, tracking, video games, self-hosted" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
<title>Timetracker - {{ title }}</title>
|
|
<script src="{% static 'js/htmx.min.js' %}"></script>
|
|
{% django_htmx_script %}
|
|
<link rel="stylesheet" href="{% static 'base.css' %}" />
|
|
<script src="https://cdn.jsdelivr.net/npm/flowbite@2.4.1/dist/flowbite.min.js"></script>
|
|
{% comment %} <script src="//unpkg.com/alpinejs" defer></script>
|
|
<script src="//unpkg.com/@alpinejs/mask" defer></script> {% endcomment %}
|
|
<script defer src="https://cdn.jsdelivr.net/npm/@alpinejs/mask@3.x.x/dist/cdn.min.js"></script>
|
|
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script>
|
|
<script>
|
|
// On page load or when changing themes, best to add inline in `head` to avoid FOUC
|
|
if (localStorage.getItem('color-theme') === 'dark' || (!('color-theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
|
|
document.documentElement.classList.add('dark');
|
|
} else {
|
|
document.documentElement.classList.remove('dark')
|
|
}
|
|
</script>
|
|
</head>
|
|
<body hx-indicator="#indicator" class="bg-neutral-primary">
|
|
<img id="indicator"
|
|
src="{% static 'icons/loading.png' %}"
|
|
class="absolute right-3 top-3 animate-spin htmx-indicator"
|
|
height="24"
|
|
width="24"
|
|
alt="loading indicator" />
|
|
<div class="flex flex-col min-h-screen">
|
|
{% include "navbar.html" %}
|
|
<div class="flex flex-1 flex-col pt-8 pb-16">{{ slot }}</div>
|
|
{% load version %}
|
|
<span class="fixed left-2 bottom-2 text-xs text-slate-300 dark:text-slate-600">{% version %} ({% version_date %})</span>
|
|
</div>
|
|
{{ scripts }}
|
|
<script type="module">
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
if (window.mountCrownIcon) {
|
|
window.mountCrownIcon('#crown-icon-mount-point', {
|
|
mastered: {{ game.mastered|yesno:"true,false" }}
|
|
});
|
|
}
|
|
|
|
// Theme toggle logic
|
|
const themeToggleDarkIcon = document.getElementById('theme-toggle-dark-icon');
|
|
const themeToggleLightIcon = document.getElementById('theme-toggle-light-icon');
|
|
const themeToggleBtn = document.getElementById('theme-toggle');
|
|
|
|
// Ensure all elements are found before proceeding
|
|
if (themeToggleDarkIcon && themeToggleLightIcon && themeToggleBtn) {
|
|
// Initial state of icons based on current theme
|
|
// The FOUC script in <head> already set document.documentElement.classList.add/remove('dark')
|
|
// So we just need to set the icon visibility based on that.
|
|
if (document.documentElement.classList.contains('dark')) {
|
|
themeToggleLightIcon.classList.remove('hidden');
|
|
themeToggleDarkIcon.classList.add('hidden');
|
|
} else {
|
|
themeToggleDarkIcon.classList.remove('hidden');
|
|
themeToggleLightIcon.classList.add('hidden');
|
|
}
|
|
|
|
themeToggleBtn.addEventListener('click', function () {
|
|
// toggle icons inside button
|
|
themeToggleDarkIcon.classList.toggle('hidden');
|
|
themeToggleLightIcon.classList.toggle('hidden');
|
|
|
|
// if set via local storage previously
|
|
if (localStorage.getItem('color-theme')) {
|
|
if (localStorage.getItem('color-theme') === 'light') {
|
|
document.documentElement.classList.add('dark');
|
|
localStorage.setItem('color-theme', 'dark');
|
|
} else { // current theme is dark, switch to light
|
|
document.documentElement.classList.remove('dark');
|
|
localStorage.setItem('color-theme', 'light');
|
|
}
|
|
|
|
// if NOT set via local storage previously
|
|
} else { // no theme in local storage, use system preference
|
|
if (document.documentElement.classList.contains('dark')) { // currently dark, switch to light
|
|
document.documentElement.classList.remove('dark');
|
|
localStorage.setItem('color-theme', 'light');
|
|
} else { // currently light, switch to dark
|
|
document.documentElement.classList.add('dark');
|
|
localStorage.setItem('color-theme', 'dark');
|
|
}
|
|
}
|
|
});
|
|
}
|
|
});
|
|
</script>
|
|
<div id="global-modal-container"></div>
|
|
</body>
|
|
</html>
|