Skip to content

Commit

Permalink
[node-build-scripts] fix(generate-css-variables): whitespace in maps (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
adidahiya authored Mar 2, 2023
1 parent 5b0687f commit cfde6bd
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/common/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ $pt-dark-input-intent-box-shadow-colors: (
"primary": $blue4,
"success": $green4,
"warning": $orange4,
"danger" : $red4,
"danger": $red4,
) !default;

$pt-dark-dialog-box-shadow: $pt-dark-elevation-shadow-3 !default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@
@test-map: {
first: #111418;
second: #ffffff;
third: #5f6b7c;
};
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ $pt-dark-popover-border-color: hsl(215deg, 3%, 38%) !default;
$test-map: (
"first": #111418,
"second": #ffffff,
"third": #5f6b7c,
) !default;
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ $pt-text-color-disabled: rgba($gray1, 0.6) !default;
$pt-dark-divider-white: rgba($white, 0.2) !default;
$pt-dark-popover-border-color: hsl(215deg, 3%, 38%) !default;
$test-map: (
"first": $black,
"first" : $black,
"second": $white,
"third" : $gray1,
) !default;
6 changes: 3 additions & 3 deletions packages/node-build-scripts/src/cssVariables.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function printVariable(value, allVariables, outputType) {
} else if (line === ")") {
return "}";
} else {
return line.replace(/"(\S+)": (.+),/, (_substr, key, value) => `${key}: ${value.trim()};`);
return line.replace(/"(\S+)"\s*: (.+),/, (_substr, key, value) => `${key}: ${value.trim()};`);
}
})
.join("\n");
Expand Down Expand Up @@ -149,12 +149,12 @@ export function generateLessVariables(parsedInput) {
const lessBlock = lessVariablesArray
.join("\n")
.replace(/rgba\((\$[\w-]+), ([\d\.]+)\)/g, (_match, color, opacity) => `fade(${color}, ${+opacity * 100}%)`)
// special case for hsl(), which supports a value like '270deg' in its first argument in Sass, but in Less we must omit the 'deg'
.replace(/hsl\(([0-9]+)deg, (.+)\)/g, (_match, degrees, rest) => `hsl(${degrees}, ${rest})`)
.replace(
/rgba\((\$[\w-]+), (\$[\w-]+)\)/g,
(_match, color, variable) => `fade(${color}, ${variable} * 100%)`,
)
// special case for hsl(), which supports a value like '270deg' in its first argument in Sass, but in Less we must omit the 'deg'
.replace(/hsl\(([0-9]+)deg, (.+)\)/g, (_match, degrees, rest) => `hsl(${degrees}, ${rest})`)
.replace(/\$/g, "@");

variablesLess = `${variablesLess}${lessBlock}\n\n`;
Expand Down

1 comment on commit cfde6bd

@adidahiya
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[node-build-scripts] fix(generate-css-variables): whitespace in maps (#5991)

Build artifact links for this commit: documentation | landing | table | demo

This is an automated comment from the deploy-preview CircleCI job.

Please sign in to comment.