1
1
@use ' sass:color' ;
2
- @use ' sass:meta' ;
3
- @use ' sass:math' ;
4
2
@use ' ../core/theming/inspection' ;
5
3
@use ' ../core/style/elevation' ;
6
- @use ' ../core/style/sass-utils' ;
7
4
@use ' ../core/tokens/m3-utils' ;
8
5
@use ' ../core/tokens/m2-utils' ;
9
6
@use ' sass:map' ;
10
7
11
- $_selected-fade-amount : 0.6 ;
12
- $_today-fade-amount : 0.2 ;
13
-
14
- // Utility that produces a range background color from a specific color.
15
- @function private-get-range-background-color ($color ) {
16
- @return rgba ($color , 0.2 );
17
- }
18
-
19
- // Utility that produces the overlap selected color from an overlap color.
20
- @function private-get-default-overlap-selected-color ($overlap-color ) {
21
- @return color .adjust ($overlap-color , $lightness : -30% );
22
- }
23
-
24
- // Default range comparison color.
25
- $private-default-comparison-color : private-get-range-background-color (#f9ab00 );
26
-
27
- // Default range overlap color.
28
- $private-default-overlap-color : #a8dab5 ;
29
-
30
8
// Tokens that can't be configured through Angular Material's current theming API,
31
9
// but may be in a future version of the theming API.
32
10
@function get-unthemable-tokens () {
@@ -39,61 +17,50 @@ $private-default-overlap-color: #a8dab5;
39
17
}
40
18
41
19
// Tokens that can be configured through Angular Material's color theming API.
42
- @function get-color-tokens ($theme ) {
20
+ @function get-color-tokens ($theme , $color-variant ) {
43
21
$system : m2-utils .get-system ($theme );
44
-
45
- $inactive-icon-color : inspection .get-theme-color ($theme , foreground , icon );
22
+ $system : m3-utils .replace-colors-with-variant ($system , primary , $color-variant );
46
23
$disabled : m3-utils .color-with-opacity (map .get ($system , on-surface ), 38% );
47
- $hint-text-color : inspection .get-theme-color ($theme , foreground , hint-text );
48
- $preview-outline-color : map .get ($system , outline );
49
- $today-disabled-outline-color : null;
50
- $is-dark : inspection .get-theme-type ($theme ) == dark ;
51
- $system : m2-utils .get-system ($theme );
52
-
53
- $primary-color : map .get ($system , primary );
54
- $range-tokens : get-range-color-tokens (private-get-range-background-color ($primary-color ));
55
- $calendar-tokens : private-get-calendar-color-palette-color-tokens ($theme , primary );
56
- $toggle-tokens : private-get-toggle-color-palette-color-tokens ($theme , primary );
57
-
58
- // The divider color is set under the assumption that it'll be used
59
- // for a solid border, but because we're using a dashed border for the
60
- // preview range, we need to bump its opacity to ensure that it's visible.
61
- @if meta .type-of ($preview-outline-color ) == color {
62
- $preview-outline-opacity : math .min (color .opacity ($preview-outline-color ) * 2 , 1 );
63
- $preview-outline-color : rgba ($preview-outline-color , $preview-outline-opacity );
64
- }
65
24
66
- @if (meta .type-of ($hint-text-color ) == color ) {
67
- $today-disabled-outline-color : color .adjust ($hint-text-color , $alpha : - $_today-fade-amount );
68
- }
69
- @else {
70
- $today-disabled-outline-color : $disabled ;
71
- }
72
-
73
- @return sass-utils .merge-all ($calendar-tokens , $toggle-tokens , $range-tokens , (
25
+ @return (
26
+ datepicker- calendar- date- in- range- state- background- color:
27
+ m3-utils .color-with-opacity (map .get ($system , primary ), 20% ),
28
+ datepicker- calendar- date- in- comparison- range- state- background- color:
29
+ m3-utils .color-with-opacity (map .get ($system , secondary ), 20% ),
30
+ datepicker- calendar- date- in- overlap- range- state- background- color: #a8dab5 ,
31
+ datepicker- calendar- date- in- overlap- range- selected- state- background- color:
32
+ color .adjust (#a8dab5 , $lightness : -30% ),
33
+ datepicker- calendar- date- selected- state- text- color: map .get ($system , on-primary ),
34
+ datepicker- calendar- date- selected- state- background- color: map .get ($system , primary ),
35
+ datepicker- calendar- date- selected- disabled- state- background- color:
36
+ m3-utils .color-with-opacity (map .get ($system , primary ), 38% ),
37
+ datepicker- calendar- date- today- selected- state- outline- color: map .get ($system , on-primary ),
38
+ datepicker- calendar- date- focus- state- background- color: m3-utils .color-with-opacity (
39
+ map .get ($system , primary ), map .get ($system , focus-state-layer-opacity )),
40
+ datepicker- calendar- date- hover- state- background- color: m3-utils .color-with-opacity (
41
+ map .get ($system , primary ), map .get ($system , hover-state-layer-opacity )),
42
+
43
+ datepicker- toggle- active- state- icon- color: map .get ($system , primary ),
74
44
datepicker- toggle- icon- color: map .get ($system , on-surface-variant ),
75
45
datepicker- calendar- body- label- text- color: map .get ($system , on-surface-variant ),
76
- datepicker- calendar- period- button- text- color:
77
- inspection .get-theme-color ($theme , foreground , base ),
46
+ datepicker- calendar- period- button- text- color: map .get ($system , on-surface ),
78
47
datepicker- calendar- period- button- icon- color: map .get ($system , on-surface-variant ),
79
48
datepicker- calendar- navigation- button- icon- color: map .get ($system , on-surface-variant ),
80
49
datepicker- calendar- header- divider- color: map .get ($system , outline ),
81
50
datepicker- calendar- header- text- color: map .get ($system , on-surface-variant ),
82
51
83
- // Note: though it's not text, the border is a hint about the fact
84
- // that this is today's date, so we use the hint color.
85
- datepicker- calendar- date- today- outline- color: $hint-text-color ,
86
- datepicker- calendar- date- today- disabled- state- outline- color: $today-disabled-outline-color ,
52
+ datepicker- calendar- date- today- outline- color: map .get ($system , on-surface-variant ),
53
+ datepicker- calendar- date- today- disabled- state- outline- color: $disabled ,
87
54
datepicker- calendar- date- text- color: map .get ($system , on-surface ),
88
55
datepicker- calendar- date- outline- color: transparent ,
89
56
datepicker- calendar- date- disabled- state- text- color: $disabled ,
90
- datepicker- calendar- date- preview- state- outline- color: $preview-outline-color ,
57
+ datepicker- calendar- date- preview- state- outline- color: map . get ( $system , on-surface-variant ) ,
91
58
datepicker- range- input- separator- color: map .get ($system , on-surface ),
92
59
datepicker- range- input- disabled- state- separator- color: $disabled ,
93
60
datepicker- range- input- disabled- state- text- color: $disabled ,
94
61
datepicker- calendar- container- background- color: map .get ($system , surface ),
95
62
datepicker- calendar- container- text- color: map .get ($system , on-surface ),
96
- )) ;
63
+ );
97
64
}
98
65
99
66
// Tokens that can be configured through Angular Material's typography theming API.
@@ -122,56 +89,6 @@ $private-default-overlap-color: #a8dab5;
122
89
);
123
90
}
124
91
125
- // Gets the tokens map that can be used to override the range colors.
126
- @function get-range-color-tokens (
127
- $range-color ,
128
- $comparison-color : $private-default-comparison-color ,
129
- $overlap-color : $private-default-overlap-color ,
130
- $overlap-selected-color : private-get-default-overlap-selected-color ($overlap-color )) {
131
-
132
- @return (
133
- datepicker- calendar- date- in- range- state- background- color: $range-color ,
134
- datepicker- calendar- date- in- comparison- range- state- background- color: $comparison-color ,
135
- datepicker- calendar- date- in- overlap- range- state- background- color: $overlap-color ,
136
- datepicker- calendar- date- in- overlap- range- selected- state- background- color:
137
- $overlap-selected-color ,
138
- );
139
- }
140
-
141
- @function private-get-calendar-color-palette-color-tokens ($theme , $color-variant ) {
142
- $system : m2-utils .get-system ($theme );
143
- $system : m3-utils .replace-colors-with-variant ($system , primary , $color-variant );
144
-
145
- $palette-color : map .get ($system , primary );
146
- $default-contrast : map .get ($system , on-primary );
147
- $active-background-color : m3-utils .color-with-opacity (map .get ($system , primary ), 30% );
148
- $active-disabled-color : null;
149
-
150
- @if (meta .type-of ($palette-color ) == color ) {
151
- $active-disabled-color : color .adjust ($palette-color , $alpha : - $_selected-fade-amount );
152
- }
153
- @else {
154
- $active-disabled-color : m3-utils .color-with-opacity (map .get ($system , on-surface ), 38% );
155
- }
156
-
157
- @return (
158
- datepicker- calendar- date- selected- state- text- color: $default-contrast ,
159
- datepicker- calendar- date- selected- state- background- color: $palette-color ,
160
- datepicker- calendar- date- selected- disabled- state- background- color: $active-disabled-color ,
161
- datepicker- calendar- date- today- selected- state- outline- color: $default-contrast ,
162
- datepicker- calendar- date- focus- state- background- color: $active-background-color ,
163
- datepicker- calendar- date- hover- state- background- color: $active-background-color ,
164
- );
165
- }
166
-
167
- @function private-get-toggle-color-palette-color-tokens ($theme , $palette-name ) {
168
- @return (
169
- datepicker- toggle- active- state- icon- color:
170
- inspection .get-theme-color ($theme , $palette-name , text ),
171
- );
172
- }
173
-
174
-
175
92
// Tokens that can be configured through Angular Material's density theming API.
176
93
@function get-density-tokens ($theme ) {
177
94
@return ();
0 commit comments