11import { Component , OnDestroy , OnInit } from '@angular/core' ;
22import { Router } from '@angular/router' ;
33
4- import {
5- PoMenuItem ,
6- PoNavbarIconAction ,
7- PoNavbarItem ,
8- PoNotificationService ,
9- PoThemeA11yEnum
10- } from '@po-ui/ng-components' ;
4+ import { PoMenuItem , PoNavbarIconAction , PoNavbarItem , PoThemeA11yEnum } from '@po-ui/ng-components' ;
115
6+ import { PoDensityMode } from 'projects/ui/src/lib/enums/po-density-mode.enum' ;
7+ import { firstValueFrom } from 'rxjs' ;
128import { PoThemeService , PoThemeTypeEnum } from '../../../ui/src/lib' ;
139import { poThemeConstant } from './shared/po-theme.constant' ;
1410import { VersionService } from './shared/version.service' ;
1511
16- const KEY_STORAGE_REVIEW_SURVEY = 'review_survey_po_ui' ;
17-
1812@Component ( {
1913 selector : 'app-root' ,
2014 templateUrl : './app.component.html' ,
@@ -30,14 +24,12 @@ export class AppComponent implements OnInit, OnDestroy {
3024 theme : PoThemeTypeEnum = 0 ;
3125 a11yLevel : PoThemeA11yEnum ;
3226
33- private location ;
3427 private themeChangeListener : any ;
3528 private a11yChangeListener : any ;
3629
3730 constructor (
38- private versionService : VersionService ,
39- private notification : PoNotificationService ,
40- private poTheme : PoThemeService ,
31+ protected versionService : VersionService ,
32+ protected poTheme : PoThemeService ,
4133 public router : Router
4234 ) {
4335 const _poTheme = this . poTheme . applyTheme ( ) ;
@@ -50,12 +42,15 @@ export class AppComponent implements OnInit, OnDestroy {
5042 this . theme = typeof _poTheme . active === 'object' ? _poTheme . active . type : _poTheme . active ;
5143 }
5244
53- if ( this . a11yLevel === 'AA' ) {
45+ if ( this . a11yLevel === PoThemeA11yEnum . AA ) {
5446 this . poTheme . setA11yDefaultSizeSmall ( true ) ;
47+ this . poTheme . setDensityMode ( PoDensityMode . Small ) ;
48+ } else {
49+ this . poTheme . setDensityMode ( PoDensityMode . Medium ) ;
5550 }
5651 }
5752
58- async ngOnInit ( ) {
53+ ngOnInit ( ) {
5954 if ( localStorage . getItem ( 'po-ui-theme' ) ) {
6055 this . themeStorage = localStorage . getItem ( 'po-ui-theme' ) ;
6156 }
@@ -64,20 +59,20 @@ export class AppComponent implements OnInit, OnDestroy {
6459 this . a11yStorage = localStorage . getItem ( 'po-ui-a11y' ) ;
6560 }
6661
67- const version = await this . versionService . getCurrentVersion ( ) . toPromise ( ) ;
68-
69- this . items = [
70- { label : 'Iniciar ' , link : '/' } ,
71- { label : 'Componentes ' , link : '/documentation ' } ,
72- { label : 'Guias ' , link : '/guides ' } ,
73- { label : 'Ícones ' , link : '/icons ' } ,
74- { label : 'Ferramentas ' , link : '/tools ' } ,
75- { label : 'Construtor de temas ' , link : '/construtor-de-temas ' } ,
76- { label : 'Como contribuir ' , link : 'https://github.com/po-ui/po-angular/blob/master/CONTRIBUTING.md ' } ,
77- { label : 'Licença ' , link : 'https://github.com/po-ui/po-angular/blob/master/LICENSE ' } ,
78- { label : 'Core Team' , link : 'https://github.com/orgs/ po-ui/people ' } ,
79- { label : `v ${ version } ` , link : 'https://github.com/po-ui/po-angular/blob/master/CHANGELOG.md' }
80- ] ;
62+ firstValueFrom ( this . versionService . getCurrentVersion ( ) ) . then ( version => {
63+ this . items = [
64+ { label : 'Iniciar' , link : '/' } ,
65+ { label : 'Componentes ' , link : '/documentation ' } ,
66+ { label : 'Guias ' , link : '/guides ' } ,
67+ { label : 'Ícones ' , link : '/icons ' } ,
68+ { label : 'Ferramentas ' , link : '/tools ' } ,
69+ { label : 'Construtor de temas ' , link : '/construtor-de-temas ' } ,
70+ { label : 'Como contribuir ' , link : 'https://github.com/po-ui/po-angular/blob/master/CONTRIBUTING.md ' } ,
71+ { label : 'Licença ' , link : 'https://github.com/po-ui/po-angular/blob/master/LICENSE ' } ,
72+ { label : 'Core Team ' , link : 'https://github.com/orgs/ po-ui/people ' } ,
73+ { label : `v ${ version } ` , link : 'https://github.com/po-ui/po-angular/blob/master/CHANGELOG.md ' }
74+ ] ;
75+ } ) ;
8176
8277 this . iconActions = this . actions ;
8378 this . logoPoUI =
@@ -111,7 +106,7 @@ export class AppComponent implements OnInit, OnDestroy {
111106
112107 this . poTheme . setTheme ( poThemeConstant , this . theme , this . a11yLevel ) ;
113108
114- if ( this . a11yLevel === 'AA' ) {
109+ if ( this . a11yLevel === PoThemeA11yEnum . AA ) {
115110 this . poTheme . setA11yDefaultSizeSmall ( true ) ;
116111 }
117112
@@ -128,8 +123,11 @@ export class AppComponent implements OnInit, OnDestroy {
128123
129124 this . poTheme . setTheme ( poThemeConstant , this . theme , this . a11yLevel ) ;
130125
131- if ( this . a11yLevel === 'AA' ) {
126+ if ( this . a11yLevel === PoThemeA11yEnum . AA ) {
132127 this . poTheme . setA11yDefaultSizeSmall ( true ) ;
128+ this . poTheme . setDensityMode ( PoDensityMode . Small ) ;
129+ } else {
130+ this . poTheme . setDensityMode ( PoDensityMode . Medium ) ;
133131 }
134132
135133 if ( dispatchEvent ) {
@@ -156,8 +154,8 @@ export class AppComponent implements OnInit, OnDestroy {
156154 } ,
157155 {
158156 icon : `${ this . a11yStorage === 'po-a11y-AAA' ? 'an-fill an-text-aa' : 'an an-text-aa' } ` ,
159- label : `Accessibility level ${ this . a11yStorage === 'po-a11y-AAA' ? 'AA' : ' AAA' } ` ,
160- tooltip : `Accessibility level ${ this . a11yStorage === 'po-a11y-AAA' ? ' AAA' : 'AA' } ` ,
157+ label : `Accessibility level ${ this . a11yStorage === 'po-a11y-AAA' ? PoThemeA11yEnum . AA : PoThemeA11yEnum . AAA } ` ,
158+ tooltip : `Accessibility level ${ this . a11yStorage === 'po-a11y-AAA' ? PoThemeA11yEnum . AAA : PoThemeA11yEnum . AA } ` ,
161159 action : this . changeA11yLevel . bind ( this )
162160 }
163161 ] ;
0 commit comments