-
Notifications
You must be signed in to change notification settings - Fork 2
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
63 additions
and
63 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
use yew::prelude::*; | ||
|
||
use crate::types::{ColorType, SizeType}; | ||
|
||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] | ||
pub enum BorderRadiusType { | ||
#[default] | ||
Default, | ||
None, | ||
OnlyLeft, | ||
OnlyRight, | ||
} | ||
|
||
#[derive(Debug, PartialEq, Clone)] | ||
pub struct ContextState { | ||
pub border_radius_type: BorderRadiusType, | ||
} | ||
|
||
#[derive(Properties, Debug, PartialEq)] | ||
pub struct ContextProps { | ||
#[prop_or(SizeType::Medium)] | ||
pub size: SizeType, | ||
#[prop_or(ColorType::Primary)] | ||
pub color: ColorType, | ||
#[prop_or(false)] | ||
pub outlined: bool, | ||
#[prop_or_default] | ||
pub border_radius_type: BorderRadiusType, | ||
|
||
#[prop_or_default] | ||
pub children: Children, | ||
} | ||
|
||
pub type ContextProviderType = UseStateHandle<ContextState>; | ||
|
||
#[function_component] | ||
pub fn ContextShell(props: &ContextProps) -> Html { | ||
let ctx = use_state(|| ContextState { | ||
border_radius_type: props.border_radius_type, | ||
}); | ||
|
||
html! { | ||
<ContextProvider<ContextProviderType> context={ctx.clone()}> | ||
{props.children.clone() } | ||
</ContextProvider<ContextProviderType>> | ||
} | ||
} |