BlueGit

ict rusty-teams

feat(thema): kleurenschema Koninklijke van Twist als standaard

Nieuw schema "Koninklijke van Twist" naast Rusty Teams en Teams, met een licht en een
donker palet in de KVT-huisstijlkleuren (Perkins blauw #00529B, Helder blauw #0099CC,
Lichtblauw #33CCFF, Donkergrijs #575757; bron: huisstijlhandboek en kleuren-kvt.pdf op
het KVT-intranet). Het schema staat in een eigen bestand (theme/kvt.rs); schemes.rs
krijgt alleen de lijstvermelding.

Nieuwe installaties en gebruikers zonder opgeslagen weergave starten in dit schema, licht
(huisstijl: logo op wit). Een opgeslagen keuze blijft behouden; instellingen zonder
schema- of themasleutel houden Rusty Teams en donker.

Alle tekstrollen halen WCAG AA (4,5:1) op elke ondergrond, getest per palet.

hephaestus

Authored 2026-11-28 · 3 days ago

Hash
21e299b0057a71832066b8b360bec3abaec15d26
Parent
18f32429
Pipeline
Passed
5 files changed +348 −11
crates/app-base/src/appearance.rs +51 −5
@@ -11,6 +11,11 @@ pub const ZOOM_STEPS: [f32; 14] = [
11 11 0.5, 0.67, 0.75, 0.8, 0.9, 1., 1.1, 1.25, 1.5, 1.75, 2., 2.5, 3., 4.,
12 12 ];
13 13 pub const DEFAULT_ZOOM: f32 = 1.;
14 /// Look of a fresh install: the KVT scheme in its light shade (house style: logo on white).
15 /// `ThemeChoice::default()` stays dark: it is what settings saved without a theme key meant.
16 const DEFAULT_THEME: ThemeChoice = ThemeChoice::Light;
17 /// Scheme of settings saved without a `color_scheme` key (before the KVT scheme existed).
18 const LEGACY_COLOR_SCHEME: &str = "rusty-teams";
14 19 const RUSTY_TEAMS_ICON_PNG: &[u8] = include_bytes!("../../app/assets/icon/teams-fast-256.png");
15 20 const MICROSOFT_TEAMS_ICON_PNG: &[u8] =
16 21 include_bytes!("../../app/assets/icon/microsoft-teams-256.png");
@@ -123,7 +128,7 @@ impl Default for AppearanceSettings {
123 128 AppearanceSettings {
124 129 color_scheme: theme::default_scheme(),
125 130 app_icon: AppIcon::default(),
126 theme: ThemeChoice::default(),
131 theme: DEFAULT_THEME,
127 132 zoom: DEFAULT_ZOOM,
128 133 }
129 134 }
@@ -206,6 +211,20 @@ fn serialize(settings: &AppearanceSettings) -> String {
206 211
207 212 fn parse(text: &str) -> AppearanceSettings {
208 213 let mut settings = AppearanceSettings::default();
214 let has_key = |key: &str| {
215 text.lines()
216 .any(|line| line.split_once('=').is_some_and(|(name, _)| name == key))
217 };
218 // Settings saved before the KVT default existed may lack a key. That user never picked
219 // one and keeps the look the app had then, instead of switching to the new default.
220 if !has_key(COLOR_SCHEME_KEY) && !text.trim().is_empty() {
221 if let Some(scheme) = theme::scheme_by_id(LEGACY_COLOR_SCHEME) {
222 settings.color_scheme = scheme;
223 }
224 }
225 if !has_key(THEME_KEY) && !text.trim().is_empty() {
226 settings.theme = ThemeChoice::default();
227 }
209 228 for line in text.lines() {
210 229 match line.split_once('=') {
211 230 Some((COLOR_SCHEME_KEY, value)) => {
@@ -239,18 +258,18 @@ mod tests {
239 258 use super::*;
240 259
241 260 #[test]
242 fn defaults_are_the_rusty_teams_look() {
261 fn defaults_are_the_koninklijke_van_twist_look() {
243 262 let settings = AppearanceSettings::default();
244 assert_eq!(settings.color_scheme.id, "rusty-teams");
263 assert_eq!(settings.color_scheme.id, "koninklijke-van-twist");
245 264 assert_eq!(settings.app_icon, AppIcon::RustyTeams);
246 assert_eq!(settings.theme, ThemeChoice::Dark);
265 assert_eq!(settings.theme, ThemeChoice::Light);
247 266 assert_eq!(settings.zoom, 1.);
248 267 }
249 268
250 269 #[test]
251 270 fn round_trips_every_field() {
252 271 let settings = AppearanceSettings {
253 color_scheme: theme::SCHEMES[1],
272 color_scheme: theme::scheme_by_id("teams").unwrap(),
254 273 app_icon: AppIcon::MicrosoftTeams,
255 274 theme: ThemeChoice::FollowOperatingSystem,
256 275 zoom: 1.25,
@@ -289,6 +308,33 @@ mod tests {
289 308 assert_eq!(parse("zoom=1.3").zoom, 1.25);
290 309 }
291 310
311 #[test]
312 fn an_explicit_choice_survives_the_new_default() {
313 for scheme in theme::SCHEMES {
314 for choice in ThemeChoice::ALL {
315 let settings = AppearanceSettings {
316 color_scheme: scheme,
317 theme: choice,
318 ..AppearanceSettings::default()
319 };
320 assert_eq!(parse(&serialize(&settings)), settings);
321 }
322 }
323 // The look the app had before the KVT scheme, saved explicitly, stays as it is.
324 let before = parse("color_scheme=rusty-teams\napp_icon=rusty-teams\ntheme=dark\nzoom=1");
325 assert_eq!(before.color_scheme.id, "rusty-teams");
326 assert_eq!(before.theme, ThemeChoice::Dark);
327 }
328
329 #[test]
330 fn settings_saved_without_a_scheme_or_theme_keep_the_old_look() {
331 let settings = parse("zoom=1.25");
332 assert_eq!(settings.color_scheme.id, "rusty-teams");
333 assert_eq!(settings.theme, ThemeChoice::Dark);
334 assert_eq!(settings.zoom, 1.25);
335 assert_eq!(parse(" \n"), AppearanceSettings::default());
336 }
337
292 338 #[test]
293 339 fn follow_os_takes_dark_light_and_forced_contrast_from_the_system() {
294 340 let follow = ThemeChoice::FollowOperatingSystem;
@@ -11,6 +11,11 @@ pub const ZOOM_STEPS: [f32; 14] = [
11 0.5, 0.67, 0.75, 0.8, 0.9, 1., 1.1, 1.25, 1.5, 1.75, 2., 2.5, 3., 4.,
11 0.5, 0.67, 0.75, 0.8, 0.9, 1., 1.1, 1.25, 1.5, 1.75, 2., 2.5, 3., 4.,
12];
12];
13pub const DEFAULT_ZOOM: f32 = 1.;
13pub const DEFAULT_ZOOM: f32 = 1.;
14/// Look of a fresh install: the KVT scheme in its light shade (house style: logo on white).
15/// `ThemeChoice::default()` stays dark: it is what settings saved without a theme key meant.
16const DEFAULT_THEME: ThemeChoice = ThemeChoice::Light;
17/// Scheme of settings saved without a `color_scheme` key (before the KVT scheme existed).
18const LEGACY_COLOR_SCHEME: &str = "rusty-teams";
14const RUSTY_TEAMS_ICON_PNG: &[u8] = include_bytes!("../../app/assets/icon/teams-fast-256.png");
19const RUSTY_TEAMS_ICON_PNG: &[u8] = include_bytes!("../../app/assets/icon/teams-fast-256.png");
15const MICROSOFT_TEAMS_ICON_PNG: &[u8] =
20const MICROSOFT_TEAMS_ICON_PNG: &[u8] =
16 include_bytes!("../../app/assets/icon/microsoft-teams-256.png");
21 include_bytes!("../../app/assets/icon/microsoft-teams-256.png");
@@ -123,7 +128,7 @@ impl Default for AppearanceSettings {
123 AppearanceSettings {
128 AppearanceSettings {
124 color_scheme: theme::default_scheme(),
129 color_scheme: theme::default_scheme(),
125 app_icon: AppIcon::default(),
130 app_icon: AppIcon::default(),
126 theme: ThemeChoice::default(),
131 theme: DEFAULT_THEME,
127 zoom: DEFAULT_ZOOM,
132 zoom: DEFAULT_ZOOM,
128 }
133 }
129 }
134 }
@@ -206,6 +211,20 @@ fn serialize(settings: &AppearanceSettings) -> String {
206
211
207fn parse(text: &str) -> AppearanceSettings {
212fn parse(text: &str) -> AppearanceSettings {
208 let mut settings = AppearanceSettings::default();
213 let mut settings = AppearanceSettings::default();
214 let has_key = |key: &str| {
215 text.lines()
216 .any(|line| line.split_once('=').is_some_and(|(name, _)| name == key))
217 };
218 // Settings saved before the KVT default existed may lack a key. That user never picked
219 // one and keeps the look the app had then, instead of switching to the new default.
220 if !has_key(COLOR_SCHEME_KEY) && !text.trim().is_empty() {
221 if let Some(scheme) = theme::scheme_by_id(LEGACY_COLOR_SCHEME) {
222 settings.color_scheme = scheme;
223 }
224 }
225 if !has_key(THEME_KEY) && !text.trim().is_empty() {
226 settings.theme = ThemeChoice::default();
227 }
209 for line in text.lines() {
228 for line in text.lines() {
210 match line.split_once('=') {
229 match line.split_once('=') {
211 Some((COLOR_SCHEME_KEY, value)) => {
230 Some((COLOR_SCHEME_KEY, value)) => {
@@ -239,18 +258,18 @@ mod tests {
239 use super::*;
258 use super::*;
240
259
241 #[test]
260 #[test]
242 fn defaults_are_the_rusty_teams_look() {
261 fn defaults_are_the_koninklijke_van_twist_look() {
243 let settings = AppearanceSettings::default();
262 let settings = AppearanceSettings::default();
244 assert_eq!(settings.color_scheme.id, "rusty-teams");
263 assert_eq!(settings.color_scheme.id, "koninklijke-van-twist");
245 assert_eq!(settings.app_icon, AppIcon::RustyTeams);
264 assert_eq!(settings.app_icon, AppIcon::RustyTeams);
246 assert_eq!(settings.theme, ThemeChoice::Dark);
265 assert_eq!(settings.theme, ThemeChoice::Light);
247 assert_eq!(settings.zoom, 1.);
266 assert_eq!(settings.zoom, 1.);
248 }
267 }
249
268
250 #[test]
269 #[test]
251 fn round_trips_every_field() {
270 fn round_trips_every_field() {
252 let settings = AppearanceSettings {
271 let settings = AppearanceSettings {
253 color_scheme: theme::SCHEMES[1],
272 color_scheme: theme::scheme_by_id("teams").unwrap(),
254 app_icon: AppIcon::MicrosoftTeams,
273 app_icon: AppIcon::MicrosoftTeams,
255 theme: ThemeChoice::FollowOperatingSystem,
274 theme: ThemeChoice::FollowOperatingSystem,
256 zoom: 1.25,
275 zoom: 1.25,
@@ -289,6 +308,33 @@ mod tests {
289 assert_eq!(parse("zoom=1.3").zoom, 1.25);
308 assert_eq!(parse("zoom=1.3").zoom, 1.25);
290 }
309 }
291
310
311 #[test]
312 fn an_explicit_choice_survives_the_new_default() {
313 for scheme in theme::SCHEMES {
314 for choice in ThemeChoice::ALL {
315 let settings = AppearanceSettings {
316 color_scheme: scheme,
317 theme: choice,
318 ..AppearanceSettings::default()
319 };
320 assert_eq!(parse(&serialize(&settings)), settings);
321 }
322 }
323 // The look the app had before the KVT scheme, saved explicitly, stays as it is.
324 let before = parse("color_scheme=rusty-teams\napp_icon=rusty-teams\ntheme=dark\nzoom=1");
325 assert_eq!(before.color_scheme.id, "rusty-teams");
326 assert_eq!(before.theme, ThemeChoice::Dark);
327 }
328
329 #[test]
330 fn settings_saved_without_a_scheme_or_theme_keep_the_old_look() {
331 let settings = parse("zoom=1.25");
332 assert_eq!(settings.color_scheme.id, "rusty-teams");
333 assert_eq!(settings.theme, ThemeChoice::Dark);
334 assert_eq!(settings.zoom, 1.25);
335 assert_eq!(parse(" \n"), AppearanceSettings::default());
336 }
337
292 #[test]
338 #[test]
293 fn follow_os_takes_dark_light_and_forced_contrast_from_the_system() {
339 fn follow_os_takes_dark_light_and_forced_contrast_from_the_system() {
294 let follow = ThemeChoice::FollowOperatingSystem;
340 let follow = ThemeChoice::FollowOperatingSystem;
crates/app-base/src/theme.rs +1 −0
@@ -4,6 +4,7 @@ use gpui_kit::component::elevation::{self, Elevation, ElevationTokens};
4 4 use gpui_kit::component::{Theme, ThemeMode};
5 5 use gpui_kit::*;
6 6
7 mod kvt;
7 8 mod schemes;
8 9
9 10 pub use schemes::{
@@ -4,6 +4,7 @@ use gpui_kit::component::elevation::{self, Elevation, ElevationTokens};
4use gpui_kit::component::{Theme, ThemeMode};
4use gpui_kit::component::{Theme, ThemeMode};
5use gpui_kit::*;
5use gpui_kit::*;
6
6
7mod kvt;
7mod schemes;
8mod schemes;
8
9
9pub use schemes::{
10pub use schemes::{
crates/app-base/src/theme/kvt.rs added +245 −0
@@ -0,0 +1,245 @@
1 //! Colour scheme "Koninklijke van Twist" (KVT house style). Kept in its own file so the
2 //! upstream scheme file stays untouched apart from the list of schemes.
3 //!
4 //! Source: Huisstijlhandboek KVT (versie september 2020) and `kleuren-kvt.pdf`, KVT Intranet >
5 //! Marketing > Huisstijlhandboek. The brand colours are the official ones:
6 //!
7 //! | Name | HEX | RGB | CMYK | PMS |
8 //! |---------------|---------|-------------|-----------------|----------------|
9 //! | Perkins blauw | #00529B | 0 82 155 | 100 69 0 11 | 287 C |
10 //! | Helder blauw | #0099CC | 0 153 204 | 100 13 1 3 | Process Blue C |
11 //! | Lichtblauw | #33CCFF | 51 204 255 | 57 0 7 0 | 305 C |
12 //! | Donkergrijs | #575757 | 86 86 86 | 0 0 0 80 | Cool gray 11 |
13 //!
14 //! `NAVY` (#00101F) is the title and body text colour of the KVT presentation template 2026.1.
15 //! Every other value is a mix of those colours with white or `NAVY` (surfaces, borders, hover
16 //! states) or a status colour copied from the other schemes.
17 //!
18 //! The house style asks for the logo on a white background, so the light shade is the primary
19 //! look and the one new installations start in. Perkins blauw carries the actions and links on
20 //! light grounds, Lichtblauw on dark ones. Helder blauw and Lichtblauw are too light for text on
21 //! white (about 3.1 and 1.8 to 1) and only appear as tints and accents.
22 //!
23 //! Font: the house style names DINPro (promotion) and Arial (letters). The app keeps its own
24 //! font: DINPro cannot be redistributed and the font is not part of a colour scheme.
25 //!
26 //! Who gets it: a new install, and anyone without saved appearance settings, starts in this
27 //! scheme in its light shade (`appearance::AppearanceSettings::default`). A saved choice is kept,
28 //! also when it is Rusty Teams or Teams. Settings saved without a scheme or theme key (oldest
29 //! versions) keep Rusty Teams and dark.
30
31 use super::schemes::{ColorScheme, DARK_BASE, LIGHT_BASE, Palette};
32
33 const AVATAR_PALETTE: [u32; 6] = [0x00529b, 0x00698f, 0x575757, 0x2c5479, 0x004e6d, 0x00315d];
34
35 pub const KVT: ColorScheme = ColorScheme {
36 id: "koninklijke-van-twist",
37 name: "Koninklijke van Twist",
38 dark: Palette {
39 background: 0x00101f,
40 surface: 0x061a2e,
41 surface_raised: 0x12304f,
42 row_hover: 0x0e2744,
43 popup: 0x183a5e,
44 popup_hover: 0x204670,
45 popup_nested: 0x214a76,
46 popup_nested_hover: 0x2a5886,
47 reply_surface: 0x0a2038,
48 border: 0x0f2a47,
49 border_strong: 0x24476b,
50 foreground: 0xf2f8fc,
51 text_strong: 0xe3eef7,
52 text_soft: 0xcfdeeb,
53 text_muted: 0xa3b8cb,
54 text_faint: 0x8fa6bb,
55 accent: 0x33ccff,
56 accent_text: 0x66d9ff,
57 accent_soft: 0x99e6ff,
58 accent_strong: 0x0099cc,
59 on_accent: 0x00101f,
60 bubble_own: 0x00396b,
61 bubble_other: 0x12304f,
62 reaction_on_own: 0x00529b,
63 mention_background: 0x0a3a66,
64 mention_background_own: 0x00529b,
65 own_meta: 0xbfe4f7,
66 own_read: 0x99e6ff,
67 drop_background: 0x33ccff14,
68 selection: 0x33ccff59,
69 rule_own: 0x1f7ac0,
70 badge_muted: 0x24476b,
71 toast_mention: 0x082f52,
72 green: 0x22c55e,
73 red: 0xef4444,
74 red_soft: 0xf87171,
75 red_tint: 0xfca5a5,
76 amber: 0xfbbf24,
77 close_button_hover: 0xc42b1c,
78 close_button_pressed: 0xb5271a,
79 avatar_palette: AVATAR_PALETTE,
80 ..DARK_BASE
81 },
82 light: Palette {
83 background: 0xe6eef5,
84 surface: 0xf5f8fb,
85 surface_raised: 0xffffff,
86 row_hover: 0xedf3f8,
87 popup: 0xffffff,
88 popup_hover: 0xf0f5f9,
89 popup_nested: 0xffffff,
90 popup_nested_hover: 0xe8eff6,
91 reply_surface: 0xfafcfd,
92 border: 0xd1e0ed,
93 border_strong: 0xadc8df,
94 foreground: 0x00101f,
95 text_strong: 0x00101f,
96 text_soft: 0x2c343b,
97 text_muted: 0x575757,
98 text_faint: 0x6b6b6b,
99 accent: 0x00529b,
100 accent_text: 0x004888,
101 accent_soft: 0x003463,
102 accent_strong: 0x003b70,
103 on_accent: 0xffffff,
104 bubble_own: 0xd2f4ff,
105 bubble_other: 0xffffff,
106 reaction_on_own: 0xa3e8ff,
107 mention_background: 0xc6f1ff,
108 mention_background_own: 0xa3e8ff,
109 own_meta: 0x004582,
110 own_read: 0x00529b,
111 drop_background: 0x0099cc14,
112 selection: 0x33ccff66,
113 rule_own: 0x8cd1e8,
114 badge_muted: 0xadc8df,
115 toast_mention: 0xc6f1ff,
116 green: 0x16a34a,
117 red: 0xc81e1e,
118 red_soft: 0xb91c1c,
119 red_tint: 0x991b1b,
120 amber: 0xc27c0e,
121 close_button_hover: 0xc42b1c,
122 close_button_pressed: 0xb5271a,
123 avatar_palette: AVATAR_PALETTE,
124 ..LIGHT_BASE
125 },
126 };
127
128 #[cfg(test)]
129 mod tests {
130 use super::super::Shade;
131 use super::*;
132
133 fn channel(hex: u32, shift: u32) -> f64 {
134 let value = f64::from((hex >> shift) & 0xff) / 255.;
135 if value <= 0.04045 {
136 value / 12.92
137 } else {
138 ((value + 0.055) / 1.055).powf(2.4)
139 }
140 }
141
142 fn luminance(hex: u32) -> f64 {
143 0.2126 * channel(hex, 16) + 0.7152 * channel(hex, 8) + 0.0722 * channel(hex, 0)
144 }
145
146 fn contrast(first: u32, second: u32) -> f64 {
147 let (first, second) = (luminance(first), luminance(second));
148 (first.max(second) + 0.05) / (first.min(second) + 0.05)
149 }
150
151 #[test]
152 fn the_scheme_uses_the_official_kvt_blues() {
153 assert_eq!(KVT.light.accent, 0x00529b, "Perkins blauw");
154 assert_eq!(KVT.dark.accent, 0x33ccff, "Lichtblauw");
155 assert_eq!(KVT.dark.accent_strong, 0x0099cc, "Helder blauw");
156 assert_eq!(KVT.light.text_muted, 0x575757, "Donkergrijs");
157 assert_eq!(KVT.light.foreground, 0x00101f);
158 assert_eq!(KVT.light.shade, Shade::Light);
159 assert_eq!(KVT.dark.shade, Shade::Dark);
160 }
161
162 /// WCAG AA asks 4.5 to 1 for normal text. The shared test in `schemes.rs` is looser for
163 /// muted and faint text; this scheme meets AA for every text role on every ground.
164 #[test]
165 fn every_text_role_meets_wcag_aa_on_every_ground() {
166 for palette in [&KVT.dark, &KVT.light] {
167 let grounds = [
168 palette.background,
169 palette.surface,
170 palette.reply_surface,
171 palette.row_hover,
172 palette.surface_raised,
173 palette.popup,
174 palette.bubble_other,
175 palette.bubble_own,
176 ];
177 let roles = [
178 ("foreground", palette.foreground),
179 ("text_soft", palette.text_soft),
180 ("text_muted", palette.text_muted),
181 ("text_faint", palette.text_faint),
182 ("accent_text", palette.accent_text),
183 ];
184 for (name, text) in roles {
185 for ground in grounds {
186 let ratio = contrast(text, ground);
187 assert!(
188 ratio >= 4.5,
189 "{:?}: {name} #{text:06x} on #{ground:06x} is {ratio:.2}",
190 palette.shade
191 );
192 }
193 }
194 for (name, text, ground) in [
195 ("on_accent", palette.on_accent, palette.accent),
196 ("own_meta", palette.own_meta, palette.bubble_own),
197 (
198 "foreground on mention",
199 palette.foreground,
200 palette.mention_background,
201 ),
202 (
203 "accent_text on mention",
204 palette.accent_text,
205 palette.mention_background,
206 ),
207 (
208 "foreground on own mention",
209 palette.foreground,
210 palette.mention_background_own,
211 ),
212 (
213 "foreground on own reaction",
214 palette.foreground,
215 palette.reaction_on_own,
216 ),
217 (
218 "foreground on popup hover",
219 palette.foreground,
220 palette.popup_hover,
221 ),
222 (
223 "text_muted on popup hover",
224 palette.text_muted,
225 palette.popup_hover,
226 ),
227 (
228 "foreground on toast mention",
229 palette.foreground,
230 palette.toast_mention,
231 ),
232 ] {
233 let ratio = contrast(text, ground);
234 assert!(
235 ratio >= 4.5,
236 "{:?}: {name} #{text:06x} on #{ground:06x} is {ratio:.2}",
237 palette.shade
238 );
239 }
240 for avatar in palette.avatar_palette {
241 assert!(contrast(0xffffff, avatar) >= 4.5, "avatar #{avatar:06x}");
242 }
243 }
244 }
245 }
@@ -0,0 +1,245 @@
1//! Colour scheme "Koninklijke van Twist" (KVT house style). Kept in its own file so the
2//! upstream scheme file stays untouched apart from the list of schemes.
3//!
4//! Source: Huisstijlhandboek KVT (versie september 2020) and `kleuren-kvt.pdf`, KVT Intranet >
5//! Marketing > Huisstijlhandboek. The brand colours are the official ones:
6//!
7//! | Name | HEX | RGB | CMYK | PMS |
8//! |---------------|---------|-------------|-----------------|----------------|
9//! | Perkins blauw | #00529B | 0 82 155 | 100 69 0 11 | 287 C |
10//! | Helder blauw | #0099CC | 0 153 204 | 100 13 1 3 | Process Blue C |
11//! | Lichtblauw | #33CCFF | 51 204 255 | 57 0 7 0 | 305 C |
12//! | Donkergrijs | #575757 | 86 86 86 | 0 0 0 80 | Cool gray 11 |
13//!
14//! `NAVY` (#00101F) is the title and body text colour of the KVT presentation template 2026.1.
15//! Every other value is a mix of those colours with white or `NAVY` (surfaces, borders, hover
16//! states) or a status colour copied from the other schemes.
17//!
18//! The house style asks for the logo on a white background, so the light shade is the primary
19//! look and the one new installations start in. Perkins blauw carries the actions and links on
20//! light grounds, Lichtblauw on dark ones. Helder blauw and Lichtblauw are too light for text on
21//! white (about 3.1 and 1.8 to 1) and only appear as tints and accents.
22//!
23//! Font: the house style names DINPro (promotion) and Arial (letters). The app keeps its own
24//! font: DINPro cannot be redistributed and the font is not part of a colour scheme.
25//!
26//! Who gets it: a new install, and anyone without saved appearance settings, starts in this
27//! scheme in its light shade (`appearance::AppearanceSettings::default`). A saved choice is kept,
28//! also when it is Rusty Teams or Teams. Settings saved without a scheme or theme key (oldest
29//! versions) keep Rusty Teams and dark.
30
31use super::schemes::{ColorScheme, DARK_BASE, LIGHT_BASE, Palette};
32
33const AVATAR_PALETTE: [u32; 6] = [0x00529b, 0x00698f, 0x575757, 0x2c5479, 0x004e6d, 0x00315d];
34
35pub const KVT: ColorScheme = ColorScheme {
36 id: "koninklijke-van-twist",
37 name: "Koninklijke van Twist",
38 dark: Palette {
39 background: 0x00101f,
40 surface: 0x061a2e,
41 surface_raised: 0x12304f,
42 row_hover: 0x0e2744,
43 popup: 0x183a5e,
44 popup_hover: 0x204670,
45 popup_nested: 0x214a76,
46 popup_nested_hover: 0x2a5886,
47 reply_surface: 0x0a2038,
48 border: 0x0f2a47,
49 border_strong: 0x24476b,
50 foreground: 0xf2f8fc,
51 text_strong: 0xe3eef7,
52 text_soft: 0xcfdeeb,
53 text_muted: 0xa3b8cb,
54 text_faint: 0x8fa6bb,
55 accent: 0x33ccff,
56 accent_text: 0x66d9ff,
57 accent_soft: 0x99e6ff,
58 accent_strong: 0x0099cc,
59 on_accent: 0x00101f,
60 bubble_own: 0x00396b,
61 bubble_other: 0x12304f,
62 reaction_on_own: 0x00529b,
63 mention_background: 0x0a3a66,
64 mention_background_own: 0x00529b,
65 own_meta: 0xbfe4f7,
66 own_read: 0x99e6ff,
67 drop_background: 0x33ccff14,
68 selection: 0x33ccff59,
69 rule_own: 0x1f7ac0,
70 badge_muted: 0x24476b,
71 toast_mention: 0x082f52,
72 green: 0x22c55e,
73 red: 0xef4444,
74 red_soft: 0xf87171,
75 red_tint: 0xfca5a5,
76 amber: 0xfbbf24,
77 close_button_hover: 0xc42b1c,
78 close_button_pressed: 0xb5271a,
79 avatar_palette: AVATAR_PALETTE,
80 ..DARK_BASE
81 },
82 light: Palette {
83 background: 0xe6eef5,
84 surface: 0xf5f8fb,
85 surface_raised: 0xffffff,
86 row_hover: 0xedf3f8,
87 popup: 0xffffff,
88 popup_hover: 0xf0f5f9,
89 popup_nested: 0xffffff,
90 popup_nested_hover: 0xe8eff6,
91 reply_surface: 0xfafcfd,
92 border: 0xd1e0ed,
93 border_strong: 0xadc8df,
94 foreground: 0x00101f,
95 text_strong: 0x00101f,
96 text_soft: 0x2c343b,
97 text_muted: 0x575757,
98 text_faint: 0x6b6b6b,
99 accent: 0x00529b,
100 accent_text: 0x004888,
101 accent_soft: 0x003463,
102 accent_strong: 0x003b70,
103 on_accent: 0xffffff,
104 bubble_own: 0xd2f4ff,
105 bubble_other: 0xffffff,
106 reaction_on_own: 0xa3e8ff,
107 mention_background: 0xc6f1ff,
108 mention_background_own: 0xa3e8ff,
109 own_meta: 0x004582,
110 own_read: 0x00529b,
111 drop_background: 0x0099cc14,
112 selection: 0x33ccff66,
113 rule_own: 0x8cd1e8,
114 badge_muted: 0xadc8df,
115 toast_mention: 0xc6f1ff,
116 green: 0x16a34a,
117 red: 0xc81e1e,
118 red_soft: 0xb91c1c,
119 red_tint: 0x991b1b,
120 amber: 0xc27c0e,
121 close_button_hover: 0xc42b1c,
122 close_button_pressed: 0xb5271a,
123 avatar_palette: AVATAR_PALETTE,
124 ..LIGHT_BASE
125 },
126};
127
128#[cfg(test)]
129mod tests {
130 use super::super::Shade;
131 use super::*;
132
133 fn channel(hex: u32, shift: u32) -> f64 {
134 let value = f64::from((hex >> shift) & 0xff) / 255.;
135 if value <= 0.04045 {
136 value / 12.92
137 } else {
138 ((value + 0.055) / 1.055).powf(2.4)
139 }
140 }
141
142 fn luminance(hex: u32) -> f64 {
143 0.2126 * channel(hex, 16) + 0.7152 * channel(hex, 8) + 0.0722 * channel(hex, 0)
144 }
145
146 fn contrast(first: u32, second: u32) -> f64 {
147 let (first, second) = (luminance(first), luminance(second));
148 (first.max(second) + 0.05) / (first.min(second) + 0.05)
149 }
150
151 #[test]
152 fn the_scheme_uses_the_official_kvt_blues() {
153 assert_eq!(KVT.light.accent, 0x00529b, "Perkins blauw");
154 assert_eq!(KVT.dark.accent, 0x33ccff, "Lichtblauw");
155 assert_eq!(KVT.dark.accent_strong, 0x0099cc, "Helder blauw");
156 assert_eq!(KVT.light.text_muted, 0x575757, "Donkergrijs");
157 assert_eq!(KVT.light.foreground, 0x00101f);
158 assert_eq!(KVT.light.shade, Shade::Light);
159 assert_eq!(KVT.dark.shade, Shade::Dark);
160 }
161
162 /// WCAG AA asks 4.5 to 1 for normal text. The shared test in `schemes.rs` is looser for
163 /// muted and faint text; this scheme meets AA for every text role on every ground.
164 #[test]
165 fn every_text_role_meets_wcag_aa_on_every_ground() {
166 for palette in [&KVT.dark, &KVT.light] {
167 let grounds = [
168 palette.background,
169 palette.surface,
170 palette.reply_surface,
171 palette.row_hover,
172 palette.surface_raised,
173 palette.popup,
174 palette.bubble_other,
175 palette.bubble_own,
176 ];
177 let roles = [
178 ("foreground", palette.foreground),
179 ("text_soft", palette.text_soft),
180 ("text_muted", palette.text_muted),
181 ("text_faint", palette.text_faint),
182 ("accent_text", palette.accent_text),
183 ];
184 for (name, text) in roles {
185 for ground in grounds {
186 let ratio = contrast(text, ground);
187 assert!(
188 ratio >= 4.5,
189 "{:?}: {name} #{text:06x} on #{ground:06x} is {ratio:.2}",
190 palette.shade
191 );
192 }
193 }
194 for (name, text, ground) in [
195 ("on_accent", palette.on_accent, palette.accent),
196 ("own_meta", palette.own_meta, palette.bubble_own),
197 (
198 "foreground on mention",
199 palette.foreground,
200 palette.mention_background,
201 ),
202 (
203 "accent_text on mention",
204 palette.accent_text,
205 palette.mention_background,
206 ),
207 (
208 "foreground on own mention",
209 palette.foreground,
210 palette.mention_background_own,
211 ),
212 (
213 "foreground on own reaction",
214 palette.foreground,
215 palette.reaction_on_own,
216 ),
217 (
218 "foreground on popup hover",
219 palette.foreground,
220 palette.popup_hover,
221 ),
222 (
223 "text_muted on popup hover",
224 palette.text_muted,
225 palette.popup_hover,
226 ),
227 (
228 "foreground on toast mention",
229 palette.foreground,
230 palette.toast_mention,
231 ),
232 ] {
233 let ratio = contrast(text, ground);
234 assert!(
235 ratio >= 4.5,
236 "{:?}: {name} #{text:06x} on #{ground:06x} is {ratio:.2}",
237 palette.shade
238 );
239 }
240 for avatar in palette.avatar_palette {
241 assert!(contrast(0xffffff, avatar) >= 4.5, "avatar #{avatar:06x}");
242 }
243 }
244 }
245}
crates/app-base/src/theme/schemes.rs +11 −6
@@ -1,6 +1,8 @@
1 1 use std::cell::Cell;
2 2 use std::sync::atomic::{AtomicU8, AtomicUsize, Ordering};
3 3
4 use super::kvt::KVT;
5
4 6 #[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
5 7 pub enum Shade {
6 8 #[default]
@@ -110,7 +112,7 @@ impl ColorScheme {
110 112
111 113 const AVATAR_PALETTE: [u32; 6] = [0x9a4a22, 0x44606e, 0x8a3434, 0x4f6a3c, 0x6a4f7a, 0x2f6b63];
112 114
113 const DARK_BASE: Palette = Palette {
115 pub(super) const DARK_BASE: Palette = Palette {
114 116 shade: Shade::Dark,
115 117 background: 0,
116 118 surface: 0,
@@ -166,7 +168,7 @@ const DARK_BASE: Palette = Palette {
166 168 table_header: 0xffffff0d,
167 169 };
168 170
169 const LIGHT_BASE: Palette = Palette {
171 pub(super) const LIGHT_BASE: Palette = Palette {
170 172 shade: Shade::Light,
171 173 code_surface: 0x0000000a,
172 174 code_header_border: 0x0000000f,
@@ -414,7 +416,8 @@ pub const HIGH_CONTRAST: Palette = Palette {
414 416 ..DARK_BASE
415 417 };
416 418
417 pub const SCHEMES: [&ColorScheme; 2] = [&RUSTY_TEAMS, &TEAMS];
419 /// The first entry is the default scheme (`default_scheme`, and the fallback for an unknown id).
420 pub const SCHEMES: [&ColorScheme; 3] = [&KVT, &RUSTY_TEAMS, &TEAMS];
418 421
419 422 static ACTIVE_SCHEME: AtomicUsize = AtomicUsize::new(0);
420 423 static ACTIVE_SHADE: AtomicU8 = AtomicU8::new(0);
@@ -513,8 +516,10 @@ mod tests {
513 516 }
514 517
515 518 #[test]
516 fn rusty_teams_is_the_default() {
517 assert_eq!(default_scheme().id, "rusty-teams");
519 fn koninklijke_van_twist_is_the_default() {
520 assert_eq!(default_scheme().id, "koninklijke-van-twist");
521 assert_eq!(default_scheme(), &KVT);
522 assert_eq!(scheme_by_id("rusty-teams"), Some(&RUSTY_TEAMS));
518 523 assert_eq!(scheme_by_id("teams"), Some(&TEAMS));
519 524 assert_eq!(scheme_by_id("solarized"), None);
520 525 }
@@ -638,7 +643,7 @@ mod tests {
638 643 set_thread_shade(Some(Shade::HighContrast));
639 644 assert_eq!(active_palette(), &HIGH_CONTRAST);
640 645 set_thread_scheme(Some("unknown"));
641 assert_eq!(active_scheme().id, "rusty-teams");
646 assert_eq!(active_scheme().id, "koninklijke-van-twist");
642 647 set_thread_scheme(None);
643 648 set_thread_shade(None);
644 649 }
@@ -1,6 +1,8 @@
1use std::cell::Cell;
1use std::cell::Cell;
2use std::sync::atomic::{AtomicU8, AtomicUsize, Ordering};
2use std::sync::atomic::{AtomicU8, AtomicUsize, Ordering};
3
3
4use super::kvt::KVT;
5
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
5pub enum Shade {
7pub enum Shade {
6 #[default]
8 #[default]
@@ -110,7 +112,7 @@ impl ColorScheme {
110
112
111const AVATAR_PALETTE: [u32; 6] = [0x9a4a22, 0x44606e, 0x8a3434, 0x4f6a3c, 0x6a4f7a, 0x2f6b63];
113const AVATAR_PALETTE: [u32; 6] = [0x9a4a22, 0x44606e, 0x8a3434, 0x4f6a3c, 0x6a4f7a, 0x2f6b63];
112
114
113const DARK_BASE: Palette = Palette {
115pub(super) const DARK_BASE: Palette = Palette {
114 shade: Shade::Dark,
116 shade: Shade::Dark,
115 background: 0,
117 background: 0,
116 surface: 0,
118 surface: 0,
@@ -166,7 +168,7 @@ const DARK_BASE: Palette = Palette {
166 table_header: 0xffffff0d,
168 table_header: 0xffffff0d,
167};
169};
168
170
169const LIGHT_BASE: Palette = Palette {
171pub(super) const LIGHT_BASE: Palette = Palette {
170 shade: Shade::Light,
172 shade: Shade::Light,
171 code_surface: 0x0000000a,
173 code_surface: 0x0000000a,
172 code_header_border: 0x0000000f,
174 code_header_border: 0x0000000f,
@@ -414,7 +416,8 @@ pub const HIGH_CONTRAST: Palette = Palette {
414 ..DARK_BASE
416 ..DARK_BASE
415};
417};
416
418
417pub const SCHEMES: [&ColorScheme; 2] = [&RUSTY_TEAMS, &TEAMS];
419/// The first entry is the default scheme (`default_scheme`, and the fallback for an unknown id).
420pub const SCHEMES: [&ColorScheme; 3] = [&KVT, &RUSTY_TEAMS, &TEAMS];
418
421
419static ACTIVE_SCHEME: AtomicUsize = AtomicUsize::new(0);
422static ACTIVE_SCHEME: AtomicUsize = AtomicUsize::new(0);
420static ACTIVE_SHADE: AtomicU8 = AtomicU8::new(0);
423static ACTIVE_SHADE: AtomicU8 = AtomicU8::new(0);
@@ -513,8 +516,10 @@ mod tests {
513 }
516 }
514
517
515 #[test]
518 #[test]
516 fn rusty_teams_is_the_default() {
519 fn koninklijke_van_twist_is_the_default() {
517 assert_eq!(default_scheme().id, "rusty-teams");
520 assert_eq!(default_scheme().id, "koninklijke-van-twist");
521 assert_eq!(default_scheme(), &KVT);
522 assert_eq!(scheme_by_id("rusty-teams"), Some(&RUSTY_TEAMS));
518 assert_eq!(scheme_by_id("teams"), Some(&TEAMS));
523 assert_eq!(scheme_by_id("teams"), Some(&TEAMS));
519 assert_eq!(scheme_by_id("solarized"), None);
524 assert_eq!(scheme_by_id("solarized"), None);
520 }
525 }
@@ -638,7 +643,7 @@ mod tests {
638 set_thread_shade(Some(Shade::HighContrast));
643 set_thread_shade(Some(Shade::HighContrast));
639 assert_eq!(active_palette(), &HIGH_CONTRAST);
644 assert_eq!(active_palette(), &HIGH_CONTRAST);
640 set_thread_scheme(Some("unknown"));
645 set_thread_scheme(Some("unknown"));
641 assert_eq!(active_scheme().id, "rusty-teams");
646 assert_eq!(active_scheme().id, "koninklijke-van-twist");
642 set_thread_scheme(None);
647 set_thread_scheme(None);
643 set_thread_shade(None);
648 set_thread_shade(None);
644 }
649 }
crates/app/src/active_appearance.rs +40 −0
@@ -160,6 +160,46 @@ mod tests {
160 160 assert_eq!(appearance::load(&store).theme, ThemeChoice::Light);
161 161 set_color_scheme(theme::default_scheme(), &store, cx);
162 162 set_theme(ThemeChoice::Dark, &store, cx);
163 assert_eq!(theme::scheme().id, "koninklijke-van-twist");
164 assert_eq!(theme::shade(), Shade::Dark);
165 });
166 }
167
168 #[gpui_kit::test]
169 fn a_fresh_install_starts_in_koninklijke_van_twist_light(cx: &mut TestAppContext) {
170 let _theme_state = theme_state();
171 let store = Store::open_in_memory().expect("in-memory store");
172 cx.update(|cx| {
173 gpui_kit::init(cx);
174 install(&store, cx);
175 theme::set_thread_scheme(None);
176 theme::set_thread_shade(None);
177 assert_eq!(theme::scheme().id, "koninklijke-van-twist");
178 assert_eq!(theme::shade(), Shade::Light);
179 assert_eq!(
180 theme::background(),
181 theme::color(theme::scheme().light.background)
182 );
183 });
184 }
185
186 #[gpui_kit::test]
187 fn a_saved_choice_wins_over_the_default(cx: &mut TestAppContext) {
188 let _theme_state = theme_state();
189 let store = Store::open_in_memory().expect("in-memory store");
190 appearance::save(
191 &store,
192 &AppearanceSettings {
193 color_scheme: theme::scheme_by_id("rusty-teams").expect("rusty-teams scheme"),
194 theme: ThemeChoice::Dark,
195 ..AppearanceSettings::default()
196 },
197 );
198 cx.update(|cx| {
199 gpui_kit::init(cx);
200 install(&store, cx);
201 theme::set_thread_scheme(None);
202 theme::set_thread_shade(None);
163 203 assert_eq!(theme::scheme().id, "rusty-teams");
164 204 assert_eq!(theme::shade(), Shade::Dark);
165 205 });
@@ -160,6 +160,46 @@ mod tests {
160 assert_eq!(appearance::load(&store).theme, ThemeChoice::Light);
160 assert_eq!(appearance::load(&store).theme, ThemeChoice::Light);
161 set_color_scheme(theme::default_scheme(), &store, cx);
161 set_color_scheme(theme::default_scheme(), &store, cx);
162 set_theme(ThemeChoice::Dark, &store, cx);
162 set_theme(ThemeChoice::Dark, &store, cx);
163 assert_eq!(theme::scheme().id, "koninklijke-van-twist");
164 assert_eq!(theme::shade(), Shade::Dark);
165 });
166 }
167
168 #[gpui_kit::test]
169 fn a_fresh_install_starts_in_koninklijke_van_twist_light(cx: &mut TestAppContext) {
170 let _theme_state = theme_state();
171 let store = Store::open_in_memory().expect("in-memory store");
172 cx.update(|cx| {
173 gpui_kit::init(cx);
174 install(&store, cx);
175 theme::set_thread_scheme(None);
176 theme::set_thread_shade(None);
177 assert_eq!(theme::scheme().id, "koninklijke-van-twist");
178 assert_eq!(theme::shade(), Shade::Light);
179 assert_eq!(
180 theme::background(),
181 theme::color(theme::scheme().light.background)
182 );
183 });
184 }
185
186 #[gpui_kit::test]
187 fn a_saved_choice_wins_over_the_default(cx: &mut TestAppContext) {
188 let _theme_state = theme_state();
189 let store = Store::open_in_memory().expect("in-memory store");
190 appearance::save(
191 &store,
192 &AppearanceSettings {
193 color_scheme: theme::scheme_by_id("rusty-teams").expect("rusty-teams scheme"),
194 theme: ThemeChoice::Dark,
195 ..AppearanceSettings::default()
196 },
197 );
198 cx.update(|cx| {
199 gpui_kit::init(cx);
200 install(&store, cx);
201 theme::set_thread_scheme(None);
202 theme::set_thread_shade(None);
163 assert_eq!(theme::scheme().id, "rusty-teams");
203 assert_eq!(theme::scheme().id, "rusty-teams");
164 assert_eq!(theme::shade(), Shade::Dark);
204 assert_eq!(theme::shade(), Shade::Dark);
165 });
205 });