Skip to content

Commit e628565

Browse files
author
Andrew Seguin
committed
fix(material/schematic): rename variables
1 parent c9db72a commit e628565

File tree

1 file changed

+25
-25
lines changed
  • src/material/schematics/ng-update

1 file changed

+25
-25
lines changed

src/material/schematics/ng-update/index.ts

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -52,36 +52,36 @@ function renameMdcTokens(): Rule {
5252
// Renames Angular Material component token CSS variables that were renamed so that the base
5353
// component's name came first or otherwise renamed to match our terminology instead of MDC's.
5454
function renameComponentTokens(): Rule {
55-
const replacements = [
56-
{oldStr: '--mat-circular-progress', newStr: '--mat-progress-spinner'},
57-
{oldStr: '--mat-elevated-card', newStr: '--mat-card-elevated'},
58-
{oldStr: '--mat-extended-fab', newStr: '--mat-fab-extended'},
59-
{oldStr: '--mat-filled-button', newStr: '--mat-button-filled'},
60-
{oldStr: '--mat-filled-text-field', newStr: '--mat-form-field-filled'},
61-
{oldStr: '--mat-full-pseudo-checkbox', newStr: '--mat-pseudo-checkbox-full'},
62-
{oldStr: '--mat-legacy-button-toggle', newStr: '--mat-button-toggle-legacy'},
63-
{oldStr: '--mat-linear-progress', newStr: '--mat-progress-bar'},
64-
{oldStr: '--mat-minimal-pseudo-checkbox', newStr: '--mat-pseudo-checkbox-minimal'},
65-
{oldStr: '--mat-outlined-button', newStr: '--mat-button-outlined'},
66-
{oldStr: '--mat-outlined-card', newStr: '--mat-card-outlined'},
67-
{oldStr: '--mat-outlined-text-field', newStr: '--mat-form-field-outlined'},
68-
{oldStr: '--mat-plain-tooltip', newStr: '--mat-tooltip'},
69-
{oldStr: '--mat-protected-button', newStr: '--mat-button-protected'},
70-
{oldStr: '--mat-secondary-navigation-tab', newStr: '--mat-tab'},
71-
{oldStr: '--mat-standard-button-toggle', newStr: '--mat-button-toggle'},
72-
{oldStr: '--mat-switch', newStr: '--mat-slide-toggle'},
73-
{oldStr: '--mat-tab-header', newStr: '--mat-tab'},
74-
{oldStr: '--mat-tab-header-with-background', newStr: '--mat-tab'},
75-
{oldStr: '--mat-tab-indicator', newStr: '--mat-tab'},
76-
{oldStr: '--mat-text-button', newStr: '--mat-button-text'},
77-
{oldStr: '--mat-tonal-button', newStr: '--mat-button-tonal'},
55+
const tokenPrefixes = [
56+
{old: '--mat-circular-progress', replacement: '--mat-progress-spinner'},
57+
{old: '--mat-elevated-card', replacement: '--mat-card-elevated'},
58+
{old: '--mat-extended-fab', replacement: '--mat-fab-extended'},
59+
{old: '--mat-filled-button', replacement: '--mat-button-filled'},
60+
{old: '--mat-filled-text-field', replacement: '--mat-form-field-filled'},
61+
{old: '--mat-full-pseudo-checkbox', replacement: '--mat-pseudo-checkbox-full'},
62+
{old: '--mat-legacy-button-toggle', replacement: '--mat-button-toggle-legacy'},
63+
{old: '--mat-linear-progress', replacement: '--mat-progress-bar'},
64+
{old: '--mat-minimal-pseudo-checkbox', replacement: '--mat-pseudo-checkbox-minimal'},
65+
{old: '--mat-outlined-button', replacement: '--mat-button-outlined'},
66+
{old: '--mat-outlined-card', replacement: '--mat-card-outlined'},
67+
{old: '--mat-outlined-text-field', replacement: '--mat-form-field-outlined'},
68+
{old: '--mat-plain-tooltip', replacement: '--mat-tooltip'},
69+
{old: '--mat-protected-button', replacement: '--mat-button-protected'},
70+
{old: '--mat-secondary-navigation-tab', replacement: '--mat-tab'},
71+
{old: '--mat-standard-button-toggle', replacement: '--mat-button-toggle'},
72+
{old: '--mat-switch', replacement: '--mat-slide-toggle'},
73+
{old: '--mat-tab-header', replacement: '--mat-tab'},
74+
{old: '--mat-tab-header-with-background', replacement: '--mat-tab'},
75+
{old: '--mat-tab-indicator', replacement: '--mat-tab'},
76+
{old: '--mat-text-button', replacement: '--mat-button-text'},
77+
{old: '--mat-tonal-button', replacement: '--mat-button-tonal'},
7878
];
7979
return tree => {
8080
tree.visit(path => {
8181
const content = tree.readText(path);
8282
let updatedContent = content;
83-
for (const replacement of replacements) {
84-
updatedContent = updatedContent.replace(replacement.oldStr, replacement.newStr);
83+
for (const tokenPrefix of tokenPrefixes) {
84+
updatedContent = updatedContent.replace(tokenPrefix.old, tokenPrefix.replacement);
8585
}
8686
if (content !== updatedContent) {
8787
tree.overwrite(path, updatedContent);

0 commit comments

Comments
 (0)