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

@ -130,7 +130,7 @@ pub fn AutoComplete(
view! {
<Binder target_ref=auto_complete_ref>
<div
class=class_list!["thaw-auto-complete", class.map(|c| move || c.get())]
class=class_list!["thaw-auto-complete", class.map(| c | move || c.get())]
ref=auto_complete_ref
on:keydown=on_keydown
>

View file

@ -12,7 +12,7 @@ pub fn BreadcrumbItem(
view! {
<li class="thaw-breadcrumb-item">
<span class=class_list![
"thaw-breadcrumb-item__link", class.map(|c| move || c.get())
"thaw-breadcrumb-item__link", class.map(| c | move || c.get())
]>{children()}</span>
<span class="thaw-breadcrumb-item__separator">
{move || breadcrumb_separator.0.get()}

View file

@ -40,7 +40,7 @@ pub fn Breadcrumb(
view! {
<Provider value=BreadcrumbSeparatorInjection(separator)>
<nav
class=class_list!["thaw-breadcrumb", class.map(|c| move || c.get())]
class=class_list!["thaw-breadcrumb", class.map(| c | move || c.get())]
style=move || css_vars.get()
>
<ul>{children()}</ul>

View file

@ -228,10 +228,12 @@ pub fn Button(
ButtonVariant::Text), ("thaw-button--link", move || variant.get() ==
ButtonVariant::Link), ("thaw-button--round", move || round.get()),
("thaw-button--circle", move || circle.get()), ("thaw-button--disabled", move ||
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()
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

@ -44,13 +44,18 @@ pub fn CollapseItem(
view! {
<div class=class_list![
"thaw-collapse-item", ("thaw-collapse-item--active", move || is_show_content.get()),
class.map(|c| move || c.get())
class.map(| c | move || c.get())
]>
<div class="thaw-collapse-item__header" on:click=on_click>
<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

@ -31,7 +31,7 @@ pub fn Collapse(
accordion,
}>
<div
class=class_list!["thaw-collapse", class.map(|c| move || c.get())]
class=class_list!["thaw-collapse", class.map(| c | move || c.get())]
style=move || css_vars.get()
>
{children()}

View file

@ -100,7 +100,7 @@ pub fn ColorPicker(
view! {
<Binder target_ref=trigger_ref>
<div
class=class_list!["thaw-color-picker-trigger", class.map(|c| move || c.get())]
class=class_list!["thaw-color-picker-trigger", class.map(| c | move || c.get())]
on:click=show_popover
ref=trigger_ref
>

View file

@ -6,7 +6,7 @@ pub fn Divider(#[prop(optional, into)] class: OptionalProp<MaybeSignal<String>>)
mount_style("divider", include_str!("./divider.css"));
view! {
<div class=class_list!["thaw-divider", class.map(|c| move || c.get())]>
<div class=class_list!["thaw-divider", class.map(| c | move || c.get())]>
<div class="thaw-divider__line"></div>
</div>
}

View file

@ -33,8 +33,9 @@ pub fn Drawer(
<div
class=class_list![
"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()
>
<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

@ -160,7 +160,7 @@ pub fn Input(
class=class_list![
"thaw-input", ("thaw-input--focus", move || is_focus.get()),
("thaw-input--disabled", move || disabled.get()), ("thaw-input--invalid", move ||
invalid.get()), class.map(|c| move || c.get())
invalid.get()), class.map(| c | move || c.get())
]
style=move || css_vars.get()

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

@ -47,7 +47,7 @@ pub fn Layout(
});
view! {
<div
class=class_list![gen_class(position), class.map(|c| move || c.get())]
class=class_list![gen_class(position), class.map(| c | move || c.get())]
style=move || style.get()
>
{children()}

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

@ -43,7 +43,7 @@ pub fn MenuItem(
<div
class=class_list![
"thaw-menu-item__content", ("thaw-menu-item__content--selected", move || menu.0
.get() == key.get()), class.map(|c| move || c.get())
.get() == key.get()), class.map(| c | move || c.get())
]
on:click=on_click

View file

@ -16,7 +16,7 @@ pub fn Menu(
) -> impl IntoView {
view! {
<Provider value=MenuInjection(value)>
<div class=class_list!["thaw-menu", class.map(|c| move || c.get())]>{children()}</div>
<div class=class_list!["thaw-menu", class.map(| c | move || c.get())]>{children()}</div>
</Provider>
}
}

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 {
@ -24,7 +27,7 @@ impl MessagePlacement {
MessagePlacement::TopRight => "thaw-message-container--top-right".to_owned(),
MessagePlacement::Bottom => "thaw-message-container--bottom".to_owned(),
MessagePlacement::BottomLeft => "thaw-message-container--bottom-left".to_owned(),
MessagePlacement::BottomRight=> "thaw-message-container--bottom-right".to_owned(),
MessagePlacement::BottomRight => "thaw-message-container--bottom-right".to_owned(),
}
}
}
@ -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

@ -115,7 +115,7 @@ pub fn Popover(
view! {
<Binder target_ref>
<div
class=class_list!["thaw-popover-trigger", trigger_class.map(|c| move || c.get())]
class=class_list!["thaw-popover-trigger", trigger_class.map(| c | move || c.get())]
ref=target_ref
on:mouseenter=on_mouse_enter
on:mouseleave=on_mouse_leave

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

@ -111,7 +111,7 @@ where
view! {
<Binder target_ref=trigger_ref>
<div
class=class_list!["thaw-select", class.map(|c| move || c.get())]
class=class_list!["thaw-select", class.map(| c | move || c.get())]
ref=trigger_ref
on:click=show_menu
style=move || css_vars.get()

View file

@ -118,7 +118,7 @@ pub fn Slider(
view! {
<div
class=class_list!["thaw-slider", class.map(|c| move || c.get())]
class=class_list!["thaw-slider", class.map(| c | move || c.get())]
style=move || css_vars.get()
on:click=on_mouse_click
>

View file

@ -30,7 +30,7 @@ pub fn Space(
view! {
<div
class=class_list!["thaw-space", class.map(|c| move || c.get())]
class=class_list!["thaw-space", class.map(| c | move || c.get())]
style:gap=gap
style:flex-direction=if vertical { "column" } else { "row" }
>

View file

@ -53,7 +53,7 @@ pub fn Spinner(
view! {
<div
class=class_list!["thaw-spinner", class.map(|c| move || c.get())]
class=class_list!["thaw-spinner", class.map(| c | move || c.get())]
style=move || css_vars.get()
></div>
}

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()
@ -103,7 +106,7 @@ fn TabsInner(
<span
class=class_list![
"thaw-tabs__label", ("thaw-tabs__label--active", move ||
is_active.get()), class.map(|c| move || c.get())
is_active.get()), class.map(| c | move || c.get())
]
on:click={

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>

View file

@ -27,7 +27,7 @@ pub fn Text(
if code {
view! {
<code
class=class_list!["thaw-text thaw-text--code", class.map(|c| move || c.get())]
class=class_list!["thaw-text thaw-text--code", class.map(| c | move || c.get())]
style=move || css_vars.get()
>
{children()}
@ -35,7 +35,7 @@ pub fn Text(
}
.into_any()
} else {
view! { <span class=class_list!["thaw-text", class.map(|c| move || c.get())]>{children()}</span> }
view! { <span class=class_list!["thaw-text", class.map(| c | move || c.get())]>{children()}</span> }
.into_any()
}
}