BlueGit

ict rusty-teams

Files

rusty-teams / crates / app-base / src / theme / kvt.rs

kvt.rs

kvt.rs 8.9 KiB Download Raw
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}