Skip to content

prefers color scheme #436

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

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
8 changes: 5 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,6 @@
}
}

@media (color-index: 48) {
body {
background-color: black;
color: white;
}
}

@media (color: 48842621) {
body {
background-color: black;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,6 @@
}
}

@media (color-index: 48) {
body {
background-color: black;
color: white;
}
}

@media (color: 48842621) {
body {
background-color: black;
Expand Down
7 changes: 0 additions & 7 deletions plugin-packs/postcss-preset-env/test/basic.ch38.expect.css
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,6 @@
}
}

@media (color-index: 48) {
body {
background-color: black;
color: white;
}
}

@media (color: 48842621) {
body {
background-color: black;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,6 @@
}
}

@media (color-index: 48) {
body {
background-color: black;
color: white;
}
}

@media (color: 48842621) {
body {
background-color: black;
Expand Down
7 changes: 0 additions & 7 deletions plugin-packs/postcss-preset-env/test/basic.expect.css
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,6 @@
}
}

@media (color-index: 48) {
body {
background-color: black;
color: white;
}
}

@media (color: 48842621) {
body {
background-color: black;
Expand Down
7 changes: 0 additions & 7 deletions plugin-packs/postcss-preset-env/test/basic.ff49.expect.css
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,6 @@
}
}

@media (color-index: 48) {
body {
background-color: black;
color: white;
}
}

@media (color: 48842621) {
body {
background-color: black;
Expand Down
7 changes: 0 additions & 7 deletions plugin-packs/postcss-preset-env/test/basic.ff66.expect.css
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,6 @@
}
}

@media (color-index: 48) {
body {
background-color: black;
color: white;
}
}

@media (color: 48842621) {
body {
background-color: black;
Expand Down
7 changes: 0 additions & 7 deletions plugin-packs/postcss-preset-env/test/basic.ie10.expect.css
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,6 @@
}
}

@media (color-index: 48) {
body {
background-color: black;
color: white;
}
}

@media (color: 48842621) {
body {
background-color: black;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,6 @@
}
}

@media (color-index: 48) {
body {
background-color: black;
color: white;
}
}

@media (color: 48842621) {
body {
background-color: black;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,6 @@

@custom-media --dark-mode (prefers-color-scheme: dark);

@media (color-index: 48) {
body {
background-color: black;
color: white;
}
}

@media (color: 48842621) {
body {
background-color: black;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,6 @@
}
}

@media (color-index: 48) {
body {
background-color: black;
color: white;
}
}

@media (color: 48842621) {
body {
background-color: black;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,6 @@
}
}

@media (color-index: 48) {
body {
background-color: black;
color: white;
}
}

@media (color: 48842621) {
body {
background-color: black;
Expand Down
7 changes: 0 additions & 7 deletions plugin-packs/postcss-preset-env/test/basic.stage0.expect.css
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,6 @@
}
}

@media (color-index: 48) {
body {
background-color: black;
color: white;
}
}

@media (color: 48842621) {
body {
background-color: black;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@
order: 4;
}

@media (color-index: 70) {
.b {
order: 5;
}
}

@media (color: 70318723) {
.b {
order: 5;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ a:has(> img) {
order: 2;
}

@media (color-index: 48) {
p {
order: 3;
}
}

@media (color: 48842621) {
p {
order: 3;
Expand Down
7 changes: 0 additions & 7 deletions plugin-packs/postcss-preset-env/test/layers-basic.expect.css
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,6 @@
}
}

@media (color-index: 48) {
body:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#) {
background-color: black;
color: white;
}
}

@media (color: 48842621) {
body:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#) {
background-color: black;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,6 @@

@custom-media --dark-mode (prefers-color-scheme: dark);

@media (color-index: 48) {
body:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#) {
background-color: black;
color: white;
}
}

@media (color: 48842621) {
body:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#) {
background-color: black;
Expand Down
11 changes: 1 addition & 10 deletions plugins/css-prefers-color-scheme/.gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
node_modules
dist
package-lock.json
yarn.lock
browser.js
!src/browser.js
browser.min.js
*.log*
*.result.css
*.result.css.map
!.editorconfig
!.gitignore
!.rollup.js
!.tape.js
!.travis.yml
dist/*
26 changes: 13 additions & 13 deletions plugins/css-prefers-color-scheme/.tape.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,6 @@ postcssTape(plugin)({
'basic': {
message: 'supports basic usage'
},
'basic:color': {
message: 'supports { mediaQuery: "color" } usage',
options: {
mediaQuery: 'color'
}
},
'basic:color-index': {
message: 'supports { mediaQuery: "color-index" } usage',
options: {
mediaQuery: 'color-index'
}
},
'basic:preserve': {
message: 'supports { preserve: true } usage',
options: {
Expand All @@ -28,5 +16,17 @@ postcssTape(plugin)({
options: {
preserve: false
}
}
},
'examples/example': {
message: 'minimal example',
},
'examples/example:preserve-false': {
message: 'minimal example',
options: {
preserve: false
}
},
'browser': {
message: 'css for browser tests',
},
});
48 changes: 48 additions & 0 deletions plugins/css-prefers-color-scheme/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,53 @@
# Changes to Prefers Color Scheme

### Unreleased (major)

[Read the full changelog](https://github.com/csstools/postcss-plugins/wiki/PostCSS-Preset-Env-8)

- Breaking: removed old CDN urls
- Breaking: remove `color-depth` queries fallback
- Breaking: remove 'no-preference' support as this was dropped from the spec
- Breaking: remove old global object

#### How to migrate :

##### Re-build your CSS with the new version of the library.


##### If you use a CDN url, please update it.

```diff
- <script src="https://unpkg.com/css-prefers-color-scheme/browser"></script>
+ <script src="https://unpkg.com/css-prefers-color-scheme/dist/browser-global.js"></script>
```

```diff
- <script src="https://unpkg.com/css-prefers-color-scheme/browser.min"></script>
+ <script src="https://unpkg.com/css-prefers-color-scheme/dist/browser-global.js"></script>
```

##### Use `prefersColorSchemeInit` to initialize the polyfill in the browser.

```diff
- initPrefersColorScheme()
+ prefersColorSchemeInit()
```

##### Remove `@media (prefer-color-scheme: no-preference)` from your CSS.

`@media (prefers-color-scheme: no-preference)` was removed from the specification and should be equivalent to not having any media query.

```diff
- @media (prefers-color-scheme: no-preference) {
- .some-selector {
- /* your styles ... */
- }
- }
+ .some-selector {
+ /* your styles ... */
+ }
```

### 6.0.3 (January 31, 2022)

- Fix `preserve: false` option.
Expand Down
Loading