From fe9d15f3ebe8ee91ddd67069017c7af37c856b8b Mon Sep 17 00:00:00 2001 From: Alexander Baranov Date: Sat, 23 May 2026 14:10:41 +0300 Subject: [PATCH] =?UTF-8?q?smart-house-web:=20leptos=20=D1=8D=D1=81=D0=BF?= =?UTF-8?q?=D0=B5=D1=80=D0=B8=D0=BC=D0=B5=D0=BD=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- smart-house-web/frontend/index.html | 8 +++- smart-house-web/frontend/src/main.rs | 64 ++++++++++++++++++++++++++-- 2 files changed, 68 insertions(+), 4 deletions(-) diff --git a/smart-house-web/frontend/index.html b/smart-house-web/frontend/index.html index 7f2ad66..a0829bb 100644 --- a/smart-house-web/frontend/index.html +++ b/smart-house-web/frontend/index.html @@ -1,5 +1,11 @@ - + + + diff --git a/smart-house-web/frontend/src/main.rs b/smart-house-web/frontend/src/main.rs index c0cfc82..86338a8 100644 --- a/smart-house-web/frontend/src/main.rs +++ b/smart-house-web/frontend/src/main.rs @@ -1,6 +1,64 @@ use leptos::prelude::*; -fn main() { - console_error_panic_hook::set_once(); - leptos::mount::mount_to_body(|| view! {

"Hello, world!"

}) +#[allow(non_snake_case)] +// Composing different components together is how we build +// user interfaces. Here, we'll define a reusable . +// You'll see how doc comments can be used to document components +// and their properties. + +/// Shows progress toward a goal. +#[component] +fn ProgressBar( + // Marks this as an optional prop. It will default to the default + // value of its type, i.e., 0. + #[prop(default = 100)] + /// The maximum value of the progress bar. + max: u16, + // Will run `.into()` on the value passed into the prop. + #[prop(into)] + // `Signal` is a wrapper for several reactive types. + // It can be helpful in component APIs like this, where we + // might want to take any kind of reactive value + /// How much progress should be displayed. + progress: Signal, +) -> impl IntoView { + view! { + +
+ } +} + +#[component] +fn App() -> impl IntoView { + let (count, set_count) = signal(0); + + let double_count = move || count.get() * 2; + + view! { + +
+ // If you have this open in CodeSandbox or an editor with + // rust-analyzer support, try hovering over `ProgressBar`, + // `max`, or `progress` to see the docs we defined above + + // Let's use the default max value on this one + // the default is 100, so it should move half as fast + + // Signal::derive creates a Signal wrapper from our derived signal + // using double_count means it should move twice as fast + + } +} + +fn main() { + leptos::mount::mount_to_body(App) }