1use leptos::{either::EitherOf3, prelude::*};
2use thaw_utils::{class_list, mount_style};
3
4#[component]
5pub fn Code(
6 #[prop(optional, into)] class: MaybeProp<String>,
7 #[prop(optional, into)] text: Option<String>,
8 #[prop(optional, into)] inner_html: Option<String>,
9) -> impl IntoView {
10 mount_style("code", include_str!("./code.css"));
11 view! {
12 <code class=class_list![
13 "thaw-code",
14 class
15 ]>
16
17 {if let Some(inner_html) = inner_html {
18 EitherOf3::A(view! { <pre inner_html=inner_html></pre> })
19 } else if let Some(text) = text {
20 EitherOf3::B(view! { <pre>{text}</pre> })
21 } else {
22 EitherOf3::C(())
23 }}
24
25 </code>
26 }
27}