[weaver-renderer] add built-in themes behind feature flag

Orual 84cc3e65 4705bfcc

+176
+2
crates/weaver-renderer/Cargo.toml
··· 12 12 syntax-highlighting = ["dep:syntect"] 13 13 # CSS generation from themes (css.rs) - native only, needs plist + themes 14 14 syntax-css = ["syntax-highlighting"] 15 + # Built-in colour schemes and code themes for UI selection (server only) 16 + themes = [] 15 17 16 18 [dependencies] 17 19 n0-future.workspace = true
+2
crates/weaver-renderer/src/lib.rs
··· 38 38 #[cfg(all(not(target_family = "wasm"), feature = "syntax-highlighting"))] 39 39 pub mod static_site; 40 40 pub mod theme; 41 + #[cfg(feature = "themes")] 42 + pub mod themes; 41 43 pub mod types; 42 44 pub mod utils; 43 45 #[cfg(not(target_family = "wasm"))]
+65
crates/weaver-renderer/src/themes/code_themes.rs
··· 1 + //! Built-in code syntax highlighting themes. 2 + 3 + /// A built-in code theme definition. 4 + #[derive(Debug, Clone)] 5 + pub struct BuiltinCodeTheme { 6 + /// Unique identifier matching the syntect theme name. 7 + pub id: &'static str, 8 + /// Human-readable name. 9 + pub name: &'static str, 10 + /// Whether this is "dark" or "light". 11 + pub variant: &'static str, 12 + } 13 + 14 + /// All built-in code themes available for selection. 15 + /// 16 + /// These include embedded themes (rose-pine variants) and syntect's default themes. 17 + pub static BUILTIN_CODE_THEMES: &[BuiltinCodeTheme] = &[ 18 + // Embedded themes (always available). 19 + BuiltinCodeTheme { 20 + id: "rose-pine", 21 + name: "Rose Pine", 22 + variant: "dark", 23 + }, 24 + BuiltinCodeTheme { 25 + id: "rose-pine-dawn", 26 + name: "Rose Pine Dawn", 27 + variant: "light", 28 + }, 29 + // Syntect default themes. 30 + BuiltinCodeTheme { 31 + id: "base16-ocean.dark", 32 + name: "Base16 Ocean", 33 + variant: "dark", 34 + }, 35 + BuiltinCodeTheme { 36 + id: "base16-eighties.dark", 37 + name: "Base16 Eighties", 38 + variant: "dark", 39 + }, 40 + BuiltinCodeTheme { 41 + id: "base16-mocha.dark", 42 + name: "Base16 Mocha", 43 + variant: "dark", 44 + }, 45 + BuiltinCodeTheme { 46 + id: "base16-ocean.light", 47 + name: "Base16 Ocean Light", 48 + variant: "light", 49 + }, 50 + BuiltinCodeTheme { 51 + id: "InspiredGitHub", 52 + name: "Inspired GitHub", 53 + variant: "light", 54 + }, 55 + BuiltinCodeTheme { 56 + id: "Solarized (dark)", 57 + name: "Solarized Dark", 58 + variant: "dark", 59 + }, 60 + BuiltinCodeTheme { 61 + id: "Solarized (light)", 62 + name: "Solarized Light", 63 + variant: "light", 64 + }, 65 + ];
+98
crates/weaver-renderer/src/themes/colour_schemes.rs
··· 1 + //! Built-in colour schemes for notebook theming. 2 + 3 + use std::sync::LazyLock; 4 + use weaver_api::sh_weaver::notebook::colour_scheme::ColourSchemeColours; 5 + use weaver_common::jacquard::CowStr; 6 + 7 + /// A built-in colour scheme definition. 8 + #[derive(Debug, Clone)] 9 + pub struct BuiltinColourScheme { 10 + /// Unique identifier for this scheme. 11 + pub id: &'static str, 12 + /// Human-readable name. 13 + pub name: &'static str, 14 + /// Whether this is "dark" or "light". 15 + pub variant: &'static str, 16 + /// The actual colour values. 17 + pub colours: ColourSchemeColours<'static>, 18 + } 19 + 20 + /// All built-in colour schemes available for selection. 21 + pub static BUILTIN_COLOUR_SCHEMES: LazyLock<Vec<BuiltinColourScheme>> = LazyLock::new(|| { 22 + vec![ 23 + BuiltinColourScheme { 24 + id: "rose-pine", 25 + name: "Rose Pine", 26 + variant: "dark", 27 + colours: ColourSchemeColours { 28 + base: CowStr::new_static("#191724"), 29 + surface: CowStr::new_static("#1f1d2e"), 30 + overlay: CowStr::new_static("#26233a"), 31 + text: CowStr::new_static("#e0def4"), 32 + muted: CowStr::new_static("#6e6a86"), 33 + subtle: CowStr::new_static("#908caa"), 34 + emphasis: CowStr::new_static("#e0def4"), 35 + primary: CowStr::new_static("#c4a7e7"), 36 + secondary: CowStr::new_static("#9ccfd8"), 37 + tertiary: CowStr::new_static("#ebbcba"), 38 + error: CowStr::new_static("#eb6f92"), 39 + warning: CowStr::new_static("#f6c177"), 40 + success: CowStr::new_static("#31748f"), 41 + border: CowStr::new_static("#403d52"), 42 + link: CowStr::new_static("#ebbcba"), 43 + highlight: CowStr::new_static("#524f67"), 44 + extra_data: None, 45 + }, 46 + }, 47 + BuiltinColourScheme { 48 + id: "rose-pine-moon", 49 + name: "Rose Pine Moon", 50 + variant: "dark", 51 + colours: ColourSchemeColours { 52 + base: CowStr::new_static("#232136"), 53 + surface: CowStr::new_static("#2a273f"), 54 + overlay: CowStr::new_static("#393552"), 55 + text: CowStr::new_static("#e0def4"), 56 + muted: CowStr::new_static("#6e6a86"), 57 + subtle: CowStr::new_static("#908caa"), 58 + emphasis: CowStr::new_static("#e0def4"), 59 + primary: CowStr::new_static("#c4a7e7"), 60 + secondary: CowStr::new_static("#9ccfd8"), 61 + tertiary: CowStr::new_static("#ea9a97"), 62 + error: CowStr::new_static("#eb6f92"), 63 + warning: CowStr::new_static("#f6c177"), 64 + success: CowStr::new_static("#3e8fb0"), 65 + border: CowStr::new_static("#44415a"), 66 + link: CowStr::new_static("#ea9a97"), 67 + highlight: CowStr::new_static("#56526e"), 68 + extra_data: None, 69 + }, 70 + }, 71 + BuiltinColourScheme { 72 + id: "rose-pine-dawn", 73 + name: "Rose Pine Dawn", 74 + variant: "light", 75 + colours: ColourSchemeColours { 76 + base: CowStr::new_static("#faf4ed"), 77 + surface: CowStr::new_static("#fffaf3"), 78 + overlay: CowStr::new_static("#f2e9e1"), 79 + // Text colors darkened for better contrast. 80 + text: CowStr::new_static("#1f1d2e"), 81 + muted: CowStr::new_static("#635e74"), 82 + subtle: CowStr::new_static("#4a4560"), 83 + emphasis: CowStr::new_static("#1e1a2d"), 84 + // Accent colors at original Rose Pine Dawn values. 85 + primary: CowStr::new_static("#907aa9"), 86 + secondary: CowStr::new_static("#56949f"), 87 + tertiary: CowStr::new_static("#286983"), 88 + error: CowStr::new_static("#b4637a"), 89 + warning: CowStr::new_static("#ea9d34"), 90 + success: CowStr::new_static("#286983"), 91 + border: CowStr::new_static("#dfdad9"), 92 + link: CowStr::new_static("#d7827e"), 93 + highlight: CowStr::new_static("#cecacd"), 94 + extra_data: None, 95 + }, 96 + }, 97 + ] 98 + });
+9
crates/weaver-renderer/src/themes/mod.rs
··· 1 + //! Built-in themes for notebooks (server-only). 2 + //! 3 + //! Gated behind the `themes` feature to avoid bloating WASM bundles. 4 + 5 + mod code_themes; 6 + mod colour_schemes; 7 + 8 + pub use code_themes::{BuiltinCodeTheme, BUILTIN_CODE_THEMES}; 9 + pub use colour_schemes::{BuiltinColourScheme, BUILTIN_COLOUR_SCHEMES};