diff --git a/projects/cdk/schematics/ng-update/v4/steps/styles/index.ts b/projects/cdk/schematics/ng-update/v4/steps/styles/index.ts index a06eca9b8ade..a9478c961edf 100644 --- a/projects/cdk/schematics/ng-update/v4/steps/styles/index.ts +++ b/projects/cdk/schematics/ng-update/v4/steps/styles/index.ts @@ -1,6 +1,7 @@ /// import {getActiveProject, saveActiveProject} from 'ng-morph'; +import {migrateLegacyMixins} from './migrate-legacy-mixins'; import {migrateLessSCSSConstants} from './migrate-less-scss-constants'; import {migrateMixins} from './migrate-mixins'; import {migrateShadowMixins} from './migrate-shadow-mixins'; @@ -49,6 +50,7 @@ export function migrateStyles(): void { migrateShadowMixins, migrateLessSCSSConstants, migrateMixins, + migrateLegacyMixins, ].reduce((text, migrate) => migrate(text), fullText); sourceFile.replaceWithText(newFileContent); diff --git a/projects/cdk/schematics/ng-update/v4/steps/styles/migrate-legacy-mixins.ts b/projects/cdk/schematics/ng-update/v4/steps/styles/migrate-legacy-mixins.ts new file mode 100644 index 000000000000..c29808725046 --- /dev/null +++ b/projects/cdk/schematics/ng-update/v4/steps/styles/migrate-legacy-mixins.ts @@ -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; +} diff --git a/projects/cdk/schematics/ng-update/v4/tests/schematic-migrate-styles.spec.ts b/projects/cdk/schematics/ng-update/v4/tests/schematic-migrate-styles.spec.ts index 42bd3e642eb0..b2545ae28acf 100644 --- a/projects/cdk/schematics/ng-update/v4/tests/schematic-migrate-styles.spec.ts +++ b/projects/cdk/schematics/ng-update/v4/tests/schematic-migrate-styles.spec.ts @@ -32,6 +32,7 @@ const STYLES_BEFORE = ` .text-overflow(); .tui-space(vertical, 4); .text-h3(); + .customize-scroll(); padding-top: @space * 2; } @@ -57,7 +58,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'; @@ -79,6 +81,7 @@ const STYLES_AFTER = ` margin-top: 1rem; margin-bottom: 1rem; font: var(--tui-font-heading-3); + .customize-scroll(); padding-top: 0.25rem * 2; }