@csstools/postcss-contrast-color-function 2.0.8 → 2.0.10
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 +6 -4
- package/README.md +5 -36
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +5 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
# Changes to PostCSS Contrast Color Function
|
|
2
2
|
|
|
3
|
-
### 2.0.
|
|
3
|
+
### 2.0.10
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
_May 27, 2025_
|
|
6
6
|
|
|
7
|
-
- Updated [`@csstools/
|
|
8
|
-
- Updated [`@csstools/
|
|
7
|
+
- Updated [`@csstools/css-tokenizer`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer) to [`3.0.4`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer/CHANGELOG.md#304) (patch)
|
|
8
|
+
- Updated [`@csstools/postcss-progressive-custom-properties`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties) to [`4.1.0`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties/CHANGELOG.md#410) (minor)
|
|
9
|
+
- Updated [`@csstools/css-parser-algorithms`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms) to [`3.0.5`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms/CHANGELOG.md#305) (patch)
|
|
10
|
+
- Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`3.0.10`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#3010) (patch)
|
|
9
11
|
|
|
10
12
|
[Full CHANGELOG](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-contrast-color-function/CHANGELOG.md)
|
package/README.md
CHANGED
|
@@ -5,32 +5,15 @@
|
|
|
5
5
|
[PostCSS Contrast Color Function] lets you dynamically specify a text color with adequate contrast following the [CSS Color 5 Specification].
|
|
6
6
|
|
|
7
7
|
```css
|
|
8
|
-
.
|
|
8
|
+
.color {
|
|
9
9
|
color: contrast-color(oklch(82% 0.2 330));
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
.max {
|
|
13
|
-
color: contrast-color(oklch(30% 0.2 79) max);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
12
|
/* becomes */
|
|
17
13
|
|
|
18
|
-
.
|
|
19
|
-
color: color(display-p3 0.15433 0 0.15992);
|
|
20
|
-
color: contrast-color(oklch(82% 0.2 330));
|
|
21
|
-
}@supports not (color: contrast-color(red max)) {@media (prefers-contrast: more) {.dynamic {
|
|
14
|
+
.color {
|
|
22
15
|
color: rgb(0, 0, 0);
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
}@supports not (color: contrast-color(red max)) {@media (prefers-contrast: less) {.dynamic {
|
|
26
|
-
color: color(display-p3 0.2925 0 0.30177);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.max {
|
|
32
|
-
color: rgb(255, 255, 255);
|
|
33
|
-
color: contrast-color(oklch(30% 0.2 79) max);
|
|
16
|
+
color: contrast-color(oklch(82% 0.2 330));
|
|
34
17
|
}
|
|
35
18
|
```
|
|
36
19
|
|
|
@@ -67,29 +50,15 @@ postcssContrastColorFunction({ preserve: false })
|
|
|
67
50
|
```
|
|
68
51
|
|
|
69
52
|
```css
|
|
70
|
-
.
|
|
53
|
+
.color {
|
|
71
54
|
color: contrast-color(oklch(82% 0.2 330));
|
|
72
55
|
}
|
|
73
56
|
|
|
74
|
-
.max {
|
|
75
|
-
color: contrast-color(oklch(30% 0.2 79) max);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
57
|
/* becomes */
|
|
79
58
|
|
|
80
|
-
.
|
|
81
|
-
color: color(display-p3 0.15433 0 0.15992);
|
|
82
|
-
}@media (prefers-contrast: more) {.dynamic {
|
|
59
|
+
.color {
|
|
83
60
|
color: rgb(0, 0, 0);
|
|
84
61
|
}
|
|
85
|
-
}@media (prefers-contrast: less) {.dynamic {
|
|
86
|
-
color: color(display-p3 0.2925 0 0.30177);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
.max {
|
|
91
|
-
color: rgb(255, 255, 255);
|
|
92
|
-
}
|
|
93
62
|
```
|
|
94
63
|
|
|
95
64
|
[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var s=require("@csstools/postcss-progressive-custom-properties"),e=require("@csstools/utilities"),o=require("@csstools/css-tokenizer"),r=require("@csstools/css-parser-algorithms"),t=require("@csstools/css-color-parser");const c=/\bcontrast-color\(/i,n=/^contrast-color$/i,basePlugin=s=>({postcssPlugin:"postcss-contrast-color-function",prepare:()=>({postcssPlugin:"postcss-contrast-color-function",Declaration(i){const a=i.value;if(!c.test(a))return;if(e.hasFallback(i))return;if(e.hasSupportsAtRuleAncestor(i,c))return;const l=o.tokenize({css:a}),u=r.replaceComponentValues(r.parseCommaSeparatedListOfComponentValues(l),(s=>{if(!r.isFunctionNode(s)||!n.test(s.getName()))return;const e=t.color(s);return e&&!e.syntaxFlags.has(t.SyntaxFlag.HasNoneKeywords)?t.serializeRGB(e):void 0})),p=r.stringify(u);p!==a&&(i.cloneBefore({value:p}),s?.preserve||i.remove())}})});basePlugin.postcss=!0;const postcssPlugin=e=>{const o=Object.assign({enableProgressiveCustomProperties:!0,preserve:!0},e);return o.enableProgressiveCustomProperties&&o.preserve?{postcssPlugin:"postcss-contrast-color-function",plugins:[s(),basePlugin(o)]}:basePlugin(o)};postcssPlugin.postcss=!0,module.exports=postcssPlugin;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import s from"@csstools/postcss-progressive-custom-properties";import{hasFallback as o,hasSupportsAtRuleAncestor as r}from"@csstools/utilities";import{tokenize as t}from"@csstools/css-tokenizer";import{replaceComponentValues as e,parseCommaSeparatedListOfComponentValues as c,isFunctionNode as n,stringify as i}from"@csstools/css-parser-algorithms";import{color as p,SyntaxFlag as l,serializeRGB as a}from"@csstools/css-color-parser";const u=/\bcontrast-color\(/i,m=/^contrast-color$/i,basePlugin=s=>({postcssPlugin:"postcss-contrast-color-function",prepare:()=>({postcssPlugin:"postcss-contrast-color-function",Declaration(f){const g=f.value;if(!u.test(g))return;if(o(f))return;if(r(f,u))return;const v=t({css:g}),P=e(c(v),(s=>{if(!n(s)||!m.test(s.getName()))return;const o=p(s);return o&&!o.syntaxFlags.has(l.HasNoneKeywords)?a(o):void 0})),b=i(P);b!==g&&(f.cloneBefore({value:b}),s?.preserve||f.remove())}})});basePlugin.postcss=!0;const postcssPlugin=o=>{const r=Object.assign({enableProgressiveCustomProperties:!0,preserve:!0},o);return r.enableProgressiveCustomProperties&&r.preserve?{postcssPlugin:"postcss-contrast-color-function",plugins:[s(),basePlugin(r)]}:basePlugin(r)};postcssPlugin.postcss=!0;export{postcssPlugin as default};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@csstools/postcss-contrast-color-function",
|
|
3
3
|
"description": "Dynamically specify a text color with adequate contrast",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.10",
|
|
5
5
|
"contributors": [
|
|
6
6
|
{
|
|
7
7
|
"name": "Antonio Laguna",
|
|
@@ -48,11 +48,10 @@
|
|
|
48
48
|
"dist"
|
|
49
49
|
],
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@csstools/color-
|
|
52
|
-
"@csstools/css-
|
|
53
|
-
"@csstools/css-
|
|
54
|
-
"@csstools/
|
|
55
|
-
"@csstools/postcss-progressive-custom-properties": "^4.0.0",
|
|
51
|
+
"@csstools/css-color-parser": "^3.0.10",
|
|
52
|
+
"@csstools/css-parser-algorithms": "^3.0.5",
|
|
53
|
+
"@csstools/css-tokenizer": "^3.0.4",
|
|
54
|
+
"@csstools/postcss-progressive-custom-properties": "^4.1.0",
|
|
56
55
|
"@csstools/utilities": "^2.0.0"
|
|
57
56
|
},
|
|
58
57
|
"peerDependencies": {
|