From 5cce9afcb91f1c4fce68572549c3e49d3a2b4ed5 Mon Sep 17 00:00:00 2001 From: luoxiaozero <48741584+luoxiaozero@users.noreply.github.com> Date: Thu, 4 Jan 2024 23:32:58 +0800 Subject: [PATCH] demo: adaptive mobile (#68) * demo: adaptive mobile * fix: demo callback --- demo/Cargo.toml | 3 +- demo/src/components/site_header.rs | 207 +++++++++++++++++++++-------- demo/src/pages/components.rs | 22 ++- demo/src/pages/guide.rs | 22 ++- demo_markdown/src/lib.rs | 2 +- demo_markdown/src/markdown/mod.rs | 18 +-- 6 files changed, 210 insertions(+), 64 deletions(-) diff --git a/demo/Cargo.toml b/demo/Cargo.toml index bf623f8..8a3001a 100644 --- a/demo/Cargo.toml +++ b/demo/Cargo.toml @@ -10,7 +10,7 @@ edition = "2021" leptos = { version = "0.5.4" } leptos_meta = { version = "0.5.4" } leptos_router = { version = "0.5.4" } -leptos_devtools = "0.0.1" +leptos_devtools = { version = "0.0.1", optional = true} thaw = { path = "../thaw", default-features = false } icondata = { version = "0.1.0", features = [ "AiCloseOutlined", @@ -18,6 +18,7 @@ icondata = { version = "0.1.0", features = [ "AiGithubOutlined", "AiUserOutlined", "AiSearchOutlined", + "AiUnorderedListOutlined" ] } demo_markdown = { path = "../demo_markdown" } diff --git a/demo/src/components/site_header.rs b/demo/src/components/site_header.rs index d667b20..8daa5f7 100644 --- a/demo/src/components/site_header.rs +++ b/demo/src/components/site_header.rs @@ -1,5 +1,6 @@ use leptos::*; -use leptos_router::use_navigate; +use leptos_meta::Style; +use leptos_router::{use_location, use_navigate}; use thaw::*; #[component] @@ -8,23 +9,21 @@ pub fn SiteHeader() -> impl IntoView { let theme_name = create_memo(move |_| { theme.with(|theme| { if theme.name == *"light" { - "Dark" + "Dark".to_string() } else { - "Light" + "Light".to_string() } }) }); - let on_theme = move |_| { + let change_theme = Callback::new(move |_| { if theme_name.get_untracked() == "Light" { - theme.set(Theme::light()) + theme.set(Theme::light()); } else { - theme.set(Theme::dark()) + theme.set(Theme::dark()); } - }; + }); let style = create_memo(move |_| { - theme.with(|theme| { - format!("height: 64px; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; border-bottom: 1px solid {}", theme.common.border_color) - }) + theme.with(|theme| format!("border-bottom: 1px solid {}", theme.common.border_color)) }); let search_value = create_rw_signal(String::new()); let search_all_options = store_value(gen_search_all_options()); @@ -77,18 +76,58 @@ pub fn SiteHeader() -> impl IntoView { } }); on_cleanup(move || handle.remove()); - view! { - - - -
+ let menu_value = use_menu_value(change_theme); + view! { + + + + +
"Thaw UI"
@@ -105,39 +144,62 @@ pub fn SiteHeader() -> impl IntoView { - - - - + + +