A fork of the Materia GTK theme.

By using this site, you agree to have cookies stored on your device, strictly for functional purposes, such as storing your session and preferences.

Dismiss

 _colors.scss

View raw Download
text/plain • 5.65 kiB
Unicode text, UTF-8 text
        
            
1
// When color definition differs for dark and light variant,
2
// it gets @if ed depending on $variant
3
4
@import 'color-palette';
5
6
$dark-theme: false !default;
7
$light-topbar: false !default;
8
9
@function gtkalpha($color, $alpha) {
10
@return unquote("alpha(#{$color}, #{$alpha})");
11
}
12
13
// Determine whether the color has alpha.
14
@function has-alpha($color) {
15
@return if(alpha($color) < 1, true, false);
16
}
17
18
// Determine whether the color is "light" or "dark".
19
@function tone($color) {
20
// Calculate color brightness as per https://www.w3.org/TR/AERT/#color-contrast
21
$brightness: (red($color) * 299 + green($color) * 587 + blue($color) * 114) / 1000;
22
23
@if $brightness >= 128 {
24
@return "light";
25
} @else {
26
@return "dark";
27
}
28
}
29
30
$on-light: #000;
31
$on-dark: #fff;
32
33
// Determine whether to use dark or light color on top of given color
34
// to meet accessibility standards for contrast.
35
@function on($color) {
36
$contrast-color: if(tone($color) == "dark", $on-dark, $on-light);
37
38
@if saturation($color) > 50% or alpha($color) < 1 {
39
@return $contrast-color;
40
} @else {
41
@return rgba($contrast-color, .87);
42
}
43
}
44
45
// Determine the strength of highlight on top of given color.
46
@function highlight($color) {
47
@if lightness($color) >= 80% {
48
@return rgba(white, .4);
49
} @else if lightness($color) >= 40% {
50
@return rgba(white, .2);
51
} @else {
52
@return rgba(white, .05);
53
}
54
}
55
56
// Make translucent color opaque by blending with the background color.
57
@function opacify($color, $on) {
58
@return mix(change-color($color, $alpha: 1), $on, alpha($color) * 100%);
59
}
60
61
$state-overlay-opacities: (
62
"hover": .08,
63
"hover-alt": .04,
64
"focus": .08,
65
"pressed": .12,
66
"dragged": .08,
67
"activated": .12,
68
"selected": .24,
69
);
70
71
// Determine the overlay color depending on the given state and color.
72
@function overlay($state, $color, $on: transparent, $opacity-modifier: 0) {
73
@if not map-has-key($state-overlay-opacities, $state) {
74
@error "Invalid state: '#{$state}'. Choose one of: #{map-keys($state-overlay-opacities)}";
75
}
76
77
@if saturation($color) > 50% or saturation($on) > 50% {
78
$opacity-modifier: .04;
79
}
80
81
$opacity: map-get($state-overlay-opacities, $state) + $opacity-modifier;
82
83
@return mix(rgba($color, 1), $on, $opacity * 100%);
84
}
85
86
//
87
// Main colors
88
//
89
90
$surface-z0: #f9f9f9;
91
$surface-z1: #fff;
92
$surface-z8: #fff;
93
$surface-switch-thumb: #fff;
94
$on-surface: on($surface-z0);
95
96
$primary-on-light: #1967d2;
97
$primary-on-dark: #8ab4f8;
98
$primary: $primary-on-light;
99
$on-primary: on($primary);
100
101
$error-on-light: #d93025;
102
$error-on-dark: #f28b82;
103
$error: $error-on-light;
104
$on-error: on($error);
105
106
$warning-on-light: #f9ab00;
107
$warning-on-dark: #fdd663;
108
$warning: $warning-on-light;
109
$on-warning: on($warning);
110
111
$success-on-light: #1e8e3e;
112
$success-on-dark: #81c995;
113
$success: $success-on-light;
114
$on-success: on($success);
115
116
$visited-on-light: #9334e6;
117
$visited-on-dark: #c58af9;
118
$visited: $visited-on-light;
119
$on-visited: on($visited);
120
121
$system: #212121;
122
$on-system: on($system);
123
124
$tooltip: rgba(#616161, .9);
125
$on-tooltip: on($tooltip);
126
127
$scrim: rgba(black, .6);
128
$on-scrim: on($scrim);
129
130
$scrim-alt: rgba(black, .3);
131
$on-scrim-alt: on($scrim-alt);
132
133
$panel: #212121;
134
$on-panel: on($panel);
135
136
// for Unity panel which doesn't allow translucent colors
137
$panel-solid: $panel;
138
$on-panel-solid: on($panel-solid);
139
140
$titlebar: #424242;
141
$titlebar-backdrop: #303030;
142
$on-titlebar: on($titlebar);
143
144
$titlebar-indicator: currentcolor;
145
146
@if $dark-theme {
147
$surface-z0: #121212;
148
$surface-z1: mix(white, $surface-z0, 5%);
149
$surface-z8: mix(white, $surface-z0, 12%);
150
$surface-switch-thumb: mix(white, $surface-z0, 60%);
151
$on-surface: on($surface-z0);
152
153
$primary: $primary-on-dark;
154
$on-primary: on($primary);
155
156
$error: $error-on-dark;
157
$on-error: on($error);
158
159
$warning: $warning-on-dark;
160
$on-warning: on($warning);
161
162
$success: $success-on-dark;
163
$on-success: on($success);
164
165
$visited: $visited-on-dark;
166
$on-visited: on($visited);
167
168
$titlebar: mix(white, $surface-z0, 9%);
169
$titlebar-backdrop: $surface-z1;
170
$on-titlebar: on($titlebar);
171
}
172
173
@if $light-topbar {
174
$panel: $scrim;
175
$on-panel: on($panel);
176
177
$panel-solid: #e0e0e0;
178
$on-panel-solid: on($panel-solid);
179
180
$titlebar: #f0f0f0;
181
$titlebar-backdrop: #ebebeb;
182
$on-titlebar: on($titlebar);
183
184
$titlebar-indicator: $primary;
185
}
186
187
//
188
// Overlay state colors
189
//
190
191
$overlay-selected: rgba($primary, .24);
192
193
//
194
// For “on” colors
195
//
196
197
@function primary($color) {
198
@return if(tone($color) == "dark", $primary-on-light, $primary-on-dark);
199
}
200
201
@function error($color) {
202
@return if(tone($color) == "dark", $error-on-light, $error-on-dark);
203
}
204
205
@function hint($color) {
206
@return rgba($color, if(has-alpha($color), .6, .7));
207
}
208
209
@function disabled($color) {
210
@return rgba($color, if(has-alpha($color), .38, .5));
211
}
212
213
@function disabled-hint($color) {
214
@return rgba($color, if(has-alpha($color), .26, .3));
215
}
216
217
@function stroke($color) {
218
@return rgba($color, if(has-alpha($color), .26, .3));
219
}
220
221
@function disabled-stroke($color) {
222
@return rgba($color, if(has-alpha($color), .12, .2));
223
}
224
225
@function divider($color) {
226
@return rgba($color, if(has-alpha($color), .12, .2));
227
}
228
229
@function fill($color) {
230
@return rgba($color, if(has-alpha($color), .08, .08));
231
}
232
233
@function entry-fill($color) {
234
@return rgba($color, if(has-alpha($color), .04, .04));
235
}
236
237
@function scrollbar-thumb($color, $state: null) {
238
@if $state == null {
239
@return rgba($color, if(has-alpha($color), .38, .5));
240
} @else if $state == "hover" {
241
@return rgba($color, if(has-alpha($color), .48, .6));
242
} @else if $state == "pressed" {
243
@return rgba($color, if(has-alpha($color), .6, .7));
244
} @else if $state == "disabled" {
245
@return rgba($color, if(has-alpha($color), .26, .3));
246
} @else {
247
@error "Invalid type: '#{$state}'";
248
}
249
}
250