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

Support for css variables in RCSS #517

Open
Illation opened this issue Sep 28, 2023 · 7 comments
Open

Support for css variables in RCSS #517

Illation opened this issue Sep 28, 2023 · 7 comments
Labels
enhancement New feature or request

Comments

@Illation
Copy link

Hi, what would it take to support CSS Variables?

They where mentioned in #22 a few years ago, but I don't believe there ever was any follow up.

I'm working on writing a tool framework for my engine on top of RmlUi, so there will be lots of different UI elements that should ideally have a consistent appearance, and I imagine all the different colours will get confusing and hard to keep track of very quickly.

At a minimum just the ability to make variables for colours in a global context would be sufficient for me, although long term it would be fantastic if they supported lengths and played well with media queries or could otherwise be controlled from c++ as well to support theming.

I'm happy to look into this myself if I'm pointed in the right direction and the scope of change isn't too huge

@mikke89 mikke89 added the enhancement New feature or request label Sep 28, 2023
@mikke89
Copy link
Owner

mikke89 commented Sep 28, 2023

Hey, and thanks for the suggestion.

There was actually a serious effort into implementing this here: #388. I am still very much interested in it if we can solve the performance issues. I think it's a very good start already, and if you feel like having a go at improving it, then I would very much encourage that :) Let me know if I can assist in any way.

@Dakror
Copy link
Contributor

Dakror commented Nov 10, 2023

Good luck.

@JailbreakPapa
Copy link

@mikke89 Curious, what mainly was the blocker for @Dakror PR for properties in-terms of performance? Was it just purely evaluating the css that was taking a while? I plan to take a look at this for a private fork.

@Dakror
Copy link
Contributor

Dakror commented Feb 5, 2024

I guess the additional indirections and recomputation of styles based on variable changes. You could always just checkout the code in the PR and benchmark it yourself.

@mikke89
Copy link
Owner

mikke89 commented Feb 5, 2024

Right, there are some numbers here: #388 (comment), and here: #388 (comment).

@JailbreakPapa
Copy link

I guess the additional indirections and recomputation of styles based on variable changes. You could always just checkout the code in the PR and benchmark it yourself.

@Dakror did your css-variables branch handle hex based colors? im "attempting" to take a go at the feature, but colors seem very broken.

For example this CSS would attempt to convert the variable to the color, but end up failing and resort to all black:

:root {
  --blue: #6495ed;
  --white: #faf0e6;
}

body { background-color: var(--blue); }

@Dakror
Copy link
Contributor

Dakror commented Feb 14, 2024

I guess the additional indirections and recomputation of styles based on variable changes. You could always just checkout the code in the PR and benchmark it yourself.

@Dakror did your css-variables branch handle hex based colors? im "attempting" to take a go at the feature, but colors seem very broken.

For example this CSS would attempt to convert the variable to the color, but end up failing and resort to all black:

:root {
  --blue: #6495ed;
  --white: #faf0e6;
}

body { background-color: var(--blue); }

I don't remember, but you could just simply checkout the PR branch and try it out yourself. I ended up writing my own preprocessor to not rely on these modifications to the RmlUi Core.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants