forked from angular/components
/
_mdc-text-field-theme-variable-refresh.scss
88 lines (83 loc) · 4.53 KB
/
_mdc-text-field-theme-variable-refresh.scss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
@use '@material/textfield' as mdc-textfield;
@use '@material/theme/variables' as mdc-theme-variables;
@use 'sass:color';
@use 'sass:meta';
// Mixin that refreshes the MDC text-field theming variables. This mixin should be used when
// the base MDC theming variables have been explicitly updated, but the component specific
// theming-based variables are still based on the old MDC base theming variables. The mixin
// restores the previous values for the variables to avoid unexpected global side effects.
@mixin private-text-field-refresh-theme-variables() {
$_disabled-border: mdc-textfield.$disabled-border;
mdc-textfield.$disabled-border:
_variable-safe-rgba(mdc-theme-variables.prop-value(on-surface), 0.06);
$_bottom-line-hover: mdc-textfield.$bottom-line-hover;
mdc-textfield.$bottom-line-hover:
_variable-safe-rgba(mdc-theme-variables.prop-value(on-surface), 0.87);
$_bottom-line-idle: mdc-textfield.$bottom-line-idle;
mdc-textfield.$bottom-line-idle:
_variable-safe-rgba(mdc-theme-variables.prop-value(on-surface), 0.42);
$_label: mdc-textfield.$label;
mdc-textfield.$label: _variable-safe-rgba(mdc-theme-variables.prop-value(on-surface), 0.6);
$_ink-color: mdc-textfield.$ink-color;
mdc-textfield.$ink-color: _variable-safe-rgba(mdc-theme-variables.prop-value(on-surface), 0.87);
$_focused-label-color: mdc-textfield.$focused-label-color;
mdc-textfield.$focused-label-color:
_variable-safe-rgba(mdc-theme-variables.prop-value(primary), 0.87);
$_placeholder-ink-color: mdc-textfield.$placeholder-ink-color;
mdc-textfield.$placeholder-ink-color:
_variable-safe-rgba(mdc-theme-variables.prop-value(on-surface), 0.6);
$_disabled-label-color: mdc-textfield.$disabled-label-color;
mdc-textfield.$disabled-label-color:
_variable-safe-rgba(mdc-theme-variables.prop-value(on-surface), 0.38);
$_disabled-ink-color: mdc-textfield.$disabled-ink-color;
mdc-textfield.$disabled-ink-color:
_variable-safe-rgba(mdc-theme-variables.prop-value(on-surface), 0.38);
$_disabled-placeholder-ink-color: mdc-textfield.$disabled-placeholder-ink-color;
mdc-textfield.$disabled-placeholder-ink-color:
_variable-safe-rgba(mdc-theme-variables.prop-value(on-surface), 0.38);
$_background: mdc-textfield.$background;
mdc-textfield.$background: _variable-safe-mix(mdc-theme-variables.prop-value(on-surface),
mdc-theme-variables.prop-value(surface), 4%);
$_disabled-background: mdc-textfield.$disabled-background;
mdc-textfield.$disabled-background: _variable-safe-mix(mdc-theme-variables.prop-value(on-surface),
mdc-theme-variables.prop-value(surface), 2%);
$_outlined-idle-border: mdc-textfield.$outlined-idle-border;
mdc-textfield.$outlined-idle-border:
_variable-safe-rgba(mdc-theme-variables.prop-value(on-surface), 0.38);
$_outlined-disabled-border: mdc-textfield.$outlined-disabled-border;
mdc-textfield.$outlined-disabled-border:
_variable-safe-rgba(mdc-theme-variables.prop-value(on-surface), 0.06);
$_outlined-hover-border: mdc-textfield.$outlined-hover-border;
mdc-textfield.$outlined-hover-border:
_variable-safe-rgba(mdc-theme-variables.prop-value(on-surface), 0.87);
// The content will be generated with the refreshed MDC text-field theming variables.
@content;
// Reset all variables to ensure that this mixin does not cause unexpected side effects.
mdc-textfield.$disabled-border: $_disabled-border;
mdc-textfield.$bottom-line-hover: $_bottom-line-hover;
mdc-textfield.$bottom-line-idle: $_bottom-line-idle;
mdc-textfield.$label: $_label;
mdc-textfield.$ink-color: $_ink-color;
mdc-textfield.$focused-label-color: $_focused-label-color;
mdc-textfield.$placeholder-ink-color: $_placeholder-ink-color;
mdc-textfield.$disabled-label-color: $_disabled-label-color;
mdc-textfield.$disabled-ink-color: $_disabled-ink-color;
mdc-textfield.$disabled-placeholder-ink-color: $_disabled-placeholder-ink-color;
mdc-textfield.$background: $_background;
mdc-textfield.$disabled-background: $_disabled-background;
mdc-textfield.$outlined-idle-border: $_outlined-idle-border;
mdc-textfield.$outlined-disabled-border: $_outlined-disabled-border;
mdc-textfield.$outlined-hover-border: $_outlined-hover-border;
}
@function _variable-safe-rgba($color, $opacity) {
@if (meta.type-of($color) == color) {
@return rgba($color, $opacity);
}
@return $color;
}
@function _variable-safe-mix($first-color, $second-color, $amount) {
@if (meta.type-of($first-color) == color and meta.type-of($second-color) == color) {
@return color.mix($first-color, $second-color, $amount);
}
@return $first-color;
}