From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 281461FF187 for ; Mon, 30 Jun 2025 10:35:02 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A022716783; Mon, 30 Jun 2025 10:35:40 +0200 (CEST) From: Dominik Csapak To: yew-devel@lists.proxmox.com Date: Mon, 30 Jun 2025 10:25:08 +0200 Message-Id: <20250630082509.1202308-19-d.csapak@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250630082509.1202308-1-d.csapak@proxmox.com> References: <20250630082509.1202308-1-d.csapak@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.022 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [yew-devel] [PATCH yew-widget-toolkit v2 11/12] touch: fab menu: convert to widget macro X-BeenThere: yew-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Yew framework devel list at Proxmox List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Yew framework devel list at Proxmox Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: yew-devel-bounces@lists.proxmox.com Sender: "yew-devel" This does many things we did here manually. Signed-off-by: Dominik Csapak --- src/touch/fab_menu.rs | 57 ++++++------------------------------------- 1 file changed, 8 insertions(+), 49 deletions(-) diff --git a/src/touch/fab_menu.rs b/src/touch/fab_menu.rs index 4ad1234..92f2331 100644 --- a/src/touch/fab_menu.rs +++ b/src/touch/fab_menu.rs @@ -1,12 +1,10 @@ -use std::rc::Rc; - -use yew::html::IntoPropValue; use yew::prelude::*; -use yew::virtual_dom::{Key, VComp, VNode}; use crate::props::{ContainerBuilder, EventSubscriber, WidgetBuilder}; use crate::widget::Container; +use pwt_macros::{builder, widget}; + use super::Fab; /// [FabMenu] direction. @@ -27,12 +25,10 @@ pub enum FabMenuAlign { } /// Favorite actions button Menu. +#[widget(pwt=crate, comp=PwtFabMenu, @element)] #[derive(Properties, Clone, PartialEq)] +#[builder] pub struct FabMenu { - /// The yew component key. - #[prop_or_default] - pub key: Option, - /// Main button Icon (CSS class). #[prop_or_default] pub main_icon_class: Option, @@ -43,11 +39,13 @@ pub struct FabMenu { /// Menu popup direction #[prop_or(FabMenuDirection::Up)] + #[builder] pub direction: FabMenuDirection, /// Menu alignment /// #[prop_or(FabMenuAlign::Center)] + #[builder] pub align: FabMenuAlign, /// Child buttons, which popup when main button is pressed. @@ -69,17 +67,6 @@ impl FabMenu { yew::props!(Self {}) } - /// Builder style method to set the yew `key` property - pub fn key(mut self, key: impl IntoPropValue>) -> Self { - self.set_key(key); - self - } - - /// Method to set the yew `key` property - pub fn set_key(&mut self, key: impl IntoPropValue>) { - self.key = key.into_prop_value(); - } - /// Builder style method to set the icon class for the main button. pub fn main_icon_class(mut self, class: impl Into) -> Self { self.set_main_icon_class(class); @@ -106,28 +93,6 @@ impl FabMenu { } } - /// Builder style method to set the popup alignment - pub fn align(mut self, align: FabMenuAlign) -> Self { - self.set_align(align); - self - } - - /// Method to set the popup alignment - pub fn set_align(&mut self, align: FabMenuAlign) { - self.align = align; - } - - /// Builder style method to set the popup direction - pub fn direction(mut self, direction: FabMenuDirection) -> Self { - self.set_direction(direction); - self - } - - /// Method to set the popup direction - pub fn set_direction(&mut self, direction: FabMenuDirection) { - self.direction = direction; - } - /// Builder style method to add a child button pub fn with_child(mut self, child: impl Into) -> Self { self.add_child(child); @@ -180,6 +145,8 @@ impl Component for PwtFabMenu { }; let mut container = Container::new() + .with_std_props(&props.std_props) + .listeners(&props.listeners) .class("pwt-fab-menu-container") .class(match props.align { FabMenuAlign::Start => Some("pwt-fab-align-start"), @@ -232,11 +199,3 @@ impl Component for PwtFabMenu { container.into() } } - -impl From for VNode { - fn from(val: FabMenu) -> Self { - let key = val.key.clone(); - let comp = VComp::new::(Rc::new(val), key); - VNode::from(comp) - } -} -- 2.39.5 _______________________________________________ yew-devel mailing list yew-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel