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