|
28 | 28 | > |
29 | 29 | <header> |
30 | 30 | <!-- Static navbar --> |
31 | | - <nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top"> |
| 31 | + <nav class="navbar navbar-expand-lg fixed-top"> |
32 | 32 | <div id="wrap" class="container-fluid ms-2"> |
33 | 33 | <a class="navbar-brand" href="{{url_for('anitya_ui.index')}}"> |
34 | 34 | release-monitoring.org |
|
171 | 171 | {% block body %}{% endblock %} |
172 | 172 | </main> |
173 | 173 |
|
174 | | - <footer class="footer mt-auto bg-light"> |
| 174 | + <footer class="footer mt-auto"> |
175 | 175 | <div class="d-flex justify-content-center flex-nowrap"> |
176 | 176 | <p class="text-muted credit"> |
177 | 177 | Anitya ({{ version }}): |
|
190 | 190 | Err ({{ cron_status.error_count }}) |
191 | 191 | Rate ({{ cron_status.ratelimit_count }}) |
192 | 192 | {% endif %} |
| 193 | + |
| 194 | + <span id="theme-toggle"></span> |
193 | 195 | </p> |
194 | 196 | </div> |
195 | 197 | </footer> |
|
226 | 228 | delay: 600, |
227 | 229 | }); |
228 | 230 | }); |
| 231 | + |
| 232 | + const html = document.documentElement; |
| 233 | + |
| 234 | + const bulbOn = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-lightbulb-fill" viewBox="0 0 16 16"> |
| 235 | + <path d="M2 6a6 6 0 1 1 10.174 4.31c-.203.196-.359.4-.453.619l-.762 1.769A.5.5 0 0 1 10.5 13h-5a.5.5 0 0 1-.46-.302l-.761-1.77a2 2 0 0 0-.453-.618A5.98 5.98 0 0 1 2 6m3 8.5a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1l-.224.447a1 1 0 0 1-.894.553H6.618a1 1 0 0 1-.894-.553L5.5 15a.5.5 0 0 1-.5-.5"/> |
| 236 | + </svg>`; |
| 237 | + |
| 238 | + const bulbOff = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-lightbulb-off" viewBox="0 0 16 16"> |
| 239 | + <path fill-rule="evenodd" d="M2.23 4.35A6 6 0 0 0 2 6c0 1.691.7 3.22 1.826 4.31.203.196.359.4.453.619l.762 1.769A.5.5 0 0 0 5.5 13a.5.5 0 0 0 0 1 .5.5 0 0 0 0 1l.224.447a1 1 0 0 0 .894.553h2.764a1 1 0 0 0 .894-.553L10.5 15a.5.5 0 0 0 0-1 .5.5 0 0 0 0-1 .5.5 0 0 0 .288-.091L9.878 12H5.83l-.632-1.467a3 3 0 0 0-.676-.941 4.98 4.98 0 0 1-1.455-4.405zm1.588-2.653.708.707a5 5 0 0 1 7.07 7.07l.707.707a6 6 0 0 0-8.484-8.484zm-2.172-.051a.5.5 0 0 1 .708 0l12 12a.5.5 0 0 1-.708.708l-12-12a.5.5 0 0 1 0-.708"/> |
| 240 | + </svg>`; |
| 241 | + |
| 242 | + const toggle = document.getElementById('theme-toggle'); |
| 243 | + let currentTheme = localStorage.getItem('theme'); |
| 244 | + if (!currentTheme) { |
| 245 | + const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches; |
| 246 | + if (prefersDark) { |
| 247 | + currentTheme = 'dark'; |
| 248 | + } else { |
| 249 | + currentTheme = 'light'; |
| 250 | + } |
| 251 | + } |
| 252 | + |
| 253 | + html.setAttribute('data-bs-theme', currentTheme); |
| 254 | + toggle.innerHTML = currentTheme === 'dark' ? bulbOff : bulbOn; |
| 255 | + toggle.onclick = function() { |
| 256 | + currentTheme = currentTheme === 'dark' ? 'light' : 'dark'; |
| 257 | + html.setAttribute('data-bs-theme', currentTheme); |
| 258 | + localStorage.setItem('theme', currentTheme); |
| 259 | + toggle.innerHTML = currentTheme === 'dark' ? bulbOff : bulbOn; |
| 260 | + }; |
| 261 | + |
229 | 262 | </script> |
230 | 263 | {% block jscript %}{% endblock %} |
231 | 264 | </body> |
|
0 commit comments