From e727d2931fcfe5f13b5068ffdf10b4ae7a163260 Mon Sep 17 00:00:00 2001 From: luoxiao Date: Tue, 13 Jun 2023 12:43:15 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20add=20gh-pages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 4 +- Cargo.toml | 2 +- gh-pages/Cargo.toml | 16 ++++++++ gh-pages/Trunk.toml | 16 ++++++++ gh-pages/index.html | 13 +++++++ gh-pages/src/app.rs | 61 ++++++++++++++++++++++++++++++ gh-pages/src/assets/css/index.css | 16 ++++++++ gh-pages/src/main.rs | 9 +++++ gh-pages/src/pages/button/mod.rs | 43 +++++++++++++++++++++ gh-pages/src/pages/checkbox/mod.rs | 14 +++++++ gh-pages/src/pages/components.rs | 52 +++++++++++++++++++++++++ gh-pages/src/pages/home.rs | 40 ++++++++++++++++++++ gh-pages/src/pages/image/mod.rs | 12 ++++++ gh-pages/src/pages/input/mod.rs | 14 +++++++ gh-pages/src/pages/menu/mod.rs | 16 ++++++++ gh-pages/src/pages/mobile.rs | 10 +++++ gh-pages/src/pages/mod.rs | 25 ++++++++++++ gh-pages/src/pages/modal/mod.rs | 15 ++++++++ gh-pages/src/pages/nav_bar/mod.rs | 24 ++++++++++++ gh-pages/src/pages/slider/mod.rs | 11 ++++++ gh-pages/src/pages/tabbar/mod.rs | 23 +++++++++++ 21 files changed, 434 insertions(+), 2 deletions(-) create mode 100644 gh-pages/Cargo.toml create mode 100644 gh-pages/Trunk.toml create mode 100644 gh-pages/index.html create mode 100644 gh-pages/src/app.rs create mode 100644 gh-pages/src/assets/css/index.css create mode 100644 gh-pages/src/main.rs create mode 100644 gh-pages/src/pages/button/mod.rs create mode 100644 gh-pages/src/pages/checkbox/mod.rs create mode 100644 gh-pages/src/pages/components.rs create mode 100644 gh-pages/src/pages/home.rs create mode 100644 gh-pages/src/pages/image/mod.rs create mode 100644 gh-pages/src/pages/input/mod.rs create mode 100644 gh-pages/src/pages/menu/mod.rs create mode 100644 gh-pages/src/pages/mobile.rs create mode 100644 gh-pages/src/pages/mod.rs create mode 100644 gh-pages/src/pages/modal/mod.rs create mode 100644 gh-pages/src/pages/nav_bar/mod.rs create mode 100644 gh-pages/src/pages/slider/mod.rs create mode 100644 gh-pages/src/pages/tabbar/mod.rs diff --git a/.gitignore b/.gitignore index 9e21b08..573e005 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,6 @@ Cargo.lock # These are backup files generated by rustfmt **/*.rs.bk -/examples/**/dist \ No newline at end of file +/examples/**/dist +/gh-pages/dist +/docs \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index 5446821..aaf1219 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,4 +27,4 @@ leptos_icons = { git = "https://github.com/luoxiaozero/leptos-icons.git", rev = wasm-bindgen = "0.2.85" [workspace] -members = ["examples/basic"] +members = ["examples/basic", "gh-pages"] diff --git a/gh-pages/Cargo.toml b/gh-pages/Cargo.toml new file mode 100644 index 0000000..e4fdbbd --- /dev/null +++ b/gh-pages/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "gh-pages" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +leptos = { git = "https://github.com/leptos-rs/leptos.git", rev = "3d75c71", features = [ + "stable", +] } +melt-ui = { path = "../" } +leptos_icons = { git = "https://github.com/luoxiaozero/leptos-icons.git", rev = "4fe4417", features = ["AiCloseOutlined", "AiCheckOutlined"] } +leptos_router = { git = "https://github.com/leptos-rs/leptos.git", rev = "3d75c71", features = ["csr"] } + +regex = "1.8.2" \ No newline at end of file diff --git a/gh-pages/Trunk.toml b/gh-pages/Trunk.toml new file mode 100644 index 0000000..e45af6e --- /dev/null +++ b/gh-pages/Trunk.toml @@ -0,0 +1,16 @@ +[build] +target = "index.html" +public_url = "/melt-ui/" +dist = "../docs" +release = true + +[watch] +watch = [ + "../src", + "./src" +] + +[serve] +address = "127.0.0.1" +port = 6421 +open = false diff --git a/gh-pages/index.html b/gh-pages/index.html new file mode 100644 index 0000000..7dd8246 --- /dev/null +++ b/gh-pages/index.html @@ -0,0 +1,13 @@ + + + + + + + Document + + + + + + \ No newline at end of file diff --git a/gh-pages/src/app.rs b/gh-pages/src/app.rs new file mode 100644 index 0000000..a29aadd --- /dev/null +++ b/gh-pages/src/app.rs @@ -0,0 +1,61 @@ +use crate::pages::*; +use leptos::*; +use leptos_router::*; + +#[component] +pub fn App(cx: Scope) -> impl IntoView { + view! { cx, + + + + } /> + + } /> + + } /> + + } > + + } /> + + } /> + + } /> + + } /> + + } /> + + } /> + + } /> + + } /> + + } /> + + + + + } /> + + } /> + + + } +} diff --git a/gh-pages/src/assets/css/index.css b/gh-pages/src/assets/css/index.css new file mode 100644 index 0000000..edc5940 --- /dev/null +++ b/gh-pages/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/gh-pages/src/main.rs b/gh-pages/src/main.rs new file mode 100644 index 0000000..38ab1fd --- /dev/null +++ b/gh-pages/src/main.rs @@ -0,0 +1,9 @@ +mod app; +mod pages; + +use app::*; +use leptos::*; + +fn main() { + mount_to_body(|cx| view! { cx, }) +} diff --git a/gh-pages/src/pages/button/mod.rs b/gh-pages/src/pages/button/mod.rs new file mode 100644 index 0000000..5c4f2d7 --- /dev/null +++ b/gh-pages/src/pages/button/mod.rs @@ -0,0 +1,43 @@ +use leptos::*; +use melt_ui::*; + +#[component] +pub fn ButtonPage(cx: Scope) -> impl IntoView { + view! {cx, + + + + + + + + + + + + +
+ + +
+ } +} \ No newline at end of file diff --git a/gh-pages/src/pages/checkbox/mod.rs b/gh-pages/src/pages/checkbox/mod.rs new file mode 100644 index 0000000..7d63d87 --- /dev/null +++ b/gh-pages/src/pages/checkbox/mod.rs @@ -0,0 +1,14 @@ +use leptos::*; +use melt_ui::*; + +#[component] +pub fn CheckboxPage(cx: Scope) -> impl IntoView { + let checked = create_rw_signal(cx, false); + view! {cx, +
+ + "Click" + +
+ } +} diff --git a/gh-pages/src/pages/components.rs b/gh-pages/src/pages/components.rs new file mode 100644 index 0000000..c57fd4f --- /dev/null +++ b/gh-pages/src/pages/components.rs @@ -0,0 +1,52 @@ +use leptos::*; +use leptos_router::{use_location, use_navigate, Outlet}; +use melt_ui::*; +use regex::Regex; + +#[component] +pub fn ComponentsPage(cx: Scope) -> impl IntoView { + let loaction = use_location(cx); + let navigate = use_navigate(cx); + let selected = create_rw_signal(cx, String::from("")); + create_effect(cx, move |_| { + let pathname = loaction.pathname.get(); + + let re = Regex::new(r"^/components/(.+)$").unwrap(); + let Some(caps) = re.captures(&pathname) else { + return; + }; + let Some(path) = caps.get(1) else { + return; + }; + let path = path.as_str().to_string(); + selected.set(path); + }); + + create_effect(cx, move |value| { + let selected = selected.get(); + if value.is_some() { + _ = navigate(&format!("/components/{selected}"), Default::default()); + } + selected + }); + view! {cx, +
+ +
+ +
+
+ } +} diff --git a/gh-pages/src/pages/home.rs b/gh-pages/src/pages/home.rs new file mode 100644 index 0000000..8d41b0c --- /dev/null +++ b/gh-pages/src/pages/home.rs @@ -0,0 +1,40 @@ +use leptos::*; +use leptos_router::use_navigate; +use melt_ui::*; + +#[component] +pub fn Home(cx: Scope) -> impl IntoView { + let (theme, set_theme) = create_signal(cx, Theme::light()); + provide_context(cx, theme); + let (count, set_count) = create_signal(cx, 0.0); + let (button_type, set_button_type) = create_signal(cx, ButtonType::TEXT); + view! { cx, + +
+ + + + + {move || count.get()} + + + + } +} diff --git a/gh-pages/src/pages/image/mod.rs b/gh-pages/src/pages/image/mod.rs new file mode 100644 index 0000000..f98e30a --- /dev/null +++ b/gh-pages/src/pages/image/mod.rs @@ -0,0 +1,12 @@ +use leptos::*; +use melt_ui::*; + +#[component] +pub fn ImagePage(cx: Scope) -> impl IntoView { + view! { cx, + <> + + + + } +} \ No newline at end of file diff --git a/gh-pages/src/pages/input/mod.rs b/gh-pages/src/pages/input/mod.rs new file mode 100644 index 0000000..090f843 --- /dev/null +++ b/gh-pages/src/pages/input/mod.rs @@ -0,0 +1,14 @@ +use leptos::*; +use melt_ui::*; + +#[component] +pub fn InputPage(cx: Scope) -> impl IntoView { + let value = create_rw_signal(cx, String::from("o")); + view! { cx, + <> + {move || value.get()} + + + + } +} \ No newline at end of file diff --git a/gh-pages/src/pages/menu/mod.rs b/gh-pages/src/pages/menu/mod.rs new file mode 100644 index 0000000..2e13f97 --- /dev/null +++ b/gh-pages/src/pages/menu/mod.rs @@ -0,0 +1,16 @@ +use leptos::*; +use melt_ui::*; + +#[component] +pub fn MenuPage(cx: Scope) -> impl IntoView { + let selected = create_rw_signal(cx, String::from("o")); + view! { cx, + <> + { move || selected.get() } + + + + + + } +} diff --git a/gh-pages/src/pages/mobile.rs b/gh-pages/src/pages/mobile.rs new file mode 100644 index 0000000..ba52df9 --- /dev/null +++ b/gh-pages/src/pages/mobile.rs @@ -0,0 +1,10 @@ +use leptos::*; + +#[component] +pub fn MobilePage(cx: Scope, path: &'static str) -> impl IntoView { + view! { cx, +
+