cut out a number of changes from the hr PR (#2580)

This commit is contained in:
Jonathan Kelley authored and GitHub committed 2024-07-02 17:09:57 -07:00
1 parent 9bf46968cd
commit b30810e486
12 files changed
+89 -18

No files matched your search

+1 -1
View File
@@ -28,7 +28,7 @@ fn app() -> Element {
link { href:"https://fonts.googleapis.com/icon?family=Material+Icons", rel:"stylesheet" }
header {
i { class: "material-icons icon-menu", "menu" }
h1 { "Files: ", {files.read().current()} }
h1 { "Files: " {files.read().current()} }
span { }
i { class: "material-icons", onclick: move |_| files.write().go_up(), "logout" }
}
+1 -1
View File
@@ -54,7 +54,7 @@ fn app() -> Element {
id: "directory-upload",
checked: enable_directory_upload,
oninput: move |evt| enable_directory_upload.set(evt.checked()),
},
}
}
div {
+2 -2
View File
@@ -41,8 +41,8 @@ fn Decrement() -> Element {
#[component]
fn Display() -> Element {
rsx! {
p { "Count: ", "{COUNT}" }
p { "Doubled: ", "{DOUBLED_COUNT}" }
p { "Count: {COUNT}" }
p { "Doubled: {DOUBLED_COUNT}" }
}
}
+1 -1
View File
@@ -20,7 +20,7 @@ fn app() -> Element {
// Add some cute animations if the radio is playing!
div { class: if state.read().is_playing { "bounce" },
"The radio is... ", {state.read().is_playing()}, "!"
"The radio is... " {state.read().is_playing()} "!"
}
button { id: "play", onclick: move |_| state.write().reduce(PlayerAction::Pause), "Pause" }
+6 -6
View File
@@ -79,7 +79,7 @@ fn app() -> Element {
}
div {
// pass simple rust expressions in
class: lazy_fmt,
class: "{lazy_fmt}",
id: format_args!("attributes can be passed lazily with std::fmt::Arguments"),
class: "asd",
class: "{asd}",
@@ -97,7 +97,7 @@ fn app() -> Element {
{rsx!(p { "More templating!" })},
// Iterators
{(0..10).map(|i| rsx!(li { "{i}" }))},
{(0..10).map(|i| rsx!(li { "{i}" }))}
// Iterators within expressions
{
@@ -117,7 +117,7 @@ fn app() -> Element {
// Conditional rendering
// Dioxus conditional rendering is based around None/Some. We have no special syntax for conditionals.
// You can convert a bool condition to rsx! with .then and .or
{true.then(|| rsx!(div {}))},
{true.then(|| rsx!(div {}))}
// Alternatively, you can use the "if" syntax - but both branches must be resolve to Element
if false {
@@ -135,7 +135,7 @@ fn app() -> Element {
}}
// returning "None" without a diverging branch is a bit noisy... but rare in practice
{None as Option<()>},
{None as Option<()>}
// can also just use empty fragments
Fragment {}
@@ -176,8 +176,8 @@ fn app() -> Element {
// Spreading can also be overridden manually
Taller {
..TallerProps { a: "ballin!", children: VNode::empty() },
a: "not ballin!"
a: "not ballin!",
..TallerProps { a: "ballin!", children: VNode::empty() }
}
// Can take children too!
+3 -3
View File
@@ -12,17 +12,17 @@ fn app() -> Element {
rsx!(
div {
// Use Map directly to lazily pull elements
{(0..10).map(|f| rsx! { "{f}" })},
{(0..10).map(|f| rsx! { "{f}" })}
// Collect into an intermediate collection if necessary, and call into_iter
{["a", "b", "c", "d", "e", "f"]
.into_iter()
.map(|f| rsx! { "{f}" })
.collect::<Vec<_>>()
.into_iter()},
.into_iter()}
// Use optionals
{Some(rsx! { "Some" })},
{Some(rsx! { "Some" })}
// use a for loop where the body itself is RSX
for name in 0..10 {
+1 -1
View File
@@ -225,7 +225,7 @@ fn ListFooter(
match active_todo_count() {
1 => "item",
_ => "items",
},
}
" left"
}
}