In my quest to push forward what is possible with custom properties in #CSS, I discovered another application of cyclic dependencies. Combined with a prior technique based on custom cascade layers, we are now even closer to something that resembles native CSS mixins.
@kizu Thanks! What a xmas gift! Looking forward to explore your techniques in the coming days. ”Please do not apply this technique in production“ – well… we'll see about that 😅
@kizu this is so cool! a third of the way into your article, i was already thinking about the ways it could be used in production. and then that Firefox bug had to be there 😔
@kizu Okay I had to read the examples a couple times but now I understand it (the quote from the spec helped — who'd have thought! :D). This is really, really clever, and interesting. Thank you for sharing, and happy holidays!
@kizu Ooohhh, that's interesting (/worrisome). What specifically are we talking about? Different whitespace collapsing or text wrapping? Or are some browsers treating the text nodes on either side as separate objects for flex/grid layout on the parent?
If you love logic and did not yet play Baba is You (@BabaIsYou, https://hempuli.itch.io/baba, also available in other places like app store, steam, switch, etc.), I cannot recommend it enough.
One of the best puzzle games ever. Literally, my favorite game.
Solving the levels in it is probably the closest feeling I had to me discovering new CSS techniques and interactions. If you are keen to learn how to think out of the box, this is THE game to play.
Sometimes, I invite someone to join #Mastodon, and I end up sharing the same links and information repeatedly.
Following the “manual until it hurts” #IndieWeb practice, after repeating the same things a few times, it is time to “automate” it. Well, in this case, just put everything into one blog post, I guess.
Many exciting things were added to #CSS specs over the years, but some have yet to be implemented by browser engines.
In this article, I spotlight two features from Level 5 of the CSS Values and Units Working Draft, describe how we can prototype them with what we have in CSS today, and provide several interactive demos of their use cases.
Note: currently, it might not work in mobile Safari. I spent a few hours trying things, the latest dev deploy of my site worked, but the prod one does not.
If you cannot open it by the link about in Safari, a workaround that works for me (but still slow) is to go to https://kizu.dev directly and then go to the article.
In a few of my latest #CSS experiments and articles, I used one naming pattern for registered custom properties that I think worth highlighting in a separate blog post. This pattern allows us to create a set of generic custom properties, covering a wide set of use cases for computing and storing their values.
- @5t3ph for her article about @property.
- @kevinpowell for his video about inheritance.
- @bramus for his post about feature detection.
- @Una for a CSSWG issue about named container query length units.
- @JaneOri for her `tan(atan2())` technique which I mention once again.
- @argyleink for Open Props (could this pattern be helpful to it?).
Media queries are nice, but for many things, we don’t even need them: there is this great #CSS property `color-scheme`, which allows us to make various things adapt to the current color scheme. We can even set it on a per-element basis. This post describes how we can use registered custom properties and style queries to read the current value of a `light-dark()` color for styling any non-color properties as well.
@kizu I feel the same way about the linked issue proposing to change how `prefers-color-scheme` to work. I think I’d have to rewrite some of my CSS mental models if that were to change. Seems less harmful to either use the style query approach you’ve demonstrated or for that to develop into its own specific query. Also, seems like style query support for at least some non-custom properties worth revisiting.
For years, what I was mindlessly doing instead: applying a negative margin with “random” values of 0.2em-0.3em for cases like this, which, coincidentally, almost the same!
Intuitively, and by testing, I was pleased with these values all this time, but having a proper method on one hand, and a confirmation that this type of adjustment results in what the fallback ends up being in the end is nice, haha.
Last boost: oh, I just thought that to work around the adblock-blocking, something in Firefox or the uBlock Origin was just slow, but that is, in fact, just an added timeout for 5s just for Firefox on YouTube.
Good job, Google! I've recently started to listen to the Internet History Podcast (thanks, @Schepp for the recommendation), and oh how similar these tactics are to what MS did employ in the 90s.
Mentioned in the post:
- @TodePond (Splash!)
- @leaverou (contrast-color!)
- Oriol Brufau (`round()`!)
- @mia and @OddBird (mixins! sponsor them!)
@kizu
Made two attempts at okclh.
First one: this has no greys, but gradients be pretty. Though lacks colors like bright yellow.
https://codepen.io/Merri/pen/PwYKzpr
Second one: here the closer each number is to being the same then the resulting color is more grey.
https://codepen.io/Merri/pen/WbeExdr
Code is messy, logic is probably bonkers, but at least selection of colors is nice.