refactor: redesign theme tokens and split catppuccin themes

This commit is contained in:
2026-05-13 20:02:26 +08:00
parent af5fd60eb5
commit 2c3de1fd6e
20 changed files with 797 additions and 667 deletions

121
src/theme/catppuccin.rs Normal file
View File

@@ -0,0 +1,121 @@
use crate::colors::{hex, hex_alpha};
use super::{Theme, ThemeColors, ThemeMode};
pub(crate) const FAMILY_ID: &str = "catppuccin";
pub(crate) const FAMILY_LABEL: &str = "Catppuccin";
pub(crate) const LATTE_LABEL: &str = "Catppuccin Latte";
pub(crate) const MOCHA_LABEL: &str = "Catppuccin Mocha";
pub(crate) const fn latte() -> Theme {
Theme {
id: "catppuccin-latte",
name: LATTE_LABEL,
mode: ThemeMode::Light,
colors: ThemeColors {
background: hex(0xeff1f5),
surface: hex(0xeff1f5),
surface_elevated: hex(0xdce0e8),
surface_chrome: hex(0xe6e9ef),
surface_hover: hex(0xe6e9ef),
surface_active: hex(0xdce0e8),
border: hex(0xbcc0cc),
border_muted: hex(0xccd0da),
border_strong: hex(0xacb0be),
focus_ring: hex(0x7287fd),
text: hex(0x4c4f69),
text_muted: hex(0x5c5f77),
text_subtle: hex(0x6c6f85),
text_disabled: hex(0x9ca0b0),
icon_muted: hex(0x6c6f85),
link: hex(0x1e66f5),
link_hover: hex(0x7287fd),
code_bg: hex(0xe6e9ef),
code_border: hex(0xccd0da),
selection_bg: hex_alpha(0x8839ef, 0.10),
selection_border: hex_alpha(0x8839ef, 0.35),
accent_fg: hex(0x8839ef),
accent_muted: hex_alpha(0x8839ef, 0.12),
accent_border: hex_alpha(0x8839ef, 0.28),
accent_solid: hex(0x8839ef),
accent_on_solid: hex(0xeff1f5),
success_fg: hex(0x40a02b),
success_muted: hex_alpha(0x40a02b, 0.12),
success_border: hex_alpha(0x40a02b, 0.28),
success_solid: hex(0x40a02b),
success_on_solid: hex(0x1e1e2e),
warning_fg: hex(0xdf8e1d),
warning_muted: hex_alpha(0xdf8e1d, 0.12),
warning_border: hex_alpha(0xdf8e1d, 0.32),
warning_solid: hex(0xdf8e1d),
warning_on_solid: hex(0x1e1e2e),
danger_fg: hex(0xd20f39),
danger_muted: hex_alpha(0xd20f39, 0.12),
danger_border: hex_alpha(0xd20f39, 0.28),
danger_solid: hex(0xd20f39),
danger_on_solid: hex(0xeff1f5),
info_fg: hex(0x1e66f5),
info_muted: hex_alpha(0x1e66f5, 0.12),
info_border: hex_alpha(0x1e66f5, 0.28),
info_solid: hex(0x1e66f5),
info_on_solid: hex(0xeff1f5),
},
}
}
pub(crate) const fn mocha() -> Theme {
Theme {
id: "catppuccin-mocha",
name: MOCHA_LABEL,
mode: ThemeMode::Dark,
colors: ThemeColors {
background: hex(0x1e1e2e),
surface: hex(0x181825),
surface_elevated: hex(0x313244),
surface_chrome: hex(0x11111b),
surface_hover: hex(0x313244),
surface_active: hex(0x45475a),
border: hex(0x585b70),
border_muted: hex(0x45475a),
border_strong: hex(0x6c7086),
focus_ring: hex(0xb4befe),
text: hex(0xcdd6f4),
text_muted: hex(0xbac2de),
text_subtle: hex(0xa6adc8),
text_disabled: hex(0x7f849c),
icon_muted: hex(0xa6adc8),
link: hex(0x89b4fa),
link_hover: hex(0xb4befe),
code_bg: hex(0x11111b),
code_border: hex(0x45475a),
selection_bg: hex_alpha(0xcba6f7, 0.18),
selection_border: hex_alpha(0xcba6f7, 0.45),
accent_fg: hex(0xcba6f7),
accent_muted: hex_alpha(0xcba6f7, 0.18),
accent_border: hex_alpha(0xcba6f7, 0.34),
accent_solid: hex(0xcba6f7),
accent_on_solid: hex(0x1e1e2e),
success_fg: hex(0xa6e3a1),
success_muted: hex_alpha(0xa6e3a1, 0.18),
success_border: hex_alpha(0xa6e3a1, 0.34),
success_solid: hex(0xa6e3a1),
success_on_solid: hex(0x1e1e2e),
warning_fg: hex(0xf9e2af),
warning_muted: hex_alpha(0xf9e2af, 0.18),
warning_border: hex_alpha(0xf9e2af, 0.38),
warning_solid: hex(0xf9e2af),
warning_on_solid: hex(0x1e1e2e),
danger_fg: hex(0xf38ba8),
danger_muted: hex_alpha(0xf38ba8, 0.18),
danger_border: hex_alpha(0xf38ba8, 0.34),
danger_solid: hex(0xf38ba8),
danger_on_solid: hex(0x1e1e2e),
info_fg: hex(0x89b4fa),
info_muted: hex_alpha(0x89b4fa, 0.18),
info_border: hex_alpha(0x89b4fa, 0.34),
info_solid: hex(0x89b4fa),
info_on_solid: hex(0x1e1e2e),
},
}
}