From 0c42aa321d4d382409172246d2cd6f1d3e340c86 Mon Sep 17 00:00:00 2001 From: krek0 Date: Wed, 22 Apr 2026 09:28:58 +0200 Subject: [PATCH] Follow system theme --- photo21/static/layout.css | 2 +- photo21/static/theme.js | 13 +++++++++++++ photo21/templates/base.html | 3 ++- .../photologue/includes/gallery_sample.html | 2 +- 4 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 photo21/static/theme.js diff --git a/photo21/static/layout.css b/photo21/static/layout.css index 27537c6..a0026d1 100644 --- a/photo21/static/layout.css +++ b/photo21/static/layout.css @@ -6,7 +6,7 @@ SPDX-License-Identifier: GPL-3.0-or-later /* Use dark scrollbar */ :root { - color-scheme: dark; + color-scheme: light dark; } /* Bootstrap icons */ diff --git a/photo21/static/theme.js b/photo21/static/theme.js new file mode 100644 index 0000000..7c890f3 --- /dev/null +++ b/photo21/static/theme.js @@ -0,0 +1,13 @@ +/* +This file is part of photo21 +Copyright (C) 2022 Amicale des élèves de l'ENS Paris-Saclay +SPDX-License-Identifier: GPL-3.0-or-later +*/ + +(function() { + var mq = window.matchMedia('(prefers-color-scheme: dark)'); + document.documentElement.setAttribute('data-bs-theme', mq.matches ? 'dark' : 'light'); + mq.addEventListener('change', function(e) { + document.documentElement.setAttribute('data-bs-theme', e.matches ? 'dark' : 'light'); + }); +})(); diff --git a/photo21/templates/base.html b/photo21/templates/base.html index 9a1c499..eeca7fd 100644 --- a/photo21/templates/base.html +++ b/photo21/templates/base.html @@ -6,7 +6,7 @@ SPDX-License-Identifier: GPL-3.0-or-later {% load static i18n %} {% get_current_language as LANGUAGE_CODE %}{% get_current_language_bidi as LANGUAGE_BIDI %} - + @@ -14,6 +14,7 @@ SPDX-License-Identifier: GPL-3.0-or-later {% block title %}{{ title }}{% endblock title %} - {{ request.site.name }} + diff --git a/photologue/templates/photologue/includes/gallery_sample.html b/photologue/templates/photologue/includes/gallery_sample.html index ec07308..7210415 100644 --- a/photologue/templates/photologue/includes/gallery_sample.html +++ b/photologue/templates/photologue/includes/gallery_sample.html @@ -5,7 +5,7 @@ SPDX-License-Identifier: GPL-3.0-or-later {% endcomment %} {% load i18n %} -
+
{% for photo in gallery.sample %} {{ photo.title }} {% endfor %}