-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(material-experimental/theming): add M3 tooltip support (#27810)
- Loading branch information
Showing
5 changed files
with
67 additions
and
24 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,87 @@ | ||
@use 'sass:map'; | ||
@use '@material/tooltip/plain-tooltip-theme' as mdc-plain-tooltip-theme; | ||
@use '../core/style/sass-utils'; | ||
@use '../core/theming/theming'; | ||
@use '../core/theming/inspection'; | ||
@use '../core/typography/typography'; | ||
@use '../core/tokens/m2/mdc/plain-tooltip' as m2-mdc-plain-tooltip; | ||
@use '../core/tokens/m2/mdc/plain-tooltip' as tokens-mdc-plain-tooltip; | ||
|
||
@mixin base($theme) { | ||
// Add default values for tokens not related to color, typography, or density. | ||
@include sass-utils.current-selector-or-root() { | ||
@include mdc-plain-tooltip-theme.theme(m2-mdc-plain-tooltip.get-unthemable-tokens()); | ||
@if inspection.get-theme-version($theme) == 1 { | ||
@include _theme-from-tokens(inspection.get-theme-tokens($theme, base)); | ||
} | ||
@else { | ||
// Add default values for tokens not related to color, typography, or density. | ||
@include sass-utils.current-selector-or-root() { | ||
@include mdc-plain-tooltip-theme.theme(tokens-mdc-plain-tooltip.get-unthemable-tokens()); | ||
} | ||
} | ||
} | ||
|
||
@mixin color($theme) { | ||
$mdc-tooltip-color-tokens: m2-mdc-plain-tooltip.get-color-tokens($theme); | ||
@if inspection.get-theme-version($theme) == 1 { | ||
@include _theme-from-tokens(inspection.get-theme-tokens($theme, color)); | ||
} | ||
@else { | ||
$mdc-tooltip-color-tokens: tokens-mdc-plain-tooltip.get-color-tokens($theme); | ||
|
||
// Add values for MDC tooltip tokens. | ||
@include sass-utils.current-selector-or-root() { | ||
@include mdc-plain-tooltip-theme.theme($mdc-tooltip-color-tokens); | ||
// Add values for MDC tooltip tokens. | ||
@include sass-utils.current-selector-or-root() { | ||
@include mdc-plain-tooltip-theme.theme($mdc-tooltip-color-tokens); | ||
} | ||
} | ||
} | ||
|
||
@mixin typography($theme) { | ||
$mdc-tooltip-typography-tokens: m2-mdc-plain-tooltip.get-typography-tokens($theme); | ||
@if inspection.get-theme-version($theme) == 1 { | ||
@include _theme-from-tokens(inspection.get-theme-tokens($theme, typography)); | ||
} | ||
@else { | ||
$mdc-tooltip-typography-tokens: tokens-mdc-plain-tooltip.get-typography-tokens($theme); | ||
|
||
// Add values for MDC tooltip tokens. | ||
@include sass-utils.current-selector-or-root() { | ||
@include mdc-plain-tooltip-theme.theme($mdc-tooltip-typography-tokens); | ||
// Add values for MDC tooltip tokens. | ||
@include sass-utils.current-selector-or-root() { | ||
@include mdc-plain-tooltip-theme.theme($mdc-tooltip-typography-tokens); | ||
} | ||
} | ||
} | ||
|
||
@mixin density($theme) { | ||
$mdc-tooltip-density-tokens: m2-mdc-plain-tooltip.get-density-tokens($theme); | ||
@if inspection.get-theme-version($theme) == 1 { | ||
@include _theme-from-tokens(inspection.get-theme-tokens($theme, density)); | ||
} | ||
@else { | ||
$mdc-tooltip-density-tokens: tokens-mdc-plain-tooltip.get-density-tokens($theme); | ||
|
||
// Add values for MDC tooltip tokens. | ||
@include sass-utils.current-selector-or-root() { | ||
@include mdc-plain-tooltip-theme.theme($mdc-tooltip-density-tokens); | ||
// Add values for MDC tooltip tokens. | ||
@include sass-utils.current-selector-or-root() { | ||
@include mdc-plain-tooltip-theme.theme($mdc-tooltip-density-tokens); | ||
} | ||
} | ||
} | ||
|
||
@mixin theme($theme) { | ||
@include theming.private-check-duplicate-theme-styles($theme, 'mat-tooltip') { | ||
@include base($theme); | ||
@if inspection.theme-has($theme, color) { | ||
@include color($theme); | ||
} | ||
@if inspection.theme-has($theme, density) { | ||
@include density($theme); | ||
@if inspection.get-theme-version($theme) == 1 { | ||
@include _theme-from-tokens(inspection.get-theme-tokens($theme)); | ||
} | ||
@if inspection.theme-has($theme, typography) { | ||
@include typography($theme); | ||
@else { | ||
@include base($theme); | ||
@if inspection.theme-has($theme, color) { | ||
@include color($theme); | ||
} | ||
@if inspection.theme-has($theme, density) { | ||
@include density($theme); | ||
} | ||
@if inspection.theme-has($theme, typography) { | ||
@include typography($theme); | ||
} | ||
} | ||
} | ||
} | ||
|
||
@mixin _theme-from-tokens($tokens) { | ||
@if $tokens != () { | ||
@include mdc-plain-tooltip-theme.theme(map.get($tokens, tokens-mdc-plain-tooltip.$prefix)); | ||
} | ||
} |