-
Notifications
You must be signed in to change notification settings - Fork 715
Parameters typed on CSS rules ? #5824
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
Comments
If I unterstand your proposal correctly, then the It keeps the selectors untouched but references the values defined in element attributes. Here are some examples: .selector {
opacity: attr(data-opacity number); /* numeric value */
font-size: attr(data-font-size length); /* length value */
background-color: attr(data-bgcolor color, white); /* color value with white as fallback */
background-image: url(attr(data-bgimage url)); /* url value */
} Though note that this function is still under discussion due to security concerns among other things. Happy New Year! 🥳 🍾 Sebastian |
Oh yes, indeed, it is exactly the same principle as the Except that instead of having the values in different attributes, having them directly in the class names directly in the "class" attribute. I find it more convenient for certain values (like numbers, keywords colors, lengths) but I can also understand the data separation of selectors. Thank you for your response and happy new year 🎊 |
Hello. I'm not a pro about Git but I guess I have to post here, these kind of specific questions and proposals about CSS.
My question is :
Would it be possible that one day we might have the possibility to have parameters typed on CSS rules (in an official way)?
Video :
I recorded a video to better understand my question. (It's something I did in JavaScript, it's not ideal.)
The idea would be to have this behavior natively, possible?
css-proposal.mp4
More explanations ?
First of all, the "types" are these : https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Types (to think about the authorized types)
We can imagine that to be able to "type" a value of a selector, a ":pseudo-class" would be mandatory.
And we could imagine that we could retrieve the value with a function, here we will call it
param(type)
.Examples with a numeric type :
Example with a length, percentage types
Example with a color type
and finally, types are equal?
Et voilà.
This idea came to me when compiling my (S)CSS sources with some tools took more than 30 seconds. So I tried to find a solution, and it looks good to me.
What do you think about it? I am curious to hear your opinion on it. Thank you for reading, and Merry Christmas. 🎅
Sorry if my English is bad, I'm not used to communicate every day in English. (french)
The text was updated successfully, but these errors were encountered: