Skip to content

Commit f5e6ad4

Browse files
committed
ToHtml has been removed in favor of IntoPropValue<Html>
see yewstack/yew#3453
1 parent e13cff2 commit f5e6ad4

File tree

11 files changed

+31
-42
lines changed

11 files changed

+31
-42
lines changed

src/components/alert.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ pub fn view(props: &GroupProperties) -> Html {
191191
html! (
192192
<ul class={classes} role="list">
193193
{ for props.children.iter().map(|child|
194-
wrapper_elt_with_attributes(child.to_html(), "li", &[("class", "pf-v5-c-alert-group__item", ApplyAttributeAs::Attribute)])
194+
wrapper_elt_with_attributes(child.into(), "li", &[("class", "pf-v5-c-alert-group__item", ApplyAttributeAs::Attribute)])
195195
)}
196196
</ul>
197197
)

src/components/chip_group.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub fn chip_group(props: &ChipGroupProperties) -> Html {
4444
aria-hidden="true"
4545
id={format!("{id}-label")}
4646
>
47-
{ &label }
47+
{ label }
4848
</span>
4949
}
5050
<ul
@@ -54,7 +54,7 @@ pub fn chip_group(props: &ChipGroupProperties) -> Html {
5454
aria-labelledby={aria_labelled_by}
5555
>
5656
{ for props.children.iter().map(|chip| {
57-
wrapper_elt_with_attributes(chip.to_html(), "li", &[("class", "pf-v5-c-chip-group__list-item", ApplyAttributeAs::Attribute)])
57+
wrapper_elt_with_attributes(chip.into(), "li", &[("class", "pf-v5-c-chip-group__list-item", ApplyAttributeAs::Attribute)])
5858
})}
5959
</ul>
6060
</div>

src/components/dual_list_selector/item_renderer.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,15 @@
22
33
use core::fmt::Debug;
44

5+
use yew::html::IntoPropValue;
56
use yew::prelude::*;
67

7-
pub trait DualListSelectorItemRenderer: Debug + Clone + PartialEq + ToHtml + 'static {}
8+
pub trait DualListSelectorItemRenderer:
9+
Debug + Clone + PartialEq + IntoPropValue<Html> + 'static
10+
{
11+
}
812

9-
impl<T: ToHtml + Debug + Clone + PartialEq + 'static> DualListSelectorItemRenderer for T {}
13+
impl<T: IntoPropValue<Html> + Debug + Clone + PartialEq + 'static> DualListSelectorItemRenderer
14+
for T
15+
{
16+
}

src/components/dual_list_selector/list/list_inner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub fn list<T: ItemRenderer>(props: &DualListSelectorListProps) -> Html {
3939
let is_selected = context.selected_options.contains(&key);
4040
html_nested! {
4141
<DualListSelectorListItem key={key} {onoptionselect} {is_selected} disabled={context.disabled}>
42-
{ option.to_html() }
42+
{ option.clone() }
4343
</DualListSelectorListItem>
4444
}
4545
})}

src/components/search_input/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use crate::components::input_group::*;
66
use crate::components::text_input_group::*;
77
use crate::icon::Icon;
88
use crate::utils::HtmlElementSupport;
9+
use yew::html::IntoPropValue;
910
use yew::prelude::*;
1011
use yew_hooks::use_event_with_window;
1112

@@ -18,8 +19,8 @@ pub enum ResultsCount {
1819
Fraction(usize, usize),
1920
}
2021

21-
impl ToHtml for ResultsCount {
22-
fn to_html(&self) -> Html {
22+
impl IntoPropValue<Html> for ResultsCount {
23+
fn into_prop_value(self) -> Html {
2324
match self {
2425
Self::Absolute(i) => html!(i),
2526
Self::Fraction(i, j) => html!(format!("{i}/{j}")),
@@ -301,7 +302,7 @@ fn inner_text_input_group(props: &InnerTextInputGroupProps) -> Html {
301302
|| (props.props.onnextclick.is_some() && props.props.onpreviousclick.is_some())
302303
|| (props.props.onclear.is_some() && props.props.expandable.is_none()));
303304
let badge = if let Some(results_count) = &props.props.results_count {
304-
html! { <Badge read=true>{results_count}</Badge> }
305+
html! { <Badge read=true>{results_count.clone()}</Badge> }
305306
} else {
306307
html! {}
307308
};

src/components/table/column.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,17 +162,15 @@ where
162162
}
163163
>
164164
<div class="pf-v5-c-table__button-content">
165-
<span class="pf-v5-c-table__text">{ &label }</span>
165+
<span class="pf-v5-c-table__text">{ label }</span>
166166
<span class="pf-v5-c-table__sort-indicator">
167167
{sort_by_next_status.0}
168168
</span>
169169
</div>
170170
</button>
171171
)
172172
} else {
173-
html_nested!(
174-
<>{ &label }</>
175-
)
173+
html_nested!({ label.into() })
176174
};
177175

178176
html!(

src/components/tabs/router.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ where
138138
data-ouia-safe={props.ouia_safe}
139139
>
140140
<Link<T> element="button" class={link_classes} to={props.to.clone()}>
141-
<span class="pf-v5-c-tabs__item-text"> { &props.title } </span>
141+
<span class="pf-v5-c-tabs__item-text"> { props.title.clone() } </span>
142142
</Link<T>>
143143
</li>
144144
)

src/components/tabs/simple.rs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ where
173173
index={c.props.index.clone()}
174174
{onselect}
175175
>
176-
{ c.props.title.to_html() }
176+
{ c.props.title.clone() }
177177
</TabHeaderItem<T>>
178178
)
179179
}) }
@@ -312,23 +312,13 @@ impl IntoPropValue<TabTitle> for Html {
312312
}
313313
}
314314

315-
impl ToHtml for TabTitle {
316-
fn to_html(&self) -> Html {
315+
impl IntoPropValue<Html> for TabTitle {
316+
fn into_prop_value(self) -> Html {
317317
match self {
318318
TabTitle::String(s) => s.into(),
319319
TabTitle::Html(html) => html.clone(),
320320
}
321321
}
322-
323-
fn into_html(self) -> Html
324-
where
325-
Self: Sized,
326-
{
327-
match self {
328-
TabTitle::String(s) => s.into(),
329-
TabTitle::Html(html) => html,
330-
}
331-
}
332322
}
333323

334324
/// Properties for [`Tab`]

src/components/truncate.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,11 @@ pub fn truncate(props: &TruncateProperties) -> Html {
146146
{
147147
match &props.content {
148148
TruncateContent::Default(value) => html!(
149-
<span class={start_class}>{ &value }</span>
149+
<span class={start_class}>{ value }</span>
150150
),
151151
TruncateContent::Middle(start, end) => html!(<>
152-
<span class={start_class}>{ &start }</span>
153-
<span class={end_class}>{ &end }</span>
152+
<span class={start_class}>{ start }</span>
153+
<span class={end_class}>{ end }</span>
154154
</>),
155155
TruncateContent::Start(value) => html!(<>
156156
<span class={end_class}>{ &value }{ "\u{200E}" }</span>

src/core/content.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,9 @@ impl DerefMut for OptionalHtml {
2020
}
2121
}
2222

23-
impl ToHtml for OptionalHtml {
24-
fn to_html(&self) -> Html {
25-
self.0.to_html()
26-
}
27-
28-
fn into_html(self) -> Html
29-
where
30-
Self: Sized,
31-
{
32-
self.0.into_html()
23+
impl IntoPropValue<Option<Html>> for OptionalHtml {
24+
fn into_prop_value(self) -> Option<Html> {
25+
self.0
3326
}
3427
}
3528

0 commit comments

Comments
 (0)