Skip to content

Commit

Permalink
feat(material/datepicker): remove dependency on dialog (#22383)
Browse files Browse the repository at this point in the history
Currently the datepicker has a hard dependency on `MatDialog` due to its touch-specific appearance which makes it difficult to use together with the MDC packages, because they have an alternate dialog module.

These changes resolve the issue by removing the datepicker's dependency on `MatDialog`.  The approach is loosely based on #13019, however I've simplified things a bit to make it more maintainable.
  • Loading branch information
crisbeto authored Apr 13, 2021
1 parent d030a87 commit 7039d3e
Show file tree
Hide file tree
Showing 9 changed files with 142 additions and 199 deletions.
2 changes: 0 additions & 2 deletions src/material/datepicker/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ ng_module(
"//src/cdk/portal",
"//src/material/button",
"//src/material/core",
"//src/material/dialog",
"//src/material/form-field",
"//src/material/input",
"@npm//@angular/animations",
Expand Down Expand Up @@ -102,7 +101,6 @@ ng_test_library(
"//src/cdk/scrolling",
"//src/cdk/testing/private",
"//src/material/core",
"//src/material/dialog",
"//src/material/form-field",
"//src/material/input",
"//src/material/testing",
Expand Down
2 changes: 1 addition & 1 deletion src/material/datepicker/_datepicker-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ $calendar-weekday-table-font-size: 11px !default;
}

.mat-datepicker-content-touch {
@include private.private-theme-elevation(0, $config);
@include private.private-theme-elevation(24, $config);
}

.mat-datepicker-toggle-active {
Expand Down
6 changes: 0 additions & 6 deletions src/material/datepicker/calendar-body.scss
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,6 @@ $calendar-range-end-body-cell-size:
}
}

// Allows for the screen reader close button to be seen in touch UI mode.
.mat-datepicker-dialog .mat-dialog-container {
position: relative;
overflow: visible;
}

@include a11y.high-contrast(active, off) {
.mat-datepicker-popup:not(:empty),
.mat-calendar-body-selected {
Expand Down
17 changes: 9 additions & 8 deletions src/material/datepicker/datepicker-animations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
style,
transition,
trigger,
keyframes,
AnimationTriggerMetadata,
} from '@angular/animations';

Expand All @@ -24,14 +25,14 @@ export const matDatepickerAnimations: {
} = {
/** Transforms the height of the datepicker's calendar. */
transformPanel: trigger('transformPanel', [
state('void', style({
opacity: 0,
transform: 'scale(1, 0.8)'
})),
transition('void => enter', animate('120ms cubic-bezier(0, 0, 0.2, 1)', style({
opacity: 1,
transform: 'scale(1, 1)'
}))),
transition('void => enter-dropdown', animate('120ms cubic-bezier(0, 0, 0.2, 1)', keyframes([
style({opacity: 0, transform: 'scale(1, 0.8)'}),
style({opacity: 1, transform: 'scale(1, 1)'})
]))),
transition('void => enter-dialog', animate('150ms cubic-bezier(0, 0, 0.2, 1)', keyframes([
style({opacity: 0, transform: 'scale(0.7)'}),
style({transform: 'none', opacity: 1})
]))),
transition('* => void', animate('100ms linear', style({opacity: 0})))
]),

Expand Down
Loading

0 comments on commit 7039d3e

Please sign in to comment.