From 8b122d0986fdc00952955bfd78c719d140f29116 Mon Sep 17 00:00:00 2001 From: luoxiao Date: Wed, 10 Jul 2024 17:26:00 +0800 Subject: [PATCH] fix: Icon attr --- demo/src/app.rs | 2 +- demo/src/components/demo.rs | 4 +--- thaw/src/accordion/accordion_item.rs | 2 +- thaw/src/dialog/dialog_body.rs | 2 +- thaw/src/dialog/dialog_content.rs | 2 +- thaw/src/dialog/dialog_title.rs | 2 +- thaw/src/drawer/drawer_header.rs | 2 +- thaw/src/icon/mod.rs | 17 +++++++--------- thaw/src/space/mod.rs | 4 ++-- thaw/src/toast/toaster.rs | 2 +- thaw_components/src/teleport/mod.rs | 3 +-- thaw_utils/src/signals/component_ref.rs | 26 ++++++++++++------------- thaw_utils/src/signals/signal_watch.rs | 7 ++++++- 13 files changed, 36 insertions(+), 39 deletions(-) diff --git a/demo/src/app.rs b/demo/src/app.rs index b10d97d..ace30e5 100644 --- a/demo/src/app.rs +++ b/demo/src/app.rs @@ -50,7 +50,7 @@ fn TheRouter(is_routing: RwSignal) -> impl IntoView { - + // // // // // // diff --git a/demo/src/components/demo.rs b/demo/src/components/demo.rs index e927023..1923b4f 100644 --- a/demo/src/components/demo.rs +++ b/demo/src/components/demo.rs @@ -24,9 +24,7 @@ pub fn Demo(demo_code: DemoCode, #[prop(optional)] children: Option) - } else { css_vars.push_str("--demo-color: #00000060;"); css_vars.push_str("--demo-color-hover: #000000e0;"); - css_vars.push_str(&format!( - "--demo-border-color: var(--colorNeutralStroke2);", - )); + css_vars.push_str(&format!("--demo-border-color: var(--colorNeutralStroke2);",)); css_vars.push_str("--demo-background-color: #f9fafb;"); } }); diff --git a/thaw/src/accordion/accordion_item.rs b/thaw/src/accordion/accordion_item.rs index b7d02c8..153b3c1 100644 --- a/thaw/src/accordion/accordion_item.rs +++ b/thaw/src/accordion/accordion_item.rs @@ -1,5 +1,5 @@ use crate::AccordionInjection; -use leptos::{prelude::*, html}; +use leptos::{html, prelude::*}; use thaw_components::CSSTransition; use thaw_utils::{mount_style, update, with, StoredMaybeSignal}; diff --git a/thaw/src/dialog/dialog_body.rs b/thaw/src/dialog/dialog_body.rs index 7dccce1..ba42a29 100644 --- a/thaw/src/dialog/dialog_body.rs +++ b/thaw/src/dialog/dialog_body.rs @@ -7,4 +7,4 @@ pub fn DialogBody(children: Children) -> impl IntoView { {children()} } -} \ No newline at end of file +} diff --git a/thaw/src/dialog/dialog_content.rs b/thaw/src/dialog/dialog_content.rs index 8095a17..ad71d3d 100644 --- a/thaw/src/dialog/dialog_content.rs +++ b/thaw/src/dialog/dialog_content.rs @@ -7,4 +7,4 @@ pub fn DialogContent(children: Children) -> impl IntoView { {children()} } -} \ No newline at end of file +} diff --git a/thaw/src/dialog/dialog_title.rs b/thaw/src/dialog/dialog_title.rs index 861e860..ad2b008 100644 --- a/thaw/src/dialog/dialog_title.rs +++ b/thaw/src/dialog/dialog_title.rs @@ -7,4 +7,4 @@ pub fn DialogTitle(children: Children) -> impl IntoView { {children()} } -} \ No newline at end of file +} diff --git a/thaw/src/drawer/drawer_header.rs b/thaw/src/drawer/drawer_header.rs index a526d0e..9b60005 100644 --- a/thaw/src/drawer/drawer_header.rs +++ b/thaw/src/drawer/drawer_header.rs @@ -7,4 +7,4 @@ pub fn DrawerHeader(children: Children) -> impl IntoView { {children()} } -} \ No newline at end of file +} diff --git a/thaw/src/icon/mod.rs b/thaw/src/icon/mod.rs index 4562a23..bcdec67 100644 --- a/thaw/src/icon/mod.rs +++ b/thaw/src/icon/mod.rs @@ -83,7 +83,7 @@ pub fn Icon( let svg = view! { >>) -> String { +fn take_signal(signal: RwSignal>>) -> Option { signal.with(|s| match s { - Some(MaybeSignal::Static(value)) => value.clone(), - Some(MaybeSignal::Dynamic(signal)) => signal.get(), - _ => String::new(), + Some(MaybeSignal::Static(value)) => Some(value.clone()), + Some(MaybeSignal::Dynamic(signal)) => Some(signal.get()), + _ => None, }) } -fn take(signal: RwSignal>) -> String { +fn take(signal: RwSignal>) -> Option { signal.track(); - signal - .try_update_untracked(|value| value.take()) - .flatten() - .unwrap_or_default() + signal.try_update_untracked(|value| value.take()).flatten() } diff --git a/thaw/src/space/mod.rs b/thaw/src/space/mod.rs index 2c16954..e84b2aa 100644 --- a/thaw/src/space/mod.rs +++ b/thaw/src/space/mod.rs @@ -107,8 +107,8 @@ impl SpaceJustify { mod test { #[test] fn main() { - use leptos::prelude::*; use super::Space; + use leptos::prelude::*; view! { @@ -117,4 +117,4 @@ mod test { }; } -} \ No newline at end of file +} diff --git a/thaw/src/toast/toaster.rs b/thaw/src/toast/toaster.rs index 90340c4..3f054c8 100644 --- a/thaw/src/toast/toaster.rs +++ b/thaw/src/toast/toaster.rs @@ -14,7 +14,7 @@ pub fn Toaster( Effect::new(move |_| { for view in receiver.try_recv() { // toast_list.update(move |list| { - // list.push(view.0); + // list.push(view.0); // }); } }); diff --git a/thaw_components/src/teleport/mod.rs b/thaw_components/src/teleport/mod.rs index c1c861a..23c2c83 100644 --- a/thaw_components/src/teleport/mod.rs +++ b/thaw_components/src/teleport/mod.rs @@ -1,6 +1,5 @@ use std::cell::Cell; - -use cfg_if::cfg_if; +// use cfg_if::cfg_if; use leptos::prelude::*; /// https://github.com/solidjs/solid/blob/main/packages/solid/web/src/index.ts#L56 diff --git a/thaw_utils/src/signals/component_ref.rs b/thaw_utils/src/signals/component_ref.rs index e371617..c94a461 100644 --- a/thaw_utils/src/signals/component_ref.rs +++ b/thaw_utils/src/signals/component_ref.rs @@ -1,12 +1,10 @@ use leptos::{ logging::debug_warn, reactive_graph::{ - effect::RenderEffect, signal::RwSignal, traits::{Get, GetUntracked, Update}, }, }; -use std::cell::Cell; pub struct ComponentRef(RwSignal>); @@ -58,17 +56,17 @@ impl ComponentRef { }); } - pub fn on_load(self, f: F) - where - T: Clone, - F: FnOnce(T) + 'static, - { - let f = Cell::new(Some(f)); + // pub fn on_load(self, f: F) + // where + // T: Clone, + // F: FnOnce(T) + 'static, + // { + // let f = Cell::new(Some(f)); - RenderEffect::new(move |_| { - if let Some(comp) = self.get() { - f.take().unwrap()(comp); - } - }); - } + // RenderEffect::new(move |_| { + // if let Some(comp) = self.get() { + // f.take().unwrap()(comp); + // } + // }); + // } } diff --git a/thaw_utils/src/signals/signal_watch.rs b/thaw_utils/src/signals/signal_watch.rs index 0da02e8..c660f59 100644 --- a/thaw_utils/src/signals/signal_watch.rs +++ b/thaw_utils/src/signals/signal_watch.rs @@ -1,4 +1,9 @@ -use leptos::reactive_graph::{effect::Effect, signal::RwSignal, traits::{Dispose, With}, untrack}; +use leptos::reactive_graph::{ + effect::Effect, + signal::RwSignal, + traits::{Dispose, With}, + untrack, +}; pub trait SignalWatch { type Value;