Skip to content

Commit

Permalink
fix(class-name-updater): ignore css vars when running in v6 mode (#778)
Browse files Browse the repository at this point in the history
  • Loading branch information
wise-king-sullyman authored Sep 30, 2024
1 parent 6522f06 commit d05506e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/class-name-updater/src/classNameUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ export async function classNameUpdate(
const isPostV5 = pfVersion > 5;
const previousVersion = isPostV5 ? "-v" + (pfVersion - 1) : "";
const classNameMatches = "[cul]";
const cssVarMatches = `${classNameMatches}|global|theme|color`;
const cssVarMatches = `${classNameMatches}|global|theme|color|chart`;
const bodyMatches = isPostV5 ? classNameMatches : cssVarMatches;
const cssVarStart = isPostV5 ? "[^-]" : "";
const changeNeededRegex = new RegExp(
"(\\b|\\$)pf" + previousVersion + `-(${bodyMatches})-`,
`(${cssVarStart})` + "(\\b|\\$)pf" + previousVersion + `-(${bodyMatches})-`,
"g"
);
const newVersion = pfVersion || 5;
Expand Down Expand Up @@ -47,7 +48,7 @@ export async function classNameUpdate(

const newContent = fileContent.replace(
changeNeededRegex,
`$1pf-v${newVersion}-$2-`
`$1$2pf-v${newVersion}-$3-`
);

printDiff(file, fileContent, newContent, changeNeededRegex);
Expand Down
1 change: 1 addition & 0 deletions packages/class-name-updater/test/test.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
}
.pf-c-console__actions > div {
margin-right: var(--pf-v5-global--spacer--sm);
box-shadow: var(--pf-v5-c-wizard__toggle--BoxShadow);
}

.pf-m-selectable {
Expand Down

0 comments on commit d05506e

Please sign in to comment.