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.94 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
// Private variables for dark background colors
87
$-dark-surface-z0: #121212;
88
$-dark-surface-z1: mix(white, $-dark-surface-z0, 5%);
89
$-dark-surface-z4: mix(white, $-dark-surface-z0, 9%);
90
$-dark-surface-z8: mix(white, $-dark-surface-z0, 12%);
91
$-dark-surface-switch-thumb: mix(white, $-dark-surface-z0, 60%);
92
93
//
94
// Main colors
95
//
96
97
$surface-z0: #f9f9f9;
98
$surface-z1: #fff;
99
$surface-z8: #fff;
100
$surface-switch-thumb: #fff;
101
$on-surface: on($surface-z0);
102
103
$primary-on-light: #1967d2;
104
$primary-on-dark: #8ab4f8;
105
$primary: $primary-on-light;
106
$on-primary: on($primary);
107
108
$error-on-light: #d93025;
109
$error-on-dark: #f28b82;
110
$error: $error-on-light;
111
$on-error: on($error);
112
113
$warning-on-light: #f9ab00;
114
$warning-on-dark: #fdd663;
115
$warning: $warning-on-light;
116
$on-warning: on($warning);
117
118
$success-on-light: #1e8e3e;
119
$success-on-dark: #81c995;
120
$success: $success-on-light;
121
$on-success: on($success);
122
123
$visited-on-light: #9334e6;
124
$visited-on-dark: #c58af9;
125
$visited: $visited-on-light;
126
$on-visited: on($visited);
127
128
$system: #212121;
129
$on-system: on($system);
130
131
$tooltip: rgba(#616161, .9);
132
$on-tooltip: on($tooltip);
133
134
$scrim: rgba(black, .6);
135
$on-scrim: on($scrim);
136
137
$scrim-alt: rgba(black, .3);
138
$on-scrim-alt: on($scrim-alt);
139
140
$panel: #212121;
141
$on-panel: on($panel);
142
143
// for Unity panel which doesn't allow translucent colors
144
$panel-solid: $panel;
145
$on-panel-solid: on($panel-solid);
146
147
$titlebar: #424242;
148
$titlebar-backdrop: #303030;
149
$on-titlebar: on($titlebar);
150
151
$titlebar-indicator: currentcolor;
152
153
@if $dark-theme {
154
$surface-z0: $-dark-surface-z0;
155
$surface-z1: $-dark-surface-z1;
156
$surface-z8: $-dark-surface-z8;
157
$surface-switch-thumb: $-dark-surface-switch-thumb;
158
$on-surface: on($surface-z0);
159
160
$primary: $primary-on-dark;
161
$on-primary: on($primary);
162
163
$error: $error-on-dark;
164
$on-error: on($error);
165
166
$warning: $warning-on-dark;
167
$on-warning: on($warning);
168
169
$success: $success-on-dark;
170
$on-success: on($success);
171
172
$visited: $visited-on-dark;
173
$on-visited: on($visited);
174
175
$titlebar: $-dark-surface-z4;
176
$titlebar-backdrop: $-dark-surface-z1;
177
$on-titlebar: on($titlebar);
178
}
179
180
@if $light-topbar {
181
$panel: $scrim;
182
$on-panel: on($panel);
183
184
$panel-solid: #e0e0e0;
185
$on-panel-solid: on($panel-solid);
186
187
$titlebar: #f0f0f0;
188
$titlebar-backdrop: #ebebeb;
189
$on-titlebar: on($titlebar);
190
191
$titlebar-indicator: $primary;
192
}
193
194
//
195
// Overlay state colors
196
//
197
198
$overlay-selected: rgba($primary, .24);
199
200
//
201
// For “on” colors
202
//
203
204
@function primary($color) {
205
@return if(tone($color) == "dark", $primary-on-light, $primary-on-dark);
206
}
207
208
@function error($color) {
209
@return if(tone($color) == "dark", $error-on-light, $error-on-dark);
210
}
211
212
@function hint($color) {
213
@return rgba($color, if(has-alpha($color), .6, .7));
214
}
215
216
@function disabled($color) {
217
@return rgba($color, if(has-alpha($color), .38, .5));
218
}
219
220
@function disabled-hint($color) {
221
@return rgba($color, if(has-alpha($color), .26, .3));
222
}
223
224
@function stroke($color) {
225
@return rgba($color, if(has-alpha($color), .26, .3));
226
}
227
228
@function disabled-stroke($color) {
229
@return rgba($color, if(has-alpha($color), .12, .2));
230
}
231
232
@function divider($color) {
233
@return rgba($color, if(has-alpha($color), .12, .2));
234
}
235
236
@function fill($color) {
237
@return rgba($color, if(has-alpha($color), .08, .08));
238
}
239
240
@function entry-fill($color) {
241
@return rgba($color, if(has-alpha($color), .04, .04));
242
}
243
244
@function scrollbar-thumb($color, $state: null) {
245
@if $state == null {
246
@return rgba($color, if(has-alpha($color), .38, .5));
247
} @else if $state == "hover" {
248
@return rgba($color, if(has-alpha($color), .48, .6));
249
} @else if $state == "pressed" {
250
@return rgba($color, if(has-alpha($color), .6, .7));
251
} @else if $state == "disabled" {
252
@return rgba($color, if(has-alpha($color), .26, .3));
253
} @else {
254
@error "Invalid type: '#{$state}'";
255
}
256
}
257