A11y: improve flow with screenreader, some more refactoring to svelte, see #1181

This commit is contained in:
Pieter Vander Vennet 2023-12-13 02:16:53 +01:00
parent 40067e35d4
commit 48ac539272
15 changed files with 188 additions and 226 deletions

View file

@ -1,20 +1,17 @@
import { Translation } from "../UI/i18n/Translation"
export function ariaLabel(htmlElement: Element, t: Translation) {
let onDestroy: () => void = undefined
let destroy: () => void = undefined
t.current.map(
(label) => {
console.log("Setting arialabel", label, "to", htmlElement)
htmlElement.setAttribute("aria-label", label)
},
[],
(f) => {
onDestroy = f
destroy = f
}
)
return {
destroy() {},
}
return { destroy }
}

17
src/Utils/placeholder.ts Normal file
View file

@ -0,0 +1,17 @@
import { Translation } from "../UI/i18n/Translation"
export function placeholder(htmlElement: HTMLInputElement, t: Translation) {
let destroy: () => void = undefined
t.current.map(
(label) => {
htmlElement.setAttribute("placeholder", label)
},
[],
(f) => {
destroy = f
}
)
return { destroy }
}