Skip to content

Commit

Permalink
fix(cdk): missing migration schematic for mixins from `@taiga-ui/lega…
Browse files Browse the repository at this point in the history
…cy/styles/taiga-ui-local`
  • Loading branch information
nsbarsukov committed Nov 20, 2024
1 parent e9b43ca commit b4f7742
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
2 changes: 2 additions & 0 deletions projects/cdk/schematics/ng-update/v4/steps/styles/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/// <reference lib="es2021" />
import {getActiveProject, saveActiveProject} from 'ng-morph';

import {migrateLegacyMixins} from './migrate-legacy-mixins';
import {migrateLessSCSSConstants} from './migrate-less-scss-constants';
import {migrateScrollbarBehavior} from './migrate-scrollbar-behavior';
import {migrateShadowMixins} from './migrate-shadow-mixins';
Expand Down Expand Up @@ -49,6 +50,7 @@ export function migrateStyles(): void {
migrateShadowMixins,
migrateLessSCSSConstants,
migrateScrollbarBehavior,
migrateLegacyMixins,
].reduce((text, migrate) => migrate(text), fullText);

sourceFile.replaceWithText(newFileContent);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const LEGACY_MIXINS = [
'clearfix',
'autofill',
'clearinput',
'visually-hidden',
'webkit-auto-fill-button-hidden',
'customize-scroll',
'inset-border',
'dashed-border',
'opacity-icon',
'hoverable-with-shadow',
'text-overflow-with-fade',
'contrast-background',
'blurred-background',
'textfield-host',
'textfield-content',
'textfield-input',
'textfield-wrapper',
'textfield-label',
'input-icon',
'input-icons',
'icon-button',
'textfield',
];

export function migrateLegacyMixins(fileContent: string): string {
if (!fileContent.includes('@taiga-ui/core/styles/taiga-ui-local')) {
return fileContent;
}

return LEGACY_MIXINS.some((x) => fileContent.includes(x))
? `@import '@taiga-ui/legacy/styles/taiga-ui-local';\n${fileContent}`
: fileContent;
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const STYLES_BEFORE = `
.text-overflow();
.tui-space(vertical, 4);
.text-h3();
.customize-scroll();
padding-top: @space * 2;
}
Expand All @@ -55,7 +56,8 @@ const STYLES_BEFORE = `
}
`;

const STYLES_AFTER = `
const STYLES_AFTER = `@import '@taiga-ui/legacy/styles/taiga-ui-local';
@import '@taiga-ui/proprietary/styles/tbank-fonts';
@import '@taiga-ui/core/styles/taiga-ui-local.less';
Expand All @@ -77,6 +79,7 @@ const STYLES_AFTER = `
margin-top: 1rem;
margin-bottom: 1rem;
font: var(--tui-font-heading-3);
.customize-scroll();
padding-top: 0.25rem * 2;
}
Expand Down

0 comments on commit b4f7742

Please sign in to comment.