diff --git a/src/material/button/_fab-theme.scss b/src/material/button/_fab-theme.scss index b956192d6e5e..49caf90fa4f1 100644 --- a/src/material/button/_fab-theme.scss +++ b/src/material/button/_fab-theme.scss @@ -1,6 +1,3 @@ -@use '@material/fab/fab-theme' as mdc-fab-theme; -@use '@material/fab/fab-small-theme' as mdc-fab-small-theme; -@use '@material/fab/extended-fab-theme' as mdc-extended-fab-theme; @use '../core/style/sass-utils'; @use '../core/theming/theming'; @use '../core/theming/inspection'; @@ -21,13 +18,13 @@ @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-fab-theme.theme(tokens-mdc-fab.get-unthemable-tokens()); - @include mdc-fab-small-theme.theme(tokens-mdc-fab-small.get-unthemable-tokens()); - @include mdc-extended-fab-theme.theme( - tokens-mdc-extended-fab.get-unthemable-tokens() - ); + @include token-utils.create-token-values( + tokens-mdc-fab.$prefix, tokens-mdc-fab.get-unthemable-tokens()); + @include token-utils.create-token-values( + tokens-mdc-fab-small.$prefix, tokens-mdc-fab-small.get-unthemable-tokens()); + @include token-utils.create-token-values( + tokens-mdc-extended-fab.$prefix, tokens-mdc-extended-fab.get-unthemable-tokens()); } } } @@ -43,7 +40,7 @@ tokens-mat-fab.get-color-tokens($theme) ); - @include mdc-fab-theme.theme($mdc-tokens); + @include token-utils.create-token-values(tokens-mdc-fab.$prefix, $mdc-tokens); @include token-utils.create-token-values(tokens-mat-fab.$prefix, $mat-tokens); } @@ -58,7 +55,7 @@ tokens-mat-fab-small.get-color-tokens($theme) ); - @include mdc-fab-small-theme.theme($mdc-tokens); + @include token-utils.create-token-values(tokens-mdc-fab-small.$prefix, $mdc-tokens); @include token-utils.create-token-values(tokens-mat-fab-small.$prefix, $mat-tokens); } @@ -75,7 +72,8 @@ @include sass-utils.current-selector-or-root() { @include _fab-variant($theme, null); @include _fab-small-variant($theme, null); - @include mdc-extended-fab-theme.theme(tokens-mdc-extended-fab.get-color-tokens($theme)); + @include token-utils.create-token-values( + tokens-mdc-extended-fab.$prefix, tokens-mdc-extended-fab.get-color-tokens($theme)); .mat-mdc-fab { &.mat-primary { @@ -116,7 +114,8 @@ } @else { @include sass-utils.current-selector-or-root() { - @include mdc-extended-fab-theme.theme(tokens-mdc-extended-fab.get-typography-tokens($theme)); + @include token-utils.create-token-values(tokens-mdc-extended-fab.$prefix, + tokens-mdc-extended-fab.get-typography-tokens($theme)); @include token-utils.create-token-values(tokens-mat-fab.$prefix, tokens-mat-fab.get-typography-tokens($theme)); @include token-utils.create-token-values(tokens-mat-fab-small.$prefix, @@ -190,9 +189,10 @@ $mat-fab-tokens: token-utils.get-tokens-for($tokens, tokens-mat-fab.$prefix, $options...); $mat-fab-small-tokens: token-utils.get-tokens-for($tokens, tokens-mat-fab-small.$prefix, $options...); - @include mdc-extended-fab-theme.theme($mdc-extended-fab-tokens); - @include mdc-fab-theme.theme($mdc-fab-tokens); - @include mdc-fab-small-theme.theme($mdc-fab-small-tokens); + @include token-utils.create-token-values(tokens-mdc-extended-fab.$prefix, + $mdc-extended-fab-tokens); + @include token-utils.create-token-values(tokens-mdc-fab.$prefix, $mdc-fab-tokens); + @include token-utils.create-token-values(tokens-mdc-fab-small.$prefix, $mdc-fab-small-tokens); @include token-utils.create-token-values(tokens-mat-fab.$prefix, $mat-fab-tokens); @include token-utils.create-token-values(tokens-mat-fab-small.$prefix, $mat-fab-small-tokens); } diff --git a/src/material/button/button-base.ts b/src/material/button/button-base.ts index 0f2d3c18b24e..c198de65c612 100644 --- a/src/material/button/button-base.ts +++ b/src/material/button/button-base.ts @@ -72,11 +72,11 @@ const HOST_SELECTOR_MDC_CLASS_PAIR: {attribute: string; mdcClasses: string[]}[] }, { attribute: 'mat-fab', - mdcClasses: ['mdc-fab', 'mat-mdc-fab'], + mdcClasses: ['mdc-fab', 'mat-mdc-fab-base', 'mat-mdc-fab'], }, { attribute: 'mat-mini-fab', - mdcClasses: ['mdc-fab', 'mdc-fab--mini', 'mat-mdc-mini-fab'], + mdcClasses: ['mdc-fab', 'mat-mdc-fab-base', 'mdc-fab--mini', 'mat-mdc-mini-fab'], }, { attribute: 'mat-icon-button', diff --git a/src/material/button/fab.scss b/src/material/button/fab.scss index 72be9b413237..5dbf2b283c35 100644 --- a/src/material/button/fab.scss +++ b/src/material/button/fab.scss @@ -1,15 +1,7 @@ -@use 'sass:map'; -@use '@material/fab' as mdc-fab; -@use '@material/fab/extended-fab-theme' as mdc-extended-fab-theme; -@use '@material/fab/fab-theme' as mdc-fab-theme; -@use '@material/fab/fab-small-theme' as mdc-fab-small-theme; -@use '@material/typography/typography' as mdc-typography; -@use '@material/theme/custom-properties' as mdc-custom-properties; - @use './button-base'; -@use '../core/mdc-helpers/mdc-helpers'; @use '../core/tokens/token-utils'; @use '../core/style/private' as style-private; +@use '../core/style/vendor-prefixes'; @use '../core/focus-indicators/private' as focus-indicators-private; @use '../core/tokens/m2/mdc/extended-fab' as tokens-mdc-extended-fab; @use '../core/tokens/m2/mdc/fab' as tokens-mdc-fab; @@ -17,52 +9,62 @@ @use '../core/tokens/m2/mdc/fab-small' as tokens-mdc-fab-small; @use '../core/tokens/m2/mat/fab-small' as tokens-mat-fab-small; -@include mdc-custom-properties.configure($emit-fallback-values: false, $emit-fallback-vars: false) { - $mdc-fab-token-slots: tokens-mdc-fab.get-token-slots(); - $mdc-fab-small-token-slots: tokens-mdc-fab-small.get-token-slots(); - $mdc-extended-fab-token-slots: tokens-mdc-extended-fab.get-token-slots(); - $exclude-tokens: ( - // Exclude the elevation tokens here since we output them manually below. - container-elevation: null, - focus-container-elevation: null, - hover-container-elevation: null, - pressed-container-elevation: null, - container-shadow-color: null, - ); +.mat-mdc-fab-base { + @include button-base.mat-private-button-interactive(); + @include style-private.private-animation-noop(); + @include vendor-prefixes.user-select(none); + position: relative; + display: inline-flex; + align-items: center; + justify-content: center; + box-sizing: border-box; + width: 56px; + height: 56px; + padding: 0; + border: none; + fill: currentColor; + text-decoration: none; + cursor: pointer; + -moz-appearance: none; + -webkit-appearance: none; + overflow: visible; + transition: box-shadow 280ms cubic-bezier(0.4, 0, 0.2, 1), opacity 15ms linear 30ms, + transform 270ms 0ms cubic-bezier(0, 0, 0.2, 1); + flex-shrink: 0; // Prevent the button from shrinking since it's always supposed to be a circle. - // Note: it's important to pass the query here, otherwise MDC generates - // some unnecessary typography styles for the extended FAB. - @include mdc-fab.static-styles($query: mdc-helpers.$mdc-base-styles-query); + &::before { + position: absolute; + box-sizing: border-box; + width: 100%; + height: 100%; + top: 0; + left: 0; + border: 1px solid transparent; + border-radius: inherit; + content: ''; + pointer-events: none; + } - .mat-mdc-fab { - @include mdc-fab-theme.theme-styles(map.merge($mdc-fab-token-slots, $exclude-tokens)); + // MDC used to include this and it seems like a lot of apps depend on it. + &[hidden] { + display: none; } - .mat-mdc-mini-fab { - @include mdc-fab-small-theme.theme-styles( - map.merge($mdc-fab-small-token-slots, $exclude-tokens)); + &::-moz-focus-inner { + padding: 0; + border: 0; } - .mat-mdc-extended-fab { - // Before tokens MDC included the font smoothing automatically, but with - // tokens it doesn't. We add it since it can cause tiny differences in - // screenshot tests and it generally looks better. - @include mdc-typography.smooth-font(); - @include mdc-extended-fab-theme.theme-styles( - map.merge($mdc-extended-fab-token-slots, $exclude-tokens)); + &:active, &:focus { + outline: none; } -} -.mat-mdc-fab, .mat-mdc-mini-fab { - @include button-base.mat-private-button-interactive(); - @include style-private.private-animation-noop(); - flex-shrink: 0; // Prevent the button from shrinking since it's always supposed to be a circle. + &:hover { + cursor: pointer; + } - // MDC adds some styles to fab and mini-fab that conflict with some of our focus indicator - // styles and don't actually do anything. This undoes those conflicting styles. - &:not(.mdc-ripple-upgraded):focus::before { - background: transparent; - opacity: 1; + & > svg { + width: 100%; } // MDC expects the fab icon to contain this HTML content: @@ -73,7 +75,9 @@ // mixin will style the icons appropriately. // stylelint-disable-next-line selector-class-pattern .mat-icon, .material-icons { - @include mdc-fab.icon_(); + transition: transform 180ms 90ms cubic-bezier(0, 0, 0.2, 1); + fill: currentColor; + will-change: transform; } .mat-mdc-focus-indicator::before { @@ -93,18 +97,18 @@ @mixin _fab-elevation($mdc-tokens) { @include token-utils.use-tokens($mdc-tokens...) { - @include button-base.mat-private-button-elevation(container-elevation); + @include token-utils.create-token-slot(box-shadow, container-elevation-shadow); &:hover { - @include button-base.mat-private-button-elevation(hover-container-elevation); + @include token-utils.create-token-slot(box-shadow, hover-container-elevation-shadow); } &:focus { - @include button-base.mat-private-button-elevation(focus-container-elevation); + @include token-utils.create-token-slot(box-shadow, focus-container-elevation-shadow); } &:active, &:focus:active { - @include button-base.mat-private-button-elevation(pressed-container-elevation); + @include token-utils.create-token-slot(box-shadow, pressed-container-elevation-shadow); } } } @@ -113,10 +117,13 @@ @include button-base.mat-private-button-touch-target(true, $mat-tokens...); @include button-base.mat-private-button-ripple($mat-tokens...); - @include mdc-helpers.disable-mdc-fallback-declarations { - @include token-utils.use-tokens($mat-tokens...) { - @include token-utils.create-token-slot(color, foreground-color, inherit); - } + @include token-utils.use-tokens($mdc-tokens...) { + @include token-utils.create-token-slot(background-color, container-color); + @include token-utils.create-token-slot(border-radius, container-shape); + } + + @include token-utils.use-tokens($mat-tokens...) { + @include token-utils.create-token-slot(color, foreground-color, inherit); } @include _fab-elevation($mdc-tokens); @@ -137,6 +144,9 @@ } .mat-mdc-mini-fab { + width: 40px; + height: 40px; + @include _fab-structure( (tokens-mdc-fab-small.$prefix, tokens-mdc-fab-small.get-token-slots()), (tokens-mat-fab-small.$prefix, tokens-mat-fab-small.get-token-slots()), @@ -144,8 +154,20 @@ } .mat-mdc-extended-fab { - @include _fab-elevation((tokens-mdc-extended-fab.$prefix, - tokens-mdc-extended-fab.get-token-slots())); + $mdc-tokens: (tokens-mdc-extended-fab.$prefix, tokens-mdc-extended-fab.get-token-slots()); + + // Before tokens MDC included the font smoothing automatically, but with + // tokens it doesn't. We add it since it can cause tiny differences in + // screenshot tests and it generally looks better. + @include vendor-prefixes.smooth-font(); + border-radius: 24px; + padding-left: 20px; + padding-right: 20px; + width: auto; + max-width: 100%; + line-height: normal; + + @include _fab-elevation($mdc-tokens); @include button-base.mat-private-button-disabled { // Necessary for interactive disabled buttons. @@ -154,30 +176,40 @@ } } - & > .mat-icon, - & > .material-icons { // stylelint-disable-line selector-class-pattern - @include mdc-fab.extended-icon-padding( - mdc-fab.$extended-icon-padding, - mdc-fab.$extended-label-padding - ); + @include token-utils.use-tokens($mdc-tokens...) { + @include token-utils.create-token-slot(height, container-height); + @include token-utils.create-token-slot(border-radius, container-shape); + @include token-utils.create-token-slot(font-family, label-text-font); + @include token-utils.create-token-slot(font-size, label-text-size); + @include token-utils.create-token-slot(font-weight, label-text-weight); + @include token-utils.create-token-slot(letter-spacing, label-text-tracking); + } + + // stylelint-disable selector-class-pattern + // For Extended FAB with text label followed by icon. + // We are checking for the a button class because white this is a FAB it + // uses the same template as button. + [dir='rtl'] & .mdc-button__label + .mat-icon, + [dir='rtl'] & .mdc-button__label + .material-icons, + > .mat-icon, + > .material-icons { + margin-left: -8px; + margin-right: 12px; } + .mdc-button__label + .mat-icon, + .mdc-button__label + .material-icons, + [dir='rtl'] & > .mat-icon, + [dir='rtl'] & > .material-icons { + margin-left: 12px; + margin-right: -8px; + } + // stylelint-enable selector-class-pattern + // All FABs are square except the extended ones so we // need to set the touch target back to full-width. .mat-mdc-button-touch-target { width: 100%; } - - // For Extended FAB with text label followed by icon. - // We are checking for the a button class because white this is a FAB it - // uses the same template as button. - // stylelint-disable-next-line selector-class-pattern - .mdc-button__label + .mat-icon, .mdc-button__label + .material-icons { - @include mdc-fab.extended-icon-padding( - mdc-fab.$extended-icon-padding, - mdc-fab.$extended-label-padding, - $is-icon-at-end: true - ); - } } diff --git a/src/material/core/tokens/m2/mdc/_extended-fab.scss b/src/material/core/tokens/m2/mdc/_extended-fab.scss index aabc50b99e12..d4f5bcb9b938 100644 --- a/src/material/core/tokens/m2/mdc/_extended-fab.scss +++ b/src/material/core/tokens/m2/mdc/_extended-fab.scss @@ -1,3 +1,4 @@ +@use '@material/elevation/elevation-theme' as mdc-elevation; @use '../../token-utils'; @use '../../../theming/inspection'; @@ -38,18 +39,22 @@ $prefix: (mdc, extended-fab); pressed-ripple-color: null, pressed-ripple-opacity: null, pressed-state-layer-color: null, - pressed-state-layer-opacity: null + pressed-state-layer-opacity: null, + container-elevation: null, + focus-container-elevation: null, + hover-container-elevation: null, + pressed-container-elevation: null, + container-shadow-color: null, ); } // Tokens that can be configured through Angular Material's color theming API. @function get-color-tokens($theme) { @return ( - container-elevation: 6, - focus-container-elevation: 8, - hover-container-elevation: 8, - pressed-container-elevation: 12, - container-shadow-color: #000, + container-elevation-shadow: mdc-elevation.elevation-box-shadow(6), + focus-container-elevation-shadow: mdc-elevation.elevation-box-shadow(8), + hover-container-elevation-shadow: mdc-elevation.elevation-box-shadow(8), + pressed-container-elevation-shadow: mdc-elevation.elevation-box-shadow(12), ); } diff --git a/src/material/core/tokens/m2/mdc/_fab-small.scss b/src/material/core/tokens/m2/mdc/_fab-small.scss index fa0471a84481..b703adf98a4c 100644 --- a/src/material/core/tokens/m2/mdc/_fab-small.scss +++ b/src/material/core/tokens/m2/mdc/_fab-small.scss @@ -1,3 +1,4 @@ +@use '@material/elevation/elevation-theme' as mdc-elevation; @use '../../../theming/inspection'; @use '../../token-utils'; @@ -9,17 +10,14 @@ $prefix: (mdc, fab-small); @function get-unthemable-tokens() { @return ( container-shape: 50%, - icon-size: 24px, - - // We don't use this token, because it doesn't set the color of any text inside the FAB. - // We create a custom token for it instead. - icon-color: null, // ============================================================================================= // = TOKENS NOT USED IN ANGULAR MATERIAL = // ============================================================================================= container-height: null, container-width: null, + icon-size: null, + icon-color: null, focus-icon-color: null, focus-outline-color: null, @@ -40,7 +38,13 @@ $prefix: (mdc, fab-small); pressed-ripple-color: null, pressed-ripple-opacity: null, pressed-state-layer-color: null, - pressed-state-layer-opacity: null + pressed-state-layer-opacity: null, + + container-elevation: null, + focus-container-elevation: null, + hover-container-elevation: null, + pressed-container-elevation: null, + container-shadow-color: null, ); } @@ -49,11 +53,10 @@ $prefix: (mdc, fab-small); @return ( // Background color of the FAB. container-color: inspection.get-theme-color($theme, background, card), - container-elevation: 6, - focus-container-elevation: 8, - hover-container-elevation: 8, - pressed-container-elevation: 12, - container-shadow-color: #000, + container-elevation-shadow: mdc-elevation.elevation-box-shadow(6), + focus-container-elevation-shadow: mdc-elevation.elevation-box-shadow(8), + hover-container-elevation-shadow: mdc-elevation.elevation-box-shadow(8), + pressed-container-elevation-shadow: mdc-elevation.elevation-box-shadow(12), ); } diff --git a/src/material/core/tokens/m2/mdc/_fab.scss b/src/material/core/tokens/m2/mdc/_fab.scss index b1253b4d1a7c..e16027f43142 100644 --- a/src/material/core/tokens/m2/mdc/_fab.scss +++ b/src/material/core/tokens/m2/mdc/_fab.scss @@ -1,3 +1,4 @@ +@use '@material/elevation/elevation-theme' as mdc-elevation; @use '../../../theming/inspection'; @use '../../token-utils'; @@ -9,11 +10,6 @@ $prefix: (mdc, fab); @function get-unthemable-tokens() { @return ( container-shape: 50%, - icon-size: 24px, - - // We don't use this token, because it doesn't set the color of any text inside the FAB. - // We create a custom token for it instead. - icon-color: null, // ============================================================================================= // = TOKENS NOT USED IN ANGULAR MATERIAL = @@ -21,6 +17,8 @@ $prefix: (mdc, fab); container-height: null, container-surface-tint-layer-color: null, container-width: null, + icon-size: null, + icon-color: null, focus-icon-color: null, focus-outline-color: null, @@ -41,7 +39,13 @@ $prefix: (mdc, fab); pressed-ripple-color: null, pressed-ripple-opacity: null, pressed-state-layer-color: null, - pressed-state-layer-opacity: null + pressed-state-layer-opacity: null, + + container-elevation: null, + focus-container-elevation: null, + hover-container-elevation: null, + pressed-container-elevation: null, + container-shadow-color: null, ); } @@ -50,11 +54,10 @@ $prefix: (mdc, fab); @return ( // Background color of the FAB. container-color: inspection.get-theme-color($theme, background, card), - container-elevation: 6, - focus-container-elevation: 8, - hover-container-elevation: 8, - pressed-container-elevation: 12, - container-shadow-color: #000, + container-elevation-shadow: mdc-elevation.elevation-box-shadow(6), + focus-container-elevation-shadow: mdc-elevation.elevation-box-shadow(8), + hover-container-elevation-shadow: mdc-elevation.elevation-box-shadow(8), + pressed-container-elevation-shadow: mdc-elevation.elevation-box-shadow(12), ); } diff --git a/src/material/core/tokens/m3/mdc/_extended-fab.scss b/src/material/core/tokens/m3/mdc/_extended-fab.scss index 5d3724c2b1b3..bfc50e5964a6 100644 --- a/src/material/core/tokens/m3/mdc/_extended-fab.scss +++ b/src/material/core/tokens/m3/mdc/_extended-fab.scss @@ -1,3 +1,5 @@ +@use 'sass:map'; +@use '@material/elevation/elevation-theme' as mdc-elevation; @use '../../token-utils'; // The prefix used to generate the fully qualified name for tokens in this file. @@ -9,7 +11,22 @@ $prefix: (mdc, extended-fab); /// @param {Map} $token-slots Possible token slots /// @return {Map} A set of tokens for the MDC extended-fab @function get-tokens($systems, $exclude-hardcoded, $token-slots) { - $mdc-tokens: token-utils.get-mdc-tokens('extended-fab-primary', $systems, $exclude-hardcoded); + $tokens: token-utils.get-mdc-tokens('extended-fab-primary', $systems, $exclude-hardcoded); + $elevation-tokens: ( + container-elevation, + focus-container-elevation, + hover-container-elevation, + pressed-container-elevation, + ); + + @each $token in $elevation-tokens { + $elevation: map.get($tokens, $token); + + @if ($elevation != null) { + $tokens: map.set($tokens, $token + '-shadow', mdc-elevation.elevation-box-shadow($elevation)); + } + } + $variant-tokens: ( // Color variants primary: (), // Default, no overrides needed. @@ -17,5 +34,5 @@ $prefix: (mdc, extended-fab); tertiary: token-utils.get-mdc-tokens('extended-fab-tertiary', $systems, $exclude-hardcoded) ); - @return token-utils.namespace-tokens($prefix, ($mdc-tokens, $variant-tokens), $token-slots); + @return token-utils.namespace-tokens($prefix, ($tokens, $variant-tokens), $token-slots); } diff --git a/src/material/core/tokens/m3/mdc/_fab-small.scss b/src/material/core/tokens/m3/mdc/_fab-small.scss index 59906c17274f..2049f22d4551 100644 --- a/src/material/core/tokens/m3/mdc/_fab-small.scss +++ b/src/material/core/tokens/m3/mdc/_fab-small.scss @@ -1,3 +1,5 @@ +@use 'sass:map'; +@use '@material/elevation/elevation-theme' as mdc-elevation; @use '../../token-utils'; // The prefix used to generate the fully qualified name for tokens in this file. @@ -9,7 +11,22 @@ $prefix: (mdc, fab-small); /// @param {Map} $token-slots Possible token slots /// @return {Map} A set of tokens for the MDC fab-small @function get-tokens($systems, $exclude-hardcoded, $token-slots) { - $mdc-tokens: token-utils.get-mdc-tokens('fab-primary-small', $systems, $exclude-hardcoded); + $tokens: token-utils.get-mdc-tokens('fab-primary-small', $systems, $exclude-hardcoded); + $elevation-tokens: ( + container-elevation, + focus-container-elevation, + hover-container-elevation, + pressed-container-elevation, + ); + + @each $token in $elevation-tokens { + $elevation: map.get($tokens, $token); + + @if ($elevation != null) { + $tokens: map.set($tokens, $token + '-shadow', mdc-elevation.elevation-box-shadow($elevation)); + } + } + $variant-tokens: ( // Color variants primary: (), // Default, no overrides needed. @@ -17,5 +34,5 @@ $prefix: (mdc, fab-small); tertiary: token-utils.get-mdc-tokens('fab-tertiary-small', $systems, $exclude-hardcoded) ); - @return token-utils.namespace-tokens($prefix, ($mdc-tokens, $variant-tokens), $token-slots); + @return token-utils.namespace-tokens($prefix, ($tokens, $variant-tokens), $token-slots); } diff --git a/src/material/core/tokens/m3/mdc/_fab.scss b/src/material/core/tokens/m3/mdc/_fab.scss index e39ff5b8a930..2695f6ce9207 100644 --- a/src/material/core/tokens/m3/mdc/_fab.scss +++ b/src/material/core/tokens/m3/mdc/_fab.scss @@ -1,3 +1,5 @@ +@use 'sass:map'; +@use '@material/elevation/elevation-theme' as mdc-elevation; @use '../../token-utils'; // The prefix used to generate the fully qualified name for tokens in this file. @@ -9,7 +11,22 @@ $prefix: (mdc, fab); /// @param {Map} $token-slots Possible token slots /// @return {Map} A set of tokens for the MDC fab @function get-tokens($systems, $exclude-hardcoded, $token-slots) { - $mdc-tokens: token-utils.get-mdc-tokens('fab-primary', $systems, $exclude-hardcoded); + $tokens: token-utils.get-mdc-tokens('fab-primary', $systems, $exclude-hardcoded); + $elevation-tokens: ( + container-elevation, + focus-container-elevation, + hover-container-elevation, + pressed-container-elevation, + ); + + @each $token in $elevation-tokens { + $elevation: map.get($tokens, $token); + + @if ($elevation != null) { + $tokens: map.set($tokens, $token + '-shadow', mdc-elevation.elevation-box-shadow($elevation)); + } + } + $variant-tokens: ( // Color variants primary: (), // Default, no overrides needed. @@ -17,5 +34,5 @@ $prefix: (mdc, fab); tertiary: token-utils.get-mdc-tokens('fab-tertiary', $systems, $exclude-hardcoded) ); - @return token-utils.namespace-tokens($prefix, ($mdc-tokens, $variant-tokens), $token-slots); + @return token-utils.namespace-tokens($prefix, ($tokens, $variant-tokens), $token-slots); } diff --git a/src/material/core/tokens/tests/test-validate-tokens.scss b/src/material/core/tokens/tests/test-validate-tokens.scss index 38bb3e4bd6aa..9af8a6fb23ec 100644 --- a/src/material/core/tokens/tests/test-validate-tokens.scss +++ b/src/material/core/tokens/tests/test-validate-tokens.scss @@ -9,8 +9,6 @@ @use '@material/card/outlined-card-theme' as mdc-outlined-card-theme; @use '@material/checkbox/checkbox-theme' as mdc-checkbox-theme; @use '@material/circular-progress/circular-progress-theme' as mdc-circular-progress-theme; -@use '@material/fab/extended-fab-theme' as mdc-extended-fab-theme; -@use '@material/fab/fab-theme' as mdc-fab-theme; @use '@material/linear-progress/linear-progress-theme' as mdc-linear-progress-theme; @use '@material/icon-button/icon-button-theme' as mdc-icon-button-theme; @use '@material/list/list-theme' as mdc-list-theme; @@ -35,8 +33,6 @@ @use '../m2/mdc/elevated-card' as tokens-mdc-elevated-card; @use '../m2/mdc/icon-button' as tokens-mdc-icon-button; @use '../m2/mdc/checkbox' as tokens-mdc-checkbox; -@use '../m2/mdc/extended-fab' as tokens-mdc-extended-fab; -@use '../m2/mdc/fab' as tokens-mdc-fab; @use '../m2/mdc/list' as tokens-mdc-list; @use '../m2/mdc/outlined-card' as tokens-mdc-outlined-card; @use '../m2/mdc/plain-tooltip' as tokens-mdc-plain-tooltip; @@ -137,17 +133,6 @@ $slots: tokens-mdc-dialog.get-token-slots(), $reference: mdc-dialog-theme.$light-theme ); -// Note: we should validate the `fab-small` here as well, but MDC doesn't expose its light theme. -@include validate-slots( - $component: 'm2.mdc.fab', - $slots: tokens-mdc-fab.get-token-slots(), - $reference: mdc-fab-theme.$light-theme -); -@include validate-slots( - $component: 'm2.mdc.extended-fab', - $slots: tokens-mdc-extended-fab.get-token-slots(), - $reference: mdc-extended-fab-theme.$extended-light-theme -); @include validate-slots( $component: 'm2.mdc.filled-text-field', $slots: tokens-mdc-filled-text-field.get-token-slots(),