public inbox for yew-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Shannon Sterz" <s.sterz@proxmox.com>
To: "Dominik Csapak" <d.csapak@proxmox.com>, <yew-devel@lists.proxmox.com>
Subject: Re: [PATCH yew-widget-toolkit v3] widget: add 'div', 'span' and 'italic' helper functions
Date: Tue, 07 Apr 2026 17:05:18 +0200	[thread overview]
Message-ID: <DHN0KCZRPBZE.3J6696LB3LP68@proxmox.com> (raw)
In-Reply-To: <810066b0-7803-4eb5-9146-84847a6d8e6c@proxmox.com>

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 `<i>` 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 `<em>`
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 <s.sterz@proxmox.com>

> 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 `<span>` and `<i>` 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 <d.csapak@proxmox.com>
>> ---
>>   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 `<div>` element with a single child.
>> +///
>> +/// It's the same as `Container::new().with_child(comp)`
>> +pub fn div(comp: impl Into<Html>) -> Container {
>> +    use crate::props::ContainerBuilder;
>> +    Container::new().with_child(comp)
>> +}
>> +
>> +/// Helper function to create a `<span>` element with a single child.
>> +///
>> +/// It's the same as `Container::from_tag("span").with_child(comp)`
>> +pub fn span(comp: impl Into<Html>) -> Container {
>> +    use crate::props::ContainerBuilder;
>> +    Container::from_tag("span").with_child(comp)
>> +}
>> +
>> +/// Helper function to create an `<i>` element with a single child.
>> +///
>> +/// It's the same as `Container::from_tag("i").with_child(comp)`
>> +pub fn italic(comp: impl Into<Html>) -> 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;





  reply	other threads:[~2026-04-07 15:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-07 13:09 Dominik Csapak
2026-04-07 13:13 ` Dominik Csapak
2026-04-07 15:05   ` Shannon Sterz [this message]
2026-04-08  7:12     ` Dominik Csapak
2026-04-08  7:56       ` Shannon Sterz
2026-04-08  8:58         ` Robert Obkircher
2026-04-08  9:44           ` Dominik Csapak
2026-04-07 17:26 ` Dietmar Maurer
2026-04-08 10:56 ` superseded: " Dominik Csapak

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=DHN0KCZRPBZE.3J6696LB3LP68@proxmox.com \
    --to=s.sterz@proxmox.com \
    --cc=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