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
55
56
57
58
59
use dioxus::prelude::*;
use freya_elements::elements as dioxus_elements;

use freya_hooks::{use_applied_theme, BodyTheme, BodyThemeWith};

/// [`Body`] component properties.
#[derive(Props, Clone, PartialEq)]
pub struct BodyProps {
    /// Theme override.
    pub theme: Option<BodyThemeWith>,
    /// Inner children for the Body.
    pub children: Element,
}

/// `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() -> Element {
///     rsx!(
///         Body {
///             label {
///                 "Click this"
///             }
///         }
///     )
/// }
/// ```
///
#[allow(non_snake_case)]
pub fn Body(props: BodyProps) -> Element {
    let theme = use_applied_theme!(&props.theme, body);
    let BodyTheme {
        background,
        color,
        padding,
    } = theme;

    rsx!(
        rect {
            width: "fill",
            height: "fill",
            color: "{color}",
            background: "{background}",
            padding: "{padding}",
            {&props.children}
        }
    )
}