Skip to content

Commit 501b78d

Browse files
committed
refactor(cdk/overlay): use index files for public Sass API instead of copying files out
Currently we copy out a few of the CDK .scss files to the root of the `cdk` package so that they're more convenient to consume. The problem with this is that it prevents us from importing other Sass files, because the import path will be wrong after the files are copied (see #22043). These changes rename the files to `_index.scss` which will allow users to maintain the same import paths while allowing us to remove the file copying logic and not having to worry about import paths. BREAKING CHANGES: Deep imports to the following CDK .scss files need to be updated: * `@import '~@angular/cdk/overlay/overlay'` -> `@import ~@angular/cdk/overlay` * `@import '~@angular/cdk/a11y/a11y'` -> `@import ~@angular/cdk/a11y` * `@import '~@angular/cdk/text-field/text-field'` -> `@import ~@angular/cdk/text-field`
1 parent 0c83adc commit 501b78d

File tree

80 files changed

+108
-116
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+108
-116
lines changed

src/cdk/BUILD.bazel

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,7 @@ ts_library(
1717
# to make it easier for developers to import these styles without needing to know about
1818
# deep imports in the release output. Note that this is done for backwards compatibility
1919
# with the Gulp release output. TODO(devversion): consider removing this in the future.
20-
rerootedStyles = [file for target in CDK_ENTRYPOINTS_WITH_STYLES for file in [
21-
[
22-
"_%s.scss" % target,
23-
target,
24-
],
25-
[
26-
"_%s.import.scss" % target,
27-
target,
28-
],
20+
prebuiltStyles = [file for target in CDK_ENTRYPOINTS_WITH_STYLES for file in [
2921
[
3022
"%s-prebuilt.css" % target,
3123
target,
@@ -34,20 +26,20 @@ rerootedStyles = [file for target in CDK_ENTRYPOINTS_WITH_STYLES for file in [
3426

3527
# Create genrules which re-root stylesheets from secondary entry-points.
3628
[genrule(
37-
name = "%s_rerooted" % file,
29+
name = "%s_prebuilt" % file,
3830
srcs = ["//src/cdk/%s:%s" % (target, file)],
3931
outs = [file],
4032
cmd = "cp $< $@",
4133
) for [
4234
file,
4335
target,
44-
] in rerootedStyles]
36+
] in prebuiltStyles]
4537

4638
# List of targets which generate the re-rooted stylesheet files.
47-
rerootedStyleTargets = ["%s_rerooted" % file for [
39+
prebuiltStyleTargets = ["%s_prebuilt" % file for [
4840
file,
4941
_,
50-
] in rerootedStyles]
42+
] in prebuiltStyles]
5143

5244
# Makes the public Sass API bundle available in the release output as `angular/cdk`.
5345
sass_library(
@@ -59,7 +51,7 @@ sass_library(
5951
ng_package(
6052
name = "npm_package",
6153
srcs = ["package.json"],
62-
data = [":sass_index"] + rerootedStyleTargets + CDK_SCSS_LIBS,
54+
data = [":sass_index"] + prebuiltStyleTargets + CDK_SCSS_LIBS,
6355
entry_point = ":public-api.ts",
6456
nested_packages = [
6557
"//src/cdk/schematics:npm_package",

src/cdk/_index.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
@forward './overlay/overlay' show overlay, $z-index-overlay-container, $z-index-overlay,
1+
@forward './overlay' show overlay, $z-index-overlay-container, $z-index-overlay,
22
$z-index-overlay-backdrop, $dark-backdrop-background;
3-
@forward './a11y/a11y' show a11y-visually-hidden, high-contrast;
4-
@forward './text-field/text-field' show text-field-autosize, text-field-autofill,
3+
@forward './a11y' show a11y-visually-hidden, high-contrast;
4+
@forward './text-field' show text-field-autosize, text-field-autofill,
55
text-field-autofill-color,
66
// `text-field` is deprecated, but we have to export it
77
// here in order for the theming API schematic to work.

src/cdk/a11y/_a11y.import.scss

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/cdk/a11y/_index.import.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@forward 'index' hide a11y, high-contrast;
2+
@forward 'index' as cdk-* hide cdk-optionally-nest-content;
File renamed without changes.

src/cdk/a11y/a11y-prebuilt.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
@use './a11y';
1+
@use './index' as a11y;
22

33
@include a11y.a11y-visually-hidden();

src/cdk/overlay/_index.import.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
@forward '../a11y' as cdk-*;
2+
@forward 'index' hide $dark-backdrop-background, $z-index-overlay, $z-index-overlay-backdrop,
3+
$z-index-overlay-container, overlay;
4+
@forward 'index' as cdk-* hide $cdk-backdrop-animation-duration,
5+
$cdk-backdrop-animation-timing-function, $cdk-dark-backdrop-background;
6+
@forward 'index' as cdk-overlay-* hide $cdk-overlay-backdrop-animation-duration,
7+
$cdk-overlay-backdrop-animation-timing-function, $cdk-overlay-z-index-overlay,
8+
$cdk-overlay-z-index-overlay-backdrop, $cdk-overlay-z-index-overlay-container, cdk-overlay-overlay;
9+
10+
@import '../a11y';
File renamed without changes.

src/cdk/overlay/_overlay.import.scss

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
@use './overlay';
1+
@use './index' as overlay;
22

33
@include overlay.overlay();

0 commit comments

Comments
 (0)