Skip to content

A self-hosted dashboard that puts all your feeds in one place

Improve accessibility #1097

Svilen Markova83db748e1c7
diff --git a/internal/glance/static/js/page.js b/internal/glance/static/js/page.js
index ff20a13..6fb3d49 100644
--- a/internal/glance/static/js/page.js
+++ b/internal/glance/static/js/page.js
@@ -708,6 +708,15 @@ function initThemePicker() {
let themePreviewElems = document.getElementsByClassName("current-theme-preview");
let isLoading = false;
+ function syncThemePreset() {
+ presetElems.forEach((e) => {
+ const isActive = e.dataset.key == pageData.theme;
+ e.classList.toggle("current", isActive);
+ e.setAttribute("aria-pressed", isActive ? "true" : "false");
+ });
+ }
+ syncThemePreset();
+
presetElems.forEach((presetElement) => {
const themeKey = presetElement.dataset.key;
@@ -727,21 +736,20 @@ function initThemePicker() {
changeTheme(themeKey, function() {
isLoading = false;
pageData.theme = themeKey;
- presetElems.forEach((e) => { e.classList.remove("current"); });
+ syncThemePreset();
Array.from(themePreviewElems).forEach((preview) => {
- preview.querySelector(".theme-preset").replaceWith(
- presetElement.cloneNode(true)
- );
- })
-
- presetElems.forEach((e) => {
- if (e.dataset.key != themeKey) return;
- e.classList.add("current");
+ const button = preview.querySelector(".theme-preset");
+ const clone = presetElement.cloneNode(true);
+
+ clone.removeAttribute("aria-pressed");
+ clone.setAttribute("aria-label", "Change theme");
+
+ button.replaceWith(clone);
});
});
});
- })
+ });
}
async function setupPage() {
diff --git a/internal/glance/templates/monitor.html b/internal/glance/templates/monitor.html
index cbdcbae..414436d 100644
--- a/internal/glance/templates/monitor.html
+++ b/internal/glance/templates/monitor.html
@@ -5,9 +5,9 @@
<ul class="dynamic-columns list-gap-20 list-with-separator">
{{ range .Sites }}
{{ if and $.ShowFailingOnly (eq .StatusStyle "ok" ) }} {{ continue }} {{ end }}
- <div class="monitor-site flex items-center gap-15">
+ <li class="monitor-site flex items-center gap-15">
{{ template "site" . }}
- </div>
+ </li>
{{ end }}
</ul>
{{ else }}
diff --git a/internal/glance/templates/theme-preset-preview.html b/internal/glance/templates/theme-preset-preview.html
index ac17f98..cbeccff 100644
--- a/internal/glance/templates/theme-preset-preview.html
+++ b/internal/glance/templates/theme-preset-preview.html
@@ -12,7 +12,7 @@
{{- end }}
{{- end }}
{{- if .NegativeColor }}{{ $negative = .NegativeColor.String | safeCSS }}{{ end }}
-<button class="theme-preset{{ if .Light }} theme-preset-light{{ end }}" style="--color: {{ $background }}" data-key="{{ .Key }}">
+<button class="theme-preset{{ if .Light }} theme-preset-light{{ end }}" style="--color: {{ $background }}" data-key="{{ .Key }}" aria-label="{{ .Key }} theme">
<div class="theme-color" style="--color: {{ $primary }}"></div>
<div class="theme-color" style="--color: {{ $positive }}"></div>
<div class="theme-color" style="--color: {{ $negative }}"></div>