1use leptos::*;
2
3pub enum TextVariant {
4 H1,
5 H2,
6 H3,
7 H4,
8 H5,
9 H6,
10 P,
11 Span,
12}
13
14#[component]
16pub fn Text(
17 #[prop(into, optional)] variant: Option<TextVariant>,
18 #[prop(into, optional)] id: Option<AttributeValue>,
19 #[prop(into, optional)] class: Option<AttributeValue>,
20 #[prop(into, optional)] style: Option<AttributeValue>,
21 children: Children,
22) -> impl IntoView {
23 match variant {
24 None => Span(SpanProps {
25 id,
26 class,
27 style,
28 children,
29 })
30 .into_view(),
31 Some(validVariant) => match validVariant {
32 TextVariant::H1 => view! {
33 <h1 id=id class=class style=style>
34 {children()}
35 </h1>
36 }
37 .into_view(),
38 TextVariant::H2 => view! {
39 <h2 id=id class=class style=style>
40 {children()}
41 </h2>
42 }
43 .into_view(),
44 TextVariant::H3 => view! {
45 <h3 id=id class=class style=style>
46 {children()}
47 </h3>
48 }
49 .into_view(),
50 TextVariant::H4 => view! {
51 <h4 id=id class=class style=style>
52 {children()}
53 </h4>
54 }
55 .into_view(),
56 TextVariant::H5 => view! {
57 <h5 id=id class=class style=style>
58 {children()}
59 </h5>
60 }
61 .into_view(),
62 TextVariant::H6 => view! {
63 <h6 id=id class=class style=style>
64 {children()}
65 </h6>
66 }
67 .into_view(),
68 TextVariant::P => view! {
69 <p id=id class=class style=style>
70 {children()}
71 </p>
72 }
73 .into_view(),
74 _ => Span(SpanProps {
75 id,
76 class,
77 style,
78 children,
79 })
80 .into_view(),
81 },
82 }
83}
84
85#[component]
86pub fn Span(
87 #[prop(into, optional)] id: Option<AttributeValue>,
88 #[prop(into, optional)] class: Option<AttributeValue>,
89 #[prop(into, optional)] style: Option<AttributeValue>,
90 children: Children,
91) -> impl IntoView {
92 view! {
93 <span id=id class=class style=style>
94 {children()}
95 </span>
96 }
97}
98