Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add specs for nested media queries #1230

Merged
merged 2 commits into from
Mar 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

2 changes: 0 additions & 2 deletions spec/scss-tests/123_test_media_interpolation/input.scss

This file was deleted.

5 changes: 0 additions & 5 deletions spec/scss-tests/124_test_script_in_media/expected_output.css

This file was deleted.

5 changes: 0 additions & 5 deletions spec/scss-tests/124_test_script_in_media/input.scss

This file was deleted.

5 changes: 0 additions & 5 deletions spec/scss-tests/125_test_script_in_media/expected_output.css

This file was deleted.

2 changes: 0 additions & 2 deletions spec/scss-tests/125_test_script_in_media/input.scss

This file was deleted.

This file was deleted.

This file was deleted.

5 changes: 0 additions & 5 deletions spec/scss/media-with-interpolation/expected_output.css

This file was deleted.

12 changes: 0 additions & 12 deletions spec/scss/media-with-interpolation/input.scss

This file was deleted.

17 changes: 17 additions & 0 deletions spec/scss/media/interpolated/expected_output.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@media bar12 {
x {
y: z;
}
}

@media only screen and (min-width: 700px) and (max-width: 1920px) {
x {
y: z;
}
}

@media screen, print and (max-width: 300px) {
x {
y: z;
}
}
15 changes: 15 additions & 0 deletions spec/scss/media/interpolated/input.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// You can interpolate into a media type.
@media bar#{12} {x {y: z}}

// Media queries should be reparsed after interpolation is resolved.
@media #{"only screen"} and
#{"(min-width: 700px)"} and
#{"(max-width: "+"1920px)"} {
x {y: z}
}

// Queries don't have to fully parse before interpolation is resolved.
@media scr#{"een, pri"}nt a#{"nd (max-width: 300px)"} {x {y: z}}



89 changes: 89 additions & 0 deletions spec/scss/media/nesting/expected_output.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
@media screen {
a {
b: c;
}
}
@media screen and (color) {
x {
y: z;
}
}

@media (color) {
a {
b: c;
}
}
@media screen and (color) {
x {
y: z;
}
}

@media (max-width: 300px) {
a {
b: c;
}
}
@media (max-width: 300px) and (min-width: 200px) {
x {
y: z;
}
}

@media screen {
a {
b: c;
}
}

@media not screen {
a {
b: c;
}
}

@media not screen {
a {
b: c;
}
}
@media print {
x {
y: z;
}
}

@media print {
a {
b: c;
}
}
@media print {
x {
y: z;
}
}

@media not screen {
a {
b: c;
}
}

@media screen {
a {
b: c;
}
}

@media only screen {
a {
b: c;
}
}
@media only screen and (color) {
x {
y: z;
}
}
62 changes: 62 additions & 0 deletions spec/scss/media/nesting/input.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Media queries can be nested within one another. The intersection of the two
// queries will be generated.
@media screen {
a {b: c}
@media (color) {x {y: z}}
}

// Features always go to the end of a query, even if they're at an outer nesting
// level.
@media (color) {
a {b: c}
@media screen {x {y: z}}
}

// Different features can be intersected.
@media (max-width: 300px) {
a {b: c}
@media (min-width: 200px) {x {y: z}}
}

// Different media types *can't* be intersected, so they're eliminated.
@media screen {
a {b: c}
@media print {x {y: z}}
}

// Likewise, there's no way to generate the intersection of these queries. We
// could write `not screen and (color)`, but that actually means "neither
// `screen` nor `(color)`" rather than "not `screen` but yes `(color)`.
//
// The latest spec allows us to generate `not screen and not (color)` here,
// which would work, but no browsers support it yet.
@media not screen {
a {b: c}
@media (color) {x {y: z}}
}

// The intersection of `not screen` and `print` is just `print`.
@media not screen {
a {b: c}
@media print {x {y: z}}
}
@media print {
a {b: c}
@media not screen {x {y: z}}
}

/// The intersection of `not screen` and `screen` is empty.
@media not screen {
a {b: c}
@media screen {x {y: z}}
}
@media screen {
a {b: c}
@media not screen {x {y: z}}
}

// Unlike `not`, the `only` keyword is preserved through intersection.
@media only screen {
a {b: c}
@media (color) {x {y: z}}
}
3 changes: 3 additions & 0 deletions spec/scss/media/nesting/options.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
:todo:
- libsass
11 changes: 11 additions & 0 deletions spec/scss/media/script_features/expected_output.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@media only screen and (max-width: 3) and (min-width: 4) {
x {
y: z;
}
}

@media screen and (max-width: 3) and (min-width: 13) {
x {
y: z;
}
}
9 changes: 9 additions & 0 deletions spec/scss/media/script_features/input.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
$foo: 3;
$bar: 4;
// Media features are special-cased to allow raw script without interpolation.
@media only screen and (max-width: $foo) and (min-width: $bar) {x {y: z}}

// Not just variables, but full script
$vals: 1 2 3;
@media screen and (max-width: 1 + 2) and (min-width: 5 + 6 + nth($vals, 2)) {x {y: z}}

6 changes: 0 additions & 6 deletions spec/scss/media2/expected_output.css

This file was deleted.

7 changes: 0 additions & 7 deletions spec/scss/media2/input.scss

This file was deleted.