-
Notifications
You must be signed in to change notification settings - Fork 11
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
Usage without selector #18
Comments
Hi, Thanks for reporting an issue. we can do this using two approaches. First we can give some css! macro which will just accept style without any selectors and by default it will be scoped to the component inside which css! macro is defined. The other way could be we can give this feature in the style! macro itself by using some placeholder like css!{"component",
background-size: 200%;
background-repeat: no-repeat;
} Second approach will be style!{
&{
background-size: 200%;
background-repeat: no-repeat;
}
} Side note:As of now we can achieve the same functionality by using parent node of all the elements as the selector. For example #[component]
fn Hello(cx: Scope, name: &'static str) -> impl IntoView {
let styler_class = style! {"Hello",
div{
color: blue;
}
};
view! {cx, class = styler_class,
<div class="one">
<h1 id="two">"Hello"</h1>
<h2>"World"</h2>
<h2>{name}</h2>
<h3>"Hello Kanna"</h3>
</div>
}
} |
Thanks for the answer. I think the first option with view! { cx,
<div class=css! {"component"
color: red;
font-family: monospace;
}/>
} But do you think providing name as first argument is still needed in this case? |
what do you think about using style attribute? in that case we don't need any class name. For example <h1
style={css!{
color:blue;
text-align:center
}}
>
This is a header
</h1> |
I'm not sure. Maybe |
Hello. I came from Linaria and there is convinient way to write CSS-in-JS:
I see now
stylers
doesn't produce output if no parent selector provided:Is it possible to implement this in stylers?
I want to make a PR, but I'm really new to Rust and don't think I can do it right.
The text was updated successfully, but these errors were encountered: