7
7
*/
8
8
9
9
import { Direction , Directionality } from '@angular/cdk/bidi' ;
10
-
11
10
import {
12
11
ChangeDetectionStrategy ,
13
12
ChangeDetectorRef ,
@@ -25,7 +24,9 @@ import {MatListModule} from '@angular/material/list';
25
24
import { MatSidenavModule } from '@angular/material/sidenav' ;
26
25
import { MatToolbarModule } from '@angular/material/toolbar' ;
27
26
import { MatTooltip , MatTooltipModule } from '@angular/material/tooltip' ;
28
- import { RouterModule } from '@angular/router' ;
27
+ import { ActivatedRoute , RouterModule } from '@angular/router' ;
28
+ import { Observable } from 'rxjs' ;
29
+ import { map } from 'rxjs/operators' ;
29
30
import { getAppState , setAppState } from './dev-app-state' ;
30
31
import { DevAppRippleOptions } from './ripple-options' ;
31
32
import { DevAppDirectionality } from './dev-app-directionality' ;
@@ -54,8 +55,10 @@ export class DevAppLayout {
54
55
private _changeDetectorRef = inject ( ChangeDetectorRef ) ;
55
56
private _document = inject ( DOCUMENT ) ;
56
57
private _iconRegistry = inject ( MatIconRegistry ) ;
58
+ private _route = inject ( ActivatedRoute ) ;
57
59
58
60
state = getAppState ( ) ;
61
+ testMode : Observable < boolean > ;
59
62
navItems = [
60
63
{ name : 'Examples' , route : '/examples' } ,
61
64
{ name : 'CDK Dialog' , route : '/cdk-dialog' } ,
@@ -135,6 +138,7 @@ export class DevAppLayout {
135
138
readonly isZoneless = this . _ngZone instanceof ɵNoopNgZone ;
136
139
137
140
constructor ( ) {
141
+ this . testMode = this . _route . queryParams . pipe ( map ( params => params [ 'testonly' ] === 'true' ) ) ;
138
142
this . toggleTheme ( this . state . darkTheme ) ;
139
143
this . toggleSystemTheme ( this . state . systemTheme ) ;
140
144
this . toggleStrongFocus ( this . state . strongFocusEnabled ) ;
@@ -143,6 +147,14 @@ export class DevAppLayout {
143
147
this . toggleDirection ( this . state . direction ) ;
144
148
this . toggleM3 ( this . state . m3Enabled ) ;
145
149
this . toggleColorApiBackCompat ( this . state . colorApiBackCompat ) ;
150
+
151
+ this . testMode . subscribe ( isTestOnly => {
152
+ if ( isTestOnly ) {
153
+ this . toggleM3 ( true ) ;
154
+ this . toggleSystemTheme ( true ) ;
155
+ this . _document . body . classList . add ( 'demo-testonly-mode' ) ;
156
+ }
157
+ } ) ;
146
158
}
147
159
148
160
toggleTheme ( value = ! this . state . darkTheme ) {
0 commit comments