Skip to content

Commit 821ee24

Browse files
authored
Migrate css-prefers-color-scheme (#34)
* css-prefers-color-scheme : monorepo migration * Migrate css-prefers-color-scheme * docs
1 parent a5a2fed commit 821ee24

File tree

17 files changed

+109
-358
lines changed

17 files changed

+109
-358
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
/* global self */
2-
import * as cssBlankPseudo from './browser';
2+
import { default as cssBlankPseudo } from './browser';
33
self.cssBlankPseudo = cssBlankPseudo;
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
/* global self */
2-
import * as cssHasPseudo from './browser';
2+
import { default as cssHasPseudo } from './browser';
33
self.cssHasPseudo = cssHasPseudo;

plugins/css-prefers-color-scheme/.editorconfig

-15
This file was deleted.

plugins/css-prefers-color-scheme/.github/workflows/test.yml

-18
This file was deleted.
+3-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
node_modules
2-
/browser.*
3-
/index.*
4-
/postcss.*
2+
dist
53
package-lock.json
64
yarn.lock
75
*.log*
8-
.*
6+
*.result.css
7+
*.result.css.map
98
!.editorconfig
109
!.gitignore
1110
!.rollup.js
1211
!.tape.js
1312
!.travis.yml
14-
!.github

plugins/css-prefers-color-scheme/.rollup.js

-42
This file was deleted.

plugins/css-prefers-color-scheme/CONTRIBUTING.md

-65
This file was deleted.

plugins/css-prefers-color-scheme/INSTALL.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,6 @@ grunt.initConfig({
145145
[Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss
146146
[PostCSS]: https://github.com/postcss/postcss
147147
[PostCSS Loader]: https://github.com/postcss/postcss-loader
148-
[Prefers Color Scheme]: https://github.com/jonathantneal/postcss-prefers-color-scheme
148+
[Prefers Color Scheme]: https://github.com/csstools/postcss-plugins/tree/main/plugins/css-prefers-color-scheme
149149
[React App Rewire PostCSS]: https://github.com/csstools/react-app-rewire-postcss
150150
[React App Rewired]: https://github.com/timarney/react-app-rewired

plugins/css-prefers-color-scheme/README-BROWSER.md

+20-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
# Prefers Color Scheme [<img src="https://jonathantneal.github.io/js-logo.svg" alt="" width="90" height="90" align="right">][Prefers Color Scheme]
22

33
[![NPM Version][npm-img]][npm-url]
4-
[![Build Status][cli-img]][cli-url]
54
[![Support Chat][git-img]][git-url]
65

76
[Prefers Color Scheme] applies color schemes with fallbacks provided by the
87
[Prefers Color Scheme PostCSS plugin](README-POSTCSS.md).
98

109
```js
1110
// initialize prefersColorScheme (applies the current OS color scheme, if available)
12-
const prefersColorScheme = require('css-prefers-color-scheme')();
11+
const prefersColorScheme = require('css-prefers-color-scheme/browser')();
1312

1413
// apply "dark" queries (you can also apply "light")
1514
prefersColorScheme.scheme = 'dark';
@@ -29,15 +28,15 @@ experience, even when JavaScript is unable to run.
2928
Use [Prefers Color Scheme] to activate your `prefers-color-scheme` queries:
3029

3130
```js
32-
const prefersColorScheme = require('css-prefers-color-scheme')();
31+
const prefersColorScheme = require('css-prefers-color-scheme/browser')();
3332
```
3433

3534
By default, the current OS color scheme is applied if your browser supports it.
3635
Otherwise, the light color scheme is applied. You may override this by passing
3736
in a color scheme.
3837

3938
```js
40-
const prefersColorScheme = require('css-prefers-color-scheme')('dark');
39+
const prefersColorScheme = require('css-prefers-color-scheme/browser')('dark');
4140
```
4241

4342
The `prefersColorScheme` object returns the following properties — `value`,
@@ -49,7 +48,7 @@ The `value` property returns the currently preferred color scheme, and it can
4948
be changed.
5049

5150
```js
52-
const prefersColorScheme = require('css-prefers-color-scheme')();
51+
const prefersColorScheme = require('css-prefers-color-scheme/browser')();
5352

5453
// log the preferred color scheme
5554
console.log(prefersColorScheme.scheme);
@@ -74,12 +73,25 @@ The `removeListener` function removes the native `prefers-color-scheme`
7473
listener, which may or may not be applied, depending on your browser support.
7574
This is provided to give you complete control over plugin cleanup.
7675

77-
[cli-img]: https://img.shields.io/travis/csstools/css-prefers-color-scheme/master.svg
78-
[cli-url]: https://travis-ci.org/csstools/css-prefers-color-scheme
76+
## Dependencies
77+
78+
Web API's:
79+
80+
- [Window.matchMedia](https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia)
81+
82+
ECMA Script:
83+
84+
- `Object.defineProperty`
85+
- `Array.prototype.forEach`
86+
- `Array.prototype.indexOf`
87+
- `RegExp.prototype.exec`
88+
- `String.prototype.match`
89+
- `String.prototype.replace`
90+
7991
[git-img]: https://img.shields.io/badge/support-chat-blue.svg
8092
[git-url]: https://gitter.im/postcss/postcss
8193
[npm-img]: https://img.shields.io/npm/v/css-prefers-color-scheme.svg
8294
[npm-url]: https://www.npmjs.com/package/css-prefers-color-scheme
8395

8496
[PostCSS]: https://github.com/postcss/postcss
85-
[Prefers Color Scheme]: https://github.com/csstools/css-prefers-color-scheme
97+
[Prefers Color Scheme]: https://github.com/csstools/postcss-plugins/tree/main/plugins/css-prefers-color-scheme

plugins/css-prefers-color-scheme/README-POSTCSS.md

+4-15
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Prefers Color Scheme [<img src="https://jonathantneal.github.io/postcss-logo.svg" alt="" width="90" height="90" align="right">][Prefers Color Scheme]
22

33
[![NPM Version][npm-img]][npm-url]
4-
[![Build Status][cli-img]][cli-url]
54
[![Support Chat][git-img]][git-url]
65

76
[Prefers Color Scheme] transforms `prefers-color-scheme` media queries into
@@ -49,22 +48,14 @@ body {
4948
Use [Prefers Color Scheme] to process your CSS:
5049

5150
```bash
52-
npx css-prefers-color-scheme INPUT.css OUTPUT.css
53-
```
54-
55-
Or use it within Node:
56-
57-
```js
58-
const postcssPrefersColorScheme = require('css-prefers-color-scheme/postcss');
59-
60-
postcssPrefersColorScheme.process(YOUR_CSS /*, processOptions, pluginOptions */);
51+
npx css-prefers-color-scheme INPUT.css --output OUTPUT.css
6152
```
6253

6354
Or use it as a [PostCSS] plugin:
6455

6556
```js
6657
const postcss = require('postcss');
67-
const postcssPrefersColorScheme = require('css-prefers-color-scheme/postcss');
58+
const postcssPrefersColorScheme = require('css-prefers-color-scheme');
6859

6960
postcss([
7061
postcssPrefersColorScheme(/* pluginOptions */)
@@ -85,7 +76,7 @@ The `preserve` option determines whether the original `prefers-color-scheme`
8576
query will be preserved or removed. By default, it is preserved.
8677

8778
```js
88-
require('css-prefers-color-scheme/postcss')({ preserve: false });
79+
require('css-prefers-color-scheme')({ preserve: false });
8980
```
9081

9182
```css
@@ -104,12 +95,10 @@ require('css-prefers-color-scheme/postcss')({ preserve: false });
10495
}
10596
```
10697

107-
[cli-img]: https://img.shields.io/travis/csstools/css-prefers-color-scheme/master.svg
108-
[cli-url]: https://travis-ci.org/csstools/css-prefers-color-scheme
10998
[git-img]: https://img.shields.io/badge/support-chat-blue.svg
11099
[git-url]: https://gitter.im/postcss/postcss
111100
[npm-img]: https://img.shields.io/npm/v/css-prefers-color-scheme.svg
112101
[npm-url]: https://www.npmjs.com/package/css-prefers-color-scheme
113102

114103
[PostCSS]: https://github.com/postcss/postcss
115-
[Prefers Color Scheme]: https://github.com/csstools/css-prefers-color-scheme
104+
[Prefers Color Scheme]: https://github.com/csstools/postcss-plugins/tree/main/plugins/css-prefers-color-scheme

plugins/css-prefers-color-scheme/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Next, use that transformed CSS with this script:
2222

2323
```html
2424
<link rel="stylesheet" href="TRANSFORMED.css">
25-
<script src="https://unpkg.com/css-prefers-color-scheme/browser.min"></script>
25+
<script src="https://unpkg.com/css-prefers-color-scheme/dist/browser-global.js"></script>
2626
<script>
2727
colorScheme = initPrefersColorScheme('dark') // apply "dark" queries (you can change it afterward, too)
2828
</script>
@@ -74,13 +74,13 @@ The value of `48` is chosen for dark mode because it is the keycode for `0`,
7474
the hexidecimal value of black. Likewise, `70` is chosen for light mode because
7575
it is the keycode for `f`, the hexidecimal value of white.
7676

77-
[cli-img]: https://github.com/csstools/css-prefers-color-scheme/workflows/test/badge.svg
78-
[cli-url]: https://github.com/csstools/css-prefers-color-scheme/actions/workflows/test.yml?query=workflow/test
77+
[cli-img]: https://github.com/csstools/postcss-plugins/workflows/test/badge.svg
78+
[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test
7979
[git-img]: https://img.shields.io/badge/support-chat-blue.svg
8080
[git-url]: https://gitter.im/postcss/postcss
8181
[npm-img]: https://img.shields.io/npm/v/css-prefers-color-scheme.svg
8282
[npm-url]: https://www.npmjs.com/package/css-prefers-color-scheme
8383

8484
[PostCSS]: https://github.com/postcss/postcss
85-
[Prefers Color Scheme]: https://github.com/csstools/css-prefers-color-scheme
85+
[Prefers Color Scheme]: https://github.com/csstools/postcss-plugins/tree/main/plugins/css-prefers-color-scheme
8686
[Media Queries]: https://drafts.csswg.org/mediaqueries-5/#descdef-media-prefers-color-scheme

0 commit comments

Comments
 (0)