-
-
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.
Add more params to previews and split into new dir
- Loading branch information
Showing
7 changed files
with
120 additions
and
88 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,24 @@ | ||
use dioxus::prelude::*; | ||
use dioxus_material::{use_theme, Button}; | ||
use lookbook::preview; | ||
|
||
/// Buttons let people take action and make choices with one tap. | ||
#[preview] | ||
pub fn ButtonPreview( | ||
cx: Scope, | ||
/// Label for the button. | ||
#[lookbook(default = "Label")] | ||
label: &'a str, | ||
|
||
/// Background color of the container (optional). | ||
#[lookbook(default = &*use_theme(cx).primary_color)] | ||
background_color: &'a str, | ||
|
||
/// Background color of the container (optional). | ||
#[lookbook(default = &*use_theme(cx).border_radius_medium)] | ||
border_radius: &'a str, | ||
) -> Element { | ||
render!( | ||
Button { background_color: background_color, border_radius: border_radius, onpress: |_| {}, label } | ||
) | ||
} |
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,11 @@ | ||
mod button; | ||
pub use button::ButtonPreview; | ||
|
||
mod tab_row; | ||
pub use tab_row::TabRowPreview; | ||
|
||
mod text_button; | ||
pub use text_button::TextButtonPreview; | ||
|
||
mod text_field; | ||
pub use text_field::TextFieldPreview; |
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,29 @@ | ||
use dioxus::prelude::*; | ||
use dioxus_material::{Tab, TabRow}; | ||
use lookbook::{preview, Json}; | ||
|
||
/// Tabs show multiple options for information. | ||
#[preview] | ||
pub fn TabRowPreview<'a>( | ||
cx: Scope<'a>, | ||
|
||
/// Selected tab index. | ||
#[lookbook(default = 0)] | ||
selected: Json<usize>, | ||
|
||
/// Tab elements. | ||
#[lookbook(default = vec![String::from("Tab A"), String::from("Tab B")])] | ||
tabs: Json<Vec<String>>, | ||
) -> Element<'a> { | ||
render!( | ||
div { width: "500px", | ||
TabRow { | ||
onselect: |_| {}, | ||
selected: selected.0, | ||
tabs: cx | ||
.bump() | ||
.alloc(tabs.0.iter().map(|label| render!(Tab { "{label}" })).collect::<Vec<_>>()) | ||
} | ||
} | ||
) | ||
} |
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,24 @@ | ||
use dioxus::prelude::*; | ||
use dioxus_material::{TextButton, use_theme}; | ||
use lookbook::preview; | ||
|
||
/// Buttons let people take action and make choices with one tap. | ||
#[preview] | ||
pub fn TextButtonPreview( | ||
cx: Scope, | ||
/// Label for the text button. | ||
#[lookbook(default = "Label")] | ||
label: &'a str, | ||
|
||
/// Background color of the container (optional). | ||
#[lookbook(default = &*use_theme(cx).primary_color)] | ||
color: &'a str, | ||
|
||
/// Background color of the container (optional). | ||
#[lookbook(default = &*use_theme(cx).border_radius_medium)] | ||
border_radius: &'a str, | ||
) -> Element { | ||
render!( | ||
TextButton { color: color, border_radius: border_radius, onpress: |_| {}, label } | ||
) | ||
} |
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,22 @@ | ||
use dioxus::prelude::*; | ||
use dioxus_material::TextField; | ||
use lookbook::preview; | ||
|
||
/// Text fields let users enter text into a UI. | ||
#[preview] | ||
pub fn TextFieldPreview<'a>( | ||
cx: Scope, | ||
/// Label for the text field. | ||
#[lookbook(default = "Label")] | ||
label: &'a str, | ||
) -> Element<'a> { | ||
let value = use_state(cx, || String::from("Text Field")); | ||
|
||
render!( | ||
TextField { | ||
label: label, | ||
value: value, | ||
onchange: move |event: FormEvent| value.set(event.data.value.clone()) | ||
} | ||
) | ||
} |