public inbox for yew-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: yew-devel@lists.proxmox.com
Subject: [yew-devel] [PATCH yew-widget-toolkit v2 09/12] touch: fab: add size option
Date: Mon, 30 Jun 2025 10:25:06 +0200	[thread overview]
Message-ID: <20250630082509.1202308-17-d.csapak@proxmox.com> (raw)
In-Reply-To: <20250630082509.1202308-1-d.csapak@proxmox.com>

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 <d.csapak@proxmox.com>
---
 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<Key>,
 
+    /// 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<Option<AttrValue>>) -> 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


  parent reply	other threads:[~2025-06-30  8:25 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-30  8:24 [yew-devel] [PATCH yew-widget-toolkit/yew-widget-toolkit-assets v2 00/19] various touch improvements Dominik Csapak
2025-06-30  8:24 ` [yew-devel] [PATCH yew-widget-toolkit-assets v2 1/7] reset: remove the tap highlight color for chrome Dominik Csapak
2025-06-30  8:24 ` [yew-devel] [PATCH yew-widget-toolkit-assets v2 2/7] page: add more page animation styles Dominik Csapak
2025-06-30  8:24 ` [yew-devel] [PATCH yew-widget-toolkit-assets v2 3/7] page: animations: reverse the direction on X axis for RTL mode Dominik Csapak
2025-06-30  8:24 ` [yew-devel] [PATCH yew-widget-toolkit-assets v2 4/7] application bar: reduce horizontal padding Dominik Csapak
2025-06-30  8:24 ` [yew-devel] [PATCH yew-widget-toolkit-assets v2 5/7] application bar: reverse back arrow for rtl Dominik Csapak
2025-06-30  8:24 ` [yew-devel] [PATCH yew-widget-toolkit-assets v2 6/7] buttons: rework fab menu Dominik Csapak
2025-06-30  8:24 ` [yew-devel] [PATCH yew-widget-toolkit-assets v2 7/7] don't use 'html[dir="rtl"]' for RTL behavior Dominik Csapak
2025-06-30  8:24 ` [yew-devel] [PATCH yew-widget-toolkit v2 01/12] widget: implement Image widget Dominik Csapak
2025-06-30  8:24 ` [yew-devel] [PATCH yew-widget-toolkit v2 02/12] widget: button: don't hardcode icons font size Dominik Csapak
2025-06-30  8:25 ` [yew-devel] [PATCH yew-widget-toolkit v2 03/12] touch: page stack: add more animations Dominik Csapak
2025-06-30  8:25 ` [yew-devel] [PATCH yew-widget-toolkit v2 04/12] touch: application bar: set custom class on back button Dominik Csapak
2025-06-30  8:25 ` [yew-devel] [PATCH yew-widget-toolkit v2 05/12] touch: page stack: don't use animation by default Dominik Csapak
2025-06-30  8:25 ` [yew-devel] [PATCH yew-widget-toolkit v2 06/12] touch: material app: allow pass through of page animation style Dominik Csapak
2025-06-30  8:25 ` [yew-devel] [PATCH yew-widget-toolkit v2 07/12] touch: scaffold: fix overflow setting for body Dominik Csapak
2025-06-30  8:25 ` [yew-devel] [PATCH yew-widget-toolkit v2 08/12] touch: scaffold: use direction independent positioning for the FAB Dominik Csapak
2025-06-30  8:25 ` Dominik Csapak [this message]
2025-06-30  8:25 ` [yew-devel] [PATCH yew-widget-toolkit v2 10/12] touch: fab: convert to widget macro Dominik Csapak
2025-06-30  8:25 ` [yew-devel] [PATCH yew-widget-toolkit v2 11/12] touch: fab menu: " Dominik Csapak
2025-06-30  8:25 ` [yew-devel] [PATCH yew-widget-toolkit v2 12/12] touch: fab menu: rework fab menu Dominik Csapak
2025-06-30 10:56 ` [yew-devel] applied: [PATCH yew-widget-toolkit/yew-widget-toolkit-assets v2 00/19] various touch improvements Dietmar Maurer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250630082509.1202308-17-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=yew-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal