Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(material/datepicker): use SVG icons for calendar #29957

Merged
merged 1 commit into from
Nov 4, 2024
Merged
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
6 changes: 6 additions & 0 deletions src/material/datepicker/calendar-header.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,17 @@
<button mat-icon-button type="button" class="mat-calendar-previous-button"
[disabled]="!previousEnabled()" (click)="previousClicked()"
[attr.aria-label]="prevButtonLabel">
<svg viewBox="0 0 24 24" focusable="false" aria-hidden="true">
<path d="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"/>
</svg>
</button>

<button mat-icon-button type="button" class="mat-calendar-next-button"
[disabled]="!nextEnabled()" (click)="nextClicked()"
[attr.aria-label]="nextButtonLabel">
<svg viewBox="0 0 24 24" focusable="false" aria-hidden="true">
<path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/>
</svg>
</button>
</div>
</div>
27 changes: 0 additions & 27 deletions src/material/datepicker/calendar.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
@use '@angular/cdk';

@use '../core/style/layout-common';
@use '../core/focus-indicators/private';
@use '../core/tokens/m2/mat/datepicker' as tokens-mat-datepicker;
@use '../core/tokens/token-utils';
Expand All @@ -16,12 +15,6 @@ $calendar-controls-side-margin: calc(33% / 7 - 16px);
$calendar-arrow-size: 5px !default;
$calendar-arrow-disabled-opacity: 0.5 !default;

// Values chosen to approximate https://material.io/icons/#ic_navigate_before and
// https://material.io/icons/#ic_navigate_next as closely as possible.
$calendar-prev-next-icon-border-width: 2px;
$calendar-prev-next-icon-margin: 15.5px;
$calendar-prev-icon-transform: translateX(2px) rotate(-45deg);
$calendar-next-icon-transform: translateX(-2px) rotate(45deg);
$_tokens: tokens-mat-datepicker.$prefix, tokens-mat-datepicker.get-token-slots();

.mat-calendar {
Expand Down Expand Up @@ -94,38 +87,18 @@ $_tokens: tokens-mat-datepicker.$prefix, tokens-mat-datepicker.get-token-slots()

.mat-calendar-previous-button,
.mat-calendar-next-button {
position: relative;

@include token-utils.use-tokens($_tokens...) {
// Needs need a bit more specificity to avoid being overwritten by the .mat-icon-button.
.mat-datepicker-content &:not(.mat-mdc-button-disabled) {
@include token-utils.create-token-slot(color, calendar-navigation-button-icon-color);
}
}

&::after {
@include layout-common.fill;
content: '';
margin: $calendar-prev-next-icon-margin;
border: 0 solid currentColor;
border-top-width: $calendar-prev-next-icon-border-width;
}

[dir='rtl'] & {
transform: rotate(180deg);
}
}

.mat-calendar-previous-button::after {
border-left-width: $calendar-prev-next-icon-border-width;
transform: $calendar-prev-icon-transform;
}

.mat-calendar-next-button::after {
border-right-width: $calendar-prev-next-icon-border-width;
transform: $calendar-next-icon-transform;
}

.mat-calendar-table {
border-spacing: 0;
border-collapse: collapse;
Expand Down
Loading