mirror of
https://github.com/adoyle0/leptos-use.git
synced 2025-01-23 00:59:22 -05:00
fixed examples
This commit is contained in:
parent
90399ee313
commit
b28f1b3e11
9 changed files with 21 additions and 16 deletions
|
@ -13,8 +13,8 @@ def main():
|
||||||
if os.path.isdir(category_dir):
|
if os.path.isdir(category_dir):
|
||||||
for file in os.listdir(category_dir):
|
for file in os.listdir(category_dir):
|
||||||
if file.endswith(".md") and (len(sys.argv) == 1 or (sys.argv[1] in file)):
|
if file.endswith(".md") and (len(sys.argv) == 1 or (sys.argv[1] in file)):
|
||||||
build_and_copy_demo(category, file)
|
if build_and_copy_demo(category, file):
|
||||||
rewrite_links(category, file)
|
rewrite_links(category, file)
|
||||||
|
|
||||||
|
|
||||||
def build_and_copy_demo(category, md_name):
|
def build_and_copy_demo(category, md_name):
|
||||||
|
@ -51,7 +51,7 @@ def build_and_copy_demo(category, md_name):
|
||||||
|
|
||||||
with open(book_html_path, "w") as f:
|
with open(book_html_path, "w") as f:
|
||||||
f.write(
|
f.write(
|
||||||
f"""{head_split[0]}
|
f"""{head_split[0]}
|
||||||
<head>
|
<head>
|
||||||
{demo_head}
|
{demo_head}
|
||||||
{target_head}
|
{target_head}
|
||||||
|
@ -62,6 +62,10 @@ def build_and_copy_demo(category, md_name):
|
||||||
</body>
|
</body>
|
||||||
{body_split[1]}""")
|
{body_split[1]}""")
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def rewrite_links(category, md_name):
|
def rewrite_links(category, md_name):
|
||||||
"""Rewrite links in generated documentation to make them
|
"""Rewrite links in generated documentation to make them
|
||||||
|
|
|
@ -5,6 +5,7 @@ edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
leptos = { version = "0.6", features = ["nightly", "csr"] }
|
leptos = { version = "0.6", features = ["nightly", "csr"] }
|
||||||
|
codee = "0.1"
|
||||||
console_error_panic_hook = "0.1"
|
console_error_panic_hook = "0.1"
|
||||||
console_log = "1"
|
console_log = "1"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
use codee::string::FromToStringCodec;
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
use leptos_use::docs::demo_or_body;
|
use leptos_use::docs::demo_or_body;
|
||||||
use leptos_use::utils::FromToStringCodec;
|
|
||||||
use leptos_use::{use_broadcast_channel, UseBroadcastChannelReturn};
|
use leptos_use::{use_broadcast_channel, UseBroadcastChannelReturn};
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
|
@ -46,8 +46,8 @@ fn Demo() -> impl IntoView {
|
||||||
<p>"Received message: " {move || message().as_ref().unwrap().to_string()}</p>
|
<p>"Received message: " {move || message().as_ref().unwrap().to_string()}</p>
|
||||||
</Show>
|
</Show>
|
||||||
|
|
||||||
<Show when=move || error().is_some()>
|
<Show when=move || error.with(|e| e.is_some())>
|
||||||
<p>"Error: " {move || format!("{:?}", error().as_ref().unwrap())}</p>
|
<p>"Error: " {move || error.with(|e| format!("{:?}", e.as_ref().unwrap()))}</p>
|
||||||
</Show>
|
</Show>
|
||||||
</Show>
|
</Show>
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
leptos = { version = "0.6", features = ["nightly", "csr"] }
|
leptos = { version = "0.6", features = ["nightly", "csr"] }
|
||||||
|
codee = "0.1"
|
||||||
console_error_panic_hook = "0.1"
|
console_error_panic_hook = "0.1"
|
||||||
console_log = "1"
|
console_log = "1"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
use leptos_use::docs::demo_or_body;
|
use leptos_use::docs::demo_or_body;
|
||||||
use leptos_use::use_cookie;
|
use leptos_use::use_cookie;
|
||||||
use leptos_use::utils::FromToStringCodec;
|
use codee::string::FromToStringCodec;
|
||||||
use rand::prelude::*;
|
use rand::prelude::*;
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
|
|
|
@ -4,14 +4,14 @@ version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
codee = { path = "../../../codee", features = ["json_serde"] }
|
codee = { version = "0.1", features = ["json_serde"] }
|
||||||
leptos = { version = "0.6", features = ["nightly", "csr"] }
|
|
||||||
console_error_panic_hook = "0.1"
|
console_error_panic_hook = "0.1"
|
||||||
console_log = "1"
|
console_log = "1"
|
||||||
log = "0.4"
|
leptos = { version = "0.6", features = ["nightly", "csr"] }
|
||||||
leptos-use = { path = "../..", features = ["docs"] }
|
leptos-use = { path = "../..", features = ["docs"] }
|
||||||
web-sys = "0.3"
|
log = "0.4"
|
||||||
serde = "1.0.163"
|
serde = "1.0.163"
|
||||||
|
web-sys = "0.3"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
wasm-bindgen = "0.2"
|
wasm-bindgen = "0.2"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
use leptos_use::docs::{demo_or_body, Note};
|
use leptos_use::docs::{demo_or_body, Note};
|
||||||
use leptos_use::storage::use_local_storage;
|
use leptos_use::storage::use_local_storage;
|
||||||
use leptos_use::utils::JsonCodec;
|
use codee::string::JsonSerdeCodec;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
|
||||||
|
@ -25,8 +25,8 @@ impl Default for BananaState {
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
fn Demo() -> impl IntoView {
|
fn Demo() -> impl IntoView {
|
||||||
let (state, set_state, reset) = use_local_storage::<BananaState, JsonCodec>("banana-state");
|
let (state, set_state, reset) = use_local_storage::<BananaState, JsonSerdeCodec>("banana-state");
|
||||||
let (state2, _, _) = use_local_storage::<BananaState, JsonCodec>("banana-state");
|
let (state2, _, _) = use_local_storage::<BananaState, JsonSerdeCodec>("banana-state");
|
||||||
|
|
||||||
view! {
|
view! {
|
||||||
<input
|
<input
|
||||||
|
|
|
@ -5,7 +5,7 @@ edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
leptos = { version = "0.6", features = ["nightly", "csr"] }
|
leptos = { version = "0.6", features = ["nightly", "csr"] }
|
||||||
codee = { path = "../../../codee", features = ["msgpack_serde"] }
|
codee = { version = "0.1", features = ["msgpack_serde"] }
|
||||||
console_error_panic_hook = "0.1"
|
console_error_panic_hook = "0.1"
|
||||||
console_log = "1"
|
console_log = "1"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
|
|
|
@ -24,7 +24,6 @@ use thiserror::Error;
|
||||||
/// > Please check [the codec chapter](https://leptos-use.rs/codecs.html) to see what codecs are
|
/// > Please check [the codec chapter](https://leptos-use.rs/codecs.html) to see what codecs are
|
||||||
/// > available and what feature flags they require.
|
/// > available and what feature flags they require.
|
||||||
///
|
///
|
||||||
///
|
|
||||||
/// ```
|
/// ```
|
||||||
/// # use leptos::*;
|
/// # use leptos::*;
|
||||||
/// # use leptos_use::{use_event_source, UseEventSourceReturn};
|
/// # use leptos_use::{use_event_source, UseEventSourceReturn};
|
||||||
|
|
Loading…
Add table
Reference in a new issue