Chris Corner: The Tao of Demos¹

Category Image 052

CodePen is a place where you can make demos. A Pen can be anything (a painting, a game, a landing page), but by and large, Pens today are demos. Why would you make a demo? Fam, why wouldn’t you make a demo? Demos are one of the most powerful tools we have as designers and developers. But the reason behind making one can be very different. That’s why it always made it hard for me to elevator pitch CodePen: I’d want to list a dozen reasons you’d want to use it, and I’d come across as unfocused. Well, too bad. I like that there is lots of reasons to use CodePen and make demos.

Let’s make an incomplete list of reasons to build a demo:

  • Prove something to yourself. You’ve seen a new library, a new web platform API, or just some kinda something you wanna try. It’s one thing to read a little something about it. That’s good, it helps you slot the [new thing] into some brain bucket where you might be able to find it later. But does it really do what you think it does? Does it? Really? Prove it with a demo.
  • Get everyone on the same page super quickly. I was just in a meeting the other day where a teammate of mine highly encouraged the meeting to start with the design comp. We actually had planned it the other way around. We wanted to go over the requirements and take a look at how the data structures were coming along, then see if the early design was on target. But after switching that up to see the design first, it immediately got everyone engaged and thinking about the same thing. How it ends up on the page is the end goal, after all. There is something about interactive visuals that gets everyone perked up. Come to that next meeting with a demo.
  • Demonstrate a concept in the most minimal way possible. If you’re trying to learn or teach something, removing the extraneous can be an effective way to focus on the core idea. Contextual demos are useful later once the ultra-focused demo has made its point. For example, see how effective Gabi’s Flexbox Playground is. After you understand that core concept, then you can move on to real-world usage.
  • Do it in a sandbox. The concept of a sandbox is usually referencing security. It’s a safe place where you can’t screw up. Cool; useful. But it also can imply that it is untethered. Like prototyping a component without the baggage of the rest of the site. Doing work free from the usual constraints can be freeing — you might think of things you wouldn’t have otherwise.
  • Help fix someone’s bug or help them fix their problem. When someone is stuck while coding, answering them with code is the best. You aren’t just running your mouth, you’re putting money in it. There is a lot of good karma to be had here — answering a question or fixing a bug with a public demo will help that person today, and more people tomorrow.
  • Whimsy. A coding job can be awfully serious. You’re doing important work. Work that affects people’s lives with things they are trying to do. You should take that seriously. But that doesn’t mean everything you do has to be so sober. Get loose. Get weird. Shake it up. Let it all hang out. Code doesn’t always have to be useful. A freaky demo might be just the catharsis the doctor ordered.
  • Build a variation on something. Great artists steal, they say. Grab it, tweak it, make it yours. Could be anything you see on the internet (I use the browser extension CSS Pro to do this sometimes: with it, you can select an element and click a button to whisk it over to CodePen with all the HTML and CSS intact). From a design systems perspective, component libraries are most useful when they have variations you can choose from that serve the needs of anyone using the system.
  • Relax. People like to knit, ya know. And crochet and cross-stitch and sew. Oh, and do crosswords and su-do-ku and that game where you spot the differences across two images. Those things require your brain to be turned on a little bit, but it’s still relaxing. It’s not weird to relax by building a little demo just for the fun of it.
  • Nothing shows you care more than a reduced test case. If you need help with code, the best thing you can possibly do is showcase your problem with as little in the way as absolutely possible. Strip away unrelated code as much as you can. Not only might you solve the problem yourself that way, anyone looking to help will be appreciative that you’re respecting their time.
  • Show off. The kids call it flexing, I think. Make something so cool people just have to stop and look. Everybody deserves a little vanity. You know plenty of people have gotten jobs based on demos they’ve made on CodePen, right? It’s true. Show the world what you can do.
  • Treat it like school. The secret goal of schools is getting you to learn how to learn. I’ll break it to you: if you’re building demos of your own volition outside of an educational context, school worked on you. Good on ya. If you wanted, you could work through a curriculum building code demos. That’s basically what coding schools are.
  • Test something. Does it work how you think it does? Is it actually possible? How do you know if it works if you don’t test it? And equally important: is it worth it?
  • Prep a hiring exercise. Live coding interviews are a little controversial, but asking someone to demonstrate that they can do the job of design and/or development during the hiring process for a job that is design and/or development is a good idea. Perhaps it’s an async thing. How much would you learn about someone if you asked them to think out the considerations around a hamburger menu? What if you asked someone to spend two hours building a tic-tac-toe game playable across two browser tabs using web sockets?
  • Write some code you know doesn’t really matter. There is a good chance you got into this field because you like code. A demo you know you’re going to throw away is proof you still like that journey. You’re a musician taking pleasure in practicing some scales.

If you look at all the wonderful demos above in this very newsletter, some of them will have been created for some of these reasons. But honestly, most demos are a little more throw-away than the ones that make it into The CodePen Spark. You’ll have your own reasons.

I was thinking about all of this after reading Andy’s The art of the demo, which starts:

Nothing enhances written content quite like a well-crafted demo, or collection of demos. They don’t have to be complex either — in fact, it’s better if they’re not complex. The most important thing is that good quality demos can help people really get what you’re trying to explain, especially if reading isn’t the most effective way for them to learn.

❤️


¹ Demtaos? Nah.

Chris’ Corner: React is Good, Bad, Old, Reliable, Stodgy, Stable, and Obsoleted

Featured Imgs 23

There is something about [INSERT MOST POPULAR THING] that inspires people to philosophize. Sometimes it’s a bummer. It’s tough to avoid the never-ending stream of “news” about Elon Musk, which strongarms your brain into having an opinion about him. WordPress, by the numbers, is pretty popular, so I’ll bet you have some kind of opinion worked out about it, whether you even really want to or not. Sometimes it’s interesting. Popular things tend to have high levels of use so people’s opinions can be rather well informed.

React has occupied this spot for a while now. It’s ultra-popular. There are developers who went to a coding school to learn only React, got a job doing React, and that’s that. And nobody in that chain is really at fault because they are getting what they want. The pseudonymous EmNudge wrote React is Holding Me Hostage:

I mean I’m practically a “React Developer” for Pete’s sake. My last company, this company, probably my next company. I can’t seem to avoid it. You’d think I’d stop caring so much after a while, but it just takes one look at the alternative to wonder why you ever stayed.

They go on to explain loads of things that are confusing or bad about React and better alternatives but then ends with five (rather massive) reasons we still use it, and:

And so my current job is React. My next job will be React. The one after might as well.

There seems to be a consensus that “React was good — but isn’t now”. How did we get here? Mat​hia⁠s S​chäf⁠er thinks it’s small steps in Client-side JavaScript and React criticism: What comes next?

There are also several economic explanations for React’s rise to power and continued dominance. For example, in 2019, Charlie O’Hara described React as the Fordism moment that commodified the web further. With React, Facebook introduced an assembly line that standardized the work for developers, turning them from artisans into factory workers.

That feels about right to me. There are a lot of open questions in web design and development. Front-end work is especially squishy, with sometimes what seems like dozens of ways to accomplish essentially the same thing. Any tool that says “do it like this” has a handful of people that dislike it because they don’t want their hands tied and many more people saying “oh god thank you for making this clear.” React, especially when you layer on a styling system, pattern library, state management approach, etc., starts feeling rather prescriptive in a way some developers love (and companies definitely do).

Josh Collinsworth also got spicy with the ultra-spicy quote:

React isn’t great at anything except being popular.

Josh kept those spicy meatballs rolling this week with Things you forgot (or never knew) because of React.

React benefitted mightily from being early to the framework game; it set the standard. But that’s come with severe drawbacks in agility and adaptability. Every decision React’s made since its inception circa 2013 is another layer of tech debt—one that its newer contemporaries aren’t constrained by.

This goes so far as to say that there is literally nothing that React offers technologically that it’s modern contemporaries (like Svelte) don’t do better.

Me, I dunno. I don’t doubt it, but at the same time, you know what they say: better the devil you know than the devil you don’t. I’ve done little things in all the various frameworks and usually left with an “eh, that was fine.” feeling. Nothing so eye-opening that I’m looking for any opportunity to do it again or, lawd help me, switch. But I’ve also got some serious sunk costs. CodePen itself is largely React, and I’m very convinced that changing frameworks right now is not worth doing. I think we’ve really benefited from things EmNudge pointed out: the big ecosystem and evolved tooling. So my mind might not be as open to seeing greener grass.

Say time wasn’t a factor. Say an entire team could be trained properly. What would the technological green grass be? Snap my fingers and have a completed rewrite in SvelteKit? SolidStart? Nuxt? Would there be no question that we’d be better off? I can’t see it just yet. Maybe we’re one new thing away from making that picture. Josh seems to think that might be the case:

What will that new thing be? I don’t know. Maybe it’ll just be the web platform. Maybe we won’t even need frameworks. Maybe it’ll be a framework above; maybe it’ll be something we haven’t even seen yet. Maybe it won’t even be a thing; maybe there will be more diversity of tooling and less coalescing around one single accepted standard (though of all the above options, I’d say that seems the least likely, because again: humans. We’re busy little monkeys and so we like defaults.)

I think, though, that the delta between React and that thing, whatever it is, will continue to grow larger and larger over time.

The pace at which new things arrive is unprecedently fast as well. Many of us lived through times in web browser evolution where, if you were looking a year out, you could be reasonably confident nothing would be that different. That is not the case anymore. Andrew Walpole makes this point:

… a lot of web developers kept a mostly even pace set from the early 2000’s to around 2015, which was fairly methodical, not necessarily stagnant, but pretty manageable to deal with the odd new feature that trickled down the pipe. And I think until now, the repercussions of keeping that pace haven’t yet critically surfaced.

A year from now, the only thing we can be sure of is that times will have changed. I’m still rooting for React, if nothing else, for selfish reasons. Get smaller! Get faster! Make the weird hooks less weird! Support web components! Ship an opinion about styling! Wait, maybe it’s fast now?

Chris’ Corner: Useful HTML and CSS Patterns

Category Image 052

The <table> is one of the grand enemies of responsive design. They don’t wrap (that wouldn’t make much sense) so they can “blow out” the width of a mobile device pretty easily. The overflow property also doesn’t work on them. So you gotta find a way, and it really depends on the data. Sometimes a row of table data is pretty independently useful (imagine a row of employee data) so making all the <tr> and <th>/<td> element display: block and stacking them works. But that doesn’t work for data that needs to be cross-referenced. I think there are 3-4 other patterns that involve shuffling the data around to be more narrow-screen friendly. The old group of jQuery plugins Tablesaw from Filament Group showcase some of them.

Lately, I find rather than dig around for a display-altering solution, people just wrap the table in a <div> and let that <div> have overflow. So now you’ve got a table that you can scroll/swipe around without really changing how the table looks. I find myself consulting Under-Engineered Responsive Tables by Adrian Roselli on how best to do that regularly.

Ryan Mulligan has a cool take as well in Full-bleed Table Scrolling on Narrow Viewports. The “full bleed” part means using the edge of the browser window. Which you might otherwise not! Typically there is padding on the left/right (“inline”) edges of content, which would also be limiting the width of the table.

Demo

The blue line in the screenshot above shows the padding on the column of content, which limits the width of the content inside there, but the table is explicitly pulled out from it to the edge. It’s a little thing but it’s classy!


Josh Comeau’s tutorial Animated Pride Flags has lots of fun things to learn along the way of creating a controllable version of this:

Notice that staggering is a big part of the look here. That happens with slightly different values to animation-delay. Since Josh used React to created the DOM for this, the loop can output those values as inline styles and use the number of iterations that map provides to stagger the value.

But wait! Maybe CSS should be helping us here, rather than us having to invent our own way to stagger things, right? That’s what the sibling-count() and sibling-index() proposal is all about. I’m a fan.

Josh’s tutorial basically just starts here and then covers more and more details. I especially like the bits of also stagging how much any given column “billows”, which is another use-case of staggering a custom property value. Also don’t miss the bits about double-stop color gradients and rounding width values to prevent awkward pixel gaps.


How should I mark this up? is always fun trivia. For me, anyway, I’m a very exciting person. Sometimes HTML has pretty cut-and-dry right and wrong ways to do things, but sometimes it doesn’t. There are differents ways with styling tradeoffs, accessibility tradeoffs, amount of markup tradeoffs, etc.

Lea Verou found a good one in What is the best way to mark up an exclusive button group? In other words, a group of buttons where only one can be active at a time. A multi-toggle? Lea, and plenty of other people, assumed that a group of <input type="radio"> is the right answer (only one radio button can be active at once), and then style them like buttons. I thought about <select> too which can only have one active choice, but no way are you going to be able to style that as buttons, even with the wildly more styleable <select-menu>.

Léonie Watson stepped in with advice that essentially boiled down to: if they look like <button>s, you should use <button>s, so there isn’t “a mismatch of expectations in terms of keyboard interaction and shortcuts.” Interesting!

Lea thinks maybe we need a <button-group>. Again, I’m a fan. I would have even kept <hgroup> around, me, for grouping multiple headers.


Have you heard this (correct) advice? Placeholders aren’t labels. Like, don’t do this:

<input type="text" placeholder="Your Mastodon Profile" />

Do this:

<label for="mastodon-profile">Your Mastodon Profile</label>
<input type="text" id="mastodon-profile" placeholder="https://fosstodon.org/@codepen" />

A placeholder can be a little bonus hint or something, but even then, if that hint is important it should be accessible text which placeholder text is not.

I’m thinking of that because I saw Stanko Tadić’s CSS only floating labels. Floating labels is a pattern where text that looks like placeholder text (text within the input) moves away from the input but remains visible. This has gotten a bit easier as of late with the :placeholder-shown pseudo-class.

Demo

What I like about the floating label pattern is that it continues to use <label>, so the accessibility remains. It’s also just kind of clever and fun. What I don’t like about it is that I don’t think it does anything truly useful. I’ve heard proponents of it say that it “saves space” because the label is inside the input. But it’s only inside the input until it’s focused, then it moves out, and it moves out to somewhere where it needs to remain visible and have space. So……… why don’t you just put the labels where they move out to in the first place? Kinda feels like movement, for movement’s sake.


If you haven’t tried to create a password with Neal Agarwal’s * The Password Game yet, you really should give it a crack.

Lol. And there is plenty to go even after this stage.

Chris’ Corner: Clever CSS Ideas & Explanations

Category Image 052

If you think frosted glass effect in CSS, you probably think of the backdrop-filter property. Just backdrop-filter: blur(10px); will do the trick. I still think the look is kind of cool and fresh, but I should check myself a little here as the effect was popularized in the iOS 7 release which was 10 years ago 🫠.

Here is a fresh take though: Frosted Glass: Depth-based blur in CSS (make sure to mouse around to see the dynamic effect, and scroll down to see the effect on different backgrounds).

The how-to is that layered blurs are masked and the mask moves with the mouse. I love clever stuff like that, which ends up fairly simple.


The above demo is a nice demonstration of masking, actually, because it’s doing something that is uniquely mask-y: using a gradient. The other concept that can cut out parts of something is a clip-path, but with a clipping path, any given part of an element is either clipped or not, whereas with a mask, an area can become partially transparent.

Ahmad Shadeed has a recent article on CSS Masking that does a good job of explaining how it all works and what you can do with it.


There is this little design concept that if you have nested elements that both have border-radius, they can’t have the same border-radius otherwise they tend to have a weird little hump in the middle and essentially just look off and not particulary professional. I wrote about this in 2011 and have had many people thank me over the years! (not that I’m the first.)

The general thinking is that you subtract one from the other, and it comes up from time to time. Adam Argyle recently noted that there is a way to solve this with no math at all, but it’s Chrome-only at this time.

This uses overflow: clip; and overflow-clip-margin: content-box; which this is the first I’m hearing of the latter! I like it!


I feel like we’re doing a good job of talking about paths this week so lemme slip another one in here: Jhey’s Circular Text with CSS?. To be clear: there isn’t a normal first-class CSS citizen kinda way to say “set this text on this path”. Unless that path is a straight line, I suppose. SVG has the <textPath> element and that’s really what you want here if you’re going to this even semi-seriously. But there is some trickery to be had here!

This makes me feel like Captain Old again saying I wrote about this in 2012, but here we are. The trick then was to break the text into individual character <span>s and then transform them all around a shared origin:

Jhey’s idea still uses a monospace font and breaking the characters up into spans, but there is more clever math involved. He’s got it set up so however many characters you use, the complete one full circle no matter what. The secret is trigonometric functions, which are only freshly available in CSS. Plus he took the time to make sure there is screen-reader-friendly text in there too, as text-as-spans is a nightmare that way.


If you read all the stuff above and felt some version of ughkg CSS is so hard, maybe you’ll find some solace in Mike Aparico’s Why we’re bad at CSS. Part of Mike’s point is that CSS gets harder the more you try to avoid it, or apply abstractions that are too heavy-handed.

We want our styles to be generic enough to reuse in different contexts but not so generic that we have to constantly repeat ourselves in those contexts.

I feel like there is a tendency for people who feel like they have a handle on CSS to have essentially invented their own methodology (whether they choose to share it or not). That might seem like a failing of CSS or something that you need to invent your own system to be effective with it, but ultimately I think that’s true of any language. You build up your own ways of doing things that works for you and run with it.

Chris’ Corner: Hot New Web Features

Category Image 052

Yuri Mikhin and Travis Turner over at Evil Martians implore us: Don’t wait, let’s use the browser Contact Picker API now. As I write, it’s only available essentially on Chrome for Android. But the spec exists and iOS also has an experimental flag for it. I’m an iOS guy so I flipped it on. I actually didn’t even know you could do that! (Settings > Safari > Advanced > Experimental Features).

You can see the contact picker in there and other cool stuff like text-wrap.

Now if you’re in a browser that supports it…

The select method will show users a modal UI to select contacts, and it will then return a Promise. If the promise resolves, it will return an array (even if only one contact was selected) filled with ContactInfo interfaces.

I’m sure you can imagine it. You tap a button or something, and it launches a contact picker. You select a contact from your device’s contacts. It returns data from those contacts, like names, emails, and phone numbers.

Not every app needs it, but I imagine a lot could make use of it (particularly in a progressive enhancement style). Does your app have any kind of invite or sharing UI? You could use it there. I’m thinking of something like Figma’s share modal:

I’m just on my own to write in email addresses in there. If this was Google Docs, well, they have the distinct advantage that they already have a contact list for you thanks to the likelihood that you also use Gmail and keep some form of your contacts there. But very few of us are Google. The Contact Picker API levels that playing field!

I gave the Evil Martians demo a spin, and it works great.

Weirdest part? No “search” ability in the contact picker popup.

If there were only some kind of easy-to-use web app that makes it really easy to play with new APIs like this and get a feel for them and save them for later reference. Some kind of playpen for code.


I think I was bitching about text-wrap: balance; the other day. Just like me, to be given such a glorious new property that helps makes headlines look better across the web and find something to not like about it. The balance value takes multi-line text and makes all those lines as roughly even as it can. I feel like that looks pretty good for headlines, generally. The kicker is that “balancing” isn’t always what people are looking to achieve, and what they really want is just to avoid an awkward orphan single word from wrapping down onto the next line.

Adam Argyle said to me: have you seen text-wrap: pretty;?

  1. No, I have not.
  2. Awww, pretty is a great keyword value in CSS.

I googled it and found Amit Merchant’s quick coverage. Then I set about making a demo and trying it out (only works in Chrome Canary until 117 ships to stable).

See what I mean about balance above? There is just far too much space left over above when all I really wanted to do was prevent the single-word orphan. Now pretty can prevent that.

That’s so generically useful I might be tempted to do something like…

p, li, dt, dd, blockquote, .no-orphan {
  text-wrap: pretty;
}

… in a “reset” stylesheet.


People reflecting on formative moments in their lives usually makes for a good story. And especially relatable when they are like: “… and that’s how I became a nerd.” That’s what happened when Alexander Miller’s dad gave him some paper:

When I was a kid, my dad gave me a piece of paper with a grid printed on it. It consisted of larger squares than standard graph paper, about an inch in size. It was basically a blank chessboard.

GRID WORLD

I didn’t become an incredible code artist like Alexander, but I can still relate. My first really “successful” programs were grid-based. First, a Conways’ Game of Life thing (that I’m still a little obsessed with) and then a Battleship clone (like Alexander’s father). These were absolutely formative moments for me.


Do you know one of the major JavaScript frameworks better than another? I bet you do, don’t you? You’re a Svelte groupie, I can tell.

Component party is a website that shows you how to do the basic and important stuff in each major framework (React, Svelte, Vue2/3, Angular, Lit, Ember, and several more). Very clever, I think! It’s helpful to know one of the frameworks so you can verify that’s how you would have done it there, then see how it works in another framework. Like if you need to loop over data in React, you probably end up doing a .map() thing, but in Svelte there is #each, where in Vue it’s a v-for attribute. I don’t work across different frameworks enough to have all this memorized so a big 👍 from me for making a useful reference here.


“Sometime this fall (2023)” is all we know for the release date of macOS Sonoma. Normally operating system releases aren’t that big of a deal for web designs and developers, who are more interested in browser version releases. But Sonoma has a trick up it’s sleeve.

With macOS Sonoma, Apple goes all-in on the concept of installable web apps. They’re highly integrated in the overall macOS experience and don’t give away their web roots by not showing any Safari UI at all.

Thomas Steiner, Web Apps on macOS Sonoma 14 Beta

Installable web apps, you say? Like… PWAs? (Progressive Web Apps). The point of PWAs, at least in my mind, is that they are meant to be real competitors to native apps. After installation, they are clickable icons right there next to any other app. Level playing field. But to become installable, there was kind of a minimum checklist of requirements, starting with a manifest.json.

The word from Apple is that there are literally zero requirements for this. You can “Add to Dock” any website, and it’ll work. I guess that means it’s possible to have a docked app that just entirely doesn’t work offline, but 🤷‍♀️.

Sites installed this way do respect all the PWA mechanics like one would hope! Sites with a manifest won’t show any Safari UI at all. I don’t think there are install prompts offered yet, so users would have to know about this and/or find the menu item. There are prompts though in regular Safari if users go to a website that is already installed (to “Open” the “app”).

Overall, apps installed this way look pretty nicely integrated into the OS. But I also agree with Thomas’ wishlist, all of which seem like they would make things much better still.

Chris’ Corner: Design

Category Image 052

Rauno Freiberg wrote an article getting into the CSS implementation of some of the neat features of the most recent Next.js website. Gotta love an article showing off how things work on a really top-notch modern design. Thoughts as I go down the list:

• The randomized dots on the switchboard look super cool. Just a tiny little box-shadow does the trick, but they need to be animated with opacity because animating opacity is super performant and animating box-shadow is very not. I wonder if we’ll ever get past gotchas like that? Also, the dots aren’t exactly random, they are just placed seemingly-randomly. What if we had real randomization in CSS? It’s been being talked about again seriously.

• The offset focus styles were done with a box-shadow. It was noted that outline now follow border-radius across the board, which opens up that door, and is powerful thanks to outline-offset. I think I would have gone with outline-offset because I like thinking about how easy that is to control. One example: if you find that your focus styles are getting cut off by hidden overflow, you have the option to use negative offset to pull the focus styles inside where they won’t get cut off instead.

• To pull the quotation marks of a blockquote toward the inline direction a bit, lining up the words, a bit of negative text-indent was used. That’ll work cross-browser, but it’s a shame we have to rely on a magic number rather than the purpose-built hanging-punctuation property. Let’s root for better support there.

• Love to see that fluid type in action! I see the blog post is using clamp() with a viewport unit. I’d recommend making sure that middle parameter factors in a little rem unit of some kind so that user font sizing is honored. The production website actually uses max(48px,min(5vw,76px)) and I’m curious about the change there. Seems… the same? And actually, since I bet the headline is an isolated React component, it’s kinda begging for the whole thing to be a container and for the header sizing to be done with a cqi unit instead.

• The “gradient tracking” trick using a moving SVG gradient background is just incredibly cool and absolutely one of the nicest effects I’ve seen anywhere this year. 5 stars.


I did a talk somewhat recently called “Modern CSS in Real Life,” and now I’ve turned it into a blog post in case digesting it that way is of interest to you.

One of the things I dwell on in the beginning is the use of Logical Properties in CSS and how you get some nice benefits out of using them. One is that I think it very slightly makes CSS easier to reason about. But the bigger one is that it helps a site that is being auto-translated behave better. In particular, I showed off an article that would have ended up mucher nicer when being translated from the Left-to-Right English default to Right-to-Left Arabic.

I thought of that again the other day as I came across the Arabic Design Archive. It’s interesting to look at designed items that need both language directions at the same time.

I like how the main thrust of the design is RTL, forcing the English headline to be right-aligned, but still looks great. Then in the smaller and slightly longer text, both directions are accommodated nicely by that vertical bar which both inline directions butt against.

Oh and speaking of design archives… archive.design is:

A digital archive of graphic design related items that are available on the Internet Archives

Chris’ Corner: Scoping

Category Image 052

If I were going to argue against @scope, the new CSS feature, I might say that CSS already has scope. Like, every selector is “scope”. If you say .el, you’re saying “scope this bit of CSS to elements that have the class name of ‘el'”. But then someone might tell you, ok, but what about “donut scope” 🍩? Donut scope is a way for a scope to stop. Keith Grant shows that off in a recent article:

@scope (.card) to (.slot) {
  /* Scoped styles target only inside `.card` but not inside `.slot` */
  :scope {
    padding: 1rem;
    background-color: white;
  }

  .title {
    font-size: 1.2rem;
    font-family: Georgia, serif;
  }
}

Imagine that applied to this HTML:

<div class="card">
  <h3 class="title">Moon lander</h3>
  <div class="slot">
    <!-- scoped styles won’t target anything here! -->
  </div>
</div>

I’m not sure how I feel about that, honestly. Don’t hate it, but also can’t think of a time when I really really wanted that. That might be because it’s never existed so my brain didn’t try to reach for it. But container queries didn’t exist before, either, and I think we all pined for those anyway. Still, it’s a bit of a +1 for @scope because it’s a thing we can’t do any other way.

If I was still arguing against @scope, then I’d say, well, it turns out actually you can replicate donut scope, thanks to another modern CSS feature, :has(), as Bramus blogged:

.from ~ :has(~ .to) {
  outline: 1px solid red;
}

And actually, you don’t even need that.

So I’m afraid I have to rescind the point I gave @scope. Are there any other tricks up its sleeve? It does have one! It’s called proximity. This is just kind of a bummer situation in CSS:

<div class="green">
  <p>I’m green</p>
  <div class="blue">
    <p>I’m blue</p>
  </div>
</div>

If you wrote the CSS like this:

.blue p {
  color: blue;
}
.green p {
  color: green;
}

Then both paragraphs are green. Just because the green selector came second. That’s just how CSS selectors work. Both have the same specificity so the latter one wins. We can fix this with scopes:

@scope (.green) {
  p {
    color: green;
  }
}

@scope (.blue) {
  p {
    color: blue;
  }
}

Now that second paragraph is properly blue because the closer scope wins (and it doesn’t matter what order they are in). This is nice for color theming when you use classes to change the theme “higher up” in the DOM. But it doesn’t save you from increased specificity of other selectors, which are probably a more common “bug”. Still, I’ll say this is worth a +1!

Still, I’m not salivating for @scope. It doesn’t solve any big pain points that I’ve personally had. But maybe it does for you, the web is a big place, so all good.

I’ve said it before, but I think the super old-school idea of wanking a <style scoped> into the DOM anywhere and having those styles scoped to the parent is still a cool idea and actually does solve problems. Coupled with :scope { } it means I don’t even have to think of a name of how to select an element, yet still get the ability to apply pseudo-elements and the like. So inline styles with more abilities. And without having to name anything, there is no possible way for the styles to leak anywhere else. Sure, it’s neat to stop style leaking with a @scope too, but because I have to apply it to a class, I need to make a super obscurely named class like .card_987adf87d (a build tool concern) for it to actually worry-lessly “scope”.

The post Chris’ Corner: Scoping appeared first on CodePen Blog.

Google Log In

Featured Imgs 23

CodePen offers it now!

Until recently, we only offered GitHub, Twitter, and Facebook social login buttons. Twitter log in totally stopped working on us (are you surprised?) last week. It turns out that was by far the least popular option for logging in anyway, so we just pulled it down and replaced it with Google. A massive amount of you have @gmail.com email addresses (which doesn’t add in people who use Gmail on custom domains), so we knew this would be a popular choice.

There is something important to know about all this!

The way our social login works is that it’s just an email matcher. Whatever email address we get back from that social login request we match with the account email here on CodePen and log you in. You don’t have to remember which social service you used to sign up with or anything like that, you can mix and match and use whatever you want, as long as the email addresses match. So when we pulled down Twitter, nobody was locked out or anything. Especially as everyone has a password here on CodePen too and you can log in that traditional way. (And if you don’t, you can always reset the password to make sure you do.)

One more funky little thing to know: the Log In and Sign Up buttons are literally the same thing. We have different pages for it because it makes for more obvious UX, but the behavior is the same. If you try to Log In and don’t have an account on CodePen with that email, we’ll just make you one quick. If you try to Sign Up but already do have an account on CodePen, we’ll just log you in.

Chris’ Corner: Dithering

Featured Imgs 23

Dithering is a vibe:

Dither is an intentionally applied form of noise used to randomize quantization error, preventing large-scale patterns such as color banding in images. 

Wikipedia

For an academic PDF, this is pretty approachable.

In the web world, I typically think of it as associated with “indexed colors” images like PNG and GIF can do. For example, if you Save for Web from Adobe Photoshop as a PNG or GIF, you can whack down the colors super low and see some cool dithering.

Here are the three dithering choices my copy of Photoshop has:

“Noise” — 11.1K
“Pattern” — 6.8K
“Dithering” — 7.7K

They are all kinda cool looking if you ask me. More relevant, they made the image smaller in size and require less colors to display. Meaning their aesthetic is like “old-school computing” or “retro video games”.

Acorn, a much more economically friendly image editor, can also dither:

Can you do it right on the web, though? Darn tooting. Well, you can replicate the aesthetic anyway, since you can read images, and we’ve always got tools like <canvas> to play with.

Andrew Stephens made a Web Component that does exactly that. You pass it an image, it reads it and does cool dithering magic, and outputs it onto a canvas for you. He wrote it up in a quick blog post Improved Web Component for Pixel-Accurate Atkinson Dithered Images where he outlines some improvements to this latest version of the component.

I snagged the code and chucked a copy of the web component JavaScript onto our Asset Hosting so I could make a Pen with it. I did have to make a few changes. I had to make the Web Worker inline instead of referencing another file. Then I had to make sure to set img.crossOrigin = "Anonymous"; so I could reference an assets-hosted image as well. You don’t have to do those things if you’re working with all relative paths locally.

This is the original image:

And here’s a Pen where I dither it on-the-fly:

Cool.

This whole vibe matches with another thing I saw recently:

https://end.city/

Refresh the page for a randomly generated busted-up old castle thing. With the random flags and glyphs and icons and stuff I feel like it’s for something specific, but damned if I know what it is.


Speaking of very specific nerdy pursuits, I enjoyed reading Philip Walton’s very custom pursuit of improving LCP (Largest Contentful Paint) in unknown situations. The blog post is Dynamic LCP Priority: Learning from Past Visits.

The overall concept is fairly simple.

  1. One element on the page is responsible. That’s the LCP.
  2. You have no idea what element that is on a dynamic site.
  3. If you did know what it was, you could improve your LCP score by using the fetchpriority attribute on that element (if it’s, say, an image). This can be used to make the browser prioritize loading and rendering that element, improving LCP.
  4. You can’t just use fetchpriority willy nilly, because if you’re wrong, you could actually harm LCP.
  5. You can actually figure out what the LCP element is… after the page has loaded.
  6. That’s too late to be useful, but if you save that information, you could pluck it out of storage and use it to put that fetchpriority on the right element for every different page of your site.

Phew. That’s friggin complicated. Not exactly the lowest-hanging web performance fruit. But it’s cool and nerdy and if you’re chasing the best possible numbers, it can go in the toolbox.

Chris’ Corner: A Balancing Act

Category Image 052

If you’re a super normal person like me, you’ve gone to war with typographic widows and orphans many times over your years as a developer, trying to ensure they don’t happen and ruin anyone’s day. You know what I mean, a headline with one silly little word that has wrapped down onto its own line. If only you could add a couple of soft returns in there to prevent it. You can, of course, but you know better. A soft return might fix a problem at one particular container width, that break causes an even more awkward problem at another container width.

One technique that is sometimes employed is to insert a &nbsp; (non-breaking space) between the last two words (maybe even three?) of a headline (or paragraphs, if you’re nasty).

This little piggy went to&nbsp;market

None of us can be troubled to hand-code that if we’re in charge of the HTML of headlines regularly. I wrote my own PHP to split headlines by word and manually insert the non-breaking space on CSS-Tricks a decade or more ago. It can be done in client-side JavaScript too, naturally, but nobody wants to see that reflow.

Finally, along comes the web platform with something that looks like a solution:

h1, h2, h3 {
  text-wrap: balance;
}

Tyler Sticka has an article about this new CSS and offers this clear comparison:

uh oh — at this width, we get an orphan
yay — no more orphan (or widow or whatever, my brain cannot learn which is which) with text-wrap: balance

That “balanced” headline nice, generally a much more pleasing result for multi-line headlines.

But notably, what is happening here isn’t explicitly orphan-fighting. Richard Rutter makes this clear in an article of his own:

What this is not is control over widows and orphans. My previous examples show how the text balancing algorithm in Chrome Canary does indeed prevent a widow (the single word dropped down), and that’s a highly likely outcome. But you have to remember that the balancing job shortens the lines, so this isn’t an approach you would take to prevent widows at the end of paragraphs. In fact Canary limits balancing to 4 lines.

So it works for avoiding orphans/widows, but almost as a side effect of the balancing. In a follow-up article, Richard shines a light on what could be a future answer:

Bit by bit, the CSSWG seems to have been converging on a potential solution. In the current draft of the CSS Text Module Level 4, there is mention of Last Line Minimum Length. …

Amelia Bellamy-Royds took the Last Line Minimum Length idea and proposed a solution with a new min-last-line property. Her proposed property would specify a minimum length for the final line, and a minimum length for the penultimate line once you’d dropped a word or more down to address the short final line.

Ship it. Especially if it works on paragraphs in multi-col.


✨ Outstanding blog post alert! ✨

Future CSS: Anchor Positioning by Roman Komarov.

We only have the most rudimentary way to “connecting” the position of two elements in CSS today. Take an element that has non-static positioning, and you can absolutely position an element within that context. That’s about it. Kinda sad when you think about it — especially as it comes up relatively often. Mostly in the context of tooltips and context menus, where you want an element (of arbitrary DOM position) to be positioned right next to the element that needs the tooltip or context menu.

This positioning challenge is usually done with JavaScript (the cow paths have been laid), by way of getBoundingClientRect and doing various geometric math to make sure the element doesn’t wank off the edge of the browser or in any way become “data loss” as we like to say in CSS. More challenging that it seems. Letting CSS do it seems awfully nice.

CSS tends not to focus solutions on one exact need though, preferring instead to solve the problem conceptually with primitives that might solve lots of use cases. This is where Roman gets clever with things and makes examples like this connecting elements with pointing arrows (involving SVG):

But also some cool demos with a slightly more practical twist, like moving highlight menus:

Jhey Tompkins’ article on this, Tether elements to each other with CSS anchor positioning, covers things from first principles and is probably a better reference for the syntax. But Jhey being Jhey, there are some weird and clever demos as well, like this emoji finger form:

It’s a Pen, naturally.


There is a <meter> element in HTML, and Dana Byerly does a great job of showcasing it. It’s a natural fit for stuff like “You’ve uploaded 47 of your maximum 100 files” in a visually more understandable way. There is some accessibilty stuff to get right though, including using “fallback text” (the text within the element) which is used by some screen readers and will certainly be useful context. Free basic styling is nice:

Live tests as a Pen, naturally.


I like the term “CSS micro-framework” as coined here by Blake Watson.

  • May include classes for building grids, components, etc. Typically limited, though, because of the next rule.
  • Under 10kb minified and gzipped. I feel like you can’t claim “micro” or “lightweight” beyond 10kb.
  • JavaScript is optional and is not supplied by the framework.

Examples:

They aren’t just a reset and they aren’t… Bootstrap. They aren’t necessarily “classless” either, which is a whole other category of framework that only styles things based on HTML selectors.

And then, another possible ending:

As we go deeper down the path of minimal CSS starters we end up at the logical conclusion—you might not need a framework at all.

Chris’ Corner: Have You Ever

Featured Imgs 23

Have you ever heard web developers talk over each other? I enjoyed Mat​hia⁠s S​chäf⁠er’s Client-side JavaScript and React criticism: What comes next?. It’s a solid baby-bear take on meta discussions on the state of building websites.

I hear JavaScript critics yelling: “Just use Progressive Enhancement! Sprinkle some JavaScript on your static HTML! Don’t believe those fraudsters, grifters, bastards, idiots that lied to you!”

Again, I understand the frustration. Nonetheless, I don’t think the current situation can be explained in terms of fraud, lies, gaslighting et cetera.

I think we’re at the point where we agree that there is, in general, too much client-side JavaScript and it has negative implications. But it wasn’t the fault of a criminal overloard.

At the risk of being reductive, it came out of developers inventing things that helped them build the things they needed to build in a way they liked, partially because the web platform itself wasn’t giving it to them. They just dropped a few balls along the way. Now we can pick them back up.


Have you ever heard someone say “Put JSX in the browser you cowards!” and scratched your chin and thought “Yeah! They should!” well perhaps you could get involved with ESX, which is as far as I know the closest thing going on that. And if you say “Why? Template literals are that”, then I think you have some catching up to do because that’s been done six ways to Sunday with all sorts of different libraries. Perhaps the biggest push was Google’s Lit, which I think even Google has gotten bored of.


Have you ever thought “TypeScript is pretty complicated, but at least it’s not Set Theory!”? Never fear, Vladimir Klepov is here to ruin that for you with Making sense of TypeScript using set theory. I kid, I kid, it’s actually a nice way to think about complex types. I’ll steal the first two bullet points of the big reveal:

  1. Our universe is all the values a JS program can produce.
  2. A type (not even a typescript type, just a type in general) is some set of JS values.

Have you ever read that web performance concerns are 80% client-side concerns and 20% back-end concerns? Tim Kadlec verified that decade-old claim recently in The Performance Golden Rule Revisited. It’s still true. It largely means you’ll see more benefit from focusing your web performance improvements on client-side things. I’ve always thought, yes, that’s true, unless that 20% is really bad, because that 20% is the first thing that happens during website loading. That’s why metrics like Time to First Byte (TTFB) are important because they measure that first response from the server. Jeremey Wagner had a post about that this year: Optimize Time to First Byte.

Hyperplexed Videos

Featured Imgs 23

Hyperplexed makes amazing Pens on CodePen! If you’ll remember from our Most Hearted of 2022 wrap-up, in 2021, he got one place on the Top 100, then in 2022 had nine, including the #1 spot.

But not only does he create great work, he’s also an educator, showing off how some super modern and classy effects are pulled off with web technologies. Where? YouTube! It’s an easy subscribe since every video is a pleasure to watch. They tend to assume an intermediate level of knowledge, which I find a nice comfortable niche.

Here’s a few recent ones:

Gotta love the CodePen usage and shout-outs, right? 💪

That URL pen.new is sure easy to remember and get started with, and works for everyone, of course.

The post Hyperplexed Videos appeared first on CodePen Blog.

Chris’ Corner: Little Websites

Featured Imgs 23

Gotta love a good little single-purpose website, right? I generally love what they do, what they say, or what service they provide, I love them on some deeper meta-level. Like someone cared so much about this idea that they just had to produce something, and a website made the most sense. Global reach! Easily findable and savable! Multimedia! It will last forever unless corporate publishers ruin it. Well done, people. You world wide that web.

Here are a few I’ve saved recently that seem to have been making the rounds.

Keyboard Accordion

I still feel like the Web Audio API is underused overall and has much untapped potential on websites, whether audio focused or not.

Broider

Never use border-image without help.

Modern Font Stacks

It is perfect timing for a new site like this. Web fonts are a big pill to swallow for web performance, so if you can get away without using them, that’s kinda nice. And nowadays, it doesn’t mean entirely boring choices.

Perfect Freehand

Of all of these, I feel like this is the one I’m going to need the most and will be the easiest to forget.

Just lemme draw something on the web real quick!

Me, regularly

Better Mobile Inputs

Everyone should do an audit of their web forms and see if you can improve them in any small way. Me and this site included! Almost certainly, there are mobile-specific things that could be improved.

Calligrapher.ai

Get a cool rendering of text without having to hand-draw it (just type). I like how you can just keep re-generating it (and adjusting the controls) until you get one you like.

Chris’ Corner: A Little Back and Forth

Category Image 052

I feel like y’all out there are like: ya know what I could use this week? A scattered collection of interesting links with light commentary about what is interesting about them or how they connect with the modern web zeitgeist. No worries gang, I got ya.


I like Josh’s take on all this coding + AI stuff and the fear of lost jobs. It’s terrible timing for all this because fricking tons of people are losing tech jobs in layoffs right now. But that isn’t because AI is taking their jobs, it’s economic fears, correcting overhiring mistakes, and some greedy “ooo look we can do mass layoffs and not get much flack for it because everyone is doing it”. Anyway here are some quotes from Josh’s article:

… since the beginning, there’s been a concern that web developers would be made redundant by some new technology. In the 2000s, it was WordPress. In the 2010s, it was Webflow. In the early 2020s, it was “no code” tools.

[on GPT-4 building simple website from napkin drawing] … we haven’t needed web developers to build these sorts of pages in decades. There is an enormous difference between this HTML document and the sorts of code front-end developers write today.

Code snippets are all over the internet, and are often generic. By contrast, every codebase is unique. There are very few large open-source codebases. How’s the AI supposed to learn how to build big real-world projects?

I actually think that this could increase the total # of developer jobs.

Certain tasks might be delegated to an AI, but not many jobs.

Normally I skip or roll my eyes at people’s hot takes on AI stuff since there is just so much of it right now, but again I think Josh’s takes here are smart. It’s also in agreement with most other takes I’ve read on this. Generally, people are writing articles trying to address people’s fear, but the fear seems a little invented.


A little accessibility back and forth!

I suppose the powers that be should listen to web accessibility experts over me, but I’m more inclined to agree with Ben here. The cowpaths are there, pave them.


Another back-and-forth took place last month between Alex Russell’s The Market for Lemons and Laurie Voss’ The case for frameworks. As much as I prefer to rate these arguments on the written word entirely, the fact is I know that both of these people are Very Big Web Personalities that both very much like to argue. Laurie for the most part brings baby-bear porridge to the party and I like that, but I also don’t mind Alex bringing down the hammer and taking hard-line stances on web performance, mostly because not a ton of other people do that and the web could use the pushback.


A good amount of web platform arguments end up being about JavaScript frameworks and the whole idea of SPAs. Probably no question we overdid it as an industry on the SPA thing. One side plot here though is that this was all happening during a time when the web was perhaps a bit more threatened by “native” apps than it is now. Native apps have a certain feel to them that is a bit different than web apps generally, and no small part of that is how they tend to animate their state and page transitions moreso than web apps do. SPAs made that far more possible than we were able to do on standard new-page-loading web apps.

Transitioning interfaces and page transitions in non-SPAs isn’t just sitting around waiting to be solved though. I think of three things:

  1. Swup is a JavaScript library just for this stuff which is being actively developed. There is also Taxi.
  2. Turbo looks still actively developed too, and while it’s not about transitions specifically, it’s about making a non-SPA behave like an SPA meaning you don’t need to change architectures but can still benefit from a page that never 100% reloads.
  3. The biggest deal is still the View Transitions API which has just landed now in stable Chrome. No libraries needed. No SPA needed. Just straight-up animations between state and page changes in native JavaScript.

I mentioned the other week that Firefox fixed this old bug a bit related to drop caps, but really, or I guess in addition to that, the best thing that can happen to drop caps is the CSS initial-letter property. I should have linked up Stephanie Stimac’s article Greater styling control over type with `initial-letter` which digs into that and strongly makes the case.

Ethan Marcotte has a wonderful video showing how to do drop caps well, but it’s frustratingly complicated. Really looks like initial-letter is the answer to all this.

Chris’ Corner: Fresh SVG Drop

Category Image 052

Lemme show off some cool SVG-related things this week. Gotta love SVG. It’s this graphics language built right into the web platform that has a ton of capability and is always right there waiting for us when we need it. Thanks the web!


Portability is a cool SVG feature. You can copy and paste a bit of SVG right into HTML and that’s not only functional but actually, a pretty good way to do it. That way you can style it freely and no additional network request is made.

Ya know… that’s how our icons feature works here on CodePen.

The Assets panel on CodePen offers one-click SVG icons from Font Awesome.

And it’s a decently common way to deliver UX on a set of SVG icons generally. For example, check out Monika Michalczyk’s Shapes project, where you can just click any of them and get all the code right on your clipboard. They paste into Pens really nicely, of course.

I like how weird they all are. Nothing practical in here, just lovely interesting shapes. I bet they would morph into each other in fun ways.

Or here’s Robb Knight’s Mac 30th Anniversary Icons which are super cool minimalist representations of Macs over the last many decades.

No click-to-copy here, but the downloaded versions you can drag-and-drop into the CodePen editor if you want to play with them there.

You can learn the SVG syntax. I guess that’s kinda obvious but maybe not to everybody as SVG is often the output of tools. You can export SVG from Figma and Illustrator and stuff and you didn’t have to learn the syntax, you just use the output.

Just SVG paths alone are fairly complicated and something of a sub-syntax. I wouldn’t say I know it super duper well, but I know enough that I wrote a guide a while back.

Some of the other attributes of SVG elements are a bit more straightforward like circle essentially has a central point at an X, Y coordinate and then a radius. Sébastien Noël has a new guide on fffuel that helps understand a lot of these syntaxes:

I just love interactive code examples like this.

But leave it to yuanchuan (creator of css-doodle) to Experimenting [with] A New Syntax To Write SVG. It’s centered around the idea that the stylistic SVG attributes can be moved to a CSS-like syntax, which doesn’t just select and style SVG, but creates it.

Check out how easy it is to play with on CodePen.

OK I saved the best for last for you: Draw SVG rope using JavaScript (and it’s not just because there is an excellent CodePen demo) from Stanko Tadić. And not just rope like a line that maybe has some basic physics, but real-looking twisted rope, like the kind that might be holding a large ship to dock. The journey, which is excellently documented, involves really digging into the SVG APIs, doing interesting math, and knowing about fancy algorithms and stuff (see “Chaikin’s method” for rounding). I like it when you can tell someone is clearly captivated by an idea, gets it all figured out, then documents it so well the output and the explanation are equally interesting.

React Email

Featured Imgs 23

Only in the last year have I started switching us over to MJML here at CodePen to help craft our HTML emails. Aside from a few minor rough edges, it’s been a nice upgrade from hand-writing the email HTML. Not only was that tricky and time-consuming, but it was also error-prone. The switch-over was in part inspired by some Microsoft Outlook bugs with our CodePen Spark email which MJML helped resolve.

But I have been eying up React Email recently. It’s really just JSX Email as React features are largely irrelevant here. It’s just a nice templating language abstraction. I feel fairly comfortable in JSX so that’s appealing, but so is the modern take on things including a hot module reloading preview and all that.

We don’t really need the sending integrations, but I like how there are basic components available, you can render them to HTML strings for porting elsewhere fairly easily, they didn’t forget about plain text output, and it looks actively developed with a sensible roadmap.

In taking another look recently, I was surprised to see they re-created our CodePen Challenges email!

I guess if we decide to switch someday, they’ve already done a good amount of the work for us. 😍

Chris’ Corner: Websites, Highlights, and Guesses

Category Image 052

I love Henry’s guide: How to Make a Website.

There is precious little recent instructional material on how you can build a website, a perfectly great website, using just the raw materials of the web. Raw HTML & CSS, as it were. But that’s not all that Henry’s guide is about. It’s full of holistic advice going well beyond web design:

Be kind and curious and humble when you’re working with folks, and be extra forgiving of their mistakes, so when the time inevitably comes that you make your own, there’s perhaps some goodwill in the vault for you.

 🙏

I do suspect if it’s not just lack of awareness that you can build a website with just hand-written raw HTML and CSS, but more of a then what? situation. Of course, we’re hoping CodePen is a place where that is a good option and are working to make that better every day. But there are plenty of options for getting that locally crafted HTML website to a real website, like Vercel, Netlify, GitHub pages, etc, which all make it pretty decently easy. It would be unfortunate if the DevOps knowledge for getting websites to production is just as much knowledge as actually making websites.

Oh hey this makes me think of a great term thrown out by Robb Owen: Hand-thrown frontends. He compares the website-making process to the ceramics process of making a bowl out of clay.

So, for me, the frontend bowl-making process is a cyclical, non-linear one. On a surface-level it probably doesn’t seem like it’s as efficient as assembling Lego bricks to order, but over time you’ll make more bowls and each phase of iteration will gradually shorten as your skill increases towards mastery.

I’m a sucker for a good ceramics analogy as that’s what my Bachelor of Arts was focused on in college.

Oh! And speaking of Ceramics, have you seen Charlotte Dann’s Ceramics project? It’s probably my favorite generative art project I’ve ever seen. This surface is totally code-generated:

Might as well be a photograph of real carved, glazed clay.

Oooooo tricky CSS challenge! Skewed Highlights. Vadim Makeev did up good:

You’d think transform: skew() would be involved somehow, but there isn’t a great opportunity for that, especially with arbitrary line breaks and such. Instead, the backgrounds are created with multiple gradient backgrounds (super clever) and fortunately box-decoration-break: clone; makes it look reasonable across lines.


Musing about slight alterations in CSS selector structure and how it affects selections? Sign me up for that party! Bramus compares:

.a .b .c { }
/* Versus! */
.a :is(.b .c) { }

They do look and behave similarly, but the former enforces that “c is a child of b is a child of a” situation solidly, while the latter allows for a situation where c is a child of a which is a child of b. That’s way too hard to understand in words, so here’s an image:

Admittedly I don’t reach for :is() all that much, but I suspect usage might go up a bit now that native CSS nesting is here and that all nested selectors must start with a symbol. So a quick way around wanting to nest element selector is wanking it in an :is():

header {
  h1 { } /* nope */
}

header {
  :is(h1) { } /* yup */
}

Let’s end with a little collection of developers looking forward to upcoming tech trends. This is, of course, popular in January and it’s March now but gimme a break I’m a little slow sometimes.

GPT-4 Demo Turns a Crude Sketch of a “My Joke Website” into a Functional Website for Revealing Jokes

Category Image 062
Here’s the clip from the original YouTube where Greg Brockman shows it off. Ultimately GPT-4 produced HTML output, which Greg copy-pasted into CodePen in order to show it off.
What a big release! Shawn Wang notes:
To use simple measures of how anticipated this was – GPT-4 is already the 11th-most upvoted Hacker News story of ALL TIMEthe Developer Livestream got 1.5 million views in 20 hours (currently #5 trending video on all of YouTube) and the announcement tweet got 4x more likes than the same for ChatGPT, itself the biggest story of 2022.
Certainly, this code-for-me angle is clicking with people!
https://twitter.com/danielgolliher/status/1636109084943433736
I popped into GPT-4 and asked it:
build an html page where you click a button to go to a random wikipedia page
Which works pretty darn nicely actually:
I don’t know about that Arial choice there, but otherwise, well done. I was hoping to try the “sketch a drawing” thing first, but apparently, that’s not quite open to us yet. If you’d like to see more examples of ChatGPT having created good working code, we’ve got a Collection going here.