You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In one of my projects (https://github.com/augustebaum/romodoro) I implement the Component trait from yew, and I'd like to be able to manipulate some CSS attributes dynamically, hence stylist seems like the right way to go. Here is what it looks like:
implComponentforMyComponent{typeMessage = Msg;typeProperties = ();// create and update methodsfnview(&self,ctx:&Context<Self>) -> Html{html!{
<>
<div id="background" class={css!("background-color: #dd6000;")}>
// other divs and stuff
</>
}}// changed, rendered, destroy methods}
This does not compile, with the following error being displayed:
error[E0277]: the trait bound `Classes:From<StyleSource<'_>>` is not satisfied
--> src/main.rs:139:9
|
139 | / html!{140 | | <>
141 | | <div id="background" class={css!("background-color: #dd6000;")}>
... |
154 | | </>
155 | | }
| |_________^ the trait `From<StyleSource<'_>>` is not implemented for `Classes`
|
= help: the following implementations were found:
<ClassesasFrom<&'static str>>
<ClassesasFrom<&Option<T>>>
<ClassesasFrom<&String>>
<ClassesasFrom<&[T]>>
and 4others
= note: required because of the requirements on the impl of `Into<Classes>` for `StyleSource<'_>`
= note: this error originates in the macro `html` (in Nightlybuilds, run with -Z macro-backtrace for more info)
I cannot make sense of this error: even though I understand what it means that some trait is not implemented, I don't know which method I should implement. How should I go about solving this?
Furthermore, it seems that stylist is designed to work well with yew, e.g. the very first item in the documentation focuses on yew function components. However, I could not find any documentation on how to use it with yew in any other way. Is this intentional?
I'm a beginner in Rust so forgive me if I overlooked some obvious detail. Thanks for your attention.
The text was updated successfully, but these errors were encountered:
It seems this is a duplicate of #86.
The solution I found was to use yew in its 0.19.3 version instead of master and I could then use css! after importing it:
You are correct, there is currently no up-to-date version for yew's master branch. IF it existed, it will get updated in this PR: #69 though, but I currently don't have the time to do so. I will try updating that next week or the following.
Hi,
Thanks so much for the hard work on this project!
In one of my projects (https://github.com/augustebaum/romodoro) I implement the
Component
trait fromyew
, and I'd like to be able to manipulate some CSS attributes dynamically, hencestylist
seems like the right way to go. Here is what it looks like:This does not compile, with the following error being displayed:
I cannot make sense of this error: even though I understand what it means that some trait is not implemented, I don't know which method I should implement. How should I go about solving this?
Furthermore, it seems that
stylist
is designed to work well withyew
, e.g. the very first item in the documentation focuses onyew
function components. However, I could not find any documentation on how to use it withyew
in any other way. Is this intentional?I'm a beginner in Rust so forgive me if I overlooked some obvious detail. Thanks for your attention.
The text was updated successfully, but these errors were encountered: