From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 042181FF191 for ; Tue, 23 Sep 2025 11:51:30 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id EAA629F46; Tue, 23 Sep 2025 11:51:58 +0200 (CEST) From: Dominik Csapak To: pdm-devel@lists.proxmox.com Date: Tue, 23 Sep 2025 11:51:05 +0200 Message-ID: <20250923095124.1679038-3-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250923095124.1679038-1-d.csapak@proxmox.com> References: <20250923095124.1679038-1-d.csapak@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.026 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: [pdm-devel] [PATCH yew-comp 2/8] status row: add option to add the icon on the right side X-BeenThere: pdm-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Datacenter Manager development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pdm-devel-bounces@lists.proxmox.com Sender: "pdm-devel" This is sometimes better than showing it always on the left side. Signed-off-by: Dominik Csapak --- src/status_row.rs | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/src/status_row.rs b/src/status_row.rs index fe64127..8eda9b7 100644 --- a/src/status_row.rs +++ b/src/status_row.rs @@ -15,6 +15,9 @@ pub struct StatusRow { #[prop_or_default] pub status: Option, + + #[prop_or_default] + pub icon_right: bool, } impl StatusRow { @@ -41,6 +44,17 @@ impl StatusRow { self.status = Some(status.into()); self } + + /// Method to control which side the icon should go on. + pub fn set_icon_right(&mut self, icon_right: impl Into) { + self.icon_right = icon_right.into(); + } + + /// Builder style method to control which side the icon should go on. + pub fn icon_right(mut self, icon_right: impl Into) -> Self { + self.set_icon_right(icon_right); + self + } } #[doc(hidden)] @@ -57,11 +71,17 @@ impl Component for ProxmoxStatusRow { fn view(&self, ctx: &Context) -> Html { let props = ctx.props(); - let icon = props.icon_class.as_ref().map(|icon_class| { - Container::from_tag("i") - .class(icon_class.clone()) - .padding_end(2) - }); + let (left_icon, right_icon) = match &props.icon_class { + Some(icon_class) => { + let icon = Container::from_tag("i").class(icon_class.clone()); + if props.icon_right { + (None, Some(icon)) + } else { + (Some(icon), None) + } + } + None => (None, None), + }; let status = match &props.status { Some(text) => text.clone(), @@ -73,11 +93,11 @@ impl Component for ProxmoxStatusRow { .class(Display::Flex) // we need to set this again .listeners(&props.listeners) .gap(2) - .with_child( - html! {
{icon}{props.title.clone()}
}, - ) + .with_optional_child(left_icon) + .with_child(html! {
{props.title.clone()}
}) .with_flex_spacer() .with_child(html! {
{status}
}) + .with_optional_child(right_icon) .into() } } -- 2.47.3 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel