Browsing caniuse.com the other day, I found a pleasant surprise: a little green flag in a red box for a feature I'd been waiting for a long time.
...
For further actions, you may consider blocking this person and/or reporting abuse
Would it be too pessimistic to say "Meh, firefox will probably just kill it like every other good thing in the web"?
I'm probably being a bit hard on firefox here, but JFC every single feature I want seems to be waiting for them to finally implement it.
You mean Safari
I ha(v/t)e to admit that Safari has been doing a good job lately. While it is way behind in features and options, some of the latest CSS things pop up on Safari first... which doesn't make much sense, but oh well...
Doesn't safari actually still have TCO in its javascript engine, even though firefox unilaterally decided to kill that feature for no reason whatsoever?
Automatically x3 times better if you ask me
The main reasons I use SCSS/SASS is because of nesting and variables. If they fix those two we are getting closer to not needing to compile everything, that would be huge.
But I have some other things, like functions or using a variable in a function call that I really like to see as well.
What do you need variables for that you cannot do with custom properties already?
I had some issues with trying to make the border of div transparent but not the element itself (else a opacity filter would have worked).
So instead I wanted to do:
But then with a variable instead as I wanted to make a light and dark togglable theme. But I found out that using css variables in this context doesn't work.
Maybe I am doing something wrong (or Firefox doesn't allow this?).
Well, no, that doesn't work, because
argb
isn't a thing, and if you want to usergb
you'll have to provide R, G and B separately.What you can do, for example:
and I'm 90% sure you can combine those three variables into a
--theme-hsl
variable somehow but cba to test it right now so won't include it in the code.EDIT: And of course, once CSS Color Module Level 5 becomes a thing, you can just do
Thanks for your explanation, I don't really do front-end that much (I do Java backend at work) but I never knew you could to things like this. Thanks!
argb isn’t a thing as mentioned, but rgba is, which is what you’re writing in the sample code anyways. R G and B go from 0 to 255, and A goes from 0.0 to 1.0
Сongratulations 🥳! Your article hit the top posts for the week - dev.to/fruntend/top-10-posts-for-f...
Keep it up 👍
Cool makes work much easier 👍🏽!
Css is going to get much easier now, thank you for sharing, can't wait for this feature :)
I was using sass/scss just because it is so much better to have nested css instructions. Love to see this feature becoming a standard...
This is a nightmare. Css should only define styles, not handle logic. Javascript is enough logic to handle already
How is this logic?
If (thing a is nested in thing b)
Apply style to thing a
Now what if I don't want to use thing b anymore but thing a? Then I have to change the css file, even though that makes no sense at all
That is how it happens right now in CSS when you put two selectors together (even without the nesting):
Those styles apply to the
.door
in a.car
, but not to a.door
inside a.house
.With CSS nesting this will be more evident for the developer:
It's just syntactic sugar that helps keep the code more organized and clean. The main danger is getting into the curly braces hell.
Fair enough. Still I would rather move in a direction where logic is handled in Javascript and css is styling and only styling. Just today I had to debug some complex sass function. That's hell. But of course this is subjective
Nesting is not logic in any way that makes the code more difficult to read when used properly and doesn't muddy seperation of concerns in any meaningful way. Once you get really adept at SCSS/Sass you start to be able to nest in ways that are intuitive, elegent and make the code a joy to read and reason about.
If you're having to debug a complex Sass function that's not intuitive, it is 100% not an issue with nesting, and everything to do with the developer not doing stuff properly. If you're struggling here then SonarCloud has some really neat features for helping to organise such code. If it's really bad it'll throw a proper riot-tantrum initially, but if you can find anyone good enough to actually fix issues it flags then you'll see what good nesting does for you.
@alvaromontoro by the way, thoughts on
@scope
?