Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
.example-form-field {
margin: 0 8px 16px 0;
}

/* The calendar renders in an overlay outside of this component, so the override has to target
the panel class. It gives the comparison range a colour that is clearly different from the
primary range, which the default M3 themes don't always do. */
.example-comparison-panel {
--mat-datepicker-calendar-date-in-comparison-range-state-background-color: rgba(249, 171, 0, 0.3);
--mat-datepicker-calendar-date-in-overlap-range-state-background-color: rgba(249, 171, 0, 0.6);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</mat-date-range-input>
<mat-hint>MM/DD/YYYY – MM/DD/YYYY</mat-hint>
<mat-datepicker-toggle matIconSuffix [for]="campaignOnePicker"></mat-datepicker-toggle>
<mat-date-range-picker #campaignOnePicker></mat-date-range-picker>
<mat-date-range-picker #campaignOnePicker panelClass="example-comparison-panel"></mat-date-range-picker>
</mat-form-field>

<mat-form-field class="example-form-field">
Expand All @@ -25,5 +25,5 @@
</mat-date-range-input>
<mat-datepicker-toggle matIconSuffix [for]="campaignTwoPicker"></mat-datepicker-toggle>
<mat-hint>MM/DD/YYYY – MM/DD/YYYY</mat-hint>
<mat-date-range-picker #campaignTwoPicker></mat-date-range-picker>
<mat-date-range-picker #campaignTwoPicker panelClass="example-comparison-panel"></mat-date-range-picker>
</mat-form-field>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component} from '@angular/core';
import {Component, ViewEncapsulation} from '@angular/core';
import {FormControl, FormGroup, FormsModule, ReactiveFormsModule} from '@angular/forms';
import {provideNativeDateAdapter} from '@angular/material/core';
import {MatDatepickerModule} from '@angular/material/datepicker';
Expand All @@ -15,6 +15,7 @@ const year = today.getFullYear();
styleUrl: 'date-range-picker-comparison-example.css',
providers: [provideNativeDateAdapter()],
imports: [MatFormFieldModule, MatDatepickerModule, FormsModule, ReactiveFormsModule],
encapsulation: ViewEncapsulation.None,
})
export class DateRangePickerComparisonExample {
readonly campaignOne = new FormGroup({
Expand Down
Loading