@thejaredwilcurt/csslop 0.0.28 → 0.0.29
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/package.json +1 -1
- package/src/declarations/border.js +27 -6
package/package.json
CHANGED
|
@@ -69,6 +69,26 @@ const INITIAL_BORDER_EDGE_PARTS = {
|
|
|
69
69
|
'border-color': 'currentcolor'
|
|
70
70
|
};
|
|
71
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Builds the `border` value that states a trio whose color differs per edge.
|
|
74
|
+
* Unlike a shorthand assembled out of whole longhand values, this value is one
|
|
75
|
+
* the rewrite composes: it takes a single component out of the color list rather
|
|
76
|
+
* than the `border-color` value as authored. So it is minified as a written
|
|
77
|
+
* value, which drops the separators CSS does not need between its components
|
|
78
|
+
* and measures the value at the length it is emitted with.
|
|
79
|
+
*
|
|
80
|
+
* @param {string} width The `border-width` value.
|
|
81
|
+
* @param {string} style The `border-style` value.
|
|
82
|
+
* @param {string} firstColor The first component of the `border-color` value.
|
|
83
|
+
* @return {string} The minified `border` value.
|
|
84
|
+
*/
|
|
85
|
+
function buildBorderShorthandValue (width, style, firstColor) {
|
|
86
|
+
return minifyValue({
|
|
87
|
+
property: 'border',
|
|
88
|
+
value: [width, style, firstColor].join(' ')
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
72
92
|
/**
|
|
73
93
|
* Finds the index of the last declaration for a property, which is the one that
|
|
74
94
|
* wins the cascade within a rule.
|
|
@@ -149,7 +169,7 @@ function collapseBorderTrioWithPerEdgeColor (declarations, context) {
|
|
|
149
169
|
return declarations;
|
|
150
170
|
}
|
|
151
171
|
|
|
152
|
-
const borderValue =
|
|
172
|
+
const borderValue = buildBorderShorthandValue(width, style, colorComponents[0]) + importantSuffix;
|
|
153
173
|
const colorValue = color + importantSuffix;
|
|
154
174
|
const rewrittenLength = ('border:' + borderValue + ';border-color:' + colorValue).length;
|
|
155
175
|
const longhandLength = (
|
|
@@ -168,8 +188,7 @@ function collapseBorderTrioWithPerEdgeColor (declarations, context) {
|
|
|
168
188
|
return [
|
|
169
189
|
{
|
|
170
190
|
property: 'border',
|
|
171
|
-
value: borderValue
|
|
172
|
-
isAssembledShorthand: true
|
|
191
|
+
value: borderValue
|
|
173
192
|
},
|
|
174
193
|
{
|
|
175
194
|
property: 'border-color',
|
|
@@ -285,9 +304,11 @@ function buildBorderTrioDeclarations (edgeDeclarations) {
|
|
|
285
304
|
edgeParts.push(parts);
|
|
286
305
|
}
|
|
287
306
|
|
|
288
|
-
// The three parts do not affect one another, so they are written in
|
|
289
|
-
//
|
|
290
|
-
|
|
307
|
+
// The three parts do not affect one another, so they are written in the fixed
|
|
308
|
+
// order the `border` grammar takes them in, rather than in an order the values
|
|
309
|
+
// would decide. A predictable order repeats across rules, which compresses
|
|
310
|
+
// better than one that varies.
|
|
311
|
+
return BORDER_TRIO_PROPERTIES.map((property) => {
|
|
291
312
|
const sideValues = edgeParts.map((parts) => {
|
|
292
313
|
return parts[property];
|
|
293
314
|
});
|