-
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
feat(datepicker): allow for mat-datepicker-toggle icon to be customized #9487
Conversation
src/lib/datepicker/datepicker.md
Outdated
<img matDatepickerToggleIcon src="my-custom-icon.png"> | ||
</mat-datepicker-toggle> | ||
<mat-datepicker #myDatepicker></mat-datepicker> | ||
``` |
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.
can you turn this into an embedded example?
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.
Done.
@Directive({ | ||
selector: '[matDatepickerToggleIcon]' | ||
}) | ||
export class MatDatepickerToggleIcon {} |
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
Allows for the consumer to set a different icon for the `mat-datepicker-icon` via the `matDatepickerToggleIcon` directive. The reasoning for the change is that not all consumers might be using the Material icons or they may want to set something different (e.g. a chevron).
f18185b
to
bff5e19
Compare
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Allows for the consumer to set a different icon for the
mat-datepicker-icon
via thematDatepickerToggleIcon
directive. The reasoning for the change is that not all consumers might be using the Material icons or they may want to set something different (e.g. a chevron).