leptos_bootstrap/v5/
icon.rs

1use leptos::prelude::*;
2use std::fmt;
3
4pub enum IconKind {
5    Circle0,
6    Circle0Fill,
7    BoxArrowRight,
8    BoxArrowInRight,
9    CupHot,
10    CupHotFill,
11    Git,
12    Github,
13    Heart,
14    HeartFill,
15    HouseFill,
16    PersonFill,
17    UiChecks,
18    TelephoneOutbound,
19    FileEarmarkRichtext,
20    People,
21}
22
23impl fmt::Display for IconKind {
24    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
25        let s = match self {
26            Self::Circle0 => "bi-0-circle",
27            Self::Circle0Fill => "bi-0-circle-fill",
28            Self::BoxArrowRight => "bi-box-arrow-right",
29            Self::BoxArrowInRight => "bi-box-arrow-in-right",
30            Self::CupHot => "bi-cup-hot",
31            Self::CupHotFill => "bi-cup-hot-fill",
32            Self::Git => "bi-git",
33            Self::Github => "bi-github",
34            Self::Heart => "bi-heart",
35            Self::HeartFill => "bi-heart-fill",
36            Self::HouseFill => "bi-house-fill",
37            Self::PersonFill => "bi-person-fill",
38            Self::UiChecks => "bi-ui-checks",
39            Self::TelephoneOutbound => "bi-telephone-outbound",
40            Self::FileEarmarkRichtext => "bi-file-earmark-richtext",
41            Self::People => "bi-people",
42        };
43        write!(f, "{}", s)
44    }
45}
46
47#[component]
48pub fn Icon<'a>(kind: IconKind, #[prop(optional, into)] class: &'a str) -> impl IntoView {
49    let class = format!("bi {} {}", kind, class);
50    view! {
51        <i class=class></i>
52    }
53}