@csstools/postcss-color-function-display-p3-linear 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/LICENSE.md +18 -0
- package/README.md +135 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.mjs +1 -0
- package/package.json +71 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Changes to PostCSS Color Function Display P3 Linear
|
|
2
|
+
|
|
3
|
+
### 1.0.0
|
|
4
|
+
|
|
5
|
+
_August 22, 2025_
|
|
6
|
+
|
|
7
|
+
- Initial version
|
|
8
|
+
- Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`3.1.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#310) (minor)
|
|
9
|
+
- Updated [`@csstools/postcss-progressive-custom-properties`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties) to [`4.2.0`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties/CHANGELOG.md#420) (minor)
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
MIT No Attribution (MIT-0)
|
|
2
|
+
|
|
3
|
+
Copyright © CSSTools Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
+
this software and associated documentation files (the “Software”), to deal in
|
|
7
|
+
the Software without restriction, including without limitation the rights to
|
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
9
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
|
10
|
+
so.
|
|
11
|
+
|
|
12
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
13
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
14
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
15
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
16
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
17
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
18
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# PostCSS Color Function Display P3 Linear [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][PostCSS]
|
|
2
|
+
|
|
3
|
+
`npm install @csstools/postcss-color-function-display-p3-linear --save-dev`
|
|
4
|
+
|
|
5
|
+
[PostCSS Color Function Display P3 Linear] lets you use the `display-p3-linear` color space in the `color` function in
|
|
6
|
+
CSS, following the [CSS Color] specification.
|
|
7
|
+
|
|
8
|
+
```css
|
|
9
|
+
.color {
|
|
10
|
+
color: color(display-p3-linear 0.3081 0.014 0.0567);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
:root {
|
|
14
|
+
--a-color: color(display-p3-linear 0.3081 0.014 0.0567);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/* becomes */
|
|
18
|
+
|
|
19
|
+
.color {
|
|
20
|
+
color: color(display-p3 0.59096 0.12316 0.26409);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
:root {
|
|
24
|
+
--a-color: color(display-p3 0.59096 0.12316 0.26409);
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
Add [PostCSS Color Function Display P3 Linear] to your project:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npm install postcss @csstools/postcss-color-function-display-p3-linear --save-dev
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Use it as a [PostCSS] plugin:
|
|
37
|
+
|
|
38
|
+
```js
|
|
39
|
+
const postcss = require('postcss');
|
|
40
|
+
const postcssColorFunctionDisplayP3Linear = require('@csstools/postcss-color-function-display-p3-linear');
|
|
41
|
+
|
|
42
|
+
postcss([
|
|
43
|
+
postcssColorFunctionDisplayP3Linear(/* pluginOptions */)
|
|
44
|
+
]).process(YOUR_CSS /*, processOptions */);
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
## Options
|
|
50
|
+
|
|
51
|
+
### preserve
|
|
52
|
+
|
|
53
|
+
The `preserve` option determines whether the original notation
|
|
54
|
+
is preserved. By default, it is not preserved.
|
|
55
|
+
|
|
56
|
+
```js
|
|
57
|
+
postcssColorFunctionDisplayP3Linear({ preserve: true })
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
```css
|
|
61
|
+
.color {
|
|
62
|
+
color: color(display-p3-linear 0.3081 0.014 0.0567);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
:root {
|
|
66
|
+
--a-color: color(display-p3-linear 0.3081 0.014 0.0567);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/* becomes */
|
|
70
|
+
|
|
71
|
+
.color {
|
|
72
|
+
color: color(display-p3 0.59096 0.12316 0.26409);
|
|
73
|
+
color: color(display-p3-linear 0.3081 0.014 0.0567);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
:root {
|
|
77
|
+
--a-color: color(display-p3 0.59096 0.12316 0.26409);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@supports (color: color(display-p3-linear 0 0 0)) {
|
|
81
|
+
:root {
|
|
82
|
+
--a-color: color(display-p3-linear 0.3081 0.014 0.0567);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### enableProgressiveCustomProperties
|
|
88
|
+
|
|
89
|
+
The `enableProgressiveCustomProperties` option determines whether the original notation
|
|
90
|
+
is wrapped with `@supports` when used in Custom Properties. By default, it is enabled.
|
|
91
|
+
|
|
92
|
+
> [!NOTE]
|
|
93
|
+
> We only recommend disabling this when you set `preserve` to `false` or if you bring your own fix for Custom Properties.
|
|
94
|
+
> See what the plugin does in its [README](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties#readme).
|
|
95
|
+
|
|
96
|
+
```js
|
|
97
|
+
postcssColorFunctionDisplayP3Linear({ enableProgressiveCustomProperties: false })
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
```css
|
|
101
|
+
.color {
|
|
102
|
+
color: color(display-p3-linear 0.3081 0.014 0.0567);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
:root {
|
|
106
|
+
--a-color: color(display-p3-linear 0.3081 0.014 0.0567);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/* becomes */
|
|
110
|
+
|
|
111
|
+
.color {
|
|
112
|
+
color: color(display-p3 0.59096 0.12316 0.26409);
|
|
113
|
+
color: color(display-p3-linear 0.3081 0.014 0.0567);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
:root {
|
|
117
|
+
--a-color: color(display-p3 0.59096 0.12316 0.26409);
|
|
118
|
+
--a-color: color(display-p3-linear 0.3081 0.014 0.0567);
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
_Custom properties do not fallback to the previous declaration_
|
|
123
|
+
|
|
124
|
+
## Copyright : color conversions
|
|
125
|
+
|
|
126
|
+
This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/tree/main/css-color-4. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
|
127
|
+
|
|
128
|
+
[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test
|
|
129
|
+
[css-url]: https://cssdb.org/#color-function-display-p3-linear
|
|
130
|
+
[discord]: https://discord.gg/bUadyRwkJS
|
|
131
|
+
[npm-url]: https://www.npmjs.com/package/@csstools/postcss-color-function-display-p3-linear
|
|
132
|
+
|
|
133
|
+
[PostCSS]: https://github.com/postcss/postcss
|
|
134
|
+
[PostCSS Color Function Display P3 Linear]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-color-function-display-p3-linear
|
|
135
|
+
[CSS Color]: https://drafts.csswg.org/css-color-4/#predefined-display-p3-linear
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var s=require("@csstools/postcss-progressive-custom-properties"),e=require("@csstools/css-tokenizer"),o=require("@csstools/css-color-parser"),r=require("@csstools/utilities"),t=require("@csstools/css-parser-algorithms");const i=/\bdisplay-p3-linear\b/i,a=/^color$/i,basePlugin=s=>({postcssPlugin:"postcss-color-function-display-p3-linear",Declaration(n){const l=n.value;if(!i.test(l))return;if(r.hasFallback(n))return;if(r.hasSupportsAtRuleAncestor(n,i))return;const c=e.tokenize({css:l}),p=t.replaceComponentValues(t.parseCommaSeparatedListOfComponentValues(c),s=>{if(!t.isFunctionNode(s)||!a.test(s.getName()))return;const e=o.color(s);return!e||e.colorNotation!==o.ColorNotation.Linear_Display_P3||e.syntaxFlags.has(o.SyntaxFlag.Experimental)||e.syntaxFlags.has(o.SyntaxFlag.HasNoneKeywords)?void 0:o.serializeP3(e)}),u=t.stringify(p);u!==l&&(n.cloneBefore({value:u}),s?.preserve||n.remove())}});basePlugin.postcss=!0;const postcssPlugin=e=>{const o=Object.assign({preserve:!1,enableProgressiveCustomProperties:!0},e);return o.enableProgressiveCustomProperties&&o.preserve?{postcssPlugin:"postcss-color-function-display-p3-linear",plugins:[s(),basePlugin(o)]}:basePlugin(o)};postcssPlugin.postcss=!0,module.exports=postcssPlugin;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PluginCreator } from 'postcss';
|
|
2
|
+
|
|
3
|
+
/** postcss-color-function-display-p3-linear plugin options */
|
|
4
|
+
export declare type pluginOptions = {
|
|
5
|
+
/** Preserve the original notation. default: false */
|
|
6
|
+
preserve?: boolean;
|
|
7
|
+
/** Enable "@csstools/postcss-progressive-custom-properties". default: true */
|
|
8
|
+
enableProgressiveCustomProperties?: boolean;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/** Transform the display-p3-linear color space in the color() function in CSS. */
|
|
12
|
+
declare const postcssPlugin: PluginCreator<pluginOptions>;
|
|
13
|
+
export default postcssPlugin;
|
|
14
|
+
|
|
15
|
+
export { }
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import s from"@csstools/postcss-progressive-custom-properties";import{tokenize as o}from"@csstools/css-tokenizer";import{color as r,ColorNotation as e,SyntaxFlag as t,serializeP3 as i}from"@csstools/css-color-parser";import{hasFallback as n,hasSupportsAtRuleAncestor as c}from"@csstools/utilities";import{replaceComponentValues as l,parseCommaSeparatedListOfComponentValues as p,isFunctionNode as a,stringify as u}from"@csstools/css-parser-algorithms";const m=/\bdisplay-p3-linear\b/i,f=/^color$/i,basePlugin=s=>({postcssPlugin:"postcss-color-function-display-p3-linear",Declaration(g){const v=g.value;if(!m.test(v))return;if(n(g))return;if(c(g,m))return;const y=o({css:v}),P=l(p(y),s=>{if(!a(s)||!f.test(s.getName()))return;const o=r(s);return!o||o.colorNotation!==e.Linear_Display_P3||o.syntaxFlags.has(t.Experimental)||o.syntaxFlags.has(t.HasNoneKeywords)?void 0:i(o)}),d=u(P);d!==v&&(g.cloneBefore({value:d}),s?.preserve||g.remove())}});basePlugin.postcss=!0;const postcssPlugin=o=>{const r=Object.assign({preserve:!1,enableProgressiveCustomProperties:!0},o);return r.enableProgressiveCustomProperties&&r.preserve?{postcssPlugin:"postcss-color-function-display-p3-linear",plugins:[s(),basePlugin(r)]}:basePlugin(r)};postcssPlugin.postcss=!0;export{postcssPlugin as default};
|
package/package.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@csstools/postcss-color-function-display-p3-linear",
|
|
3
|
+
"description": "Use the display-p3-linear color space on the color() function in CSS",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"contributors": [
|
|
6
|
+
{
|
|
7
|
+
"name": "Romain Menke",
|
|
8
|
+
"email": "romainmenke@gmail.com"
|
|
9
|
+
}
|
|
10
|
+
],
|
|
11
|
+
"license": "MIT-0",
|
|
12
|
+
"funding": [
|
|
13
|
+
{
|
|
14
|
+
"type": "github",
|
|
15
|
+
"url": "https://github.com/sponsors/csstools"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"type": "opencollective",
|
|
19
|
+
"url": "https://opencollective.com/csstools"
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=18"
|
|
24
|
+
},
|
|
25
|
+
"type": "module",
|
|
26
|
+
"main": "dist/index.cjs",
|
|
27
|
+
"module": "dist/index.mjs",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"import": {
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"default": "./dist/index.mjs"
|
|
33
|
+
},
|
|
34
|
+
"require": {
|
|
35
|
+
"default": "./dist/index.cjs"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"files": [
|
|
40
|
+
"CHANGELOG.md",
|
|
41
|
+
"LICENSE.md",
|
|
42
|
+
"README.md",
|
|
43
|
+
"dist"
|
|
44
|
+
],
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@csstools/css-color-parser": "^3.1.0",
|
|
47
|
+
"@csstools/css-parser-algorithms": "^3.0.5",
|
|
48
|
+
"@csstools/css-tokenizer": "^3.0.4",
|
|
49
|
+
"@csstools/postcss-progressive-custom-properties": "^4.2.0",
|
|
50
|
+
"@csstools/utilities": "^2.0.0"
|
|
51
|
+
},
|
|
52
|
+
"peerDependencies": {
|
|
53
|
+
"postcss": "^8.4"
|
|
54
|
+
},
|
|
55
|
+
"scripts": {},
|
|
56
|
+
"homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-color-function-display-p3-linear#readme",
|
|
57
|
+
"repository": {
|
|
58
|
+
"type": "git",
|
|
59
|
+
"url": "git+https://github.com/csstools/postcss-plugins.git",
|
|
60
|
+
"directory": "plugins/postcss-color-function-display-p3-linear"
|
|
61
|
+
},
|
|
62
|
+
"bugs": "https://github.com/csstools/postcss-plugins/issues",
|
|
63
|
+
"keywords": [
|
|
64
|
+
"color",
|
|
65
|
+
"css",
|
|
66
|
+
"display-p3-linear",
|
|
67
|
+
"postcss",
|
|
68
|
+
"postcss-plugin",
|
|
69
|
+
"syntax"
|
|
70
|
+
]
|
|
71
|
+
}
|