From d7bbf2b8e23c3a483f86ad3ff369d124e6858128 Mon Sep 17 00:00:00 2001 From: Svilen Markov <7613769+svilenmarkov@users.noreply.github.com> Date: Wed, 12 Mar 2025 18:01:06 +0000 Subject: [PATCH] Accessibility improvements --- internal/glance/glance.go | 2 +- internal/glance/static/js/main.js | 5 +++++ internal/glance/static/main.css | 21 +++++++++++++++++---- internal/glance/templates/group.html | 17 +++++++++-------- internal/glance/templates/page.html | 20 +++++++++++--------- internal/glance/templates/widget-base.html | 4 ++-- internal/glance/widget.go | 4 ++-- 7 files changed, 47 insertions(+), 26 deletions(-) diff --git a/internal/glance/glance.go b/internal/glance/glance.go index b1fcc37..8fb3e40 100644 --- a/internal/glance/glance.go +++ b/internal/glance/glance.go @@ -68,7 +68,7 @@ func newApplication(config *config) (*application, error) { for w := range column.Widgets { widget := column.Widgets[w] - app.widgetByID[widget.id()] = widget + app.widgetByID[widget.GetID()] = widget widget.setProviders(providers) } diff --git a/internal/glance/static/js/main.js b/internal/glance/static/js/main.js index a10804e..dcd8946 100644 --- a/internal/glance/static/js/main.js +++ b/internal/glance/static/js/main.js @@ -284,7 +284,9 @@ function setupGroups() { for (let i = 0; i < titles.length; i++) { titles[i].classList.remove("widget-group-title-current"); + titles[i].setAttribute("aria-selected", "false"); tabs[i].classList.remove("widget-group-content-current"); + tabs[i].setAttribute("aria-hidden", "true"); } if (current < t) { @@ -296,7 +298,9 @@ function setupGroups() { current = t; title.classList.add("widget-group-title-current"); + title.setAttribute("aria-selected", "true"); tabs[t].classList.add("widget-group-content-current"); + tabs[t].setAttribute("aria-hidden", "false"); }); } } @@ -670,6 +674,7 @@ async function setupPage() { setupLazyImages(); } finally { pageElement.classList.add("content-ready"); + pageElement.setAttribute("aria-busy", "false"); for (let i = 0; i < contentReadyCallbacks.length; i++) { contentReadyCallbacks[i](); diff --git a/internal/glance/static/main.css b/internal/glance/static/main.css index a271d4a..c9c3c17 100644 --- a/internal/glance/static/main.css +++ b/internal/glance/static/main.css @@ -110,7 +110,7 @@ .visited-indicator:not(.text-truncate)::after, .visited-indicator.text-truncate::before, .bookmarks-link:not(.bookmarks-link-no-arrow)::after { - content: '↗'; + content: '↗' / ""; margin-left: 0.5em; display: inline-block; position: relative; @@ -189,7 +189,7 @@ } .expand-toggle-button-icon::before { - content: ''; + content: '' / ""; font-size: 0.8rem; transform: rotate(90deg); line-height: 1; @@ -341,6 +341,19 @@ html, body, .body-content { height: 100%; } +h1, h2, h3, h4, h5 { + font: inherit; +} + +.visually-hidden { + clip-path: inset(50%); + height: 1px; + overflow: hidden; + position: absolute; + white-space: nowrap; + width: 1px; +} + a { text-decoration: none; color: inherit; @@ -563,7 +576,7 @@ kbd:active { } .summary::after { - content: "◀"; + content: "◀" / ""; font-size: 1.2em; position: absolute; top: 0; @@ -822,7 +835,7 @@ details[open] .summary::after { } .list-horizontal-text > *:not(:last-child)::after { - content: '•'; + content: '•' / ""; color: var(--color-text-subdue); margin: 0 0.4rem; position: relative; diff --git a/internal/glance/templates/group.html b/internal/glance/templates/group.html index 646df2f..3a1fb79 100644 --- a/internal/glance/templates/group.html +++ b/internal/glance/templates/group.html @@ -4,17 +4,18 @@ {{ define "widget-content" }}
-
- {{ range $i, $widget := .Widgets }} - - {{ end }} +
+ {{- range $i, $widget := .Widgets }} + + {{- end }}
-{{ range $i, $widget := .Widgets }} -
{{ .Render }}
-{{ end }} +{{- range $i, $widget := .Widgets }} +
+ {{- .Render -}} +
+{{- end }}
- {{ end }} diff --git a/internal/glance/templates/page.html b/internal/glance/templates/page.html index e740d03..90f7177 100644 --- a/internal/glance/templates/page.html +++ b/internal/glance/templates/page.html @@ -25,7 +25,7 @@ {{ define "navigation-links" }} {{ range .App.Config.Pages }} -{{ .Title }} +{{ .Title }} {{ end }} {{ end }} @@ -35,10 +35,10 @@
- - +
{{ end }} @@ -57,17 +57,19 @@
-
+
+

{{ .Page.Title }}

-
+
Loading
+
-
+
{{ if not .App.Config.Branding.HideFooter }} -