diff --git a/src/material/core/tokens/_custom-tokens.scss b/src/material/core/tokens/_custom-tokens.scss deleted file mode 100644 index ebc3fa052f52..000000000000 --- a/src/material/core/tokens/_custom-tokens.scss +++ /dev/null @@ -1,1918 +0,0 @@ -@use 'sass:map'; -@use '../style/sass-utils'; -@use '@material/elevation/elevation-theme' as mdc-elevation; - -/// Hardcode the given value, or null if hardcoded values are excluded. -@function _hardcode($value, $exclude-hardcoded) { - @return if($exclude-hardcoded, null, $value); -} - -/// Sets all of the standard typography tokens for the given token base name to the given typography -/// level. -/// @param {Map} $systems The MDC system tokens -/// @param {String} $base-name The token base name to get the typography tokens for -/// @param {String} $typography-level The typography level to base the token values on -/// @return {Map} A map containing the typography tokens for the given base token name -@function _generate-typography-tokens($systems, $base-name, $typography-level) { - $result: (); - @each $prop in (font, line-height, size, tracking, weight) { - $result: map.set($result, #{$base-name}-#{$prop}, - map.get($systems, md-sys-typescale, #{$typography-level}-#{$prop})); - } - @return $result; -} - -/// Generates custom tokens for the mat-autocomplete. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of custom tokens for the mat-autocomplete -@function autocomplete($systems, $exclude-hardcoded) { - @return ( - background-color: map.get($systems, md-sys-color, surface-container), - container-shape: map.get($systems, md-sys-shape, corner-extra-small), - container-elevation-shadow: - _hardcode(mdc-elevation.elevation-box-shadow(2), $exclude-hardcoded), - ); -} - -/// Generates custom tokens for the app. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of custom tokens for the app -@function app($systems, $exclude-hardcoded) { - @return ( - background-color: map.get($systems, md-sys-color, background), - text-color: map.get($systems, md-sys-color, on-background), - ); -} - -/// Generates custom tokens for the mat-badge. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of custom tokens for the mat-badge -@function badge($systems, $exclude-hardcoded) { - @return (( - background-color: map.get($systems, md-sys-color, error), - text-color: map.get($systems, md-sys-color, on-error), - disabled-state-background-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, error), - $alpha: 0.38, - ), - disabled-state-text-color: map.get($systems, md-sys-color, on-error), - text-font: map.get($systems, md-sys-typescale, label-small-font), - text-size: map.get($systems, md-sys-typescale, label-small-size), - text-weight: map.get($systems, md-sys-typescale, label-small-weight), - small-size-text-size: _hardcode(0, $exclude-hardcoded), - container-shape: map.get($systems, md-sys-shape, corner-full), - container-size: _hardcode(16px, $exclude-hardcoded), - legacy-container-size: _hardcode(unset, $exclude-hardcoded), - legacy-small-size-container-size: _hardcode(unset, $exclude-hardcoded), - small-size-container-size: _hardcode(6px, $exclude-hardcoded), - container-padding: _hardcode(0 4px, $exclude-hardcoded), - small-size-container-padding: _hardcode(0, $exclude-hardcoded), - container-offset: _hardcode(-12px 0, $exclude-hardcoded), - small-size-container-offset: _hardcode(-6px 0, $exclude-hardcoded), - container-overlap-offset: _hardcode(-12px, $exclude-hardcoded), - small-size-container-overlap-offset: _hardcode(-6px, $exclude-hardcoded), - - // This size isn't in the M3 spec so we emit the same values as for `medium`. - large-size-container-size: _hardcode(16px, $exclude-hardcoded), - large-size-container-offset: _hardcode(-12px 0, $exclude-hardcoded), - large-size-container-overlap-offset: _hardcode(-12px, $exclude-hardcoded), - large-size-text-size: map.get($systems, md-sys-typescale, label-small-size), - large-size-container-padding: _hardcode(0 4px, $exclude-hardcoded), - legacy-large-size-container-size: _hardcode(unset, $exclude-hardcoded), - ), ( - primary: ( - background-color: map.get($systems, md-sys-color, primary), - text-color: map.get($systems, md-sys-color, on-primary), - disabled-state-background-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, primary), - $alpha: 0.38, - ), - disabled-state-text-color: map.get($systems, md-sys-color, on-primary), - ), - secondary: ( - background-color: map.get($systems, md-sys-color, secondary), - text-color: map.get($systems, md-sys-color, on-secondary), - disabled-state-background-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, secondary), - $alpha: 0.38, - ), - disabled-state-text-color: map.get($systems, md-sys-color, on-secondary), - ), - tertiary: ( - background-color: map.get($systems, md-sys-color, tertiary), - text-color: map.get($systems, md-sys-color, on-tertiary), - disabled-state-background-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, tertiary), - $alpha: 0.38, - ), - disabled-state-text-color: map.get($systems, md-sys-color, on-tertiary), - ), - error: () // Default, no overrides needed - )); -} - -/// Generates custom tokens for the mat-bottom-sheet. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of custom tokens for the mat-bottom-sheet -@function bottom-sheet($systems, $exclude-hardcoded) { - @return sass-utils.merge-all( - _generate-typography-tokens($systems, container-text, body-large), - ( - container-shape: _hardcode(28px, $exclude-hardcoded), - container-text-color: map.get($systems, md-sys-color, on-surface), - container-background-color: map.get($systems, md-sys-color, surface-container-low), - ), - ); -} - -/// Generates custom tokens for the mat-button-toggle. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of custom tokens for the mat-button-toggle -@function button-toggle($systems, $exclude-hardcoded) { - @return sass-utils.merge-all( - _generate-typography-tokens($systems, label-text, label-large), - ( - shape: map.get($systems, md-sys-shape, corner-full), - hover-state-layer-opacity: map.get($systems, md-sys-state, hover-state-layer-opacity), - focus-state-layer-opacity: map.get($systems, md-sys-state, focus-state-layer-opacity), - text-color: map.get($systems, md-sys-color, on-surface), - background-color: _hardcode(transparent, $exclude-hardcoded), - state-layer-color: map.get($systems, md-sys-color, on-surface), - selected-state-background-color: map.get($systems, md-sys-color, secondary-container), - selected-state-text-color: map.get($systems, md-sys-color, on-secondary-container), - disabled-state-text-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, on-surface), - $alpha: 0.38, - ), - disabled-state-background-color: _hardcode(transparent, $exclude-hardcoded), - disabled-selected-state-text-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, on-surface), - $alpha: 0.38, - ), - disabled-selected-state-background-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, on-surface), - $alpha: 0.12, - ), - divider-color: map.get($systems, md-sys-color, outline), - ), ( - // Color variants: - primary: ( - selected-state-background-color: map.get($systems, md-sys-color, primary-container), - selected-state-text-color: map.get($systems, md-sys-color, on-primary-container), - ), - secondary: (), // Default, no overrides needed - tertiary: ( - selected-state-background-color: map.get($systems, md-sys-color, tertiary-container), - selected-state-text-color: map.get($systems, md-sys-color, on-tertiary-container), - ), - error: ( - selected-state-background-color: map.get($systems, md-sys-color, error-container), - selected-state-text-color: map.get($systems, md-sys-color, on-error-container), - ) - )); -} - -/// Generates custom tokens for the mat-card. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of custom tokens for the mat-card -@function card($systems, $exclude-hardcoded) { - @return sass-utils.merge-all( - _generate-typography-tokens($systems, title-text, title-large), - _generate-typography-tokens($systems, subtitle-text, title-medium), - ( - subtitle-text-color: map.get($systems, md-sys-color, on-surface) - ) - ); -} - -/// Generates custom tokens for the mat-chip. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of custom tokens for the mat-chip -@function chip($systems, $exclude-hardcoded) { - @return (( - disabled-container-opacity: _hardcode(1, $exclude-hardcoded), - selected-trailing-icon-color: map.get($systems, md-sys-color, on-secondary-container), - selected-disabled-trailing-icon-color: map.get($systems, md-sys-color, on-surface), - trailing-action-state-layer-color: map.get($systems, md-sys-color, on-surface-variant), - selected-trailing-action-state-layer-color: - map.get($systems, md-sys-color, on-secondary-container), - trailing-action-hover-state-layer-opacity: - map.get($systems, md-sys-state, hover-state-layer-opacity), - trailing-action-focus-state-layer-opacity: - map.get($systems, md-sys-state, focus-state-layer-opacity), - trailing-action-opacity: _hardcode(1, $exclude-hardcoded), - trailing-action-focus-opacity: _hardcode(1, $exclude-hardcoded), - ), ( - primary: ( - selected-trailing-icon-color: map.get($systems, md-sys-color, on-primary-container), - selected-trailing-action-state-layer-color: - map.get($systems, md-sys-color, on-primary-container), - ), - secondary: (), // Default, no overrides needed. - tertiary: ( - selected-trailing-icon-color: map.get($systems, md-sys-color, on-tertiary-container), - selected-trailing-action-state-layer-color: - map.get($systems, md-sys-color, on-tertiary-container), - ), - error: ( - selected-trailing-icon-color: map.get($systems, md-sys-color, on-error-container), - selected-trailing-action-state-layer-color: - map.get($systems, md-sys-color, on-error-container), - ), - )); -} - -/// Generates custom tokens for the mdc-chip. (MDC has a chip component, but they -/// seem to have made up the tokens rather than using ones generated from the token database, -/// therefore we need a custom token function for it). -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of custom tokens for the mdc-chip -@function mdc-chip($systems, $exclude-hardcoded) { - @return (sass-utils.merge-all( - _generate-typography-tokens($systems, label-text, label-large), - ( - container-shape: _hardcode(( - family: rounded, - radius: 8px, - ), $exclude-hardcoded), - with-avatar-avatar-size: _hardcode(24px, $exclude-hardcoded), - label-text-color: map.get($systems, md-sys-color, on-surface-variant), - disabled-label-text-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, on-surface), - $alpha: 0.38, - ), - with-icon-icon-size: _hardcode(18px, $exclude-hardcoded), - with-icon-icon-color: map.get($systems, md-sys-color, on-surface-variant), - with-icon-disabled-icon-color: map.get($systems, md-sys-color, on-surface), - with-icon-selected-icon-color: map.get($systems, md-sys-color, on-secondary-container), - with-trailing-icon-trailing-icon-color: map.get($systems, md-sys-color, on-surface-variant), - with-trailing-icon-disabled-trailing-icon-color: map.get($systems, md-sys-color, on-surface), - focus-state-layer-opacity: map.get($systems, md-sys-state, focus-state-layer-opacity), - focus-state-layer-color: map.get($systems, md-sys-color, on-surface-variant), - outline-width: _hardcode(1px, $exclude-hardcoded), - outline-color: map.get($systems, md-sys-color, outline), - disabled-outline-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, on-surface), - $alpha: 0.12, - ), - focus-outline-color: map.get($systems, md-sys-color, on-surface-variant), - hover-state-layer-color: map.get($systems, md-sys-color, on-surface-variant), - hover-state-layer-opacity: map.get($systems, md-sys-state, hover-state-layer-opacity), - with-avatar-disabled-avatar-opacity: _hardcode(0.38, $exclude-hardcoded), - elevated-selected-container-color: map.get($systems, md-sys-color, secondary-container), - flat-selected-outline-width: _hardcode(0, $exclude-hardcoded), - selected-label-text-color: map.get($systems, md-sys-color, on-secondary-container), - flat-disabled-selected-container-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, on-surface), - $alpha: 0.12, - ), - selected-hover-state-layer-color: map.get($systems, md-sys-color, on-secondary-container), - selected-hover-state-layer-opacity: - map.get($systems, md-sys-state, hover-state-layer-opacity), - selected-focus-state-layer-color: map.get($systems, md-sys-color, on-secondary-container), - selected-focus-state-layer-opacity: - map.get($systems, md-sys-state, focus-state-layer-opacity), - with-icon-disabled-icon-opacity: _hardcode(0.38, $exclude-hardcoded), - with-trailing-icon-disabled-trailing-icon-opacity: _hardcode(0.38, $exclude-hardcoded), - ), - ), ( - // Color variants: - primary: ( - with-icon-selected-icon-color: map.get($systems, md-sys-color, on-primary-container), - elevated-selected-container-color: map.get($systems, md-sys-color, primary-container), - selected-label-text-color: map.get($systems, md-sys-color, on-primary-container), - selected-hover-state-layer-color: map.get($systems, md-sys-color, on-primary-container), - selected-focus-state-layer-color: map.get($systems, md-sys-color, on-primary-container), - ), - secondary: (), // Default, no overrides needed. - tertiary: ( - with-icon-selected-icon-color: map.get($systems, md-sys-color, on-tertiary-container), - elevated-selected-container-color: map.get($systems, md-sys-color, tertiary-container), - selected-label-text-color: map.get($systems, md-sys-color, on-tertiary-container), - selected-hover-state-layer-color: map.get($systems, md-sys-color, on-tertiary-container), - selected-focus-state-layer-color: map.get($systems, md-sys-color, on-tertiary-container), - ), - error: ( - with-icon-selected-icon-color: map.get($systems, md-sys-color, on-error-container), - elevated-selected-container-color: map.get($systems, md-sys-color, error-container), - selected-label-text-color: map.get($systems, md-sys-color, on-error-container), - selected-hover-state-layer-color: map.get($systems, md-sys-color, on-error-container), - selected-focus-state-layer-color: map.get($systems, md-sys-color, on-error-container), - ) - )); -} - -/// Generates custom tokens for the mat-datepicker. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of custom tokens for the mat-datepicker -@function datepicker($systems, $exclude-hardcoded) { - @return (( - calendar-date-in-range-state-background-color: - map.get($systems, md-sys-color, primary-container), - calendar-date-in-comparison-range-state-background-color: - map.get($systems, md-sys-color, tertiary-container), - calendar-date-in-overlap-range-state-background-color: - map.get($systems, md-sys-color, secondary-container), - calendar-date-in-overlap-range-selected-state-background-color: - map.get($systems, md-sys-color, secondary), - calendar-date-selected-state-text-color: map.get($systems, md-sys-color, on-primary), - calendar-date-selected-state-background-color: map.get($systems, md-sys-color, primary), - calendar-date-selected-disabled-state-background-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, on-surface), - $alpha: 0.38 - ), - calendar-date-today-selected-state-outline-color: map.get($systems, md-sys-color, primary), - calendar-date-focus-state-background-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, on-surface), - $alpha: map.get($systems, md-sys-state, focus-state-layer-opacity) - ), - calendar-date-hover-state-background-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, on-surface), - $alpha: map.get($systems, md-sys-state, hover-state-layer-opacity) - ), - toggle-active-state-icon-color: map.get($systems, md-sys-color, on-surface-variant), - toggle-icon-color: map.get($systems, md-sys-color, on-surface-variant), - calendar-body-label-text-color: map.get($systems, md-sys-color, on-surface), - calendar-period-button-text-color: map.get($systems, md-sys-color, on-surface-variant), - calendar-period-button-icon-color: map.get($systems, md-sys-color, on-surface-variant), - calendar-navigation-button-icon-color: map.get($systems, md-sys-color, on-surface-variant), - calendar-header-divider-color: _hardcode(transparent, $exclude-hardcoded), - calendar-header-text-color: map.get($systems, md-sys-color, on-surface-variant), - calendar-date-today-outline-color: map.get($systems, md-sys-color, primary), - calendar-date-today-disabled-state-outline-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, on-surface), - $alpha: 0.38 - ), - calendar-date-text-color: map.get($systems, md-sys-color, on-surface), - calendar-date-outline-color: _hardcode(transparent, $exclude-hardcoded), - calendar-date-disabled-state-text-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, on-surface), - $alpha: 0.38 - ), - calendar-date-preview-state-outline-color: map.get($systems, md-sys-color, primary), - range-input-separator-color: map.get($systems, md-sys-color, on-surface), - range-input-disabled-state-separator-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, on-surface), - $alpha: 0.38 - ), - range-input-disabled-state-text-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, on-surface), - $alpha: 0.38 - ), - calendar-container-background-color: map.get($systems, md-sys-color, surface-container-high), - calendar-container-text-color: map.get($systems, md-sys-color, on-surface), - calendar-container-elevation-shadow: _hardcode(mdc-elevation.elevation-box-shadow(0), - $exclude-hardcoded), - calendar-container-touch-elevation-shadow: _hardcode(mdc-elevation.elevation-box-shadow(0), - $exclude-hardcoded), - calendar-container-shape: map.get($systems, md-sys-shape, corner-large), - calendar-container-touch-shape: map.get($systems, md-sys-shape, corner-extra-large), - calendar-text-font: map.get($systems, md-sys-typescale, body-large-font), - calendar-text-size: map.get($systems, md-sys-typescale, body-large-size), - calendar-body-label-text-size: map.get($systems, md-sys-typescale, title-small-size), - calendar-body-label-text-weight: map.get($systems, md-sys-typescale, title-small-weight), - calendar-period-button-text-size: map.get($systems, md-sys-typescale, title-small-size), - calendar-period-button-text-weight: map.get($systems, md-sys-typescale, title-small-weight), - calendar-header-text-size: map.get($systems, md-sys-typescale, title-small-size), - calendar-header-text-weight: map.get($systems, md-sys-typescale, title-small-weight), - ), ( - // Color variants: - primary: (), // Default, no overrides needed. - secondary: ( - calendar-date-in-range-state-background-color: - map.get($systems, md-sys-color, secondary-container), - calendar-date-selected-state-text-color: map.get($systems, md-sys-color, on-secondary), - calendar-date-selected-state-background-color: map.get($systems, md-sys-color, secondary), - calendar-date-today-selected-state-outline-color: map.get($systems, md-sys-color, secondary), - calendar-date-today-outline-color: map.get($systems, md-sys-color, secondary), - calendar-date-preview-state-outline-color: map.get($systems, md-sys-color, secondary), - calendar-date-in-overlap-range-state-background-color: - map.get($systems, md-sys-color, primary-container), - calendar-date-in-overlap-range-selected-state-background-color: - map.get($systems, md-sys-color, primary), - ), - tertiary: ( - calendar-date-in-range-state-background-color: - map.get($systems, md-sys-color, tertiary-container), - calendar-date-selected-state-text-color: map.get($systems, md-sys-color, on-tertiary), - calendar-date-selected-state-background-color: map.get($systems, md-sys-color, tertiary), - calendar-date-today-selected-state-outline-color: map.get($systems, md-sys-color, tertiary), - calendar-date-today-outline-color: map.get($systems, md-sys-color, tertiary), - calendar-date-preview-state-outline-color: map.get($systems, md-sys-color, tertiary), - calendar-date-in-comparison-range-state-background-color: - map.get($systems, md-sys-color, primary-container), - ), - error: ( - calendar-date-in-range-state-background-color: - map.get($systems, md-sys-color, error-container), - calendar-date-selected-state-text-color: map.get($systems, md-sys-color, on-error), - calendar-date-selected-state-background-color: map.get($systems, md-sys-color, error), - calendar-date-today-selected-state-outline-color: map.get($systems, md-sys-color, error), - calendar-date-today-outline-color: map.get($systems, md-sys-color, error), - calendar-date-preview-state-outline-color: map.get($systems, md-sys-color, error), - ) - )); -} - -/// Generates custom tokens for the dialog. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of custom tokens for the dialog -@function dialog($systems, $exclude-hardcoded) { - @return ( - container-max-width: _hardcode(560px, $exclude-hardcoded), - container-small-max-width: _hardcode(calc(100vw - 32px), $exclude-hardcoded), - container-min-width: _hardcode(280px, $exclude-hardcoded), - actions-alignment: _hardcode(flex-end, $exclude-hardcoded), - content-padding: _hardcode(20px 24px, $exclude-hardcoded), - with-actions-content-padding: _hardcode(20px 24px 0, $exclude-hardcoded), - actions-padding: _hardcode(16px 24px, $exclude-hardcoded), - - // The vertical padding values are a bit weird, because MDC uses a `::before` pseudo - // element to size the title which in turn means that we can't set a specific padding - // and get the exact same space out of it. These values were determined through - // trial and error so that the first line of text is 24px from the top and the bottom - // of the text is 16px from the content under it. - headline-padding: _hardcode(6px 24px 13px, $exclude-hardcoded), - ); -} - -/// Generates custom tokens for the mat-divider. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of custom tokens for the mat-divider -@function divider($systems, $exclude-hardcoded) { - @return ( - width: _hardcode(1px, $exclude-hardcoded), - color: map.get($systems, md-sys-color, outline-variant), - ); -} - -/// Generates custom tokens for the mat-expansion. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of custom tokens for the mat-expansion -@function expansion($systems, $exclude-hardcoded) { - @return sass-utils.merge-all( - _generate-typography-tokens($systems, header-text, title-medium), - _generate-typography-tokens($systems, container-text, body-large), - ( - container-shape: _hardcode(12px, $exclude-hardcoded), - legacy-header-indicator-display: _hardcode(none, $exclude-hardcoded), - header-indicator-display: _hardcode(inline-block, $exclude-hardcoded), - container-background-color: map.get($systems, md-sys-color, surface), - container-text-color: map.get($systems, md-sys-color, on-surface), - actions-divider-color: map.get($systems, md-sys-color, outline-variant), - header-hover-state-layer-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, on-surface), - $alpha: map.get($systems, md-sys-state, hover-state-layer-opacity) - ), - header-focus-state-layer-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, on-surface), - $alpha: map.get($systems, md-sys-state, focus-state-layer-opacity) - ), - header-disabled-state-text-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, on-surface), $alpha: 0.38), - header-text-color: map.get($systems, md-sys-color, on-surface), - header-description-color: map.get($systems, md-sys-color, on-surface-variant), - header-indicator-color: map.get($systems, md-sys-color, on-surface-variant), - ) - ); -} - -/// Generates custom tokens for the mat-fab. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of custom tokens for the mat-fab -@function fab($systems, $exclude-hardcoded) { - @return (( - foreground-color: map.get($systems, md-sys-color, on-primary-container), - state-layer-color: map.get($systems, md-sys-color, on-primary-container), - ripple-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, on-primary-container), - $alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity) - ), - hover-state-layer-opacity: map.get($systems, md-sys-state, hover-state-layer-opacity), - focus-state-layer-opacity: map.get($systems, md-sys-state, focus-state-layer-opacity), - pressed-state-layer-opacity: map.get($systems, md-sys-state, pressed-state-layer-opacity), - disabled-state-container-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, on-surface), $alpha: 0.12), - disabled-state-foreground-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, on-surface), $alpha: 0.38), - ), ( - // Color variants - primary: (), // Default, no overrides needed. - secondary: ( - foreground-color: map.get($systems, md-sys-color, on-secondary-container), - state-layer-color: map.get($systems, md-sys-color, on-secondary-container), - ripple-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, on-secondary-container), - $alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity) - ), - ), - tertiary: ( - foreground-color: map.get($systems, md-sys-color, on-tertiary-container), - state-layer-color: map.get($systems, md-sys-color, on-tertiary-container), - ripple-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, on-tertiary-container), - $alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity) - ), - ) - )); -} - -/// Generates custom tokens for the mat-mini-fab. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of custom tokens for the mat-mini-fab -@function fab-small($systems, $exclude-hardcoded) { - @return (( - foreground-color: map.get($systems, md-sys-color, on-primary-container), - state-layer-color: map.get($systems, md-sys-color, on-primary-container), - ripple-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, on-primary-container), - $alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity) - ), - hover-state-layer-opacity: map.get($systems, md-sys-state, hover-state-layer-opacity), - focus-state-layer-opacity: map.get($systems, md-sys-state, focus-state-layer-opacity), - pressed-state-layer-opacity: map.get($systems, md-sys-state, pressed-state-layer-opacity), - disabled-state-container-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, on-surface), $alpha: 0.12), - disabled-state-foreground-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, on-surface), $alpha: 0.38), - ), ( - // Color variants - primary: (), // Default, no overrides needed. - secondary: ( - foreground-color: map.get($systems, md-sys-color, on-secondary-container), - state-layer-color: map.get($systems, md-sys-color, on-secondary-container), - ripple-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, on-secondary-container), - $alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity) - ), - ), - tertiary: ( - foreground-color: map.get($systems, md-sys-color, on-tertiary-container), - state-layer-color: map.get($systems, md-sys-color, on-tertiary-container), - ripple-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, on-tertiary-container), - $alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity) - ), - ) - )); -} - -/// Generates custom tokens for the mat-form-field. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of custom tokens for the mat-form-field -@function form-field($systems, $exclude-hardcoded) { - @return (sass-utils.merge-all( - _generate-typography-tokens($systems, container-text, body-large), - _generate-typography-tokens($systems, subscript-text, body-small), - ( - disabled-input-text-placeholder-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, on-surface), $alpha: 0.38), - state-layer-color: map.get($systems, md-sys-color, on-surface), - error-text-color: map.get($systems, md-sys-color, error), - select-option-text-color: map.get($systems, md-ref-palette, neutral10), - select-disabled-option-text-color: sass-utils.safe-color-change( - map.get($systems, md-ref-palette, neutral10), $alpha: 0.38), - enabled-select-arrow-color: map.get($systems, md-sys-color, on-surface-variant), - disabled-select-arrow-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, on-surface), $alpha: 0.38), - hover-state-layer-opacity: map.get($systems, md-sys-state, hover-state-layer-opacity), - focus-state-layer-opacity: _hardcode(0, $exclude-hardcoded), - focus-select-arrow-color: map.get($systems, md-sys-color, primary), - outlined-label-text-populated-size: map.get($systems, md-sys-typeface, body-large-size), - - leading-icon-color: map.get($systems, md-sys-color, on-surface-variant), - disabled-leading-icon-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, on-surface), $alpha: 0.38), - - trailing-icon-color: map.get($systems, md-sys-color, on-surface-variant), - disabled-trailing-icon-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, on-surface), $alpha: 0.38), - error-focus-trailing-icon-color: map.get($systems, md-sys-color, error), - error-hover-trailing-icon-color: map.get($systems, md-sys-color, on-error-container), - error-trailing-icon-color: map.get($systems, md-sys-color, error), - ) - ), ( - // Color variants: - primary: (), // Default, no overrides needed. - secondary: ( - focus-select-arrow-color: map.get($systems, md-sys-color, secondary), - ), - tertiary: ( - focus-select-arrow-color: map.get($systems, md-sys-color, tertiary), - ), - error: ( - focus-select-arrow-color: map.get($systems, md-sys-color, error), - ) - )); -} - -/// Generates custom tokens for the mat-grid-list. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of custom tokens for the mat-grid-list -@function grid-list($systems, $exclude-hardcoded) { - @return ( - tile-header-primary-text-size: map.get($systems, md-sys-typescale, body-large), - tile-header-secondary-text-size: map.get($systems, md-sys-typescale, body-medium), - tile-footer-primary-text-size: map.get($systems, md-sys-typescale, body-large), - tile-footer-secondary-text-size: map.get($systems, md-sys-typescale, body-medium), - ); -} - -/// Generates custom tokens for the mat-icon. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of custom tokens for the mat-icon -@function icon($systems, $exclude-hardcoded) { - @return (( - color: _hardcode(inherit, $exclude-hardcoded), - ), ( - // Color variants: - surface: (), // Default, no overrides needed. - primary: ( - color: map.get($systems, md-sys-color, primary), - ), - secondary: ( - color: map.get($systems, md-sys-color, secondary), - ), - tertiary: ( - color: map.get($systems, md-sys-color, tertiary), - ), - error: ( - color: map.get($systems, md-sys-color, error), - ) - )); -} - -/// Generates custom tokens for the mat-list. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of custom tokens for the mat-list -@function list($systems, $exclude-hardcoded) { - @return ( - active-indicator-color: map.get($systems, md-sys-color, secondary-container), - active-indicator-shape: map.get($systems, md-sys-shape, corner-full), - ); -} - -/// Generates custom tokens for the mat-button. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of custom tokens for the mat-button -@function text-button($systems, $exclude-hardcoded) { - @return (( - horizontal-padding: _hardcode(12px, $exclude-hardcoded), - with-icon-horizontal-padding: _hardcode(16px, $exclude-hardcoded), - icon-spacing: _hardcode(8px, $exclude-hardcoded), - icon-offset: _hardcode(-4px, $exclude-hardcoded), - state-layer-color: map.get($systems, md-sys-color, primary), - disabled-state-layer-color: map.get($systems, md-sys-color, on-surface-variant), - ripple-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, primary), - $alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity) - ), - hover-state-layer-opacity: map.get($systems, md-sys-state, hover-state-layer-opacity), - focus-state-layer-opacity: map.get($systems, md-sys-state, focus-state-layer-opacity), - pressed-state-layer-opacity: map.get($systems, md-sys-state, pressed-state-layer-opacity), - ), ( - // Color variants: - primary: (), // Default, no overrides needed. - secondary: ( - state-layer-color: map.get($systems, md-sys-color, secondary), - ripple-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, secondary), - $alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity) - ) - ), - tertiary: ( - state-layer-color: map.get($systems, md-sys-color, tertiary), - ripple-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, tertiary), - $alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity) - ) - ), - error: ( - state-layer-color: map.get($systems, md-sys-color, error), - ripple-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, error), - $alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity) - ) - ) - )); -} - -/// Generates custom tokens for the mat-flat-button. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of custom tokens for the mat-flat-button -@function filled-button($systems, $exclude-hardcoded) { - @return (( - horizontal-padding: _hardcode(24px, $exclude-hardcoded), - icon-spacing: _hardcode(8px, $exclude-hardcoded), - icon-offset: _hardcode(-8px, $exclude-hardcoded), - state-layer-color: map.get($systems, md-sys-color, on-primary), - disabled-state-layer-color: map.get($systems, md-sys-color, on-surface-variant), - ripple-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, on-primary), - $alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity) - ), - hover-state-layer-opacity: map.get($systems, md-sys-state, hover-state-layer-opacity), - focus-state-layer-opacity: map.get($systems, md-sys-state, focus-state-layer-opacity), - pressed-state-layer-opacity: map.get($systems, md-sys-state, pressed-state-layer-opacity), - ), ( - // Color variants: - primary: (), // Default, no overrides needed. - secondary: ( - state-layer-color: map.get($systems, md-sys-color, on-secondary), - ripple-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, on-secondary), - $alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity) - ), - ), - tertiary: ( - state-layer-color: map.get($systems, md-sys-color, on-tertiary), - ripple-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, on-tertiary), - $alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity) - ), - ), - error: ( - state-layer-color: map.get($systems, md-sys-color, on-error), - ripple-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, on-error), - $alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity) - ), - ) - )); -} - -/// Generates custom tokens for the mat-raised-button. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of custom tokens for the mat-raised-button -@function elevated-button($systems, $exclude-hardcoded) { - @return (( - horizontal-padding: _hardcode(24px, $exclude-hardcoded), - icon-spacing: _hardcode(8px, $exclude-hardcoded), - icon-offset: _hardcode(-8px, $exclude-hardcoded), - state-layer-color: map.get($systems, md-sys-color, primary), - disabled-state-layer-color: map.get($systems, md-sys-color, on-surface-variant), - ripple-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, primary), - $alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity) - ), - hover-state-layer-opacity: map.get($systems, md-sys-state, hover-state-layer-opacity), - focus-state-layer-opacity: map.get($systems, md-sys-state, focus-state-layer-opacity), - pressed-state-layer-opacity: map.get($systems, md-sys-state, pressed-state-layer-opacity), - ), ( - // Color variants: - primary: (), // Default, no overrides needed. - secondary: ( - state-layer-color: map.get($systems, md-sys-color, secondary), - ripple-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, secondary), - $alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity) - ), - ), - tertiary: ( - state-layer-color: map.get($systems, md-sys-color, tertiary), - ripple-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, tertiary), - $alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity) - ), - ), - error: ( - state-layer-color: map.get($systems, md-sys-color, error), - ripple-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, error), - $alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity) - ), - ) - )); -} - -/// Generates custom tokens for the mat-outlined-button. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of custom tokens for the mat-outlined-button -@function outlined-button($systems, $exclude-hardcoded) { - @return (( - horizontal-padding: _hardcode(24px, $exclude-hardcoded), - icon-spacing: _hardcode(8px, $exclude-hardcoded), - icon-offset: _hardcode(-8px, $exclude-hardcoded), - state-layer-color: map.get($systems, md-sys-color, primary), - disabled-state-layer-color: map.get($systems, md-sys-color, on-surface-variant), - ripple-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, primary), - $alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity) - ), - hover-state-layer-opacity: map.get($systems, md-sys-state, hover-state-layer-opacity), - focus-state-layer-opacity: map.get($systems, md-sys-state, focus-state-layer-opacity), - pressed-state-layer-opacity: map.get($systems, md-sys-state, pressed-state-layer-opacity), - ), ( - // Color variants: - primary: (), // Default, no overrides needed. - secondary: ( - state-layer-color: map.get($systems, md-sys-color, secondary), - ripple-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, secondary), - $alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity) - ), - ), - tertiary: ( - state-layer-color: map.get($systems, md-sys-color, tertiary), - ripple-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, tertiary), - $alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity) - ), - ), - error: ( - state-layer-color: map.get($systems, md-sys-color, error), - ripple-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, error), - $alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity) - ), - ) - )); -} - -/// Generates custom tokens for the mat-icon-button. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of custom tokens for the mat-icon-button -@function icon-button($systems, $exclude-hardcoded) { - @return ( - state-layer-color: map.get($systems, md-sys-color, on-surface-variant), - disabled-state-layer-color: map.get($systems, md-sys-color, on-surface-variant), - ripple-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, on-surface-variant), - $alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity) - ), - hover-state-layer-opacity: map.get($systems, md-sys-state, hover-state-layer-opacity), - focus-state-layer-opacity: map.get($systems, md-sys-state, focus-state-layer-opacity), - pressed-state-layer-opacity: map.get($systems, md-sys-state, pressed-state-layer-opacity), - ); -} - -/// Generates custom tokens for the mat-menu. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of custom tokens for the mat-menu -@function menu($systems, $exclude-hardcoded) { - @return sass-utils.merge-all( - _generate-typography-tokens($systems, item-label-text, label-large), - ( - container-shape: map.get($systems, md-sys-shape, corner-extra-small), - divider-color: map.get($systems, md-sys-color, surface-variant), - divider-bottom-spacing: _hardcode(8px, $exclude-hardcoded), - divider-top-spacing: _hardcode(8px, $exclude-hardcoded), - item-label-text-color: map.get($systems, md-sys-color, on-surface), - item-icon-color: map.get($systems, md-sys-color, on-surface-variant), - item-icon-size: _hardcode(24px, $exclude-hardcoded), - item-hover-state-layer-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, on-surface), - $alpha: map.get($systems, md-sys-state, hover-state-layer-opacity) - ), - item-focus-state-layer-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, on-surface), - $alpha: map.get($systems, md-sys-state, focus-state-layer-opacity) - ), - item-spacing: _hardcode(12px, $exclude-hardcoded), - item-leading-spacing: _hardcode(12px, $exclude-hardcoded), - item-trailing-spacing: _hardcode(12px, $exclude-hardcoded), - item-with-icon-leading-spacing: _hardcode(12px, $exclude-hardcoded), - item-with-icon-trailing-spacing: _hardcode(12px, $exclude-hardcoded), - container-color: map.get($systems, md-sys-color, surface-container), - ) - ); -} - -/// Generates custom tokens for the mat-optgroup. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of custom tokens for the mat-optgroup -@function optgroup($systems, $exclude-hardcoded) { - @return sass-utils.merge-all( - _generate-typography-tokens($systems, label-text, title-small), - ( - label-text-color: map.get($systems, md-sys-color, on-surface-variant), - ) - ); -} - -/// Generates custom tokens for the mat-option. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of custom tokens for the mat-option -@function option($systems, $exclude-hardcoded) { - @return (( - selected-state-label-text-color: map.get($systems, md-sys-color, on-secondary-container), - label-text-color: map.get($systems, md-sys-color, on-surface), - hover-state-layer-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, on-surface), - $alpha: map.get($systems, md-sys-state, hover-state-layer-opacity) - ), - focus-state-layer-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, on-surface), - $alpha: map.get($systems, md-sys-state, focus-state-layer-opacity) - ), - selected-state-layer-color: map.get($systems, md-sys-color, secondary-container), - - // According to the spec the options have to be `label-large` in all typography - // dimensions, however this is inconsistent with the designs and with MDC's - // own implementation. This appears to be a bug in the spec, because MDC overrides - // the font size and weight to be `body-large` (see b/261838263). We make the same - // override here so the label looks correct. - label-text-size: map.get($systems, md-sys-typescale, body-large-size), - label-text-weight: map.get($systems, md-sys-typescale, body-large-weight), - label-text-font: map.get($systems, md-sys-typescale, label-large-font), - label-text-line-height: map.get($systems, md-sys-typescale, label-large-line-height), - label-text-tracking: map.get($systems, md-sys-typescale, label-large-tracking), - ), ( - // Color variants: - primary: ( - selected-state-label-text-color: map.get($systems, md-sys-color, on-primary-container), - selected-state-layer-color: map.get($systems, md-sys-color, primary-container), - ), - secondary: (), // Default, no overrides needed - tertiary: ( - selected-state-label-text-color: map.get($systems, md-sys-color, on-tertiary-container), - selected-state-layer-color: map.get($systems, md-sys-color, tertiary-container), - ), - error: ( - selected-state-label-text-color: map.get($systems, md-sys-color, on-error-container), - selected-state-layer-color: map.get($systems, md-sys-color, error-container), - ) - )); -} - -/// Generates custom tokens for the mat-paginator. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of custom tokens for the mat-paginator -@function paginator($systems, $exclude-hardcoded) { - @return sass-utils.merge-all( - _generate-typography-tokens($systems, container-text, body-small), - ( - container-text-color: map.get($systems, md-sys-color, on-surface), - container-background-color: map.get($systems, md-sys-color, surface), - enabled-icon-color: map.get($systems, md-sys-color, on-surface-variant), - disabled-icon-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, on-surface), $alpha: 0.38), - select-trigger-text-size: map.get($systems, md-sys-typescale, body-small-size), - ) - ); -} - -/// Generates custom tokens for the full variant of mat-pseudo-checkbox. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of custom tokens for the full variant of mat-pseudo-checkbox -@function full-pseudo-checkbox($systems, $exclude-hardcoded) { - $disabled-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, on-surface), $alpha: 0.38); - - @return (( - selected-icon-color: map.get($systems, md-sys-color, primary), - selected-checkmark-color: map.get($systems, md-sys-color, on-primary), - unselected-icon-color: map.get($systems, md-sys-color, on-surface-variant), - disabled-selected-checkmark-color: map.get($systems, md-sys-color, surface), - disabled-unselected-icon-color: $disabled-color, - disabled-selected-icon-color: $disabled-color, - ), ( - // Color variants: - primary: (), // Default, no overrides needed. - secondary: ( - selected-icon-color: map.get($systems, md-sys-color, secondary), - selected-checkmark-color: map.get($systems, md-sys-color, on-secondary), - ), - tertiary: ( - selected-icon-color: map.get($systems, md-sys-color, tertiary), - selected-checkmark-color: map.get($systems, md-sys-color, on-tertiary), - ), - error: ( - selected-icon-color: map.get($systems, md-sys-color, error), - selected-checkmark-color: map.get($systems, md-sys-color, on-error), - ) - )); -} - -/// Generates custom tokens for the minimal variant of mat-pseudo-checkbox. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of custom tokens for the minimal variant of mat-pseudo-checkbox -@function minimal-pseudo-checkbox($systems, $exclude-hardcoded) { - @return (( - selected-checkmark-color: map.get($systems, md-sys-color, primary), - disabled-selected-checkmark-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, on-surface), $alpha: 0.38), - ), ( - // Color variants: - primary: (), // Default, no overrides needed. - secondary: ( - selected-checkmark-color: map.get($systems, md-sys-color, secondary), - ), - tertiary: ( - selected-checkmark-color: map.get($systems, md-sys-color, tertiary), - ), - error: ( - selected-checkmark-color: map.get($systems, md-sys-color, error), - ) - )); -} - -/// Generates custom tokens for mat-checkbox. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of custom tokens for mat-checkbox -@function checkbox($systems, $exclude-hardcoded) { - @return ( - disabled-label-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, on-surface), $alpha: 0.38), - ); -} - - -/// Generates custom tokens for the mat-radio. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of custom tokens for the mat-radio -@function radio($systems, $exclude-hardcoded) { - @return (( - ripple-color: map.get($systems, md-sys-color, on-surface), - checked-ripple-color: map.get($systems, md-sys-color, primary), - disabled-label-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, on-surface), $alpha: 0.38), - ), ( - // Color variants: - primary: (), // Default, no overrides needed - secondary: ( - checked-ripple-color: map.get($systems, md-sys-color, secondary), - ), - tertiary: ( - checked-ripple-color: map.get($systems, md-sys-color, tertiary), - ), - error: ( - checked-ripple-color: map.get($systems, md-sys-color, error), - ), - )); -} - -/// Generates custom tokens for the mat-ripple. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of custom tokens for the mat-ripple -@function ripple($systems, $exclude-hardcoded) { - @return ( - color: sass-utils.safe-color-change(map.get($systems, md-sys-color, on-surface), $alpha: 0.1), - ); -} - -/// Generates custom tokens for the mat-select. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of custom tokens for the mat-select -@function select($systems, $exclude-hardcoded) { - @return (sass-utils.merge-all( - _generate-typography-tokens($systems, trigger-text, body-large), - ( - panel-background-color: map.get($systems, md-sys-color, surface-container), - enabled-trigger-text-color: map.get($systems, md-sys-color, on-surface), - disabled-trigger-text-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, on-surface), $alpha: 0.38), - placeholder-text-color: map.get($systems, md-sys-color, on-surface-variant), - enabled-arrow-color: map.get($systems, md-sys-color, on-surface-variant), - disabled-arrow-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, on-surface), $alpha: 0.38), - focused-arrow-color: map.get($systems, md-sys-color, primary), - invalid-arrow-color: map.get($systems, md-sys-color, error), - container-elevation-shadow: - _hardcode(mdc-elevation.elevation-box-shadow(2), $exclude-hardcoded), - ) - ), ( - // Color variants: - primary: (), // Default, no overrides needed - secondary: ( - focused-arrow-color: map.get($systems, md-sys-color, secondary), - ), - tertiary: ( - focused-arrow-color: map.get($systems, md-sys-color, tertiary), - ), - error: ( - focused-arrow-color: map.get($systems, md-sys-color, error), - ) - )); -} - -/// Generates custom tokens for the mat-sidenav. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of custom tokens for the mat-sidenav -@function sidenav($systems, $exclude-hardcoded) { - @return ( - container-elevation-shadow: _hardcode(none, $exclude-hardcoded), - container-divider-color: _hardcode(transparent, $exclude-hardcoded), - container-width: _hardcode(360px, $exclude-hardcoded), - container-shape: map.get($systems, md-sys-shape, corner-large), - container-background-color: map.get($systems, md-sys-color, surface), - container-text-color: map.get($systems, md-sys-color, on-surface-variant), - content-background-color: map.get($systems, md-sys-color, background), - content-text-color: map.get($systems, md-sys-color, on-background), - scrim-color: sass-utils.safe-color-change( - map.get($systems, md-ref-palette, neutral-variant20), $alpha: 0.4), - ); -} - -/// Generates custom tokens for the mat-slider. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of custom tokens for the mat-slider -@function slider($systems, $exclude-hardcoded) { - @return (( - ripple-color: map.get($systems, md-sys-color, primary), - hover-state-layer-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, primary), $alpha: 0.05), - focus-state-layer-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, primary), $alpha: 0.2), - value-indicator-opacity: _hardcode(1, $exclude-hardcoded), - value-indicator-padding: _hardcode(0, $exclude-hardcoded), - value-indicator-width: _hardcode(28px, $exclude-hardcoded), - value-indicator-height: _hardcode(28px, $exclude-hardcoded), - value-indicator-caret-display: _hardcode(none, $exclude-hardcoded), - value-indicator-border-radius: _hardcode(50% 50% 50% 0, $exclude-hardcoded), - value-indicator-text-transform: _hardcode(rotate(45deg), $exclude-hardcoded), - value-indicator-container-transform: - _hardcode(translateX(-50%) rotate(-45deg), $exclude-hardcoded) - ), ( - // Color variants - primary: (), // Default, no overrides needed - secondary: ( - ripple-color: map.get($systems, md-sys-color, secondary), - hover-state-layer-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, secondary), $alpha: 0.05), - focus-state-layer-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, secondary), $alpha: 0.2), - ), - tertiary: ( - ripple-color: map.get($systems, md-sys-color, tertiary), - hover-state-layer-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, tertiary), $alpha: 0.05), - focus-state-layer-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, tertiary), $alpha: 0.2), - ), - error: ( - ripple-color: map.get($systems, md-sys-color, error), - hover-state-layer-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, error), $alpha: 0.05), - focus-state-layer-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, error), $alpha: 0.2), - ), - )); -} - -/// Generates custom tokens for the mat-slide-toggle. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of custom tokens for the mat-slide-toggle -@function switch($systems, $exclude-hardcoded) { - @return ( - disabled-selected-handle-opacity: _hardcode(1, $exclude-hardcoded), - disabled-unselected-handle-opacity: _hardcode(0.38, $exclude-hardcoded), - unselected-handle-size: _hardcode(16px, $exclude-hardcoded), - selected-handle-size: _hardcode(24px, $exclude-hardcoded), - with-icon-handle-size: _hardcode(24px, $exclude-hardcoded), - pressed-handle-size: _hardcode(28px, $exclude-hardcoded), - selected-handle-horizontal-margin: _hardcode(0 24px, $exclude-hardcoded), - selected-with-icon-handle-horizontal-margin: _hardcode(0 24px, $exclude-hardcoded), - selected-pressed-handle-horizontal-margin: _hardcode(0 22px, $exclude-hardcoded), - unselected-handle-horizontal-margin: _hardcode(0 8px, $exclude-hardcoded), - unselected-with-icon-handle-horizontal-margin: _hardcode(0 4px, $exclude-hardcoded), - unselected-pressed-handle-horizontal-margin: _hardcode(0 2px, $exclude-hardcoded), - // The hidden and visible track represent whichever track is visible or - // hidden in the ui. This could be the .mdc-switch__track :before or - // :after depending on whether the switch is selected or unselected. - // - // The m2 slide-toggle uses transforms to hide & show the tracks while - // the m3 slide-toggle uses opacity. - visible-track-opacity: _hardcode(1, $exclude-hardcoded), - hidden-track-opacity: _hardcode(0, $exclude-hardcoded), - visible-track-transition: _hardcode(opacity 75ms, $exclude-hardcoded), - hidden-track-transition: _hardcode(opacity 75ms, $exclude-hardcoded), - track-outline-width: _hardcode(2px, $exclude-hardcoded), - track-outline-color: map.get($systems, md-sys-color, outline), - selected-track-outline-width: _hardcode(0, $exclude-hardcoded), - disabled-unselected-track-outline-width: _hardcode(2px, $exclude-hardcoded), - disabled-unselected-track-outline-color: map.get($systems, md-sys-color, on-surface), - ), (); -} - -/// Generates custom tokens for the mat-snack-bar. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of custom tokens for the mat-snack-bar -@function snack-bar($systems, $exclude-hardcoded) { - @return ( - button-color: map.get($systems, md-sys-color, inverse-primary), - ); -} - -/// Generates custom tokens for the mat-sort. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of custom tokens for the mat-sort -@function sort($systems, $exclude-hardcoded) { - @return ( - arrow-color: map.get($systems, md-sys-color, on-surface), - ); -} - -/// Generates custom tokens for the mat-stepper. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of custom tokens for the mat-stepper -@function stepper($systems, $exclude-hardcoded) { - @return ( - ( - container-color: map.get($systems, md-sys-color, surface), - line-color: map.get($systems, md-sys-color, outline-variant), - header-hover-state-layer-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, inverse-surface), - $alpha: map.get($systems, md-sys-state, hover-state-layer-opacity) - ), - header-focus-state-layer-color: sass-utils.safe-color-change( - map.get($systems, md-sys-color, inverse-surface), - $alpha: map.get($systems, md-sys-state, focus-state-layer-opacity) - ), - header-label-text-color: map.get($systems, md-sys-color, on-surface-variant), - header-optional-label-text-color: map.get($systems, md-sys-color, on-surface-variant), - header-selected-state-label-text-color: map.get($systems, md-sys-color, on-surface-variant), - header-icon-background-color: map.get($systems, md-sys-color, on-surface-variant), - header-icon-foreground-color: map.get($systems, md-sys-color, surface), - header-edit-state-icon-background-color: map.get($systems, md-sys-color, primary), - header-edit-state-icon-foreground-color: map.get($systems, md-sys-color, on-primary), - header-error-state-label-text-color: map.get($systems, md-sys-color, error), - header-error-state-icon-foreground-color: map.get($systems, md-sys-color, error), - header-error-state-icon-background-color: _hardcode(transparent, $exclude-hardcoded), - container-text-font: map.get($systems, md-sys-typescale, body-medium-font), - header-label-text-font: map.get($systems, md-sys-typescale, title-small-font), - header-label-text-size: map.get($systems, md-sys-typescale, title-small-size), - header-label-text-weight: map.get($systems, md-sys-typescale, title-small-weight), - header-error-state-label-text-size: map.get($systems, md-sys-typescale, title-small-size), - header-focus-state-layer-shape: map.get($systems, md-sys-shape, corner-medium), - header-hover-state-layer-shape: map.get($systems, md-sys-shape, corner-medium), - header-selected-state-label-text-size: map.get($systems, md-sys-typescale, title-small-size), - header-selected-state-label-text-weight: map.get( - $systems, md-sys-typescale, title-small-weight), - header-selected-state-icon-background-color: map.get($systems, md-sys-color, primary), - header-selected-state-icon-foreground-color: map.get($systems, md-sys-color, on-primary), - ), ( - // Color variants - primary: ( - header-edit-state-icon-background-color: map.get($systems, md-sys-color, primary), - header-edit-state-icon-foreground-color: map.get($systems, md-sys-color, on-primary), - header-selected-state-icon-background-color: map.get($systems, md-sys-color, primary), - header-selected-state-icon-foreground-color: map.get($systems, md-sys-color, on-primary), - ), - secondary: ( - header-edit-state-icon-background-color: map.get($systems, md-sys-color, secondary), - header-edit-state-icon-foreground-color: map.get($systems, md-sys-color, on-secondary), - header-selected-state-icon-background-color: map.get($systems, md-sys-color, secondary), - header-selected-state-icon-foreground-color: map.get($systems, md-sys-color, on-secondary), - ), - tertiary: ( - header-edit-state-icon-background-color: map.get($systems, md-sys-color, tertiary), - header-edit-state-icon-foreground-color: map.get($systems, md-sys-color, on-tertiary), - header-selected-state-icon-background-color: map.get($systems, md-sys-color, tertiary), - header-selected-state-icon-foreground-color: map.get($systems, md-sys-color, on-tertiary), - ), - error: ( - header-edit-state-icon-background-color: map.get($systems, md-sys-color, error), - header-edit-state-icon-foreground-color: map.get($systems, md-sys-color, on-error), - header-selected-state-icon-background-color: map.get($systems, md-sys-color, error), - header-selected-state-icon-foreground-color: map.get($systems, md-sys-color, on-error), - ) - ) - ); -} - -/// Generates custom tokens for the mat-tab-header. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of custom tokens for the mat-tab-header -@function tab-header($systems, $exclude-hardcoded) { - @return (sass-utils.merge-all( - _generate-typography-tokens($systems, label-text, title-small), - ( - divider-color: map.get($systems, md-sys-color, surface-variant), - divider-height: _hardcode(1px, $exclude-hardcoded), - disabled-ripple-color: null, // TODO(mmalerba): Figure out correct value. - pagination-icon-color: map.get($systems, md-sys-color, on-surface), - inactive-label-text-color: map.get($systems, md-sys-color, on-surface), - active-label-text-color: map.get($systems, md-sys-color, on-surface), - active-ripple-color: map.get($systems, md-sys-color, on-surface), - inactive-ripple-color: map.get($systems, md-sys-color, on-surface), - inactive-focus-label-text-color: map.get($systems, md-sys-color, on-surface), - inactive-hover-label-text-color: map.get($systems, md-sys-color, on-surface), - active-focus-label-text-color: map.get($systems, md-sys-color, on-surface), - active-hover-label-text-color: map.get($systems, md-sys-color, on-surface), - active-focus-indicator-color: map.get($systems, md-sys-color, primary), - active-hover-indicator-color: map.get($systems, md-sys-color, primary), - ), - ), ( - // Color variants - primary: (), // Default, no overrides needed - secondary: ( - active-focus-indicator-color: map.get($systems, md-sys-color, secondary), - active-hover-indicator-color: map.get($systems, md-sys-color, secondary), - ), - tertiary: ( - active-focus-indicator-color: map.get($systems, md-sys-color, tertiary), - active-hover-indicator-color: map.get($systems, md-sys-color, tertiary), - ), - error: ( - active-focus-indicator-color: map.get($systems, md-sys-color, error), - active-hover-indicator-color: map.get($systems, md-sys-color, error), - ) - )); -} - -/// Generates custom tokens for the mdc-tab-indicator. (MDC has a tab-indicator component, but they -/// seem to have made up the tokens rather than using ones generated from the token database, -/// therefore we need a custom token function for it). -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of custom tokens for the mdc-tab-indicator -@function tab-indicator($systems, $exclude-hardcoded) { - @return (( - active-indicator-height: _hardcode(2px, $exclude-hardcoded), - active-indicator-shape: _hardcode(0, $exclude-hardcoded), - active-indicator-color: map.get($systems, md-sys-color, primary), - ), ( - // Color variants - primary: (), // Default, no overrides needed - secondary: ( - active-indicator-color: map.get($systems, md-sys-color, secondary), - ), - tertiary: ( - active-indicator-color: map.get($systems, md-sys-color, tertiary), - ), - error: ( - active-indicator-color: map.get($systems, md-sys-color, error), - ) - )); -} - -/// Generates custom tokens for the mat-table. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of custom tokens for the mat-table -@function table($systems, $exclude-hardcoded) { - @return sass-utils.merge-all( - _generate-typography-tokens($systems, header-headline, title-small), - _generate-typography-tokens($systems, row-item-label-text, body-medium), - _generate-typography-tokens($systems, footer-supporting-text, body-medium), - ( - row-item-outline-width: _hardcode(1px, $exclude-hardcoded), - background-color: map.get($systems, md-sys-color, surface), - header-headline-color: map.get($systems, md-sys-color, on-surface), - row-item-label-text-color: map.get($systems, md-sys-color, on-surface), - row-item-outline-color: map.get($systems, md-sys-color, outline-variant), - ), - ); -} - -/// Generates custom tokens for the mat-toolbar. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of custom tokens for the mat-toolbar -@function toolbar($systems, $exclude-hardcoded) { - @return sass-utils.merge-all( - _generate-typography-tokens($systems, title-text, title-large), - ( - container-background-color: map.get($systems, md-sys-color, surface), - container-text-color: map.get($systems, md-sys-color, on-surface), - ) - ); -} - -/// Generates custom tokens for the mat-tree. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of custom tokens for the mat-tree -@function tree($systems, $exclude-hardcoded) { - @return ( - container-background-color: map.get($systems, md-sys-color, surface), - node-text-color: map.get($systems, md-sys-color, on-surface), - node-text-font: map.get($systems, md-sys-typescale, body-large-font), - node-text-size: map.get($systems, md-sys-typescale, body-large-size), - node-text-weight: map.get($systems, md-sys-typescale, body-large-weight), - ); -} - -/// Generates custom token overrides for the mdc-checkbox color variants. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of color variant token overrides for the mdc-checkbox -@function mdc-checkbox-color-variants($systems, $exclude-hardcoded) { - @return ( - primary: (), // Default, no overrides needed - secondary: ( - selected-container-color: map.get($systems, md-sys-color, secondary), - selected-focus-container-color: map.get($systems, md-sys-color, secondary), - selected-focus-icon-color: map.get($systems, md-sys-color, on-secondary), - selected-focus-state-layer-color: map.get($systems, md-sys-color, secondary), - selected-hover-container-color: map.get($systems, md-sys-color, secondary), - selected-hover-icon-color: map.get($systems, md-sys-color, on-secondary), - selected-hover-state-layer-color: map.get($systems, md-sys-color, secondary), - selected-icon-color: map.get($systems, md-sys-color, on-secondary), - selected-pressed-container-color: map.get($systems, md-sys-color, secondary), - selected-pressed-icon-color: map.get($systems, md-sys-color, on-secondary), - unselected-pressed-state-layer-color: map.get($systems, md-sys-color, secondary), - ), - tertiary: ( - selected-container-color: map.get($systems, md-sys-color, tertiary), - selected-focus-container-color: map.get($systems, md-sys-color, tertiary), - selected-focus-icon-color: map.get($systems, md-sys-color, on-tertiary), - selected-focus-state-layer-color: map.get($systems, md-sys-color, tertiary), - selected-hover-container-color: map.get($systems, md-sys-color, tertiary), - selected-hover-icon-color: map.get($systems, md-sys-color, on-tertiary), - selected-hover-state-layer-color: map.get($systems, md-sys-color, tertiary), - selected-icon-color: map.get($systems, md-sys-color, on-tertiary), - selected-pressed-container-color: map.get($systems, md-sys-color, tertiary), - selected-pressed-icon-color: map.get($systems, md-sys-color, on-tertiary), - unselected-pressed-state-layer-color: map.get($systems, md-sys-color, tertiary), - ), - error: ( - selected-container-color: map.get($systems, md-sys-color, error), - selected-focus-container-color: map.get($systems, md-sys-color, error), - selected-focus-icon-color: map.get($systems, md-sys-color, on-error), - selected-focus-state-layer-color: map.get($systems, md-sys-color, error), - selected-hover-container-color: map.get($systems, md-sys-color, error), - selected-hover-icon-color: map.get($systems, md-sys-color, on-error), - selected-hover-state-layer-color: map.get($systems, md-sys-color, error), - selected-icon-color: map.get($systems, md-sys-color, on-error), - selected-pressed-container-color: map.get($systems, md-sys-color, error), - selected-pressed-icon-color: map.get($systems, md-sys-color, on-error), - unselected-pressed-state-layer-color: map.get($systems, md-sys-color, error), - ) - ); -} - -/// Generates custom token overrides for the mdc-slider color variants. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of color variant token overrides for the mdc-slider -@function mdc-slider-color-variants($systems, $exclude-hardcoded) { - @return ( - primary: (), // Default, no overrides needed - secondary: ( - active-track-color: map.get($systems, md-sys-color, secondary), - focus-handle-color: map.get($systems, md-sys-color, secondary), - focus-state-layer-color: map.get($systems, md-sys-color, secondary), - handle-color: map.get($systems, md-sys-color, secondary), - hover-handle-color: map.get($systems, md-sys-color, secondary), - hover-state-layer-color: map.get($systems, md-sys-color, secondary), - label-container-color: map.get($systems, md-sys-color, secondary), - label-label-text-color: map.get($systems, md-sys-color, on-secondary), - pressed-handle-color: map.get($systems, md-sys-color, secondary), - pressed-state-layer-color: map.get($systems, md-sys-color, secondary), - with-overlap-handle-outline-color: map.get($systems, md-sys-color, on-secondary), - with-tick-marks-active-container-color: map.get($systems, md-sys-color, on-secondary), - ), - tertiary: ( - active-track-color: map.get($systems, md-sys-color, tertiary), - focus-handle-color: map.get($systems, md-sys-color, tertiary), - focus-state-layer-color: map.get($systems, md-sys-color, tertiary), - handle-color: map.get($systems, md-sys-color, tertiary), - hover-handle-color: map.get($systems, md-sys-color, tertiary), - hover-state-layer-color: map.get($systems, md-sys-color, tertiary), - label-container-color: map.get($systems, md-sys-color, tertiary), - label-label-text-color: map.get($systems, md-sys-color, on-tertiary), - pressed-handle-color: map.get($systems, md-sys-color, tertiary), - pressed-state-layer-color: map.get($systems, md-sys-color, tertiary), - with-overlap-handle-outline-color: map.get($systems, md-sys-color, on-tertiary), - with-tick-marks-active-container-color: map.get($systems, md-sys-color, on-tertiary), - ), - error: ( - active-track-color: map.get($systems, md-sys-color, error), - focus-handle-color: map.get($systems, md-sys-color, error), - focus-state-layer-color: map.get($systems, md-sys-color, error), - handle-color: map.get($systems, md-sys-color, error), - hover-handle-color: map.get($systems, md-sys-color, error), - hover-state-layer-color: map.get($systems, md-sys-color, error), - label-container-color: map.get($systems, md-sys-color, error), - label-label-text-color: map.get($systems, md-sys-color, on-error), - pressed-handle-color: map.get($systems, md-sys-color, error), - pressed-state-layer-color: map.get($systems, md-sys-color, error), - with-overlap-handle-outline-color: map.get($systems, md-sys-color, on-error), - with-tick-marks-active-container-color: map.get($systems, md-sys-color, on-error), - ), - ); -} - -/// Generates custom token overrides for the mdc-switch color variants. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of color variant token overrides for the mdc-switch -@function mdc-switch-color-variants($systems, $exclude-hardcoded) { - @return ( - primary: (), // Default, no overrides needed - secondary: ( - selected-focus-handle-color: map.get($systems, md-sys-color, secondary-container), - selected-focus-icon-color: map.get($systems, md-sys-color, on-secondary-container), - selected-focus-state-layer-color: map.get($systems, md-sys-color, secondary), - selected-focus-track-color: map.get($systems, md-sys-color, secondary), - selected-handle-color: map.get($systems, md-sys-color, on-secondary), - selected-hover-handle-color: map.get($systems, md-sys-color, secondary-container), - selected-hover-icon-color: map.get($systems, md-sys-color, on-secondary-container), - selected-hover-state-layer-color: map.get($systems, md-sys-color, secondary), - selected-hover-track-color: map.get($systems, md-sys-color, secondary), - selected-icon-color: map.get($systems, md-sys-color, on-secondary-container), - selected-pressed-handle-color: map.get($systems, md-sys-color, secondary-container), - selected-pressed-icon-color: map.get($systems, md-sys-color, on-secondary-container), - selected-pressed-state-layer-color: map.get($systems, md-sys-color, secondary), - selected-pressed-track-color: map.get($systems, md-sys-color, secondary), - selected-track-color: map.get($systems, md-sys-color, secondary), - ), - tertiary: ( - selected-focus-handle-color: map.get($systems, md-sys-color, tertiary-container), - selected-focus-icon-color: map.get($systems, md-sys-color, on-tertiary-container), - selected-focus-state-layer-color: map.get($systems, md-sys-color, tertiary), - selected-focus-track-color: map.get($systems, md-sys-color, tertiary), - selected-handle-color: map.get($systems, md-sys-color, on-tertiary), - selected-hover-handle-color: map.get($systems, md-sys-color, tertiary-container), - selected-hover-icon-color: map.get($systems, md-sys-color, on-tertiary-container), - selected-hover-state-layer-color: map.get($systems, md-sys-color, tertiary), - selected-hover-track-color: map.get($systems, md-sys-color, tertiary), - selected-icon-color: map.get($systems, md-sys-color, on-tertiary-container), - selected-pressed-handle-color: map.get($systems, md-sys-color, tertiary-container), - selected-pressed-icon-color: map.get($systems, md-sys-color, on-tertiary-container), - selected-pressed-state-layer-color: map.get($systems, md-sys-color, tertiary), - selected-pressed-track-color: map.get($systems, md-sys-color, tertiary), - selected-track-color: map.get($systems, md-sys-color, tertiary), - ), - error: ( - selected-focus-handle-color: map.get($systems, md-sys-color, error-container), - selected-focus-icon-color: map.get($systems, md-sys-color, on-error-container), - selected-focus-state-layer-color: map.get($systems, md-sys-color, error), - selected-focus-track-color: map.get($systems, md-sys-color, error), - selected-handle-color: map.get($systems, md-sys-color, on-error), - selected-hover-handle-color: map.get($systems, md-sys-color, error-container), - selected-hover-icon-color: map.get($systems, md-sys-color, on-error-container), - selected-hover-state-layer-color: map.get($systems, md-sys-color, error), - selected-hover-track-color: map.get($systems, md-sys-color, error), - selected-icon-color: map.get($systems, md-sys-color, on-error-container), - selected-pressed-handle-color: map.get($systems, md-sys-color, error-container), - selected-pressed-icon-color: map.get($systems, md-sys-color, on-error-container), - selected-pressed-state-layer-color: map.get($systems, md-sys-color, error), - selected-pressed-track-color: map.get($systems, md-sys-color, error), - selected-track-color: map.get($systems, md-sys-color, error), - ), - ); -} - -/// Generates custom token overrides for the mdc-radio color variants. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of color variant token overrides for the mdc-radio -@function mdc-radio-color-variants($systems, $exclude-hardcoded) { - @return ( - primary: (), // Default, no overrides needed - secondary: ( - selected-focus-icon-color: map.get($systems, md-sys-color, secondary), - selected-focus-state-layer-color: map.get($systems, md-sys-color, secondary), - selected-hover-icon-color: map.get($systems, md-sys-color, secondary), - selected-hover-state-layer-color: map.get($systems, md-sys-color, secondary), - selected-icon-color: map.get($systems, md-sys-color, secondary), - selected-pressed-icon-color: map.get($systems, md-sys-color, secondary), - unselected-pressed-state-layer-color: map.get($systems, md-sys-color, secondary), - ), - tertiary: ( - selected-focus-icon-color: map.get($systems, md-sys-color, tertiary), - selected-focus-state-layer-color: map.get($systems, md-sys-color, tertiary), - selected-hover-icon-color: map.get($systems, md-sys-color, tertiary), - selected-hover-state-layer-color: map.get($systems, md-sys-color, tertiary), - selected-icon-color: map.get($systems, md-sys-color, tertiary), - selected-pressed-icon-color: map.get($systems, md-sys-color, tertiary), - unselected-pressed-state-layer-color: map.get($systems, md-sys-color, tertiary), - ), - error: ( - selected-focus-icon-color: map.get($systems, md-sys-color, error), - selected-focus-state-layer-color: map.get($systems, md-sys-color, error), - selected-hover-icon-color: map.get($systems, md-sys-color, error), - selected-hover-state-layer-color: map.get($systems, md-sys-color, error), - selected-icon-color: map.get($systems, md-sys-color, error), - selected-pressed-icon-color: map.get($systems, md-sys-color, error), - unselected-pressed-state-layer-color: map.get($systems, md-sys-color, error), - ), - ); -} - -/// Generates custom token overrides for the mdc-circular-progress color variants. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of color variant token overrides for the mdc-circular-progress -@function mdc-circular-progress-color-variants($systems, $exclude-hardcoded) { - @return ( - primary: (), // Default, no overrides needed - secondary: ( - active-indicator-color: map.get($systems, md-sys-color, secondary), - ), - tertiary: ( - active-indicator-color: map.get($systems, md-sys-color, tertiary), - ), - error: ( - active-indicator-color: map.get($systems, md-sys-color, error), - ) - ); -} - -/// Generates custom token overrides for the mdc-linear-progress color variants. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of color variant token overrides for the mdc-linear-progress -@function mdc-linear-progress-color-variants($systems, $exclude-hardcoded) { - @return ( - primary: (), // Default, no overrides needed - secondary: ( - active-indicator-color: map.get($systems, md-sys-color, secondary), - track-color: map.get($systems, md-sys-color, secondary-container), - ), - tertiary: ( - active-indicator-color: map.get($systems, md-sys-color, tertiary), - track-color: map.get($systems, md-sys-color, tertiary-container), - ), - error: ( - active-indicator-color: map.get($systems, md-sys-color, error), - track-color: map.get($systems, md-sys-color, error-container), - ), - ); -} - -/// Generates custom token overrides for the mdc-filled-form-field color variants. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of color variant token overrides for the mdc-filled-form-field -@function mdc-filled-text-field-color-variants($systems, $exclude-hardcoded) { - @return ( - primary: (), // Default, no overrides needed - secondary: ( - caret-color: map.get($systems, md-sys-color, secondary), - focus-active-indicator-color: map.get($systems, md-sys-color, secondary), - focus-label-text-color: map.get($systems, md-sys-color, secondary), - ), - tertiary: ( - caret-color: map.get($systems, md-sys-color, tertiary), - focus-active-indicator-color: map.get($systems, md-sys-color, tertiary), - focus-label-text-color: map.get($systems, md-sys-color, tertiary), - ), - error: ( - caret-color: map.get($systems, md-sys-color, error), - focus-active-indicator-color: map.get($systems, md-sys-color, error), - focus-label-text-color: map.get($systems, md-sys-color, error), - ), - ); -} - -/// Generates custom token overrides for the mdc-outlined-form-field color variants. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of color variant token overrides for the mdc-outlined-form-field -@function mdc-outlined-text-field-color-variants($systems, $exclude-hardcoded) { - @return ( - primary: (), // Default, no overrides needed - secondary: ( - caret-color: map.get($systems, md-sys-color, secondary), - focus-label-text-color: map.get($systems, md-sys-color, secondary), - focus-outline-color: map.get($systems, md-sys-color, secondary), - ), - tertiary: ( - caret-color: map.get($systems, md-sys-color, tertiary), - focus-label-text-color: map.get($systems, md-sys-color, tertiary), - focus-outline-color: map.get($systems, md-sys-color, tertiary), - ), - error: ( - caret-color: map.get($systems, md-sys-color, error), - focus-label-text-color: map.get($systems, md-sys-color, error), - focus-outline-color: map.get($systems, md-sys-color, error), - ), - ); -} - -/// Generates custom token overrides for the mdc-text-button color variants. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of color variant token overrides for the mdc-text-button -@function mdc-text-button-color-variants($systems, $exclude-hardcoded) { - @return ( - primary: (), // Default, no overrides needed. - secondary: ( - focus-label-text-color: map.get($systems, md-sys-color, secondary), - focus-state-layer-color: map.get($systems, md-sys-color, secondary), - hover-label-text-color: map.get($systems, md-sys-color, secondary), - hover-state-layer-color: map.get($systems, md-sys-color, secondary), - label-text-color: map.get($systems, md-sys-color, secondary), - pressed-label-text-color: map.get($systems, md-sys-color, secondary), - pressed-state-layer-color: map.get($systems, md-sys-color, secondary), - with-icon-focus-icon-color: map.get($systems, md-sys-color, secondary), - with-icon-hover-icon-color: map.get($systems, md-sys-color, secondary), - with-icon-icon-color: map.get($systems, md-sys-color, secondary), - with-icon-pressed-icon-color: map.get($systems, md-sys-color, secondary) - ), - tertiary: ( - focus-label-text-color: map.get($systems, md-sys-color, tertiary), - focus-state-layer-color: map.get($systems, md-sys-color, tertiary), - hover-label-text-color: map.get($systems, md-sys-color, tertiary), - hover-state-layer-color: map.get($systems, md-sys-color, tertiary), - label-text-color: map.get($systems, md-sys-color, tertiary), - pressed-label-text-color: map.get($systems, md-sys-color, tertiary), - pressed-state-layer-color: map.get($systems, md-sys-color, tertiary), - with-icon-focus-icon-color: map.get($systems, md-sys-color, tertiary), - with-icon-hover-icon-color: map.get($systems, md-sys-color, tertiary), - with-icon-icon-color: map.get($systems, md-sys-color, tertiary), - with-icon-pressed-icon-color: map.get($systems, md-sys-color, tertiary) - ), - error: ( - focus-label-text-color: map.get($systems, md-sys-color, error), - focus-state-layer-color: map.get($systems, md-sys-color, error), - hover-label-text-color: map.get($systems, md-sys-color, error), - hover-state-layer-color: map.get($systems, md-sys-color, error), - label-text-color: map.get($systems, md-sys-color, error), - pressed-label-text-color: map.get($systems, md-sys-color, error), - pressed-state-layer-color: map.get($systems, md-sys-color, error), - with-icon-focus-icon-color: map.get($systems, md-sys-color, error), - with-icon-hover-icon-color: map.get($systems, md-sys-color, error), - with-icon-icon-color: map.get($systems, md-sys-color, error), - with-icon-pressed-icon-color: map.get($systems, md-sys-color, error) - ) - ); -} - -/// Generates custom token overrides for the mdc-elevated-button color variants. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of color variant token overrides for the mdc-elevated-button -@function mdc-elevated-button-color-variants($systems, $exclude-hardcoded) { - @return ( - primary: (), // Default, no overrides needed. - secondary: ( - focus-label-text-color: map.get($systems, md-sys-color, secondary), - focus-state-layer-color: map.get($systems, md-sys-color, secondary), - hover-label-text-color: map.get($systems, md-sys-color, secondary), - hover-state-layer-color: map.get($systems, md-sys-color, secondary), - label-text-color: map.get($systems, md-sys-color, secondary), - pressed-label-text-color: map.get($systems, md-sys-color, secondary), - pressed-state-layer-color: map.get($systems, md-sys-color, secondary), - with-icon-focus-icon-color: map.get($systems, md-sys-color, secondary), - with-icon-hover-icon-color: map.get($systems, md-sys-color, secondary), - with-icon-icon-color: map.get($systems, md-sys-color, secondary), - with-icon-pressed-icon-color: map.get($systems, md-sys-color, secondary) - ), - tertiary: ( - focus-label-text-color: map.get($systems, md-sys-color, tertiary), - focus-state-layer-color: map.get($systems, md-sys-color, tertiary), - hover-label-text-color: map.get($systems, md-sys-color, tertiary), - hover-state-layer-color: map.get($systems, md-sys-color, tertiary), - label-text-color: map.get($systems, md-sys-color, tertiary), - pressed-label-text-color: map.get($systems, md-sys-color, tertiary), - pressed-state-layer-color: map.get($systems, md-sys-color, tertiary), - with-icon-focus-icon-color: map.get($systems, md-sys-color, tertiary), - with-icon-hover-icon-color: map.get($systems, md-sys-color, tertiary), - with-icon-icon-color: map.get($systems, md-sys-color, tertiary), - with-icon-pressed-icon-color: map.get($systems, md-sys-color, tertiary) - ), - error: ( - focus-label-text-color: map.get($systems, md-sys-color, error), - focus-state-layer-color: map.get($systems, md-sys-color, error), - hover-label-text-color: map.get($systems, md-sys-color, error), - hover-state-layer-color: map.get($systems, md-sys-color, error), - label-text-color: map.get($systems, md-sys-color, error), - pressed-label-text-color: map.get($systems, md-sys-color, error), - pressed-state-layer-color: map.get($systems, md-sys-color, error), - with-icon-focus-icon-color: map.get($systems, md-sys-color, error), - with-icon-hover-icon-color: map.get($systems, md-sys-color, error), - with-icon-icon-color: map.get($systems, md-sys-color, error), - with-icon-pressed-icon-color: map.get($systems, md-sys-color, error) - ) - ); -} - -/// Generates custom token overrides for the mdc-filled-button color variants. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of color variant token overrides for the mdc-filled-button -@function mdc-filled-button-color-variants($systems, $exclude-hardcoded) { - @return ( - primary: (), // Default, no overrides needed. - secondary: ( - container-color: map.get($systems, md-sys-color, secondary), - focus-label-text-color: map.get($systems, md-sys-color, on-secondary), - focus-state-layer-color: map.get($systems, md-sys-color, on-secondary), - hover-label-text-color: map.get($systems, md-sys-color, on-secondary), - hover-state-layer-color: map.get($systems, md-sys-color, on-secondary), - label-text-color: map.get($systems, md-sys-color, on-secondary), - pressed-label-text-color: map.get($systems, md-sys-color, on-secondary), - pressed-state-layer-color: map.get($systems, md-sys-color, on-secondary), - with-icon-focus-icon-color: map.get($systems, md-sys-color, on-secondary), - with-icon-hover-icon-color: map.get($systems, md-sys-color, on-secondary), - with-icon-icon-color: map.get($systems, md-sys-color, on-secondary), - with-icon-pressed-icon-color: map.get($systems, md-sys-color, on-secondary) - ), - tertiary: ( - container-color: map.get($systems, md-sys-color, tertiary), - focus-label-text-color: map.get($systems, md-sys-color, on-tertiary), - focus-state-layer-color: map.get($systems, md-sys-color, on-tertiary), - hover-label-text-color: map.get($systems, md-sys-color, on-tertiary), - hover-state-layer-color: map.get($systems, md-sys-color, on-tertiary), - label-text-color: map.get($systems, md-sys-color, on-tertiary), - pressed-label-text-color: map.get($systems, md-sys-color, on-tertiary), - pressed-state-layer-color: map.get($systems, md-sys-color, on-tertiary), - with-icon-focus-icon-color: map.get($systems, md-sys-color, on-tertiary), - with-icon-hover-icon-color: map.get($systems, md-sys-color, on-tertiary), - with-icon-icon-color: map.get($systems, md-sys-color, on-tertiary), - with-icon-pressed-icon-color: map.get($systems, md-sys-color, on-tertiary) - ), - error: ( - container-color: map.get($systems, md-sys-color, error), - focus-label-text-color: map.get($systems, md-sys-color, on-error), - focus-state-layer-color: map.get($systems, md-sys-color, on-error), - hover-label-text-color: map.get($systems, md-sys-color, on-error), - hover-state-layer-color: map.get($systems, md-sys-color, on-error), - label-text-color: map.get($systems, md-sys-color, on-error), - pressed-label-text-color: map.get($systems, md-sys-color, on-error), - pressed-state-layer-color: map.get($systems, md-sys-color, on-error), - with-icon-focus-icon-color: map.get($systems, md-sys-color, on-error), - with-icon-hover-icon-color: map.get($systems, md-sys-color, on-error), - with-icon-icon-color: map.get($systems, md-sys-color, on-error), - with-icon-pressed-icon-color: map.get($systems, md-sys-color, on-error) - ) - ); -} - -/// Generates custom token overrides for the mdc-outlined-button color variants. -/// @param {Map} $systems The MDC system tokens -/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values -/// @return {Map} A set of color variant token overrides for the mdc-outlined-button -@function mdc-outlined-button-color-variants($systems, $exclude-hardcoded) { - @return ( - primary: (), // Default, no overrides needed. - secondary: ( - focus-label-text-color: map.get($systems, md-sys-color, secondary), - focus-outline-color: map.get($systems, md-sys-color, secondary), - focus-state-layer-color: map.get($systems, md-sys-color, secondary), - hover-label-text-color: map.get($systems, md-sys-color, secondary), - hover-state-layer-color: map.get($systems, md-sys-color, secondary), - label-text-color: map.get($systems, md-sys-color, secondary), - pressed-label-text-color: map.get($systems, md-sys-color, secondary), - pressed-state-layer-color: map.get($systems, md-sys-color, secondary), - with-icon-focus-icon-color: map.get($systems, md-sys-color, secondary), - with-icon-hover-icon-color: map.get($systems, md-sys-color, secondary), - with-icon-icon-color: map.get($systems, md-sys-color, secondary), - with-icon-pressed-icon-color: map.get($systems, md-sys-color, secondary) - ), - tertiary: ( - focus-label-text-color: map.get($systems, md-sys-color, tertiary), - focus-outline-color: map.get($systems, md-sys-color, tertiary), - focus-state-layer-color: map.get($systems, md-sys-color, tertiary), - hover-label-text-color: map.get($systems, md-sys-color, tertiary), - hover-state-layer-color: map.get($systems, md-sys-color, tertiary), - label-text-color: map.get($systems, md-sys-color, tertiary), - pressed-label-text-color: map.get($systems, md-sys-color, tertiary), - pressed-state-layer-color: map.get($systems, md-sys-color, tertiary), - with-icon-focus-icon-color: map.get($systems, md-sys-color, tertiary), - with-icon-hover-icon-color: map.get($systems, md-sys-color, tertiary), - with-icon-icon-color: map.get($systems, md-sys-color, tertiary), - with-icon-pressed-icon-color: map.get($systems, md-sys-color, tertiary) - ), - error: ( - focus-label-text-color: map.get($systems, md-sys-color, error), - focus-outline-color: map.get($systems, md-sys-color, error), - focus-state-layer-color: map.get($systems, md-sys-color, error), - hover-label-text-color: map.get($systems, md-sys-color, error), - hover-state-layer-color: map.get($systems, md-sys-color, error), - label-text-color: map.get($systems, md-sys-color, error), - pressed-label-text-color: map.get($systems, md-sys-color, error), - pressed-state-layer-color: map.get($systems, md-sys-color, error), - with-icon-focus-icon-color: map.get($systems, md-sys-color, error), - with-icon-hover-icon-color: map.get($systems, md-sys-color, error), - with-icon-icon-color: map.get($systems, md-sys-color, error), - with-icon-pressed-icon-color: map.get($systems, md-sys-color, error) - ) - ); -} - diff --git a/src/material/core/tokens/_m3-tokens.scss b/src/material/core/tokens/_m3-tokens.scss index ec42918d3c5f..f8aa47040666 100644 --- a/src/material/core/tokens/_m3-tokens.scss +++ b/src/material/core/tokens/_m3-tokens.scss @@ -1,102 +1,12 @@ -@use 'sass:list'; @use 'sass:map'; -@use 'sass:meta'; @use '@material/tokens/v0_161' as mdc-tokens; @use '../style/sass-utils'; @use '../m2' as m2-theming; +@use './m3'; @use '../tokens/m2' as m2-tokens; @use './density'; -@use './custom-tokens'; @use './format-tokens'; -// TODO(mmalerba): Split up this file into smaller pieces. - -/// Maps the values in a map to new values using the given mapping function -/// @param {Map} $map The maps whose values will be mapped to new values. -/// @param {Function} $fn The value mapping function. -/// @param {Map} A new map with its values updated using the mapping function. -@function _map-values($map, $fn) { - $result: (); - @each $key, $value in $map { - $result: map.set($result, $key, meta.call($fn, $value)); - } - @return $result; -} - -/// Picks a submap containing only the given keys out the given map. -/// @param {Map} $map The map to pick from. -/// @param {List} $keys The map keys to pick. -/// @return {Map} A submap containing only the given keys. -@function _pick($map, $keys) { - $result: (); - @each $key in $keys { - @if map.has-key($map, $key) { - $result: map.set($result, $key, map.get($map, $key)); - } - } - @return $result; -} - -/// Filters keys with a null value out of the map. -/// @param {Map} $map The map to filter. -/// @return {Map} The given map with all of the null keys filtered out. -@function _filter-nulls($map) { - $result: (); - @each $key, $val in $map { - @if $val != null { - $result: map.set($result, $key, $val); - } - } - @return $result; -} - -/// Renames the keys in a map -/// @param {Map} $map The map whose keys should be renamed -/// @param {Map} $rename-keys A map of original key to renamed key to apply to $map -/// @return {Map} The result of applying the given key renames to the given map. -@function _rename-map-keys($map, $rename-keys) { - $result: $map; - @each $old-key-name, $new-key-name in $rename-keys { - @if map.has-key($map, $old-key-name) { - $result: map.set($result, $new-key-name, map.get($map, $old-key-name)); - } - } - @return $result; -} - -/// Gets the MDC tokens for the given prefix, M3 token values, and supported token slots. -/// @param {List} $prefix The token prefix for the given tokens. -/// @param {Map|(Map, Map)} $values A map of M3 token values for the given prefix. -/// This param may also be a tuple of maps, the first one representing the default M3 token values, -// and the second containing overrides for different color variants. -// Single map example: -// (token1: green, token2: 2px) -// Tuple example: -// ( -// (token1: green, token2: 2px), -// ( -// secondary: (token1: blue), -// error: (token1: red), -// ) -// ) -/// @param {Map} $slots A map of token slots, with null value indicating the token is not supported. -/// @param {String|null} $variant The name of the variant the token values are for. -/// @return {Map} A map of fully qualified token names to values, for only the supported tokens. -@function _namespace-tokens($prefix, $values, $slots, $variant: null) { - $result: (); - @if $variant == null and meta.type-of($values) == 'list' and list.length($values == 2) { - $variants: list.nth($values, 2); - $values: list.nth($values, 1); - @each $variant, $overrides in $variants { - $result: map.merge($result, _namespace-tokens($prefix, $overrides, $slots, $variant)); - } - } - $used-token-names: map.keys(_filter-nulls(map.get($slots, $prefix))); - $used-m3-tokens: _pick(_filter-nulls($values), $used-token-names); - $prefix: if($variant == null, $prefix, list.append($prefix, $variant)); - @return map.merge($result, ($prefix: $used-m3-tokens)); -} - /// Generates tokens for the given palette with the given prefix. /// @param {Map} $palette The palette to generate tokens for /// @param {String} $prefix The key prefix used to name the tokens @@ -147,348 +57,6 @@ ); } -/// At the time of writing, some color tokens (e.g. disabled state) are defined as a solid color -/// token and a separate opacity token. This function applies the opacity to the color and drops the -/// opacity key from the map. Can be removed once b/213331407 is resolved. -/// @param {Map} $tokens The map of tokens currently being generated -/// @param {Map} $all-tokens A map of all tokens, including hardcoded values -/// @param {List} $pairs Pairs of color token names and their opacities. Should be in the shape of -/// `((color: 'color-key', opacity: 'opacity-key'))`. -/// @return {Map} The initial tokens with the combined color values. -@function _combine-color-tokens($tokens, $opacity-lookup, $pairs) { - $result: $tokens; - - @each $pair in $pairs { - $color-key: map.get($pair, color); - $opacity-key: map.get($pair, opacity); - $color: map.get($tokens, $color-key); - $opacity: map.get($opacity-lookup, $opacity-key); - - @if(meta.type-of($color) == 'color') { - $result: map.remove($result, $opacity-key); - $result: map.set($result, $color-key, rgba($color, $opacity)); - } - @else if($color != null) { - $result: map.remove($result, $opacity-key); - $combined-color: #{color-mix(in srgb, #{$color} #{($opacity * 100) + '%'}, transparent)}; - $result: map.set($result, $color-key, $combined-color); - } - } - - @return $result; -} - -/// Renames the official checkbox tokens to match the names actually used in MDC's code (which are -/// different). This is a temporary workaround until MDC updates to use the correct names for the -/// tokens. -/// @param {Map} $tokens The map of checkbox tokens with the official tokens names -/// @param {Map} $all-tokens Map of all checkbox tokens, including hardcoded values. -/// This is necessary in order to do opacity lookups. -/// @return {Map} The given tokens, renamed to be compatible with MDC's token implementation. -@function _fix-checkbox-tokens($tokens) { - // Need to get the hardcoded values, because they include opacities that are used for the disabled - // state. - $hardcoded-tokens: mdc-tokens.md-comp-checkbox-values((), false); - - $rename-keys: ( - selected-icon-color: selected-checkmark-color, - selected-disabled-icon-color: disabled-selected-checkmark-color, - selected-container-color: selected-icon-color, - selected-hover-container-color: selected-hover-icon-color, - selected-disabled-container-color: disabled-selected-icon-color, - selected-disabled-container-opacity: disabled-selected-icon-opacity, - selected-focus-container-color: selected-focus-icon-color, - selected-pressed-container-color: selected-pressed-icon-color, - unselected-disabled-outline-color: disabled-unselected-icon-color, - unselected-disabled-container-opacity: disabled-unselected-icon-opacity, - unselected-focus-outline-color: unselected-focus-icon-color, - unselected-hover-outline-color: unselected-hover-icon-color, - unselected-outline-color: unselected-icon-color, - unselected-pressed-outline-color: unselected-pressed-icon-color - ); - - $remapped-tokens: _rename-map-keys($tokens, $rename-keys); - $remapped-hardcoded-tokens: _rename-map-keys($hardcoded-tokens, $rename-keys); - - @return _combine-color-tokens($remapped-tokens, $remapped-hardcoded-tokens, ( - ( - color: disabled-selected-icon-color, - opacity: disabled-selected-icon-opacity, - ), - ( - color: disabled-unselected-icon-color, - opacity: disabled-unselected-icon-opacity, - ), - )); -} - -/// Fixes inconsistent values in the filled text field tokens so that they can produce valid -/// styles. -/// @param {Map} $initial-tokens Map of filled text field tokens currently being generated. -/// @return {Map} The given tokens, with the invalid values replaced with valid ones. -@function _fix-filled-text-field-tokens($initial-tokens) { - // Need to get the hardcoded values, because they include opacities that are used for the disabled - // state. - $hardcoded-tokens: mdc-tokens.md-comp-filled-text-field-values((), false); - - $tokens: _combine-color-tokens($initial-tokens, $hardcoded-tokens, ( - ( - color: disabled-active-indicator-color, - opacity: disabled-active-indicator-opacity - ), - ( - color: disabled-container-color, - opacity: disabled-container-opacity - ), - ( - color: disabled-input-text-color, - opacity: disabled-input-text-opacity - ), - ( - color: disabled-label-text-color, - opacity: disabled-label-text-opacity - ), - ( - color: disabled-leading-icon-color, - opacity: disabled-leading-icon-opacity - ), - ( - color: disabled-supporting-text-color, - opacity: disabled-supporting-text-opacity - ), - ( - color: disabled-trailing-icon-color, - opacity: disabled-trailing-icon-opacity - ) - )); - - $container-shape: map.get($tokens, container-shape); - - // The M2 token slots define a single `container-shape` slot while the M3 tokens provide a list - // of shapes (e.g. top/bottom/left/right). Extract the first value so it matches the expected - // token slot in M2. - @if meta.type-of($container-shape) == 'list' { - $tokens: map.set($tokens, container-shape, list.nth($container-shape, 1)); - } - - @return $tokens; -} - - -/// Fixes inconsistent values in the text button tokens so that they can produce valid styles. -/// @param {Map} $initial-tokens Map of text button tokens currently being generated. -/// @return {Map} The given tokens, with the invalid values replaced with valid ones. -@function _fix-text-button-tokens($initial-tokens) { - // Need to get the hardcoded values, because they include opacities that are used for the disabled - // state. - $hardcoded-tokens: mdc-tokens.md-comp-text-button-values((), false); - - @return _combine-color-tokens($initial-tokens, $hardcoded-tokens, ( - ( - color: disabled-label-text-color, - opacity: disabled-label-text-opacity, - ), - )); -} - -/// Fixes inconsistent values in the filled button tokens so that they can produce valid styles. -/// @param {Map} $initial-tokens Map of filled button tokens currently being generated. -/// @return {Map} The given tokens, with the invalid values replaced with valid ones. -@function _fix-filled-button-tokens($initial-tokens) { - // Need to get the hardcoded values, because they include opacities that are used for the disabled - // state. - $hardcoded-tokens: mdc-tokens.md-comp-filled-button-values((), false); - - @return _combine-color-tokens($initial-tokens, $hardcoded-tokens, ( - ( - color: disabled-label-text-color, - opacity: disabled-label-text-opacity, - ), - ( - color: disabled-container-color, - opacity: disabled-container-opacity, - ) - )); -} - -/// Fixes inconsistent values in the protected button tokens so that they can produce valid styles. -/// @param {Map} $initial-tokens Map of protected button tokens currently being generated. -/// @return {Map} The given tokens, with the invalid values replaced with valid ones. -@function _fix-protected-button-tokens($initial-tokens) { - // Need to get the hardcoded values, because they include opacities that are used for the disabled - // state. - $hardcoded-tokens: mdc-tokens.md-comp-elevated-button-values((), false); - - @return _combine-color-tokens($initial-tokens, $hardcoded-tokens, ( - ( - color: disabled-label-text-color, - opacity: disabled-label-text-opacity, - ), - ( - color: disabled-container-color, - opacity: disabled-container-opacity, - ) - )); -} - -/// Fixes inconsistent values in the outlined button tokens so that they can produce valid styles. -/// @param {Map} $initial-tokens Map of outlined button tokens currently being generated. -/// @return {Map} The given tokens, with the invalid values replaced with valid ones. -@function _fix-outlined-button-tokens($initial-tokens) { - $hardcoded-tokens: mdc-tokens.md-comp-outlined-button-values((), false); - - @return _combine-color-tokens($initial-tokens, $hardcoded-tokens, ( - ( - color: disabled-label-text-color, - opacity: disabled-label-text-opacity, - ), - ( - color: disabled-outline-color, - opacity: disabled-outline-opacity, - ) - )); -} - -/// Fixes inconsistent values in the outlined text field tokens so that they can produce valid -/// styles. -/// @param {Map} $initial-tokens Map of outlined text field tokens currently being generated. -/// @param {Map} $all-tokens Map of all outlined text field tokens, including hardcoded values. -/// This is necessary in order to do opacity lookups. -/// @return {Map} The given tokens, with the invalid values replaced with valid ones. -@function _fix-outlined-text-field-tokens($initial-tokens) { - // Need to get the hardcoded values, because they include opacities that are used for the disabled - // state. - $hardcoded-tokens: mdc-tokens.md-comp-outlined-text-field-values((), false); - - @return _combine-color-tokens($initial-tokens, $hardcoded-tokens, ( - ( - color: disabled-outline-color, - opacity: disabled-outline-opacity - ), - ( - color: disabled-active-indicator-color, - opacity: disabled-active-indicator-opacity - ), - ( - color: disabled-container-color, - opacity: disabled-container-opacity - ), - ( - color: disabled-input-text-color, - opacity: disabled-input-text-opacity - ), - ( - color: disabled-label-text-color, - opacity: disabled-label-text-opacity - ), - ( - color: disabled-leading-icon-color, - opacity: disabled-leading-icon-opacity - ), - ( - color: disabled-supporting-text-color, - opacity: disabled-supporting-text-opacity - ), - ( - color: disabled-trailing-icon-color, - opacity: disabled-trailing-icon-opacity - ) - )); -} - -/// Gets the token values for the MDC form field. -/// @param {Map} $systems The MDC system tokens. -/// @return {Map} The form field tokens. -@function _get-form-field-tokens($systems) { - @return ( - // TODO: MDC currently doesn't provide tokens for the form field so we need to - // define them ourselves. Clean this up once b/246297033 is resolved. - label-text-color: map.get($systems, 'md-sys-color', 'on-surface'), - label-text-font: map.get($systems, 'md-sys-typescale', 'body-medium-font'), - label-text-line-height: map.get($systems, 'md-sys-typescale', 'body-medium-line-height'), - label-text-size: map.get($systems, 'md-sys-typescale', 'body-medium-size'), - label-text-tracking: map.get($systems, 'md-sys-typescale', 'body-medium-tracking'), - label-text-weight: map.get($systems, 'md-sys-typescale', 'body-medium-weight'), - ); -} - -/// Fixes inconsistent values in the icon button tokens so that they can produce valid styles. -/// @param {Map} $initial-tokens Map of icon button tokens currently being generated. -/// @param {Map} $all-tokens Map of all icon button tokens, including hardcoded values. -/// @return {Map} The given tokens, with the invalid values replaced with valid ones. -@function _fix-icon-button-tokens($tokens) { - // Need to get the hardcoded values, because they include opacities that are used for the disabled - // state. - $hardcoded-tokens: mdc-tokens.md-comp-icon-button-values((), false); - - $rename-keys: ( - unselected-icon-color: icon-color, - ); - - $remapped-tokens: _rename-map-keys($tokens, $rename-keys); - $remapped-hardcoded-tokens: _rename-map-keys($hardcoded-tokens, $rename-keys); - - @return _combine-color-tokens($remapped-tokens, $remapped-hardcoded-tokens, ( - ( - color: disabled-icon-color, - opacity: disabled-icon-opacity, - ), - )); -} - -/// Fixes inconsistent values in the dialog tokens so that they can produce valid styles. -/// @param {Map} $initial-tokens Map of dialog tokens currently being generated. -/// @param {Map} $all-tokens Map of all dialog tokens, including hardcoded values. -/// @return {Map} The given tokens, with the invalid values replaced with valid ones. -@function _fix-dialog-tokens($systems, $tokens) { - $tokens: _rename-map-keys($tokens, ( - headline-color: subhead-color, - headline-font: subhead-font, - headline-line-height: subhead-line-height, - headline-size: subhead-size, - headline-tracking: subhead-tracking, - headline-weight: subhead-weight, - )); - - @if map.get($tokens, container-elevation) != null { - $tokens: map.merge($tokens, ( - // The spec has the dialog at an elevation of 3 which is consistent with the current - // version of the tokens (0_161), however both the designs and MDC's implementation - // have the elevation set to 0. Set it manually to 0 here since the value in the - // exported tokens is likely outdated. - container-elevation: 0, - - // This color needs to be supplied for MDC to produce the shadow. Technically we don't - // have to provide it since the elevation is set to 0 above, but we do it in case - // the value changes in the future. - container-shadow-color: #000, - )); - } - - @return $tokens; -} - -/// Fixes values in the list tokens that are inconsistent with its usage. -/// @param {Map} $initial-tokens Map of list tokens currently being generated. -/// @return {Map} The given tokens, with the inconsistent values replaced with valid ones. -@function _fix-list-tokens($tokens) { - // This does not match the spec, which defines this to be `md.sys.color.surface`. - // However, this interferes with the use case of placing a list on other components. For example, - // the bottom sheet's container color is `md.sys.color.surface-container-low`. Instead, allow the - // list to just display the colors for its background. - @if map.get($tokens, list-item-container-color) != null { - $tokens: map.set($tokens, list-item-container-color, transparent); - } - - // Match spec, which has list-item-leading-icon-size of 24px. Current version of tokens (0_161) - // has 18px. - @if map.get($tokens, list-item-leading-icon-size) != null { - $tokens: map.set($tokens, list-item-leading-icon-size, 24px); - } - - @return $tokens; -} - /// Generates a set of namespaced tokens for all components. /// @param {Map} $systems The MDC system tokens /// @param {Boolean} $include-non-systemized Whether to include non-systemized tokens @@ -529,447 +97,7 @@ (mdc, theme): map.get($systems, md-sys-color), (mdc, typography): map.get($systems, md-sys-typescale), ), - // Get the official MDC component tokens - _namespace-tokens( - (mdc, checkbox), - ( - _fix-checkbox-tokens(mdc-tokens.md-comp-checkbox-values($systems, $exclude-hardcoded)), - _map-values( - custom-tokens.mdc-checkbox-color-variants($systems, $exclude-hardcoded), - meta.get-function(_fix-checkbox-tokens) - ) - ), - $token-slots - ), - _namespace-tokens( - (mdc, chip), - custom-tokens.mdc-chip($systems, $exclude-hardcoded), - $token-slots - ), - _namespace-tokens( - (mdc, circular-progress), - ( - mdc-tokens.md-comp-circular-progress-indicator-values($systems, $exclude-hardcoded), - custom-tokens.mdc-circular-progress-color-variants($systems, $exclude-hardcoded), - ), - $token-slots - ), - _namespace-tokens( - (mdc, dialog), - _fix-dialog-tokens($systems, mdc-tokens.md-comp-dialog-values($systems, $exclude-hardcoded)), - $token-slots - ), - _namespace-tokens( - (mdc, elevated-card), - mdc-tokens.md-comp-elevated-card-values($systems, $exclude-hardcoded), - $token-slots - ), - _namespace-tokens( - (mdc, fab), - ( - mdc-tokens.md-comp-fab-primary-values($systems, $exclude-hardcoded), - ( - // Color variants - primary: (), // Default, no overrides needed. - secondary: mdc-tokens.md-comp-fab-secondary-values($systems, $exclude-hardcoded), - tertiary: mdc-tokens.md-comp-fab-tertiary-values($systems, $exclude-hardcoded) - ) - ), - $token-slots - ), - _namespace-tokens( - (mdc, fab-small), - ( - mdc-tokens.md-comp-fab-primary-small-values($systems, $exclude-hardcoded), - ( - // Color variants - primary: (), // Default, no overrides needed. - secondary: mdc-tokens.md-comp-fab-secondary-small-values($systems, $exclude-hardcoded), - tertiary: mdc-tokens.md-comp-fab-tertiary-small-values($systems, $exclude-hardcoded) - ) - ), - $token-slots - ), - _namespace-tokens( - (mdc, extended-fab), - ( - mdc-tokens.md-comp-extended-fab-primary-values($systems, $exclude-hardcoded), - ( - // Color variants - primary: (), // Default, no overrides needed. - secondary: mdc-tokens.md-comp-extended-fab-secondary-values($systems, $exclude-hardcoded), - tertiary: mdc-tokens.md-comp-extended-fab-tertiary-values($systems, $exclude-hardcoded) - ), - ), - $token-slots - ), - _namespace-tokens( - (mdc, filled-text-field), - ( - _fix-filled-text-field-tokens( - mdc-tokens.md-comp-filled-text-field-values($systems, $exclude-hardcoded) - ), - _map-values( - custom-tokens.mdc-filled-text-field-color-variants($systems, $exclude-hardcoded), - meta.get-function(_fix-filled-text-field-tokens) - ) - ), - $token-slots - ), - _namespace-tokens( - (mdc, form-field), - _get-form-field-tokens($systems), - $token-slots - ), - _namespace-tokens( - (mdc, icon-button), - _fix-icon-button-tokens(mdc-tokens.md-comp-icon-button-values($systems, $exclude-hardcoded)), - $token-slots - ), - _namespace-tokens( - (mdc, text-button), - ( - _fix-text-button-tokens( - mdc-tokens.md-comp-text-button-values($systems, $exclude-hardcoded) - ), - _map-values( - custom-tokens.mdc-text-button-color-variants($systems, $exclude-hardcoded), - meta.get-function(_fix-text-button-tokens) - ) - ), - $token-slots - ), - _namespace-tokens( - // Note: in M3 the "protected" button is called "elevated". - (mdc, protected-button), - ( - _fix-protected-button-tokens( - mdc-tokens.md-comp-elevated-button-values($systems, $exclude-hardcoded) - ), - _map-values( - custom-tokens.mdc-elevated-button-color-variants($systems, $exclude-hardcoded), - meta.get-function(_fix-protected-button-tokens) - ) - ), - $token-slots - ), - _namespace-tokens( - (mdc, filled-button), - ( - _fix-filled-button-tokens( - mdc-tokens.md-comp-filled-button-values($systems, $exclude-hardcoded), - ), - _map-values( - custom-tokens.mdc-filled-button-color-variants($systems, $exclude-hardcoded), - meta.get-function(_fix-filled-button-tokens) - ) - ), - $token-slots - ), - _namespace-tokens( - (mdc, outlined-button), - ( - _fix-outlined-button-tokens( - mdc-tokens.md-comp-outlined-button-values($systems, $exclude-hardcoded), - ), - _map-values( - custom-tokens.mdc-outlined-button-color-variants($systems, $exclude-hardcoded), - meta.get-function(_fix-outlined-button-tokens) - ) - ), - $token-slots - ), - _namespace-tokens( - (mdc, linear-progress), - ( - mdc-tokens.md-comp-linear-progress-indicator-values($systems, $exclude-hardcoded), - custom-tokens.mdc-linear-progress-color-variants($systems, $exclude-hardcoded), - ), - $token-slots - ), - _namespace-tokens( - (mdc, list), - _fix-list-tokens( - mdc-tokens.md-comp-list-values($systems, $exclude-hardcoded) - ), - $token-slots - ), - _namespace-tokens( - (mdc, outlined-card), - mdc-tokens.md-comp-outlined-card-values($systems, $exclude-hardcoded), - $token-slots - ), - _namespace-tokens( - (mdc, outlined-text-field), - ( - _fix-outlined-text-field-tokens( - mdc-tokens.md-comp-outlined-text-field-values($systems, $exclude-hardcoded) - ), - _map-values( - custom-tokens.mdc-outlined-text-field-color-variants($systems, $exclude-hardcoded), - meta.get-function(_fix-outlined-text-field-tokens) - ) - ), - $token-slots - ), - _namespace-tokens( - (mdc, plain-tooltip), - mdc-tokens.md-comp-plain-tooltip-values($systems, $exclude-hardcoded), - $token-slots - ), - _namespace-tokens( - (mdc, radio), - ( - mdc-tokens.md-comp-radio-button-values($systems, $exclude-hardcoded), - custom-tokens.mdc-radio-color-variants($systems, $exclude-hardcoded) - ), - $token-slots - ), - _namespace-tokens( - (mdc, slider), - ( - mdc-tokens.md-comp-slider-values($systems, $exclude-hardcoded), - custom-tokens.mdc-slider-color-variants($systems, $exclude-hardcoded) - ), - $token-slots - ), - _namespace-tokens( - (mdc, snackbar), - mdc-tokens.md-comp-snackbar-values($systems, $exclude-hardcoded), - $token-slots, - ), - _namespace-tokens( - (mdc, switch), - ( - mdc-tokens.md-comp-switch-values($systems, $exclude-hardcoded), - custom-tokens.mdc-switch-color-variants($systems, $exclude-hardcoded) - ), - $token-slots - ), - _namespace-tokens( - (mdc, tab), - mdc-tokens.md-comp-secondary-navigation-tab-values($systems, $exclude-hardcoded), - $token-slots - ), - - // Choose values for our made up tokens based on MDC system tokens or sensible hardcoded - // values. - _namespace-tokens( - (mat, app), - custom-tokens.app($systems, $exclude-hardcoded), - $token-slots - ), - _namespace-tokens( - (mdc, tab-indicator), - custom-tokens.tab-indicator($systems, $exclude-hardcoded), - $token-slots - ), - _namespace-tokens( - (mat, autocomplete), - custom-tokens.autocomplete($systems, $exclude-hardcoded), - $token-slots - ), - _namespace-tokens( - (mat, badge), - custom-tokens.badge($systems, $exclude-hardcoded), - $token-slots - ), - _namespace-tokens( - (mat, bottom-sheet), - custom-tokens.bottom-sheet($systems, $exclude-hardcoded), - $token-slots - ), - _namespace-tokens( - (mat, card), - custom-tokens.card($systems, $exclude-hardcoded), - $token-slots - ), - _namespace-tokens( - (mat, chip), - custom-tokens.chip($systems, $exclude-hardcoded), - $token-slots - ), - _namespace-tokens( - (mat, datepicker), - custom-tokens.datepicker($systems, $exclude-hardcoded), - $token-slots - ), - _namespace-tokens( - (mat, dialog), - custom-tokens.dialog($systems, $exclude-hardcoded), - $token-slots - ), - _namespace-tokens( - (mat, divider), - custom-tokens.divider($systems, $exclude-hardcoded), - $token-slots - ), - _namespace-tokens( - (mat, fab), - custom-tokens.fab($systems, $exclude-hardcoded), - $token-slots - ), - _namespace-tokens( - (mat, fab-small), - custom-tokens.fab-small($systems, $exclude-hardcoded), - $token-slots - ), - _namespace-tokens( - (mat, form-field), - custom-tokens.form-field($systems, $exclude-hardcoded), - $token-slots - ), - _namespace-tokens( - (mat, expansion), - custom-tokens.expansion($systems, $exclude-hardcoded), - $token-slots - ), - _namespace-tokens( - (mat, grid-list), - custom-tokens.grid-list($systems, $exclude-hardcoded), - $token-slots - ), - _namespace-tokens( - (mat, icon), - custom-tokens.icon($systems, $exclude-hardcoded), - $token-slots - ), - _namespace-tokens( - (mat, text-button), - custom-tokens.text-button($systems, $exclude-hardcoded), - $token-slots - ), - _namespace-tokens( - (mat, filled-button), - custom-tokens.filled-button($systems, $exclude-hardcoded), - $token-slots - ), - _namespace-tokens( - (mat, list), - custom-tokens.list($systems, $exclude-hardcoded), - $token-slots - ), - _namespace-tokens( - // Note: in M3 the "protected" button is called "elevated". - (mat, protected-button), - custom-tokens.elevated-button($systems, $exclude-hardcoded), - $token-slots - ), - _namespace-tokens( - (mat, outlined-button), - custom-tokens.outlined-button($systems, $exclude-hardcoded), - $token-slots - ), - _namespace-tokens( - (mat, icon-button), - custom-tokens.icon-button($systems, $exclude-hardcoded), - $token-slots - ), - _namespace-tokens( - (mat, menu), - custom-tokens.menu($systems, $exclude-hardcoded), - $token-slots - ), - _namespace-tokens( - (mat, optgroup), - custom-tokens.optgroup($systems, $exclude-hardcoded), - $token-slots - ), - _namespace-tokens( - (mat, option), - custom-tokens.option($systems, $exclude-hardcoded), - $token-slots - ), - _namespace-tokens( - (mat, paginator), - custom-tokens.paginator($systems, $exclude-hardcoded), - $token-slots - ), - _namespace-tokens( - (mat, full-pseudo-checkbox), - custom-tokens.full-pseudo-checkbox($systems, $exclude-hardcoded), - $token-slots - ), - _namespace-tokens( - (mat, minimal-pseudo-checkbox), - custom-tokens.minimal-pseudo-checkbox($systems, $exclude-hardcoded), - $token-slots - ), - _namespace-tokens( - (mat, checkbox), - custom-tokens.checkbox($systems, $exclude-hardcoded), - $token-slots - ), - _namespace-tokens( - (mat, radio), - custom-tokens.radio($systems, $exclude-hardcoded), - $token-slots - ), - _namespace-tokens( - (mat, ripple), - custom-tokens.ripple($systems, $exclude-hardcoded), - $token-slots - ), - _namespace-tokens( - (mat, select), - custom-tokens.select($systems, $exclude-hardcoded), - $token-slots - ), - _namespace-tokens( - (mat, sidenav), - custom-tokens.sidenav($systems, $exclude-hardcoded), - $token-slots - ), - _namespace-tokens( - (mat, slider), - custom-tokens.slider($systems, $exclude-hardcoded), - $token-slots - ), - _namespace-tokens( - (mat, snack-bar), - custom-tokens.snack-bar($systems, $exclude-hardcoded), - $token-slots - ), - _namespace-tokens( - (mat, sort), - custom-tokens.sort($systems, $exclude-hardcoded), - $token-slots - ), - _namespace-tokens( - (mat, standard-button-toggle), - custom-tokens.button-toggle($systems, $exclude-hardcoded), - $token-slots - ), - _namespace-tokens( - (mat, stepper), - custom-tokens.stepper($systems, $exclude-hardcoded), - $token-slots - ), - _namespace-tokens( - (mat, switch), - custom-tokens.switch($systems, $exclude-hardcoded), - $token-slots - ), - _namespace-tokens( - (mat, tab-header), - custom-tokens.tab-header($systems, $exclude-hardcoded), - $token-slots - ), - _namespace-tokens( - (mat, table), - custom-tokens.table($systems, $exclude-hardcoded), - $token-slots - ), - _namespace-tokens( - (mat, toolbar), - custom-tokens.toolbar($systems, $exclude-hardcoded), - $token-slots, - ), - _namespace-tokens( - (mat, tree), - custom-tokens.tree($systems, $exclude-hardcoded), - $token-slots - ), + m3.get-m3-tokens($systems, $exclude-hardcoded, $token-slots), ); // Strip out tokens that are systemized by our made up density system. diff --git a/src/material/core/tokens/_token-utils.scss b/src/material/core/tokens/_token-utils.scss index 7dd35dd31856..d537d3667ce0 100644 --- a/src/material/core/tokens/_token-utils.scss +++ b/src/material/core/tokens/_token-utils.scss @@ -1,9 +1,11 @@ @use 'sass:list'; @use 'sass:map'; +@use 'sass:meta'; @use '@material/elevation/elevation-theme' as mdc-elevation-theme; @use '@material/theme/custom-properties' as mdc-custom-properties; @use '@material/theme/theme' as mdc-theme; @use '@material/theme/keys' as mdc-keys; +@use '@material/tokens/v0_161' as mdc-tokens; @use '../style/sass-utils'; @use '../m2/palette' as m2-palette; @use '../m2/theming' as m2-theming; @@ -141,6 +143,17 @@ $_component-prefix: null; } } +/// Gets all the MDC token values for a specific component. This function serves as single +/// point at which we directly reference a specific version of the MDC tokens. +/// @param {String} $component Name of the component for which to get the tokens +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @return {List} Map of token names to values +@function get-mdc-tokens($component, $systems, $exclude-hardcoded) { + $fn: meta.get-function($name: 'md-comp-' + $component + '-values', $module: 'mdc-tokens'); + @return meta.call($fn, $systems, $exclude-hardcoded); +} + // MDC doesn't currently handle elevation tokens properly. As a temporary workaround we can combine // the elevation and shadow-color tokens into a full box-shadow and use it as the value for the // elevation token. @@ -234,6 +247,116 @@ $_component-prefix: null; } } +/// Gets the MDC tokens for the given prefix, M3 token values, and supported token slots. +/// @param {List} $prefix The token prefix for the given tokens. +/// @param {Map|(Map, Map)} $values A map of M3 token values for the given prefix. +/// This param may also be a tuple of maps, the first one representing the default M3 token values, +// and the second containing overrides for different color variants. +// Single map example: +// (token1: green, token2: 2px) +// Tuple example: +// ( +// (token1: green, token2: 2px), +// ( +// secondary: (token1: blue), +// error: (token1: red), +// ) +// ) +/// @param {Map} $slots A map of token slots, with null value indicating the token is not supported. +/// @param {String|null} $variant The name of the variant the token values are for. +/// @return {Map} A map of fully qualified token names to values, for only the supported tokens. +@function namespace-tokens($prefix, $values, $slots, $variant: null) { + $result: (); + @if $variant == null and meta.type-of($values) == 'list' and list.length($values == 2) { + $variants: list.nth($values, 2); + $values: list.nth($values, 1); + @each $variant, $overrides in $variants { + $result: map.merge($result, namespace-tokens($prefix, $overrides, $slots, $variant)); + } + } + $used-token-names: map.keys(_filter-nulls(map.get($slots, $prefix))); + $used-m3-tokens: _pick(_filter-nulls($values), $used-token-names); + $prefix: if($variant == null, $prefix, list.append($prefix, $variant)); + @return map.merge($result, ($prefix: $used-m3-tokens)); +} + +/// Hardcode the given value, or null if hardcoded values are excluded. +@function hardcode($value, $exclude-hardcoded) { + @return if($exclude-hardcoded, null, $value); +} + +/// Sets all of the standard typography tokens for the given token base name to the given typography +/// level. +/// @param {Map} $systems The MDC system tokens +/// @param {String} $base-name The token base name to get the typography tokens for +/// @param {String} $typography-level The typography level to base the token values on +/// @return {Map} A map containing the typography tokens for the given base token name +@function generate-typography-tokens($systems, $base-name, $typography-level) { + $result: (); + @each $prop in (font, line-height, size, tracking, weight) { + $result: map.set($result, #{$base-name}-#{$prop}, + map.get($systems, md-sys-typescale, #{$typography-level}-#{$prop})); + } + @return $result; +} + +/// Maps the values in a map to new values using the given mapping function +/// @param {Map} $map The maps whose values will be mapped to new values. +/// @param {Function} $fn The value mapping function. +/// @param {Map} A new map with its values updated using the mapping function. +@function map-values($map, $fn) { + $result: (); + @each $key, $value in $map { + $result: map.set($result, $key, meta.call($fn, $value)); + } + @return $result; +} + +/// Renames the keys in a map +/// @param {Map} $map The map whose keys should be renamed +/// @param {Map} $rename-keys A map of original key to renamed key to apply to $map +/// @return {Map} The result of applying the given key renames to the given map. +@function rename-map-keys($map, $rename-keys) { + $result: $map; + @each $old-key-name, $new-key-name in $rename-keys { + @if map.has-key($map, $old-key-name) { + $result: map.set($result, $new-key-name, map.get($map, $old-key-name)); + } + } + @return $result; +} + +/// At the time of writing, some color tokens (e.g. disabled state) are defined as a solid color +/// token and a separate opacity token. This function applies the opacity to the color and drops the +/// opacity key from the map. Can be removed once b/213331407 is resolved. +/// @param {Map} $tokens The map of tokens currently being generated +/// @param {Map} $all-tokens A map of all tokens, including hardcoded values +/// @param {List} $pairs Pairs of color token names and their opacities. Should be in the shape of +/// `((color: 'color-key', opacity: 'opacity-key'))`. +/// @return {Map} The initial tokens with the combined color values. +@function combine-color-tokens($tokens, $opacity-lookup, $pairs) { + $result: $tokens; + + @each $pair in $pairs { + $color-key: map.get($pair, color); + $opacity-key: map.get($pair, opacity); + $color: map.get($tokens, $color-key); + $opacity: map.get($opacity-lookup, $opacity-key); + + @if(meta.type-of($color) == 'color') { + $result: map.remove($result, $opacity-key); + $result: map.set($result, $color-key, rgba($color, $opacity)); + } + @else if($color != null) { + $result: map.remove($result, $opacity-key); + $combined-color: #{color-mix(in srgb, #{$color} #{($opacity * 100) + '%'}, transparent)}; + $result: map.set($result, $color-key, $combined-color); + } + } + + @return $result; +} + /// Verifies that the token overrides exist and are used in one of the given token maps. @mixin _validate-token-overrides($overrides: (), $token-maps) { $valid-token-names: (); @@ -255,3 +378,31 @@ $_component-prefix: null; } } } + +/// Picks a submap containing only the given keys out the given map. +/// @param {Map} $map The map to pick from. +/// @param {List} $keys The map keys to pick. +/// @return {Map} A submap containing only the given keys. +@function _pick($map, $keys) { + $result: (); + @each $key in $keys { + @if map.has-key($map, $key) { + $result: map.set($result, $key, map.get($map, $key)); + } + } + @return $result; +} + + +/// Filters keys with a null value out of the map. +/// @param {Map} $map The map to filter. +/// @return {Map} The given map with all of the null keys filtered out. +@function _filter-nulls($map) { + $result: (); + @each $key, $val in $map { + @if $val != null { + $result: map.set($result, $key, $val); + } + } + @return $result; +} diff --git a/src/material/core/tokens/m3/_index.scss b/src/material/core/tokens/m3/_index.scss new file mode 100644 index 000000000000..fcf86dffd366 --- /dev/null +++ b/src/material/core/tokens/m3/_index.scss @@ -0,0 +1,161 @@ +@use 'sass:meta'; +@use 'sass:map'; +@use './mat/app' as tokens-mat-app; +@use './mat/autocomplete' as tokens-mat-autocomplete; +@use './mat/badge' as tokens-mat-badge; +@use './mat/text-button' as tokens-mat-text-button; +@use './mat/protected-button' as tokens-mat-protected-button; +@use './mat/filled-button' as tokens-mat-filled-button; +@use './mat/outlined-button' as tokens-mat-outlined-button; +@use './mat/dialog' as tokens-mat-dialog; +@use './mat/bottom-sheet' as tokens-mat-bottom-sheet; +@use './mat/card' as tokens-mat-card; +@use './mat/chip' as tokens-mat-chip; +@use './mat/datepicker' as tokens-mat-datepicker; +@use './mat/divider' as tokens-mat-divider; +@use './mat/expansion' as tokens-mat-expansion; +@use './mat/fab' as tokens-mat-fab; +@use './mat/fab-small' as tokens-mat-fab-small; +@use './mat/form-field' as tokens-mat-form-field; +@use './mat/grid-list' as tokens-mat-grid-list; +@use './mat/icon' as tokens-mat-icon; +@use './mat/icon-button' as tokens-mat-icon-button; +@use './mat/list' as tokens-mat-list; +@use './mat/menu' as tokens-mat-menu; +@use './mat/option' as tokens-mat-option; +@use './mat/optgroup' as tokens-mat-optgroup; +@use './mat/paginator' as tokens-mat-paginator; +@use './mat/checkbox' as tokens-mat-checkbox; +@use './mat/full-pseudo-checkbox' as tokens-mat-full-pseudo-checkbox; +@use './mat/minimal-pseudo-checkbox' as tokens-mat-minimal-pseudo-checkbox; +@use './mat/radio' as tokens-mat-radio; +@use './mat/ripple' as tokens-mat-ripple; +@use './mat/select' as tokens-mat-select; +@use './mat/sidenav' as tokens-mat-sidenav; +@use './mat/slider' as tokens-mat-slider; +@use './mat/switch' as tokens-mat-switch; +@use './mat/snack-bar' as tokens-mat-snack-bar; +@use './mat/sort' as tokens-mat-sort; +@use './mat/standard-button-toggle' as tokens-mat-button-toggle; +@use './mat/stepper' as tokens-mat-stepper; +@use './mat/tab-header' as tokens-mat-tab-header; +@use './mat/table' as tokens-mat-table; +@use './mat/toolbar' as tokens-mat-toolbar; +@use './mat/tree' as tokens-mat-tree; +@use './mdc/checkbox' as tokens-mdc-checkbox; +@use './mdc/text-button' as tokens-mdc-text-button; +@use './mdc/protected-button' as tokens-mdc-protected-button; +@use './mdc/filled-button' as tokens-mdc-filled-button; +@use './mdc/outlined-button' as tokens-mdc-outlined-button; +@use './mdc/chip' as tokens-mdc-chip; +@use './mdc/circular-progress' as tokens-mdc-circular-progress; +@use './mdc/dialog' as tokens-mdc-dialog; +@use './mdc/elevated-card' as tokens-mdc-elevated-card; +@use './mdc/extended-fab' as tokens-mdc-extended-fab; +@use './mdc/fab' as tokens-mdc-fab; +@use './mdc/fab-small' as tokens-mdc-fab-small; +@use './mdc/form-field' as tokens-mdc-form-field; +@use './mdc/filled-text-field' as tokens-mdc-filled-text-field; +@use './mdc/icon-button' as tokens-mdc-icon-button; +@use './mdc/linear-progress' as tokens-mdc-linear-progress; +@use './mdc/list' as tokens-mdc-list; +@use './mdc/outlined-card' as tokens-mdc-outlined-card; +@use './mdc/outlined-text-field' as tokens-mdc-outlined-text-field; +@use './mdc/plain-tooltip' as tokens-mdc-plain-tooltip; +@use './mdc/radio' as tokens-mdc-radio; +@use './mdc/slider' as tokens-mdc-slider; +@use './mdc/snack-bar' as tokens-mdc-snack-bar; +@use './mdc/switch' as tokens-mdc-switch; +@use './mdc/tab' as tokens-mdc-tab; +@use './mdc/tab-indicator' as tokens-mdc-tab-indicator; + +$_module-names: ( + // Custom tokens + tokens-mat-app, + tokens-mat-autocomplete, + tokens-mat-badge, + tokens-mat-bottom-sheet, + tokens-mat-button-toggle, + tokens-mat-card, + tokens-mat-chip, + tokens-mat-datepicker, + tokens-mat-dialog, + tokens-mat-divider, + tokens-mat-expansion, + tokens-mat-fab, + tokens-mat-fab-small, + tokens-mat-filled-button, + tokens-mat-form-field, + tokens-mat-grid-list, + tokens-mat-icon-button, + tokens-mat-icon, + tokens-mat-menu, + tokens-mat-optgroup, + tokens-mat-option, + tokens-mat-outlined-button, + tokens-mat-paginator, + tokens-mat-checkbox, + tokens-mat-full-pseudo-checkbox, + tokens-mat-list, + tokens-mat-minimal-pseudo-checkbox, + tokens-mat-protected-button, + tokens-mat-radio, + tokens-mat-ripple, + tokens-mat-select, + tokens-mat-sidenav, + tokens-mat-slider, + tokens-mat-switch, + tokens-mat-snack-bar, + tokens-mat-sort, + tokens-mat-stepper, + tokens-mat-tab-header, + tokens-mat-table, + tokens-mat-text-button, + tokens-mat-toolbar, + tokens-mat-tree, + + // MDC tokens + tokens-mdc-checkbox, + tokens-mdc-chip, + tokens-mdc-text-button, + tokens-mdc-protected-button, + tokens-mdc-filled-button, + tokens-mdc-outlined-button, + tokens-mdc-chip, + tokens-mdc-circular-progress, + tokens-mdc-dialog, + tokens-mdc-elevated-card, + tokens-mdc-extended-fab, + tokens-mdc-fab, + tokens-mdc-fab-small, + tokens-mdc-form-field, + tokens-mdc-filled-text-field, + tokens-mdc-icon-button, + tokens-mdc-linear-progress, + tokens-mdc-list, + tokens-mdc-outlined-card, + tokens-mdc-outlined-text-field, + tokens-mdc-plain-tooltip, + tokens-mdc-radio, + tokens-mdc-slider, + tokens-mdc-snack-bar, + tokens-mdc-switch, + tokens-mdc-tab, + tokens-mdc-tab-indicator, +); + +/// Gets the full set of M3 tokens for the given theme object. +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} Full set of M3 tokens +@function get-m3-tokens($systems, $exclude-hardcoded, $token-slots) { + $tokens: (); + + @each $module-name in $_module-names { + $fn: meta.get-function($name: 'get-tokens', $module: $module-name); + $tokens: map.merge($tokens, meta.call($fn, $systems, $exclude-hardcoded, $token-slots)); + } + + @return $tokens; +} diff --git a/src/material/core/tokens/m3/mat/_app.scss b/src/material/core/tokens/m3/mat/_app.scss new file mode 100644 index 000000000000..879fdc9570ad --- /dev/null +++ b/src/material/core/tokens/m3/mat/_app.scss @@ -0,0 +1,19 @@ +@use 'sass:map'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mat, app); + +/// Generates custom tokens for the app. +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of custom tokens for the app +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $tokens: ( + background-color: map.get($systems, md-sys-color, background), + text-color: map.get($systems, md-sys-color, on-background), + ); + + @return token-utils.namespace-tokens($prefix, $tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mat/_autocomplete.scss b/src/material/core/tokens/m3/mat/_autocomplete.scss new file mode 100644 index 000000000000..485e452f4275 --- /dev/null +++ b/src/material/core/tokens/m3/mat/_autocomplete.scss @@ -0,0 +1,22 @@ +@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. +$prefix: (mat, autocomplete); + +/// Generates custom tokens for the mat-autocomplete. +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of custom tokens for the mat-autocomplete +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $tokens: ( + background-color: map.get($systems, md-sys-color, surface-container), + container-shape: map.get($systems, md-sys-shape, corner-extra-small), + container-elevation-shadow: + token-utils.hardcode(mdc-elevation.elevation-box-shadow(2), $exclude-hardcoded), + ); + + @return token-utils.namespace-tokens($prefix, $tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mat/_badge.scss b/src/material/core/tokens/m3/mat/_badge.scss new file mode 100644 index 000000000000..65d974b226a7 --- /dev/null +++ b/src/material/core/tokens/m3/mat/_badge.scss @@ -0,0 +1,77 @@ +@use 'sass:map'; +@use '../../../style/sass-utils'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mat, badge); + +/// Generates custom tokens for the mat-badge. +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of custom tokens for the mat-badge +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $tokens: (( + background-color: map.get($systems, md-sys-color, error), + text-color: map.get($systems, md-sys-color, on-error), + disabled-state-background-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, error), + $alpha: 0.38, + ), + disabled-state-text-color: map.get($systems, md-sys-color, on-error), + text-font: map.get($systems, md-sys-typescale, label-small-font), + text-size: map.get($systems, md-sys-typescale, label-small-size), + text-weight: map.get($systems, md-sys-typescale, label-small-weight), + small-size-text-size: token-utils.hardcode(0, $exclude-hardcoded), + container-shape: map.get($systems, md-sys-shape, corner-full), + container-size: token-utils.hardcode(16px, $exclude-hardcoded), + legacy-container-size: token-utils.hardcode(unset, $exclude-hardcoded), + legacy-small-size-container-size: token-utils.hardcode(unset, $exclude-hardcoded), + small-size-container-size: token-utils.hardcode(6px, $exclude-hardcoded), + container-padding: token-utils.hardcode(0 4px, $exclude-hardcoded), + small-size-container-padding: token-utils.hardcode(0, $exclude-hardcoded), + container-offset: token-utils.hardcode(-12px 0, $exclude-hardcoded), + small-size-container-offset: token-utils.hardcode(-6px 0, $exclude-hardcoded), + container-overlap-offset: token-utils.hardcode(-12px, $exclude-hardcoded), + small-size-container-overlap-offset: token-utils.hardcode(-6px, $exclude-hardcoded), + + // This size isn't in the M3 spec so we emit the same values as for `medium`. + large-size-container-size: token-utils.hardcode(16px, $exclude-hardcoded), + large-size-container-offset: token-utils.hardcode(-12px 0, $exclude-hardcoded), + large-size-container-overlap-offset: token-utils.hardcode(-12px, $exclude-hardcoded), + large-size-text-size: map.get($systems, md-sys-typescale, label-small-size), + large-size-container-padding: token-utils.hardcode(0 4px, $exclude-hardcoded), + legacy-large-size-container-size: token-utils.hardcode(unset, $exclude-hardcoded), + ), ( + primary: ( + background-color: map.get($systems, md-sys-color, primary), + text-color: map.get($systems, md-sys-color, on-primary), + disabled-state-background-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, primary), + $alpha: 0.38, + ), + disabled-state-text-color: map.get($systems, md-sys-color, on-primary), + ), + secondary: ( + background-color: map.get($systems, md-sys-color, secondary), + text-color: map.get($systems, md-sys-color, on-secondary), + disabled-state-background-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, secondary), + $alpha: 0.38, + ), + disabled-state-text-color: map.get($systems, md-sys-color, on-secondary), + ), + tertiary: ( + background-color: map.get($systems, md-sys-color, tertiary), + text-color: map.get($systems, md-sys-color, on-tertiary), + disabled-state-background-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, tertiary), + $alpha: 0.38, + ), + disabled-state-text-color: map.get($systems, md-sys-color, on-tertiary), + ), + error: () // Default, no overrides needed + )); + + @return token-utils.namespace-tokens($prefix, $tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mat/_bottom-sheet.scss b/src/material/core/tokens/m3/mat/_bottom-sheet.scss new file mode 100644 index 000000000000..3913c0ceacec --- /dev/null +++ b/src/material/core/tokens/m3/mat/_bottom-sheet.scss @@ -0,0 +1,24 @@ +@use 'sass:map'; +@use '../../../style/sass-utils'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mat, bottom-sheet); + +/// Generates custom tokens for the mat-bottom-sheet. +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of custom tokens for the mat-bottom-sheet +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $tokens: sass-utils.merge-all( + token-utils.generate-typography-tokens($systems, container-text, body-large), + ( + container-shape: token-utils.hardcode(28px, $exclude-hardcoded), + container-text-color: map.get($systems, md-sys-color, on-surface), + container-background-color: map.get($systems, md-sys-color, surface-container-low), + ), + ); + + @return token-utils.namespace-tokens($prefix, $tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mat/_card.scss b/src/material/core/tokens/m3/mat/_card.scss new file mode 100644 index 000000000000..8ab88638c1e7 --- /dev/null +++ b/src/material/core/tokens/m3/mat/_card.scss @@ -0,0 +1,24 @@ +@use 'sass:map'; +@use '../../../style/sass-utils'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mat, card); + +/// Generates custom tokens for the mat-card. +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of custom tokens for the mat-card +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $tokens: sass-utils.merge-all( + token-utils.generate-typography-tokens($systems, title-text, title-large), + token-utils.generate-typography-tokens($systems, subtitle-text, title-medium), + ( + subtitle-text-color: map.get($systems, md-sys-color, on-surface) + ) + ); + + @return token-utils.namespace-tokens($prefix, $tokens, $token-slots); +} + diff --git a/src/material/core/tokens/m3/mat/_checkbox.scss b/src/material/core/tokens/m3/mat/_checkbox.scss new file mode 100644 index 000000000000..87ab6d8750d1 --- /dev/null +++ b/src/material/core/tokens/m3/mat/_checkbox.scss @@ -0,0 +1,21 @@ +@use 'sass:map'; +@use '../../../style/sass-utils'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mat, checkbox); + +/// Generates custom tokens for mat-checkbox. +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of custom tokens for mat-checkbox +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $tokens: ( + disabled-label-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, on-surface), $alpha: 0.38), + ); + + @return token-utils.namespace-tokens($prefix, $tokens, $token-slots); +} + diff --git a/src/material/core/tokens/m3/mat/_chip.scss b/src/material/core/tokens/m3/mat/_chip.scss new file mode 100644 index 000000000000..3b57e8ca4b7e --- /dev/null +++ b/src/material/core/tokens/m3/mat/_chip.scss @@ -0,0 +1,46 @@ +@use 'sass:map'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mat, chip); + +/// Generates custom tokens for the mat-chip. +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of custom tokens for the mat-chip +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $tokens: (( + disabled-container-opacity: token-utils.hardcode(1, $exclude-hardcoded), + selected-trailing-icon-color: map.get($systems, md-sys-color, on-secondary-container), + selected-disabled-trailing-icon-color: map.get($systems, md-sys-color, on-surface), + trailing-action-state-layer-color: map.get($systems, md-sys-color, on-surface-variant), + selected-trailing-action-state-layer-color: + map.get($systems, md-sys-color, on-secondary-container), + trailing-action-hover-state-layer-opacity: + map.get($systems, md-sys-state, hover-state-layer-opacity), + trailing-action-focus-state-layer-opacity: + map.get($systems, md-sys-state, focus-state-layer-opacity), + trailing-action-opacity: token-utils.hardcode(1, $exclude-hardcoded), + trailing-action-focus-opacity: token-utils.hardcode(1, $exclude-hardcoded), + ), ( + primary: ( + selected-trailing-icon-color: map.get($systems, md-sys-color, on-primary-container), + selected-trailing-action-state-layer-color: + map.get($systems, md-sys-color, on-primary-container), + ), + secondary: (), // Default, no overrides needed. + tertiary: ( + selected-trailing-icon-color: map.get($systems, md-sys-color, on-tertiary-container), + selected-trailing-action-state-layer-color: + map.get($systems, md-sys-color, on-tertiary-container), + ), + error: ( + selected-trailing-icon-color: map.get($systems, md-sys-color, on-error-container), + selected-trailing-action-state-layer-color: + map.get($systems, md-sys-color, on-error-container), + ), + )); + + @return token-utils.namespace-tokens($prefix, $tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mat/_datepicker.scss b/src/material/core/tokens/m3/mat/_datepicker.scss new file mode 100644 index 000000000000..3f33859e3eef --- /dev/null +++ b/src/material/core/tokens/m3/mat/_datepicker.scss @@ -0,0 +1,123 @@ +@use 'sass:map'; +@use '../../../style/sass-utils'; +@use '../../token-utils'; +@use '@material/elevation' as mdc-elevation; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mat, datepicker); + +/// Generates custom tokens for the mat-datepicker. +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of custom tokens for the mat-datepicker +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $tokens: (( + calendar-date-in-range-state-background-color: + map.get($systems, md-sys-color, primary-container), + calendar-date-in-comparison-range-state-background-color: + map.get($systems, md-sys-color, tertiary-container), + calendar-date-in-overlap-range-state-background-color: + map.get($systems, md-sys-color, secondary-container), + calendar-date-in-overlap-range-selected-state-background-color: + map.get($systems, md-sys-color, secondary), + calendar-date-selected-state-text-color: map.get($systems, md-sys-color, on-primary), + calendar-date-selected-state-background-color: map.get($systems, md-sys-color, primary), + calendar-date-selected-disabled-state-background-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, on-surface), + $alpha: 0.38 + ), + calendar-date-today-selected-state-outline-color: map.get($systems, md-sys-color, primary), + calendar-date-focus-state-background-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, on-surface), + $alpha: map.get($systems, md-sys-state, focus-state-layer-opacity) + ), + calendar-date-hover-state-background-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, on-surface), + $alpha: map.get($systems, md-sys-state, hover-state-layer-opacity) + ), + toggle-active-state-icon-color: map.get($systems, md-sys-color, on-surface-variant), + toggle-icon-color: map.get($systems, md-sys-color, on-surface-variant), + calendar-body-label-text-color: map.get($systems, md-sys-color, on-surface), + calendar-period-button-text-color: map.get($systems, md-sys-color, on-surface-variant), + calendar-period-button-icon-color: map.get($systems, md-sys-color, on-surface-variant), + calendar-navigation-button-icon-color: map.get($systems, md-sys-color, on-surface-variant), + calendar-header-divider-color: token-utils.hardcode(transparent, $exclude-hardcoded), + calendar-header-text-color: map.get($systems, md-sys-color, on-surface-variant), + calendar-date-today-outline-color: map.get($systems, md-sys-color, primary), + calendar-date-today-disabled-state-outline-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, on-surface), + $alpha: 0.38 + ), + calendar-date-text-color: map.get($systems, md-sys-color, on-surface), + calendar-date-outline-color: token-utils.hardcode(transparent, $exclude-hardcoded), + calendar-date-disabled-state-text-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, on-surface), + $alpha: 0.38 + ), + calendar-date-preview-state-outline-color: map.get($systems, md-sys-color, primary), + range-input-separator-color: map.get($systems, md-sys-color, on-surface), + range-input-disabled-state-separator-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, on-surface), + $alpha: 0.38 + ), + range-input-disabled-state-text-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, on-surface), + $alpha: 0.38 + ), + calendar-container-background-color: map.get($systems, md-sys-color, surface-container-high), + calendar-container-text-color: map.get($systems, md-sys-color, on-surface), + calendar-container-elevation-shadow: token-utils.hardcode(mdc-elevation.elevation-box-shadow(0), + $exclude-hardcoded), + calendar-container-touch-elevation-shadow: + token-utils.hardcode(mdc-elevation.elevation-box-shadow(0), $exclude-hardcoded), + calendar-container-shape: map.get($systems, md-sys-shape, corner-large), + calendar-container-touch-shape: map.get($systems, md-sys-shape, corner-extra-large), + calendar-text-font: map.get($systems, md-sys-typescale, body-large-font), + calendar-text-size: map.get($systems, md-sys-typescale, body-large-size), + calendar-body-label-text-size: map.get($systems, md-sys-typescale, title-small-size), + calendar-body-label-text-weight: map.get($systems, md-sys-typescale, title-small-weight), + calendar-period-button-text-size: map.get($systems, md-sys-typescale, title-small-size), + calendar-period-button-text-weight: map.get($systems, md-sys-typescale, title-small-weight), + calendar-header-text-size: map.get($systems, md-sys-typescale, title-small-size), + calendar-header-text-weight: map.get($systems, md-sys-typescale, title-small-weight), + ), ( + // Color variants: + primary: (), // Default, no overrides needed. + secondary: ( + calendar-date-in-range-state-background-color: + map.get($systems, md-sys-color, secondary-container), + calendar-date-selected-state-text-color: map.get($systems, md-sys-color, on-secondary), + calendar-date-selected-state-background-color: map.get($systems, md-sys-color, secondary), + calendar-date-today-selected-state-outline-color: map.get($systems, md-sys-color, secondary), + calendar-date-today-outline-color: map.get($systems, md-sys-color, secondary), + calendar-date-preview-state-outline-color: map.get($systems, md-sys-color, secondary), + calendar-date-in-overlap-range-state-background-color: + map.get($systems, md-sys-color, primary-container), + calendar-date-in-overlap-range-selected-state-background-color: + map.get($systems, md-sys-color, primary), + ), + tertiary: ( + calendar-date-in-range-state-background-color: + map.get($systems, md-sys-color, tertiary-container), + calendar-date-selected-state-text-color: map.get($systems, md-sys-color, on-tertiary), + calendar-date-selected-state-background-color: map.get($systems, md-sys-color, tertiary), + calendar-date-today-selected-state-outline-color: map.get($systems, md-sys-color, tertiary), + calendar-date-today-outline-color: map.get($systems, md-sys-color, tertiary), + calendar-date-preview-state-outline-color: map.get($systems, md-sys-color, tertiary), + calendar-date-in-comparison-range-state-background-color: + map.get($systems, md-sys-color, primary-container), + ), + error: ( + calendar-date-in-range-state-background-color: + map.get($systems, md-sys-color, error-container), + calendar-date-selected-state-text-color: map.get($systems, md-sys-color, on-error), + calendar-date-selected-state-background-color: map.get($systems, md-sys-color, error), + calendar-date-today-selected-state-outline-color: map.get($systems, md-sys-color, error), + calendar-date-today-outline-color: map.get($systems, md-sys-color, error), + calendar-date-preview-state-outline-color: map.get($systems, md-sys-color, error), + ) + )); + + @return token-utils.namespace-tokens($prefix, $tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mat/_dialog.scss b/src/material/core/tokens/m3/mat/_dialog.scss new file mode 100644 index 000000000000..0524b04e48a3 --- /dev/null +++ b/src/material/core/tokens/m3/mat/_dialog.scss @@ -0,0 +1,30 @@ +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mat, dialog); + +/// Generates custom tokens for the dialog. +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of custom tokens for the dialog +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $tokens: ( + container-max-width: token-utils.hardcode(560px, $exclude-hardcoded), + container-small-max-width: token-utils.hardcode(calc(100vw - 32px), $exclude-hardcoded), + container-min-width: token-utils.hardcode(280px, $exclude-hardcoded), + actions-alignment: token-utils.hardcode(flex-end, $exclude-hardcoded), + content-padding: token-utils.hardcode(20px 24px, $exclude-hardcoded), + with-actions-content-padding: token-utils.hardcode(20px 24px 0, $exclude-hardcoded), + actions-padding: token-utils.hardcode(16px 24px, $exclude-hardcoded), + + // The vertical padding values are a bit weird, because MDC uses a `::before` pseudo + // element to size the title which in turn means that we can't set a specific padding + // and get the exact same space out of it. These values were determined through + // trial and error so that the first line of text is 24px from the top and the bottom + // of the text is 16px from the content under it. + headline-padding: token-utils.hardcode(6px 24px 13px, $exclude-hardcoded), + ); + + @return token-utils.namespace-tokens($prefix, $tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mat/_divider.scss b/src/material/core/tokens/m3/mat/_divider.scss new file mode 100644 index 000000000000..5b7095e9d74f --- /dev/null +++ b/src/material/core/tokens/m3/mat/_divider.scss @@ -0,0 +1,19 @@ +@use 'sass:map'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mat, divider); + +/// Generates custom tokens for the mat-divider. +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of custom tokens for the mat-divider +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $tokens: ( + width: token-utils.hardcode(1px, $exclude-hardcoded), + color: map.get($systems, md-sys-color, outline-variant), + ); + + @return token-utils.namespace-tokens($prefix, $tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mat/_expansion.scss b/src/material/core/tokens/m3/mat/_expansion.scss new file mode 100644 index 000000000000..1db3992d71e8 --- /dev/null +++ b/src/material/core/tokens/m3/mat/_expansion.scss @@ -0,0 +1,41 @@ +@use 'sass:map'; +@use '../../../style/sass-utils'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mat, expansion); + +/// Generates custom tokens for the mat-expansion. +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of custom tokens for the mat-expansion +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $tokens: sass-utils.merge-all( + token-utils.generate-typography-tokens($systems, header-text, title-medium), + token-utils.generate-typography-tokens($systems, container-text, body-large), + ( + container-shape: token-utils.hardcode(12px, $exclude-hardcoded), + legacy-header-indicator-display: token-utils.hardcode(none, $exclude-hardcoded), + header-indicator-display: token-utils.hardcode(inline-block, $exclude-hardcoded), + container-background-color: map.get($systems, md-sys-color, surface), + container-text-color: map.get($systems, md-sys-color, on-surface), + actions-divider-color: map.get($systems, md-sys-color, outline-variant), + header-hover-state-layer-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, on-surface), + $alpha: map.get($systems, md-sys-state, hover-state-layer-opacity) + ), + header-focus-state-layer-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, on-surface), + $alpha: map.get($systems, md-sys-state, focus-state-layer-opacity) + ), + header-disabled-state-text-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, on-surface), $alpha: 0.38), + header-text-color: map.get($systems, md-sys-color, on-surface), + header-description-color: map.get($systems, md-sys-color, on-surface-variant), + header-indicator-color: map.get($systems, md-sys-color, on-surface-variant), + ) + ); + + @return token-utils.namespace-tokens($prefix, $tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mat/_fab-small.scss b/src/material/core/tokens/m3/mat/_fab-small.scss new file mode 100644 index 000000000000..35bd8330d80c --- /dev/null +++ b/src/material/core/tokens/m3/mat/_fab-small.scss @@ -0,0 +1,50 @@ +@use 'sass:map'; +@use '../../../style/sass-utils'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mat, fab-small); + +/// Generates custom tokens for the mat-mini-fab. +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of custom tokens for the mat-mini-fab +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $tokens: (( + foreground-color: map.get($systems, md-sys-color, on-primary-container), + state-layer-color: map.get($systems, md-sys-color, on-primary-container), + ripple-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, on-primary-container), + $alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity) + ), + hover-state-layer-opacity: map.get($systems, md-sys-state, hover-state-layer-opacity), + focus-state-layer-opacity: map.get($systems, md-sys-state, focus-state-layer-opacity), + pressed-state-layer-opacity: map.get($systems, md-sys-state, pressed-state-layer-opacity), + disabled-state-container-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, on-surface), $alpha: 0.12), + disabled-state-foreground-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, on-surface), $alpha: 0.38), + ), ( + // Color variants + primary: (), // Default, no overrides needed. + secondary: ( + foreground-color: map.get($systems, md-sys-color, on-secondary-container), + state-layer-color: map.get($systems, md-sys-color, on-secondary-container), + ripple-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, on-secondary-container), + $alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity) + ), + ), + tertiary: ( + foreground-color: map.get($systems, md-sys-color, on-tertiary-container), + state-layer-color: map.get($systems, md-sys-color, on-tertiary-container), + ripple-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, on-tertiary-container), + $alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity) + ), + ) + )); + + @return token-utils.namespace-tokens($prefix, $tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mat/_fab.scss b/src/material/core/tokens/m3/mat/_fab.scss new file mode 100644 index 000000000000..c7ad83501b96 --- /dev/null +++ b/src/material/core/tokens/m3/mat/_fab.scss @@ -0,0 +1,50 @@ +@use 'sass:map'; +@use '../../../style/sass-utils'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mat, fab); + +/// Generates custom tokens for the mat-fab. +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of custom tokens for the mat-fab +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $tokens: (( + foreground-color: map.get($systems, md-sys-color, on-primary-container), + state-layer-color: map.get($systems, md-sys-color, on-primary-container), + ripple-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, on-primary-container), + $alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity) + ), + hover-state-layer-opacity: map.get($systems, md-sys-state, hover-state-layer-opacity), + focus-state-layer-opacity: map.get($systems, md-sys-state, focus-state-layer-opacity), + pressed-state-layer-opacity: map.get($systems, md-sys-state, pressed-state-layer-opacity), + disabled-state-container-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, on-surface), $alpha: 0.12), + disabled-state-foreground-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, on-surface), $alpha: 0.38), + ), ( + // Color variants + primary: (), // Default, no overrides needed. + secondary: ( + foreground-color: map.get($systems, md-sys-color, on-secondary-container), + state-layer-color: map.get($systems, md-sys-color, on-secondary-container), + ripple-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, on-secondary-container), + $alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity) + ), + ), + tertiary: ( + foreground-color: map.get($systems, md-sys-color, on-tertiary-container), + state-layer-color: map.get($systems, md-sys-color, on-tertiary-container), + ripple-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, on-tertiary-container), + $alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity) + ), + ) + )); + + @return token-utils.namespace-tokens($prefix, $tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mat/_filled-button.scss b/src/material/core/tokens/m3/mat/_filled-button.scss new file mode 100644 index 000000000000..7d7707a4a3b7 --- /dev/null +++ b/src/material/core/tokens/m3/mat/_filled-button.scss @@ -0,0 +1,54 @@ +@use 'sass:map'; +@use '../../../style/sass-utils'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mat, filled-button); + +/// Generates custom tokens for the mat-flat-button. +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of custom tokens for the mat-flat-button +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $tokens: (( + horizontal-padding: token-utils.hardcode(24px, $exclude-hardcoded), + icon-spacing: token-utils.hardcode(8px, $exclude-hardcoded), + icon-offset: token-utils.hardcode(-8px, $exclude-hardcoded), + state-layer-color: map.get($systems, md-sys-color, on-primary), + disabled-state-layer-color: map.get($systems, md-sys-color, on-surface-variant), + ripple-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, on-primary), + $alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity) + ), + hover-state-layer-opacity: map.get($systems, md-sys-state, hover-state-layer-opacity), + focus-state-layer-opacity: map.get($systems, md-sys-state, focus-state-layer-opacity), + pressed-state-layer-opacity: map.get($systems, md-sys-state, pressed-state-layer-opacity), + ), ( + // Color variants: + primary: (), // Default, no overrides needed. + secondary: ( + state-layer-color: map.get($systems, md-sys-color, on-secondary), + ripple-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, on-secondary), + $alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity) + ), + ), + tertiary: ( + state-layer-color: map.get($systems, md-sys-color, on-tertiary), + ripple-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, on-tertiary), + $alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity) + ), + ), + error: ( + state-layer-color: map.get($systems, md-sys-color, on-error), + ripple-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, on-error), + $alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity) + ), + ) + )); + + @return token-utils.namespace-tokens($prefix, $tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mat/_form-field.scss b/src/material/core/tokens/m3/mat/_form-field.scss new file mode 100644 index 000000000000..93af7ab3cac2 --- /dev/null +++ b/src/material/core/tokens/m3/mat/_form-field.scss @@ -0,0 +1,59 @@ +@use 'sass:map'; +@use '../../../style/sass-utils'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mat, form-field); + +/// Generates custom tokens for the mat-form-field. +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of custom tokens for the mat-form-field +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $tokens: sass-utils.merge-all( + token-utils.generate-typography-tokens($systems, container-text, body-large), + token-utils.generate-typography-tokens($systems, subscript-text, body-small), + ( + disabled-input-text-placeholder-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, on-surface), $alpha: 0.38), + state-layer-color: map.get($systems, md-sys-color, on-surface), + error-text-color: map.get($systems, md-sys-color, error), + select-option-text-color: map.get($systems, md-ref-palette, neutral10), + select-disabled-option-text-color: sass-utils.safe-color-change( + map.get($systems, md-ref-palette, neutral10), $alpha: 0.38), + enabled-select-arrow-color: map.get($systems, md-sys-color, on-surface-variant), + disabled-select-arrow-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, on-surface), $alpha: 0.38), + hover-state-layer-opacity: map.get($systems, md-sys-state, hover-state-layer-opacity), + focus-state-layer-opacity: token-utils.hardcode(0, $exclude-hardcoded), + focus-select-arrow-color: map.get($systems, md-sys-color, primary), + outlined-label-text-populated-size: map.get($systems, md-sys-typeface, body-large-size), + + leading-icon-color: map.get($systems, md-sys-color, on-surface-variant), + disabled-leading-icon-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, on-surface), $alpha: 0.38), + + trailing-icon-color: map.get($systems, md-sys-color, on-surface-variant), + disabled-trailing-icon-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, on-surface), $alpha: 0.38), + error-focus-trailing-icon-color: map.get($systems, md-sys-color, error), + error-hover-trailing-icon-color: map.get($systems, md-sys-color, on-error-container), + error-trailing-icon-color: map.get($systems, md-sys-color, error), + ) + ), ( + // Color variants: + primary: (), // Default, no overrides needed. + secondary: ( + focus-select-arrow-color: map.get($systems, md-sys-color, secondary), + ), + tertiary: ( + focus-select-arrow-color: map.get($systems, md-sys-color, tertiary), + ), + error: ( + focus-select-arrow-color: map.get($systems, md-sys-color, error), + ) + ); + + @return token-utils.namespace-tokens($prefix, $tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mat/_full-pseudo-checkbox.scss b/src/material/core/tokens/m3/mat/_full-pseudo-checkbox.scss new file mode 100644 index 000000000000..eb6e5ef97b30 --- /dev/null +++ b/src/material/core/tokens/m3/mat/_full-pseudo-checkbox.scss @@ -0,0 +1,42 @@ +@use 'sass:map'; +@use '../../../style/sass-utils'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mat, full-pseudo-checkbox); + +/// Generates custom tokens for the full variant of mat-pseudo-checkbox. +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of custom tokens for the full variant of mat-pseudo-checkbox +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $disabled-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, on-surface), $alpha: 0.38); + + $tokens: (( + selected-icon-color: map.get($systems, md-sys-color, primary), + selected-checkmark-color: map.get($systems, md-sys-color, on-primary), + unselected-icon-color: map.get($systems, md-sys-color, on-surface-variant), + disabled-selected-checkmark-color: map.get($systems, md-sys-color, surface), + disabled-unselected-icon-color: $disabled-color, + disabled-selected-icon-color: $disabled-color, + ), ( + // Color variants: + primary: (), // Default, no overrides needed. + secondary: ( + selected-icon-color: map.get($systems, md-sys-color, secondary), + selected-checkmark-color: map.get($systems, md-sys-color, on-secondary), + ), + tertiary: ( + selected-icon-color: map.get($systems, md-sys-color, tertiary), + selected-checkmark-color: map.get($systems, md-sys-color, on-tertiary), + ), + error: ( + selected-icon-color: map.get($systems, md-sys-color, error), + selected-checkmark-color: map.get($systems, md-sys-color, on-error), + ) + )); + + @return token-utils.namespace-tokens($prefix, $tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mat/_grid-list.scss b/src/material/core/tokens/m3/mat/_grid-list.scss new file mode 100644 index 000000000000..af1ce6b6d533 --- /dev/null +++ b/src/material/core/tokens/m3/mat/_grid-list.scss @@ -0,0 +1,21 @@ +@use 'sass:map'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mat, grid-list); + +/// Generates custom tokens for the mat-grid-list. +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of custom tokens for the mat-grid-list +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $tokens: ( + tile-header-primary-text-size: map.get($systems, md-sys-typescale, body-large), + tile-header-secondary-text-size: map.get($systems, md-sys-typescale, body-medium), + tile-footer-primary-text-size: map.get($systems, md-sys-typescale, body-large), + tile-footer-secondary-text-size: map.get($systems, md-sys-typescale, body-medium), + ); + + @return token-utils.namespace-tokens($prefix, $tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mat/_icon-button.scss b/src/material/core/tokens/m3/mat/_icon-button.scss new file mode 100644 index 000000000000..e7378cf4db14 --- /dev/null +++ b/src/material/core/tokens/m3/mat/_icon-button.scss @@ -0,0 +1,27 @@ +@use 'sass:map'; +@use '../../../style/sass-utils'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mat, icon-button); + +/// Generates custom tokens for the mat-icon-button. +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of custom tokens for the mat-icon-button +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $tokens: ( + state-layer-color: map.get($systems, md-sys-color, on-surface-variant), + disabled-state-layer-color: map.get($systems, md-sys-color, on-surface-variant), + ripple-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, on-surface-variant), + $alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity) + ), + hover-state-layer-opacity: map.get($systems, md-sys-state, hover-state-layer-opacity), + focus-state-layer-opacity: map.get($systems, md-sys-state, focus-state-layer-opacity), + pressed-state-layer-opacity: map.get($systems, md-sys-state, pressed-state-layer-opacity), + ); + + @return token-utils.namespace-tokens($prefix, $tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mat/_icon.scss b/src/material/core/tokens/m3/mat/_icon.scss new file mode 100644 index 000000000000..a24f1d0556e9 --- /dev/null +++ b/src/material/core/tokens/m3/mat/_icon.scss @@ -0,0 +1,33 @@ +@use 'sass:map'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mat, icon); + +/// Generates custom tokens for the mat-icon. +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of custom tokens for the mat-icon +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $tokens: (( + color: token-utils.hardcode(inherit, $exclude-hardcoded), + ), ( + // Color variants: + surface: (), // Default, no overrides needed. + primary: ( + color: map.get($systems, md-sys-color, primary), + ), + secondary: ( + color: map.get($systems, md-sys-color, secondary), + ), + tertiary: ( + color: map.get($systems, md-sys-color, tertiary), + ), + error: ( + color: map.get($systems, md-sys-color, error), + ) + )); + + @return token-utils.namespace-tokens($prefix, $tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mat/_list.scss b/src/material/core/tokens/m3/mat/_list.scss new file mode 100644 index 000000000000..a3a9fa86e0bc --- /dev/null +++ b/src/material/core/tokens/m3/mat/_list.scss @@ -0,0 +1,19 @@ +@use 'sass:map'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mat, list); + +/// Generates custom tokens for the mat-list. +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of custom tokens for the mat-list +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $tokens: ( + active-indicator-color: map.get($systems, md-sys-color, secondary-container), + active-indicator-shape: map.get($systems, md-sys-shape, corner-full), + ); + + @return token-utils.namespace-tokens($prefix, $tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mat/_menu.scss b/src/material/core/tokens/m3/mat/_menu.scss new file mode 100644 index 000000000000..bbb36c889c4f --- /dev/null +++ b/src/material/core/tokens/m3/mat/_menu.scss @@ -0,0 +1,42 @@ +@use 'sass:map'; +@use '../../../style/sass-utils'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mat, menu); + +/// Generates custom tokens for the mat-menu. +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of custom tokens for the mat-menu +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $tokens: sass-utils.merge-all( + token-utils.generate-typography-tokens($systems, item-label-text, label-large), + ( + container-shape: map.get($systems, md-sys-shape, corner-extra-small), + divider-color: map.get($systems, md-sys-color, surface-variant), + divider-bottom-spacing: token-utils.hardcode(8px, $exclude-hardcoded), + divider-top-spacing: token-utils.hardcode(8px, $exclude-hardcoded), + item-label-text-color: map.get($systems, md-sys-color, on-surface), + item-icon-color: map.get($systems, md-sys-color, on-surface-variant), + item-icon-size: token-utils.hardcode(24px, $exclude-hardcoded), + item-hover-state-layer-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, on-surface), + $alpha: map.get($systems, md-sys-state, hover-state-layer-opacity) + ), + item-focus-state-layer-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, on-surface), + $alpha: map.get($systems, md-sys-state, focus-state-layer-opacity) + ), + item-spacing: token-utils.hardcode(12px, $exclude-hardcoded), + item-leading-spacing: token-utils.hardcode(12px, $exclude-hardcoded), + item-trailing-spacing: token-utils.hardcode(12px, $exclude-hardcoded), + item-with-icon-leading-spacing: token-utils.hardcode(12px, $exclude-hardcoded), + item-with-icon-trailing-spacing: token-utils.hardcode(12px, $exclude-hardcoded), + container-color: map.get($systems, md-sys-color, surface-container), + ) + ); + + @return token-utils.namespace-tokens($prefix, $tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mat/_minimal-pseudo-checkbox.scss b/src/material/core/tokens/m3/mat/_minimal-pseudo-checkbox.scss new file mode 100644 index 000000000000..ec49a5eb0256 --- /dev/null +++ b/src/material/core/tokens/m3/mat/_minimal-pseudo-checkbox.scss @@ -0,0 +1,33 @@ +@use 'sass:map'; +@use '../../../style/sass-utils'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mat, minimal-pseudo-checkbox); + +/// Generates custom tokens for the minimal variant of mat-pseudo-checkbox. +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of custom tokens for the minimal variant of mat-pseudo-checkbox +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $tokens: (( + selected-checkmark-color: map.get($systems, md-sys-color, primary), + disabled-selected-checkmark-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, on-surface), $alpha: 0.38), + ), ( + // Color variants: + primary: (), // Default, no overrides needed. + secondary: ( + selected-checkmark-color: map.get($systems, md-sys-color, secondary), + ), + tertiary: ( + selected-checkmark-color: map.get($systems, md-sys-color, tertiary), + ), + error: ( + selected-checkmark-color: map.get($systems, md-sys-color, error), + ) + )); + + @return token-utils.namespace-tokens($prefix, $tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mat/_optgroup.scss b/src/material/core/tokens/m3/mat/_optgroup.scss new file mode 100644 index 000000000000..30601980d16b --- /dev/null +++ b/src/material/core/tokens/m3/mat/_optgroup.scss @@ -0,0 +1,22 @@ +@use 'sass:map'; +@use '../../../style/sass-utils'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mat, optgroup); + +/// Generates custom tokens for the mat-optgroup. +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of custom tokens for the mat-optgroup +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $tokens: sass-utils.merge-all( + token-utils.generate-typography-tokens($systems, label-text, title-small), + ( + label-text-color: map.get($systems, md-sys-color, on-surface-variant), + ) + ); + + @return token-utils.namespace-tokens($prefix, $tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mat/_option.scss b/src/material/core/tokens/m3/mat/_option.scss new file mode 100644 index 000000000000..62d99e02ff12 --- /dev/null +++ b/src/material/core/tokens/m3/mat/_option.scss @@ -0,0 +1,55 @@ +@use 'sass:map'; +@use '../../../style/sass-utils'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mat, option); + +/// Generates custom tokens for the mat-option. +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of custom tokens for the mat-option +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $tokens: (( + selected-state-label-text-color: map.get($systems, md-sys-color, on-secondary-container), + label-text-color: map.get($systems, md-sys-color, on-surface), + hover-state-layer-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, on-surface), + $alpha: map.get($systems, md-sys-state, hover-state-layer-opacity) + ), + focus-state-layer-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, on-surface), + $alpha: map.get($systems, md-sys-state, focus-state-layer-opacity) + ), + selected-state-layer-color: map.get($systems, md-sys-color, secondary-container), + + // According to the spec the options have to be `label-large` in all typography + // dimensions, however this is inconsistent with the designs and with MDC's + // own implementation. This appears to be a bug in the spec, because MDC overrides + // the font size and weight to be `body-large` (see b/261838263). We make the same + // override here so the label looks correct. + label-text-size: map.get($systems, md-sys-typescale, body-large-size), + label-text-weight: map.get($systems, md-sys-typescale, body-large-weight), + label-text-font: map.get($systems, md-sys-typescale, label-large-font), + label-text-line-height: map.get($systems, md-sys-typescale, label-large-line-height), + label-text-tracking: map.get($systems, md-sys-typescale, label-large-tracking), + ), ( + // Color variants: + primary: ( + selected-state-label-text-color: map.get($systems, md-sys-color, on-primary-container), + selected-state-layer-color: map.get($systems, md-sys-color, primary-container), + ), + secondary: (), // Default, no overrides needed + tertiary: ( + selected-state-label-text-color: map.get($systems, md-sys-color, on-tertiary-container), + selected-state-layer-color: map.get($systems, md-sys-color, tertiary-container), + ), + error: ( + selected-state-label-text-color: map.get($systems, md-sys-color, on-error-container), + selected-state-layer-color: map.get($systems, md-sys-color, error-container), + ) + )); + + @return token-utils.namespace-tokens($prefix, $tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mat/_outlined-button.scss b/src/material/core/tokens/m3/mat/_outlined-button.scss new file mode 100644 index 000000000000..5c1f73064dee --- /dev/null +++ b/src/material/core/tokens/m3/mat/_outlined-button.scss @@ -0,0 +1,54 @@ +@use 'sass:map'; +@use '../../../style/sass-utils'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mat, outlined-button); + +/// Generates custom tokens for the mat-outlined-button. +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of custom tokens for the mat-outlined-button +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $tokens: (( + horizontal-padding: token-utils.hardcode(24px, $exclude-hardcoded), + icon-spacing: token-utils.hardcode(8px, $exclude-hardcoded), + icon-offset: token-utils.hardcode(-8px, $exclude-hardcoded), + state-layer-color: map.get($systems, md-sys-color, primary), + disabled-state-layer-color: map.get($systems, md-sys-color, on-surface-variant), + ripple-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, primary), + $alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity) + ), + hover-state-layer-opacity: map.get($systems, md-sys-state, hover-state-layer-opacity), + focus-state-layer-opacity: map.get($systems, md-sys-state, focus-state-layer-opacity), + pressed-state-layer-opacity: map.get($systems, md-sys-state, pressed-state-layer-opacity), + ), ( + // Color variants: + primary: (), // Default, no overrides needed. + secondary: ( + state-layer-color: map.get($systems, md-sys-color, secondary), + ripple-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, secondary), + $alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity) + ), + ), + tertiary: ( + state-layer-color: map.get($systems, md-sys-color, tertiary), + ripple-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, tertiary), + $alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity) + ), + ), + error: ( + state-layer-color: map.get($systems, md-sys-color, error), + ripple-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, error), + $alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity) + ), + ) + )); + + @return token-utils.namespace-tokens($prefix, $tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mat/_paginator.scss b/src/material/core/tokens/m3/mat/_paginator.scss new file mode 100644 index 000000000000..f2afd2a059fb --- /dev/null +++ b/src/material/core/tokens/m3/mat/_paginator.scss @@ -0,0 +1,27 @@ +@use 'sass:map'; +@use '../../../style/sass-utils'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mat, paginator); + +/// Generates custom tokens for the mat-paginator. +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of custom tokens for the mat-paginator +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $tokens: sass-utils.merge-all( + token-utils.generate-typography-tokens($systems, container-text, body-small), + ( + container-text-color: map.get($systems, md-sys-color, on-surface), + container-background-color: map.get($systems, md-sys-color, surface), + enabled-icon-color: map.get($systems, md-sys-color, on-surface-variant), + disabled-icon-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, on-surface), $alpha: 0.38), + select-trigger-text-size: map.get($systems, md-sys-typescale, body-small-size), + ) + ); + + @return token-utils.namespace-tokens($prefix, $tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mat/_protected-button.scss b/src/material/core/tokens/m3/mat/_protected-button.scss new file mode 100644 index 000000000000..1b2c54e3dbda --- /dev/null +++ b/src/material/core/tokens/m3/mat/_protected-button.scss @@ -0,0 +1,55 @@ +@use 'sass:map'; +@use '../../../style/sass-utils'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +// Note: in M3 the "protected" button is called "elevated". +$prefix: (mat, protected-button); + +/// Generates custom tokens for the mat-raised-button. +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of custom tokens for the mat-raised-button +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $tokens: (( + horizontal-padding: token-utils.hardcode(24px, $exclude-hardcoded), + icon-spacing: token-utils.hardcode(8px, $exclude-hardcoded), + icon-offset: token-utils.hardcode(-8px, $exclude-hardcoded), + state-layer-color: map.get($systems, md-sys-color, primary), + disabled-state-layer-color: map.get($systems, md-sys-color, on-surface-variant), + ripple-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, primary), + $alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity) + ), + hover-state-layer-opacity: map.get($systems, md-sys-state, hover-state-layer-opacity), + focus-state-layer-opacity: map.get($systems, md-sys-state, focus-state-layer-opacity), + pressed-state-layer-opacity: map.get($systems, md-sys-state, pressed-state-layer-opacity), + ), ( + // Color variants: + primary: (), // Default, no overrides needed. + secondary: ( + state-layer-color: map.get($systems, md-sys-color, secondary), + ripple-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, secondary), + $alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity) + ), + ), + tertiary: ( + state-layer-color: map.get($systems, md-sys-color, tertiary), + ripple-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, tertiary), + $alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity) + ), + ), + error: ( + state-layer-color: map.get($systems, md-sys-color, error), + ripple-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, error), + $alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity) + ), + ) + )); + + @return token-utils.namespace-tokens($prefix, $tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mat/_radio.scss b/src/material/core/tokens/m3/mat/_radio.scss new file mode 100644 index 000000000000..118f3b6191cd --- /dev/null +++ b/src/material/core/tokens/m3/mat/_radio.scss @@ -0,0 +1,34 @@ +@use 'sass:map'; +@use '../../../style/sass-utils'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mat, radio); + +/// Generates custom tokens for the mat-radio. +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of custom tokens for the mat-radio +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $tokens: (( + ripple-color: map.get($systems, md-sys-color, on-surface), + checked-ripple-color: map.get($systems, md-sys-color, primary), + disabled-label-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, on-surface), $alpha: 0.38), + ), ( + // Color variants: + primary: (), // Default, no overrides needed + secondary: ( + checked-ripple-color: map.get($systems, md-sys-color, secondary), + ), + tertiary: ( + checked-ripple-color: map.get($systems, md-sys-color, tertiary), + ), + error: ( + checked-ripple-color: map.get($systems, md-sys-color, error), + ), + )); + + @return token-utils.namespace-tokens($prefix, $tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mat/_ripple.scss b/src/material/core/tokens/m3/mat/_ripple.scss new file mode 100644 index 000000000000..ad0809472ef9 --- /dev/null +++ b/src/material/core/tokens/m3/mat/_ripple.scss @@ -0,0 +1,19 @@ +@use 'sass:map'; +@use '../../../style/sass-utils'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mat, ripple); + +/// Generates custom tokens for the mat-ripple. +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of custom tokens for the mat-ripple +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $tokens: ( + color: sass-utils.safe-color-change(map.get($systems, md-sys-color, on-surface), $alpha: 0.1), + ); + + @return token-utils.namespace-tokens($prefix, $tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mat/_select.scss b/src/material/core/tokens/m3/mat/_select.scss new file mode 100644 index 000000000000..0e928e015928 --- /dev/null +++ b/src/material/core/tokens/m3/mat/_select.scss @@ -0,0 +1,46 @@ +@use 'sass:map'; +@use '../../../style/sass-utils'; +@use '../../token-utils'; +@use '@material/elevation' as mdc-elevation; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mat, select); + +/// Generates custom tokens for the mat-select. +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of custom tokens for the mat-select +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $tokens: sass-utils.merge-all( + token-utils.generate-typography-tokens($systems, trigger-text, body-large), + ( + panel-background-color: map.get($systems, md-sys-color, surface-container), + enabled-trigger-text-color: map.get($systems, md-sys-color, on-surface), + disabled-trigger-text-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, on-surface), $alpha: 0.38), + placeholder-text-color: map.get($systems, md-sys-color, on-surface-variant), + enabled-arrow-color: map.get($systems, md-sys-color, on-surface-variant), + disabled-arrow-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, on-surface), $alpha: 0.38), + focused-arrow-color: map.get($systems, md-sys-color, primary), + invalid-arrow-color: map.get($systems, md-sys-color, error), + container-elevation-shadow: + token-utils.hardcode(mdc-elevation.elevation-box-shadow(2), $exclude-hardcoded), + ) + ), ( + // Color variants: + primary: (), // Default, no overrides needed + secondary: ( + focused-arrow-color: map.get($systems, md-sys-color, secondary), + ), + tertiary: ( + focused-arrow-color: map.get($systems, md-sys-color, tertiary), + ), + error: ( + focused-arrow-color: map.get($systems, md-sys-color, error), + ) + ); + + @return token-utils.namespace-tokens($prefix, $tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mat/_sidenav.scss b/src/material/core/tokens/m3/mat/_sidenav.scss new file mode 100644 index 000000000000..bcd7e67a5d29 --- /dev/null +++ b/src/material/core/tokens/m3/mat/_sidenav.scss @@ -0,0 +1,28 @@ +@use 'sass:map'; +@use '../../../style/sass-utils'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mat, sidenav); + +/// Generates custom tokens for the mat-sidenav. +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of custom tokens for the mat-sidenav +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $tokens: ( + container-elevation-shadow: token-utils.hardcode(none, $exclude-hardcoded), + container-divider-color: token-utils.hardcode(transparent, $exclude-hardcoded), + container-width: token-utils.hardcode(360px, $exclude-hardcoded), + container-shape: map.get($systems, md-sys-shape, corner-large), + container-background-color: map.get($systems, md-sys-color, surface), + container-text-color: map.get($systems, md-sys-color, on-surface-variant), + content-background-color: map.get($systems, md-sys-color, background), + content-text-color: map.get($systems, md-sys-color, on-background), + scrim-color: sass-utils.safe-color-change( + map.get($systems, md-ref-palette, neutral-variant20), $alpha: 0.4), + ); + + @return token-utils.namespace-tokens($prefix, $tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mat/_slider.scss b/src/material/core/tokens/m3/mat/_slider.scss new file mode 100644 index 000000000000..0e8a4fadf9c6 --- /dev/null +++ b/src/material/core/tokens/m3/mat/_slider.scss @@ -0,0 +1,56 @@ +@use 'sass:map'; +@use '../../../style/sass-utils'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mat, slider); + +/// Generates custom tokens for the mat-slider. +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of custom tokens for the mat-slider +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $tokens: (( + ripple-color: map.get($systems, md-sys-color, primary), + hover-state-layer-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, primary), $alpha: 0.05), + focus-state-layer-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, primary), $alpha: 0.2), + value-indicator-opacity: token-utils.hardcode(1, $exclude-hardcoded), + value-indicator-padding: token-utils.hardcode(0, $exclude-hardcoded), + value-indicator-width: token-utils.hardcode(28px, $exclude-hardcoded), + value-indicator-height: token-utils.hardcode(28px, $exclude-hardcoded), + value-indicator-caret-display: token-utils.hardcode(none, $exclude-hardcoded), + value-indicator-border-radius: token-utils.hardcode(50% 50% 50% 0, $exclude-hardcoded), + value-indicator-text-transform: token-utils.hardcode(rotate(45deg), $exclude-hardcoded), + value-indicator-container-transform: + token-utils.hardcode(translateX(-50%) rotate(-45deg), $exclude-hardcoded) + ), ( + // Color variants + primary: (), // Default, no overrides needed + secondary: ( + ripple-color: map.get($systems, md-sys-color, secondary), + hover-state-layer-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, secondary), $alpha: 0.05), + focus-state-layer-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, secondary), $alpha: 0.2), + ), + tertiary: ( + ripple-color: map.get($systems, md-sys-color, tertiary), + hover-state-layer-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, tertiary), $alpha: 0.05), + focus-state-layer-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, tertiary), $alpha: 0.2), + ), + error: ( + ripple-color: map.get($systems, md-sys-color, error), + hover-state-layer-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, error), $alpha: 0.05), + focus-state-layer-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, error), $alpha: 0.2), + ), + )); + + @return token-utils.namespace-tokens($prefix, $tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mat/_snack-bar.scss b/src/material/core/tokens/m3/mat/_snack-bar.scss new file mode 100644 index 000000000000..9dc079b49768 --- /dev/null +++ b/src/material/core/tokens/m3/mat/_snack-bar.scss @@ -0,0 +1,18 @@ +@use 'sass:map'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mat, snack-bar); + +/// Generates custom tokens for the mat-snack-bar. +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of custom tokens for the mat-snack-bar +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $tokens: ( + button-color: map.get($systems, md-sys-color, inverse-primary), + ); + + @return token-utils.namespace-tokens($prefix, $tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mat/_sort.scss b/src/material/core/tokens/m3/mat/_sort.scss new file mode 100644 index 000000000000..41dc4441f2cf --- /dev/null +++ b/src/material/core/tokens/m3/mat/_sort.scss @@ -0,0 +1,18 @@ +@use 'sass:map'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mat, sort); + +/// Generates custom tokens for the mat-sort. +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of custom tokens for the mat-sort +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $tokens: ( + arrow-color: map.get($systems, md-sys-color, on-surface), + ); + + @return token-utils.namespace-tokens($prefix, $tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mat/_standard-button-toggle.scss b/src/material/core/tokens/m3/mat/_standard-button-toggle.scss new file mode 100644 index 000000000000..f7e900c97be7 --- /dev/null +++ b/src/material/core/tokens/m3/mat/_standard-button-toggle.scss @@ -0,0 +1,57 @@ +@use 'sass:map'; +@use '../../../style/sass-utils'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mat, standard-button-toggle); + +/// Generates custom tokens for the mat-button-toggle. +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of custom tokens for the mat-button-toggle +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $tokens: sass-utils.merge-all( + token-utils.generate-typography-tokens($systems, label-text, label-large), + ( + shape: map.get($systems, md-sys-shape, corner-full), + hover-state-layer-opacity: map.get($systems, md-sys-state, hover-state-layer-opacity), + focus-state-layer-opacity: map.get($systems, md-sys-state, focus-state-layer-opacity), + text-color: map.get($systems, md-sys-color, on-surface), + background-color: token-utils.hardcode(transparent, $exclude-hardcoded), + state-layer-color: map.get($systems, md-sys-color, on-surface), + selected-state-background-color: map.get($systems, md-sys-color, secondary-container), + selected-state-text-color: map.get($systems, md-sys-color, on-secondary-container), + disabled-state-text-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, on-surface), + $alpha: 0.38, + ), + disabled-state-background-color: token-utils.hardcode(transparent, $exclude-hardcoded), + disabled-selected-state-text-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, on-surface), + $alpha: 0.38, + ), + disabled-selected-state-background-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, on-surface), + $alpha: 0.12, + ), + divider-color: map.get($systems, md-sys-color, outline), + ), ( + // Color variants: + primary: ( + selected-state-background-color: map.get($systems, md-sys-color, primary-container), + selected-state-text-color: map.get($systems, md-sys-color, on-primary-container), + ), + secondary: (), // Default, no overrides needed + tertiary: ( + selected-state-background-color: map.get($systems, md-sys-color, tertiary-container), + selected-state-text-color: map.get($systems, md-sys-color, on-tertiary-container), + ), + error: ( + selected-state-background-color: map.get($systems, md-sys-color, error-container), + selected-state-text-color: map.get($systems, md-sys-color, on-error-container), + ) + )); + + @return token-utils.namespace-tokens($prefix, $tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mat/_stepper.scss b/src/material/core/tokens/m3/mat/_stepper.scss new file mode 100644 index 000000000000..ed4fb918cfed --- /dev/null +++ b/src/material/core/tokens/m3/mat/_stepper.scss @@ -0,0 +1,79 @@ +@use 'sass:map'; +@use '../../../style/sass-utils'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mat, stepper); + +/// Generates custom tokens for the mat-stepper. +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of custom tokens for the mat-stepper +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $tokens: ( + ( + container-color: map.get($systems, md-sys-color, surface), + line-color: map.get($systems, md-sys-color, outline-variant), + header-hover-state-layer-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, inverse-surface), + $alpha: map.get($systems, md-sys-state, hover-state-layer-opacity) + ), + header-focus-state-layer-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, inverse-surface), + $alpha: map.get($systems, md-sys-state, focus-state-layer-opacity) + ), + header-label-text-color: map.get($systems, md-sys-color, on-surface-variant), + header-optional-label-text-color: map.get($systems, md-sys-color, on-surface-variant), + header-selected-state-label-text-color: map.get($systems, md-sys-color, on-surface-variant), + header-icon-background-color: map.get($systems, md-sys-color, on-surface-variant), + header-icon-foreground-color: map.get($systems, md-sys-color, surface), + header-edit-state-icon-background-color: map.get($systems, md-sys-color, primary), + header-edit-state-icon-foreground-color: map.get($systems, md-sys-color, on-primary), + header-error-state-label-text-color: map.get($systems, md-sys-color, error), + header-error-state-icon-foreground-color: map.get($systems, md-sys-color, error), + header-error-state-icon-background-color: + token-utils.hardcode(transparent, $exclude-hardcoded), + container-text-font: map.get($systems, md-sys-typescale, body-medium-font), + header-label-text-font: map.get($systems, md-sys-typescale, title-small-font), + header-label-text-size: map.get($systems, md-sys-typescale, title-small-size), + header-label-text-weight: map.get($systems, md-sys-typescale, title-small-weight), + header-error-state-label-text-size: map.get($systems, md-sys-typescale, title-small-size), + header-focus-state-layer-shape: map.get($systems, md-sys-shape, corner-medium), + header-hover-state-layer-shape: map.get($systems, md-sys-shape, corner-medium), + header-selected-state-label-text-size: map.get($systems, md-sys-typescale, title-small-size), + header-selected-state-label-text-weight: map.get( + $systems, md-sys-typescale, title-small-weight), + header-selected-state-icon-background-color: map.get($systems, md-sys-color, primary), + header-selected-state-icon-foreground-color: map.get($systems, md-sys-color, on-primary), + ), ( + // Color variants + primary: ( + header-edit-state-icon-background-color: map.get($systems, md-sys-color, primary), + header-edit-state-icon-foreground-color: map.get($systems, md-sys-color, on-primary), + header-selected-state-icon-background-color: map.get($systems, md-sys-color, primary), + header-selected-state-icon-foreground-color: map.get($systems, md-sys-color, on-primary), + ), + secondary: ( + header-edit-state-icon-background-color: map.get($systems, md-sys-color, secondary), + header-edit-state-icon-foreground-color: map.get($systems, md-sys-color, on-secondary), + header-selected-state-icon-background-color: map.get($systems, md-sys-color, secondary), + header-selected-state-icon-foreground-color: map.get($systems, md-sys-color, on-secondary), + ), + tertiary: ( + header-edit-state-icon-background-color: map.get($systems, md-sys-color, tertiary), + header-edit-state-icon-foreground-color: map.get($systems, md-sys-color, on-tertiary), + header-selected-state-icon-background-color: map.get($systems, md-sys-color, tertiary), + header-selected-state-icon-foreground-color: map.get($systems, md-sys-color, on-tertiary), + ), + error: ( + header-edit-state-icon-background-color: map.get($systems, md-sys-color, error), + header-edit-state-icon-foreground-color: map.get($systems, md-sys-color, on-error), + header-selected-state-icon-background-color: map.get($systems, md-sys-color, error), + header-selected-state-icon-foreground-color: map.get($systems, md-sys-color, on-error), + ) + ) + ); + + @return token-utils.namespace-tokens($prefix, $tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mat/_switch.scss b/src/material/core/tokens/m3/mat/_switch.scss new file mode 100644 index 000000000000..62b505078369 --- /dev/null +++ b/src/material/core/tokens/m3/mat/_switch.scss @@ -0,0 +1,44 @@ +@use 'sass:map'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mat, switch); + +/// Generates custom tokens for the mat-slide-toggle. +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of custom tokens for the mat-slide-toggle +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $tokens: ( + disabled-selected-handle-opacity: token-utils.hardcode(1, $exclude-hardcoded), + disabled-unselected-handle-opacity: token-utils.hardcode(0.38, $exclude-hardcoded), + unselected-handle-size: token-utils.hardcode(16px, $exclude-hardcoded), + selected-handle-size: token-utils.hardcode(24px, $exclude-hardcoded), + with-icon-handle-size: token-utils.hardcode(24px, $exclude-hardcoded), + pressed-handle-size: token-utils.hardcode(28px, $exclude-hardcoded), + selected-handle-horizontal-margin: token-utils.hardcode(0 24px, $exclude-hardcoded), + selected-with-icon-handle-horizontal-margin: token-utils.hardcode(0 24px, $exclude-hardcoded), + selected-pressed-handle-horizontal-margin: token-utils.hardcode(0 22px, $exclude-hardcoded), + unselected-handle-horizontal-margin: token-utils.hardcode(0 8px, $exclude-hardcoded), + unselected-with-icon-handle-horizontal-margin: token-utils.hardcode(0 4px, $exclude-hardcoded), + unselected-pressed-handle-horizontal-margin: token-utils.hardcode(0 2px, $exclude-hardcoded), + // The hidden and visible track represent whichever track is visible or + // hidden in the ui. This could be the .mdc-switch__track :before or + // :after depending on whether the switch is selected or unselected. + // + // The m2 slide-toggle uses transforms to hide & show the tracks while + // the m3 slide-toggle uses opacity. + visible-track-opacity: token-utils.hardcode(1, $exclude-hardcoded), + hidden-track-opacity: token-utils.hardcode(0, $exclude-hardcoded), + visible-track-transition: token-utils.hardcode(opacity 75ms, $exclude-hardcoded), + hidden-track-transition: token-utils.hardcode(opacity 75ms, $exclude-hardcoded), + track-outline-width: token-utils.hardcode(2px, $exclude-hardcoded), + track-outline-color: map.get($systems, md-sys-color, outline), + selected-track-outline-width: token-utils.hardcode(0, $exclude-hardcoded), + disabled-unselected-track-outline-width: token-utils.hardcode(2px, $exclude-hardcoded), + disabled-unselected-track-outline-color: map.get($systems, md-sys-color, on-surface), + ); + + @return token-utils.namespace-tokens($prefix, $tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mat/_tab-header.scss b/src/material/core/tokens/m3/mat/_tab-header.scss new file mode 100644 index 000000000000..893db546bb2e --- /dev/null +++ b/src/material/core/tokens/m3/mat/_tab-header.scss @@ -0,0 +1,51 @@ +@use 'sass:map'; +@use '../../../style/sass-utils'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mat, tab-header); + +/// Generates custom tokens for the mat-tab-header. +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of custom tokens for the mat-tab-header +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $tokens: sass-utils.merge-all( + token-utils.generate-typography-tokens($systems, label-text, title-small), + ( + divider-color: map.get($systems, md-sys-color, surface-variant), + divider-height: token-utils.hardcode(1px, $exclude-hardcoded), + disabled-ripple-color: null, // TODO(mmalerba): Figure out correct value. + pagination-icon-color: map.get($systems, md-sys-color, on-surface), + inactive-label-text-color: map.get($systems, md-sys-color, on-surface), + active-label-text-color: map.get($systems, md-sys-color, on-surface), + active-ripple-color: map.get($systems, md-sys-color, on-surface), + inactive-ripple-color: map.get($systems, md-sys-color, on-surface), + inactive-focus-label-text-color: map.get($systems, md-sys-color, on-surface), + inactive-hover-label-text-color: map.get($systems, md-sys-color, on-surface), + active-focus-label-text-color: map.get($systems, md-sys-color, on-surface), + active-hover-label-text-color: map.get($systems, md-sys-color, on-surface), + active-focus-indicator-color: map.get($systems, md-sys-color, primary), + active-hover-indicator-color: map.get($systems, md-sys-color, primary), + ), + ), ( + // Color variants + primary: (), // Default, no overrides needed + secondary: ( + active-focus-indicator-color: map.get($systems, md-sys-color, secondary), + active-hover-indicator-color: map.get($systems, md-sys-color, secondary), + ), + tertiary: ( + active-focus-indicator-color: map.get($systems, md-sys-color, tertiary), + active-hover-indicator-color: map.get($systems, md-sys-color, tertiary), + ), + error: ( + active-focus-indicator-color: map.get($systems, md-sys-color, error), + active-hover-indicator-color: map.get($systems, md-sys-color, error), + ) + ); + + @return token-utils.namespace-tokens($prefix, $tokens, $token-slots); +} + diff --git a/src/material/core/tokens/m3/mat/_table.scss b/src/material/core/tokens/m3/mat/_table.scss new file mode 100644 index 000000000000..d9603df5480b --- /dev/null +++ b/src/material/core/tokens/m3/mat/_table.scss @@ -0,0 +1,28 @@ +@use 'sass:map'; +@use '../../../style/sass-utils'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mat, table); + +/// Generates custom tokens for the mat-table. +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of custom tokens for the mat-table +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $tokens: sass-utils.merge-all( + token-utils.generate-typography-tokens($systems, header-headline, title-small), + token-utils.generate-typography-tokens($systems, row-item-label-text, body-medium), + token-utils.generate-typography-tokens($systems, footer-supporting-text, body-medium), + ( + row-item-outline-width: token-utils.hardcode(1px, $exclude-hardcoded), + background-color: map.get($systems, md-sys-color, surface), + header-headline-color: map.get($systems, md-sys-color, on-surface), + row-item-label-text-color: map.get($systems, md-sys-color, on-surface), + row-item-outline-color: map.get($systems, md-sys-color, outline-variant), + ), + ); + + @return token-utils.namespace-tokens($prefix, $tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mat/_text-button.scss b/src/material/core/tokens/m3/mat/_text-button.scss new file mode 100644 index 000000000000..3d8bfda67168 --- /dev/null +++ b/src/material/core/tokens/m3/mat/_text-button.scss @@ -0,0 +1,55 @@ +@use 'sass:map'; +@use '../../../style/sass-utils'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mat, text-button); + +/// Generates custom tokens for the mat-button. +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of custom tokens for the mat-button +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $tokens: (( + horizontal-padding: token-utils.hardcode(12px, $exclude-hardcoded), + with-icon-horizontal-padding: token-utils.hardcode(16px, $exclude-hardcoded), + icon-spacing: token-utils.hardcode(8px, $exclude-hardcoded), + icon-offset: token-utils.hardcode(-4px, $exclude-hardcoded), + state-layer-color: map.get($systems, md-sys-color, primary), + disabled-state-layer-color: map.get($systems, md-sys-color, on-surface-variant), + ripple-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, primary), + $alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity) + ), + hover-state-layer-opacity: map.get($systems, md-sys-state, hover-state-layer-opacity), + focus-state-layer-opacity: map.get($systems, md-sys-state, focus-state-layer-opacity), + pressed-state-layer-opacity: map.get($systems, md-sys-state, pressed-state-layer-opacity), + ), ( + // Color variants: + primary: (), // Default, no overrides needed. + secondary: ( + state-layer-color: map.get($systems, md-sys-color, secondary), + ripple-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, secondary), + $alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity) + ) + ), + tertiary: ( + state-layer-color: map.get($systems, md-sys-color, tertiary), + ripple-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, tertiary), + $alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity) + ) + ), + error: ( + state-layer-color: map.get($systems, md-sys-color, error), + ripple-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, error), + $alpha: map.get($systems, md-sys-state, pressed-state-layer-opacity) + ) + ) + )); + + @return token-utils.namespace-tokens($prefix, $tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mat/_toolbar.scss b/src/material/core/tokens/m3/mat/_toolbar.scss new file mode 100644 index 000000000000..fcd413ab73e3 --- /dev/null +++ b/src/material/core/tokens/m3/mat/_toolbar.scss @@ -0,0 +1,23 @@ +@use 'sass:map'; +@use '../../../style/sass-utils'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mat, toolbar); + +/// Generates custom tokens for the mat-toolbar. +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of custom tokens for the mat-toolbar +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $tokens: sass-utils.merge-all( + token-utils.generate-typography-tokens($systems, title-text, title-large), + ( + container-background-color: map.get($systems, md-sys-color, surface), + container-text-color: map.get($systems, md-sys-color, on-surface), + ) + ); + + @return token-utils.namespace-tokens($prefix, $tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mat/_tree.scss b/src/material/core/tokens/m3/mat/_tree.scss new file mode 100644 index 000000000000..40018d8ce480 --- /dev/null +++ b/src/material/core/tokens/m3/mat/_tree.scss @@ -0,0 +1,22 @@ +@use 'sass:map'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mat, tree); + +/// Generates custom tokens for the mat-tree. +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of custom tokens for the mat-tree +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $tokens: ( + container-background-color: map.get($systems, md-sys-color, surface), + node-text-color: map.get($systems, md-sys-color, on-surface), + node-text-font: map.get($systems, md-sys-typescale, body-large-font), + node-text-size: map.get($systems, md-sys-typescale, body-large-size), + node-text-weight: map.get($systems, md-sys-typescale, body-large-weight), + ); + + @return token-utils.namespace-tokens($prefix, $tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mdc/_checkbox.scss b/src/material/core/tokens/m3/mdc/_checkbox.scss new file mode 100644 index 000000000000..ea8b91360e38 --- /dev/null +++ b/src/material/core/tokens/m3/mdc/_checkbox.scss @@ -0,0 +1,110 @@ +@use 'sass:map'; +@use 'sass:meta'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mdc, checkbox); + +/// Generates the tokens for MDC checkbox +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of tokens for the MDC checkbox +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $mdc-tokens: token-utils.get-mdc-tokens('checkbox', $systems, $exclude-hardcoded); + $variant-tokens: ( + primary: (), // Default, no overrides needed + secondary: ( + selected-container-color: map.get($systems, md-sys-color, secondary), + selected-focus-container-color: map.get($systems, md-sys-color, secondary), + selected-focus-icon-color: map.get($systems, md-sys-color, on-secondary), + selected-focus-state-layer-color: map.get($systems, md-sys-color, secondary), + selected-hover-container-color: map.get($systems, md-sys-color, secondary), + selected-hover-icon-color: map.get($systems, md-sys-color, on-secondary), + selected-hover-state-layer-color: map.get($systems, md-sys-color, secondary), + selected-icon-color: map.get($systems, md-sys-color, on-secondary), + selected-pressed-container-color: map.get($systems, md-sys-color, secondary), + selected-pressed-icon-color: map.get($systems, md-sys-color, on-secondary), + unselected-pressed-state-layer-color: map.get($systems, md-sys-color, secondary), + ), + tertiary: ( + selected-container-color: map.get($systems, md-sys-color, tertiary), + selected-focus-container-color: map.get($systems, md-sys-color, tertiary), + selected-focus-icon-color: map.get($systems, md-sys-color, on-tertiary), + selected-focus-state-layer-color: map.get($systems, md-sys-color, tertiary), + selected-hover-container-color: map.get($systems, md-sys-color, tertiary), + selected-hover-icon-color: map.get($systems, md-sys-color, on-tertiary), + selected-hover-state-layer-color: map.get($systems, md-sys-color, tertiary), + selected-icon-color: map.get($systems, md-sys-color, on-tertiary), + selected-pressed-container-color: map.get($systems, md-sys-color, tertiary), + selected-pressed-icon-color: map.get($systems, md-sys-color, on-tertiary), + unselected-pressed-state-layer-color: map.get($systems, md-sys-color, tertiary), + ), + error: ( + selected-container-color: map.get($systems, md-sys-color, error), + selected-focus-container-color: map.get($systems, md-sys-color, error), + selected-focus-icon-color: map.get($systems, md-sys-color, on-error), + selected-focus-state-layer-color: map.get($systems, md-sys-color, error), + selected-hover-container-color: map.get($systems, md-sys-color, error), + selected-hover-icon-color: map.get($systems, md-sys-color, on-error), + selected-hover-state-layer-color: map.get($systems, md-sys-color, error), + selected-icon-color: map.get($systems, md-sys-color, on-error), + selected-pressed-container-color: map.get($systems, md-sys-color, error), + selected-pressed-icon-color: map.get($systems, md-sys-color, on-error), + unselected-pressed-state-layer-color: map.get($systems, md-sys-color, error), + ) + ); + + @return token-utils.namespace-tokens( + $prefix, + ( + _fix-tokens($mdc-tokens), + token-utils.map-values($variant-tokens, meta.get-function(_fix-tokens)) + ), + $token-slots + ); +} + +/// Renames the official checkbox tokens to match the names actually used in MDC's code (which are +/// different). This is a temporary workaround until MDC updates to use the correct names for the +/// tokens. +/// @param {Map} $tokens The map of checkbox tokens with the official tokens names +/// @param {Map} $all-tokens Map of all checkbox tokens, including hardcoded values. +/// This is necessary in order to do opacity lookups. +/// @return {Map} The given tokens, renamed to be compatible with MDC's token implementation. +@function _fix-tokens($tokens) { + // Need to get the hardcoded values, because they include opacities that are used for the disabled + // state. + $hardcoded-tokens: token-utils.get-mdc-tokens('checkbox', (), false); + + $rename-keys: ( + selected-icon-color: selected-checkmark-color, + selected-disabled-icon-color: disabled-selected-checkmark-color, + selected-container-color: selected-icon-color, + selected-hover-container-color: selected-hover-icon-color, + selected-disabled-container-color: disabled-selected-icon-color, + selected-disabled-container-opacity: disabled-selected-icon-opacity, + selected-focus-container-color: selected-focus-icon-color, + selected-pressed-container-color: selected-pressed-icon-color, + unselected-disabled-outline-color: disabled-unselected-icon-color, + unselected-disabled-container-opacity: disabled-unselected-icon-opacity, + unselected-focus-outline-color: unselected-focus-icon-color, + unselected-hover-outline-color: unselected-hover-icon-color, + unselected-outline-color: unselected-icon-color, + unselected-pressed-outline-color: unselected-pressed-icon-color + ); + + $remapped-tokens: token-utils.rename-map-keys($tokens, $rename-keys); + $remapped-hardcoded-tokens: token-utils.rename-map-keys($hardcoded-tokens, $rename-keys); + + @return token-utils.combine-color-tokens($remapped-tokens, $remapped-hardcoded-tokens, ( + ( + color: disabled-selected-icon-color, + opacity: disabled-selected-icon-opacity, + ), + ( + color: disabled-unselected-icon-color, + opacity: disabled-unselected-icon-opacity, + ), + )); +} diff --git a/src/material/core/tokens/m3/mdc/_chip.scss b/src/material/core/tokens/m3/mdc/_chip.scss new file mode 100644 index 000000000000..943ede0c943e --- /dev/null +++ b/src/material/core/tokens/m3/mdc/_chip.scss @@ -0,0 +1,91 @@ +@use 'sass:map'; +@use '../../../style/sass-utils'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mdc, chip); + +/// Generates the tokens for MDC chip +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of tokens for the MDC chip +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + // MDC has a chip component, but they seem to have made up the tokens rather than using ones + // generated from the token database, therefore we need a custom token function for it. + $tokens: sass-utils.merge-all( + token-utils.generate-typography-tokens($systems, label-text, label-large), + ( + container-shape: token-utils.hardcode(( + family: rounded, + radius: 8px, + ), $exclude-hardcoded), + with-avatar-avatar-size: token-utils.hardcode(24px, $exclude-hardcoded), + label-text-color: map.get($systems, md-sys-color, on-surface-variant), + disabled-label-text-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, on-surface), + $alpha: 0.38, + ), + with-icon-icon-size: token-utils.hardcode(18px, $exclude-hardcoded), + with-icon-icon-color: map.get($systems, md-sys-color, on-surface-variant), + with-icon-disabled-icon-color: map.get($systems, md-sys-color, on-surface), + with-icon-selected-icon-color: map.get($systems, md-sys-color, on-secondary-container), + with-trailing-icon-trailing-icon-color: map.get($systems, md-sys-color, on-surface-variant), + with-trailing-icon-disabled-trailing-icon-color: map.get($systems, md-sys-color, on-surface), + focus-state-layer-opacity: map.get($systems, md-sys-state, focus-state-layer-opacity), + focus-state-layer-color: map.get($systems, md-sys-color, on-surface-variant), + outline-width: token-utils.hardcode(1px, $exclude-hardcoded), + outline-color: map.get($systems, md-sys-color, outline), + disabled-outline-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, on-surface), + $alpha: 0.12, + ), + focus-outline-color: map.get($systems, md-sys-color, on-surface-variant), + hover-state-layer-color: map.get($systems, md-sys-color, on-surface-variant), + hover-state-layer-opacity: map.get($systems, md-sys-state, hover-state-layer-opacity), + with-avatar-disabled-avatar-opacity: token-utils.hardcode(0.38, $exclude-hardcoded), + elevated-selected-container-color: map.get($systems, md-sys-color, secondary-container), + flat-selected-outline-width: token-utils.hardcode(0, $exclude-hardcoded), + selected-label-text-color: map.get($systems, md-sys-color, on-secondary-container), + flat-disabled-selected-container-color: sass-utils.safe-color-change( + map.get($systems, md-sys-color, on-surface), + $alpha: 0.12, + ), + selected-hover-state-layer-color: map.get($systems, md-sys-color, on-secondary-container), + selected-hover-state-layer-opacity: + map.get($systems, md-sys-state, hover-state-layer-opacity), + selected-focus-state-layer-color: map.get($systems, md-sys-color, on-secondary-container), + selected-focus-state-layer-opacity: + map.get($systems, md-sys-state, focus-state-layer-opacity), + with-icon-disabled-icon-opacity: token-utils.hardcode(0.38, $exclude-hardcoded), + with-trailing-icon-disabled-trailing-icon-opacity: + token-utils.hardcode(0.38, $exclude-hardcoded), + ), + ), ( + // Color variants: + primary: ( + with-icon-selected-icon-color: map.get($systems, md-sys-color, on-primary-container), + elevated-selected-container-color: map.get($systems, md-sys-color, primary-container), + selected-label-text-color: map.get($systems, md-sys-color, on-primary-container), + selected-hover-state-layer-color: map.get($systems, md-sys-color, on-primary-container), + selected-focus-state-layer-color: map.get($systems, md-sys-color, on-primary-container), + ), + secondary: (), // Default, no overrides needed. + tertiary: ( + with-icon-selected-icon-color: map.get($systems, md-sys-color, on-tertiary-container), + elevated-selected-container-color: map.get($systems, md-sys-color, tertiary-container), + selected-label-text-color: map.get($systems, md-sys-color, on-tertiary-container), + selected-hover-state-layer-color: map.get($systems, md-sys-color, on-tertiary-container), + selected-focus-state-layer-color: map.get($systems, md-sys-color, on-tertiary-container), + ), + error: ( + with-icon-selected-icon-color: map.get($systems, md-sys-color, on-error-container), + elevated-selected-container-color: map.get($systems, md-sys-color, error-container), + selected-label-text-color: map.get($systems, md-sys-color, on-error-container), + selected-hover-state-layer-color: map.get($systems, md-sys-color, on-error-container), + selected-focus-state-layer-color: map.get($systems, md-sys-color, on-error-container), + ) + ); + + @return token-utils.namespace-tokens($prefix, $tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mdc/_circular-progress.scss b/src/material/core/tokens/m3/mdc/_circular-progress.scss new file mode 100644 index 000000000000..37e012dbabd1 --- /dev/null +++ b/src/material/core/tokens/m3/mdc/_circular-progress.scss @@ -0,0 +1,29 @@ +@use 'sass:map'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mdc, circular-progress); + +/// Generates the tokens for MDC circular-progress +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of tokens for the MDC circular-progress +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $mdc-tokens: + token-utils.get-mdc-tokens('circular-progress-indicator', $systems, $exclude-hardcoded); + $variant-tokens: ( + primary: (), // Default, no overrides needed + secondary: ( + active-indicator-color: map.get($systems, md-sys-color, secondary), + ), + tertiary: ( + active-indicator-color: map.get($systems, md-sys-color, tertiary), + ), + error: ( + active-indicator-color: map.get($systems, md-sys-color, error), + ) + ); + + @return token-utils.namespace-tokens($prefix, ($mdc-tokens, $variant-tokens), $token-slots); +} diff --git a/src/material/core/tokens/m3/mdc/_dialog.scss b/src/material/core/tokens/m3/mdc/_dialog.scss new file mode 100644 index 000000000000..9f20cbb00820 --- /dev/null +++ b/src/material/core/tokens/m3/mdc/_dialog.scss @@ -0,0 +1,39 @@ +@use 'sass:map'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mdc, dialog); + +/// Generates the tokens for MDC dialog +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of tokens for the MDC dialog +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $tokens: token-utils.get-mdc-tokens('dialog', $systems, $exclude-hardcoded); + $tokens: token-utils.rename-map-keys($tokens, ( + headline-color: subhead-color, + headline-font: subhead-font, + headline-line-height: subhead-line-height, + headline-size: subhead-size, + headline-tracking: subhead-tracking, + headline-weight: subhead-weight, + )); + + @if map.get($tokens, container-elevation) != null { + $tokens: map.merge($tokens, ( + // The spec has the dialog at an elevation of 3 which is consistent with the current + // version of the tokens (0_161), however both the designs and MDC's implementation + // have the elevation set to 0. Set it manually to 0 here since the value in the + // exported tokens is likely outdated. + container-elevation: 0, + + // This color needs to be supplied for MDC to produce the shadow. Technically we don't + // have to provide it since the elevation is set to 0 above, but we do it in case + // the value changes in the future. + container-shadow-color: #000, + )); + } + + @return token-utils.namespace-tokens($prefix, $tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mdc/_elevated-card.scss b/src/material/core/tokens/m3/mdc/_elevated-card.scss new file mode 100644 index 000000000000..a53446d2746b --- /dev/null +++ b/src/material/core/tokens/m3/mdc/_elevated-card.scss @@ -0,0 +1,15 @@ +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mdc, elevated-card); + +/// Generates the tokens for MDC elevated-card +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of tokens for the MDC elevated-card +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $mdc-tokens: token-utils.get-mdc-tokens('elevated-card', $systems, $exclude-hardcoded); + + @return token-utils.namespace-tokens($prefix, $mdc-tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mdc/_extended-fab.scss b/src/material/core/tokens/m3/mdc/_extended-fab.scss new file mode 100644 index 000000000000..5d3724c2b1b3 --- /dev/null +++ b/src/material/core/tokens/m3/mdc/_extended-fab.scss @@ -0,0 +1,21 @@ +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mdc, extended-fab); + +/// Generates the tokens for MDC extended-fab +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @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); + $variant-tokens: ( + // Color variants + primary: (), // Default, no overrides needed. + secondary: token-utils.get-mdc-tokens('extended-fab-secondary', $systems, $exclude-hardcoded), + tertiary: token-utils.get-mdc-tokens('extended-fab-tertiary', $systems, $exclude-hardcoded) + ); + + @return token-utils.namespace-tokens($prefix, ($mdc-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 new file mode 100644 index 000000000000..59906c17274f --- /dev/null +++ b/src/material/core/tokens/m3/mdc/_fab-small.scss @@ -0,0 +1,21 @@ +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mdc, fab-small); + +/// Generates the tokens for MDC fab-small +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @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); + $variant-tokens: ( + // Color variants + primary: (), // Default, no overrides needed. + secondary: token-utils.get-mdc-tokens('fab-secondary-small', $systems, $exclude-hardcoded), + tertiary: token-utils.get-mdc-tokens('fab-tertiary-small', $systems, $exclude-hardcoded) + ); + + @return token-utils.namespace-tokens($prefix, ($mdc-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 new file mode 100644 index 000000000000..e39ff5b8a930 --- /dev/null +++ b/src/material/core/tokens/m3/mdc/_fab.scss @@ -0,0 +1,21 @@ +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mdc, fab); + +/// Generates the tokens for MDC fab +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @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); + $variant-tokens: ( + // Color variants + primary: (), // Default, no overrides needed. + secondary: token-utils.get-mdc-tokens('fab-secondary', $systems, $exclude-hardcoded), + tertiary: token-utils.get-mdc-tokens('fab-tertiary', $systems, $exclude-hardcoded) + ); + + @return token-utils.namespace-tokens($prefix, ($mdc-tokens, $variant-tokens), $token-slots); +} diff --git a/src/material/core/tokens/m3/mdc/_filled-button.scss b/src/material/core/tokens/m3/mdc/_filled-button.scss new file mode 100644 index 000000000000..9240897e14d1 --- /dev/null +++ b/src/material/core/tokens/m3/mdc/_filled-button.scss @@ -0,0 +1,86 @@ +@use 'sass:map'; +@use 'sass:meta'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mdc, filled-button); + +/// Generates the tokens for MDC filled-button +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of tokens for the MDC filled-button +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $mdc-tokens: token-utils.get-mdc-tokens('filled-button', $systems, $exclude-hardcoded); + $variant-tokens: ( + primary: (), // Default, no overrides needed. + secondary: ( + container-color: map.get($systems, md-sys-color, secondary), + focus-label-text-color: map.get($systems, md-sys-color, on-secondary), + focus-state-layer-color: map.get($systems, md-sys-color, on-secondary), + hover-label-text-color: map.get($systems, md-sys-color, on-secondary), + hover-state-layer-color: map.get($systems, md-sys-color, on-secondary), + label-text-color: map.get($systems, md-sys-color, on-secondary), + pressed-label-text-color: map.get($systems, md-sys-color, on-secondary), + pressed-state-layer-color: map.get($systems, md-sys-color, on-secondary), + with-icon-focus-icon-color: map.get($systems, md-sys-color, on-secondary), + with-icon-hover-icon-color: map.get($systems, md-sys-color, on-secondary), + with-icon-icon-color: map.get($systems, md-sys-color, on-secondary), + with-icon-pressed-icon-color: map.get($systems, md-sys-color, on-secondary) + ), + tertiary: ( + container-color: map.get($systems, md-sys-color, tertiary), + focus-label-text-color: map.get($systems, md-sys-color, on-tertiary), + focus-state-layer-color: map.get($systems, md-sys-color, on-tertiary), + hover-label-text-color: map.get($systems, md-sys-color, on-tertiary), + hover-state-layer-color: map.get($systems, md-sys-color, on-tertiary), + label-text-color: map.get($systems, md-sys-color, on-tertiary), + pressed-label-text-color: map.get($systems, md-sys-color, on-tertiary), + pressed-state-layer-color: map.get($systems, md-sys-color, on-tertiary), + with-icon-focus-icon-color: map.get($systems, md-sys-color, on-tertiary), + with-icon-hover-icon-color: map.get($systems, md-sys-color, on-tertiary), + with-icon-icon-color: map.get($systems, md-sys-color, on-tertiary), + with-icon-pressed-icon-color: map.get($systems, md-sys-color, on-tertiary) + ), + error: ( + container-color: map.get($systems, md-sys-color, error), + focus-label-text-color: map.get($systems, md-sys-color, on-error), + focus-state-layer-color: map.get($systems, md-sys-color, on-error), + hover-label-text-color: map.get($systems, md-sys-color, on-error), + hover-state-layer-color: map.get($systems, md-sys-color, on-error), + label-text-color: map.get($systems, md-sys-color, on-error), + pressed-label-text-color: map.get($systems, md-sys-color, on-error), + pressed-state-layer-color: map.get($systems, md-sys-color, on-error), + with-icon-focus-icon-color: map.get($systems, md-sys-color, on-error), + with-icon-hover-icon-color: map.get($systems, md-sys-color, on-error), + with-icon-icon-color: map.get($systems, md-sys-color, on-error), + with-icon-pressed-icon-color: map.get($systems, md-sys-color, on-error) + ) + ); + + @return token-utils.namespace-tokens($prefix, ( + _fix-tokens($mdc-tokens), + token-utils.map-values($variant-tokens, meta.get-function(_fix-tokens)) + ), $token-slots); +} + + +/// Fixes inconsistent values in the filled button tokens so that they can produce valid styles. +/// @param {Map} $initial-tokens Map of filled button tokens currently being generated. +/// @return {Map} The given tokens, with the invalid values replaced with valid ones. +@function _fix-tokens($initial-tokens) { + // Need to get the hardcoded values, because they include opacities that are used for the disabled + // state. + $hardcoded-tokens: token-utils.get-mdc-tokens('filled-button', (), false); + + @return token-utils.combine-color-tokens($initial-tokens, $hardcoded-tokens, ( + ( + color: disabled-label-text-color, + opacity: disabled-label-text-opacity, + ), + ( + color: disabled-container-color, + opacity: disabled-container-opacity, + ) + )); +} diff --git a/src/material/core/tokens/m3/mdc/_filled-text-field.scss b/src/material/core/tokens/m3/mdc/_filled-text-field.scss new file mode 100644 index 000000000000..65a400036e15 --- /dev/null +++ b/src/material/core/tokens/m3/mdc/_filled-text-field.scss @@ -0,0 +1,92 @@ +@use 'sass:map'; +@use 'sass:meta'; +@use 'sass:list'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mdc, filled-text-field); + +/// Generates the tokens for MDC filled-text-field +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of tokens for the MDC filled-text-field +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $mdc-tokens: token-utils.get-mdc-tokens('filled-text-field', $systems, $exclude-hardcoded); + $variant-tokens: ( + primary: (), // Default, no overrides needed + secondary: ( + caret-color: map.get($systems, md-sys-color, secondary), + focus-active-indicator-color: map.get($systems, md-sys-color, secondary), + focus-label-text-color: map.get($systems, md-sys-color, secondary), + ), + tertiary: ( + caret-color: map.get($systems, md-sys-color, tertiary), + focus-active-indicator-color: map.get($systems, md-sys-color, tertiary), + focus-label-text-color: map.get($systems, md-sys-color, tertiary), + ), + error: ( + caret-color: map.get($systems, md-sys-color, error), + focus-active-indicator-color: map.get($systems, md-sys-color, error), + focus-label-text-color: map.get($systems, md-sys-color, error), + ), + ); + + @return token-utils.namespace-tokens($prefix, ( + _fix-tokens($mdc-tokens), + token-utils.map-values($variant-tokens, meta.get-function(_fix-tokens)) + ), $token-slots); +} + + +/// Fixes inconsistent values in the filled text field tokens so that they can produce valid +/// styles. +/// @param {Map} $initial-tokens Map of filled text field tokens currently being generated. +/// @return {Map} The given tokens, with the invalid values replaced with valid ones. +@function _fix-tokens($initial-tokens) { + // Need to get the hardcoded values, because they include opacities that are used for the disabled + // state. + $hardcoded-tokens: token-utils.get-mdc-tokens('filled-text-field', (), false); + + $tokens: token-utils.combine-color-tokens($initial-tokens, $hardcoded-tokens, ( + ( + color: disabled-active-indicator-color, + opacity: disabled-active-indicator-opacity + ), + ( + color: disabled-container-color, + opacity: disabled-container-opacity + ), + ( + color: disabled-input-text-color, + opacity: disabled-input-text-opacity + ), + ( + color: disabled-label-text-color, + opacity: disabled-label-text-opacity + ), + ( + color: disabled-leading-icon-color, + opacity: disabled-leading-icon-opacity + ), + ( + color: disabled-supporting-text-color, + opacity: disabled-supporting-text-opacity + ), + ( + color: disabled-trailing-icon-color, + opacity: disabled-trailing-icon-opacity + ) + )); + + $container-shape: map.get($tokens, container-shape); + + // The M2 token slots define a single `container-shape` slot while the M3 tokens provide a list + // of shapes (e.g. top/bottom/left/right). Extract the first value so it matches the expected + // token slot in M2. + @if meta.type-of($container-shape) == 'list' { + $tokens: map.set($tokens, container-shape, list.nth($container-shape, 1)); + } + + @return $tokens; +} diff --git a/src/material/core/tokens/m3/mdc/_form-field.scss b/src/material/core/tokens/m3/mdc/_form-field.scss new file mode 100644 index 000000000000..6700750fcb10 --- /dev/null +++ b/src/material/core/tokens/m3/mdc/_form-field.scss @@ -0,0 +1,25 @@ +@use 'sass:map'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mdc, form-field); + +/// Generates the tokens for MDC form-field +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of tokens for the MDC form-field +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $tokens: ( + // TODO: MDC currently doesn't provide tokens for the form field so we need to + // define them ourselves. Clean this up once b/246297033 is resolved. + label-text-color: map.get($systems, md-sys-color, on-surface), + label-text-font: map.get($systems, md-sys-typescale, body-medium-font), + label-text-line-height: map.get($systems, md-sys-typescale, body-medium-line-height), + label-text-size: map.get($systems, md-sys-typescale, body-medium-size), + label-text-tracking: map.get($systems, md-sys-typescale, body-medium-tracking), + label-text-weight: map.get($systems, md-sys-typescale, body-medium-weight), + ); + + @return token-utils.namespace-tokens($prefix, $tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mdc/_icon-button.scss b/src/material/core/tokens/m3/mdc/_icon-button.scss new file mode 100644 index 000000000000..93661d52ddde --- /dev/null +++ b/src/material/core/tokens/m3/mdc/_icon-button.scss @@ -0,0 +1,39 @@ +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mdc, icon-button); + +/// Generates the tokens for MDC icon-button +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of tokens for the MDC icon-button +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $mdc-tokens: token-utils.get-mdc-tokens('icon-button', $systems, $exclude-hardcoded); + + @return token-utils.namespace-tokens($prefix, _fix-tokens($mdc-tokens), $token-slots); +} + +/// Fixes inconsistent values in the icon button tokens so that they can produce valid styles. +/// @param {Map} $initial-tokens Map of icon button tokens currently being generated. +/// @param {Map} $all-tokens Map of all icon button tokens, including hardcoded values. +/// @return {Map} The given tokens, with the invalid values replaced with valid ones. +@function _fix-tokens($tokens) { + // Need to get the hardcoded values, because they include opacities that are used for the disabled + // state. + $hardcoded-tokens: token-utils.get-mdc-tokens('icon-button', (), false); + + $rename-keys: ( + unselected-icon-color: icon-color, + ); + + $remapped-tokens: token-utils.rename-map-keys($tokens, $rename-keys); + $remapped-hardcoded-tokens: token-utils.rename-map-keys($hardcoded-tokens, $rename-keys); + + @return token-utils.combine-color-tokens($remapped-tokens, $remapped-hardcoded-tokens, ( + ( + color: disabled-icon-color, + opacity: disabled-icon-opacity, + ), + )); +} diff --git a/src/material/core/tokens/m3/mdc/_linear-progress.scss b/src/material/core/tokens/m3/mdc/_linear-progress.scss new file mode 100644 index 000000000000..8ccfaad1edd0 --- /dev/null +++ b/src/material/core/tokens/m3/mdc/_linear-progress.scss @@ -0,0 +1,32 @@ +@use 'sass:map'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mdc, linear-progress); + +/// Generates the tokens for MDC linear-progress +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of tokens for the MDC linear-progress +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $mdc-tokens: + token-utils.get-mdc-tokens('linear-progress-indicator', $systems, $exclude-hardcoded); + $variant-tokens: ( + primary: (), // Default, no overrides needed + secondary: ( + active-indicator-color: map.get($systems, md-sys-color, secondary), + track-color: map.get($systems, md-sys-color, secondary-container), + ), + tertiary: ( + active-indicator-color: map.get($systems, md-sys-color, tertiary), + track-color: map.get($systems, md-sys-color, tertiary-container), + ), + error: ( + active-indicator-color: map.get($systems, md-sys-color, error), + track-color: map.get($systems, md-sys-color, error-container), + ), + ); + + @return token-utils.namespace-tokens($prefix, ($mdc-tokens, $variant-tokens), $token-slots); +} diff --git a/src/material/core/tokens/m3/mdc/_list.scss b/src/material/core/tokens/m3/mdc/_list.scss new file mode 100644 index 000000000000..f5bfafc16297 --- /dev/null +++ b/src/material/core/tokens/m3/mdc/_list.scss @@ -0,0 +1,37 @@ +@use 'sass:map'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mdc, list); + +/// Generates the tokens for MDC list +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of tokens for the MDC list +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $mdc-tokens: token-utils.get-mdc-tokens('list', $systems, $exclude-hardcoded); + + @return token-utils.namespace-tokens($prefix, _fix-tokens($mdc-tokens), $token-slots); +} + +/// Fixes values in the list tokens that are inconsistent with its usage. +/// @param {Map} $initial-tokens Map of list tokens currently being generated. +/// @return {Map} The given tokens, with the inconsistent values replaced with valid ones. +@function _fix-tokens($tokens) { + // This does not match the spec, which defines this to be `md.sys.color.surface`. + // However, this interferes with the use case of placing a list on other components. For example, + // the bottom sheet's container color is `md.sys.color.surface-container-low`. Instead, allow the + // list to just display the colors for its background. + @if map.get($tokens, list-item-container-color) != null { + $tokens: map.set($tokens, list-item-container-color, transparent); + } + + // Match spec, which has list-item-leading-icon-size of 24px. + // Current version of tokens (0_161) has 18px. + @if map.get($tokens, list-item-leading-icon-size) != null { + $tokens: map.set($tokens, list-item-leading-icon-size, 24px); + } + + @return $tokens; +} diff --git a/src/material/core/tokens/m3/mdc/_outlined-button.scss b/src/material/core/tokens/m3/mdc/_outlined-button.scss new file mode 100644 index 000000000000..0df3bebc2776 --- /dev/null +++ b/src/material/core/tokens/m3/mdc/_outlined-button.scss @@ -0,0 +1,83 @@ +@use 'sass:map'; +@use 'sass:meta'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mdc, outlined-button); + +/// Generates the tokens for MDC outlined-button +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of tokens for the MDC outlined-button +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $mdc-tokens: token-utils.get-mdc-tokens('outlined-button', $systems, $exclude-hardcoded); + $variant-tokens: ( + primary: (), // Default, no overrides needed. + secondary: ( + focus-label-text-color: map.get($systems, md-sys-color, secondary), + focus-outline-color: map.get($systems, md-sys-color, secondary), + focus-state-layer-color: map.get($systems, md-sys-color, secondary), + hover-label-text-color: map.get($systems, md-sys-color, secondary), + hover-state-layer-color: map.get($systems, md-sys-color, secondary), + label-text-color: map.get($systems, md-sys-color, secondary), + pressed-label-text-color: map.get($systems, md-sys-color, secondary), + pressed-state-layer-color: map.get($systems, md-sys-color, secondary), + with-icon-focus-icon-color: map.get($systems, md-sys-color, secondary), + with-icon-hover-icon-color: map.get($systems, md-sys-color, secondary), + with-icon-icon-color: map.get($systems, md-sys-color, secondary), + with-icon-pressed-icon-color: map.get($systems, md-sys-color, secondary) + ), + tertiary: ( + focus-label-text-color: map.get($systems, md-sys-color, tertiary), + focus-outline-color: map.get($systems, md-sys-color, tertiary), + focus-state-layer-color: map.get($systems, md-sys-color, tertiary), + hover-label-text-color: map.get($systems, md-sys-color, tertiary), + hover-state-layer-color: map.get($systems, md-sys-color, tertiary), + label-text-color: map.get($systems, md-sys-color, tertiary), + pressed-label-text-color: map.get($systems, md-sys-color, tertiary), + pressed-state-layer-color: map.get($systems, md-sys-color, tertiary), + with-icon-focus-icon-color: map.get($systems, md-sys-color, tertiary), + with-icon-hover-icon-color: map.get($systems, md-sys-color, tertiary), + with-icon-icon-color: map.get($systems, md-sys-color, tertiary), + with-icon-pressed-icon-color: map.get($systems, md-sys-color, tertiary) + ), + error: ( + focus-label-text-color: map.get($systems, md-sys-color, error), + focus-outline-color: map.get($systems, md-sys-color, error), + focus-state-layer-color: map.get($systems, md-sys-color, error), + hover-label-text-color: map.get($systems, md-sys-color, error), + hover-state-layer-color: map.get($systems, md-sys-color, error), + label-text-color: map.get($systems, md-sys-color, error), + pressed-label-text-color: map.get($systems, md-sys-color, error), + pressed-state-layer-color: map.get($systems, md-sys-color, error), + with-icon-focus-icon-color: map.get($systems, md-sys-color, error), + with-icon-hover-icon-color: map.get($systems, md-sys-color, error), + with-icon-icon-color: map.get($systems, md-sys-color, error), + with-icon-pressed-icon-color: map.get($systems, md-sys-color, error) + ) + ); + + @return token-utils.namespace-tokens($prefix, ( + _fix-tokens($mdc-tokens), + token-utils.map-values($variant-tokens, meta.get-function(_fix-tokens)) + ), $token-slots); +} + +/// Fixes inconsistent values in the outlined button tokens so that they can produce valid styles. +/// @param {Map} $initial-tokens Map of outlined button tokens currently being generated. +/// @return {Map} The given tokens, with the invalid values replaced with valid ones. +@function _fix-tokens($initial-tokens) { + $hardcoded-tokens: token-utils.get-mdc-tokens('outlined-button', (), false); + + @return token-utils.combine-color-tokens($initial-tokens, $hardcoded-tokens, ( + ( + color: disabled-label-text-color, + opacity: disabled-label-text-opacity, + ), + ( + color: disabled-outline-color, + opacity: disabled-outline-opacity, + ) + )); +} diff --git a/src/material/core/tokens/m3/mdc/_outlined-card.scss b/src/material/core/tokens/m3/mdc/_outlined-card.scss new file mode 100644 index 000000000000..b7e70ab843a6 --- /dev/null +++ b/src/material/core/tokens/m3/mdc/_outlined-card.scss @@ -0,0 +1,15 @@ +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mdc, outlined-card); + +/// Generates the tokens for MDC outlined-card +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of tokens for the MDC outlined-card +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $mdc-tokens: token-utils.get-mdc-tokens('outlined-card', $systems, $exclude-hardcoded); + + @return token-utils.namespace-tokens($prefix, $mdc-tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mdc/_outlined-text-field.scss b/src/material/core/tokens/m3/mdc/_outlined-text-field.scss new file mode 100644 index 000000000000..7bd123183e26 --- /dev/null +++ b/src/material/core/tokens/m3/mdc/_outlined-text-field.scss @@ -0,0 +1,85 @@ +@use 'sass:map'; +@use 'sass:meta'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mdc, outlined-text-field); + +/// Generates the tokens for MDC outlined-text-field +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of tokens for the MDC outlined-text-field +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $mdc-tokens: token-utils.get-mdc-tokens('outlined-text-field', $systems, $exclude-hardcoded); + $variant-tokens: ( + primary: (), // Default, no overrides needed + secondary: ( + caret-color: map.get($systems, md-sys-color, secondary), + focus-label-text-color: map.get($systems, md-sys-color, secondary), + focus-outline-color: map.get($systems, md-sys-color, secondary), + ), + tertiary: ( + caret-color: map.get($systems, md-sys-color, tertiary), + focus-label-text-color: map.get($systems, md-sys-color, tertiary), + focus-outline-color: map.get($systems, md-sys-color, tertiary), + ), + error: ( + caret-color: map.get($systems, md-sys-color, error), + focus-label-text-color: map.get($systems, md-sys-color, error), + focus-outline-color: map.get($systems, md-sys-color, error), + ), + ); + + @return token-utils.namespace-tokens($prefix, ( + _fix-tokens($mdc-tokens), + token-utils.map-values($variant-tokens, meta.get-function(_fix-tokens)) + ), $token-slots); +} + +/// Fixes inconsistent values in the outlined text field tokens so that they can produce valid +/// styles. +/// @param {Map} $initial-tokens Map of outlined text field tokens currently being generated. +/// @param {Map} $all-tokens Map of all outlined text field tokens, including hardcoded values. +/// This is necessary in order to do opacity lookups. +/// @return {Map} The given tokens, with the invalid values replaced with valid ones. +@function _fix-tokens($initial-tokens) { + // Need to get the hardcoded values, because they include opacities that are used for the disabled + // state. + $hardcoded-tokens: token-utils.get-mdc-tokens('outlined-text-field', (), false); + + @return token-utils.combine-color-tokens($initial-tokens, $hardcoded-tokens, ( + ( + color: disabled-outline-color, + opacity: disabled-outline-opacity + ), + ( + color: disabled-active-indicator-color, + opacity: disabled-active-indicator-opacity + ), + ( + color: disabled-container-color, + opacity: disabled-container-opacity + ), + ( + color: disabled-input-text-color, + opacity: disabled-input-text-opacity + ), + ( + color: disabled-label-text-color, + opacity: disabled-label-text-opacity + ), + ( + color: disabled-leading-icon-color, + opacity: disabled-leading-icon-opacity + ), + ( + color: disabled-supporting-text-color, + opacity: disabled-supporting-text-opacity + ), + ( + color: disabled-trailing-icon-color, + opacity: disabled-trailing-icon-opacity + ) + )); +} diff --git a/src/material/core/tokens/m3/mdc/_plain-tooltip.scss b/src/material/core/tokens/m3/mdc/_plain-tooltip.scss new file mode 100644 index 000000000000..1081645db88c --- /dev/null +++ b/src/material/core/tokens/m3/mdc/_plain-tooltip.scss @@ -0,0 +1,15 @@ +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mdc, plain-tooltip); + +/// Generates the tokens for MDC plain-tooltip +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of tokens for the MDC plain-tooltip +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $mdc-tokens: token-utils.get-mdc-tokens('plain-tooltip', $systems, $exclude-hardcoded); + + @return token-utils.namespace-tokens($prefix, $mdc-tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mdc/_protected-button.scss b/src/material/core/tokens/m3/mdc/_protected-button.scss new file mode 100644 index 000000000000..98b11a2b2b34 --- /dev/null +++ b/src/material/core/tokens/m3/mdc/_protected-button.scss @@ -0,0 +1,84 @@ +@use 'sass:map'; +@use 'sass:meta'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mdc, protected-button); + +/// Generates the tokens for MDC protected-button +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of tokens for the MDC protected-button +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + // Note: in M3 the "protected" button is called "elevated". + $mdc-tokens: token-utils.get-mdc-tokens('elevated-button', $systems, $exclude-hardcoded); + $variant-tokens: ( + primary: (), // Default, no overrides needed. + secondary: ( + focus-label-text-color: map.get($systems, md-sys-color, secondary), + focus-state-layer-color: map.get($systems, md-sys-color, secondary), + hover-label-text-color: map.get($systems, md-sys-color, secondary), + hover-state-layer-color: map.get($systems, md-sys-color, secondary), + label-text-color: map.get($systems, md-sys-color, secondary), + pressed-label-text-color: map.get($systems, md-sys-color, secondary), + pressed-state-layer-color: map.get($systems, md-sys-color, secondary), + with-icon-focus-icon-color: map.get($systems, md-sys-color, secondary), + with-icon-hover-icon-color: map.get($systems, md-sys-color, secondary), + with-icon-icon-color: map.get($systems, md-sys-color, secondary), + with-icon-pressed-icon-color: map.get($systems, md-sys-color, secondary) + ), + tertiary: ( + focus-label-text-color: map.get($systems, md-sys-color, tertiary), + focus-state-layer-color: map.get($systems, md-sys-color, tertiary), + hover-label-text-color: map.get($systems, md-sys-color, tertiary), + hover-state-layer-color: map.get($systems, md-sys-color, tertiary), + label-text-color: map.get($systems, md-sys-color, tertiary), + pressed-label-text-color: map.get($systems, md-sys-color, tertiary), + pressed-state-layer-color: map.get($systems, md-sys-color, tertiary), + with-icon-focus-icon-color: map.get($systems, md-sys-color, tertiary), + with-icon-hover-icon-color: map.get($systems, md-sys-color, tertiary), + with-icon-icon-color: map.get($systems, md-sys-color, tertiary), + with-icon-pressed-icon-color: map.get($systems, md-sys-color, tertiary) + ), + error: ( + focus-label-text-color: map.get($systems, md-sys-color, error), + focus-state-layer-color: map.get($systems, md-sys-color, error), + hover-label-text-color: map.get($systems, md-sys-color, error), + hover-state-layer-color: map.get($systems, md-sys-color, error), + label-text-color: map.get($systems, md-sys-color, error), + pressed-label-text-color: map.get($systems, md-sys-color, error), + pressed-state-layer-color: map.get($systems, md-sys-color, error), + with-icon-focus-icon-color: map.get($systems, md-sys-color, error), + with-icon-hover-icon-color: map.get($systems, md-sys-color, error), + with-icon-icon-color: map.get($systems, md-sys-color, error), + with-icon-pressed-icon-color: map.get($systems, md-sys-color, error) + ) + ); + + @return token-utils.namespace-tokens($prefix, ( + _fix-tokens($mdc-tokens), + token-utils.map-values($variant-tokens, meta.get-function(_fix-tokens)), + ), $token-slots); +} + + +/// Fixes inconsistent values in the protected button tokens so that they can produce valid styles. +/// @param {Map} $initial-tokens Map of protected button tokens currently being generated. +/// @return {Map} The given tokens, with the invalid values replaced with valid ones. +@function _fix-tokens($initial-tokens) { + // Need to get the hardcoded values, because they include opacities that are used for the disabled + // state. + $hardcoded-tokens: token-utils.get-mdc-tokens('elevated-button', (), false); + + @return token-utils.combine-color-tokens($initial-tokens, $hardcoded-tokens, ( + ( + color: disabled-label-text-color, + opacity: disabled-label-text-opacity, + ), + ( + color: disabled-container-color, + opacity: disabled-container-opacity, + ) + )); +} diff --git a/src/material/core/tokens/m3/mdc/_radio.scss b/src/material/core/tokens/m3/mdc/_radio.scss new file mode 100644 index 000000000000..843a2f44913f --- /dev/null +++ b/src/material/core/tokens/m3/mdc/_radio.scss @@ -0,0 +1,46 @@ +@use 'sass:map'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mdc, radio); + +/// Generates the tokens for MDC radio +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of tokens for the MDC radio +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $mdc-tokens: token-utils.get-mdc-tokens('radio-button', $systems, $exclude-hardcoded); + $variant-tokens: ( + primary: (), // Default, no overrides needed + secondary: ( + selected-focus-icon-color: map.get($systems, md-sys-color, secondary), + selected-focus-state-layer-color: map.get($systems, md-sys-color, secondary), + selected-hover-icon-color: map.get($systems, md-sys-color, secondary), + selected-hover-state-layer-color: map.get($systems, md-sys-color, secondary), + selected-icon-color: map.get($systems, md-sys-color, secondary), + selected-pressed-icon-color: map.get($systems, md-sys-color, secondary), + unselected-pressed-state-layer-color: map.get($systems, md-sys-color, secondary), + ), + tertiary: ( + selected-focus-icon-color: map.get($systems, md-sys-color, tertiary), + selected-focus-state-layer-color: map.get($systems, md-sys-color, tertiary), + selected-hover-icon-color: map.get($systems, md-sys-color, tertiary), + selected-hover-state-layer-color: map.get($systems, md-sys-color, tertiary), + selected-icon-color: map.get($systems, md-sys-color, tertiary), + selected-pressed-icon-color: map.get($systems, md-sys-color, tertiary), + unselected-pressed-state-layer-color: map.get($systems, md-sys-color, tertiary), + ), + error: ( + selected-focus-icon-color: map.get($systems, md-sys-color, error), + selected-focus-state-layer-color: map.get($systems, md-sys-color, error), + selected-hover-icon-color: map.get($systems, md-sys-color, error), + selected-hover-state-layer-color: map.get($systems, md-sys-color, error), + selected-icon-color: map.get($systems, md-sys-color, error), + selected-pressed-icon-color: map.get($systems, md-sys-color, error), + unselected-pressed-state-layer-color: map.get($systems, md-sys-color, error), + ), + ); + + @return token-utils.namespace-tokens($prefix, ($mdc-tokens, $variant-tokens), $token-slots); +} diff --git a/src/material/core/tokens/m3/mdc/_slider.scss b/src/material/core/tokens/m3/mdc/_slider.scss new file mode 100644 index 000000000000..b30d8dfdbcd8 --- /dev/null +++ b/src/material/core/tokens/m3/mdc/_slider.scss @@ -0,0 +1,61 @@ +@use 'sass:map'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mdc, slider); + +/// Generates the tokens for MDC slider +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of tokens for the MDC slider +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $mdc-tokens: token-utils.get-mdc-tokens('slider', $systems, $exclude-hardcoded); + $variant-tokens: ( + primary: (), // Default, no overrides needed + secondary: ( + active-track-color: map.get($systems, md-sys-color, secondary), + focus-handle-color: map.get($systems, md-sys-color, secondary), + focus-state-layer-color: map.get($systems, md-sys-color, secondary), + handle-color: map.get($systems, md-sys-color, secondary), + hover-handle-color: map.get($systems, md-sys-color, secondary), + hover-state-layer-color: map.get($systems, md-sys-color, secondary), + label-container-color: map.get($systems, md-sys-color, secondary), + label-label-text-color: map.get($systems, md-sys-color, on-secondary), + pressed-handle-color: map.get($systems, md-sys-color, secondary), + pressed-state-layer-color: map.get($systems, md-sys-color, secondary), + with-overlap-handle-outline-color: map.get($systems, md-sys-color, on-secondary), + with-tick-marks-active-container-color: map.get($systems, md-sys-color, on-secondary), + ), + tertiary: ( + active-track-color: map.get($systems, md-sys-color, tertiary), + focus-handle-color: map.get($systems, md-sys-color, tertiary), + focus-state-layer-color: map.get($systems, md-sys-color, tertiary), + handle-color: map.get($systems, md-sys-color, tertiary), + hover-handle-color: map.get($systems, md-sys-color, tertiary), + hover-state-layer-color: map.get($systems, md-sys-color, tertiary), + label-container-color: map.get($systems, md-sys-color, tertiary), + label-label-text-color: map.get($systems, md-sys-color, on-tertiary), + pressed-handle-color: map.get($systems, md-sys-color, tertiary), + pressed-state-layer-color: map.get($systems, md-sys-color, tertiary), + with-overlap-handle-outline-color: map.get($systems, md-sys-color, on-tertiary), + with-tick-marks-active-container-color: map.get($systems, md-sys-color, on-tertiary), + ), + error: ( + active-track-color: map.get($systems, md-sys-color, error), + focus-handle-color: map.get($systems, md-sys-color, error), + focus-state-layer-color: map.get($systems, md-sys-color, error), + handle-color: map.get($systems, md-sys-color, error), + hover-handle-color: map.get($systems, md-sys-color, error), + hover-state-layer-color: map.get($systems, md-sys-color, error), + label-container-color: map.get($systems, md-sys-color, error), + label-label-text-color: map.get($systems, md-sys-color, on-error), + pressed-handle-color: map.get($systems, md-sys-color, error), + pressed-state-layer-color: map.get($systems, md-sys-color, error), + with-overlap-handle-outline-color: map.get($systems, md-sys-color, on-error), + with-tick-marks-active-container-color: map.get($systems, md-sys-color, on-error), + ), + ); + + @return token-utils.namespace-tokens($prefix, ($mdc-tokens, $variant-tokens), $token-slots); +} diff --git a/src/material/core/tokens/m3/mdc/_snack-bar.scss b/src/material/core/tokens/m3/mdc/_snack-bar.scss new file mode 100644 index 000000000000..355e72935de0 --- /dev/null +++ b/src/material/core/tokens/m3/mdc/_snack-bar.scss @@ -0,0 +1,15 @@ +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mdc, snackbar); + +/// Generates the tokens for MDC snackbar +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of tokens for the MDC snackbar +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $mdc-tokens: token-utils.get-mdc-tokens('snackbar', $systems, $exclude-hardcoded); + + @return token-utils.namespace-tokens($prefix, $mdc-tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mdc/_switch.scss b/src/material/core/tokens/m3/mdc/_switch.scss new file mode 100644 index 000000000000..ca77b61dc4f4 --- /dev/null +++ b/src/material/core/tokens/m3/mdc/_switch.scss @@ -0,0 +1,70 @@ +@use 'sass:map'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mdc, switch); + +/// Generates the tokens for MDC switch +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of tokens for the MDC switch +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $mdc-tokens: token-utils.get-mdc-tokens('switch', $systems, $exclude-hardcoded); + $variant-tokens: ( + primary: (), // Default, no overrides needed + secondary: ( + selected-focus-handle-color: map.get($systems, md-sys-color, secondary-container), + selected-focus-icon-color: map.get($systems, md-sys-color, on-secondary-container), + selected-focus-state-layer-color: map.get($systems, md-sys-color, secondary), + selected-focus-track-color: map.get($systems, md-sys-color, secondary), + selected-handle-color: map.get($systems, md-sys-color, on-secondary), + selected-hover-handle-color: map.get($systems, md-sys-color, secondary-container), + selected-hover-icon-color: map.get($systems, md-sys-color, on-secondary-container), + selected-hover-state-layer-color: map.get($systems, md-sys-color, secondary), + selected-hover-track-color: map.get($systems, md-sys-color, secondary), + selected-icon-color: map.get($systems, md-sys-color, on-secondary-container), + selected-pressed-handle-color: map.get($systems, md-sys-color, secondary-container), + selected-pressed-icon-color: map.get($systems, md-sys-color, on-secondary-container), + selected-pressed-state-layer-color: map.get($systems, md-sys-color, secondary), + selected-pressed-track-color: map.get($systems, md-sys-color, secondary), + selected-track-color: map.get($systems, md-sys-color, secondary), + ), + tertiary: ( + selected-focus-handle-color: map.get($systems, md-sys-color, tertiary-container), + selected-focus-icon-color: map.get($systems, md-sys-color, on-tertiary-container), + selected-focus-state-layer-color: map.get($systems, md-sys-color, tertiary), + selected-focus-track-color: map.get($systems, md-sys-color, tertiary), + selected-handle-color: map.get($systems, md-sys-color, on-tertiary), + selected-hover-handle-color: map.get($systems, md-sys-color, tertiary-container), + selected-hover-icon-color: map.get($systems, md-sys-color, on-tertiary-container), + selected-hover-state-layer-color: map.get($systems, md-sys-color, tertiary), + selected-hover-track-color: map.get($systems, md-sys-color, tertiary), + selected-icon-color: map.get($systems, md-sys-color, on-tertiary-container), + selected-pressed-handle-color: map.get($systems, md-sys-color, tertiary-container), + selected-pressed-icon-color: map.get($systems, md-sys-color, on-tertiary-container), + selected-pressed-state-layer-color: map.get($systems, md-sys-color, tertiary), + selected-pressed-track-color: map.get($systems, md-sys-color, tertiary), + selected-track-color: map.get($systems, md-sys-color, tertiary), + ), + error: ( + selected-focus-handle-color: map.get($systems, md-sys-color, error-container), + selected-focus-icon-color: map.get($systems, md-sys-color, on-error-container), + selected-focus-state-layer-color: map.get($systems, md-sys-color, error), + selected-focus-track-color: map.get($systems, md-sys-color, error), + selected-handle-color: map.get($systems, md-sys-color, on-error), + selected-hover-handle-color: map.get($systems, md-sys-color, error-container), + selected-hover-icon-color: map.get($systems, md-sys-color, on-error-container), + selected-hover-state-layer-color: map.get($systems, md-sys-color, error), + selected-hover-track-color: map.get($systems, md-sys-color, error), + selected-icon-color: map.get($systems, md-sys-color, on-error-container), + selected-pressed-handle-color: map.get($systems, md-sys-color, error-container), + selected-pressed-icon-color: map.get($systems, md-sys-color, on-error-container), + selected-pressed-state-layer-color: map.get($systems, md-sys-color, error), + selected-pressed-track-color: map.get($systems, md-sys-color, error), + selected-track-color: map.get($systems, md-sys-color, error), + ), + ); + + @return token-utils.namespace-tokens($prefix, ($mdc-tokens, $variant-tokens), $token-slots); +} diff --git a/src/material/core/tokens/m3/mdc/_tab-indicator.scss b/src/material/core/tokens/m3/mdc/_tab-indicator.scss new file mode 100644 index 000000000000..cb3ac50d6833 --- /dev/null +++ b/src/material/core/tokens/m3/mdc/_tab-indicator.scss @@ -0,0 +1,33 @@ +@use 'sass:map'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mdc, tab-indicator); + +/// Generates the tokens for MDC tab-indicator +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of tokens for the MDC tab-indicator +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $tokens: ( + active-indicator-height: token-utils.hardcode(2px, $exclude-hardcoded), + active-indicator-shape: token-utils.hardcode(0, $exclude-hardcoded), + active-indicator-color: map.get($systems, md-sys-color, primary), + ); + $variant-tokens: ( + // Color variants + primary: (), // Default, no overrides needed + secondary: ( + active-indicator-color: map.get($systems, md-sys-color, secondary), + ), + tertiary: ( + active-indicator-color: map.get($systems, md-sys-color, tertiary), + ), + error: ( + active-indicator-color: map.get($systems, md-sys-color, error), + ) + ); + + @return token-utils.namespace-tokens($prefix, ($tokens, $variant-tokens), $token-slots); +} diff --git a/src/material/core/tokens/m3/mdc/_tab.scss b/src/material/core/tokens/m3/mdc/_tab.scss new file mode 100644 index 000000000000..b6b0cda33bb8 --- /dev/null +++ b/src/material/core/tokens/m3/mdc/_tab.scss @@ -0,0 +1,15 @@ +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mdc, tab); + +/// Generates the tokens for MDC tab +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of tokens for the MDC tab +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $mdc-tokens: token-utils.get-mdc-tokens('secondary-navigation-tab', $systems, $exclude-hardcoded); + + @return token-utils.namespace-tokens($prefix, $mdc-tokens, $token-slots); +} diff --git a/src/material/core/tokens/m3/mdc/_text-button.scss b/src/material/core/tokens/m3/mdc/_text-button.scss new file mode 100644 index 000000000000..eca21f745bcd --- /dev/null +++ b/src/material/core/tokens/m3/mdc/_text-button.scss @@ -0,0 +1,79 @@ +@use 'sass:map'; +@use 'sass:meta'; +@use '../../token-utils'; + +// The prefix used to generate the fully qualified name for tokens in this file. +$prefix: (mdc, text-button); + +/// Generates the tokens for MDC text-button +/// @param {Map} $systems The MDC system tokens +/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values +/// @param {Map} $token-slots Possible token slots +/// @return {Map} A set of tokens for the MDC text-button +@function get-tokens($systems, $exclude-hardcoded, $token-slots) { + $mdc-tokens: token-utils.get-mdc-tokens('text-button', $systems, $exclude-hardcoded); + $variant-tokens: ( + primary: (), // Default, no overrides needed. + secondary: ( + focus-label-text-color: map.get($systems, md-sys-color, secondary), + focus-state-layer-color: map.get($systems, md-sys-color, secondary), + hover-label-text-color: map.get($systems, md-sys-color, secondary), + hover-state-layer-color: map.get($systems, md-sys-color, secondary), + label-text-color: map.get($systems, md-sys-color, secondary), + pressed-label-text-color: map.get($systems, md-sys-color, secondary), + pressed-state-layer-color: map.get($systems, md-sys-color, secondary), + with-icon-focus-icon-color: map.get($systems, md-sys-color, secondary), + with-icon-hover-icon-color: map.get($systems, md-sys-color, secondary), + with-icon-icon-color: map.get($systems, md-sys-color, secondary), + with-icon-pressed-icon-color: map.get($systems, md-sys-color, secondary) + ), + tertiary: ( + focus-label-text-color: map.get($systems, md-sys-color, tertiary), + focus-state-layer-color: map.get($systems, md-sys-color, tertiary), + hover-label-text-color: map.get($systems, md-sys-color, tertiary), + hover-state-layer-color: map.get($systems, md-sys-color, tertiary), + label-text-color: map.get($systems, md-sys-color, tertiary), + pressed-label-text-color: map.get($systems, md-sys-color, tertiary), + pressed-state-layer-color: map.get($systems, md-sys-color, tertiary), + with-icon-focus-icon-color: map.get($systems, md-sys-color, tertiary), + with-icon-hover-icon-color: map.get($systems, md-sys-color, tertiary), + with-icon-icon-color: map.get($systems, md-sys-color, tertiary), + with-icon-pressed-icon-color: map.get($systems, md-sys-color, tertiary) + ), + error: ( + focus-label-text-color: map.get($systems, md-sys-color, error), + focus-state-layer-color: map.get($systems, md-sys-color, error), + hover-label-text-color: map.get($systems, md-sys-color, error), + hover-state-layer-color: map.get($systems, md-sys-color, error), + label-text-color: map.get($systems, md-sys-color, error), + pressed-label-text-color: map.get($systems, md-sys-color, error), + pressed-state-layer-color: map.get($systems, md-sys-color, error), + with-icon-focus-icon-color: map.get($systems, md-sys-color, error), + with-icon-hover-icon-color: map.get($systems, md-sys-color, error), + with-icon-icon-color: map.get($systems, md-sys-color, error), + with-icon-pressed-icon-color: map.get($systems, md-sys-color, error) + ) + ); + + @return token-utils.namespace-tokens($prefix, ( + _fix-tokens($mdc-tokens), + token-utils.map-values($variant-tokens, meta.get-function(_fix-tokens)) + ), $token-slots); +} + + +/// Fixes inconsistent values in the text button tokens so that they can produce valid styles. +/// @param {Map} $initial-tokens Map of text button tokens currently being generated. +/// @return {Map} The given tokens, with the invalid values replaced with valid ones. +@function _fix-tokens($initial-tokens) { + // Need to get the hardcoded values, because they include opacities that are used for the disabled + // state. + $hardcoded-tokens: token-utils.get-mdc-tokens('text-button', (), false); + + @return token-utils.combine-color-tokens($initial-tokens, $hardcoded-tokens, ( + ( + color: disabled-label-text-color, + opacity: disabled-label-text-opacity, + ), + )); +}