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())
]
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()
on:click=on_click
>

View file

@ -116,7 +116,10 @@ pub fn Calendar(
};
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">
<span class="thaw-calendar__header-title">

View file

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

View file

@ -35,7 +35,8 @@ pub fn Checkbox(
view! {
<div
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()

View file

@ -9,20 +9,18 @@ pub fn Code(
) -> impl IntoView {
mount_style("code", include_str!("./code.css"));
view! {
<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>
}.into()
<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> }.into()
} else if let Some(text) = text {
view! {
<pre>{text}</pre>
}.into()
view! { <pre>{text}</pre> }.into()
} else {
None
}
}
}}
</code>
}
}

View file

@ -50,7 +50,12 @@ pub fn CollapseItem(
<Icon icon=icondata::AiRightOutlined class="thaw-collapse-item-arrow"/>
{move || title.get()}
</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
class="thaw-collapse-item__content"
ref=content_ref

View file

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

View file

@ -36,7 +36,10 @@ pub fn GridItem(
});
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()}
</div>
}

View file

@ -24,7 +24,10 @@ pub fn Grid(
view! {
<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()}
</div>
</Provider>

View file

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

View file

@ -8,7 +8,10 @@ pub fn LayoutHeader(
children: Children,
) -> impl IntoView {
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()}
</div>
}

View file

@ -9,7 +9,10 @@ pub fn LayoutSider(
) -> impl IntoView {
mount_style("layout-sider", include_str!("./layout-sider.css"));
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()}
</div>
}

View file

@ -22,7 +22,10 @@ pub fn MenuGroup(
});
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}
</div>
{children()}

View file

@ -1,7 +1,10 @@
use std::time::Duration;
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 uuid::Uuid;
@ -13,7 +16,7 @@ pub enum MessagePlacement {
TopRight,
Bottom,
BottomLeft,
BottomRight
BottomRight,
}
impl MessagePlacement {
@ -111,5 +114,3 @@ impl MessageInjection {
pub fn use_message() -> MessageInjection {
expect_context::<MessageInjection>()
}

View file

@ -2,11 +2,15 @@ mod message_environment;
mod message_provider;
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 uuid::Uuid;
pub use message_provider::*;
pub use theme::MessageTheme;
use uuid::Uuid;
#[derive(Default, Clone)]
pub enum MessageVariant {
@ -71,5 +75,3 @@ pub(crate) fn Message(
</div>
}
}

View file

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

View file

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

View file

@ -27,7 +27,8 @@ pub fn Radio(
view! {
<div
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()

View file

@ -33,7 +33,8 @@ pub fn Switch(
view! {
<div
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()

View file

@ -46,7 +46,8 @@ pub fn Table(
<table
class=class_list![
"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())

View file

@ -61,7 +61,10 @@ fn TabsInner(
let children = children();
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">
<For
each=move || tab_options_vec.get()

View file

@ -61,7 +61,8 @@ pub fn Tab(
view! {
<div
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"

View file

@ -73,7 +73,10 @@ pub fn Tag(
});
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>
</div>
}

View file

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