1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
use dioxus::prelude::*;
use freya_elements::elements as dioxus_elements;
use freya_hooks::{use_get_theme, BodyTheme};
/// [`Body`] component properties.
#[derive(Props)]
pub struct BodyProps<'a> {
/// Inner children for the Body.
children: Element<'a>,
/// Padding for the Body.
#[props(default = "none".to_string(), into)]
padding: String,
}
/// `Body` component.
///
/// Usually just used one time and as a root component for all the app.
///
/// # Props
/// See [`BodyProps`].
///
/// # Styling
/// Inherits the [`BodyTheme`](freya_hooks::BodyTheme) theme.
///
/// # Example
///
/// ```no_run
/// # use freya::prelude::*;
/// fn app(cx: Scope) -> Element {
/// render!(
/// Body {
/// label {
/// "Click this"
/// }
/// }
/// )
/// }
/// ```
///
#[allow(non_snake_case)]
pub fn Body<'a>(cx: Scope<'a, BodyProps<'a>>) -> Element {
let theme = use_get_theme(cx);
let BodyTheme { background, color } = theme.body;
let BodyProps { children, padding } = cx.props;
render!(rect {
width: "fill",
height: "fill",
color: "{color}",
background: "{background}",
padding: "{padding}",
children
})
}