use crate::CooljapanTheme;
use oxiui_core::{Color, FontSpec, Palette};
fn theme(palette: Palette) -> CooljapanTheme {
CooljapanTheme::new(palette, FontSpec::new("Inter", 14.0, 400))
}
pub fn make_nord_dark() -> CooljapanTheme {
theme(Palette {
background: Color(46, 52, 64, 255), surface: Color(59, 66, 82, 255), primary: Color(136, 192, 208, 255), on_primary: Color(46, 52, 64, 255), text: Color(216, 222, 233, 255), muted: Color(76, 86, 106, 255), })
}
pub fn make_nord_light() -> CooljapanTheme {
theme(Palette {
background: Color(236, 239, 244, 255), surface: Color(229, 233, 240, 255), primary: Color(94, 129, 172, 255), on_primary: Color(236, 239, 244, 255), text: Color(46, 52, 64, 255), muted: Color(76, 86, 106, 255), })
}
pub fn make_dracula() -> CooljapanTheme {
theme(Palette {
background: Color(40, 42, 54, 255), surface: Color(68, 71, 90, 255), primary: Color(189, 147, 249, 255), on_primary: Color(40, 42, 54, 255), text: Color(248, 248, 242, 255), muted: Color(98, 114, 164, 255), })
}
pub fn make_solarized_dark() -> CooljapanTheme {
theme(Palette {
background: Color(0, 43, 54, 255), surface: Color(7, 54, 66, 255), primary: Color(38, 139, 210, 255), on_primary: Color(0, 43, 54, 255), text: Color(131, 148, 150, 255), muted: Color(88, 110, 117, 255), })
}
pub fn make_solarized_light() -> CooljapanTheme {
theme(Palette {
background: Color(253, 246, 227, 255), surface: Color(238, 232, 213, 255), primary: Color(38, 139, 210, 255), on_primary: Color(253, 246, 227, 255), text: Color(101, 123, 131, 255), muted: Color(147, 161, 161, 255), })
}
pub fn make_catppuccin_mocha() -> CooljapanTheme {
theme(Palette {
background: Color(30, 30, 46, 255), surface: Color(49, 50, 68, 255), primary: Color(137, 180, 250, 255), on_primary: Color(30, 30, 46, 255), text: Color(205, 214, 244, 255), muted: Color(166, 173, 200, 255), })
}
pub fn make_catppuccin_latte() -> CooljapanTheme {
theme(Palette {
background: Color(239, 241, 245, 255), surface: Color(204, 208, 218, 255), primary: Color(30, 102, 245, 255), on_primary: Color(239, 241, 245, 255), text: Color(76, 79, 105, 255), muted: Color(108, 111, 133, 255), })
}
pub fn make_material_dark() -> CooljapanTheme {
theme(Palette {
background: Color(20, 18, 24, 255), surface: Color(33, 31, 38, 255), primary: Color(208, 188, 255, 255), on_primary: Color(56, 30, 114, 255), text: Color(230, 225, 229, 255), muted: Color(147, 143, 153, 255), })
}
pub fn make_material_light() -> CooljapanTheme {
theme(Palette {
background: Color(255, 251, 254, 255), surface: Color(243, 237, 247, 255), primary: Color(103, 80, 164, 255), on_primary: Color(255, 255, 255, 255), text: Color(28, 27, 31, 255), muted: Color(73, 69, 79, 255), })
}
#[cfg(test)]
mod tests {
use super::*;
use crate::high_contrast::wcag_contrast;
use oxiui_core::Theme;
fn contrast_text_on_bg(theme: &CooljapanTheme) -> f64 {
let p = theme.palette();
wcag_contrast(
(p.text.0, p.text.1, p.text.2),
(p.background.0, p.background.1, p.background.2),
)
}
#[test]
fn nord_dark_constructs_without_panic() {
let t = make_nord_dark();
let ratio = contrast_text_on_bg(&t);
assert!(ratio >= 3.0, "nord dark text/bg contrast: {ratio:.2}");
}
#[test]
fn nord_light_constructs() {
let _t = make_nord_light();
}
#[test]
fn dracula_constructs() {
let _t = make_dracula();
}
#[test]
fn solarized_light_constructs_and_is_accessible() {
let t = make_solarized_light();
let ratio = contrast_text_on_bg(&t);
assert!(ratio >= 4.0, "solarized light text/bg contrast: {ratio:.2}");
}
#[test]
fn solarized_dark_constructs() {
let _t = make_solarized_dark();
}
#[test]
fn catppuccin_mocha_constructs() {
let _t = make_catppuccin_mocha();
}
#[test]
fn catppuccin_latte_constructs() {
let _t = make_catppuccin_latte();
}
#[test]
fn material_dark_constructs() {
let _t = make_material_dark();
}
#[test]
fn material_light_constructs() {
let _t = make_material_light();
}
#[test]
fn all_gallery_themes_construct() {
let themes: Vec<CooljapanTheme> = vec![
make_nord_dark(),
make_nord_light(),
make_dracula(),
make_solarized_dark(),
make_solarized_light(),
make_catppuccin_mocha(),
make_catppuccin_latte(),
make_material_dark(),
make_material_light(),
];
assert_eq!(
themes.len(),
9,
"all 9 gallery themes must be constructible"
);
}
}