From 98dbdf8f86ee6992edd7b84a4850698a23eee16c Mon Sep 17 00:00:00 2001
From: Maccesch
Date: Wed, 10 Apr 2024 22:51:01 +0100
Subject: [PATCH] added cookie support to use_color_mode
---
CHANGELOG.md | 8 ++-
Cargo.toml | 5 +-
README.md | 2 +-
docs/book/src/introduction.md | 2 +-
examples/ssr/Cargo.toml | 2 +-
examples/ssr/src/app.rs | 15 +++---
src/use_color_mode.rs | 95 +++++++++++++++++++++++++++++++++--
7 files changed, 112 insertions(+), 17 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6150878..a1dfddd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,12 +3,16 @@
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).
-## [Unreleased] -
+## [0.10.7] - 2024-04-10
-### New Functions 🚀
+### New Function 🚀
- `sync_signal`
+### Change 🔥
+
+- `use_color_mode` now supports cookies.
+
## [0.10.6] - 2024-04-02
### Fixes 🍕
diff --git a/Cargo.toml b/Cargo.toml
index 6016717..0f7bfd0 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "leptos-use"
-version = "0.10.6"
+version = "0.10.7"
edition = "2021"
authors = ["Marc-Stefan Cassola"]
categories = ["gui", "web-programming"]
@@ -131,8 +131,9 @@ features = [
]
[dev-dependencies]
-rand = "0.8"
getrandom = { version = "0.2", features = ["js"] }
+leptos_meta = "0.6"
+rand = "0.8"
[features]
actix = ["dep:actix-web", "dep:leptos_actix", "dep:http0_2"]
diff --git a/README.md b/README.md
index 95ab332..57516cc 100644
--- a/README.md
+++ b/README.md
@@ -13,7 +13,7 @@
-
+
diff --git a/docs/book/src/introduction.md b/docs/book/src/introduction.md
index 2796c28..f12ec1b 100644
--- a/docs/book/src/introduction.md
+++ b/docs/book/src/introduction.md
@@ -12,6 +12,6 @@
-
+
\ No newline at end of file
diff --git a/examples/ssr/Cargo.toml b/examples/ssr/Cargo.toml
index 6b657b8..d0b6e6a 100644
--- a/examples/ssr/Cargo.toml
+++ b/examples/ssr/Cargo.toml
@@ -21,7 +21,7 @@ simple_logger = "4"
tokio = { version = "1", features = ["full"], optional = true }
tower = { version = "0.4", optional = true }
tower-http = { version = "0.5", features = ["fs"], optional = true }
-wasm-bindgen = "0.2.88"
+wasm-bindgen = "0.2.92"
thiserror = "1.0.38"
tracing = { version = "0.1.37", optional = true }
http = "1"
diff --git a/examples/ssr/src/app.rs b/examples/ssr/src/app.rs
index fa44443..9b4e6f0 100644
--- a/examples/ssr/src/app.rs
+++ b/examples/ssr/src/app.rs
@@ -6,9 +6,10 @@ use leptos_router::*;
use leptos_use::storage::use_local_storage;
use leptos_use::utils::FromToStringCodec;
use leptos_use::{
- use_color_mode, use_cookie_with_options, use_debounce_fn, use_event_listener, use_interval,
- use_intl_number_format, use_preferred_dark, use_timestamp, use_window, ColorMode,
- UseColorModeReturn, UseCookieOptions, UseIntervalReturn, UseIntlNumberFormatOptions,
+ use_color_mode_with_options, use_cookie_with_options, use_debounce_fn, use_event_listener,
+ use_interval, use_intl_number_format, use_preferred_dark, use_timestamp, use_window, ColorMode,
+ UseColorModeOptions, UseColorModeReturn, UseCookieOptions, UseIntervalReturn,
+ UseIntlNumberFormatOptions,
};
#[component]
@@ -65,7 +66,8 @@ fn HomePage() -> impl IntoView {
);
debounced_fn();
- let UseColorModeReturn { mode, set_mode, .. } = use_color_mode();
+ let UseColorModeReturn { mode, set_mode, .. } =
+ use_color_mode_with_options(UseColorModeOptions::default().cookie_enabled(true));
let timestamp = use_timestamp();
@@ -79,6 +81,8 @@ fn HomePage() -> impl IntoView {
);
view! {
+