Skip to main content

email_components/components/
button.rs

1use stylist::yew::use_style;
2use yew::{AttrValue, Classes, Html, Properties, classes, function_component, html};
3
4#[derive(Properties, PartialEq)]
5pub struct Props {
6    #[prop_or(AttrValue::Static("_blank"))]
7    pub target: AttrValue,
8
9    #[prop_or_default]
10    pub class: Classes,
11    pub children: Html,
12}
13
14#[function_component]
15pub fn Button(props: &Props) -> Html {
16    let Props {
17        target,
18        class,
19        children,
20    } = props;
21
22    let default = use_style!(
23        "
24        line-height: 100%;
25        text-decoration: none;
26        display: inline-block;
27        max-width: 100%;
28        mso-padding-alt: 0px;
29    "
30    );
31
32    html! {
33        <a
34            target={target}
35            class={classes!(
36                default,
37                class.clone(),
38            )}
39        >
40            <span
41                style="
42                    max-width: 100%;
43                    display: inline-block;
44                    line-height: 120%;
45                    mso-padding-alt: 0px
46                "
47            >
48                { children.clone() }
49            </span>
50        </a>
51    }
52}