@@ -2,6 +2,8 @@ import {ComponentInterface, h, Component, Element, Host, State} from '@stencil/c
22
33import i18n from '../../../../stores/i18n.store' ;
44import { AppIcon } from '../../../../components/core/app-icon/app-icon' ;
5+ import { EnvironmentAppConfig , EnvironmentAppConfigFeature } from '../../../../config/environment-config' ;
6+ import { EnvironmentConfigService } from '../../../../services/environment/environment-config.service' ;
57
68@Component ( {
79 tag : 'app-new' ,
@@ -13,42 +15,54 @@ export class AppNew implements ComponentInterface {
1315 @State ( )
1416 private type : 'deck' | 'doc' | undefined ;
1517
18+ private features : EnvironmentAppConfigFeature [ ] = EnvironmentConfigService . getInstance ( ) . get < EnvironmentAppConfig > ( 'app' ) . features ;
19+
1620 async closePopover ( confirm : boolean ) {
1721 if ( ! confirm ) {
1822 await ( this . el . closest ( 'ion-popover' ) as HTMLIonPopoverElement ) . dismiss ( ) ;
1923 return ;
2024 }
2125
22- await ( this . el . closest ( 'ion-popover' ) as HTMLIonPopoverElement ) . dismiss ( this . type ) ;
26+ await ( this . el . closest ( 'ion-popover' ) as HTMLIonPopoverElement ) . dismiss ( this . type || this . features [ 0 ] ) ;
2327 }
2428
2529 render ( ) {
2630 return (
2731 < Host >
28- < div class = "type" >
29- < div > { this . type === 'doc' && < mark > { i18n . state . tools . new_experimental } </ mark > } </ div >
30-
31- < article >
32- < button onClick = { ( ) => ( this . type = 'deck' ) } class = { `ion-activatable ${ this . type === 'deck' ? 'selected' : '' } ` } >
33- < ion-ripple-effect > </ ion-ripple-effect >
34- < AppIcon name = "deck" path = "icons" ariaLabel = "" ariaHidden = { true } lazy = { false } slot = "start" > </ AppIcon >
35- < ion-label > { i18n . state . tools . new_deck } </ ion-label >
36- </ button >
37- </ article >
38-
39- < article >
40- < button onClick = { ( ) => ( this . type = 'doc' ) } class = { `ion-activatable ${ this . type === 'doc' ? 'selected' : '' } ` } >
41- < ion-ripple-effect > </ ion-ripple-effect >
42- < AppIcon name = "doc" path = "icons" ariaLabel = "" ariaHidden = { true } lazy = { false } slot = "start" > </ AppIcon >
43- < ion-label > { i18n . state . tools . new_doc } </ ion-label >
44- </ button >
45- </ article >
46- </ div >
32+ { this . renderTypes ( ) }
4733
4834 < p > { i18n . state . tools . new_warning_text } </ p >
4935
5036 < app-popover-confirm onConfirm = { ( { detail} : CustomEvent < boolean > ) => this . closePopover ( detail ) } > </ app-popover-confirm >
5137 </ Host >
5238 ) ;
5339 }
40+
41+ private renderTypes ( ) {
42+ if ( this . features . length === 1 ) {
43+ return undefined ;
44+ }
45+
46+ return (
47+ < div class = "type" >
48+ < div > { this . type === 'doc' && < mark > { i18n . state . tools . new_experimental } </ mark > } </ div >
49+
50+ < article >
51+ < button onClick = { ( ) => ( this . type = 'deck' ) } class = { `ion-activatable ${ this . type === 'deck' ? 'selected' : '' } ` } >
52+ < ion-ripple-effect > </ ion-ripple-effect >
53+ < AppIcon name = "deck" path = "icons" ariaLabel = "" ariaHidden = { true } lazy = { false } slot = "start" > </ AppIcon >
54+ < ion-label > { i18n . state . tools . new_deck } </ ion-label >
55+ </ button >
56+ </ article >
57+
58+ < article >
59+ < button onClick = { ( ) => ( this . type = 'doc' ) } class = { `ion-activatable ${ this . type === 'doc' ? 'selected' : '' } ` } >
60+ < ion-ripple-effect > </ ion-ripple-effect >
61+ < AppIcon name = "doc" path = "icons" ariaLabel = "" ariaHidden = { true } lazy = { false } slot = "start" > </ AppIcon >
62+ < ion-label > { i18n . state . tools . new_doc } </ ion-label >
63+ </ button >
64+ </ article >
65+ </ div >
66+ ) ;
67+ }
5468}
0 commit comments