forked from angular/components
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(material/form-field): replicate tooltipClass to default MatToolt…
…ipDefaultOptions The `tooltipClass` property has been added to the default configuration options in `MatTooltipDefaultOptions`. This new property is optional and supports the same syntax as `ngClass`, just like the component's default attribute. As with some existing configurations, if a CSS class is defined directly on the tooltip component, it will automatically override the default class. An example has been added to the `tooltip-demo` file. Additionally, two tests have been created to ensure the solution works as expected. Fixes angular#29355
- Loading branch information
Showing
8 changed files
with
136 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
3 changes: 3 additions & 0 deletions
3
...es/material/tooltip/tooltip-default-custom-class/tooltip-default-custom-class-example.css
This file contains 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,3 @@ | ||
.example-tooltip-default-custom-class { | ||
text-transform: uppercase; | ||
} |
5 changes: 5 additions & 0 deletions
5
...s/material/tooltip/tooltip-default-custom-class/tooltip-default-custom-class-example.html
This file contains 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,5 @@ | ||
<button mat-raised-button | ||
matTooltip="This tooltip uses the global custom class" | ||
aria-label="Button that displays a tooltip with a globally applied custom class"> | ||
Button with custom tooltip class | ||
</button> |
30 changes: 30 additions & 0 deletions
30
...les/material/tooltip/tooltip-default-custom-class/tooltip-default-custom-class-example.ts
This file contains 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,30 @@ | ||
import {Component, ViewEncapsulation} from '@angular/core'; | ||
import { | ||
MAT_TOOLTIP_DEFAULT_OPTIONS, | ||
MAT_TOOLTIP_DEFAULT_OPTIONS_FACTORY, | ||
MatTooltipDefaultOptions, | ||
MatTooltipModule, | ||
} from '@angular/material/tooltip'; | ||
import {MatButtonModule} from '@angular/material/button'; | ||
|
||
/** Custom options the configure the tooltip's default class. */ | ||
export const myCustomTooltipDefaults: MatTooltipDefaultOptions = { | ||
...MAT_TOOLTIP_DEFAULT_OPTIONS_FACTORY(), | ||
tooltipClass: 'example-tooltip-default-custom-class', | ||
}; | ||
|
||
/** | ||
* @title Tooltip with default custom class | ||
*/ | ||
@Component({ | ||
selector: 'tooltip-default-custom-class-example', | ||
templateUrl: 'tooltip-default-custom-class-example.html', | ||
styleUrl: 'tooltip-default-custom-class-example.css', | ||
providers: [{provide: MAT_TOOLTIP_DEFAULT_OPTIONS, useValue: myCustomTooltipDefaults}], | ||
standalone: true, | ||
// Need to remove view encapsulation so that the custom tooltip style defined in | ||
// `tooltip-default-custom-class-example.css` will not be scoped to this component's view. | ||
encapsulation: ViewEncapsulation.None, | ||
imports: [MatButtonModule, MatTooltipModule], | ||
}) | ||
export class TooltipDefaultCustomClassExample {} |
This file contains 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 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 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 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