patternfly_yew/utils/
styled.rs1use yew::{html::IntoPropValue, prelude::*, virtual_dom::VNode};
2
3pub struct Styled<T>
5where
6 T: Into<Html>,
7{
8 pub content: T,
9 pub style: Option<AttrValue>,
10}
11
12impl<T> Styled<T>
13where
14 T: Into<Html>,
15{
16 pub fn into_html(self) -> Html {
17 html! (<span style={&self.style}>{ self.content.into() }</span>)
18 }
19}
20
21impl<T> From<Styled<T>> for VNode
22where
23 T: Into<Html>,
24{
25 fn from(value: Styled<T>) -> Self {
26 value.into_html()
27 }
28}
29
30impl<T> IntoPropValue<Html> for Styled<T>
31where
32 T: Into<Html>,
33{
34 fn into_prop_value(self) -> Html {
35 self.into_html()
36 }
37}
38
39impl<T> IntoPropValue<Option<Html>> for Styled<T>
40where
41 T: Into<Html>,
42{
43 fn into_prop_value(self) -> Option<Html> {
44 Some(self.into_html())
45 }
46}