use dioxus::native::{Config, LogicalSize, WindowAttributes};
use dioxus::prelude::*;
fn main() {
let window = WindowAttributes::default().with_surface_size(LogicalSize::new(500.0, 500.0));
let config = Config::new().with_window_attributes(window);
dioxus::native::launch_cfg(app, vec![], vec![Box::new(config)]);
}
fn app() -> Element {
rsx! {
Stylesheet { href: asset!("/assets/tailwind.css") }
HelloWorld { text: "World" }
}
}
#[component]
fn HelloWorld(text: String) -> Element {
rsx! {
div { class: "flex flex-col gap-3 bg-[#505050] size-[500px] justify-center items-center shadow-lg border border-[#0000ff] text-xl text-white",
"Hello, {text}!"
div { class: "flex gap-2",
div { class: "size-8 bg-[red]" }
div { class: "size-8 bg-[lime]" }
div { class: "size-8 bg-[blue]" }
div { class: "size-8 bg-[yellow]" }
div { class: "size-8 bg-black" }
div { class: "size-8 bg-white" }
}
}
}
}
You can also use standard CSS if you prefer it over tailwind. And if you wanted to deduplicate, the 6 divs can be written in a loop like so: for color in ["red", "lime", "blue", "yellow", "black", "white"] {
div { width: "32px", height: "32px", background_color: color }
}> move |_| container::background(c)
There's no way anyone can see this and thinks it is legible
New languages always feel a bit inapproachable. It’s like learning Russian (for a westerner). Super impenetrable at first, but at some point (early on!) the alphabet just clicks and then the rest is “just” regular language learning. Same with PL syntax. Overwhelming at first, until it clicks and then you can’t remember what you found overwhelming about it.
I see this and think it is very legible. It is hard to imagine why anyone can have issues with this.
I really like :()), it looks like a monkey with two chins!
fn view(_: &()) -> impl Widget<()> {
and think "nailed it"Pretty straightforward to my mind.