mirror of
https://github.com/adoyle0/thaw.git
synced 2025-01-23 06:19:22 -05:00
Merge pull request #3 from luoxiaozero/feat/stable
feat: remove stylers
This commit is contained in:
commit
35da30b8f1
24 changed files with 46 additions and 92 deletions
|
@ -14,7 +14,6 @@ license = "MIT"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
leptos = { version = "0.5.0", features = ["csr"] }
|
leptos = { version = "0.5.0", features = ["csr"] }
|
||||||
stylers = "0.3.2"
|
|
||||||
web-sys = { version = "0.3.62", features = ["DomRect"] }
|
web-sys = { version = "0.3.62", features = ["DomRect"] }
|
||||||
leptos_dom = { version = "0.5.0" }
|
leptos_dom = { version = "0.5.0" }
|
||||||
wasm-bindgen = "0.2.85"
|
wasm-bindgen = "0.2.85"
|
||||||
|
|
|
@ -10,7 +10,7 @@ pub struct DemoCode {
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn Demo(demo_code: DemoCode, children: Children) -> impl IntoView {
|
pub fn Demo(demo_code: DemoCode, children: Children) -> impl IntoView {
|
||||||
mount_style("demo", || ("", prisms::prism_css!()));
|
mount_style("demo", prisms::prism_css!());
|
||||||
view! {
|
view! {
|
||||||
<div style="background-image: url(/melt-ui/grid_dot.svg); background-repeat: repeat; background-size: 1.5rem; margin-top: 1rem; padding: 1rem; border: 1px solid #e5e8eb; border-top-left-radius: 0.5rem; border-top-right-radius: 0.5rem;">
|
<div style="background-image: url(/melt-ui/grid_dot.svg); background-repeat: repeat; background-size: 1.5rem; margin-top: 1rem; padding: 1rem; border: 1px solid #e5e8eb; border-top-left-radius: 0.5rem; border-top-right-radius: 0.5rem;">
|
||||||
{ children() }
|
{ children() }
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
mod theme;
|
mod theme;
|
||||||
|
|
||||||
use crate::{components::*, icon::*, theme::*, utils::mount_style::mount_style};
|
use crate::{components::*, icon::*, theme::*, utils::mount_style::mount_style};
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
use stylers::style_sheet_str;
|
|
||||||
pub use theme::ButtonTheme;
|
pub use theme::ButtonTheme;
|
||||||
|
|
||||||
#[derive(Default, PartialEq, Clone, Copy)]
|
#[derive(Default, PartialEq, Clone, Copy)]
|
||||||
|
@ -84,7 +84,7 @@ pub fn Button(
|
||||||
|
|
||||||
css_vars
|
css_vars
|
||||||
});
|
});
|
||||||
let class_name = mount_style("button", || style_sheet_str!("./src/button/button.css"));
|
mount_style("button", include_str!("./button.css"));
|
||||||
|
|
||||||
let icon_style = if children.is_some() {
|
let icon_style = if children.is_some() {
|
||||||
"margin-right: 6px"
|
"margin-right: 6px"
|
||||||
|
@ -110,7 +110,7 @@ pub fn Button(
|
||||||
callback.call(event);
|
callback.call(event);
|
||||||
};
|
};
|
||||||
|
|
||||||
view! {class=class_name,
|
view! {
|
||||||
<button
|
<button
|
||||||
class:melt-button=true
|
class:melt-button=true
|
||||||
class=("melt-button--text", move || type_.get() == ButtonType::TEXT)
|
class=("melt-button--text", move || type_.get() == ButtonType::TEXT)
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
use std::rc::Rc;
|
|
||||||
|
|
||||||
use crate::{components::*, utils::mount_style::mount_style};
|
use crate::{components::*, utils::mount_style::mount_style};
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
use stylers::style_sheet_str;
|
use std::rc::Rc;
|
||||||
|
|
||||||
#[slot]
|
#[slot]
|
||||||
pub struct CardHeader {
|
pub struct CardHeader {
|
||||||
|
@ -29,7 +27,7 @@ pub fn Card(
|
||||||
children: Children,
|
children: Children,
|
||||||
#[prop(optional)] card_footer: Option<CardFooter>,
|
#[prop(optional)] card_footer: Option<CardFooter>,
|
||||||
) -> impl IntoView {
|
) -> impl IntoView {
|
||||||
let class_name = mount_style("card", || style_sheet_str!("./src/card/card.css"));
|
mount_style("card", include_str!("./card.css"));
|
||||||
|
|
||||||
let is_header = card_header.is_some();
|
let is_header = card_header.is_some();
|
||||||
let header = card_header.map_or(None, |v| Some(Rc::new(v)));
|
let header = card_header.map_or(None, |v| Some(Rc::new(v)));
|
||||||
|
@ -37,7 +35,6 @@ pub fn Card(
|
||||||
// let footer = card_footer.map_or(None, |v| Some(Rc::new(v)));
|
// let footer = card_footer.map_or(None, |v| Some(Rc::new(v)));
|
||||||
|
|
||||||
view! {
|
view! {
|
||||||
class=class_name,
|
|
||||||
<div class="melt-card">
|
<div class="melt-card">
|
||||||
<If cond=MaybeSignal::derive( move || is_header || !title.get().is_empty()) >
|
<If cond=MaybeSignal::derive( move || is_header || !title.get().is_empty()) >
|
||||||
<Then slot>
|
<Then slot>
|
||||||
|
|
|
@ -12,7 +12,6 @@ pub use checkbox_group::CheckboxGroup;
|
||||||
pub use checkbox_item::CheckboxItem;
|
pub use checkbox_item::CheckboxItem;
|
||||||
use icondata::AiIcon;
|
use icondata::AiIcon;
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
use stylers::style_sheet_str;
|
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn Checkbox(
|
pub fn Checkbox(
|
||||||
|
@ -20,9 +19,7 @@ pub fn Checkbox(
|
||||||
children: Children,
|
children: Children,
|
||||||
) -> impl IntoView {
|
) -> impl IntoView {
|
||||||
let theme = use_theme(Theme::light);
|
let theme = use_theme(Theme::light);
|
||||||
let class_name = mount_style("checkbox", || {
|
mount_style("checkbox", include_str!("./checkbox.css"));
|
||||||
style_sheet_str!("./src/checkbox/checkbox.css")
|
|
||||||
});
|
|
||||||
|
|
||||||
let css_vars = create_memo(move |_| {
|
let css_vars = create_memo(move |_| {
|
||||||
let mut css_vars = String::new();
|
let mut css_vars = String::new();
|
||||||
|
@ -32,7 +29,7 @@ pub fn Checkbox(
|
||||||
css_vars
|
css_vars
|
||||||
});
|
});
|
||||||
|
|
||||||
view! {class=class_name,
|
view! {
|
||||||
<div class:melt-checkbox=true class=("melt-checkbox--checked", move || checked.get()) style=move || css_vars.get()
|
<div class:melt-checkbox=true class=("melt-checkbox--checked", move || checked.get()) style=move || css_vars.get()
|
||||||
on:click=move |_| checked.set(!checked.get_untracked())>
|
on:click=move |_| checked.set(!checked.get_untracked())>
|
||||||
<input class="melt-checkbox__input" type="checkbox" />
|
<input class="melt-checkbox__input" type="checkbox" />
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
mod theme;
|
mod theme;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
theme::{use_theme, Theme},
|
theme::{use_theme, Theme},
|
||||||
utils::mount_style::mount_style,
|
utils::mount_style::mount_style,
|
||||||
};
|
};
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
use stylers::style_sheet_str;
|
|
||||||
pub use theme::InputTheme;
|
pub use theme::InputTheme;
|
||||||
|
|
||||||
#[derive(Default, Clone)]
|
#[derive(Default, Clone)]
|
||||||
|
@ -29,7 +29,7 @@ pub fn Input(
|
||||||
#[prop(optional, into)] type_: MaybeSignal<InputType>,
|
#[prop(optional, into)] type_: MaybeSignal<InputType>,
|
||||||
) -> impl IntoView {
|
) -> impl IntoView {
|
||||||
let theme = use_theme(Theme::light);
|
let theme = use_theme(Theme::light);
|
||||||
let class_name = mount_style("input", || style_sheet_str!("./src/input/input.css"));
|
mount_style("input", include_str!("./input.css"));
|
||||||
|
|
||||||
let input_ref = create_node_ref::<html::Input>();
|
let input_ref = create_node_ref::<html::Input>();
|
||||||
input_ref.on_load(move |input| {
|
input_ref.on_load(move |input| {
|
||||||
|
@ -48,7 +48,6 @@ pub fn Input(
|
||||||
css_vars
|
css_vars
|
||||||
});
|
});
|
||||||
view! {
|
view! {
|
||||||
class=class_name,
|
|
||||||
<div class:melt-input=true style=move || css_vars.get()>
|
<div class:melt-input=true style=move || css_vars.get()>
|
||||||
<input type=move || type_.get().as_str() prop:value=move || value.get() ref=input_ref class="melt-input__input-el"/>
|
<input type=move || type_.get().as_str() prop:value=move || value.get() ref=input_ref class="melt-input__input-el"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,16 +1,13 @@
|
||||||
use crate::utils::mount_style::mount_style;
|
use crate::utils::mount_style::mount_style;
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
use stylers::style_sheet_str;
|
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn LayoutSider(
|
pub fn LayoutSider(
|
||||||
#[prop(optional, into)] style: MaybeSignal<String>,
|
#[prop(optional, into)] style: MaybeSignal<String>,
|
||||||
children: Children,
|
children: Children,
|
||||||
) -> impl IntoView {
|
) -> impl IntoView {
|
||||||
let class_name = mount_style("layout-sider", || {
|
mount_style("layout-sider", include_str!("./layout-sider.css"));
|
||||||
style_sheet_str!("./src/layout/layout-sider.css")
|
view! {
|
||||||
});
|
|
||||||
view! {class=class_name,
|
|
||||||
<div class="melt-layout-sider" style=move || style.get()>
|
<div class="melt-layout-sider" style=move || style.get()>
|
||||||
{ children() }
|
{ children() }
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -5,7 +5,6 @@ use crate::utils::mount_style::mount_style;
|
||||||
pub use layout_header::*;
|
pub use layout_header::*;
|
||||||
pub use layout_sider::*;
|
pub use layout_sider::*;
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
use stylers::style_sheet_str;
|
|
||||||
|
|
||||||
#[derive(Default, PartialEq)]
|
#[derive(Default, PartialEq)]
|
||||||
pub enum LayoutPosition {
|
pub enum LayoutPosition {
|
||||||
|
@ -30,7 +29,7 @@ pub fn Layout(
|
||||||
#[prop(optional, into)] has_sider: MaybeSignal<bool>,
|
#[prop(optional, into)] has_sider: MaybeSignal<bool>,
|
||||||
children: Children,
|
children: Children,
|
||||||
) -> impl IntoView {
|
) -> impl IntoView {
|
||||||
let class_name = mount_style("layout", || style_sheet_str!("./src/layout/layout.css"));
|
mount_style("layout", include_str!("./layout.css"));
|
||||||
|
|
||||||
let style = create_memo(move |_| {
|
let style = create_memo(move |_| {
|
||||||
let mut style = style.get();
|
let mut style = style.get();
|
||||||
|
@ -39,7 +38,7 @@ pub fn Layout(
|
||||||
}
|
}
|
||||||
style
|
style
|
||||||
});
|
});
|
||||||
view! { class=class_name,
|
view! {
|
||||||
<div class="melt-layout" class=("melt-layout--absolute-positioned", position == LayoutPosition::ABSOLUTE) style=move || style.get()>
|
<div class="melt-layout" class=("melt-layout--absolute-positioned", position == LayoutPosition::ABSOLUTE) style=move || style.get()>
|
||||||
{ children() }
|
{ children() }
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
use crate::{theme::use_theme, utils::mount_style::mount_style, Theme};
|
use crate::{theme::use_theme, utils::mount_style::mount_style, Theme};
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
use stylers::style_sheet_str;
|
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn MenuGroup(label: &'static str, children: Children) -> impl IntoView {
|
pub fn MenuGroup(label: &'static str, children: Children) -> impl IntoView {
|
||||||
let class_name = mount_style("menu-group", || {
|
mount_style("menu-group", include_str!("./menu-group.css"));
|
||||||
style_sheet_str!("./src/menu/menu-group.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 |_| {
|
||||||
let mut css_vars = String::new();
|
let mut css_vars = String::new();
|
||||||
|
@ -15,7 +12,7 @@ pub fn MenuGroup(label: &'static str, children: Children) -> impl IntoView {
|
||||||
});
|
});
|
||||||
css_vars
|
css_vars
|
||||||
});
|
});
|
||||||
view! {class=class_name,
|
view! {
|
||||||
<div class="melt-menu-group" style=move || css_vars.get()>
|
<div class="melt-menu-group" style=move || css_vars.get()>
|
||||||
{ label }
|
{ label }
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
use super::{use_menu, MenuInjectionKey};
|
use super::{use_menu, MenuInjectionKey};
|
||||||
use crate::{theme::use_theme, utils::mount_style::mount_style, Theme};
|
use crate::{theme::use_theme, utils::mount_style::mount_style, Theme};
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
use stylers::style_sheet_str;
|
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn MenuItem(
|
pub fn MenuItem(
|
||||||
#[prop(into)] key: MaybeSignal<&'static str>,
|
#[prop(into)] key: MaybeSignal<&'static str>,
|
||||||
#[prop(into)] label: MaybeSignal<String>,
|
#[prop(into)] label: MaybeSignal<String>,
|
||||||
) -> impl IntoView {
|
) -> impl IntoView {
|
||||||
let class_name = mount_style("menu-item", || style_sheet_str!("./src/menu/menu-item.css"));
|
mount_style("menu-item", include_str!("./menu-item.css"));
|
||||||
let theme = use_theme(Theme::light);
|
let theme = use_theme(Theme::light);
|
||||||
let menu = use_menu();
|
let menu = use_menu();
|
||||||
let onclick_select = move |_| {
|
let onclick_select = move |_| {
|
||||||
|
@ -28,7 +27,7 @@ pub fn MenuItem(
|
||||||
));
|
));
|
||||||
css_vars
|
css_vars
|
||||||
});
|
});
|
||||||
view! { class=class_name,
|
view! {
|
||||||
<div class="melt-menu-item">
|
<div class="melt-menu-item">
|
||||||
<div class="melt-menu-item__content" class=("melt-menu-item__content--selected", move || menu.get().value == key.get()) on:click=onclick_select style=move || css_vars.get()>
|
<div class="melt-menu-item__content" class=("melt-menu-item__content--selected", move || menu.get().value == key.get()) on:click=onclick_select style=move || css_vars.get()>
|
||||||
{ move || label.get() }
|
{ move || label.get() }
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use crate::{components::*, icon::*, utils::mount_style::mount_style};
|
use crate::{components::*, icon::*, utils::mount_style::mount_style};
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
use stylers::style_sheet_str;
|
|
||||||
use web_sys::MouseEvent;
|
use web_sys::MouseEvent;
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
|
@ -12,9 +11,7 @@ pub fn NavBar(
|
||||||
#[prop(optional, into)] right_text: MaybeSignal<&'static str>,
|
#[prop(optional, into)] right_text: MaybeSignal<&'static str>,
|
||||||
#[prop(optional, into)] click_right: Option<SignalSetter<MouseEvent>>,
|
#[prop(optional, into)] click_right: Option<SignalSetter<MouseEvent>>,
|
||||||
) -> impl IntoView {
|
) -> impl IntoView {
|
||||||
let class_name = mount_style("nav-bar", || {
|
mount_style("nav-bar", include_str!("./nav-bar.css"));
|
||||||
style_sheet_str!("./src/mobile/nav_bar/nav-bar.css")
|
|
||||||
});
|
|
||||||
|
|
||||||
let onclick_left = move |ev| {
|
let onclick_left = move |ev| {
|
||||||
if let Some(click_left) = click_left {
|
if let Some(click_left) = click_left {
|
||||||
|
@ -27,7 +24,7 @@ pub fn NavBar(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
view! { class=class_name,
|
view! {
|
||||||
<div class="melt-nav-bar">
|
<div class="melt-nav-bar">
|
||||||
<If cond=MaybeSignal::derive( move || left_arrow.get() || !left_text.get().is_empty())>
|
<If cond=MaybeSignal::derive( move || left_arrow.get() || !left_text.get().is_empty())>
|
||||||
<Then slot>
|
<Then slot>
|
||||||
|
|
|
@ -2,14 +2,12 @@ mod tabbar_item;
|
||||||
|
|
||||||
use crate::utils::mount_style::mount_style;
|
use crate::utils::mount_style::mount_style;
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
use stylers::style_sheet_str;
|
|
||||||
pub use tabbar_item::*;
|
pub use tabbar_item::*;
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn Tabbar(#[prop(into)] selected: RwSignal<String>, children: Children) -> impl IntoView {
|
pub fn Tabbar(#[prop(into)] selected: RwSignal<String>, children: Children) -> impl IntoView {
|
||||||
let class_name = mount_style("tabbar", || {
|
mount_style("tabbar", include_str!("./tabbar.css"));
|
||||||
style_sheet_str!("./src/mobile/tabbar/tabbar.css")
|
|
||||||
});
|
|
||||||
|
|
||||||
let tabbar_injection_key = create_rw_signal(TabbarInjectionKey::new(selected.get()));
|
let tabbar_injection_key = create_rw_signal(TabbarInjectionKey::new(selected.get()));
|
||||||
create_effect(move |_| {
|
create_effect(move |_| {
|
||||||
|
@ -28,7 +26,7 @@ pub fn Tabbar(#[prop(into)] selected: RwSignal<String>, children: Children) -> i
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
provide_context(tabbar_injection_key);
|
provide_context(tabbar_injection_key);
|
||||||
view! { class=class_name,
|
view! {
|
||||||
<div class="melt-tabbar">
|
<div class="melt-tabbar">
|
||||||
{ children() }
|
{ children() }
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -2,7 +2,6 @@ use super::{use_tabbar, TabbarInjectionKey};
|
||||||
use crate::components::*;
|
use crate::components::*;
|
||||||
use crate::{icon::*, theme::use_theme, utils::mount_style::mount_style, Theme};
|
use crate::{icon::*, theme::use_theme, utils::mount_style::mount_style, Theme};
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
use stylers::style_sheet_str;
|
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn TabbarItem(
|
pub fn TabbarItem(
|
||||||
|
@ -10,9 +9,7 @@ pub fn TabbarItem(
|
||||||
#[prop(optional, into)] icon: Option<Icon>,
|
#[prop(optional, into)] icon: Option<Icon>,
|
||||||
children: Children,
|
children: Children,
|
||||||
) -> impl IntoView {
|
) -> impl IntoView {
|
||||||
let class_name = mount_style("tabbar-item", || {
|
mount_style("tabbar-item", include_str!("./tabbar-item.css"));
|
||||||
style_sheet_str!("./src/mobile/tabbar/tabbar-item.css")
|
|
||||||
});
|
|
||||||
let theme = use_theme(Theme::light);
|
let theme = use_theme(Theme::light);
|
||||||
let tabbar = use_tabbar();
|
let tabbar = use_tabbar();
|
||||||
let onclick_select = move |_| {
|
let onclick_select = move |_| {
|
||||||
|
@ -27,7 +24,7 @@ pub fn TabbarItem(
|
||||||
css_vars
|
css_vars
|
||||||
});
|
});
|
||||||
|
|
||||||
view! { class=class_name,
|
view! {
|
||||||
<div class="melt-tabbar-item" class=("melt-tabbar-item--selected", move || tabbar.get().value == name.get()) on:click=onclick_select style=move || css_vars.get()>
|
<div class="melt-tabbar-item" class=("melt-tabbar-item--selected", move || tabbar.get().value == name.get()) on:click=onclick_select style=move || css_vars.get()>
|
||||||
<OptionComp value=icon let:icon>
|
<OptionComp value=icon let:icon>
|
||||||
<Icon icon=icon width="22px" height="22px" class="melt-tabbar-item__icon"/>
|
<Icon icon=icon width="22px" height="22px" class="melt-tabbar-item__icon"/>
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use crate::utils::mount_style::mount_style;
|
use crate::utils::mount_style::mount_style;
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use stylers::style_sheet_str;
|
|
||||||
use web_sys::Element;
|
use web_sys::Element;
|
||||||
|
|
||||||
pub struct ToastOptions {
|
pub struct ToastOptions {
|
||||||
|
@ -10,10 +9,10 @@ pub struct ToastOptions {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn show_toast(options: ToastOptions) {
|
pub fn show_toast(options: ToastOptions) {
|
||||||
let class_name = mount_style("toast", || style_sheet_str!("./src/mobile/toast/toast.css"));
|
mount_style("toast", include_str!("./toast.css"));
|
||||||
|
|
||||||
let parent = Element::from(document().body().expect("body element not to exist"));
|
let parent = Element::from(document().body().expect("body element not to exist"));
|
||||||
let children = view! { class=class_name,
|
let children = view! {
|
||||||
<div class="melt-toast">
|
<div class="melt-toast">
|
||||||
{ options.message }
|
{ options.message }
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -4,7 +4,6 @@ use crate::icon::*;
|
||||||
use crate::teleport::*;
|
use crate::teleport::*;
|
||||||
use crate::utils::mount_style::mount_style;
|
use crate::utils::mount_style::mount_style;
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
use stylers::style_sheet_str;
|
|
||||||
|
|
||||||
#[slot]
|
#[slot]
|
||||||
pub struct ModalFooter {
|
pub struct ModalFooter {
|
||||||
|
@ -18,10 +17,9 @@ pub fn Modal(
|
||||||
children: Children,
|
children: Children,
|
||||||
#[prop(optional)] modal_footer: Option<ModalFooter>,
|
#[prop(optional)] modal_footer: Option<ModalFooter>,
|
||||||
) -> impl IntoView {
|
) -> impl IntoView {
|
||||||
let class_name = mount_style("modal", || style_sheet_str!("./src/modal/modal.css"));
|
mount_style("modal", include_str!("./modal.css"));
|
||||||
|
|
||||||
view! {
|
view! {
|
||||||
class=class_name,
|
|
||||||
<Teleport>
|
<Teleport>
|
||||||
<div class="melt-modal-container" style=move || if show.get() { "" } else { "display: none" }>
|
<div class="melt-modal-container" style=move || if show.get() { "" } else { "display: none" }>
|
||||||
<div class="melt-modal-mask"></div>
|
<div class="melt-modal-mask"></div>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use crate::{components::*, utils::mount_style::mount_style};
|
use crate::{components::*, utils::mount_style::mount_style};
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
use stylers::style_sheet_str;
|
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn Progress(
|
pub fn Progress(
|
||||||
|
@ -8,12 +7,9 @@ pub fn Progress(
|
||||||
#[prop(optional, into)] right_tip: MaybeSignal<&'static str>,
|
#[prop(optional, into)] right_tip: MaybeSignal<&'static str>,
|
||||||
percentage: ReadSignal<f64>,
|
percentage: ReadSignal<f64>,
|
||||||
) -> impl IntoView {
|
) -> impl IntoView {
|
||||||
let class_name = mount_style("progress", || {
|
mount_style("progress", include_str!("./progress.css"));
|
||||||
style_sheet_str!("./src/progress/progress.css")
|
|
||||||
});
|
|
||||||
let style = move || format!("width: {}%", percentage.get());
|
let style = move || format!("width: {}%", percentage.get());
|
||||||
view! {
|
view! {
|
||||||
class=class_name,
|
|
||||||
<div class="melt-progress">
|
<div class="melt-progress">
|
||||||
<span class="melt-progress__tip-left">
|
<span class="melt-progress__tip-left">
|
||||||
<If cond=MaybeSignal::derive( move || !left_tip.get().is_empty())>
|
<If cond=MaybeSignal::derive( move || !left_tip.get().is_empty())>
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use crate::{teleport::Teleport, theme::use_theme, utils::mount_style::mount_style, Theme};
|
use crate::{teleport::Teleport, theme::use_theme, utils::mount_style::mount_style, Theme};
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
use stylers::style_sheet_str;
|
|
||||||
use wasm_bindgen::__rt::IntoJsResult;
|
use wasm_bindgen::__rt::IntoJsResult;
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, Hash)]
|
#[derive(Clone, PartialEq, Eq, Hash)]
|
||||||
|
@ -18,7 +17,7 @@ pub fn Select<T>(
|
||||||
where
|
where
|
||||||
T: Eq + Hash + Clone + 'static,
|
T: Eq + Hash + Clone + 'static,
|
||||||
{
|
{
|
||||||
let class_name = mount_style("select", || style_sheet_str!("./src/select/select.css"));
|
mount_style("select", include_str!("./select.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 |_| {
|
||||||
|
@ -79,7 +78,7 @@ where
|
||||||
.map_or(String::new(), |v| v.label.clone()),
|
.map_or(String::new(), |v| v.label.clone()),
|
||||||
None => String::new(),
|
None => String::new(),
|
||||||
});
|
});
|
||||||
view! { class=class_name,
|
view! {
|
||||||
<div class="melt-select" ref=trigger_ref on:click=show_popover style=move || css_vars.get()>
|
<div class="melt-select" ref=trigger_ref on:click=show_popover style=move || css_vars.get()>
|
||||||
{
|
{
|
||||||
move || select_option_label.get()
|
move || select_option_label.get()
|
||||||
|
@ -97,7 +96,7 @@ where
|
||||||
value.set(Some(item_value));
|
value.set(Some(item_value));
|
||||||
is_show_popover.set(false);
|
is_show_popover.set(false);
|
||||||
};
|
};
|
||||||
view! { class=class_name,
|
view! {
|
||||||
<div class="melt-select-menu__item" class=("melt-select-menu__item-selected", move || value.get() == Some(item.get_value().value) ) on:click=onclick>
|
<div class="melt-select-menu__item" class=("melt-select-menu__item-selected", move || value.get() == Some(item.get_value().value) ) on:click=onclick>
|
||||||
{ item.get_value().label }
|
{ item.get_value().label }
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use crate::{theme::use_theme, utils::mount_style::mount_style, Theme};
|
use crate::{theme::use_theme, utils::mount_style::mount_style, Theme};
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
use stylers::style_sheet_str;
|
|
||||||
use wasm_bindgen::JsCast;
|
use wasm_bindgen::JsCast;
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
|
@ -27,7 +26,7 @@ pub fn Slider(
|
||||||
value.get() / max.get() * 100.0
|
value.get() / max.get() * 100.0
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
let class_name = mount_style("slider", || style_sheet_str!("./src/slider/slider.css"));
|
mount_style("slider", include_str!("./slider.css"));
|
||||||
|
|
||||||
let do_update_value = move |val| {
|
let do_update_value = move |val| {
|
||||||
value.set(val);
|
value.set(val);
|
||||||
|
@ -66,7 +65,7 @@ pub fn Slider(
|
||||||
});
|
});
|
||||||
on_cleanup(move || on_mouse_move.remove());
|
on_cleanup(move || on_mouse_move.remove());
|
||||||
|
|
||||||
view! { class=class_name,
|
view! {
|
||||||
<div class="melt-slider" style=move || css_vars.get()>
|
<div class="melt-slider" style=move || css_vars.get()>
|
||||||
<div class="melt-slider-rail" ref=rail_ref>
|
<div class="melt-slider-rail" ref=rail_ref>
|
||||||
<div class="melt-slider-rail__fill" style=move || format!("width: {}%", percentage.get())></div>
|
<div class="melt-slider-rail__fill" style=move || format!("width: {}%", percentage.get())></div>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use crate::utils::mount_style::mount_style;
|
use crate::utils::mount_style::mount_style;
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
use stylers::style_sheet_str;
|
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub enum SpaceGap {
|
pub enum SpaceGap {
|
||||||
|
@ -18,7 +17,7 @@ pub fn Space(
|
||||||
#[prop(optional)] vertical: bool,
|
#[prop(optional)] vertical: bool,
|
||||||
children: Children,
|
children: Children,
|
||||||
) -> impl IntoView {
|
) -> impl IntoView {
|
||||||
let class_name = mount_style("space", || style_sheet_str!("./src/space/space.css"));
|
mount_style("space", include_str!("./space.css"));
|
||||||
let gap = match gap {
|
let gap = match gap {
|
||||||
SpaceGap::SMALL => "4px 8px".into(),
|
SpaceGap::SMALL => "4px 8px".into(),
|
||||||
SpaceGap::MEDIUM => "8px 12px".into(),
|
SpaceGap::MEDIUM => "8px 12px".into(),
|
||||||
|
@ -28,12 +27,10 @@ pub fn Space(
|
||||||
};
|
};
|
||||||
|
|
||||||
view! {
|
view! {
|
||||||
class=class_name,
|
|
||||||
<div class="melt-space" style:gap={gap} style:flex-direction=if vertical { "column" } else { "row" }>
|
<div class="melt-space" style:gap={gap} style:flex-direction=if vertical { "column" } else { "row" }>
|
||||||
{
|
{
|
||||||
children().nodes.into_iter().map(|node| {
|
children().nodes.into_iter().map(|node| {
|
||||||
view! {
|
view! {
|
||||||
class=class_name,
|
|
||||||
<div class="melt-space__item">
|
<div class="melt-space__item">
|
||||||
{node}
|
{node}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
use crate::utils::mount_style::mount_style;
|
use crate::utils::mount_style::mount_style;
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
use stylers::style_sheet_str;
|
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn Table(children: Children) -> impl IntoView {
|
pub fn Table(children: Children) -> impl IntoView {
|
||||||
let class_name = mount_style("table", || style_sheet_str!("./src/table/table.css"));
|
mount_style("table", include_str!("./table.css"));
|
||||||
view! { class=class_name,
|
view! {
|
||||||
<table class="melt-table">
|
<table class="melt-table">
|
||||||
{children()}
|
{children()}
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
mod tab;
|
mod tab;
|
||||||
use crate::{theme::use_theme, utils::mount_style::mount_style, Theme};
|
use crate::{theme::use_theme, utils::mount_style::mount_style, Theme};
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
use stylers::style_sheet_str;
|
|
||||||
pub use tab::*;
|
pub use tab::*;
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn Tabs(active_key: RwSignal<&'static str>, children: Children) -> impl IntoView {
|
pub fn Tabs(active_key: RwSignal<&'static str>, children: Children) -> impl IntoView {
|
||||||
let class_name = mount_style("tabs", || style_sheet_str!("./src/tabs/tabs.css"));
|
mount_style("tabs", include_str!("./tabs.css"));
|
||||||
let tab_options_vec = create_rw_signal(vec![]);
|
let tab_options_vec = create_rw_signal(vec![]);
|
||||||
provide_context(TabsInjectionKey {
|
provide_context(TabsInjectionKey {
|
||||||
active_key: active_key.clone(),
|
active_key: active_key.clone(),
|
||||||
|
@ -33,7 +33,7 @@ pub fn Tabs(active_key: RwSignal<&'static str>, children: Children) -> impl Into
|
||||||
});
|
});
|
||||||
let label_list_ref = create_node_ref::<html::Div>();
|
let label_list_ref = create_node_ref::<html::Div>();
|
||||||
|
|
||||||
view! {class=class_name,
|
view! {
|
||||||
<div class="melt-tabs" style=move || css_vars.get()>
|
<div class="melt-tabs" style=move || css_vars.get()>
|
||||||
<div class="melt-tabs__label-list" ref=label_list_ref>
|
<div class="melt-tabs__label-list" ref=label_list_ref>
|
||||||
<For each=move || tab_options_vec.get() key=move |v| v.key children=move | options| {
|
<For each=move || tab_options_vec.get() key=move |v| v.key children=move | options| {
|
||||||
|
@ -56,7 +56,7 @@ pub fn Tabs(active_key: RwSignal<&'static str>, children: Children) -> impl Into
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
view! { class=class_name,
|
view! {
|
||||||
<span class="melt-tabs__label" class=("melt-tabs__label--active", move || options.key == active_key.get())
|
<span class="melt-tabs__label" class=("melt-tabs__label--active", move || options.key == active_key.get())
|
||||||
on:click=move |_| active_key.set(options.key)
|
on:click=move |_| active_key.set(options.key)
|
||||||
ref=label_ref
|
ref=label_ref
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use super::use_tabs;
|
use super::use_tabs;
|
||||||
use crate::utils::mount_style::mount_style;
|
use crate::utils::mount_style::mount_style;
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
use stylers::style_sheet_str;
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub(crate) struct TabOptions {
|
pub(crate) struct TabOptions {
|
||||||
|
@ -11,10 +10,10 @@ pub(crate) struct TabOptions {
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn Tab(key: &'static str, label: &'static str, children: Children) -> impl IntoView {
|
pub fn Tab(key: &'static str, label: &'static str, children: Children) -> impl IntoView {
|
||||||
let class_name = mount_style("tab", || style_sheet_str!("./src/tabs/tab.css"));
|
mount_style("tab", include_str!("./tab.css"));
|
||||||
let tabs = use_tabs();
|
let tabs = use_tabs();
|
||||||
tabs.push_tab_options(TabOptions { key, label });
|
tabs.push_tab_options(TabOptions { key, label });
|
||||||
view! { class=class_name,
|
view! {
|
||||||
<div class="melt-tab" class=("melt-tab--hidden", move || key != tabs.get_key()) >
|
<div class="melt-tab" class=("melt-tab--hidden", move || key != tabs.get_key()) >
|
||||||
{ children() }
|
{ children() }
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,17 +1,13 @@
|
||||||
use leptos::document;
|
use leptos::document;
|
||||||
|
|
||||||
pub fn mount_style<'a, F>(id: &'a str, f: F) -> &str
|
pub fn mount_style(id: &str, content: &str) {
|
||||||
where
|
|
||||||
F: FnOnce() -> (&'a str, &'a str),
|
|
||||||
{
|
|
||||||
let head = document().head().expect("head no exist");
|
let head = document().head().expect("head no exist");
|
||||||
let style = head
|
let style = head
|
||||||
.query_selector(&format!("style[csr-id=\"melt-{id}\"]"))
|
.query_selector(&format!("style[csr-id=\"melt-{id}\"]"))
|
||||||
.expect("query style element error");
|
.expect("query style element error");
|
||||||
|
|
||||||
let (class_name, content) = f();
|
|
||||||
if style.is_some() {
|
if style.is_some() {
|
||||||
return class_name;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let style = document()
|
let style = document()
|
||||||
|
@ -21,6 +17,4 @@ where
|
||||||
style.set_text_content(Some(content));
|
style.set_text_content(Some(content));
|
||||||
|
|
||||||
_ = head.append_child(&style);
|
_ = head.append_child(&style);
|
||||||
|
|
||||||
class_name
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
use crate::utils::mount_style::mount_style;
|
use crate::utils::mount_style::mount_style;
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
use stylers::style_sheet_str;
|
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn Wave(children: Children) -> impl IntoView {
|
pub fn Wave(children: Children) -> impl IntoView {
|
||||||
let class_name = mount_style("wave", || style_sheet_str!("./src/wave/wave.css"));
|
mount_style("wave", include_str!("./wave.css"));
|
||||||
let (css_vars, set_css_vars) = create_signal(String::new());
|
let (css_vars, set_css_vars) = create_signal(String::new());
|
||||||
let wave_ref = create_node_ref::<html::Div>();
|
let wave_ref = create_node_ref::<html::Div>();
|
||||||
wave_ref.on_load(move |wave| {
|
wave_ref.on_load(move |wave| {
|
||||||
|
@ -22,7 +21,6 @@ pub fn Wave(children: Children) -> impl IntoView {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
view! {
|
view! {
|
||||||
class=class_name,
|
|
||||||
<div class="melt-wave" ref=wave_ref style=move || css_vars.get()>
|
<div class="melt-wave" ref=wave_ref style=move || css_vars.get()>
|
||||||
{ children() }
|
{ children() }
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Reference in a new issue