use crate::{use_theme, Ripple};
use dioxus::prelude::*;
#[component]
pub fn Button(
onpress: EventHandler<Event<MouseData>>,
children: Element,
background_color: Option<String>,
border_radius: Option<String>,
height: Option<String>,
) -> Element {
let theme = use_theme();
let background_color = background_color.as_deref().unwrap_or(&theme.primary_color);
let border_radius = border_radius
.as_deref()
.unwrap_or(&theme.border_radius_medium);
let height = height.as_deref().unwrap_or("50px");
rsx!(
div {
display: "inline-block",
position: "relative",
height: "{height}",
line_height: "{height}",
color: "#fff",
background: "{background_color}",
border_radius: "{border_radius}",
overflow: "hidden",
cursor: "pointer",
Ripple { onclick: move |event| onpress.call(event),
div {
position: "relative",
z_index: 9,
padding: "0 25px",
font_family: "sans-serif",
user_select: "none",
webkit_user_select: "none",
{children}
}
}
}
)
}
#[component]
pub fn TextButton(
onpress: EventHandler<Event<MouseData>>,
children: Element,
border_radius: Option<String>,
color: Option<String>,
height: Option<String>,
) -> Element {
let theme = use_theme();
let color = color.as_deref().unwrap_or(&theme.primary_color);
let border_radius = border_radius
.as_deref()
.unwrap_or(&theme.border_radius_medium);
let height = height.as_deref().unwrap_or("40px");
rsx!(
div {
display: "inline-block",
position: "relative",
height: "{height}",
line_height: "{height}",
border_radius: "{border_radius}",
color: "{color}",
font_weight: "bold",
overflow: "hidden",
cursor: "pointer",
Ripple { onclick: move |event| onpress.call(event),
div {
position: "relative",
z_index: 9,
padding: "0 25px",
font_family: "sans-serif",
user_select: "none",
webkit_user_select: "none",
{children}
}
}
}
)
}