-
Notifications
You must be signed in to change notification settings - Fork 814
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
Review setting style attributes with CSS variables #1724
Comments
This feels like it should be made to work. Although it may have repercussions beyond colors. I would expect that anywhere a string is accepted Textual should to the preprocess step. So We should probably review how much effort this will be, and how we can report errors. If that is going to cause too much complication, we can still consider throwing an error. As long as the dev can still accomplish the same thing, with perhaps an additional line or two of code. |
styles.color
property to a $variable
Shall we revise the docs to reflect current working for now? |
I wouldn't bother until we have a plan with this issue. If anyone else notices we can point them here. |
Is there a function to do this? Look in to how errors are reported? |
The function In order to fully support setting CSS styles with variables, we would need to make a couple of changes to the codebase:
The second change can be done even if we do not allow user-defined variables to be used when setting styles programmatically, for example by creating a regex that looks for variable references when a style is set to a string value. Overall, I don't think it makes sense to only support setting styles to variables defined by Textual's design system.
|
Stemming from this question on Discord:
Currently the normal advice would be to use a CSS class and swap the class in and out. However, the person asking says they were thinking that it should work as the Python docs at the bottom of this page say it should:
At first glance it seems that this isn't supported, and the docs may have been written thinking it does/would, but we're thinking that this would be a good thing to support.
So... look into adding support for this if possible.
The text was updated successfully, but these errors were encountered: