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 095831FF15C for ; Fri, 27 Jun 2025 14:08:30 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 837B913694; Fri, 27 Jun 2025 14:09:06 +0200 (CEST) From: Dominik Csapak To: yew-devel@lists.proxmox.com Date: Fri, 27 Jun 2025 14:08:56 +0200 Message-Id: <20250627120859.3723554-15-d.csapak@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250627120859.3723554-1-d.csapak@proxmox.com> References: <20250627120859.3723554-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 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 08/11] touch: fab: add size option 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" While this can be configured with classes (and the large/small method). It's more ergonomic to have it directly as an enum, especially when we'll want to pass that through in the FabMenu also. Signed-off-by: Dominik Csapak --- src/touch/fab.rs | 37 +++++++++++++++++++++++++++++++++++-- src/touch/mod.rs | 2 +- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/touch/fab.rs b/src/touch/fab.rs index 72637c7..2ae1551 100644 --- a/src/touch/fab.rs +++ b/src/touch/fab.rs @@ -7,6 +7,14 @@ use yew::virtual_dom::{Key, VComp, VNode}; use crate::props::{AsClassesMut, WidgetBuilder}; use crate::widget::Button; +#[derive(Clone, Copy, PartialEq, Eq, Default)] +pub enum FabSize { + Small, + #[default] + Standard, + Large, +} + /// Favorite action button. #[derive(Properties, Clone, PartialEq)] pub struct Fab { @@ -14,6 +22,10 @@ pub struct Fab { #[prop_or_default] pub key: Option, + /// The size of the FAB + #[prop_or_default] + pub size: FabSize, + /// Icon (CSS class). pub icon_class: Classes, @@ -83,16 +95,27 @@ impl Fab { /// Builder style method to add the "pwt-fab-small" class pub fn small(mut self) -> Self { - self.add_class("pwt-fab-small"); + self.size = FabSize::Small; self } /// Builder style method to add the "pwt-fab-large" class pub fn large(mut self) -> Self { - self.add_class("pwt-fab-large"); + self.size = FabSize::Large; + self + } + + /// Builder method to set the FAB size. + pub fn size(mut self, size: FabSize) -> Self { + self.set_size(size); self } + /// Method to set the FAB size. + pub fn set_size(&mut self, size: FabSize) { + self.size = size; + } + /// Builder style method to set the button text pub fn text(mut self, text: impl IntoPropValue>) -> Self { self.set_text(text); @@ -131,6 +154,16 @@ impl Component for PwtFab { let mut class = props.class.clone(); class.push("pwt-fab"); + match props.size { + FabSize::Small => { + class.push("pwt-fab-small"); + } + FabSize::Standard => {} + FabSize::Large => { + class.push("pwt-fab-large"); + } + } + let button = match &props.text { Some(text) => Button::new(text) .icon_class(icon_class) diff --git a/src/touch/mod.rs b/src/touch/mod.rs index 87fcc85..f559689 100644 --- a/src/touch/mod.rs +++ b/src/touch/mod.rs @@ -8,7 +8,7 @@ mod gesture_detector; pub use gesture_detector::{GestureDetector, GestureSwipeEvent, InputEvent, PwtGestureDetector}; mod fab; -pub use fab::{Fab, PwtFab}; +pub use fab::{Fab, FabSize, PwtFab}; mod fab_menu; pub use fab_menu::{FabMenu, FabMenuAlign, FabMenuDirection, PwtFabMenu}; -- 2.39.5 _______________________________________________ yew-devel mailing list yew-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel