//! Colour scheme "Koninklijke van Twist" (KVT house style). Kept in its own file so the //! upstream scheme file stays untouched apart from the list of schemes. //! //! Source: Huisstijlhandboek KVT (versie september 2020) and `kleuren-kvt.pdf`, KVT Intranet > //! Marketing > Huisstijlhandboek. The brand colours are the official ones: //! //! | Name | HEX | RGB | CMYK | PMS | //! |---------------|---------|-------------|-----------------|----------------| //! | Perkins blauw | #00529B | 0 82 155 | 100 69 0 11 | 287 C | //! | Helder blauw | #0099CC | 0 153 204 | 100 13 1 3 | Process Blue C | //! | Lichtblauw | #33CCFF | 51 204 255 | 57 0 7 0 | 305 C | //! | Donkergrijs | #575757 | 86 86 86 | 0 0 0 80 | Cool gray 11 | //! //! `NAVY` (#00101F) is the title and body text colour of the KVT presentation template 2026.1. //! Every other value is a mix of those colours with white or `NAVY` (surfaces, borders, hover //! states) or a status colour copied from the other schemes. //! //! The house style asks for the logo on a white background, so the light shade is the primary //! look and the one new installations start in. Perkins blauw is the accent in both shades: //! buttons, focus rings, tab indicators, badges, selection and other fills. On a dark ground //! Perkins is too dark for text (and Helder blauw / Lichtblauw are too light for text on white, //! about 3.1 and 1.8 to 1), so links and icons on dark surfaces use a light tint of Lichtblauw, //! and those two blues otherwise appear as tints. //! //! Font: the house style names DINPro (promotion) and Arial (letters). The app keeps its own //! font: DINPro cannot be redistributed and the font is not part of a colour scheme. //! //! Who gets it: a new install, and anyone without saved appearance settings, starts in this //! scheme in its light shade (`appearance::AppearanceSettings::default`). A saved choice is kept, //! also when it is Rusty Teams or Teams. Settings saved without a scheme or theme key (oldest //! versions) keep Rusty Teams and dark. use super::schemes::{ColorScheme, DARK_BASE, LIGHT_BASE, Palette}; /// Family names under which DINPro is commonly installed. The font is not shipped /// with the app (licence); we only use it when the OS already has it. pub const FONT_CANDIDATES: &[&str] = &["DINPro", "DIN Pro", "DINPro-Regular", "DIN Pro Regular"]; /// First installed family that matches [`FONT_CANDIDATES`], case-insensitive. /// `None` means the caller should keep the bundled default. pub fn system_font_family>(installed: &[S]) -> Option<&'static str> { FONT_CANDIDATES.iter().copied().find(|candidate| { installed .iter() .any(|name| name.as_ref().eq_ignore_ascii_case(candidate)) }) } const AVATAR_PALETTE: [u32; 6] = [0x00529b, 0x00698f, 0x575757, 0x2c5479, 0x004e6d, 0x00315d]; pub const KVT: ColorScheme = ColorScheme { id: "koninklijke-van-twist", name: "Koninklijke van Twist", dark: Palette { background: 0x00101f, surface: 0x061a2e, surface_raised: 0x12304f, row_hover: 0x0e2744, popup: 0x183a5e, popup_hover: 0x204670, popup_nested: 0x214a76, popup_nested_hover: 0x2a5886, reply_surface: 0x0a2038, border: 0x0f2a47, border_strong: 0x24476b, foreground: 0xf2f8fc, text_strong: 0xe3eef7, text_soft: 0xcfdeeb, text_muted: 0xa3b8cb, text_faint: 0x8fa6bb, accent: 0x00529b, accent_text: 0x66d9ff, accent_soft: 0x99e6ff, accent_strong: 0x003b70, on_accent: 0xffffff, bubble_own: 0x00396b, bubble_other: 0x12304f, reaction_on_own: 0x00529b, mention_background: 0x0a3a66, mention_background_own: 0x00529b, own_meta: 0xbfe4f7, own_read: 0x66d9ff, drop_background: 0x00529b14, selection: 0x00529b66, rule_own: 0x00529b, badge_muted: 0x24476b, toast_mention: 0x082f52, green: 0x22c55e, red: 0xef4444, red_soft: 0xf87171, red_tint: 0xfca5a5, amber: 0xfbbf24, close_button_hover: 0xc42b1c, close_button_pressed: 0xb5271a, avatar_palette: AVATAR_PALETTE, ..DARK_BASE }, light: Palette { background: 0xe6eef5, surface: 0xf5f8fb, surface_raised: 0xffffff, row_hover: 0xedf3f8, popup: 0xffffff, popup_hover: 0xf0f5f9, popup_nested: 0xffffff, popup_nested_hover: 0xe8eff6, reply_surface: 0xfafcfd, border: 0xd1e0ed, border_strong: 0xadc8df, foreground: 0x00101f, text_strong: 0x00101f, text_soft: 0x2c343b, text_muted: 0x575757, text_faint: 0x626262, accent: 0x00529b, accent_text: 0x004888, accent_soft: 0x003463, accent_strong: 0x003b70, on_accent: 0xffffff, bubble_own: 0xd1e0ed, bubble_other: 0xffffff, reaction_on_own: 0xd1e0ed, mention_background: 0xd6e3ef, mention_background_own: 0xd1e0ed, own_meta: 0x004582, own_read: 0x00529b, drop_background: 0x00529b14, selection: 0x00529b59, rule_own: 0xa6c2dc, badge_muted: 0xadc8df, toast_mention: 0xd6e3ef, green: 0x16a34a, red: 0xc81e1e, red_soft: 0xb91c1c, red_tint: 0x991b1b, amber: 0xc27c0e, close_button_hover: 0xc42b1c, close_button_pressed: 0xb5271a, avatar_palette: AVATAR_PALETTE, ..LIGHT_BASE }, }; #[cfg(test)] mod tests { use super::super::Shade; use super::*; fn channel(hex: u32, shift: u32) -> f64 { let value = f64::from((hex >> shift) & 0xff) / 255.; if value <= 0.04045 { value / 12.92 } else { ((value + 0.055) / 1.055).powf(2.4) } } fn luminance(hex: u32) -> f64 { 0.2126 * channel(hex, 16) + 0.7152 * channel(hex, 8) + 0.0722 * channel(hex, 0) } fn contrast(first: u32, second: u32) -> f64 { let (first, second) = (luminance(first), luminance(second)); (first.max(second) + 0.05) / (first.min(second) + 0.05) } #[test] fn the_scheme_uses_the_official_kvt_blues() { assert_eq!(KVT.light.accent, 0x00529b, "Perkins blauw"); assert_eq!(KVT.dark.accent, 0x00529b, "Perkins blauw on fills"); assert_eq!(KVT.dark.on_accent, 0xffffff); assert_eq!(KVT.dark.accent_text, 0x66d9ff, "readable on dark grounds"); assert_eq!(KVT.dark.accent_strong, 0x003b70); assert_eq!(KVT.light.selection, 0x00529b59); assert_eq!(KVT.dark.selection, 0x00529b66); assert_eq!(KVT.light.text_muted, 0x575757, "Donkergrijs"); assert_eq!(KVT.light.foreground, 0x00101f); assert_eq!(KVT.light.shade, Shade::Light); assert_eq!(KVT.dark.shade, Shade::Dark); } /// WCAG AA asks 4.5 to 1 for normal text. The shared test in `schemes.rs` is looser for /// muted and faint text; this scheme meets AA for every text role on every ground. #[test] fn every_text_role_meets_wcag_aa_on_every_ground() { for palette in [&KVT.dark, &KVT.light] { let grounds = [ palette.background, palette.surface, palette.reply_surface, palette.row_hover, palette.surface_raised, palette.popup, palette.bubble_other, palette.bubble_own, ]; let roles = [ ("foreground", palette.foreground), ("text_soft", palette.text_soft), ("text_muted", palette.text_muted), ("text_faint", palette.text_faint), ("accent_text", palette.accent_text), ]; for (name, text) in roles { for ground in grounds { let ratio = contrast(text, ground); assert!( ratio >= 4.5, "{:?}: {name} #{text:06x} on #{ground:06x} is {ratio:.2}", palette.shade ); } } for (name, text, ground) in [ ("on_accent", palette.on_accent, palette.accent), ("own_meta", palette.own_meta, palette.bubble_own), ( "foreground on mention", palette.foreground, palette.mention_background, ), ( "accent_text on mention", palette.accent_text, palette.mention_background, ), ( "foreground on own mention", palette.foreground, palette.mention_background_own, ), ( "foreground on own reaction", palette.foreground, palette.reaction_on_own, ), ( "foreground on popup hover", palette.foreground, palette.popup_hover, ), ( "text_muted on popup hover", palette.text_muted, palette.popup_hover, ), ( "foreground on toast mention", palette.foreground, palette.toast_mention, ), ] { let ratio = contrast(text, ground); assert!( ratio >= 4.5, "{:?}: {name} #{text:06x} on #{ground:06x} is {ratio:.2}", palette.shade ); } for avatar in palette.avatar_palette { assert!(contrast(0xffffff, avatar) >= 4.5, "avatar #{avatar:06x}"); } } } #[test] fn dinpro_is_picked_when_installed_and_ignored_otherwise() { assert_eq!(system_font_family(&[] as &[&str]), None); assert_eq!(system_font_family(&["Google Sans Flex", "Arial"]), None); assert_eq!(system_font_family(&["DINPro"]), Some("DINPro")); assert_eq!(system_font_family(&["dinpro"]), Some("DINPro")); assert_eq!(system_font_family(&["DIN Pro"]), Some("DIN Pro")); assert_eq!( system_font_family(&["DIN Pro Regular"]), Some("DIN Pro Regular") ); assert_eq!( system_font_family(&["DINPro-Regular"]), Some("DINPro-Regular") ); // Prefer the first candidate when several are present. assert_eq!( system_font_family(&["DIN Pro Regular", "DIN Pro", "DINPro"]), Some("DINPro") ); } }