dioxus/packages/autofmt/tests/samples/complex.rsx
Jonathan Kelley 828cc502f1
Fix: #2604, Fix: #2240, Fix: #2341, Fix #1355 - Better error handling and and spaces handling in autofmt (#2736)
* add new autofmt sample
* Feat: implement rustfmt::skip support for rsx
* generally improve error handling with better expect messages
* wip: nested rsx formatting and expression formatting
* nested rsx formatting works
* collapse autofmt crate
* cast indent through macros
* use proper whitespace
* no more eating comments!
* Use proper error handling
2024-07-30 18:36:13 -07:00

74 lines
1.8 KiB
R

rsx! {
// Complex nesting with components
button {
class: "flex items-center pl-3 py-3 pr-2 text-gray-500 hover:bg-indigo-50 rounded",
onclick: move |evt| {
show_user_menu.set(!show_user_menu.get());
evt.cancel_bubble();
},
onmousedown: move |evt| show_user_menu.set(!show_user_menu.get()),
span { class: "inline-block mr-4", icons::icon_14 {} }
span { "Settings" }
}
// Complex nesting with handlers
li {
Link {
class: "flex items-center pl-3 py-3 pr-4 {active_class} rounded",
to: "{to}",
span { class: "inline-block mr-3", icons::icon_0 {} }
span { "{name}" }
{children.is_some().then(|| rsx! {
span {
class: "inline-block ml-auto hover:bg-gray-500",
onclick: move |evt| {
evt.cancel_bubble();
},
icons::icon_8 {}
}
})}
}
div { class: "px-4",
{is_current.then(|| rsx! {
{children}
})}
}
}
// No nesting
Component {
adsasd: "asd",
onclick: move |_| {
let blah = 120;
},
}
// Component path
my::thing::Component {
adsasd: "asd",
onclick: move |_| {
let blah = 120;
},
}
for i in 0..10 {
Component { key: "{i}", blah: 120 }
}
for i in 0..10 {
Component { key: "{i}" }
}
for i in 0..10 {
div { key: "{i}", blah: 120 }
}
for i in 0..10 {
div { key: "{i}" }
}
div {
"asdbascasdbasd"
"asbdasbdabsd"
{asbdabsdbasdbas}
}
}