@@ -107,8 +107,16 @@ export class MdJsPreview extends ScopedElementsMixin(LitElement) {
107
107
// { key: 'ios', name: 'iOS' },
108
108
] ;
109
109
110
- this . size = 'webSmall ' ;
110
+ this . size = 'webInline ' ;
111
111
this . sizes = [
112
+ {
113
+ key : 'webInline' ,
114
+ name : 'Inline' ,
115
+ platform : 'web' ,
116
+ width : 360 ,
117
+ height : 640 ,
118
+ dpr : 1 ,
119
+ } ,
112
120
{
113
121
key : 'webSmall' ,
114
122
name : 'Small' ,
@@ -241,6 +249,10 @@ export class MdJsPreview extends ScopedElementsMixin(LitElement) {
241
249
if ( this . lightDomRenderTarget && changeProps . has ( 'story' ) ) {
242
250
render ( this . story ( { shadowRoot : this } ) , this . lightDomRenderTarget ) ;
243
251
}
252
+
253
+ if ( changeProps . has ( 'platform' ) || changeProps . has ( 'size' ) ) {
254
+ this . deviceMode = this . platform === 'web' && this . size === 'webInline' ? false : true ;
255
+ }
244
256
}
245
257
246
258
disconnectedCallback ( ) {
@@ -311,7 +323,6 @@ export class MdJsPreview extends ScopedElementsMixin(LitElement) {
311
323
renderPlatforms ( ) {
312
324
if ( this . platforms . length ) {
313
325
return html `
314
- <h4> Platfor m</ h4>
315
326
<div
316
327
class= "segmented-control"
317
328
@change = ${
@@ -344,17 +355,27 @@ export class MdJsPreview extends ScopedElementsMixin(LitElement) {
344
355
if ( this . platforms . length ) {
345
356
return html `
346
357
<div>
347
- <h3 > Platform </ h3 >
358
+ <h4 > Platform </ h4 >
348
359
${ this . renderPlatforms ( ) }
349
360
</ div>
350
361
` ;
351
362
}
352
363
}
353
364
365
+ renderSize ( ) {
366
+ if ( this . sizes . length ) {
367
+ return html `
368
+ <div>
369
+ <h4> Size </ h4>
370
+ ${ this . renderSizes ( ) }
371
+ </ div>
372
+ ` ;
373
+ }
374
+ }
375
+
354
376
renderSizes ( ) {
355
377
if ( this . sizes . length ) {
356
378
return html `
357
- <h4> Size </ h4>
358
379
<div
359
380
class= "segmented-control"
360
381
@change = ${
@@ -387,7 +408,7 @@ export class MdJsPreview extends ScopedElementsMixin(LitElement) {
387
408
return html `
388
409
<div>
389
410
<h3> Viewport </ h3>
390
- ${ this . renderSizes ( ) } ${ this . renderAutoHeight ( ) }
411
+ ${ this . renderAutoHeight ( ) }
391
412
</ div>
392
413
` ;
393
414
}
@@ -571,6 +592,11 @@ export class MdJsPreview extends ScopedElementsMixin(LitElement) {
571
592
572
593
render ( ) {
573
594
return html `
595
+ ${ this . simulatorUrl
596
+ ? html `
597
+ <div class= "platform-size-controls" > ${ this . renderPlatform ( ) } ${ this . renderSize ( ) } </ div>
598
+ `
599
+ : `` }
574
600
<div id= "wrapper" >
575
601
<slot name= "story" > </ slot>
576
602
${ this . deviceMode === true
@@ -588,19 +614,28 @@ export class MdJsPreview extends ScopedElementsMixin(LitElement) {
588
614
: nothing }
589
615
</ div>
590
616
<lion- accor dion class= "options" >
591
- ${ this . deviceMode
617
+ ${ this . simulatorUrl
592
618
? html `
593
619
<h3 slot= "invoker" >
594
620
<butto n> Settings </ butto n>
595
621
</ h3>
596
622
<div slot= "content" >
623
+ ${ this . deviceMode
624
+ ? ``
625
+ : html `<div>
626
+ Note : Additional settings become available when not in web inline mode
627
+ </ div> ` }
597
628
<div class= "settings-wrapper" >
598
- ${ this . renderPlatform ( ) } ${ this . renderViewport ( ) } ${ this . renderVisual ( ) }
599
- ${ this . renderLocalization ( ) } ${ this . renderSyncSettings ( ) }
629
+ ${ this . deviceMode
630
+ ? html `
631
+ ${ this . renderViewport ( ) } ${ this . renderVisual ( ) } ${ this . renderLocalization ( ) }
632
+ ${ this . renderSyncSettings ( ) }
633
+ `
634
+ : html ` ${ this . renderSyncSettings ( ) } ` }
600
635
</ div>
601
636
</ div>
602
637
`
603
- : '' }
638
+ : `` }
604
639
<h3 slot= "invoker" >
605
640
<butto n> Code </ butto n>
606
641
</ h3>
@@ -615,12 +650,6 @@ export class MdJsPreview extends ScopedElementsMixin(LitElement) {
615
650
? html `
616
651
<div class= "controls" >
617
652
<a href= ${ this . iframeUrl } target= "_blank" > Open simulation in new window </ a>
618
- <butto n
619
- @click = ${ ( ) => ( this . deviceMode = ! this . deviceMode ) }
620
- class= "simulation-toggle"
621
- >
622
- ${ this . deviceMode ? html `Disable` : html `Enable ` } device simulation
623
- </ butto n>
624
653
</ div>
625
654
`
626
655
: '' }
@@ -638,6 +667,10 @@ export class MdJsPreview extends ScopedElementsMixin(LitElement) {
638
667
display : none;
639
668
}
640
669
670
+ : host (: not ([device-mode ])) # wrapper {
671
+ border : 2px solid # 4caf50 ;
672
+ }
673
+
641
674
iframe {
642
675
border : 2px solid # 4caf50 ;
643
676
background : # fff ;
@@ -732,6 +765,15 @@ export class MdJsPreview extends ScopedElementsMixin(LitElement) {
732
765
padding : 15px 0 ;
733
766
}
734
767
768
+ .platform-size-controls {
769
+ display : flex;
770
+ justify-content : flex-start;
771
+ }
772
+
773
+ .platform-size-controls > * {
774
+ margin-right : 25px ;
775
+ }
776
+
735
777
.controls {
736
778
display : flex;
737
779
justify-content : space-between;
0 commit comments