From ffd48e4cdbb0e0892a4b67d0bbdafb4b37569540 Mon Sep 17 00:00:00 2001 From: Alexander Baranov Date: Sun, 24 May 2026 11:39:21 +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/src/main.rs | 145 +++++++++++++++++++-------- 1 file changed, 105 insertions(+), 40 deletions(-) diff --git a/smart-house-web/frontend/src/main.rs b/smart-house-web/frontend/src/main.rs index d7c5702..57c11e5 100644 --- a/smart-house-web/frontend/src/main.rs +++ b/smart-house-web/frontend/src/main.rs @@ -1,49 +1,114 @@ #![allow(non_snake_case)] -use leptos::prelude::*; + +use leptos::{ev::MouseEvent, prelude::*}; + +// This highlights four different ways that child components can communicate +// with their parent: +// 1) : passing a WriteSignal as one of the child component props, +// for the child component to write into and the parent to read +// 2) : passing a closure as one of the child component props, for +// the child component to call +// 3) : adding an `on:` event listener to a component +// 4) : providing a context that is used in the component (rather than prop drilling) + +#[derive(Copy, Clone)] +struct SmallcapsContext(WriteSignal); #[component] -fn App() -> impl IntoView { - let (value, set_value) = signal(Ok(0)); +pub fn App() -> impl IntoView { + // just some signals to toggle four classes on our

+ let (red, set_red) = signal(false); + let (right, set_right) = signal(false); + let (italics, set_italics) = signal(false); + let (smallcaps, set_smallcaps) = signal(false); + + // the newtype pattern isn't *necessary* here but is a good practice + // it avoids confusion with other possible future `WriteSignal` contexts + // and makes it easier to refer to it in ButtonD + provide_context(SmallcapsContext(set_smallcaps)); view! { -

"Error Handling"

-