feat: Add inital dark/light mode switching
All checks were successful
Build Docker / Build Image (push) Successful in 2m10s

This commit is contained in:
2025-08-07 00:26:22 +10:00
parent 6ebeb1b5bc
commit 0761d9d707
26 changed files with 2297 additions and 94 deletions

View File

@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html data-bs-theme="light" lang="en">
<html data-bs-theme="auto" lang="en">
<head>
<meta charset="utf-8">
@@ -17,6 +17,87 @@
<meta property="og:title" content="Pins | HNS AU">
<meta name="twitter:description" content="Show that you support Handshake with a HNS lapel pin. Created to our high stands with multiple colours to choose from. Free shipping worldwide.">
<meta name="twitter:title" content="Pins | HNS AU">
<script>
(function() {
// JavaScript snippet handling Dark/Light mode switching
const getStoredTheme = () => localStorage.getItem('theme');
const setStoredTheme = theme => localStorage.setItem('theme', theme);
const forcedTheme = document.documentElement.getAttribute('data-bss-forced-theme');
const getPreferredTheme = () => {
if (forcedTheme) return forcedTheme;
const storedTheme = getStoredTheme();
if (storedTheme) {
return storedTheme;
}
const pageTheme = document.documentElement.getAttribute('data-bs-theme');
if (pageTheme) {
return pageTheme;
}
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
}
const setTheme = theme => {
if (theme === 'auto' && window.matchMedia('(prefers-color-scheme: dark)').matches) {
document.documentElement.setAttribute('data-bs-theme', 'dark');
} else {
document.documentElement.setAttribute('data-bs-theme', theme);
}
}
setTheme(getPreferredTheme());
const showActiveTheme = (theme, focus = false) => {
const themeSwitchers = [].slice.call(document.querySelectorAll('.theme-switcher'));
if (!themeSwitchers.length) return;
document.querySelectorAll('[data-bs-theme-value]').forEach(element => {
element.classList.remove('active');
element.setAttribute('aria-pressed', 'false');
});
for (const themeSwitcher of themeSwitchers) {
const btnToActivate = themeSwitcher.querySelector('[data-bs-theme-value="' + theme + '"]');
if (btnToActivate) {
btnToActivate.classList.add('active');
btnToActivate.setAttribute('aria-pressed', 'true');
}
}
}
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => {
const storedTheme = getStoredTheme();
if (storedTheme !== 'light' && storedTheme !== 'dark') {
setTheme(getPreferredTheme());
}
});
window.addEventListener('DOMContentLoaded', () => {
showActiveTheme(getPreferredTheme());
document.querySelectorAll('[data-bs-theme-value]')
.forEach(toggle => {
toggle.addEventListener('click', (e) => {
e.preventDefault();
const theme = toggle.getAttribute('data-bs-theme-value');
setStoredTheme(theme);
setTheme(theme);
showActiveTheme(theme);
})
})
});
})();
</script>
<link rel="icon" type="image/png" sizes="600x627" href="/assets/img/favicon.png">
<link rel="icon" type="image/png" sizes="600x627" href="/assets/img/favicon-light.png" media="(prefers-color-scheme: dark)">
<link rel="icon" type="image/png" sizes="600x627" href="/assets/img/favicon.png">
@@ -30,14 +111,15 @@
<link rel="stylesheet" href="/assets/css/bss-overrides.css">
<link rel="stylesheet" href="/assets/css/Hero-Features-icons.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/baguettebox.js/1.10.0/baguetteBox.min.css">
<link rel="stylesheet" href="/assets/css/theme.css">
<link rel="stylesheet" href="/assets/css/vanilla-zoom.min.css">
<script async src="https://umami.woodburn.au/script.js" data-website-id="15852010-8d3c-4553-92fc-2d6ac31098e8"></script>
{{handshake_scripts | safe}}
</head>
<body>
<nav class="navbar navbar-expand-lg fixed-top bg-light clean-navbar navbar-light">
<div class="container-fluid"><a class="navbar-brand logo" href="/" style="width: 50%;"><img src="/assets/img/HandshakeAustraliaT.webp" style="margin-right: 10px;height: 50px;"></a><button data-bs-toggle="collapse" class="navbar-toggler" data-bs-target="#navcol-1"><span class="visually-hidden">Toggle navigation</span><span class="navbar-toggler-icon"></span></button>
<nav class="navbar navbar-expand-lg fixed-top bg-secondary-subtle clean-navbar navbar-light">
<div class="container-fluid"><a class="navbar-brand logo" href="/" style="width: 50%;"><img src="/assets/img/HandshakeAustraliaT.webp" style="margin-right: 10px;height: 50px;" class="light-only"><img src="/assets/img/HandshakeAustraliaTW.webp" style="margin-right: 10px;height: 50px;" class="dark-only"></a><button data-bs-toggle="collapse" class="navbar-toggler" data-bs-target="#navcol-1"><span class="visually-hidden">Toggle navigation</span><span class="navbar-toggler-icon"></span></button>
<div class="collapse navbar-collapse" id="navcol-1">
<ul class="navbar-nav ms-auto">
<li class="nav-item"><a class="nav-link" href="/" style="color: var(--bs-primary);">Home</a></li>
@@ -45,9 +127,13 @@
<li class="nav-item"><a class="nav-link" href="/links" style="color: var(--bs-primary);">Links</a></li>
<li class="nav-item"><a class="nav-link" href="/#about" style="color: var(--bs-primary);">About</a></li>
<li class="nav-item"><a class="nav-link" href="https://domains.hns.au" style="color: var(--bs-primary);">Domains</a></li>
<li class="nav-item"><a class="nav-link" href="/pins" style="color: var(--bs-primary);">Pins</a></li>
<li class="nav-item"><a class="nav-link" href="/#contact" style="color: var(--bs-primary);">Contact</a></li>
</ul>
<div><button class="btn btn-primary btn-sm" type="button" onclick="toggle();"><svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="currentColor" viewBox="0 0 16 16" class="bi bi-sun light-only" style="font-size: 20px;margin: auto;">
<path d="M8 11a3 3 0 1 1 0-6 3 3 0 0 1 0 6m0 1a4 4 0 1 0 0-8 4 4 0 0 0 0 8M8 0a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 0m0 13a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 13m8-5a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2a.5.5 0 0 1 .5.5M3 8a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2A.5.5 0 0 1 3 8m10.657-5.657a.5.5 0 0 1 0 .707l-1.414 1.415a.5.5 0 1 1-.707-.708l1.414-1.414a.5.5 0 0 1 .707 0m-9.193 9.193a.5.5 0 0 1 0 .707L3.05 13.657a.5.5 0 0 1-.707-.707l1.414-1.414a.5.5 0 0 1 .707 0zm9.193 2.121a.5.5 0 0 1-.707 0l-1.414-1.414a.5.5 0 0 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .707M4.464 4.465a.5.5 0 0 1-.707 0L2.343 3.05a.5.5 0 1 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .708z"></path>
</svg><svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="currentColor" viewBox="0 0 16 16" class="bi bi-moon-fill dark-only" style="font-size: 20px;margin: auto;">
<path d="M6 .278a.768.768 0 0 1 .08.858 7.208 7.208 0 0 0-.878 3.46c0 4.021 3.278 7.277 7.318 7.277.527 0 1.04-.055 1.533-.16a.787.787 0 0 1 .81.316.733.733 0 0 1-.031.893A8.349 8.349 0 0 1 8.344 16C3.734 16 0 12.286 0 7.71 0 4.266 2.114 1.312 5.124.06A.752.752 0 0 1 6 .278"></path>
</svg></button></div>
</div>
</div>
</nav>
@@ -55,7 +141,7 @@
<section class="clean-block clean-catalog dark">
<div class="container">
<div class="block-heading">
<h2 class="text-info">Pins</h2>
<h2 class="text-primary">Pins</h2>
<p>Show that you support Handshake with a HNS lapel pin. Created to our high stands with multiple colours to choose from.<br>Free shipping worldwide</p>
</div>
<div class="products" style="padding: 30px;">