-
Notifications
You must be signed in to change notification settings - Fork 6.8k
feat(datepicker): allow for mat-datepicker-toggle icon to be customized #9487
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
Merged
jelbourn
merged 1 commit into
angular:master
from
crisbeto:datepicker-toggle-custom-icon
Jan 24, 2018
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
<button mat-icon-button type="button" [attr.aria-label]="_intl.openCalendarLabel" | ||
[disabled]="disabled" (click)="_open($event)"> | ||
<mat-icon> | ||
<mat-icon *ngIf="!_customIcon"> | ||
<svg viewBox="0 0 24 24" width="100%" height="100%" fill="currentColor" | ||
style="vertical-align: top" focusable="false"> | ||
<path d="M0 0h24v24H0z" fill="none"/> | ||
<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"/> | ||
</svg> | ||
</mat-icon> | ||
|
||
<ng-content select="[matDatepickerToggleIcon]"></ng-content> | ||
</button> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/material-examples/datepicker-custom-icon/datepicker-custom-icon-example.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/** No CSS for this example */ |
7 changes: 7 additions & 0 deletions
7
src/material-examples/datepicker-custom-icon/datepicker-custom-icon-example.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<mat-form-field class="example-full-width"> | ||
<input matInput [matDatepicker]="picker" placeholder="Choose a date"> | ||
<mat-datepicker-toggle matSuffix [for]="picker"> | ||
<mat-icon matDatepickerToggleIcon>keyboard_arrow_down</mat-icon> | ||
</mat-datepicker-toggle> | ||
<mat-datepicker #picker></mat-datepicker> | ||
</mat-form-field> |
9 changes: 9 additions & 0 deletions
9
src/material-examples/datepicker-custom-icon/datepicker-custom-icon-example.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import {Component} from '@angular/core'; | ||
|
||
/** @title Datepicker with custom icon */ | ||
@Component({ | ||
selector: 'datepicker-custom-icon-example', | ||
templateUrl: 'datepicker-custom-icon-example.html', | ||
styleUrls: ['datepicker-custom-icon-example.css'], | ||
}) | ||
export class DatepickerCustomIconExample {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need a special directive? what if we just treat any projected content as a custom icon?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could, but it gets a little dirtier when you try to figure out whether to hide the default icon. We'd have to loop through all the
children
of the content element and count the amount of element nodes (skipping comments, text nodes etc.) on every change detection.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, I thought there was an easier way to check if any content was projected, but it looks like you're right