futursolo / stylist-rs

A CSS-in-Rust styling solution for WebAssembly Applications
https://crates.io/crates/stylist
MIT License
366 stars 22 forks source link

Feature request: get component identifier from function name if PascalCase #90

Closed allan2 closed 1 year ago

allan2 commented 1 year ago

Thanks @futursolo and @WorldSEnder for this crate!

It would be nice if the attribute name could be omitted, like in Yew 0.20. #69 maybe relevant?

Current:

#[styled_component](MyStyledComponent)
fn my_styled_component() -> Html {
    html! {<div class={css!("color: red;")}>{"Hello World!"}</div>}
}

Proposed:

#[styled_component]
fn MyStyledComponent() -> Html {
    html! {<div class={css!("color: red;")}>{"Hello World!"}</div>}
}
futursolo commented 1 year ago

Yes, this will be supported after we update stylist to Yew 0.20.

It would be nice if the attribute name could be omitted, like in Yew 0.20. https://github.com/futursolo/stylist-rs/pull/69 maybe relevant?

#[styled_component] is a wrapper around #[function_component]. But the attribute parsing is separate so it will need to be updated manually.

69 currently does not contain an update that supports function component without attribute name.