forked from angular/components
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_m2-outlined-text-field.scss
100 lines (87 loc) · 4.24 KB
/
_m2-outlined-text-field.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
89
90
91
92
93
94
95
96
97
98
99
100
@use 'sass:map';
@use '../core/theming/inspection';
@use '../core/style/sass-utils';
@use '../core/tokens/m2-utils';
// The prefix used to generate the fully qualified name for tokens in this file.
$prefix: (mat, form-field-outlined);
// Tokens that can't be configured through Angular Material's current theming API,
// but may be in a future version of the theming API.
//
// Tokens that are available in MDC, but not used in Angular Material should be mapped to `null`.
// `null` indicates that we are intentionally choosing not to emit a slot or value for the token in
// our CSS.
@function get-unthemable-tokens() {
@return (
outline-width: 1px,
focus-outline-width: 2px,
container-shape: 4px,
);
}
// Tokens that can be configured through Angular Material's color theming API.
@function get-color-tokens($theme) {
$is-dark: inspection.get-theme-type($theme) == dark;
$warn-color: inspection.get-theme-color($theme, warn);
$color-tokens: private-get-color-palette-color-tokens($theme, primary);
// Ideally we would derive all values directly from the theme, but it causes a lot of regressions
// internally. For now we fall back to the old hardcoded behavior only for internal apps.
$on-surface: if($is-dark, #fff, #000);
$text-color-base: if(m2-utils.$private-is-internal-build, $on-surface,
inspection.get-theme-color($theme, foreground, text, 1));
$disabled-text-color-base: if(m2-utils.$private-is-internal-build, $on-surface,
inspection.get-theme-color($theme, foreground, disabled-text, 1));
$divider-base: if(m2-utils.$private-is-internal-build, $on-surface,
inspection.get-theme-color($theme, foreground, divider, 1));
@return map.merge($color-tokens, (
label-text-color: sass-utils.safe-color-change($text-color-base, $alpha: 0.6),
hover-label-text-color: sass-utils.safe-color-change($text-color-base, $alpha: 0.6),
disabled-label-text-color:
sass-utils.safe-color-change($disabled-text-color-base, $alpha: 0.38),
input-text-color: sass-utils.safe-color-change($text-color-base, $alpha: 0.87),
disabled-input-text-color:
sass-utils.safe-color-change($disabled-text-color-base, $alpha: 0.38),
input-text-placeholder-color: sass-utils.safe-color-change($text-color-base, $alpha: 0.6),
error-caret-color: $warn-color,
error-focus-label-text-color: $warn-color,
error-label-text-color: $warn-color,
error-hover-label-text-color: $warn-color,
// Outline tokens
outline-color: sass-utils.safe-color-change($divider-base, $alpha: 0.38),
disabled-outline-color: sass-utils.safe-color-change($divider-base, $alpha: 0.06),
hover-outline-color: sass-utils.safe-color-change($divider-base, $alpha: 0.87),
error-focus-outline-color: $warn-color,
error-hover-outline-color: $warn-color,
error-outline-color: $warn-color,
));
}
// Generates the mapping for the properties that change based on the text field color.
@function private-get-color-palette-color-tokens($theme, $palette-name) {
$palette-color: inspection.get-theme-color($theme, $palette-name);
@return (
caret-color: $palette-color,
focus-outline-color: $palette-color,
focus-label-text-color: sass-utils.safe-color-change($palette-color, $alpha: 0.87),
);
}
// Tokens that can be configured through Angular Material's typography theming API.
@function get-typography-tokens($theme) {
@return (
label-text-font: inspection.get-theme-typography($theme, body-1, font-family),
label-text-size: inspection.get-theme-typography($theme, body-1, font-size),
label-text-tracking: inspection.get-theme-typography($theme, body-1, letter-spacing),
label-text-weight: inspection.get-theme-typography($theme, body-1, font-weight),
);
}
// Tokens that can be configured through Angular Material's density theming API.
@function get-density-tokens($theme) {
@return ();
}
// Combines the tokens generated by the above functions into a single map with placeholder values.
// This is used to create token slots.
@function get-token-slots() {
@return sass-utils.deep-merge-all(
get-unthemable-tokens(),
get-color-tokens(m2-utils.$placeholder-color-config),
get-typography-tokens(m2-utils.$placeholder-typography-config),
get-density-tokens(m2-utils.$placeholder-density-config)
);
}