|
| 1 | +@use 'sass:color'; |
| 2 | +@use '@material/theme/variables' as theme-variables; |
| 3 | + |
| 4 | +@import '@material/textfield/variables.import'; |
| 5 | + |
| 6 | +// Mixin that refreshes the MDC text-field theming variables. This mixin should be used when |
| 7 | +// the base MDC theming variables have been explicitly updated, but the component specific |
| 8 | +// theming-based variables are still based on the old MDC base theming variables. The mixin |
| 9 | +// restores the previous values for the variables to avoid unexpected global side effects. |
| 10 | +@mixin _mdc-text-field-refresh-theme-variables() { |
| 11 | + $_mdc-text-field-disabled-border-border: $mdc-text-field-disabled-border-border; |
| 12 | + $mdc-text-field-disabled-border: rgba(theme-variables.prop-value(on-surface), 0.06) !global; |
| 13 | + $_mdc-text-field-bottom-line-idle: $mdc-text-field-bottom-line-idle; |
| 14 | + $mdc-text-field-bottom-line-idle: rgba(theme-variables.prop-value(on-surface), 0.42) !global; |
| 15 | + $_mdc-text-field-label: $mdc-text-field-label; |
| 16 | + $mdc-text-field-label: rgba(theme-variables.prop-value(on-surface), 0.6) !global; |
| 17 | + $_mdc-text-field-ink-color: $mdc-text-field-ink-color; |
| 18 | + $mdc-text-field-ink-color: rgba(theme-variables.prop-value(on-surface), 0.87) !global; |
| 19 | + $_mdc-text-field-focused-label-color: $mdc-text-field-focused-label-color; |
| 20 | + $mdc-text-field-focused-label-color: rgba(theme-variables.prop-value(primary), 0.87) !global; |
| 21 | + $_mdc-text-field-placeholder-ink-color: $mdc-text-field-placeholder-ink-color; |
| 22 | + $mdc-text-field-placeholder-ink-color: rgba(theme-variables.prop-value(on-surface), 0.54) !global; |
| 23 | + $_mdc-text-field-disabled-label-color: $mdc-text-field-disabled-label-color; |
| 24 | + $mdc-text-field-disabled-label-color: rgba(theme-variables.prop-value(on-surface), 0.38) !global; |
| 25 | + $_mdc-text-field-disabled-ink-color: $mdc-text-field-disabled-ink-color; |
| 26 | + $mdc-text-field-disabled-ink-color: rgba(theme-variables.prop-value(on-surface), 0.38) !global; |
| 27 | + $_mdc-text-field-disabled-placeholder-ink-color: $mdc-text-field-disabled-placeholder-ink-color; |
| 28 | + $mdc-text-field-disabled-placeholder-ink-color: |
| 29 | + rgba(theme-variables.prop-value(on-surface), 0.38) !global; |
| 30 | + $_mdc-text-field-background: $mdc-text-field-background; |
| 31 | + $mdc-text-field-background: color.mix( |
| 32 | + theme-variables.prop-value(on-surface), theme-variables.prop-value(surface), 4%) !global; |
| 33 | + $_mdc-text-field-disabled-background: $mdc-text-field-disabled-background; |
| 34 | + $mdc-text-field-disabled-background: color.mix( |
| 35 | + theme-variables.prop-value(on-surface), theme-variables.prop-value(surface), 2%) !global; |
| 36 | + $_mdc-text-field-outlined-idle-border: $mdc-text-field-outlined-idle-border; |
| 37 | + $mdc-text-field-outlined-idle-border: rgba(theme-variables.prop-value(on-surface), 0.38) !global; |
| 38 | + $_mdc-text-field-outlined-disabled-border: $mdc-text-field-outlined-disabled-border; |
| 39 | + $mdc-text-field-outlined-disabled-border: |
| 40 | + rgba(theme-variables.prop-value(on-surface), 0.06) !global; |
| 41 | + $_mdc-text-field-outlined-hover-border: $mdc-text-field-outlined-hover-border; |
| 42 | + $mdc-text-field-outlined-hover-border: rgba(theme-variables.prop-value(on-surface), 0.87) !global; |
| 43 | + |
| 44 | + // The content will be generated with the refreshed MDC text-field theming variables. |
| 45 | + @content; |
| 46 | + |
| 47 | + // Reset all variables to ensure that this mixin does not cause unexpected side effects. |
| 48 | + $mdc-text-field-disabled-border-border: $_mdc-text-field-disabled-border-border !global; |
| 49 | + $mdc-text-field-bottom-line-idle: $_mdc-text-field-bottom-line-idle !global; |
| 50 | + $mdc-text-field-label: $_mdc-text-field-label !global; |
| 51 | + $mdc-text-field-ink-color: $_mdc-text-field-ink-color !global; |
| 52 | + $mdc-text-field-focused-label-color: $_mdc-text-field-focused-label-color !global; |
| 53 | + $mdc-text-field-placeholder-ink-color: $_mdc-text-field-placeholder-ink-color !global; |
| 54 | + $mdc-text-field-disabled-label-color: $_mdc-text-field-disabled-label-color !global; |
| 55 | + $mdc-text-field-disabled-ink-color: $_mdc-text-field-disabled-ink-color !global; |
| 56 | + $mdc-text-field-disabled-placeholder-ink-color: |
| 57 | + $_mdc-text-field-disabled-placeholder-ink-color !global; |
| 58 | + $mdc-text-field-background: $_mdc-text-field-background !global; |
| 59 | + $mdc-text-field-disabled-background: $_mdc-text-field-disabled-background !global; |
| 60 | + $mdc-text-field-outlined-idle-border: $_mdc-text-field-outlined-idle-border !global; |
| 61 | + $mdc-text-field-outlined-disabled-border: $_mdc-text-field-outlined-disabled-border !global; |
| 62 | + $mdc-text-field-outlined-hover-border: $_mdc-text-field-outlined-hover-border !global; |
| 63 | +} |
0 commit comments