Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(class-name-updater): ignore css vars when running in v6 mode #778

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading