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