-
Notifications
You must be signed in to change notification settings - Fork 42
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
19 changed files
with
849 additions
and
120 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,80 @@ | ||
//! Drive the renderer from Dioxus | ||
|
||
use dioxus::prelude::*; | ||
|
||
fn main() { | ||
dioxus_blitz::launch(app); | ||
} | ||
|
||
fn app() -> Element { | ||
let mut checkbox_checked = use_signal(|| false); | ||
|
||
rsx! { | ||
div { | ||
class: "container", | ||
style { {CSS} } | ||
form { | ||
div { | ||
input { | ||
type: "checkbox", | ||
id: "check1", | ||
name: "check1", | ||
value: "check1", | ||
checked: Some("").filter(|_| checkbox_checked()), | ||
oninput: move |ev| { | ||
dbg!(ev); | ||
checkbox_checked.set(!checkbox_checked()); | ||
}, | ||
} | ||
label { | ||
r#for: "check1", | ||
"Checkbox 1 (controlled)" | ||
} | ||
} | ||
div { | ||
label { | ||
input { | ||
type: "checkbox", | ||
name: "check2", | ||
value: "check2", | ||
} | ||
"Checkbox 2 (uncontrolled)" | ||
} | ||
} | ||
} | ||
div { "Checkbox 1 checked: {checkbox_checked}" } | ||
} | ||
} | ||
} | ||
|
||
const CSS: &str = r#" | ||
.container { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
height: 100vh; | ||
width: 100vw; | ||
} | ||
form { | ||
margin: 12px 0; | ||
display: block; | ||
} | ||
form > div { | ||
margin: 8px 0; | ||
} | ||
label { | ||
display: inline-block; | ||
} | ||
input { | ||
/* Should be accent-color */ | ||
color: #0000cc; | ||
} | ||
"#; |
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,55 @@ | ||
// Example: scrolling. | ||
// Creates a scrollable element to demo being able to scroll elements when their content size | ||
// exceeds their layout size | ||
use dioxus::prelude::*; | ||
|
||
fn root() -> Element { | ||
let css = r#" | ||
.scrollable { | ||
background-color: green; | ||
overflow: scroll; | ||
height: 200px; | ||
} | ||
.gap { | ||
height: 300px; | ||
margin: 8px; | ||
background: #11ff11; | ||
display: flex; | ||
align-items: center; | ||
color: white; | ||
} | ||
.gap:hover { | ||
background: red; | ||
} | ||
.not-scrollable { | ||
background-color: yellow; | ||
padding-top: 16px; | ||
padding-bottom: 16px; | ||
"#; | ||
|
||
rsx! { | ||
style { {css} } | ||
div { class: "not-scrollable", "Not scrollable" } | ||
div { class: "scrollable", | ||
div { | ||
"Scroll me" | ||
} | ||
div { | ||
class: "gap", | ||
onclick: |_| println!("Gap clicked!"), | ||
"gap" | ||
} | ||
div { | ||
"Hello" | ||
} | ||
} | ||
div { class: "not-scrollable", "Not scrollable" } | ||
} | ||
} | ||
|
||
fn main() { | ||
dioxus_blitz::launch(root); | ||
} |
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
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
Oops, something went wrong.