From e0ced4ecb53ff194c92ef3adf3225da1e77e4326 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABlle=20Huisman?= Date: Fri, 3 Jan 2025 17:38:17 +0100 Subject: [PATCH] Update Label to Leptos v0.7 (#401) --- Cargo.lock | 78 +++ Cargo.toml | 7 +- book-examples/leptos/icons/Cargo.toml | 5 +- book-examples/leptos/icons/src/app.rs | 18 +- book-examples/leptos/icons/src/main.rs | 8 +- book-examples/leptos/primitives/Cargo.toml | 37 +- book-examples/leptos/primitives/src/app.rs | 111 ++-- book-examples/leptos/primitives/src/label.rs | 4 +- book-examples/leptos/primitives/src/main.rs | 32 +- packages/primitives/leptos/label/Cargo.toml | 1 - packages/primitives/leptos/label/src/label.rs | 70 +-- stories/leptos/Cargo.toml | 40 +- stories/leptos/src/app.rs | 484 +++++++++--------- stories/leptos/src/main.rs | 4 +- stories/leptos/src/primitives.rs | 36 +- stories/leptos/src/primitives/label.rs | 8 +- 16 files changed, 525 insertions(+), 418 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d034817a..f2259f7c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2204,6 +2204,41 @@ dependencies = [ "uuid", ] +[[package]] +name = "leptos_router" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c93e40eef0b39384dc8a9aceb0f598d36de8f40d9ad14ef431023fae9b40bc88" +dependencies = [ + "any_spawner", + "either_of", + "futures", + "gloo-net 0.6.0", + "js-sys", + "leptos", + "leptos_router_macro", + "once_cell", + "or_poisoned", + "reactive_graph", + "send_wrapper", + "tachys", + "thiserror 2.0.9", + "url", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "leptos_router_macro" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "757692288bd1aeb03d597481ec350c4eba26ffd98f06c5491e30a9c21ae9fbfb" +dependencies = [ + "proc-macro-error2", + "proc-macro2", + "quote", +] + [[package]] name = "leptos_server" version = "0.7.2" @@ -2796,6 +2831,27 @@ dependencies = [ "web-sys", ] +[[package]] +name = "radix-leptos-book-icons" +version = "0.0.2" +dependencies = [ + "console_error_panic_hook", + "console_log", + "leptos", + "log", +] + +[[package]] +name = "radix-leptos-book-primitives" +version = "0.0.2" +dependencies = [ + "console_error_panic_hook", + "console_log", + "leptos", + "log", + "radix-leptos-label", +] + [[package]] name = "radix-leptos-id" version = "0.0.2" @@ -2803,6 +2859,28 @@ dependencies = [ "leptos", ] +[[package]] +name = "radix-leptos-label" +version = "0.0.2" +dependencies = [ + "leptos", + "web-sys", +] + +[[package]] +name = "radix-leptos-stories" +version = "0.0.2" +dependencies = [ + "console_error_panic_hook", + "console_log", + "leptos", + "leptos_router", + "log", + "radix-leptos-label", + "tailwind_fuse", + "web-sys", +] + [[package]] name = "radix-number" version = "0.0.2" diff --git a/Cargo.toml b/Cargo.toml index bff1da40..0a19d53c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,17 +10,16 @@ # "stories/*", # ] members = [ - "book-examples/dioxus/*", - "book-examples/yew/*", + "book-examples/*/*", "packages/colors", "packages/icons/dioxus", "packages/icons/yew", "packages/primitives/leptos/id", + "packages/primitives/leptos/label", "packages/primitives/yew/*", "packages/themes/yew", "scripts", - "stories/dioxus", - "stories/yew", + "stories/*", ] resolver = "2" diff --git a/book-examples/leptos/icons/Cargo.toml b/book-examples/leptos/icons/Cargo.toml index 49de61d6..40bf9e7b 100644 --- a/book-examples/leptos/icons/Cargo.toml +++ b/book-examples/leptos/icons/Cargo.toml @@ -14,8 +14,9 @@ console_error_panic_hook.workspace = true console_log.workspace = true leptos = { workspace = true, features = ["csr"] } log.workspace = true -radix-leptos-icons = { path = "../../../packages/icons/leptos", optional = true } +# radix-leptos-icons = { path = "../../../packages/icons/leptos", optional = true } [features] default = [] -icons = ["dep:radix-leptos-icons"] +icons = [] +# icons = ["dep:radix-leptos-icons"] diff --git a/book-examples/leptos/icons/src/app.rs b/book-examples/leptos/icons/src/app.rs index 192bb79b..36bc291c 100644 --- a/book-examples/leptos/icons/src/app.rs +++ b/book-examples/leptos/icons/src/app.rs @@ -1,17 +1,17 @@ -use leptos::*; +use leptos::prelude::*; #[component] pub fn App() -> impl IntoView { #[allow(unused_mut)] - let mut views: Vec = vec![]; + let mut views: Vec = vec![]; - #[cfg(feature = "icons")] - { - use crate::icons::IconsDemo; - views.push(view! { - - }); - } + // #[cfg(feature = "icons")] + // { + // use crate::icons::IconsDemo; + // views.push(view! { + // + // }); + // } view! {
diff --git a/book-examples/leptos/icons/src/main.rs b/book-examples/leptos/icons/src/main.rs index 5a49d204..bf90caf6 100644 --- a/book-examples/leptos/icons/src/main.rs +++ b/book-examples/leptos/icons/src/main.rs @@ -1,7 +1,9 @@ mod app; -#[cfg(feature = "icons")] -mod icons; +// #[cfg(feature = "icons")] +// mod icons; + +use leptos::prelude::*; use crate::app::App; @@ -9,5 +11,5 @@ pub fn main() { _ = console_log::init_with_level(log::Level::Debug); console_error_panic_hook::set_once(); - leptos::mount_to_body(App); + mount_to_body(App); } diff --git a/book-examples/leptos/primitives/Cargo.toml b/book-examples/leptos/primitives/Cargo.toml index 67b1cbec..e12f6c96 100644 --- a/book-examples/leptos/primitives/Cargo.toml +++ b/book-examples/leptos/primitives/Cargo.toml @@ -14,15 +14,15 @@ console_error_panic_hook.workspace = true console_log.workspace = true leptos = { workspace = true, features = ["csr"] } log.workspace = true -radix-leptos-aspect-ratio = { path = "../../../packages/primitives/leptos/aspect-ratio", optional = true } -radix-leptos-avatar = { path = "../../../packages/primitives/leptos/avatar", optional = true } -radix-leptos-checkbox = { path = "../../../packages/primitives/leptos/checkbox", optional = true } -radix-leptos-icons = { path = "../../../packages/icons/leptos", optional = true } +# radix-leptos-aspect-ratio = { path = "../../../packages/primitives/leptos/aspect-ratio", optional = true } +# radix-leptos-avatar = { path = "../../../packages/primitives/leptos/avatar", optional = true } +# radix-leptos-checkbox = { path = "../../../packages/primitives/leptos/checkbox", optional = true } +# radix-leptos-icons = { path = "../../../packages/icons/leptos", optional = true } radix-leptos-label = { path = "../../../packages/primitives/leptos/label", optional = true } -radix-leptos-progress = { path = "../../../packages/primitives/leptos/progress", optional = true } -radix-leptos-separator = { path = "../../../packages/primitives/leptos/separator", optional = true } -radix-leptos-switch = { path = "../../../packages/primitives/leptos/switch", optional = true } -radix-leptos-toggle = { path = "../../../packages/primitives/leptos/toggle", optional = true } +# radix-leptos-progress = { path = "../../../packages/primitives/leptos/progress", optional = true } +# radix-leptos-separator = { path = "../../../packages/primitives/leptos/separator", optional = true } +# radix-leptos-switch = { path = "../../../packages/primitives/leptos/switch", optional = true } +# radix-leptos-toggle = { path = "../../../packages/primitives/leptos/toggle", optional = true } [features] default = [ @@ -35,11 +35,18 @@ default = [ "switch", "toggle", ] -aspect-ratio = ["dep:radix-leptos-aspect-ratio"] -avatar = ["dep:radix-leptos-avatar"] -checkbox = ["dep:radix-leptos-checkbox", "dep:radix-leptos-icons"] +aspect-ratio = [] +avatar = [] +checkbox = [] label = ["dep:radix-leptos-label"] -progress = ["dep:radix-leptos-progress"] -separator = ["dep:radix-leptos-separator"] -switch = ["dep:radix-leptos-switch"] -toggle = ["dep:radix-leptos-toggle", "dep:radix-leptos-icons"] +progress = [] +separator = [] +switch = [] +toggle = [] +# aspect-ratio = ["dep:radix-leptos-aspect-ratio"] +# avatar = ["dep:radix-leptos-avatar"] +# checkbox = ["dep:radix-leptos-checkbox", "dep:radix-leptos-icons"] +# progress = ["dep:radix-leptos-progress"] +# separator = ["dep:radix-leptos-separator"] +# switch = ["dep:radix-leptos-switch"] +# toggle = ["dep:radix-leptos-toggle", "dep:radix-leptos-icons"] diff --git a/book-examples/leptos/primitives/src/app.rs b/book-examples/leptos/primitives/src/app.rs index 773a20b2..46c2fc65 100644 --- a/book-examples/leptos/primitives/src/app.rs +++ b/book-examples/leptos/primitives/src/app.rs @@ -1,65 +1,68 @@ -use leptos::*; +use leptos::prelude::*; #[component] pub fn App() -> impl IntoView { - let mut views: Vec = vec![]; + let mut views: Vec = vec![]; - #[cfg(feature = "aspect-ratio")] - { - use crate::aspect_ratio::AspectRatioDemo; - views.push(view! { - - }); - } - #[cfg(feature = "avatar")] - { - use crate::avatar::AvatarDemo; - views.push(view! { - - }); - } - #[cfg(feature = "checkbox")] - { - use crate::checkbox::CheckboxDemo; - views.push(view! { - - }); - } + // #[cfg(feature = "aspect-ratio")] + // { + // use crate::aspect_ratio::AspectRatioDemo; + // views.push(view! { + // + // }); + // } + // #[cfg(feature = "avatar")] + // { + // use crate::avatar::AvatarDemo; + // views.push(view! { + // + // }); + // } + // #[cfg(feature = "checkbox")] + // { + // use crate::checkbox::CheckboxDemo; + // views.push(view! { + // + // }); + // } #[cfg(feature = "label")] { use crate::label::LabelDemo; - views.push(view! { - - }); - } - #[cfg(feature = "progress")] - { - use crate::progress::ProgressDemo; - views.push(view! { - - }); - } - #[cfg(feature = "separator")] - { - use crate::separator::SeparatorDemo; - views.push(view! { - - }); - } - #[cfg(feature = "switch")] - { - use crate::switch::SwitchDemo; - views.push(view! { - - }); - } - #[cfg(feature = "toggle")] - { - use crate::toggle::ToggleDemo; - views.push(view! { - - }); + views.push( + view! { + + } + .into_any(), + ); } + // #[cfg(feature = "progress")] + // { + // use crate::progress::ProgressDemo; + // views.push(view! { + // + // }); + // } + // #[cfg(feature = "separator")] + // { + // use crate::separator::SeparatorDemo; + // views.push(view! { + // + // }); + // } + // #[cfg(feature = "switch")] + // { + // use crate::switch::SwitchDemo; + // views.push(view! { + // + // }); + // } + // #[cfg(feature = "toggle")] + // { + // use crate::toggle::ToggleDemo; + // views.push(view! { + // + // }); + // } view! {
diff --git a/book-examples/leptos/primitives/src/label.rs b/book-examples/leptos/primitives/src/label.rs index 1365c757..1295411d 100644 --- a/book-examples/leptos/primitives/src/label.rs +++ b/book-examples/leptos/primitives/src/label.rs @@ -1,11 +1,11 @@ -use leptos::*; +use leptos::prelude::*; use radix_leptos_label::*; #[component] pub fn LabelDemo() -> impl IntoView { view! {
-