-
-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
67 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters