leptos_bootstrap/v5/
typography.rs

1use leptos::prelude::*;
2use std::fmt;
3
4#[component]
5pub fn Display<'a>(
6    size: &'a u8,
7    #[prop(optional, into)] class: &'a str,
8    children: Children,
9) -> impl IntoView {
10    let class = format!("display-{} {}", size, class);
11    view! { <h1 class=class>{children()}</h1> }
12}
13
14#[component]
15pub fn Lead<'a>(#[prop(optional, into)] class: &'a str, children: Children) -> impl IntoView {
16    let class = format!("lead {}", class);
17    view! { <p class=class>{children()}</p> }
18}
19
20#[component]
21pub fn BlockQuote<'a>(
22    #[prop(optional, into)] source: String,
23    #[prop(optional, into)] class: &'a str,
24    children: Children,
25) -> impl IntoView {
26    let class = format!("blockquote {}", class);
27    let empty = source.is_empty();
28    view! {
29        <blockquote class=class>
30            {children()} <Show when=move || !empty>
31                <figcaption class="blockquote-footer">{source.clone()}</figcaption>
32            </Show>
33        </blockquote>
34    }
35}
36
37pub enum ImageKind {
38    Fluid,
39    Thumbnail,
40}
41
42impl fmt::Display for ImageKind {
43    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
44        let s = match self {
45            Self::Fluid => "img-fluid",
46            Self::Thumbnail => "img-thumbnail",
47        };
48        write!(f, "{}", s)
49    }
50}
51
52#[component]
53pub fn Image<'a>(
54    #[prop(default = ImageKind::Fluid)] kind: ImageKind,
55    #[prop(optional, into)] src: &'a str,
56    #[prop(optional, into)] alt: &'a str,
57    #[prop(optional, into)] class: &'a str,
58) -> impl IntoView {
59    let class = format!("{} {}", kind, class);
60    view! { <img src=src class=class alt=alt /> }
61}