<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[CodeSpud RSS Feed]]></title><description><![CDATA[A coding nerd taking life one line of code at a time.]]></description><link>https://www.codespud.com</link><generator>GatsbyJS</generator><lastBuildDate>Sun, 23 Aug 2026 21:30:51 GMT</lastBuildDate><item><title><![CDATA[View Transitions vs. My Old CSS Habit: What Actually Changes]]></title><description><![CDATA[I’ve made CSS transitions for years. This article shows you what changes when the browser does the coordinating instead. Also where we are…]]></description><link>https://www.codespud.com/2026/react-view-transitions-vs-old-css-habit/</link><guid isPermaLink="false">https://www.codespud.com/2026/react-view-transitions-vs-old-css-habit/</guid><pubDate>Mon, 17 Aug 2026 08:29:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;em&gt;I’ve made CSS transitions for years. This article shows you what changes when the browser does the coordinating instead. Also where we are with ViewTransition in ReactJs.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Almost every state change animation on the web runs on the same trick. Add a class, wait for the browser to notice, remove the class when the animations should end &lt;code class=&quot;language-text&quot;&gt;transitionend&lt;/code&gt;, or on simpler work that uses &lt;code class=&quot;language-text&quot;&gt;setTimeout&lt;/code&gt; set to whatever duration makes sense in the CSS. This is the pattern most front-end developers have leaned on for years, myself included, and it works well enough.&lt;/p&gt;
&lt;p&gt;But the code always felt wrong to me. You end up doing most of the job by hand, coordinating a start state and an end state while the browser waits on the sidelines. So when &lt;code class=&quot;language-text&quot;&gt;&amp;lt;ViewTransition&gt;&lt;/code&gt; kept showing up in React’s release notes, I wanted to actually sit down with it, instead of nodding along at another shiny component name.&lt;/p&gt;
&lt;h2 id=&quot;contents&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#contents&quot; aria-label=&quot;contents permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Contents&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;#o-old-way&quot;&gt;The old way, and why it always felt fragile&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#o-browser-does&quot;&gt;What the browser does differently&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#o-react-wraps&quot;&gt;React wraps it, with real constraints&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#o-two-ways&quot;&gt;Building the same toggle two ways&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;o-old-way&quot;&gt;The old way, and why it always felt fragile&lt;/h2&gt;
&lt;p&gt;Here’s the pattern we are going to work with:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;jsx&quot;&gt;&lt;pre class=&quot;language-jsx&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;Card&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; children &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;open&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; setOpen&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;useState&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;animating&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; setAnimating&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;useState&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;toggle&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;setAnimating&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;setOpen&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;o&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;o&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt;
      &lt;span class=&quot;token attr-name&quot;&gt;className&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;card &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;open &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;card--open&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt; &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;animating &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;card--animating&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token attr-name&quot;&gt;onTransitionEnd&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;setAnimating&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token attr-name&quot;&gt;onClick&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;toggle&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;children&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.card&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;max-height&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 60px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;overflow&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; hidden&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;transition&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; max-height 300ms ease&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token selector&quot;&gt;.card--open&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;max-height&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 400px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Nothing here is new. The code before is not technically wrong it’s just you’re the one keeping three things in sync.&lt;/p&gt;
&lt;p&gt;There’s the logical &lt;code class=&quot;language-text&quot;&gt;open&lt;/code&gt; flag. There’s a separate &lt;code class=&quot;language-text&quot;&gt;animating&lt;/code&gt; flag, we keep track on so the code knows when the transition is running. And there’s a CSS class name that has to match a selector we added in a separate file.&lt;/p&gt;
&lt;p&gt;Miss the &lt;code class=&quot;language-text&quot;&gt;onTransitionEnd&lt;/code&gt; call, and the animation runs forever, breaking other interactions on the page. One bad pattern in some code I’ve seen is separate timing for CSS and one for JavacScript. Forget updating one and you get a bug that’s not easy find in reviews.&lt;/p&gt;
&lt;p&gt;The bigger limitation is scope, though. CSS transitions animate properties changing on an element that already exists.&lt;/p&gt;
&lt;p&gt;CSS transitions can’t animate one element being swapped for a completely different one. They definitely can’t animate a whole page turning into a different page, because there’s no shared element left for the browser to transition between. For that gap, people reached for &lt;code class=&quot;language-text&quot;&gt;react-transition-group&lt;/code&gt; or &lt;code class=&quot;language-text&quot;&gt;framer-motion&lt;/code&gt;, which solves the mounting problem well but add a dependency and a second API on top of the CSS you already know.&lt;/p&gt;
&lt;h2 id=&quot;o-browser-does&quot;&gt;What the browser does differently&lt;/h2&gt;
&lt;p&gt;The &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API&quot;&gt;View Transitions API&lt;/a&gt; skips the class-juggling by working a level up, at the whole-DOM-snapshot level instead of the single-property level. You hand the browser a callback that updates the DOM, and it takes care of the rest:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;startViewTransition&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;updateTheDOMSomehow&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Before that callback runs, the browser takes a screenshot of the current page. After it runs, it takes a second screenshot of the new state. Then it builds a small pseudo-element tree, &lt;code class=&quot;language-text&quot;&gt;::view-transition-old()&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;::view-transition-new()&lt;/code&gt;, and cross-fades between the two images by default, since it already has both snapshots sitting right there.&lt;/p&gt;
&lt;p&gt;No &lt;code class=&quot;language-text&quot;&gt;transitionend&lt;/code&gt; listener required. The browser owns the whole lifecycle, and it cleans up the pseudo-elements the moment it’s done.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;mermaid&quot;&gt;&lt;pre class=&quot;language-mermaid&quot;&gt;&lt;code class=&quot;language-mermaid&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;sequenceDiagram&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;participant&lt;/span&gt; JS as Your callback
    &lt;span class=&quot;token keyword&quot;&gt;participant&lt;/span&gt; Browser
    Browser&lt;span class=&quot;token arrow operator&quot;&gt;-&gt;&gt;&lt;/span&gt;Browser&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; snapshot &lt;span class=&quot;token string&quot;&gt;&quot;old&quot;&lt;/span&gt; state
    JS&lt;span class=&quot;token arrow operator&quot;&gt;-&gt;&gt;&lt;/span&gt;Browser&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; mutate the DOM
    Browser&lt;span class=&quot;token arrow operator&quot;&gt;-&gt;&gt;&lt;/span&gt;Browser&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; snapshot &lt;span class=&quot;token string&quot;&gt;&quot;new&quot;&lt;/span&gt; state
    Browser&lt;span class=&quot;token arrow operator&quot;&gt;-&gt;&gt;&lt;/span&gt;Browser&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; build &lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;view-transition-old/new
    Browser&lt;span class=&quot;token arrow operator&quot;&gt;-&gt;&gt;&lt;/span&gt;Browser&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; cross-fade &lt;span class=&quot;token text string&quot;&gt;(or your CSS animation)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You can still write real CSS if the default cross-fade comes out boring. The pseudo-elements are just elements, so you target &lt;code class=&quot;language-text&quot;&gt;::view-transition-old(root)&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;::view-transition-new(root)&lt;/code&gt; with your own &lt;code class=&quot;language-text&quot;&gt;@keyframes&lt;/code&gt;, and the browser runs those instead of its default fade.&lt;/p&gt;
&lt;p&gt;What you’re not doing anymore is manually tracking which state you’re leaving and which state you’re entering, since the browser already has both.&lt;/p&gt;
&lt;p&gt;This used to be a Chrome-only party trick, which is probably why a lot of older tutorials still target it. That’s changed quite a bit lately. &lt;a href=&quot;https://caniuse.com/view-transitions&quot;&gt;Current support data&lt;/a&gt; puts single-document View Transitions at roughly 90% global usage, with Safari on board since version 18 and Firefox shipping it too.&lt;/p&gt;
&lt;p&gt;There’s a second half to the platform API, not included (yet) on React code. Cross-document transitions animate across a full page navigation rather than inside a single-page app. Opting in takes one line of CSS, an &lt;code class=&quot;language-text&quot;&gt;@view-transition&lt;/code&gt; at-rule with &lt;code class=&quot;language-text&quot;&gt;navigation: auto&lt;/code&gt;, declared on both the page you’re leaving and the page you’re arriving at.&lt;/p&gt;
&lt;p&gt;Two events, &lt;code class=&quot;language-text&quot;&gt;pagereveal&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;pageswap&lt;/code&gt;, fire on the way in and the way out, so the transition can be adjusted based on which page is which. Support here is a step behind the single-document API, though. &lt;a href=&quot;https://caniuse.com/cross-document-view-transitions&quot;&gt;Caniuse puts cross-document transitions&lt;/a&gt; at roughly 86% support: Chrome, Edge, and Safari 18.2+ all ship it, but Firefox still only has it partially implemented. For a blog like this one, still generated the old-fashioned multi-page way for most routes, that’s the half of the API that matters most, and the one to feature-detect before you use it.&lt;/p&gt;
&lt;h2 id=&quot;o-react-wraps&quot;&gt;React wraps it, with real constraints&lt;/h2&gt;
&lt;p&gt;React’s &lt;code class=&quot;language-text&quot;&gt;&amp;lt;ViewTransition&gt;&lt;/code&gt; is a declarative wrapper over that browser API. That is putting it simply but its true.&lt;/p&gt;
&lt;p&gt;As of the stable &lt;a href=&quot;https://react.dev/blog/2025/10/01/react-19-2&quot;&gt;React 19.2 release&lt;/a&gt; in October 2025, &lt;code class=&quot;language-text&quot;&gt;&amp;lt;ViewTransition&gt;&lt;/code&gt; did not ship. The &lt;a href=&quot;https://react.dev/reference/react/ViewTransition&quot;&gt;component’s own reference page&lt;/a&gt; still lists it as Canary and Experimental channel only, months later, as of this writing. Plenty of tutorials online will show it to you like it’s a settled API. It isn’t yet, so treat any production use of it as an experiment you’re opting into on purpose, not a feature you can quietly reach for.&lt;/p&gt;
&lt;p&gt;That said, the design is worth understanding regardless of channel. The raw browser API is imperative, since you call &lt;code class=&quot;language-text&quot;&gt;startViewTransition()&lt;/code&gt; yourself and hand it a DOM-mutation callback. React is declarative, so React’s version flips that around: you wrap the JSX you want animated, and React decides, during a transition, which wrapped boundaries actually need one.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;jsx&quot;&gt;&lt;pre class=&quot;language-jsx&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; ViewTransition&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; startTransition &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;react&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;Card&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; open&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; children &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;ViewTransition&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;className&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;open &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;card--open&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;card&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;children&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;ViewTransition&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;There are three caveats you need to remember:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;&amp;lt;ViewTransition&gt;&lt;/code&gt; has to be the outermost thing a component returns, not wrapped by a &lt;code class=&quot;language-text&quot;&gt;&amp;lt;div&gt;&lt;/code&gt; or any other DOM element above it, or React can’t attach the enter and exit animations correctly.&lt;/li&gt;
&lt;li&gt;It only activates for state changes wrapped in &lt;code class=&quot;language-text&quot;&gt;startTransition()&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;useDeferredValue()&lt;/code&gt;, or a resolving &lt;code class=&quot;language-text&quot;&gt;&amp;lt;Suspense&gt;&lt;/code&gt; boundary, so a plain &lt;code class=&quot;language-text&quot;&gt;setState&lt;/code&gt; call animates nothing at all.&lt;/li&gt;
&lt;li&gt;If two &lt;code class=&quot;language-text&quot;&gt;&amp;lt;ViewTransition&gt;&lt;/code&gt; elements share the same &lt;code class=&quot;language-text&quot;&gt;name&lt;/code&gt;, expecting a shared-element morph between them, only one may be mounted at a time or React crashes.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;That last constraint makes sense once you remember it’s tracking identity across a delete-and-insert, not just a style change. React also gives you a way to vary the animation by &lt;em&gt;why&lt;/em&gt; a transition happened, not merely that one happened, through &lt;a href=&quot;https://react.dev/reference/react/addTransitionType&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;addTransitionType&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;jsx&quot;&gt;&lt;pre class=&quot;language-jsx&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;ViewTransition&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token attr-name&quot;&gt;enter&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token string-property property&quot;&gt;&quot;navigation-forward&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;slide-left&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token string-property property&quot;&gt;&quot;navigation-back&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;slide-right&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;auto&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;Page&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;ViewTransition&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;jsx&quot;&gt;&lt;pre class=&quot;language-jsx&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;&lt;span class=&quot;token function&quot;&gt;startTransition&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;addTransitionType&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;navigation-forward&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;navigate&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;/next&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;That’s the bit the raw browser API doesn’t hand you for free: a forward navigation and a back navigation can now animate in opposite directions, from a single component, without you threading a direction flag through props yourself.&lt;/p&gt;
&lt;p&gt;The 19.2 release notes are clear that work is still in progress. One change batches Suspense boundaries during server-side rendering specifically so content streaming in close together reveals as one animation instead of several chained ones. It’s framed plainly as prep work, not a finished feature, which matches everything else about this component’s status right now.&lt;/p&gt;
&lt;h2 id=&quot;o-two-ways&quot;&gt;Building the same toggle two ways&lt;/h2&gt;
&lt;p&gt;You see the difference when you put both techniques side by side.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The CSS version uses class name for “open,” a second class name for “animating,” and an event handler to unwind that second one.&lt;/li&gt;
&lt;li&gt;The View Transition version has one wrapper and a trigger.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;jsx&quot;&gt;&lt;pre class=&quot;language-jsx&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;Card&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; children &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;open&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; setOpen&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;useState&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;toggle&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;startTransition&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;setOpen&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;o&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;o&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;ViewTransition&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;className&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;open &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;card--open&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;card&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;onClick&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;toggle&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;children&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;ViewTransition&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In the ViewTransition code above, the &lt;code class=&quot;language-text&quot;&gt;animating&lt;/code&gt; flag is gone. There’s nothing animation related to track, because the browser’s own transition object resolves when the animation finishes, and React never asks you to babysit it.&lt;/p&gt;
&lt;p&gt;Just a gentle reminder about accessibility, we still need to set up an override for users who enabled “prefer reduced motion”. The browser does not include it when you enable view transitions:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token atrule&quot;&gt;&lt;span class=&quot;token rule&quot;&gt;@media&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token property&quot;&gt;prefers-reduced-motion&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; reduce&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token selector&quot;&gt;::view-transition-old(*),
  ::view-transition-new(*)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;animation&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; none &lt;span class=&quot;token important&quot;&gt;!important&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;What surprised me most, going through this, is how little of the &lt;em&gt;hard&lt;/em&gt; part actually changed. Coordinating a shared-element morph between a list item and its detail view was always going to require matching identity across two separate renders. It was the same with &lt;code class=&quot;language-text&quot;&gt;react-transition-group&lt;/code&gt;, and it’s still true here.&lt;/p&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;&amp;lt;ViewTransition name=&quot;...&quot;&gt;&lt;/code&gt; just names that identity explicitly, instead of you inferring it from a key prop and hoping the DOM diff cooperated. The &lt;code class=&quot;language-text&quot;&gt;name&lt;/code&gt; is a kind of contract to the browser: these two elements are the same thing, so animate between them accordingly.&lt;/p&gt;
&lt;h2 id=&quot;wrapping-up&quot;&gt;Wrapping up&lt;/h2&gt;
&lt;p&gt;There’s nothing wrong about the old CSS pattern. For one element changing one or two properties, it’s still the least code one could write, and I’ll probably keep using that. See my &lt;a href=&quot;https://www.codepen.com/chrisbautista/&quot;&gt;codepen&lt;/a&gt; for samples.&lt;/p&gt;
&lt;p&gt;It becomes more complex if the work involves more than one element, a full page swap, or shared indentity between what’s leaving the page and what’s arriving. That’s exactly the gap the View Transitions API is made for, by working at the snapshot level instead of the property level.&lt;/p&gt;
&lt;p&gt;React’s &lt;code class=&quot;language-text&quot;&gt;&amp;lt;ViewTransition&gt;&lt;/code&gt; makes that native capability feel at home in a component tree, which is genuinely nice. Can’t wait for a stable channel, until then,  I’ll be watching the release notes.&lt;/p&gt;
&lt;p&gt;Happy coding!&lt;/p&gt;</content:encoded></item><item><title><![CDATA[My Drafts Folder Is a Graveyard, and a WIP Limit Fixed It, So Far]]></title><description><![CDATA[Every idea for this blog starts the same way. I pin a note in Google Keep, or I scribble a line in the notebook that lives on my desk, and…]]></description><link>https://www.codespud.com/2026/drafts-folder-graveyard-wip-limit/</link><guid isPermaLink="false">https://www.codespud.com/2026/drafts-folder-graveyard-wip-limit/</guid><pubDate>Tue, 11 Aug 2026 08:29:00 GMT</pubDate><content:encoded>&lt;p&gt;Every idea for this blog starts the same way. I pin a note in Google Keep, or I scribble a line in the notebook that lives on my desk, and that’s it. There’s no formal next step after that. Nothing enforces the “idea” into “task.” It just sits there next to a dozen other notes until I think its worth doing or I forget why I wrote it down.&lt;/p&gt;
&lt;p&gt;That gap is the problem, and it’s a lot like a parking lot with three spaces and noone to attend to it. A sign says the limit is three cars.&lt;/p&gt;
&lt;p&gt;Nobody’s watching, so cars just don’t leave. I’ll come back to what happens once you hire the attendant.&lt;/p&gt;
&lt;h2 id=&quot;contents&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#contents&quot; aria-label=&quot;contents permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Contents&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;#o-where-it-starts&quot;&gt;Where the mess actually starts&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#o-wip-limit&quot;&gt;What a WIP limit is supposed to fix&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#o-cost-something&quot;&gt;Making the limit cost something&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;o-where-it-starts&quot;&gt;Where the mess actually starts&lt;/h2&gt;
&lt;p&gt;The drafts folder isn’t really the problem. It’s a symptom of a missing one step further upstream, at the exact moment an idea shows up.&lt;/p&gt;
&lt;p&gt;I get an idea in the shower, or reading someone else’s post, or debugging something that turns out to be interesting for some reason. I write it down in Keep or the notebook, and I feel like I did something productive.&lt;/p&gt;
&lt;p&gt;I didn’t.&lt;/p&gt;
&lt;p&gt;I moved the idea from my head to a slightly more durable piece of paper, and that’s all it did. Nothing in that step asks whether I’ll ever act on it, or when, or what “acting on it” would even look like.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://www.todoist.com/inspiration/personal-productivity-methods#getting-thingsdone&quot;&gt;Getting Things Done&lt;/a&gt; splits capture and clarify into two separate stages on purpose: write everything down first with zero evaluation, then come back and turn each vague item into one concrete next action, the way “Bank” becomes “call the bank about the loan.” My system has the first half and skips the second completely.&lt;/p&gt;
&lt;p&gt;Experts say unfinished thoughts eat at your focus and hurt you. &lt;a href=&quot;https://www.uwb.edu/business/faculty/sophie-leroy/attention-residue&quot;&gt;Sophie Leroy&lt;/a&gt; has spent 17 years studying attention at the University of Washington. She calls this attention residue: part of your focus stays attached to an unfinished task even while you’re doing something else entirely, and it gets worse the more unresolved the task feels. A note in Keep with no next action attached is about as unresolved as a task can get.&lt;/p&gt;
&lt;p&gt;It’s not costing me time to sit there. It’s costing me a sliver of attention multiplied by how many I have unresolved, every single day, whether I’m looking at it or not.&lt;/p&gt;
&lt;h2 id=&quot;o-wip-limit&quot;&gt;What a WIP limit is supposed to fix&lt;/h2&gt;
&lt;p&gt;The standard fix for my unresolved pile is a &lt;a href=&quot;https://www.personalkanban.com/pk/uncategorized/how-to-setting-your-personal-wip-limit&quot;&gt;Personal Kanban&lt;/a&gt;, a method built by Jim Benson around two rules. Visualize your work. Limit how much of it can be “in progress” at once.&lt;/p&gt;
&lt;p&gt;Benson’s advice is to start at three, and his reasoning isn’t about resilience: three stickies are easy to see, and large to avoid arguments. Below that limit, a fourth idea simply isn’t allowed until something already in progress ships or gets cut. That’s the parking lot with an attendant, in theory: the lot fills up, and the next car waits for a space.&lt;/p&gt;
&lt;p&gt;Visualizing helped a little: my first idea of moving all 36 in one place was good. Instead of scattered across two apps and a notebook. I can concentrate on acting on them.&lt;/p&gt;
&lt;p&gt;Here’s where my system fell apart. I drew the board but I was not disciplined enough to enforce it. I look at a sticky and either work on it or put it back so I can get back to it later instead of decisively cutting it. That was the issue.&lt;/p&gt;
&lt;p&gt;Cars don’t leave a lot because a sign asks nicely; they leave because someone eventually tows the ones that overstayed. My drafts folder had no tow truck, so 36 cars parked there and stayed.&lt;/p&gt;
&lt;p&gt;That’s the piece most Personal Kanban explainers skip. The visualization is the easy 20%. Actually enforcing the limit, the part that requires you to give something up before you can start something new, is the other 80%. What it needs is a mechanism, not a whiteboard.&lt;/p&gt;
&lt;h2 id=&quot;o-cost-something&quot;&gt;Making the limit cost something&lt;/h2&gt;
&lt;p&gt;The mechanism I landed on borrows from a tool I already use everyday: git. Before I’m allowed to open a fourth draft, I have to remove one of the three already in “Doing”, and removing one means one of two things. Either it ships (finished, moved to Done, same as any normal task), or I kill it, and killing it means writing an obituary.&lt;/p&gt;
&lt;p&gt;Killing a draft looks like this:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;git mv drafts/ts7-post.md archive/ts7-post.md
git commit -m &quot;RIP: Microsoft shipped the real writeup before I finished mine&quot;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;em&gt;One line moves the file out of the way. The other line is the part that actually costs something.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;That’s the whole mechanism, laid out as a flowchart:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;mermaid&quot;&gt;&lt;pre class=&quot;language-mermaid&quot;&gt;&lt;code class=&quot;language-mermaid&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;flowchart&lt;/span&gt; TD
    A&lt;span class=&quot;token text string&quot;&gt;[&quot;Doing column is full&amp;lt;br/&gt;3 drafts at the limit&quot;]&lt;/span&gt; &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt; B&lt;span class=&quot;token text string&quot;&gt;[&quot;New idea shows up&amp;lt;br/&gt;no open slot&quot;]&lt;/span&gt;
    B &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt; C&lt;span class=&quot;token text string&quot;&gt;[&quot;Pick one to remove&amp;lt;br/&gt;to make room&quot;]&lt;/span&gt;
    C &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt; D&lt;span class=&quot;token text string&quot;&gt;[&quot;Finish it&amp;lt;br/&gt;ships normally to Done&quot;]&lt;/span&gt;
    C &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt; E&lt;span class=&quot;token text string&quot;&gt;[&quot;Kill it&amp;lt;br/&gt;git mv to archive/&amp;lt;br/&gt;commit says why&quot;]&lt;/span&gt;
    D &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt; F&lt;span class=&quot;token text string&quot;&gt;[&quot;Slot opens&amp;lt;br/&gt;new idea can start&quot;]&lt;/span&gt;
    E &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt; F&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The &lt;code class=&quot;language-text&quot;&gt;RIP&lt;/code&gt; is the part doing the actual work, and there’s a reason a public commit message succeeds where a private whiteboard sign failed.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://web.mit.edu/curhan/www/docs/Articles/15341_Readings/Behavioral_Decision_Theory/Kahneman_Tversky_1979_Prospect_theory.pdf&quot;&gt;Kahneman and Tversky&lt;/a&gt; laid the groundwork for this back in 1979, in a paper that eventually won Kahneman a Nobel Prize: “losses loom larger than gains.” Their actual finding was that most people turn down a fair coin flip for equal stakes, even though it’s break-even on average, because losing feels worse than winning the same amount feels good. If offered $20 on heads or -$20 on tails, most people say no. This is called Loss Aversion.&lt;/p&gt;
&lt;p&gt;Deleting a draft silently is a loss you are OK with it most of the time, since nothing marks the moment it happened. Writing &lt;code class=&quot;language-text&quot;&gt;git commit -m &quot;RIP: ...&quot;&lt;/code&gt; turns the same event into a loss you have to name out loud, in a log you can see anytime. That small, deliberate discomfort is the tow truck that pulls the car who overstayed its welcome.&lt;/p&gt;
&lt;p&gt;This step is what makes the three-item limit something I actually respect instead of something I quietly work around.&lt;/p&gt;
&lt;p&gt;I recommend wrapping the commands in a bash script or git alias. Easier you make the action the more you will use the step.&lt;/p&gt;
&lt;p&gt;Here’s a git alias definition:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;git config --global alias.abandon &apos;!f() { local msg=&quot;${2:-abandoned $1}&quot;; git mv &quot;drafts/$1&quot; &quot;archive/$1&quot; &amp;amp;&amp;amp; git commit -m &quot;RIP: $msg&quot;; }; f &quot;$@&quot;&apos;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Usage:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;git abandon some-draft.md &quot;draft angle is thin&quot;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Caveat: Although I have tested this git alias extensively. Make sure to test it on a non-critical code you currently have first. It works on bash on a Mac, Linux might support it too. I would check in WSL2 in windows.&lt;/p&gt;
&lt;p&gt;Don’t be tempted to extend the script to recursively run on all contents of a folder. The single draft triage makes it deliberate and makes the step hurt more. The “loss” we are looking for that makes system work.&lt;/p&gt;
&lt;h2 id=&quot;whats-on-the-board-right-now&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#whats-on-the-board-right-now&quot; aria-label=&quot;whats on the board right now permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;What’s on the board right now&lt;/h2&gt;
&lt;p&gt;Three things: this post, a TypeScript piece I still believe in, and a build-tooling draft I give 50/50 surviving the week. One other got the &lt;code class=&quot;language-text&quot;&gt;git abandon&lt;/code&gt; treatment while I was writing this, with an honest one-line reason.&lt;/p&gt;
&lt;p&gt;What makes the trick work is that quitting something finally costs me something I can see.&lt;/p&gt;
&lt;p&gt;Cheers!&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Accessibility Law World Map]]></title><description><![CDATA[Shows the clickable map and details on the right. Not for legal advice. Study aide for CPACC exam An interactive map showing which…]]></description><link>https://www.codespud.com/accessibility-law-world-map/</link><guid isPermaLink="false">https://www.codespud.com/accessibility-law-world-map/</guid><pubDate>Mon, 10 Aug 2026 10:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;img src=&quot;/blog/accessibility-map.png&quot; alt=&quot;Shows the clickable map and details on the right.&quot;&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Not for legal advice. Study aide for CPACC exam&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;An interactive map showing which accessibility instruments apply in which jurisdiction, seeded from Domain III of the CPACC Content Outline. Select a country on the map or a row in the table to see what’s recorded against it. A jurisdiction also inherits everything recorded against its parent (Ontario through Canada, French Guiana through France).&lt;/p&gt;
&lt;p&gt;An unmarked country means the dataset has no entry for it, not that no accessibility law exists there.&lt;/p&gt;
&lt;h2 id=&quot;data&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#data&quot; aria-label=&quot;data permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Data&lt;/h2&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;data.json&lt;/code&gt; is the only file meant to be edited routinely: jurisdictions, instruments, and a &lt;code class=&quot;language-text&quot;&gt;verifiedOn&lt;/code&gt; date marking when the tool last checked the claim against its source, never when the law itself was enacted. Each entry is tagged &lt;code class=&quot;language-text&quot;&gt;cpacc-outline&lt;/code&gt; (transcribed, unchecked) or &lt;code class=&quot;language-text&quot;&gt;primary&lt;/code&gt; (checked against the statute or ratification record, with a required source URL).&lt;/p&gt;
&lt;p&gt;The basemap (&lt;code class=&quot;language-text&quot;&gt;geometry.json&lt;/code&gt;) is generated once from &lt;a href=&quot;https://www.naturalearthdata.com/&quot;&gt;Natural Earth&lt;/a&gt; 1:110m data via &lt;a href=&quot;https://github.com/topojson/world-atlas&quot;&gt;world-atlas&lt;/a&gt;, public domain, and never hand-edited.&lt;/p&gt;
&lt;h2 id=&quot;notes&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#notes&quot; aria-label=&quot;notes permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Notes&lt;/h2&gt;
&lt;p&gt;There’s no build step and no validation on deploy, so a malformed &lt;code class=&quot;language-text&quot;&gt;data.json&lt;/code&gt; goes straight to the public URL. A few deliberate omissions from the CPACC seed list: the US signed but never ratified the CRPD, so it isn’t recorded as applying; the UK’s EU Charter of Fundamental Rights entry doesn’t survive Brexit; and Ontario’s dataset entry is the 2001 &lt;em&gt;Ontarians with Disabilities Act&lt;/em&gt;, not the better-known 2005 &lt;em&gt;AODA&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Links&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://chrisbautista.github.io/accessibility-map/&quot;&gt;Live demo&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/chrisbautista/accessibility-map&quot;&gt;Source on GitHub&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[Top 5 Git Commands You Should Know for a Better Dev Workflow]]></title><description><![CDATA[My entire git workflow runs on two commands.  when I need to get out of the way.  when I need to get somewhere else. No aliases, no muscle…]]></description><link>https://www.codespud.com/2026/top-5-git-commands-better-dev-workflow/</link><guid isPermaLink="false">https://www.codespud.com/2026/top-5-git-commands-better-dev-workflow/</guid><pubDate>Thu, 06 Aug 2026 08:29:00 GMT</pubDate><content:encoded>&lt;p&gt;My entire git workflow runs on two commands.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;git stash&lt;/code&gt; when I need to get out of the way.&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;git checkout&lt;/code&gt; when I need to get somewhere else.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;No aliases, no muscle-memory shortcuts, no clever &lt;code class=&quot;language-text&quot;&gt;bisect&lt;/code&gt; story about the regression I hunted down in fifteen minutes. Just stash and checkout for years, because they cover almost everything a normal day asks for.&lt;/p&gt;
&lt;p&gt;But “almost” is doing a lot of work in that sentence.&lt;/p&gt;
&lt;p&gt;The five commands below are what I’ve started reaching for instead, because each accomplishes tasks I had to manually do in some hacky way.&lt;/p&gt;
&lt;p&gt;All of these commands shipped in git for years. You can call each with &lt;code class=&quot;language-text&quot;&gt;--help&lt;/code&gt; for more comprehensive information.&lt;/p&gt;
&lt;p&gt;Consider this a shortlist for anyone else who’s been getting by on two verbs when git actually offers a whole vocabulary.&lt;/p&gt;
&lt;h2 id=&quot;contents&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#contents&quot; aria-label=&quot;contents permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Contents&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;#o-switch&quot;&gt;git switch&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#o-restore&quot;&gt;git restore&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#o-worktree&quot;&gt;git worktree&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#o-bisect&quot;&gt;git bisect&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#o-reflog&quot;&gt;git reflog&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;o-switch&quot;&gt;git switch&lt;/h2&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;git checkout&lt;/code&gt; does three unrelated jobs: switch branches, restore files, and detach &lt;code class=&quot;language-text&quot;&gt;HEAD&lt;/code&gt; for a look around.&lt;/p&gt;
&lt;p&gt;Git 2.23 split that pile in two, and &lt;a href=&quot;https://git-scm.com/docs/git-switch&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;git switch&lt;/code&gt;&lt;/a&gt; got the branch-switching half (detaching &lt;code class=&quot;language-text&quot;&gt;HEAD&lt;/code&gt; came along with it, since it’s a special case of switching).&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;git switch main
git switch -c fix/leaky-modal&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The difference from &lt;code class=&quot;language-text&quot;&gt;checkout&lt;/code&gt; is that &lt;code class=&quot;language-text&quot;&gt;switch&lt;/code&gt; only touches branches, so it refuses to guess when you type a filename instead of a branch name, which is exactly the ambiguity that used to eat an afternoon. &lt;code class=&quot;language-text&quot;&gt;git switch --&lt;/code&gt; even swaps back to your previous branch, the same trick as &lt;code class=&quot;language-text&quot;&gt;cd --&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;switch&lt;/code&gt; won’t guess what you meant, and after typing it often I’ve come to prefer that certainty. Old habits still work, since &lt;code class=&quot;language-text&quot;&gt;checkout&lt;/code&gt; isn’t going anywhere, but &lt;code class=&quot;language-text&quot;&gt;switch&lt;/code&gt; is the one I reach for now.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Use case&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Jumping to &lt;code class=&quot;language-text&quot;&gt;main&lt;/code&gt; to review a teammate’s PR without losing your place on your own branch&lt;/li&gt;
&lt;li&gt;Creating a new branch straight from a ticket number, before touching a single file&lt;/li&gt;
&lt;li&gt;Bouncing back to whatever you were just on with &lt;code class=&quot;language-text&quot;&gt;git switch -&lt;/code&gt;, the same trick as &lt;code class=&quot;language-text&quot;&gt;cd -&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;git switch -   # use case 3: bounce back to whatever you were just on&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id=&quot;o-restore&quot;&gt;git restore&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://git-scm.com/docs/git-restore&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;git restore&lt;/code&gt;&lt;/a&gt; took the other half of &lt;code class=&quot;language-text&quot;&gt;checkout&lt;/code&gt;’s job: pulling a file back to how it looked in the index or in some earlier commit.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;git restore --staged app.js
git restore --source=HEAD~2 app.js&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Where this works best is with &lt;code class=&quot;language-text&quot;&gt;--staged&lt;/code&gt; flag. It unstages a file without touching your working copy, which used to mean memorizing &lt;code class=&quot;language-text&quot;&gt;git reset HEAD -- &amp;lt;file&gt;&lt;/code&gt; and hoping you got the argument order right.&lt;/p&gt;
&lt;p&gt;git restore operates on three distinct locations in your repository: the Source (where the clean content is pulled from), the Staging Area (index), and the Working Tree (your local files).By controlling —staged and —worktree, you determine which destination gets modified, while —source (-s) dictates where the snapshot is pulled from.&lt;/p&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;git restore&lt;/code&gt; reads like what it does. &lt;code class=&quot;language-text&quot;&gt;reset&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;checkout&lt;/code&gt; sounds alien for new users, not for anyone who wasn’t already fluent in git’s plumbing.&lt;/p&gt;
&lt;p&gt;Unlike &lt;code class=&quot;language-text&quot;&gt;checkout&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;restore&lt;/code&gt; focuses strictly on files, eliminating the risk of accidentally switching branches.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Use case&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Undoing edits to a file you weren’t supposed to touch, back to how &lt;code class=&quot;language-text&quot;&gt;HEAD&lt;/code&gt; has it&lt;/li&gt;
&lt;li&gt;Unstaging a file you &lt;code class=&quot;language-text&quot;&gt;git add&lt;/code&gt;ed by mistake, without losing the edits sitting in it&lt;/li&gt;
&lt;li&gt;Pulling one file back from two commits ago, just to compare an old approach&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;git restore app.js   # use case 1: undo edits to a file you weren&apos;t supposed to touch&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id=&quot;o-worktree&quot;&gt;git worktree&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://git-scm.com/docs/git-worktree&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;git worktree&lt;/code&gt;&lt;/a&gt; is the one that would have saved me the most stashes.&lt;/p&gt;
&lt;p&gt;It checks out a second branch into its own folder, fully independent of whatever’s happening in your main one.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;git worktree add ../hotfix main&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;No more stashing a half-finished feature just to hop over and fix something urgent on &lt;code class=&quot;language-text&quot;&gt;main&lt;/code&gt; (as long as &lt;code class=&quot;language-text&quot;&gt;main&lt;/code&gt; isn’t the branch you’re currently sitting on, since git refuses to check the same branch out twice). Both branches sit on disk at once, each with its own working tree, so you can build one while testing the other in a separate terminal tab. Run &lt;code class=&quot;language-text&quot;&gt;git worktree remove ../hotfix&lt;/code&gt; when the fix ships, and the extra folder disappears with it, without any cleanup ritual.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Use case&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Fixing something urgent on &lt;code class=&quot;language-text&quot;&gt;main&lt;/code&gt; without stashing the feature you’re mid-way through&lt;/li&gt;
&lt;li&gt;Checking out a teammate’s branch to test their PR, while your own work stays untouched&lt;/li&gt;
&lt;li&gt;Running a slow test suite on one branch while you keep coding on another&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;git worktree add ../review teammate-feature   # use case 2: check out a teammate&apos;s PR branch
git worktree list                             # use case 3: keep tabs on trees while one runs tests&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;It’s also having a moment among people running coding agents, since &lt;a href=&quot;https://dev.to/copyleftdev/the-git-commands-you-forgot-exist-and-why-ai-workflows-make-them-relevant-again-2gb8&quot;&gt;switching branches mid-session breaks an AI agent’s context, and worktree lets you avoid that collision entirely&lt;/a&gt;, and that’s a workflow &lt;code class=&quot;language-text&quot;&gt;stash&lt;/code&gt; was never built for. The mention of AI is a whole other story we will not tackle here.&lt;/p&gt;
&lt;h2 id=&quot;o-bisect&quot;&gt;git bisect&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://git-scm.com/docs/git-bisect&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;git bisect&lt;/code&gt;&lt;/a&gt; finds the commit that broke something, using binary search instead of your eyeballs.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;git bisect start
git bisect bad
git bisect good v1.4.0&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Confused? &lt;code class=&quot;language-text&quot;&gt;git bisect&lt;/code&gt; is simply Git running this exact game of “higher or lower” for you. Instead of guessing commit hashes by hand, Git checks out the code at the midpoint, lets you test it, and waits for your answer.&lt;/p&gt;
&lt;p&gt;The coolest part of &lt;code class=&quot;language-text&quot;&gt;git bisect&lt;/code&gt; is that if you have an automated script or unit test that detects the bug (returning 0 for success and non-zero for failure), you don’t even have to test it manually. One gotcha to watch for: if a commit can’t be tested for reasons unrelated to the bug (e.g. it doesn’t build), have your script exit with code 125 instead of a generic non-zero. That tells &lt;code class=&quot;language-text&quot;&gt;git bisect&lt;/code&gt; to skip the commit rather than mark it “bad,” which would otherwise throw off the search.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Use case&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Finding which commit introduced a flaky test, somewhere across weeks of history&lt;/li&gt;
&lt;li&gt;Tracking down the exact release that broke a performance benchmark&lt;/li&gt;
&lt;li&gt;Locating the merge that quietly reintroduced a bug someone had already fixed once&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;git bisect run ./benchmark.sh                 # use case 2: automate the hunt for a broken benchmark
git bisect start --first-parent HEAD v1.4.0   # use case 3: focus on the merge that reintroduced a bug&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id=&quot;o-reflog&quot;&gt;git reflog&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://git-scm.com/docs/git-reflog&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;git reflog&lt;/code&gt;&lt;/a&gt; is the safety net under everything else on this list.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;git reflog
git reset --hard HEAD@{2}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Every time &lt;code class=&quot;language-text&quot;&gt;HEAD&lt;/code&gt; moves, whether from a commit, a checkout, a rebase, or a reset you immediately regretted, git writes it down. Nothing is actually gone until git’s garbage collector runs, and that default window is 90 days for anything still reachable, 30 for anything that isn’t.&lt;/p&gt;
&lt;p&gt;So the branch you just force-pushed over, or the commit &lt;code class=&quot;language-text&quot;&gt;reset --hard&lt;/code&gt; seemed to delete, is usually still sitting in your local reflog, waiting for you to point back at it and push again. It’s worth running once, cold, before you ever need it, the same way you’d want to know where the fire extinguisher is before there’s a fire.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Use case&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Recovering a branch you just deleted with &lt;code class=&quot;language-text&quot;&gt;git branch -D&lt;/code&gt;, one keystroke too fast&lt;/li&gt;
&lt;li&gt;Undoing a &lt;code class=&quot;language-text&quot;&gt;reset --hard&lt;/code&gt; that wiped out committed work you hadn’t pushed anywhere&lt;/li&gt;
&lt;li&gt;Getting back a commit that seems to have vanished after a rebase went sideways&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;git reflog                             # reference your safety net
-----
9e8b7c (HEAD -&gt; master, origin/master, origin/HEAD) HEAD@{0}: commit: redesign
a7e23c85 HEAD@{1}: commit: new post
1d768e5c HEAD@{2}: branch: deleted recovered-branch
abc1234  HEAD@{3}: commit: redesign 1
8df55c2b HEAD@{4}: commit: fix resolution post
4e284f5c HEAD@{5}: commit: cleanup
...

git branch recovered-branch HEAD@{2}   # use case 1: recover a branch deleted with git branch -D
git cherry-pick abc1234                # use case 3: get back a commit lost after a bad rebase&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id=&quot;a-habit-not-a-full-workflow&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#a-habit-not-a-full-workflow&quot; aria-label=&quot;a habit not a full workflow permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;A habit, not a full workflow&lt;/h2&gt;
&lt;p&gt;None of this makes &lt;code class=&quot;language-text&quot;&gt;stash&lt;/code&gt; or &lt;code class=&quot;language-text&quot;&gt;checkout&lt;/code&gt; obsolete.&lt;/p&gt;
&lt;p&gt;I still reach for both most days, and I probably always will. What’s changed is that they’re no longer the only tools on the bench: &lt;code class=&quot;language-text&quot;&gt;switch&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;restore&lt;/code&gt; for the everyday moves, &lt;code class=&quot;language-text&quot;&gt;worktree&lt;/code&gt; for when two branches need to exist at once, &lt;code class=&quot;language-text&quot;&gt;bisect&lt;/code&gt; for the bug I can’t just eyeball, &lt;code class=&quot;language-text&quot;&gt;reflog&lt;/code&gt; for the moment I do something I can’t undo any other way.&lt;/p&gt;
&lt;p&gt;Pick one from this list and use it on purpose this week.&lt;/p&gt;
&lt;p&gt;Start with whichever one solves a problem you already have. If you keep stashing to switch branches, that’s &lt;code class=&quot;language-text&quot;&gt;worktree&lt;/code&gt;. If you keep losing work to a bad &lt;code class=&quot;language-text&quot;&gt;reset --hard&lt;/code&gt;, that’s &lt;code class=&quot;language-text&quot;&gt;reflog&lt;/code&gt;. The rest will follow once one of them earns your trust.&lt;/p&gt;
&lt;p&gt;Happy coding!&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Four Things Every CMS Image Field Needs]]></title><description><![CDATA[Most CMS image fields do exactly one job. They take a file, then hand you a single box to type an alt attribute into. That’s fine for one…]]></description><link>https://www.codespud.com/2026/five-things-every-cms-image-field-is-missing/</link><guid isPermaLink="false">https://www.codespud.com/2026/five-things-every-cms-image-field-is-missing/</guid><pubDate>Tue, 04 Aug 2026 08:29:00 GMT</pubDate><content:encoded>&lt;p&gt;Most CMS image fields do exactly one job.&lt;/p&gt;
&lt;p&gt;They take a file, then hand you a single box to type an alt attribute into. That’s fine for one photo on one page, but it falls apart the moment the same photo gets reused as a hero here and a thumbnail there, because a single field can’t hold two different jobs at once.&lt;/p&gt;
&lt;p&gt;Three real media libraries make the pattern easy to spot.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/blog/media-library-wordpress.png&quot; alt=&quot;Showing separate Title, Caption, and Alt Text fields that are all saved once per file.&quot;&gt;
&lt;em&gt;Three separate text fields, one saved value each, no per-placement override.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/blog/media-library-contentful.png&quot; alt=&quot;Asset editor, showing a single Description field used as both caption and alt text for every entry that links the file.&quot;&gt;
&lt;em&gt;One Description field doing alt text’s job, same everywhere the asset appears.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/blog/media-library-sanity.png&quot; alt=&quot;Image field, showing a hotspot circle on the thumbnail next to a single, still-empty Alt Text box below it.&quot;&gt;
&lt;em&gt;A hotspot for cropping, but still just one alt text box underneath it.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;For the previous examples, the model might look like this,&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;json&quot;&gt;&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;asset&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;photo-042.jpg&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;alt&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Team standup, April 2026&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;description&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Company X development team. Sign below says &apos;April 2026&apos;&quot;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;There’s nothing wrong with the JSON model, but for most use cases it’s not enough.&lt;/p&gt;
&lt;p&gt;Here’s what I’d want added into the metadata every time an image is uploaded.&lt;/p&gt;
&lt;h2 id=&quot;additional-metadata-that-makes-an-image-an-asset&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#additional-metadata-that-makes-an-image-an-asset&quot; aria-label=&quot;additional metadata that makes an image an asset permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Additional metadata that makes an image an “asset”&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;#o-alt-travels&quot;&gt;Alt text that travels with the placement&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#o-ask-first&quot;&gt;A field that asks what the image is for, before what to call it&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#o-focal-point&quot;&gt;Focal points, not fixed crops&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#o-lazy-reserved&quot;&gt;Lazy loading and reserved space, by default&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;o-alt-travels&quot;&gt;Alt text that travels with the placement&lt;/h2&gt;
&lt;p&gt;Most media libraries store exactly one alt text per asset, saved once when the file goes in.&lt;/p&gt;
&lt;p&gt;That is wrong, because the same image plays a different role every time it gets reused. A product photo can be informative on a listing page and purely decorative as a background texture on a landing page three templates over.&lt;/p&gt;
&lt;p&gt;The &lt;a href=&quot;https://www.w3.org/WAI/WCAG22/Understanding/non-text-content.html&quot;&gt;W3C’s guidance on text alternatives&lt;/a&gt; asks for an alternative that serves an &lt;em&gt;equivalent purpose&lt;/em&gt;, and purpose is a property of the placement, not the file. The practical fix: store a sensible default on the asset, then &lt;u&gt;let each placement override it&lt;/u&gt;.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;mermaid&quot;&gt;&lt;pre class=&quot;language-mermaid&quot;&gt;&lt;code class=&quot;language-mermaid&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;flowchart&lt;/span&gt; TD
    A&lt;span class=&quot;token text string&quot;&gt;[Image asset]&lt;/span&gt; &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt;&lt;span class=&quot;token label property&quot;&gt;|default alt|&lt;/span&gt; B&lt;span class=&quot;token text string&quot;&gt;[&quot;Team standup, April 2026&quot;]&lt;/span&gt;
    A &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt; C&lt;span class=&quot;token text string&quot;&gt;[Used as: blog post hero]&lt;/span&gt;
    A &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt; D&lt;span class=&quot;token text string&quot;&gt;[Used as: about-page thumbnail]&lt;/span&gt;
    C &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt;&lt;span class=&quot;token label property&quot;&gt;|override: decorative|&lt;/span&gt; E&lt;span class=&quot;token text string&quot;&gt;[&quot;alt is empty&quot;]&lt;/span&gt;
    D &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt;&lt;span class=&quot;token label property&quot;&gt;|override: informative|&lt;/span&gt; F&lt;span class=&quot;token text string&quot;&gt;[&quot;Five of us at the whiteboard&quot;]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;em&gt;One asset, one default, two placements that override it, because the image’s job changes, not the file.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;That turns alt text from a property of a file into something that describes the relationship between the image and everything around it.&lt;/p&gt;
&lt;h2 id=&quot;o-ask-first&quot;&gt;A field that asks what the image is for, before what to call it&lt;/h2&gt;
&lt;p&gt;As mentioned earlier, most apps show an input for alt text and nothing else. Nothing tells the editor what to describe, so most either skip it or type “image of a person smiling,” which helps no one.&lt;/p&gt;
&lt;p&gt;Let’s change it: ask the role first. Decorative? Functional? Informative? The &lt;a href=&quot;https://www.w3.org/WAI/tutorials/images/decision-tree/&quot;&gt;W3C decision tree&lt;/a&gt; walks through exactly that triage. Most CMS platforms skip “functional” entirely. In those cases, the UI can be as simple as a “decorative?” checkbox, unchecked by default.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;mermaid&quot;&gt;&lt;pre class=&quot;language-mermaid&quot;&gt;&lt;code class=&quot;language-mermaid&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;flowchart&lt;/span&gt; TD
    A&lt;span class=&quot;token text string&quot;&gt;[Upload image]&lt;/span&gt; &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt; B&lt;span class=&quot;token text string&quot;&gt;{What is this image for?}&lt;/span&gt;
    B &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt;&lt;span class=&quot;token label property&quot;&gt;|Decorative|&lt;/span&gt; C&lt;span class=&quot;token text string&quot;&gt;[Lock alt to empty, show why]&lt;/span&gt;
    B &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt;&lt;span class=&quot;token label property&quot;&gt;|Functional|&lt;/span&gt; D&lt;span class=&quot;token text string&quot;&gt;[Ask: what action does it trigger?]&lt;/span&gt;
    B &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt;&lt;span class=&quot;token label property&quot;&gt;|Informative|&lt;/span&gt; E&lt;span class=&quot;token text string&quot;&gt;[Ask: what one fact does it add?]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;em&gt;The role picked up top decides what the field asks next. No more blank box, no more guessing.&lt;/em&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Pick decorative and the field locks to an empty alt with a short note explaining why.&lt;/li&gt;
&lt;li&gt;Pick functional and it asks for the action the image triggers, not its appearance.&lt;/li&gt;
&lt;li&gt;Pick informative and it asks for the one fact the image adds that the surrounding text doesn’t already say.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The upload form becomes a two-second decision instead of a blank input that quietly punishes whoever fills it in last.&lt;/p&gt;
&lt;h2 id=&quot;o-focal-point&quot;&gt;Focal points, not fixed crops&lt;/h2&gt;
&lt;p&gt;A photo gets uploaded, and can be used everywhere in the application: a square avatar, a wide hero, a tall card on mobile.&lt;/p&gt;
&lt;p&gt;A single manual crop only helps the ratio it was cut for, so the next template either squeezes the subject out of frame or drags a designer back in with scissors.&lt;/p&gt;
&lt;p&gt;A “focal point” fixes this at the source. &lt;a href=&quot;https://www.sanity.io/docs/apis-and-sdks/presenting-images&quot;&gt;Sanity’s image pipeline&lt;/a&gt; stores a hotspot on the image once, then its URL builder crops every requested ratio around that point automatically, with no per-template manual work required (Storyblok ships the same pattern natively; Contentful gets there via a marketplace app, though you still write the crop logic yourself).&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;mermaid&quot;&gt;&lt;pre class=&quot;language-mermaid&quot;&gt;&lt;code class=&quot;language-mermaid&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;flowchart&lt;/span&gt; TD
    A&lt;span class=&quot;token text string&quot;&gt;[&quot;Photo + hotspot (x, y)&quot;]&lt;/span&gt; &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt; B&lt;span class=&quot;token text string&quot;&gt;[Square avatar]&lt;/span&gt;
    A &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt; C&lt;span class=&quot;token text string&quot;&gt;[Wide hero, 16:9]&lt;/span&gt;
    A &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt; D&lt;span class=&quot;token text string&quot;&gt;[Tall mobile card]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;em&gt;Same file, same hotspot, three crops that keeps what is important in frame.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;It’s a small piece of metadata, but it’s the difference between an image library that scales with new templates and one that generates a support ticket every time somebody adds a layout.&lt;/p&gt;
&lt;h2 id=&quot;o-lazy-reserved&quot;&gt;Lazy loading and reserved space, by default&lt;/h2&gt;
&lt;p&gt;An &lt;code class=&quot;language-text&quot;&gt;&amp;lt;img&gt;&lt;/code&gt; tag with no &lt;code class=&quot;language-text&quot;&gt;loading&lt;/code&gt; attribute and no dimensions does two things wrong at once.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;It competes with everything else on the page for bandwidth the instant the page loads.&lt;/li&gt;
&lt;li&gt;It leaves no space reserved for itself, so the layout jumps the moment it finally arrives.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Native lazy loading fixes the first problem. Setting &lt;code class=&quot;language-text&quot;&gt;loading=&quot;lazy&quot;&lt;/code&gt; tells the browser to &lt;a href=&quot;https://web.dev/articles/browser-level-image-lazy-loading&quot;&gt;defer offscreen images until they’re actually needed&lt;/a&gt;, a single attribute and no library required.&lt;/p&gt;
&lt;p&gt;The standard setup has one exception. Whatever loads first (above the fold), often the hero, should stay eager, sometimes with &lt;code class=&quot;language-text&quot;&gt;fetchpriority=&quot;high&quot;&lt;/code&gt;, because &lt;a href=&quot;https://web.dev/articles/optimize-lcp&quot;&gt;lazy-loading the Largest Contentful Paint candidate&lt;/a&gt; only delays the page’s most important image.&lt;/p&gt;
&lt;p&gt;Declaring width and height, or a CSS aspect-ratio, fixes the second problem, because the browser can reserve the right box before a single byte of the image arrives.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;img&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;children-playing.png&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;500&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;350&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;loading&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;lazy&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;Kids playing tag on the street&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;mermaid&quot;&gt;&lt;pre class=&quot;language-mermaid&quot;&gt;&lt;code class=&quot;language-mermaid&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;flowchart&lt;/span&gt; TD
    A&lt;span class=&quot;token text string&quot;&gt;[img rendered by template]&lt;/span&gt; &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt; B&lt;span class=&quot;token text string&quot;&gt;{Above the fold?}&lt;/span&gt;
    B &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt;&lt;span class=&quot;token label property&quot;&gt;|Yes, LCP candidate|&lt;/span&gt; C&lt;span class=&quot;token text string&quot;&gt;[&quot;loading=eager, fetchpriority=high&quot;]&lt;/span&gt;
    B &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt;&lt;span class=&quot;token label property&quot;&gt;|No|&lt;/span&gt; D&lt;span class=&quot;token text string&quot;&gt;[loading=lazy]&lt;/span&gt;
    C &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt; E&lt;span class=&quot;token text string&quot;&gt;[width/height or aspect-ratio reserved]&lt;/span&gt;
    D &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt; E&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;em&gt;One branch for the hero, one for everything else. Both still reserve their space.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Both belong in whatever template renders the image, generated automatically from data the CMS already has instead of leaving it the browser to fill in later when image is loaded which is a step too late.&lt;/p&gt;
&lt;h2 id=&quot;what-a-boring-image-field-buys-you&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#what-a-boring-image-field-buys-you&quot; aria-label=&quot;what a boring image field buys you permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;What a boring image field buys you&lt;/h2&gt;
&lt;p&gt;None of these five properties take much code once a platform already has the underlying primitive, a hotspot API, an image CDN, a role-aware form. The harder version is building that primitive yourself, from a blank content model.&lt;/p&gt;
&lt;h3 id=&quot;the-checklist&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#the-checklist&quot; aria-label=&quot;the checklist permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;The checklist&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;a default alt with a per-placement override&lt;/li&gt;
&lt;li&gt;a role-first prompt&lt;/li&gt;
&lt;li&gt;a focal point&lt;/li&gt;
&lt;li&gt;lazy loading with reserved space&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;the-image-metadata-we-want&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#the-image-metadata-we-want&quot; aria-label=&quot;the image metadata we want permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;The image metadata we want&lt;/h3&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;json&quot;&gt;&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;asset&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;photo-042.jpg&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;altDefault&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Team standup, April 2026&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;hotspot&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token property&quot;&gt;&quot;x&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0.52&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token property&quot;&gt;&quot;y&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0.38&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;variants&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;400w&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;800w&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;1200w&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;1600w&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;loading&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;lazy&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;placements&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;blog-hero&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token property&quot;&gt;&quot;role&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;decorative&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token property&quot;&gt;&quot;alt&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;about-page-thumbnail&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token property&quot;&gt;&quot;role&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;informative&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token property&quot;&gt;&quot;alt&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Our team of five working at the whiteboard&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;em&gt;That’s the all the metadata: four suggestions from this post, one small schema. Just slightly more than the usual filename and alt text.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;What they give you is an image pipeline that doesn’t depend on every editor remembering every rule on every upload, because the rules live in the field instead of in someone’s memory.&lt;/p&gt;
&lt;p&gt;Happy building!&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Typographic Hierarchy Playground]]></title><description><![CDATA[Drag four sliders and watch where your eye lands first. Visual hierarchy has many levers — layout, color, imagery, motion. This demo…]]></description><link>https://www.codespud.com/typographic-hierarchy-playground/</link><guid isPermaLink="false">https://www.codespud.com/typographic-hierarchy-playground/</guid><pubDate>Sun, 26 Jul 2026 10:00:00 GMT</pubDate><content:encoded>&lt;blockquote&gt;
&lt;p&gt;Drag four sliders and watch where your eye lands first.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Visual hierarchy has many levers — layout, color, imagery, motion. This demo isolates the typographic ones. Four sliders control font size, weight, spacing, and contrast; a live preview stage re-renders on every change, so the effect of each lever is visible rather than described.&lt;/p&gt;
&lt;p&gt;Every value derives from one base. The headline is a multiple of the body size, subhead and CTA weights are offsets from the headline weight, and the spacing slider drives line-height, block gaps, and button padding together. Pushing a slider doesn’t just scale one thing — it widens or narrows the gap between elements, which is what hierarchy actually is.&lt;/p&gt;
&lt;h2 id=&quot;presets&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#presets&quot; aria-label=&quot;presets permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Presets&lt;/h2&gt;
&lt;p&gt;Each preset jumps to the layout it belongs to and explains what it’s demonstrating:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Clear Hierarchy&lt;/strong&gt; — every lever pulls the same direction; one obvious reading path.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Editorial&lt;/strong&gt; — the restrained middle ground most documentation sites converge on.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Flat Hierarchy&lt;/strong&gt; — nearly uniform blocks. No entry point, so the eye searches. Correct for legal text, wrong for an article.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Bold &amp;#x26; Cramped&lt;/strong&gt; — weight still leads, but near-zero spacing collapses the structure.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Low-Contrast Whisper&lt;/strong&gt; — decent hierarchy hiding a contrast failure. It’s labeled as a mistake: at that setting the body copy fails WCAG AA and reads closer to invisible than subtle.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Size Only&lt;/strong&gt; — weight and contrast left neutral. It works, but less confidently.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Everything Maxed&lt;/strong&gt; — every lever at its ceiling. Nothing is emphasized once everything shouts.&lt;/li&gt;
&lt;/ul&gt;
&lt;figure&gt;
&lt;img src=&quot;/typographic-hierarchy-presets-wireframe.png&quot; width=&quot;80%&quot; alt=&quot;Three side-by-side wireframe panels showing identical content blocks under different settings: Clear Hierarchy with distinct sizes and generous gaps, Flat Hierarchy with uniform low-contrast bars crammed together, and Everything Maxed with oversized dark blocks and huge gaps.&quot; /&gt;
&lt;figcaption&gt;The same blocks under three settings — the only variables are size, weight, spacing and contrast&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;The point of the “bad” presets is that most of them aren’t bad — they’re mismatched. Flat hierarchy is the right answer for a spec sheet and the wrong one for a blog post. Only the low-contrast preset is unambiguously broken, and it’s marked as such.&lt;/p&gt;
&lt;h2 id=&quot;layouts-changes-with-presets&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#layouts-changes-with-presets&quot; aria-label=&quot;layouts changes with presets permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Layouts changes with Presets&lt;/h2&gt;
&lt;p&gt;A single article layout would only prove that big headlines beat small ones. Instead the stage swaps between six scenes, each one a place the setting in question actually shows up in production:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Blog article&lt;/strong&gt; — headline, subhead, body, CTA&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Legal / T&amp;#x26;Cs list&lt;/strong&gt; — dense reference text with no single entry point&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Notification card&lt;/strong&gt; — a heavy label winning attention in a tiny footprint&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Product update with disclaimer and timestamp&lt;/strong&gt; — deliberately de-emphasized metadata&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Editorial pull-quote&lt;/strong&gt; — large, light type as its own device&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Marketing hero&lt;/strong&gt; — eyebrow, headline, subhead, dual CTAs&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;notes&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#notes&quot; aria-label=&quot;notes permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Notes&lt;/h2&gt;
&lt;p&gt;Contrast is the one lever doing two jobs: it pulls the eye &lt;em&gt;and&lt;/em&gt; keeps text legible. That’s why it’s the only slider whose extreme is called out as an accessibility failure rather than a stylistic choice — the same setting that makes a disclaimer feel appropriately quiet, pushed a little further, makes it unreadable on a phone in sunlight.&lt;/p&gt;
&lt;p&gt;Built with React and Vite, styled with Tailwind, deployed to GitHub Pages on push to &lt;code class=&quot;language-text&quot;&gt;main&lt;/code&gt; via GitHub Actions.&lt;/p&gt;
&lt;h2 id=&quot;final-screen&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#final-screen&quot; aria-label=&quot;final screen permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Final screen&lt;/h2&gt;
&lt;p&gt;Here’s the final output. Previous iterations had was text heavy - made the page too busy. The preview screen should be the star. Now we only disclose the information you need for the current state. The levers show explanations on hover or focus.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&quot;/typography-hierarchy-final-screen.png&quot; width=&quot;80%&quot; alt=&quot;less cluttered view of typographic hierarchy playground&quot; /&gt;
&lt;figcaption&gt;Playground final design &lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;&lt;strong&gt;Links&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://chrisbautista.github.io/visual-hierarchy-typography/&quot;&gt;Live demo&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/chrisbautista/visual-hierarchy-typography&quot;&gt;Source on GitHub&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[10 TypeScript Patterns That Make Code Explain Itself]]></title><description><![CDATA[Comments rot. Types don’t - the compiler checks them on every build. The best comment you’ll ever write is the one you skip, because the…]]></description><link>https://www.codespud.com/2026/10-typescript-patterns-that-explain-themselves/</link><guid isPermaLink="false">https://www.codespud.com/2026/10-typescript-patterns-that-explain-themselves/</guid><pubDate>Sat, 25 Jul 2026 08:29:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;em&gt;Comments rot. Types don’t - the compiler checks them on every build.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;The best comment you’ll ever write is the one you skip, because the code and the already said it. Comments describe intent once, then sit there. Nobody re-checks a comment when the code around it changes six months later. A type gets no such luxury: the compiler re-verifies it on every build. A lying type gets caught. A lying comment just keeps lying, quietly, for as long as nobody notices.&lt;/p&gt;
&lt;p&gt;Here are two versions of the same function: one documented by a comment above it, the other by the function definition.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;typescript&quot;&gt;&lt;pre class=&quot;language-typescript&quot;&gt;&lt;code class=&quot;language-typescript&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// callback fires with the new value; the type depends on which key changed&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;on&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;eventName&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; callback&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;token comment&quot;&gt;//...&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Versus,&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;typescript&quot;&gt;&lt;pre class=&quot;language-typescript&quot;&gt;&lt;code class=&quot;language-typescript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token generic-function&quot;&gt;&lt;span class=&quot;token function&quot;&gt;on&lt;/span&gt;&lt;span class=&quot;token generic class-name&quot;&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;Key &lt;span class=&quot;token keyword&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;keyof&lt;/span&gt; Type&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
     eventName&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;Key&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;Changed&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; 
     &lt;span class=&quot;token function-variable function&quot;&gt;callback&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;value&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; Type&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;Key&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;void&lt;/span&gt; 
   &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;token comment&quot;&gt;//...&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Both try to say the same thing. The latter breaks the build the moment it stops being true, because it is checked by something other than a human remembering to update it.&lt;/p&gt;
&lt;p&gt;That’s the argument I am presenting in this post. Not “add more types.” Plenty of heavily typed code is still unreadable: all &lt;code class=&quot;language-text&quot;&gt;any&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;as&lt;/code&gt; casts, interfaces named &lt;code class=&quot;language-text&quot;&gt;Props2&lt;/code&gt;. This is narrower: ten specific patterns that turn a signature into something a teammate can read cold, six months out, without opening the implementation, and trust.&lt;/p&gt;
&lt;p&gt;Most of these shipped in TypeScript within the last four years, which means plenty of frontend codebases haven’t picked them up yet, not from resistance, just because a feature landing in a release note doesn’t automatically show up in a team’s habits. Some are old TypeScript wearing a sharper technique, not new syntax at all. What ties all ten together is that each one moves a fact a reader needs out of a sentence and into something the compiler is willing to enforce.&lt;/p&gt;
&lt;h2 id=&quot;1-satisfies-keep-the-specific-type-not-just-the-general-one&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#1-satisfies-keep-the-specific-type-not-just-the-general-one&quot; aria-label=&quot;1 satisfies keep the specific type not just the general one permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;1. &lt;code class=&quot;language-text&quot;&gt;satisfies&lt;/code&gt;: keep the specific type, not just the general one&lt;/h2&gt;
&lt;p&gt;Define a config object and you want TypeScript to check it against a shape like &lt;code class=&quot;language-text&quot;&gt;Record&amp;lt;string, RouteConfig&gt;&lt;/code&gt;. The old move, a type annotation, works, but it throws away information. Every property on &lt;code class=&quot;language-text&quot;&gt;routes&lt;/code&gt; now reads as &lt;code class=&quot;language-text&quot;&gt;RouteConfig&lt;/code&gt;, even though TypeScript knew a second ago that &lt;code class=&quot;language-text&quot;&gt;routes.home&lt;/code&gt; was specifically &lt;code class=&quot;language-text&quot;&gt;{ path: &quot;/&quot;, exact: true }&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://devblogs.microsoft.com/typescript/announcing-typescript-4-9/&quot;&gt;TypeScript 4.9&lt;/a&gt; (November 15, 2022) added &lt;code class=&quot;language-text&quot;&gt;satisfies&lt;/code&gt; to fix this. It checks an expression against a type without changing the expression’s own inferred type:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;ts&quot;&gt;&lt;pre class=&quot;language-ts&quot;&gt;&lt;code class=&quot;language-ts&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;RouteConfig&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; path&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; exact&lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;boolean&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; routes &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  home&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; path&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;/&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; exact&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  about&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; path&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;/about&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; satisfies Record&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; RouteConfig&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

routes&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;home&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;exact&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// still known to be `true`, not `boolean | undefined`&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Read that signature and you know two things at once: this object matches &lt;code class=&quot;language-text&quot;&gt;Record&amp;lt;string, RouteConfig&gt;&lt;/code&gt;, and each entry keeps its own literal shape. Hover over &lt;code class=&quot;language-text&quot;&gt;routes.home.exact&lt;/code&gt; in your editor and it shows &lt;code class=&quot;language-text&quot;&gt;true&lt;/code&gt;. The annotated version would show &lt;code class=&quot;language-text&quot;&gt;boolean | undefined&lt;/code&gt; and send you back up to the object literal to check what was actually there: the exact round trip a self-documenting signature is meant to remove. It’s become the default choice for theme objects and default-options objects, anywhere a value needs validating without losing its specifics.&lt;/p&gt;
&lt;p&gt;The &lt;code class=&quot;language-text&quot;&gt;routes&lt;/code&gt; example leaves the key set open: any string key is allowed, as long as its value matches &lt;code class=&quot;language-text&quot;&gt;RouteConfig&lt;/code&gt;. Just as often, you want the opposite: a closed, specific set of keys, with each value still keeping its literal type. &lt;code class=&quot;language-text&quot;&gt;satisfies&lt;/code&gt; does both at once:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;ts&quot;&gt;&lt;pre class=&quot;language-ts&quot;&gt;&lt;code class=&quot;language-ts&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;IconName&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;home&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;settings&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;profile&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; icons &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  home&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; size&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;24&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; viewBox&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;0 0 24 24&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  settings&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; size&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; viewBox&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;0 0 20 20&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  profile&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; size&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;24&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; viewBox&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;0 0 24 24&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; satisfies Record&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;IconName&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; size&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; viewBox&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

icons&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;settings&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;size&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// still known to be `20`, not widened to `number`&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// const broken = {&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;//   home: { size: 24, viewBox: &quot;0 0 24 24&quot; },&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;//   banner: { size: 32, viewBox: &quot;0 0 32 32&quot; }, // error: &quot;banner&quot; isn&apos;t in IconName&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// } satisfies Record&amp;lt;IconName, { size: number; viewBox: string }&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The code above reads as &lt;code class=&quot;language-text&quot;&gt;icons&lt;/code&gt; can only have the three keys &lt;code class=&quot;language-text&quot;&gt;IconName&lt;/code&gt; allows (add a &lt;code class=&quot;language-text&quot;&gt;banner&lt;/code&gt; icon without updating the union and the object literal itself fails to compile&lt;sup id=&quot;fnref-1&quot;&gt;&lt;a href=&quot;#fn-1&quot; class=&quot;footnote-ref&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;), and each entry still reports its own literal &lt;code class=&quot;language-text&quot;&gt;size&lt;/code&gt;, not a widened &lt;code class=&quot;language-text&quot;&gt;number&lt;/code&gt;. A plain type annotation on &lt;code class=&quot;language-text&quot;&gt;icons&lt;/code&gt; would have gotten the closed key set but lost the literals; the looser &lt;code class=&quot;language-text&quot;&gt;Record&amp;lt;string, ...&gt;&lt;/code&gt; from the first example gets the literals but not the closed set. &lt;code class=&quot;language-text&quot;&gt;satisfies&lt;/code&gt; is the only one of the three that keeps both.&lt;/p&gt;
&lt;h2 id=&quot;2-const-type-parameters&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#2-const-type-parameters&quot; aria-label=&quot;2 const type parameters permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;2. &lt;code class=&quot;language-text&quot;&gt;const&lt;/code&gt; type parameters&lt;/h2&gt;
&lt;p&gt;Pass an array or object into a generic function, and TypeScript widens it: &lt;code class=&quot;language-text&quot;&gt;[&quot;a&quot;, &quot;b&quot;]&lt;/code&gt; becomes &lt;code class=&quot;language-text&quot;&gt;string[]&lt;/code&gt;, not the tuple &lt;code class=&quot;language-text&quot;&gt;[&quot;a&quot;, &quot;b&quot;]&lt;/code&gt;. For years the workaround was &lt;code class=&quot;language-text&quot;&gt;as const&lt;/code&gt; at every call site, a small ritual that works but adds noise the reader has to filter out.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/&quot;&gt;TypeScript 5.0&lt;/a&gt; (March 16, 2023) moved that behavior into the function definition with a &lt;code class=&quot;language-text&quot;&gt;const&lt;/code&gt; modifier on the type parameter:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;ts&quot;&gt;&lt;pre class=&quot;language-ts&quot;&gt;&lt;code class=&quot;language-ts&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token generic-function&quot;&gt;&lt;span class=&quot;token function&quot;&gt;getNamesExactly&lt;/span&gt;&lt;span class=&quot;token generic class-name&quot;&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;T&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; names&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;readonly&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;arg&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; arg&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;names&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token function&quot;&gt;getNamesExactly&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; names&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Milo&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Otis&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// return type: readonly [&quot;Milo&quot;, &quot;Otis&quot;] — no `as const` at the call site&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Whatever you pass keeps its literal shape, guaranteed by the function definition rather than by every caller remembering . It shows up in small custom hooks constantly. A &lt;code class=&quot;language-text&quot;&gt;useToggle&lt;/code&gt; that should return the precise tuple &lt;code class=&quot;language-text&quot;&gt;[boolean, () =&gt; void]&lt;/code&gt;, not a loosely typed array, benefits from this.&lt;/p&gt;
&lt;h2 id=&quot;3-discriminated-unions-with-exhaustive-checks-a-state-machine-in-the-type&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#3-discriminated-unions-with-exhaustive-checks-a-state-machine-in-the-type&quot; aria-label=&quot;3 discriminated unions with exhaustive checks a state machine in the type permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;3. Discriminated unions with exhaustive checks: a state machine in the type&lt;/h2&gt;
&lt;p&gt;Loading states are the classic frontend mess: &lt;code class=&quot;language-text&quot;&gt;{ loading: boolean, data?: T, error?: string }&lt;/code&gt;, where &lt;code class=&quot;language-text&quot;&gt;loading: true&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;error: &quot;oops&quot;&lt;/code&gt; can both be true at once and nothing complains about it.&lt;/p&gt;
&lt;p&gt;A discriminated union makes the states mutually exclusive and names each one:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;ts&quot;&gt;&lt;pre class=&quot;language-ts&quot;&gt;&lt;code class=&quot;language-ts&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;FetchState&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;
  &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; status&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;idle&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; status&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;loading&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; status&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;success&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; data&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;T&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; status&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;error&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; error&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;state&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; FetchState&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;User&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;switch&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;state&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;status&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;idle&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;loading&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Loading…&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;success&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; state&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;data&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// `data` only exists here&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;error&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; state&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;error&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;       &lt;span class=&quot;token comment&quot;&gt;// `error` only exists here&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; _exhaustive&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;never&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; state&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;     &lt;span class=&quot;token comment&quot;&gt;// compile error if a case is missing&lt;/span&gt;
      &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; _exhaustive&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The state goes like this:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;mermaid&quot;&gt;&lt;pre class=&quot;language-mermaid&quot;&gt;&lt;code class=&quot;language-mermaid&quot;&gt;&lt;span class=&quot;token arrow operator&quot;&gt;---&lt;/span&gt;
title&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; Fetch State
&lt;span class=&quot;token arrow operator&quot;&gt;---&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;stateDiagram-v2&lt;/span&gt;
  &lt;span class=&quot;token text string&quot;&gt;[*]&lt;/span&gt; &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt; idle
  idle &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt; loading&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; fetch&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  loading &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt; success&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; resolves
  loading &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt; error&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; rejects
  success &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt; loading&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; refetch&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  error &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt; loading&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; retry&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Discriminated unions aren’t new. What makes them documentation, not just structure, is the &lt;code class=&quot;language-text&quot;&gt;never&lt;/code&gt; check in the default branch. It turns “can loading and error both be true?” from a question raised in a pull request into a question the compiler already answered. Add a fifth state and forget to handle it, and the build breaks at that exact call site. No comment thread does that automatically.&lt;/p&gt;
&lt;h2 id=&quot;4-noinfer-say-which-part-of-the-signature-is-fixed&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#4-noinfer-say-which-part-of-the-signature-is-fixed&quot; aria-label=&quot;4 noinfer say which part of the signature is fixed permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;4. &lt;code class=&quot;language-text&quot;&gt;NoInfer&lt;/code&gt;: say which part of the signature is fixed&lt;/h2&gt;
&lt;p&gt;Generic functions sometimes infer from the wrong argument. Picture a function that picks a default from a known set:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;ts&quot;&gt;&lt;pre class=&quot;language-ts&quot;&gt;&lt;code class=&quot;language-ts&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token generic-function&quot;&gt;&lt;span class=&quot;token function&quot;&gt;pickDefault&lt;/span&gt;&lt;span class=&quot;token generic class-name&quot;&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;options&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; fallback&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;T&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; options&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;includes&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;fallback&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; fallback &lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; options&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token function&quot;&gt;pickDefault&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;a&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;b&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;c&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// `T` widens to &quot;a&quot; | &quot;b&quot; | &quot;c&quot; — `fallback` shouldn&apos;t drive this&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href=&quot;https://devblogs.microsoft.com/typescript/announcing-typescript-5-4/&quot;&gt;TypeScript 5.4&lt;/a&gt; (March 6, 2024) added &lt;code class=&quot;language-text&quot;&gt;NoInfer&amp;lt;T&gt;&lt;/code&gt; to mark an argument as ineligible for inference:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;ts&quot;&gt;&lt;pre class=&quot;language-ts&quot;&gt;&lt;code class=&quot;language-ts&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token generic-function&quot;&gt;&lt;span class=&quot;token function&quot;&gt;pickDefault&lt;/span&gt;&lt;span class=&quot;token generic class-name&quot;&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;options&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; fallback&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; NoInfer&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;T&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; options&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;includes&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;fallback&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; fallback &lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; options&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token function&quot;&gt;pickDefault&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;a&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;b&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;c&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// now a type error: &quot;c&quot; isn&apos;t in &quot;a&quot; | &quot;b&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The feature is small, but it makes the signature honest: &lt;code class=&quot;language-text&quot;&gt;options&lt;/code&gt; decides what &lt;code class=&quot;language-text&quot;&gt;T&lt;/code&gt; is, &lt;code class=&quot;language-text&quot;&gt;fallback&lt;/code&gt; just has to match it. That distinction used to live only in the author’s head, which is exactly how a &lt;code class=&quot;language-text&quot;&gt;useReducer&lt;/code&gt; helper’s initial-state type quietly gets widened by whatever the reducer’s action union includes. The bug shows up as broken autocomplete three files from the actual cause, and takes real effort to trace back.&lt;/p&gt;
&lt;h2 id=&quot;5-using-declarations&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#5-using-declarations&quot; aria-label=&quot;5 using declarations permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;5. &lt;code class=&quot;language-text&quot;&gt;using&lt;/code&gt; declarations&lt;/h2&gt;
&lt;p&gt;Anything needing teardown (a subscription, an &lt;code class=&quot;language-text&quot;&gt;AbortController&lt;/code&gt;, a mutex) usually ends up in a &lt;code class=&quot;language-text&quot;&gt;try&lt;/code&gt;/&lt;code class=&quot;language-text&quot;&gt;finally&lt;/code&gt; block, cleanup logic physically far from setup. &lt;a href=&quot;https://devblogs.microsoft.com/typescript/announcing-typescript-5-2/&quot;&gt;TypeScript 5.2&lt;/a&gt; (August 24, 2023) added &lt;code class=&quot;language-text&quot;&gt;using&lt;/code&gt; declarations, implementing the TC39 Explicit Resource Management proposal:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;ts&quot;&gt;&lt;pre class=&quot;language-ts&quot;&gt;&lt;code class=&quot;language-ts&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;subscribeToResize&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;el&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; HTMLElement&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;onResize&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; observer &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;ResizeObserver&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;onResize&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  observer&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;observe&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;el&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  using _disposable &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;Symbol&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;dispose&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; observer&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;disconnect&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// scope ends, disconnect() runs automatically — no finally block needed&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;using&lt;/code&gt; sits right next to the resource it disposes of. Compare that to the usual React effect pattern (&lt;code class=&quot;language-text&quot;&gt;addEventListener&lt;/code&gt; at the top of &lt;code class=&quot;language-text&quot;&gt;useEffect&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;removeEventListener&lt;/code&gt; twenty lines later in the cleanup function it returns), where someone reading the code has to hold both ends in their head to confirm they match. &lt;code class=&quot;language-text&quot;&gt;using&lt;/code&gt; collapses that distance to zero, and it applies just as directly to a plain &lt;code class=&quot;language-text&quot;&gt;addEventListener&lt;/code&gt;/&lt;code class=&quot;language-text&quot;&gt;removeEventListener&lt;/code&gt; pair as it does to a &lt;code class=&quot;language-text&quot;&gt;ResizeObserver&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;ts&quot;&gt;&lt;pre class=&quot;language-ts&quot;&gt;&lt;code class=&quot;language-ts&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;onOutsideClick&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;el&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; HTMLElement&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;onOutside&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;handleClick&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;e&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; MouseEvent&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;el&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;contains&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;e&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;target &lt;span class=&quot;token keyword&quot;&gt;as&lt;/span&gt; Node&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;onOutside&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;click&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; handleClick&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  using _disposable &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;Symbol&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;dispose&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;removeEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;click&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; handleClick&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// scope ends, removeEventListener runs with the exact same handler reference —&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// no risk of the add/remove pair drifting out of sync&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The listener that gets removed is guaranteed to be the same reference that got added, because they’re declared four lines apart instead of on opposite ends of a component. That’s the actual bug &lt;code class=&quot;language-text&quot;&gt;using&lt;/code&gt; prevents here: a &lt;code class=&quot;language-text&quot;&gt;removeEventListener&lt;/code&gt; call with a handler that’s been re-created since the matching &lt;code class=&quot;language-text&quot;&gt;addEventListener&lt;/code&gt;, which silently leaves the old listener attached forever. One setup note before you reach for it: &lt;code class=&quot;language-text&quot;&gt;Symbol.dispose&lt;/code&gt; isn’t in TypeScript’s default &lt;code class=&quot;language-text&quot;&gt;lib&lt;/code&gt;, so this won’t compile until your &lt;code class=&quot;language-text&quot;&gt;tsconfig.json&lt;/code&gt;’s &lt;code class=&quot;language-text&quot;&gt;lib&lt;/code&gt; array includes &lt;code class=&quot;language-text&quot;&gt;&quot;esnext.disposable&quot;&lt;/code&gt; (or the broader &lt;code class=&quot;language-text&quot;&gt;&quot;esnext&quot;&lt;/code&gt;). A self-documenting snippet that fails to build on paste isn’t documenting anything. It’s still early in frontend code specifically, but as more browser and Node APIs pick up &lt;code class=&quot;language-text&quot;&gt;Symbol.dispose&lt;/code&gt;, expect it to spread past the toy examples.&lt;/p&gt;
&lt;h2 id=&quot;6-branded-types&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#6-branded-types&quot; aria-label=&quot;6 branded types permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;6. Branded types&lt;/h2&gt;
&lt;p&gt;TypeScript’s structural typing is usually a feature: two objects with the same shape are the same type. For IDs, that’s a liability. &lt;code class=&quot;language-text&quot;&gt;UserId&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;OrderId&lt;/code&gt; can. be both &lt;code class=&quot;language-text&quot;&gt;string&lt;/code&gt; underneath, so nothing stops you passing one where the other belongs. Branded types fixes that by attaching a fake, compile-time-only tag.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;ts&quot;&gt;&lt;pre class=&quot;language-ts&quot;&gt;&lt;code class=&quot;language-ts&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Brand&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;B&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;T&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;readonly&lt;/span&gt; __brand&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;B&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;UserId&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; Brand&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;UserId&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;OrderId&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; Brand&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;OrderId&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;cancelOrder&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;id&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; OrderId&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;/* ... */&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;declare&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; someUserId&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; UserId&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;cancelOrder&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;someUserId&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// error: UserId isn&apos;t assignable to OrderId&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Read &lt;code class=&quot;language-text&quot;&gt;function cancelOrder(id: OrderId)&lt;/code&gt; and you know exactly which flavor of string is expected, no comment required. The compiler backs that reading up. It targets one of the most common frontend bug classes there is: a cart reducer that takes a &lt;code class=&quot;language-text&quot;&gt;productId&lt;/code&gt; where a &lt;code class=&quot;language-text&quot;&gt;variantId&lt;/code&gt; belongs, both valid strings, no runtime error until the wrong item vanishes from someone’s order. The &lt;code class=&quot;language-text&quot;&gt;__brand&lt;/code&gt; tag never exists at runtime. It’s erased on compile, so the safety is free.&lt;/p&gt;
&lt;p&gt;The same trick fixes a nastier, security-flavored version of the same problem: telling a sanitized string apart from a raw one. &lt;code class=&quot;language-text&quot;&gt;dangerouslySetInnerHTML&lt;/code&gt; doesn’t care whether the string you hand it has been through a sanitizer. It renders whatever it gets, which is exactly how stored XSS ends up in a React app. Brand the output of your sanitizer, and the type system refuses anything that hasn’t been through it:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;ts&quot;&gt;&lt;pre class=&quot;language-ts&quot;&gt;&lt;code class=&quot;language-ts&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;SafeHtml&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; Brand&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;SafeHtml&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;declare&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;sanitize&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;raw&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; SafeHtml&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;html&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; SafeHtml&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; __html&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; html &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; userComment &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&amp;lt;img src=x onerror=alert(1)&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;userComment&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;          &lt;span class=&quot;token comment&quot;&gt;// error: string isn&apos;t assignable to SafeHtml&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;sanitize&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;userComment&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// fine — sanitize() is the only way to produce a SafeHtml&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Nobody has to leave a comment reading &lt;code class=&quot;language-text&quot;&gt;// make sure this is sanitized first&lt;/code&gt; above &lt;code class=&quot;language-text&quot;&gt;render&lt;/code&gt;. The signature already refuses to compile without it.&lt;/p&gt;
&lt;h2 id=&quot;7-template-literal-types&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#7-template-literal-types&quot; aria-label=&quot;7 template literal types permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;7. Template literal types&lt;/h2&gt;
&lt;p&gt;String-shaped values (event names, route paths, CSS custom properties) are usually just &lt;code class=&quot;language-text&quot;&gt;string&lt;/code&gt;, which throws away a pattern a reader could otherwise see at a glance. Template literal types let the type carry that pattern. The &lt;a href=&quot;https://www.typescriptlang.org/docs/handbook/2/template-literal-types.html&quot;&gt;TypeScript Handbook&lt;/a&gt; builds a typed event API this way:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;ts&quot;&gt;&lt;pre class=&quot;language-ts&quot;&gt;&lt;code class=&quot;language-ts&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;PropEventSource&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;Type&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token generic-function&quot;&gt;&lt;span class=&quot;token function&quot;&gt;on&lt;/span&gt;&lt;span class=&quot;token generic class-name&quot;&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;Key &lt;span class=&quot;token keyword&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;keyof&lt;/span&gt; Type&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
    eventName&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;Key&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;Changed&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token function-variable function&quot;&gt;callback&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;newValue&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; Type&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;Key&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;void&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;declare&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token generic-function&quot;&gt;&lt;span class=&quot;token function&quot;&gt;makeWatchedObject&lt;/span&gt;&lt;span class=&quot;token generic class-name&quot;&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;Type&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;obj&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; Type&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; Type &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt; PropEventSource&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;Type&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; person &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;makeWatchedObject&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; firstName&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Saoirse&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; age&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;26&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

person&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;on&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;firstNameChanged&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;name&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; name&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;toUpperCase&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// `name` is `string`&lt;/span&gt;
person&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;on&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;firstName&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;                            &lt;span class=&quot;token comment&quot;&gt;// error: not a valid event name&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The signature of &lt;code class=&quot;language-text&quot;&gt;on&lt;/code&gt; documents every valid event name (&lt;code class=&quot;language-text&quot;&gt;firstNameChanged&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;ageChanged&lt;/code&gt;) and rejects typos before the code runs. Nobody keeps a comment listing valid events; the type generates the list. The same cross-multiplication trick shows up in community Tailwind tooling, not the framework’s own bundled types: projects like &lt;a href=&quot;https://github.com/muhammadsammy/tailwindcss-classnames&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;tailwindcss-classnames&lt;/code&gt;&lt;/a&gt; generate a template-literal union of every valid utility class from a project’s config, so an invalid class string becomes a type error instead of a silent no-op in the browser. For more worked examples of the same trick (role-gated event unions, chaining it with &lt;code class=&quot;language-text&quot;&gt;Uppercase&lt;/code&gt;/&lt;code class=&quot;language-text&quot;&gt;Lowercase&lt;/code&gt; string manipulation types), see &lt;a href=&quot;https://www.jameslmilner.com/posts/typescript-template-literal-types/&quot;&gt;Exploring TypeScript Template Literal Types&lt;/a&gt; (James Milner, April 21, 2021).&lt;/p&gt;
&lt;h2 id=&quot;8-generic-components-without-reactfc-let-the-signature-describe-what-it-accepts&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#8-generic-components-without-reactfc-let-the-signature-describe-what-it-accepts&quot; aria-label=&quot;8 generic components without reactfc let the signature describe what it accepts permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;8. Generic components without &lt;code class=&quot;language-text&quot;&gt;React.FC&lt;/code&gt;: let the signature describe what it accepts&lt;/h2&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;React.FC&lt;/code&gt; handles generics badly, so the &lt;a href=&quot;https://github.com/typescript-cheatsheets/react&quot;&gt;React TypeScript Cheatsheet&lt;/a&gt;, the community’s de facto reference for this stuff, recommends skipping it in favor of a plain generic function instead:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;tsx&quot;&gt;&lt;pre class=&quot;language-tsx&quot;&gt;&lt;code class=&quot;language-tsx&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;DropdownProps&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  items&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token function-variable function&quot;&gt;onSelect&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;item&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token function-variable function&quot;&gt;labelFor&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;item&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token generic-function&quot;&gt;&lt;span class=&quot;token function&quot;&gt;Dropdown&lt;/span&gt;&lt;span class=&quot;token generic class-name&quot;&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; items&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; onSelect&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; labelFor &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; DropdownProps&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;select&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;onChange&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;e&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;onSelect&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;items&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;Number&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;e&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;target&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;value&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;items&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;item&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; i&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
        &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;option&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;i&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;i&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;labelFor&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;item&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;option&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;select&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;(The trailing comma after &lt;code class=&quot;language-text&quot;&gt;T&lt;/code&gt; isn’t a typo: in a &lt;code class=&quot;language-text&quot;&gt;.tsx&lt;/code&gt; file, &lt;code class=&quot;language-text&quot;&gt;&amp;lt;T&gt;&lt;/code&gt; alone reads as a JSX tag, so the comma disambiguates it.) Call &lt;code class=&quot;language-text&quot;&gt;&amp;lt;Dropdown items={users} onSelect={...} labelFor={...} /&gt;&lt;/code&gt; and TypeScript infers &lt;code class=&quot;language-text&quot;&gt;T&lt;/code&gt; as &lt;code class=&quot;language-text&quot;&gt;User&lt;/code&gt; for that call, then holds every prop to it. Compare that to the usual fallback when generics feel like too much ceremony: typing &lt;code class=&quot;language-text&quot;&gt;items&lt;/code&gt; as &lt;code class=&quot;language-text&quot;&gt;any[]&lt;/code&gt;, which compiles but tells a new teammate nothing about what the component supports. Read the generic signature once, and you know &lt;code class=&quot;language-text&quot;&gt;Dropdown&lt;/code&gt; works with any item type, not just whichever one an earlier version hardcoded.&lt;/p&gt;
&lt;h2 id=&quot;9-componentpropswithoutref&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#9-componentpropswithoutref&quot; aria-label=&quot;9 componentpropswithoutref permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;9. &lt;code class=&quot;language-text&quot;&gt;ComponentPropsWithoutRef&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;Wrapping a native element is common: a custom &lt;code class=&quot;language-text&quot;&gt;Button&lt;/code&gt; around &lt;code class=&quot;language-text&quot;&gt;&amp;lt;button&gt;&lt;/code&gt;. It’s tempting to grab all its props with &lt;code class=&quot;language-text&quot;&gt;ComponentProps&amp;lt;&apos;button&apos;&gt;&lt;/code&gt;. But that type includes a &lt;code class=&quot;language-text&quot;&gt;ref&lt;/code&gt; prop, implying the wrapper forwards it. If it doesn’t, that’s a silent lie in the signature: a caller passes &lt;code class=&quot;language-text&quot;&gt;ref&lt;/code&gt;, expects DOM access, and gets nothing, because the wrapper never spread it down. The &lt;a href=&quot;https://github.com/typescript-cheatsheets/react&quot;&gt;React TypeScript Cheatsheet&lt;/a&gt; recommends &lt;code class=&quot;language-text&quot;&gt;ComponentPropsWithoutRef&lt;/code&gt; for exactly this reason:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;tsx&quot;&gt;&lt;pre class=&quot;language-tsx&quot;&gt;&lt;code class=&quot;language-tsx&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;ButtonProps&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; React&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;ComponentPropsWithoutRef&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;button&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  variant&lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;primary&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;secondary&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;Button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; variant &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;primary&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;rest &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; ButtonProps&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;className&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;btn-&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;variant&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token spread&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;rest&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If &lt;code class=&quot;language-text&quot;&gt;Button&lt;/code&gt; later grows a real &lt;code class=&quot;language-text&quot;&gt;forwardRef&lt;/code&gt;, the type swaps to &lt;code class=&quot;language-text&quot;&gt;ComponentPropsWithRef&lt;/code&gt;. That one-word change is the whole changelog entry. The props type tells the truth about ref support without a sentence of prose, and it tells that truth at every call site at once, which a comment on the component definition alone never could.&lt;/p&gt;
&lt;h2 id=&quot;10-type-predicates&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#10-type-predicates&quot; aria-label=&quot;10 type predicates permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;10. Type predicates&lt;/h2&gt;
&lt;p&gt;TypeScript narrows types automatically inside an &lt;code class=&quot;language-text&quot;&gt;if&lt;/code&gt; block, but that narrowing doesn’t survive a function call by default.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;ts&quot;&gt;&lt;pre class=&quot;language-ts&quot;&gt;&lt;code class=&quot;language-ts&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;User&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; id&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; email&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;MaybeUser&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; User &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;null&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;undefined&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;greet&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;u&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; MaybeUser&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;u &lt;span class=&quot;token operator&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;null&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;typeof&lt;/span&gt; u&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;email &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;string&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token builtin&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;u&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// u is User&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token builtin&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;u&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// u is MaybeUser &lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;TypeScript forgets what it just verified. Pull the check into &lt;code class=&quot;language-text&quot;&gt;isValidUser(x)&lt;/code&gt; and a type predicate return type the type gets narrowed down:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;ts&quot;&gt;&lt;pre class=&quot;language-ts&quot;&gt;&lt;code class=&quot;language-ts&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;User&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; id&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; email&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;MaybeUser&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; User &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;null&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;undefined&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;isValidUser&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;u&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; MaybeUser&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; u &lt;span class=&quot;token keyword&quot;&gt;is&lt;/span&gt; User &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; u &lt;span class=&quot;token operator&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;null&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;typeof&lt;/span&gt; u&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;email &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;string&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;greet&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;u&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; MaybeUser&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;isValidUser&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;u&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token builtin&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;u&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// u is User&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token builtin&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;u&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// u is { null | undefined }&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The &lt;code class=&quot;language-text&quot;&gt;u is User&lt;/code&gt; return type is a documented promise: call this, get &lt;code class=&quot;language-text&quot;&gt;true&lt;/code&gt; back, and the compiler treats &lt;code class=&quot;language-text&quot;&gt;u&lt;/code&gt; as &lt;code class=&quot;language-text&quot;&gt;User&lt;/code&gt; from there. A plain boolean can’t make that promise. And the same signature composes free with &lt;code class=&quot;language-text&quot;&gt;Array.prototype.filter&lt;/code&gt;, so &lt;code class=&quot;language-text&quot;&gt;users.filter(isValidUser)&lt;/code&gt; narrows the whole array to &lt;code class=&quot;language-text&quot;&gt;User[]&lt;/code&gt; in one line. That’s where this pattern earns its keep most in frontend code: validating a list of maybe-null form entries or API results before rendering them.&lt;/p&gt;
&lt;h2 id=&quot;wrapping-up&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#wrapping-up&quot; aria-label=&quot;wrapping up permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Wrapping up&lt;/h2&gt;
&lt;p&gt;None of these patterns replaces comments outright. Types document shape and contract: what a value can be, what a function accepts, what states exist. They say nothing about why: why this endpoint retries three times and not five, why this component exists instead of reusing an older one, why one edge case matters to one particular customer. That’s still a comment’s job, and a good comment explaining a business reason is worth keeping right where it is.&lt;/p&gt;
&lt;p&gt;What these ten patterns do is narrow the space where a comment is your only option. Each one pushes a fact out of a sentence that can drift and into a signature the compiler checks on every build. The compiler doesn’t get tired and doesn’t skip a re-check because the deadline is close. That’s the actual advantage over code comments.&lt;/p&gt;
&lt;div class=&quot;footnotes&quot;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&quot;fn-1&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;satisfies&lt;/code&gt; performs the same excess-property check on object literals that a normal type annotation would. TypeScript’s own team has discussed this exact mechanic (whether an unlisted key like &lt;code class=&quot;language-text&quot;&gt;&quot;banner&quot;&lt;/code&gt; should error) in &lt;a href=&quot;https://github.com/microsoft/TypeScript/issues/52999&quot;&gt;microsoft/TypeScript#52999&lt;/a&gt;.&lt;a href=&quot;#fnref-1&quot; class=&quot;footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;a href=&quot;#fnref-1&quot; class=&quot;footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;</content:encoded></item><item><title><![CDATA[Stop Writing Novels in Your Gallery's Alt Text]]></title><description><![CDATA[How to write alt text for image galleries, and when to reach for captions or long descriptions instead. A photography portfolio has forty…]]></description><link>https://www.codespud.com/2026/stop-writing-novels-in-gallery-alt-text/</link><guid isPermaLink="false">https://www.codespud.com/2026/stop-writing-novels-in-gallery-alt-text/</guid><pubDate>Thu, 16 Jul 2026 08:29:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;em&gt;How to write alt text for image galleries, and when to reach for captions or long descriptions instead.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;A photography portfolio has forty images. Someone decides each one deserves justice, so every thumbnail gets a 60-word description of light and mood. It feels generous. It’s a tax.&lt;/p&gt;
&lt;p&gt;A screen reader reads a page top to bottom. The user weighs each item, then decides to skip it or not. So forty rich descriptions become forty small essays the user has to sit through before they reach anything they can act on. Sighted visitors scan the grid in two seconds. The assistive-tech user gets the audiobook. That isn’t equal access.&lt;/p&gt;
&lt;p&gt;The instinct is a good one. You wanted no one left out. But equal access means equal speed, not extra words.&lt;/p&gt;
&lt;p&gt;More is not better. Both alt text and galleries have rules, and long descriptions have a home that’s rarely the &lt;code class=&quot;language-text&quot;&gt;alt&lt;/code&gt; attribute.&lt;/p&gt;
&lt;h2 id=&quot;what-an-image-gallery-is-and-why-we-reach-for-one&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#what-an-image-gallery-is-and-why-we-reach-for-one&quot; aria-label=&quot;what an image gallery is and why we reach for one permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;What an image gallery is, and why we reach for one&lt;/h2&gt;
&lt;p&gt;An image gallery is a set of related images shown together as a group: a grid of thumbnails, a swipeable carousel, a masonry wall, a lightbox you click into. The point isn’t any single picture. It’s the collection.&lt;/p&gt;
&lt;p&gt;Galleries earn their keep when one image can’t carry the load: a photographer shows a body of work, not a headshot, a shop shows a product from six angles, a listing shows every room, a recipe shows each step. The images are the content, and browsing them &lt;em&gt;is&lt;/em&gt; the task: scan the set, compare a few, open the one that matters.&lt;/p&gt;
&lt;p&gt;A gallery exists so people can move through images and choose. Anything that slows that down (a paragraph of alt text on every thumbnail included) fights the reason you built it.&lt;/p&gt;
&lt;h2 id=&quot;what-alt-text-is-for&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#what-alt-text-is-for&quot; aria-label=&quot;what alt text is for permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;What alt text is for&lt;/h2&gt;
&lt;p&gt;Ask why the image is here, not what it looks like. The &lt;a href=&quot;https://www.w3.org/WAI/tutorials/images/decision-tree/&quot;&gt;W3C alt decision tree&lt;/a&gt; runs the same check: does the image carry meaning the page would lose without it, is it a link or button, or is it decoration? &lt;a href=&quot;https://www.w3.org/WAI/WCAG22/Understanding/non-text-content.html&quot;&gt;WCAG 1.1.1&lt;/a&gt; asks for a text alternative that serves an &lt;em&gt;equivalent purpose&lt;/em&gt;, not a transcript of pixels.&lt;/p&gt;
&lt;p&gt;That sorts images into roles. Decorative images get an empty alt so assistive tech skips them; the &lt;a href=&quot;https://www.w3.org/WAI/tutorials/images/decorative/&quot;&gt;W3C says so plainly&lt;/a&gt;: use &lt;code class=&quot;language-text&quot;&gt;alt=&quot;&quot;&lt;/code&gt;. A clickable thumbnail is functional, so its alt names the action. An informative image gets one line for the fact it adds.&lt;/p&gt;
&lt;p&gt;Keep that line short. WCAG sets no character limit, but NN/g’s &lt;a href=&quot;https://www.nngroup.com/articles/write-alt-text/&quot;&gt;guide to writing alt text&lt;/a&gt; says hold it to about a sentence, put the key words first, and cut the rest. Need a paragraph? The &lt;code class=&quot;language-text&quot;&gt;alt&lt;/code&gt; attribute is the wrong box.&lt;/p&gt;
&lt;h2 id=&quot;why-galleries-make-it-worse&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#why-galleries-make-it-worse&quot; aria-label=&quot;why galleries make it worse permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Why galleries make it worse&lt;/h2&gt;
&lt;p&gt;A mouse gives random access: you point at the one image you want. A screen reader is sequential. NN/g makes the point in &lt;a href=&quot;https://www.nngroup.com/articles/alt-text-usability/&quot;&gt;“Alt Text: Not Always Needed”&lt;/a&gt;: when alt text is useless for common tasks, “images bring confusion, not clarity.” Multiply that by forty and you get a novel no one chose to open.&lt;/p&gt;
&lt;p&gt;Most sites err the other way. The &lt;a href=&quot;https://webaim.org/projects/million/2025/&quot;&gt;WebAIM Million 2025 report&lt;/a&gt; found 18.5% of home-page images had no alt text, and about a third had missing, questionable, or repeated alternatives. So both sins are common: nothing, or far too much. Galleries pull you toward too much.&lt;/p&gt;
&lt;h2 id=&quot;rules-for-an-accessible-gallery&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#rules-for-an-accessible-gallery&quot; aria-label=&quot;rules for an accessible gallery permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Rules for an accessible gallery&lt;/h2&gt;
&lt;p&gt;A gallery is a structure, not a pile of &lt;code class=&quot;language-text&quot;&gt;&amp;lt;img&gt;&lt;/code&gt; tags. Structure is where most galleries fail.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Group the images.&lt;/strong&gt; The &lt;a href=&quot;https://www.w3.org/WAI/tutorials/images/groups/&quot;&gt;W3C Groups of Images tutorial&lt;/a&gt; shows the pattern: wrap the set in a &lt;code class=&quot;language-text&quot;&gt;&amp;lt;figure&gt;&lt;/code&gt;, caption the whole group, and give each item its own short alt and caption.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;figure&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;role&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;group&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;aria-labelledby&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;gallery-cap&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;figcaption&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;gallery-cap&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Baler, three mornings in the rainy season.&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;figcaption&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;

  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;figure&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;img&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;day1.jpg&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;Grey surf under a low, flat sky.&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;figcaption&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Day one. Overcast.&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;figcaption&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;figure&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;

  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;figure&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;img&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;day2.jpg&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;Sun breaking through cloud onto the break.&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;figcaption&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Day two. Clearing.&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;figcaption&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;figure&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;figure&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The alt stays short and carries the one visual fact. Mood and date live in the visible &lt;code class=&quot;language-text&quot;&gt;&amp;lt;figcaption&gt;&lt;/code&gt;, where everyone reads them.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Treat clickable thumbnails as controls.&lt;/strong&gt; A thumbnail that opens a lightbox is functional, so its alt names the destination (the &lt;a href=&quot;https://www.w3.org/WAI/tutorials/images/functional/&quot;&gt;W3C’s Functional Images guidance&lt;/a&gt; is clear on this). The full image gets the description, because that’s what the user is about to open.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;sunrise-full.jpg&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;thumb&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;img&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;sunrise-thumb.jpg&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;View full image: Sunrise over Baler&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Make it work without a mouse.&lt;/strong&gt; Every thumbnail link must take keyboard focus, the focus ring must stay visible, and a lightbox must trap focus while open, return it on close, and close on &lt;code class=&quot;language-text&quot;&gt;Escape&lt;/code&gt; (the &lt;a href=&quot;https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/&quot;&gt;ARIA dialog pattern&lt;/a&gt; spells this out). A lightbox built from non-focusable &lt;code class=&quot;language-text&quot;&gt;&amp;lt;div&gt;&lt;/code&gt;s locks keyboard and screen reader users out.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Don’t repeat yourself.&lt;/strong&gt; If the caption already says “Sunrise over Baler,” empty the alt. Saying it twice just makes the user hear it twice.&lt;/p&gt;
&lt;h2 id=&quot;alternatives-to-alt-text&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#alternatives-to-alt-text&quot; aria-label=&quot;alternatives to alt text permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Alternatives to alt text&lt;/h2&gt;
&lt;p&gt;The &lt;code class=&quot;language-text&quot;&gt;alt&lt;/code&gt; attribute is one tool. For anything past a sentence, reach for these instead.&lt;/p&gt;
&lt;h3 id=&quot;visible-captions&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#visible-captions&quot; aria-label=&quot;visible captions permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Visible captions&lt;/h3&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;&amp;lt;figcaption&gt;&lt;/code&gt; is read by assistive tech &lt;em&gt;and&lt;/em&gt; seen by everyone, yet most teams still default to a hidden &lt;code class=&quot;language-text&quot;&gt;alt&lt;/code&gt;. Let the caption carry the description and it does what an overstuffed &lt;code class=&quot;language-text&quot;&gt;alt&lt;/code&gt; can’t: it shows that description to sighted users too. When the caption covers the image, empty the alt. One source of truth.&lt;/p&gt;
&lt;h3 id=&quot;page-copy&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#page-copy&quot; aria-label=&quot;page copy permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Page copy&lt;/h3&gt;
&lt;p&gt;Often the strongest move is to write the thing in the body. The &lt;a href=&quot;https://www.w3.org/WAI/tutorials/images/complex/&quot;&gt;W3C Complex Images tutorial&lt;/a&gt; notes that long descriptions also help people with low vision, cognitive differences, and limited subject knowledge, none of whom reach text trapped in an attribute.&lt;/p&gt;
&lt;h3 id=&quot;a-linked-long-description&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#a-linked-long-description&quot; aria-label=&quot;a linked long description permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;A linked long description&lt;/h3&gt;
&lt;p&gt;When an image really needs a paragraph (a detailed diagram, an annotated map), give it a short alt that names it, then put the full description on the page and tie the two together with &lt;code class=&quot;language-text&quot;&gt;&amp;lt;figure&gt;&lt;/code&gt;/&lt;code class=&quot;language-text&quot;&gt;&amp;lt;figcaption&gt;&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&quot;aria-describedby-for-prose&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#aria-describedby-for-prose&quot; aria-label=&quot;aria describedby for prose permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;&lt;code class=&quot;language-text&quot;&gt;aria-describedby&lt;/code&gt; for prose&lt;/h3&gt;
&lt;p&gt;For a plain-text description, link it by &lt;code class=&quot;language-text&quot;&gt;id&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;img&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;peacock.jpg&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
     &lt;span class=&quot;token attr-name&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;Male peacock head&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
     &lt;span class=&quot;token attr-name&quot;&gt;aria-describedby&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;peacock-desc&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;p&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;peacock-desc&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  The male is metallic blue on the crown, with a fan-shaped crest of
  bare-shafted feathers tipped in blue-green. A white stripe sits above
  the eye and a white crescent below it.
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;One catch the &lt;a href=&quot;https://www.w3.org/WAI/tutorials/images/complex/&quot;&gt;W3C flags&lt;/a&gt;: &lt;code class=&quot;language-text&quot;&gt;aria-describedby&lt;/code&gt; flattens its target into one run of text. Screen readers drop the headings, lists, and tables inside it. Use it for prose, not structured content.&lt;/p&gt;
&lt;h3 id=&quot;skip-autopilot-ai-alt-text&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#skip-autopilot-ai-alt-text&quot; aria-label=&quot;skip autopilot ai alt text permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Skip autopilot AI alt text&lt;/h3&gt;
&lt;p&gt;AI auto describers have their place, but think long and hard before you reach for one. Auto-describers drop a paragraph on every image: the pile-up this whole post is trying to prevent. They describe pixels, not purpose, and they can’t know why you chose the image. Accessibility vendor Silktide reports that in its own testing, &lt;a href=&quot;https://silktide.com/blog/the-downsides-of-ai-alt-text/&quot;&gt;screen reader users can spot AI-written alt text&lt;/a&gt;: technically accurate and practically useless. Draft with these tools if you must, then edit hard.&lt;/p&gt;
&lt;h2 id=&quot;the-checklist&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#the-checklist&quot; aria-label=&quot;the checklist permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;The checklist&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Decorative image: empty alt (&lt;code class=&quot;language-text&quot;&gt;alt=&quot;&quot;&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Clickable thumbnail: alt names the action. Describe the image where it opens, not on the thumbnail.&lt;/li&gt;
&lt;li&gt;Informative image: one short, front-loaded sentence, or empty alt if a caption already covers it.&lt;/li&gt;
&lt;li&gt;Description longer than a sentence: move it to a caption, page copy, or a linked description.&lt;/li&gt;
&lt;li&gt;Wrap the set in &lt;code class=&quot;language-text&quot;&gt;&amp;lt;figure&gt;&lt;/code&gt;, caption the group, let each item caption itself.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;/2026/one-year-of-the-accessibility-act-unplug-your-mouse-and-see-what-breaks/&quot;&gt;Unplug the mouse&lt;/a&gt; and tab through. Focus stays visible. The lightbox opens, traps focus, and closes on &lt;code class=&quot;language-text&quot;&gt;Escape&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Accessibility is counted in tasks finished, not words written. Write less in the alt attribute. Build more into the page.&lt;/p&gt;
&lt;h2 id=&quot;references&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#references&quot; aria-label=&quot;references permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://www.w3.org/WAI/tutorials/images/decision-tree/&quot;&gt;An alt Decision Tree&lt;/a&gt; (W3C WAI)&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.w3.org/WAI/tutorials/images/groups/&quot;&gt;Groups of Images&lt;/a&gt; (W3C WAI)&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.w3.org/WAI/WCAG22/Understanding/non-text-content.html&quot;&gt;Understanding SC 1.1.1 Non-text Content&lt;/a&gt; (W3C WCAG 2.2)&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.nngroup.com/articles/alt-text-usability/&quot;&gt;Alt Text: Not Always Needed&lt;/a&gt; (Nielsen Norman Group)&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.nngroup.com/articles/write-alt-text/&quot;&gt;How to Write Good Alt Text&lt;/a&gt; (Nielsen Norman Group)&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://silktide.com/blog/the-downsides-of-ai-alt-text/&quot;&gt;The Downsides of AI Alt Text&lt;/a&gt; (Silktide)&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[Research, Plan, Execute, Learn: The Agent Loop I Wish Someone Had Drawn Me First]]></title><description><![CDATA[“What goes into the agent before it runs decides what comes out.” That’s a lesson I keep relearning. A confession: give me a coding agent…]]></description><link>https://www.codespud.com/2026/research-plan-execute-learn/</link><guid isPermaLink="false">https://www.codespud.com/2026/research-plan-execute-learn/</guid><pubDate>Fri, 10 Jul 2026 08:29:00 GMT</pubDate><content:encoded>&lt;blockquote&gt;
&lt;p&gt;“What goes into the agent before it runs decides what comes out.” That’s a lesson I keep relearning.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;A confession: give me a coding agent and a task, and I want to type the task and hit go. Research and planning feel like chores. There’s a wire running straight from “I have an idea” to “build it,” and I take it almost every time.&lt;/p&gt;
&lt;p&gt;That wire is the red dashes in the picture up top. It feels fast. It rarely is.&lt;/p&gt;
&lt;p&gt;Four phases make agent-assisted coding work: &lt;strong&gt;Research, Plan, Execute, Learn&lt;/strong&gt;. The phase everyone drops is the one that pays off most, and it pays off because it compounds: Learn feeds each session’s lesson back into the agent, so every task you finish makes the next one cheaper. Skip it and you’re stuck re-explaining the same things every morning. None of the rest depends on your tool either. It works in a terminal, an editor, or a browser tab.&lt;/p&gt;
&lt;h2 id=&quot;shortcut&quot;&gt;The shortcut nobody admits to&lt;/h2&gt;
&lt;p&gt;Agents are eager. Give one a task and it starts producing. That’s the appeal, and the trap. Producing something and producing the right thing are two different events.&lt;/p&gt;
&lt;p&gt;People who get good results build a process around the agent instead of firing prompts at it. Better prompts alone don’t do it. Anthropic’s guidance says it plainly: &lt;a href=&quot;https://code.claude.com/docs/en/best-practices&quot;&gt;explore first, then plan, then code&lt;/a&gt;, so you don’t solve the wrong problem. Tyler Burleigh calls the same shape &lt;a href=&quot;https://tylerburleigh.com/blog/2026/02/22/&quot;&gt;Research, Plan, Implement, Review&lt;/a&gt;. The &lt;a href=&quot;https://tweag.github.io/agentic-coding-handbook/&quot;&gt;Tweag handbook&lt;/a&gt; starts with exploration too.&lt;/p&gt;
&lt;p&gt;Four names, one idea. Split the thinking from the typing. Then close the loop.&lt;/p&gt;
&lt;h2 id=&quot;research&quot;&gt;1. Research: read before you write&lt;/h2&gt;
&lt;p&gt;Research is the cheapest phase, and the first I skip. It’s just this: before the agent changes anything, make it read.&lt;/p&gt;
&lt;p&gt;Point it at the real files. Have it trace how the current code works. Ask what you’d ask a senior engineer in their second week: how does auth work, where do sessions live, what’s the pattern for a new endpoint. You don’t want code yet. You want the agent’s context filled with your codebase so it stops guessing.&lt;/p&gt;
&lt;p&gt;When an agent doesn’t know your code, it fills the gap with the average of every codebase it has seen. That average produces the subtly-wrong output. Research swaps the average for your specifics.&lt;/p&gt;
&lt;p&gt;One guardrail: research sprawls. Tell an agent to “look into” something and it reads two hundred files and chokes. Scope it. “Read &lt;code class=&quot;language-text&quot;&gt;src/auth&lt;/code&gt; and the session middleware” beats “understand the app.” If your tool has a separate research context, use it, so the reading doesn’t crowd out the work.&lt;/p&gt;
&lt;h2 id=&quot;plan&quot;&gt;2. Plan: a plan is a contract, not a vibe&lt;/h2&gt;
&lt;p&gt;Once the agent has read enough, make it write a plan before code. On the page, where you can argue with it.&lt;/p&gt;
&lt;p&gt;A good plan names the files it will touch, the shape of the change, what’s out of scope, and how you’ll know it worked. That last part carries the weight. A plan that ends with “here’s how we verify it” is a contract. A plan that ends with “then I’ll implement it” is a vibe.&lt;/p&gt;
&lt;p&gt;I treat the plan as the real work. Get it right and the code is mechanical. Get it wrong and no clever code saves you. You get a finished-looking solution to the wrong problem, which beats a broken one at hiding.&lt;/p&gt;
&lt;p&gt;A skeleton I reuse:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;markdown&quot;&gt;&lt;pre class=&quot;language-markdown&quot;&gt;&lt;code class=&quot;language-markdown&quot;&gt;&lt;span class=&quot;token title important&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;##&lt;/span&gt; Goal&lt;/span&gt;
One sentence. What does &quot;done&quot; mean?

&lt;span class=&quot;token title important&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;##&lt;/span&gt; Files to change&lt;/span&gt;
&lt;span class=&quot;token list punctuation&quot;&gt;-&lt;/span&gt; src/foo.ts — add X
&lt;span class=&quot;token list punctuation&quot;&gt;-&lt;/span&gt; src/foo.test.ts — cover the logged-out case
&lt;span class=&quot;token list punctuation&quot;&gt;-&lt;/span&gt; src/good.example.ts - if doing similar job give it an example

&lt;span class=&quot;token title important&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;##&lt;/span&gt; Out of scope&lt;/span&gt;
&lt;span class=&quot;token list punctuation&quot;&gt;-&lt;/span&gt; Don&apos;t touch the billing flow
&lt;span class=&quot;token list punctuation&quot;&gt;-&lt;/span&gt; No new dependencies without asking

&lt;span class=&quot;token title important&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;##&lt;/span&gt; Verification&lt;/span&gt;
&lt;span class=&quot;token list punctuation&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;token code-snippet code keyword&quot;&gt;`npm test`&lt;/span&gt; passes, including the new logged-out case
&lt;span class=&quot;token list punctuation&quot;&gt;-&lt;/span&gt; Manual: hit /api/foo while signed out, expect 401&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;One section tells the agent what &lt;em&gt;not&lt;/em&gt; to do. Agents drift toward the easiest thing to build. Boundaries on the plan stop the drift before it starts.&lt;/p&gt;
&lt;h2 id=&quot;execute&quot;&gt;3. Execute: let it check its own work&lt;/h2&gt;
&lt;p&gt;Execute is the fun part, the glowing node we all rush. It holds the one habit that matters most: &lt;strong&gt;give the agent a check it can run, and never take “done” at face value.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;An agent will tell you it’s finished, and sound sure. That sureness is generated text, not a status report. Anthropic’s docs name it the ”&lt;a href=&quot;https://code.claude.com/docs/en/best-practices&quot;&gt;trust-then-verify gap&lt;/a&gt;”: the model writes a plausible implementation, declares success, and the edge cases quietly fail. In one documented run, an agent &lt;a href=&quot;https://docs.bswen.com/blog/2026-06-25-ai-coding-agent-false-positive-failure/&quot;&gt;declared success on 19 of 45 tasks whose hidden tests still failed&lt;/a&gt; (42%), because it ran only the visible tests and never checked the rest. The model isn’t lying. “Looks done” is just part of what it writes, pass or fail.&lt;/p&gt;
&lt;p&gt;So close the loop. Hand it a check it runs itself: tests, a build, a linter, a script that diffs output. Now it works, runs the check, reads the failure, and fixes it, instead of handing you a guess. Ask for evidence, not the adjective:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;Implement the plan. Write a test for the logged-out case.
Run the suite and paste the actual output. Don&apos;t tell me it passed — show me.&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Sometimes I add a Steps section when I want things done in order, with the check built in beforehand, like this:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;markdown&quot;&gt;&lt;pre class=&quot;language-markdown&quot;&gt;&lt;code class=&quot;language-markdown&quot;&gt;&lt;span class=&quot;token title important&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;##&lt;/span&gt; Steps&lt;/span&gt;
&lt;span class=&quot;token list punctuation&quot;&gt;1.&lt;/span&gt; Create unit tests for X first
&lt;span class=&quot;token list punctuation&quot;&gt;2.&lt;/span&gt; Implement X - make sure unit test passes
&lt;span class=&quot;token list punctuation&quot;&gt;3.&lt;/span&gt; ...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;A second failure earns its own line: invented dependencies. A &lt;a href=&quot;https://www.usenix.org/publications/loginonline/we-have-package-you-comprehensive-analysis-package-hallucinations-code&quot;&gt;2025 USENIX Security study&lt;/a&gt; found the coding models it tested recommended packages that don’t exist about one in five times on average (near 21% for open-source models, closer to 5% for commercial ones), and the fake names repeat. That gap spawned an attack called &lt;a href=&quot;https://socket.dev/blog/slopsquatting-how-ai-hallucinations-are-fueling-a-new-class-of-supply-chain-attacks&quot;&gt;“slopsquatting”&lt;/a&gt;: someone registers the invented name, ships malware, and waits for the next agent to invent it again. When your agent reaches for a package you’ve never heard of, check that it’s real before you install it. Compiling isn’t the same as safe.&lt;/p&gt;
&lt;p&gt;Verification lives inside Execute, not after it.&lt;/p&gt;
&lt;h2 id=&quot;learn&quot;&gt;4. Learn: the phase everyone skips&lt;/h2&gt;
&lt;p&gt;Learn is the phase missing from most versions of this loop, and it’s the one that matters most. After the work ships, feed the lesson back.&lt;/p&gt;
&lt;p&gt;Every session teaches you how the agent behaves in &lt;em&gt;your&lt;/em&gt; code. It grabs the wrong test helper. It forgets you use ES modules. It rebuilds a utility you already have. Most people notice, sigh, fix it by hand, and let the lesson evaporate. Next session, same fix.&lt;/p&gt;
&lt;p&gt;Learn is where you write the correction somewhere the agent reads every time: a rules file, a &lt;code class=&quot;language-text&quot;&gt;CLAUDE.md&lt;/code&gt;, a conventions doc, whatever loads at the start of a session. A few lines do it:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;markdown&quot;&gt;&lt;pre class=&quot;language-markdown&quot;&gt;&lt;code class=&quot;language-markdown&quot;&gt;&lt;span class=&quot;token title important&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;#&lt;/span&gt; Conventions&lt;/span&gt;
&lt;span class=&quot;token list punctuation&quot;&gt;-&lt;/span&gt; Use ES modules (import/export), never require()
&lt;span class=&quot;token list punctuation&quot;&gt;-&lt;/span&gt; Reuse &lt;span class=&quot;token code-snippet code keyword&quot;&gt;`formatMoney()`&lt;/span&gt; from src/util — don&apos;t roll your own
&lt;span class=&quot;token list punctuation&quot;&gt;-&lt;/span&gt; Tests: no mocks past the system boundary&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Only this phase compounds. Research, Plan, and Execute improve &lt;em&gt;this&lt;/em&gt; task. Learn improves &lt;em&gt;every&lt;/em&gt; task, because you’re teaching the agent your codebase instead of re-explaining it each morning. Skip it and you stay on the treadmill, making the same three fixes forever.&lt;/p&gt;
&lt;p&gt;One caveat: don’t let the rules file swell. A bloated doc is one the agent ignores, because the rule that matters hides under twenty that don’t. For each line, ask the question I took from the docs: would cutting this make the agent mess up? If not, cut it. Learn means adding the lessons that count and pruning the rest.&lt;/p&gt;
&lt;h2 id=&quot;the-loop&quot;&gt;The whole loop in one picture&lt;/h2&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;mermaid&quot;&gt;&lt;pre class=&quot;language-mermaid&quot;&gt;&lt;code class=&quot;language-mermaid&quot;&gt;&lt;span class=&quot;token arrow operator&quot;&gt;---&lt;/span&gt;
title&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; Research, Plan, Execute and Learn loop
&lt;span class=&quot;token arrow operator&quot;&gt;---&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;flowchart&lt;/span&gt; TD
    R&lt;span class=&quot;token text string&quot;&gt;[Research&amp;lt;br/&gt;read before you write]&lt;/span&gt; &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt; P&lt;span class=&quot;token text string&quot;&gt;[Plan&amp;lt;br/&gt;a contract, not a vibe]&lt;/span&gt;
    P &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt; E&lt;span class=&quot;token text string&quot;&gt;[Execute&amp;lt;br/&gt;verify, don&apos;t trust]&lt;/span&gt;
    E &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt; L&lt;span class=&quot;token text string&quot;&gt;[Learn&amp;lt;br/&gt;write the lesson down]&lt;/span&gt;
    E -.&lt;span class=&quot;token string&quot;&gt;&quot;done&quot;&lt;/span&gt; is not evidence.&lt;span class=&quot;token arrow operator&quot;&gt;-&gt;&lt;/span&gt; E
    L &lt;span class=&quot;token inter-arrow-label&quot;&gt;&lt;span class=&quot;token arrow-head arrow operator&quot;&gt;-.&lt;/span&gt;&lt;span class=&quot;token label property&quot;&gt;feeds the next task&lt;/span&gt;&lt;span class=&quot;token arrow operator&quot;&gt;.-&gt;&lt;/span&gt;&lt;/span&gt; R&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The dashed line from Learn back to Research is the whole game. It’s a loop that tightens each lap rather than a pipeline with an end, because every lap leaves a rule that shortens the next Research phase.&lt;/p&gt;
&lt;p&gt;The straight red wire from the picture, idea straight to Execute, is still there. It always will be. For a one-line typo, taking it is right. The skill is knowing when the task is big enough that the shortcut becomes the long way around.&lt;/p&gt;
&lt;h2 id=&quot;wrapping-up&quot;&gt;Wrapping up&lt;/h2&gt;
&lt;p&gt;None of this is tool-specific, and none of it is new. It’s the discipline good engineers already use on themselves. The agent just makes skipping it cost you faster. The loop is what turns a fast demo into something you’d sign your name to.&lt;/p&gt;
&lt;p&gt;Now excuse me. I have a rules file to prune. (Spoiler: it’s too long. It’s always too long.)&lt;/p&gt;
&lt;p&gt;Happy building.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[The ts-jest to Vitest Switch Is Lower-Risk Than You Think]]></title><description><![CDATA[Every frontend team has the ticket. “Evaluate moving off ts-jest.” It rots in the backlog for a year. Nobody picks it up, because everyone…]]></description><link>https://www.codespud.com/2026/vitest-migration-not-the-risk/</link><guid isPermaLink="false">https://www.codespud.com/2026/vitest-migration-not-the-risk/</guid><pubDate>Fri, 10 Jul 2026 04:29:00 GMT</pubDate><content:encoded>&lt;p&gt;Every frontend team has the ticket. “Evaluate moving off ts-jest.” It rots in the backlog for a year. Nobody picks it up, because everyone assumes a test-runner swap means rewriting hundreds of files.&lt;/p&gt;
&lt;p&gt;It doesn’t. Vitest ships a Jest-compatible API on purpose, so the switch stays cheap. The &lt;a href=&quot;https://vitest.dev/guide/migration.html#jest&quot;&gt;official migration guide&lt;/a&gt; is short, and most of it covers edge cases you may never hit. The common path is one config file, a find-and-replace, and a green run. The risk you picture is bigger than the risk that’s there. The reward, faster tests, is the part you keep ignoring.&lt;/p&gt;
&lt;h2 id=&quot;why-ts-jest-got-slow&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#why-ts-jest-got-slow&quot; aria-label=&quot;why ts jest got slow permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Why ts-jest got slow&lt;/h2&gt;
&lt;p&gt;Start with the pain, since it’s the reason to move.&lt;/p&gt;
&lt;p&gt;ts-jest is a Jest transformer. On every run it hands each file to the TypeScript compiler to type-check and transpile. That work is correct and thorough and slow. The compiler resolves types across your whole project before one assertion fires.&lt;/p&gt;
&lt;p&gt;The usual fix proves the point. You reach for &lt;a href=&quot;https://kulshekhar.github.io/ts-jest/docs/getting-started/options/isolatedModules&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;isolatedModules: true&lt;/code&gt;&lt;/a&gt;, which skips type-checking and compiles each file alone. On our own codebase, turning it on in &lt;code class=&quot;language-text&quot;&gt;tsconfig&lt;/code&gt; cut a full-suite run from 16 minutes to about 3. But look at what you did. You switched off the type-checking that justified ts-jest’s cost, and you gave up features like &lt;code class=&quot;language-text&quot;&gt;const enum&lt;/code&gt;. So a tuned ts-jest setup runs no type-checking in tests and still trails the alternative. That is the bottleneck.&lt;/p&gt;
&lt;p&gt;Vitest attacks it differently. It reuses Vite’s pipeline, which strips types with esbuild. esbuild is written in Go and transpiles TypeScript far faster than the TypeScript compiler — &lt;a href=&quot;https://datastation.multiprocess.io/blog/2021-11-13-benchmarking-esbuild-swc-typescript-babel.html&quot;&gt;benchmarks&lt;/a&gt; put it anywhere from several times to tens of times quicker, depending on the project. It strips types instead of understanding them. You add no separate transform, no Babel preset. TypeScript works because the build tool already reads it.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;mermaid&quot;&gt;&lt;pre class=&quot;language-mermaid&quot;&gt;&lt;code class=&quot;language-mermaid&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;flowchart&lt;/span&gt; LR
  &lt;span class=&quot;token keyword&quot;&gt;subgraph&lt;/span&gt; tsjest&lt;span class=&quot;token text string&quot;&gt;[&quot;ts-jest run&quot;]&lt;/span&gt;
    A&lt;span class=&quot;token text string&quot;&gt;[Test file .ts]&lt;/span&gt; &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt; B&lt;span class=&quot;token text string&quot;&gt;[TypeScript compiler]&lt;/span&gt;
    B &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt; C&lt;span class=&quot;token text string&quot;&gt;[Type-check + transpile]&lt;/span&gt;
    C &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt; D&lt;span class=&quot;token text string&quot;&gt;[Jest executes test]&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;end&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;subgraph&lt;/span&gt; vitest&lt;span class=&quot;token text string&quot;&gt;[&quot;Vitest run&quot;]&lt;/span&gt;
    E&lt;span class=&quot;token text string&quot;&gt;[Test file .ts]&lt;/span&gt; &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt; F&lt;span class=&quot;token text string&quot;&gt;[esbuild strips types]&lt;/span&gt;
    F &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt; G&lt;span class=&quot;token text string&quot;&gt;[Vitest executes test]&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;end&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;One pipeline does less, and it skips the costly part.&lt;/p&gt;
&lt;h2 id=&quot;its-compatible-on-purpose&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#its-compatible-on-purpose&quot; aria-label=&quot;its compatible on purpose permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;It’s compatible on purpose&lt;/h2&gt;
&lt;p&gt;Teams treat Vitest as a foreign framework. It isn’t.&lt;/p&gt;
&lt;p&gt;The API matches Jest. &lt;code class=&quot;language-text&quot;&gt;describe&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;it&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;test&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;expect&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;beforeEach&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;afterEach&lt;/code&gt; — same names, same shapes. Matchers like &lt;code class=&quot;language-text&quot;&gt;toBe&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;toEqual&lt;/code&gt;, and &lt;code class=&quot;language-text&quot;&gt;toHaveBeenCalledWith&lt;/code&gt; carry over. Set one flag, &lt;code class=&quot;language-text&quot;&gt;globals: true&lt;/code&gt;, and tests that call &lt;code class=&quot;language-text&quot;&gt;describe&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;expect&lt;/code&gt; without imports keep running. The &lt;a href=&quot;https://vitest.dev/config/globals&quot;&gt;globals setting&lt;/a&gt; exists so you skip adding an import to every file on day one.&lt;/p&gt;
&lt;p&gt;That flag is why this is find-and-replace, not a rewrite. Your test bodies mostly hold. The plumbing around them moves.&lt;/p&gt;
&lt;h2 id=&quot;what-actually-changes&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#what-actually-changes&quot; aria-label=&quot;what actually changes permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;What actually changes&lt;/h2&gt;
&lt;p&gt;Three things move. None is scary.&lt;/p&gt;
&lt;p&gt;First, the config. You write a small &lt;code class=&quot;language-text&quot;&gt;vitest.config.ts&lt;/code&gt;. If you build with Vite, you extend what you have.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;ts&quot;&gt;&lt;pre class=&quot;language-ts&quot;&gt;&lt;code class=&quot;language-ts&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// vitest.config.ts&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; defineConfig &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;vitest/config&apos;&lt;/span&gt;
 
&lt;span class=&quot;token keyword&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;default&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;defineConfig&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  test&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    globals&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;        &lt;span class=&quot;token comment&quot;&gt;// keep Jest-style describe/expect without imports&lt;/span&gt;
    environment&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;jsdom&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// for component tests; omit for pure Node code&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Second, &lt;code class=&quot;language-text&quot;&gt;jest&lt;/code&gt; becomes &lt;code class=&quot;language-text&quot;&gt;vi&lt;/code&gt;. Vitest names the mocking object &lt;code class=&quot;language-text&quot;&gt;vi&lt;/code&gt;. This is most of your diff, and it’s mechanical.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;ts&quot;&gt;&lt;pre class=&quot;language-ts&quot;&gt;&lt;code class=&quot;language-ts&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// before (ts-jest / Jest)&lt;/span&gt;
jest&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;mock&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;./api&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; spy &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; jest&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;fn&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
jest&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;useFakeTimers&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
jest&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;spyOn&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;obj&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;method&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
 
&lt;span class=&quot;token comment&quot;&gt;// after (Vitest)&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; vi &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;vitest&apos;&lt;/span&gt;
vi&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;mock&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;./api&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; spy &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; vi&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;fn&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
vi&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;useFakeTimers&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
vi&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;spyOn&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;obj&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;method&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Find &lt;code class=&quot;language-text&quot;&gt;jest.&lt;/code&gt;, replace with &lt;code class=&quot;language-text&quot;&gt;vi.&lt;/code&gt;, add the import or skip it with &lt;code class=&quot;language-text&quot;&gt;globals: true&lt;/code&gt;. A codemod clears a large suite in one sitting.&lt;/p&gt;
&lt;p&gt;Third, a few named quirks. The guide lists them. &lt;code class=&quot;language-text&quot;&gt;jest.requireActual&lt;/code&gt; becomes &lt;code class=&quot;language-text&quot;&gt;vi.importActual&lt;/code&gt;. &lt;code class=&quot;language-text&quot;&gt;jest.setTimeout(5000)&lt;/code&gt; becomes &lt;code class=&quot;language-text&quot;&gt;vi.setConfig({ testTimeout: 5000 })&lt;/code&gt;. The &lt;code class=&quot;language-text&quot;&gt;jest.Mock&lt;/code&gt; type becomes an imported &lt;code class=&quot;language-text&quot;&gt;Mock&lt;/code&gt; from &lt;code class=&quot;language-text&quot;&gt;vitest&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&quot;run-it-in-an-afternoon&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#run-it-in-an-afternoon&quot; aria-label=&quot;run it in an afternoon permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Run it in an afternoon&lt;/h2&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;mermaid&quot;&gt;&lt;pre class=&quot;language-mermaid&quot;&gt;&lt;code class=&quot;language-mermaid&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;flowchart&lt;/span&gt; TD
  A&lt;span class=&quot;token text string&quot;&gt;[Install vitest + remove ts-jest]&lt;/span&gt; &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt; B&lt;span class=&quot;token text string&quot;&gt;[Add vitest.config.ts with globals: true]&lt;/span&gt;
  B &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt; C&lt;span class=&quot;token text string&quot;&gt;[Find/replace jest. with vi.]&lt;/span&gt;
  C &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt; D&lt;span class=&quot;token text string&quot;&gt;[Swap package.json test script to vitest]&lt;/span&gt;
  D &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt; E&lt;span class=&quot;token text string&quot;&gt;[Run the suite]&lt;/span&gt;
  E &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt; F&lt;span class=&quot;token text string&quot;&gt;{All green?}&lt;/span&gt;
  F &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt;&lt;span class=&quot;token label property&quot;&gt;|Yes|&lt;/span&gt; G&lt;span class=&quot;token text string&quot;&gt;[Done]&lt;/span&gt;
  F &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt;&lt;span class=&quot;token label property&quot;&gt;|No|&lt;/span&gt; H&lt;span class=&quot;token text string&quot;&gt;[Fix named gotchas from the guide]&lt;/span&gt;
  H &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt; E&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Install Vitest and drop ts-jest and its presets. Add the config. Replace &lt;code class=&quot;language-text&quot;&gt;jest.&lt;/code&gt; with &lt;code class=&quot;language-text&quot;&gt;vi.&lt;/code&gt;. Point the &lt;code class=&quot;language-text&quot;&gt;test&lt;/code&gt; script at &lt;code class=&quot;language-text&quot;&gt;vitest&lt;/code&gt;. Run it. Fix the short list of documented differences below.&lt;/p&gt;
&lt;p&gt;The failure mode isn’t “my tests are broken forever.” It’s a green run after a handful of named fixes.&lt;/p&gt;
&lt;h2 id=&quot;the-gotchas-worth-knowing&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#the-gotchas-worth-knowing&quot; aria-label=&quot;the gotchas worth knowing permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;The Gotchas Worth Knowing&lt;/h2&gt;
&lt;p&gt;A few differences bite if you don’t know them. Two cause &lt;em&gt;silently wrong&lt;/em&gt; tests, not loud errors — so here’s the exact shape.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;code class=&quot;language-text&quot;&gt;mockReset&lt;/code&gt;:&lt;/strong&gt; Jest empties the implementation. Vitest &lt;a href=&quot;https://vitest.dev/guide/migration.html#mock-mockreset&quot;&gt;restores the original&lt;/a&gt; you passed to &lt;code class=&quot;language-text&quot;&gt;vi.fn(impl)&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;ts&quot;&gt;&lt;pre class=&quot;language-ts&quot;&gt;&lt;code class=&quot;language-ts&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; fn &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; vi&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;fn&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;real&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
fn&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;mockReset&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;fn&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;            &lt;span class=&quot;token comment&quot;&gt;// Vitest → &apos;real&apos;   |   Jest → undefined&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Module mock factories:&lt;/strong&gt; In Jest the factory returns the default export. In Vitest it must return an object with each export named, including &lt;code class=&quot;language-text&quot;&gt;default&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;ts&quot;&gt;&lt;pre class=&quot;language-ts&quot;&gt;&lt;code class=&quot;language-ts&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Jest&lt;/span&gt;
jest&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;mock&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;./greet&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;hello&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Vitest&lt;/span&gt;
vi&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;mock&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;./greet&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;hello&apos;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Timers &amp;#x26; legacy callbacks:&lt;/strong&gt; Vitest drops Jest’s legacy fake timers and the &lt;code class=&quot;language-text&quot;&gt;done&lt;/code&gt; callback. Rewrite those as &lt;code class=&quot;language-text&quot;&gt;async&lt;/code&gt;/&lt;code class=&quot;language-text&quot;&gt;await&lt;/code&gt; or a Promise.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Version floor:&lt;/strong&gt; Vitest 4 needs Vite 6 and Node 20 or newer, per the &lt;a href=&quot;https://vitest.dev/guide/migration.html#vitest-4&quot;&gt;migration guide&lt;/a&gt;. Check your runtime first.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Each is a line in a checklist. Keep the guide open during the swap and clear them as they appear.&lt;/p&gt;
&lt;h2 id=&quot;the-bottom-line&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#the-bottom-line&quot; aria-label=&quot;the bottom line permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;The bottom line&lt;/h2&gt;
&lt;p&gt;The reason to move is speed. ts-jest either type-checks and crawls, or skips it and still trails esbuild. esbuild strips types in Go, not JavaScript — on a large suite that’s the difference between a coffee break and a glance. The reason you can move is compatibility: Vitest copied Jest’s API, so your tests survive the trip.&lt;/p&gt;
&lt;p&gt;The ticket is smaller than its reputation. You rename &lt;code class=&quot;language-text&quot;&gt;jest&lt;/code&gt; to &lt;code class=&quot;language-text&quot;&gt;vi&lt;/code&gt;, add one config file, and work a short list of gotchas. Do it on a quiet afternoon. Then keep the faster feedback loop all year.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Your Alt Text Is Not the Problem — Your Images Are]]></title><description><![CDATA[A confession: early in my career, my images shipped with no  text at all. If an image mattered, I gave it a visible caption and moved on (I…]]></description><link>https://www.codespud.com/2026/your-alt-text-is-not-the-problem/</link><guid isPermaLink="false">https://www.codespud.com/2026/your-alt-text-is-not-the-problem/</guid><pubDate>Sun, 05 Jul 2026 08:29:00 GMT</pubDate><content:encoded>&lt;h2 id=&quot;o-the-mistake&quot;&gt;The mistake I kept making&lt;/h2&gt;
&lt;p&gt;A confession: early in my career, my images shipped with no &lt;code class=&quot;language-text&quot;&gt;alt&lt;/code&gt; text at all. If an image mattered, I gave it a visible caption and moved on (I thought &lt;code class=&quot;language-text&quot;&gt;alt&lt;/code&gt; was a box the SEO people cared about). Screen reader users got silence, or file names — “hero underscore final underscore v three dot jaypeg.”&lt;/p&gt;
&lt;p&gt;A caption doesn’t substitute. It describes the image for everyone, but leaves the &lt;code class=&quot;language-text&quot;&gt;&amp;lt;img&gt;&lt;/code&gt; itself unnamed, and it can’t say whether that image is a link, a chart, or wallpaper. I didn’t know that then. I’m not sure I’d heard of a screen reader.&lt;/p&gt;
&lt;p&gt;The usual penance, once you learn better, is to overcorrect: describe &lt;em&gt;everything&lt;/em&gt;, decorative swooshes included. That’s the opposite failure. The &lt;a href=&quot;https://www.w3.org/WAI/tutorials/images/&quot;&gt;W3C Images Tutorial&lt;/a&gt; says decorative images should get a null alternative — &lt;code class=&quot;language-text&quot;&gt;alt=&quot;&quot;&lt;/code&gt; — so assistive technology skips them. Silence where there should be words, then words where there should be silence.&lt;/p&gt;
&lt;p&gt;The lesson took years to sink in. The hard part of image accessibility isn’t writing the description. It’s deciding whether one should exist and what job it must do. Wording comes last. Classification comes first. Most of us skip to the last step.&lt;/p&gt;
&lt;h2 id=&quot;o-the-question&quot;&gt;The question that fixes most alt text&lt;/h2&gt;
&lt;p&gt;Before you touch the &lt;code class=&quot;language-text&quot;&gt;alt&lt;/code&gt; attribute, ask: &lt;strong&gt;what does this image &lt;em&gt;do&lt;/em&gt; on this page?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Not “what does it show”. A photo of a woman smiling at a laptop &lt;em&gt;shows&lt;/em&gt; that. What it &lt;em&gt;does&lt;/em&gt; might be nothing (stock decoration), navigation (it links to her profile), or information (the article is about her).&lt;/p&gt;
&lt;p&gt;Same pixels. Three alt texts. One is empty.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://www.w3.org/WAI/WCAG22/Understanding/non-text-content.html&quot;&gt;WCAG Success Criterion 1.1.1&lt;/a&gt; requires text alternatives that serve “the equivalent purpose” of the content. Purpose, not appearance. The spec has said so since &lt;a href=&quot;https://www.w3.org/TR/WCAG10/&quot;&gt;WCAG 1.0 in 1999&lt;/a&gt;. We still write alt text that describes what marketing exported from Figma.&lt;/p&gt;
&lt;h2 id=&quot;o-three-roles&quot;&gt;The three types of alt text: decorative, functional, informative&lt;/h2&gt;
&lt;p&gt;The &lt;a href=&quot;https://www.w3.org/WAI/tutorials/images/&quot;&gt;WAI Images Tutorial&lt;/a&gt; sorts images into categories. Three cover almost everything you’ll ship: decorative, functional, informative.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Decorative&lt;/strong&gt; — visual polish, no information. Empty &lt;code class=&quot;language-text&quot;&gt;alt&lt;/code&gt;, move on:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- A wave divider between page sections --&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;img&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;wave-divider.svg&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;em&gt;&lt;code class=&quot;language-text&quot;&gt;alt=&quot;&quot;&lt;/code&gt; tells screen readers to skip it. Omitting the attribute is worse — &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/img&quot;&gt;MDN warns&lt;/a&gt; some screen readers then announce the file name. That’s how users end up hearing “wave hyphen divider dot ess vee gee”.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Functional&lt;/strong&gt; — the image is a control. Describe the action, not the picture:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- Bad: describes the pixels --&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;/print&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;img&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;printer.svg&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;An icon of a printer&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- Good: describes the job --&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;/print&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;img&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;printer.svg&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;Print this page&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;em&gt;The alt text becomes the link’s name. “An icon of a printer” tells users what your designer drew. “Print this page” tells them what Enter does. Only one helps mid-task.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Informative&lt;/strong&gt; — the image carries meaning the text doesn’t. Convey it, briefly:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Attach the strap using the D-ring on the left side.&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;img&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;strap-dring.jpg&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
     &lt;span class=&quot;token attr-name&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;The strap threaded through the D-ring, folded back and clipped&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;em&gt;The alt completes the instruction. It doesn’t repeat the paragraph, and it doesn’t start with “Image of” — the screen reader announces that already.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;A fourth case: &lt;strong&gt;complex images&lt;/strong&gt; — charts, infographics — where a short alt can’t hold the data. Give a short &lt;code class=&quot;language-text&quot;&gt;alt&lt;/code&gt; plus a long description nearby:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;figure&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;img&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;q2-signups.png&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
       &lt;span class=&quot;token attr-name&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;Bar chart of Q2 signups by month. Full data follows.&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;figcaption&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    Q2 signups: April 1,240 · May 1,610 · June 2,380
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;figcaption&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;                                                                                                                      
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;figure&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;em&gt;The &lt;code class=&quot;language-text&quot;&gt;alt&lt;/code&gt; names the chart; the &lt;code class=&quot;language-text&quot;&gt;figcaption&lt;/code&gt; carries the numbers.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;A self-test from &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/img&quot;&gt;MDN&lt;/a&gt;: read the alt text aloud with the paragraph before it. If the pair conveys what a sighted reader gets, stop. If it repeats or leaves a hole, keep editing.&lt;/p&gt;
&lt;h2 id=&quot;o-decision-tree&quot;&gt;The alt text decision tree&lt;/h2&gt;
&lt;p&gt;The W3C’s &lt;a href=&quot;https://www.w3.org/WAI/tutorials/images/decision-tree/&quot;&gt;alt decision tree&lt;/a&gt; formalizes this. I run a simplified version on every &lt;code class=&quot;language-text&quot;&gt;&amp;lt;img&gt;&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;mermaid&quot;&gt;&lt;pre class=&quot;language-mermaid&quot;&gt;&lt;code class=&quot;language-mermaid&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;flowchart&lt;/span&gt; TD
    A&lt;span class=&quot;token text string&quot;&gt;[&quot;New &amp;lt;img&gt;. What does it DO?&quot;]&lt;/span&gt; &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt; B&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;Is it purely
decoration?&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
    B &lt;span class=&quot;token inter-arrow-label&quot;&gt;&lt;span class=&quot;token arrow-head arrow operator&quot;&gt;--&lt;/span&gt; &lt;span class=&quot;token label property&quot;&gt;Yes&lt;/span&gt; &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt;&lt;/span&gt; C[&quot;alt=&apos;&apos;
&lt;span class=&quot;token text string&quot;&gt;(empty, not missing)&lt;/span&gt;&quot;]
    B &lt;span class=&quot;token inter-arrow-label&quot;&gt;&lt;span class=&quot;token arrow-head arrow operator&quot;&gt;--&lt;/span&gt; &lt;span class=&quot;token label property&quot;&gt;No&lt;/span&gt; &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt;&lt;/span&gt; D&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;Is it inside a link
or button?&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
    D &lt;span class=&quot;token inter-arrow-label&quot;&gt;&lt;span class=&quot;token arrow-head arrow operator&quot;&gt;--&lt;/span&gt; &lt;span class=&quot;token label property&quot;&gt;Yes&lt;/span&gt; &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt;&lt;/span&gt; E[&quot;Describe the ACTION
&lt;span class=&quot;token keyword&quot;&gt;alt&lt;/span&gt;=&apos;Print this page&apos;&quot;]
    D &lt;span class=&quot;token inter-arrow-label&quot;&gt;&lt;span class=&quot;token arrow-head arrow operator&quot;&gt;--&lt;/span&gt; &lt;span class=&quot;token label property&quot;&gt;No&lt;/span&gt; &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt;&lt;/span&gt; F&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;Does it carry info
the text doesn&apos;t?&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
    F &lt;span class=&quot;token inter-arrow-label&quot;&gt;&lt;span class=&quot;token arrow-head arrow operator&quot;&gt;--&lt;/span&gt; &lt;span class=&quot;token label property&quot;&gt;No&lt;/span&gt; &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt;&lt;/span&gt; C
    F &lt;span class=&quot;token inter-arrow-label&quot;&gt;&lt;span class=&quot;token arrow-head arrow operator&quot;&gt;--&lt;/span&gt; &lt;span class=&quot;token label property&quot;&gt;Yes&lt;/span&gt; &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt;&lt;/span&gt; G&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;Too complex for
a sentence?&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
    G &lt;span class=&quot;token inter-arrow-label&quot;&gt;&lt;span class=&quot;token arrow-head arrow operator&quot;&gt;--&lt;/span&gt; &lt;span class=&quot;token label property&quot;&gt;No&lt;/span&gt; &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt;&lt;/span&gt; H[&quot;Short alt conveying
the meaning&quot;]
    G &lt;span class=&quot;token inter-arrow-label&quot;&gt;&lt;span class=&quot;token arrow-head arrow operator&quot;&gt;--&lt;/span&gt; &lt;span class=&quot;token label property&quot;&gt;Yes&lt;/span&gt; &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt;&lt;/span&gt; I[&quot;Short alt + long description
&lt;span class=&quot;token text string&quot;&gt;(figure, table, or link)&lt;/span&gt;&quot;]&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;No box says “describe what the image looks like”. Appearance matters only when appearance &lt;em&gt;is&lt;/em&gt; the information — a painting on a gallery site, a rash on a medical page, a mockup in a design critique.&lt;/p&gt;
&lt;h2 id=&quot;o-ai-cant-classify&quot;&gt;Why AI-generated alt text fails&lt;/h2&gt;
&lt;p&gt;In 2026, every CMS and editor plugin will generate alt text for you. The models describe pixels well. I use them. But the first three branches of the tree above have nothing to do with pixels.&lt;/p&gt;
&lt;p&gt;Is the image decorative? Depends on the page. Functional? Depends on the markup around it. Does it add information? Depends on the text. A model looking at a cropped file sees none of that. It answers the one question it can — “what’s in this picture?” — which is the last question that matters, and often the wrong one.&lt;/p&gt;
&lt;p&gt;Researchers have documented the failure. &lt;a href=&quot;https://silktide.com/blog/the-downsides-of-ai-alt-text/&quot;&gt;Silktide found&lt;/a&gt; that screen reader users can tell when alt text is AI-generated: accurate descriptions that convey no purpose or function. The &lt;a href=&quot;https://afb.org/blog/entry/alt-text-age-ai&quot;&gt;American Foundation for the Blind&lt;/a&gt; puts it plainly: description without intent isn’t access.&lt;/p&gt;
&lt;p&gt;Picture a CMS plugin writing &lt;code class=&quot;language-text&quot;&gt;alt=&quot;A person holding a credit card near a laptop&quot;&lt;/code&gt; for a checkout help page. Accurate. Useless. The image is a &lt;em&gt;button&lt;/em&gt; opening the payment FAQ. Screen reader users get stock-photo narration and no hint the thing is clickable. Arguably worse than no alt at all, because it &lt;em&gt;sounds&lt;/em&gt; finished.&lt;/p&gt;
&lt;p&gt;My rule: AI drafts wording on informative images after I classify them. It never decides the role. That’s a design decision, and it belongs to someone who can see the whole page (in every sense).&lt;/p&gt;
&lt;h2 id=&quot;o-one-in-six&quot;&gt;Missing alt text by the numbers (WebAIM 2026)&lt;/h2&gt;
&lt;p&gt;WCAG has required text alternatives since 1999, so you might expect the problem solved. The &lt;a href=&quot;https://webaim.org/projects/million/&quot;&gt;2026 WebAIM Million report&lt;/a&gt; — an automated audit of the top million home pages — found:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;16.2% of home page images&lt;/strong&gt; lack alternative text (about 10.8 per page)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;45% of those&lt;/strong&gt; sit inside links — links with no name&lt;/li&gt;
&lt;li&gt;Home pages average &lt;strong&gt;66.6 images&lt;/strong&gt;, nearly double eight years ago&lt;/li&gt;
&lt;li&gt;Missing alt text stays among the six error types making up &lt;strong&gt;96% of detected failures&lt;/strong&gt;, unchanged for seven years&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The second bullet is the bad one. A missing alt on decoration is noise. A missing alt on a &lt;em&gt;linked&lt;/em&gt; image is a door with no handle — the screen reader announces a raw URL, or nothing. Half our missing-alt problem is the highest-stakes category with the easiest fix.&lt;/p&gt;
&lt;p&gt;We ship more images than ever and classify fewer. The tools improved. The thinking didn’t.&lt;/p&gt;
&lt;h2 id=&quot;o-describe-less&quot;&gt;Describe less, decide more&lt;/h2&gt;
&lt;p&gt;Alt text quality is decided before you write a word. Classify first: decorative, functional, informative, complex. The &lt;a href=&quot;https://www.w3.org/WAI/tutorials/images/decision-tree/&quot;&gt;decision tree&lt;/a&gt; makes the decision for you. Wording is the easy 20%.&lt;/p&gt;
&lt;p&gt;Next PR with images: don’t ask “does this have alt text?“. Ask “does this alt text know what the image is for?“. The first is a checkbox. The second is accessibility. Otherwise you’re hanging masterpieces in the gallery and labeling them &lt;code class=&quot;language-text&quot;&gt;IMG_4032.JPG&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Happy (inclusive) building!&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Unplug Your Mouse - One Year On, Accessibility Widgets Still Don't Work]]></title><description><![CDATA[The European Accessibility Act turns one tomorrow. It took force on 28 June 2025. For many teams it was the first hard deadline they had…]]></description><link>https://www.codespud.com/2026/one-year-of-the-accessibility-act-unplug-your-mouse-and-see-what-breaks/</link><guid isPermaLink="false">https://www.codespud.com/2026/one-year-of-the-accessibility-act-unplug-your-mouse-and-see-what-breaks/</guid><pubDate>Sat, 27 Jun 2026 08:29:00 GMT</pubDate><content:encoded>&lt;p&gt;The &lt;a href=&quot;https://commission.europa.eu/strategy-and-policy/policies/justice-and-fundamental-rights/disability/european-accessibility-act-eaa_en&quot;&gt;European Accessibility Act&lt;/a&gt; turns one tomorrow. It took force on 28 June 2025. For many teams it was the first hard deadline they had ever faced for this work: e-commerce, banking, transport, ticketing, and telecom, across all 27 EU countries.&lt;/p&gt;
&lt;p&gt;A year on, the same reflex persists, and it still doesn’t work. A team bolts an &lt;a href=&quot;https://www.hintogroup.eu/en/blog/digital-accessibility-when-widget-no-longer-enough-and-what-actually-needed&quot;&gt;accessibility widget&lt;/a&gt; into the corner of the page: a floating icon that swears it fixes accessibility in one click. &lt;strong&gt;It does not&lt;/strong&gt;. Here is why, and here is what I do instead.&lt;/p&gt;
&lt;h2 id=&quot;a-widget-is-a-sticker-over-a-crack&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#a-widget-is-a-sticker-over-a-crack&quot; aria-label=&quot;a widget is a sticker over a crack permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;A widget is a sticker over a crack&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;Accessibility widgets (often called “overlays”) are plugins installed on websites to add functionality via overlay buttons. They frequently promise compliance with regulations (such as WCAG or EAA) with a single line of code. - &lt;a href=&quot;http://www.hintogroup.eu&quot;&gt;www.hintogroup.eu&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Most accessibility lives in your markup and your CSS, not in a script you paste before &lt;code class=&quot;language-text&quot;&gt;&amp;lt;/body&gt;&lt;/code&gt;. A widget can recolor text or grow the font. It won’t build a focus order your page never had. It can’t teach a &lt;code class=&quot;language-text&quot;&gt;&amp;lt;div onclick&gt;&lt;/code&gt; to behave like a &lt;code class=&quot;language-text&quot;&gt;&amp;lt;button /&gt;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The Nielsen Norman Group has said this for years: accessibility is a mindset, not a checklist, and a bolted-on widget is not enough. The only real test is to put disabled users in front of the design. So drop the sticker. The best test costs nothing but a little pride.&lt;/p&gt;
&lt;h2 id=&quot;unplug-your-mouse&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#unplug-your-mouse&quot; aria-label=&quot;unplug your mouse permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Unplug your mouse&lt;/h2&gt;
&lt;p&gt;Testing keyboard accessibility starts the same way every time: pull the mouse out. Use your own site with the keyboard. Tab forward, &lt;kbd&gt;Shift+Tab&lt;/kbd&gt; back, &lt;kbd&gt;Enter&lt;/kbd&gt; and &lt;kbd&gt;Space&lt;/kbd&gt; to act, &lt;kbd&gt;Esc&lt;/kbd&gt; to close.&lt;/p&gt;
&lt;p&gt;You will find the broken parts in a minute. A modal you can tab into but never out of. A dropdown the keyboard skips. A “button” that ignores &lt;kbd&gt;Enter&lt;/kbd&gt; because it is a &lt;code class=&quot;language-text&quot;&gt;&amp;lt;span&gt;&lt;/code&gt; in costume. The mouse hid all of it.&lt;/p&gt;
&lt;p&gt;This is no fringe group. Some people drive the keyboard because their hands need it, some because a screen reader drives it for them, some because it is faster. Marieke McCloskey set the &lt;a href=&quot;https://www.nngroup.com/articles/keyboard-accessibility/&quot;&gt;three rules a decade ago&lt;/a&gt;, and they still hold: keep focus visible, let the &lt;kbd&gt;Tab&lt;/kbd&gt; key reach every control, and let users skip past long menus.&lt;/p&gt;
&lt;p&gt;This is the check I run as I tab:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;mermaid&quot;&gt;&lt;pre class=&quot;language-mermaid&quot;&gt;&lt;code class=&quot;language-mermaid&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;flowchart&lt;/span&gt; TD
    A&lt;span class=&quot;token text string&quot;&gt;[Press Tab]&lt;/span&gt; &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt; B&lt;span class=&quot;token text string&quot;&gt;{Can I see where focus landed?}&lt;/span&gt;
    B &lt;span class=&quot;token inter-arrow-label&quot;&gt;&lt;span class=&quot;token arrow-head arrow operator&quot;&gt;--&lt;/span&gt; &lt;span class=&quot;token label property&quot;&gt;No&lt;/span&gt; &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt;&lt;/span&gt; F&lt;span class=&quot;token text string&quot;&gt;[Fail: focus indicator missing or hidden]&lt;/span&gt;
    B &lt;span class=&quot;token inter-arrow-label&quot;&gt;&lt;span class=&quot;token arrow-head arrow operator&quot;&gt;--&lt;/span&gt; &lt;span class=&quot;token label property&quot;&gt;Yes&lt;/span&gt; &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt;&lt;/span&gt; C&lt;span class=&quot;token text string&quot;&gt;{Did focus reach every control in a sane order?}&lt;/span&gt;
    C &lt;span class=&quot;token inter-arrow-label&quot;&gt;&lt;span class=&quot;token arrow-head arrow operator&quot;&gt;--&lt;/span&gt; &lt;span class=&quot;token label property&quot;&gt;No&lt;/span&gt; &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt;&lt;/span&gt; G&lt;span class=&quot;token text string&quot;&gt;[Fail: unreachable or illogical focus order]&lt;/span&gt;
    C &lt;span class=&quot;token inter-arrow-label&quot;&gt;&lt;span class=&quot;token arrow-head arrow operator&quot;&gt;--&lt;/span&gt; &lt;span class=&quot;token label property&quot;&gt;Yes&lt;/span&gt; &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt;&lt;/span&gt; D&lt;span class=&quot;token text string&quot;&gt;{Can I activate it with Enter or Space?}&lt;/span&gt;
    D &lt;span class=&quot;token inter-arrow-label&quot;&gt;&lt;span class=&quot;token arrow-head arrow operator&quot;&gt;--&lt;/span&gt; &lt;span class=&quot;token label property&quot;&gt;No&lt;/span&gt; &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt;&lt;/span&gt; H&lt;span class=&quot;token text string&quot;&gt;[Fail: not a real interactive element]&lt;/span&gt;
    D &lt;span class=&quot;token inter-arrow-label&quot;&gt;&lt;span class=&quot;token arrow-head arrow operator&quot;&gt;--&lt;/span&gt; &lt;span class=&quot;token label property&quot;&gt;Yes&lt;/span&gt; &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt;&lt;/span&gt; E&lt;span class=&quot;token text string&quot;&gt;{Can I get back out? No keyboard trap?}&lt;/span&gt;
    E &lt;span class=&quot;token inter-arrow-label&quot;&gt;&lt;span class=&quot;token arrow-head arrow operator&quot;&gt;--&lt;/span&gt; &lt;span class=&quot;token label property&quot;&gt;No&lt;/span&gt; &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt;&lt;/span&gt; I&lt;span class=&quot;token text string&quot;&gt;[Fail: keyboard trap]&lt;/span&gt;
    E &lt;span class=&quot;token inter-arrow-label&quot;&gt;&lt;span class=&quot;token arrow-head arrow operator&quot;&gt;--&lt;/span&gt; &lt;span class=&quot;token label property&quot;&gt;Yes&lt;/span&gt; &lt;span class=&quot;token arrow operator&quot;&gt;--&gt;&lt;/span&gt;&lt;/span&gt; J&lt;span class=&quot;token text string&quot;&gt;[Pass this element]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Three of those boxes catch most of what I find. None need a widget. They need markup.&lt;/p&gt;
&lt;h2 id=&quot;the-dull-css-that-does-the-work&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#the-dull-css-that-does-the-work&quot; aria-label=&quot;the dull css that does the work permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;The dull CSS that does the work&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://www.w3.org/TR/WCAG22/&quot;&gt;WCAG 2.2&lt;/a&gt; shipped on 5 October 2023 and added &lt;a href=&quot;https://www.w3.org/WAI/standards-guidelines/wcag/new-in-22/&quot;&gt;nine new criteria&lt;/a&gt;. Most are boring, deliberately. They turn good intentions into numbers you can check.&lt;/p&gt;
&lt;h3 id=&quot;focus-first&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#focus-first&quot; aria-label=&quot;focus first permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Focus first&lt;/h3&gt;
&lt;p&gt;This is still the worst line of CSS on the web:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;/* Please don&apos;t. This blinds every keyboard user. */&lt;/span&gt;
&lt;span class=&quot;token selector&quot;&gt;:focus&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;outline&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; none&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;People strip the ring because it looks untidy on a mouse click. Don’t delete it: show it to the people who need it. The &lt;code class=&quot;language-text&quot;&gt;:focus-visible&lt;/code&gt; pseudo-class fires only when the browser judges a ring would help, which means keyboard use and not a stray click (&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/:focus-visible&quot;&gt;MDN&lt;/a&gt;).&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;/* Quiet for mouse clicks, loud for keyboard users. */&lt;/span&gt;
&lt;span class=&quot;token selector&quot;&gt;:focus-visible&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;outline&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 3px solid #1a73e8&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;outline-offset&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 2px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;em&gt;Keyboard users get a clear ring. Mouse users see nothing on click. Nobody is stranded.&lt;/em&gt; WCAG 2.2 even put numbers on it: &lt;a href=&quot;https://www.w3.org/WAI/WCAG22/Understanding/focus-appearance.html&quot;&gt;Focus Appearance&lt;/a&gt; wants a ring large and sharp enough to spot, and &lt;a href=&quot;https://www.w3.org/WAI/WCAG22/Understanding/focus-not-obscured-minimum.html&quot;&gt;Focus Not Obscured&lt;/a&gt; bars a sticky header from hiding it.&lt;/p&gt;
&lt;p&gt;Now hit targets. &lt;a href=&quot;https://www.w3.org/WAI/WCAG22/Understanding/target-size-minimum.html&quot;&gt;Target Size (Minimum)&lt;/a&gt; asks for at least 24 by 24 CSS pixels, or enough space that a 24px circle on each does not touch its neighbor. This is for everyone who has missed a tiny close button.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;/* Small icon button? Give it a real target. */&lt;/span&gt;
&lt;span class=&quot;token selector&quot;&gt;.icon-button&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;min-width&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 24px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;min-height&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 24px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; inline-flex&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;align-items&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; center&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;justify-content&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; center&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Twenty-four pixels is the floor, not the goal. I go bigger for the main action. But it is a number, and a number is something a team can ship.&lt;/p&gt;
&lt;h3 id=&quot;use-the-element-not-the-costume&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#use-the-element-not-the-costume&quot; aria-label=&quot;use the element not the costume permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Use the element, not the costume&lt;/h3&gt;
&lt;p&gt;Using the right HTML element is the cheapest win there is, older than any guideline. A real &lt;code class=&quot;language-text&quot;&gt;&amp;lt;button&gt;&lt;/code&gt; takes focus, fires on &lt;code class=&quot;language-text&quot;&gt;Enter&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;Space&lt;/code&gt;, names itself to a screen reader, and joins the tab order for free. A &lt;code class=&quot;language-text&quot;&gt;&amp;lt;div&gt;&lt;/code&gt; in costume gives you none of that until you wire up &lt;code class=&quot;language-text&quot;&gt;tabindex&lt;/code&gt;, key handlers, and an ARIA role by hand. You will miss one.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;jsx&quot;&gt;&lt;pre class=&quot;language-jsx&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// A costume. Skips the tab order, ignores Enter, silent to screen readers.&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;className&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;btn&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;onClick&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;save&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;Save&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// The real thing. Keyboard, focus, and semantics included.&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;button&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;className&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;btn&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;onClick&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;save&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;Save&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Same pixels. Worlds apart for anyone off the mouse. I have deleted many clever components by swapping in the plain element that already worked.&lt;/p&gt;
&lt;h2 id=&quot;why-this-beats-the-fine&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#why-this-beats-the-fine&quot; aria-label=&quot;why this beats the fine permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Why this beats the fine&lt;/h2&gt;
&lt;p&gt;The EAA carries real penalties, and within days of the deadline &lt;a href=&quot;https://www.inclusiveweb.co/accessibility-resources/eaa-wakeup-call&quot;&gt;French groups sent legal notices&lt;/a&gt; to big retailers. The fines are a good reason to care. They are not my reason.&lt;/p&gt;
&lt;p&gt;My reason is, for example, a potential buyer who will reach a checkout screen. She drove the page by keyboard, reached the “Pay” button, pressed Enter, and nothing happened. It was a &lt;code class=&quot;language-text&quot;&gt;&amp;lt;div&gt;&lt;/code&gt;. She tabbed back, tried again, then quietly closed the tab. No error, no fine, no record. Just a sale that never happened and a person told, without a word, that the site was not built for her.&lt;/p&gt;
&lt;p&gt;That is what the widget hides. Roughly &lt;a href=&quot;https://www.cdc.gov/disability-and-health/articles-documents/infographic-adults-with-disabilities-ethnicity-and-race.html&quot;&gt;one in five people lives with a disability&lt;/a&gt;, and many more are neurodiverse. Build for them and the work pays everyone back: the parent holding a baby and a phone, the commuter in glare, the person whose trackpad just died. A focus ring helps the power user. A 24-pixel target helps every thumb. Here the edge case makes the center better.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&quot;/blog/infograph-adults-disabilities-ethnicity-race.png&quot; alt=&quot;Adults with disabilities: Ethinicity and Race&quot;&gt;
&lt;figcaption&gt;One in five people lives with a disability - cdc.gov&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;The widget swears it skips all this. It can not. Your keyboard shows you the truth in a minute, and three lines of CSS fix most of what it shows.&lt;/p&gt;
&lt;h2 id=&quot;start-tomorrow-morning&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#start-tomorrow-morning&quot; aria-label=&quot;start tomorrow morning permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Start tomorrow morning&lt;/h2&gt;
&lt;p&gt;The Act turning one is a fine nudge. Unplug the mouse, tab through your top page, and note what breaks. Remove &lt;code class=&quot;language-text&quot;&gt;outline: none&lt;/code&gt; in &lt;code class=&quot;language-text&quot;&gt;:focus&lt;/code&gt; selectors. If you must touch &lt;code class=&quot;language-text&quot;&gt;outline&lt;/code&gt;, use &lt;code class=&quot;language-text&quot;&gt;:focus-visible&lt;/code&gt; so the ring still appears for the people who rely on it. Give your small buttons 24 real pixels. Replace one fake button with a real one. Small, dull, and it stays fixed. That beats a sticker.&lt;/p&gt;
&lt;p&gt;Happy (inclusive) building!&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Automating Accessibility Audits With AI]]></title><description><![CDATA[“Standards evolve, user needs are wildly diverse, and manual audits can feel like searching for a semicolon in a haystack.” Let’s be honest…]]></description><link>https://www.codespud.com/2025/ai-accessibility-audits/</link><guid isPermaLink="false">https://www.codespud.com/2025/ai-accessibility-audits/</guid><pubDate>Sat, 28 Jun 2025 10:30:00 GMT</pubDate><content:encoded>&lt;blockquote&gt;
&lt;p&gt;“Standards evolve, user needs are wildly diverse, and manual audits can feel like searching for a semicolon in a haystack.”&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Let’s be honest: accessibility is one of those things that everyone agrees is important, but somehow always ends up on the “we’ll get to it later” list. (Right next to “refactor that one function” and “actually read the WCAG guidelines.”) But here’s the thing: the web is for everyone. Or at least, it should be.&lt;/p&gt;
&lt;h2 id=&quot;accessibility-not-just-a-checkbox&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#accessibility-not-just-a-checkbox&quot; aria-label=&quot;accessibility not just a checkbox permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Accessibility: Not Just a Checkbox&lt;/h2&gt;
&lt;p&gt;If you’re a developer or DevOps engineer, you know the drill. New features, tight deadlines, and somewhere in the mix, a vague hope that your site works for everyone—including folks with disabilities and neurodivergent users. But accessibility isn’t just a legal checkbox or a last-minute scramble. It’s about building digital experiences that don’t leave anyone behind.&lt;/p&gt;
&lt;p&gt;And yes, it’s tricky. Standards evolve, user needs are wildly diverse, and manual audits can feel like searching for a semicolon in a haystack. (Spoiler: it’s always missing.)&lt;/p&gt;
&lt;h2 id=&quot;enter-ai-your-new-accessibility-sidekick&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#enter-ai-your-new-accessibility-sidekick&quot; aria-label=&quot;enter ai your new accessibility sidekick permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Enter AI: Your New Accessibility Sidekick&lt;/h2&gt;
&lt;p&gt;Manual audits are thorough, but let’s face it—they’re slow, expensive, and often get pushed to the end of the sprint. That means:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Real user issues slip through the cracks.&lt;/li&gt;
&lt;li&gt;Fixes get more expensive the longer you wait.&lt;/li&gt;
&lt;li&gt;Teams get frustrated, and so do users.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Automating accessibility audits brings some real superpowers:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Continuous feedback:&lt;/strong&gt; Catch issues early and often, not just before launch.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Scalability:&lt;/strong&gt; Big sites and frequent updates? No sweat.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Empowerment:&lt;/strong&gt; Developers, designers, and content creators get actionable insights—no PhD in accessibility required.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;ai-not-just-for-chatbots-and-cat-memes&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#ai-not-just-for-chatbots-and-cat-memes&quot; aria-label=&quot;ai not just for chatbots and cat memes permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;AI: Not Just for Chatbots and Cat Memes&lt;/h2&gt;
&lt;p&gt;Traditional tools like axe-core or Lighthouse are great at catching the obvious stuff—missing alt text, color contrast fails, or headings that are more lost than your car keys. But nuance? Context? The wild variety of user needs? That’s where generative AI and large language models (LLMs) step in.&lt;/p&gt;
&lt;p&gt;By understanding content, intent, and user journeys, AI can:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Flag ambiguous or misleading link text (like the classic “click here”—about as helpful as a screen door on a submarine)&lt;/li&gt;
&lt;li&gt;Suggest more descriptive alt text for images&lt;/li&gt;
&lt;li&gt;Detect cognitive overload in layouts or copy (because nobody likes a wall of text)&lt;/li&gt;
&lt;li&gt;Simulate diverse user experiences, including those of neurodivergent users&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;tools-that-actually-help-and-dont-just-add-more-tabs&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#tools-that-actually-help-and-dont-just-add-more-tabs&quot; aria-label=&quot;tools that actually help and dont just add more tabs permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Tools That Actually Help (And Don’t Just Add More Tabs)&lt;/h2&gt;
&lt;h3 id=&quot;1-microsoft-accessibility-insights--copilot&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#1-microsoft-accessibility-insights--copilot&quot; aria-label=&quot;1 microsoft accessibility insights  copilot permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;1. Microsoft Accessibility Insights + Copilot&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://accessibilityinsights.io/docs/web/overview/&quot;&gt;Accessibility Insights for Web&lt;/a&gt; is a browser extension for Chrome and Edge that helps you test and fix accessibility issues in web applications. It now teams up with &lt;a href=&quot;https://docs.github.com/en/copilot&quot;&gt;GitHub Copilot&lt;/a&gt;, so you get AI-powered suggestions for fixing accessibility issues right in your codebase.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;What it’s used for:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Automated and guided accessibility testing: Run quick or comprehensive checks and get step-by-step guidance to resolve issues.&lt;/li&gt;
&lt;li&gt;Visualizing and fixing issues in real time: Instantly see accessibility problems highlighted on your site and learn how to fix them.&lt;/li&gt;
&lt;li&gt;Getting AI-powered code suggestions for accessibility: Use Copilot to receive smart recommendations and code fixes as you develop.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;How to integrate Accessibility Insights and Copilot in your workflow:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Install Accessibility Insights for Web&lt;/strong&gt; as a browser extension in Chrome or Edge. &lt;a href=&quot;https://accessibilityinsights.io/downloads&quot;&gt;Get it here.&lt;/a&gt; &lt;a href=&quot;https://accessibilityinsights.io/docs/web/overview/&quot;&gt;Docs.&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Review the issues found&lt;/strong&gt; by Accessibility Insights. Each issue comes with detailed guidance and links to relevant documentation. &lt;a href=&quot;https://accessibilityinsights.io/docs/web/getstarted/&quot;&gt;How to interpret results.&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Open your code editor (e.g., VS Code) with GitHub Copilot enabled.&lt;/strong&gt; &lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=GitHub.copilot&quot;&gt;Install Copilot.&lt;/a&gt; As you address flagged issues, Copilot can suggest code changes—such as adding ARIA attributes, improving semantic HTML, or fixing color contrast. &lt;a href=&quot;https://docs.github.com/en/copilot&quot;&gt;Copilot guides.&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Use Copilot’s inline suggestions&lt;/strong&gt; to quickly implement recommended fixes. You can ask Copilot for accessibility-specific help (e.g., “Add accessible label to this button”) or let it auto-complete as you code. For example, in TypeScript/React:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;tsx&quot;&gt;&lt;pre class=&quot;language-tsx&quot;&gt;&lt;code class=&quot;language-tsx&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Before&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;Submit&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Copilot suggestion for accessibility&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;aria-label&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;Submit form&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;Submit&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ol start=&quot;5&quot;&gt;
&lt;li&gt;&lt;strong&gt;Re-run Accessibility Insights&lt;/strong&gt; in your browser to verify that the issues are resolved. Repeat the process for continuous improvement.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Integrate both tools into your CI/CD pipeline&lt;/strong&gt; by using &lt;a href=&quot;https://github.com/microsoft/accessibility-insights-cli&quot;&gt;Accessibility Insights CLI&lt;/a&gt; and Copilot’s code review features, ensuring accessibility checks and fixes are part of every pull request. &lt;a href=&quot;https://github.com/microsoft/accessibility-insights-cli#usage&quot;&gt;See CLI usage.&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This workflow helps you catch, fix, and prevent accessibility issues early—making accessibility a seamless part of your development process.&lt;/p&gt;
&lt;h3 id=&quot;2-google-lighthouse--gemini&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#2-google-lighthouse--gemini&quot; aria-label=&quot;2 google lighthouse  gemini permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;2. Google Lighthouse + Gemini&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://developer.chrome.com/docs/lighthouse/accessibility/&quot;&gt;Google Lighthouse&lt;/a&gt; is an open-source tool for auditing web page quality, including accessibility. When paired with &lt;a href=&quot;https://deepmind.google/technologies/gemini&quot;&gt;Gemini&lt;/a&gt;, Google’s large language model, it can:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Summarize accessibility issues in plain English&lt;/li&gt;
&lt;li&gt;Suggest improvements tailored to your site’s content and audience&lt;/li&gt;
&lt;li&gt;Predict the impact of changes on real users&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;What it’s used for:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Quickly assess your site’s accessibility with automated reports and scoring, helping you spot and prioritize issues. (Adapted from &lt;a href=&quot;https://developer.chrome.com/docs/lighthouse/overview/&quot;&gt;Lighthouse docs&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Get plain-language explanations and actionable recommendations for each issue, powered by AI.&lt;/li&gt;
&lt;li&gt;Integrate with Chrome DevTools or your CI/CD pipeline for seamless, repeatable checks.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;How to integrate Google Lighthouse and Gemini in your workflow:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Install Google Lighthouse&lt;/strong&gt; as a &lt;a href=&quot;https://chrome.google.com/webstore/detail/lighthouse/blipmdconlkpinefehnmjammfjpmpbjk&quot;&gt;browser extension&lt;/a&gt; or use it directly in &lt;a href=&quot;https://developer.chrome.com/docs/devtools/accessibility/reference/&quot;&gt;Chrome DevTools&lt;/a&gt;. For more, see the &lt;a href=&quot;https://developer.chrome.com/docs/lighthouse/overview/&quot;&gt;official docs&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Run an audit and review the Lighthouse report.&lt;/strong&gt; Each finding comes with explanations and links to best practices. &lt;a href=&quot;https://developer.chrome.com/docs/lighthouse/accessibility/&quot;&gt;Accessibility audits with Lighthouse.&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Bring in Gemini (or your favorite LLM) for deeper insights:&lt;/strong&gt; Copy the Lighthouse report or specific issues and ask Gemini to break them down, explain, or suggest improvements tailored to your site’s content and audience. &lt;a href=&quot;https://deepmind.google/technologies/gemini&quot;&gt;Gemini overview.&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Put the AI’s advice into action.&lt;/strong&gt; For instance, Gemini might spot a vague button label and suggest something more descriptive in your React code:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;tsx&quot;&gt;&lt;pre class=&quot;language-tsx&quot;&gt;&lt;code class=&quot;language-tsx&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Before&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;Click here&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// Gemini’s suggestion for clarity (adapted from accessibility best practices)&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;aria-label&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;Download report&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;Download&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ol start=&quot;5&quot;&gt;
&lt;li&gt;&lt;strong&gt;Run Lighthouse again&lt;/strong&gt; to see if your fixes did the trick and if your accessibility score is climbing. Keep iterating for steady progress.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Level up your workflow by automating audits in CI/CD.&lt;/strong&gt; Use &lt;a href=&quot;https://github.com/GoogleChrome/lighthouse-ci&quot;&gt;Lighthouse CI&lt;/a&gt; to run checks on every deployment or pull request, and let Gemini help you interpret the results. &lt;a href=&quot;https://github.com/GoogleChrome/lighthouse-ci/blob/main/docs/getting-started.md&quot;&gt;Lighthouse CI docs.&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;em&gt;Feature descriptions and workflow steps paraphrased and adapted from &lt;a href=&quot;https://developer.chrome.com/docs/lighthouse/overview/&quot;&gt;Lighthouse documentation&lt;/a&gt;, &lt;a href=&quot;https://github.com/GoogleChrome/lighthouse-ci/blob/main/docs/getting-started.md&quot;&gt;Lighthouse CI docs&lt;/a&gt;, and &lt;a href=&quot;https://deepmind.google/technologies/gemini&quot;&gt;Gemini overview&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;This workflow lets you combine automated audits with AI-powered explanations, making accessibility improvements more practical and less mysterious.&lt;/p&gt;
&lt;h3 id=&quot;3-axe-by-deque&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#3-axe-by-deque&quot; aria-label=&quot;3 axe by deque permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;3. Axe by Deque&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://www.deque.com/axe/&quot;&gt;Axe&lt;/a&gt; is a suite of accessibility testing tools built on the open-source &lt;a href=&quot;https://github.com/dequelabs/axe-core&quot;&gt;axe-core&lt;/a&gt; library. Here’s what’s in the toolbox:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://www.deque.com/axe/devtools/&quot;&gt;Axe DevTools&lt;/a&gt;: Browser extensions for automated and guided accessibility testing&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.deque.com/axe/auditor/&quot;&gt;Axe Auditor&lt;/a&gt;: Manual testing for full WCAG coverage&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.deque.com/axe/monitor/&quot;&gt;Axe Monitor&lt;/a&gt;: Continuous monitoring and reporting&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/dequelabs/axe-core&quot;&gt;Axe-core API&lt;/a&gt;: Integrate accessibility checks into your automated test suites&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;What it’s used for:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Run quick automated scans or deep-dive manual audits, so you’re covered for both fast checks and full compliance reviews.&lt;/li&gt;
&lt;li&gt;Keep tabs on your site’s accessibility over time and make sure you’re always in line with the latest standards.&lt;/li&gt;
&lt;li&gt;Build accessibility checks right into your development and deployment pipelines for peace of mind.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;em&gt;Feature list and descriptions paraphrased and adapted from &lt;a href=&quot;https://www.deque.com/axe/&quot;&gt;Axe documentation&lt;/a&gt; and &lt;a href=&quot;https://github.com/dequelabs/axe-core&quot;&gt;axe-core GitHub&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;workflow-ai-driven-accessibility-in-action&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#workflow-ai-driven-accessibility-in-action&quot; aria-label=&quot;workflow ai driven accessibility in action permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Workflow: AI-Driven Accessibility in Action&lt;/h2&gt;
&lt;p&gt;Curious how all these tools and AI-powered features come together in practice? Here’s a quick overview of what a modern, automated accessibility workflow can look like. The following steps show how you can integrate accessibility checks, AI review, and team collaboration into your development process—making accessibility a seamless part of building and shipping great web experiences:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Continuous Integration:&lt;/strong&gt; Set up your CI pipeline to run automated accessibility checks on every pull request using tools like &lt;a href=&quot;https://github.com/dequelabs/axe-core&quot;&gt;axe-core&lt;/a&gt;, &lt;a href=&quot;https://accessibilityinsights.io/docs/web/overview/&quot;&gt;Accessibility Insights&lt;/a&gt;, or &lt;a href=&quot;https://developer.chrome.com/docs/lighthouse/accessibility/&quot;&gt;Lighthouse&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;AI Review:&lt;/strong&gt; Use Copilot or Gemini to review flagged issues, generate code suggestions, and explain the impact. See &lt;a href=&quot;https://docs.github.com/en/copilot/using-github-copilot/coding-agent/extending-copilot-coding-agent-with-mcp&quot;&gt;Copilot coding agent with MCP&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Team Collaboration:&lt;/strong&gt; Share AI-generated reports with designers, developers, and content creators for holistic improvements.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;User Testing:&lt;/strong&gt; Simulate diverse user journeys with AI to uncover edge cases and cognitive barriers (because everyone deserves a smooth ride).&lt;/li&gt;
&lt;/ol&gt;
&lt;hr&gt;
&lt;h2 id=&quot;looking-ahead-the-human--ai-partnership&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#looking-ahead-the-human--ai-partnership&quot; aria-label=&quot;looking ahead the human  ai partnership permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Looking Ahead: The Human + AI Partnership&lt;/h2&gt;
&lt;p&gt;AI is not a silver bullet (if only!). Some issues—like the emotional tone of content or the lived experience of neurodivergent users—still need a human touch. But by automating the repetitive and technical parts of accessibility, AI frees up your team to focus on what matters most: creating delightful, inclusive experiences for everyone.&lt;/p&gt;
&lt;h2 id=&quot;wrap-up&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#wrap-up&quot; aria-label=&quot;wrap up permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Wrap-Up&lt;/h2&gt;
&lt;p&gt;The future of web accessibility is bright—and a little more automated. By embracing AI-powered audits, we can build a web that’s not just compliant, but truly welcoming to all. As you explore these tools, remember: accessibility is a journey, not a checkbox. Let AI handle the heavy lifting, and let your team’s creativity and empathy shine.&lt;/p&gt;
&lt;p&gt;Happy coding, and happy (inclusive) building!&lt;/p&gt;
&lt;hr&gt;
&lt;blockquote&gt;
&lt;p&gt;“Accessibility allows us to tap into everyone’s potential.”&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;— &lt;a href=&quot;https://www.debraruh.com/&quot;&gt;Debra Ruh&lt;/a&gt;&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Ten Common Typescript Discriminated Union Examples]]></title><description><![CDATA[In this post we explore the marvelous world of Discriminated Unions in TypeScript. Discriminated Unions are a way to combine types that have…]]></description><link>https://www.codespud.com/2025/discriminated-unions-examples-typescript/</link><guid isPermaLink="false">https://www.codespud.com/2025/discriminated-unions-examples-typescript/</guid><pubDate>Sat, 08 Feb 2025 07:07:00 GMT</pubDate><content:encoded>&lt;p&gt;In this post we explore the marvelous world of Discriminated Unions in TypeScript.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Discriminated Unions&lt;/em&gt; are a way to combine types that have a common discriminant (usually a literal property) so that TypeScript can narrow down which type it’s dealing with. Let’s explore the 10 patterns that make these unions your coding sidekick!&lt;/p&gt;
&lt;p&gt;If you’re like me and learn better with sample code, then I won’t go into explaining what Discriminated Unions are anymore—let’s get straight to some examples.&lt;/p&gt;
&lt;h2 id=&quot;1-basic-discriminated-union&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#1-basic-discriminated-union&quot; aria-label=&quot;1 basic discriminated union permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;1. Basic Discriminated Union&lt;/h2&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;typescript&quot;&gt;&lt;pre class=&quot;language-typescript&quot;&gt;&lt;code class=&quot;language-typescript&quot;&gt;	&lt;span class=&quot;token keyword&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Circle&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; kind&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;circle&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; radius&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;number&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;token keyword&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Square&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; kind&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;square&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; side&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;number&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;token keyword&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Shape&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; Circle &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; Square&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	
	&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;getArea&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;shape&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; Shape&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;number&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
	  &lt;span class=&quot;token keyword&quot;&gt;switch&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;shape&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;kind&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
	    &lt;span class=&quot;token keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;circle&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;
	      &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; Math&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;PI&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; shape&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;radius &lt;span class=&quot;token operator&quot;&gt;**&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	    &lt;span class=&quot;token keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;square&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;
	      &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; shape&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;side &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; shape&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;side&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
	&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;em&gt;This pattern shows the simple yet powerful use of a common property (&lt;code class=&quot;language-text&quot;&gt;kind&lt;/code&gt;) to determine how to process each shape. This is the most common pattern for using Discriminated Unions. When your object has a common property that helps “discriminate” the “shape” of the object. Other common properties used are “type”, “status”, “responseType” etc.&lt;/em&gt;&lt;/p&gt;
&lt;h2 id=&quot;2--exhaustiveness-checking&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#2--exhaustiveness-checking&quot; aria-label=&quot;2  exhaustiveness checking permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;2.  Exhaustiveness Checking&lt;/h2&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;typescript&quot;&gt;&lt;pre class=&quot;language-typescript&quot;&gt;&lt;code class=&quot;language-typescript&quot;&gt;
	&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;assertNever&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;x&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;never&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;never&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
	  &lt;span class=&quot;token keyword&quot;&gt;throw&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Error&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Unexpected object: &quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; x&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
	
	&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;getArea&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;shape&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; Shape&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;number&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
	  &lt;span class=&quot;token keyword&quot;&gt;switch&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;shape&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;kind&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
	    &lt;span class=&quot;token keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;circle&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;
	      &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; Math&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;PI&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; shape&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;radius &lt;span class=&quot;token operator&quot;&gt;**&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	    &lt;span class=&quot;token keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;square&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;
	      &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; shape&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;side &lt;span class=&quot;token operator&quot;&gt;**&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	    &lt;span class=&quot;token keyword&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;
	      &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;assertNever&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;shape&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// Compiler will remind you if a new type is forgotten.&lt;/span&gt;
	  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
	&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;em&gt;This example ensures every case is handled. The &lt;code class=&quot;language-text&quot;&gt;assertNever&lt;/code&gt; function throws an exception if you introduce a new type that you have not defined. Use this pattern to safeguard against “oops” moments and future-proof your code as your union grows.&lt;/em&gt;&lt;/p&gt;
&lt;h2 id=&quot;3-handling-different-api-responses&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#3-handling-different-api-responses&quot; aria-label=&quot;3 handling different api responses permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;3. Handling Different API Responses&lt;/h2&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;typescript&quot;&gt;&lt;pre class=&quot;language-typescript&quot;&gt;&lt;code class=&quot;language-typescript&quot;&gt;
	&lt;span class=&quot;token keyword&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;APISuccess&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; kind&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;success&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; data&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;any&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;token keyword&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;APIError&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; kind&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;error&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; errorCode&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; message&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;token keyword&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;APIResponse&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; APISuccess &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; APIError&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	
	&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;handleResponse&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;response&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; APIResponse&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
	  &lt;span class=&quot;token keyword&quot;&gt;switch&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;response&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;kind&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
	    &lt;span class=&quot;token keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;success&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;
	      &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Data: &quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;JSON&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;stringify&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;response&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;data&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	    &lt;span class=&quot;token keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;error&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;
	      &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;Error &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;response&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;errorCode&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;response&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;message&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
	&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;em&gt;By using a discriminant (&lt;code class=&quot;language-text&quot;&gt;kind&lt;/code&gt;), this pattern cleanly separates successful responses from errors. Imagine it as the Avengers assembling to tackle any API threat—each with its own special move!&lt;/em&gt;&lt;/p&gt;
&lt;h2 id=&quot;4-handling-success-and-failure&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#4-handling-success-and-failure&quot; aria-label=&quot;4 handling success and failure permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;4. Handling Success and Failure&lt;/h2&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;typescript&quot;&gt;&lt;pre class=&quot;language-typescript&quot;&gt;&lt;code class=&quot;language-typescript&quot;&gt;
	&lt;span class=&quot;token keyword&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Success&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; status&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;success&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; data&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;T&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;token keyword&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Failure&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; status&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;failure&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; error&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;token keyword&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Result&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; Success&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; Failure&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	
	&lt;span class=&quot;token keyword&quot;&gt;interface&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;ChatResponse&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;ApiResponse&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
	
	&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;MyComponent&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;props&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; Readonly&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;IMyComponentProps&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;result&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; setResult&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token generic-function&quot;&gt;&lt;span class=&quot;token function&quot;&gt;useState&lt;/span&gt;&lt;span class=&quot;token generic class-name&quot;&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;Result&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;ChatResponse&lt;span class=&quot;token operator&quot;&gt;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; status&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;failure&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; error&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
		
		&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;fetchData&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
		  &lt;span class=&quot;token comment&quot;&gt;// Simulating an API call ...&lt;/span&gt;
		&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
		
		&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;handleFetchResult&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;response&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; Result&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;ChatResponse&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;		
			&lt;span class=&quot;token function&quot;&gt;setResult&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;response &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
		&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
		
		&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;result&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;status &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;success&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
		    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;SuccessfulFetchView data&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;result&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;data&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
		&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
		
		&lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;FailedFetchView error&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;result&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;error&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;*Here we use Discriminated Unions to elegantly handle both success and error outcomes and render the appropriate view.&lt;/p&gt;
&lt;h2 id=&quot;5-representing-ui-states&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#5-representing-ui-states&quot; aria-label=&quot;5 representing ui states permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;5. Representing UI States&lt;/h2&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;typescript&quot;&gt;&lt;pre class=&quot;language-typescript&quot;&gt;&lt;code class=&quot;language-typescript&quot;&gt;
	&lt;span class=&quot;token keyword&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;LoadingState&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; status&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;loading&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;token keyword&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;LoadedState&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; status&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;loaded&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; data&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;T&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;token keyword&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;ErrorState&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; status&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;error&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; message&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	
	&lt;span class=&quot;token keyword&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;UIState&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; LoadingState &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; LoadedState&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; ErrorState&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	
	&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token generic-function&quot;&gt;&lt;span class=&quot;token function&quot;&gt;getMessageText&lt;/span&gt;&lt;span class=&quot;token generic class-name&quot;&gt;&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;state&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; UIState&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
	  &lt;span class=&quot;token keyword&quot;&gt;switch&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;state&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;status&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
	    &lt;span class=&quot;token keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;loading&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;
	      &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Loading...&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	    &lt;span class=&quot;token keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;loaded&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;
	      &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;Data: &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;JSON&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;stringify&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;state&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;data&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	    &lt;span class=&quot;token keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;error&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;
	      &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;Error: &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;state&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;message&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
	&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;em&gt;This pattern leverages discriminated unions to manage different UI states. It’s like switching between your favorite streaming channels—each state brings a different vibe to the screen!&lt;/em&gt;&lt;/p&gt;
&lt;h2 id=&quot;6-navigating-nested-data-structures&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#6-navigating-nested-data-structures&quot; aria-label=&quot;6 navigating nested data structures permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;6. Navigating Nested Data Structures&lt;/h2&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;typescript&quot;&gt;&lt;pre class=&quot;language-typescript&quot;&gt;&lt;code class=&quot;language-typescript&quot;&gt;
	&lt;span class=&quot;token keyword&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;TreeNode&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; type&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;node&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; value&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; children&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; TreeNode&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;token keyword&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;LeafNode&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; type&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;leaf&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; value&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;number&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	
	&lt;span class=&quot;token keyword&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Tree&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; TreeNode &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; LeafNode&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	
	&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;sumTree&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;tree&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; Tree&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;number&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
	  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;tree&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;type &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;leaf&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
	    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; tree&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;value&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
	    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; tree&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;value &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; tree&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;children&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;reduce&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;sum&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; child&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; sum &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;sumTree&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;child&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
	&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;em&gt;This pattern shows how discriminated unions can power recursive data structures, like summing values in a tree. (Pattern adapted from the &lt;a href=&quot;https://www.typescriptlang.org/docs/handbook/advanced-types.html&quot;&gt;TypeScript Handbook&lt;/a&gt;.)&lt;/em&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;7--managing-different-events&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#7--managing-different-events&quot; aria-label=&quot;7  managing different events permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;7.  Managing Different Events&lt;/h2&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;typescript&quot;&gt;&lt;pre class=&quot;language-typescript&quot;&gt;&lt;code class=&quot;language-typescript&quot;&gt;
	&lt;span class=&quot;token keyword&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;ClickEvent&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; type&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;click&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; x&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; y&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;number&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;token keyword&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;KeyPressEvent&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; type&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;keypress&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; key&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;token keyword&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Event&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; ClickEvent &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; KeyPressEvent&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	
	&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;handleEvent&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;event&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; Event&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
	  &lt;span class=&quot;token keyword&quot;&gt;switch&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;event&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;type&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
	    &lt;span class=&quot;token keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;click&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;
	      &lt;span class=&quot;token builtin&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;Clicked at (&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;event&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;x&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;event&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;y&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	      &lt;span class=&quot;token keyword&quot;&gt;break&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	    &lt;span class=&quot;token keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;keypress&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;
	      &lt;span class=&quot;token builtin&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;Key pressed: &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;event&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;key&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	      &lt;span class=&quot;token keyword&quot;&gt;break&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
	&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;em&gt;Discriminated unions here allow you to handle different events with precision. (Pattern adapted from the &lt;a href=&quot;https://www.typescriptlang.org/docs/handbook/advanced-types.html&quot;&gt;TypeScript Handbook&lt;/a&gt;.) It’s like having a remote control that instantly switches channels—only, in this case, you’re switching event handlers!&lt;/em&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;8-representing-validation-states&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#8-representing-validation-states&quot; aria-label=&quot;8 representing validation states permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;8. Representing Validation States&lt;/h2&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;typescript&quot;&gt;&lt;pre class=&quot;language-typescript&quot;&gt;&lt;code class=&quot;language-typescript&quot;&gt;
	&lt;span class=&quot;token keyword&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;ValidForm&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; status&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;valid&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; values&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; Record&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;any&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;token keyword&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;InvalidForm&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; status&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;invalid&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; errors&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; Record&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	
	&lt;span class=&quot;token keyword&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;FormState&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; ValidForm &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; InvalidForm&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	
	&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;processForm&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;state&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; FormState&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
	  &lt;span class=&quot;token keyword&quot;&gt;switch&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;state&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;status&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
	    &lt;span class=&quot;token keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;valid&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;
	      &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Processing form with values: &quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;JSON&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;stringify&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;state&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;values&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	    &lt;span class=&quot;token keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;invalid&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;
	      &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Errors: &quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;JSON&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;stringify&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;state&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;errors&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
	&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;em&gt;This pattern utilizes discriminated unions to clearly represent whether a form is valid or not. It’s like having a Hogwarts sorting hat that instantly tells you if your form is magical (valid) or a muggle (invalid)!&lt;/em&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;9-handling-multiple-plugin-types&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#9-handling-multiple-plugin-types&quot; aria-label=&quot;9 handling multiple plugin types permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;9. Handling Multiple Plugin Types&lt;/h2&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;typescript&quot;&gt;&lt;pre class=&quot;language-typescript&quot;&gt;&lt;code class=&quot;language-typescript&quot;&gt;
	&lt;span class=&quot;token keyword&quot;&gt;interface&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;BasePlugin&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
	  type&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
	
	&lt;span class=&quot;token keyword&quot;&gt;interface&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;LoggerPlugin&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;BasePlugin&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
	  type&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;logger&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	  logLevel&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;debug&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;info&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;warn&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;error&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
	
	&lt;span class=&quot;token keyword&quot;&gt;interface&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;AuthPlugin&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;BasePlugin&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
	  type&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;auth&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	  provider&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
	
	&lt;span class=&quot;token keyword&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Plugin&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; LoggerPlugin &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; AuthPlugin&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	
	&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;initializePlugin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;plugin&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; Plugin&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
	  &lt;span class=&quot;token keyword&quot;&gt;switch&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;plugin&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;type&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
	    &lt;span class=&quot;token keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;logger&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;
	      &lt;span class=&quot;token builtin&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;Logger initialized with level &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;plugin&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;logLevel&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	      &lt;span class=&quot;token keyword&quot;&gt;break&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	    &lt;span class=&quot;token keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;auth&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;
	      &lt;span class=&quot;token builtin&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;Auth plugin using &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;plugin&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;provider&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	      &lt;span class=&quot;token keyword&quot;&gt;break&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
	&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;em&gt;Here, discriminated unions help manage various plugin types within an architecture. Think of it as assembling your own tech-savvy Justice League where every plugin has a specific role to play!&lt;/em&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;10-streamlining-command-execution&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#10-streamlining-command-execution&quot; aria-label=&quot;10 streamlining command execution permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;10. Streamlining Command Execution&lt;/h2&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;typescript&quot;&gt;&lt;pre class=&quot;language-typescript&quot;&gt;&lt;code class=&quot;language-typescript&quot;&gt;
	&lt;span class=&quot;token keyword&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;CreateCommand&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; type&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;create&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; payload&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; User &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;token keyword&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;UpdateCommand&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; type&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;update&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; id&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; payload&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; User &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;token keyword&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;DeleteCommand&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; type&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;delete&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; id&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;number&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	
	&lt;span class=&quot;token keyword&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Command&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; CreateCommand &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; UpdateCommand &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; DeleteCommand&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
	
	&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;execute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;command&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; Command&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; DbResponse &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
	  &lt;span class=&quot;token keyword&quot;&gt;switch&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;command&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;type&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
	    &lt;span class=&quot;token keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;create&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;
	      &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; db&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;query&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;sql&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;payload&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; command&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;payload &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; 
	    &lt;span class=&quot;token keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;update&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;
	      &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; db&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;query&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;sql&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;id&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; command&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; payload&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; command&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;payload &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; 	
	    &lt;span class=&quot;token keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;delete&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;
	      &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; db&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;query&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;sql&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;id&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; command&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; 	
	  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
	&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;*In this pattern, discriminated unions simplify the handling of different commands, ensuring that each command is executed correctly. It’s akin to having a Swiss Army knife of commands, ready to take on any task with precision! *&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;when-to-use-discriminated-unions&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#when-to-use-discriminated-unions&quot; aria-label=&quot;when to use discriminated unions permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;When to use Discriminated Unions&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Do you have multiple related types that share common fields?&lt;/li&gt;
&lt;li&gt;Do the types have a clear “kind” or “type” discriminator?&lt;/li&gt;
&lt;li&gt;Do you need type safety in switch or if-else checks?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you answered yes to all the questions, use a Discriminated Union. If you answered no to any of the questions, you may need to consider a different pattern.&lt;/p&gt;
&lt;h1 id=&quot;wrap-up&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#wrap-up&quot; aria-label=&quot;wrap up permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Wrap-Up&lt;/h1&gt;
&lt;p&gt;Discriminated unions are another TypeScript feature to help you write robust, maintainable code. By clearly defining each possible state or variant, you can avoid runtime errors and make your code self-documenting, just like a well-curated 80’s playlist. As you experiment with these patterns, explore further resources like the &lt;a href=&quot;https://www.typescriptlang.org/docs/handbook/advanced-types.html&quot;&gt;TypeScript Handbook on Advanced Types&lt;/a&gt; and &lt;a href=&quot;https://basarat.gitbook.io/typescript/&quot;&gt;TypeScript Deep Dive&lt;/a&gt; to continue your journey.&lt;/p&gt;
&lt;p&gt;Happy coding!&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Using Container Queries to Make a News Layout]]></title><description><![CDATA[When I hear media query I think about a bottle filled with liquids that don’t mix (e.g. oil and water). The content(water/oil) will assume…]]></description><link>https://www.codespud.com/2023/using-container-queries-news-layout/</link><guid isPermaLink="false">https://www.codespud.com/2023/using-container-queries-news-layout/</guid><pubDate>Fri, 24 Feb 2023 08:07:00 GMT</pubDate><content:encoded>&lt;p&gt;When I hear media query I think about a bottle filled with liquids that don’t mix (e.g. oil and water). The content(water/oil) will assume the shape and size of the container (bottle). I will not bore you with “science-sy” stuff but some predetermined properties of these liquids define how they exist inside the bottle. Oil is lighter than water so it floats etc. But ultimately they are governed by their single container. You can’t make the oil shaped as a globe float inside of the region of water occupies. What if you have a glass sphere to contain the oil? Then made it so it is suspended inside the bottle? That is what container queries do for CSS. Container queries become the smaller glass container inside the bottle. Then your content can then follow the rules of that smaller container instead of depending on the rules of one bottle. This will allow you more flexibility in styling layouts.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Container queries enable you to apply styles to an element based on the size of the element’s container. If, for example, a container has less space available in the surrounding context, you can hide certain elements or use smaller fonts.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Container_Queries&quot;&gt;MDN: Css Container queries&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;p&gt;For years, developers like me have asked for a better way of styling website elements, especially on where or how they are contained in a site. Media queries have their uses but they don’t help much if you want to make reusable independent components. Media queries are better suited for setting up page layouts. The dream is to have a UI element - drop it anywhere on the site and it reconfigures itself based on where and how the container is configured. Because you are using the container dimensions and not the viewport you can more accurately bake in the styling of a reusable element based on what available space the parent element has and not how wide the browser viewport is showing. Imagine the glass sphere in the bottle analogy earlier. Oil is the UI element and the glass sphere is the parent container. The UI element will not care how the rest of the page is configured. Only on how its parent is configured. To achieve this in the past developers resorted to JavaScript. You know how I hate adding more scripts to a page. Sometimes the convenience does not justify the added library size.&lt;/p&gt;
&lt;p&gt;This is where container queries come in. They are the solution we’ve been asking for all along.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Some technical explanations and code patterns in this post are based on the &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Container_Queries&quot;&gt;MDN documentation on CSS Container Queries&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;h2 id=&quot;how-to-do-container-queries&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#how-to-do-container-queries&quot; aria-label=&quot;how to do container queries permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;How to do container queries&lt;/h2&gt;
&lt;p&gt;There are two steps to doing container queries.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Make a wrapper element and setup &lt;code class=&quot;language-text&quot;&gt;container&lt;/code&gt; property&lt;/li&gt;
&lt;li&gt;Define styles in container query&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&quot;1-make-a-wrapper-element-and-setup-container-property&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#1-make-a-wrapper-element-and-setup-container-property&quot; aria-label=&quot;1 make a wrapper element and setup container property permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;1. Make a wrapper element and setup &lt;code class=&quot;language-text&quot;&gt;container&lt;/code&gt; property&lt;/h3&gt;
&lt;p&gt;To start using container queries, we first define a container or wrapper element with a &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/container-type&quot;&gt;container type&lt;/a&gt;.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;scss&quot;&gt;&lt;pre class=&quot;language-scss&quot;&gt;&lt;code class=&quot;language-scss&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.section-container &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;container&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; my-container &lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt; inline-size&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In the CSS above, we are using the shorthand way of defining a container. The first value is the name we want to identify the container query the second value is the container type. It is equivalent to the CSS below.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;scss&quot;&gt;&lt;pre class=&quot;language-scss&quot;&gt;&lt;code class=&quot;language-scss&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.section-container &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;container-name&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; my-container&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;container-type&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; inline-size&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3 id=&quot;2-define-styles-in-container-query&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#2-define-styles-in-container-query&quot; aria-label=&quot;2 define styles in container query permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;2. Define styles in container query&lt;/h3&gt;
&lt;p&gt;A container query is similar to that a media query.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;scss&quot;&gt;&lt;pre class=&quot;language-scss&quot;&gt;&lt;code class=&quot;language-scss&quot;&gt;
&lt;span class=&quot;token atrule&quot;&gt;&lt;span class=&quot;token rule&quot;&gt;@container&lt;/span&gt; my-container &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token property&quot;&gt;min-width&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 800px&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// style here&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;These are the very minimum things you need to learn to use container queries. There are other things to know &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Container_Queries#container_query_length_units&quot;&gt;container units&lt;/a&gt; - I will leave that for a later post.&lt;/p&gt;
&lt;h2 id=&quot;the-experiment&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#the-experiment&quot; aria-label=&quot;the experiment permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;The experiment&lt;/h2&gt;
&lt;p&gt;To understand container queries better I did made an experiment. My idea was to create a news layout where the content is a bunch of cards with the same markup and content. Depending on how the container is configured the news cards will show in different ways.&lt;/p&gt;
&lt;p&gt;I made a wireframe with the following:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Full-width hero card on top&lt;/li&gt;
&lt;li&gt;A medium-sized news card&lt;/li&gt;
&lt;li&gt;A news list with multiple content&lt;/li&gt;
&lt;li&gt;A grid with multiple contents&lt;/li&gt;
&lt;/ol&gt;
&lt;img src=&quot;/blog/container-experiment.png&quot; alt=&quot;wireframe of news layout&quot;&gt;
&lt;p&gt;I’ve configured the cards in the wireframe to show in different styles. For the full-width top section “stage”, I want the card to show as a hero element. In the medium “stage”, the card would look like a wide news card. With the news list stage, I placed multiple cards that will show as a text list with no images. In the final grid “stage”, I wanted to show a news grid with multiple cards.&lt;/p&gt;
&lt;p&gt;Also not to forget, on smaller screens(e.g. mobile) all the cards will show as one column card grid.&lt;/p&gt;
&lt;p&gt;Remember that all these cards have the same markup. Imagine you have a server-side rendered(SSR) endpoint that returns an array of cards with similar markup sorted by descending date(e.g news post). Then you just drop all this content in different containers until you fill the layout. No need to cherry pick the data and render to different locations.&lt;/p&gt;
&lt;p&gt;Check the pen here for a demo.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://codepen.io/chrisbautista/pen/vYaxdXr&quot;&gt;&lt;div&gt;&lt;iframe 
        height=&apos;400&apos; 
        scrolling=&apos;no&apos; 
        src=&apos;//codepen.io/chrisbautista/embed/preview/vYaxdXr/?height=400&amp;theme-id=dark&amp;default-tab=html,result&apos; 
        frameborder=&apos;no&apos; 
        allowtransparency=&apos;true&apos; 
        allowfullscreen=&apos;true&apos; 
        style=&apos;width: 100%;&apos;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;what-i-learned&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#what-i-learned&quot; aria-label=&quot;what i learned permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;What I learned&lt;/h2&gt;
&lt;p&gt;Doing the experiment I learned a few things. It is easy to start using container query after you get through the initial confusion in learning to think in containers.  Once you get used to thinking in container queries you’ll be amazed. I was thinking it would be great if we had this a decade ago when we were building our layout editor.😀&lt;/p&gt;
&lt;p&gt;You are not limited to querying width. If we use &lt;code class=&quot;language-text&quot;&gt;container-type: size&lt;/code&gt; we can use the container height when defining a container query block. Using height opens up more possibilities when doing layouts. For example, I made the news list text wall by using the height of the container to tell the news card to only render the text and hide the images. In some way, I made my news cards smarter. Before the container query era, I had to do some complicated CSS class combinations to achieve the same thing or worse yet use JavaScript.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;scss&quot;&gt;&lt;pre class=&quot;language-scss&quot;&gt;&lt;code class=&quot;language-scss&quot;&gt;
&lt;span class=&quot;token selector&quot;&gt;.stage &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;container-name&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; stage&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;container-type&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; size&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token atrule&quot;&gt;&lt;span class=&quot;token rule&quot;&gt;@container&lt;/span&gt; stage &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;width &lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; 768px&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;and&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;height = 1000px&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token selector&quot;&gt;.card &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;calc&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;100% &lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt; 3&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id=&quot;wrapping-up&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#wrapping-up&quot; aria-label=&quot;wrapping up permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Wrapping up&lt;/h2&gt;
&lt;p&gt;Container queries are another great tool in a web developer’s toolbelt. I would recommend spending some time learning the basics and how it interacts with layout-specific CSS like flexbox and grids. I would also suggest spending time learning the differences between container types and how to use container units.&lt;/p&gt;
&lt;p&gt;Cheers!&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Automatically generate skip buttons to improve accessibility]]></title><description><![CDATA[Another common accessibility tool is the skip button. It comes in different forms. It would sometimes be smartly included in the design or hidden until needed.]]></description><link>https://www.codespud.com/2023/skip-button-js/</link><guid isPermaLink="false">https://www.codespud.com/2023/skip-button-js/</guid><pubDate>Fri, 17 Feb 2023 12:07:00 GMT</pubDate><content:encoded>&lt;p&gt;Another common accessibility tool is the skip button. It comes in different forms. It would sometimes be smartly included in the design or hidden until needed. &lt;!--more--&gt;  Whatever form skip buttons allow users to bypass sections of content to make it easier to navigate websites. Adding ways to bypass content is part of the &lt;a href=&quot;https://www.w3.org/WAI/WCAG21/quickref/?versions=2.0#qr-navigation-mechanisms-skip&quot;&gt;WCAG accessibility guidelines: Bypass blocks&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;problem&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#problem&quot; aria-label=&quot;problem permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Problem&lt;/h2&gt;
&lt;p&gt;I recently got a complaint from a screen reader user that some UI/widget on a client site was terrible to navigate through. Widely used screen readers like JAWS, NVDA or Voiceover have a feature to navigate based on common semantic tags like headings (h1, h2, h3, etc.) or links. In the case of the broken UI control, it has quite a lot of headings and links in the content. So when the screen reader tried to use the navigation shortcut for headings. It still included the headings in the UI control.&lt;/p&gt;
&lt;h2 id=&quot;solution&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#solution&quot; aria-label=&quot;solution permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Solution&lt;/h2&gt;
&lt;p&gt;To fix the issue we had two options. One(1) is to re-work the widget to remove the headings and use links instead. This required quite a bit of refactoring and testing. The effort is not worth the benefit. The second(2) option is to add skip buttons. We opted for the second option.&lt;/p&gt;
&lt;p&gt;Now when the screen reader or keyboard user navigates through the widget they will first encounter the skip button which they can activate to jump to the next section or ignore to continue through the widget. For the previous solution, we hard-coded the skip buttons as part of the design.&lt;/p&gt;
&lt;p&gt;The demo below shows code to generate skip buttons. The way it works is the developer provides a list of tags and selectors you want to skip. These can be blocks of content or sections that are quite difficult to navigate through like navigation, forms, etc.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;javascript&quot;&gt;&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; nodesToSkip &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelectorAll&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot; header .demo-header, aside .links, section&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Next, the code loops thru these sections and adds skip buttons. When the button is focused and activated( using the &lt;key&gt;Enter&lt;/key&gt; key ), the focus jumps to the next section or focusable element. When you navigate to the last section there is no skip button cause there is no section to jump to next.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://codepen.io/chrisbautista/pen/zYJLQRp&quot;&gt;&lt;div&gt;&lt;iframe 
        height=&apos;400&apos; 
        scrolling=&apos;no&apos; 
        src=&apos;//codepen.io/chrisbautista/embed/preview/zYJLQRp/?height=400&amp;theme-id=dark&amp;default-tab=html,result&apos; 
        frameborder=&apos;no&apos; 
        allowtransparency=&apos;true&apos; 
        allowfullscreen=&apos;true&apos; 
        style=&apos;width: 100%;&apos;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;In this demo, I opted to focus on sections but it is easy to tweak the code to focus on the next focusable element like a button or input control instead. As a bonus, whenever a section has a heading(h2) or title, the generated button text will use the heading/title text to further improve recognition.&lt;/p&gt;
&lt;h2 id=&quot;wrapping-up&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#wrapping-up&quot; aria-label=&quot;wrapping up permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Wrapping up&lt;/h2&gt;
&lt;p&gt;Skip buttons are a powerful tool for improving accessibility. They provide greater control over users’ experience navigating through websites. Feel free to reuse the code provided to generate skip buttons in your projects. Your users and customers will thank you.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[CSS Snippets I Use 90% of The Time - Part 2]]></title><description><![CDATA[This is part 2 of CSS snippets I used 90% of the time post. As promised this is second part of CSS styles I commonly used with my projects. If you are going to think of a rule I’d say this is my 80/20 rule for CSS.]]></description><link>https://www.codespud.com/2023/most-used-css-patterns-part-2/</link><guid isPermaLink="false">https://www.codespud.com/2023/most-used-css-patterns-part-2/</guid><pubDate>Thu, 09 Feb 2023 12:22:00 GMT</pubDate><content:encoded>&lt;!--

Part 2
- centered child
- modal overlay
- text truncate
   - line
   - multiline
- card container
- fullscreen image

Part 3
- news layout
- 2 column layout
- grid layout
- z layout
- f layout 


angle

I love CSS
I hate repeating myself
I am hoarder

--&gt;
&lt;blockquote&gt;
&lt;p&gt;This is part 2 of &lt;a href=&quot;/most-used-css-patterns&quot;&gt;CSS snippets I used 90% of the time&lt;/a&gt; post.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;As promised this is second part of CSS styles I commonly used with my projects. If you are going to think of a rule I’d say this is my 80/20 rule for CSS. &lt;!--more--&gt; I have a common set patterns when designing and building sites. The rest depends on what the client needs.&lt;/p&gt;
&lt;p&gt;The list this time are of interactive and UI elements used on of my recent projects.&lt;/p&gt;
&lt;h2 id=&quot;create&quot;&gt;Centering an element in a box&lt;/h2&gt;
&lt;p&gt;There are a lot ways to &lt;a href=&quot;https://css-tricks.com/centering-css-complete-guide/&quot;&gt;center an element&lt;/a&gt; but in 8 out 10 projects I use only two styles when I need to center an element in a box. I keep two styles because it depends on the circumstance.&lt;/p&gt;
&lt;h3 id=&quot;using-flex&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#using-flex&quot; aria-label=&quot;using flex permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Using flex&lt;/h3&gt;
&lt;p&gt;I use this if I can use &lt;code class=&quot;language-text&quot;&gt;display:flex&lt;/code&gt; mostly because flexbox is well “flexible”. Most of the time I need to center more than one item so wrapping is a concern. Flexbox is very good with this.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;scss&quot;&gt;&lt;pre class=&quot;language-scss&quot;&gt;&lt;code class=&quot;language-scss&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// source CSS Tricks&lt;/span&gt;
&lt;span class=&quot;token selector&quot;&gt;.parent &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;token property&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; flex&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;token property&quot;&gt;justify-content&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; center&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;token property&quot;&gt;align-items&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; center&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

   &lt;span class=&quot;token comment&quot;&gt;// define dimensions of the box&lt;/span&gt;
   &lt;span class=&quot;token property&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 100vw&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;token property&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 100vh&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; 

&lt;span class=&quot;token selector&quot;&gt;.child &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;token comment&quot;&gt;//...&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;parent&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
   &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;centered-child&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; Child element &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This will center an element inside the box. Another good thing about using this technique is your element is in the normal document flow except when adding &lt;code class=&quot;language-text&quot;&gt;order&lt;/code&gt; property to child elements. If you are concerned with accessibility this is very important to remember. Using &lt;a href=&quot;https://webaim.org/blog/flexbox-and-the-screen-reader-experience/&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;order&lt;/code&gt; to arrange flex elements is discouraged&lt;/a&gt; because they break the &lt;a href=&quot;https://www.w3.org/WAI/WCAG21/Understanding/meaningful-sequence&quot;&gt;reading order&lt;/a&gt; of the elements.&lt;/p&gt;
&lt;h3 id=&quot;absolute-positioning&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#absolute-positioning&quot; aria-label=&quot;absolute positioning permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Absolute positioning&lt;/h3&gt;
&lt;p&gt;I use this next style if I can’t use flexbox and/or I need dynamic element like a modal. Another reason I might use this style is if I can’t touch the parent style since the all the positioning style is in the child element.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;scss&quot;&gt;&lt;pre class=&quot;language-scss&quot;&gt;&lt;code class=&quot;language-scss&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Source CSS Tricks&lt;/span&gt;
&lt;span class=&quot;token selector&quot;&gt;.parent &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;position&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; relative&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;.modal &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;position&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; absolute&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;top&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 50%&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;left&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 50%&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;transform&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;translate&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;-50%&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; -50%&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token comment&quot;&gt;//...&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;parent&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;modal&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    This is a modal
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id=&quot;overlay&quot;&gt; Overlay &lt;/h2&gt;
&lt;p&gt;Overlays are another UI pattern I use a lot. They are great for preventing mouse input where you don’t want it, giving contrast to an element, and goes great with modals. Before I needed to use javascript to add the overlay as we want to know when the modal is visible in the parent. I accomplish that by adding a &lt;code class=&quot;language-text&quot;&gt;.has-modal&lt;/code&gt; class in the parent when modal is visible.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;parent has-modal&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;modal&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    This is a modal
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;scss&quot;&gt;&lt;pre class=&quot;language-scss&quot;&gt;&lt;code class=&quot;language-scss&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.parent &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;position&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; relative&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;.modal &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;position&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; absolute&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;top&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 50%&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;left&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 50%&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;transform&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;translate&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;-50%&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; -50%&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token comment&quot;&gt;//...&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// overlay&lt;/span&gt;
&lt;span class=&quot;token selector&quot;&gt;.parent.has-modal:before  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos; &apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;position&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; absolute&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;top&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;left&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 100vw&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 100vh&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;background-color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;rgba&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;0&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;0&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;0&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;0.3&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now we can do away with that and use &lt;code class=&quot;language-text&quot;&gt;:has&lt;/code&gt; selector.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;parent&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;modal&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    This is a modal
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;scss&quot;&gt;&lt;pre class=&quot;language-scss&quot;&gt;&lt;code class=&quot;language-scss&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// overlay&lt;/span&gt;
.&lt;span class=&quot;token property&quot;&gt;parent&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;has&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;.modal&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token selector&quot;&gt;:before  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos; &apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;position&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; absolute&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;top&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;left&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 100vw&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 100vh&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;background-color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;rgba&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;0&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;0&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;0&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;0.3&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Check out the demo to see the styles in action.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://codepen.io/chrisbautista/pen/WNgQRQE&quot;&gt;&lt;div&gt;&lt;iframe 
        height=&apos;400&apos; 
        scrolling=&apos;no&apos; 
        src=&apos;//codepen.io/chrisbautista/embed/preview/WNgQRQE/?height=400&amp;theme-id=dark&amp;default-tab=html,result&apos; 
        frameborder=&apos;no&apos; 
        allowtransparency=&apos;true&apos; 
        allowfullscreen=&apos;true&apos; 
        style=&apos;width: 100%;&apos;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Note that the overlay only prevents mouse input to the elements underneath the overlay. It will not stop keyboard users from tabbing into elements. This is not good for accessibility. We can fix this looping through the elements that need to be ignored and add &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert&quot;&gt;inert&lt;/a&gt;.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;javascript&quot;&gt;&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;//e.g&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; focusableElements &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; Array&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelectorAll&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;:not(.modal) a, :not(.modal) button, input, :not(.modal) [contentEditable],:not(.modal)  [tabindex]:not([tabindex=-1])&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

focusableElements&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;forEach&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;el&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
el&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setAttribute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;inert&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id=&quot;truncaste&quot;&gt;Truncate text&lt;/h2&gt;
&lt;p&gt;There will be times you want to truncate a large amount of text. It could be to improve a design and optimize the space or just to indicate you have more information and you want to signal the user to dig some more. Whatever reason its good to have a handy CSS class you can use to do the truncation for you.&lt;/p&gt;
&lt;p&gt;Below is the markup we are going to use for truncation classes.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt; &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;truncate-demo&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum laoreet a nisi quis lacinia. Pellentesque sit amet mauris ac nunc pellentesque dignissim a at quam. Aliquam pulvinar nulla sit amet ligula malesuada luctus a et mauris. Maecenas in mauris massa. Proin sit amet tellus a ipsum hendrerit varius. Sed eleifend odio vitae magna gravida mollis. Aenean massa ipsum, vehicula in enim gravida, tempus tempus arcu. Nullam porta nisi vitae sem fringilla, ut tristique neque dapibus. Cras commodo nunc non elit lobortis, at pretium elit efficitur. Etiam condimentum varius rutrum.&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;scss&quot;&gt;&lt;pre class=&quot;language-scss&quot;&gt;&lt;code class=&quot;language-scss&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.truncate-demo &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 100%&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;border&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 2px solid #d3d3d3&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 8px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3 id=&quot;one-line-truncation&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#one-line-truncation&quot; aria-label=&quot;one line truncation permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;One-line truncation&lt;/h3&gt;
&lt;p&gt;For one line truncation, the trick is use the CSS property &lt;code class=&quot;language-text&quot;&gt;text-overflow&lt;/code&gt;. Whether its one-line or multiline, you need to first set the boundaries of the text container, in the case of a onle truncate its the width of the container. After that set make sure nothing bleeds out of the container by setting &lt;code class=&quot;language-text&quot;&gt;overflow:hidden&lt;/code&gt;.&lt;/p&gt;
&lt;style&gt;

.one-line {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.truncate-demo {
  width: 100%;
  border: 2px solid #d3d3d3;
  padding: 8px;
}

&lt;/style&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;scss&quot;&gt;&lt;pre class=&quot;language-scss&quot;&gt;&lt;code class=&quot;language-scss&quot;&gt;
&lt;span class=&quot;token selector&quot;&gt;.one-line &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;white-space&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; nowrap&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;overflow&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; hidden&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;text-overflow&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; ellipsis&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;.truncate-demo &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 100%&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;border&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 2px solid #d3d3d3&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 8px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;demo&quot;&gt;
 &lt;div class=&quot;one-line truncate-demo&quot;&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum laoreet a nisi quis lacinia. Pellentesque sit amet mauris ac nunc pellentesque dignissim a at quam. Aliquam pulvinar nulla sit amet ligula malesuada luctus a et mauris. Maecenas in mauris massa. Proin sit amet tellus a ipsum hendrerit varius. Sed eleifend odio vitae magna gravida mollis. Aenean massa ipsum, vehicula in enim gravida, tempus tempus arcu. Nullam porta nisi vitae sem fringilla, ut tristique neque dapibus. Cras commodo nunc non elit lobortis, at pretium elit efficitur. Etiam condimentum varius rutrum.&lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&quot;multiline-truncation&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#multiline-truncation&quot; aria-label=&quot;multiline truncation permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Multiline truncation&lt;/h3&gt;
&lt;p&gt;For multiline truncation its a bit different but the same principle. For this we need to use &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-line-clamp&quot;&gt;line clamping&lt;/a&gt;.&lt;/p&gt;
&lt;style&gt;

.three-line {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}

&lt;/style&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;scss&quot;&gt;&lt;pre class=&quot;language-scss&quot;&gt;&lt;code class=&quot;language-scss&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.three-line &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; -webkit-box&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;-webkit-box-orient&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; vertical&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;-webkit-line-clamp&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 3&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;overflow&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; hidden&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;demo&quot;&gt;
 &lt;div class=&quot;three-line truncate-demo&quot;&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum laoreet a nisi quis lacinia. Pellentesque sit amet mauris ac nunc pellentesque dignissim a at quam. Aliquam pulvinar nulla sit amet ligula malesuada luctus a et mauris. Maecenas in mauris massa. Proin sit amet tellus a ipsum hendrerit varius. Sed eleifend odio vitae magna gravida mollis. Aenean massa ipsum, vehicula in enim gravida, tempus tempus arcu. Nullam porta nisi vitae sem fringilla, ut tristique neque dapibus. Cras commodo nunc non elit lobortis, at pretium elit efficitur. Etiam condimentum varius rutrum.&lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&quot;fullscreenimage&quot;&gt;Fullscreen background image&lt;/h2&gt;
&lt;p&gt;Fullscreen background images have been a constant mainstay in my projects. The trend started in the late 2000s, popularized by Apple’s website featuring the Iphone. Nowadays, most websites especially those in marketing, creative or business websites will have a fullscreen image background or a large image style as “above the fold”. Be careful with this depending on the image you may impact the speed at which your site loads.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;scss&quot;&gt;&lt;pre class=&quot;language-scss&quot;&gt;&lt;code class=&quot;language-scss&quot;&gt;
&lt;span class=&quot;token selector&quot;&gt;body &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;background-image&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token url&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;path/to/background.png&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;background-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; cover&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;background-repeat&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; no-repeat&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;background-position&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; center center&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 100vh&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;margin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The key part here that enables fullscreen images is &lt;code class=&quot;language-text&quot;&gt;background-size:cover&lt;/code&gt;.  Setting &lt;code class=&quot;language-text&quot;&gt;cover&lt;/code&gt; to &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/background-size&quot;&gt;background-size&lt;/a&gt; resizes your image to “cover” most of the container without stretching or skewing the image.&lt;/p&gt;
&lt;h2 id=&quot;wrapping-up&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#wrapping-up&quot; aria-label=&quot;wrapping up permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Wrapping up&lt;/h2&gt;
&lt;p&gt;Having a quick reference for common frontend work is a good way to improve your workflow. Hope these list of CSS styles will be of use to you. I recommend installing a snippet library so its available when you need it.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Five common Javascript mistakes I am guilty of]]></title><description><![CDATA[Errors in code are normal. That is why we have a whole branch of the IT industry dedicated to quality assurance and testing. Javascript is the easiest programming language to learn, but it is also the easiest to get wrong. Javascript is a very forgiving programming language. As a result, Javascript code can be prone to errors.]]></description><link>https://www.codespud.com/2023/five-common-javascript-mistakes/</link><guid isPermaLink="false">https://www.codespud.com/2023/five-common-javascript-mistakes/</guid><pubDate>Thu, 02 Feb 2023 07:07:00 GMT</pubDate><content:encoded>&lt;!--

problem: Javascript errors that trip most programmers

1. For in vs For out
2. Equality in array function
3. == vs ===
4. scope
5. Events and this

--&gt;
&lt;p&gt;Errors in code are normal. That is why we have a whole branch of the IT industry dedicated to quality assurance and testing. Javascript is the easiest programming language to learn, but it is also the easiest to get wrong. Javascript is a very forgiving programming language. As a result, Javascript code can be prone to errors. &lt;!--more--&gt;&lt;/p&gt;
&lt;p&gt;In this post, I will list some of the mistakes I’ve encountered coding in Javascript.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;./#equality&quot;&gt;Misunderstanding “const”&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;./#equality&quot;&gt;Strict vs Loose Equality&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;./#assignment&quot;&gt;Assignment vs Equality&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;./#forof&quot;&gt;For…of vs For…in&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;./#this&quot;&gt;Event handlers and proper use of “this”&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;const&quot;&gt;Misunderstanding &quot;const&quot;&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;The const declaration creates a read-only reference to a value. It does not mean the value it holds is immutable—just that the variable identifier cannot be reassigned.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const&quot;&gt;MDN&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;p&gt;One mistake I keep repeating is forgetting that defining an object with &lt;code class=&quot;language-text&quot;&gt;const&lt;/code&gt; does not prevent the contents from mutation. &lt;code class=&quot;language-text&quot;&gt;Const&lt;/code&gt; only prevents the variable from being reassigned.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; i &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; myObject &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token literal-property property&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; myArray &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;

  i &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; i &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// TypeError: Assignment to constant variable &lt;/span&gt;

  myObject&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;a &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; myObject&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;a &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// {a: 2, b: 2};&lt;/span&gt;
  myObject &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token literal-property property&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// TypeError: Assignment to constant variable&lt;/span&gt;

  myArray&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// [2, 1, 2, 3]&lt;/span&gt;
  myArray &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// TypeError: Assignment to constant variable&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This means you can update the contents of an object or array. This is legal because we are not acting on the reference. This is more confusing than problematic. As you can just change the declaration with &lt;code class=&quot;language-text&quot;&gt;let&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Rather than keep making this mistake and avoid confusion, I use &lt;code class=&quot;language-text&quot;&gt;let&lt;/code&gt; to define variables all the time even for magic values. I think &lt;code class=&quot;language-text&quot;&gt;const&lt;/code&gt; is not worth the confusion it causes.&lt;/p&gt;
&lt;h2 id=&quot;equality&quot;&gt;Strict vs Loose Equality&lt;/h2&gt;
&lt;p&gt;As a javascript developer, I have learned to always use strict equality (&lt;code class=&quot;language-text&quot;&gt;===&lt;/code&gt;). Most javascript programmers will tell you to follow that rule. If you come from a C-based language like C# or C++, you are probably more familiar with double equals(&lt;code class=&quot;language-text&quot;&gt;==&lt;/code&gt;) than strict equality. I am guilty of this mistake, especially when switching the coding context between the frontend(&lt;code class=&quot;language-text&quot;&gt;Javascript&lt;/code&gt;) and the backend(&lt;code class=&quot;language-text&quot;&gt;C#&lt;/code&gt;). The mistake is easily remedied but hard to trace especially in a massive codebase. The difference is that (loose) equality (== and !=) will try to force type conversion when comparing two values. Sometimes this is not what we want.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;javascript&quot;&gt;&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;
&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; foo &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; bar &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;1&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

foo &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; bar &lt;span class=&quot;token comment&quot;&gt;// true&lt;/span&gt;
foo &lt;span class=&quot;token operator&quot;&gt;!=&lt;/span&gt; bar &lt;span class=&quot;token comment&quot;&gt;// false&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This is not the case for strict equality(=== and !==). Strict equality checks will never apply type conversion and test the two values directly. If two values are not of the same data type the test fails.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;javascript&quot;&gt;&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;
&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; foo &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; bar &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;1&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; der &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

foo &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; bar &lt;span class=&quot;token comment&quot;&gt;// false&lt;/span&gt;
foo &lt;span class=&quot;token operator&quot;&gt;!==&lt;/span&gt; bar &lt;span class=&quot;token comment&quot;&gt;// true&lt;/span&gt;

foo &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; der &lt;span class=&quot;token comment&quot;&gt;// true&lt;/span&gt;
foo &lt;span class=&quot;token operator&quot;&gt;!==&lt;/span&gt; der &lt;span class=&quot;token comment&quot;&gt;// false&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;As I mentioned in the beginning always use strict equality, unless you have a good reason to use loose equality. An example of that is if you are pulling data from some source and just want to know that a value exists without testing the data type. You can use loose equality in those cases, but be careful and make sure you know what you’re doing.&lt;/p&gt;
&lt;h3 id=&quot;example&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#example&quot; aria-label=&quot;example permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Example&lt;/h3&gt;
&lt;p&gt;Here’s an example component I made in React where I had an issue with equality.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;jsx&quot;&gt;&lt;pre class=&quot;language-jsx&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;
&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;AwesomeComponent&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;props&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;buyOption&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; setBuyOption&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; React&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;useState&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;onChange&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;setBuyOption&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;e&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;target&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;value&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;React.Fragment&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;buyJeansStyle&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;radio&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;checked&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;buyOption &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;onChange&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;onChange&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt; Style 1
  &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;buyJeansStyle&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;radio&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;checked&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;buyOption &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;onChange&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;onChange&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt; Style 2
  &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;React.Fragment&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
}
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;At first glance, everything works fine. Then I tested the result, I found I can’t change my choice. Clicking on a radio button did not set the button. I tried everything I can think of to fix the component. I refactored a few times but to no avail. It took me forever to find the issue. I finally realized that the issue is the equality test for the &lt;code class=&quot;language-text&quot;&gt;checked&lt;/code&gt; prop on the radio buttons. I was acting on the assumption that the values assigned, &lt;code class=&quot;language-text&quot;&gt;value=0&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;value=1&lt;/code&gt;, are integers when the state is set, but I was mistaken. The event handler was setting the string version of the values. Meaning &lt;code class=&quot;language-text&quot;&gt;e.target.value&lt;/code&gt; where strings, ‘0’ and ‘1’, and not the integer equivalents. So strict equality was always false for both checks causing the bug. Here is where the loose equality check is a better option.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;jsx&quot;&gt;&lt;pre class=&quot;language-jsx&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;buyJeansStyle&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;radio&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;checked&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;buyOption &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;onChange&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;onChange&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt; Style 1
  &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;buyJeansStyle&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;radio&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;checked&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;buyOption &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;onChange&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;onChange&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt; Style 2
  &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now the component works but to follow the “always use strict equality” rule I refactored again by casting the event value into an &lt;code class=&quot;language-text&quot;&gt;integer&lt;/code&gt; value.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;jsx&quot;&gt;&lt;pre class=&quot;language-jsx&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;
  &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;onChange&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;setBuyOption&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;parseInt&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;e&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;target&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;value&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Both fixes accomplish the same thing. Your choice will depend if you need to keep the resulting value in a specific data type or not.&lt;/p&gt;
&lt;!--ad--&gt;
&lt;h2 id=&quot;assignment&quot;&gt;Assignment vs Equality&lt;/h2&gt;
&lt;p&gt;I feel foolish whenever I commit this next error.&lt;/p&gt;
&lt;p&gt;Like the difference between loose equality and strict equality operators, the difference between assignment and equality is a single equal (&lt;code class=&quot;language-text&quot;&gt;=&lt;/code&gt;) sign. Thus it is easy to mistake using the former when you meant to use the latter.  Take for example the following code.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;

  &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; results &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;loanAmount&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1000&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;interest&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0.02&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;loanAmount&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;40000&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;interest&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0.05&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;loanAmount&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1000&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;interest&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0.03&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;loanAmount&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;10300&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;interest&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0.09&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;//...&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; loansBelowAThousandCount &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; results&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;token parameter&quot;&gt;item&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; item&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;loanAmount &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1000&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Without knowing all the contents in &lt;code class=&quot;language-text&quot;&gt;results&lt;/code&gt;, you can guess what the code wants to accomplish. I wanted to get the number of loans with &lt;code class=&quot;language-text&quot;&gt;loanAmount&lt;/code&gt; equal to 1000. I assume I would get a number less than the results count but instead got the same number as the results array every time. Looking at this simple code there will be some who would immediately find the issue. Do you see my error?&lt;/p&gt;
&lt;p&gt;I mistakenly use the assignment operator instead of the equality test. Inspecting the array from &lt;code class=&quot;language-text&quot;&gt;results.filter( item =&gt; item.loanAmount = 1000 )&lt;/code&gt;, I get the same items but with the &lt;code class=&quot;language-text&quot;&gt;loanAmount&lt;/code&gt; equal to 1000.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;
results&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;token parameter&quot;&gt;item&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; item&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;loanAmount &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1000&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; 
&lt;span class=&quot;token comment&quot;&gt;/*
[
    { loanAmount: 1000, interest: 0.02  ... }
    { loanAmount: 1000, interest: 0.05 ... }
    { loanAmount: 1000, interest: 0.03  ... }
    { loanAmount: 1000, interest: 0.09 ... }
    //...
  ];
*/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Once I’ve verified the issue I corrected the code below.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;
&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; newArray &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; myArray&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;token parameter&quot;&gt;item&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; item&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;a &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// or better yet `===`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Since I know the &lt;code class=&quot;language-text&quot;&gt;loanAmount&lt;/code&gt; is always a number I can get away with the loose equality check.&lt;/p&gt;
&lt;p&gt;It is a very simple mistake to recognize but if it is in a big codebase with a lot of moving parts, it is quite difficult to see.&lt;/p&gt;
&lt;h2 id=&quot;forof&quot;&gt;For ... in vs For ... of&lt;/h2&gt;
&lt;p&gt;If you want to loop through an array you may be familiar with this pattern.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; myArray &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;31&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; i&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; i &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt; myArray&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; i&lt;span class=&quot;token operator&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; item &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; myArray&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;i&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;item&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// 0 &lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// 10 &lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// 31&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// 20&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;What I hate about the structure above is that &lt;code class=&quot;language-text&quot;&gt;i&lt;/code&gt; is only used to get the array value. If variable &lt;code class=&quot;language-text&quot;&gt;i&lt;/code&gt; has some other purpose on the loop it would have been fine but with this pattern it’s overkill. There are better ways to loop through an array like &lt;code class=&quot;language-text&quot;&gt;Array.forEach&lt;/code&gt; etc.&lt;/p&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;For...of&lt;/code&gt; is the fairly new iterator control structure we can use to replace the &lt;code class=&quot;language-text&quot;&gt;for(;;)&lt;/code&gt; loop. Using &lt;code class=&quot;language-text&quot;&gt;for...of&lt;/code&gt; we can refactor the code above.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;
&lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; item &lt;span class=&quot;token keyword&quot;&gt;of&lt;/span&gt; myArray&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;item&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// 0 &lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// 10 &lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// 31&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// 20&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;I like this structure because it’s more readable. I can automatically read that in every iteration of the loop, I get a new “item” until the loop gets to the end of the array. It’s a great pattern. Eslint has a rule that recommends it over the old &lt;code class=&quot;language-text&quot;&gt;for(;;)&lt;/code&gt; pattern.&lt;/p&gt;
&lt;p&gt;Sometimes I make a mistake and confuse the &lt;code class=&quot;language-text&quot;&gt;for...in&lt;/code&gt; loop instead of &lt;code class=&quot;language-text&quot;&gt;for..of&lt;/code&gt;. &lt;code class=&quot;language-text&quot;&gt;For..in&lt;/code&gt; is similar &lt;code class=&quot;language-text&quot;&gt;for..of&lt;/code&gt; but instead of the values of an array it returns the keys or index of an array item.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;
&lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; item &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; myArray&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;item&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// 0 &lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// 1 &lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// 2&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// 3&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;I have made this mistake a few times so I made myself a mnemonic so I don’t forget.&lt;/p&gt;
&lt;p&gt;Remember &lt;strong&gt;‘Key IN the value OF’&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;for..IN&lt;/code&gt; returns “key”/index of an array item and &lt;code class=&quot;language-text&quot;&gt;for..OF&lt;/code&gt; returns the value.&lt;/p&gt;
&lt;h2 id=&quot;this&quot;&gt;Event handlers and proper use of &quot;this&quot;&lt;/h2&gt;
&lt;p&gt;Here’s another error I keep committing when working on Javascript. The &lt;code class=&quot;language-text&quot;&gt;this&lt;/code&gt; keyword like many programming languages hold special meaning. It represents the current context the code is acting on. In Javascript, most values are objects even functions.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;
&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;MessageClicker&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;constructor&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;elem&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; message&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;message &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; message&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

    elem&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;click&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;onClick&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;onClick&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;alert&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;message&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; fragment &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;createDocumentFragment&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; button &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; fragment&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;appendChild&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;createElement&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;button&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
button&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;textContent &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;click me&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; messageMe &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;MessageClicker&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;button&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;This is an awesome class&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;body&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;appendChild&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;button&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In the example above, I have a class &lt;code class=&quot;language-text&quot;&gt;MessageClicker&lt;/code&gt; that accepts a DOM element and a string &lt;code class=&quot;language-text&quot;&gt;message&lt;/code&gt;. An alert opens up with the provided string. When I tested I get the alert but with an &lt;code class=&quot;language-text&quot;&gt;undefined&lt;/code&gt; message. The issue is in the &lt;code class=&quot;language-text&quot;&gt;onClick&lt;/code&gt; event handler.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;
  &lt;span class=&quot;token function&quot;&gt;onClick&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;alert&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;message&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The &lt;code class=&quot;language-text&quot;&gt;this&lt;/code&gt; keyword refers to the object but not all the time. Like our example, when contained in a callback function &lt;code class=&quot;language-text&quot;&gt;this&lt;/code&gt; is actually &lt;code class=&quot;language-text&quot;&gt;undefined&lt;/code&gt;. We can fix this in a few ways. One way is to bind the function when we attach it to the element.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;  &lt;span class=&quot;token function&quot;&gt;constructor&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;elem&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; message&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;message &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; message&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    elem&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;click&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;onClick&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;bind&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;onClick&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;/* ... */&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The other way is to use arrow functions.  In arrow functions, &lt;code class=&quot;language-text&quot;&gt;this&lt;/code&gt; keeps the value of the enclosing context. In our example it’s the class &lt;code class=&quot;language-text&quot;&gt;MessageClicker&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;MessageClicker&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;constructor&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;elem&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; message&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;message &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; message&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

    elem&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;click&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;onClick&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token function-variable function&quot;&gt;onClick&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;alert&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;message&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;/* ... */&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id=&quot;wrapping-up&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#wrapping-up&quot; aria-label=&quot;wrapping up permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Wrapping up&lt;/h2&gt;
&lt;p&gt;These are just some of the errors I come across with when working with Javascript. Mostly the mistakes are caused by confusion around certain concepts like the &lt;code class=&quot;language-text&quot;&gt;this&lt;/code&gt; context and the meaning of &lt;code class=&quot;language-text&quot;&gt;const&lt;/code&gt;. Most of these are easy to fix. My take is avoid the confusion and use more familiar syntax. If you think its worth using then I recommend trying to dig deeper before introducing any new keyword or convention in to your code. Cheers!&lt;/p&gt;</content:encoded></item><item><title><![CDATA[CSS Snippets I Use 90% of The Time - Part 1]]></title><description><![CDATA[I have snippets of code I return to whenever I find patterns in a design. It is one of those efficiency hacks I’ve adopted as a programmer. I have quite a collection. Gathered working on websites in different industries. Although the size and theme of these websites vary,  I can still count on some basic UI patterns.]]></description><link>https://www.codespud.com/2023/most-used-css-patterns/</link><guid isPermaLink="false">https://www.codespud.com/2023/most-used-css-patterns/</guid><pubDate>Sat, 28 Jan 2023 08:37:00 GMT</pubDate><content:encoded>&lt;!--
- modal overlay
- screenreader-only
- golden ratio font settings
- inline list
- breadcrumbs

- text truncate
   - line
   - multiline
-  full card image
-  button with icon
-  flip card
-  centered child

angle

I love CSS
I hate repeating myself
I am hoarder


--&gt;
&lt;p&gt;I have snippets of code I return to whenever I find patterns in a design. It is one of those efficiency hacks I’ve adopted as a programmer. I have quite a collection. Gathered working on websites in different industries. Although the size and theme of these websites vary,  I can still count on some basic UI patterns. &lt;!--more--&gt; I condensed them into tried and tested snippets I use often.&lt;/p&gt;
&lt;p&gt;In this post, I am sharing some of these CSS snippets.&lt;/p&gt;
&lt;h2 id=&quot;font-settings&quot;&gt;1. Golden ratio font settings&lt;/h2&gt;
&lt;p&gt;The first thing I learned as a web developer is that how you define the text styles tells the reader the hierarchy of the information presented on a page. For that reason one of the very first things a web developer defines in CSS is the font styles.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token atrule&quot;&gt;&lt;span class=&quot;token rule&quot;&gt;@import&lt;/span&gt; &lt;span class=&quot;token url&quot;&gt;&lt;span class=&quot;token function&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string url&quot;&gt;&apos;https://fonts.googleapis.com/css?family=Poppins:400&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;body&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;background&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; white&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Poppins&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; sans-serif&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-weight&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 400&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 16px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;line-height&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 1.75&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; #000000&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;p&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token property&quot;&gt;margin-bottom&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 1rem&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;h1, h2, h2, h4, h5&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;margin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 3rem 0 1.38rem&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Poppins&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; sans-serif&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-weight&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 400&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;line-height&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 1.3&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;h1&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;margin-top&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 11.089rem&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;h2&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 6.854rem&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;h2&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 4.236rem&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;h4&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 2.618rem&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;h5&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 1.618rem&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;small, .text_small&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0.618rem&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Here we’ve defined all the important semantic tags concerning the text. The font sizes are defined according to the Golden Ratio. The &lt;a href=&quot;https://www.britannica.com/science/golden-ratio&quot;&gt;golden ratio&lt;/a&gt;, is also known as the golden section or divine proportion. In mathematics, it is defined as approximately equal to &lt;code class=&quot;language-text&quot;&gt;1.618&lt;/code&gt;. In aesthetics, the golden ratio is known as a basis for beauty. You can apply this in typography when you are figuring out the font size of a body text and its header. For example, if your body font size is 16px, multiply it by 1.618 to get the heading font size. I use the “Poppins” font here as an example. Change the font depending on your needs.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt; &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;h5&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Heading title&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;h5&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Nunc velit leo, pellentesque a velit pretium, hendrerit tempor tortor. 
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas massa 
  lectus, venenatis non elit sed, egestas gravida lacus. Etiam porta congue 
  est, sed bibendum purus feugiat eu. Integer at vulputate tellus, tristique 
  tempor lectus. Nam nisl enim, viverra egestas bibendum eget, aliquet id 
  eros. Pellentesque habitant morbi tristique senectus et netus et malesuada 
 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;style&gt;
  .golden-ratio h5 {font-size: 1.618rem;}
  .golden-ratio p {font-size: 1rem;}
&lt;/style&gt;
&lt;div class=&quot;demo golden-ratio&quot;&gt;
 &lt;h5&gt;Heading title&lt;/h5&gt;
 &lt;p&gt;Nunc velit leo, pellentesque a velit pretium, hendrerit tempor tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas massa lectus, venenatis non elit sed, egestas gravida lacus. Etiam porta congue est, sed bibendum purus feugiat eu. Integer at vulputate tellus, tristique tempor lectus. Nam nisl enim, viverra egestas bibendum eget, aliquet id eros. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris venenatis erat et dui commodo, id tempus ante porttitor. Integer eget sapien accumsan, sodales ante ac, mattis nulla.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;The golden ratio here is the &lt;a href=&quot;https://fonts.google.com/knowledge/glossary/scale&quot;&gt;typographic scale&lt;/a&gt; that dictates font sizes within your visual text hierarchy. The golden ratio might not fit your design but it’s a good starting point. My suggestion is to start with these and then adjust them to match your needs. I recently discovered &lt;a href=&quot;https://www.layoutgridcalculator.com/type-scale/&quot;&gt;layoutgridcalculator’s typography tool&lt;/a&gt;. It’s very versatile with options to define the scale ratio and the number of steps in the scale. You can even generate the CSS once you’re happy with your settings. Check it out if you’re not quite sure where to start.&lt;/p&gt;
&lt;!--ad--&gt;
&lt;h2 id=&quot;inline-lists&quot;&gt;2. Horizontal list&lt;/h2&gt;
&lt;p&gt;I always use list tags for accessibility. The bad thing about lists is that by default they are rendered vertically. For some designs, you will need to render these lists in a row. Start with the markup below and stick these CSS into your stylesheet and add &lt;code class=&quot;language-text&quot;&gt;.horizontal-list&lt;/code&gt; class to turn any list into a horizontal list.&lt;/p&gt;
&lt;div class=&quot;demo list-initial&quot;&gt;
   &lt;ul&gt;
    &lt;li&gt;
        list item 1
    &lt;/li&gt;
    &lt;li&gt;
        list item 2
    &lt;/li&gt;
    &lt;li&gt;
        list item 3
    &lt;/li&gt;
    &lt;li&gt;
        list item 4
    &lt;/li&gt;
  &lt;/ul&gt;
&lt;/div&gt;
&lt;style&gt;
  .demo.list .horizontal-list {
    list-style: none;
    padding: 0;
    margin: 0;
  }

 .demo.list .horizontal-list li{
  display: inline-block;
  padding: 4px;
  margin: 4px 0 0;
  border: 1px solid #ddd;
 }

&lt;/style&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;scss&quot;&gt;&lt;pre class=&quot;language-scss&quot;&gt;&lt;code class=&quot;language-scss&quot;&gt;
  &lt;span class=&quot;token selector&quot;&gt;.horizontal-list &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;list-style&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; none&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;margin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token selector&quot;&gt;.horizontal-list li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; inline-block&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 4px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;margin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 4px 0 0&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;border&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 1px solid #ddd&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;ul&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;horizontal-list&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
        sample item 1
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
        sample item 2
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
        sample item 3
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
        sample item 4
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;ul&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;demo list&quot;&gt;
   &lt;ul class=&quot;horizontal-list&quot;&gt;
    &lt;li&gt;
        list item 1
    &lt;/li&gt;
    &lt;li&gt;
        list item 2
    &lt;/li&gt;
    &lt;li&gt;
        list item 3
    &lt;/li&gt;
    &lt;li&gt;
        list item 4
    &lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;p&gt;I used this a lot, especially for navigation. You can replace the text with anchor tags or buttons. If you have a lot of items this style will also wrap nicely.&lt;/p&gt;
&lt;div class=&quot;demo list&quot;&gt;
   &lt;ul class=&quot;horizontal-list&quot;&gt;
    &lt;li&gt;
        list item 1
    &lt;/li&gt;
    &lt;li&gt;
        list item 2
    &lt;/li&gt;
    &lt;li&gt;
        list item 3
    &lt;/li&gt;
    &lt;li&gt;
        list item 4
    &lt;/li&gt;
        &lt;li&gt;
        list item 4
    &lt;/li&gt;
        &lt;li&gt;
        list item 4
    &lt;/li&gt;
        &lt;li&gt;
        list item 4
    &lt;/li&gt;
        &lt;li&gt;
        list item 4
    &lt;/li&gt;
          &lt;li&gt;
        list item 4
    &lt;/li&gt;      &lt;li&gt;
        list item 4
    &lt;/li&gt;
  &lt;/ul&gt;
&lt;/div&gt;
&lt;p&gt;It is good to remember that this is not the only way to style a list. It has not failed me so far so I am sticking with it.&lt;/p&gt;
&lt;h2 id=&quot;breadcrumbs&quot;&gt;3. Breadcrumbs&lt;/h2&gt;
&lt;p&gt;The horizontal list earlier is the basis for another common web UI pattern. The breadcrumb is a great navigation tool, especially for sites with a lot of content. You tackle it as a list with a divider symbol, usually, a chevron pointed to a child page.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;nav&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;breadcrumbs&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;ul&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;horizontal-list&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
          &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;#&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;parent item 1&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
          &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;#&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;parent item 2&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
          &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;#&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;parent item 3&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
          current page title
      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;ul&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;nav&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;
 &lt;span class=&quot;token selector&quot;&gt;.breadcrumbs li:not(:last-child)::after&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; inline-block&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0 5px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
 &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;style&gt;
  .demo.crumb .horizontal-list {
    list-style: none;
    padding: 0;
    margin: 0;
  }

 .demo.crumb .horizontal-list li {
  display: inline-block;
  padding: 4px;
  margin: 4px 0 0 -8px;
 }

 .demo.crumb li:not(:last-child)::after {
    display: inline-block;
    content: &apos;&gt;&apos;;
    padding: 0 5px;
 }

 .demo.crumb li a {
    border-bottom: none !important;
 }
&lt;/style&gt;
&lt;div class=&quot;demo crumb&quot;&gt;
  &lt;nav class=&quot;breadcrumbs&quot;&gt;
    &lt;ul class=&quot;horizontal-list&quot;&gt;
      &lt;li &gt;
          &lt;a href=&quot;#&quot;&gt;parent item 1&lt;/a&gt;
      &lt;/li&gt;
      &lt;li &gt;
          &lt;a href=&quot;#&quot;&gt;parent item 2&lt;/a&gt;
      &lt;/li&gt;
      &lt;li &gt;
          &lt;a href=&quot;#&quot;&gt;parent item 3&lt;/a&gt;
      &lt;/li&gt;
      &lt;li &gt;
          current page title
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/nav&gt;
&lt;/div&gt;
&lt;p&gt;It’s important to note that you need to add the “horizontal list” style with the breadcrumb CSS here.&lt;/p&gt;
&lt;h2 id=&quot;screen-reader-only&quot;&gt;4. For screen readers only&lt;/h2&gt;
&lt;p&gt;Accessibility work might take you into situations where you need to expose text to screenreaders but hide it from sighted users. One use case is when you need image buttons without text.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;
&lt;span class=&quot;token selector&quot;&gt;.screenreader-only&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;position&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;absolute&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;left&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;-10000px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;top&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;auto&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;1px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;1px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;overflow&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;hidden&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;ul&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;horizontal-list icon-buttons&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
          &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;✖&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
          &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;💾&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;ul&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;style&gt;
  .demo.icon .horizontal-list {
    list-style: none;
    padding: 0;
    margin: 0;
    border: 1px solid #ddd;
  }

 .demo.icon .horizontal-list li{
  display: inline-block;
  padding: 4px;
  margin: 4px 0 0;
 }

 .demo.icon button {
  background-color: transparent;
  border: none;
  font-size: 1.5rem;
 }

  .demo.icon .screenreader-only {
  position:absolute;
  left:-10000px;
  top:auto;
  width:1px;
  height:1px;
  overflow:hidden;
 }

&lt;/style&gt;
&lt;p&gt;Here we have a list of icon buttons. The output can be understood by sighted users but is next to useless for screen reader users. We need descriptive text to tell screen reader users the buttons’ purpose.&lt;/p&gt;
&lt;div class=&quot;demo icon&quot;&gt;
    &lt;ul class=&quot;horizontal-list icon-buttons&quot;&gt;
      &lt;li&gt;
          &lt;button&gt;&lt;span&gt;✖&lt;/span&gt;&lt;/button&gt;
      &lt;/li&gt;
      &lt;li&gt;
          &lt;button&gt;&lt;span&gt;💾&lt;/span&gt;&lt;/button&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
&lt;/div&gt;
&lt;p&gt;To remedy this we change the markup a bit to include the button text. Wrap the text in span with &lt;code class=&quot;language-text&quot;&gt;screenreader-only&lt;/code&gt; class.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;ul&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;horizontal-list icon-buttons&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
          &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;✖&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;screenreader-only&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; Delete&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
          &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;💾&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;screenreader-only&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; Save&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;ul&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now when a screen reader focuses on one of the buttons it will announce the included text.&lt;/p&gt;
&lt;p&gt;Use a screen reader to test the widget below.&lt;/p&gt;
&lt;div class=&quot;demo icon&quot;&gt;
    &lt;ul class=&quot;horizontal-list icon-buttons&quot;&gt;
      &lt;li&gt;
          &lt;button&gt;&lt;span&gt;✖&lt;/span&gt;&lt;span class=&quot;screenreader-only&quot;&gt; Delete&lt;/span&gt;&lt;/button&gt;
      &lt;/li&gt;
      &lt;li&gt;
          &lt;button&gt;&lt;span&gt;💾&lt;/span&gt;&lt;span class=&quot;screenreader-only&quot;&gt; Save&lt;/span&gt;&lt;/button&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
&lt;/div&gt;
&lt;h2 id=&quot;disabled&quot;&gt;5. Disabled area&lt;/h2&gt;
&lt;p&gt;Here is a style commonly used but rarely thought about. I for one only remember adding disabled styles when I actually need it. The use case is you want to disable an area to prevent interaction. On form controls (input, textarea, buttons etc.) you can accomplish this by using the &lt;code class=&quot;language-text&quot;&gt;[disabled=true]&lt;/code&gt; parameter. But for non-form controls like a table or big wall of text. There is no markup or attribute to aid with this.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;wall-of-text&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
Fusce porta pellentesque molestie. Praesent sit amet tempus enim, in convallis risus. Vivamus id urna augue. Quisque laoreet fringilla lorem vitae posuere. Integer non ex molestie, maximus ex non, tristique enim. Pellentesque dapibus ultrices elit, eget ornare risus. Etiam eget ullamcorper nunc, sed ultricies enim. Quisque vehicula sit amet enim eu imperdiet. Aenean dignissim purus nisi, ultricies accumsan tortor finibus et. Duis dictum orci vitae convallis bibendum.
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Another reason to disable a section of your page is to tell the user the difference between different states like when a toggle controls some content.&lt;/p&gt;
&lt;style&gt;

  .demo.disabled .toggle ~ .wall-of-text {
    opacity: 0.5;
    pointer-events: none;
  }

  .demo.disabled .toggle:checked ~ .wall-of-text {
    opacity: 1;
    pointer-events: auto;
  }

&lt;/style&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;
  &lt;span class=&quot;token selector&quot;&gt;.disabled, [disabled]&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;opacity&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0.5&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;pointer-events&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; none&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;demo disabled&quot;&gt;
  &lt;input type=&quot;checkbox&quot; class=&quot;toggle&quot;&gt; Read agreement
  &lt;div class=&quot;wall-of-text&quot;&gt;
  Fusce porta pellentesque molestie. Praesent sit amet tempus enim, in convallis risus. Vivamus id urna augue. Quisque laoreet fringilla lorem vitae posuere. Integer non ex molestie, maximus ex non, tristique enim. Pellentesque dapibus ultrices elit, eget ornare risus. Etiam eget ullamcorper nunc, sed ultricies enim. Quisque vehicula sit amet enim eu imperdiet. Aenean dignissim purus nisi, ultricies accumsan tortor finibus et. Duis dictum orci vitae convallis bibendum.
  &lt;label&gt;&lt;input type=&quot;radio&quot; name=&quot;choice&quot; class=&quot;toggle&quot;&gt; Agree&lt;/label&gt;
  &lt;label&gt;&lt;input type=&quot;radio&quot; name=&quot;choice&quot; class=&quot;toggle&quot;&gt; Disagree&lt;/label&gt;
  &lt;/div&gt;   
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; Most browsers now support &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inert&quot;&gt;inert&lt;/a&gt; attribute. It works similarly to &lt;code class=&quot;language-text&quot;&gt;pointer-events: none&lt;/code&gt; that prevents triggering or receiving any events on the element. Note that, unlike form controls that change the style when &lt;code class=&quot;language-text&quot;&gt;disabled&lt;/code&gt; attribute is set, there is no visible indication when inert is set. It is the developer’s responsibility to define if needed.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;
&lt;span class=&quot;token selector&quot;&gt;[inert]&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;opacity&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0.5&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id=&quot;wrapping-up&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#wrapping-up&quot; aria-label=&quot;wrapping up permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Wrapping up&lt;/h2&gt;
&lt;p&gt;These styles may not be as glamorous as grid layouts or flip cards but equally important when building a website. There are more styles to share in future posts.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Top three things to do for better keyboard and screenreader navigation]]></title><description><![CDATA[Improving accessibility is an exercise in empathy. We put ourselves in other people’s shoes and imagine how we can do a specific task. Tasks like going up a flight of stairs, knowing when to cross a street, or how to consume a website.]]></description><link>https://www.codespud.com/2023/three-things-you-can-do-for-keyboard-screanreader-navigation/</link><guid isPermaLink="false">https://www.codespud.com/2023/three-things-you-can-do-for-keyboard-screanreader-navigation/</guid><pubDate>Fri, 20 Jan 2023 08:07:00 GMT</pubDate><content:encoded>&lt;p&gt;Improving accessibility is an exercise in empathy. We put ourselves in other people’s shoes and imagine how we can do a specific task. Tasks like going up a flight of stairs, knowing when to cross a street, or how to consume a website. &lt;!--more--&gt; Knowing the difficulties people encounter when using your website/application, can aid us in designing better experiences for our users.&lt;/p&gt;
&lt;p&gt;One of the areas UX designers and developers alike fail to give attention to is keyboard navigation. Keyboard navigation is important because you may have users that depend on the keyboard or screenreaders to read your website. If your site is hard to navigate for these users, they might just quit your site all together and move on.&lt;/p&gt;
&lt;p&gt;Here are my top three tips for better keyboard and screen reader navigation&lt;/p&gt;
&lt;h2 id=&quot;1-use-headings-and-landmarks&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#1-use-headings-and-landmarks&quot; aria-label=&quot;1 use headings and landmarks permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;1. Use headings and landmarks&lt;/h2&gt;
&lt;p&gt;I mentioned before in &lt;a href=&quot;/2022/five_steps_to_improve_accessibility&quot;&gt;five steps to improve accessibility&lt;/a&gt;. One of the simplest thing you can do to improve accessibility is to use semantic tags like headings and landmarks to mark up your HTML. Headings and landmark tags not only help tell the screen reader about the information hierarchy on your page but also helps in navigation. This technique benefits screenreader users.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://www.w3.org/WAI/tutorials/page-structure/headings/&quot;&gt;Headings&lt;/a&gt; provide a straightforward way of distinguishing information hierarchy on a page. The first heading (&lt;code class=&quot;language-text&quot;&gt;&amp;lt;h1 /&gt;&lt;/code&gt;) is commonly the title of the page which tells the reader what the site or page is about. After that, you organize the supporting information into sub-topics titled &lt;code class=&quot;language-text&quot;&gt;&amp;lt;h2/&gt;&lt;/code&gt; and so on.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Best practices for headings and landmarks are based on &lt;a href=&quot;https://www.w3.org/WAI/tutorials/page-structure/headings/&quot;&gt;W3C WAI Tutorials&lt;/a&gt; and &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/HTML/Element#content_sectioning&quot;&gt;MDN&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Headings&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;h1&lt;/li&gt;
&lt;li&gt;h2&lt;/li&gt;
&lt;li&gt;h3&lt;/li&gt;
&lt;li&gt;h4&lt;/li&gt;
&lt;li&gt;h5&lt;/li&gt;
&lt;li&gt;h6&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a href=&quot;https://www.w3.org/WAI/tutorials/page-structure/regions/&quot;&gt;Page regions or landmarks&lt;/a&gt; divide the content into meaningful areas. For example, the &lt;code class=&quot;language-text&quot;&gt;&amp;lt;header /&gt;&lt;/code&gt; will contain navigation links and the name of a website, and the &lt;code class=&quot;language-text&quot;&gt;&amp;lt;main /&gt;&lt;/code&gt; tag will wrap the “main” content of the page.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Region tags&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;header&lt;/li&gt;
&lt;li&gt;footer&lt;/li&gt;
&lt;li&gt;aside&lt;/li&gt;
&lt;li&gt;nav&lt;/li&gt;
&lt;li&gt;main&lt;/li&gt;
&lt;li&gt;section&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We can also use &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles&quot;&gt;ARIA roles&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Landmark roles&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;banner&lt;/li&gt;
&lt;li&gt;complementary&lt;/li&gt;
&lt;li&gt;main&lt;/li&gt;
&lt;li&gt;navigation&lt;/li&gt;
&lt;li&gt;region&lt;/li&gt;
&lt;li&gt;and more.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Screen readers are capable of traversing a page through headings and landmarks. Using certain shortcuts, assistive technologies can jump from one heading to another. Some screenreaders can even list all the headings and landmarks on a page and then give the user a choice to jump to a specific heading or landmark.&lt;/p&gt;
&lt;h2 id=&quot;2-add-skip-links&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#2-add-skip-links&quot; aria-label=&quot;2 add skip links permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;2. Add skip links&lt;/h2&gt;
&lt;p&gt;The worst part about navigating a page with the keyboard (e.g. &lt;kbd&gt;Tab&lt;/kbd&gt;) is having to go through a lot of page real estate. For example, you would need to go through the main navigation, aside elements, tag lists, and call-to-action buttons before you can get to the main content. It can be exhausting for your users to do that every time. My &lt;kbd&gt;Tab&lt;/kbd&gt; key finger (if that is a thing) already hurts just thinking about it. It wastes your users’ time when they can already be reading your awesome content. To remedy this add skip links to your markup. Skip links can be part of your design or hidden until needed. These elements allow the user to jump to a specific topic or area on your page. Saving them so much pain.&lt;/p&gt;
&lt;!--ad--&gt;
&lt;p&gt;Here’s a simple “skip to main content” link you can incorporate to your site.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Skip link pattern adapted from &lt;a href=&quot;https://webaim.org/techniques/skipnav/&quot;&gt;WebAIM: Skip navigation links&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;scss&quot;&gt;&lt;pre class=&quot;language-scss&quot;&gt;&lt;code class=&quot;language-scss&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.skip-to-main-content &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// hide by default but readable to screenreaders &lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 1px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 1px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;position&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; absolute&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;top&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; -999px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;left&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 50%&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;transform&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;translateX&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;-50%&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;transitio&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; top 0.35s&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token selector&quot;&gt;&lt;span class=&quot;token parent important&quot;&gt;&amp;amp;&lt;/span&gt;:focus&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;// show in to view when focused &lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;top&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; auto&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;body&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;#main-content&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;skip-to-main-content&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Skip to main content&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
...

&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;article&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;h1&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;main-content&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;h1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;article&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;body&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The key here is to make the skip link the very top element in the markup so that it gets focused first. The link scrolls the page to the area marked by &lt;code class=&quot;language-text&quot;&gt;id=main-content&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&quot;3-minimize-key-presses&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#3-minimize-key-presses&quot; aria-label=&quot;3 minimize key presses permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;3. Minimize key presses&lt;/h2&gt;
&lt;p&gt;If you have a user interface/design that requires a lot of traversals and you can’t use skip links, modify the key handling used for navigation.&lt;/p&gt;
&lt;h3 id=&quot;31-assign-other-keys-for-navigation&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#31-assign-other-keys-for-navigation&quot; aria-label=&quot;31 assign other keys for navigation permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;3.1 Assign other keys for navigation&lt;/h3&gt;
&lt;div class=&quot;img-demo&quot;&gt;
  &lt;img src=&quot;/blog/just-tabs.png&quot;/&gt;
&lt;/div&gt;
&lt;p&gt;Tables are a common pattern to present information for a related group of data. Take, for example, the wireframe above, we have columns for data and a column for action buttons. The easiest we can do is just mark up the HTML so that the focusable elements like buttons can be “tabbed” into. In the previous image, we marked the element the user needs to interact with. If you use the &lt;kbd&gt;Tab&lt;/kbd&gt; key, it will take you 8 key presses before a user reaches the &lt;code class=&quot;language-text&quot;&gt;Delete&lt;/code&gt; button. I call &lt;strong&gt;8&lt;/strong&gt; key presses the traversal index (&lt;code class=&quot;language-text&quot;&gt;T&lt;/code&gt; index for short) to activate the &lt;code class=&quot;language-text&quot;&gt;Delete&lt;/code&gt; button.&lt;/p&gt;
&lt;p&gt;Before we go further, note I just coined the term, traversal index. Not sure if there’s a proper term for that.&lt;/p&gt;
&lt;p&gt;Anyhow, the table still looks fine with three controls(checkbox, delete and save button) and a few rows. But when you’ve add more focusable elements or when the number of table rows increases, the traversal index will grow quite large.&lt;/p&gt;
&lt;p&gt;We want to reduce the &lt;code class=&quot;language-text&quot;&gt;T&lt;/code&gt; index to make your keyboard(/screen reader) users happy.  Now check out the sample below,&lt;/p&gt;
&lt;div class=&quot;img-demo&quot;&gt;
  &lt;img src=&quot;/blog/with-arrow-keys.png&quot;/&gt;
&lt;/div&gt;
&lt;p&gt;In this table, we’ve added event handlers to use &lt;kbd&gt;Arrow Up&lt;/kbd&gt; and &lt;kbd&gt;Arrow Down&lt;/kbd&gt; keys to navigate between table rows. Once a row is focused(indicated by grey background color), the user can then use the &lt;kbd&gt;Tab&lt;/kbd&gt; key to navigate between the items within the row. With this simple change, we’ve reduced the &lt;code class=&quot;language-text&quot;&gt;T&lt;/code&gt; index to 4. Sparing your users from carpal tunnel syndrome.&lt;/p&gt;
&lt;p&gt;It is important to note that since this is not a common navigation convention for tables, you need to notify the user about the extended navigation before or when the table is focused.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;For example,&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Instruction:&lt;/strong&gt; Use arrow keys to navigate rows and &lt;kbd&gt;Tab&lt;/kbd&gt;(/&lt;kbd&gt;Shift&lt;/kbd&gt;+&lt;kbd&gt;Tab&lt;/kbd&gt;) key to move between items in a row.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;!--ad--&gt;
&lt;h3 id=&quot;32-limit-navigation-between-same-level-areas&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#32-limit-navigation-between-same-level-areas&quot; aria-label=&quot;32 limit navigation between same level areas permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;3.2 Limit navigation between same level areas&lt;/h3&gt;
&lt;p&gt;Here’s another,&lt;/p&gt;
&lt;div class=&quot;img-demo&quot;&gt;
  &lt;img src=&quot;/blog/page-sections-tabs-only.png&quot;/&gt;
&lt;/div&gt;
&lt;p&gt;The wireframe shows three sections (header, table, and links). The header has only one link and the table has four(4) rows with one(1) focusable element per row. To navigate from the header to the “links” section, we will need to press the &lt;kbd&gt;Tab&lt;/kbd&gt; key six(6) times. The problematic step here is we spend a lot of time focusing on the table rows before arriving at the Links section.&lt;/p&gt;
&lt;p&gt;We can improve the keyboard navigation by keeping the “tab” stops on the three sections initially. One way of doing this is to prevent your table contents from getting focused until needed. For instance, adding &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert&quot;&gt;inert&lt;/a&gt; attribute to the &lt;code class=&quot;language-text&quot;&gt;&amp;lt;tbody /&gt;&lt;/code&gt; wrapper will prevent the table contents from getting focused. This change reduces the &lt;code class=&quot;language-text&quot;&gt;T&lt;/code&gt; index to &lt;code class=&quot;language-text&quot;&gt;3&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The second part of this technique is to assign a special key( or keys) to enable navigation inside the table. For example, same with the previous table navigation handler, when the table is focused pressing &lt;kbd&gt;Arrow down&lt;/kbd&gt; or &lt;kbd&gt;Arrow up&lt;/kbd&gt; keys will focus one of the rows. Then you can navigate vertically or horizontally inside the table after. We can then continue through the table rows or press &lt;kbd&gt;Escape&lt;/kbd&gt; key to exit the table.&lt;/p&gt;
&lt;div class=&quot;img-demo&quot;&gt;
  &lt;img src=&quot;/blog/page-sections-plan-focus.png&quot;/&gt;
&lt;/div&gt;
&lt;p&gt;You might think that the additional navigation is complex. It won’t be - it really depends on your implementation. It will take quite a bit of coding but the other side of the equation is a better way of navigating your page.&lt;/p&gt;
&lt;p&gt;Another option we can do here to improve the &lt;code class=&quot;language-text&quot;&gt;T&lt;/code&gt; index is to assign a key combination(/s) to each section. For example, assign &lt;kbd&gt;/&lt;/kbd&gt; + &lt;kbd&gt;l&lt;/kbd&gt; to jump straight to the links section. This will keep the default navigation behavior but still provide the user a means to avoid extraneous key presses.&lt;/p&gt;
&lt;p&gt;Again, the key for both techniques is to inform the user of the special keyboard navigation.&lt;/p&gt;
&lt;h2 id=&quot;wrapping-up&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#wrapping-up&quot; aria-label=&quot;wrapping up permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Wrapping up&lt;/h2&gt;
&lt;p&gt;Improve keyboard accessibility further by making sure to;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;use headings and landmarks;&lt;/li&gt;
&lt;li&gt;add skip links when necessary and;&lt;/li&gt;
&lt;li&gt;reduce the number of keypresses to navigate a page/section&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;reference&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#reference&quot; aria-label=&quot;reference permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Reference&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://www.w3.org/WAI/tutorials/page-structure/&quot;&gt;WCAG Tutorials&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://webaim.org/techniques/skipnav/&quot;&gt;WebAIM: Skip navigation links&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://a11y-guidelines.orange.com/en/web/toolbox/methods-and-test-tools/navigating-with-a-screen-reader/&quot;&gt;Navigating with a screenreader&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles&quot;&gt;MDN: WAI-ARIA roles&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/HTML/Element#content_sectioning&quot;&gt;MDN: Elements - Content sectioning&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[Newbie's Guide to Learning Vue.js]]></title><description><![CDATA[Every time I want to learn something new I try to plan first. A very quick to-do list related to the subject. I know there’s a lot of great guides out there about Vue.js.]]></description><link>https://www.codespud.com/2023/newbies_guide_to_learning_vuejs/</link><guid isPermaLink="false">https://www.codespud.com/2023/newbies_guide_to_learning_vuejs/</guid><pubDate>Sat, 14 Jan 2023 07:07:00 GMT</pubDate><content:encoded>&lt;p&gt;Every time I want to learn something new I try to plan first. A very quick to-do list related to the subject. I know there’s a lot of great guides out there about Vue.js. &lt;!--more--&gt; But I still like making my little todo list. It keeps me focused.&lt;/p&gt;
&lt;p&gt;To start, I went to &lt;a href=&quot;https://vuejs.org/guide/introduction.html&quot;&gt;Vue.js’ documentation page&lt;/a&gt;. I scanned all the topics provided. I looked for the least amount of concepts to get a sense of Vue.js - enough to start a simple application. Then, I grew my knowledge gradually. I’ve outlined these initial concepts in this post.&lt;/p&gt;
&lt;p&gt;If you’re like me, one that is practically new to Vue.js, or if you worked on Vue.js before but interested in a refresher, or are just interested in reading on the topic, continue to read on.&lt;/p&gt;
&lt;h2 id=&quot;vuejs-learning-plan&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#vuejs-learning-plan&quot; aria-label=&quot;vuejs learning plan permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Vue.js learning plan&lt;/h2&gt;
&lt;p&gt;To be honest I got lost quite early because of topics I am not familiar with. Topics like the difference between Options API and Composition API. If you don’t know what that is either, then you were me at the beginning. &lt;a href=&quot;https://vuejs.org/guide/introduction.html#api-styles&quot;&gt;Vue.js documentation on API Preference&lt;/a&gt; should explain the difference between API styles.&lt;/p&gt;
&lt;p&gt;To simplify, I restricted my study to just using the &lt;a href=&quot;https://vuejs.org/guide/introduction.html#options-api&quot;&gt;Options API&lt;/a&gt;. Feel free to try whichever API style you prefer. I found I readily applied the same concepts using Composition API once I understood it. So don’t worry about having to learn both in the beginning.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;/2023/newbies_guide_to_learning_vuejs/#create&quot;&gt;How to create a Vue application&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;/2023/newbies_guide_to_learning_vuejs/#templates&quot;&gt;Working with Templates&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;/2023/newbies_guide_to_learning_vuejs/#directives&quot;&gt;Vue.js Directives&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;/2023/newbies_guide_to_learning_vuejs/#data&quot;&gt;Data handling and methods&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;/2023/newbies_guide_to_learning_vuejs/#computed&quot;&gt;Computed properties&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;/2023/newbies_guide_to_learning_vuejs/#event-handling&quot;&gt;Handling events&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;!--ad--&gt;
&lt;h3 id=&quot;create&quot;&gt;1. How to create a Vue Application&lt;/h3&gt;
&lt;p&gt;To start off, the first thing any developer wants to learn is how to make a simple application. Like most front-end frameworks nowadays, there are two ways to start creating an application. The first option is hosting an HTML page with the library CDN loaded and one is to build an application using build setup. Choose whichever way you want to start with. What’s important is you get started early to practice.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;HTML page loading Vue CDN&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://vuejs.org/guide/quick-start.html#using-vue-from-cdn&quot;&gt;Vuejs.org: Using a CDN&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://vueschool.io/lessons/getting-started-with-vuejs&quot;&gt;Vue School: Getting started with VueJS&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;script&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;https://unpkg.com/vue@3/dist/vue.global.js&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token script&quot;&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;script&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Build setup with NodeJS&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://vuejs.org/guide/quick-start.html#creating-a-vue-application&quot;&gt;Vuejs.org: Using NodeJS Setup&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Learn/Tools_and_testing/Client-side_JavaScript_frameworks/Vue_getting_started#installation&quot;&gt;MDN: Vue.js - Installation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;npm&lt;/span&gt; init vue@latest&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3 id=&quot;templates&quot;&gt;2. Working with Templates&lt;/h3&gt;
&lt;p&gt;Vue.js has templates to define the structure of a simple application. Templates are written in HTML(or HTML-like syntax) and can include special library-specific directives and expressions to render data.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Message: {{ msg }}&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;{{ rawHtml }}&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://vuejs.org/guide/essentials/template-syntax.html&quot;&gt;Vuejs.org: Template Syntax&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://vueschool.io/lessons/vuejs-template-syntax-and-expressions&quot;&gt;Vue School: Vue.js Template Syntax and Expressions&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;directives&quot;&gt;3. Vue.js Directives&lt;/h3&gt;
&lt;p&gt;While working with templates, you will come across directives. Directives appear as element attributes specific to Vue.js. They are prefixed with &lt;code class=&quot;language-text&quot;&gt;v-&lt;/code&gt; syntax like the example below. Directives extend templates with logic and additional functionality. The example below the directive &lt;code class=&quot;language-text&quot;&gt;v-for&lt;/code&gt; loops thru the items and render the text for each item inside the div.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;v-for&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;item in items&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  {{ item.text }}
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://vuejs.org/api/built-in-directives.html&quot;&gt;VueJS.org: Directives&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.codecademy.com/courses/learn-vue-js/lessons/vue-introduction/exercises/directives&quot;&gt;CodeAcademy: Directives 💵&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://vuejsdevelopers.com/lessons/understanding-directives-1/1/&quot;&gt;Vuejsdevelopers.com: Understanding Directives&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;data&quot;&gt;4. Data handling and methods&lt;/h3&gt;
&lt;p&gt;Vue.js components have a data object that holds the component’s state, and methods that can be used to manipulate the state. In my opinion, the ability to manage and manipulate data is what makes front-end frameworks interesting. It’s the difference between a simple HTML page and a dynamic site.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://vuejs.org/api/options-state.html#data&quot;&gt;VueJS.org: Data&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://vueschool.io/lessons/vue-methods&quot;&gt;Vue School: Fundamentals - Vue methods&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;state-management&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#state-management&quot; aria-label=&quot;state management permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;State management&lt;/h3&gt;
&lt;p&gt;State management is an advance topic related to data and how it drives your application. You can use the data object and other techniques to manage the state of the application. For simple cases that is enough. For more complex applications we should be using state management libraries. These libraries are Vue.js’ answer to the flux pattern libraries ubiquitous to React.js projects.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://pinia.vuejs.org/introduction.html&quot;&gt;Pinia&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://vuex.vuejs.org/&quot;&gt;Vuex&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Some articles I’ve read - recommends using &lt;strong&gt;Pinia&lt;/strong&gt; over &lt;strong&gt;Vuex&lt;/strong&gt;.&lt;/p&gt;
&lt;h3 id=&quot;computed&quot;&gt;5. Computed Properties&lt;/h3&gt;
&lt;p&gt;Computed properties are calculated based on other data or properties on a page. The contrived example below illustrates what computed properties are used for. The values are automatically “calculated” from the source property, &lt;code class=&quot;language-text&quot;&gt;store.fruits&lt;/code&gt;. When the source property changes the computed value also changes without additional code.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;javascript&quot;&gt;&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;
&lt;span class=&quot;token keyword&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;default&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token literal-property property&quot;&gt;store&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token literal-property property&quot;&gt;fruits&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;
          &lt;span class=&quot;token string&quot;&gt;&apos;apple&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
          &lt;span class=&quot;token string&quot;&gt;&apos;mango&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
          &lt;span class=&quot;token string&quot;&gt;&apos;banana&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
          &lt;span class=&quot;token comment&quot;&gt;//...&lt;/span&gt;
        &lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;computed&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;hasMangoToSell&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;store&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;fruits&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;indexOf&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;mango&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;!==&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Yes&apos;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;No&apos;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;//...&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;dl&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;dt&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Has mango to sell?&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;dt&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;dd&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;{{ hasMangoToSell }}&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;dd&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  ...
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;dl&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The &lt;code class=&quot;language-text&quot;&gt;hasMangoToSell&lt;/code&gt; computed property above is “computed” from the data object property &lt;code class=&quot;language-text&quot;&gt;store&lt;/code&gt;.&lt;/p&gt;
&lt;!--ad--&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://vuejs.org/guide/essentials/computed.html&quot;&gt;VueJs.org: Computed properties&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://vueschool.io/lessons/vuejs-computed-properties&quot;&gt;Vue School: Computed properties&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Learn/Tools_and_testing/Client-side_JavaScript_frameworks/Vue_computed_properties&quot;&gt;MDN: Using Vue computed properties&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;event-handling&quot;&gt;6. Handling events&lt;/h3&gt;
&lt;p&gt;Event handling is the essence of front-end interactivity. Vue.js allows you to handle events, such as button clicks, form inputs, and more. These events could either be inline or method handlers.&lt;/p&gt;
&lt;p&gt;Inline handlers executed code is defined inside a &lt;code class=&quot;language-text&quot;&gt;@&amp;lt;event name here&gt;=&quot;&quot;&lt;/code&gt; attribute. Like so:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;javascript&quot;&gt;&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token function&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token literal-property property&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;@click&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;counter++&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Increment&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;There are {{ counter }} sheep jumping over the fence&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Method handlers on the other hand are defined from the application object itself under the &lt;code class=&quot;language-text&quot;&gt;methods&lt;/code&gt; prop.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;javascript&quot;&gt;&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;
&lt;span class=&quot;token function&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token literal-property property&quot;&gt;counter&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;token literal-property property&quot;&gt;methods&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;increment&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;counter&lt;span class=&quot;token operator&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;@click&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;increment&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Increment&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;There are {{ counter }} sheep jumping over the fence&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://vuejs.org/guide/essentials/event-handling.html&quot;&gt;VueJS.org: Event Handling&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://vuejs.org/guide/essentials/forms.html&quot;&gt;VueJS.org: Form Input Bindings&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://vueschool.io/lessons/vuejs-user-events&quot;&gt;Vue School: User events&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;wrapping-up&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#wrapping-up&quot; aria-label=&quot;wrapping up permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Wrapping up&lt;/h2&gt;
&lt;p&gt;There are other concepts a Vue.js developer needs to learn of course. I think you will encounter those topics while running through the topics in this list. Advanced topics like components, watchers, and hooks. Feel free to add that to your own learning plan. I am thinking to cover those topics when I start building more complex applications.&lt;/p&gt;
&lt;p&gt;After the list above I plan to explore more advanced topics and start building a project. It is important to practice by building small projects, experimenting with different features, and following tutorials. I think that is still the best way to learn.&lt;/p&gt;
&lt;h2 id=&quot;bonus&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#bonus&quot; aria-label=&quot;bonus permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Bonus&lt;/h2&gt;
&lt;p&gt;Aside from the excellent documentation on Vue.js’ website. I found their &lt;a href=&quot;https://vuejs.org/tutorial/#step-1&quot;&gt;tutorial&lt;/a&gt; page really helpful too. If you like learning ala-FreecodeCamp-style, you can appreciate a similar experience. Same with FreecodeCamp, you are presented with topics on the language accompanied with code problems to solve. I recommend checking it out.&lt;/p&gt;
&lt;h2 id=&quot;my-progress-so-far&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#my-progress-so-far&quot; aria-label=&quot;my progress so far permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;My progress so far&lt;/h2&gt;
&lt;p&gt;Below is my where I am in terms of my efforts learning Vue.js.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;span&gt;Learn Vue.js essential concepts&lt;/span&gt; (partial)&lt;/li&gt;
&lt;li&gt;Debugging a VueJS application&lt;/li&gt;
&lt;li&gt;Create a blog application using Vue.js&lt;/li&gt;
&lt;li&gt;Learn Vue-Router&lt;/li&gt;
&lt;li&gt;Build for Production&lt;/li&gt;
&lt;/ol&gt;</content:encoded></item><item><title><![CDATA[Fix accessibility using focus-within]]></title><description><![CDATA[A few issues I found recently for clients were related to accessibility. A few perfectly working user interfaces were not keyboard accessible. Not because they are custom controls nor because the controls were not tabable.]]></description><link>https://www.codespud.com/2023/fix_accessibility_with_focus_within/</link><guid isPermaLink="false">https://www.codespud.com/2023/fix_accessibility_with_focus_within/</guid><pubDate>Sun, 08 Jan 2023 01:07:00 GMT</pubDate><content:encoded>&lt;p&gt;A few issues I found recently for clients were related to accessibility. A few perfectly working user interfaces were not keyboard accessible. Not because they are custom controls nor because the controls were not tabable. &lt;!--more--&gt; But, because the keyboard experience did not match the mouse-only interactions. These user interfaces are confusing, to say the least.&lt;/p&gt;
&lt;p&gt;I solved these issues by using the &lt;code class=&quot;language-text&quot;&gt;:focus-within&lt;/code&gt; psuedo-selector.&lt;/p&gt;
&lt;p&gt;I listed a few of them and the solutions.&lt;/p&gt;
&lt;h2 id=&quot;table-row-with-hidden-buttons&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#table-row-with-hidden-buttons&quot; aria-label=&quot;table row with hidden buttons permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Table row with hidden buttons&lt;/h2&gt;
&lt;p&gt;Here the developer added an effect that shows the buttons when hovered. The markup is accessible to screen readers but does not look correct for sighted persons that use the keyboard. Accessibility is not just for screenreaders. &lt;a href=&quot;https://www.w3.org/TR/UNDERSTANDING-WCAG20/navigation-mechanisms-focus-order.html&quot;&gt;Sighted people need to make sense&lt;/a&gt; of the page too.&lt;/p&gt;
&lt;style&gt;
.demo table {
  min-width: 500px;
  border-collapse: collapse;
}

.demo td,
.demo th {
  border: none;
}

.demo td,
.demo th:not(:first-child) {
  padding: 1rem 0.8rem;
  margin: 0;
  text-align: left;
}

thead tr {
  border-bottom: 3px solid #ddd;
}

tbody {
  /**
  * Show buttons on hover and when an element is focused inside the row
  */
    border-bottom: 2px solid #ddd;
}
tbody tr button {
  opacity: 0;
}
tbody tr:hover {
  background-color: #ffd57e;
}
tbody tr:hover button {
  opacity: 100%;
}

button {
  border: none;
  padding: 0;
  margin: 0;
  background: transparent;
  -webkit-appearance: none;
  box-shadow: none;
}

&lt;/style&gt;
&lt;div class=&quot;demo&quot;&gt;
&lt;table tabindex=&quot;0&quot;&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;
        &lt;div class=&quot;sr-only&quot;&gt;Checkbox&lt;/div&gt;
      &lt;/th&gt;
      &lt;th&gt;Name&lt;/th&gt;
      &lt;th&gt;Job description&lt;/th&gt;
      &lt;th&gt;
        &lt;div class=&quot;sr-only&quot;&gt;Controls&lt;/div&gt;
      &lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;input type=&quot;checkbox&quot; value=&quot;1&quot; name=&quot;user&quot;&gt;&lt;/td&gt;
      &lt;td&gt;John Doe&lt;/td&gt;
      &lt;td&gt;rocket scientist&lt;/td&gt;
      &lt;td&gt;
        &lt;button class=&quot;delete&quot; aria-label=&quot;delete&quot;&gt;❌&lt;/button&gt;
        &lt;button class=&quot;save&quot;  aria-label=&quot;save&quot;&gt;💾&lt;/button&gt;
      &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;input type=&quot;checkbox&quot; value=&quot;1&quot; name=&quot;user&quot;&gt;&lt;/td&gt;
      &lt;td&gt;Adam smith&lt;/td&gt;
      &lt;td&gt;economist&lt;/td&gt;
      &lt;td&gt;
        &lt;button class=&quot;delete&quot; aria-label=&quot;delete&quot;&gt;❌&lt;/button&gt;
        &lt;button class=&quot;save&quot; aria-label=&quot;save&quot;&gt;💾&lt;/button&gt;
      &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;input type=&quot;checkbox&quot; value=&quot;1&quot; name=&quot;user&quot;&gt;&lt;/td&gt;
      &lt;td&gt;Jose &lt;rizal&gt;&lt;/rizal&gt;
      &lt;/td&gt;
      &lt;td&gt;novelist&lt;/td&gt;
      &lt;td&gt;
        &lt;button class=&quot;delete&quot; aria-label=&quot;delete&quot;&gt;❌&lt;/button&gt;
        &lt;button class=&quot;save&quot; aria-label=&quot;save&quot;&gt;💾&lt;/button&gt;
      &lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;table&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;tabindex&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;0&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;thead&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;tr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;th&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
          &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;sr-only&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Checkbox&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;th&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;th&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Name&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;th&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;th&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Job description&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;th&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;th&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
          &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;sr-only&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Controls&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;th&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;tr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;thead&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;tbody&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;tr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;td&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;checkbox&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;1&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;user&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;td&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;td&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;John Doe&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;td&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;td&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;rocket scientist&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;td&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;td&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
          &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;delete&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;aria-label&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;delete&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;❌&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
          &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;save&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;aria-label&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;save&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;💾&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;td&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;tr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
      ...
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;tbody&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;table&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Using the mouse, the table above works perfectly well. There is color highlighting and the buttons become visible when the mouse is over a table row.&lt;/p&gt;
&lt;p&gt;If you navigate the table using the keyboard, the experience is not what you will expect. Firstly, you don’t see the highlight color when focused on a row. The worst of it is you will be able to go through all the focusable elements using the keyboard - including the invisible buttons. This is confusing for sighted people using the keyboard.&lt;/p&gt;
&lt;!--ad--&gt;
&lt;p&gt;Let’s check the style code below. The buttons are invisible by default(&lt;code class=&quot;language-text&quot;&gt;opacity: 0&lt;/code&gt;). When the mouse is over the row (&lt;code class=&quot;language-text&quot;&gt;:hover&lt;/code&gt;), it gets a background color and buttons become visible(&lt;code class=&quot;language-text&quot;&gt;opacity: 100%&lt;/code&gt;).&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;scss&quot;&gt;&lt;pre class=&quot;language-scss&quot;&gt;&lt;code class=&quot;language-scss&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// SCSS&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;tbody tr &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token selector&quot;&gt;button &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;opacity&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token comment&quot;&gt;/**
  * Show buttons on hover
  */&lt;/span&gt;
  &lt;span class=&quot;token selector&quot;&gt;&lt;span class=&quot;token parent important&quot;&gt;&amp;amp;&lt;/span&gt;:hover &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;background-color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; #ffd57e&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token selector&quot;&gt;button &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;opacity&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 100%&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3 id=&quot;solution&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#solution&quot; aria-label=&quot;solution permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Solution&lt;/h3&gt;
&lt;p&gt;We can use javascript and add an event handler on the focusable elements that gets triggered whenever any element on the row is focused. With that we can set a class (&lt;code class=&quot;language-text&quot;&gt;.has-focused-element&lt;/code&gt;) that applies the same style above.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;javascript&quot;&gt;&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; els &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelectorAll&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;tr input[type=checkbox], tr button&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

els&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;forEach&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;el&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;focus&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; onFocus&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// etc...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;scss&quot;&gt;&lt;pre class=&quot;language-scss&quot;&gt;&lt;code class=&quot;language-scss&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// SCSS&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;tbody tr &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// ...&lt;/span&gt;

  &lt;span class=&quot;token comment&quot;&gt;/**
  * Show buttons on hover
  */&lt;/span&gt;
  &lt;span class=&quot;token selector&quot;&gt;&lt;span class=&quot;token parent important&quot;&gt;&amp;amp;&lt;/span&gt;:hover,
  &lt;span class=&quot;token parent important&quot;&gt;&amp;amp;&lt;/span&gt;.has-focused-element &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;background-color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; #ffd57e&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token selector&quot;&gt;button &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;opacity&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 100%&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The changes above will work but uneccessary. We should try to solve any style problems inside the CSS first before reaching for Javascript.&lt;/p&gt;
&lt;p&gt;Another solution is to use &lt;code class=&quot;language-text&quot;&gt;:focus-within&lt;/code&gt; where the &lt;code class=&quot;language-text&quot;&gt;:hover&lt;/code&gt; psuedo-selector is defined.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The :focus-within CSS pseudo-class matches an element if the element or any of its descendants are focused. In other words, it represents an element that is itself matched by the :focus pseudo-class or has a descendant that is matched by :focus. (This includes descendants in shadow trees.) - &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/:focus-within&quot;&gt;MDN&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;“Focus-within” psuedo selector can match elements that has elements that gets focused. In this case, we have the &lt;code class=&quot;language-text&quot;&gt;checkbox&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;button&lt;/code&gt; elements. When these elements gets focus, we can apply the same style as if we hovered the pointer on the table row. This will work without adding a line of javascript.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;scss&quot;&gt;&lt;pre class=&quot;language-scss&quot;&gt;&lt;code class=&quot;language-scss&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// SCSS&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;tbody tr &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token selector&quot;&gt;button &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;opacity&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token comment&quot;&gt;/**
  * Show buttons on hover and when an element is focused inside the row
  */&lt;/span&gt;
  &lt;span class=&quot;token selector&quot;&gt;&lt;span class=&quot;token parent important&quot;&gt;&amp;amp;&lt;/span&gt;:hover,
  &lt;span class=&quot;token parent important&quot;&gt;&amp;amp;&lt;/span&gt;:focus-within &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;background-color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; #ffd57e&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token selector&quot;&gt;button &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;opacity&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 100%&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3 id=&quot;solution-in-action&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#solution-in-action&quot; aria-label=&quot;solution in action permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Solution in action&lt;/h3&gt;
&lt;p&gt;Here’s the same table using &lt;code class=&quot;language-text&quot;&gt;:focus-within&lt;/code&gt;,&lt;/p&gt;
&lt;style&gt;

.fix tbody tr:hover, .fix tbody tr:focus-within {
  background-color: #ffd57e;
}
.fix tbody tr:hover button, .fix tbody tr:focus-within button {
  opacity: 100%;
}

&lt;/style&gt;
&lt;div class=&quot;demo fix&quot;&gt;
&lt;table tabindex=&quot;0&quot;&gt;
        &lt;thead&gt;
          &lt;tr&gt;
            &lt;th&gt;
              &lt;div class=&quot;sr-only&quot;&gt;Checkbox&lt;/div&gt;
            &lt;/th&gt;
            &lt;th&gt;Name&lt;/th&gt;
            &lt;th&gt;Job description&lt;/th&gt;
            &lt;th&gt;
              &lt;div class=&quot;sr-only&quot;&gt;Controls&lt;/div&gt;
            &lt;/th&gt;
          &lt;/tr&gt;
        &lt;/thead&gt;
        &lt;tbody&gt;
          &lt;tr&gt;
            &lt;td&gt;&lt;input type=&quot;checkbox&quot; value=&quot;1&quot; name=&quot;user&quot;&gt;&lt;/td&gt;
            &lt;td&gt;John Doe&lt;/td&gt;
            &lt;td&gt;rocket scientist&lt;/td&gt;
            &lt;td&gt;
              &lt;button class=&quot;delete&quot;&gt;❌&lt;/button&gt;
              &lt;button class=&quot;save&quot;&gt;💾&lt;/button&gt;
            &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
            &lt;td&gt;&lt;input type=&quot;checkbox&quot; value=&quot;1&quot; name=&quot;user&quot;&gt;&lt;/td&gt;
            &lt;td&gt;Adam smith&lt;/td&gt;
            &lt;td&gt;economist&lt;/td&gt;
            &lt;td&gt;
              &lt;button class=&quot;delete&quot;&gt;❌&lt;/button&gt;
              &lt;button class=&quot;save&quot;&gt;💾&lt;/button&gt;
            &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
            &lt;td&gt;&lt;input type=&quot;checkbox&quot; value=&quot;1&quot; name=&quot;user&quot;&gt;&lt;/td&gt;
            &lt;td&gt;Jose &lt;rizal&gt;&lt;/rizal&gt;
            &lt;/td&gt;
            &lt;td&gt;novelist&lt;/td&gt;
            &lt;td&gt;
              &lt;button class=&quot;delete&quot;&gt;❌&lt;/button&gt;
              &lt;button class=&quot;save&quot;&gt;💾&lt;/button&gt;
            &lt;/td&gt;
          &lt;/tr&gt;
        &lt;/tbody&gt;
      &lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;A user can navigate through the focusable elements in the row and see the “hover” effect.&lt;/p&gt;
&lt;!--ad--&gt;
&lt;h2 id=&quot;card-with-like-button&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#card-with-like-button&quot; aria-label=&quot;card with like button permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Card with like(♥) button&lt;/h2&gt;
&lt;p&gt;Here’s another user interface with a hover effect but no keyboard focus effect. Hovering over any part of the card applies a heart icon on top of the image indicating to the user that they can make the image their favorite. This card UI is part of an image gallery.&lt;/p&gt;
&lt;style&gt;

.card {
  min-width: 250px;
  max-width: 250px;
  overflow: hidden;
  position: relative;
  box-shadow: 1px 1px 4px 0 rgba(0 0 0 / 0.2), 2px 2px 8px 1px rgba(0 0 0 / 0.2);
  padding: 15px 15px 10px 15px;
  border-radius: 6px;
}
.card img {
  width: 100%;
  transition: opacity 0.35s ease-in-out;
  margin: 0;
}
.card span {
  font-size: 9rem;
  position: absolute;
  left: 50%;
  top: 50%;
  color: #ddd;
  transform: translate(-50%, -50%);
  text-decoration: none;
  opacity: 0;
}
.card:hover img, .fix .card:focus-within img {
  opacity: 70%;
  background-color: #000;
}
.card:hover span, .fix .card:focus-within span {
  opacity: 100%;
}
.card:hover button, .fix .card:focus-within button {
  opacity: 0;
}
.fix .card:focus-within {
  outline: 4px dashed #555;
  outline-offset: -5px;
}
.card button {
  position: absolute;
  bottom: 20px;
  right: 20px;
  color: #ddd;
  font-size: 1.5rem;
  padding: 2px 4px;
}

&lt;/style&gt;
&lt;div class=&apos;demo&apos; tabindex=&quot;0&quot;&gt;
&lt;div class=&quot;card&quot;&gt;
    &lt;img src=&quot;https://images.unsplash.com/photo-1671026423293-7adf6a6abd13?crop=entropy&amp;amp;cs=tinysrgb&amp;amp;fm=jpg&amp;amp;ixid=MnwzMjM4NDZ8MHwxfHJhbmRvbXx8fHx8fHx8fDE2NzMwNTEwNzE&amp;amp;ixlib=rb-4.0.3&amp;amp;q=80&quot; alt=&quot;&quot;&gt;
    &lt;span&gt;♥&lt;/span&gt;
    &lt;button class=&quot;like&quot;&gt;♥&lt;/button&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Works when using the mouse but when navigating using the keyboard - again the user experience fails. It lacks a good keyboard experience. When you tab through the card, the button gets focused - which is fine - but it’s not the effect we wanted.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;card&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;img&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;https://images.unsplash.com/photo-1671026423293-7adf6a6abd13?crop=entropy&amp;amp;cs=tinysrgb&amp;amp;fm=jpg&amp;amp;ixid=MnwzMjM4NDZ8MHwxfHJhbmRvbXx8fHx8fHx8fDE2NzMwNTEwNzE&amp;amp;ixlib=rb-4.0.3&amp;amp;q=80&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;♥&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;button-group&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;like&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;♥&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;scss&quot;&gt;&lt;pre class=&quot;language-scss&quot;&gt;&lt;code class=&quot;language-scss&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// scss&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;.card &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  
  &lt;span class=&quot;token comment&quot;&gt;// ...&lt;/span&gt;
  
  &lt;span class=&quot;token selector&quot;&gt;&lt;span class=&quot;token parent important&quot;&gt;&amp;amp;&lt;/span&gt;:hover &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token selector&quot;&gt;img &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;opacity&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 70%&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;background-color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; #000&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;token selector&quot;&gt;span &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;opacity&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 100%&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;token selector&quot;&gt;button &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;opacity&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token comment&quot;&gt;// ...&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;I know some will ask why can we not just add &lt;code class=&quot;language-text&quot;&gt;tabindex=0&lt;/code&gt; on the card and add a &lt;code class=&quot;language-text&quot;&gt;:focus&lt;/code&gt; style. Yeah that could work. But, we would end up with two focus steps(one for the card and the heart (♥) button) instead of just the button. We don’t want that.&lt;/p&gt;
&lt;h3 id=&quot;solution-1&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#solution-1&quot; aria-label=&quot;solution 1 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Solution&lt;/h3&gt;
&lt;p&gt;Again &lt;code class=&quot;language-text&quot;&gt;:focus-within&lt;/code&gt; to the rescue. We go back to the style code and look for &lt;code class=&quot;language-text&quot;&gt;:hover&lt;/code&gt; styling.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;scss&quot;&gt;&lt;pre class=&quot;language-scss&quot;&gt;&lt;code class=&quot;language-scss&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// scss&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;/**
  * Make heart cover image visible when button is focused
  */&lt;/span&gt;
  &lt;span class=&quot;token selector&quot;&gt;&lt;span class=&quot;token parent important&quot;&gt;&amp;amp;&lt;/span&gt;:hover,
  &lt;span class=&quot;token parent important&quot;&gt;&amp;amp;&lt;/span&gt;:focus-within &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token selector&quot;&gt;img &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;opacity&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 70%&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;background-color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; #000&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;token selector&quot;&gt;span &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;opacity&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 100%&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;token selector&quot;&gt;button &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;opacity&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The changes above should apply the same experience for both mouse and keyboard users.&lt;/p&gt;
&lt;p&gt;As a rule, we also want to add an outline when the card is focused using the keyboard. Similar to what we get when we focus any interactive control with the keyboard.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;scss&quot;&gt;&lt;pre class=&quot;language-scss&quot;&gt;&lt;code class=&quot;language-scss&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// scss&lt;/span&gt;
&lt;span class=&quot;token selector&quot;&gt;.card &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// ...&lt;/span&gt;
  
  &lt;span class=&quot;token selector&quot;&gt;&lt;span class=&quot;token parent important&quot;&gt;&amp;amp;&lt;/span&gt;:focus-within &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;outline&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 4px dashed #333&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;outline-offset&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 2px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token comment&quot;&gt;//...&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3 id=&quot;solution-in-action-1&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#solution-in-action-1&quot; aria-label=&quot;solution in action 1 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Solution in action&lt;/h3&gt;
&lt;p&gt;Use the &lt;kbd&gt;Tab&lt;/kbd&gt; key to navigate through the card. When the button gets focused the card activates the hover effect we defined earlier. Now both hover and focus events show the same effect.&lt;/p&gt;
&lt;div class=&apos;demo fix&apos; tabindex=&quot;0&quot;&gt;
&lt;div class=&quot;card&quot;&gt;
    &lt;img src=&quot;https://images.unsplash.com/photo-1671026423293-7adf6a6abd13?crop=entropy&amp;amp;cs=tinysrgb&amp;amp;fm=jpg&amp;amp;ixid=MnwzMjM4NDZ8MHwxfHJhbmRvbXx8fHx8fHx8fDE2NzMwNTEwNzE&amp;amp;ixlib=rb-4.0.3&amp;amp;q=80&quot; alt=&quot;&quot;&gt;
    &lt;span&gt;♥&lt;/span&gt;
    &lt;button class=&quot;like&quot;&gt;♥&lt;/button&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;!--ad--&gt;
&lt;h2 id=&quot;apply-effects-when-buttons-are-hovered&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#apply-effects-when-buttons-are-hovered&quot; aria-label=&quot;apply effects when buttons are hovered permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Apply effects when buttons are hovered&lt;/h2&gt;
&lt;p&gt;In this example we have an image with a color swatch control. When you hover over any of the colors, the corresponding color value is blended with the image. This works correctly with the mouse but with the keyboard. We want to be able to get the same effect on the image when any of the buttons gets focused using the keyboard.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;picker&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;picker-group&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;picker-item&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token special-attr&quot;&gt;&lt;span class=&quot;token attr-name&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token value css language-css&quot;&gt;&lt;span class=&quot;token property&quot;&gt;--selected-color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; #912424&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;sr-only&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;red&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;picker-item&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token special-attr&quot;&gt;&lt;span class=&quot;token attr-name&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token value css language-css&quot;&gt;&lt;span class=&quot;token property&quot;&gt;--selected-color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; #3566b2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;sr-only&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;blue&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;picker-item&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token special-attr&quot;&gt;&lt;span class=&quot;token attr-name&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token value css language-css&quot;&gt;&lt;span class=&quot;token property&quot;&gt;--selected-color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; #226642&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;sr-only&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;green&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;scss&quot;&gt;&lt;pre class=&quot;language-scss&quot;&gt;&lt;code class=&quot;language-scss&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// scss&lt;/span&gt;
&lt;span class=&quot;token selector&quot;&gt;.picker &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;

  &lt;span class=&quot;token comment&quot;&gt;// ...&lt;/span&gt;
  
  &lt;span class=&quot;token property&quot;&gt;background-image&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token url&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token property&quot;&gt;https&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token comment&quot;&gt;//images.unsplash.com/photo-1552944150-6dd1180e5999?crop=entropy&amp;amp;cs=tinysrgb&amp;amp;fm=jpg&amp;amp;ixid=MnwzMjM4NDZ8MHwxfHJhbmRvbXx8fHx8fHx8fDE2NzMwNTkzNzg&amp;amp;ixlib=rb-4.0.3&amp;amp;q=80);&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;background-color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;--selected-color&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token comment&quot;&gt;// ...&lt;/span&gt;

  &lt;span class=&quot;token selector&quot;&gt;&lt;span class=&quot;token parent important&quot;&gt;&amp;amp;&lt;/span&gt;:hover &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;// blend image with color when button is hovered or focused&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;background-blend-mode&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; hard-light&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token comment&quot;&gt;// ...&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;For this one we have some scripting to setup the hover(mouseover) effect. We try set the CSS variable &lt;code class=&quot;language-text&quot;&gt;--selected-color&lt;/code&gt; as the picker background color.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;javascript&quot;&gt;&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; picker &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;.picker&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; buttons &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelectorAll&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;.picker-item&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;onHighlight&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; target &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; e&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;currentTarget&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  picker&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;style &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; target&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;style&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;cssText&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;onRemoveColor&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  picker&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;style &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

buttons&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;forEach&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  button&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;mouseover&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; onHighlight&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

picker&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;mouseout&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; onRemoveColor&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;style&gt;
.picker {
  position: relative;
  display: flex;
  width: 300px;
  height: 300px;
  overflow: hidden;
  background-image: url(https://images.unsplash.com/photo-1552944150-6dd1180e5999?crop=entropy&amp;cs=tinysrgb&amp;fm=jpg&amp;ixid=MnwzMjM4NDZ8MHwxfHJhbmRvbXx8fHx8fHx8fDE2NzMwNTkzNzg&amp;ixlib=rb-4.0.3&amp;q=80);
  background-size: cover;
  background-position: 20%;
  border-radius: 4px;
  background-color: var(--selected-color);
  transition: background-color 0.35s ease-in-out;
  flex: 1;
}
.picker:hover, .picker:focus-within {
  background-blend-mode: hard-light;
}
.picker-item {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid #ededed;
  background-color: var(--selected-color);
  cursor: pointer;
}
.picker-group {
  position: absolute;
  bottom: 8px;
  left: 8px;
}
&lt;/style&gt;
&lt;p&gt;This is how it looks. My blog software does not run javascript so the UI below only shows a snapshot of one of the button focused. I will include a Codepen demo later in this page so you can interact with it.&lt;/p&gt;
&lt;div class=&apos;demo&apos;&gt;
  &lt;div class=&quot;picker&quot; style=&quot;--selected-color: #912424; background-blend-mode: hard-light;&quot;&gt;
    &lt;div class=&quot;picker-group&quot; &gt;
      &lt;button class=&quot;picker-item&quot; style=&quot;--selected-color: #912424; outline: 2px dashed #fff;&quot;&gt;&lt;span class=&quot;sr-only&quot;&gt;red&lt;/span&gt;&lt;/button&gt;
      &lt;button class=&quot;picker-item&quot; style=&quot;--selected-color: #3566b2&quot;&gt;&lt;span class=&quot;sr-only&quot;&gt;blue&lt;/span&gt;&lt;/button&gt;
      &lt;button class=&quot;picker-item&quot; style=&quot;--selected-color: #226642&quot;&gt;&lt;span class=&quot;sr-only&quot;&gt;green&lt;/span&gt;&lt;/button&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Again the issue here is that the interface does not work well with the keyboard for sighted people. It’s screen reader friendly but the experience is lacking when not using the mouse.&lt;/p&gt;
&lt;p&gt;This is a bit more complicated so we leverage &lt;code class=&quot;language-text&quot;&gt;:focus-within&lt;/code&gt; in conjunction with a &lt;code class=&quot;language-text&quot;&gt;focus&lt;/code&gt; event handler to set the color and blend style when using the keyboard.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;scss&quot;&gt;&lt;pre class=&quot;language-scss&quot;&gt;&lt;code class=&quot;language-scss&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// SCSS&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;.picker &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token comment&quot;&gt;// ...&lt;/span&gt;

  &lt;span class=&quot;token selector&quot;&gt;&lt;span class=&quot;token parent important&quot;&gt;&amp;amp;&lt;/span&gt;:hover,
  &lt;span class=&quot;token parent important&quot;&gt;&amp;amp;&lt;/span&gt;:focus-within &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;// blend image with color when button is hovered or focused&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;background-blend-mode&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; hard-light&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;javascript&quot;&gt;&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// ...&lt;/span&gt;

buttons&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;forEach&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  button&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;mouseover&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; onHighlight&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  button&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;focus&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; onHighlight&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// trigger highlight script when buttons are focused&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;//...&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Using the solution above, we get a better experience without a lot of extra code. See the solution in action in the Codepen below.&lt;/p&gt;
&lt;h2 id=&quot;full-solution&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#full-solution&quot; aria-label=&quot;full solution permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Full solution&lt;/h2&gt;
&lt;p&gt;Here are all three solutions in action. Check out the final code to understand the solutions in their entirety.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://codepen.io/chrisbautista/pen/bGjBZzM&quot;&gt;&lt;div&gt;&lt;iframe 
        height=&apos;400&apos; 
        scrolling=&apos;no&apos; 
        src=&apos;//codepen.io/chrisbautista/embed/preview/bGjBZzM/?height=400&amp;theme-id=dark&amp;default-tab=html,result&apos; 
        frameborder=&apos;no&apos; 
        allowtransparency=&apos;true&apos; 
        allowfullscreen=&apos;true&apos; 
        style=&apos;width: 100%;&apos;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;wrapping-up&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#wrapping-up&quot; aria-label=&quot;wrapping up permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Wrapping up&lt;/h2&gt;
&lt;p&gt;Sometimes as web developers, it is great to work on problems that improve the user experience for a variety of people. For all the tools in our disposal its really great to know that adding a single psuedo-selector like &lt;code class=&quot;language-text&quot;&gt;:focus-within&lt;/code&gt; could be so useful. Without it, we might have ended up with some complicated solutions or worst case have to start from scratch.&lt;/p&gt;
&lt;h2 id=&quot;reference&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#reference&quot; aria-label=&quot;reference permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Reference&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/:focus-within&quot;&gt;MDN: focus-within&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.w3.org/TR/UNDERSTANDING-WCAG20/navigation-mechanisms-focus-order.html&quot;&gt;WCAG: Focus order&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.w3.org/TR/2012/NOTE-UNDERSTANDING-WCAG20-20120103/navigation-mechanisms-focus-visible.html&quot;&gt;WCAG: Focus visible&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[React Custom button: a study on accessibility]]></title><description><![CDATA[React and accessibility I love ReactJs. I learned late in my career as there were not a lot of opportunities to do so. Most of the shops I worked at back then were jQuery-and-a-prayer operations, and there’s a whole separate post in how long it took to unwind that habit. But I digress, that’s a story for another day. When I finally found a suitable situation to explore ReactJs for a previous employer, I jumped on it and picked it up quickly. It was weird in the beginning but it became quite natural in the end. Now I mainly work with ReactJS in most of my projects.]]></description><link>https://www.codespud.com/2022/custom_button-a_study_on_react_accessibility/</link><guid isPermaLink="false">https://www.codespud.com/2022/custom_button-a_study_on_react_accessibility/</guid><pubDate>Mon, 19 Dec 2022 01:07:00 GMT</pubDate><content:encoded>&lt;h2 id=&quot;react-and-accessibility&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#react-and-accessibility&quot; aria-label=&quot;react and accessibility permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;React and accessibility&lt;/h2&gt;
&lt;p&gt;I love ReactJs. I learned late in my career as there were not a lot of opportunities to do so. Most of the shops I worked at back then were jQuery-and-a-prayer operations, and there’s a whole separate post in how long it took to unwind that habit. But I digress, that’s a story for another day.&lt;/p&gt;
&lt;p&gt;When I finally found a suitable situation to explore ReactJs for a previous employer, I jumped on it and picked it up quickly. It was weird in the beginning but it became quite natural in the end. Now I mainly work with ReactJS in most of my projects. &lt;!--more--&gt;&lt;/p&gt;
&lt;p&gt;One of the great things about working with ReactJs is working with JSX. ReactJS does not understand JSX - we achieve this with Babel. Babel transpiles JSX into something ReactJS can understand. Anyhow, JSX is almost like HTML with some differences, and because it looks like HTML markup it becomes really easy to learn.&lt;/p&gt;
&lt;p&gt;But, and it’s a big but, making it easy to learn does not save developers from issues related to accessibility. Some patterns that are perfectly valid in ReactJS aren’t necessarily accessible.&lt;/p&gt;
&lt;p&gt;For example, when using labels in forms&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;jsx&quot;&gt;&lt;pre class=&quot;language-jsx&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;
&lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;label&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;htmlFor&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;firstName&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;First Name &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    isEditing  
    &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;text&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;firstName&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;firstName&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; data&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;FirstName
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;When not editing, the input element identified &lt;code class=&quot;language-text&quot;&gt;id=firstName&lt;/code&gt; is not available. So the browser will ignore the label but still render it. This is confusing to screenreaders. The markup above looks contrived but you will be surprised how often I see this. We can easily fix this by keeping the input element available to the browser but hidden to the user when not editing.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;jsx&quot;&gt;&lt;pre class=&quot;language-jsx&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;
&lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;label&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;htmlFor&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;firstName&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;First Name &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;text&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;firstName&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;firstName&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;data&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;firstName&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;disabled&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;isEditing&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The outcome is similar to the former but the current markup is more accessible. Screenreader-friendly, in short.&lt;/p&gt;
&lt;p&gt;I wanted to understand how best to tackle accessibility for custom components in React. With some rudimentary understanding of ReactJS, I proceeded with my education with a custom button. I know I’ve always said to always use semantic tags when possible, and that is still true. But to understand what a button should have to make it accessible, learning to make a custom button seemed like a good exercise before building anything more complex. Not just what ARIA attributes to put in but what I should be looking for when working with React and keeping it accessible. Things like styling and visual feedback when buttons are activated etc.&lt;/p&gt;
&lt;h2 id=&quot;custom-button&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#custom-button&quot; aria-label=&quot;custom button permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Custom Button&lt;/h2&gt;
&lt;p&gt;I started with a simple ReactJS component. A &lt;code class=&quot;language-text&quot;&gt;span&lt;/code&gt; wrapper element with an onclick event.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;jsx&quot;&gt;&lt;pre class=&quot;language-jsx&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;
  &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;CustomButton&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; onClick&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; children&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;restProps &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;onClick&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;onClick&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token spread&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;restProps&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;children&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token comment&quot;&gt;// usage&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;onClick&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;alert&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;button clicked&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;CustomButton&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;onClick&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;onClick&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;Click me&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;token class-name&quot;&gt;CustomButton&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To simplify, we will assume that the button will always have text, passed as a &lt;code class=&quot;language-text&quot;&gt;children&lt;/code&gt; prop.&lt;/p&gt;
&lt;p&gt;The markup for the component above has issues. Firstly, since it’s a span it needs some styling to make it look like a button. It really depends on how you want to render a button but for our purpose, I will stick to a classic raised button style.&lt;/p&gt;
&lt;h3 id=&quot;button-styling&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#button-styling&quot; aria-label=&quot;button styling permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Button styling&lt;/h3&gt;
&lt;p&gt;We add some css to handle hover and clicked event styling.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;scss&quot;&gt;&lt;pre class=&quot;language-scss&quot;&gt;&lt;code class=&quot;language-scss&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;/* SCSS */&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;.custom-button &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; inline-flex&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;justify-content&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; center&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;background-color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; #f1f2f3&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;min-width&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 140px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;box-shadow&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; inset -3px -3px 6px 0 &lt;span class=&quot;token function&quot;&gt;rgba&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;#000&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; 0.15&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    1px 1px 2px 0 &lt;span class=&quot;token function&quot;&gt;rgba&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;#000&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; 0.15&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; 2px 2px 4px 0 &lt;span class=&quot;token function&quot;&gt;rgba&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;#000&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; 0.15&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0.35rem 0.5rem&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;border-radius&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 10px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token selector&quot;&gt;&lt;span class=&quot;token parent important&quot;&gt;&amp;amp;&lt;/span&gt;:active &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;box-shadow&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; inset 3px 3px 6px 0 &lt;span class=&quot;token function&quot;&gt;rgba&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;#000&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; 0.15&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      -1px -1px 2px 0 &lt;span class=&quot;token function&quot;&gt;rgba&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;#000&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; 0.15&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; -2px -2px 4px 0 &lt;span class=&quot;token function&quot;&gt;rgba&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;#000&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; 0.15&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token selector&quot;&gt;&lt;span class=&quot;token parent important&quot;&gt;&amp;amp;&lt;/span&gt;:focus-visible, &lt;span class=&quot;token parent important&quot;&gt;&amp;amp;&lt;/span&gt;:hover &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;outline&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 4px dashed orange&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;!--ad--&gt;
&lt;h3 id=&quot;selectors&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#selectors&quot; aria-label=&quot;selectors permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Selectors&lt;/h3&gt;
&lt;p&gt;The &lt;code class=&quot;language-text&quot;&gt;:active&lt;/code&gt; selector is applied when the button is clicked, while &lt;code class=&quot;language-text&quot;&gt;:hover&lt;/code&gt; applies when the mouse is over the button. Finally, &lt;code class=&quot;language-text&quot;&gt;:focus-visible&lt;/code&gt; will ensure that the button gets a visible outline when the button is navigated to using the keyboard.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;Our custom button looks like a proper button now with drop shadow and on press styling. When I click the button it writes “button clicked”. For a button to be accessible it should be keyboard accessible. Let’s try navigating to the button using &lt;kbd&gt;Tab&lt;/kbd&gt; (and &lt;kbd&gt;Shift&lt;/kbd&gt; + &lt;kbd&gt;Tab&lt;/kbd&gt;) key in the Codepen demo below.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://codepen.io/chrisbautista/pen/ExpaJMP&quot;&gt;&lt;div&gt;&lt;iframe 
        height=&apos;400&apos; 
        scrolling=&apos;no&apos; 
        src=&apos;//codepen.io/chrisbautista/embed/preview/ExpaJMP/?height=400&amp;theme-id=dark&amp;default-tab=html,result&apos; 
        frameborder=&apos;no&apos; 
        allowtransparency=&apos;true&apos; 
        allowfullscreen=&apos;true&apos; 
        style=&apos;width: 100%;&apos;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;As you can see, we are unable to focus the button. Next problem in our custom button we need to tackle is making it operable using the keyboard.&lt;/p&gt;
&lt;h3 id=&quot;keyboard-accessible&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#keyboard-accessible&quot; aria-label=&quot;keyboard accessible permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Keyboard accessible&lt;/h3&gt;
&lt;p&gt;The &lt;a href=&quot;https://www.w3.org/WAI/WCAG22/Understanding/keyboard&quot;&gt;WCAG guideline 2.1: Keyboard&lt;/a&gt; criterion requires interactive content(such as a button) to be operable using the keyboard. This is for users that can not use a mouse like people who are blind or with issues that make them prefer the keyboard. Simply, anything you can operate with a mouse should be available for a keyboard user too.&lt;/p&gt;
&lt;h3 id=&quot;tabindex&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#tabindex&quot; aria-label=&quot;tabindex permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Tabindex&lt;/h3&gt;
&lt;p&gt;We need to be able to navigate to the button. What we need is to add tabindex so that it becomes focusable.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;jsx&quot;&gt;&lt;pre class=&quot;language-jsx&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;
&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;CustomButton&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; onClick&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; children&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;restProps &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt; 
      &lt;span class=&quot;token attr-name&quot;&gt;className&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;custom-button&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; 
      &lt;span class=&quot;token attr-name&quot;&gt;tabIndex&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt; 
      &lt;span class=&quot;token attr-name&quot;&gt;onClick&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;onClick&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt; 
      &lt;span class=&quot;token spread&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;restProps&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;children&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Cool! 😎 Now it’s focusable. Next, press &lt;kbd&gt;Enter&lt;/kbd&gt; key to trigger the button. If you notice nothing happened, that is because we lack a keyboard event handler!&lt;/p&gt;
&lt;h3 id=&quot;keydown-handler&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#keydown-handler&quot; aria-label=&quot;keydown handler permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Keydown handler&lt;/h3&gt;
&lt;p&gt;We need a &lt;code class=&quot;language-text&quot;&gt;KeyDown&lt;/code&gt; handler that runs the same operation as if it was clicked like a native button. And like how a native button works we trigger the designated action with &lt;kbd&gt;Enter&lt;/kbd&gt; and &lt;kbd&gt;Spacebar&lt;/kbd&gt; keys.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;jsx&quot;&gt;&lt;pre class=&quot;language-jsx&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;
&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;CustomButton&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; onClick&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; children&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;restProps &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;onKeyDown&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;e&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;key &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Enter&apos;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; e&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;key &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos; &apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token function&quot;&gt;onClick&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;e&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt; 
      &lt;span class=&quot;token attr-name&quot;&gt;className&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;custom-button&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; 
      &lt;span class=&quot;token attr-name&quot;&gt;tabIndex&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt; 
      &lt;span class=&quot;token attr-name&quot;&gt;onClick&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;onClick&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt; 
      &lt;span class=&quot;token attr-name&quot;&gt;onKeyDown&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;onKeyDown&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt; 
      &lt;span class=&quot;token spread&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;restProps&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;children&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Let’s see how it works so far — use the &lt;kbd&gt;Tab&lt;/kbd&gt; key to navigate and activate the button:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://codepen.io/chrisbautista/pen/gOjbJLB&quot;&gt;&lt;div&gt;&lt;iframe 
        height=&apos;400&apos; 
        scrolling=&apos;no&apos; 
        src=&apos;//codepen.io/chrisbautista/embed/preview/gOjbJLB/?height=400&amp;theme-id=dark&amp;default-tab=html,result&apos; 
        frameborder=&apos;no&apos; 
        allowtransparency=&apos;true&apos; 
        allowfullscreen=&apos;true&apos; 
        style=&apos;width: 100%;&apos;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3 id=&quot;keydown-styling&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#keydown-styling&quot; aria-label=&quot;keydown styling permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Keydown styling&lt;/h3&gt;
&lt;p&gt;Nice, the action is activated with either the &lt;kbd&gt;Enter&lt;/kbd&gt; or &lt;kbd&gt;Spacebar&lt;/kbd&gt; key. There is another issue. None of the previous styles we added earlier will apply when we activate the custom button using the keyboard. We don’t have a selector for that so we need to use class selectors.&lt;/p&gt;
&lt;p&gt;Since this is a state of the button, we need to provide code so that the component can track it internally.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;jsx&quot;&gt;&lt;pre class=&quot;language-jsx&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;
&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;CustomButton&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; onClick&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; children&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;restProps &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;isPressed&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; setIsPressed&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; React&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;useState&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;onKeyDown&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;e&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;key &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Enter&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; e&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;key &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot; &quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token function&quot;&gt;onClick&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;e&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;token function&quot;&gt;setIsPressed&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// when pressed&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;onKeyUp&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;e&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;key &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Enter&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; e&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;key &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot; &quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token function&quot;&gt;setIsPressed&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// when keyboard released a key&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;token comment&quot;&gt;// ...&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;We need to tell the button when to apply the “button pressed” styling. We accomplish that by setting a className, &lt;code class=&quot;language-text&quot;&gt;custom-button-pressed&lt;/code&gt;. We can recycle the &lt;code class=&quot;language-text&quot;&gt;:active&lt;/code&gt; styling defined earlier.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;scss&quot;&gt;&lt;pre class=&quot;language-scss&quot;&gt;&lt;code class=&quot;language-scss&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.custom-button &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  
  &lt;span class=&quot;token comment&quot;&gt;//...*&lt;/span&gt;

  &lt;span class=&quot;token selector&quot;&gt;&lt;span class=&quot;token parent important&quot;&gt;&amp;amp;&lt;/span&gt;:active,
  &lt;span class=&quot;token parent important&quot;&gt;&amp;amp;&lt;/span&gt;-pressed &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;box-shadow&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; inset 3px 3px 6px 0 &lt;span class=&quot;token function&quot;&gt;rgba&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;#000&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; 0.15&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      -1px -1px 2px 0 &lt;span class=&quot;token function&quot;&gt;rgba&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;#000&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; 0.15&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; -2px -2px 4px 0 &lt;span class=&quot;token function&quot;&gt;rgba&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;#000&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; 0.15&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Next, we apply/remove the class name whenever the state changes.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;jsx&quot;&gt;&lt;pre class=&quot;language-jsx&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;
  &lt;span class=&quot;token comment&quot;&gt;// ...&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; classNames &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;custom-button&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;isPressed&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    classNames &lt;span class=&quot;token operator&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot; custom-button-pressed&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt;
      &lt;span class=&quot;token attr-name&quot;&gt;className&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;classNames&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token attr-name&quot;&gt;tabIndex&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token attr-name&quot;&gt;onClick&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;onClick&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token attr-name&quot;&gt;onKeyDown&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;onKeyDown&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token attr-name&quot;&gt;onKeyUp&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;onKeyUp&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;token spread&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;restProps&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;children&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Voila, the button style when activated with the keyboard works.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://codepen.io/chrisbautista/pen/WNKQWxj&quot;&gt;&lt;div&gt;&lt;iframe 
        height=&apos;400&apos; 
        scrolling=&apos;no&apos; 
        src=&apos;//codepen.io/chrisbautista/embed/preview/WNKQWxj/?height=400&amp;theme-id=dark&amp;default-tab=html,result&apos; 
        frameborder=&apos;no&apos; 
        allowtransparency=&apos;true&apos; 
        allowfullscreen=&apos;true&apos; 
        style=&apos;width: 100%;&apos;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3 id=&quot;screen-reader&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#screen-reader&quot; aria-label=&quot;screen reader permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Screen reader&lt;/h3&gt;
&lt;p&gt;Our custom button is looking great! To recap, we styled the button and made it operable with both the mouse and the keyboard. It looks shippable, right?&lt;/p&gt;
&lt;p&gt;Not yet.&lt;/p&gt;
&lt;p&gt;If you use a screen reader now, you will notice that the custom button is treated as a clickable div - NOT a button. Since we only made the span look and act like a button, the browser does not tell the screen reader that we’ve made a button. It still thinks this is a clickable div. We add markup to tell the browser what to expect.&lt;/p&gt;
&lt;h3 id=&quot;rolebutton&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#rolebutton&quot; aria-label=&quot;rolebutton permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Role=button&lt;/h3&gt;
&lt;p&gt;To tell the browser that we have a button we assign it a &lt;code class=&quot;language-text&quot;&gt;role&lt;/code&gt; of &lt;code class=&quot;language-text&quot;&gt;button&lt;/code&gt; — simple enough, right?&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;ARIA roles provide semantic meaning to content, allowing screen readers and other tools to present and support interaction with object in a way that is consistent with user expectations of that type of object.
— &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles&quot;&gt;MDN: WAI-ARIA Roles&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I mentioned before we should be using &lt;a href=&quot;/2022/five_steps_to_improve_accessibility/&quot;&gt;semantic tags&lt;/a&gt;. The browser readily understands the behavior and information about semantic elements telling assistive technologies(like a screenreader) what to expect. This is already baked into the semantic element. We can just use it straight away. On the other hand, our custom button needs our help providing that information to the browser. Setting the role turns our custom button into a semantic button element for click, keyboard, and screen-reader purposes. It still won’t behave like a native button for form submission or the &lt;code class=&quot;language-text&quot;&gt;disabled&lt;/code&gt; attribute — that needs &lt;code class=&quot;language-text&quot;&gt;aria-disabled&lt;/code&gt; and a bit more work — but that’s outside what we’re tackling here.&lt;/p&gt;
&lt;p&gt;Test the next demo with a screen reader.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://codepen.io/chrisbautista/pen/BaPoEbw&quot;&gt;&lt;div&gt;&lt;iframe 
        height=&apos;400&apos; 
        scrolling=&apos;no&apos; 
        src=&apos;//codepen.io/chrisbautista/embed/preview/BaPoEbw/?height=400&amp;theme-id=dark&amp;default-tab=html,result&apos; 
        frameborder=&apos;no&apos; 
        allowtransparency=&apos;true&apos; 
        allowfullscreen=&apos;true&apos; 
        style=&apos;width: 100%;&apos;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Install a screenreader&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://www.nvaccess.org/&quot;&gt;NVDA&lt;/a&gt; for windows&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.apple.com/voiceover/info/guide/_1121.html&quot;&gt;VoiceOver&lt;/a&gt; for Macs&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://wiki.gnome.org/Projects/Orca&quot;&gt;ORCA&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;h2 id=&quot;react-hook-usebutton&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#react-hook-usebutton&quot; aria-label=&quot;react hook usebutton permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;React hook: useButton&lt;/h2&gt;
&lt;p&gt;I like React hooks. It is great for reusing functionality. Our custom button is great but we are stuck with a span element. We can change this in several ways. My favorite is moving the component behavior and state in a React hook. Once we’ve moved the behavior out of the custom button, we don’t need the custom component anymore. We can directly apply the props to any element we want to make into a button.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;jsx&quot;&gt;&lt;pre class=&quot;language-jsx&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;KEY&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;Enter&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Enter&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;Spacebar&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos; &apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;useButton&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; onClick&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; className &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;isPressed&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; setIsPressed&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; React&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;useState&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;onKeyDown&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;e&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;key &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;KEY&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Enter &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; e&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;key &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;KEY&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Spacebar&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token function&quot;&gt;onClick&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;e&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
      &lt;span class=&quot;token function&quot;&gt;setIsPressed&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;onKeyUp&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;e&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;key &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;KEY&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Enter &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; e&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;key &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;KEY&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Spacebar&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token function&quot;&gt;setIsPressed&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    isPressed&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// tells if the button is pressed&lt;/span&gt;
    &lt;span class=&quot;token literal-property property&quot;&gt;a11yProps&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// props that tell the browser this is a button &lt;/span&gt;
      &lt;span class=&quot;token literal-property property&quot;&gt;tabIndex&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token literal-property property&quot;&gt;role&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;button&quot;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token literal-property property&quot;&gt;eventProps&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// event handlers &lt;/span&gt;
      onClick&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      onKeyDown&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      onKeyUp
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;// usage&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; isPressed&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; a11yProps&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; eventProps &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;useButton&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; onClick &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; className &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;custom-button&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;isPressed&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    className &lt;span class=&quot;token operator&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot; custom-button-pressed&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token comment&quot;&gt;//...&lt;/span&gt;
  
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;className&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;className&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token spread&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;a11yProps&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token spread&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;eventProps&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
    Click Me
  &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;


  &lt;span class=&quot;token comment&quot;&gt;//...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href=&quot;https://codepen.io/chrisbautista/pen/poZjmNG&quot;&gt;&lt;div&gt;&lt;iframe 
        height=&apos;400&apos; 
        scrolling=&apos;no&apos; 
        src=&apos;//codepen.io/chrisbautista/embed/preview/poZjmNG/?height=400&amp;theme-id=dark&amp;default-tab=html,result&apos; 
        frameborder=&apos;no&apos; 
        allowtransparency=&apos;true&apos; 
        allowfullscreen=&apos;true&apos; 
        style=&apos;width: 100%;&apos;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;For the &lt;code class=&quot;language-text&quot;&gt;a11yProps&lt;/code&gt;, we only needed &lt;code class=&quot;language-text&quot;&gt;tabIndex&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;role=button&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&quot;extending-the-hook&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#extending-the-hook&quot; aria-label=&quot;extending the hook permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Extending the hook&lt;/h3&gt;
&lt;p&gt;We can extend useButton with other ARIA props for various use cases e.g. a toggle button. A toggle button keeps its &lt;code class=&quot;language-text&quot;&gt;isPressed&lt;/code&gt; state until triggered again. Using &lt;code class=&quot;language-text&quot;&gt;aria-pressed&lt;/code&gt;, we can keep the state set for the browser’s benefit.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;jsx&quot;&gt;&lt;pre class=&quot;language-jsx&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;
&lt;span class=&quot;token comment&quot;&gt;// usage&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;import&lt;/span&gt; _ &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;lodash&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; isPressed&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; a11yProps&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; eventProps &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;useButton&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; onClick &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; className &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;custom-button&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;isPressed&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    className &lt;span class=&quot;token operator&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot; custom-button-pressed&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; newA11yProps &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; _&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;extend&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; a11yProps&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token string-property property&quot;&gt;&apos;aria-pressed&apos;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; isPressed&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token string-property property&quot;&gt;&apos;aria-label&apos;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;Toggle&apos;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;token comment&quot;&gt;//...&lt;/span&gt;
  
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;className&lt;/span&gt;&lt;span class=&quot;token script language-javascript&quot;&gt;&lt;span class=&quot;token script-punctuation punctuation&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;className&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token spread&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;newA11yProps&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token spread&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;eventProps&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;className&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;toggle-notch&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token plain-text&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;


  &lt;span class=&quot;token comment&quot;&gt;//...&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;We’ll use lodash’s &lt;code class=&quot;language-text&quot;&gt;_.extend&lt;/code&gt; here (make sure it’s imported: &lt;code class=&quot;language-text&quot;&gt;import _ from &apos;lodash&apos;;&lt;/code&gt;) to merge the new props in without mutating the original object. Also, we threw in &lt;code class=&quot;language-text&quot;&gt;aria-label&lt;/code&gt; to fix the lack of visible text.&lt;/p&gt;
&lt;h2 id=&quot;wrapping-up&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#wrapping-up&quot; aria-label=&quot;wrapping up permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Wrapping up&lt;/h2&gt;
&lt;p&gt;To make an accessible custom button component we need a few things;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;CSS to simulate a button state from unpressed, focused, and when activated.&lt;/li&gt;
&lt;li&gt;Event handlers not just for the mouse but for the keyboard as well.&lt;/li&gt;
&lt;li&gt;ARIA to change the semantic meaning of an element to a button.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;With the &lt;code class=&quot;language-text&quot;&gt;useButton&lt;/code&gt; hook we can extract the learnings from this exercise into a reusable function and apply it anywhere we need a custom button element.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Five Web Accessibility Extensions for Visual Studio Code]]></title><description><![CDATA[Developing with accessibility in mind requires knowledge of WCAG rules and good techniques. These techniques boils down to remembering good accessbility patterns in code. Linters are good at discerning less ideal patterns and provide hints on how to fix them. Before I used to think linters are optional for developers. But now I don’t think I can work without them. Using a good IDE linter will help making sure your code follows accessibility best practices and in turn make you more productive.]]></description><link>https://www.codespud.com/2022/five_accessibility_vscode_extensions/</link><guid isPermaLink="false">https://www.codespud.com/2022/five_accessibility_vscode_extensions/</guid><pubDate>Thu, 15 Dec 2022 08:07:00 GMT</pubDate><content:encoded>&lt;!--
    Angle:

    Aid in making sure code is acessible
    Find patterns that are against accessibility rules
    Provide sufficient techniques in code
    Avoid accessibility issues in code

    - Webhint https://marketplace.visualstudio.com/items?itemName=webhint.vscode-webhint

    - Axe-Linter https://marketplace.visualstudio.com/items?itemName=deque-systems.vscode-axe-linter

    - Web Accessibility https://marketplace.visualstudio.com/items?itemName=MaxvanderSchee.web-accessibility

    - Eslint with jsx-a11y https://www.npmjs.com/search?ranking=popularity&amp;q=eslint%20a11y

    - SonarLint https://marketplace.visualstudio.com/items?itemName=SonarSource.sonarlint-vscode

    - Bonus: ErrorLens https://marketplace.visualstudio.com/items?itemName=usernamehw.errorlens
--&gt;
&lt;p&gt;Developing with accessibility in mind requires knowledge of WCAG rules and good techniques. These techniques boils down to remembering good accessbility patterns in code. Linters are good at discerning less ideal patterns and provide hints on how to fix them. Before I used to think linters are optional for developers. But now I don’t think I can work without them. Using a good IDE linter will help making sure your code follows accessibility best practices and in turn make you more productive.&lt;/p&gt;
&lt;!--more--&gt;
&lt;blockquote&gt;
&lt;p&gt;Web accessibility involves following certain design principles which ensure that people who experience difficulties or limitations have the same or a similar experience as those who do not. - &lt;a href=&quot;https://blog.hubspot.com/website/web-accessibility&quot;&gt;Hubspot&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;In the example below the linter should be able to recognize that the button tag is missing a visible label.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;img&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;save.png&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;responsive&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The code above is problematic for screenreaders because it does not have any text to describe what action the button is supposed to do.  I have seen a lot of HTML markup that forgets this simple rule. A linter would have caught this before even going into production.&lt;/p&gt;
&lt;p&gt;Here is the same code with a linter&lt;/p&gt;
&lt;img src=&quot;/blog/code-with-linter.png&quot;  alt=&quot;Code with linter warning&quot; class=&quot;no-margin&quot;&gt;
&lt;p&gt;Visual Studio Code have plugins that help coders make their code pass accessibility checks.&lt;/p&gt;
&lt;p&gt;Here are the top 5 plugins I use:&lt;/p&gt;
&lt;h2 id=&quot;1-axe-accessibility-linter&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#1-axe-accessibility-linter&quot; aria-label=&quot;1 axe accessibility linter permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;1. &lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=deque-systems.vscode-axe-linter&quot;&gt;Axe accessibility linter&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Axe&lt;/strong&gt; is a leader in accessibility testing and tooling. They built &lt;a href=&quot;https://github.com/dequelabs/axe-core&quot;&gt;axe-core&lt;/a&gt; which powers axe-linter. It is easy to install and no configuration needed. You can start enjoying the benefits of realtime code accessibility checks.&lt;/p&gt;
&lt;p&gt;Its pre-configured to check the following file extensions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;React (.js, .ts, .jsx, .tsx)&lt;/li&gt;
&lt;li&gt;HTML (.htm, .html)&lt;/li&gt;
&lt;li&gt;Markdown (.md, .markdown)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The great thing about axe-linter is you can click a link in the hint. The linked page will explain the issue, why its relevant and how to fix it.&lt;/p&gt;
&lt;img src=&quot;/blog/vsce-example.png&quot; alt=&quot;Axe linter&quot;&gt;
&lt;!--ad--&gt;
&lt;h2 id=&quot;2-webhint&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#2-webhint&quot; aria-label=&quot;2 webhint permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;2. &lt;a href=&quot;https://webhint.io/docs/user-guide/extensions/vscode-webhint/&quot;&gt;Webhint&lt;/a&gt;&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;Webhint helps you improve your site’s accessibility, speed, cross-browser compatibility, and more by checking your code for best practices and common errors. - &lt;a href=&quot;https://webhint.io/&quot;&gt;Webhint&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;strong&gt;Webhint.io&lt;/strong&gt; is a tool that looks for a suite of website best practices. These best practices include accessibility, website performance, security, etc. The &lt;a href=&quot;https://webhint.io/docs/user-guide/&quot;&gt;command line tool&lt;/a&gt; will scan the site provided and return a report. The webhint visual studio extension, on the other hand, analyzes code while you develop.  (&lt;a href=&quot;https://webhint.io/docs/user-guide/hints/hint-axe/&quot;&gt;See accessibility hints&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;It also uses axe-core to analyze the code.&lt;/p&gt;
&lt;img src=&quot;/blog/webhint-vscode.gif&quot; alt=&quot;Webhint.io&quot;&gt;
&lt;h2 id=&quot;3-web-accessibility&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#3-web-accessibility&quot; aria-label=&quot;3 web accessibility permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;3. &lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=MaxvanderSchee.web-accessibility&quot;&gt;Web Accessibility&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Website accessiblity&lt;/strong&gt; is another Vscode plugin geared at checking for accessibility issues in code. Not as extensive as the first two plugins but I think that is a good thing. Its focus is just accessibility issues nothing else. The hints are simple and does not offer any other options. Perfect for coders who love memory efficient IDEs.&lt;/p&gt;
&lt;img src=&quot;/blog/web-accessibility.gif&quot; alt=&quot;Web accessibility&quot;&gt;
&lt;h2 id=&quot;4-eslint-with-jsx-a11y&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#4-eslint-with-jsx-a11y&quot; aria-label=&quot;4 eslint with jsx a11y permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;4. &lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint&quot;&gt;Eslint&lt;/a&gt; with &lt;a href=&quot;https://www.npmjs.com/search?ranking=popularity&amp;#x26;q=eslint%20a11y&quot;&gt;jsx-a11y&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Eslint is a bit more complex to install than the previous plugins. If you’ve been developing with the Eslint and Eslint plugin then you will have an easier time.&lt;/p&gt;
&lt;h3 id=&quot;installation&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#installation&quot; aria-label=&quot;installation permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Installation&lt;/h3&gt;
&lt;p&gt;Run these commands in your project root&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;
&lt;span class=&quot;token function&quot;&gt;npm&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt; --save-dev eslint eslint-plugin-jsx-a11y
./node_modules/.bin/eslint &lt;span class=&quot;token parameter variable&quot;&gt;--init&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You can also do this globally;&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;
&lt;span class=&quot;token function&quot;&gt;npm&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-g&lt;/span&gt; eslint eslint-plugin-jsx-a11y 
eslint &lt;span class=&quot;token parameter variable&quot;&gt;--init&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Finally, add jsx-a11y in plugins section of your &lt;code class=&quot;language-text&quot;&gt;.eslintrc&lt;/code&gt;&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;json&quot;&gt;&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;
&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;

 &lt;span class=&quot;token property&quot;&gt;&quot;plugins&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;jsx-a11y&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You might get a popup saying there is an error starting eslint plugin, check the output logs in Vscode for any issues. In most cases, making sure you have the latest nodejs and npm fixes the issue.&lt;/p&gt;
&lt;h2 id=&quot;5-sonarlint&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#5-sonarlint&quot; aria-label=&quot;5 sonarlint permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;5. &lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=SonarSource.sonarlint-vscode&quot;&gt;SonarLint&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Last but not the least, Sonarlint is a code quality checking tool, like Webhint and Eslint. It checks for a suite of issues in your code not just accessibility. It requires Java runtime to work.&lt;/p&gt;
&lt;p&gt;The accessibility rules are limited to &lt;a href=&quot;https://rules.sonarsource.com/html/tag/accessibility&quot;&gt;HTML&lt;/a&gt; portion of your code.&lt;/p&gt;
&lt;p&gt;If you are more interested in accessibility checks, I recommend using the other plugins on this list.&lt;/p&gt;
&lt;!--ad--&gt;
&lt;h2 id=&quot;bonus-errorlens&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#bonus-errorlens&quot; aria-label=&quot;bonus errorlens permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Bonus: &lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=usernamehw.errorlens&quot;&gt;Errorlens&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Errorlens is not an accessibility plugin but a support plugin that places the warnings and errors from the linters front and center. Its nice to see the issues directly without having to hover over the squiggly lines or opening the “problems” tab.&lt;/p&gt;
&lt;p&gt;Once you have chosen your accessibility plugin I recommend installing Errorlens to improve visibility of errors and warning messages.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Without Errorlens&lt;/strong&gt;&lt;/p&gt;
&lt;img src=&quot;/blog/without-errorlens.png&quot; alt=&quot;Vscode without Errorlens&quot; class=&quot;no-margin&quot;&gt;
&lt;p&gt;&lt;strong&gt;With Errorlens&lt;/strong&gt;&lt;/p&gt;
&lt;img src=&quot;/blog/vscode-with-errorlens.png&quot; alt=&quot;Vscode with Errorlens&quot; class=&quot;no-margin&quot;&gt;
&lt;h2 id=&quot;wrapping-up&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#wrapping-up&quot; aria-label=&quot;wrapping up permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Wrapping up&lt;/h2&gt;
&lt;p&gt;You still need to have unit and regression tests in place before pushing anything into production but at least the number accessibility issues that get through would be less than just leaving it to CI/CD testing suites. Using proper tools in development makes your work look more professional. It also helps your team. Use these accessibility plugins so you can bake in accessibility into your workflow will less effort.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Five simple steps to improve website accessibility]]></title><description><![CDATA[Accessibility is very important. It ensures that anything we make is available to a greater number of people. It is not just about people…]]></description><link>https://www.codespud.com/2022/five_steps_to_improve_accessibility/</link><guid isPermaLink="false">https://www.codespud.com/2022/five_steps_to_improve_accessibility/</guid><pubDate>Sat, 10 Dec 2022 23:07:00 GMT</pubDate><content:encoded>&lt;p&gt;Accessibility is very important. It ensures that anything we make is available to a greater number of people. It is not just about people who use screen readers.&lt;/p&gt;
&lt;p&gt;Web Content Accessibility Guidelines (WCAG) set down a set of rules on how to make websites accessible to people with health conditions or impairments.&lt;/p&gt;
&lt;p&gt;It is hard to meet all the WCAG criterions. It requires understanding of each criterion and the sufficient techniques to meet those requirements. I have been working to improve accessibility in our product. Most of the time I’ve only needed to remember five things.&lt;/p&gt;
&lt;h2 id=&quot;1-add-labels-to-interactive-elementsbuttons-links-input-etc-and-descriptive-text-to-images&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#1-add-labels-to-interactive-elementsbuttons-links-input-etc-and-descriptive-text-to-images&quot; aria-label=&quot;1 add labels to interactive elementsbuttons links input etc and descriptive text to images permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;1. Add labels to interactive elements(buttons, links, input etc.) and descriptive text to images&lt;/h2&gt;
&lt;p&gt;Interactive elements like buttons, links, and form elements should have labels. Images should have alternative text. This ensures assistive technologies are able to get context for these page elements.&lt;/p&gt;
&lt;h3 id=&quot;buttons&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#buttons&quot; aria-label=&quot;buttons permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Buttons&lt;/h3&gt;
&lt;p&gt;Buttons are used to trigger an action. Best practice is to name it to something that describes the action.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Save&lt;/li&gt;
&lt;li&gt;Download&lt;/li&gt;
&lt;li&gt;Delete&lt;/li&gt;
&lt;li&gt;Add&lt;/li&gt;
&lt;li&gt;etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Save&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;image&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;download.svg&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt; Download this wallpaper &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;There will be instances that you may want to hide the label e.g. icon buttons. You can still be accessible by adding an aria-label.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;aria-label&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;Delete&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;image&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;delete.svg&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;!--ad--&gt;
&lt;h3 id=&quot;links&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#links&quot; aria-label=&quot;links permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Links&lt;/h3&gt;
&lt;p&gt;We use links to provide a way to navigate to other locations on the net. It can be another web page, email address, or a section on the current page. So link labels should convey the purpose or destination.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;/home&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; Home &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4 id=&quot;link-to-download-an-image&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#link-to-download-an-image&quot; aria-label=&quot;link to download an image permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Link to download an image&lt;/h4&gt;
&lt;p&gt;For links with images, you can add an adjacent text or provide the image with alternative text.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;
 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;/wallpaper-wide.jpg&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;image&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;thumbnail.png&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;Download wallpaper&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
 &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4 id=&quot;email&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#email&quot; aria-label=&quot;email permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Email&lt;/h4&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;
 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; Email me to &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;mailto:help@codespud.com&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;get help.&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4 id=&quot;link-to-new-window-or-tab&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#link-to-new-window-or-tab&quot; aria-label=&quot;link to new window or tab permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Link to new window or tab&lt;/h4&gt;
&lt;p&gt;Sometimes you want to provide a portion of the text to screen readers. Style the text so that they are hidden but visible to screen readers.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;target&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;_blank&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;http://google.com&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; 
 Go to Google 
 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;screenreader-only&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;(Link opens in a new tab)&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.screenreader-only&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;position&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;absolute&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;left&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;-10000px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;top&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;auto&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;1px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;1px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;overflow&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;hidden&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4 id=&quot;link-text-should-be-unique&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#link-text-should-be-unique&quot; aria-label=&quot;link text should be unique permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Link text should be unique&lt;/h4&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- Do NOT do this! --&gt;&lt;/span&gt;

&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;ul&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;John Doe&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; 
 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;/user/1&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Read Profile&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; 
 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Sam Flag&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; 
 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;/user/2&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Read Profile&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; 
 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Rick Star&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; 
 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;/user/4&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Read Profile&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; 
 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;ul&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Screen reader users can scan links and may bypass context when they do. The markup above will make it hard for the user to locate the information they are looking for.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- Better! --&gt;&lt;/span&gt;

&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;ul&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
   &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;/user/1&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;John Doe &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;screenreader-only&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;profile&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; 
 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
   &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;/user/2&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Sam Flag &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;screenreader-only&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;profile&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; 
 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
   &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;/user/3&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Rick Star &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;screenreader-only&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;profile&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; 
 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;ul&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now the screen reader can jump to these links and immediately understand that these are links to user profiles.&lt;/p&gt;
&lt;h3 id=&quot;form-elements&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#form-elements&quot; aria-label=&quot;form elements permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Form elements&lt;/h3&gt;
&lt;p&gt;Form elements must have labels. This should be a name or short description of the data you are collecting. For radio or checkbox input types, describe the relationship of the invidual items.&lt;/p&gt;
&lt;h4 id=&quot;explicit-labels&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#explicit-labels&quot; aria-label=&quot;explicit labels permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Explicit labels&lt;/h4&gt;
&lt;p&gt;Using label tag&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;label&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;firstname&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;First name&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;text&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;firstname&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;firstname&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;checkbox&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;attending&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;attending&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;label&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;attending&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Attend event&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Using aria-label&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;search&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;aria-label&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;Search&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Search&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4 id=&quot;implicit-labels&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#implicit-labels&quot; aria-label=&quot;implicit labels permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Implicit labels&lt;/h4&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
 Firstname: 
 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;text&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;firstname&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4 id=&quot;checkbox-and-radio-input-tags&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#checkbox-and-radio-input-tags&quot; aria-label=&quot;checkbox and radio input tags permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Checkbox and radio input tags&lt;/h4&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;checkbox&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;attending&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
 Attend event
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;fieldset&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;legend&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Choose a fruit to buy&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;legend&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;radio&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;fruit&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;apple&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt; Apple
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;radio&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;fruit&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;pineapple&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;Pineapple 
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;radio&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;fruit&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;pear&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt; Pear 
 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;fieldset&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;!--ad--&gt;
&lt;h3 id=&quot;images&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#images&quot; aria-label=&quot;images permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Images&lt;/h3&gt;
&lt;p&gt;Alternative text should describe the image. It is useless for impaired users to hear the image filename.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt; &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;img&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;blue-sky.jpg&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;Beautiful clear summer sky &lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;img&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;couple.png&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;Senior couple holding hands&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Using figure tag&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt; &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;figure&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;img&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;couple.png&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;figcaption&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Senior couple holding hands&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;figcaption&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;figure&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Embedded SVG uses title&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;svg&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;viewBox&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;0 0 20 10&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;xmlns&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;http://www.w3.org/2000/svg&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;polygon&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;points&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;473.486,182.079 310.615,157.952 235.904,11.23 162.628,158.675 0,184.389 117.584,299.641 91.786,462.257 237.732,386.042 384.416,460.829 357.032,298.473 &lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;title&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;A black star&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;title&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;polygon&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;svg&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id=&quot;2-do-a-keyboard-test-ensure-focus-order-makes-sense&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#2-do-a-keyboard-test-ensure-focus-order-makes-sense&quot; aria-label=&quot;2 do a keyboard test ensure focus order makes sense permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;2. Do a keyboard test. Ensure focus order makes sense.&lt;/h2&gt;
&lt;p&gt;Screen readers and assistive technologies work with/like a keyboard. Ensuring that your site is keyboard accessible will help in navigating through interactive elements like buttons and links.&lt;/p&gt;
&lt;p&gt;The rule is if an element is operable using the mouse then you should be able to do the same via the keyboard.&lt;/p&gt;
&lt;p&gt;At the very least, a user should be able to:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Navigate through elements using the &lt;kbd&gt;Tab&lt;/kbd&gt; (and &lt;kbd&gt;Shift + Tab&lt;/kbd&gt;) key.&lt;/li&gt;
&lt;li&gt;Confirm action using the &lt;kbd&gt;Enter&lt;/kbd&gt; key or &lt;kbd&gt;Spacebar&lt;/kbd&gt;.&lt;/li&gt;
&lt;li&gt;Close a revealed widget using the &lt;kbd&gt;Escape&lt;/kbd&gt; key e.g. popup menu.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;It is important to understand the UI/page/form functionality. Check that each functional element is navigate-able and operable using the keyboard.&lt;/p&gt;
&lt;p&gt;The focus order should follow the visual order on the page. If you find something out of place or an element is not focusable. Refactor your code or add tabindex to manage the focus order.&lt;/p&gt;
&lt;p&gt;Make focusable&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;tabindex&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;0&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;form-response&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Submission is successful&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Prevent element from getting focus&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;drawer is-closed&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;tabindex&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;-1&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id=&quot;3-use-semantic-markup&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#3-use-semantic-markup&quot; aria-label=&quot;3 use semantic markup permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;3. Use semantic markup&lt;/h2&gt;
&lt;p&gt;Semantic elements&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Region (main, nav, footer, header etc.)&lt;/li&gt;
&lt;li&gt;Lists (ol, ul, li, dl, dt, dd)&lt;/li&gt;
&lt;li&gt;Headings (h1, h2, h3 etc.)&lt;/li&gt;
&lt;li&gt;Content (article, section)&lt;/li&gt;
&lt;li&gt;For emphasis (strong, em, b, i, u etc.)*&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;* &lt;em&gt;In the past, its not recommended to use &lt;code class=&quot;language-text&quot;&gt;b&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;i&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;u&lt;/code&gt; tag when you intend to style a phrase or word to provide emphasis. Latest Screen readers now can understand &lt;code class=&quot;language-text&quot;&gt;strong&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;b&lt;/code&gt;(old) tag serve the same purpose. It is true for &lt;code class=&quot;language-text&quot;&gt;em&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;i&lt;/code&gt; too.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Landmark tags provide shortcuts for assistive technologies to bypass blocks on a page. For example, a user can go straight to the main content (marked by the &lt;code class=&quot;language-text&quot;&gt;main&lt;/code&gt; tag) or jump to the navigation block to move to a new page (wrapped by &lt;code class=&quot;language-text&quot;&gt;nav&lt;/code&gt; tag).&lt;/p&gt;
&lt;!--ad--&gt;
&lt;p&gt;Headings aid assistive technologies to skip through topics on a page. For example, if I only want to know about the legal ramifications of whaling, I can locate the third heading and read on the topic.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt; &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;h2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Moby Dick and whales in literature&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;h2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; 
 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Captain Ahab&apos;s nemesis ... &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;

 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;h2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;How to catch a whale&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;h2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;First, you need a boat. ... &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;

 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;h2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Whaling is illegal in most countries&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;h2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;IWC banned the practice in 1986 ... &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Use list tags to describe a collection. Screen readers will anounce a list and help it navigate each item and were you are in the list.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- screen reader will treat this as a block of text
Do NOT do this if you intend to present a list --&gt;&lt;/span&gt;

&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;h3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; Fruits on sale&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;h3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;list&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Pineapple&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Apple&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Mango&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Pear&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;    

&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- proper list uses list elements --&gt;&lt;/span&gt;

&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;h3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; Fruits on sale &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;h3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;ul&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;list&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Pineapple&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Apple&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Mango&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Pear&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;ul&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;    
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id=&quot;4-make-sure-to-have-color-and-non-color-indicators-to-convey-the-same-information&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#4-make-sure-to-have-color-and-non-color-indicators-to-convey-the-same-information&quot; aria-label=&quot;4 make sure to have color and non color indicators to convey the same information permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;4. Make sure to have color and non-color indicators to convey the same information.&lt;/h2&gt;
&lt;p&gt;Using a red asterisk to tag required fields is a classic example of this. Using a symbol and a color ensures that color-impaired users can distinguish required fields.&lt;/p&gt;
&lt;p&gt;Another example is adding patterns to a chart. Using patterns in conjunction with color make charts more inclusive. Imagine looking at a bar chart using only a color key. If a user suffering color blindness look at the same chart, he/she will find it hard to understand.&lt;/p&gt;
&lt;h2 id=&quot;5-use-relative-sizing-for-fonts&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#5-use-relative-sizing-for-fonts&quot; aria-label=&quot;5 use relative sizing for fonts permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;5. Use relative sizing for fonts&lt;/h2&gt;
&lt;p&gt;For font-size, use relative units(em, rem) instead of absolute units (px, pt). I recommend using &lt;code class=&quot;language-text&quot;&gt;rem&lt;/code&gt; with a body font size of 16px. Using relative units will ensure that users that need to zoom in on text are able to. This is especially important in mobile devices with smaller screens.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;
&lt;span class=&quot;token selector&quot;&gt;body&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 16px &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token selector&quot;&gt;h1&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 4 rem &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token selector&quot;&gt;h2&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 2.5 rem &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token selector&quot;&gt;blockquote&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 1.25rem &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token selector&quot;&gt;p&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 1rem&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id=&quot;wrapping-up&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#wrapping-up&quot; aria-label=&quot;wrapping up permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Wrapping up&lt;/h2&gt;
&lt;p&gt;There are more things to do to make a truly accessible website like color contrast and using ARIA attributes. For now, follow these few simple steps and you will have a more inclusive site that caters to a wider audience than just leaving it as is.&lt;/p&gt;
&lt;h2 id=&quot;reference&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#reference&quot; aria-label=&quot;reference permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Reference&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://www.w3.org/WAI/WCAG21/quickref/&quot;&gt;How to meet WCAG (quick reference)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://webaim.org/techniques/keyboard/&quot;&gt;WebAIM: Keyboard Accessibility&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://accessibility.huit.harvard.edu/provide-accessible-labels-and-instructions&quot;&gt;Harvard.edu: Digital Accessibility&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[Working with Date and Time Input]]></title><description><![CDATA[I remember using JqueryUI’s datepicker. It was my go-to calendar widget in the past. It was great.  I just drop an input box give it an “id” and then run a function. You get a great-looking calendar picker for your forms. It was a great bit of software engineering. I’ve used it in a lot of my old projects and clients were impressed.]]></description><link>https://www.codespud.com/2022/working_with_date_tag/</link><guid isPermaLink="false">https://www.codespud.com/2022/working_with_date_tag/</guid><pubDate>Fri, 09 Dec 2022 12:07:00 GMT</pubDate><content:encoded>&lt;p&gt;I remember using JqueryUI’s datepicker. It was my go-to calendar widget in the past. It was great.  I just drop an input box give it an “id” and then run a function.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;javascript&quot;&gt;&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;
&lt;span class=&quot;token function&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;#datepicker&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;datepicker&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You get a great-looking calendar picker for your forms. It was a great bit of software engineering. I’ve used it in a lot of my old projects and clients were impressed.  &lt;!--more--&gt;&lt;/p&gt;
&lt;p&gt;Some experts strongly advise against adding too many third-party libraries to websites. The extra library requests increase the time your site loads. Now that &lt;a href=&quot;https://www.browserstack.com/guide/why-website-speed-is-important&quot;&gt;site speed has grown increasingly important to users&lt;/a&gt;, developers must be smart when deciding on the modules they add to their projects. Resources like javascript files block the browser from rendering until it’s fully loaded.&lt;/p&gt;
&lt;p&gt;One less library to load is a few seconds slashed from your site’s loading time. Read &lt;a href=&quot;https://web.dev/optimizing-content-efficiency-loading-third-party-javascript/&quot;&gt;Web.dev&lt;/a&gt; for more information regarding optimizing content loading with regards to third-party javascript.&lt;/p&gt;
&lt;h2 id=&quot;use-native-elements&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#use-native-elements&quot; aria-label=&quot;use native elements permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Use native elements&lt;/h2&gt;
&lt;p&gt;One strategy to optimize a website is to use native elements like the date and time inputs instead of third-party widgets.&lt;/p&gt;
&lt;p&gt;Aside from reducing the fat from your site, using native elements improves accessibility. You don’t need the extra coding necessary to make these elements work with assistive technologies.&lt;/p&gt;
&lt;h2 id=&quot;date-input&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#date-input&quot; aria-label=&quot;date input permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Date input&lt;/h2&gt;
&lt;p&gt;The date input looks pretty much like any regular input element. Some browsers(e.g. Chrome) will have a placeholder corresponding to the date value and a calendar icon button.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;label&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;birthdate&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Birth date:&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;date&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;birthdate&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;birthdate&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;demo&quot;&gt;
&lt;label for=&quot;birthdate&quot;&gt;Birth date:&lt;/label&gt;
&lt;input type=&quot;date&quot; id=&quot;birthdate&quot; name=&quot;birthdate&quot; /&gt;
&lt;/div&gt;
&lt;h2 id=&quot;month-input&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#month-input&quot; aria-label=&quot;month input permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Month input&lt;/h2&gt;
&lt;p&gt;The month input lets a user enter a month and year. The input value returned is of format &lt;code class=&quot;language-text&quot;&gt;YYYY-MMM&lt;/code&gt; where &lt;code class=&quot;language-text&quot;&gt;YYYY&lt;/code&gt; is the four-digit year and &lt;code class=&quot;language-text&quot;&gt;MM&lt;/code&gt; is the month number e.g. January is &lt;code class=&quot;language-text&quot;&gt;01&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Month&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;month&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;demo&quot;&gt;
    &lt;label&gt;
        &lt;span&gt;Month&lt;/span&gt;
        &lt;input type=&quot;month&quot; &gt;
    &lt;/label&gt;
&lt;/div&gt;
&lt;h2 id=&quot;week-input&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#week-input&quot; aria-label=&quot;week input permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Week input&lt;/h2&gt;
&lt;p&gt;Use the &lt;code class=&quot;language-text&quot;&gt;week&lt;/code&gt; input type when you want to accept the week number of a year in your forms. It lets a user set up a picker for the 52/53 weeks out of a year.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Week&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;week&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;week&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;demo&quot;&gt;
&lt;label&gt;
    &lt;span&gt;Week&lt;/span&gt;
    &lt;input type=&quot;week&quot; name=&quot;week&quot; &gt;
&lt;/label&gt;
&lt;/div&gt;
&lt;h2 id=&quot;time-input&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#time-input&quot; aria-label=&quot;time input permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Time input&lt;/h2&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Time: &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;time&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;demo&quot;&gt;
&lt;label&gt;
        &lt;span&gt;Time: &lt;/span&gt;
        &lt;input type=&quot;time&quot;&gt;
&lt;/label&gt;
&lt;/div&gt;
&lt;h2 id=&quot;date-time-local-input&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#date-time-local-input&quot; aria-label=&quot;date time local input permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Date-time local input&lt;/h2&gt;
&lt;p&gt;The &lt;code class=&quot;language-text&quot;&gt;datetime-local&lt;/code&gt; input type provides a way to input both date and time.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Date and time - local: &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;datetime-local&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;demo&quot;&gt;
&lt;label&gt;
    &lt;span&gt;Date and time - local: &lt;/span&gt;
    &lt;input type=&quot;datetime-local&quot;&gt;
&lt;/label&gt;
&lt;/div&gt;
&lt;!--ad--&gt;
&lt;h2 id=&quot;specifying-a-range&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#specifying-a-range&quot; aria-label=&quot;specifying a range permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Specifying a range&lt;/h2&gt;
&lt;p&gt;There will be instances where you want to limit the possible values. For example, your form is about a month-long event. You can prevent your clients from setting up a date that is outside your set event by specifying a range. This is done with the minimum(min) and maximum(max) values.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;label&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;event&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Event date:&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;date&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;eventdate&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;eventdate&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;min&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;2023-04-01&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;max&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;2023-04-30&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;demo&quot;&gt;
&lt;label for=&quot;eventdate&quot;&gt;Event date:&lt;/label&gt;
&lt;input type=&quot;date&quot; id=&quot;eventdate&quot; name=&quot;eventdate&quot; min=&quot;2023-04-01&quot; max=&quot;2023-04-30&quot;/&gt;
&lt;/div&gt;
&lt;p&gt;Another use case is preventing inputting past dates, for example when scheduling airplane flights. Specifying the minimum value to date before today is what you want to do.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Today is: 2022-12-01&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;label&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;flightstartdate&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Event date:&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;date&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;flightstartdate&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;flightstartdate&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;demo&quot;&gt;
&lt;p&gt;&lt;label for=&quot;flightstartdate&quot;&gt;Event date:&lt;/label&gt;
&lt;input type=&quot;date&quot; id=&quot;flightstartdate&quot; name=&quot;flightstartdate&quot; min=&quot;2023-12-01&quot; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Limit the &lt;code class=&quot;language-text&quot;&gt;week&lt;/code&gt; input to a certain year, e.g. selling monthly tickets for a sports season.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Event Month&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;month&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;min&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;2022-01&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;2022-12&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;demo&quot;&gt;
    &lt;label&gt;
        &lt;span&gt;Event Month&lt;/span&gt;
        &lt;input type=&quot;month&quot; min=&quot;2022-01&quot; value=&quot;2022-12&quot; &gt;
    &lt;/label&gt;
&lt;/div&gt;
&lt;p&gt;The format for the &lt;code class=&quot;language-text&quot;&gt;min&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;max&lt;/code&gt; setup for the &lt;code class=&quot;language-text&quot;&gt;week&lt;/code&gt; input type is “year-week number” e.g. &lt;code class=&quot;language-text&quot;&gt;2023-W01&lt;/code&gt; for the first week of 2023.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Week&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;week&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;week&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;min&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;2023-W01&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;max&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;2023-W52&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;demo&quot;&gt;
&lt;label&gt;
    &lt;span&gt;Week&lt;/span&gt;
    &lt;input type=&quot;week&quot; name=&quot;week&quot; min=&quot;2023-W01&quot; max=&quot;2023-W52&quot;&gt;
&lt;/label&gt;
&lt;/div&gt;
&lt;h2 id=&quot;adding-suggestions&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#adding-suggestions&quot; aria-label=&quot;adding suggestions permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Adding Suggestions&lt;/h2&gt;
&lt;p&gt;Using &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/HTML/Element/datalist&quot;&gt;datalist&lt;/a&gt; element we can add hardcoded values as options to a date input. A great use case for this is suggested dates for restaurant reservations in the current week.&lt;/p&gt;
&lt;h3 id=&quot;date-input-with-datalist&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#date-input-with-datalist&quot; aria-label=&quot;date input with datalist permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Date input with datalist&lt;/h3&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Recommended dates: &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;date&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;list&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;recent-dates&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;datalist&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;recent-dates&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;option&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;2022-01-01&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;option&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;2022-02-14&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;option&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;2022-05-01&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;datalist&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;demo&quot;&gt;
&lt;div&gt;
    &lt;label&gt;
    &lt;span&gt;Recommended dates: &lt;/span&gt;
    &lt;input type=&quot;date&quot; list=&quot;recent-dates&quot;&gt;
    &lt;datalist id=&quot;recent-dates&quot;&gt;
        &lt;option value=&quot;2022-01-01&quot;&gt;
        &lt;option value=&quot;2022-02-14&quot;&gt;
        &lt;option value=&quot;2022-05-01&quot;&gt;
    &lt;/datalist&gt;
    &lt;/label&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&quot;time-input-with-datalist&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#time-input-with-datalist&quot; aria-label=&quot;time input with datalist permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Time input with datalist&lt;/h3&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Popular hours: &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;input&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;time&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;list&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;popularHours&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;datalist&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;popularHours&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;option&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;12:00&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;option&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;13:00&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;option&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;14:00&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;datalist&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;label&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;demo&quot;&gt;
&lt;label&gt;
    &lt;span&gt;Popular hours: &lt;/span&gt;
    &lt;input type=&quot;time&quot; list=&quot;popularHours&quot;&gt;
    &lt;datalist id=&quot;popularHours&quot;&gt;
    &lt;option value=&quot;12:00&quot;&gt;
    &lt;option value=&quot;13:00&quot;&gt;
    &lt;option value=&quot;14:00&quot;&gt;
    &lt;/datalist&gt;
&lt;/label&gt;
&lt;/div&gt;
&lt;h2 id=&quot;wrapping-up&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#wrapping-up&quot; aria-label=&quot;wrapping up permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Wrapping up&lt;/h2&gt;
&lt;p&gt;Support is &lt;a href=&quot;https://caniuse.com/input-datetime&quot;&gt;limited but getting better&lt;/a&gt;. Most modern browsers support these input types. Do be wary and check your audience. I still had clients who stuck with IE until IE11 was decommissioned. For old browsers, the input type will default to a regular input text box. Make sure to provide a fallback in those cases.&lt;/p&gt;
&lt;p&gt;I am glad we have native options for something ubiquitous as requiring a date/time input. Try using these new input types in your next project.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Rock-Paper-Scissors-Lizard-Spock Game]]></title><description><![CDATA[I am a big Big Bang Theory fan. So is my wife. Her absolute favorite character is Sheldon Cooper. In one of the episodes Sheldon proposed an improved version of the rock-paper-scissors game.  This version extends the possible moves to five(5). The additional two options would increase the possibility of win chances as it minimizes the chance of both players picking the same move.]]></description><link>https://www.codespud.com/2022/rock-paper-scissors-lizard-spock/</link><guid isPermaLink="false">https://www.codespud.com/2022/rock-paper-scissors-lizard-spock/</guid><pubDate>Sun, 20 Nov 2022 02:13:00 GMT</pubDate><content:encoded>&lt;p&gt;I am a big Big Bang Theory fan. So is my wife. Her absolute favorite character is Sheldon Cooper. In one of the episodes Sheldon proposed an improved version of the rock-paper-scissors game.  This version extends the possible moves to five(5). The additional two options would increase the possibility of win chances as it minimizes the chance of both players picking the same move. &lt;!--more--&gt;&lt;/p&gt;
&lt;p&gt;I made a javascript version. Using a few emojis for the hand graphics. I made a very simple interface&lt;/p&gt;
&lt;h2 id=&quot;game-logic&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#game-logic&quot; aria-label=&quot;game logic permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Game logic&lt;/h2&gt;
&lt;p&gt;The game logic is pretty simple.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;
build gameboard

:play
  get user move
  get computer move
  get win_or_lose
  increment round
  if (round equals max_round) goto display_winner
  goto play 

:display_winner
...
end game
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To check who wins per round we need to know the rules of the game (taken from Big Bang Theory wiki).&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Scissors cuts Paper&lt;/li&gt;
&lt;li&gt;Paper covers Rock&lt;/li&gt;
&lt;li&gt;Rock crushes Lizard&lt;/li&gt;
&lt;li&gt;Lizard poisons Spock&lt;/li&gt;
&lt;li&gt;Spock smashes Scissors&lt;/li&gt;
&lt;li&gt;Scissors decapitates Lizard&lt;/li&gt;
&lt;li&gt;Lizard eats Paper&lt;/li&gt;
&lt;li&gt;Paper disproves Spock&lt;/li&gt;
&lt;li&gt;Spock vaporizes Rock&lt;/li&gt;
&lt;li&gt;(and as it always has) Rock crushes Scissors&lt;/li&gt;
&lt;/ul&gt;
&lt;!--ad--&gt;
&lt;p&gt;Here are the rules again coded in javascript.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;javascript&quot;&gt;&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;
&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;winOrLose&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;playerChoice&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; computerChoice&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;

    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
        &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;playerChoice &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; Hands&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Scissor &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; computerChoice &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; Hands&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Paper&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt;
        &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;playerChoice &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; Hands&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Paper &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; computerChoice &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; Hands&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Rock&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt;
        &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;playerChoice &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; Hands&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Rock &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; computerChoice &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; Hands&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Lizard&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt;
        &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;playerChoice &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; Hands&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Lizard &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; computerChoice &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; Hands&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Spock&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt;
        &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;playerChoice &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; Hands&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Scissors &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; computerChoice &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; Hands&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Lizard&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt;

        &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;playerChoice &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; Hands&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Rock &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; computerChoice &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; Hands&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Scissor&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt;
        &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;playerChoice &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; Hands&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Spock &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; computerChoice &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; Hands&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Scissors&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt;
        &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;playerChoice &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; Hands&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Lizard &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; computerChoice &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; Hands&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Paper&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt;
        &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;playerChoice &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; Hands&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Paper &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; computerChoice &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; Hands&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Spock&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt;
        &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;playerChoice &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; Hands&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Spock &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; computerChoice &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; Hands&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Rock&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token comment&quot;&gt;// player wins &lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;I love hash tables! They minimize code complexity. This is a great alternative to the code above.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;javascript&quot;&gt;&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;WIN_OR_LOSE&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;Hands&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Paper&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;Hands&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Rock&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;Hands&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Rock&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;Hands&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Scissor&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;Hands&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Scissor&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;Hands&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;Paper&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;


&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;WIN_OR_LOSE&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;playerChoice&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;computerChoice&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token comment&quot;&gt;// player wins&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The previous bit of code only handle win conditions, what if both players choose the same move? We test this even before testing win conditions,&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;javascript&quot;&gt;&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;
&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;winOrLose&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;playerChoice&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; computerChoice&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;playerChoice &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; computerChoice&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token comment&quot;&gt;// show tie result  &lt;/span&gt;
      &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Finally, we test if the game has ended. Whenever a round ends, we check if the game should end(finished 10 rounds). If yes, we calculate the game result and notify the user.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;javascript&quot;&gt;&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;  &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;gameOver&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;yourScore&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; pcScore&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; score&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;games &lt;span class=&quot;token operator&quot;&gt;&gt;=&lt;/span&gt; maxGames&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      done &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
      &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;yourScore &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; pcScore&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token function&quot;&gt;gameResult&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;It&apos;s a draw!&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;tie&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;yourScore &lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; pcScore&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token function&quot;&gt;gameResult&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;You win!&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;win&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token function&quot;&gt;gameResult&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;You lost!&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;lose&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
      &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id=&quot;user-interface&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#user-interface&quot; aria-label=&quot;user interface permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;User interface&lt;/h2&gt;
&lt;p&gt;For the input, I made five(5) buttons with images corresponding each game move. When the game starts you are prompted to choose a move. When the player chooses a game move, it’s checked agains winning conditions and depending on the outcome computes the score.&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&quot;/blog/Rock-Paper-Scissors-Lizard-Spock-Game-Images.png&quot; alt=&quot;rock-paper-scissors game buttons&quot;&gt;
&lt;figcaption&gt;
&lt;span&gt;Rock-paper-scissors-lizard-spock game buttons&lt;/span&gt;
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;&lt;a href=&quot;https://codepen.io/chrisbautista/pen/dyJyebW&quot;&gt;&lt;div&gt;&lt;iframe 
        height=&apos;400&apos; 
        scrolling=&apos;no&apos; 
        src=&apos;//codepen.io/chrisbautista/embed/preview/dyJyebW/?height=400&amp;theme-id=dark&amp;default-tab=html,result&apos; 
        frameborder=&apos;no&apos; 
        allowtransparency=&apos;true&apos; 
        allowfullscreen=&apos;true&apos; 
        style=&apos;width: 100%;&apos;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Play the &lt;a href=&quot;https://codepen.io/chrisbautista/full/dyJyebW&quot;&gt;game&lt;/a&gt;. Enjoy!&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Creating My Animated Bottom Bar Experiment]]></title><description><![CDATA[I wanted to see how much we can do with CSS transitions. No keyframe animations at all. Although you would have more control over the…]]></description><link>https://www.codespud.com/2022/animated-bottom-bar/</link><guid isPermaLink="false">https://www.codespud.com/2022/animated-bottom-bar/</guid><pubDate>Sat, 19 Nov 2022 01:07:00 GMT</pubDate><content:encoded>&lt;p&gt;I wanted to see how much we can do with CSS transitions. No keyframe animations at all. Although you would have more control over the animation with keyframes. For our demo, we need a simple change from one state to another. CSS transitions are all we need.&lt;/p&gt;
&lt;p&gt;In one of the animations, I used a technique I call the Sibling-Follow technique. Before you ask, I did not invent this technique - just the name. It’s nice to name something when it’s this good. I got it from one of the front-end sites - I forgot which.&lt;/p&gt;
&lt;p&gt;When I understood the technique, my brain ran on overdrive. I was sketching different designs I can abuse this technique. I used this to animate the highlight element in the codepen below.&lt;/p&gt;
&lt;!--ad--&gt;
&lt;h2 id=&quot;sibling-follow-technique&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#sibling-follow-technique&quot; aria-label=&quot;sibling follow technique permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Sibling-Follow Technique&lt;/h2&gt;
&lt;p&gt;To illustrate, let me walk you through a simple tab bar animation. If you are familiar with Material UI tabs, it behaves very similarly.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://mui.com/material-ui/react-tabs/&quot;&gt;Material UI tabs&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Make a list of buttons. Then, add another element and set the class as follow. We will use this to target and style the element later.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;HTML&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;ul&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; button 1 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; button 2 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; button 3 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; button 4 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; button 5 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;follow&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;ul&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;CSS&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;
&lt;span class=&quot;token selector&quot;&gt;ul,
li&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; flex&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;list-style-type&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; none&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;margin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;ul&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;position&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; relative&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;li&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 50px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 5px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token selector&quot;&gt;.follow&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;position&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; absolute&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;top&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;left&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;transition&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; left 0.4s ease-in-out&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 2px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;background-color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; red&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;I made a Javascript event handler to add the &lt;code class=&quot;language-text&quot;&gt;active&lt;/code&gt; class to the list item containing the button I clicked.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;ul&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; button 1 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;active&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; button 2 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; button 3 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; button 4 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; button 5 &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;follow&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;ul&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Using the sibling selector(~), we apply the desired styling for .follow element. In this case, I want to position the mentioned element above the second list button.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;css&quot;&gt;&lt;pre class=&quot;language-css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;
&lt;span class=&quot;token selector&quot;&gt;li:nth-child(2):active ~ .follow&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;left&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 60px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;I added the other left positions to the rest of the &lt;code class=&quot;language-text&quot;&gt;li&lt;/code&gt; items with some trial and error.&lt;/p&gt;
&lt;p&gt;Voila! We get a simple highlight animation, ala Material UI tabs, with a few markup and the magic of CSS transitions.&lt;/p&gt;
&lt;p&gt;For my demo, I hardcoded the &lt;code class=&quot;language-text&quot;&gt;left&lt;/code&gt; property to the CSS for each transition state. Add a Javascript function to calculate these coordinates for you. Then you do not need to hardcode these values, especially if you are going to incorporate this into your professional work.&lt;/p&gt;
&lt;!--ad--&gt;
&lt;p&gt;You can make it fancier by animating the width of the follow tab at different speeds. Apply different easing functions. Make many follow elements running at various vectors. I will let you play with that on your own. Let your imagination run free.&lt;/p&gt;
&lt;p&gt;I made five tab bar styles. Feel free to use these in your projects.&lt;/p&gt;
&lt;h2 id=&quot;wrapping-up&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#wrapping-up&quot; aria-label=&quot;wrapping up permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Wrapping up&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;You can make pretty amazing things with CSS, HTML, and a bit of Javascript.&lt;/li&gt;
&lt;li&gt;Sibling-Follow technique is a simple method you can use to create tab animations.&lt;/li&gt;
&lt;li&gt;CSS transition is your friend if you want to animate a simple change from one state to another.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All in all, I was happy with the outcome of this exercise. I had so much fun and learned a lot. We could use some accessibility work though. 😜 That is something we can work on for another day.&lt;/p&gt;
&lt;p&gt;I will explain the other animation styles I made with this pen later.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: This pen got showcased in a Codepen Spark newsletter last April 14th (link below). Thanks Codepen!😀🎉&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://codepen.io/spark/280&quot;&gt;Tab Bar Styles, AI Games, and Some Good Forking News (April 14)&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://codepen.io/chrisbautista/pen/NWXjqLN&quot;&gt;&lt;div&gt;&lt;iframe 
        height=&apos;400&apos; 
        scrolling=&apos;no&apos; 
        src=&apos;//codepen.io/chrisbautista/embed/preview/NWXjqLN/?height=400&amp;theme-id=dark&amp;default-tab=html,result&apos; 
        frameborder=&apos;no&apos; 
        allowtransparency=&apos;true&apos; 
        allowfullscreen=&apos;true&apos; 
        style=&apos;width: 100%;&apos;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;/a&gt;&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Build an Accessible Tab Container]]></title><description><![CDATA[As part of the work I do for my employer, I analyze UI elements on our product to check if we need to re-engineer the component to improve…]]></description><link>https://www.codespud.com/2022/accessible-tab-container/</link><guid isPermaLink="false">https://www.codespud.com/2022/accessible-tab-container/</guid><pubDate>Mon, 10 Oct 2022 01:07:00 GMT</pubDate><content:encoded>&lt;p&gt;As part of the work I do for my employer, I analyze UI elements on our product to check if we need to re-engineer the component to improve accessibility. One of the accessibility challenges I have reworked for our company site is the tabbed container.&lt;/p&gt;
&lt;p&gt;Imagine a folder with pages you can flip through using tabs at the edges. That is the closest I can imagine when I think of tabbed containers. This concept is very straightforward, tabs on top of the container  serves as buttons to access the corresponding grouped content. Only one grouped content is shown at any time. I love tabbed containers because they are very good at cleaning up the interface when you have so much content but have the same level of importance.&lt;/p&gt;
&lt;p&gt;For the new component, I based it on the &lt;a href=&quot;https://www.w3.org/WAI/ARIA/apg/patterns/tabpanel/&quot;&gt;tab panel pattern&lt;/a&gt; suggested in the WAI(&lt;em&gt;Web Accessibility Initiative&lt;/em&gt;) site.&lt;/p&gt;
&lt;h2 id=&quot;focus-order&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#focus-order&quot; aria-label=&quot;focus order permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Focus Order&lt;/h2&gt;
&lt;p&gt;Using the keyboard with the old tabbed container, the focus goes from the first tab, 2nd tab, 3rd tab, and so on. Then the tab content 1, etc. One would need to finish traversing the tabs before you can access the first tab’s content. Its confusing to screenreader users as you would assume when you focus on the tab you can read the content.&lt;/p&gt;
&lt;figure&gt;
  &lt;img src=&quot;/blog/build_an_accessible_tab_container___focus_order.png&quot; alt=&quot;incorrect focus order&quot;&gt;
  &lt;figcaption&gt;
    &lt;p&gt;The navigation sequence does not follow the natural way of content consumption.&lt;/p&gt;
  &lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;To improve the focus/read order, we should make the first tab active and prevent the inactive tabs from getting the focus sequence. Navigation will go directly to the content when tabbing from the tab button. Another rule some UI developers forget is to make sure hidden elements do not get focus. So for the previous example, the “Services” and “Products” content panels and its content must not receive focus.&lt;/p&gt;
&lt;figure&gt;
  &lt;img src=&quot;/blog/build_an_accessible_tab_container___correct_focus_order.png&quot; alt=&quot;corrected focus order&quot;&gt;
  &lt;figcaption&gt;
    &lt;p&gt; Now the user is only able to access the currently active tab and tab content&lt;/p&gt;.
  &lt;/figcaption&gt;
&lt;/figure&gt;
&lt;!--ad--&gt;
&lt;h2 id=&quot;keyboard-controls&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#keyboard-controls&quot; aria-label=&quot;keyboard controls permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Keyboard controls&lt;/h2&gt;
&lt;p&gt;The old tab container component only supported the &lt;kbd&gt;Tab&lt;/kbd&gt; key to navigate which only follows the DOM sequence. A few tabs are tolerable but once you get more than five(5) tabs it can be annoying for the user to use.&lt;/p&gt;
&lt;p&gt;To make the component keyboard accessible, we add behavior that follows the WAI tab panel pattern. The tab navigation activates once the focus goes to the active tab (button). Using the &lt;kbd&gt;Arrow Left&lt;/kbd&gt; and &lt;kbd&gt;Arrow Right&lt;/kbd&gt;, the user can navigate to the previous and next tabs correspondingly.&lt;/p&gt;
&lt;p&gt;Additionally, you have two types of tab container behavior. &lt;em&gt;Automatic&lt;/em&gt; tab containers will switch to a new tab when focus changes. While, &lt;em&gt;Manual&lt;/em&gt; tabbed containers use &lt;kbd&gt;Enter&lt;/kbd&gt; or &lt;kbd&gt;Spacebar&lt;/kbd&gt; key to confirm the switch. I will use the “automatic” behavior for our demo.&lt;/p&gt;
&lt;figure&gt;
  &lt;img src=&quot;/blog/build_an_accessible_tab_container___active_tab_focused.png&quot; alt=&quot;active tab is focused&quot;&gt;
  &lt;figcaption&gt;
    &lt;p&gt;The active tab shows focused styling when navigating with the keyboard. Using the arrow keys we can navigate to other tabs.&lt;/p&gt;  
  &lt;/figcaption&gt;
&lt;/figure&gt;
&lt;h2 id=&quot;aria-attributes&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#aria-attributes&quot; aria-label=&quot;aria attributes permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;ARIA attributes&lt;/h2&gt;
&lt;figure&gt;
  &lt;blockquote&gt; Accessible Rich Internet Applications (ARIA) is a set of roles and attributes that define ways to make web content and web applications (especially those developed with JavaScript) more accessible to people with disabilities.
  &lt;/blockquote&gt;
  &lt;figcaption&gt;
    &lt;cite&gt;- MDN&lt;/cite&gt;  
  &lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;It would have been nice if there was a tab panel semantic tag. There is none so we use ARIA attributes. On their own ARIA attributes do not do much. It does not add styling or extra behavior. But for screen readers or tools that aid people with impairments, ARIA attributes paint a picture that a browser can interpret.&lt;/p&gt;
&lt;p&gt;For the tabbed container, we set the following ARIA attributes.&lt;/p&gt;
&lt;table&gt;
  &lt;thead&gt;
  &lt;tr&gt;
    &lt;th style=&quot;min-width: 200px;&quot;&gt;ARIA attribute/role&lt;/th&gt;
    &lt;th&gt;Description&lt;/th&gt;
  &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
  &lt;tr&gt;
    &lt;td&gt;role=tablist&lt;/td&gt;
    &lt;td&gt;Container for tab buttons&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;role=tab&lt;/td&gt;
    &lt;td&gt;Tab button element. Contains the label for the currently active content.&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;role=tabpanel&lt;/td&gt;
    &lt;td&gt;Container for the currently active tab content&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;aria-selected=true&lt;/td&gt;
    &lt;td&gt;Tab button is selected and content is visible&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;aria-selected=false&lt;/td&gt;
    &lt;td&gt;Tab button is inactive and content is hidden&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;tabindex=-1&lt;/td&gt;
    &lt;td&gt;Removes the element from tab order sequence. We use this for the inactive tabs and hidden tab content. Aids in focus management.&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;aria-controls=ID&lt;/td&gt;
    &lt;td&gt;Set on the tab button. ID refers to the associated tab content&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;aria-labelledby=ID&lt;/td&gt;
    &lt;td&gt;Set on the tab content container. Refers to the tab button serving as a label for the content.&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;tabindex=0&lt;/td&gt;
    &lt;td&gt;Set on the tab content container. Puts the container back to tab sequence&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id=&quot;our-tabbed-container-in-action&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#our-tabbed-container-in-action&quot; aria-label=&quot;our tabbed container in action permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Our tabbed container in action&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://codepen.io/chrisbautista/pen/XWZgrVx&quot;&gt;&lt;div&gt;&lt;iframe 
        height=&apos;400&apos; 
        scrolling=&apos;no&apos; 
        src=&apos;//codepen.io/chrisbautista/embed/preview/XWZgrVx/?height=400&amp;theme-id=dark&amp;default-tab=html,result&apos; 
        frameborder=&apos;no&apos; 
        allowtransparency=&apos;true&apos; 
        allowfullscreen=&apos;true&apos; 
        style=&apos;width: 100%;&apos;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;/a&gt;&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Accessible UI Component Series]]></title><description><![CDATA[A short series of accessible UI components built on one shared “Codespud” design-token file, so I could test ARIA Authoring Practices…]]></description><link>https://www.codespud.com/accessible-ui-component-series/</link><guid isPermaLink="false">https://www.codespud.com/accessible-ui-component-series/</guid><pubDate>Thu, 19 May 2022 21:24:33 GMT</pubDate><content:encoded>&lt;p&gt;A short series of accessible UI components built on one shared “Codespud” design-token file, so I could test &lt;a href=&quot;https://www.w3.org/WAI/ARIA/apg/&quot;&gt;ARIA Authoring Practices&lt;/a&gt; patterns myself instead of trusting a component library blindly.&lt;/p&gt;
&lt;p&gt;Two more pieces from the same series already have full write-ups: the &lt;a href=&quot;/accessible-tab-container/&quot;&gt;accessible tab container&lt;/a&gt; and the &lt;a href=&quot;/fix_accessibility_with_focus_within/&quot;&gt;focus-within fixes&lt;/a&gt; for common hover-only UI patterns.&lt;/p&gt;
&lt;h2 id=&quot;accordion&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#accordion&quot; aria-label=&quot;accordion permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Accordion&lt;/h2&gt;
&lt;p&gt;Disclosure pattern using &lt;code class=&quot;language-text&quot;&gt;aria-expanded&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;aria-controls&lt;/code&gt;, and &lt;code class=&quot;language-text&quot;&gt;role=&quot;region&quot;&lt;/code&gt; per the &lt;a href=&quot;https://www.w3.org/WAI/ARIA/apg/patterns/accordion/&quot;&gt;ARIA APG accordion pattern&lt;/a&gt;, with animated expand/collapse and visible focus states.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://codepen.io/chrisbautista/pen/zYRzOPM&quot;&gt;&lt;div&gt;&lt;iframe 
        height=&apos;400&apos; 
        scrolling=&apos;no&apos; 
        src=&apos;//codepen.io/chrisbautista/embed/preview/zYRzOPM/?height=400&amp;theme-id=dark&amp;default-tab=html,result&apos; 
        frameborder=&apos;no&apos; 
        allowtransparency=&apos;true&apos; 
        allowfullscreen=&apos;true&apos; 
        style=&apos;width: 100%;&apos;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;accessible-buttons-in-claymorphic-styling&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#accessible-buttons-in-claymorphic-styling&quot; aria-label=&quot;accessible buttons in claymorphic styling permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Accessible buttons in claymorphic styling&lt;/h2&gt;
&lt;p&gt;Proof that an on-trend visual style (claymorphic / soft-UI) doesn’t have to come at the cost of accessible markup — real &lt;code class=&quot;language-text&quot;&gt;&amp;lt;button&gt;&lt;/code&gt; elements, visible focus rings, and sufficient contrast underneath the styling.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://codepen.io/chrisbautista/pen/PoQjYJz&quot;&gt;&lt;div&gt;&lt;iframe 
        height=&apos;400&apos; 
        scrolling=&apos;no&apos; 
        src=&apos;//codepen.io/chrisbautista/embed/preview/PoQjYJz/?height=400&amp;theme-id=dark&amp;default-tab=html,result&apos; 
        frameborder=&apos;no&apos; 
        allowtransparency=&apos;true&apos; 
        allowfullscreen=&apos;true&apos; 
        style=&apos;width: 100%;&apos;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;shared-design-tokens&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#shared-design-tokens&quot; aria-label=&quot;shared design tokens permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Shared design tokens&lt;/h2&gt;
&lt;p&gt;Both components above (and the tab container/accordion pair) pull from one &lt;a href=&quot;https://codepen.io/chrisbautista/pen/ZEryzKx&quot;&gt;typography and color token file&lt;/a&gt; — a small design system built with accessible contrast ratios in mind from the start.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;More CodePen experiments:&lt;/strong&gt; &lt;a href=&quot;https://codepen.io/chrisbautista&quot;&gt;codepen.io/chrisbautista&lt;/a&gt;&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Mobile Pet Gallery]]></title><description><![CDATA[A CodePen challenge entry: a pet adoption gallery sized to a phone, with two views — a thumbnail grid and a full-bleed carousel — and a…]]></description><link>https://www.codespud.com/mobile-pet-gallery/</link><guid isPermaLink="false">https://www.codespud.com/mobile-pet-gallery/</guid><pubDate>Tue, 12 Apr 2022 05:41:39 GMT</pubDate><content:encoded>&lt;p&gt;A CodePen challenge entry: a pet adoption gallery sized to a phone, with two views — a thumbnail grid and a full-bleed carousel — and a transition between them that runs on CSS alone.&lt;/p&gt;
&lt;h2 id=&quot;the-experiment&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#the-experiment&quot; aria-label=&quot;the experiment permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;The experiment&lt;/h2&gt;
&lt;p&gt;The question was how much of a layout change CSS transitions can absorb before you need JavaScript to animate it. The answer: more than expected, as long as you transition the container rather than the items.&lt;/p&gt;
&lt;p&gt;The two views are one DOM tree. A hidden checkbox holds the mode, and the sibling combinator (&lt;code class=&quot;language-text&quot;&gt;.mode:checked ~ .gallery&lt;/code&gt;) swaps the gallery between a wrapped flex grid of 110px thumbnails and a single-row flex track of 360px slides. The transition list on &lt;code class=&quot;language-text&quot;&gt;.gallery&lt;/code&gt; — &lt;code class=&quot;language-text&quot;&gt;left&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;width&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;height&lt;/code&gt; — plus &lt;code class=&quot;language-text&quot;&gt;width&lt;/code&gt; on each &lt;code class=&quot;language-text&quot;&gt;figure&lt;/code&gt; means the browser tweens the reflow. Clicking a thumbnail unchecks the box and slides the track to that index; the home button re-checks it and returns to zero.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/mobile-pet-gallery-view-image.png&quot; alt=&quot;View pet screen&quot;&gt;&lt;/p&gt;
&lt;p&gt;Paging is the same trick applied to a smaller element. Six dots sit behind a single dark “follow” dot, positioned by &lt;code class=&quot;language-text&quot;&gt;.active:nth-child(n) ~ .follow&lt;/code&gt; rules and transitioned on &lt;code class=&quot;language-text&quot;&gt;left&lt;/code&gt;, so the indicator glides to the current page instead of the page repainting. A short scale keyframe fires on arrival, restarted by the usual clear-animation/force-reflow/restore dance since animations don’t replay on their own.&lt;/p&gt;
&lt;p&gt;JavaScript does the bookkeeping only: track the index, set &lt;code class=&quot;language-text&quot;&gt;gallery.style.left&lt;/code&gt;, toggle the active dot, hide the arrow at either end. Every visible movement is a transition.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://codepen.io/chrisbautista/pen/jOYpKdW&quot;&gt;&lt;div&gt;&lt;iframe 
        height=&apos;400&apos; 
        scrolling=&apos;no&apos; 
        src=&apos;//codepen.io/chrisbautista/embed/preview/jOYpKdW/?height=400&amp;theme-id=dark&amp;default-tab=html,result&apos; 
        frameborder=&apos;no&apos; 
        allowtransparency=&apos;true&apos; 
        allowfullscreen=&apos;true&apos; 
        style=&apos;width: 100%;&apos;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;notes&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#notes&quot; aria-label=&quot;notes permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Notes&lt;/h2&gt;
&lt;p&gt;Transitioning &lt;code class=&quot;language-text&quot;&gt;left&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;width&lt;/code&gt; means animating on layout properties, which is the expensive path. At six slides in a 360px frame it’s fine; a longer gallery would want &lt;code class=&quot;language-text&quot;&gt;transform: translateX()&lt;/code&gt; instead. The checkbox-as-state-holder is doing real work here, but it’s a hack — the mode toggle isn’t announced to assistive tech, and swipe/drag handling never got built.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Links&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://codepen.io/chrisbautista/pen/jOYpKdW&quot;&gt;Pen on CodePen&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Photos from Unsplash, hosted on CodePen assets&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[Remote Development Setup]]></title><description><![CDATA[Tell me if this sounds familiar. You have a workstation that can not support the technology stack your project requires. Having VMs or Docker installed on your machine is out of the question since it can barely support office software.  You end up building a development machine(perhaps an Linux box) as a  desktop server. This works well for a while until you need to access your development setup remotely. Luckily there’s a number of ways you can achieve this.]]></description><link>https://www.codespud.com/2019/remote-development-setups/</link><guid isPermaLink="false">https://www.codespud.com/2019/remote-development-setups/</guid><pubDate>Sun, 19 May 2019 12:07:00 GMT</pubDate><content:encoded>&lt;p&gt;Tell me if this sounds familiar. You have a workstation that can not support the technology stack your project requires. Having VMs or Docker installed on your machine is out of the question since it can barely support office software.  You end up building a development machine(perhaps an Linux box) as a  desktop server. This works well for a while until you need to access your development setup remotely. Luckily there’s a number of ways you can achieve this. &lt;!--more--&gt;&lt;/p&gt;
&lt;h2 id=&quot;the-options&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#the-options&quot; aria-label=&quot;the options permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;The Options&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Local editor/IDE via SFTP&lt;/strong&gt;. - This entails connecting via SFTP and uploading the code changes manually. Problem with this setup, you need to run a lot of steps to test your code. Upload (manually) then run tests, rinse and repeat. Don’t expect to use any IDE functionality here. Not very useful but it works when the need arises. I recommend using &lt;a href=&quot;https://winscp.net/eng/download.php&quot;&gt;WinSCP&lt;/a&gt; on windows for this.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Local editor/IDE with automatic syncing via an SFTP client.&lt;/strong&gt; - Very similar to the first option minus the manual uploads. Some SFTP clients would have a “sync on changes” option. WinSCP has the  &lt;a href=&quot;https://winscp.net/eng/docs/task_keep_up_to_date&quot;&gt;“keep up to date”&lt;/a&gt; feature which serves this purpose well.&lt;/p&gt;
&lt;p&gt;For Apple machines, &lt;a href=&quot;https://panic.com/&quot;&gt;Panic’s&lt;/a&gt; Coda/Transmit setup is a great example.&lt;/p&gt;
&lt;p&gt;Additionally, using a plugin, some editors/IDE’s (e.g. SublimeText, VSCode, etc.) would be able to carry out the same use case. In my experience though, managing files via plugin is not very consistent. When it fails, it fails spectacularly with me ending up trying to resolve corrupted files.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;!--ad--&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Local IDE using rsync&lt;/strong&gt; - This setup leverages &lt;a href=&quot;https://rsync.samba.org/features.html&quot;&gt;rsync&lt;/a&gt; to synchronize your changes automatically. Using rsync is similar to using SFTP with automatic syncing. The difference is that rsync by default only upload/download files that changed. The most popular setup is to watch for file changes and then trigger a rsync command to upload only the delta. No manual uploading but not very different from the first one on this list. You can use inotifywait or gulps watch functionality to monitor file changes then manually trigger a function or command based on rsync.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Using inotifywait&lt;/strong&gt;,&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;#watch_and_sync.sh&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;#!/bin.ssh&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;while&lt;/span&gt; inotifywait &lt;span class=&quot;token parameter variable&quot;&gt;-r&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-e&lt;/span&gt; modify,create,delete /directory&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;do&lt;/span&gt;
    &lt;span class=&quot;token function&quot;&gt;rsync&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-avz&lt;/span&gt; /directory /target
&lt;span class=&quot;token keyword&quot;&gt;done&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Using gulp and &lt;a href=&quot;https://www.npmjs.com/package/gulp-rsync&quot;&gt;gulp-rsync&lt;/a&gt;,&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;npm&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt; gulp-rsync --save-dev&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;js&quot;&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;//gulpfile.js&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; gulp &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;gulp&apos;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; rsync &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;gulp-rsync&apos;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
gulp&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;task&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;watch&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; watchFiles &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;
    &lt;span class=&quot;token string&quot;&gt;&apos;./src/**&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;./templates/**&apos;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; watcher &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; gulp&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;watch&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt; watchedFiles&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;sync&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
gulp&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;task&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;sync&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; gulp&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;js/**&apos;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;pipe&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;rsync&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token literal-property property&quot;&gt;hostname&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;remote.server.com&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token literal-property property&quot;&gt;destination&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;~/project/&apos;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Local IDE using SSHFS&lt;/strong&gt; - SSHFS(Secured SHell File Systems) can mount directories and files from remote machines as if they were local folders. Using this logic you can set up your remotely available codebase into your local IDE. This is very easy to put up since most Linux machines support SSH and it does not need any other libraries to install and configure. Although useful it’s not very consistently executed in most clients.
For windows, check out &lt;a href=&quot;https://www.nsoftware.com/sftp/netdrive/&quot;&gt;NetDrive&lt;/a&gt; and &lt;a href=&quot;http://www.secfs.net/winfsp/&quot;&gt;WinSFP&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Remote editing using vi/vim&lt;/strong&gt; - Developing using vim on the development machine is a very powerful setup. This requires opening a terminal and connecting to the remote machine via SSH. Then navigating to your code base and running vim. You use vi’s powerful text editing features to edit files. A bit of tweaking and installing some vi/vim plugins would make vim work more like an IDE. The problem most have is the learning curve but once you get around the idea of coding on the terminal, you might end up loving it or not. :) Another minor issue is when you need to upload new files like images and PDFs. If you’re used to dragging and dropping your files into your IDE this might be off-putting. You will need a separate SFTP client to do upload these files.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;!--ad--&gt;
&lt;p&gt;Here’s a link to my &lt;a href=&quot;https://github.com/chrisbautista/vim-workflow/blob/master/.vimrc&quot;&gt;vimrc&lt;/a&gt;. Search through Github there’s no shortage of excellent vim configurations that might fit your liking.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;    &lt;span class=&quot;token string&quot;&gt;&quot;====================
    &quot;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;vim&lt;/span&gt; workflow
    &lt;span class=&quot;token string&quot;&gt;&quot; @chrisbautista &quot;&lt;/span&gt;codespud&lt;span class=&quot;token string&quot;&gt;&quot;
    &quot;&lt;/span&gt; features:
    &lt;span class=&quot;token string&quot;&gt;&quot; - asynchronous linting
    &quot;&lt;/span&gt; - prettier
    &lt;span class=&quot;token string&quot;&gt;&quot; - dark theme
    &quot;&lt;/span&gt; - tree &lt;span class=&quot;token function&quot;&gt;file&lt;/span&gt; view via NerdTree
    &lt;span class=&quot;token string&quot;&gt;&quot; - fuzzy file search
    &quot;&lt;/span&gt; - &lt;span class=&quot;token function&quot;&gt;more&lt;/span&gt; info on status and tab lines
    &lt;span class=&quot;token string&quot;&gt;&quot; - keyboard mappings
    &quot;&lt;/span&gt; - php debugging
    &lt;span class=&quot;token string&quot;&gt;&quot; - use , as &amp;lt;leader&gt;
    &quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt;
    
    //&lt;span class=&quot;token punctuation&quot;&gt;..&lt;/span&gt;.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;My recommendation to you is to use vim without modifications. Once you get the hang of it, you might NOT even need plugins.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Remote editing using a cloud editor&lt;/strong&gt; - This has been quite popular lately. My favorite is &lt;a href=&quot;https://en.wikipedia.org/wiki/Cloud9_IDE&quot;&gt;Cloud9 IDE&lt;/a&gt;. Even &lt;a href=&quot;https://aws.amazon.com/cloud9/&quot;&gt;Amazon Web Services(AWS) uses it&lt;/a&gt; for its cloud services.&lt;/p&gt;
&lt;p&gt;Using the &lt;a href=&quot;https://github.com/c9/core&quot;&gt;Cloud9 IDE&lt;/a&gt; project you can set up any code base and make it available via the browser. It is not as powerful as Eclipse ( or clones e.g. PHPStorm, Netbeans) but it keeps your code and tasks in the same machine — not yet at least. But it is significantly better than most options in this list as its very similar to how you would develop in a regular IDE. Most would have terminal emulation as well and support for plugins. The problem is you can’t really do this for all your projects. Since you will be exposing the editor via the browser you still run the risk having your code hacked easier than without it. Like any internal application, there are ways to secure it.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;
&lt;span class=&quot;token comment&quot;&gt;# Install&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;git&lt;/span&gt; clone https://github.com/c9/core.git c9sdk
&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; c9sdk
scripts/install-sdk.sh

&lt;span class=&quot;token comment&quot;&gt;# Start Cloud9 and expose /var/www/html&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;node&lt;/span&gt; server.js &lt;span class=&quot;token parameter variable&quot;&gt;-w&lt;/span&gt; /var/www/html
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;VSCode with remote development pack&lt;/strong&gt; - To be precise, the &lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack&quot;&gt;Remote development pack&lt;/a&gt; is only available through &lt;a href=&quot;https://code.visualstudio.com/insiders/&quot;&gt;VS Code Insiders edition&lt;/a&gt; as of yet. No local code needed locally when using the remote development pack. The best benefit is all your beloved VSCode plugins can run on the code as if it’s local.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Aside from SSH, the pack also include support for container setups(Docker) and Windows Subsystem for Linux (WSL).&lt;/p&gt;
&lt;p&gt;To install &lt;a href=&quot;https://code.visualstudio.com/docs/remote/ssh&quot;&gt;Remote development pack: SSH&lt;/a&gt;&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;- Install an [OpenSSH compatible SSH client](https://code.visualstudio.com/docs/remote/troubleshooting#_installing-a-supported-ssh-client) if one is not already present. 
    I recommend installing [Git Bash](https://git-scm.com/downloads) for windows. 

    Note: PuTTY is not supported on Windows since the ssh command must be in the path.
- Install [Visual Studio Code Insiders](https://code.visualstudio.com/insiders/). 
- Open **Visual Studio Code Insiders** then open modules
- Search for [Remote Development](https://code.visualstudio.com/insiders/) extension pack, then hit Install.

From VS Code documentation

&gt;   [Optional] If your server requires multi-factor authentication, set &quot;remote.SSH.showLoginTerminal&quot;:&quot;true&quot; in settings.json 
&gt;   and enable the [ControlMaster](http://man.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man5/ssh_config.5?query=ssh%255fconfig%26arch=i386#ControlMaster) SSH feature. See here for details.&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id=&quot;security&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#security&quot; aria-label=&quot;security permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Security&lt;/h2&gt;
&lt;p&gt;Since your code base needs to be accessed in the cloud, security is very important. Most of these setups use Secured SHell since its more secure than FTP and not to mention a lot of firewalls would have SSH open. There are also some features you might want to keep to secure SSH further.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Never let login with root &lt;code class=&quot;language-text&quot;&gt;(PermitRootLogin=no)&lt;/code&gt; and create sudo-users&lt;/li&gt;
&lt;li&gt;Enable key authentication &lt;code class=&quot;language-text&quot;&gt;(PubKeyAuthentication=yes)&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Limiting the service to a specific host and address instead of listening to all interfaces.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;(ListenAddress=hostname:port)&lt;/code&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Create Private keys with passphrases&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;There are other SSHD configuration options that can further secure your connection. Check some recommendations from &lt;a href=&quot;https://www.ssh.com/ssh/&quot;&gt;ssh.com&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;For Cloud editors like Cloud9 IDE; Enabling SSL(HTTPS), gating(strong password) and limiting access to known networks will keep your risk to a minimum.&lt;/p&gt;
&lt;h2 id=&quot;recommendation&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#recommendation&quot; aria-label=&quot;recommendation permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Recommendation&lt;/h2&gt;
&lt;p&gt;I still prefer using vim for remote development but having an IDE setup like &lt;strong&gt;VSCode with Remote Development pack&lt;/strong&gt; comes with great benefits which a developer like me finds quite appealing. Having to use a graphical UI for engaging my code base not to mention having some great plugins for language support is a major plus. But I digress, this is not an article to compare the benefits of IDEs in development. :) I’ll let you decide on that on your own.&lt;/p&gt;
&lt;p&gt;It really depends on what’s available for you and how comfortable you are in different environments.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Image attributed to &lt;strong&gt;Microsoft VS Code Documentation&lt;/strong&gt;.&lt;/em&gt;&lt;/p&gt;</content:encoded></item><item><title><![CDATA[How to Use Custom Domains with Github Pages]]></title><description><![CDATA[Hosting a project wiki or a personal blog on Github is very easy with github-pages and static site generators like Jekyll.  You will end up with a site hosted on , if you’re happy with that then skip the rest of this article. If you want more or just curious about the steps then keep reading.]]></description><link>https://www.codespud.com/2019/how-to-use-custom-domains-to-github-pages/</link><guid isPermaLink="false">https://www.codespud.com/2019/how-to-use-custom-domains-to-github-pages/</guid><pubDate>Mon, 22 Apr 2019 14:20:00 GMT</pubDate><content:encoded>&lt;p&gt;Hosting a project wiki or a personal blog on Github is very easy with github-pages and static site generators like Jekyll.  You will end up with a site hosted on &lt;code class=&quot;language-text&quot;&gt;&amp;lt;Project/Repository Name&gt;.github.io&lt;/code&gt;, if you’re happy with that then skip the rest of this article. If you want more or just curious about the steps then keep reading. &lt;!--more--&gt;&lt;/p&gt;
&lt;h2 id=&quot;what-youll-need&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#what-youll-need&quot; aria-label=&quot;what youll need permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;What you’ll need&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Domain hosting&lt;/li&gt;
&lt;li&gt;Github hosted static site (gh-pages branch)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;steps&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#steps&quot; aria-label=&quot;steps permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Steps&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Setup your domain hosting&lt;/p&gt;
&lt;p&gt;As an example, I am using Godaddy’s admin panel. Your mileage might be different but most domain providers will have similar tools for you to use.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/godaddy-domain-admin_1.png&quot; alt=&quot;alt text&quot; title=&quot;Godaddy domain admin panel&quot;&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Add a &lt;strong&gt;A&lt;/strong&gt; entry to &lt;strong&gt;185.199.108.153&lt;/strong&gt; with the following details.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Host: @&lt;/li&gt;
&lt;li&gt;Points to: 185.199.109.153&lt;/li&gt;
&lt;li&gt;TTL: 600 seconds&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img src=&quot;/godaddy-domain-manager.png&quot; alt=&quot;alt text&quot; title=&quot;Godaddy domain manager&quot;&gt;&lt;/p&gt;
&lt;ol start=&quot;2&quot;&gt;
&lt;li&gt;
&lt;p&gt;Do the same for &lt;strong&gt;185.199.109.153&lt;/strong&gt;, &lt;strong&gt;185.199.110.153&lt;/strong&gt; and &lt;strong&gt;185.199.111.153&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Add a CNAME with the following details:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Host: www&lt;/li&gt;
&lt;li&gt;Points to: -----.github.io&lt;/li&gt;
&lt;li&gt;TTL: 1 hour&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Save your settings.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;blockquote&gt;
&lt;p&gt;Update: It seems Godaddy has upgraded their interface you need to add those entries and the settings are automatically saved for you.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a name=&quot;setup-gh&quot;&gt;Setup Github Pages&lt;/a&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Switch to your gh-pages branch and create a text file with your domain (e.g.  &lt;a href=&quot;http://www.codespud.com)Save&quot;&gt;www.codespud.com)Save&lt;/a&gt; it in the root of your static site.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img src=&quot;/godaddy-cname-file.png&quot; alt=&quot;alt text&quot; title=&quot;Github pages CNAME file&quot;&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Navigate to &lt;strong&gt;Settings &gt; Options &gt; GitHub Pages&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img src=&quot;/godaddy-github-pages.png&quot; alt=&quot;alt text&quot; title=&quot;Github pages settings&quot;&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Point branch to &lt;strong&gt;gh-pages branch&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Fill in your domain. In my case, it’s &lt;em&gt;&lt;a href=&quot;http://www.codespud.com&quot;&gt;www.codespud.com&lt;/a&gt;&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Enable &lt;strong&gt;‘Enforce HTTPS’&lt;/strong&gt;, if the option is enabled. Sometimes it will indicate you need to wait for 24 hours. Just check again later and enable it if you’re allowed to. If you have a different issue checkout &lt;a href=&quot;https://help.github.com/en/articles/troubleshooting-custom-domains&quot;&gt;Github article&lt;/a&gt; on troubleshooting custom domains.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;hr&gt;
&lt;!--ad--&gt;
&lt;h3 id=&quot;npm-package&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#npm-package&quot; aria-label=&quot;npm package permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;NPM package&lt;/h3&gt;
&lt;p&gt;If you’re familiar with npm, you can use &lt;a href=&quot;https://www.npmjs.com/package/gh-pages-cli&quot;&gt;gh-pages cli&lt;/a&gt; to setup this for you.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;npm&lt;/span&gt; i &lt;span class=&quot;token parameter variable&quot;&gt;-g&lt;/span&gt; gh-pages&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Before you can deploy to gh-pages. Remember to create the CNAME text file I mentioned earlier in step 1 of &lt;a href=&quot;#setup-gh&quot;&gt;Setup Github Pages&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Point it to your static site code, e.g. (&lt;em&gt;dist&lt;/em&gt; folder)&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;gh-pages &lt;span class=&quot;token parameter variable&quot;&gt;-d&lt;/span&gt; dist &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This will set up your Github pages with the content of your &lt;em&gt;dist&lt;/em&gt; folder and point it to whatever domain you specified in CNAME.&lt;/p&gt;
&lt;h2 id=&quot;conclusion&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#conclusion&quot; aria-label=&quot;conclusion permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;If everything went well. You should have your Github hosted site using your shiny new custom domain. :)&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Morsecode-Potato]]></title><description><![CDATA[Morsecode-Potato is an experiment in packaging functionality into reusable React hooks. It translates text to Morse code and plays it back…]]></description><link>https://www.codespud.com/morsecode-potato/</link><guid isPermaLink="false">https://www.codespud.com/morsecode-potato/</guid><pubDate>Tue, 28 Aug 2018 19:21:31 GMT</pubDate><content:encoded>&lt;p&gt;Morsecode-Potato is an experiment in packaging functionality into reusable React hooks. It translates text to Morse code and plays it back as sound, light, or both.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Role&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Sole author. I built the hooks and the demo app:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;useMorse&lt;/code&gt; — translates text to international Morse code (ITU-R M.1677-1) and returns a Morse string.&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;useMorsePlayer&lt;/code&gt; — plays a Morse string as audio, as a silent visual signal, or both in sync. One clock drives everything, so sound and light can’t drift.&lt;/li&gt;
&lt;li&gt;Demo page — a Tailwind-styled React app themed after an old-time telegraph station, with an input text area, playback controls, and an abbreviation reference table.&lt;/li&gt;
&lt;/ul&gt;
&lt;figure&gt;
&lt;img src=&quot;/morsecode-potato-app.png&quot; width=&quot;50%&quot; alt=&quot;Morsecode-Potato demo page in light theme&quot; /&gt;
&lt;figcaption&gt;Demo page in light theme&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;figure&gt;
&lt;img src=&quot;/morsecode-potato-dark.png&quot; width=&quot;50%&quot; alt=&quot;Morsecode-Potato demo page in dark theme&quot; /&gt;
&lt;figcaption&gt;Demo page in dark theme&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;&lt;strong&gt;Links&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://chrisbautista.github.io/morsecode-potato/?202607&quot;&gt;Live demo&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/chrisbautista/morsecode-potato&quot;&gt;Source on GitHub&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[Make Your Bash Prompt Work For You]]></title><description><![CDATA[If you work with Linux or Unix-like operating systems like Ubuntu or the MacOS, you might be familiar with Bourne-Again Shell or BASH for short. This article will show you that with a little elbow grease, you can have your BASH prompt work for you and heck maybe have a little fun with it.]]></description><link>https://www.codespud.com/2016/make-bash-prompt-work/</link><guid isPermaLink="false">https://www.codespud.com/2016/make-bash-prompt-work/</guid><pubDate>Mon, 14 Nov 2016 04:08:17 GMT</pubDate><content:encoded>&lt;p&gt;If you work with Linux or Unix-like operating systems like Ubuntu or the MacOS, you might be familiar with Bourne-Again Shell or &lt;a href=&quot;https://www.gnu.org/software/bash/bash.html&quot;&gt;BASH&lt;/a&gt; for short. This article will show you that with a little elbow grease, you can have your BASH prompt work for you and heck maybe have a little fun with it.&lt;/p&gt;
&lt;!--more--&gt;
&lt;p&gt;People tell me the invention of the GUI (graphical user interface) is the best thing that ever happened to modern computing. I beg to differ. Not all work is accomplished through the GUI nor is it efficient.&lt;/p&gt;
&lt;p&gt;I find myself working on the command line for work more and more — managing my servers even my Apple computer. So I get to spend much of my time on the command line. Launching commands like a stenographer recording the latest court drama. I realized very early how powerful the command line could be.&lt;/p&gt;
&lt;p&gt;But not having a GUI does not mean you should be happy with the default command prompt. Is this familiar?&lt;figure&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/assets/2016/11/boring.png&quot; alt=&quot;boring&quot; width=&quot;512&quot; height=&quot;224&quot; class=&quot;alignnone size-full wp-image-544&quot; srcset=&quot;/assets/2016/11/boring.png 512w, /assets/2016/11/boring-300x131.png 300w&quot; sizes=&quot;(max-width: 512px) 100vw, 512px&quot; /&gt; &lt;figcaption&gt;Boring command prompt!&lt;/figcaption&gt;&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;Using the table below we can build a BASH prompt that is not only pretty but saves us a few keystrokes as well.&lt;/p&gt;
&lt;h2 id=&quot;bash-special-characters-reference&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#bash-special-characters-reference&quot; aria-label=&quot;bash special characters reference permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;BASH Special Characters Reference&lt;/h2&gt;
&lt;table &gt;
  &lt;tr&gt;
    &lt;th&gt;
      Special character
    &lt;/th&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;&amp;lt;th align=&quot;left&quot;&gt;
  Description
&amp;lt;/th&gt;

&amp;lt;th&gt;
  Special character
&amp;lt;/th&gt;

&amp;lt;th align=&quot;left&quot;&gt;
  Description
&amp;lt;/th&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td align=&quot;center&quot;&gt;
      \a
    &lt;/td&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;&amp;lt;td&gt;
  an ASCII bell character (07)
&amp;lt;/td&gt;

&amp;lt;td align=&quot;center&quot;&gt;
  \d
&amp;lt;/td&gt;

&amp;lt;td&gt;
  the date in &amp;amp;#8220;Weekday Month Date&amp;amp;#8221; format (e.g., &amp;amp;#8220;Tue May 26&amp;amp;#8221;)
&amp;lt;/td&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td align=&quot;center&quot;&gt;
      \]
    &lt;/td&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;&amp;lt;td&gt;
  end a sequence of non-printing characters
&amp;lt;/td&gt;

&amp;lt;td align=&quot;center&quot;&gt;
  \e
&amp;lt;/td&gt;

&amp;lt;td&gt;
  an ASCII escape character (033)
&amp;lt;/td&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td align=&quot;center&quot;&gt;
      \h
    &lt;/td&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;&amp;lt;td&gt;
  the hostname up to the first `.&amp;amp;#8217;
&amp;lt;/td&gt;

&amp;lt;td align=&quot;center&quot;&gt;
  \H
&amp;lt;/td&gt;

&amp;lt;td&gt;
  the hostname
&amp;lt;/td&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td align=&quot;center&quot;&gt;
      \j
    &lt;/td&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;&amp;lt;td&gt;
  the number of jobs currently managed by the shell
&amp;lt;/td&gt;

&amp;lt;td align=&quot;center&quot;&gt;
  \l
&amp;lt;/td&gt;

&amp;lt;td&gt;
  the basename of the shell&amp;amp;#8217;s terminal device name
&amp;lt;/td&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td align=&quot;center&quot;&gt;
      \n
    &lt;/td&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;&amp;lt;td&gt;
  newline
&amp;lt;/td&gt;

&amp;lt;td align=&quot;center&quot;&gt;
  \r
&amp;lt;/td&gt;

&amp;lt;td&gt;
  carriage return
&amp;lt;/td&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td align=&quot;center&quot;&gt;
      \s
    &lt;/td&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;&amp;lt;td&gt;
  the name of the shell, the basename of $0 (the portion following the final slash)
&amp;lt;/td&gt;

&amp;lt;td align=&quot;center&quot;&gt;
  \t
&amp;lt;/td&gt;

&amp;lt;td&gt;
  the current time in 24-hour HH:MM:SS format
&amp;lt;/td&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td align=&quot;center&quot;&gt;
      \T
    &lt;/td&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;&amp;lt;td&gt;
  the current time in 12-hour HH:MM:SS format
&amp;lt;/td&gt;

&amp;lt;td align=&quot;center&quot;&gt;
  \@
&amp;lt;/td&gt;

&amp;lt;td&gt;
  the current time in 12-hour am/pm format
&amp;lt;/td&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td align=&quot;center&quot;&gt;
      \A
    &lt;/td&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;&amp;lt;td&gt;
  the current time in 24-hour HH:MM format
&amp;lt;/td&gt;

&amp;lt;td align=&quot;center&quot;&gt;
  \u
&amp;lt;/td&gt;

&amp;lt;td&gt;
  the username of the current user
&amp;lt;/td&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td align=&quot;center&quot;&gt;
      \v
    &lt;/td&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;&amp;lt;td&gt;
  the version of bash (e.g., 2.00)
&amp;lt;/td&gt;

&amp;lt;td align=&quot;center&quot;&gt;
  \V
&amp;lt;/td&gt;

&amp;lt;td&gt;
  the release of bash, version + patchelvel (e.g., 2.00.0)
&amp;lt;/td&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td align=&quot;center&quot;&gt;
      \w
    &lt;/td&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;&amp;lt;td&gt;
  the current working directory
&amp;lt;/td&gt;

&amp;lt;td align=&quot;center&quot;&gt;
  \W
&amp;lt;/td&gt;

&amp;lt;td&gt;
  the basename of the current working directory
&amp;lt;/td&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td align=&quot;center&quot;&gt;
      \!
    &lt;/td&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;&amp;lt;td&gt;
  the history number of this command
&amp;lt;/td&gt;

&amp;lt;td align=&quot;center&quot;&gt;
  \#
&amp;lt;/td&gt;

&amp;lt;td&gt;
  the command number of this command
&amp;lt;/td&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td align=&quot;center&quot;&gt;
      \$
    &lt;/td&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;&amp;lt;td&gt;
  if the effective UID is 0, a #, otherwise a $
&amp;lt;/td&gt;

&amp;lt;td align=&quot;center&quot;&gt;
  \nnn
&amp;lt;/td&gt;

&amp;lt;td&gt;
  the character corresponding to the octal number nnn
&amp;lt;/td&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td align=&quot;center&quot;&gt;
      \\
    &lt;/td&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;&amp;lt;td&gt;
  a backslash
&amp;lt;/td&gt;

&amp;lt;td align=&quot;center&quot;&gt;
  \[
&amp;lt;/td&gt;

&amp;lt;td&gt;
  begin a sequence of non-printing characters, which could be used to embed a terminal control sequence into the prompt
&amp;lt;/td&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td align=&quot;center&quot;&gt;
      \D{format}
    &lt;/td&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;&amp;lt;td colspan=&quot;3&quot;&gt;
  the format is passed to strftime(3) and the result is inserted into the prompt string; an empty format results in a locale-specific time representation. The braces are required
&amp;lt;/td&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
  &lt;/tr&gt;
&lt;/table&gt;
&lt;h2 id=&quot;change-the-bash-prompt&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#change-the-bash-prompt&quot; aria-label=&quot;change the bash prompt permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Change the Bash Prompt&lt;/h2&gt;
&lt;p&gt;The environment variable we want to modify is &lt;strong&gt;PS1&lt;/strong&gt;.&lt;figure&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/assets/2016/11/editPS1.png&quot; alt=&quot;editps1&quot; width=&quot;376&quot; height=&quot;90&quot; class=&quot;alignnone size-full wp-image-535&quot; srcset=&quot;/assets/2016/11/editPS1.png 376w, /assets/2016/11/editPS1-300x72.png 300w&quot; sizes=&quot;(max-width: 376px) 100vw, 376px&quot; /&gt; &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;Using the reference table above we can break down the current prompt as&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;\u&lt;/em&gt; – the current user&lt;/li&gt;
&lt;li&gt;&lt;em&gt;\h&lt;/em&gt; – the computer’s hostname&lt;/li&gt;
&lt;li&gt;&lt;em&gt;\w&lt;/em&gt; – the current working directory&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Not very useful is it? Let’s change that.&lt;/p&gt;
&lt;p&gt;By modifying the PS1 variable and exporting it with the command below we can manipulate the prompt to output anything we want.&lt;figure&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/assets/2016/11/bash_prompt_smiley.png&quot; alt=&quot;bash_prompt_smiley&quot; width=&quot;476&quot; height=&quot;131&quot; class=&quot;alignnone size-full wp-image-538&quot; srcset=&quot;/assets/2016/11/bash_prompt_smiley.png 476w, /assets/2016/11/bash_prompt_smiley-300x83.png 300w&quot; sizes=&quot;(max-width: 476px) 100vw, 476px&quot; /&gt; &lt;figcaption&gt;Add a smiley&lt;/figcaption&gt;&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;Below is my favorite bash prompt which I install for all my servers and even my workstation. I can easily see important details like the hostname – very important if you find yourself managing multiple terminal windows and you can distinguish between windows. This configuration also shows the load averages, the current date and time and the working directory. The color helps to give it contrast to the monotonous black on white default of most terminal windows.&lt;figure&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/assets/2016/11/mybashpromot_in_action.png&quot; alt=&quot;mybashpromot_in_action&quot; width=&quot;719&quot; height=&quot;370&quot; class=&quot;alignnone size-full wp-image-536&quot; srcset=&quot;/assets/2016/11/mybashpromot_in_action.png 719w, /assets/2016/11/mybashpromot_in_action-300x154.png 300w&quot; sizes=&quot;(max-width: 719px) 100vw, 719px&quot; /&gt; &lt;/figure&gt;&lt;/p&gt;
&lt;h2 id=&quot;make-it-permanent&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#make-it-permanent&quot; aria-label=&quot;make it permanent permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Make it Permanent&lt;/h2&gt;
&lt;p&gt;To make your BASH prompt permanent, just edit ~/.bash_profile or ~/.bashrc or ~/.profile or run the command&lt;figure&gt;&lt;/p&gt;
&lt;img src=&quot;/assets/2016/11/make_bashprompt_permanent.png&quot; alt=&quot;Make your bash prompt permanent&quot; width=&quot;722&quot; height=&quot;183&quot; class=&quot;alignnone size-full wp-image-541&quot; srcset=&quot;/assets/2016/11/make_bashprompt_permanent.png 722w, /assets/2016/11/make_bashprompt_permanent-300x76.png 300w&quot; sizes=&quot;(max-width: 722px) 100vw, 722px&quot; /&gt;  
&lt;/figure&gt;
&lt;h2 id=&quot;ideas&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#ideas&quot; aria-label=&quot;ideas permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Ideas&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Count the files in the current directory&lt;/li&gt;
&lt;li&gt;Display in blinking colors the last line of a todo list&lt;/li&gt;
&lt;li&gt;Display CPU/Memory/Disk usage&lt;/li&gt;
&lt;li&gt;Display command to pull up a help screen&lt;/li&gt;
&lt;li&gt;Echo a smiley if the system is working in top condition&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;There you have it, you can now work on the command line with a little bit more help. The key here is to be creative and think of what you want your bash prompt to have. Enjoy!&lt;/p&gt;</content:encoded></item><item><title><![CDATA[BoxerJS]]></title><description><![CDATA[A lightweight jQuery plugin that turns links to images into quick inline previews. BoxerJS wraps image links so they open as fast previews…]]></description><link>https://www.codespud.com/boxerjs/</link><guid isPermaLink="false">https://www.codespud.com/boxerjs/</guid><pubDate>Mon, 02 Mar 2015 23:06:34 GMT</pubDate><content:encoded>&lt;blockquote&gt;
&lt;p&gt;A lightweight jQuery plugin that turns links to images into quick inline previews.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;BoxerJS wraps image links so they open as fast previews instead of full page loads. It supports images and HTML snippets loaded over AJAX. See the demo for live examples.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Install&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Download the files.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Copy &lt;code class=&quot;language-text&quot;&gt;boxer.js&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;boxer.css&lt;/code&gt;, and &lt;code class=&quot;language-text&quot;&gt;close.png&lt;/code&gt; into your project.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Include &lt;code class=&quot;language-text&quot;&gt;boxer.js&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;boxer.css&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Wrap your target anchors in a container:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;boxer&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;picture1.png&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;this is a picture&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;img&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;picture1_thumb.jpg&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;picture2.png&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;this is another picture&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;img&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;picture2_thumb.jpg&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Initialize it: &lt;code class=&quot;language-text&quot;&gt;$(&quot;.boxer&quot;).boxer();&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;strong&gt;Role&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Sole author. I designed and built the plugin, its preview/overlay behavior, and the AJAX snippet support.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Links&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/chrisbautista/boxerjs&quot;&gt;Source on GitHub&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://chrisbautista.github.io/boxerjs/&quot;&gt;Live demo&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[How To Make A Timer/Stopwatch Using AngularJS]]></title><description><![CDATA[I’ve got some leeway pushing Khrunus off the ground.  I’ve always been successful using JavaScript’s timing functions but since Khrunus would primarily be built-in in AngularJS. I have to research a way to reuse my timing snippets into proper Angular code.  To study, I built a simple angular app:]]></description><link>https://www.codespud.com/2014/how-to-make-a-timer-stopwatch-using-angularjs/</link><guid isPermaLink="false">https://www.codespud.com/2014/how-to-make-a-timer-stopwatch-using-angularjs/</guid><pubDate>Sun, 28 Sep 2014 18:09:50 GMT</pubDate><content:encoded>&lt;p&gt;I’ve got some leeway pushing &lt;a title=&quot;Khrunus&quot; href=&quot;https://github.com/chrisbautista/Khrunus&quot; target=&quot;_blank&quot;&gt;Khrunus&lt;/a&gt; off the ground.  I’ve always been successful using JavaScript’s timing functions but since Khrunus would primarily be built-in in AngularJS. I have to research a way to reuse my timing snippets into proper Angular code.  To study, I built a simple angular app:&lt;!--more--&gt;&lt;/p&gt;
&lt;h2 id=&quot;problem&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#problem&quot; aria-label=&quot;problem permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Problem&lt;/h2&gt;
&lt;p&gt;How to use AngularJS to make a time-related app, in this case, a timer for logging elapsed time?&lt;/p&gt;
&lt;h2 id=&quot;what-i-need&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#what-i-need&quot; aria-label=&quot;what i need permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;What I need&lt;/h2&gt;
&lt;p&gt;Before I started this little venture, I need to detail the parameters of the experiment.&lt;/p&gt;
&lt;p&gt;Firstly,  I need to layout my application into two sections. The top section will show a digital clock face and a button to toggle(start or stop) the clock. The bottom section will be a table showing start and end times, as well as the total duration. To know that the application is successful, start and end times should be logged. Using those values I can compute for the duration.&lt;/p&gt;
&lt;p&gt;We have two modes; an idle state,”stopped” and an active mode,”started”. We need to consider that when coding the helper functions.&lt;/p&gt;
&lt;h2 id=&quot;solution&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#solution&quot; aria-label=&quot;solution permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Solution&lt;/h2&gt;
&lt;p&gt;Firstly, we start with a basic AngularJS template. Please note I am assuming you have at least some experience working with HTML, Javascript, and AngularJS.&lt;/p&gt;
&lt;p&gt;I need two sections so I make two main DIVs.&lt;/p&gt;
&lt;p&gt;Next, in DIV 1,  we add another div to serve as the container for the timer digits and a button.&lt;/p&gt;
&lt;p&gt;Next in DIV #2, we format a table with a header and three columns; “Start”, “End” and “Duration(secs)” correspondingly.&lt;/p&gt;
&lt;p&gt;What we have now is not very pretty, we’re going to fix that in a bit. Create a CSS file, call it “app.css”. Let’s style everything as follows,&lt;/p&gt;
&lt;p&gt;Looking good! 🙂  Now to add the functionality we need. Let’s start with some data binding and a basic controller.&lt;/p&gt;
&lt;h4 id=&quot;html&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#html&quot; aria-label=&quot;html permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;HTML&lt;/h4&gt;
&lt;h3 id=&quot;javascript&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#javascript&quot; aria-label=&quot;javascript permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Javascript&lt;/h3&gt;
&lt;p&gt;Awesome! For the button, we’re going to use that as a trigger to toggle between modes as well as an indicator to show the user what’s happening.&lt;/p&gt;
&lt;p&gt;Now, we can switch between modes, using the button data {{mode}} as a toggle flag. Now to the meat of the application, as a reference I’m going to use this basic clock code I use when I need digital clock displays.&lt;/p&gt;
&lt;p&gt;The hero of this application is AngularJS’s &lt;a title=&quot;$timeout service&quot; href=&quot;https://docs.angularjs.org/api/ng/service/$timeout&quot; target=&quot;_blank&quot;&gt;$timeout service&lt;/a&gt;. The $timeout service gives the user a wrapper for window.setTimeOut. So it still acts like setTimeOut but with the code organization and excellent exception handling that AngularJS provides. Our code should follow this format&lt;/p&gt;
&lt;p&gt;We build the clock functionality via a $timeout statement, but first let’s refactor our controller and add two functions to handle the Start and Stop modes.&lt;/p&gt;
&lt;p&gt;Now for the $timeout service,&lt;/p&gt;
&lt;p&gt;You can see that we used the timeout service to recursively call the &lt;strong&gt;StartTimer&lt;/strong&gt; function. When you call &lt;code class=&quot;language-text&quot;&gt;$timeout&lt;/code&gt;, just as window.setTimeOut, you create a timing object that we then save to our variable ‘tmPromise’. We’ll get into more of that later just take a note of it. Since we’re really making a stopwatch and not a clock that tells the current time, let’s recode. We need the current time so we use &lt;code class=&quot;language-text&quot;&gt;date.getTime()&lt;/code&gt;. Adding two more variables timeStart and timeEnd. When we button is clicked, we save the time to &lt;strong&gt;timerStart&lt;/strong&gt;. Every time the timeout completes and we call StartTimer, the value of &lt;strong&gt;$scope.timeEnd&lt;/strong&gt; changes. We then subtract &lt;strong&gt;$scope.timeStart&lt;/strong&gt; to get the current elapsed time in milliseconds. We add some normalization code and we end up with this,&lt;/p&gt;
&lt;p&gt;Now for the stopTimer function, issuing the cancel method will stop the $timeout service. Remember the variable we made earlier, ‘tmPromise’. We will use that as the parameter for our cancel call illustrated below. We then collect the start and end times and push that into the history array.&lt;/p&gt;
&lt;h3 id=&quot;conclusion&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#conclusion&quot; aria-label=&quot;conclusion permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;Yay, we just made an AngularJS timer widget. Adding a service to insert a line in our table we end up with this.&lt;/p&gt;
&lt;p&gt;This is a very simple implementation. One that did not need a unit test but if we wanted to, we can use a $timeout.flush() method. More details from the reference links below.&lt;/p&gt;
&lt;p&gt;See the app in action &lt;a title=&quot;here&quot; href=&quot;http://chrisbautista.github.io/experiments/cbTimerDirective/public_html/&quot; target=&quot;_blank&quot;&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;** UPDATE: Code sample here &lt;a title=&quot;here&quot; href=&quot;http://chrisbautista.github.io/experiments/cbTimerDirective/public_html/&quot; target=&quot;_blank&quot;&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Download all the source &lt;a title=&quot;angular js timer experiment zip file&quot; href=&quot;http://chrisbautista.github.io/experiments/cbTimer/angularjs_timer_experiment.zip&quot; target=&quot;_blank&quot;&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;references&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#references&quot; aria-label=&quot;references permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://docs.angularjs.org/api/ng/service/$timeout&quot;&gt;https://docs.angularjs.org/api/ng/service/$timeout&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://docs.angularjs.org/api/ng/filter/date&quot;&gt;https://docs.angularjs.org/api/ng/filter/date&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[Quick and Free Way to Set Up Your App using Heroku]]></title><description><![CDATA[I had a struck of inspiration earlier this week. I’ve always wanted to make this webapp that has been playing in my mind  for a while and I finally had some ideas to start on.  Of course, like any of my projects, the first thing I do is research. First in my list was a workflow to streamline development. It’s been a while since I modified my workflow and so I thought it was time for a change.]]></description><link>https://www.codespud.com/2014/quick-and-free-way-to-set-up-your-app-using-heroku/</link><guid isPermaLink="false">https://www.codespud.com/2014/quick-and-free-way-to-set-up-your-app-using-heroku/</guid><pubDate>Sun, 20 Apr 2014 20:52:49 GMT</pubDate><content:encoded>&lt;p&gt;I had a struck of inspiration earlier this week. I’ve always wanted to make this webapp that has been playing in my mind  for a while and I finally had some ideas to start on.  Of course, like any of my projects, the first thing I do is research. First in my list was a workflow to streamline development. It’s been a while since I modified my workflow and so I thought it was time for a change.&lt;!--more--&gt;&lt;/p&gt;
&lt;p&gt;Aside from the design and flow of the application, my immediate concern was where to host my apps once I’m done with the first milestone. I was researching around the interweb and a familiar link caught my eye.  Heroku was the 2nd link of my search. I investigated Heroku when I first made a Facebook application for Lowe Philippines.  I remember seeing a link to Heroku from Facebook’s “Create App” wizard. Back then I was more curious than impressed. Anyway, this time I was very curious but now I’m also very impressed with how Heroku made it easy to deploy an app. Heroku does not magically build a scaffold for you but it does guide you through steps in their “Getting started” page and heck it’s free.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;What you get for a free account?&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;One(1) Dyno&lt;/li&gt;
&lt;li&gt;10,000 rows of data (postgres)&lt;/li&gt;
&lt;li&gt;512 Mb RAM&lt;/li&gt;
&lt;li&gt;One(1) hour business-hour support&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A dyno is a processing unit coined by Heroku. Heroku help says “A dyno is a lightweight container running a single user-specified command. You can think of it as a virtualized Unix container—it can run any command available in its default environment”. It’s a lot to take in but it simply means you have one worker processing requests and things for you to serve your website and other arbitrary functions like data requests.  One seems not a lot but with how fast this requests gets done you won’t even notice, unless of course your application gets some substantial traffic.  Aside from the dyno, you get to save 10000 rows of data to Postgres and a generous 512Mb RAM allocation.  If you think your application will need more resources, you can scale up by buying more dynos.  But for a hobby app or POC, a Heroku free account will serve you nicely.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;How to start?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Heroku is very easy to setup.  You can go straight to the toolbelt and the dashboard or you can go to their Getting Started page, which I recommend if you’re starting to learn or new to deploying to Heroku.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;https://devcenter.heroku.com/start&quot; title=&quot;start here to build your heroku app&quot;&gt;Getting Started&lt;/a&gt; &amp;#x3C;-  start here&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Heroku supports a number of languages including PHP, NodeJS etc.  This time I was making a PHP application with some AngularJS for the frontend so I followed the PHP track. Anyway, I just did the steps and I got a functional workflow as a starting point.&lt;/p&gt;
&lt;p&gt;In summary the steps are:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Download and Install Heroku Toolbelt for your OS.&lt;/li&gt;
&lt;li&gt;Login to Heroku&lt;/li&gt;
&lt;li&gt;Get keys&lt;/li&gt;
&lt;li&gt;Create App&lt;/li&gt;
&lt;li&gt;Deploy App with git push&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;strong&gt;Is that it?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;You followed the steps, and you got a lean file structure to start with. You have to ,of course, be familiar with Composer and Git to optimize your project, both of which are not covered by this post. Just google them, there are a lot of well written articles and tutorials out there. I especially like the ff:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://getcomposer.org/doc/00-intro.md&quot;&gt;https://getcomposer.org/doc/00-intro.md&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://www.atlassian.com/git/tutorial/git-basics&quot;&gt;https://www.atlassian.com/git/tutorial/git-basics&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Final thoughts&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The cool thing about this is everything is accessible and manageable from one console. If you’re a little queasy at the idea of working with the console,  this might not be the best thing for you. An alternative is the Heroku dashboard – just create the app and  setup a more familiar way of deployment like github.  Just provide Heroku of a repo and Heroku will monitor and automatically deploy your app when a change is uploaded.&lt;/p&gt;
&lt;p&gt;Heroku is neat and well documented. There’s a bit of a learning curve  especially if you’re starting to learn to code or is a total console-phobe. Also, if you’re app has grown popular and pulling some substantial traffic, you need to increase the dynos or your app will shutdown and refuse to process requests. Which will catch a hefty bill. Nevertheless, it does get you started with some impressive workflow and and it’s free-ish. 🙂&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Some notes:&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;First time you push a project (git push heroku master) and it’s empty, it would trigger a error similar to this&lt;/p&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;!     Push rejected, no Cedar-supported app detected&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;It just means, Heroku does not know what your app is about and so it can’t build the application. Solution is just provide a common starter file like index.php or index.html. This will tell Heroku that you have a PHP or HTML project and build the necessary dependencies.  You can also fix this by providing a composer.json, setting up the dependencies you need.&lt;/p&gt;
&lt;img class=&quot;aligncenter wp-image-318 size-full&quot; src=&quot;/assets/2014/08/Screen-Shot-2014-08-28-at-1.35.13-PM-768x449.png&quot; alt=&quot;Deploy&quot; width=&quot;846&quot; height=&quot;495&quot; srcset=&quot;/assets/2014/08/Screen-Shot-2014-08-28-at-1.35.13-PM.png 846w, /assets/2014/08/Screen-Shot-2014-08-28-at-1.35.13-PM-300x176.png 300w, /assets/2014/08/Screen-Shot-2014-08-28-at-1.35.13-PM-768x449.png 768w&quot; sizes=&quot;(max-width: 846px) 100vw, 846px&quot; /&gt;</content:encoded></item><item><title><![CDATA[Self: AWARE]]></title><description><![CDATA[Self is an award-winning iOS app for the AWARE Foundation of Singapore. Most women do not report domestic violence, verbal or physical…]]></description><link>https://www.codespud.com/self-aware/</link><guid isPermaLink="false">https://www.codespud.com/self-aware/</guid><pubDate>Fri, 29 Jun 2012 21:18:35 GMT</pubDate><content:encoded>&lt;p&gt;Self is an award-winning iOS app for the AWARE Foundation of Singapore.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Most women do not report domestic violence, verbal or physical, because they have no evidence to prove it. When activated, this app monitors for a spike in ambient sound (for example, shouting) and automatically starts recording, saving the audio to a hidden folder the victim can later use as proof of abuse. It can also send an SOS via SMS to a nominated contact when the sound level crosses a set threshold.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;strong&gt;Role&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I built all of the server backend for user management and SMS processing, using the Slim PHP framework for its small footprint. The initial iOS version was created by a contractor; I later took it over and maintained the whole app, applying Noel Perlas’s flat design when it was updated for iOS 6.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Credits&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Concept — Dominic Stallard&lt;/li&gt;
&lt;li&gt;Creative direction — Noel Perlas, Eranga Tennekoon, Mandar Wairkar&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Awards&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://www.dandad.org/work/d-ad-awards-archive/self&quot;&gt;D&amp;#x26;AD Wood Pencil, 2014&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Creative Circle Awards — part of Lowe Singapore’s 29-award haul&lt;/li&gt;
&lt;li&gt;Spikes Asia 2013, Mobile&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[Install Twitter Search Widget]]></title><description><![CDATA[When I started blogging again last September, I was delighted to get a template with built-in message polling to twitter. I played with it a bit and settled with the look you see at the right. I am not a prolific ‘twitterer’, but I love the whole concept of micropublishing.]]></description><link>https://www.codespud.com/2009/install-twitter-search-widget/</link><guid isPermaLink="false">https://www.codespud.com/2009/install-twitter-search-widget/</guid><pubDate>Mon, 19 Oct 2009 04:40:00 GMT</pubDate><content:encoded>&lt;p&gt;When I started blogging again last September, I was delighted to get a template with built-in message polling to twitter. I played with it a bit and settled with the look you see at the right. I am not a prolific ‘twitterer’, but I love the whole concept of &lt;a href=&quot;http://en.wikipedia.org/wiki/Micropublishing&quot;&gt;micropublishing&lt;/a&gt;.&lt;/p&gt;
&lt;!--more--&gt;
&lt;p&gt;Sometimes when I feel lazy but I want something new in potatokorner; I’d post a tweet, from quotes to funny videos, just to see the widget change(LOL). Great as it is – it’s not perfect. What the widget lacks is interactivity. One day, I started planning (with frameworks like &lt;a href=&quot;http://jquery.com/&quot;&gt;Jquery&lt;/a&gt; and &lt;a href=&quot;http://mootools.net/&quot;&gt;Mootools&lt;/a&gt; in mind), to make a custom widget that can access &lt;a href=&quot;http://apiwiki.twitter.com/&quot;&gt;twitter API&lt;/a&gt; with features like searching for a user’s tweets or scrolling through a &lt;a href=&quot;https://twitter.com/twitter101/learning&quot;&gt;Trending Topic&lt;/a&gt; . Also thought adding some nice animation and CSS styles. Luckily, I don’t have to; the nice peeps from Twitter beat me to the punch and released a widget – packing almost all the things I wanted. I experimented with this along with some feed scripts from Google a days back (&lt;a href=&quot;http://potatokorner.blogspot.com/2009/10/updates-on-pepeng.html#main&quot;&gt;Updates on Pepeng&lt;/a&gt;).&lt;/p&gt;
&lt;h4 id=&quot;what-is-a-twitter-search-widget&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#what-is-a-twitter-search-widget&quot; aria-label=&quot;what is a twitter search widget permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;What is a Twitter Search Widget!?&lt;/h4&gt;
&lt;p&gt;The widget’s concept is to supply the it with a search term (or phrase), like ‘potatokorner’ and it will periodically check twitter.com for tweets with the word potatokorner – but not just tweets by yours truly – every single tweet which it appears. Unlike a regular search the widget periodically pulls messages from the site(twitter) and displays it in a marquee. Twitter.com describes it,&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;“Displays search results in real time! Ideal for live events, broadcastings, conferences, TV Shows, or even just keeping up with the news.”&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h4 id=&quot;get-the-widget&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#get-the-widget&quot; aria-label=&quot;get the widget permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Get the widget&lt;/h4&gt;
&lt;p&gt;Making your widget is easy. Log in to twitter.com. Open the Settings page, then click &lt;a href=&quot;http://twitter.com/goodies/widgets&quot;&gt;“You can add twitter to your site here”&lt;/a&gt;.&lt;/p&gt;
&lt;div&gt;
  &lt;a style=&quot;margin-left: 1em; margin-right: 1em;&quot; href=&quot;http://4.bp.blogspot.com/_BBS5bkzuLXM/Stvr3MiCQ0I/AAAAAAAADK0/PAJxPF4FpjA/s1600-h/potatokorner-twitter-search-widget.PNG&quot;&gt;&lt;img src=&quot;http://4.bp.blogspot.com/_BBS5bkzuLXM/Stvr3MiCQ0I/AAAAAAAADK0/PAJxPF4FpjA/s320/potatokorner-twitter-search-widget.PNG&quot; alt=&quot;&quot; border=&quot;0&quot;&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;p&gt;You are asked where you want to place your widget, click “My Website”.&lt;/p&gt;
&lt;div&gt;
  &lt;a style=&quot;margin-left: 1em; margin-right: 1em;&quot; href=&quot;http://3.bp.blogspot.com/_BBS5bkzuLXM/StvssWMQRVI/AAAAAAAADLE/0h7qv6ggYV4/s1600-h/potatokorner-twitter-search-widget-step2.PNG&quot;&gt;&lt;img src=&quot;http://3.bp.blogspot.com/_BBS5bkzuLXM/StvssWMQRVI/AAAAAAAADLE/0h7qv6ggYV4/s320/potatokorner-twitter-search-widget-step2.PNG&quot; alt=&quot;&quot; border=&quot;0&quot;&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;p&gt;Then, you are presented three widgets, choose the “Search Widget”.&lt;/p&gt;
&lt;div&gt;
  &lt;a style=&quot;margin-left: 1em; margin-right: 1em;&quot; href=&quot;http://3.bp.blogspot.com/_BBS5bkzuLXM/StvsyHJVE6I/AAAAAAAADLM/tFwZeVyrcxI/s1600-h/potatokorner-twitter-search-widget-step3.PNG&quot;&gt;&lt;img src=&quot;http://3.bp.blogspot.com/_BBS5bkzuLXM/StvsyHJVE6I/AAAAAAAADLM/tFwZeVyrcxI/s320/potatokorner-twitter-search-widget-step3.PNG&quot; alt=&quot;&quot; border=&quot;0&quot;&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;p&gt;Now what you have before you is the heart of the “search widget” configuration.&lt;/p&gt;
&lt;div&gt;
  &lt;a style=&quot;margin-left: 1em; margin-right: 1em;&quot; href=&quot;http://1.bp.blogspot.com/_BBS5bkzuLXM/StvtGGtbBOI/AAAAAAAADLU/aaM8noAbmZU/s1600-h/potatokorner-twitter-search-config.PNG&quot;&gt;&lt;img src=&quot;http://1.bp.blogspot.com/_BBS5bkzuLXM/StvtGGtbBOI/AAAAAAAADLU/aaM8noAbmZU/s320/potatokorner-twitter-search-config.PNG&quot; alt=&quot;&quot; border=&quot;0&quot;&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;p&gt;You’ll learn when you’ve finally playing with your new widget that it’s a parsing nightmare when people add tags even if their topics are not related, especially when it’s a “trending topic”. Fortunately, Twitter.com provided quite a collection of filters to narrow down your search. You can limit tweets to a certain vicinity( near:{location}) or screen out certain words ( -{word}), you can even limit them to happy ones ( 🙂 ). See &lt;a href=&quot;http://search.twitter.com/operators&quot;&gt;Advance operators&lt;/a&gt; to build your strings. I won’t touch this much, but I’ll explain what I’m going to use.&lt;/p&gt;
&lt;p&gt;For our example, I want to add a twitter search widget to find tweets with the word “party”, but I only want positive or happy tweets! , thus the smiley, ” 🙂 “. The smiley is a generic one, but twitter is smart enough to find all the variations (e.g. “:D”,”=)” etc. ). Now lets test it.&lt;/p&gt;
&lt;div&gt;
  &lt;a style=&quot;margin-left: 1em; margin-right: 1em;&quot; href=&quot;http://3.bp.blogspot.com/_BBS5bkzuLXM/StvtQSnAXbI/AAAAAAAADLc/OW3As3VfJpY/s1600-h/potatokorner-twitter-search-test.PNG&quot;&gt;&lt;img src=&quot;http://3.bp.blogspot.com/_BBS5bkzuLXM/StvtQSnAXbI/AAAAAAAADLc/OW3As3VfJpY/s320/potatokorner-twitter-search-test.PNG&quot; alt=&quot;&quot; border=&quot;0&quot;&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;p&gt;Great! It’s working. As you can see, there are only a few tweets shown. It gives it an air of history unfolding. If you like it to show all the tweets in history at once, we’ll move to that later. Now that our search string is tested and working. You have the option of changing the “Title” and “Caption”. Lets leave the title alone and match our search string to the Caption.&lt;/p&gt;
&lt;div&gt;
  &lt;a style=&quot;margin-left: 1em; margin-right: 1em;&quot; href=&quot;http://4.bp.blogspot.com/_BBS5bkzuLXM/StvtXiBgOxI/AAAAAAAADLk/ObOyPgSCPs0/s1600-h/potatokorner-twitter-search-config-2-1.PNG&quot;&gt;&lt;img src=&quot;http://4.bp.blogspot.com/_BBS5bkzuLXM/StvtXiBgOxI/AAAAAAAADLk/ObOyPgSCPs0/s320/potatokorner-twitter-search-config-2-1.PNG&quot; alt=&quot;&quot; border=&quot;0&quot;&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;p&gt;So far so good, let’s see how we can configure tweets. Choose preferences. This tab controls how your tweets will look and behave.&lt;/p&gt;
&lt;div&gt;
  &lt;a style=&quot;margin-left: 1em; margin-right: 1em;&quot; href=&quot;http://2.bp.blogspot.com/_BBS5bkzuLXM/Stvt9WNTcpI/AAAAAAAADLs/Nk4bRBgcKTI/s1600-h/potatokorner-twitter-search-config-2.PNG&quot;&gt;&lt;img src=&quot;http://2.bp.blogspot.com/_BBS5bkzuLXM/Stvt9WNTcpI/AAAAAAAADLs/Nk4bRBgcKTI/s320/potatokorner-twitter-search-config-2.PNG&quot; alt=&quot;&quot; border=&quot;0&quot;&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;p&gt;Enable “Poll New Results?”, if you want the widget to continue checking the public timeline of relevant tweets to your search. (Default: Checked)&lt;/p&gt;
&lt;div&gt;
  &lt;a style=&quot;margin-left: 1em; margin-right: 1em;&quot; href=&quot;http://3.bp.blogspot.com/_BBS5bkzuLXM/StzbFlGO71I/AAAAAAAADL0/C_W70lovF7o/s1600-h/potatokorner-twitter-search-config-3+-poll.PNG&quot;&gt;&lt;img src=&quot;http://3.bp.blogspot.com/_BBS5bkzuLXM/StzbFlGO71I/AAAAAAAADL0/C_W70lovF7o/s320/potatokorner-twitter-search-config-3+-poll.PNG&quot; alt=&quot;&quot; border=&quot;0&quot;&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;p&gt;Enable “Enable Scrollbars”, if you need to be able to review the rest of the resulting tweets without waiting for it to &lt;a href=&quot;http://www.blogger.com/post-edit.g?blogID=21010737&amp;#x26;postID=6325991344956883481#twitter-loop&quot;&gt;loop&lt;/a&gt;. (Default: Checked)&lt;/p&gt;
&lt;div&gt;
  &lt;a style=&quot;margin-left: 1em; margin-right: 1em;&quot; href=&quot;http://4.bp.blogspot.com/_BBS5bkzuLXM/StzbK9XmG0I/AAAAAAAADL8/mTLPB6ox8dg/s1600-h/potatokorner-twitter-search-config-3+-loop.PNG&quot;&gt;&lt;img src=&quot;http://4.bp.blogspot.com/_BBS5bkzuLXM/StzbK9XmG0I/AAAAAAAADL8/mTLPB6ox8dg/s320/potatokorner-twitter-search-config-3+-loop.PNG&quot; alt=&quot;&quot; border=&quot;0&quot;&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;p&gt;Behavior has two values, its either “timed interval” or “load all tweets.” Default behavior is timed interval – tweets are shown one at a time, kind of like a news marquee. When set as timed interval, you have an option to set how much time it takes before showing more results(Interval). You can also set if you want it to repeat the results when all the tweets have been shown(Loop Results).&lt;/p&gt;
&lt;div&gt;
  &lt;a style=&quot;margin-left: 1em; margin-right: 1em;&quot; href=&quot;http://1.bp.blogspot.com/_BBS5bkzuLXM/StzeVgDk71I/AAAAAAAADMU/Ka7ak5kgIig/s1600-h/potatokorner-twitter-search-config-3+-timed.PNG&quot;&gt;&lt;img src=&quot;http://1.bp.blogspot.com/_BBS5bkzuLXM/StzeVgDk71I/AAAAAAAADMU/Ka7ak5kgIig/s320/potatokorner-twitter-search-config-3+-timed.PNG&quot; alt=&quot;&quot; border=&quot;0&quot;&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;p&gt;“Load all tweets” on the other hand, set’s the widget to show all the tweets related to your search – all in one go. No fancy animation. Kind of boring to me, but someone out there might have a use for it.&lt;/p&gt;
&lt;div&gt;
  &lt;a style=&quot;margin-left: 1em; margin-right: 1em;&quot; href=&quot;http://3.bp.blogspot.com/_BBS5bkzuLXM/Stzedu-uzpI/AAAAAAAADMc/pQH-SJoS6ds/s1600-h/potatokorner-twitter-search-config-3-alltweets.PNG&quot;&gt;&lt;img src=&quot;http://3.bp.blogspot.com/_BBS5bkzuLXM/Stzedu-uzpI/AAAAAAAADMc/pQH-SJoS6ds/s320/potatokorner-twitter-search-config-3-alltweets.PNG&quot; alt=&quot;&quot; border=&quot;0&quot;&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;p&gt;For our example, let’s leave it as is.&lt;/p&gt;
&lt;p&gt;For really large results, you can increase or decrease the number of tweets to show.&lt;/p&gt;
&lt;div&gt;
  &lt;a style=&quot;margin-left: 1em; margin-right: 1em;&quot; href=&quot;http://1.bp.blogspot.com/_BBS5bkzuLXM/StzlVklMMmI/AAAAAAAADMs/x4oFwD1pp8g/s1600-h/potatokorner-twitter-search-config-3+-tweets.PNG&quot;&gt;&lt;img src=&quot;http://1.bp.blogspot.com/_BBS5bkzuLXM/StzlVklMMmI/AAAAAAAADMs/x4oFwD1pp8g/s320/potatokorner-twitter-search-config-3+-tweets.PNG&quot; alt=&quot;&quot; border=&quot;0&quot;&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;p&gt;Finally, you also have control over how your tweets will look like. If you only need the messages without people’s faces polluting the content area, unset “Show Avatar”.&lt;/p&gt;
&lt;div&gt;
  &lt;a style=&quot;margin-left: 1em; margin-right: 1em;&quot; href=&quot;http://3.bp.blogspot.com/_BBS5bkzuLXM/StzlcscW53I/AAAAAAAADM0/tKoKQpfPuZE/s1600-h/potatokorner-twitter-search-config-3-noavatar.PNG&quot;&gt;&lt;img src=&quot;http://3.bp.blogspot.com/_BBS5bkzuLXM/StzlcscW53I/AAAAAAAADM0/tKoKQpfPuZE/s320/potatokorner-twitter-search-config-3-noavatar.PNG&quot; alt=&quot;&quot; border=&quot;0&quot;&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;p&gt;If the time the message was sent doesn’t interest you, you can remove it by unchecking “Show Timestamps”.&lt;/p&gt;
&lt;div&gt;
  &lt;a style=&quot;margin-left: 1em; margin-right: 1em;&quot; href=&quot;http://2.bp.blogspot.com/_BBS5bkzuLXM/StzlidwW-cI/AAAAAAAADM8/E9NC69-DdbA/s1600-h/potatokorner-twitter-search-config-3-notime.PNG&quot;&gt;&lt;img src=&quot;http://2.bp.blogspot.com/_BBS5bkzuLXM/StzlidwW-cI/AAAAAAAADM8/E9NC69-DdbA/s320/potatokorner-twitter-search-config-3-notime.PNG&quot; alt=&quot;&quot; border=&quot;0&quot;&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;p&gt;Finally, if seeing &lt;a href=&quot;http://twitter.pbworks.com/Hashtags&quot;&gt;hashtags&lt;/a&gt; so many times is starting to strain your eyes, hide it by unchecking “Show hashtags”. I find helpful when my search word is a hashtag.&lt;/p&gt;
&lt;div&gt;
  &lt;a style=&quot;margin-left: 1em; margin-right: 1em;&quot; href=&quot;http://4.bp.blogspot.com/_BBS5bkzuLXM/StzlnQIgVPI/AAAAAAAADNE/rLZSZLA6-l4/s1600-h/potatokorner-twitter-search-config-3-nohashtags.PNG&quot;&gt;&lt;img src=&quot;http://4.bp.blogspot.com/_BBS5bkzuLXM/StzlnQIgVPI/AAAAAAAADNE/rLZSZLA6-l4/s320/potatokorner-twitter-search-config-3-nohashtags.PNG&quot; alt=&quot;&quot; border=&quot;0&quot;&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;p&gt;Now for aesthetics, lets change colors to match my site.&lt;/p&gt;
&lt;div&gt;
  &lt;a style=&quot;margin-left: 1em; margin-right: 1em;&quot; href=&quot;http://1.bp.blogspot.com/_BBS5bkzuLXM/StzelmVUs3I/AAAAAAAADMk/80RqxBQMEzg/s1600-h/potatokorner-twitter-search-config-4.PNG&quot;&gt;&lt;img src=&quot;http://1.bp.blogspot.com/_BBS5bkzuLXM/StzelmVUs3I/AAAAAAAADMk/80RqxBQMEzg/s320/potatokorner-twitter-search-config-4.PNG&quot; alt=&quot;&quot; border=&quot;0&quot;&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;p&gt;I’ll leave the dimensions as is. Unfortunately, you can not test the numbers you have set for the widget. You just have to see how it looks in your page – and decide if you need to adjust. Note you can let the widget grow into the container you want to place it, or if you’re just not sure how to adjust it to fit your site – you can try setting “auto-width”.&lt;/p&gt;
&lt;div&gt;
  &lt;a style=&quot;margin-left: 1em; margin-right: 1em;&quot; href=&quot;http://2.bp.blogspot.com/_BBS5bkzuLXM/StzlugcxuiI/AAAAAAAADNM/Qe2LsIwoGfw/s1600-h/potatokorner-twitter-search-config-5.PNG&quot;&gt;&lt;img src=&quot;http://2.bp.blogspot.com/_BBS5bkzuLXM/StzlugcxuiI/AAAAAAAADNM/Qe2LsIwoGfw/s320/potatokorner-twitter-search-config-5.PNG&quot; alt=&quot;&quot; border=&quot;0&quot;&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;p&gt;I’m happy with the results, click “Finish and Grab Code” button to get the code. See our results below.&lt;/p&gt;
&lt;div&gt;
  &lt;a style=&quot;margin-left: 1em; margin-right: 1em;&quot; href=&quot;http://2.bp.blogspot.com/_BBS5bkzuLXM/Stzmzg7JsII/AAAAAAAADNU/4MuMeU_2viE/s1600-h/potatokorner-twitter-search-config-getcode.PNG&quot;&gt;&lt;img src=&quot;http://2.bp.blogspot.com/_BBS5bkzuLXM/Stzmzg7JsII/AAAAAAAADNU/4MuMeU_2viE/s320/potatokorner-twitter-search-config-getcode.PNG&quot; alt=&quot;&quot; border=&quot;0&quot;&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;p&gt;Simply insert the code into your page’s html and you’re done. see results here&lt;/p&gt;
&lt;p&gt;There you have it, shown you how to get the widget. Now go play with your new toy! If you have a problem installing, just leave a comment or email me at &lt;code class=&quot;language-text&quot;&gt;questions at codespud dot com&lt;/code&gt;.&lt;/p&gt;
&lt;h4 id=&quot;some-closing-tips&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#some-closing-tips&quot; aria-label=&quot;some closing tips permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Some closing tips&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;If you’re using a fluid-width layout, you might find auto-width useful.&lt;/li&gt;
&lt;li&gt;Use the minus operator(-) plus word (you want to leave out) in the search parameter to narrow your search.&lt;/li&gt;
&lt;li&gt;If you’ll remove the scrollbar, enable “Loop results” so you’ll be able to see all the results.&lt;/li&gt;
&lt;li&gt;I found the optimum interval for showing tweets is 5 secs, but of course it depends on what you intend to use it for.&lt;/li&gt;
&lt;li&gt;Sometimes, you can clean your results by showing hashtags and filtering unwanted tags out with minus(-).&lt;/li&gt;
&lt;li&gt;Enable scrollbars if you chose to load all results.&lt;/li&gt;
&lt;/ol&gt;</content:encoded></item><item><title><![CDATA[Bit.ly, A Simple URL Shortener]]></title><description><![CDATA[It started with TinyURL, URL aliasing/shortening has become big business with similar sites growing out of the woodwork(See URL Shortening – History). With other unrelated services following the trend, like scr.im(email aliasing) and twt.fm(promotes music), adding value to support our slowly growing twittering society.]]></description><link>https://www.codespud.com/2009/bit-ly-a-simple-url-shortener/</link><guid isPermaLink="false">https://www.codespud.com/2009/bit-ly-a-simple-url-shortener/</guid><pubDate>Sat, 17 Oct 2009 23:50:00 GMT</pubDate><content:encoded>&lt;p&gt;It started with &lt;a href=&quot;http://tinyurl.com/&quot; target=&quot;_blank&quot;&gt;TinyURL&lt;/a&gt;, &lt;a href=&quot;http://en.wikipedia.org/wiki/URL_shortening&quot; target=&quot;_blank&quot;&gt;URL aliasing/shortening&lt;/a&gt; has become big business with similar sites growing out of the woodwork(See &lt;a href=&quot;http://en.wikipedia.org/wiki/URL_shortening&quot; target=&quot;_blank&quot;&gt;URL Shortening – History&lt;/a&gt;). With other unrelated services following the trend, like &lt;a href=&quot;http://scr.im/&quot; target=&quot;_blank&quot;&gt;scr.im&lt;/a&gt;(email aliasing) and &lt;a href=&quot;http://twt.fm/&quot; target=&quot;_blank&quot;&gt;twt.fm&lt;/a&gt;(promotes music), adding value to support our slowly growing twittering society. &lt;!--more--&gt;Bit.ly is one such revolutionary child; &lt;a href=&quot;http://mashable.com/2009/09/08/bitly-tinyurl/&quot;&gt;but this child has grown big enough to even rival TinyURL&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;What so great about bit.ly?&lt;/p&gt;
&lt;p&gt;It accomplishes it task, but with flair. I love that bit.ly provides a means for me to track how many clicked the URLs i sent. Might be the reason for it’s sudden increase in popularity for such a short period. It doesn’t hurt either that it’s officially endorsed by twitter.com.&lt;/p&gt;
&lt;p&gt;The member’s site has a number of features but I’ll concentrate on URL shortening and tracking.&lt;/p&gt;
&lt;div style=&quot;clear: both; text-align: center;&quot;&gt;
  &lt;a style=&quot;margin-left: 1em; margin-right: 1em;&quot; href=&quot;http://4.bp.blogspot.com/_BBS5bkzuLXM/St_PiBvq24I/AAAAAAAADNc/zzDKghXJmQc/s1600-h/potatokorner-bit-ly.PNG&quot;&gt;&lt;img src=&quot;http://4.bp.blogspot.com/_BBS5bkzuLXM/St_PiBvq24I/AAAAAAAADNc/zzDKghXJmQc/s320/potatokorner-bit-ly.PNG&quot; alt=&quot;&quot; border=&quot;0&quot;&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;p&gt;Above screenshot you see the URL entry tool in RED dashed borders. This is where you jam your uber long URL. Usually, URL shortening is more conveniently done via an API call via a tool in your client software. But if you’re just want your un-memorize-able URL to be easier to carry around or share then the web tool should suffice.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://bit.ly/&quot;&gt;bit.ly, a simple url shortener&lt;/a&gt;&lt;/p&gt;</content:encoded></item><item><title><![CDATA[All You Need Is A Browser]]></title><description><![CDATA[The web has become more than just a glorified paperless library, now it has become a place where everyone works, plays and meet up. This has become more true with the surge of desktop applications to their web equivalents (email, desktop publishing, spreadsheet etc.) and the advancement in web technologies(AJAX, HTML5 etc). More and more I find myself using online versions of my computer’s desktop.]]></description><link>https://www.codespud.com/2009/all-you-need-is-a-browser/</link><guid isPermaLink="false">https://www.codespud.com/2009/all-you-need-is-a-browser/</guid><pubDate>Mon, 12 Oct 2009 05:02:00 GMT</pubDate><content:encoded>&lt;p&gt;The web has become more than just a &lt;a href=&quot;http://www.ipl.org/&quot; target=&quot;_blank&quot;&gt;glorified paperless library&lt;/a&gt;, now it has become a place where everyone works, plays and meet up. This has become more true with the surge of desktop applications to their web equivalents (email, desktop publishing, spreadsheet etc.) and the advancement in web technologies(AJAX, HTML5 etc). More and more I find myself using online versions of my computer’s desktop. &lt;!--more--&gt;Having been hosted on a remote server I enjoy; savings in storage space, automatic backups, safety from physical hardware damage(like for some of my friends affected by Typhoon Ondoy) and ready support(depends on the service provider). Though you do need to constantly have a decent internet connection, for me it works just fine. If you’re interested, read on!.&lt;/p&gt;
&lt;h3 id=&quot;what-you-need&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#what-you-need&quot; aria-label=&quot;what you need permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;What you need?&lt;/h3&gt;
&lt;p&gt;You need to install &lt;a href=&quot;http://www.google.com/chrome&quot; target=&quot;_blank&quot;&gt;Google’s Chrome&lt;/a&gt; browser. No specific channel. Though I recommend using &lt;a href=&quot;http://dev.chromium.org/getting-involved/dev-channel&quot; target=&quot;_blank&quot;&gt;“Dev”&lt;/a&gt;, for plugin support and cutting edge stuff. Secondly a list of online services that emulates software you normally would install like Gmail/YahooMail(Email), Grooveshark(Music Player) etc. Also, depending on the web application, you might need to register for accounts to use their services.&lt;/p&gt;
&lt;h3 id=&quot;how&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#how&quot; aria-label=&quot;how permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;How?&lt;/h3&gt;
&lt;p&gt;The secret of this system is Chrome’s &lt;a href=&quot;http://www.google.com/support/chrome/bin/answer.py?hl=en&amp;answer=95710&quot; target=&quot;_blank&quot;&gt;create application shortcuts&lt;/a&gt;. It’s a menu item inside the page menu, shown below.&lt;/p&gt;
&lt;div style=&quot;clear: both; text-align: center;&quot;&gt;
  &lt;a style=&quot;margin-left: 1em; margin-right: 1em;&quot; href=&quot;http://3.bp.blogspot.com/_BBS5bkzuLXM/StH9Kkvps7I/AAAAAAAADJ8/bms9XUcHG5I/s1600-h/potatokorner-build-workstation-using-chrome-gmail-step1.PNG&quot; target=&quot;_blank&quot;&gt;&lt;img src=&quot;http://3.bp.blogspot.com/_BBS5bkzuLXM/StH9Kkvps7I/AAAAAAAADJ8/bms9XUcHG5I/s400/potatokorner-build-workstation-using-chrome-gmail-step1.PNG&quot; alt=&quot;&quot; border=&quot;0&quot;&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;p&gt;Why use this you say, when you can simply bookmark the sites URL. Firstly, making webapps as application shortcuts makes them readily accessible; without the extra steps of opening a browser and finding the bookmark. Also, to get the illusion of a desktop app, we need the chrome(extra browser sections like the menu bar, status bar etc) to disappear(See below) leaving only the application in its intended glory.&lt;/p&gt;
&lt;div style=&quot;clear: both; text-align: center;&quot;&gt;
  &lt;a style=&quot;margin-left: 1em; margin-right: 1em;&quot; href=&quot;http://4.bp.blogspot.com/_BBS5bkzuLXM/StJoSaWGMfI/AAAAAAAADKc/GqIOV1K0_64/s1600-h/potatokorner-chromeless-window.PNG&quot; target=&quot;_blank&quot;&gt;&lt;img src=&quot;http://4.bp.blogspot.com/_BBS5bkzuLXM/StJoSaWGMfI/AAAAAAAADKc/GqIOV1K0_64/s400/potatokorner-chromeless-window.PNG&quot; alt=&quot;&quot; border=&quot;0&quot;&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;p&gt;What is more awesome is whatever favicon image the site has, is saved with the shortcut as an icon.&lt;/p&gt;
&lt;div style=&quot;clear: both; text-align: center;&quot;&gt;
  &lt;a style=&quot;margin-left: 1em; margin-right: 1em;&quot; href=&quot;http://3.bp.blogspot.com/_BBS5bkzuLXM/StLytRz5lOI/AAAAAAAADKk/F4DfqmZNzPk/s1600-h/potatokorner-shortcuticons.PNG&quot; target=&quot;_blank&quot;&gt;&lt;img src=&quot;http://3.bp.blogspot.com/_BBS5bkzuLXM/StLytRz5lOI/AAAAAAAADKk/F4DfqmZNzPk/s400/potatokorner-shortcuticons.PNG&quot; alt=&quot;&quot; border=&quot;0&quot;&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;p&gt;&lt;em&gt;Note: This system can work for other browsers. I just used Chrome since most of what I need are Google Apps. So if you know how to do this in Firefox or IE then go ahead.&lt;/em&gt;&lt;br&gt;
Let’s get started. Say we need an email client. You have either a choice between a &lt;a href=&quot;http://en.wikipedia.org/wiki/Webmail&quot; target=&quot;_blank&quot;&gt;webmail client&lt;/a&gt;, like Gmail and Yahoo Mail, or a &lt;a href=&quot;http://en.wikipedia.org/wiki/Post_Office_Protocol&quot; target=&quot;_blank&quot;&gt;POP&lt;/a&gt;/&lt;a href=&quot;http://en.wikipedia.org/wiki/IMAP&quot; target=&quot;_blank&quot;&gt;IMAP&lt;/a&gt; client like Squirrel or Horde installation. Let’s go with Gmail. You log in to Gmail – find a comfortable page like the inbox or the login page. Normally for security purposes I’d go with the login page, but since I’m the only one using this workstation lets make it easy for me and pick the Inbox as our starting page.&lt;/p&gt;
&lt;p&gt;Now a popup should appear asking where you want to place your shortcut. It can be on the Desktop, the start menu, or a shortcut on the Quicklaunch bar. This is just a matter of preference. I prefer the Quicklaunch bar to maintain the minimalist feel of this system.&lt;/p&gt;
&lt;div style=&quot;clear: both; text-align: center;&quot;&gt;
  &lt;a style=&quot;margin-left: 1em; margin-right: 1em;&quot; href=&quot;http://1.bp.blogspot.com/_BBS5bkzuLXM/StH9X1KKHVI/AAAAAAAADKE/vX_2bLjktWg/s1600-h/potatokorner-build-workstation-using-chrome-gmail-step2.PNG&quot; target=&quot;_blank&quot;&gt;&lt;img src=&quot;http://1.bp.blogspot.com/_BBS5bkzuLXM/StH9X1KKHVI/AAAAAAAADKE/vX_2bLjktWg/s400/potatokorner-build-workstation-using-chrome-gmail-step2.PNG&quot; alt=&quot;&quot; width=&quot;400&quot; height=&quot;289&quot; border=&quot;0&quot;&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;p&gt;Voila! you now have an email client on steroids. Well, almost. You can configure Gmail some more to personalize it. I’ll cover this part in a future post. Repeat this for other applications, each time finding the “comfortable” starting page when you create the shortcuts. Fortunately for you I’ve listed a number of them below to get you started.&lt;br&gt;
Update 2010/08/21: If you don’t like Chrome. Mozilla’s Prism accomplishes the same thing.&lt;/p&gt;
&lt;p&gt;Download from &lt;a href=&quot;http://prism.mozillalabs.com/&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;div style=&quot;clear: both; text-align: center;&quot;&gt;
  &lt;a style=&quot;margin-left: 1em; margin-right: 1em;&quot; href=&quot;http://4.bp.blogspot.com/_BBS5bkzuLXM/StIAUDMLqzI/AAAAAAAADKM/ynVMoh_LERA/s1600-h/potatokorner-build-workstation-using-chrome-gmail-step3.PNG&quot; target=&quot;_blank&quot;&gt;&lt;img src=&quot;http://4.bp.blogspot.com/_BBS5bkzuLXM/StIAUDMLqzI/AAAAAAAADKM/ynVMoh_LERA/s400/potatokorner-build-workstation-using-chrome-gmail-step3.PNG&quot; alt=&quot;&quot; border=&quot;0&quot;&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;p&gt; &lt;/p&gt;
&lt;h3 id=&quot;applications&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#applications&quot; aria-label=&quot;applications permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Applications&lt;/h3&gt;
&lt;h5 id=&quot;office-alternativeword-excel-powerpoint-etc&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#office-alternativeword-excel-powerpoint-etc&quot; aria-label=&quot;office alternativeword excel powerpoint etc permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Office Alternative(Word, Excel, PowerPoint etc.)&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://docs.google.com/&quot; target=&quot;_blank&quot;&gt;Google Docs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.thinkfree.com/&quot; target=&quot;_blank&quot;&gt;Thinkfree.com/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.zoho.com/&quot; target=&quot;_blank&quot;&gt;Zoho&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.peepel.com/&quot; target=&quot;_blank&quot;&gt;Peepel&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.adobe.com/acom/buzzword/&quot; target=&quot;_blank&quot;&gt;Buzz Word&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://etherpad.com/&quot; target=&quot;_blank&quot;&gt;Etherpad&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://opengoo.org/&quot; target=&quot;_blank&quot;&gt;OpenGoo&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h5 id=&quot;email&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#email&quot; aria-label=&quot;email permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Email&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://mail.google.com/&quot; target=&quot;_blank&quot;&gt;Gmail&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.fastmail.fm/&quot; target=&quot;_blank&quot;&gt;Fastmail&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.runbox.com/&quot; target=&quot;_blank&quot;&gt;Runbox&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.inbox.com/login.aspx?gdi=true&quot; target=&quot;_blank&quot;&gt;Inbox.com&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h5 id=&quot;calendar-and-tasks&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#calendar-and-tasks&quot; aria-label=&quot;calendar and tasks permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Calendar and Tasks&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://www.google.com/calendar/render?tab=mc&quot; target=&quot;_blank&quot;&gt;Google Calendar&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://30boxes.com/&quot; target=&quot;_blank&quot;&gt;30boxes&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt; &lt;/p&gt;
&lt;div style=&quot;clear: both; text-align: center;&quot;&gt;
  &lt;a style=&quot;margin-left: 1em; margin-right: 1em;&quot; href=&quot;http://1.bp.blogspot.com/_BBS5bkzuLXM/StIA2TK7ZmI/AAAAAAAADKU/LHeRsPt_Fxs/s1600-h/potatokorner-30boxes.PNG&quot; target=&quot;_blank&quot;&gt;&lt;img src=&quot;http://1.bp.blogspot.com/_BBS5bkzuLXM/StIA2TK7ZmI/AAAAAAAADKU/LHeRsPt_Fxs/s400/potatokorner-30boxes.PNG&quot; alt=&quot;&quot; border=&quot;0&quot;&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;h5 id=&quot;music-playeronline-radio&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#music-playeronline-radio&quot; aria-label=&quot;music playeronline radio permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Music Player/Online Radio&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://listen.grooveshark.com/&quot; target=&quot;_blank&quot;&gt;Grooveshark&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://spotify.com/&quot; target=&quot;_blank&quot;&gt;Spotify.com&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.pandora.com/&quot; target=&quot;_blank&quot;&gt;Pandora Radio&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.last.fm/&quot; target=&quot;_blank&quot;&gt;Last.FM&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.jamendo.com/en/&quot; target=&quot;_blank&quot;&gt;Jamendo.com&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h5 id=&quot;picture-organizer&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#picture-organizer&quot; aria-label=&quot;picture organizer permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Picture Organizer&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://picasaweb.google.com/home&quot; target=&quot;_blank&quot;&gt;Picasa Web Albums&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.flickr.com/&quot; target=&quot;_blank&quot;&gt;Flickr&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.fotonomy.com/&quot; target=&quot;_blank&quot;&gt;Fotomy&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.smugmug.com/&quot; target=&quot;_blank&quot;&gt;SmugMug&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h5 id=&quot;instant-messaging&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#instant-messaging&quot; aria-label=&quot;instant messaging permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Instant Messaging&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://meebo.com/home&quot; target=&quot;_blank&quot;&gt;Meebo&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you know other similar applications or more web alternatives to desktop applications, please don’t hesitate to mention in it in your comments.&lt;/p&gt;
&lt;h3 id=&quot;read-some-more&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#read-some-more&quot; aria-label=&quot;read some more permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Read some more&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;http://www.google.com/support/chrome/&quot; target=&quot;_blank&quot;&gt;&lt;a href=&quot;http://www.google.com/support/chrome/&quot;&gt;http://www.google.com/support/chrome/&lt;/a&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href=&quot;http://www.makeuseof.com/tag/5-great-alternatives-to-google-docs-you-should-consider/&quot; target=&quot;_blank&quot;&gt;&lt;a href=&quot;http://www.makeuseof.com/tag/5-great-alternatives-to-google-docs-you-should-consider/&quot;&gt;http://www.makeuseof.com/tag/5-great-alternatives-to-google-docs-you-should-consider/&lt;/a&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href=&quot;http://alternativeto.net/&quot; target=&quot;_blank&quot;&gt;&lt;a href=&quot;http://alternativeto.net&quot;&gt;http://alternativeto.net&lt;/a&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href=&quot;http://brontesaurus.com/blog/2008/12/3-webmail-alternatives/&quot; target=&quot;_blank&quot;&gt;&lt;a href=&quot;http://brontesaurus.com/blog/2008/12/3-webmail-alternatives/&quot;&gt;http://brontesaurus.com/blog/2008/12/3-webmail-alternatives/&lt;/a&gt;&lt;/a&gt;&lt;/p&gt;</content:encoded></item><item><title><![CDATA[What Browser?]]></title><description><![CDATA[Ever wondered what a browser truly is? Or know someone you’ve been trying to educate for a long time to use one? Ever met someone who keeps confusing a browser with a webpage? Are you still at hairs end trying to pick the best one? Don’t fret, Google comes to the rescue again.]]></description><link>https://www.codespud.com/2009/what-browser/</link><guid isPermaLink="false">https://www.codespud.com/2009/what-browser/</guid><pubDate>Sat, 10 Oct 2009 16:04:00 GMT</pubDate><content:encoded>&lt;p&gt;Ever wondered what a browser truly is? Or know someone you’ve been trying to educate for a long time to use one? Ever met someone who keeps confusing a browser with a webpage? Are you still at hairs end trying to pick the best one? Don’t fret, Google comes to the rescue again.&lt;/p&gt;
&lt;!--more--&gt;
&lt;p&gt;Built by “some folks from Google”, WhatBrowser.org is a site dedicated to what we all would agree to be the most used application in any computer, “the Browser”. Any Operating System has it in some form or another(Anyone said &lt;a href=&quot;http://en.wikipedia.org/wiki/Lynx_(web_browser))&quot; target=&quot;_blank&quot;&gt;Lynx&lt;/a&gt;(?). Companies battle it out for supremacy, sometimes even forcing their religion; &lt;a href=&quot;http://www.pcadvisor.co.uk/news/index.cfm?newsid=3203729&amp;pn=2&quot; target=&quot;_blank&quot;&gt;I mean browser, down our throats&lt;/a&gt;. Whatever a browser is or where it came from, it paved the way for the information superhighway AKA The Internet. That is cause for celebration and dedicatory site, won’t you agree?&lt;/p&gt;
&lt;p&gt;WhatBrowser.org is kind of timely if you think &lt;a href=&quot;http://www.pcadvisor.co.uk/news/index.cfm?newsid=3203729&quot; target=&quot;_blank&quot;&gt;Oct 13 will be birthday no. 15&lt;/a&gt; of the commercial browser. Imagine software, a teener! No wonder some people still gets confused (LOL).&lt;/p&gt;
&lt;h2 id=&quot;visit-the-site&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#visit-the-site&quot; aria-label=&quot;visit the site permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Visit the site&lt;/h2&gt;
&lt;p&gt;When you visit the site, you are presented a video. The video is a cute presentation of what a browser Is and what it is Not. It continues with what you can do with it(browser). Watch the video. It may amuse you and educate you a bit at the same time. Also opposite the video is the name of the browser you used to access the site, the user-agent. You can see that I use Chrome. I will admit that lacking plugins for Chrome was kind of a turn off at first, but with the release of the &lt;a href=&quot;http://dev.chromium.org/getting-involved/dev-channel&quot; target=&quot;_blank&quot;&gt;dev channel&lt;/a&gt; and it’s plugin support, I found myself doing more and more work with it, but thats a topic for another day.&lt;/p&gt;
&lt;p&gt;Your user-agent may not be what you expect it to be,since some browsers enable you to &lt;a href=&quot;http://johnbokma.com/mexit/2004/04/24/changinguseragent.html&quot; target=&quot;_blank&quot;&gt;change user agents&lt;/a&gt;. The site also has 3 more sections below the video, linking to other features/services. I especially like the “Under the hood” page. There you can subject your browser to some benchmarking tests. I’ll post a comprehensive post related to this tests later.&lt;/p&gt;
&lt;div style=&quot;clear: both; text-align: center;&quot;&gt;
  &lt;a href=&quot;http://3.bp.blogspot.com/_BBS5bkzuLXM/StCj8W4Lr_I/AAAAAAAADJs/oMXt0rUh3tw/s1600-h/potatokorner-whatbrowser.PNG&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://3.bp.blogspot.com/_BBS5bkzuLXM/StCj8W4Lr_I/AAAAAAAADJs/oMXt0rUh3tw/s400/potatokorner-whatbrowser.PNG&quot;&gt;&lt;/a&gt;&lt;br&gt;WhatBrowser.Org
&lt;/div&gt;
&lt;p&gt;The site is a awesome idea. Maybe in the near future, the site will grow and provide even more tools to help us understand and make the most out of our “browsers”.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;http://www.whatbrowser.org/&quot;&gt;What Browser? – Home&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;h2 id=&quot;read-some-more&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#read-some-more&quot; aria-label=&quot;read some more permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Read some more&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://www.pcadvisor.co.uk/news/index.cfm?newsid=3203729&quot; target=&quot;_blank&quot;&gt;&lt;a href=&quot;http://www.pcadvisor.co.uk/news/index.cfm?newsid=3203729&quot;&gt;http://www.pcadvisor.co.uk/news/index.cfm?newsid=3203729&lt;/a&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Web_browser&quot; target=&quot;_blank&quot;&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Web_browser&quot;&gt;http://en.wikipedia.org/wiki/Web_browser&lt;/a&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://websearch.about.com/od/whatistheinternet/a/browser.htm&quot; target=&quot;_blank&quot;&gt;&lt;a href=&quot;http://websearch.about.com/od/whatistheinternet/a/browser.htm&quot;&gt;http://websearch.about.com/od/whatistheinternet/a/browser.htm&lt;/a&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://kb.iu.edu/data/aepv.html&quot; target=&quot;_blank&quot;&gt;&lt;a href=&quot;http://kb.iu.edu/data/aepv.html&quot;&gt;http://kb.iu.edu/data/aepv.html&lt;/a&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.techcrunch.com/2009/06/17/yeah-what-is-a-browser-anyway/&quot; target=&quot;_blank&quot;&gt;&lt;a href=&quot;http://www.techcrunch.com/2009/06/17/yeah-what-is-a-browser-anyway/&quot;&gt;http://www.techcrunch.com/2009/06/17/yeah-what-is-a-browser-anyway/&lt;/a&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://browsers.about.com/od/howbrowserswork/a/whatisabrowser.htm&quot; target=&quot;_blank&quot;&gt;&lt;a href=&quot;http://browsers.about.com/od/howbrowserswork/a/whatisabrowser.htm&quot;&gt;http://browsers.about.com/od/howbrowserswork/a/whatisabrowser.htm&lt;/a&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[Funny Video: Animator vs Animated]]></title><description><![CDATA[Shared for your viewing pleasure.]]></description><link>https://www.codespud.com/2009/funny-video-animator-vs-animated/</link><guid isPermaLink="false">https://www.codespud.com/2009/funny-video-animator-vs-animated/</guid><pubDate>Thu, 08 Oct 2009 01:07:00 GMT</pubDate><content:encoded>&lt;p&gt;Shared for your viewing pleasure.&lt;/p&gt;
&lt;!--more--&gt;
&lt;p&gt;&lt;em&gt;Programmers beware the evil of AI! LOL!&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;gatsby-resp-iframe-wrapper&quot; style=&quot;padding-bottom: 80.20833333333334%; position: relative; height: 0; overflow: hidden; margin-bottom: 1.0725rem&quot; &gt; &lt;iframe src=&quot;https://www.youtube.com/embed/0_fPV13lKm4&quot; frameborder=&quot;0&quot; allow=&quot;accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture&quot; allowfullscreen=&quot;&quot; style=&quot; position: absolute; top: 0; left: 0; width: 100%; height: 100%; &quot;&gt;&lt;/iframe&gt; &lt;/div&gt;</content:encoded></item><item><title><![CDATA[OCR API on Google Docs(not yet)]]></title><description><![CDATA[Google API blog announced today, new features for their Documents List – Data APIs (DLDA) – one of which is Optical Character Recognition(OCR). To put it simpy, sending an image(with readable text) to a DLDA application, when OCR is enabled into the request, will equip the API to read the image and generate a properly editable document.]]></description><link>https://www.codespud.com/2009/ocr-api-on-google-docsnot-yet/</link><guid isPermaLink="false">https://www.codespud.com/2009/ocr-api-on-google-docsnot-yet/</guid><pubDate>Wed, 30 Sep 2009 07:41:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;a href=&quot;http://googledataapis.blogspot.com/2009/09/import-scans-or-go-multilingual.html&quot; target=&quot;_blank&quot;&gt;Google API blog&lt;/a&gt; announced today, new features for their &lt;a href=&quot;http://code.google.com/apis/documents/overview.html&quot; target=&quot;_blank&amp;quot;&amp;quot;&quot;&gt;Documents List – Data APIs (DLDA)&lt;/a&gt; – one of which is Optical Character Recognition(&lt;a href=&quot;http://en.wikipedia.org/wiki/Optical_character_recognition&quot; target=&quot;_blank&quot;&gt;OCR&lt;/a&gt;). To put it simpy, sending an image(with readable text) to a DLDA application, when OCR is enabled into the request, will equip the API to read the image and generate a properly editable document.&lt;!--more--&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Applied Fiction&lt;/p&gt;
&lt;p&gt;Agent 007 photographed a top secret document he needs to deliver to M in &lt;em&gt;CSV&lt;/em&gt; format (LOL). Q is not around to give him a nifty watch-slash-camera with OCR features. Good thing he also talks geek and plays with GoogleAPIs. He uploads the digital image into Google Docs and after a length of a blink, he gets a text version of the document. M receives the document, sends Bond a beautiful accountant to “help” him, found the location of the villain, saves the world – the end.&lt;/p&gt;
&lt;p&gt;summary: 007:The Gold Potato that Never Dies Tomorrow&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;a name=&quot;more&quot;&gt;&lt;/a&gt;&lt;br&gt;
_Oh, I forgot he gets to trash another Aston Martin while saving the girl(not the accountant).&lt;br&gt;
_&lt;br&gt;
OCR is not integrated into Google Docs Home interface yet, but this API improvement is a step closer. Heres, a mockup of how I believe this feature would integrate into Google Docs’s upload function.&lt;/p&gt;
&lt;div style=&quot;clear: both; text-align: center;&quot;&gt;
  &lt;img class=&quot;alignnone size-medium wp-image-468&quot; src=&quot;/assets/2009/09/ocr-googlemockup-300x212.png&quot; alt=&quot;ocr-googlemockup&quot; width=&quot;300&quot; height=&quot;212&quot; srcset=&quot;/assets/2009/09/ocr-googlemockup-300x212.png 300w, /assets/2009/09/ocr-googlemockup.png 400w&quot; sizes=&quot;(max-width: 300px) 100vw, 300px&quot; /&gt;
&lt;/div&gt;
&lt;p&gt;The feature is still in its early stages, shown by errors and misses in documents generated by the live demo. The developers did say to use high quality images.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;OCR will only work well on high-resolution images. The quality of the extracted text isn’t perfect yet, but we’re busy improving it!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Miss or not, this is all very exciting, especially for Google Doc users like myself.&lt;/p&gt;
&lt;p&gt;source: &lt;a href=&quot;http://googledataapis.blogspot.com/2009/09/import-scans-or-go-multilingual.html&quot;&gt;http://googledataapis.blogspot.com/2009/09/import-scans-or-go-multilingual.html&lt;/a&gt;&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Updated list of Verified Relief Centers]]></title><description><![CDATA[Here’s another repost.A list of verified in-kind drop off points for Ondoy victims relief operations. Includes what they need and who to contact.]]></description><link>https://www.codespud.com/2009/updated-list-of-verified-relief-centers/</link><guid isPermaLink="false">https://www.codespud.com/2009/updated-list-of-verified-relief-centers/</guid><pubDate>Mon, 28 Sep 2009 23:02:00 GMT</pubDate><content:encoded>&lt;p&gt;Here’s another repost.A list of verified in-kind drop off points for Ondoy victims relief operations. Includes what they need and who to contact.&lt;/p&gt;
&lt;!--more--&gt;
&lt;blockquote&gt;
&lt;p&gt;image attributed to: &lt;a href=&quot;http://news.xinhuanet.com&quot;&gt;http://news.xinhuanet.com&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;For updates keep checking &lt;a href=&quot;http://www.gmanews.tv/story/173288/update-list-of-verified-relief-centers-for-ondoy-victims&quot; target=&quot;_blank&quot;&gt;gmanewstv.com&lt;/a&gt;&lt;/p&gt;
&lt;h4 id=&quot;update-list-of-verified-relief-centers-for-ondoy-victims&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#update-list-of-verified-relief-centers-for-ondoy-victims&quot; aria-label=&quot;update list of verified relief centers for ondoy victims permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Update: List of verified relief centers for ‘Ondoy’ victims&lt;/h4&gt;
&lt;p&gt;&lt;b&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;QUEZON CITY&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;UP College of Arts and Letters&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Go to:&lt;/strong&gt; College of Arts and Letters (CAL)&lt;br&gt;
University of the Philippines, Diliman, Quezon City&lt;br&gt;
&lt;strong&gt;Hotline:&lt;/strong&gt; 09296454102 (Prof. Roselle Pineda)&lt;br&gt;
&lt;strong&gt;Look for:&lt;/strong&gt; Guard on Duty (in UP CAL)&lt;br&gt;
&lt;strong&gt;Operations:&lt;/strong&gt; 24 hours until Wednesday tentatively&lt;br&gt;
&lt;strong&gt;You can:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Donate medicines, clothes, blankets, food to be distributed by Citizens’ Disaster Response Center.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;Erica Paredes&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Go to:&lt;/strong&gt; Katipunan Avenue, Quezon City&lt;br&gt;
(Call or text contact number for complete address) Contact #: 09174741930&lt;br&gt;
&lt;strong&gt;Look for:&lt;/strong&gt; Erica Paredes&lt;br&gt;
&lt;strong&gt;Operations:&lt;/strong&gt; Throughout the week tentatively, from 10 am to 6 pm&lt;br&gt;
&lt;strong&gt;You can:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt; Donate ready-to-eat foods like hard-boiled egg, bread, packed juice, sandwich filling&lt;/li&gt;
&lt;li&gt;Volunteer to prepare sandwiches and distribute goods&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;NoyMar Relief Operations – QC&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Go to:&lt;/strong&gt; Balay Expo Center, Farmers Market, Cubao or in White Space, Pasong Tamo Ext., Near BMW, Makati&lt;br&gt;
&lt;strong&gt;Look for:&lt;/strong&gt; Clare Amador or Jana Vicente&lt;br&gt;
&lt;strong&gt;Hotlines:&lt;/strong&gt; 09285205508, 09285205499, 0908-6579998, 0939-3633436, 9137122&lt;br&gt;
&lt;strong&gt;Operations:&lt;/strong&gt; 8 a.m. to 9 p.m. throughout the week until further notice.&lt;br&gt;
&lt;strong&gt;Website:&lt;/strong&gt; &lt;a href=&quot;http://www.marroxas.com&quot;&gt;www.marroxas.com&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;You can:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Donate drinking water, old medicines, clothing, blankets, canned goods, noodles&lt;/li&gt;
&lt;li&gt;Volunteer to man stations and repack food.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;Miriam Quiambao and World Vision Development Foundation&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Go to:&lt;/strong&gt; One Orchard Road Building in Eastwood or at the World Vision office at 389 Quezon Avenue, corner West 6th St., Quezon City&lt;br&gt;
&lt;strong&gt;Hotline:&lt;/strong&gt; 0917-8623209&lt;br&gt;
&lt;strong&gt;Look for:&lt;/strong&gt; The guard in the lobby (on One Orchard Road)&lt;br&gt;
&lt;strong&gt;Website:&lt;/strong&gt; &lt;a href=&quot;http://www.twitter.com/miriamq&quot;&gt;http://www.twitter.com/miriamq&lt;/a&gt;, &lt;a href=&quot;http://www.worldvision.org.ph&quot;&gt;www.worldvision.org.ph&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Operations:&lt;/strong&gt; Until Sept. 28, 2009 (Monday), 24-hour operation&lt;br&gt;
&lt;strong&gt;You can:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Donate goods like clothes, blankets, canned goods, crackers, mattress, hygiene kits, noodles, bottled water, oatmeal, instant coffee, sugar (for relief pack to be distributed by World Vision)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Volunteer to help repack relief goods for World Vision starting today at 7pm&lt;/li&gt;
&lt;li&gt;Deposit cash donations to World Vision Development Foundation, BPI savings account number 4251002415 and BDO savings account number 270043411&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;Philippine Army&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Go to:&lt;/strong&gt; Philippine Army Gym inside Fort Bonifacio, Makati or General Head Quarter’s Gym in Camp Gen. Emilio Aguinaldo, EDSA, Quezon City&lt;br&gt;
&lt;strong&gt;Hotline:&lt;/strong&gt; 892-3417 (direct line), 845-9555 (trunkline) local. 6464 and 6466&lt;br&gt;
&lt;strong&gt;Look for:&lt;/strong&gt; Any personnel on duty&lt;br&gt;
&lt;strong&gt;Operations:&lt;/strong&gt; Ongoing everyday for 24 hours until further notice&lt;br&gt;
&lt;strong&gt;You can:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt; Donate relief goods (no cash)&lt;/li&gt;
&lt;li&gt;Call hotline for rescue, evacuation or relief assistance.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Call to report missing persons&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;Papemelroti Gifts and Decorative Accessories&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Go to:&lt;/strong&gt; 91 Roces Ave., Corner Scout Tobias, Quezon City or mall branches in Ali Mall Cubao, SM City North EDSA, SM Fairview, SM Megamall, Glorietta 3 in Makati, SM Centerpoint, SM Southmall&lt;br&gt;
&lt;strong&gt;Hotline:&lt;/strong&gt; refer to website for individual branch numbers&lt;br&gt;
&lt;strong&gt;Website:&lt;/strong&gt; &lt;a href=&quot;http://www.papemelroti.com&quot;&gt;www.papemelroti.com&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Operations:&lt;/strong&gt; Mall hours (10am-9pm), ongoing everyday until further notice&lt;br&gt;
&lt;strong&gt;You can:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt; Donate goods like canned goods, clothings, blanket, cooking utensils and other relief goods EXCEPT cash.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;Ateneo de Manila University Disaster Response Group&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;**Go to: **Ateneo de Manila University, Loyola Heights , Quezon City, Manuel V. Pangilinan Building Center for Student Leadership Lobby, University Dorm Cervini Hall&lt;br&gt;
&lt;strong&gt;Hotlines:&lt;/strong&gt; 09089977166, 09178952792, 4266001 local 5050&lt;br&gt;
&lt;strong&gt;Look for:&lt;/strong&gt; Gio Tiongson, President, Sanggunian ng mga Mag-aaral&lt;br&gt;
&lt;strong&gt;Website:&lt;/strong&gt; &lt;a href=&quot;http://www.ateneosanggu.com&quot;&gt;www.ateneosanggu.com&lt;/a&gt;&lt;br&gt;
**Operations: **24-hour operations for the entire week&lt;br&gt;
&lt;strong&gt;You can:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Donate goods like bottled water, sardines, canned goods, candles, cup noodles.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Volunteer to help repack relief goods, administer basic first aid.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Report missing persons.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Seek evacuation/temporary shelter at University Dorm Cervini Hall.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;&lt;b&gt;Citizens Disaster Response Center (CDRC)&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Go To:&lt;/strong&gt; 72-A Times St., West Triangle Homes, Quezon City.&lt;br&gt;
**Hotlines: **9299820, 9299822&lt;br&gt;
&lt;strong&gt;Operations:&lt;/strong&gt; 8 a.m. onwards.&lt;br&gt;
&lt;strong&gt;You can:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Donate money, old clothes, blanket, bigas, munggo.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Volunteer to help distribute goods.&lt;span style=&quot;text-decoration: underline;&quot;&gt;&lt;b&gt;Radio Veritas&lt;/b&gt;&lt;/span&gt;
**Go To: **Veritas Tower , West Ave. corner EDSA&lt;br&gt;
&lt;strong&gt;Look For:&lt;/strong&gt; Karla Turingan&lt;br&gt;
**Hotlines: **9257931 to 39, 0918VERITAS&lt;br&gt;
&lt;strong&gt;Operations:&lt;/strong&gt; 24-hours, tentatively until Tuesday.&lt;br&gt;
&lt;strong&gt;You can:&lt;/strong&gt;&lt;/li&gt; &lt;/ul&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Donate old clothes, food, assorted goods, bottled water, cash.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;&lt;b&gt;Our Lady of Pentecost Parish&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;**Go to: **12 F. dela Rosa cor. C. Salvador Streets, Loyola Heights , Quezon City&lt;br&gt;
**Hotlines: **632 4342397, 63 2 9290665&lt;br&gt;
&lt;strong&gt;Operations:&lt;/strong&gt; 7 a.m. till 10 p.m. Sunday, until further notice.&lt;br&gt;
&lt;strong&gt;You Can:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Donate packed meals, bottled water.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt; &lt;/p&gt;
&lt;center&gt;
  &lt;span style=&quot;text-decoration: underline;&quot;&gt;&lt;b&gt;MAKATI/TAGUIG/MUNTINLUPA&lt;/b&gt;&lt;/span&gt;
&lt;/center&gt;
&lt;p&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;&lt;b&gt;Victory Fellowship – Fort Bonifacio &lt;/b&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;**Go to: **Victory Fellowship, Every Nation Building , across Market-Market, Fort Bonifacio&lt;br&gt;
&lt;strong&gt;Look for:&lt;/strong&gt; Pastor Bernard Marquez&lt;br&gt;
&lt;strong&gt;Hotlines:&lt;/strong&gt; 813-FORT, 8171212&lt;br&gt;
**Operations: **Tentatively until 5pm, may may extend hours. Entire week until Friday.&lt;br&gt;
&lt;strong&gt;Website:&lt;/strong&gt; &lt;a href=&quot;http://www.twitter.com/VictoryFort&quot;&gt;www.twitter.com/VictoryFort&lt;/a&gt;&lt;br&gt;
**You can: **&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Donate canned goods, milk, bottled water, clothes, cash.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Volunteer to help pack relief goods&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;Sacred Heart of Jesus Chaplaincy&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Go to:&lt;/strong&gt; Hillsborough Village, Cupang, Muntinlupa City, Metro Manila&lt;br&gt;
&lt;strong&gt;Hotline:&lt;/strong&gt; 8428148, 8079847&lt;br&gt;
&lt;strong&gt;Look for:&lt;/strong&gt; Genelyn Sembrano, Meanne Cuneta&lt;br&gt;
&lt;strong&gt;Website:&lt;/strong&gt; &lt;a href=&quot;http://www.sacredheartofjesus-alabang.org&quot;&gt;www.sacredheartofjesus-alabang.org&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Operations:&lt;/strong&gt; Tuesday-Sunday (Sept. 29-Oct 4). 8 am to 12 noon, 2 to 6 pm&lt;br&gt;
&lt;strong&gt;You can:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt; Donate water, blankets, shoes, clothes and other goods&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Donate in cash&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt; &lt;/p&gt;
&lt;center&gt;
  &lt;b&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;PASIG CITY&lt;/span&gt;&lt;/b&gt;
&lt;/center&gt;
&lt;p&gt;&lt;strong&gt;&lt;span style=&quot;text-decoration: underline;&quot;&gt;LUZON RELIEF: Volunteer / Donate / Pray&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Go to:&lt;/strong&gt; Renaissance Fitness Center, 2nd Floor, Bramante Building, Renaissance Towers, Ortigas, Meralco Avenue, Pasig City&lt;br&gt;
&lt;strong&gt;Hotline:&lt;/strong&gt; 0929-8713488&lt;br&gt;
&lt;strong&gt;Look for:&lt;/strong&gt; Warren Habaluyas, co-founder&lt;br&gt;
&lt;strong&gt;E-mail:&lt;/strong&gt; &lt;a href=&quot;mailto:luzonrelief@gmail.com&quot;&gt;luzonrelief@gmail.com&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Operations:&lt;/strong&gt; Monday to Saturday (Sept. 28-Oct. 3), 9am-7pm&lt;br&gt;
&lt;strong&gt;You can:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt; Donate non-perishable food items, beddings, pillows, blankets, clothes&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;You can donate cash but it is not encouraged&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;– Compiled by Annalyn Ardoña and Patricia Faustino, GMA NEWS AND PUBLIC AFFAIRS&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Update: some more info from &lt;a href=&quot;http://www.google.com/landing/typhoon-ondoy.html&quot;&gt;google-ondoy page&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[Google Ondoy Help Page]]></title><description><![CDATA[Updates: Helping Victims of Tropical Storm Google joins the Filipino nation in helping those affected by Typhoon Ondoy! I am reposting the info here if you have time please check the actual google page.]]></description><link>https://www.codespud.com/2009/google-ondoy-help-page/</link><guid isPermaLink="false">https://www.codespud.com/2009/google-ondoy-help-page/</guid><pubDate>Mon, 28 Sep 2009 10:39:00 GMT</pubDate><content:encoded>&lt;p&gt;Updates:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://googleblog.blogspot.com/2009/10/helping-victims-of-tropical-storm.html&quot;&gt;Helping Victims of Tropical Storm&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Google joins the Filipino nation in helping those affected by Typhoon Ondoy!&lt;/p&gt;
&lt;p&gt;I am reposting the info here if you have time please check the actual google page.&lt;!--more--&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.google.com/landing/typhoon-ondoy.html&quot; target=&quot;_blank&quot;&gt;&lt;a href=&quot;http://www.google.com/landing/typhoon-ondoy.html&quot;&gt;http://www.google.com/landing/typhoon-ondoy.html&lt;/a&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3 id=&quot;help-for-typhoon-ondoy-victims-in-the-philippines&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#help-for-typhoon-ondoy-victims-in-the-philippines&quot; aria-label=&quot;help for typhoon ondoy victims in the philippines permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Help for Typhoon Ondoy Victims in the Philippines&lt;/h3&gt;
&lt;p&gt;&lt;span&gt;O&lt;/span&gt;n September 26, 2009, Typhoon Ondoy brought a month’s worth of rainfall to Metro Manila and nearby areas in just a few hours, causing severe flooding which resulted in the loss of many lives and the displacement of hundreds of thousands of people. This site compiles relevant information about the disaster, including a volunteer-maintained map of persons needing rescue and a list of relief organizations accepting donations, so that more help can be provided where it is needed. You can also keep track of the latest news on &lt;a href=&quot;http://news.google.com.ph/news/search?aq=f&amp;pz=1&amp;cf=all&amp;ned=en_ph&amp;hl=en&amp;q=ondoy&quot; &gt;Google News&lt;/a&gt; and &lt;a href=&quot;http://news.google.com.ph/news/search?aq=f&amp;pz=1&amp;cf=all&amp;ned=en_ph&amp;hl=en&amp;q=ondoy&quot; &gt;YouTube&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&quot;know-someone-who-needs-help&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#know-someone-who-needs-help&quot; aria-label=&quot;know someone who needs help permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Know someone who needs help?&lt;/h3&gt;
&lt;p&gt;A group of volunteer map makers have been maintaining the map below, which documents flood updates and persons needing rescue. If you know someone who needs help urgently or if you would like to report the status of the flood in your area, please&lt;a href=&quot;https://spreadsheets.google.com/viewform?formkey=dExYV0pxcWlLLWVOUmQzeDUwWUdObVE6MA&quot; &gt;complete this form&lt;/a&gt;. The information will be sent to the group’s main database for posting on the map.&lt;/p&gt;
&lt;p&gt;View &lt;a href=&quot;http://maps.google.com/maps/ms?ie=UTF8&amp;hl=en&amp;msa=0&amp;msid=110868206150348750692.00047479b6400ee29bd89&amp;ll=14.645791,121.107874&amp;spn=0.107954,0.154324&amp;source=embed&quot; &gt;Ondoy situation map for Metro Manila&lt;/a&gt; in a larger map&lt;/p&gt;
&lt;p&gt;Disclaimer: This map was initiated by a group of volunteers not directly connected with Google. We cannot guarantee 100% accuracy of all placemarks. If you are familiar with Google Maps and would like to help the group’s volunteer efforts, please email&lt;a href=&quot;http://www.google.com/landing/typhoonondoy@googlegroups.com&quot; &gt;&lt;a href=&quot;mailto:typhoonondoy@googlegroups.com&quot;&gt;typhoonondoy@googlegroups.com&lt;/a&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&quot;useful-links&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#useful-links&quot; aria-label=&quot;useful links permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Useful Links&lt;/h3&gt;
&lt;h4 id=&quot;news-and-updates&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#news-and-updates&quot; aria-label=&quot;news and updates permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;News and Updates&lt;/h4&gt;
&lt;ul style=&quot;margin-bottom: 1em; margin-top: 1em;&quot;&gt;
  &lt;li&gt;
    &lt;a href=&quot;http://news.google.com.ph/news/search?aq=f&amp;pz=1&amp;cf=all&amp;ned=us&amp;hl=en&amp;q=ondoy+&quot; &gt;Google News&lt;/a&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;a href=&quot;http://www.youtube.com/results?search_query=ondoy&amp;search_type=&amp;aq=f&quot; &gt;YouTube&lt;/a&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;a href=&quot;http://www.google.com/url?q=http%3A//www.gmanews.tv/&amp;sa=D&amp;sntz=1&amp;usg=AFQjCNHFiSDgL_SqlsAxemTYt_NX9F4oCg&quot; &gt;GMA News&lt;/a&gt;&amp;nbsp;(&lt;a href=&quot;http://www.google.com/url?q=http%3A%2F%2Fwww.gmanews.tv%2Fstory%2F173283%2Fnew-map-of-most-urgent-cases-needing-rescue&amp;sa=D&amp;sntz=1&amp;usg=AFQjCNFGL7rP1MVOnKSzm9m_xcmIC88UuQ&quot; &gt;Relief Map&lt;/a&gt;)
  &lt;/li&gt;
  &lt;li&gt;
    &lt;a href=&quot;http://www.google.com/url?q=http%3A%2F%2Fwww.gov.ph%2F&amp;sa=D&amp;sntz=1&amp;usg=AFQjCNHX2nPQmikb5g5aiMavnCNp7nas_g&quot; &gt;Official Government Site&lt;/a&gt;
  &lt;/li&gt;
  &lt;li&gt;
    Local media websites 
    &lt;ul style=&quot;margin-bottom: 1em; margin-top: 0px;&quot;&gt;
      &lt;li&gt;
        &lt;a href=&quot;http://www.abs-cbnnews.com/&quot;  title=&quot;ABS-CBN News&quot;&gt;ABS-CBN News&lt;/a&gt;
      &lt;/li&gt;
      &lt;li&gt;
        &lt;a href=&quot;http://www.gmanews.tv/&quot;  title=&quot;GMA News&quot;&gt;GMA News&lt;/a&gt;
      &lt;/li&gt;
      &lt;li&gt;
        &lt;span dir=&quot;ltr&quot;&gt;&lt;a href=&quot;http://www.mb.com.ph/&quot;  title=&quot;Manila Bulletin&quot;&gt;Manila Bulletin&lt;/a&gt;&lt;/span&gt;
      &lt;/li&gt;
      &lt;li&gt;
        &lt;a href=&quot;http://www.inquirer.net/&quot;  title=&quot;Philippine Daily Inquirer&quot;&gt;Philippine Daily Inquirer&lt;/a&gt;
      &lt;/li&gt;
      &lt;li&gt;
        &lt;a href=&quot;http://www.phistar.com/&quot;  title=&quot;Philippine Star&quot;&gt;Philippine Star&lt;/a&gt;
      &lt;/li&gt;
    &lt;/ul&gt;    
    &lt;/li&gt; 
&lt;/ul&gt; 
&lt;h4 id=&quot;disaster-emergency&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#disaster-emergency&quot; aria-label=&quot;disaster emergency permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Disaster Emergency&lt;/h4&gt;
&lt;ul style=&quot;margin-bottom: 1em; margin-top: 1em;&quot;&gt;
&lt;li&gt;
  Rescue Operations 
  &lt;ul style=&quot;margin-bottom: 1em; margin-top: 0px;&quot;&gt;
    &lt;li&gt;
      National Disaster Coordinating Council (NDCC) (+632-9125668, +632-9111406, +632-9115061, +632-9122665) Help hotlines: (+65 734-2118, 734-2120)
    &lt;/li&gt;
    &lt;li&gt;
      Philippine Coast Guard (+632-5276136)
    &lt;/li&gt;
    &lt;li&gt;
      Air Force (+63908-1126976, +632-8535023)
    &lt;/li&gt;
    &lt;li&gt;
      Metro Manila Development Authority (136)
    &lt;/li&gt;
    &lt;li&gt;
      Marikina City Rescue (+632-6462436, +632-6462423, +632920-9072902)
    &lt;/li&gt;
    &lt;li&gt;
      Pasig Rescue Emergency Number (+632-6310099)
    &lt;/li&gt;
    &lt;li&gt;
      Quezon City Rescue (161)
    &lt;/li&gt;
    &lt;li&gt;
      San Juan City Hall Command Post (+632-4681697)
    &lt;/li&gt;
    &lt;li&gt;
      Bureau of Fire Protection Region III (Central Luzon) Hotline: (+63245-9634376)
    &lt;/li&gt;
    &lt;li&gt;
      Senator Dick Gordon (+639178997898, +63938-444BOYS, +632-9342118, +632-4338528)
    &lt;/li&gt;
    &lt;li&gt;
      Senator Manny Villar (+639174226800. +639172414864, +639276751981)
    &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt; 
  &lt;li&gt;
      Civil Society/ Media 
      &lt;ul style=&quot;margin-bottom: 1em; margin-top: 0px;&quot;&gt;
        &lt;li&gt;
          Philippine National Red Cross (143, +632-5270000)
        &lt;/li&gt;
        &lt;li&gt;
          Philippine National Red Cross Rizal Chapter operations center hotline: (+632-6350922, +632-6347824)
        &lt;/li&gt;
        &lt;li&gt;
          Go to&amp;nbsp;&lt;a href=&quot;http://www.facebook.com/topic.php?uid=116724526976&amp;topic=9724&quot; rel=&quot;nofollow&quot;  target=&quot;_blank&quot;&gt;GMA Facebook page&lt;/a&gt;&amp;nbsp;&amp; post complete addresses and names of people in need of immediate help.
        &lt;/li&gt;
        &lt;li&gt;
          ABS-CBN Typhoon Ondoy Hotline: (+632-4163641)
        &lt;/li&gt;
        &lt;li&gt;
          Jam 88.3: (+632- 6318803) or SMS at JAM (space) 883 (space) your message to 2968
        &lt;/li&gt;
      &lt;/ul&gt;
  &lt;/li&gt; 
  &lt;li&gt;
    Rubber Boat Requests, 4×4 Trucks &lt;ul style=&quot;margin-bottom: 1em; margin-top: 0px;&quot;&gt;
      &lt;li&gt;
        NCRPO (+632-8383203, +632-8383354)
      &lt;/li&gt;
      &lt;li&gt;
        Private citizens who would like to lend their motor boats for rescue&lt;br /&gt;please call emergency nos: +632-9125668, +632-9111406, +632-9122665, +632-9115061)
      &lt;/li&gt;
      &lt;li&gt;
        You can also text (+632917-4226800 or +632927-6751981) for rescue dump trucks.
      &lt;/li&gt;
      &lt;li&gt;
        For those who are able to lend 4×4 trucks for rescue: Please send truck to Greenhills Shoppng Center Unimart Grocery to await deployment, Tel No. (+632920-9072902).
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt; 
&lt;/ul&gt; 
&lt;h3 id=&quot;online-and-in-kind-donations&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#online-and-in-kind-donations&quot; aria-label=&quot;online and in kind donations permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Online and In-Kind Donations&lt;/h3&gt;
&lt;p&gt;Below you’ll find a list of groups in the Phillippines that are accepting cash and in-kind donations to help with disaster relief efforts:&lt;/p&gt;
&lt;h4 id=&quot;monetary-donations&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#monetary-donations&quot; aria-label=&quot;monetary donations permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Monetary Donations&lt;/h4&gt;
  &lt;div style=&quot;font-weight: bold; margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 1em;&quot;&gt;
    1. Bank Donations &lt;a href=&quot;http://www.google.com/landing/typhoon-ondoy.html&quot; target=&quot;_blank&quot;&gt;Actual table here&lt;/a&gt;
  &lt;/div&gt;
  &lt;div style=&quot;font-weight: bold; margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 1em;&quot;&gt;
    1. Credit Card/PayPal Donations
  &lt;/div&gt;
  &lt;ul style=&quot;margin-bottom: 1em; margin-top: 1em;&quot;&gt;
    &lt;li&gt;
      &lt;a href=&quot;http://www.google.com/url?q=http://www.kapusofoundation.com/donate&amp;usd=2&amp;usg=ALhdy2946VOU4pgNTr6v4MUOlJa43wdQog&quot; &gt;GMA Kapuso Foundation&lt;/a&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;a href=&quot;http://www.txtpower.org/2009/09/philippines-help-typhoon-victims-in-luzon-philippine&quot; &gt;ABS-CBN Foundation&lt;/a&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;a href=&quot;http://www.philippineaid.com/&quot; &gt;Philippine Aid&lt;/a&gt;
    &lt;/li&gt;
  &lt;/ul&gt;
  &lt;div style=&quot;font-weight: bold; margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 1em;&quot;&gt;
    1. SMS Donations
  &lt;/div&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Procedure&lt;/th&gt;
&lt;th&gt;Smart Money&lt;/th&gt;
&lt;th&gt;Globe GCash&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;PNRC&lt;/td&gt;
&lt;td&gt;Type RED &lt;code class=&quot;language-text&quot;&gt;Ex. RED 100&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;4493&lt;/td&gt;
&lt;td&gt;2899&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;TXT POWER&lt;/td&gt;
&lt;td&gt;5577-5144-1866-7103&lt;/td&gt;
&lt;td&gt;0917-9751092&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h5 id=&quot;in-kind-donation&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#in-kind-donation&quot; aria-label=&quot;in kind donation permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;In-Kind Donation&lt;/h5&gt;
  &lt;ul style=&quot;margin-bottom: 1em; margin-top: 1em;&quot;&gt;
    &lt;li&gt;
      &lt;strong&gt;Victory Fort&lt;/strong&gt;&amp;nbsp;is opening its doors to those affected by the typhoon. Call 813-FORT.
    &lt;/li&gt;
    &lt;li&gt;
      &lt;strong&gt;NoyMar relief Operations&lt;/strong&gt;: Clare Amador (+639285205508) or Jana Vicente at +639285205499). Drop off for relief donations is at Balay Expo Center across Farmers Market Cubao.
    &lt;/li&gt;
    &lt;li&gt;
      &lt;strong&gt;Miriam Quiambao&lt;/strong&gt;&amp;nbsp;drop off points: One Orchard Road Building in Eastwood, or message &lt;a href=&quot;http://www.twitter.com/miriamq&quot; rel=&quot;nofollow&quot; &gt;http://www.twitter.com/miriamq&lt;/a&gt; for more details.
    &lt;/li&gt;
    &lt;li&gt;
      &lt;strong&gt;Philippine Army Gym&amp;nbsp;&lt;/strong&gt;inside Fort Bonifacio or&amp;nbsp;&lt;strong&gt;GHQ Gym&lt;/strong&gt;&amp;nbsp;in Camp Aguinaldo are now distributing donations for Ondoy Victims.
    &lt;/li&gt;
    &lt;li&gt;
      &lt;strong&gt;Team Manila&lt;/strong&gt;&amp;nbsp;stores in Trinoma, Mall of Asia, Jupiter Bel-Air and Rockwell shall be accepting relief goods (Canned Goods, Ready-to-drink Milk,Bottled Water and Clothes) for distribution by Veritas.
    &lt;/li&gt;
    &lt;li&gt;
      &lt;strong&gt;Caritas Manila&lt;/strong&gt;&amp;nbsp;Office at Jesus St., Pandacan Manila near Nagtahan Bridge (+632-5639298, +632-5639308)
    &lt;/li&gt;
    &lt;li&gt;
      &lt;strong&gt;Radio Veritas&lt;/strong&gt;&amp;nbsp;at Veritas Tower West Ave. Cor EDSA (+632-9257931-40)
    &lt;/li&gt;
    &lt;li&gt;
      &lt;strong&gt;Aranaz Stores&lt;/strong&gt;&amp;nbsp;in Rockwell &amp; Greenbelt is accepting donations of any kind for Payatas communities affected by Ondoy
    &lt;/li&gt;
    &lt;li&gt;
      &lt;strong&gt;Simbahang Lingkod ng Bayan Task Force Noah&lt;/strong&gt;, a disaster response arm of the Jesuits, is accepting donations. Please drop it off sa Ateneo Cervini Dorm.
    &lt;/li&gt;
    &lt;li&gt;
      &lt;strong&gt;Philippine National Red Cross&lt;/strong&gt;‘&amp;nbsp;&lt;a href=&quot;http://www.redcross.org.ph/Site/PNRC/wtd.aspx&quot; rel=&quot;nofollow&quot; &gt;different ways to Donate.&lt;/a&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;strong&gt;Red Cross Load Donations&lt;/strong&gt;: Right now the easiest way to make donations from the seat of your chair is via mobile phone load. The Red Cross Rescue and Relief Operations. Text: RED&lt;space&gt;AMOUNT to 2899 (Globe) or 4483 (Smart)&lt;/space&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;strong&gt;Ateneo de Manila University&lt;/strong&gt;&amp;nbsp;is now accepting donations for the victims of Ondoy. Donations can be dropped at MVP Lobby. For those stranded/those who need help: To all students who need help or know of people who need help. Please text the name, location, and contact number to (+6329088877166). ATENEO, which is now an&amp;nbsp;&lt;strong&gt;open shelter, accepts refugees&lt;/strong&gt;. Call (+632917-8952792)
    &lt;/li&gt;
    &lt;li&gt;
      &lt;strong&gt;Papemelroti&lt;/strong&gt;&amp;nbsp;stores in 91 Roces Ave. / Ali Mall Cubao / SM City North EDSA / SM Fairview / SM Megamall / Glorietta 3 in Makati / SM Centerpoint / SM Southmall are accepting relief goods (canned goods / milk / bottled water / clothes – NO CASH pls.)
    &lt;/li&gt;
    &lt;li&gt;
      &lt;strong&gt;TXTPower&lt;/strong&gt;&amp;nbsp;now accepts donations via SmartMoney 5577514418667103, GCash 09179751092 and Paypal&lt;a href=&quot;http://is.gd/3GvuN&quot; rel=&quot;nofollow&quot;  target=&quot;_blank&quot;&gt;http://is.gd/3GvuN&lt;/a&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;strong&gt;Our Lady of Pentecost Parish&amp;nbsp;&lt;/strong&gt;(+632-4342397, +632-9290665) per&amp;nbsp;&lt;a href=&quot;http://twitter.com/gabemercado/status/4393300142&quot; rel=&quot;nofollow&quot;  title=&quot;Gabe Mercado on Twitter&quot;&gt;Gabe Mercado&lt;/a&gt;, donations are very much welcome. The Parish is located at 12 F. Dela Rosa corner C. Salvador Sts., Loyola Heights, Quezon City.
    &lt;/li&gt;
    &lt;li&gt;
      &lt;strong&gt;Hillsborough Village Chapel&lt;/strong&gt;&amp;nbsp;– Water, blankets, shoes, and clothes may be sent to Hillsborough Village Chapel in Muntinlupa City. These will go to families whose houses were washed out in the nearby sitios.
    &lt;/li&gt;
    &lt;li&gt;
      Greenhills/Mandaluyong/San Juan Area, if you want to help out with the rescue and relief operations, you can drop off your donations (clothes, food, etc..) at&amp;nbsp;&lt;strong&gt;La Salle Greenhills&lt;/strong&gt;&amp;nbsp;Gate 2 tomorrow or volunteer from 9am to receive, sort, repack the donations.
    &lt;/li&gt;
    &lt;li&gt;
      &lt;strong&gt;Petron&lt;/strong&gt;: You may bring your relief goods to all Petron branches.
    &lt;/li&gt;
    &lt;li&gt;
      &lt;strong&gt;LUCA&lt;/strong&gt;&amp;nbsp;stores (Rockwell, Shang-rila, Eastwood, or GA towers): Send your old clothes &amp; donations (no cash pls).
    &lt;/li&gt;
    &lt;li&gt;
      &lt;strong&gt;“LUZON RELIEF: Volunteer / Donate / Pray”&lt;/strong&gt;: Donations can be brought to RENAISSANCE FITNESS CENTER, 2nd Floor, Bramante Building, Renaissance Towers Ortigas, MeralcoAvenue, Pasig City starting MONDAY (Sept.28) / 9am – 7pm Contact Person: Warren Habaluyas (+632929-8713488) or email at&amp;nbsp;&lt;a href=&quot;http://us.mc1114.mail.yahoo.com/mc/compose?to=luzonrelief@gmail.com&quot; rel=&quot;nofollow&quot; &gt;luzonrelief@gmail.com&lt;/a&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;strong&gt;MOONSHINE&lt;/strong&gt;&amp;nbsp;boutique in Rockwell also accepting relief good to help Ondoy victims in Marikina and&amp;nbsp;&lt;span style=&quot;background-color: transparent; background-repeat: repeat repeat;&quot;&gt;Cainta.&lt;/span&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;strong&gt;Katipunan Avenue. Contact Erica Paredes&lt;/strong&gt;&amp;nbsp;at (+632917-4741930) — they need bread, packed juice, sandwich filling (tuna, chicken, anything) You can help her make them, deliver the sandwiches to her house, or help her distribute! Call for more details.
    &lt;/li&gt;
    &lt;li&gt;
      &lt;strong&gt;Manor Superclub&lt;/strong&gt;, Eastwood City will accept goods and other emergency items starting Sunday at 10 am.
    &lt;/li&gt;
    &lt;li&gt;
      &lt;strong&gt;Citizens Disaster Response Center (CDRC):&lt;/strong&gt;&amp;nbsp;Relief goods for typhoon victims being accepted at 72-A Times St., West Triangle, QC. Tel (+632-9299820/22)
    &lt;/li&gt;
    &lt;li&gt;
      &lt;strong&gt;MINISTOP&lt;/strong&gt;&amp;nbsp;IBARRA (Espana cor. Blumentritt, Sampaloc Manila) is also accepting relief goods, Food (non-perishable goods only) Clothing, Medicines, Beds, Pillows, Blankets, Emergency Supplies to help Typhoon Ondoy victims.
    &lt;/li&gt;
  &lt;/ul&gt;</content:encoded></item><item><title><![CDATA[Updates on Ondoy: Places to donate – Efforts by bloggers]]></title><description><![CDATA[A call for help. If you are able, please donate whatever you can spare to the victims of Ondoy(Ketsana). I collected some details of donation centers and numbers but it pales in comparison to what other bloggers were able to post.]]></description><link>https://www.codespud.com/2009/updates-on-ondoy-places-to-donate-efforts-by-bloggers/</link><guid isPermaLink="false">https://www.codespud.com/2009/updates-on-ondoy-places-to-donate-efforts-by-bloggers/</guid><pubDate>Mon, 28 Sep 2009 03:07:00 GMT</pubDate><content:encoded>&lt;p&gt;A call for help. If you are able, please donate whatever you can spare to the victims of Ondoy(Ketsana).&lt;/p&gt;
&lt;p&gt;I collected some details of donation centers and numbers but it pales in comparison to what other bloggers were able to post. &lt;!--more--&gt;&lt;/p&gt;
&lt;p&gt;Please check the list of posts below:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://thefashpack.blogspot.com/2009/09/typhoon-ondoy-rescue-operations.html&quot; target=&quot;_blank&quot;&gt;Fashpack: typhoon ondoy rescue operations&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://conradmiguel.com/bagyong-ondoy-advisories-photos-etc&quot; target=&quot;_blank&quot;&gt;conradmiguel: Bagyong Ondoy – Advisories, Photos, Videos, How to Donate, etc&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.yousaytoo.com/typhoon-ondoy-emergency-hotlines-relief-operations/99711&quot; target=&quot;_blank&quot;&gt;yousaytoo: Typhoon Ondoy Emergency Hotlines &amp;#x26; Relief Operations&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://nowieh08.blogspot.com/2009/09/cebuanos-lets-help-victims-of-ondoy.html&quot; target=&quot;_blank&quot;&gt;nowieh08: cebuanos-lets-help-victims-of-ondoy&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://socialmediaphilippines.com/donate-for-ondoy-victims/&quot; target=&quot;_blank&quot;&gt;socialmediaphilippines: Manila Under Water – Barrio Bayanihan For Ondoy Victims&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://barriosiete.com/donate-for-ondoy-victims/&quot; target=&quot;_blank&quot;&gt;barriosiete: donate-for-ondoy-victims&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.blogherald.com/2009/09/26/filipino-bloggers-vigilant-with-typhoon-ondoy-floods/&quot; target=&quot;_blank&quot;&gt;blogherald: filipino-bloggers-vigilant-with-typhoon-ondoy-floods&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://herestolife.wordpress.com/2009/09/27/how-you-can-help-victims-of-tropical-storm-ketsanaondoy/&quot; target=&quot;_blank&quot;&gt;herestolife:how-you-can-help-victims-of-tropical-storm-ketsanaondoy&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.gingerbreadrunning.com/2009/09/no-laughing-matter-lets-help-ondoy.html&quot; target=&quot;_blank&quot;&gt;gingerbreadrunning: no-laughing-matter-lets-help-ondoy&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://apolthegreat.blogspot.com/2009/09/typhoon-ondoy-flood-and-rescue-updates.html&quot; target=&quot;_blank&quot;&gt;apolthegreat: typhoon-ondoy-flood-and-rescue-updates&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.pinaylighterside.com/2009/09/help-typhoon-ondoy-victims.html&quot; target=&quot;_blank&quot;&gt;pinaylighterside: help-typhoon-ondoy-victims&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://sourpolitics.wordpress.com/2009/09/26/typhoon-ondoy-emergency-hotlines-and-relief-operations/&quot; target=&quot;_blank&quot;&gt;sourpolitics: typhoon-ondoy-emergency-hotlines-and-relief-operations&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.marketmanila.com/archives/lets-mobilize-thousands-of-meals&quot; target=&quot;_blank&quot;&gt;Market Manila. Thousands of Hot Meals for The Kids…&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.abigwhale.info/random-thoughts/ondoy-relief-drop-off-sites&quot;&gt;abigwhale.info : ondoy-relief-drop-off-sites&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a name=&apos;more&apos;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Here are government and NGO sites with some info as well.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://www.redcross.org.ph/Site/PNRC/Home.aspx?ID=I,1469,P,-1&amp;ShowID=703&amp;SS=P&quot; target=&quot;_blank&quot;&gt;Philippine National Red Cross&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.dswd.gov.ph/&quot; target=&quot;_blank&quot;&gt;DSWD&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.owwa.gov.ph/news/2009/09/owwa-assists-typhoon-ondoy-affected-families-to-call-abroad/&quot; target=&quot;_blank&quot;&gt;OWWA&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://rtvm.gov.ph/index.php?option=com_content&amp;view=article&amp;id=1765:national-disaster-coordinating-council-ndcc-meeting&amp;catid=41:othr-engmnts&amp;Itemid=60&quot; target=&quot;_blank&quot;&gt;RTVM&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I know a hundred more bloggers and sites out there I don’t know about- doing the same thing. God bless them. Even if you can’t donate material items or you dont have specialized skills like doctors and nurses – you can help by spreading the word – checking the sites listed above and others. If you have anything to add to the list, please post a comment.&lt;/p&gt;
&lt;p&gt;Thanks and Lets pray for the safety of those affected.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Added Oct 6, 2009&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Here’s a site dedicated to the cause! Thanks goes to @Joel for sharing.&lt;br&gt;
&lt;strong&gt;&lt;a href=&quot;http://www.ketsanarelief.com/&quot; target=&quot;_blank&quot;&gt;&lt;a href=&quot;http://www.ketsanarelief.com/&quot;&gt;http://www.ketsanarelief.com/&lt;/a&gt;&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;These are times that I’m proud to be Filipino!&lt;/p&gt;
&lt;/blockquote&gt;</content:encoded></item><item><title><![CDATA[Project 10^100: The Voting Begins]]></title><description><![CDATA[Project 10^100 is a Google Project that transcends the information superhighway. It’s aim, simply, is to help – to help people so they can help others. How ? They promised to give 10 million dollars to fund any project that can improve peoples lives. But as funding is finite, they need to find the best ideas.]]></description><link>https://www.codespud.com/2009/project-10100-the-voting-begins/</link><guid isPermaLink="false">https://www.codespud.com/2009/project-10100-the-voting-begins/</guid><pubDate>Fri, 25 Sep 2009 23:39:00 GMT</pubDate><content:encoded>&lt;p&gt;Project 10^100 is a Google Project that transcends the information superhighway. It’s aim, simply, is to help – to help people so they can help others. How ? They promised to give 10 million dollars to fund any project that can improve peoples lives. But as funding is finite, they need to find the best ideas.&lt;!--more--&gt; Projects they believe, can do the most good.&lt;/p&gt;
&lt;div style=&quot;border: 1px solid #DDD; clear: both; text-align: center;&quot;&gt;
  &lt;a style=&quot;margin-left: 1em; margin-right: 1em;&quot; href=&quot;//3.bp.blogspot.com/_BBS5bkzuLXM/Sr1TvZGmd3I/AAAAAAAADF8/UQFO6reQYbU/s1600-h/potatokorner-project-10-100.png&quot;&gt;&lt;img src=&quot;//3.bp.blogspot.com/_BBS5bkzuLXM/Sr1TvZGmd3I/AAAAAAAADF8/UQFO6reQYbU/s320/potatokorner-project-10-100.png&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;p&gt;The past year (2008), Google received more than 150,000 ideas. It took another year(2009) and 3000 Google employees to sort them through. The ideas need to cover one of the following categories&lt;/p&gt;
&lt;p&gt;Categories:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Community:&lt;/strong&gt; How can we help connect people, build communities and protect unique cultures?&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Opportunity:&lt;/strong&gt; How can we help people better provide for themselves and their families?&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Energy:&lt;/strong&gt; How can we help move the world toward safe, clean, inexpensive energy?&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Environment:&lt;/strong&gt; How can we help promote a cleaner and more sustainable global ecosystem?&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Health:&lt;/strong&gt; How can we help individuals lead longer, healthier lives?&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Education:&lt;/strong&gt; How can we help more people get more access to better education?&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Shelter:&lt;/strong&gt; How can we help ensure that everyone has a safe place to live?&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Everything else:&lt;/strong&gt; Sometimes the best ideas don’t fit into any category at all.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Out of the huge collection of ideas, they have narrowed them down to 16. Each of which is inspired by different submissions. So no one submission can claim the idea, just part of the whole. Its a wonder how some minds are alike. 🙂 Even greater wonder that they choose to do good with those creative brains.&lt;br&gt;
&lt;a name=&quot;more&quot;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;What now?!&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Now they are asking for people to vote. To pick the ideas they believe can make the difference. Out of 16 they need 5 ideas to turn into funded projects. The call to vote started September 24, 2009 and will end October 8, 2009. Watch this video:&lt;/p&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;p&gt;So I invite you guys to go on &lt;a href=&quot;//www.project10tothe100.com/vote.html&quot; target=&quot;_blank&quot;&gt;Project 10^100’s voting page&lt;/a&gt;. Read all the ideas, and look into yourself what you think will help this hurting world of ours. Then pick the best one. After that invite others( friends,family, co-workers etc.) to do the same.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;It’s great that large companies like Google still have that sense of civic responsibility to better this world. I hope this generation can nurture what Google started and the projects that will win this opportunity. God bless us all!&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Use Export Command To Help Linux Find Your Scripts]]></title><description><![CDATA[You compiled and installed a linux binary or made a nifty script but you don’t want to mess the server bin tree. So you placed it in an isolated folder like so:]]></description><link>https://www.codespud.com/2009/use-export-command-to-help-linux-find-your-scripts/</link><guid isPermaLink="false">https://www.codespud.com/2009/use-export-command-to-help-linux-find-your-scripts/</guid><pubDate>Fri, 25 Sep 2009 03:37:00 GMT</pubDate><content:encoded>&lt;p&gt;You compiled and installed a linux binary or made a nifty script but you don’t want to mess the server bin tree. So you placed it in an isolated folder like so:&lt;/p&gt;
&lt;!--more--&gt;
&lt;h6 id=&quot;level-beginner-intermediate&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#level-beginner-intermediate&quot; aria-label=&quot;level beginner intermediate permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Level: Beginner, Intermediate&lt;/h6&gt;
&lt;div style=&quot;margin-left: 1em; margin-right: 1em; text-align: center;&quot;&gt;
  &lt;img src=&quot;//1.bp.blogspot.com/_BBS5bkzuLXM/Srw5tM3OeRI/AAAAAAAACjE/qLCjLDvRLHo/s200/punk+penguin.png&quot; /&gt;&lt;br /&gt;Yeah your a rockstar!
&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;  /usr/local/myscripts/really/great/work/bin/myutility&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You go on with business as usual. But soon you got tired of typing the whole path or changing folders every time you need the app. You could simplify your life by making a symbolic link(shortcut) or a wrapper script and place it on a more convenient path like /bin or /usr/bin. But you realize that would be defeating your original intent. what do you do? &lt;!--more--&gt;&lt;/p&gt;
&lt;p&gt;&lt;a name=&apos;more&apos;&gt;&lt;/a&gt;&lt;br&gt;
Simple. Do what experts do. Use “export” to modify the PATH environment variable.&lt;/p&gt;
&lt;div&gt;
  &gt; help export &lt;/p&gt; 
  &lt;p&gt;
    export: export [-nf] [name[=value] &amp;#8230;] or export -p &lt;br /&gt;NAMEs are marked for automatic export to the environment of subsequently executed commands. If the -f option is given, the NAMEs refer to functions. If no NAMEs are given, or if `-p&amp;#8217; is given, a list of all names that are exported in this shell is printed. An argument of `-n&amp;#8217; says to remove the export property from subsequent NAMEs. An argument of `&amp;#8211;&amp;#8216; disables further option processing.&lt;/div&gt; 
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;&amp;lt;p&gt;
  To get an idea, try this command on the console:
&amp;lt;/p&gt;

&amp;lt;div&gt;
  &gt; echo $PATH&amp;lt;/p&gt; 
  
  &amp;lt;p&gt;
    /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin&amp;lt;/div&gt; 
    
    &amp;lt;p&gt;
    &amp;lt;/p&gt;
    
    &amp;lt;p&gt;
      The above value is a typical &amp;amp;#8220;root&amp;amp;#8221; PATH for a fresh text-only CentOS installation &amp;amp;#8211; so don&amp;amp;#8217;t fret if you got something different. This will grow in time the more you install applications. Anyway, back to business, now you want to add your &amp;amp;#8220;incredible&amp;amp;#8221; scripts. Run the ff:
    &amp;lt;/p&gt;
    
    &amp;lt;div&gt;
      &gt; export PATH=$PATH:/usr/local/myscripts/really/great/work/bin
    &amp;lt;/div&gt;
    
    &amp;lt;p&gt;
      Done, now see if Linux can find your script or binary.
    &amp;lt;/p&gt;
    
    &amp;lt;div&gt;
      &gt; which myutility&amp;lt;/p&gt; 
      
      &amp;lt;p&gt;
        /usr/local/myscripts/really/great/work/bin/myutility&amp;lt;/div&gt; 
        
        &amp;lt;p&gt;
          Success! Now test your script.
        &amp;lt;/p&gt;
        
        &amp;lt;div&gt;
          &gt; myutility
        &amp;lt;/div&gt;
        
        &amp;lt;p&gt;
        &amp;lt;/p&gt;
        
        &amp;lt;blockquote&gt;
          &amp;lt;p&gt;
            If your script throws an error, you may need to work on it. It may be using hard coded relative paths. Sometimes using absolute paths can do the trick.
          &amp;lt;/p&gt;
        &amp;lt;/blockquote&gt;
        
        &amp;lt;p&gt;
          Yahoo! It works! Now lets take it a bit further, lets configure your system so you don&amp;amp;#8217;t need to keep typing the export-PATH command. Open the ~/.bash_profile file in your favorite text editor.
        &amp;lt;/p&gt;
        
        &amp;lt;div&gt;
          &gt; vi ~/.bash_profile&amp;lt;/p&gt; 
          
          &amp;lt;p&gt;
            # .bash_profile
          &amp;lt;/p&gt;
          
          &amp;lt;p&gt;
            # Get the aliases and functions&amp;lt;br /&gt;if [ -f ~/.bashrc ]; then&amp;lt;br /&gt;. ~/.bashrc&amp;lt;br /&gt;fi
          &amp;lt;/p&gt;
          
          &amp;lt;p&gt;
            # User specific environment and startup programs
          &amp;lt;/p&gt;
          
          &amp;lt;p&gt;
            PATH=$PATH:$HOME/bin
          &amp;lt;/p&gt;
          
          &amp;lt;p&gt;
            export PATH&amp;lt;br /&gt;unset USERNAME&amp;lt;/div&gt; 
            
            &amp;lt;p&gt;
            &amp;lt;/p&gt;
            
            &amp;lt;blockquote&gt;
              &amp;lt;p&gt;
                Note the tilde(~) symbol, this is just shorthand for your home folder. Lets say your username is iamgenius, that should translate to /home/iamgenius/.bash_profile
              &amp;lt;/p&gt;
            &amp;lt;/blockquote&gt;
            
            &amp;lt;p&gt;
              Same as what you did earlier, append your script folder to the PATH construct, as shown below
            &amp;lt;/p&gt;
            
            &amp;lt;div&gt;
              PATH=$PATH:$HOME/bin:/usr/local/myscripts/really/great/work/bin
            &amp;lt;/div&gt;
            
            &amp;lt;p&gt;
              Now your done, the next time you login, the new &amp;amp;#8220;PATH&amp;amp;#8221; should kick in.
            &amp;lt;/p&gt;
            
            &amp;lt;p&gt;
              Congratulations! Now go play with your scripts!
            &amp;lt;/p&gt;
            
            &amp;lt;p&gt;
              &amp;lt;a href=&quot;//dl.getdropbox.com/u/1510515/potatokorner/potatokorner-tutorial-export-command.pdf&quot; target=&quot;_blank&quot;&gt;Download a PDF copy&amp;lt;/a&gt;
            &amp;lt;/p&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</content:encoded></item><item><title><![CDATA[About Me]]></title><description><![CDATA[Hi, I’m Chris Bautista — a frontend engineer who specializes in accessible, production-grade web interfaces.]]></description><link>https://www.codespud.com/2009/about-me/</link><guid isPermaLink="false">https://www.codespud.com/2009/about-me/</guid><pubDate>Thu, 24 Sep 2009 01:07:00 GMT</pubDate><content:encoded>&lt;p&gt;Hi, I’m Chris Bautista — a frontend engineer who specializes in accessible, production-grade web interfaces. &lt;!--more--&gt;&lt;/p&gt;
&lt;p&gt;My recent posts are about accessibility (WCAG 2.1 AA) and modern frontend engineering: auditing components for screen reader and keyboard support, fixing real-world issues like focus traps, missing alt text, and unlabeled controls, and writing about what I learn along the way so other developers can skip the trial and error.&lt;/p&gt;
&lt;h2 id=&quot;what-i-work-with&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#what-i-work-with&quot; aria-label=&quot;what i work with permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;What I work with&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Languages:&lt;/strong&gt; JavaScript, TypeScript&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Frontend:&lt;/strong&gt; React, Gatsby, Tailwind CSS&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Accessibility:&lt;/strong&gt; WCAG 2.1 AA audits, ARIA patterns, keyboard/screen-reader testing, semantic HTML&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Testing:&lt;/strong&gt; Vitest&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Other:&lt;/strong&gt; Node.js, REST APIs, CSS (container queries, modern layout)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;recent-case-studies&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#recent-case-studies&quot; aria-label=&quot;recent case studies permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;Recent case studies&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;/accessible-tab-container/&quot;&gt;Build an Accessible Tab Container&lt;/a&gt; — roving tabindex, arrow-key navigation, ARIA tab pattern&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;/fix_accessibility_with_focus_within/&quot;&gt;Fix accessibility using focus-within&lt;/a&gt; — solving keyboard-vs-mouse UI mismatches without JavaScript&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;/skip-button-js/&quot;&gt;Automatically generate skip buttons&lt;/a&gt; — scripted skip-navigation links&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;/accessible-ui-component-series/&quot;&gt;Accessible UI Component Series&lt;/a&gt; — an accordion, buttons, and shared design tokens built to test ARIA patterns firsthand&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Also see &lt;a href=&quot;/animated-bottom-bar/&quot;&gt;Creating My Animated Bottom Bar Experiment&lt;/a&gt;, my most-loved CodePen experiment — interaction and motion rather than accessibility, but a good look at range.&lt;/p&gt;
&lt;p&gt;See the full &lt;a href=&quot;/works&quot;&gt;portfolio&lt;/a&gt; or browse posts tagged &lt;a href=&quot;/tags/accessibility&quot;&gt;accessibility&lt;/a&gt; for more.&lt;/p&gt;
&lt;h2 id=&quot;a-bit-of-background&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#a-bit-of-background&quot; aria-label=&quot;a bit of background permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;/span&gt;&lt;/a&gt;A bit of background&lt;/h2&gt;
&lt;p&gt;I’ve been building for the web for over 15 years — from hybrid mobile apps (Cordova, jQuery Mobile) and PHP/REST backends to, more recently, React and TypeScript. These days accessibility is the thread that ties most of my work together.&lt;/p&gt;
&lt;p&gt;I still own &lt;a href=&quot;http://www.codespud.com/&quot;&gt;CodeSpud Web Services&lt;/a&gt;, and you can find my code on &lt;a href=&quot;https://github.com/chrisbautista/&quot;&gt;GitHub&lt;/a&gt;. Have a challenge I can help with? Email me at &lt;u&gt;&lt;strong&gt;chris at codespud dot com&lt;/strong&gt;&lt;/u&gt;.&lt;/p&gt;
&lt;p&gt;Outside of code: gaming, cooking, and chasing the perfect cup of coffee.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Picasa 3.5 comes with Face Recognition]]></title><description><![CDATA[Google released Picasa 3.5 yesterday, with some cool features. In keeping with Picasa Web Albums enhancements,  Developers have added face recognition and geo tags to their photo-organizer-slash-jack-of-all-trades software.]]></description><link>https://www.codespud.com/2009/picasa-3-5-comes-with-face-recognition/</link><guid isPermaLink="false">https://www.codespud.com/2009/picasa-3-5-comes-with-face-recognition/</guid><pubDate>Thu, 24 Sep 2009 00:28:00 GMT</pubDate><content:encoded>&lt;p&gt;Google released Picasa 3.5 yesterday, with some cool features. In keeping with Picasa Web Albums enhancements,  Developers have added &lt;a href=&quot;http://picasa.google.com/features-nametags.html&quot; target=&quot;_blank&quot;&gt;face recognition&lt;/a&gt; and &lt;a href=&quot;http://en.wikipedia.org/wiki/Geotagging&quot; target=&quot;_blank&quot;&gt;geo tags&lt;/a&gt; to their photo-organizer-slash-jack-of-all-trades software.&lt;/p&gt;
&lt;!--more--&gt;
&lt;p&gt;&lt;a href=&quot;http://picasa-readme.blogspot.com/&quot; target=&quot;_blank&quot;&gt;&lt;a href=&quot;http://picasa-readme.blogspot.com/&quot;&gt;http://picasa-readme.blogspot.com/&lt;/a&gt;&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;With name tags, you can organize your photos based on what matters most: the people in them&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;As soon as the announcement came, I installed Picasa 3.5 – eager to try the new features. As it seems, face recognition is activated from start , no warning whatsoever, but you do need to login to your picasa account to get your name tags.&lt;/p&gt;
&lt;p&gt;Processing seems a bit longer than usual, as with the old version, you can still use the application even while it’s still sorting through all your stuff – so no worries. Picasa 3.5 got almost 100% from my tests. I already tagged faces on Web Albums so I didn’t had the chance to tag new faces. But I’m amazed how good this works even if the person is facing front or showing their profile. Nevertheless, your results may vary depending on how distinct people in your photos are. If it’s anything like Picasa Web Albums, the engine should improve in time the more you use it.&lt;/p&gt;
&lt;p&gt;Its a great addition to Picasa. It eases the pain of digging all your albums to find people. I know I’ll be abusing this one for a long time. 🙂&lt;/p&gt;
&lt;p&gt;
&lt;i&gt;&lt;a href=&quot;http://picasa.google.com/&quot; target=&quot;_blank&quot;&gt;Download Picasa 3.5&lt;/a&gt;&lt;br /&gt;Image from &lt;a href=&quot;http://parenting.leehansen.com/downloads/clipart/halloween/pages/clown-mask.htm&quot; target=&quot;_blank&quot;&gt;http://parenting.leehansen.com&lt;/a&gt;&lt;/i&gt;
&lt;/p&gt;</content:encoded></item><item><title><![CDATA[NES on Javascript]]></title><description><![CDATA[Here’s something amazing for Javascript, your good-ole  NES (Nintendo Entertainment System) games are now available and playable via Ben Firshman’s JSNES page. JSNES, is an NES emulator built on javascript’s canvas objects.]]></description><link>https://www.codespud.com/2009/nes-on-javascript/</link><guid isPermaLink="false">https://www.codespud.com/2009/nes-on-javascript/</guid><pubDate>Mon, 21 Sep 2009 08:19:00 GMT</pubDate><content:encoded>&lt;p&gt;Here’s something amazing for Javascript, your good-ole  NES (Nintendo Entertainment System) games are now available and playable via Ben Firshman’s JSNES page. JSNES, is an NES emulator built on javascript’s canvas objects.&lt;/p&gt;
&lt;!--more--&gt;
&lt;div&gt;
  &lt;a href=&quot;http://benfirshman.com/projects/jsnes/&quot; target=&quot;_blank&quot;&gt;http://benfirshman.com/projects/jsnes/&lt;/a&gt;
&lt;/div&gt;
&lt;p&gt;Mr. Firshman recommends to use Google’s Chrome browser to maximize your gaming pleasure. I tried it on IE8, it doesnt work as well. So take his word for it.&lt;/p&gt;
&lt;p&gt;Aside from SMB(Super Mario Bros.), he also ported some old favorites like the Zelda, the banana maniac-Donkey Kong and the blaster wielding Megaman. &lt;/p&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
  Ben Firshman shows us that with a little programming acrobatics and some improvements to browser canvas objects, anything is possible.&amp;nbsp;
&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
  Enjoy peeps!&amp;nbsp;
&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;blockquote&gt;
&lt;p&gt;Question: When can we start seeing 3D games running on browsers? Hehehe&lt;/p&gt;
&lt;/blockquote&gt;</content:encoded></item><item><title><![CDATA[XOXO Creativity]]></title><description><![CDATA[Here’s a good way to promote creativity and have fun at the same time. The rule is to draw as many things as your imagination can conjure up from X’s and O’s.]]></description><link>https://www.codespud.com/2009/xoxo-creativity/</link><guid isPermaLink="false">https://www.codespud.com/2009/xoxo-creativity/</guid><pubDate>Sun, 20 Sep 2009 12:16:00 GMT</pubDate><content:encoded>&lt;p&gt;Here’s a good way to promote creativity and have fun at the same time. The rule is to draw as many things as your imagination can conjure up from X’s and O’s.&lt;/p&gt;
&lt;!--more--&gt;
&lt;div style=&quot;clear: both; text-align: center;&quot;&gt;
  &lt;a href=&quot;http://2.bp.blogspot.com/_BBS5bkzuLXM/SrYMrUXkywI/AAAAAAAAChE/-eiXrZLTvAk/s1600-h/crea7128934724tivity11.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://2.bp.blogspot.com/_BBS5bkzuLXM/SrYMrUXkywI/AAAAAAAAChE/-eiXrZLTvAk/s400/crea7128934724tivity11.jpg&quot;&gt;&lt;/a&gt;&lt;br&gt;Almost done.
&lt;/div&gt;
&lt;p&gt;&lt;a name=&apos;more&apos;&gt;&lt;/a&gt;This is what &lt;strong&gt;Panamericana School of Art and Design&lt;/strong&gt; did in a advertising campaign.I tried googling for their site but can’t seem to find it. Anyway I’ll update this page when I get more info.&lt;/p&gt;
&lt;div style=&quot;clear: both; text-align: center;&quot;&gt;
  &lt;a href=&quot;http://3.bp.blogspot.com/_BBS5bkzuLXM/SrYM7xiv9pI/AAAAAAAAChM/kgBpufSfVeo/s1600-h/creativityasdad12.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://3.bp.blogspot.com/_BBS5bkzuLXM/SrYM7xiv9pI/AAAAAAAAChM/kgBpufSfVeo/s400/creativityasdad12.jpg&quot;&gt;&lt;/a&gt;&lt;br&gt;There’s something naughty in this shot.
&lt;/div&gt;
&lt;p&gt;I made my own versions to work with. You can download them below. Try them out with your kids and friends. You might just be surprised what plays in their minds. 🙂  Everybody say &lt;a href=&quot;http://en.wikipedia.org/wiki/Rorschach_test&quot;&gt;Rorschach test&lt;/a&gt;! :D.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Credit to Panamericana for the idea.&lt;/em&gt;&lt;br&gt;
&lt;em&gt;Images from &lt;a href=&quot;http://www.toxel.com/inspiration/2009/05/06/school-of-art-and-design-creativity-test/&quot;&gt;www.toxel.com&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;O’s Creativity Test &lt;a href=&quot;http://dl.getdropbox.com/u/1510515/potatokorner/potatokorner-O-creativity-test.pdf&quot;&gt;DOWNLOAD&lt;/a&gt;&lt;br&gt;
X’s Creativity Test &lt;a href=&quot;http://dl.getdropbox.com/u/1510515/potatokorner/potatokorner-X-creativity-test.pdf&quot;&gt;DOWNLOAD&lt;/a&gt;&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Resume on Youtube!]]></title><description><![CDATA[Streaming Video giant, Youtube, recently announced a Resume feature along with other improvements for their groundbreaking service. (Cheers! claps! Bring in the beer! LOL).]]></description><link>https://www.codespud.com/2009/resume-on-youtube/</link><guid isPermaLink="false">https://www.codespud.com/2009/resume-on-youtube/</guid><pubDate>Sat, 19 Sep 2009 13:51:00 GMT</pubDate><content:encoded>&lt;div style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;
  &lt;img border=&quot;0&quot; src=&quot;http://3.bp.blogspot.com/_BBS5bkzuLXM/SrTbWg_-NnI/AAAAAAAACg8/C9JxDO7GXBk/s320/youtubea23123.jpg&quot;&gt;
&lt;/div&gt;
&lt;p&gt;Streaming Video giant, Youtube, recently announced a Resume feature along with other improvements for their groundbreaking service. (Cheers! claps! Bring in the beer! LOL). &lt;!--more--&gt;Gone will be the days where you had to restart a video just to continue where you left of. Now you dont need to restart a whole video or pause till the video fully loads then skip every so and so, just to pick up where you last watched.&lt;/p&gt;
&lt;p&gt;Note the feature will only work for resumes past the 3 minute mark – meaning any resumes less than mentioned duration are ignored – so you need to run the video from the start again. A perfectly logical limitation. &lt;/p&gt;
&lt;p&gt;This addition is a big step forward for online media players – hopefully other video sites will follow suit. 🙂  For more info go &lt;a href=&quot;http://googlesystem.blogspot.com/2009/09/youtube-resume.html&quot;&gt;here&lt;/a&gt;&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Google got reCAPTCHA]]></title><description><![CDATA[Google announced recently in its official blog, that it has acquired reCAPTCHA. CAPTCHA is a web technology made out of necessity. It primarily is used to prevent BOTS (or automated apps designed to do malicious tasks) by adding an extra step to site pages that require human interaction.]]></description><link>https://www.codespud.com/2009/google-got-recaptcha/</link><guid isPermaLink="false">https://www.codespud.com/2009/google-got-recaptcha/</guid><pubDate>Sat, 19 Sep 2009 08:55:00 GMT</pubDate><content:encoded>&lt;p&gt;Google announced recently in its official blog, that it has acquired reCAPTCHA. &lt;a href=&quot;http://en.wikipedia.org/wiki/CAPTCHA&quot; target=&quot;_blank&quot;&gt;CAPTCHA&lt;/a&gt; is a web technology made out of necessity. It primarily is used to prevent BOTS (or automated apps designed to do malicious tasks) by adding an extra step to site pages that require human interaction. &lt;!--more--&gt;Yes, they’re the annoying barely readable text images when you register/login for a site.&lt;/p&gt;
&lt;div style=&quot;clear: both; text-align: center;&quot;&gt;
  &lt;a href=&quot;http://4.bp.blogspot.com/_BBS5bkzuLXM/SrSXzUCQrPI/AAAAAAAACgk/abV4JRYilQE/s1600-h/recaptcha-1231dasdqd.gif&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://4.bp.blogspot.com/_BBS5bkzuLXM/SrSXzUCQrPI/AAAAAAAACgk/abV4JRYilQE/s320/recaptcha-1231dasdqd.gif&quot;&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;p&gt;Anyway, this move by Google is more than just for improving it’s CAPTCHA capabilities. As they explain, reCAPTCHA technology will improve Google projects that require reading text in images. The best to benefit from this are &lt;span style=&quot;font-family: Arial; font-size: 13px; white-space: pre;&quot;&gt;Google’s &lt;span style=&quot;font-family: &apos;Times New Roman&apos;; font-size: medium; white-space: normal;&quot;&gt; &lt;a href=&quot;http://books.google.com/&quot; target=&quot;_blank&quot;&gt;Books&lt;/a&gt; project and the recent &lt;a href=&quot;http://fastflip.googlelabs.com/&quot; target=&quot;_blank&quot;&gt;Fast Flip &lt;/a&gt; zine search. For more info see the &lt;a href=&quot;http://googleblog.blogspot.com/2009/09/teaching-computers-to-read-google.html&quot; target=&quot;_blank&quot;&gt;official announcement.&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;</content:encoded></item><item><title><![CDATA[M I STUPID?]]></title><description><![CDATA[Do you know how to send an SOS in morse code? Do you know your birthstone? Or the winners of the Oscars since 1927 ? MIStupid.com has an assortment of trivia and topics not known by the most of us. As a bonus they have categories with games and puzzles you can play with when you catch a bit of an information overload.]]></description><link>https://www.codespud.com/2009/m-i-stupid/</link><guid isPermaLink="false">https://www.codespud.com/2009/m-i-stupid/</guid><pubDate>Sat, 19 Sep 2009 07:41:00 GMT</pubDate><content:encoded>&lt;p&gt;Do you know how to send an SOS in morse code? Do you know your birthstone? Or the winners of the Oscars since 1927 ? MIStupid.com has an assortment of trivia and topics not known by the most of us. As a bonus they have categories with games and puzzles you can play with when you catch a bit of an information overload.&lt;/p&gt;
&lt;!--more--&gt;
&lt;div&gt;
  &lt;a href=&quot;http://mistupid.com/contents.htm&quot; target=&quot;_blank&quot;&gt;http://mistupid.com/contents.htm&lt;/a&gt;
&lt;/div&gt;
&lt;p&gt;No matter how trivial or uninteresting the fact is &lt;strong&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;MIStupid.com&lt;/span&gt;&lt;/strong&gt; will surely have it, otherwise go back to &lt;strong&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Google&lt;/span&gt;&lt;/strong&gt; (hehehe). Well okay it’s not Encarta but its free and &lt;strong&gt;&lt;span style=&quot;color: green;&quot;&gt;&lt;span style=&quot;color: green; font-weight: bold;&quot;&gt;GREEN&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt; 🙂&lt;/p&gt;
&lt;p&gt;Enjoy!&lt;/p&gt;
&lt;p&gt;potato&lt;/p&gt;</content:encoded></item><item><title><![CDATA[How to Write a Backup Shell Script using Tar and Gnu Zip]]></title><description><![CDATA[Happy New Year! As promised I made a rudimentary Linux shell script utilizing the tar and gzip commands to archive or make backups. If you’re new to shell scripting you might like to read these articles. Unix shell scripting with ksh/bash
Advanced Bash-Scripting Guide If you’re lazy like I am. Don’t worry I’ll explain parts of the code.]]></description><link>https://www.codespud.com/2009/how-to-write-a-backup-shell-script-using-tar-and-gnu-zip/</link><guid isPermaLink="false">https://www.codespud.com/2009/how-to-write-a-backup-shell-script-using-tar-and-gnu-zip/</guid><pubDate>Fri, 02 Jan 2009 23:20:00 GMT</pubDate><content:encoded>&lt;p&gt;Happy New Year!&lt;/p&gt;
&lt;p&gt;As promised I made a rudimentary Linux shell script utilizing the tar and gzip commands to archive or make backups. If you’re new to shell scripting you might like to read these articles.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.dartmouth.edu/~rc/classes/ksh/print_pages.shtml&quot;&gt;Unix shell scripting with ksh/bash&lt;/a&gt;
&lt;a href=&quot;http://tldp.org/LDP/abs/html/&quot;&gt;Advanced Bash-Scripting Guide&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;If you’re lazy like I am. Don’t worry I’ll explain parts of the code.&lt;/p&gt;
&lt;!--more--&gt;
&lt;p&gt;Our goal is to make a shell script to create backups (in tar-gzip versions) of the folders we want unto a safe location on a disk. We want to be able to list all the folders and have the script loop through them. Now that’s settled, we can proceed to the code.&lt;!--more--&gt;&lt;/p&gt;
&lt;p&gt;First, don’t forget to tell linux what scripting interpreter to use. I usually use &lt;span style=&quot;font-style: italic;&quot;&gt;sh&lt;/span&gt; but there are others like &lt;span style=&quot;font-style: italic;&quot;&gt;bash and ksh&lt;/span&gt;. But many experts suggest to use sh for portability to older systems.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token shebang important&quot;&gt;#!/bin/sh&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Next, we configure the script. The lines below enumerates the folders I want archived ,then stores them in a SHELL VARIABLE named FOLDERS. (duhh!..)&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;# — LIST OF FILES/FOLDERS TO BACKUP&lt;/span&gt;
&lt;span class=&quot;token assign-left variable&quot;&gt;FOLDERS&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;”/var/www/html /opt/sandbox”&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This line saves the folder path I want the archives to be stored in.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;# — BACKUP HERE&lt;/span&gt;
&lt;span class=&quot;token assign-left variable&quot;&gt;BACKUPFOLDER&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;”/opt/backup”&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;em&gt;REMINDER&lt;/em&gt;&lt;br&gt;
Make sure that the backup folder exist. If it doesn’t run the lines below on the console.&lt;/p&gt;
&lt;div style=&quot;background-color: green; color: white; padding: 10px;&quot;&gt;
  &gt; mkdir /opt/backup&lt;br /&gt; &gt; chown root:root /opt/backup&lt;br /&gt; &gt; chmod 755 /opt/backup
&lt;/div&gt;
&lt;p&gt;Here I configure the command string I want to use. Regarding the details of the command I used – see this &lt;a href=&quot;http://potatokorner.blogspot.com/2008/12/linux-snippet-backup-using-tar-and-gzip.html&quot;&gt;[link]&lt;/a&gt;.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;# — ARCHIVE COMMAND&lt;/span&gt;
&lt;span class=&quot;token assign-left variable&quot;&gt;COMPRESSCMD&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;”tar czfv “&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Here we use the &lt;span style=&quot;font-style: italic;&quot;&gt;for&lt;/span&gt; command to loop through all the items we listed in &lt;span style=&quot;font-style: italic;&quot;&gt;$FOLDERS&lt;/span&gt; and store it in another variable, &lt;span style=&quot;font-style: italic;&quot;&gt;$itm&lt;/span&gt;.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;## loop thru folders&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;token for-or-select variable&quot;&gt;itm&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$FOLDERS&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;do&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;# commands here&lt;/span&gt;
….
&lt;span class=&quot;token keyword&quot;&gt;done&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;These lines configures the commands we’re going to use inside the loop. The first line generates a formatted file path for my archive, $FARCHIVE.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token assign-left variable&quot;&gt;FARCHIVE&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$BACKUPFOLDER&lt;/span&gt;/&lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;basename&lt;/span&gt; $itm&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;/span&gt;_&lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;uname&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-n&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;/span&gt;_&lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;date&lt;/span&gt; +%F&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;/span&gt;.tgz
&lt;span class=&quot;token variable&quot;&gt;$COMPRESSCMD&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$FARCHIVE&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$itm&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If you’ve noticed I used the tilde symbol(`). Yes they are not single quotation marks. In linux console, any commands enclosed within tildes are ran first and the result is returned as a string. So for example &lt;span style=&quot;font-style: italic;&quot;&gt;$itm&lt;/span&gt; is equal to &lt;span style=&quot;font-style: italic;&quot;&gt;/var/www/html&lt;/span&gt;. The resulting FARCHIVE value will be:&lt;/p&gt;
&lt;div style=&quot;background-color: green; color: white; padding: 10px;&quot;&gt;
  &gt; echo $FARCHIVE&lt;br /&gt; /opt/backup/html_potato_2009-01-02.tgz
&lt;/div&gt;
&lt;p&gt;The second line uses $FARCHIVE as well as the command we configured earlier and runs it.&lt;/p&gt;
&lt;p&gt;For a breakdown of the enclosed commands we used.&lt;/p&gt;
&lt;p&gt;echo the last(base) name in a path string.&lt;/p&gt;
&lt;div style=&quot;background-color: green; color: white; padding: 10px;&quot;&gt;
  &gt; basename /var/www/html&lt;br /&gt; html
&lt;/div&gt;
&lt;p&gt;echo the system’s computer name.&lt;/p&gt;
&lt;div style=&quot;background-color: green; color: white; padding: 10px;&quot;&gt;
  &gt; uname -n&lt;br /&gt; potato
&lt;/div&gt;
&lt;p&gt;echo the current date in this format (YYYY-MM-DD)&lt;/p&gt;
&lt;div style=&quot;background-color: green; color: white; padding: 10px;&quot;&gt;
  &gt; date +%F&lt;br /&gt; 2009-01-02
&lt;/div&gt;
&lt;p&gt;Here is the full script.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token shebang important&quot;&gt;#!/bin/sh&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;#set -x&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;#——————————————–&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;# ID: cabBackup.sh – BACKUP items to folder&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;# USAGE: ./cabBackup.sh&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;#——————————————–&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;# AUTHOR: codespud 2008-2009&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;# VERSION: 0.01&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;# TODO: arguments&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;# TODO: config file&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;# TODO: functions&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;# TODO: filtering&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;# Sources&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;# http://www.hsrl.rutgers.edu/ug/shell_help.html&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;# PATH&lt;/span&gt;
&lt;span class=&quot;token assign-left variable&quot;&gt;&lt;span class=&quot;token environment constant&quot;&gt;PATH&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;/opt/bin:/usr/bin:/bin&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token builtin class-name&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;token environment constant&quot;&gt;PATH&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;# CONFIG&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;# — LIST OF FILES/FOLDERS TO BACKUP if not specified via console&lt;/span&gt;

&lt;span class=&quot;token assign-left variable&quot;&gt;FOLDERS&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;”/var/www/html /opt/sandbox”
&lt;span class=&quot;token comment&quot;&gt;#FOLDERS=””&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;# — BACKUP HERE&lt;/span&gt;
&lt;span class=&quot;token assign-left variable&quot;&gt;BACKUPFOLDER&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;”/opt/backup”

&lt;span class=&quot;token comment&quot;&gt;# — ARCHIVE COMMAND&lt;/span&gt;
&lt;span class=&quot;token assign-left variable&quot;&gt;COMPRESSCMD&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;”tar czfv ”

&lt;span class=&quot;token comment&quot;&gt;# — DO NOT EDIT BEYOND THIS LINE (unless if you knw what ur doing ;] ) —&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;# Check if the folder exists if not make it&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-d&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$BACKUPFOLDER&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;mkdir&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-p&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$BACKUPFOLDER&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;token builtin class-name&quot;&gt;:&lt;/span&gt;

&lt;span class=&quot;token function&quot;&gt;chown&lt;/span&gt; root:root &lt;span class=&quot;token variable&quot;&gt;$BACKUPFOLDER&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;chmod&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;755&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$BACKUPFOLDER&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;# clean the screen&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;clear&lt;/span&gt;

&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; lets start

&lt;span class=&quot;token comment&quot;&gt;## loop thru folders&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;token for-or-select variable&quot;&gt;itm&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$FOLDERS&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;do&lt;/span&gt;

&lt;span class=&quot;token assign-left variable&quot;&gt;FARCHIVE&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$BACKUPFOLDER&lt;/span&gt;/&lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;basename&lt;/span&gt; $itm&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;/span&gt;_&lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;uname&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-n&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;/span&gt;_&lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;date&lt;/span&gt; +%F&lt;span class=&quot;token variable&quot;&gt;`&lt;/span&gt;&lt;/span&gt;.tgz
&lt;span class=&quot;token variable&quot;&gt;$COMPRESSCMD&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$FARCHIVE&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$itm&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;done&lt;/span&gt;

&lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;..&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now name and save the file. I named mine &lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;cabBackup.sh&lt;/span&gt;&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;You need to make the script executable.&lt;/p&gt;
&lt;div style=&quot;background-color: green; color: white; padding: 10px;&quot;&gt;
  &gt; chmod 755 ./cabBackup.sh
&lt;/div&gt;
&lt;p&gt;There you have it just run it from the console.&lt;/p&gt;
&lt;div style=&quot;background-color: green; color: white; padding: 10px;&quot;&gt;
  &gt; ./cabBackup.sh
&lt;/div&gt;
&lt;p&gt;There are still some things we need to do to make it a fully fledged automation script like configuration files, some pre-process commands and error trapping. But what we have now serves our purpose very well. I’ll post revisions of this script so watch for that.&lt;/p&gt;
&lt;p&gt;Links&lt;br&gt;
&lt;a href=&quot;http://www.dartmouth.edu/~rc/classes/ksh/print_pages.shtml&quot;&gt;http://www.dartmouth.edu/~rc/classes/ksh/print_pages.shtml&lt;/a&gt;&lt;br&gt;
&lt;a href=&quot;http://tldp.org/LDP/abs/html/&quot;&gt;http://tldp.org/LDP/abs/html/&lt;/a&gt;&lt;br&gt;
&lt;a href=&quot;http://potatokorner.blogspot.com/2008/12/linux-snippet-backup-using-tar-and-gzip.html&quot;&gt;Linux: Snippet – Backup using Tar and gzip&lt;/a&gt;&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Linux: Snippet – Backup using Tar and gzip]]></title><description><![CDATA[As a programmer i have to make multiple revisions of a project on a remote site. Getting things wrong and messing up the files tend to happen more often than I am comfortable with. Fortunately, making quick backups in linux is a breeze. You can either make a folder and just copy your existing files via recursive cp command or; archive it using tar and gzip. Personally, I prefer archives since they tend to be smaller and easy to manage.]]></description><link>https://www.codespud.com/2008/linux-snippet-backup-using-tar-and-gzip/</link><guid isPermaLink="false">https://www.codespud.com/2008/linux-snippet-backup-using-tar-and-gzip/</guid><pubDate>Sun, 07 Dec 2008 08:51:00 GMT</pubDate><content:encoded>&lt;p&gt;As a programmer i have to make multiple revisions of a project on a remote site. Getting things wrong and messing up the files tend to happen more often than I am comfortable with. Fortunately, making quick backups in linux is a breeze. You can either make a folder and just copy your existing files via recursive cp command or; archive it using tar and gzip. Personally, I prefer archives since they tend to be smaller and easy to manage. &lt;!--more--&gt;&lt;/p&gt;
 &lt;div&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;span &gt;&lt;span&gt;Install tar and gzip&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;
 &lt;div&gt;
&lt;span &gt;&lt;span&gt; You can be hardcore and download the source for tar and gzip and recompile them.&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;
 &lt;div&gt;
&lt;span style=&quot;font-size: 13px;&quot;&gt; &lt;/span&gt;
&lt;/div&gt;
 &lt;div&gt;
&lt;a href=&quot;http://www.gnu.org/software/tar&quot;&gt;&lt;span&gt;http://www.gnu.org/software/tar/&lt;/span&gt;&lt;/a&gt;
&lt;/div&gt;
 &lt;div&gt;
&lt;a href=&quot;http://www.gzip.org/&quot;&gt;&lt;span&gt;http://www.gzip.org/&lt;/span&gt;&lt;/a&gt;
&lt;/div&gt;
 &lt;div&gt;
&lt;span&gt; Or you can use apt-get or yum(Yellow dog Updater, Modified ? &amp;#8212; weird name ) to do it for you.&lt;/span&gt;
&lt;/div&gt;
 &lt;div&gt;
&lt;span&gt; yum install tar&lt;/span&gt;
&lt;/div&gt;
 &lt;div&gt;
&lt;span&gt; yum install gzip&lt;/span&gt;
&lt;/div&gt;
 &lt;div&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;Sample commands&lt;/span&gt;
&lt;/div&gt;
 &lt;div&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;Archive a folder ( -c means create )&lt;/span&gt;
&lt;/div&gt;
 &lt;pre&gt;&lt;span style=&quot;color: #009900;&quot;&gt;tar cvf - folder | gzip &amp;gt; archive.tar.gz&lt;/span&gt;&lt;/pre&gt;
 &lt;div&gt;
&lt;span style=&quot;font-family: &apos;courier new&apos;;&quot;&gt;Archive a file&lt;/span&gt;
&lt;/div&gt;
 &lt;pre&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;tar cvf - filename | gzip &amp;gt; archive.tar.gz&lt;/span&gt;&lt;/pre&gt;
 &lt;div&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;Archive files&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;
 &lt;pre&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;tar cvf - filename1 filename2 | gzip &amp;gt; archive.tar.g&lt;/span&gt;&lt;/pre&gt;
 &lt;div&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;Alternative format (-z means use gzip to compress)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;
 &lt;pre&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;tar cvzf /path/to/dir/archive.tar.gz filename&lt;/span&gt;&lt;/pre&gt;
 &lt;pre&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;tar cvzf /path/to/dir/archive.tar.gz filename1 filename&lt;/span&gt;&lt;/pre&gt;
 &lt;div&gt;
&lt;span style=&quot;font-weight: bold;&quot;&gt;Extracting (-x means extract )&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;
 &lt;pre&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;tar xvzf /path/to/dir/archive.tar.gz&lt;/span&gt;&lt;/pre&gt;
 &lt;div&gt;
&lt;span&gt; There are other ways and tools to make your archives. But we&amp;#8217;ll continue with that some other time. For the really lazy, I&amp;#8217;ll make a bash script that uses tar and gzip in a later post so watch for that.&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;
 &lt;div&gt;
&lt;span &gt;&lt;span&gt; I hope my article helped some newbies out there. Mabuhay!&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;</content:encoded></item></channel></rss>