Title
Lea Verou – Life at the bleeding edge (of web standards)
Go Home
Category
Description
Address
Phone Number
+1 609-831-2326 (US) | Message me
Site Icon
Lea Verou – Life at the bleeding edge (of web standards)
Tags
Page Views
0
Share
Update Time
2022-05-04 17:52:47

"I love Lea Verou – Life at the bleeding edge (of web standards)"

www.verou.me VS www.gqak.com

2022-05-04 17:52:47

Skip to the contentSearchLea VerouLife at the bleeding edge (of web standards)MenuProjectsSpeakingPublicationsPressInterviewsAboutSearchClose searchClose MenuProjectsSpeakingPublicationsPressInterviewsAbout@leaverou on TwitterGitHubLinkedInDribbbleCodePenCategoriesApps & scripts Original PersonalOn Yak Shaving and , a new HTML element for MarkdownPost authorBy Lea VerouPost dateNovember 26, 2021No Comments on On Yak Shaving and , a new HTML element for MarkdownThis week has been Yak Shaving Galore. It went a bit like this:I’ve been working on a web component that I need for the project I’m working on. More on that later, but let’s call it for now.Of course that needs to be developed as a separate reusable library and released as a separate open source project. No, this is not the titular component, this was only level 1 of my multi-level yak shaving… ??‍♀️I wanted to showcase various usage examples of that component in its page, so I made another component for these demos: . This demo component would have markup with editable parts on one side and the live rendering on the other side.I wanted the editable parts to autosize as you type. Hey, I’ve written a library for that in the past, it’s called Stretchy! But Stretchy was not written in ESM, nor did it support Shadow DOM. I must rewrite Stretchy in ESM and support Shadow DOM first! Surely it won’t take more than a half hour, it’s a tiny library.(It took more than a half hour)Ok, now I have a nice lil’ module, but I also need to export IIFE as well, so that it’s compatible with Stretchy v1. Let’s switch to Rollup and npm scripts and ditch Gulp.Oh look, Stretchy’s CSS is still written in Sass, even though it doesn’t really need it now. Let’s rewrite it to use CSS variables, use PostCSS for nesting, and use conic-gradient() instead of inline SVG data URIs.Ok, Stretchy v2 is ready, now I need to update its docs. Oooh, it doesn’t have a README? I should add one. But I don’t want to duplicate content between the page and the README. Hmmm, if only…I know! I’ll make a web component for rendering both inline and remote Markdown! I have an unfinished one lying around somewhere, surely it won’t take more than a couple hours to finish it?(It took almost a day, two with docs, demos etc)Done! Here it is! https://md-block.verou.meGreat! Now I can update Stretchy’s docs and release its v2Great! Now I can use Stretchy in my component demoing my component and be back to only one level of yak shaving!Wow, it’s already Friday afternoon?! ??‍♀️?Hopefully you find useful! Enjoy!Tagsesm, Markdown, Stretchy, Web Components, Yak ShavingCategoriesArticles Original TutorialsCustom properties with defaults: 3+1 strategiesPost authorBy Lea VerouPost dateOctober 15, 2021No Comments on Custom properties with defaults: 3+1 strategiesWhen developing customizable components, one often wants to expose various parameters of the styling as custom properties, and form a sort of CSS API. This is still underutlized, but there are libraries, e.g. Shoelace, that already list custom properties alongside other parts of each component’s API (even CSS parts!).Note: I’m using “component” here broadly, as any reusable chunk of HTML/CSS/JS, not necessarily a web component or framework component. What we are going to discuss applies to reusable chunks of HTML just as much as it does to “proper” web components.Let’s suppose we are designing a certain button styling, that looks like this: Continue reading “Custom properties with defaults: 3+1 strategies”TagsCSS, CSS Custom Properties, CSS variables, Dynamic CSSCategoriesArticles Original TutorialsInherit ancestor font-size, for fun and profitPost authorBy Lea VerouPost dateJune 24, 2021No Comments on Inherit ancestor font-size, for fun and profitIf you’ve been writing CSS for any length of time, you’re probably familiar with the em unit, and possibly the other type-relative units. We are going to refer to em for the rest of this post, but anything described works for all type-relative units.As you well know, em resolves to the current font size on all properties except font-size, where it resolves to the parent font size. It can be quite useful for making scalable components that adapt to their context size.However, I have often come across cases where you actually need to “circumvent” one level of this. Either you need to set font-size to the grandparent font size instead of the parent one, or you need to set other properties to the parent font size, not the current one. Continue reading “Inherit ancestor font-size, for fun and profit”CategoriesRantsIs the current tab active?Post authorBy Lea VerouPost dateMay 24, 2021No Comments on Is the current tab active?Today I ran into an interesting problem. Interesting because it’s one of those very straightforward, deceptively simple questions, that after a fair amount of digging, does not appear to have a definite answer (though I would love to be wrong!). The problem was to determine if the current tab is active. Yes, as simple as that. Continue reading “Is the current tab active?”CategoriesUncategorized82% of developers get this 3 line CSS quiz wrongPost authorBy Lea VerouPost dateMay 21, 2021No Comments on 82% of developers get this 3 line CSS quiz wrong(I always wanted to do a clickbait title like this and when this chance came along I could not pass it up. ? Sorry!)While putting my ideas into slides for my Dynamic CSS workshop for next week, I was working on a slide explaining how the CSS wide keywords work with custom properties. inherit, initial, unset I had used numerous times and knew well. But what about revert? How did that work? I had an idea, but quickly coded up a demo to try it out. The code was::root { --accent-color: skyblue;}div { --accent-color: revert; background: var(--accent-color, orange);}Phew, I was correct, but the amount of uncertainty I had before seeing the result tipped me that I might be on to something.Before you read on, take a moment to think about what you would vote. Warning: Spoilers ahead! Continue reading “82% of developers get this 3 line CSS quiz wrong”CategoriesArticles Original TutorialsDark mode in 5 minutes, with inverted lightness variablesPost authorBy Lea VerouPost dateMarch 30, 2021No Comments on Dark mode in 5 minutes, with inverted lightness variablesBy now, you probably know that you can use custom properties for individual color components, to avoid repeating the same color coordinates multiple times throughout your theme. You may even know that you can use the same variable for multiple components, e.g. HSL hue and lightness::root {--primary-hs: 250 30%;}h1 {color: hsl(var(--primary-hs) 30%);}article {background: hsl(var(--primary-hs) 90%);}article h2 {background: hsl(var(--primary-hs) 40%);color: white;}Here is a very simple page designed with this technque:Unlike preprocessor variables, you could even locally override the variable, to have blocks with a different accent color::root {--primary-hs: 250 30%;--secondary-hs: 190 40%;}article {background: hsl(var(--primary-hs) 90%);}article.alt {--primary-hs: var(--secondary-hs);}This is all fine and dandy, until dark mode comes into play. The idea of using custom properties to make it easier to adapt a theme to dark mode is not new. However, in every article I have seen, the strategy suggested is to create a bunch of custom properties, one for each color, and override them in a media query.This is a fine approach, and you’ll likely want to do that for at least part of your colors eventually. However, even in the most disciplined of designs, not every color is a CSS variable. You often have colors declared inline, especially grays (e.g. the footer color in our example). This means that adding a dark mode is taxing enough that you may put it off for later, especially on side projects.The trick I’m going to show you will make anyone who knows enough about color cringe (sorry Chris!) but it does help you create a dark mode that works in minutes. It won’t be great, and you should eventually tweak it to create a proper dark mode (also dark mode is not just about swapping colors) but it’s better than nothing and can serve as a base. Continue reading “Dark mode in 5 minutes, with inverted lightness variables”TagsCSS variables, dark mode, hsl, lchCategoriesArticlesMass function overloading: why and how?Post authorBy Lea VerouPost dateFebruary 10, 2021No Comments on Mass function overloading: why and how?One of the things I’ve been doing for the past few months (on and off—more off than on TBH) is rewriting Bliss to use ESM 1. Since Bliss v1 was not using a modular architecture at all, this introduced some interesting challenges. Continue reading “Mass function overloading: why and how?”TagsAPI Design, Bliss, esm, JavaScript, JSCategoriesTutorialsWritable gettersPost authorBy Lea VerouPost dateDecember 23, 2020No Comments on Writable gettersSetters removing themselves are reminiscent of Ouroboros, the serpent eating its own tail, an ancient symbol. Media creditA pattern that has come up a few times in my code is the following: an object has a property which defaults to an expression based on its other properties unless it’s explicitly set, in which case it functions like a normal property. Essentially, the expression functions as a default value. Continue reading “Writable getters”TagsAccessors, ECMAScript, JavaScript, JS, JS PatternsCategoriesPersonalPosition Statement for the 2020 W3C TAG ElectionPost authorBy Lea VerouPost dateNovember 30, 2020Update: I got elected!! Thank you so much to every W3C member organization who voted for me. ?? Now on to making the Web better, alongside fellow TAG members!Context: I’m running for one of the four open seats in this year’s W3C TAG election. The W3C Technical Architecture Group (TAG) is the Working Group that ensures that Web Platform technologies are usable and follow consistent design principles, whether they are created inside or outside W3C. It advocates for the needs of everyone who uses the Web and everyone who works on the Web. If you work for a company that is a W3C Member, please consider encouraging your AC rep to vote for me! My candidate statement follows. Continue reading “Position Statement for the 2020 W3C TAG Election”Tagsstandards, W3CCategoriesArticlesThe case for Weak Dependencies in JSPost authorBy Lea VerouPost dateNovember 19, 2020No Comments on The case for Weak Dependencies in JSEarlier today, I was briefly entertaining the idea of writing a library to wrap and enhance querySelectorAll in certain ways. I thought I’d rather not introduce a Parsel dependency out of the box, but only use it to parse selectors properly when it’s available, and use more crude regex when it’s not (which would cover most use cases for what I wanted to do).In the olden days, where every library introduced a global, I could just do:if (window.Parsel) {let ast = Parsel.parse();// rewrite selector properly, with AST}else {// crude regex replace}However, with ESM, there doesn’t seem to be a way to detect whether a module is imported, without actually importing it yourself.I tweeted about this… Continue reading “The case for Weak Dependencies in JS”Tagsesm, JS, software engineeringPosts navigation← Newer Posts12…21Older Posts →@leaverou on TwitterGitHubLinkedInDribbbleCodePenBuy my book!CategoriesApps & scripts (34)Articles (33)Benchmarks (2)CSS WG (3)News (13)Original (79)Personal (37)Rants (13)Replies (6)Speaking (11)Thoughts (19)Tips (52)Tutorials (5)Uncategorized (4)Carbon adsRecent PostsOn Yak Shaving and , a new HTML element for MarkdownCustom properties with defaults: 3+1 strategiesInherit ancestor font-size, for fun and profitIs the current tab active?82% of developers get this 3 line CSS quiz wrongDark mode in 5 minutes, with inverted lightness variablesMass function overloading: why and how?Writable gettersPosition Statement for the 2020 W3C TAG ElectionThe case for Weak Dependencies in JS©2022Lea VerouPowered by WordPressTo the top ↑Up ↑