diff --git a/thaw/src/anchor/anchor_link.rs b/thaw/src/anchor/anchor_link.rs index f281c12..a810624 100644 --- a/thaw/src/anchor/anchor_link.rs +++ b/thaw/src/anchor/anchor_link.rs @@ -1,5 +1,5 @@ use crate::use_anchor; -use leptos::*; +use leptos::{html, prelude::*}; use thaw_components::OptionComp; use thaw_utils::{class_list, OptionalProp, StoredMaybeSignal}; @@ -39,7 +39,10 @@ pub fn AnchorLink( }); }); - title_ref.on_load(move |title_el| { + Effect::new(|_| { + let Some(title_el) = title_ref.get() else { + return; + }; let _ = watch( move || is_active.get(), move |is_active, _, _| { @@ -70,7 +73,7 @@ pub fn AnchorLink( href=href class="thaw-anchor-link__title" on:click=on_click - ref=title_ref + node_ref=title_ref title=move || title.get() > {move || title.get()} diff --git a/thaw/src/anchor/mod.rs b/thaw/src/anchor/mod.rs index fead0a4..6b183b0 100644 --- a/thaw/src/anchor/mod.rs +++ b/thaw/src/anchor/mod.rs @@ -2,7 +2,7 @@ mod anchor_link; pub use anchor_link::AnchorLink; -use leptos::*; +use leptos::{context::Provider, ev, html, prelude::*}; use std::cmp::Ordering; use thaw_utils::{add_event_listener_with_bool, class_list, mount_style, throttle, OptionalProp}; use web_sys::{DomRect, Element}; @@ -87,7 +87,7 @@ pub fn Anchor( view! {
impl IntoView { @@ -11,7 +11,7 @@ pub fn AutoCompleteOption(key: String, children: Children) -> impl IntoView {
{children()} diff --git a/thaw/src/auto_complete/mod.rs b/thaw/src/auto_complete/mod.rs index 16a8ffe..b8c334d 100644 --- a/thaw/src/auto_complete/mod.rs +++ b/thaw/src/auto_complete/mod.rs @@ -3,7 +3,7 @@ mod auto_complete_option; pub use auto_complete_option::AutoCompleteOption; use crate::{ComponentRef, ConfigInjection, Input, InputPrefix, InputRef, InputSuffix}; -use leptos::*; +use leptos::{prelude::*, html}; use thaw_components::{ Binder, CSSTransition, Follower, FollowerPlacement, FollowerWidth, OptionComp, }; @@ -42,10 +42,10 @@ pub fn AutoComplete( let default_index = if allow_free_input { None } else { Some(0) }; - let select_option_index = create_rw_signal::>(default_index); - let menu_ref = create_node_ref::(); - let is_show_menu = create_rw_signal(false); - let auto_complete_ref = create_node_ref::(); + let select_option_index = RwSignal::>::new(default_index); + let menu_ref = NodeRef::::new(); + let is_show_menu = RwSignal::new(false); + let auto_complete_ref = NodeRef::::new(); let open_menu = move || { select_option_index.set(default_index); is_show_menu.set(true); @@ -141,7 +141,7 @@ pub fn AutoComplete(
diff --git a/thaw/src/avatar/mod.rs b/thaw/src/avatar/mod.rs index 147b7cf..7bafd46 100644 --- a/thaw/src/avatar/mod.rs +++ b/thaw/src/avatar/mod.rs @@ -1,4 +1,4 @@ -use leptos::*; +use leptos::prelude::*; use thaw_components::OptionComp; use thaw_utils::{class_list, mount_style, OptionalProp, StoredMaybeSignal}; @@ -49,7 +49,7 @@ pub fn Avatar( view! { diff --git a/thaw/src/back_top/mod.rs b/thaw/src/back_top/mod.rs index 2da90a5..bde1938 100644 --- a/thaw/src/back_top/mod.rs +++ b/thaw/src/back_top/mod.rs @@ -1,5 +1,5 @@ use crate::{ConfigInjection, Icon}; -use leptos::{html::ToHtmlElement, *}; +use leptos::{ev, html, html::ToHtmlElement, prelude::*}; use thaw_components::{CSSTransition, Fallback, OptionComp, Teleport}; use thaw_utils::{ add_event_listener, class_list, get_scroll_parent, mount_style, EventListenerHandle, @@ -32,10 +32,14 @@ pub fn BackTop( let scroll_to_top = StoredValue::new(None::>); let scroll_handle = StoredValue::new(None::); - placeholder_ref.on_load(move |el| { + Effect::new(move |_| { + let Some(placeholder_el) = placeholder_ref.get() else { + return; + }; + request_animation_frame(move || { - let scroll_el = get_scroll_parent(&el.into_any()) - .unwrap_or_else(|| document().document_element().unwrap().to_leptos_element()); + let scroll_el = get_scroll_parent(&placeholder_el) + .unwrap_or_else(|| document().document_element().unwrap()); { let scroll_el = scroll_el.clone(); @@ -72,7 +76,7 @@ pub fn BackTop( }; view! { -