mirror of
https://github.com/adoyle0/leptos-use.git
synced 2025-01-22 16:49:22 -05:00
Merge pull request #44 from feral-dot-io/resize
Remove use of --cfg=web_sys_unstable_apis
This commit is contained in:
commit
1a9c98c36e
7 changed files with 10 additions and 41 deletions
|
@ -1,3 +0,0 @@
|
|||
[unstable]
|
||||
rustflags = ["--cfg=web_sys_unstable_apis"]
|
||||
rustdocflags = ["--cfg=web_sys_unstable_apis"]
|
|
@ -24,7 +24,7 @@ num = { version = "0.4", optional = true }
|
|||
paste = "1"
|
||||
serde = { version = "1", optional = true }
|
||||
serde_json = { version = "1", optional = true }
|
||||
wasm-bindgen = "0.2"
|
||||
wasm-bindgen = "0.2.87"
|
||||
wasm-bindgen-futures = "0.4"
|
||||
|
||||
[dependencies.web-sys]
|
||||
|
@ -97,6 +97,3 @@ ssr = []
|
|||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
rustdoc-args = ["--cfg=web_sys_unstable_apis"]
|
||||
rustc-args = ["--cfg=web_sys_unstable_apis"]
|
||||
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
[build]
|
||||
rustflags = ["--cfg=web_sys_unstable_apis", "--cfg=has_std"]
|
|
@ -1,2 +0,0 @@
|
|||
[build]
|
||||
rustflags = ["--cfg=web_sys_unstable_apis"]
|
14
src/lib.rs
14
src/lib.rs
|
@ -1,8 +1,6 @@
|
|||
// #![feature(doc_cfg)]
|
||||
//! Collection of essential Leptos utilities inspired by SolidJS USE / VueUse
|
||||
|
||||
use cfg_if::cfg_if;
|
||||
|
||||
pub mod core;
|
||||
#[cfg(feature = "docs")]
|
||||
pub mod docs;
|
||||
|
@ -12,14 +10,6 @@ pub mod math;
|
|||
pub mod storage;
|
||||
pub mod utils;
|
||||
|
||||
cfg_if! { if #[cfg(web_sys_unstable_apis)] {
|
||||
mod use_element_size;
|
||||
mod use_resize_observer;
|
||||
|
||||
pub use use_element_size::*;
|
||||
pub use use_resize_observer::*;
|
||||
}}
|
||||
|
||||
mod is_err;
|
||||
mod is_none;
|
||||
mod is_ok;
|
||||
|
@ -38,6 +28,7 @@ mod use_document_visibility;
|
|||
mod use_draggable;
|
||||
mod use_drop_zone;
|
||||
mod use_element_hover;
|
||||
mod use_element_size;
|
||||
mod use_element_visibility;
|
||||
mod use_event_listener;
|
||||
mod use_favicon;
|
||||
|
@ -54,6 +45,7 @@ mod use_mutation_observer;
|
|||
mod use_preferred_contrast;
|
||||
mod use_preferred_dark;
|
||||
mod use_raf_fn;
|
||||
mod use_resize_observer;
|
||||
mod use_scroll;
|
||||
mod use_service_worker;
|
||||
mod use_sorted;
|
||||
|
@ -90,6 +82,7 @@ pub use use_document_visibility::*;
|
|||
pub use use_draggable::*;
|
||||
pub use use_drop_zone::*;
|
||||
pub use use_element_hover::*;
|
||||
pub use use_element_size::*;
|
||||
pub use use_element_visibility::*;
|
||||
pub use use_event_listener::*;
|
||||
pub use use_favicon::*;
|
||||
|
@ -106,6 +99,7 @@ pub use use_mutation_observer::*;
|
|||
pub use use_preferred_contrast::*;
|
||||
pub use use_preferred_dark::*;
|
||||
pub use use_raf_fn::*;
|
||||
pub use use_resize_observer::*;
|
||||
pub use use_scroll::*;
|
||||
pub use use_service_worker::*;
|
||||
pub use use_sorted::*;
|
||||
|
|
|
@ -12,9 +12,6 @@ cfg_if! { if #[cfg(not(feature = "ssr"))] {
|
|||
|
||||
/// Reactive size of an HTML element.
|
||||
///
|
||||
/// > This function requires `--cfg=web_sys_unstable_apis` to be activated as
|
||||
/// [described in the wasm-bindgen guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html).
|
||||
///
|
||||
/// Please refer to [ResizeObserver on MDN](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver)
|
||||
/// for more details.
|
||||
///
|
||||
|
@ -25,12 +22,12 @@ cfg_if! { if #[cfg(not(feature = "ssr"))] {
|
|||
/// ## Usage
|
||||
///
|
||||
/// ```
|
||||
/// # use leptos::*;
|
||||
/// # use leptos::{html::Div, *};
|
||||
/// # use leptos_use::{use_element_size, UseElementSizeReturn};
|
||||
/// #
|
||||
/// # #[component]
|
||||
/// # fn Demo() -> impl IntoView {
|
||||
/// let el = create_node_ref();
|
||||
/// let el = create_node_ref::<Div>();
|
||||
///
|
||||
/// let UseElementSizeReturn { width, height } = use_element_size(el);
|
||||
///
|
||||
|
@ -175,7 +172,7 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(DefaultBuilder)]
|
||||
#[derive(DefaultBuilder, Default)]
|
||||
/// Options for [`use_element_size_with_options`].
|
||||
pub struct UseElementSizeOptions {
|
||||
/// Initial size returned before any measurements on the `target` are done. Also the value reported
|
||||
|
@ -187,15 +184,6 @@ pub struct UseElementSizeOptions {
|
|||
pub box_: Option<web_sys::ResizeObserverBoxOptions>,
|
||||
}
|
||||
|
||||
impl Default for UseElementSizeOptions {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
initial_size: Size::default(),
|
||||
box_: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The return value of [`use_element_size`].
|
||||
pub struct UseElementSizeReturn {
|
||||
/// The width of the element.
|
||||
|
|
|
@ -12,9 +12,6 @@ cfg_if! { if #[cfg(not(feature = "ssr"))] {
|
|||
|
||||
/// Reports changes to the dimensions of an Element's content or the border-box.
|
||||
///
|
||||
/// > This function requires `--cfg=web_sys_unstable_apis` to be activated as
|
||||
/// [described in the wasm-bindgen guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html).
|
||||
///
|
||||
/// Please refer to [ResizeObserver on MDN](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver)
|
||||
/// for more details.
|
||||
///
|
||||
|
@ -25,12 +22,12 @@ cfg_if! { if #[cfg(not(feature = "ssr"))] {
|
|||
/// ## Usage
|
||||
///
|
||||
/// ```
|
||||
/// # use leptos::*;
|
||||
/// # use leptos::{html::Div, *};
|
||||
/// # use leptos_use::use_resize_observer;
|
||||
/// #
|
||||
/// # #[component]
|
||||
/// # fn Demo() -> impl IntoView {
|
||||
/// let el = create_node_ref();
|
||||
/// let el = create_node_ref::<Div>();
|
||||
/// let (text, set_text) = create_signal("".to_string());
|
||||
///
|
||||
/// use_resize_observer(
|
||||
|
|
Loading…
Add table
Reference in a new issue