Consitent break for comma seperated value (#16907)
* add softline before root paren group * add changelog * make conservative
This commit is contained in:
1 parent
730770e29a
commit
a7ddbdb899
3 files changed
+62
-21
No files matched your search
@@ -0,0 +1,28 @@
|
|||||||
|
#### Break before breaking comma separated values (#16907 by @seiyab)
|
||||||
|
|
||||||
|
<!-- prettier-ignore -->
|
||||||
|
```css
|
||||||
|
/* Input */
|
||||||
|
a {
|
||||||
|
background-image:
|
||||||
|
linear-gradient(to bottom, rgb(255 255 0 / 50%), rgb(0 0 255 / 50%)),
|
||||||
|
url("catfront.png");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Prettier stable */
|
||||||
|
a {
|
||||||
|
background-image: linear-gradient(
|
||||||
|
to bottom,
|
||||||
|
rgb(255 255 0 / 50%),
|
||||||
|
rgb(0 0 255 / 50%)
|
||||||
|
),
|
||||||
|
url("catfront.png");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Prettier main */
|
||||||
|
a {
|
||||||
|
background-image:
|
||||||
|
linear-gradient(to bottom, rgb(255 255 0 / 50%), rgb(0 0 255 / 50%)),
|
||||||
|
url("catfront.png");
|
||||||
|
}
|
||||||
|
```
|
||||||
@@ -88,7 +88,11 @@ function printParenthesizedValueGroup(path, options, print) {
|
|||||||
assertDocArray(groupDocs);
|
assertDocArray(groupDocs);
|
||||||
const withComma = chunk(join(",", groupDocs), 2);
|
const withComma = chunk(join(",", groupDocs), 2);
|
||||||
const parts = join(forceHardLine ? hardline : line, withComma);
|
const parts = join(forceHardLine ? hardline : line, withComma);
|
||||||
return indent(forceHardLine ? [hardline, parts] : group(fill(parts)));
|
return indent(
|
||||||
|
forceHardLine
|
||||||
|
? [hardline, parts]
|
||||||
|
: group([shouldPrecededBySoftline(path) ? softline : "", fill(parts)]),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const parts = path.map(({ node: child, isLast, index }) => {
|
const parts = path.map(({ node: child, isLast, index }) => {
|
||||||
@@ -165,6 +169,15 @@ function shouldBreakList(path) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function shouldPrecededBySoftline(path) {
|
||||||
|
return path.match(
|
||||||
|
(node) => node.type === "value-paren_group" && !node.open,
|
||||||
|
(node, key) => key === "group" && node.type === "value-value",
|
||||||
|
(node, key) => key === "group" && node.type === "value-root",
|
||||||
|
(node, key) => key === "value" && node.type === "css-decl",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @template {*} T
|
* @template {*} T
|
||||||
* @param {T[]} array
|
* @param {T[]} array
|
||||||
|
|||||||
@@ -412,11 +412,8 @@ background-image: linear-gradient(
|
|||||||
|
|
||||||
=====================================output=====================================
|
=====================================output=====================================
|
||||||
\`\`\`css
|
\`\`\`css
|
||||||
background-image: linear-gradient(
|
background-image:
|
||||||
to bottom,
|
linear-gradient(to bottom, rgb(255 255 0 / 50%), rgb(0 0 255 / 50%)),
|
||||||
rgb(255 255 0 / 50%),
|
|
||||||
rgb(0 0 255 / 50%)
|
|
||||||
),
|
|
||||||
url("catfront.png");
|
url("catfront.png");
|
||||||
\`\`\`
|
\`\`\`
|
||||||
|
|
||||||
@@ -452,7 +449,8 @@ width: 400px;
|
|||||||
.box {
|
.box {
|
||||||
margin: 10px 0;
|
margin: 10px 0;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
background: linear-gradient(
|
background:
|
||||||
|
linear-gradient(
|
||||||
90deg,
|
90deg,
|
||||||
rgb(131 58 180 / 100%) 0%,
|
rgb(131 58 180 / 100%) 0%,
|
||||||
rgb(253 29 29 / 60%) 60%,
|
rgb(253 29 29 / 60%) 60%,
|
||||||
@@ -498,7 +496,8 @@ background-position:
|
|||||||
.multi-bg-example {
|
.multi-bg-example {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 400px;
|
height: 400px;
|
||||||
background-image: url(firefox.png), url(bubbles.png),
|
background-image:
|
||||||
|
url(firefox.png), url(bubbles.png),
|
||||||
linear-gradient(to right, rgb(30 75 115 / 100%), rgb(255 255 255 / 0%));
|
linear-gradient(to right, rgb(30 75 115 / 100%), rgb(255 255 255 / 0%));
|
||||||
background-repeat: no-repeat, no-repeat, no-repeat;
|
background-repeat: no-repeat, no-repeat, no-repeat;
|
||||||
background-position:
|
background-position:
|
||||||
@@ -535,11 +534,8 @@ proseWrap: "always"
|
|||||||
=====================================output=====================================
|
=====================================output=====================================
|
||||||
\`\`\`css
|
\`\`\`css
|
||||||
.stacked-linear {
|
.stacked-linear {
|
||||||
background: linear-gradient(
|
background:
|
||||||
217deg,
|
linear-gradient(217deg, rgb(255 0 0 / 80%), rgb(255 0 0 / 0%) 70.71%),
|
||||||
rgb(255 0 0 / 80%),
|
|
||||||
rgb(255 0 0 / 0%) 70.71%
|
|
||||||
),
|
|
||||||
linear-gradient(127deg, rgb(0 255 0 / 80%), rgb(0 255 0 / 0%) 70.71%),
|
linear-gradient(127deg, rgb(0 255 0 / 80%), rgb(0 255 0 / 0%) 70.71%),
|
||||||
linear-gradient(336deg, rgb(0 0 255 / 80%), rgb(0 0 255 / 0%) 70.71%);
|
linear-gradient(336deg, rgb(0 0 255 / 80%), rgb(0 0 255 / 0%) 70.71%);
|
||||||
}
|
}
|
||||||
@@ -648,7 +644,8 @@ rgb(255 255 0 / 50%) 120px,
|
|||||||
=====================================output=====================================
|
=====================================output=====================================
|
||||||
\`\`\`css
|
\`\`\`css
|
||||||
.multi-repeating-linear {
|
.multi-repeating-linear {
|
||||||
background: repeating-linear-gradient(
|
background:
|
||||||
|
repeating-linear-gradient(
|
||||||
190deg,
|
190deg,
|
||||||
rgb(255 0 0 / 50%) 40px,
|
rgb(255 0 0 / 50%) 40px,
|
||||||
rgb(255 153 0 / 50%) 80px,
|
rgb(255 153 0 / 50%) 80px,
|
||||||
@@ -765,7 +762,8 @@ transparent 69px,
|
|||||||
=====================================output=====================================
|
=====================================output=====================================
|
||||||
\`\`\`css
|
\`\`\`css
|
||||||
.plaid-gradient {
|
.plaid-gradient {
|
||||||
background: repeating-linear-gradient(
|
background:
|
||||||
|
repeating-linear-gradient(
|
||||||
90deg,
|
90deg,
|
||||||
transparent,
|
transparent,
|
||||||
transparent 50px,
|
transparent 50px,
|
||||||
@@ -810,7 +808,8 @@ transparent 69px,
|
|||||||
rgb(143 77 63 / 25%) 10px
|
rgb(143 77 63 / 25%) 10px
|
||||||
);
|
);
|
||||||
|
|
||||||
background: repeating-linear-gradient(
|
background:
|
||||||
|
repeating-linear-gradient(
|
||||||
90deg,
|
90deg,
|
||||||
transparent 0 50px,
|
transparent 0 50px,
|
||||||
rgb(255 127 0 / 25%) 50px 56px,
|
rgb(255 127 0 / 25%) 50px 56px,
|
||||||
@@ -1110,8 +1109,8 @@ mask-image: image(url(mask.png), skyblue), linear-gradi
|
|||||||
=====================================output=====================================
|
=====================================output=====================================
|
||||||
\`\`\`css
|
\`\`\`css
|
||||||
/* Multiple values */
|
/* Multiple values */
|
||||||
mask-image: image(url(mask.png), skyblue),
|
mask-image:
|
||||||
linear-gradient(rgb(0 0 0 / 100%), transparent);
|
image(url(mask.png), skyblue), linear-gradient(rgb(0 0 0 / 100%), transparent);
|
||||||
\`\`\`
|
\`\`\`
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
@@ -1269,9 +1268,10 @@ U+0152-0153, U+02BB-02BC, U+02C6,
|
|||||||
local("Montserrat Regular"),
|
local("Montserrat Regular"),
|
||||||
local("Montserrat-Regular"),
|
local("Montserrat-Regular"),
|
||||||
url("fonts/montserrat-regular.woff2") format("woff2");
|
url("fonts/montserrat-regular.woff2") format("woff2");
|
||||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
|
unicode-range:
|
||||||
U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193,
|
U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
|
||||||
U+2212, U+2215, U+FEFF, U+FFFD;
|
U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215,
|
||||||
|
U+FEFF, U+FFFD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
\`\`\`
|
\`\`\`
|
||||||
|
|||||||
Reference in new issue
Block a user