all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH yew-widget-toolkit v3] widget: add 'div', 'span' and 'italic' helper functions
@ 2026-04-07 13:09 Dominik Csapak
  2026-04-07 13:13 ` Dominik Csapak
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Dominik Csapak @ 2026-04-07 13:09 UTC (permalink / raw)
  To: yew-devel

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;
-- 
2.47.3





^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH yew-widget-toolkit v3] widget: add 'div', 'span' and 'italic' helper functions
  2026-04-07 13:09 [PATCH yew-widget-toolkit v3] widget: add 'div', 'span' and 'italic' helper functions Dominik Csapak
@ 2026-04-07 13:13 ` Dominik Csapak
  2026-04-07 15:05   ` Shannon Sterz
  2026-04-07 17:26 ` Dietmar Maurer
  2026-04-08 10:56 ` superseded: " Dominik Csapak
  2 siblings, 1 reply; 9+ messages in thread
From: Dominik Csapak @ 2026-04-07 13:13 UTC (permalink / raw)
  To: yew-devel

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

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;





^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH yew-widget-toolkit v3] widget: add 'div', 'span' and 'italic' helper functions
  2026-04-07 13:13 ` Dominik Csapak
@ 2026-04-07 15:05   ` Shannon Sterz
  2026-04-08  7:12     ` Dominik Csapak
  0 siblings, 1 reply; 9+ messages in thread
From: Shannon Sterz @ 2026-04-07 15:05 UTC (permalink / raw)
  To: Dominik Csapak, yew-devel

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;





^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH yew-widget-toolkit v3] widget: add 'div', 'span' and 'italic' helper functions
  2026-04-07 13:09 [PATCH yew-widget-toolkit v3] widget: add 'div', 'span' and 'italic' helper functions Dominik Csapak
  2026-04-07 13:13 ` Dominik Csapak
@ 2026-04-07 17:26 ` Dietmar Maurer
  2026-04-08 10:56 ` superseded: " Dominik Csapak
  2 siblings, 0 replies; 9+ messages in thread
From: Dietmar Maurer @ 2026-04-07 17:26 UTC (permalink / raw)
  To: Dominik Csapak; +Cc: yew-devel

[-- Attachment #1: Type: text/plain, Size: 3179 bytes --]

italic() is IMHO very missleading ...
On Tuesday, 04/07/2026, 15:09, Dominik Csapak <d.csapak@proxmox.com> wrote:

>From : Dominik Csapak <d.csapak@proxmox.com>
Sent on : Tuesday, 04/07/2026, 15:09
To : yew-devel@lists.proxmox.com
Subject : [PATCH yew-widget-toolkit v3] widget: add 'div', 'span' and 'italic' helper functions
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 [http://container.rs/] | 24 ++++++++++++++++++++++++
 src/widget/mod.rs [http://mod.rs/]       |  2 +-
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/src/widget/container.rs [http://container.rs/] b/src/widget/container.rs [http://container.rs/]
index 23d637b..0f5e9b5 100644
--- a/src/widget/container.rs [http://container.rs/]
+++ b/src/widget/container.rs [http://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 [http://mod.rs/] b/src/widget/mod.rs [http://mod.rs/]
index 0df2cbf..ff3234a 100644
--- a/src/widget/mod.rs [http://mod.rs/]
+++ b/src/widget/mod.rs [http://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;
-- 
2.47.3







[-- Attachment #2: Type: text/html, Size: 4488 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH yew-widget-toolkit v3] widget: add 'div', 'span' and 'italic' helper functions
  2026-04-07 15:05   ` Shannon Sterz
@ 2026-04-08  7:12     ` Dominik Csapak
  2026-04-08  7:56       ` Shannon Sterz
  0 siblings, 1 reply; 9+ messages in thread
From: Dominik Csapak @ 2026-04-08  7:12 UTC (permalink / raw)
  To: Shannon Sterz, yew-devel, Dietmar Maurer



On 4/7/26 7:25 PM, Dietmar Maurer wrote:
> italic() is IMHO very missleading ...

On 4/7/26 5:04 PM, Shannon Sterz wrote:
> 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:
> 


i actually didn't want to express the italic styling here, but wanted
to have the 'i' tag (since we use that often for icons and so on),
but didn't come up with a better name than 'italic'. I also didn't want
to add a single-letter function.

does any of you have a better idea ?

mdn calls it the "Idiomatic Text element" but 'idiomatic()' also does
not really convey what it does.

I can of course leave it out for now and we can decide later.

> 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;
> 





^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH yew-widget-toolkit v3] widget: add 'div', 'span' and 'italic' helper functions
  2026-04-08  7:12     ` Dominik Csapak
@ 2026-04-08  7:56       ` Shannon Sterz
  2026-04-08  8:58         ` Robert Obkircher
  0 siblings, 1 reply; 9+ messages in thread
From: Shannon Sterz @ 2026-04-08  7:56 UTC (permalink / raw)
  To: Dominik Csapak, yew-devel, Dietmar Maurer

On Wed Apr 8, 2026 at 9:12 AM CEST, Dominik Csapak wrote:
>
>
> On 4/7/26 7:25 PM, Dietmar Maurer wrote:
>> italic() is IMHO very missleading ...
>
> On 4/7/26 5:04 PM, Shannon Sterz wrote:
>> 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:
>>
>
>
> i actually didn't want to express the italic styling here, but wanted
> to have the 'i' tag (since we use that often for icons and so on),
> but didn't come up with a better name than 'italic'. I also didn't want
> to add a single-letter function.
>
> does any of you have a better idea ?
>
> mdn calls it the "Idiomatic Text element" but 'idiomatic()' also does
> not really convey what it does.
>
> I can of course leave it out for now and we can decide later.

just to put a couple of ideas out there: keeping with the rest of the
functions here would be `i()`, but that might be a bit too short.

we could maybe have a naming convention for wrapper helpers like this
like `i_element()`, `span_element()`, and `div_element()` (alternatively
replace `element` with `container` or `wrapper`). that feels a bit
unnecessarily verbose, though.

if the intention is for this to mostly be used with icons, maybe that is
best handled separately? for example, with an `Icon` component that
takes the appropriate icon classes. somewhat analogous to `ActionIcon`
except without the interactive component.

--> snip <--




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH yew-widget-toolkit v3] widget: add 'div', 'span' and 'italic' helper functions
  2026-04-08  7:56       ` Shannon Sterz
@ 2026-04-08  8:58         ` Robert Obkircher
  2026-04-08  9:44           ` Dominik Csapak
  0 siblings, 1 reply; 9+ messages in thread
From: Robert Obkircher @ 2026-04-08  8:58 UTC (permalink / raw)
  To: Shannon Sterz, Dominik Csapak, yew-devel, Dietmar Maurer


On 08.04.26 09:55, Shannon Sterz wrote:
> On Wed Apr 8, 2026 at 9:12 AM CEST, Dominik Csapak wrote:
>>
>> On 4/7/26 7:25 PM, Dietmar Maurer wrote:
>>> italic() is IMHO very missleading ...
>> On 4/7/26 5:04 PM, Shannon Sterz wrote:
>>> 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:
>>>
>>
>> i actually didn't want to express the italic styling here, but wanted
>> to have the 'i' tag (since we use that often for icons and so on),
>> but didn't come up with a better name than 'italic'. I also didn't want
>> to add a single-letter function.
>>
>> does any of you have a better idea ?
>>
>> mdn calls it the "Idiomatic Text element" but 'idiomatic()' also does
>> not really convey what it does.
>>
>> I can of course leave it out for now and we can decide later.
> just to put a couple of ideas out there: keeping with the rest of the
> functions here would be `i()`, but that might be a bit too short.
>
> we could maybe have a naming convention for wrapper helpers like this
> like `i_element()`, `span_element()`, and `div_element()` (alternatively
> replace `element` with `container` or `wrapper`). that feels a bit
> unnecessarily verbose, though.
Or a module like `tag::i` to let the caller decide whether the
function should be imported directly.
> if the intention is for this to mostly be used with icons, maybe that is
> best handled separately? for example, with an `Icon` component that
> takes the appropriate icon classes. somewhat analogous to `ActionIcon`
> except without the interactive component.
>
> --> snip <--
>
>
>
>




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH yew-widget-toolkit v3] widget: add 'div', 'span' and 'italic' helper functions
  2026-04-08  8:58         ` Robert Obkircher
@ 2026-04-08  9:44           ` Dominik Csapak
  0 siblings, 0 replies; 9+ messages in thread
From: Dominik Csapak @ 2026-04-08  9:44 UTC (permalink / raw)
  To: Robert Obkircher, Shannon Sterz, yew-devel, Dietmar Maurer



On 4/8/26 10:57 AM, Robert Obkircher wrote:
> 
> On 08.04.26 09:55, Shannon Sterz wrote:
>> On Wed Apr 8, 2026 at 9:12 AM CEST, Dominik Csapak wrote:
>>>
>>> On 4/7/26 7:25 PM, Dietmar Maurer wrote:
>>>> italic() is IMHO very missleading ...
>>> On 4/7/26 5:04 PM, Shannon Sterz wrote:
>>>> 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:
>>>>
>>>
>>> i actually didn't want to express the italic styling here, but wanted
>>> to have the 'i' tag (since we use that often for icons and so on),
>>> but didn't come up with a better name than 'italic'. I also didn't want
>>> to add a single-letter function.
>>>
>>> does any of you have a better idea ?
>>>
>>> mdn calls it the "Idiomatic Text element" but 'idiomatic()' also does
>>> not really convey what it does.
>>>
>>> I can of course leave it out for now and we can decide later.
>> just to put a couple of ideas out there: keeping with the rest of the
>> functions here would be `i()`, but that might be a bit too short.
>>
>> we could maybe have a naming convention for wrapper helpers like this
>> like `i_element()`, `span_element()`, and `div_element()` (alternatively
>> replace `element` with `container` or `wrapper`). that feels a bit
>> unnecessarily verbose, though.
> Or a module like `tag::i` to let the caller decide whether the
> function should be imported directly.
>> if the intention is for this to mostly be used with icons, maybe that is
>> best handled separately? for example, with an `Icon` component that
>> takes the appropriate icon classes. somewhat analogous to `ActionIcon`
>> except without the interactive component.
>>
>> --> snip <--
>>
>>
>>
>>

I think I'll simply leave the i tag out for now. It's not necessary,
and we could use our 'Fa' for most of the icons.

i'll send a v4




^ permalink raw reply	[flat|nested] 9+ messages in thread

* superseded: [PATCH yew-widget-toolkit v3] widget: add 'div', 'span' and 'italic' helper functions
  2026-04-07 13:09 [PATCH yew-widget-toolkit v3] widget: add 'div', 'span' and 'italic' helper functions Dominik Csapak
  2026-04-07 13:13 ` Dominik Csapak
  2026-04-07 17:26 ` Dietmar Maurer
@ 2026-04-08 10:56 ` Dominik Csapak
  2 siblings, 0 replies; 9+ messages in thread
From: Dominik Csapak @ 2026-04-08 10:56 UTC (permalink / raw)
  To: yew-devel

superseded by v4:
https://lore.proxmox.com/yew-devel/20260408100408.1274308-1-d.csapak@proxmox.com/T/#u

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;





^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-04-08 10:56 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-04-07 13:09 [PATCH yew-widget-toolkit v3] widget: add 'div', 'span' and 'italic' helper functions Dominik Csapak
2026-04-07 13:13 ` Dominik Csapak
2026-04-07 15:05   ` Shannon Sterz
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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal