A fork of the Materia GTK theme.

Important information: Google announced that, from September 2026, Android devices will require ALL apps to be signed by Google, effectively leading to an iOS situation. Value your right to a computer that does what you want; do not tolerate this monopolistic practice! Contact me if you don't understand why it is bad. Click to learn more.

 _colors.scss

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