mirror of
https://github.com/adoyle0/leptos-use.git
synced 2025-01-23 00:59:22 -05:00
Problem: use_color_mode doesn't work with new use_storage API. Use StringCodec
This commit is contained in:
parent
1371b81b67
commit
f23d8ad31c
1 changed files with 15 additions and 5 deletions
|
@ -1,6 +1,7 @@
|
|||
use crate::core::{ElementMaybeSignal, MaybeRwSignal};
|
||||
use crate::storage::{use_storage_with_options, UseStorageOptions};
|
||||
use std::fmt::{Display, Formatter};
|
||||
use std::str::FromStr;
|
||||
|
||||
use crate::core::StorageType;
|
||||
use crate::use_preferred_dark;
|
||||
|
@ -263,13 +264,14 @@ fn get_store_signal(
|
|||
let (store, set_store) = storage_signal.split();
|
||||
(store.into(), set_store)
|
||||
} else if storage_enabled {
|
||||
use_storage_with_options(
|
||||
let (store, set_store, _) = use_storage_with_options(
|
||||
storage,
|
||||
storage_key,
|
||||
initial_value,
|
||||
UseStorageOptions::default()
|
||||
UseStorageOptions::string_codec()
|
||||
.listen_to_storage_changes(listen_to_storage_changes)
|
||||
.storage_type(storage),
|
||||
)
|
||||
.default_value(initial_value),
|
||||
);
|
||||
(store, set_store)
|
||||
} else {
|
||||
initial_value.into_signal()
|
||||
}
|
||||
|
@ -306,6 +308,14 @@ impl From<String> for ColorMode {
|
|||
}
|
||||
}
|
||||
|
||||
impl FromStr for ColorMode {
|
||||
type Err = ();
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
Ok(ColorMode::from(s))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(DefaultBuilder)]
|
||||
pub struct UseColorModeOptions<El, T>
|
||||
where
|
||||
|
|
Loading…
Add table
Reference in a new issue