use std::borrow::Cow;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum IconRole {
FolderClosed,
FolderOpen,
File,
Error,
CaretRight,
CaretDown,
}
#[derive(Debug, Clone, PartialEq)]
pub struct IconSpec {
pub glyph: Cow<'static, str>,
pub font: Option<&'static str>,
pub size: Option<f32>,
}
pub trait IconTheme: Send + Sync {
fn glyph(&self, role: IconRole) -> IconSpec;
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub struct UnicodeTheme;
impl IconTheme for UnicodeTheme {
fn glyph(&self, role: IconRole) -> IconSpec {
let glyph: &'static str = match role {
IconRole::FolderClosed => "📁",
IconRole::FolderOpen => "📂",
IconRole::File => "📄",
IconRole::Error => "⚠",
IconRole::CaretRight => "▸",
IconRole::CaretDown => "▾",
};
IconSpec {
glyph: Cow::Borrowed(glyph),
font: None,
size: None,
}
}
}
#[cfg(feature = "icons")]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub struct LucideTheme;
#[cfg(feature = "icons")]
impl IconTheme for LucideTheme {
fn glyph(&self, role: IconRole) -> IconSpec {
let glyph: &'static str = match role {
IconRole::FolderClosed => "\u{ea83}", IconRole::FolderOpen => "\u{ea84}", IconRole::File => "\u{ea7f}", IconRole::Error => "\u{ea78}", IconRole::CaretRight => "\u{ea59}", IconRole::CaretDown => "\u{ea56}", _ => "\u{ea30}", };
IconSpec {
glyph: Cow::Borrowed(glyph),
font: Some("lucide"),
size: Some(14.0),
}
}
}
#[cfg(feature = "icons")]
pub const LUCIDE_FONT_BYTES: &[u8] = &[];