-
Notifications
You must be signed in to change notification settings - Fork 20
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
CSS Variable Support #65
Comments
It seems generating unique names will be needed more often. I've also needed it to generate unique names for animations. It could make sense to have a more general setup, if it's not too complicated with the different naming schemes. |
I thought we are adding a |
I think a full variable management system is worth the R&D, because it can be useful in other aspects. In general, I've seen a use-case for this, and it's faster to let the browser update via variables? (#79) Here's a use-case I've battled with, and I'm not sure if there's a better way. I set a global variable for font size, I'd love a way to respond to the variable changes, and use these variables in other classes, with the current value of #[function_component(Icon)]
pub fn icon(props: &Props) -> Html {
let font_size = variables::get("--fs");
html! {
<i class={css!("height: ${fs}; width: ${fs};", fs=font_size)}>
/* Icon SVG Mask which could be 1.04em or 1em! */
</i>
} My best solution so far has been storing my font sizes in my theme context, but I can't get media query updates this way. |
I have implemented what described in this issue a couple month ago but only had time to copy the implementation into this repository last week. You can find the work under the branch Feel free to give it a shot and let me know how it works. The It enforces reading a field from a |
Brilliant, I may have time to give this a shot and give feedback. |
do you have an example of how to use css_var! with yew? |
When using a SSR'ed page with dark mode support, as WebAssembly bundles are non render blocking content, users that defaults to dark mode will see a flash of light mode page.
The solution is to use CSS Variables (alongside a small render blocking JavaScript script to help detect which theme to use) which can be loaded before the page is rendered.
However, I find it difficult to ensure a globally unique css variable name across the entire application.
This issue aims to introduce a CssVariables derive macro that helps with the implementation.
The text was updated successfully, but these errors were encountered: