Skip to content

Commit

Permalink
feat: aria translation
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Pajung authored and nowseemee committed Aug 2, 2021
1 parent 6260826 commit a41d150
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,13 @@ export class ToggleButton {
@Prop() styles?: string;
/** (optional) position within group */
@Prop() position?: number;
/** (optional) translation of 'selected */
@Prop() ariaLangSelected? = 'selected';
/** (optional) translation of 'deselected */
@Prop() ariaLangDeselected? = 'deselected';
/** a11y text for getting meaningful value. `$buttonNumber` and `$selected` are template variables and will be replaces by their corresponding properties. */
@Prop() ariaDescriptionTranslation =
'button at position $position; selected: $selected';
'button at position $position; $selected';
/** Emitted when button is clicked */
@Event() scaleClick!: EventEmitter<{ id: string; selected: boolean }>;

Expand All @@ -88,7 +92,7 @@ export class ToggleButton {
getAriaDescriptionTranslation() {
const filledText = this.ariaDescriptionTranslation
.replace(/\$position/g, `${this.position}`)
.replace(/\$selected/g, `${this.selected}`);
.replace(/\$selected/g, `${this.selected ? this.ariaLangSelected : this.ariaLangDeselected}`);
return filledText;
}

Expand Down

0 comments on commit a41d150

Please sign in to comment.