lang selector aria and ids

This commit is contained in:
Tykayn 2022-02-15 12:32:27 +01:00 committed by tykayn
parent 00a2dd7e1d
commit 5d25754c16
4 changed files with 57 additions and 36 deletions

View File

@ -82,11 +82,7 @@
>
<ng-template pTemplate="titlebar">
<div class="columns">
<div class="column">
<h1 class="title">
{{ 'hours.modal.title' | translate }}
</h1>
</div>
<div class="column"></div>
<div class="column is-narrow">
<button
id="close_dialog"
@ -97,7 +93,9 @@
</button>
</div>
</div>
<h1 class="title">
{{ 'hours.modal.title' | translate }}
</h1>
<section class="same-time-slices">
<section class="same-time-slices">
<section class="proposals" *ngIf="environment.creation_display_proposals_time_slices">

View File

@ -3,6 +3,7 @@
id="lang_button_popup{{ idSuffix }}"
class="lang-button"
(click)="openDialogLang()"
[attr.aria-controls]="'lang_selector_modale'"
[attr.aria-label]="'LANGUAGES.' + currentLang.toUpperCase() | translate"
>
<i class="fa fa-language"></i>
@ -22,22 +23,31 @@
[draggable]="false"
[showHeader]="false"
[resizable]="true"
[attr.aria-labelledby]="'popup.languages.title' | translate"
role="dialog"
id="lang_selector_modale"
>
<ng-template pTemplate="titlebar">
<div class="columns">
<div class="column">
<div class="top">
<button
id="close_dialog{{ idSuffix }}"
class="button cancel-button-reject pull-right img-marged-left"
lang="{{ currentLang }}"
(click)="focusOnCancelButton()"
>
{{ 'SENTENCES.Close' | translate }}
<img class="icon" src="assets/icons/x_blue.svg" />
</button>
</div>
<h2 class="title is-2 has-text-left">
</div>
</div>
<h1 class="title is-2 has-text-left" id="lang_selector_modale_title">
{{ 'popup.languages.title' | translate }}
</h2>
</h1>
<div class="list-of-langs">
<button
class="lang-element button"
[ngClass]="{ 'is-primary': language_to_apply === language, 'is-current': language === currentLang }"
@ -49,14 +59,18 @@
{{ language }} -
{{ 'LANGUAGES.' + language.toUpperCase() | translate }}
</button>
</div>
</ng-template>
<ng-template pTemplate="footer">
<button class="button" (click)="applyLangAndClosePopup()">
<div class="buttons-bottom">
<button class="button" (click)="applyLangAndClosePopup()" lang="{{ currentLang }}">
{{ 'SENTENCES.Cancel' | translate }}
</button>
<button class="button is-primary" (click)="applyLangAndClosePopup()">
<button class="button is-primary" (click)="applyLangAndClosePopup()" lang="{{ currentLang }}">
{{ 'nav.save' | translate }}
</button>
</div>
</ng-template>
</p-dialog>
</div>

View File

@ -35,7 +35,14 @@
.lang-element {
float: left;
margin: 0.5em;
min-width: 11em;
min-width: 8em;
border: 0;
border-radius: 2rem;
padding: 0.5rem 0.25rem;
&:hover {
background: $d-neutral;
}
}
.is-current {

View File

@ -1,4 +1,4 @@
import { Component, Inject, Input, OnInit } from '@angular/core';
import { ChangeDetectorRef, Component, Inject, Input, OnInit } from '@angular/core';
import { LanguageEnum } from '../../../../core/enums/language.enum';
import { LanguageService } from '../../../../core/services/language.service';
@ -23,6 +23,7 @@ export class LanguageSelectorComponent implements OnInit {
private languageService: LanguageService,
private storageService: StorageService,
private pollService: PollService,
private cd: ChangeDetectorRef,
@Inject(DOCUMENT) private document: any
) {}
@ -78,7 +79,8 @@ export class LanguageSelectorComponent implements OnInit {
openDialogLang() {
this.display_lang_dialog = true;
let elem = this.document.querySelector('#lang_button_popup');
this.cd.detectChanges();
let elem = this.document.querySelector('#close_dialog');
if (elem) {
elem.focus();
}