ailloli_ui_render_wgpu/icons/
lucide.rs

1//! Maps `IconId` to Lucide font glyphs (fontdue raster path).
2
3use ailloli_ui_core::IconId;
4use lucide_icons::Icon;
5
6/// Maps the framework's curated icon identifiers to Lucide glyphs.
7///
8/// Existing `IconId::Lucide` values pass through. Devicon and SVG identifiers
9/// have separate raster paths and therefore map to `Circle` only as a defensive
10/// fallback when this function is called directly.
11///
12/// # Examples
13///
14/// ```
15/// use ailloli_ui_core::IconId;
16/// use ailloli_ui_render_wgpu::icons::lucide::curated_to_lucide;
17/// assert_eq!(char::from(curated_to_lucide(IconId::Plus)),
18///     char::from(lucide_icons::Icon::Plus));
19/// ```
20pub fn curated_to_lucide(id: IconId) -> Icon {
21    match id {
22        IconId::Minimize => Icon::Minus,
23        IconId::Maximize => Icon::Square,
24        IconId::Close => Icon::X,
25        IconId::Copy => Icon::Copy,
26        IconId::Trash => Icon::Trash2,
27        IconId::History => Icon::RotateCcw,
28        IconId::Plus => Icon::Plus,
29        IconId::Check => Icon::Check,
30        IconId::Lucide(icon) => icon,
31        IconId::Devicon(_) | IconId::Svg(_) => Icon::Circle,
32    }
33}
34
35/// Returns the font character for a curated or direct Lucide icon identifier.
36///
37/// # Examples
38///
39/// ```
40/// use ailloli_ui_core::IconId;
41/// use ailloli_ui_render_wgpu::icons::lucide::lucide_char;
42/// assert_eq!(lucide_char(&IconId::Check), char::from(lucide_icons::Icon::Check));
43/// ```
44pub fn lucide_char(id: &IconId) -> char {
45    char::from(curated_to_lucide(id.clone()))
46}