timetracker/games/templates/cotton/layouts/base.html

82 lines
3.7 KiB
HTML
Raw Normal View History

{% load django_htmx %}
2023-11-17 20:06:57 +00:00
<!DOCTYPE html>
2022-12-31 13:18:27 +00:00
<html lang="en">
2023-01-05 21:05:26 +00:00
{% load static %}
<head>
2023-11-17 20:06:57 +00:00
<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" />
2024-10-16 15:49:55 +00:00
<title>Timetracker - {{ title }}</title>
<script src="{% static 'js/htmx.min.js' %}"></script>
{% django_htmx_script %}
2023-01-05 21:05:26 +00:00
<link rel="stylesheet" href="{% static 'base.css' %}" />
2024-07-09 21:03:03 +00:00
<script src="https://cdn.jsdelivr.net/npm/flowbite@2.4.1/dist/flowbite.min.js"></script>
2024-08-09 10:22:26 +00:00
<script>
// On page load or when changing themes, best to add inline in `head` to avoid FOUC
2024-09-10 12:26:06 +00:00
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')
}
2024-08-09 10:22:26 +00:00
</script>
2023-01-05 21:05:26 +00:00
</head>
2024-08-09 10:22:26 +00:00
<body hx-indicator="#indicator">
2023-11-17 20:06:57 +00:00
<img id="indicator"
2024-04-04 09:27:33 +00:00
src="{% static 'icons/loading.png' %}"
class="absolute right-3 top-3 animate-spin htmx-indicator"
height="24"
width="24"
alt="loading indicator" />
2024-02-10 08:50:53 +00:00
<div class="flex flex-col min-h-screen">
2024-08-09 11:14:18 +00:00
{% include "navbar.html" %}
2024-10-16 15:49:55 +00:00
<div class="flex flex-1 flex-col dark:bg-gray-800 pt-8">{{ slot }}</div>
2024-08-08 12:47:51 +00:00
{% load version %}
2024-08-11 15:23:18 +00:00
<span class="fixed left-2 bottom-2 text-xs text-slate-300 dark:text-slate-600">{% version %} ({% version_date %})</span>
2024-08-08 12:47:51 +00:00
</div>
2024-10-16 15:49:55 +00:00
{{ scripts }}
2024-08-09 10:22:26 +00:00
<script>
2024-09-10 12:26:06 +00:00
var themeToggleDarkIcon = document.getElementById('theme-toggle-dark-icon');
var themeToggleLightIcon = document.getElementById('theme-toggle-light-icon');
2024-08-09 10:22:26 +00:00
// Change the icons inside the button based on previous settings
2024-09-10 12:26:06 +00:00
if (localStorage.getItem('color-theme') === 'dark' || (!('color-theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
themeToggleLightIcon.classList.remove('hidden');
} else {
themeToggleDarkIcon.classList.remove('hidden');
}
2024-08-09 10:22:26 +00:00
2024-09-10 12:26:06 +00:00
var themeToggleBtn = document.getElementById('theme-toggle');
2024-08-09 10:22:26 +00:00
2024-09-10 12:26:06 +00:00
themeToggleBtn.addEventListener('click', function () {
2024-08-09 10:22:26 +00:00
// toggle icons inside button
2024-09-10 12:26:06 +00:00
themeToggleDarkIcon.classList.toggle('hidden');
themeToggleLightIcon.classList.toggle('hidden');
2024-08-09 10:22:26 +00:00
// if set via local storage previously
2024-09-10 12:26:06 +00:00
if (localStorage.getItem('color-theme')) {
if (localStorage.getItem('color-theme') === 'light') {
document.documentElement.classList.add('dark');
localStorage.setItem('color-theme', 'dark');
} else {
document.documentElement.classList.remove('dark');
localStorage.setItem('color-theme', 'light');
}
2024-08-09 10:22:26 +00:00
// if NOT set via local storage previously
} else {
2024-09-10 12:26:06 +00:00
if (document.documentElement.classList.contains('dark')) {
document.documentElement.classList.remove('dark');
localStorage.setItem('color-theme', 'light');
} else {
document.documentElement.classList.add('dark');
localStorage.setItem('color-theme', 'dark');
}
2024-08-09 10:22:26 +00:00
}
2024-09-10 12:26:06 +00:00
});
2024-08-09 10:22:26 +00:00
</script>
2024-08-08 12:47:51 +00:00
</body>
</html>