leptos_bootstrap/v5/
typography.rs1use 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! {
12 <h1 class=class>
13 {children()}
14 </h1>
15 }
16}
17
18#[component]
19pub fn Lead<'a>(#[prop(optional, into)] class: &'a str, children: Children) -> impl IntoView {
20 let class = format!("lead {}", class);
21 view! {
22 <p class=class>
23 {children()}
24 </p>
25 }
26}
27
28#[component]
29pub fn BlockQuote<'a>(
30 #[prop(optional, into)] source: String,
31 #[prop(optional, into)] class: &'a str,
32 children: Children,
33) -> impl IntoView {
34 let class = format!("blockquote {}", class);
35 let empty = source.is_empty();
36 view! {
37 <blockquote class=class>
38 {children()}
39 <Show when=move || !empty>
40 <figcaption class="blockquote-footer">
41 {source.clone()}
42 </figcaption>
43 </Show>
44 </blockquote>
45 }
46}
47
48pub enum ImageKind {
49 Fluid,
50 Thumbnail,
51}
52
53impl fmt::Display for ImageKind {
54 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
55 let s = match self {
56 Self::Fluid => "img-fluid",
57 Self::Thumbnail => "img-thumbnail",
58 };
59 write!(f, "{}", s)
60 }
61}
62
63#[component]
64pub fn Image<'a>(
65 #[prop(default = ImageKind::Fluid)] kind: ImageKind,
66 #[prop(optional, into)] src: &'a str,
67 #[prop(optional, into)] alt: &'a str,
68 #[prop(optional, into)] class: &'a str,
69) -> impl IntoView {
70 let class = format!("{} {}", kind, class);
71 view! {
72 <img src=src class=class alt=alt />
73 }
74}