From 6cde29ab4948fcc9f2685f8f5bd2fdaaf61ff8f3 Mon Sep 17 00:00:00 2001 From: splincode Date: Fri, 11 Oct 2024 12:36:11 +0300 Subject: [PATCH] refactor: improve a11y --- package.json | 3 +- .../textfield/textfield.component.ts | 4 ++- .../textfield/textfield.template.html | 4 ++- projects/core/tokens/i18n.ts | 5 +++ .../components/app-bar/examples/1/index.html | 2 ++ .../components/app-bar/examples/3/index.html | 2 ++ .../components/carousel/examples/4/index.html | 8 +++-- .../data-list/examples/2/index.html | 4 ++- .../data-list/examples/3/index.html | 8 +++-- .../input-slider/examples/2/index.html | 8 +++-- .../mobile-calendar/examples/4/index.html | 4 ++- .../mobile-calendar/examples/5/index.html | 4 ++- .../primitive-textfield/examples/1/index.html | 4 ++- .../components/slider/examples/6/index.html | 8 +++-- .../swipe-action/examples/1/index.html | 32 ++++++++++++++----- .../swipe-action/examples/2/index.html | 4 ++- .../swipe-action/examples/3/index.html | 24 ++++++++++---- .../swipe-action/examples/4/index.html | 8 +++-- .../swipe-action/examples/5/index.html | 12 +++++-- .../components/tag/examples/3/index.html | 4 ++- .../components/tag/examples/6/index.html | 8 +++-- .../dropdown-hover/examples/2/index.html | 1 + .../dropdown-open/examples/4/index.html | 4 ++- projects/i18n/languages/belarusian/core.ts | 1 + projects/i18n/languages/chinese/core.ts | 1 + projects/i18n/languages/dutch/core.ts | 1 + projects/i18n/languages/english/core.ts | 1 + projects/i18n/languages/french/core.ts | 1 + projects/i18n/languages/german/core.ts | 1 + projects/i18n/languages/hebrew/core.ts | 1 + projects/i18n/languages/italian/core.ts | 1 + projects/i18n/languages/japan/core.ts | 1 + projects/i18n/languages/kazakh/core.ts | 1 + projects/i18n/languages/korean/core.ts | 1 + projects/i18n/languages/lithuanian/core.ts | 1 + projects/i18n/languages/malay/core.ts | 1 + projects/i18n/languages/polish/core.ts | 1 + projects/i18n/languages/portuguese/core.ts | 1 + projects/i18n/languages/russian/core.ts | 1 + projects/i18n/languages/spanish/core.ts | 1 + projects/i18n/languages/turkish/core.ts | 1 + projects/i18n/languages/ukrainian/core.ts | 1 + projects/i18n/languages/vietnamese/core.ts | 1 + projects/i18n/types/language.ts | 1 + .../pagination/pagination.style.less | 1 + .../pagination/pagination.template.html | 4 ++- .../tree-item-content.component.ts | 2 ++ .../tree-item-content.template.html | 4 ++- 48 files changed, 155 insertions(+), 42 deletions(-) diff --git a/package.json b/package.json index 0f894356827fb..c2a7a4e6229de 100644 --- a/package.json +++ b/package.json @@ -87,8 +87,7 @@ "i18n/no-russian-character": "off", "i18n/no-thai-character": "off", "jest/prefer-importing-jest-globals": "off", - "sonarjs/prefer-nullish-coalescing": "off", - "@angular-eslint/template/elements-content": "off" + "sonarjs/prefer-nullish-coalescing": "off" }, "overrides": [ { diff --git a/projects/core/components/textfield/textfield.component.ts b/projects/core/components/textfield/textfield.component.ts index 6c8bf06b0eede..d72428928aae9 100644 --- a/projects/core/components/textfield/textfield.component.ts +++ b/projects/core/components/textfield/textfield.component.ts @@ -13,6 +13,7 @@ import { ViewContainerRef, ViewEncapsulation, } from '@angular/core'; +import {toSignal} from '@angular/core/rxjs-interop'; import {NgControl} from '@angular/forms'; import {WaResizeObserver} from '@ng-web-apis/resize-observer'; import {tuiInjectId} from '@taiga-ui/cdk/services'; @@ -31,7 +32,7 @@ import { TuiWithDropdownOpen, } from '@taiga-ui/core/directives/dropdown'; import {TuiWithIcons} from '@taiga-ui/core/directives/icons'; -import {TUI_COMMON_ICONS} from '@taiga-ui/core/tokens'; +import {TUI_CLEAR_WORD, TUI_COMMON_ICONS} from '@taiga-ui/core/tokens'; import type {TuiSizeL, TuiSizeS} from '@taiga-ui/core/types'; import type {PolymorpheusContent} from '@taiga-ui/polymorpheus'; import {PolymorpheusOutlet} from '@taiga-ui/polymorpheus'; @@ -81,6 +82,7 @@ export class TuiTextfieldComponent implements TuiDataListHost { protected readonly control?: NgControl; protected readonly icons = inject(TUI_COMMON_ICONS); + protected readonly clear = toSignal(inject(TUI_CLEAR_WORD)); protected computedFiller = computed(() => { const value = this.directive?.nativeValue() || ''; diff --git a/projects/core/components/textfield/textfield.template.html b/projects/core/components/textfield/textfield.template.html index aba2f6b964ca7..32ddda880a7a2 100644 --- a/projects/core/components/textfield/textfield.template.html +++ b/projects/core/components/textfield/textfield.template.html @@ -18,7 +18,9 @@ [iconStart]="icons.close" (click)="directive?.setValue(null)" (pointerdown.silent.prevent)="input?.nativeElement?.focus()" - > + > + {{ clear() }} + diff --git a/projects/core/tokens/i18n.ts b/projects/core/tokens/i18n.ts index df553ddf237f8..f5f61cf6789a4 100644 --- a/projects/core/tokens/i18n.ts +++ b/projects/core/tokens/i18n.ts @@ -11,6 +11,11 @@ export const TUI_MONTHS = tuiCreateTokenFromFactory(tuiExtractI18n('months')); */ export const TUI_CLOSE_WORD = tuiCreateTokenFromFactory(tuiExtractI18n('close')); +/** + * i18n 'clear' word + */ +export const TUI_CLEAR_WORD = tuiCreateTokenFromFactory(tuiExtractI18n('clear')); + /** * i18n 'Nothing found' message */ diff --git a/projects/demo/src/modules/components/app-bar/examples/1/index.html b/projects/demo/src/modules/components/app-bar/examples/1/index.html index 45a62a964c05a..8deb7091b4983 100644 --- a/projects/demo/src/modules/components/app-bar/examples/1/index.html +++ b/projects/demo/src/modules/components/app-bar/examples/1/index.html @@ -37,6 +37,7 @@

iOS

+ > + Previous +

Carousel is awesome

@@ -66,7 +68,9 @@

Buttons

type="button" class="tui-space_left-4" (click)="navigate(1)" - > + > + Next +
+> + Open + Multi select control [tuiDropdown]="content" [tuiDropdownMaxHeight]="500" [(tuiDropdownOpen)]="control" -> +> + Open + Separate toggles [tuiDropdown]="separate" [tuiDropdownMaxHeight]="500" [(tuiDropdownOpen)]="label" -> +> + Open + {{ hint }} diff --git a/projects/demo/src/modules/components/slider/examples/6/index.html b/projects/demo/src/modules/components/slider/examples/6/index.html index dc815b9489991..9ca6ca1fd93d6 100644 --- a/projects/demo/src/modules/components/slider/examples/6/index.html +++ b/projects/demo/src/modules/components/slider/examples/6/index.html @@ -7,7 +7,9 @@ type="button" class="minus" (click)="change(-0.25)" - > + > + Minus +