mirror of
https://github.com/StefBuwalda/cal_counter.git
synced 2025-10-30 11:19:59 +00:00
Add theme toggle and admin nav link, update styles
Introduced a dark/light theme toggle with persistent user preference using localStorage. Updated base template to use Bootstrap's theme system, adjusted body background class, and added a conditional 'Food Items' nav link for admins. Simplified scan page header text.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="en">
|
<html lang="en" data-bs-theme="dark">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
@@ -10,8 +10,7 @@
|
|||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body class="bg-light">
|
<body class="bg-body-secondary">
|
||||||
|
|
||||||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark mb-4">
|
<nav class="navbar navbar-expand-lg navbar-dark bg-dark mb-4">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<a class="navbar-brand" href="{{ url_for('index') }}">Iman was here</a>
|
<a class="navbar-brand" href="{{ url_for('index') }}">Iman was here</a>
|
||||||
@@ -24,6 +23,11 @@
|
|||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="{{ url_for('scan') }}">Scan</a>
|
<a class="nav-link" href="{{ url_for('scan') }}">Scan</a>
|
||||||
</li>
|
</li>
|
||||||
|
{% if current_user.is_admin %}
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="{{ url_for('admin.food_items') }}">Food Items</a>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
<ul class="navbar-nav ms-auto">
|
<ul class="navbar-nav ms-auto">
|
||||||
{% if current_user.is_authenticated %}
|
{% if current_user.is_authenticated %}
|
||||||
@@ -35,12 +39,10 @@
|
|||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="{{ url_for('login') }}">Login</a>
|
<a class="nav-link" href="{{ url_for('login') }}">Login</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="{{ url_for('dashboard') }}">Dashboard</a>
|
|
||||||
</li>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
<button id="toggleTheme" class="btn btn-outline-light ms-3">Toggle Theme</button>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
@@ -55,9 +57,25 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
|
|
||||||
{% block content %}{% endblock %}
|
{% block content %}
|
||||||
|
{% endblock %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
const html = document.documentElement;
|
||||||
|
const savedTheme = localStorage.getItem("theme");
|
||||||
|
if (savedTheme) {
|
||||||
|
html.setAttribute("data-bs-theme", savedTheme);
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementById("toggleTheme").addEventListener("click", () => {
|
||||||
|
const current = html.getAttribute("data-bs-theme");
|
||||||
|
const next = current === "dark" ? "light" : "dark";
|
||||||
|
html.setAttribute("data-bs-theme", next);
|
||||||
|
localStorage.setItem("theme", next);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="container py-5">
|
<div class="container py-5">
|
||||||
<div class="text-center mb-4">
|
<div class="text-center mb-4">
|
||||||
<h1 class="fw-bold">📷 ZXing Barcode Scanner</h1>
|
<h1 class="fw-bold">Barcode Scanner</h1>
|
||||||
<p class="text-muted">Use your camera to scan barcodes in real time.</p>
|
<p class="text-muted">Use your camera to scan barcodes</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="d-flex justify-content-center mb-4">
|
<div class="d-flex justify-content-center mb-4">
|
||||||
|
|||||||
Reference in New Issue
Block a user