style: fmt

This commit is contained in:
luoxiao 2024-02-01 15:24:09 +08:00 committed by luoxiaozero
parent a423d1c655
commit 8bdbda33a0
40 changed files with 198 additions and 143 deletions

View file

@ -231,7 +231,9 @@ pub fn Button(
disabled.get()), class.map(| c | move || c.get()) disabled.get()), class.map(| c | move || c.get())
] ]
style=move || format!("{}{}", css_vars.get(), style.as_ref().map(|s| s.get()).unwrap_or_default()) style=move || {
format!("{}{}", css_vars.get(), style.as_ref().map(|s| s.get()).unwrap_or_default())
}
disabled=move || disabled.get() disabled=move || disabled.get()
on:click=on_click on:click=on_click
> >

View file

@ -116,7 +116,10 @@ pub fn Calendar(
}; };
view! { view! {
<div class=class_list!["thaw-calendar", class.map(|c| move || c.get())] style=move || css_vars.get()> <div
class=class_list!["thaw-calendar", class.map(| c | move || c.get())]
style=move || css_vars.get()
>
<div class="thaw-calendar__header"> <div class="thaw-calendar__header">
<span class="thaw-calendar__header-title"> <span class="thaw-calendar__header-title">

View file

@ -50,31 +50,35 @@ pub fn Card(
}); });
view! { view! {
<div class=class_list!["thaw-card", class.map(|c| move || c.get())] style=move || css_vars.get()> <div
{ class=class_list!["thaw-card", class.map(| c | move || c.get())]
if card_header.is_some() || title.is_some() { style=move || css_vars.get()
>
{if card_header.is_some() || title.is_some() {
view! { view! {
<div class="thaw-card__header"> <div class="thaw-card__header">
<div class="thaw-card__header-content"> <div class="thaw-card__header-content">
{
if let Some(header) = card_header { {if let Some(header) = card_header {
(header.children)().into_view() (header.children)().into_view()
} else if let Some(title) = title.into_option() { } else if let Some(title) = title.into_option() {
(move || title.get()).into_view() (move || title.get()).into_view()
} else { } else {
unreachable!() unreachable!()
} }}
}
</div> </div>
<OptionComp value=card_header_extra let:header_extra> <OptionComp value=card_header_extra let:header_extra>
<div class="thaw-card__header-extra">{(header_extra.children)()}</div> <div class="thaw-card__header-extra">{(header_extra.children)()}</div>
</OptionComp> </OptionComp>
</div> </div>
}.into() }
.into()
} else { } else {
None None
} }}
}
<div class="thaw-card__content">{children()}</div> <div class="thaw-card__content">{children()}</div>
<OptionComp value=card_footer let:footer> <OptionComp value=card_footer let:footer>
<If cond=footer.if_> <If cond=footer.if_>

View file

@ -35,7 +35,8 @@ pub fn Checkbox(
view! { view! {
<div <div
class=class_list![ class=class_list![
"thaw-checkbox", ("thaw-checkbox--checked", move || value.get()), class.map(|c| move || c.get()) "thaw-checkbox", ("thaw-checkbox--checked", move || value.get()), class.map(| c |
move || c.get())
] ]
style=move || css_vars.get() style=move || css_vars.get()

View file

@ -9,20 +9,18 @@ pub fn Code(
) -> impl IntoView { ) -> impl IntoView {
mount_style("code", include_str!("./code.css")); mount_style("code", include_str!("./code.css"));
view! { view! {
<code class=class_list!["thaw-code", class.map(|c| move || c.get())]> <code class=class_list![
{ "thaw-code", class.map(| c | move || c.get())
if let Some(inner_html) = inner_html { ]>
view! {
<pre inner_html=inner_html></pre> {if let Some(inner_html) = inner_html {
}.into() view! { <pre inner_html=inner_html></pre> }.into()
} else if let Some(text) = text { } else if let Some(text) = text {
view! { view! { <pre>{text}</pre> }.into()
<pre>{text}</pre>
}.into()
} else { } else {
None None
} }}
}
</code> </code>
} }
} }

View file

@ -50,7 +50,12 @@ pub fn CollapseItem(
<Icon icon=icondata::AiRightOutlined class="thaw-collapse-item-arrow"/> <Icon icon=icondata::AiRightOutlined class="thaw-collapse-item-arrow"/>
{move || title.get()} {move || title.get()}
</div> </div>
<CSSTransition node_ref=content_ref show=is_show_content name="thaw-collapse-item" let:display> <CSSTransition
node_ref=content_ref
show=is_show_content
name="thaw-collapse-item"
let:display
>
<div <div
class="thaw-collapse-item__content" class="thaw-collapse-item__content"
ref=content_ref ref=content_ref

View file

@ -35,6 +35,7 @@ pub fn Drawer(
"thaw-drawer", move || format!("thaw-drawer--placement-{}", placement.get() "thaw-drawer", move || format!("thaw-drawer--placement-{}", placement.get()
.as_str()), class.map(| c | move || c.get()) .as_str()), class.map(| c | move || c.get())
] ]
style=move || css_vars.get() style=move || css_vars.get()
> >
<Card title>{children()}</Card> <Card title>{children()}</Card>

View file

@ -36,7 +36,10 @@ pub fn GridItem(
}); });
view! { view! {
<div class=class_list!["thaw-grid-item", class.map(|c| move || c.get())] style=move || style.get()> <div
class=class_list!["thaw-grid-item", class.map(| c | move || c.get())]
style=move || style.get()
>
{children()} {children()}
</div> </div>
} }

View file

@ -24,7 +24,10 @@ pub fn Grid(
view! { view! {
<Provider value=GridInjection::new(x_gap)> <Provider value=GridInjection::new(x_gap)>
<div class=class_list!["thaw-grid", class.map(|c| move || c.get())] style=move || style.get()> <div
class=class_list!["thaw-grid", class.map(| c | move || c.get())]
style=move || style.get()
>
{children()} {children()}
</div> </div>
</Provider> </Provider>

View file

@ -107,8 +107,8 @@ pub fn TextArea(
<div <div
class=class_list![ class=class_list![
"thaw-textarea", ("thaw-textarea--focus", move || is_focus.get()), "thaw-textarea", ("thaw-textarea--focus", move || is_focus.get()),
("thaw-textarea--disabled", move || disabled.get()), ("thaw-textarea--invalid", move || ("thaw-textarea--disabled", move || disabled.get()), ("thaw-textarea--invalid", move
invalid.get()), class.map(|c| move || c.get()) || invalid.get()), class.map(| c | move || c.get())
] ]
style=move || css_vars.get() style=move || css_vars.get()
@ -127,7 +127,7 @@ pub fn TextArea(
disabled=move || disabled.get() disabled=move || disabled.get()
placeholder=placeholder.map(|p| move || p.get()) placeholder=placeholder.map(|p| move || p.get())
ref=textarea_ref ref=textarea_ref
/> ></textarea>
</div> </div>
} }
} }

View file

@ -8,7 +8,10 @@ pub fn LayoutHeader(
children: Children, children: Children,
) -> impl IntoView { ) -> impl IntoView {
view! { view! {
<div class=class_list!["thaw-layout-header", class.map(|c| move || c.get())] style=style.map(|s| move || s.get())> <div
class=class_list!["thaw-layout-header", class.map(| c | move || c.get())]
style=style.map(|s| move || s.get())
>
{children()} {children()}
</div> </div>
} }

View file

@ -9,7 +9,10 @@ pub fn LayoutSider(
) -> impl IntoView { ) -> impl IntoView {
mount_style("layout-sider", include_str!("./layout-sider.css")); mount_style("layout-sider", include_str!("./layout-sider.css"));
view! { view! {
<div class=class_list!["thaw-layout-sider", class.map(|c| move || c.get())] style=style.map(|s| move || s.get())> <div
class=class_list!["thaw-layout-sider", class.map(| c | move || c.get())]
style=style.map(|s| move || s.get())
>
{children()} {children()}
</div> </div>
} }

View file

@ -22,7 +22,10 @@ pub fn MenuGroup(
}); });
view! { view! {
<div class=class_list!["thaw-menu-group", class.map(|c| move || c.get())] style=move || css_vars.get()> <div
class=class_list!["thaw-menu-group", class.map(| c | move || c.get())]
style=move || css_vars.get()
>
{label} {label}
</div> </div>
{children()} {children()}

View file

@ -1,7 +1,10 @@
use std::time::Duration; use std::time::Duration;
use super::{message_environment::MessageEnvironment, MessageVariant}; use super::{message_environment::MessageEnvironment, MessageVariant};
use crate::{components::Teleport, utils::{class_list::class_list, mount_style}}; use crate::{
components::Teleport,
utils::{class_list::class_list, mount_style},
};
use leptos::*; use leptos::*;
use uuid::Uuid; use uuid::Uuid;
@ -13,7 +16,7 @@ pub enum MessagePlacement {
TopRight, TopRight,
Bottom, Bottom,
BottomLeft, BottomLeft,
BottomRight BottomRight,
} }
impl MessagePlacement { impl MessagePlacement {
@ -111,5 +114,3 @@ impl MessageInjection {
pub fn use_message() -> MessageInjection { pub fn use_message() -> MessageInjection {
expect_context::<MessageInjection>() expect_context::<MessageInjection>()
} }

View file

@ -2,11 +2,15 @@ mod message_environment;
mod message_provider; mod message_provider;
mod theme; mod theme;
use crate::{theme::use_theme, Icon, Theme, components::{If, Then}}; use crate::{
components::{If, Then},
theme::use_theme,
Icon, Theme,
};
use leptos::*; use leptos::*;
use uuid::Uuid;
pub use message_provider::*; pub use message_provider::*;
pub use theme::MessageTheme; pub use theme::MessageTheme;
use uuid::Uuid;
#[derive(Default, Clone)] #[derive(Default, Clone)]
pub enum MessageVariant { pub enum MessageVariant {
@ -71,5 +75,3 @@ pub(crate) fn Message(
</div> </div>
} }
} }

View file

@ -60,14 +60,21 @@ pub fn NavBar(
}; };
view! { view! {
<div class=class_list!["thaw-nav-bar", class.map(|c| move || c.get())] style=move || css_vars.get()> <div
{ class=class_list!["thaw-nav-bar", class.map(| c | move || c.get())]
if let Some(NavBarLeft { class, children }) = nav_bar_left { style=move || css_vars.get()
>
{if let Some(NavBarLeft { class, children }) = nav_bar_left {
view! { view! {
<div class=class_list!["thaw-nav-bar__left", class.map(|c| move || c.get())] on:click=on_click_left> <div
class=class_list!["thaw-nav-bar__left", class.map(| c | move || c.get())]
on:click=on_click_left
>
{children()} {children()}
</div> </div>
}.into_view() }
.into_view()
} else if let Some(left_text) = left_text.into_option() { } else if let Some(left_text) = left_text.into_option() {
view! { view! {
<div class="thaw-nav-bar__left" on:click=on_click_left> <div class="thaw-nav-bar__left" on:click=on_click_left>
@ -78,7 +85,8 @@ pub fn NavBar(
</If> </If>
{move || left_text.get()} {move || left_text.get()}
</div> </div>
}.into_view() }
.into_view()
} else { } else {
(move || { (move || {
if left_arrow.get() { if left_arrow.get() {
@ -86,31 +94,38 @@ pub fn NavBar(
<div class="thaw-nav-bar__left" on:click=on_click_left> <div class="thaw-nav-bar__left" on:click=on_click_left>
<Icon icon=icondata::AiLeftOutlined/> <Icon icon=icondata::AiLeftOutlined/>
</div> </div>
}.into() }
.into()
} else { } else {
None None
} }
}).into_view() })
} .into_view()
} }}
<div class="thaw-nav-bar__center">{move || title.get()}</div> <div class="thaw-nav-bar__center">{move || title.get()}</div>
{
if let Some(NavBarRight { class, children }) = nav_bar_right { {if let Some(NavBarRight { class, children }) = nav_bar_right {
view! { view! {
<div class=class_list!["thaw-nav-bar__right", class.map(|c| move || c.get())] on:click=on_click_right> <div
class=class_list!["thaw-nav-bar__right", class.map(| c | move || c.get())]
on:click=on_click_right
>
{children()} {children()}
</div> </div>
}.into() }
.into()
} else if let Some(right_text) = right_text.into_option() { } else if let Some(right_text) = right_text.into_option() {
view! { view! {
<div class="thaw-nav-bar__right" on:click=on_click_right> <div class="thaw-nav-bar__right" on:click=on_click_right>
{move || right_text.get()} {move || right_text.get()}
</div> </div>
}.into() }
.into()
} else { } else {
None None
} }}
}
</div> </div>
} }
} }

View file

@ -1,16 +1,17 @@
mod tabbar_item; mod tabbar_item;
mod theme; mod theme;
use crate::{use_theme, utils::{mount_style, Model}, Theme}; use crate::{
use_theme,
utils::{mount_style, Model},
Theme,
};
use leptos::*; use leptos::*;
pub use tabbar_item::*; pub use tabbar_item::*;
pub use theme::TabbarTheme; pub use theme::TabbarTheme;
#[component] #[component]
pub fn Tabbar( pub fn Tabbar(#[prop(optional, into)] value: Model<String>, children: Children) -> impl IntoView {
#[prop(optional, into)] value: Model<String>,
children: Children,
) -> impl IntoView {
mount_style("tabbar", include_str!("./tabbar.css")); mount_style("tabbar", include_str!("./tabbar.css"));
let theme = use_theme(Theme::light); let theme = use_theme(Theme::light);
let css_vars = create_memo(move |_| { let css_vars = create_memo(move |_| {

View file

@ -27,7 +27,8 @@ pub fn Radio(
view! { view! {
<div <div
class=class_list![ class=class_list![
"thaw-radio", ("thaw-radio--checked", move || value.get()), class.map(|c| move || c.get()) "thaw-radio", ("thaw-radio--checked", move || value.get()), class.map(| c | move ||
c.get())
] ]
style=move || css_vars.get() style=move || css_vars.get()

View file

@ -33,7 +33,8 @@ pub fn Switch(
view! { view! {
<div <div
class=class_list![ class=class_list![
"thaw-switch", ("thaw-switch--active", move || value.get()), class.map(|c| move || c.get()) "thaw-switch", ("thaw-switch--active", move || value.get()), class.map(| c | move ||
c.get())
] ]
style=move || css_vars.get() style=move || css_vars.get()

View file

@ -46,7 +46,8 @@ pub fn Table(
<table <table
class=class_list![ class=class_list![
"thaw-table", ("thaw-table--single-row", move || single_row.get()), "thaw-table", ("thaw-table--single-row", move || single_row.get()),
("thaw-table--single-column", move || single_column.get()), class.map(|c| move || c.get()) ("thaw-table--single-column", move || single_column.get()), class.map(| c | move ||
c.get())
] ]
style=move || format!("{}{}", css_vars.get(), style.get()) style=move || format!("{}{}", css_vars.get(), style.get())

View file

@ -61,7 +61,10 @@ fn TabsInner(
let children = children(); let children = children();
view! { view! {
<div class=class_list!["thaw-tabs", class.map(|c| move || c.get())] style=move || css_vars.get()> <div
class=class_list!["thaw-tabs", class.map(| c | move || c.get())]
style=move || css_vars.get()
>
<div class="thaw-tabs__label-list" ref=label_list_ref role="tablist"> <div class="thaw-tabs__label-list" ref=label_list_ref role="tablist">
<For <For
each=move || tab_options_vec.get() each=move || tab_options_vec.get()

View file

@ -61,7 +61,8 @@ pub fn Tab(
view! { view! {
<div <div
class=class_list![ class=class_list![
"thaw-tab", ("thaw-tab--hidden", move || ! is_active.get()), class.map(|c| move || c.get()) "thaw-tab", ("thaw-tab--hidden", move || ! is_active.get()), class.map(| c | move ||
c.get())
] ]
role="tabpanel" role="tabpanel"

View file

@ -73,7 +73,10 @@ pub fn Tag(
}); });
view! { view! {
<div class=class_list!["thaw-tag", class.map(|c| move || c.get())] style=move || css_vars.get()> <div
class=class_list!["thaw-tag", class.map(| c | move || c.get())]
style=move || css_vars.get()
>
<span class="thaw-tag__content">{children()}</span> <span class="thaw-tag__content">{children()}</span>
</div> </div>
} }

View file

@ -76,10 +76,7 @@ pub fn TimePicker(
<div ref=time_picker_ref> <div ref=time_picker_ref>
<Input attrs class value=show_time_text on_focus=open_panel on_blur=on_input_blur> <Input attrs class value=show_time_text on_focus=open_panel on_blur=on_input_blur>
<InputSuffix slot> <InputSuffix slot>
<Icon <Icon icon=icondata::AiClockCircleOutlined style="font-size: 18px"/>
icon=icondata::AiClockCircleOutlined
style="font-size: 18px"
/>
</InputSuffix> </InputSuffix>
</Input> </Input>
</div> </div>