1use rune::{Color, TextStyle}; 2use rune_kit::{Kit, MarkdownStyle, PaletteSeed, Type}; 3use std::sync::OnceLock; 4 5pub struct Pal { 6 pub bg: Color, 7 pub surface: Color, 8 pub raised: Color, 9 pub line: Color, 10 pub fg: Color, 11 pub strong: Color, 12 pub muted: Color, 13 pub faint: Color, 14 pub accent: Color, 15 pub accent_fg: Color, 16 pub soft: Color, 17 pub selection: Color, 18 pub ok: Color, 19 pub danger: Color, 20 pub hover: Color, 21 pub shadow: Color, 22} 23 24fn c(h: &str) -> Color { 25 rune::color::hex(h).unwrap_or(Color::WHITE) 26} 27 28pub fn pal() -> &'static Pal { 29 static P: OnceLock<Pal> = OnceLock::new(); 30 P.get_or_init(|| Pal { 31 bg: c("#0a0b0d"), 32 surface: c("#0e1013"), 33 raised: c("#16191e"), 34 line: c("#22262d"), 35 fg: c("#cfd3da"), 36 strong: c("#f2f3f5"), 37 muted: c("#7b8290"), 38 faint: c("#5d6470"), 39 accent: c("#ff8a3d"), 40 accent_fg: c("#0a0b0d"), 41 soft: c("#1d1710"), 42 selection: c("#3a2814"), 43 ok: c("#3ddc97"), 44 danger: c("#ff5d5d"), 45 hover: c("#cfd3da").alpha(0.06), 46 shadow: Color::BLACK.alpha(0.6), 47 }) 48} 49 50pub const SMALL: TextStyle = TextStyle::new(14.0, 400.0).mono().lh(20.0); 51pub const BODY: TextStyle = TextStyle::new(16.0, 400.0).lh(24.0); 52pub const STRONG: TextStyle = TextStyle::new(16.0, 500.0).lh(24.0); 53pub const MONO: TextStyle = BODY.mono(); 54pub const TITLE: TextStyle = TextStyle::new(20.0, 500.0).lh(28.0); 55pub const DISPLAY: TextStyle = TextStyle::new(30.0, 500.0).mono().lh(36.0); 56pub const CONTROL: f32 = 28.0; 57 58pub fn kit() -> Kit { 59 let p = pal(); 60 let mut k = Kit::from_palette(PaletteSeed { 61 bg: p.bg, 62 fg: p.fg, 63 accent: p.accent, 64 }); 65 k.radius.sm = 4.0; 66 k.radius.md = 4.0; 67 k.ty = Type { 68 ui: BODY, 69 ui_medium: STRONG, 70 ui_compact: BODY.lh(20.0), 71 small: SMALL, 72 small_medium: SMALL, 73 body: BODY, 74 body_medium: STRONG, 75 text_small: BODY, 76 text_small_medium: STRONG, 77 text_xsmall: BODY, 78 text_xsmall_medium: STRONG, 79 mono: MONO, 80 }; 81 k 82} 83 84pub fn markdown(k: &Kit) -> MarkdownStyle { 85 MarkdownStyle::from_kit(k) 86 .body_font(BODY) 87 .heading_font(1, TITLE) 88 .heading_font(2, STRONG) 89 .heading_font(3, STRONG) 90 .heading_font(4, STRONG) 91 .code_block_font(MONO) 92 .diagram_font(BODY) 93}