diff --git a/demo/src/components/demo.rs b/demo/src/components/demo.rs index 82d1d7b..bce1da2 100644 --- a/demo/src/components/demo.rs +++ b/demo/src/components/demo.rs @@ -42,7 +42,7 @@ pub fn Demo(demo_code: DemoCode, children: Children) -> impl IntoView { let content_class = create_memo(move |_| { theme.with(|theme| { format!( - "thaw-demo__content color-scheme--{}", + "color-scheme--{}", theme.common.color_scheme ) }) @@ -66,21 +66,17 @@ pub fn Demo(demo_code: DemoCode, children: Children) -> impl IntoView {
{children()}
- { if is_highlight { view! { -

+                            
                         }
                     } else {
                         view! {
-                            
-                                {html}
-                            
+ } } } -
} } diff --git a/demo/src/components/syntect-css.css b/demo/src/components/syntect-css.css index 9c11bff..fee86b7 100644 --- a/demo/src/components/syntect-css.css +++ b/demo/src/components/syntect-css.css @@ -1,8 +1,3 @@ -.thaw-demo__content pre { - font-family: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, - Liberation Mono, monospace; -} - /** https://github.com/AmjadHD/sublime_one_theme */ /** light */ diff --git a/thaw/src/code/code.css b/thaw/src/code/code.css index 0618aef..34c33f3 100644 --- a/thaw/src/code/code.css +++ b/thaw/src/code/code.css @@ -1,3 +1,12 @@ .thaw-code { font-size: 14px; -} \ No newline at end of file + font-family: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, + Liberation Mono, monospace; +} + +.thaw-code pre { + margin: 0; + line-height: inherit; + font-size: inherit; + font-family: inherit; +} diff --git a/thaw/src/code/mod.rs b/thaw/src/code/mod.rs index 1320b76..9d75fdf 100644 --- a/thaw/src/code/mod.rs +++ b/thaw/src/code/mod.rs @@ -1,8 +1,28 @@ -use crate::utils::mount_style; +use crate::utils::{class_list::class_list, mount_style, OptionalProp}; use leptos::*; #[component] -pub fn Code(children: Children) -> impl IntoView { +pub fn Code( + #[prop(optional, into)] class: OptionalProp>, + #[prop(optional, into)] text: Option, + #[prop(optional, into)] inner_html: Option, +) -> impl IntoView { mount_style("code", include_str!("./code.css")); - view! { {children()} } + view! { + + { + if let Some(inner_html) = inner_html { + view! { +

+                    }.into()
+                } else if let Some(text) = text {
+                    view! {
+                        
{text}
+ }.into() + } else { + None + } + } +
+ } }