Skip to content

Commit 9b5e0c3

Browse files
committed
refactor(datepicker): remove MatIconModule dependency
Removes the dependency between the `MatDatepickerModule` and `MatIconModule`, because we were only using a handful of styles but were pulling in all of the overhead that comes with the icon module (e.g. the icon registry, the dependency to the `HttpClientModule` etc.).
1 parent 4523556 commit 9b5e0c3

File tree

5 files changed

+27
-10
lines changed

5 files changed

+27
-10
lines changed

src/lib/datepicker/BUILD.bazel

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ ng_module(
99
module_name = "@angular/material/datepicker",
1010
assets = [
1111
":datepicker_content_css",
12+
":datepicker_toggle_css",
1213
":calendar_body_css",
1314
":calendar_css",
1415
],
1516
deps = [
1617
"//src/lib/core",
1718
"//src/lib/button",
1819
"//src/lib/dialog",
19-
"//src/lib/icon",
2020
"//src/lib/input",
2121
"//src/cdk/a11y",
2222
"//src/cdk/bidi",
@@ -35,6 +35,12 @@ sass_binary(
3535
deps = ["//src/lib/core:core_scss_lib"],
3636
)
3737

38+
sass_binary(
39+
name = "datepicker_toggle_scss",
40+
src = "datepicker-toggle.scss",
41+
deps = ["//src/lib/core:core_scss_lib"],
42+
)
43+
3844
sass_binary(
3945
name = "calendar_scss",
4046
src = "calendar.scss",
@@ -56,6 +62,15 @@ genrule(
5662
cmd = "cat $(locations :datepicker_content_scss) > $@",
5763
)
5864

65+
# TODO(jelbourn): remove this when sass_binary supports specifying an output filename and dir.
66+
# Copy the output of the sass_binary such that the filename and path match what we expect.
67+
genrule(
68+
name = "datepicker_toggle_css",
69+
srcs = [":datepicker_toggle_scss"],
70+
outs = ["datepicker-toggle.css"],
71+
cmd = "cat $(locations :datepicker_toggle_scss) > $@",
72+
)
73+
5974
# TODO(jelbourn): remove this when sass_binary supports specifying an output filename and dir.
6075
# Copy the output of the sass_binary such that the filename and path match what we expect.
6176
genrule(

src/lib/datepicker/datepicker-module.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {CommonModule} from '@angular/common';
1212
import {NgModule} from '@angular/core';
1313
import {MatButtonModule} from '@angular/material/button';
1414
import {MatDialogModule} from '@angular/material/dialog';
15-
import {MatIconModule} from '@angular/material/icon';
1615
import {MatCalendar} from './calendar';
1716
import {MatCalendarBody} from './calendar-body';
1817
import {
@@ -33,7 +32,6 @@ import {MatYearView} from './year-view';
3332
CommonModule,
3433
MatButtonModule,
3534
MatDialogModule,
36-
MatIconModule,
3735
OverlayModule,
3836
A11yModule,
3937
],
Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
<button mat-icon-button type="button" [attr.aria-label]="_intl.openCalendarLabel"
22
[disabled]="disabled" (click)="_open($event)">
3-
<mat-icon>
4-
<svg viewBox="0 0 24 24" width="100%" height="100%" fill="currentColor"
5-
style="vertical-align: top" focusable="false">
6-
<path d="M0 0h24v24H0z" fill="none"/>
7-
<path d="M19 3h-1V1h-2v2H8V1H6v2H5c-1.11 0-1.99.9-1.99 2L3 19c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V8h14v11zM7 10h5v5H7z"/>
8-
</svg>
9-
</mat-icon>
3+
<svg class="mat-datepicker-toggle-default-icon" viewBox="0 0 24 24" width="24px" height="24px" fill="currentColor" focusable="false">
4+
<path d="M0 0h24v24H0z" fill="none"/>
5+
<path d="M19 3h-1V1h-2v2H8V1H6v2H5c-1.11 0-1.99.9-1.99 2L3 19c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V8h14v11zM7 10h5v5H7z"/>
6+
</svg>
107
</button>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.mat-datepicker-toggle-default-icon {
2+
.mat-form-field-prefix &,
3+
.mat-form-field-suffix & {
4+
width: 1em;
5+
}
6+
}

src/lib/datepicker/datepicker-toggle.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {MatDatepickerIntl} from './datepicker-intl';
2929
moduleId: module.id,
3030
selector: 'mat-datepicker-toggle',
3131
templateUrl: 'datepicker-toggle.html',
32+
styleUrls: ['datepicker-toggle.css'],
3233
host: {
3334
'class': 'mat-datepicker-toggle',
3435
},

0 commit comments

Comments
 (0)