Skip to content
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
11 changes: 11 additions & 0 deletions plugins/postcss-alpha-function/test/basic.css
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,14 @@
color-1: alpha(from color(srgb srgb-linear 0.5 1 0) / calc(alpha / 2));
color-2: alpha(from color(var(--foo) 0.5 1 0) / calc(alpha / 2));
}

@property --foo {
inherits: false;
initial-value: alpha(from oklch(2 1 0) / calc(alpha / 2));
}

@keyframes --foo {
to {
--color: alpha(from oklch(2 1 0) / calc(alpha / 2));
}
}
11 changes: 11 additions & 0 deletions plugins/postcss-alpha-function/test/basic.expect.css
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,14 @@
color-1: alpha(from color(srgb srgb-linear 0.5 1 0) / calc(alpha / 2));
color-2: alpha(from color(var(--foo) 0.5 1 0) / calc(alpha / 2));
}

@property --foo {
inherits: false;
initial-value: oklch(from oklch(2 1 0) l c h / calc(alpha / 2));
}

@keyframes --foo {
to {
--color: oklch(from oklch(2 1 0) l c h / calc(alpha / 2));
}
}
28 changes: 28 additions & 0 deletions plugins/postcss-alpha-function/test/basic.preserve-true.expect.css
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,31 @@
color-1: alpha(from color(srgb srgb-linear 0.5 1 0) / calc(alpha / 2));
color-2: alpha(from color(var(--foo) 0.5 1 0) / calc(alpha / 2));
}

@property --foo {
inherits: false;
initial-value: oklch(from oklch(2 1 0) l c h / calc(alpha / 2));
}

@supports (color: alpha(from red / 1)) and (color: oklab(0% 0 0%)) {
@property --foo {
inherits: false;
initial-value: alpha(from oklch(2 1 0) / calc(alpha / 2));
}
}

@keyframes --foo {
to {
--color: oklch(from oklch(2 1 0) l c h / calc(alpha / 2));
}
}

@supports (color: alpha(from red / 1)) and (color: oklab(0% 0 0%)) {

@keyframes --foo {
to {
--color: oklch(from oklch(2 1 0) l c h / calc(alpha / 2));
--color: alpha(from oklch(2 1 0) / calc(alpha / 2));
}
}
}
11 changes: 11 additions & 0 deletions plugins/postcss-color-function-display-p3-linear/test/basic.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,14 @@
to-clone {
color: color(display-p3-linear 1 0 0);
}

@property --foo {
inherits: false;
initial-value: color(display-p3-linear 0.1 0.1 0.1);
}

@keyframes --foo {
to {
--color: color(display-p3-linear 0.1 0.1 0.1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,14 @@
to-clone {
color: color(display-p3 1 0 0);
}

@property --foo {
inherits: false;
initial-value: color(display-p3 0.34919 0.34919 0.34919);
}

@keyframes --foo {
to {
--color: color(display-p3 0.34919 0.34919 0.34919);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,31 @@ to-clone {
color: color(display-p3 1 0 0);
color: color(display-p3-linear 1 0 0);
}

@property --foo {
inherits: false;
initial-value: color(display-p3 0.34919 0.34919 0.34919);
}

@supports (color: color(display-p3-linear 0 0 0)) {
@property --foo {
inherits: false;
initial-value: color(display-p3-linear 0.1 0.1 0.1);
}
}

@keyframes --foo {
to {
--color: color(display-p3 0.34919 0.34919 0.34919);
}
}

@supports (color: color(display-p3-linear 0 0 0)) {

@keyframes --foo {
to {
--color: color(display-p3 0.34919 0.34919 0.34919);
--color: color(display-p3-linear 0.1 0.1 0.1);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,31 @@ to-clone {
color: color(display-p3 1 0 0);
color: color(display-p3-linear 1 0 0);
}

@property --foo {
inherits: false;
initial-value: color(display-p3 0.34919 0.34919 0.34919);
}

@supports (color: color(display-p3-linear 0 0 0)) {
@property --foo {
inherits: false;
initial-value: color(display-p3-linear 0.1 0.1 0.1);
}
}

@keyframes --foo {
to {
--color: color(display-p3 0.34919 0.34919 0.34919);
}
}

@supports (color: color(display-p3-linear 0 0 0)) {

@keyframes --foo {
to {
--color: color(display-p3 0.34919 0.34919 0.34919);
--color: color(display-p3-linear 0.1 0.1 0.1);
}
}
}
11 changes: 11 additions & 0 deletions plugins/postcss-color-function/test/basic.css
Original file line number Diff line number Diff line change
Expand Up @@ -221,3 +221,14 @@
to-clone {
color: color(display-p3 1 0 0);
}

@property --foo {
inherits: false;
initial-value: color(display-p3 0.1 0.1 0.1);
}

@keyframes --foo {
to {
--color: color(display-p3 0.1 0.1 0.1);
}
}
11 changes: 11 additions & 0 deletions plugins/postcss-color-function/test/basic.expect.css
Original file line number Diff line number Diff line change
Expand Up @@ -221,3 +221,14 @@
to-clone {
color: rgb(255, 52, 40);
}

@property --foo {
inherits: false;
initial-value: rgb(26, 26, 26);
}

@keyframes --foo {
to {
--color: rgb(26, 26, 26);
}
}
28 changes: 28 additions & 0 deletions plugins/postcss-color-function/test/basic.preserve-true.expect.css
Original file line number Diff line number Diff line change
Expand Up @@ -324,3 +324,31 @@ to-clone {
color: rgb(255, 52, 40);
color: color(display-p3 1 0 0);
}

@property --foo {
inherits: false;
initial-value: rgb(26, 26, 26);
}

@supports (color: color(display-p3 0 0 0%)) {
@property --foo {
inherits: false;
initial-value: color(display-p3 0.1 0.1 0.1);
}
}

@keyframes --foo {
to {
--color: rgb(26, 26, 26);
}
}

@supports (color: color(display-p3 0 0 0%)) {

@keyframes --foo {
to {
--color: rgb(26, 26, 26);
--color: color(display-p3 0.1 0.1 0.1);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -329,3 +329,31 @@ to-clone {
color: rgb(255, 52, 40);
color: color(display-p3 1 0 0);
}

@property --foo {
inherits: false;
initial-value: rgb(26, 26, 26);
}

@supports (color: color(display-p3 0 0 0%)) {
@property --foo {
inherits: false;
initial-value: color(display-p3 0.1 0.1 0.1);
}
}

@keyframes --foo {
to {
--color: rgb(26, 26, 26);
}
}

@supports (color: color(display-p3 0 0 0%)) {

@keyframes --foo {
to {
--color: rgb(26, 26, 26);
--color: color(display-p3 0.1 0.1 0.1);
}
}
}
11 changes: 11 additions & 0 deletions plugins/postcss-color-functional-notation/test/basic.css
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,14 @@
to-clone {
color: rgb(255 0 0);
}

@property --foo {
inherits: false;
initial-value: rgb(255 0 0);
}

@keyframes --foo {
to {
--color: rgb(255 0 0);
}
}
11 changes: 11 additions & 0 deletions plugins/postcss-color-functional-notation/test/basic.expect.css
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,14 @@
to-clone {
color: rgb(255, 0, 0);
}

@property --foo {
inherits: false;
initial-value: rgb(255, 0, 0);
}

@keyframes --foo {
to {
--color: rgb(255, 0, 0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,31 @@ to-clone {
color: rgb(255, 0, 0);
color: rgb(255 0 0);
}

@property --foo {
inherits: false;
initial-value: rgb(255, 0, 0);
}

@supports (color: rgb(0 0 0 / 0)) {
@property --foo {
inherits: false;
initial-value: rgb(255 0 0);
}
}

@keyframes --foo {
to {
--color: rgb(255, 0, 0);
}
}

@supports (color: rgb(0 0 0 / 0)) {

@keyframes --foo {
to {
--color: rgb(255, 0, 0);
--color: rgb(255 0 0);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,31 @@ to-clone {
color: rgb(255, 0, 0);
color: rgb(255 0 0);
}

@property --foo {
inherits: false;
initial-value: rgb(255, 0, 0);
}

@supports (color: rgb(0 0 0 / 0)) {
@property --foo {
inherits: false;
initial-value: rgb(255 0 0);
}
}

@keyframes --foo {
to {
--color: rgb(255, 0, 0);
}
}

@supports (color: rgb(0 0 0 / 0)) {

@keyframes --foo {
to {
--color: rgb(255, 0, 0);
--color: rgb(255 0 0);
}
}
}
4 changes: 4 additions & 0 deletions plugins/postcss-color-hex-alpha/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changes to PostCSS Color Hex Alpha

### Unreleased (patch)

- Ignore `initial-value` in `@property`

### 11.0.0

_January 14, 2026_
Expand Down
2 changes: 1 addition & 1 deletion plugins/postcss-color-hex-alpha/dist/index.mjs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import e from"postcss-value-parser";import{hasFallback as s}from"@csstools/utilities";const creator=a=>{const o=Object.assign({preserve:!1},a);return{postcssPlugin:"postcss-color-hex-alpha",Declaration(a){if(!t.test(a.value))return;if(s(a))return;const{value:l}=a,n=e(l);n.walk(e=>{if("function"===e.type&&"url"===e.value)return!1;"word"===e.type&&r.test(e.value)&&hexa2rgba(e)});const c=n.toString();c!==l&&(a.cloneBefore({value:c}),o.preserve||a.remove())}}};creator.postcss=!0;const t=/#[0-9a-f]{4}(?:[0-9a-f]{4})?\b/i,r=/^#[0-9a-f]{4}(?:[0-9a-f]{4})?$/i,a=1e5,o=/[0-9a-f]/gi;function hexa2rgba(e){const s=e.value,t=`0x${5===s.length?s.slice(1).replace(o,"$&$&"):s.slice(1)}`,[r,l,n,c]=[parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16),parseInt(t.slice(6,8),16),Math.round(parseInt(t.slice(8,10),16)/255*a)/a];e.value=`rgba(${r},${l},${n},${c})`}export{creator as default,creator as"module.exports"};
import e from"postcss-value-parser";import{hasFallback as t}from"@csstools/utilities";const creator=a=>{const o=Object.assign({preserve:!1},a);return{postcssPlugin:"postcss-color-hex-alpha",Declaration(a){if(!r.test(a.value))return;if(t(a))return;if("atrule"===a.parent?.type&&"property"===a.parent.name.toLowerCase())return;const{value:n}=a,l=e(n);l.walk(e=>{if("function"===e.type&&"url"===e.value)return!1;"word"===e.type&&s.test(e.value)&&hexa2rgba(e)});const c=l.toString();c!==n&&(a.cloneBefore({value:c}),o.preserve||a.remove())}}};creator.postcss=!0;const r=/#[0-9a-f]{4}(?:[0-9a-f]{4})?\b/i,s=/^#[0-9a-f]{4}(?:[0-9a-f]{4})?$/i,a=1e5,o=/[0-9a-f]/gi;function hexa2rgba(e){const t=e.value,r=`0x${5===t.length?t.slice(1).replace(o,"$&$&"):t.slice(1)}`,[s,n,l,c]=[parseInt(r.slice(2,4),16),parseInt(r.slice(4,6),16),parseInt(r.slice(6,8),16),Math.round(parseInt(r.slice(8,10),16)/255*a)/a];e.value=`rgba(${s},${n},${l},${c})`}export{creator as default,creator as"module.exports"};
4 changes: 4 additions & 0 deletions plugins/postcss-color-hex-alpha/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ const creator: PluginCreator<pluginOptions> = (opts?: pluginOptions) => {
return;
}

if (decl.parent?.type === 'atrule' && decl.parent.name.toLowerCase() === 'property') {
return;
}

const { value: originalValue } = decl;

// replace instances of hexa with rgba()
Expand Down
11 changes: 11 additions & 0 deletions plugins/postcss-color-hex-alpha/test/basic.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,14 @@ body {
to-clone {
color: #9823f8a9;
}

@property --foo {
inherits: false;
initial-value: #9823f8a9;
}

@keyframes --foo {
to {
--color: #9823f8a9;
}
}
11 changes: 11 additions & 0 deletions plugins/postcss-color-hex-alpha/test/basic.expect.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,14 @@ body {
to-clone {
color: rgba(152,35,248,0.66275);
}

@property --foo {
inherits: false;
initial-value: #9823f8a9;
}

@keyframes --foo {
to {
--color: rgba(152,35,248,0.66275);
}
}
Loading
Loading