Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add own Classes struct implementation #585

Merged
merged 1 commit into from
Aug 13, 2019
Merged

Add own Classes struct implementation #585

merged 1 commit into from
Aug 13, 2019

Conversation

therustmonk
Copy link
Member

Hide details of Classes set implementation and add a feature to produce that struct from variety of sources like &str, String and Vec<T> where T: AsRef<str>.

I need this to have an effective way to construct complex classes set for https://github.com/yewstack/facade. With this PR we can do something like:

let mut classes = vec!["container"];
classes.push("fluid");
// or
let mut classes = Classes::new();
classes.append("container");
if fluid_flag {
    container.append("fluid");
}

html! {
    <div classes=classes />
}

In the future we can implement impl Info<Classes> for (tuple) and simplify macro by delegating tuples to classes conversion to type system (instead of macro).

Let's give a chance to CI to check it 🤞

Also I applied cargo fmt to the root crate sources.

Hide details of Classes set implementation and add a feature to produce that struct
from variety of sources like `&str`, `String` and `Vec<T> where T: AsRef<str>`.
Copy link
Member

@jstarry jstarry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Setting with a vec is a great improvement!

@therustmonk
Copy link
Member Author

bors r+

bors bot added a commit that referenced this pull request Aug 13, 2019
585: Add own Classes struct implementation r=DenisKolodin a=DenisKolodin

Hide details of Classes set implementation and add a feature to produce that struct from variety of sources like `&str`, `String` and `Vec<T> where T: AsRef<str>`.

I need this to have an effective way to construct complex classes set for https://github.com/yewstack/facade. With this PR we can do something like:

```rust
let mut classes = vec!["container"];
classes.push("fluid");
// or
let mut classes = Classes::new();
classes.append("container");
if fluid_flag {
    container.append("fluid");
}

html! {
    <div classes=classes />
}
```

In the future we can implement `impl Info<Classes> for (tuple)` and  simplify macro by delegating **tuples to classes** conversion to type system (instead of macro).

Let's give a chance to CI to check it 🤞 

Also I applied `cargo fmt` to the root crate sources.

Co-authored-by: Denis Kolodin <deniskolodin@gmail.com>
@bors
Copy link
Contributor

bors bot commented Aug 13, 2019

Build succeeded

  • continuous-integration/travis-ci/push

@bors bors bot merged commit 46ae317 into master Aug 13, 2019
@jstarry jstarry deleted the classes-producer branch September 27, 2019 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants