1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
use leptos::*;

pub enum TextVariant {
    H1,
    H2,
    H3,
    H4,
    H5,
    H6,
    P,
    Span,
}

/// Text Leptos Component
#[component]
pub fn Text(
    #[prop(into, optional)] variant: Option<TextVariant>,
    #[prop(into, optional)] id: Option<AttributeValue>,
    #[prop(into, optional)] class: Option<AttributeValue>,
    #[prop(into, optional)] style: Option<AttributeValue>,
    children: Children,
) -> impl IntoView {
    match variant {
        None => Span(SpanProps {
            id,
            class,
            style,
            children,
        })
        .into_view(),
        Some(validVariant) => match validVariant {
            TextVariant::H1 => view! {
                <h1 id=id class=class style=style>
                    {children()}
                </h1>
            }
            .into_view(),
            TextVariant::H2 => view! {
                <h2 id=id class=class style=style>
                    {children()}
                </h2>
            }
            .into_view(),
            TextVariant::H3 => view! {
                <h3 id=id class=class style=style>
                    {children()}
                </h3>
            }
            .into_view(),
            TextVariant::H4 => view! {
                <h4 id=id class=class style=style>
                    {children()}
                </h4>
            }
            .into_view(),
            TextVariant::H5 => view! {
                <h5 id=id class=class style=style>
                    {children()}
                </h5>
            }
            .into_view(),
            TextVariant::H6 => view! {
                <h6 id=id class=class style=style>
                    {children()}
                </h6>
            }
            .into_view(),
            TextVariant::P => view! {
                <p id=id class=class style=style>
                    {children()}
                </p>
            }
            .into_view(),
            _ => Span(SpanProps {
                id,
                class,
                style,
                children,
            })
            .into_view(),
        },
    }
}

#[component]
pub fn Span(
    #[prop(into, optional)] id: Option<AttributeValue>,
    #[prop(into, optional)] class: Option<AttributeValue>,
    #[prop(into, optional)] style: Option<AttributeValue>,
    children: Children,
) -> impl IntoView {
    view! {
        <span id=id class=class style=style>
            {children()}
        </span>
    }
}