Skip to content

Commit 7ce23de

Browse files
committed
feat(components): implementa alternância no nível de acessibilidade
Implementa alternância no nível de acessibilidade dos componentes de formulário. fixes DTHFUI-10108
1 parent b575168 commit 7ce23de

File tree

424 files changed

+81362
-2009
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

424 files changed

+81362
-2009
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ projects/portal/src/app/guide/menu-guides.service.ts
5858
projects/portal/src/app/documentation/samples/
5959
projects/portal/src/app/menu.service.ts
6060
projects/portal/src/assets/json/api-list.json
61+
projects/portal/src/assets/json/icons-fill.json
62+
projects/portal/src/assets/json/icons-regular.json
6163
projects/portal/src/assets/json/version.json
6264
projects/portal/src/app/documentation/documentation-routing.module.ts
6365

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ yarn global add @angular/cli@19
3939
O [Angular CLI](https://cli.angular.io/) se encarrega de construir toda estrutura inicial do projeto. Para isso, execute o seguinte comando:
4040

4141
```
42-
ng new my-po-project --skipInstall
42+
ng new my-po-project --skip-install
4343
```
4444

4545
> O parâmetro `--skip-install` permite criar o projeto, contudo, não instalará as dependências automaticamente.

projects/portal/src/app/app.component.ts

+51-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import { Component, OnDestroy, OnInit } from '@angular/core';
22
import { Router } from '@angular/router';
33

4-
import { PoMenuItem, PoNavbarIconAction, PoNavbarItem, PoNotificationService } from '@po-ui/ng-components';
4+
import {
5+
PoMenuItem,
6+
PoNavbarIconAction,
7+
PoNavbarItem,
8+
PoNotificationService,
9+
PoThemeA11yEnum
10+
} from '@po-ui/ng-components';
511

612
import { PoThemeService, PoThemeTypeEnum } from '../../../ui/src/lib';
713
import { poThemeConstant } from './shared/po-theme.constant';
@@ -19,11 +25,14 @@ export class AppComponent implements OnInit, OnDestroy {
1925
items: Array<PoNavbarItem> = [];
2026
iconActions: Array<PoNavbarIconAction> = [];
2127
themeStorage = 'po-theme-default';
28+
a11yStorage = 'po-a11y-AAA';
2229
logoPoUI = './assets/po-logos/po_black.png';
2330
theme: PoThemeTypeEnum = 0;
31+
a11y: PoThemeA11yEnum = PoThemeA11yEnum.AAA;
2432

2533
private location;
2634
private themeChangeListener: any;
35+
private a11yChangeListener: any;
2736

2837
constructor(
2938
private versionService: VersionService,
@@ -34,7 +43,7 @@ export class AppComponent implements OnInit, OnDestroy {
3443
const _poTheme = this.poTheme.applyTheme();
3544
if (!_poTheme) {
3645
this.theme = poThemeConstant.active;
37-
this.poTheme.setTheme(poThemeConstant, this.theme);
46+
this.poTheme.setTheme(poThemeConstant, this.theme, this.a11y);
3847
} else {
3948
this.theme = typeof _poTheme.active === 'object' ? _poTheme.active.type : _poTheme.active;
4049
}
@@ -45,6 +54,10 @@ export class AppComponent implements OnInit, OnDestroy {
4554
this.themeStorage = localStorage.getItem('po-ui-theme');
4655
}
4756

57+
if (localStorage.getItem('po-ui-a11y')) {
58+
this.a11yStorage = localStorage.getItem('po-ui-a11y');
59+
}
60+
4861
const version = await this.versionService.getCurrentVersion().toPromise();
4962

5063
this.items = [
@@ -67,7 +80,13 @@ export class AppComponent implements OnInit, OnDestroy {
6780
this.themeChangeListener = () => {
6881
this.changeTheme(false);
6982
};
83+
84+
this.a11yChangeListener = () => {
85+
this.changeA11yLevel(false);
86+
};
87+
7088
window.addEventListener('po-sample-change-theme', this.themeChangeListener);
89+
window.addEventListener('po-sample-change-a11y', this.a11yChangeListener);
7190
}
7291

7392
openExternalLink(url) {
@@ -82,27 +101,52 @@ export class AppComponent implements OnInit, OnDestroy {
82101
this.themeStorage === 'po-theme-default' ? './assets/po-logos/po_black.png' : './assets/po-logos/po_white.png';
83102
this.iconActions = this.actions;
84103

85-
this.poTheme.setTheme(poThemeConstant, this.theme);
104+
this.poTheme.setTheme(poThemeConstant, this.theme, this.a11y);
86105

87106
if (dispatchEvent) {
88107
window.dispatchEvent(new Event(this.themeStorage));
89108
}
90109
}
91110

111+
changeA11yLevel(dispatchEvent = true) {
112+
this.a11yStorage = this.a11yStorage === 'po-a11y-AAA' ? 'po-a11y-AA' : 'po-a11y-AAA';
113+
localStorage.setItem('po-ui-a11y', this.a11yStorage);
114+
this.a11y = this.a11yStorage === 'po-a11y-AAA' ? PoThemeA11yEnum.AAA : PoThemeA11yEnum.AA;
115+
this.iconActions = this.actions;
116+
117+
this.poTheme.setTheme(poThemeConstant, this.theme, this.a11y);
118+
119+
if (dispatchEvent) {
120+
window.dispatchEvent(new Event(this.a11yStorage));
121+
}
122+
}
123+
92124
get actions() {
93125
return [
94-
{ icon: 'an an-github-logo', link: 'https://github.com/po-ui', label: 'Github' },
95-
{ icon: 'an an-x-logo', link: 'https://twitter.com/@pouidev', label: 'Twitter' },
96-
{ icon: 'an an-instagram-logo', link: 'https://www.instagram.com/pouidev/', label: 'Instagram' },
126+
{ icon: 'an an-github-logo', link: 'https://github.com/po-ui', label: 'Github', tooltip: 'Github' },
127+
{
128+
icon: 'an an-instagram-logo',
129+
link: 'https://www.instagram.com/pouidev/',
130+
label: 'Instagram',
131+
tooltip: 'Instagram'
132+
},
97133
{
98134
icon: `${this.themeStorage === 'po-theme-dark' ? 'an an-sun' : 'an an-moon'}`,
99-
label: 'tema',
135+
label: `Theme ${this.themeStorage === 'po-theme-dark' ? 'Light' : 'Dark'}`,
136+
tooltip: `Theme ${this.themeStorage === 'po-theme-dark' ? 'Dark' : 'Light'}`,
100137
action: this.changeTheme.bind(this)
138+
},
139+
{
140+
icon: `${this.a11yStorage === 'po-a11y-AAA' ? 'an-fill an-text-aa' : 'an an-text-aa'}`,
141+
label: `Accessibility level ${this.a11yStorage === 'po-a11y-AAA' ? 'AA' : 'AAA'}`,
142+
tooltip: `Accessibility level ${this.a11yStorage === 'po-a11y-AAA' ? 'AAA' : 'AA'}`,
143+
action: this.changeA11yLevel.bind(this)
101144
}
102145
];
103146
}
104147

105148
ngOnDestroy(): void {
106149
window.removeEventListener('po-sample-change-theme', this.themeChangeListener);
150+
window.removeEventListener('po-sample-change-a11y', this.a11yChangeListener);
107151
}
108152
}

0 commit comments

Comments
 (0)