You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.2 KiB
59 lines
1.2 KiB
use crate::prelude::*; |
|
use yew::{html::Children, prelude::*}; |
|
|
|
pub struct CardText { |
|
props: Props, |
|
} |
|
|
|
#[derive(Properties, Clone, PartialEq)] |
|
pub struct Props { |
|
#[prop_or_default] |
|
pub class: String, |
|
#[prop_or_default] |
|
pub style: String, |
|
#[prop_or_default] |
|
pub children: Children, |
|
} |
|
|
|
impl Component for CardText { |
|
type Properties = Props; |
|
type Message = (); |
|
|
|
fn create(props: Self::Properties, _: ComponentLink<Self>) -> Self { |
|
Self { props } |
|
} |
|
|
|
fn update(&mut self, _: Self::Message) -> ShouldRender { |
|
false |
|
} |
|
|
|
fn change(&mut self, props: Self::Properties) -> ShouldRender { |
|
render_on_change(&mut self.props, props) |
|
} |
|
|
|
fn view(&self) -> Html { |
|
html! { |
|
<p class=self.class() style=self.style()> |
|
{ self.props.children.render() } |
|
</p> |
|
} |
|
} |
|
} |
|
|
|
impl CardText { |
|
fn class(&self) -> String { |
|
if self.props.class.is_empty() { |
|
"card-text".into() |
|
} else { |
|
format!("card-text {}", self.props.class) |
|
} |
|
} |
|
|
|
fn style(&self) -> &str { |
|
if self.props.style.is_empty() { |
|
"" |
|
} else { |
|
&self.props.style |
|
} |
|
} |
|
}
|
|
|