A quick light-dark() experiment

 I wanted to experiment with the new CSS function light-dark() and get a sense of how to use it in a CSS architecture of nested (web) components. I think it’s going to be a powerful tool in the new responsive world of component architecture but I don’t want to recommend something unless I have experience with it in a project first.

My first pass was to add light-dark() to my components…

/* global.css */
:root {
  --dark: #000;
  --light: #fff;
}

/* Inside <my-component>'s Shadow DOM */
:host {
  background-color: light-dark(var(--light), var(--dark));
  color: light-dark(var(--dark), var(--light));
}

But if every component is in charge of it’s own light-dark() handling for border, background, and color on every element… the codebase will get messy managing dark mode in a lot of different places, leading to a lot of inconsistencies over time. A more elegant solution for me would be to handle this job in a single location at the root scope level and leverage the cascade a bit.

:root {
  color-scheme:  light dark;
  --surface-color: light-dark( #fff, #000 );
  --text-color: light-dark( #000, #fff );
}

The nice thing about using light-dark() at the root token level is your components can be dumber. You provide default light-dark experience and, like good children, your components abide in their parent’s decision. Of course, due to the nature of CSS custom properties, your components aren’t locked into the system and your component level styles can opt out (read: not include) or override the global variables if necessary.

/* Inside <my-component>'s Shadow DOM */
:host {
  background: var(--surface-color);
  color: var(--text-color);
}
/* this is a real example from my past */
:host[theme="lunar-new-year"] {
  --surface-color: red;
  --text-color: black;
}

At this point in the experiment I was pleased with the results… until I deployed it to production. I overestimated the browser support for light-dark() and it didn’t work on my phone running Safari 17.4 (but it’s coming in Safari 17.5). I replicated the issue by changing light-dark() to light-d0rk() to verify and fixed it by adding a tried-and-true CSS @supports query.

:root {
  --surface-color: #000;
  --text-color: #fff;

	/* NOTE: For Safari 17.4 (2024-05) */
  @supports (color: light-dark(black, white)) {
    color-scheme:  light dark;
	  --surface-color: light-dark( #fff, #000 );
	  --text-color: light-dark( #000, #fff );
  }
}

Now Safari 17.4 and other browsers that lack support will only have a dark theme and newer browsers will get the light-dark() enhancement. I also threw a little NOTE: and datestamp in there so future versions of me will know when and why I built this fence.

daverupert.com

05 May 2024 at 16:27

Vibe Check №32

 An unseasonable gloomy spring in Austin, TX. The kids are nearly done with school for the year and summer plans are shoring up. My son goes to middle school next year. Unbelievable.

We’ve battled some on-and-off sicknesses these past couple months and with all the holidays every week has felt like a false start. But here we are, barreling into summer. I’ve already been out on the lake to surf on my cousin’s boat, so I’ve got that going for me.

The Eclipse

In April my wife’s entire family came out from Arizona to Austin for the eclipse on April 8th. We got a big Vrbo near the lake right in the path of totality. The weather was cloudy and dismal in Austin for the eclipse. But then… ten minutes before full totality, the sky broke open.

I’ve seen partial eclipses before and those were cool. But nothing prepared me for seeing the total eclipse. The complete darkness. The confused birds. The sudden drop in temperature. The fully visible halo effect eminating from the sun. It’s other worldly to see the big space rock that goes around our planet move in front of the big fireball that keeps our planet alive.

Happy to get to celebrate something so cosmic with the family.

44 and there’s so much more

I turned 44 at the end of April and had an uneventful birthday. That’s how birthdays go after the big four-oh. I spent most of my day cleaning the house and watching anime. My family treated me to a “fancy dinner” at a place with cloth napkins and the kids behaved themselves through the whole meal.

The highlight of my birthday was exchanging texts with some old friends who have known me for decades. Old friends like that – even though you often live distant parallel busy lives – have the ability to tap into a deep well of friendship. For that I am thankful.

Making Games

I haven’t talked about it much, because I don’t want to jinx it, but I’ve been making some games in my spare time. And not one style of game either, a big swath of random ideas in different formats.

  • A “Guess Who?”-style game for Panic’s Playdate.
  • A one-page TTRPG. Almost everything is in place for this.
  • A 52-card deck game that I’m turning into a game for your mobile computer.

Making games has been a fun and different way to spend my time. I don’t have much to show for all that tinkering right this minute, but soon maybe?

Waiting for a life-changing email

You know that feeling when your boss emails you and asks “Hey, you got a minute?” and those minutes until you talk to your boss feels like hours as your amygdala floods your limbic system with intense, wet, hot anxiety? That’s more or less what I’ve been feeling for the last two months as I waited for a life-changing email. There were two emails actually. Then that got stressful. Then I had to wait on a package.

To be totally honest, all that waiting nearly broke me. I’m a decently patient person but a giant cloud LOOMING over me every day that I’m unable to control is distressing. Then your friends and family and kids ask you “Hey did that life-changing email come yet?” and you have to say “Nope, not yet” over and over.

But the email did come. And so did the package. And the giant cloud of concern is slowly dissipating. And on Monday I’ll embark on the next big phase of my adult life. Ominous, I know.

Stats and consumption

What you jackals come here for…

🧠 Learning

I took some time to do some deep dives both formally and informally.

  • TypeScript - Almost certain I’ll be using this sometime in the future, so I took a FrontendMasters course to connect all the pieces I had scattered about in my brain.
  • LLM Vector Embeddings - All this LLM search jazz is normal vector search but with special GPT-based embeddings instead of Postgres’s default embeddings. Way less threatening or opaque to me now that I understand it.
  • Solo RPGs - I got a bit obsessed with the idea of playing a TTRPG by yourself and it inspired me to make a game.

💪 Wellness

I’ve put on a bit of weight and that’s frustrating but I think again it’s stress-related.

  • Taking walks
  • Got a weighted vest for “rucking”
  • Rode my new bike once

📖 Reading

Reading is still on a book-a-week clip. This year I’m mulling around tech and ethics, as well as reading about people who created or harnessed a new technology. I also got back into comics and have read some wonderful pieces. If it’s sci-fi themed and has good art, I’m all-in.

Finished

  • Doom Guy: Life in First Person by John Romero - An autobiography about the man who created DOOM.
  • Of Boys and Men by Richard V. Reeves - The boys are not alright. A good look at the problems and struggles facing men.
  • Empire of Imagination by Michael Witwer - A well-written biography about Gary Gygax, creator of Dungeons & Dragons.
  • Excellent Advice for Living by Kevin Kelly - I’m a sucker for the “old man shares one-liner quips for living life better” genre. I’m also a big Kevin Kelly fan.
  • The Shame Machine by Cathy O’Neil - The follow up to Weapons of Math Destruction is an illuminating book about the negative impact social media has on our lives.
  • The Coming Wave by Mustafa Suleyman - The new CEO of AI at Microsoft, Mustafa Suleyman, has a history with AI and his work at Google’s Deep Mind which produced the AlphaGo AI. I thought this was going to be all “rah-rah” hypefest about AI, but instead I found it a pretty sober critique with a major theme around “containment” of this new technology.
  • The Hitchhiker’s Guide to the Galaxy by Douglas Adams by Douglas Adams - I as happy to finally read this classic piece of sci-fi. Suprisingly relevant to now… down to the whole idea that politicians like Zaphod Beeblebrox win their office by creating outrage.
  • Moon Man #1-2 by Kid Cudi - An amazing work of art. It’s just getting started, so hop on now!
  • Napalm Lullaby #1-2 - Siblings hellbent on taking down the religious authoritarian regime.
  • We Only Find Them When They’re Dead #4-5 - Having a tough time with how “jumpy” this series is but I picked up the next volume.
  • The Weatherman Vol. 1 - The first issue has an explosive hook and it never stops.
  • The Weatherman Vol. 2 - More of the same great sci-fi thriller.

In Progress

📝 Blogging

Slowed down a lot on blogging. That’s okay. I still have three dozen drafts but I’m being pretty choosy about where I toil. It’s easy for me to lose a weekend tinkering on a handful of posts, or piecing together a giant overly complex post like this. I need to stop doing that. Or I need to do that more often. Who knows.

FrontendMasters Boost (1 post)

This Blog (5 posts)

📺 Media

Movies

TV

  • Unlocked: A Jail Experiment (Netflix) - What happens when you don’t make prisoners stay locked up in their cells 23 hours a day? And you let them have free phone calls? The experiment was nearly called off, but the men pulled together to make the best of their situation.

Anime

Podcasts

  • Sold a Story Ep10-11 - Follow up to the 2022 exposé on reading eduction and what’s changed.
  • The Adventure Zone Kills Dracula - This is the most surreal of all the series so far.
  • If Books Could Kill… - The recent episode on “Going Infinite” was awesome.
  • Bundyville S1: Bundyville - An investigation into the origin story of an anti-government right wing extremist group. One unexpected twist was though I do not support their beliefs at all, I sympathize how they were setup by the FBI agents… which is unfortunate because all these guys need is a match to start a fire.
  • Bundyville S2: The Remnant - The ripple effects of Cliven Bundy’s extremism.

🎙 Recording

A normal couple months of ShopTalk with some great guests.

🎲 GameDev

Mentioned above, I’ve been making some games.

  • Untitled TTRPG
  • Untitled Card Game
  • Untitled Playdate Game

🤖 Gunpla

three gundam models

A great couple months of Gunpla with some really stellar models.

  • RG Sazabi
  • HG Freedom Strike Rouge
  • MGSD Barbatos

For my birthday I got the Perfect Grade Unleashed RX-78-2 which is like the pinnacle of Gundam models. It’s $300 worth of plastic and I couldn’t be more excited to build it.

👨‍💻 Open source and web community

I hope to pick up again here and I have some projects behind the scenes, but not much to show at this point.

  • Presented “HTML with Superpowers” at Bleeding Edge ATX
  • CSS4 Community Group
  • Web Component Community Group (Open Styleable, Declarative Web Components)

I’m bad at setting calendar reminders for community group meeting times. I hope to be more involved going forward.

👾 Video games

  • Warzone, but probably need to quit for my mental health
  • Reinstalled Overwatch for a friend’s birthday
  • Uninstalled Gundam UC Engage for wasting too much of my time.
daverupert.com

05 May 2024 at 04:56



Refresh complete

ReloadX
Home
(243) All feeds

Last 24 hours
Download OPML
*
A Very Good Blog by Keenan
A Working Library
Alastair Johnston
*
Andy Sylvester's Web
Anna Havron
annie mueller
*
Annie Mueller
*
Apple Annie's Weblog
Artcasting test feed
*
Articles – Dan Q
Austin Kleon
*
Baty.net posts
bgfay
Bix Dot Blog
*
Brandon's Journal
*
Chris Coyier
Chris Lovie-Tyler
Chris McLeod's blog
CJ Chilvers
CJ Eller
Colin Devroe
*
Colin Walker – Daily Feed
Content on Kwon.nyc
*
Dave's famous linkblog
*
daverupert.com
Dino's Journal 📖
dispatches
E L S U A ~ A blog by Luis Suarez
Excursions
Flashing Palely in the Margins
Floating Flinders
For You
*
Frank Meeuwsen
frittiert.es
Hello! on Alan Ralph
*
Human Stuff from Lisa Olivera
inessential.com
*
Interconnected
Into the Book
*
jabel
*
Jake LaCaze
*
James Van Dyne
*
Jan-Lukas Else
*
Jim Nielsen's Blog
Jo's Blog
*
Kev Quirk
lili's musings
*
Live & Learn
Lucy Bellwood
*
Maggie Appleton
*
Manton Reece
*
Manu's Feed
maya.land
*
Meadow 🌱
*
Minutes to Midnight RSS feed
Nicky's Blog
*
Notes – Dan Q
*
On my Om
One Man & His Blog
Own Your Web
Paul's Dev Notes
*
QC RSS
*
rebeccatoh.co
reverie v. reality
*
Rhoneisms
*
ribbonfarm
Robin Rendle
Robin Rendle
Sara Joy
*
Scripting News
*
Scripting News for email
Sentiers – Blog
Simon Collison | Articles & Stream
*
strandlines
the dream machine
*
The Homebound Symphony
*
The Marginalian
*
thejaymo
*
theunderground.blog
tomcritchlow.com
*
Tracy Durnell
*
Winnie Lim
wiwi blog
*
yours, tiramisu
Žan Černe's Blog

About Reader


Reader is a public/private RSS & Atom feed reader.


The page is publicly available but all admin and post actions are gated behind login checks. Anyone is welcome to come and have a look at what feeds are listed — the posts visible will be everything within the last week and be unaffected by my read/unread status.


Reader currently updates every six hours.


Close

Search




x
Colin Walker Colin Walker colin@colinwalker.blog