1- // These breakpoints are also overridden by gulpfile.js when building styles for
2- // the editor. We need to define these as integers here because in our
3- // definition in gulpfile.js, we cannot use px .
1+ // The editor build uses its selected device class instead of viewport media
2+ // queries. The active theme controls the preview width at runtime, so Sass
3+ // cannot safely provide a fixed editor breakpoint .
44$desktop-width : 1024 !default ;
55$tablet-width : 768 !default ;
6+ $use-editor-preview-classes : false !default ;
67
7- @mixin desktop {
8- @media only screen and ( min-width : #{ $desktop-width + 0 px } ) {
8+ @mixin editor-preview-device ( $device ) {
9+ @at-root .stk-preview-device- #{ $device } #{ & } {
910 @content ;
1011 }
1112}
13+
14+ @mixin desktop {
15+ @if $use-editor-preview-classes {
16+ @include editor-preview-device ( desktop ) {
17+ @content ;
18+ }
19+ } @else {
20+ @media only screen and (min-width : #{$desktop-width + 0px } ) {
21+ @content ;
22+ }
23+ }
24+ }
1225@mixin desktop-tablet {
13- @media only screen and (min-width : #{$tablet-width + 0px } ) {
14- @content ;
26+ @if $use-editor-preview-classes {
27+ @include editor-preview-device ( desktop ) {
28+ @content ;
29+ }
30+ @include editor-preview-device ( tablet ) {
31+ @content ;
32+ }
33+ } @else {
34+ @media only screen and (min-width : #{$tablet-width + 0px } ) {
35+ @content ;
36+ }
1537 }
1638}
1739@mixin tablet {
18- @media only screen and (min-width : #{$tablet-width + 0px } ) and (max-width : #{$desktop-width - 1px } ) {
19- @content ;
40+ @if $use-editor-preview-classes {
41+ @include editor-preview-device ( tablet ) {
42+ @content ;
43+ }
44+ } @else {
45+ @media only screen and (min-width : #{$tablet-width + 0px } ) and (max-width : #{$desktop-width - 1px } ) {
46+ @content ;
47+ }
2048 }
2149}
2250@mixin tablet-mobile {
23- @media only screen and (max-width : #{$desktop-width - 1px } ) {
24- @content ;
51+ @if $use-editor-preview-classes {
52+ @include editor-preview-device ( tablet ) {
53+ @content ;
54+ }
55+ @include editor-preview-device ( mobile ) {
56+ @content ;
57+ }
58+ } @else {
59+ @media only screen and (max-width : #{$desktop-width - 1px } ) {
60+ @content ;
61+ }
2562 }
2663}
2764@mixin mobile {
28- @media only screen and (max-width : #{$tablet-width - 1px } ) {
29- @content ;
65+ @if $use-editor-preview-classes {
66+ @include editor-preview-device ( mobile ) {
67+ @content ;
68+ }
69+ } @else {
70+ @media only screen and (max-width : #{$tablet-width - 1px } ) {
71+ @content ;
72+ }
3073 }
3174}
3275
@@ -41,28 +84,31 @@ $tablet-width: 768 !default;
4184 * These dummy styles are removed by gulpfile.js in the `style-editor` and
4285 * `style` tasks.
4386 */
44- @include desktop {
45- .z {
46- opacity : 1 ;
87+
88+ @if not $use-editor-preview-classes {
89+ @include desktop {
90+ .z {
91+ opacity : 1 ;
92+ }
4793 }
48- }
49- @include desktop-tablet {
50- .z {
51- opacity : 1 ;
94+ @include desktop-tablet {
95+ .z {
96+ opacity : 1 ;
97+ }
5298 }
53- }
54- @include tablet {
55- .z {
56- opacity : 1 ;
99+ @include tablet {
100+ .z {
101+ opacity : 1 ;
102+ }
57103 }
58- }
59- @include tablet-mobile {
60- .z {
61- opacity : 1 ;
104+ @include tablet-mobile {
105+ .z {
106+ opacity : 1 ;
107+ }
62108 }
63- }
64- @include mobile {
65- .z {
66- opacity : 1 ;
109+ @include mobile {
110+ .z {
111+ opacity : 1 ;
112+ }
67113 }
68114}
0 commit comments