-
Notifications
You must be signed in to change notification settings - Fork 6.8k
feat(material/button): allow appearance to be set dynamically #30626
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
Conversation
a8f588e
to
c6cb080
Compare
Adds the following features to the button: * Allows the appearance of a button to be set dynamically using the `matButton` input. * Aligns the terminology with the M3 spec. Currently the names are derived from an old spec. * Adds the ability to set the default appearance for buttons. * Adds a `matIconButton` selector to the icon button for consistency. * Adds a `matFab` selector to the FAB for consistency. * Adds a `matMiniFab` selector to the mini FAB for consistency. All of these changes are backwards-compatible and allow us to evolve the button in the future. Fixes angular#15367. Fixes angular#29841.
bacfd17
to
cea2075
Compare
Updates the button harness to align with the terminology for button appearances. BREAKING CHANGE: * `ButtonVariant` which is returned by `MatButtonHarness.getVariant` no longer includes the appearance of the button. Use `MatButtonHarness.getAppearance` instead.
Reworks the various places where we have buttons to use the new selectors.
cea2075
to
2347d69
Compare
const inferredAppearance = _inferAppearance(element); | ||
|
||
// This class is common across all the appearances so we add it ahead of time. | ||
element.classList.add('mdc-button'); |
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.
would be easier to just make this a host binding?
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.
I was trying to match the behavior of what we do at the moment. Moving it into a host binding can change the order in which the class is applied which can break internal clients and I was trying to minimize the amount of breakages. I can try moving it in a follow-up. We'll have to shuffle around the host
object a bit anyways if we want to get type checking support for it.
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.
Ah okay that makes sense
Following up on angular#30626 (comment), these changes move the button's shared host bindings into the base class and turn some classes that are added manually into host bindings. The previous approach was only necessary with ViewEngine, because it wasn't doing inheritance of host bindings correctly and wasn't merging classes. These are no longer issues in Ivy.
Following up on angular#30626 (comment), these changes move the button's shared host bindings into the base class and turn some classes that are added manually into host bindings. The previous approach was only necessary with ViewEngine, because it wasn't doing inheritance of host bindings correctly and wasn't merging classes. These are no longer issues in Ivy. Finally, these changes allow us to take advantage of an upcoming framework feature: angular/angular#60267
Following up on angular#30626 (comment), these changes move the button's shared host bindings into the base class and turn some classes that are added manually into host bindings. The previous approach was only necessary with ViewEngine, because it wasn't doing inheritance of host bindings correctly and wasn't merging classes. These are no longer issues in Ivy. Finally, these changes allow us to take advantage of an upcoming framework feature: angular/angular#60267
Following up on #30626 (comment), these changes move the button's shared host bindings into the base class and turn some classes that are added manually into host bindings. The previous approach was only necessary with ViewEngine, because it wasn't doing inheritance of host bindings correctly and wasn't merging classes. These are no longer issues in Ivy. Finally, these changes allow us to take advantage of an upcoming framework feature: angular/angular#60267
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. |
Adds the following features to the button:
matButton
input.matIconButton
selector to the icon button for consistency.matFab
selector to the FAB for consistency.matMiniFab
selector to the mini FAB for consistency.All of these changes are backwards-compatible and allow us to evolve the button in the future.
BREAKING CHANGE:
ButtonVariant
which is returned byMatButtonHarness.getVariant
no longer includes the appearance of the button. UseMatButtonHarness.getAppearance
instead.Fixes #15367.
Fixes #29841.