forked from angular/components
-
Notifications
You must be signed in to change notification settings - Fork 9
/
_datepicker.scss
182 lines (154 loc) · 7.98 KB
/
_datepicker.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
@use '@material/elevation/elevation-theme' as mdc-elevation;
@use 'sass:color';
@use 'sass:meta';
@use 'sass:math';
@use '../../token-utils';
@use '../../../theming/inspection';
@use '../../../style/sass-utils';
// The prefix used to generate the fully qualified name for tokens in this file.
$prefix: (mat, datepicker);
$_selected-fade-amount: 0.6;
$_today-fade-amount: 0.2;
// Utility that produces a range background color from a specific color.
@function private-get-range-background-color($color) {
@return rgba($color, 0.2);
}
// Utility that produces the overlap selected color from an overlap color.
@function private-get-default-overlap-selected-color($overlap-color) {
@return color.adjust($overlap-color, $lightness: -30%);
}
// Default range comparison color.
$private-default-comparison-color: private-get-range-background-color(#f9ab00);
// Default range overlap color.
$private-default-overlap-color: #a8dab5;
// Tokens that can't be configured through Angular Material's current theming API,
// but may be in a future version of the theming API.
@function get-unthemable-tokens() {
@return (
calendar-container-shape: 4px,
calendar-container-touch-shape: 4px,
calendar-container-elevation-shadow: mdc-elevation.elevation-box-shadow(4),
calendar-container-touch-elevation-shadow: mdc-elevation.elevation-box-shadow(24),
);
}
// Tokens that can be configured through Angular Material's color theming API.
@function get-color-tokens($theme) {
$inactive-icon-color: inspection.get-theme-color($theme, foreground, icon);
$text-color: inspection.get-theme-color($theme, foreground, text);
$secondary-text-color: inspection.get-theme-color($theme, foreground, secondary-text);
$disabled-text-color: inspection.get-theme-color($theme, foreground, disabled-text);
$divider-color: inspection.get-theme-color($theme, foreground, divider);
$hint-text-color: inspection.get-theme-color($theme, foreground, hint-text);
$preview-outline-color: $divider-color;
$today-disabled-outline-color: null;
$is-dark: inspection.get-theme-type($theme) == dark;
$primary-color: inspection.get-theme-color($theme, primary);
$range-tokens: get-range-color-tokens(private-get-range-background-color($primary-color));
$calendar-tokens: private-get-calendar-color-palette-color-tokens($theme, primary);
$toggle-tokens: private-get-toggle-color-palette-color-tokens($theme, primary);
// The divider color is set under the assumption that it'll be used
// for a solid border, but because we're using a dashed border for the
// preview range, we need to bump its opacity to ensure that it's visible.
@if meta.type-of($preview-outline-color) == color {
$preview-outline-opacity: math.min(opacity($preview-outline-color) * 2, 1);
$preview-outline-color: rgba($preview-outline-color, $preview-outline-opacity);
}
@if (meta.type-of($hint-text-color) == color) {
$today-disabled-outline-color: color.adjust($hint-text-color, $alpha: -$_today-fade-amount);
}
@else {
$today-disabled-outline-color: $disabled-text-color;
}
@return sass-utils.merge-all($calendar-tokens, $toggle-tokens, $range-tokens, (
toggle-icon-color: $inactive-icon-color,
calendar-body-label-text-color: $secondary-text-color,
calendar-period-button-text-color: inspection.get-theme-color($theme, foreground, text, 1),
calendar-period-button-icon-color: $inactive-icon-color,
calendar-navigation-button-icon-color: $inactive-icon-color,
calendar-header-divider-color: $divider-color,
calendar-header-text-color: $secondary-text-color,
// Note: though it's not text, the border is a hint about the fact
// that this is today's date, so we use the hint color.
calendar-date-today-outline-color: $hint-text-color,
calendar-date-today-disabled-state-outline-color: $today-disabled-outline-color,
calendar-date-text-color: $text-color,
calendar-date-outline-color: transparent,
calendar-date-disabled-state-text-color: $disabled-text-color,
calendar-date-preview-state-outline-color: $preview-outline-color,
range-input-separator-color: $text-color,
range-input-disabled-state-separator-color: $disabled-text-color,
range-input-disabled-state-text-color: $disabled-text-color,
calendar-container-background-color: inspection.get-theme-color($theme, background, card),
calendar-container-text-color: $text-color,
));
}
// Tokens that can be configured through Angular Material's typography theming API.
@function get-typography-tokens($theme) {
@return (
// TODO(crisbeto): the typography tokens for other components set every typography dimension of
// an element (e.g. size, weight, line height, letter spacing). These tokens only set the values
// that were set in the previous theming API to reduce the amount of subtle screenshot
// differences. We should look into introducing the other tokens in a follow-up.
calendar-text-font: inspection.get-theme-typography($theme, body-1, font-family),
calendar-text-size: 13px, // TODO(crisbeto): this doesn't appear to affect anything
calendar-body-label-text-size: inspection.get-theme-typography($theme, button, font-size),
calendar-body-label-text-weight: inspection.get-theme-typography($theme, button, font-weight),
calendar-period-button-text-size: inspection.get-theme-typography($theme, button, font-size),
calendar-period-button-text-weight: inspection.get-theme-typography(
$theme, button, font-weight),
calendar-header-text-size: 11px,
calendar-header-text-weight: inspection.get-theme-typography($theme, body-1, font-weight),
);
}
// Gets the tokens map that can be used to override the range colors.
@function get-range-color-tokens(
$range-color,
$comparison-color: $private-default-comparison-color,
$overlap-color: $private-default-overlap-color,
$overlap-selected-color: private-get-default-overlap-selected-color($overlap-color)) {
@return (
calendar-date-in-range-state-background-color: $range-color,
calendar-date-in-comparison-range-state-background-color: $comparison-color,
calendar-date-in-overlap-range-state-background-color: $overlap-color,
calendar-date-in-overlap-range-selected-state-background-color: $overlap-selected-color,
);
}
@function private-get-calendar-color-palette-color-tokens($theme, $palette-name) {
$palette-color: inspection.get-theme-color($theme, $palette-name);
$default-contrast: inspection.get-theme-color($theme, $palette-name, default-contrast);
$active-background-color: sass-utils.safe-color-change($palette-color, $alpha: 0.3);
$active-disabled-color: null;
@if (meta.type-of($palette-color) == color) {
$active-disabled-color: color.adjust($palette-color, $alpha: -$_selected-fade-amount);
}
@else {
$active-disabled-color: inspection.get-theme-color($theme, foreground, disabled-button);
}
@return (
calendar-date-selected-state-text-color: $default-contrast,
calendar-date-selected-state-background-color: $palette-color,
calendar-date-selected-disabled-state-background-color: $active-disabled-color,
calendar-date-today-selected-state-outline-color: $default-contrast,
calendar-date-focus-state-background-color: $active-background-color,
calendar-date-hover-state-background-color: $active-background-color,
);
}
@function private-get-toggle-color-palette-color-tokens($theme, $palette-name) {
@return (
toggle-active-state-icon-color: inspection.get-theme-color($theme, $palette-name, text),
);
}
// 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(token-utils.$placeholder-color-config),
get-typography-tokens(token-utils.$placeholder-typography-config),
get-density-tokens(token-utils.$placeholder-density-config)
);
}