I built a Web Component that adds native copy to clipboard and sharing controls to a web page. The original idea was based on this excellent blog post by the folks at Set Studio. In this post I don't really want to go into the technical details of …
Continue reading →9 Tagged | code
The WebC plugin brings a component model similar to frameworks like Vue and Svelte to Eleventy. It allows you to create HTML-only components (basically includes) all the way up to interactive Web Components with shadow DOM and all the benefits it …
Continue reading →I've found myself needing to do this on a couple of projects lately so it seemed like a good idea to write it down here as a snippet to reference later. This sort of a vanilla replacement for jQuery's .wrap() method /** * Helper function to wrap one …
Continue reading →There are several ways to hide content using CSS. For example using display: none, or visibility: hidden. Each way of hiding elements is useful in different situations, but this snippet is specifically for visually hiding elements while keeping the …
Continue reading →It's that time of year again, so I thought I'd do a quick post on the simple bit of JavaScript I use to keep the copyright date current in the static sites I build. Add the hidden attribute to your container element markup so that if JS fails for …
Continue reading →One of the things that interests me about Web Components is that they make it possible to build components that can be progressively enhanced. I recently wrote about how I've been making progressive enhancement more of a priority in my work, and the …
Continue reading →I maintain a lightweight JavaScript theme switcher library called Themur. The other day I was adding a new feature that automatically detects a user’s OS theme settings by looking at the prefers-color-scheme media query and got to thinking …
Continue reading →I was looking through Microsoft's design system Fabric the other day and came across an interesting component in the Utilities section called FocusTrapZone. FocusTrapZone is a React component that is used to trap focus inside any HTML element. What …
Continue reading →When I write CSS I generally favor clarity over brevity when choosing the way I name classes/components. I will admit that this can make for some pretty long class names and can look a little weird if you're using a naming convention like BEM. For …
Continue reading →