From db11387912b19a72058fef666950486ec79ad412 Mon Sep 17 00:00:00 2001 From: luoxiao Date: Tue, 23 May 2023 13:32:34 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(example):=20add=20components?= =?UTF-8?q?=20page?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/basic/index.html | 1 + examples/basic/src/app.rs | 11 ++++++++++ examples/basic/src/assets/css/index.css | 16 +++++++++++++++ examples/basic/src/components.rs | 27 +++++++++++++++++++++++++ examples/basic/src/main.rs | 1 + 5 files changed, 56 insertions(+) create mode 100644 examples/basic/src/assets/css/index.css create mode 100644 examples/basic/src/components.rs diff --git a/examples/basic/index.html b/examples/basic/index.html index 56efbdb..7dd8246 100644 --- a/examples/basic/index.html +++ b/examples/basic/index.html @@ -5,6 +5,7 @@ Document + diff --git a/examples/basic/src/app.rs b/examples/basic/src/app.rs index 0e5e748..4c7e407 100644 --- a/examples/basic/src/app.rs +++ b/examples/basic/src/app.rs @@ -1,3 +1,4 @@ +use crate::components::*; use crate::pages::*; use leptos::*; use leptos_router::*; @@ -16,6 +17,16 @@ pub fn App(cx: Scope) -> impl IntoView { } /> + + } > + + } /> + + } /> + } diff --git a/examples/basic/src/assets/css/index.css b/examples/basic/src/assets/css/index.css new file mode 100644 index 0000000..edc5940 --- /dev/null +++ b/examples/basic/src/assets/css/index.css @@ -0,0 +1,16 @@ +body { + margin: 0; +} + + +.components-page-box { + display: flex; +} + +.components-page-box aside { + width: 260px; +} + +.components-page-box main { + flex: 1; +} \ No newline at end of file diff --git a/examples/basic/src/components.rs b/examples/basic/src/components.rs new file mode 100644 index 0000000..ca782cb --- /dev/null +++ b/examples/basic/src/components.rs @@ -0,0 +1,27 @@ +use leptos::*; +use leptos_router::{Outlet, use_route, use_router}; +use melt_ui::*; + +#[component] +pub fn ComponentsPage(cx: Scope) -> impl IntoView { + let router = use_router(cx); + let route = use_route(cx); + let selected = create_rw_signal(cx, String::from("")); + create_effect(cx, move |_| { + let path = route.original_path(); + let path2 = route.path(); + log!("{:?} {}", path, path2); + }); + view! {cx, +
+ +
+ +
+
+ } +} diff --git a/examples/basic/src/main.rs b/examples/basic/src/main.rs index b3334f8..fff11de 100644 --- a/examples/basic/src/main.rs +++ b/examples/basic/src/main.rs @@ -4,6 +4,7 @@ mod demo_checkbox; mod demo_modal; mod demo_slider; mod pages; +mod components; use app::*; use leptos::*;