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 C53EC1FF142 for ; Tue, 07 Apr 2026 17:05:18 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 9A03F1ED4D; Tue, 7 Apr 2026 17:05:53 +0200 (CEST) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Tue, 07 Apr 2026 17:05:18 +0200 Message-Id: To: "Dominik Csapak" , Subject: Re: [PATCH yew-widget-toolkit v3] widget: add 'div', 'span' and 'italic' helper functions X-Mailer: aerc 0.20.0 References: <20260407130919.3451837-1-d.csapak@proxmox.com> <810066b0-7803-4eb5-9146-84847a6d8e6c@proxmox.com> In-Reply-To: <810066b0-7803-4eb5-9146-84847a6d8e6c@proxmox.com> From: "Shannon Sterz" X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1775574252293 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.124 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 Message-ID-Hash: 4LZ4433MFBQV72BQRIN6PYIMXFML6PMC X-Message-ID-Hash: 4LZ4433MFBQV72BQRIN6PYIMXFML6PMC X-MailFrom: s.sterz@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Yew framework devel list at Proxmox List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Tue Apr 7, 2026 at 3:13 PM CEST, Dominik Csapak wrote: > ah, missed inserting the changelog, so here it is: > > changes from v2: > * use standalone functions instead of macro > * add span/italic too for convenience > * make container mod public one small thing that occured to me is that the `` element no longer is inteded for "italic text", but rather is a semantic element that should be used for "text that is set off from the normal prose for readability reasons" [1]. so it might be more appropriate to use a `span` with italic styling here or we could add helpers for other semantic text elements such as `` etc. too. no hard feelings on my side, though, i don't think this matters all too much. [1]: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/i= #usage_notes but overall, looks good to me, so consider this: Reviewed-by: Shannon Sterz > On 4/7/26 3:08 PM, Dominik Csapak wrote: >> these are just a simple wrapper around the `Container` widget, but it's >> very useful in situations where bare strings are used in a flex layout, >> since e.g. a `Row` with multiple children that are all strings won't get >> a proper flex layout (since they're not elements) >> >> So instead of writing >> ``` >> Row::new() >> .with_child(Container::new().with_child("Text1")) >> .with_child(Container::new().with_child("Text2")) >> ``` >> >> one can now write >> ``` >> Row::new() >> .with_child(div("Text1")) >> .with_child(div("Text2")) >> ``` >> >> which is much shorter and more readable. >> >> In addition to the `div` helper also add a `span` and `italic` helper, >> which correspond to the `` and `` tag respectively. >> >> We have to use the ContainerBuilder trait in the individual functions, >> since a global import in this file here would conflict with the >> `Properties` derive macro. >> >> To expose these functions, simply make the 'container' module public. >> >> Signed-off-by: Dominik Csapak >> --- >> src/widget/container.rs | 24 ++++++++++++++++++++++++ >> src/widget/mod.rs | 2 +- >> 2 files changed, 25 insertions(+), 1 deletion(-) >> >> diff --git a/src/widget/container.rs b/src/widget/container.rs >> index 23d637b..0f5e9b5 100644 >> --- a/src/widget/container.rs >> +++ b/src/widget/container.rs >> @@ -57,3 +57,27 @@ impl IntoVTag for Container { >> ) >> } >> } >> + >> +/// Helper function to create a `
` element with a single child. >> +/// >> +/// It's the same as `Container::new().with_child(comp)` >> +pub fn div(comp: impl Into) -> Container { >> + use crate::props::ContainerBuilder; >> + Container::new().with_child(comp) >> +} >> + >> +/// Helper function to create a `` element with a single child. >> +/// >> +/// It's the same as `Container::from_tag("span").with_child(comp)` >> +pub fn span(comp: impl Into) -> Container { >> + use crate::props::ContainerBuilder; >> + Container::from_tag("span").with_child(comp) >> +} >> + >> +/// Helper function to create an `` element with a single child. >> +/// >> +/// It's the same as `Container::from_tag("i").with_child(comp)` >> +pub fn italic(comp: impl Into) -> Container { >> + use crate::props::ContainerBuilder; >> + Container::from_tag("i").with_child(comp) >> +} >> diff --git a/src/widget/mod.rs b/src/widget/mod.rs >> index 0df2cbf..ff3234a 100644 >> --- a/src/widget/mod.rs >> +++ b/src/widget/mod.rs >> @@ -31,7 +31,7 @@ pub use catalog_loader::PwtCatalogLoader; >> mod column; >> pub use column::Column; >> >> -mod container; >> +pub mod container; >> pub use container::Container; >> >> mod confirm_dialog;