-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
_variables.scss
166 lines (144 loc) · 6.54 KB
/
_variables.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
//
// Copyright 2017 Google Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
@import "./functions";
//
// Main theme colors for your brand.
//
// If you're a user customizing your color scheme in SASS, these are probably the only variables you need to change.
//
$mdc-theme-primary: #6200ee !default; // baseline purple, 500 tone
$mdc-theme-on-primary: if(mdc-theme-contrast-tone($mdc-theme-primary) == "dark", #000, #fff) !default;
// The $mdc-theme-accent variable is DEPRECATED - it exists purely for backward compatibility.
// The $mdc-theme-secondary* variables should be used for all new projects.
$mdc-theme-accent: #018786 !default; // baseline teal, 600 tone
$mdc-theme-secondary: $mdc-theme-accent !default;
$mdc-theme-on-secondary: if(mdc-theme-contrast-tone($mdc-theme-secondary) == "dark", #000, #fff) !default;
$mdc-theme-background: #fff !default; // White
$mdc-theme-surface: #fff !default;
$mdc-theme-on-surface: if(mdc-theme-contrast-tone($mdc-theme-surface) == "dark", #000, #fff) !default;
$mdc-theme-error: #b00020 !default;
$mdc-theme-on-error: if(mdc-theme-contrast-tone($mdc-theme-error) == "dark", #000, #fff) !default;
//
// Text colors according to light vs dark and text type.
//
$mdc-theme-text-colors: (
dark: (
primary: rgba(black, .87),
secondary: rgba(black, .54),
hint: rgba(black, .38),
disabled: rgba(black, .38),
icon: rgba(black, .38)
),
light: (
primary: white,
secondary: rgba(white, .7),
hint: rgba(white, .5),
disabled: rgba(white, .5),
icon: rgba(white, .5)
)
) !default;
$mdc-theme-text-emphasis: (
high: .87,
medium: .6,
disabled: .38,
) !default;
@function mdc-theme-ink-color-for-fill_($text-style, $fill-color) {
$contrast-tone: mdc-theme-contrast-tone($fill-color);
@return map-get(map-get($mdc-theme-text-colors, $contrast-tone), $text-style);
}
//
// Primary text colors for each of the theme colors.
//
$mdc-theme-property-values: (
// Primary
primary: $mdc-theme-primary,
// Secondary
secondary: $mdc-theme-secondary,
// Background
background: $mdc-theme-background,
// Surface
surface: $mdc-theme-surface,
// Error
error: $mdc-theme-error,
on-primary: $mdc-theme-on-primary,
on-secondary: $mdc-theme-on-secondary,
on-surface: $mdc-theme-on-surface,
on-error: $mdc-theme-on-error,
// Text-primary on "background" background
text-primary-on-background: mdc-theme-ink-color-for-fill_(primary, $mdc-theme-background),
text-secondary-on-background: mdc-theme-ink-color-for-fill_(secondary, $mdc-theme-background),
text-hint-on-background: mdc-theme-ink-color-for-fill_(hint, $mdc-theme-background),
text-disabled-on-background: mdc-theme-ink-color-for-fill_(disabled, $mdc-theme-background),
text-icon-on-background: mdc-theme-ink-color-for-fill_(icon, $mdc-theme-background),
// Text-primary on "light" background
text-primary-on-light: mdc-theme-ink-color-for-fill_(primary, light),
text-secondary-on-light: mdc-theme-ink-color-for-fill_(secondary, light),
text-hint-on-light: mdc-theme-ink-color-for-fill_(hint, light),
text-disabled-on-light: mdc-theme-ink-color-for-fill_(disabled, light),
text-icon-on-light: mdc-theme-ink-color-for-fill_(icon, light),
// Text-primary on "dark" background
text-primary-on-dark: mdc-theme-ink-color-for-fill_(primary, dark),
text-secondary-on-dark: mdc-theme-ink-color-for-fill_(secondary, dark),
text-hint-on-dark: mdc-theme-ink-color-for-fill_(hint, dark),
text-disabled-on-dark: mdc-theme-ink-color-for-fill_(disabled, dark),
text-icon-on-dark: mdc-theme-ink-color-for-fill_(icon, dark)
) !default;
// If `$style` is a color (a literal color value, `currentColor`, or a CSS custom property), it is returned verbatim.
// Otherwise, `$style` is treated as a theme property name, and the corresponding value from
// `$mdc-theme-property-values` is returned. If this also fails, an error is thrown.
//
// This is mainly useful in situations where `mdc-theme-prop` cannot be used directly (e.g., `box-shadow`).
//
// Examples:
//
// 1. mdc-theme-prop-value(primary) => "#6200ee"
// 2. mdc-theme-prop-value(blue) => "blue"
//
// NOTE: This function must be defined in _variables.scss instead of _functions.scss to avoid circular imports.
@function mdc-theme-prop-value($style) {
@if mdc-theme-is-var-with-fallback_($style) {
@return mdc-theme-get-var-fallback_($style);
}
@if mdc-theme-is-valid-theme-prop-value_($style) {
@return $style;
}
@if not map-has-key($mdc-theme-property-values, $style) {
@error "Invalid theme property: '#{$style}'. Choose one of: #{map-keys($mdc-theme-property-values)}";
}
@return map-get($mdc-theme-property-values, $style);
}
// NOTE: This function must be defined in _variables.scss instead of _functions.scss to avoid circular imports.
@function mdc-theme-accessible-ink-color($fill-color, $text-style: primary) {
$fill-color-value: mdc-theme-prop-value($fill-color);
$color-map-for-tone: map-get($mdc-theme-text-colors, mdc-theme-contrast-tone($fill-color-value));
@if not map-has-key($color-map-for-tone, $text-style) {
@error "Invalid $text-style: '#{$text-style}'. Choose one of: #{map-keys($color-map-for-tone)}";
}
@return map-get($color-map-for-tone, $text-style);
}
// NOTE: This function is depended upon by mdc-theme-prop-value (above) and thus must be defined in this file.
@function mdc-theme-is-valid-theme-prop-value_($style) {
@return type-of($style) == "color" or $style == "currentColor" or str_slice($style, 1, 4) == "var(";
}
@function mdc-theme-text-emphasis($emphasis) {
@return map-get($mdc-theme-text-emphasis, $emphasis);
}