clearloop / elvis

Your wasm UI library
https://elvisjs.github.io/
MIT License
108 stars 8 forks source link

Style setter implementation #49

Closed clearloop closed 4 years ago

clearloop commented 4 years ago

Desc

Rust doesn't support optional arguments like javascript, the syntax of style is too verbose, for example:

impl Default for TextStyle {
    fn default() -> TextStyle {
        TextStyle {
            bold: true,
            color: Colors::Pink,
            italic: true,
            size: Unit::Rem(2.0),
            weight: Unit::None(400.0),
            height: Unit::Rem(1.0),
            stretch: Unit::Percent(100.0),
        }
    }
}

We need a syntax of chain setting styles like:

let style = TextStyle::new().bold(true);