-
-
Notifications
You must be signed in to change notification settings - Fork 62
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
34 changed files
with
1,174 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
name = "freya-design-system-example" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
freya = { workspace = true } | ||
dioxus = { workspace = true } | ||
dioxus-router = { workspace = true } | ||
strum = { version = "0.26", features = ["derive"] } | ||
itertools = "0.13.0" |
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,37 @@ | ||
use freya::prelude::*; | ||
|
||
#[allow(non_snake_case)] | ||
pub fn DsAccordion() -> Element { | ||
rsx!( | ||
Accordion { | ||
summary: rsx!(AccordionSummary { | ||
label { | ||
"Accordion 1" | ||
} | ||
}), | ||
AccordionBody { | ||
label { | ||
"This is the body" | ||
} | ||
label { | ||
"This is the body" | ||
} | ||
label { | ||
"This is the body" | ||
} | ||
label { | ||
"This is the body" | ||
} | ||
label { | ||
"This is the body" | ||
} | ||
label { | ||
"This is the body" | ||
} | ||
label { | ||
"This is the body" | ||
} | ||
} | ||
} | ||
) | ||
} |
15 changes: 15 additions & 0 deletions
15
examples/all-components/src/ds/components/activable_route.rs
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,15 @@ | ||
use freya::prelude::*; | ||
|
||
use crate::Route; | ||
|
||
#[allow(non_snake_case)] | ||
pub fn DsActivableRoute() -> Element { | ||
rsx!( | ||
ActivableRoute { | ||
route: Route::Home, | ||
label { | ||
"ActivableRoute 1" | ||
} | ||
} | ||
) | ||
} |
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,23 @@ | ||
use freya::prelude::*; | ||
|
||
#[allow(non_snake_case)] | ||
pub fn DsButton() -> Element { | ||
rsx!( | ||
Button { | ||
onclick: move |_| { | ||
println!("button clicked") | ||
}, | ||
label { | ||
"A button" | ||
} | ||
} | ||
) | ||
} | ||
|
||
#[component] | ||
pub fn ButtonThemeEditor(theme: Signal<Theme>) -> Element { | ||
rsx!(Input { | ||
value: theme().button.background, | ||
onchange: move |e: String| { theme.write().button.background = e.into() } | ||
}) | ||
} |
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,104 @@ | ||
use std::collections::HashSet; | ||
|
||
use freya::prelude::*; | ||
|
||
#[derive(PartialEq, Eq, Hash)] | ||
enum Choice { | ||
First, | ||
Second, | ||
Third, | ||
} | ||
|
||
#[allow(non_snake_case)] | ||
pub fn DsCheckbox() -> Element { | ||
let mut selected = use_signal::<HashSet<Choice>>(HashSet::default); | ||
|
||
rsx!( | ||
Tile { | ||
onselect: move |_| { | ||
if selected.read().contains(&Choice::First) { | ||
selected.write().remove(&Choice::First); | ||
} else { | ||
selected.write().insert(Choice::First); | ||
} | ||
}, | ||
leading: rsx!( | ||
Checkbox { | ||
selected: selected.read().contains(&Choice::First), | ||
}, | ||
), | ||
label { "First choice" } | ||
} | ||
Tile { | ||
onselect: move |_| { | ||
if selected.read().contains(&Choice::Second) { | ||
selected.write().remove(&Choice::Second); | ||
} else { | ||
selected.write().insert(Choice::Second); | ||
} | ||
}, | ||
leading: rsx!( | ||
Checkbox { | ||
selected: selected.read().contains(&Choice::Second), | ||
}, | ||
), | ||
label { "Second choice" } | ||
} | ||
Tile { | ||
onselect: move |_| { | ||
if selected.read().contains(&Choice::Third) { | ||
selected.write().remove(&Choice::Third); | ||
} else { | ||
selected.write().insert(Choice::Third); | ||
} | ||
}, | ||
leading: rsx!( | ||
Checkbox { | ||
selected: selected.read().contains(&Choice::Third), | ||
}, | ||
), | ||
label { "Third choice" } | ||
} | ||
) | ||
} | ||
|
||
#[allow(non_snake_case)] | ||
pub fn DsRadio() -> Element { | ||
let mut selected = use_signal(|| Choice::First); | ||
|
||
rsx!( | ||
Tile { | ||
onselect: move |_| { | ||
selected.set(Choice::First); | ||
}, | ||
leading: rsx!( | ||
Radio { | ||
selected: *selected.read() == Choice::First, | ||
}, | ||
), | ||
label { "First choice" } | ||
} | ||
Tile { | ||
onselect: move |_| { | ||
selected.set(Choice::Second); | ||
}, | ||
leading: rsx!( | ||
Radio { | ||
selected: *selected.read() == Choice::Second, | ||
}, | ||
), | ||
label { "Second choice" } | ||
} | ||
Tile { | ||
onselect: move |_| { | ||
selected.set(Choice::Third); | ||
}, | ||
leading: rsx!( | ||
Radio { | ||
selected: *selected.read() == Choice::Third, | ||
}, | ||
), | ||
label { "Third choice" } | ||
} | ||
) | ||
} |
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,37 @@ | ||
use freya::prelude::*; | ||
|
||
#[allow(non_snake_case)] | ||
pub fn DsDragProvider() -> Element { | ||
let column = vec!["I Like".to_string(), "Rust".to_string(), "🦀!".to_string()]; | ||
|
||
rsx!( | ||
DragProvider::<String> { | ||
DropZone { | ||
ondrop: move |data: String| { | ||
println!("drop {data}"); | ||
}, | ||
rect { | ||
width: "100%", | ||
height: "100%", | ||
direction: "vertical", | ||
for el in column { | ||
DragZone { | ||
data: el.to_string(), | ||
drag_element: rsx!( | ||
label { | ||
width: "200", | ||
font_size: "20", | ||
"Moving '{el}'" | ||
} | ||
), | ||
label { | ||
font_size: "30", | ||
"{el}" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
) | ||
} |
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 freya::prelude::*; | ||
|
||
#[allow(non_snake_case)] | ||
pub fn DsDropdown() -> Element { | ||
let values = use_hook(|| { | ||
vec![ | ||
"First Option".to_string(), | ||
"Second Option".to_string(), | ||
"Rust".to_string(), | ||
] | ||
}); | ||
let mut selected_dropdown = use_signal(|| "First Option".to_string()); | ||
|
||
rsx!( | ||
Dropdown { | ||
value: selected_dropdown.read().clone(), | ||
for ch in values { | ||
DropdownItem { | ||
value: ch.clone(), | ||
onclick: { | ||
to_owned![ch]; | ||
move |_| selected_dropdown.set(ch.clone()) | ||
}, | ||
label { "{ch}" } | ||
} | ||
} | ||
} | ||
) | ||
} |
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,19 @@ | ||
use freya::prelude::*; | ||
|
||
#[allow(non_snake_case)] | ||
pub fn DsArrowIcon() -> Element { | ||
rsx!(ArrowIcon { | ||
fill: "black", | ||
rotate: "0" | ||
}) | ||
} | ||
|
||
#[allow(non_snake_case)] | ||
pub fn DsCrossIcon() -> Element { | ||
rsx!(CrossIcon { fill: "black" }) | ||
} | ||
|
||
#[allow(non_snake_case)] | ||
pub fn DsTickIcon() -> Element { | ||
rsx!(TickIcon { fill: "black" }) | ||
} |
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,18 @@ | ||
use freya::prelude::*; | ||
|
||
#[allow(non_snake_case)] | ||
pub fn DsInput() -> Element { | ||
let mut value = use_signal(String::new); | ||
|
||
rsx!( | ||
label { | ||
"Value: {value}" | ||
} | ||
Input { | ||
value: value.read().clone(), | ||
onchange: move |e| { | ||
value.set(e) | ||
} | ||
} | ||
) | ||
} |
Oops, something went wrong.