Skip to content

Commit

Permalink
Merge pull request #1465 from maykinmedia/issue/2367-A11y-toggle-enla…
Browse files Browse the repository at this point in the history
…rgefont-attribute

♿  [#2367] Fix data-attributes for toggling larger font
  • Loading branch information
alextreme authored Oct 28, 2024
2 parents 91da9fe + 42c2a85 commit 295ce5c
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/open_inwoner/js/components/accessibility/enlarge_font.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export class EnlargeFont {
this.root.style.getPropertyValue(this.styles.bodyFontSizeDefault) ===
this.enlargeSizes.default

// Loop through all styles and set either the enlarged size or the base size
Object.keys(this.styles).forEach((key) => {
const sizeKey = this.getSizeKey(key)
this.root.style.setProperty(
Expand All @@ -78,12 +79,20 @@ export class EnlargeFont {
)
})

this.text.innerText = isEnlarged
? this.node.dataset.text
: this.node.dataset.altText
this.icon.innerText = isEnlarged
? this.node.dataset.icon
: this.node.dataset.altIcon
// Update text, aria-label, and title based on the state
if (isEnlarged) {
// Set back to original state
this.text.innerText = this.node.dataset.text
this.node.setAttribute('aria-label', this.node.dataset.text)
this.node.setAttribute('title', this.node.dataset.text)
this.icon.innerText = this.node.dataset.icon
} else {
// Switch to larger font state
this.text.innerText = this.node.dataset.altText
this.node.setAttribute('aria-label', this.node.dataset.altText)
this.node.setAttribute('title', this.node.dataset.altText)
this.icon.innerText = this.node.dataset.altIcon
}
}
}

Expand Down

0 comments on commit 295ce5c

Please sign in to comment.