Skip to content

Commit

Permalink
refactor: improve a11y
Browse files Browse the repository at this point in the history
  • Loading branch information
splincode committed Oct 16, 2024
1 parent 2598626 commit 6cde29a
Show file tree
Hide file tree
Showing 48 changed files with 155 additions and 42 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand Down
4 changes: 3 additions & 1 deletion projects/core/components/textfield/textfield.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
Expand Down Expand Up @@ -81,6 +82,7 @@ export class TuiTextfieldComponent<T> implements TuiDataListHost<T> {
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() || '';
Expand Down
4 changes: 3 additions & 1 deletion projects/core/components/textfield/textfield.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
[iconStart]="icons.close"
(click)="directive?.setValue(null)"
(pointerdown.silent.prevent)="input?.nativeElement?.focus()"
></button>
>
{{ clear() }}
</button>
<ng-container #vcr />
<ng-content select="tui-icon" />
</span>
Expand Down
5 changes: 5 additions & 0 deletions projects/core/tokens/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ <h3>iOS</h3>

<tui-app-bar>
<button
title="Back"
tuiAppBarBack
tuiSlot="left"
type="button"
Expand Down Expand Up @@ -128,6 +129,7 @@ <h3 class="tui-space_top-8">Android</h3>

<tui-app-bar>
<button
title="Back"
tuiAppBarBack
tuiSlot="left"
type="button"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ <h3>Customization</h3>
<button
appearance=""
iconStart="@tui.settings"
title="Settings"
tuiIconButton
tuiSlot="right"
type="button"
Expand Down Expand Up @@ -111,6 +112,7 @@ <h3 class="tui-space_top-8">Centered Android</h3>

<tui-app-bar>
<button
title="Back"
tuiAppBarBack
tuiSlot="left"
type="button"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
type="button"
class="tui-space_right-4"
(click)="navigate(-1)"
></button>
>
Previous
</button>
<tui-carousel [(index)]="index">
<div *tuiItem>
<h2>Carousel is awesome</h2>
Expand Down Expand Up @@ -66,7 +68,9 @@ <h2>Buttons</h2>
type="button"
class="tui-space_left-4"
(click)="navigate(1)"
></button>
>
Next
</button>
</div>
<tui-pagination
size="s"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
[tuiAppearanceState]="open ? 'hover' : null"
[tuiDropdown]="content"
[(tuiDropdownOpen)]="open"
></button>
>
Open
</button>
<ng-template #content>
<tui-data-list
tuiDataListDropdownManager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ <h3>Multi select control</h3>
[tuiDropdown]="content"
[tuiDropdownMaxHeight]="500"
[(tuiDropdownOpen)]="control"
></button>
>
Open
</button>
<ng-template #content>
<tui-data-list [style.width.rem]="12">
<tui-opt-group
Expand Down Expand Up @@ -49,7 +51,9 @@ <h3>Separate toggles</h3>
[tuiDropdown]="separate"
[tuiDropdownMaxHeight]="500"
[(tuiDropdownOpen)]="label"
></button>
>
Open
</button>
<ng-template #separate>
<tui-data-list [style.width.rem]="10">
<label tuiOption>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
tuiIconButton
type="button"
(click)="decrease()"
></button>
>
Decrease
</button>
</span>
<span>20%</span>
<span>40%</span>
Expand All @@ -30,6 +32,8 @@
tuiIconButton
type="button"
(click)="increase()"
></button>
>
Increase
</button>
</span>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
type="button"
[style.border-radius.%]="100"
(click)="onClick()"
></button>
>
Calendar
</button>
<span
class="date"
[class.date_empty]="empty"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
type="button"
[style.border-radius.%]="100"
(click)="onClick()"
></button>
>
Calendar
</button>
<span
class="date"
[class.date_empty]="empty"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
[iconStart]="icon"
[tuiHint]="hintContent"
(click)="togglePasswordVisibility()"
></button>
>
Toggle password visibility
</button>
</ng-template>

<ng-template #hintContent>{{ hint }}</ng-template>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
type="button"
class="minus"
(click)="change(-0.25)"
></button>
>
Minus
</button>
<label
tuiSliderThumbLabel
class="slider-wrapper"
Expand Down Expand Up @@ -40,5 +42,7 @@
type="button"
class="plus"
(click)="change(+0.25)"
></button>
>
Plus
</button>
</section>
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,28 @@
tuiIconButton
tuiSwipeAction
type="button"
></button>
>
Show
</button>
<button
iconStart="@tui.pencil-line"
size="m"
tuiIconButton
tuiSwipeAction
type="button"
></button>
>
Edit
</button>
<button
appearance="secondary"
iconStart="@tui.share"
size="m"
tuiIconButton
tuiSwipeAction
type="button"
></button>
>
Share
</button>
</tui-swipe-actions>

<tui-swipe-actions>
Expand All @@ -60,7 +66,9 @@
tuiIconButton
tuiSwipeAction
type="button"
></button>
>
Show
</button>
</tui-swipe-actions>

<tui-swipe-actions
Expand Down Expand Up @@ -88,28 +96,36 @@
tuiIconButton
tuiSwipeAction
type="button"
></button>
>
Show
</button>
<button
iconStart="@tui.pencil-line"
size="s"
tuiIconButton
tuiSwipeAction
type="button"
></button>
>
Edit
</button>
<button
appearance="secondary"
iconStart="@tui.share"
size="s"
tuiIconButton
tuiSwipeAction
type="button"
></button>
>
Share
</button>
<button
appearance="destructive"
iconStart="@tui.trash"
size="s"
tuiIconButton
tuiSwipeAction
type="button"
></button>
>
Delete
</button>
</tui-swipe-actions>
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,7 @@ <h3 tuiTitle="m">Alex Inkin</h3>
tuiSwipeAction
type="button"
[style.borderRadius.%]="100"
></button>
>
Trash
</button>
</tui-swipe-actions>
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,28 @@
tuiIconButton
tuiSwipeAction
type="button"
></button>
>
Show
</button>
<button
iconStart="@tui.pencil-line"
size="m"
tuiIconButton
tuiSwipeAction
type="button"
></button>
>
Edit
</button>
<button
appearance="secondary"
iconStart="@tui.share"
size="m"
tuiIconButton
tuiSwipeAction
type="button"
></button>
>
Share
</button>
</tui-swipe-actions>

<tui-swipe-actions [autoClose]="true">
Expand All @@ -60,20 +66,26 @@
tuiIconButton
tuiSwipeAction
type="button"
></button>
>
Show
</button>
<button
iconStart="@tui.pencil-line"
size="m"
tuiIconButton
tuiSwipeAction
type="button"
></button>
>
Edit
</button>
<button
appearance="secondary"
iconStart="@tui.share"
size="m"
tuiIconButton
tuiSwipeAction
type="button"
></button>
>
Share
</button>
</tui-swipe-actions>
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
tuiIconButton
tuiSwipeAction
type="button"
></button>
>
Edit
</button>
<button
*ngIf="shareButton"
appearance="secondary"
Expand All @@ -30,7 +32,9 @@
tuiIconButton
tuiSwipeAction
type="button"
></button>
>
Share
</button>
</tui-swipe-actions>

<label>
Expand Down
Loading

0 comments on commit 6cde29a

Please sign in to comment.