Skip to content

Commit 6da885e

Browse files
authored
various fixes (#289)
1 parent 8feed04 commit 6da885e

File tree

16 files changed

+511
-153
lines changed

16 files changed

+511
-153
lines changed

plugins/postcss-double-position-gradients/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
### Unreleased (patch)
44

55
- Add typescript support
6+
- Fix color functions.
67
- Fix `at` keyword with `at 20px 20px` being interpreted as a double position color stop.
78

89
### 3.1.0 (February 15, 2022)

plugins/postcss-double-position-gradients/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ const basePlugin = (opts) => {
9898
// if the argument concludes a double-position gradient
9999
if (isDoublePositionLength) {
100100
// insert the fallback colors
101-
const color = { type: twoValuesBack.type, value: twoValuesBack.value };
101+
const color = twoValuesBack;
102102
const comma = {
103103
type: 'div',
104104
value: ',',

plugins/postcss-double-position-gradients/test/basic.css

+8
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,11 @@
5656
.test-color-space-interop {
5757
background: linear-gradient(in lab to right, #44C 0% 10%, #795)
5858
}
59+
60+
.repeating-conic {
61+
background: repeating-conic-gradient(
62+
from 3deg,
63+
hsl(200, 100%, 50%) 0deg 15deg,
64+
hsl(200, 100%, 60%) 10deg 30deg
65+
);
66+
}

plugins/postcss-double-position-gradients/test/basic.expect.css

+13
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,16 @@
9191
background: linear-gradient(in lab to right, #44C 0%,#44C 10%, #795);
9292
background: linear-gradient(in lab to right, #44C 0% 10%, #795)
9393
}
94+
95+
.repeating-conic {
96+
background: repeating-conic-gradient(
97+
from 3deg,
98+
hsl(200, 100%, 50%) 0deg,hsl(200, 100%, 50%) 15deg,
99+
hsl(200, 100%, 60%) 10deg, hsl(200, 100%, 60%) 30deg
100+
);
101+
background: repeating-conic-gradient(
102+
from 3deg,
103+
hsl(200, 100%, 50%) 0deg 15deg,
104+
hsl(200, 100%, 60%) 10deg 30deg
105+
);
106+
}

plugins/postcss-double-position-gradients/test/basic.preserve.expect.css

+8
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,11 @@
5656
.test-color-space-interop {
5757
background: linear-gradient(in lab to right, #44C 0%,#44C 10%, #795)
5858
}
59+
60+
.repeating-conic {
61+
background: repeating-conic-gradient(
62+
from 3deg,
63+
hsl(200, 100%, 50%) 0deg,hsl(200, 100%, 50%) 15deg,
64+
hsl(200, 100%, 60%) 10deg, hsl(200, 100%, 60%) 30deg
65+
);
66+
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changes to PostCSS Gradients Interpolation Method
22

3+
### Unreleased (patch)
4+
5+
- fix dependencies
6+
37
### 1.0.0 (March 4, 2022)
48

59
- Initial version

plugins/postcss-gradients-interpolation-method/package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@
2323
"README.md",
2424
"dist"
2525
],
26-
"peerDependencies": {
27-
"postcss": "^8.3"
28-
},
29-
"devDependencies": {
26+
"dependencies": {
3027
"@csstools/postcss-progressive-custom-properties": "^1.1.0",
3128
"postcss-value-parser": "^4.2.0"
3229
},
30+
"peerDependencies": {
31+
"postcss": "^8.3"
32+
},
3333
"scripts": {
3434
"build": "rollup -c ../../rollup/default.js",
3535
"clean": "node -e \"fs.rmSync('./dist', { recursive: true, force: true });\"",

plugins/postcss-progressive-custom-properties/CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# Changes to PostCSS Progressive Custom Properties
22

3-
## Unreleased (patch)
3+
## Unreleased (minor)
44

5+
- Add matching rules for `color-mix`
56
- fix matching rules for gradient functions
7+
- reduce matchers size
68

79
## 1.2.0 (February 15, 2022)
810

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { matcherForValue } from './matcher-for-value.mjs';
2+
3+
export const colorMixMatchers = [
4+
{
5+
'supports': 'color-mix(in oklch, #000, #fff)',
6+
'property': 'color',
7+
'sniff': 'color-mix',
8+
'matchers': [
9+
matcherForValue('color-mix(in $a,$1,$2)'),
10+
matcherForValue('color-mix(in $a,$1 $2,$3)'),
11+
matcherForValue('color-mix(in $a,$1,$2 $3)'),
12+
matcherForValue('color-mix(in $a,$1 $2,$3 $4)'),
13+
14+
matcherForValue('color-mix(in $a $b,$1,$2)'),
15+
matcherForValue('color-mix(in $a $b,$1 $2,$3)'),
16+
matcherForValue('color-mix(in $a $b,$1,$2 $3)'),
17+
matcherForValue('color-mix(in $a $b,$1 $2,$3 $4)'),
18+
],
19+
},
20+
];

plugins/postcss-progressive-custom-properties/generate/color.mjs

-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ export const hslMatchers = [
3131
'sniff': 'hsl',
3232
'matchers': [
3333
matcherForValue('hsl($1,$2,$3,$4)'),
34-
matcherForValue('hsl($1, $2, $3, $4)'),
3534
],
3635
},
3736
{
@@ -119,7 +118,6 @@ export const rgbMatchers = [
119118
'property': 'color',
120119
'sniff': 'rgb',
121120
'matchers': [
122-
matcherForValue('rgb($1, $2, $3, $4)'),
123121
matcherForValue('rgb($1,$2,$3,$4)'),
124122
],
125123
},

plugins/postcss-progressive-custom-properties/generate/matcher-for-value.mjs

+5-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ export function matcherForValue(value) {
1010
delete node.after;
1111
delete node.sourceEndIndex;
1212

13-
if (node.value.startsWith('$')) {
13+
if (node.type === 'space') {
14+
delete node.value;
15+
} else if (node.value.startsWith('$')) {
1416
delete node.value;
1517
node.isVariable = true;
1618
} else {
@@ -19,6 +21,8 @@ export function matcherForValue(value) {
1921
} finally {
2022
if (node.dimension === false) {
2123
delete node.dimension;
24+
} else {
25+
delete node.dimension.number;
2226
}
2327
}
2428
}

plugins/postcss-progressive-custom-properties/generate/matchers.mjs

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { promises as fsp } from 'fs';
2+
import { colorMixMatchers } from './color-mix.mjs';
23
import { colorMatchers, hslMatchers, hwbMatchers, labMatchers, lchMatchers, oklabMatchers, oklchMatchers, rgbMatchers } from './color.mjs';
34
import { icUnitMatchers } from './font-size.mjs';
45

@@ -16,6 +17,9 @@ fsp.writeFile(
1617
...oklchMatchers,
1718
...rgbMatchers,
1819

20+
// color mix:
21+
...colorMixMatchers,
22+
1923
// font-size:
2024
...icUnitMatchers,
2125
],

plugins/postcss-progressive-custom-properties/src/match.ts

+16-5
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,23 @@ export function matches(a, b) {
1212
}
1313

1414
if (a.nodes && b.nodes) {
15-
if (a.nodes.length !== b.nodes.length) {
16-
return false;
17-
}
18-
1915
for (let i = 0; i < a.nodes.length; i++) {
20-
if (!matches(a.nodes[i], b.nodes[i])) {
16+
let ia = i;
17+
let ib = i;
18+
19+
while (a.nodes[ia] && a.nodes[ia].type === 'space') {
20+
ia++;
21+
}
22+
23+
while (b.nodes[ib] && b.nodes[ib].type === 'space') {
24+
ib++;
25+
}
26+
27+
if (!!a.nodes[ia] !== !!b.nodes[ib]) {
28+
return false;
29+
}
30+
31+
if (!matches(a.nodes[ia], b.nodes[ib])) {
2132
return false;
2233
}
2334
}

0 commit comments

Comments
 (0)