thaw/src/typography/text.rs
luoxiaozero e9778b6008
Fix/ci nightly (#45)
* demo: Modify button click

* fix: ci run nightly

* pref: fmt and clippy
2023-12-11 15:44:22 +08:00

29 lines
848 B
Rust

use crate::{use_theme, utils::mount_style, Theme};
use leptos::*;
#[component]
pub fn Text(#[prop(optional)] code: bool, children: Children) -> impl IntoView {
mount_style("text", include_str!("./text.css"));
let theme = use_theme(Theme::light);
let css_vars = create_memo(move |_| {
let mut css_vars = String::new();
theme.with(|theme| {
css_vars.push_str(&format!(
"--thaw-background-color: {}",
theme.typograph.code_background_color
));
});
css_vars
});
if code {
view! {
<code class="thaw-text thaw-text--code" style=move || css_vars.get()>
{children()}
</code>
}
.into_any()
} else {
view! { <span class="thaw-text">{children()}</span> }.into_any()
}
}