_colors.scss
ASCII 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($c, $a) {
7
@return unquote("alpha(#{$c}, #{$a})");
8
}
9
10
@function on($color, $state: 'primary') {
11
// Calculate color brightness according to https://www.w3.org/TR/AERT/#color-contrast
12
$brightness: (red($color) * 299 + green($color) * 587 + blue($color) * 114) / 1000;
13
@if ($brightness >= 128) {
14
@if ($state == 'primary') { @return rgba(black, 0.87); }
15
@if ($state == 'secondary') { @return rgba(black, 0.54); }
16
@if ($state == 'disabled') { @return rgba(black, 0.38); }
17
@if ($state == 'secondary-disabled') { @return rgba(black, 0.26); }
18
@if ($state == 'track') { @return rgba(black, 0.26); }
19
@if ($state == 'divider') { @return rgba(black, 0.12); }
20
@if ($state == 'fill') { @return rgba(black, 0.04); }
21
} @else {
22
@if ($state == 'primary') { @return white; }
23
@if ($state == 'secondary') { @return rgba(white, 0.7); }
24
@if ($state == 'disabled') { @return rgba(white, 0.5); }
25
@if ($state == 'secondary-disabled') { @return rgba(white, 0.3); }
26
@if ($state == 'track') { @return rgba(white, 0.3); }
27
@if ($state == 'divider') { @return rgba(white, 0.12); }
28
@if ($state == 'fill') { @return rgba(white, 0.04); }
29
}
30
}
31
32
@function highlight($color) {
33
@if (lightness($color) > 80%) { @return rgba(white, 0.4); }
34
@else if (lightness($color) > 40%) { @return rgba(white, 0.2); }
35
@else { @return rgba(white, 0.1); }
36
}
37
38
//
39
// Basic colors
40
//
41
42
$blue: #4285F4;
43
$green: #34A853;
44
$yellow: #FBBC05;
45
$red: #EA4335;
46
47
$primary: $blue;
48
$primary-alt: #7BAAF7;
49
50
$background: if($variant == 'light', #F2F2F2, #282828);
51
$surface: if($variant == 'light', #FFFFFF, #424242);
52
$base: if($variant == 'light', #FFFFFF, #303030);
53
$base-alt: if($variant == 'light', #FAFAFA, #2C2C2C);
54
55
$os-background: #303030;
56
$tooltip: rgba(#616161, 0.9);
57
$scrim: rgba(black, 0.6);
58
$scrim-alt: rgba(black, 0.3);
59
$scrim-inverse: rgba(white, 0.1);
60
$titlebar: if($topbar == 'dark', #383838, #E0E0E0);
61
$panel: if($topbar == 'dark', #212121, $scrim);
62
$panel-solid: if($topbar == 'dark', #212121, #CBCBCB); // for Unity panel which doesn't allow translucent colors
63
64
//
65
// Misc colors
66
//
67
68
$link: $primary;
69
$link-visited: $purple-a200;
70
71
$warning: $yellow;
72
$error: $red;
73
$success: $green;
74
75
$suggested: $primary;
76
$destructive: $error;
77
78
$infobar-info: $green;
79
$infobar-question: $blue;
80
$infobar-warning: $warning;
81
$infobar-error: $error;
82
83
$border: if($variant == 'light', rgba(black, 0.12), rgba(black, 0.26));
84
$border-alt: rgba(black, 0.26); // darker border color for Chrome and Firefox
85
$titlebar-indicator: if($topbar == 'dark', currentColor, $primary);
86
87
//
88
// Overlay state colors
89
//
90
91
$overlay-hover: gtkalpha(currentColor, 0.08);
92
$overlay-focus: gtkalpha(currentColor, 0.12);
93
$overlay-focus-hover: gtkalpha(currentColor, 0.16);
94
$overlay-active: gtkalpha(currentColor, 0.12);
95
$overlay-checked: gtkalpha(currentColor, 0.24);
96
$overlay-selected: rgba($primary, 0.32);
97
98
//
99
// Text and derivative colors
100
//
101
102
$text: on($background);
103
$text-secondary: on($background, secondary);
104
$text-disabled: on($background, disabled);
105
$text-secondary-disabled: on($background, secondary-disabled);
106
$track: on($background, track);
107
$divider: on($background, divider);
108
$fill: on($background, fill);
109
110
$titlebar-text: on($titlebar);
111
$titlebar-text-secondary: on($titlebar, secondary);
112
$titlebar-text-disabled: on($titlebar, disabled);
113
$titlebar-text-secondary-disabled: on($titlebar, secondary-disabled);
114
$titlebar-track: on($titlebar, track);
115
$titlebar-divider: on($titlebar, divider);
116
$titlebar-fill: on($titlebar, fill);
117
118
// workaround for Electron menu which doesn't allow translucent colors
119
$solid-text: if($variant == 'light', $grey-900, $white);
120
$solid-text-secondary: if($variant == 'light', $grey-600, mix($white, $surface, percentage(0.7)));
121
$solid-text-disabled: if($variant == 'light', $grey-500, mix($white, $surface, percentage(0.5)));
122
$solid-divider: if($variant == 'light', $grey-300, mix($white, $surface, percentage(0.12)));
123
124
// workaround for GTK3 @placeholder_text_color which doesn't allow translucent colors
125
$placeholder_text_color: if($variant == 'light', $grey-600, mix($white, $base, percentage(0.7)));
126