diff --git a/.idea/leptos-use.iml b/.idea/leptos-use.iml
index 3693411..91f8ed7 100644
--- a/.idea/leptos-use.iml
+++ b/.idea/leptos-use.iml
@@ -20,6 +20,7 @@
+
@@ -37,6 +38,7 @@
+
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 18991f3..b679427 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,13 +3,18 @@
## 0.2.0
#### Braking Changes
-- `watch` doesn't accept `immediate` as an argument anymore. This is only provided by the option variant.
+- `watch` doesn't accept `immediate` as a direct argument anymore. This is only provided by the option variant.
#### New Functions
- `use_storage`
+- `use_local_storage`
+- `use_session_storage`
- `watch_debounced`
- `watch_throttled`
- `watch_pausable`
+- `use_ceil`
+- `use_round`
+- `use_media_query`
#### Other Changes
diff --git a/Cargo.toml b/Cargo.toml
index ca34c76..48e7573 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -31,6 +31,7 @@ features = [
"CustomEventInit",
"DomRectReadOnly",
"Element",
+ "MediaQueryList",
"MouseEvent",
"Navigator",
"ResizeObserver",
diff --git a/README.md b/README.md
index 8f36a08..8fbfbe1 100644
--- a/README.md
+++ b/README.md
@@ -46,9 +46,16 @@ and run
```shell
mdbook serve
```
+
This builds the html version of the book and runs a local dev server.
To also add in the examples open another shell and run
```shell
python3 post_build.py
+```
+
+If you only want to add the example for one function you can run for example
+
+```shell
+python3 post_build.py use_media_query
```
\ No newline at end of file
diff --git a/docs/book/post_build.py b/docs/book/post_build.py
index d6cc821..61a9909 100644
--- a/docs/book/post_build.py
+++ b/docs/book/post_build.py
@@ -1,6 +1,7 @@
import os
import shutil
import subprocess
+import sys
def main():
@@ -10,7 +11,7 @@ def main():
category_dir = os.path.join(src_dir, dir)
if os.path.isdir(category_dir):
for file in os.listdir(category_dir):
- if file.endswith(".md"):
+ if file.endswith(".md") and (len(sys.argv) == 1 or (sys.argv[1] in file)):
build_and_copy_demo(category, file)
diff --git a/docs/book/src/SUMMARY.md b/docs/book/src/SUMMARY.md
index 7d2000b..b366373 100644
--- a/docs/book/src/SUMMARY.md
+++ b/docs/book/src/SUMMARY.md
@@ -19,6 +19,7 @@
# Browser
- [use_event_listener](browser/use_event_listener.md)
+- [use_media_query](browser/use_media_query.md)
# Sensors
diff --git a/docs/book/src/browser/use_media_query.md b/docs/book/src/browser/use_media_query.md
new file mode 100644
index 0000000..d986055
--- /dev/null
+++ b/docs/book/src/browser/use_media_query.md
@@ -0,0 +1,3 @@
+# use_media_query
+
+
diff --git a/examples/use_media_query/Cargo.toml b/examples/use_media_query/Cargo.toml
new file mode 100644
index 0000000..9b64d51
--- /dev/null
+++ b/examples/use_media_query/Cargo.toml
@@ -0,0 +1,16 @@
+[package]
+name = "use_media_query"
+version = "0.1.0"
+edition = "2021"
+
+[dependencies]
+leptos = "0.3"
+console_error_panic_hook = "0.1"
+console_log = "1"
+log = "0.4"
+leptos-use = { path = "../..", features = ["docs"] }
+web-sys = "0.3"
+
+[dev-dependencies]
+wasm-bindgen = "0.2"
+wasm-bindgen-test = "0.3.0"
diff --git a/examples/use_media_query/README.md b/examples/use_media_query/README.md
new file mode 100644
index 0000000..cf0d0dc
--- /dev/null
+++ b/examples/use_media_query/README.md
@@ -0,0 +1,23 @@
+A simple example for `use_media_query`.
+
+If you don't have it installed already, install [Trunk](https://trunkrs.dev/) and [Tailwind](https://tailwindcss.com/docs/installation)
+as well as the nightly toolchain for Rust and the wasm32-unknown-unknown target:
+
+```bash
+cargo install trunk
+npm install -D tailwindcss @tailwindcss/forms
+rustup toolchain install nightly
+rustup target add wasm32-unknown-unknown
+```
+
+Then, open two terminals. In the first one, run:
+
+```
+npx tailwindcss -i ./input.css -o ./style/output.css --watch
+```
+
+In the second one, run:
+
+```bash
+trunk serve --open
+```
\ No newline at end of file
diff --git a/examples/use_media_query/Trunk.toml b/examples/use_media_query/Trunk.toml
new file mode 100644
index 0000000..3e4be08
--- /dev/null
+++ b/examples/use_media_query/Trunk.toml
@@ -0,0 +1,2 @@
+[build]
+public_url = "/demo/"
\ No newline at end of file
diff --git a/examples/use_media_query/index.html b/examples/use_media_query/index.html
new file mode 100644
index 0000000..ae249a6
--- /dev/null
+++ b/examples/use_media_query/index.html
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/examples/use_media_query/input.css b/examples/use_media_query/input.css
new file mode 100644
index 0000000..bd6213e
--- /dev/null
+++ b/examples/use_media_query/input.css
@@ -0,0 +1,3 @@
+@tailwind base;
+@tailwind components;
+@tailwind utilities;
\ No newline at end of file
diff --git a/examples/use_media_query/rust-toolchain.toml b/examples/use_media_query/rust-toolchain.toml
new file mode 100644
index 0000000..271800c
--- /dev/null
+++ b/examples/use_media_query/rust-toolchain.toml
@@ -0,0 +1,2 @@
+[toolchain]
+channel = "nightly"
\ No newline at end of file
diff --git a/examples/use_media_query/src/main.rs b/examples/use_media_query/src/main.rs
new file mode 100644
index 0000000..90f2329
--- /dev/null
+++ b/examples/use_media_query/src/main.rs
@@ -0,0 +1,23 @@
+use leptos::*;
+use leptos_use::docs::{demo_or_body, BooleanDisplay};
+use leptos_use::use_media_query;
+
+#[component]
+fn Demo(cx: Scope) -> impl IntoView {
+ let is_large_screen = use_media_query(cx, "(min-width: 1024px)");
+ let is_dark_preferred = use_media_query(cx, "(prefers-color-scheme: dark)");
+
+ view! { cx,
+