From a6e94af982614bdfd0f8f8f1f7a3a8ad6897f826 Mon Sep 17 00:00:00 2001 From: Maccesch Date: Tue, 13 Jun 2023 00:31:38 +0100 Subject: [PATCH] added use_mutation_observer --- .github/workflows/ci.yml | 11 + .idea/leptos-use.iml | 1 + CHANGELOG.md | 68 ++- Cargo.toml | 3 + docs/book/src/SUMMARY.md | 1 + .../src/elements/use_mutation_observer.md | 3 + docs/logo.svg | 4 +- examples/Cargo.toml | 1 + examples/use_mutation_observer/Cargo.toml | 16 + examples/use_mutation_observer/README.md | 23 ++ examples/use_mutation_observer/Trunk.toml | 2 + examples/use_mutation_observer/index.html | 7 + examples/use_mutation_observer/input.css | 3 + .../use_mutation_observer/rust-toolchain.toml | 2 + examples/use_mutation_observer/src/main.rs | 65 +++ .../use_mutation_observer/style/output.css | 289 +++++++++++++ .../use_mutation_observer/tailwind.config.js | 15 + ...aybe_signal.rs => element_maybe_signal.rs} | 39 +- src/core/elements_maybe_signal.rs | 387 ++++++++++++++++++ src/core/mod.rs | 6 +- src/lib.rs | 2 + src/use_element_size.rs | 6 +- src/use_element_visibility.rs | 2 +- src/use_event_listener.rs | 75 ++-- src/use_intersection_observer.rs | 95 ++--- src/use_media_query.rs | 4 +- src/use_mutation_observer.rs | 138 +++++++ src/use_resize_observer.rs | 74 ++-- 28 files changed, 1176 insertions(+), 166 deletions(-) create mode 100644 docs/book/src/elements/use_mutation_observer.md create mode 100644 examples/use_mutation_observer/Cargo.toml create mode 100644 examples/use_mutation_observer/README.md create mode 100644 examples/use_mutation_observer/Trunk.toml create mode 100644 examples/use_mutation_observer/index.html create mode 100644 examples/use_mutation_observer/input.css create mode 100644 examples/use_mutation_observer/rust-toolchain.toml create mode 100644 examples/use_mutation_observer/src/main.rs create mode 100644 examples/use_mutation_observer/style/output.css create mode 100644 examples/use_mutation_observer/tailwind.config.js rename src/core/{event_target_maybe_signal.rs => element_maybe_signal.rs} (81%) create mode 100644 src/core/elements_maybe_signal.rs create mode 100644 src/use_mutation_observer.rs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cccd68e..7851a21 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -71,6 +71,17 @@ jobs: with: registry-token: ${{ secrets.CRATES_TOKEN }} + - uses: CSchoel/release-notes-from-changelog@v1 + - name: Create Release using GitHub CLI + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: > + gh release create + -d + -F RELEASE.md + -t "Version $RELEASE_VERSION" + ${GITHUB_REF#refs/*/} + # coverage: # name: Coverage # runs-on: ubuntu-latest diff --git a/.idea/leptos-use.iml b/.idea/leptos-use.iml index ca8d127..012417e 100644 --- a/.idea/leptos-use.iml +++ b/.idea/leptos-use.iml @@ -28,6 +28,7 @@ + diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a3d0fe..0629804 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,25 +1,44 @@ # Changelog -## v0.2.2 +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -### New Functions +## [Unreleased] + +### Braking Changes 🛠 +- `use_event_listener` no longer returns a `Box` but a `impl Fn() + Clone` + +### Changes 🔥 + +- You can now specify a `&str` or `Signal` with CSS selectors wherever a node ref is accepted +- Callbacks of the following functions no longer require `Clone` + - `use_resize_observer` + - `use_intersection_observer` +- These functions now also accept multiple target elements in addition to a single one: + - `use_resize_observer` + - `use_intersection_observer` + +### New Functions 🚀 - `whenever` +- `use_mutation_observer` -## 0.2.1 +## [0.2.1] - 2023-06-11 ### New Functions - `use_intersection_observer` - `use_element_visibility` -## 0.2.0 +## [0.2.0] - 2023-06-11 + +### Braking Changes -#### Braking Changes - `watch` doesn't accept `immediate` as a direct argument anymore. This is only provided by the option variant. - `watch` has now variant `watch_with_options` which allows for debouncing and throttling. -#### New Functions +### New Functions + - `use_storage` - `use_local_storage` - `use_session_storage` @@ -34,49 +53,58 @@ - `use_favicon` - `use_breakpoints` -#### Other Changes +### Other Changes - Function count badge in readme -## 0.1.8/9 +## [0.1.8/9] - 2023-06-05 - Fixed documentation and doc tests running for functions behind `#[cfg(web_sys_unstable_apis)]` -## 0.1.7 +## [0.1.7] - 2023-06-05 + +### New Function -#### New Function - `use_element_size` -## 0.1.6 +## [0.1.6] - 2023-06-03 + +### Changes - Fixed documentation so all feature are documented -## 0.1.5 +## [0.1.5] - 2023-06-03 + +### New Functions -#### New Functions - `use_floor` - `use_max` - `use_min` -#### Other Changes +### Changes + - New feature: `math` that has to be activated in order to use the math functions. -## 0.1.4 +## [0.1.4] - 2023-06-02 + +### New Functions -#### New Functions - `use_supported` - `use_resize_observer` - `watch` - `use_mouse` -#### Other Changes +### Changes + - Use the crate `default-struct-builder` to provide ergonimic function options. -## 0.1.3 +## [0.1.3] - 2023-05-28 + +### New Functions -#### New Functions - `use_scroll` - `use_debounce_fn` -#### Other Changes +### Other Changes + - Better and more beautiful demo integration into the guide. \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index ca8e34a..1736cc2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,6 +37,9 @@ features = [ "IntersectionObserverEntry", "MediaQueryList", "MouseEvent", + "MutationObserver", + "MutationObserverInit", + "MutationRecord", "Navigator", "NodeList", "ResizeObserver", diff --git a/docs/book/src/SUMMARY.md b/docs/book/src/SUMMARY.md index 5e5b4d2..fc1a0d3 100644 --- a/docs/book/src/SUMMARY.md +++ b/docs/book/src/SUMMARY.md @@ -16,6 +16,7 @@ - [use_element_size](elements/use_element_size.md) - [use_element_visibility](elements/use_element_visibility.md) - [use_intersection_observer](elements/use_intersection_observer.md) +- [use_mutation_observer](elements/use_mutation_observer.md) - [use_resize_observer](elements/use_resize_observer.md) # Browser diff --git a/docs/book/src/elements/use_mutation_observer.md b/docs/book/src/elements/use_mutation_observer.md new file mode 100644 index 0000000..65a585b --- /dev/null +++ b/docs/book/src/elements/use_mutation_observer.md @@ -0,0 +1,3 @@ +# use_mutation_observer + + diff --git a/docs/logo.svg b/docs/logo.svg index 5ef6f02..15e8968 100644 --- a/docs/logo.svg +++ b/docs/logo.svg @@ -5,12 +5,12 @@