<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title>Fotis Papadogeorgopoulos</title>
	<subtitle>Thoughts, talks, notes, and everything in-between. Personal blog of Fotis Papadogeorgopoulos.</subtitle>
	<link href="" rel="self"/>
	<link href="https://fotis.xyz/feed/feed.xml" rel="self"/>
	<link href="https://fotis.xyz"/>
	<updated>2025-04-14T00:00:00Z</updated>
	<id>https://fotis.xyz/</id>
	<author>
		<name>Fotis Papadogeorgopoulos</name>
		<email>fotis@fpapado.com</email>
	</author>
	
	<entry>
		<title>Linking to Headings</title>
		<link href="https://fotis.xyz/posts/linking-to-headings/"/>
		<updated>2019-01-20T00:00:00Z</updated>
		<id>https://fotis.xyz/posts/linking-to-headings/</id>
		<content type="html">&lt;p&gt;Recently, a co-worker, &lt;a href=&quot;https://twitter.com/hamatti&quot;&gt;Juhis&lt;/a&gt;, asked me about the pattern of linking to specific headings in a document:&lt;/p&gt;
&lt;div class=&quot;md-img aspect-ratio aspect-ratio--6x4 bg-light-gray  &quot;&gt;
  &lt;img src=&quot;https://fotis.xyz/img/posts/linking_headings_1.jpg&quot; alt=&quot;#Accessibility and #semantics question for #HTML: if I use an anchor name=&#39;foo&#39;, should I also add href attribute to it to make it link to itself?&quot; loading=&quot;lazy&quot; class=&quot;aspect-ratio--object fit-cover o-pos-top  &quot; /&gt;
&lt;/div&gt;
&lt;p&gt;This is a pattern I see often in documentation sites, where the headings are linked from a Table of Contents. Users might want to refer back or save a link to a section for posterity. Exposing that link next to the heading can help that goal.&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;markup&quot; tabindex=&quot;-1&quot;&gt;Markup&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/linking-to-headings/#markup&quot; aria-label=&quot;Link to Markup&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;The &lt;code&gt;name&lt;/code&gt; attribute has been deprecated in HTML5. You can use the &lt;code&gt;id&lt;/code&gt; attribute to achieve the same goal. I really like the &lt;code&gt;id&lt;/code&gt;, because it is shared with form &lt;code&gt;label&lt;/code&gt;, &lt;code&gt;aria-labelledby&lt;/code&gt; and other cases of referencing content.&lt;/p&gt;
&lt;p&gt;So, suppose we have a list of links that point to sections. A first attempt at linking things would look like this:&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;h1&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;README&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;h1&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;h2&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;Table of contents&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;h2&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;ol&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; href&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;#installation&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;Installation&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; href&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;#development&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;Development&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; href&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;#credits&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;Credits&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;ol&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;h2&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; id&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;installation&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;Installation&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;h2&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;You can install the library from npm.&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;h2&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; id&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;development&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;Development&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;h2&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;You will need node version 10 installed.&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;h2&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; id&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;credits&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;Credits&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;h2&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;Here is an article about past work on this problem.&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We give each section heading an &lt;code&gt;id&lt;/code&gt;, and associate the &lt;code&gt;href&lt;/code&gt; to it. What if we want to make the link available for copying?&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;affordances-and-announcements&quot; tabindex=&quot;-1&quot;&gt;Affordances and announcements&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/linking-to-headings/#affordances-and-announcements&quot; aria-label=&quot;Link to Affordances and announcements&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;I see two things to answer here:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Visually representing the link&lt;/li&gt;
&lt;li&gt;Deciding whether to announce it to screen readers&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Visual representation&lt;/h3&gt;
&lt;p&gt;On the visual side, I think that it is a good idea to always have the link available. Having it appear or disappear based on hover (and focus!) states can be confusing. I also think that hiding it would make the behaviour less discoverable. Nothing bad really happens if someone clicks on the link; they are taken to where they were, and then they know what it does.&lt;/p&gt;
&lt;p&gt;If I had to pick, I would go for a standalone hash symbol, ‘#’. You could probably add an icon as well. In general, I am curious to read any research/user testing on this
pattern!&lt;/p&gt;
&lt;h3&gt;Screen reader announcement (or not)&lt;/h3&gt;
&lt;p&gt;Now, what do we do about screen reader announcements? Having duplicate announcements can be bad, because there is no context for what each link does. On the other hand, I think that any user might want to save or send the link. In that case, removing the announcement might remove useful functionality.&lt;/p&gt;
&lt;p&gt;Having said that, I would probably opt to not announce the link. The extra announcements do not make sense if you list links. Moreover, in cases where I have a table of contents (e.g. in a docs site), there are already explicit links, with context, available! The extra ‘#’ would be very much an enhancement in that case, and the &lt;a href=&quot;https://inclusivedesignprinciples.org/#provide-comparable-experience&quot;&gt;comparable experience&lt;/a&gt; seems in place.&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;in-the-wild&quot; tabindex=&quot;-1&quot;&gt;In the wild&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/linking-to-headings/#in-the-wild&quot; aria-label=&quot;Link to In the wild&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;Here are a few uses of this pattern that I spotted in the wild.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/fpapado/fotis.xyz&quot;&gt;Github README rendering&lt;/a&gt; shows a link only on hover, and hides the announcement with &lt;code&gt;aria-hidden=&amp;quot;true&amp;quot;&lt;/code&gt;. I am not a huge fan of that. Especially since READMEs are typically documentation and reference, I would think that making the link always visible would be more intuitive.&lt;/p&gt;
&lt;div class=&quot;md-img aspect-ratio aspect-ratio--6x4 bg-light-gray  &quot;&gt;
  &lt;img src=&quot;https://fotis.xyz/img/posts/linking-headings-github.jpg&quot; alt=&quot;&quot; loading=&quot;lazy&quot; class=&quot;aspect-ratio--object fit-cover   &quot; /&gt;
&lt;/div&gt;
&lt;p&gt;&lt;a href=&quot;https://css-tricks.com/2019-css-wishlist/&quot;&gt;CSS Tricks&lt;/a&gt; has the links always visible as ‘#’ and always announced. They are placed at the beginning of headings, which keeps the alignment flush on the start.&lt;/p&gt;
&lt;div class=&quot;md-img aspect-ratio aspect-ratio--16x9 bg-light-gray  &quot;&gt;
  &lt;img src=&quot;https://fotis.xyz/img/posts/linking-headings-css-tricks.jpg&quot; alt=&quot;&quot; loading=&quot;lazy&quot; class=&quot;aspect-ratio--object fit-cover o-pos-left  &quot; /&gt;
&lt;/div&gt;
&lt;p&gt;The &lt;a href=&quot;https://inclusivedesignprinciples.org/&quot;&gt;Inclusive Design Principles&lt;/a&gt; website offers an explicit link for sections. For example, the “Provide Comparable Experience” section has a link “Link to Provide comparable experience” at the end. I like how direct it is, and the placement at the section seems distinct enough. I would definitely consider this for a site!&lt;/p&gt;
&lt;div class=&quot;md-img aspect-ratio aspect-ratio--6x4 bg-light-gray  &quot;&gt;
  &lt;img src=&quot;https://fotis.xyz/img/posts/linking-headings-inclusive-design-principles.jpg&quot; alt=&quot;&quot; loading=&quot;lazy&quot; class=&quot;aspect-ratio--object fit-cover   &quot; /&gt;
&lt;/div&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;final-words&quot; tabindex=&quot;-1&quot;&gt;Final words&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/linking-to-headings/#final-words&quot; aria-label=&quot;Link to Final words&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;Given everything above, here is how I would do it:&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;h1&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;README&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;h1&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;h2&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;Table of contents&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;h2&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;ol&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; href&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;#installation&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;Installation&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; href&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;#development&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;Development&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; href&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;#credits&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;Credits&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;ol&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;h2&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; id&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;installation&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;Installation&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; href&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;#installation&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; aria-label&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;Link to Installation section&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;h2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;You can install the library from npm.&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;h2&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; id&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;development&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;Development&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; href&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;#development&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; aria-label&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;Link to Development section&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;h2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;You will need node version 10 installed.&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;h2&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; id&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;credits&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;Credits &lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; href&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;#credits&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; aria-label&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;Link to Credits section&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;h2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;Here is an article about past work on this problem.&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Would you pick some other combination or priorities? Do you have user insights or more cases to consider? Get in touch, I’d love to know!&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>New Year, New Blog</title>
		<link href="https://fotis.xyz/posts/new-year-new-blog/"/>
		<updated>2019-01-20T00:00:00Z</updated>
		<id>https://fotis.xyz/posts/new-year-new-blog/</id>
		<content type="html">&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;the-road-so-far&quot; tabindex=&quot;-1&quot;&gt;The road so far&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/new-year-new-blog/#the-road-so-far&quot; aria-label=&quot;Link to The road so far&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;A few months back, I spent a good amount of time working at the website for Futurice’s Tech Weeklies.&lt;/p&gt;
&lt;p&gt;Tech Weeklies is our, well, weekly gathering, where we share thoughts about tech and everything related. We have a great mix of people at the office, and I love seeing what everyone is passionate about! It’s one of my favourite parts of working here.&lt;/p&gt;
&lt;p&gt;Given that background, and having recently come back from the &lt;a href=&quot;https://perfnow.nl/&quot;&gt;performance.now()&lt;/a&gt; conference, I was super motivated to work on the site. Taking on that task was a good opportunity to showcase what an accessible, performant site looked like in my mind.&lt;/p&gt;
&lt;p&gt;And so we made it! You can find the &lt;a href=&quot;https://techweeklies.futurice.com/&quot;&gt;Tech Weeklies site here&lt;/a&gt;. We launched to a warm reception, achieved most of our goals, and content is being added every week. I was happy.&lt;/p&gt;
&lt;p&gt;Also, I was exhausted. Between that burst of energy, travels, talk preparations and the darkness of Finnish November, it is fair to say that my batteries were empty.&lt;/p&gt;
&lt;p&gt;I made a point to stash my laptop away on the weekends, and get away from coding a bit.&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;now&quot; tabindex=&quot;-1&quot;&gt;Now&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/new-year-new-blog/#now&quot; aria-label=&quot;Link to Now&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;This was the tenth weekend without coding. I have recharged, and learned a thing or two about balancing my time.&lt;/p&gt;
&lt;p&gt;I have been thinking about what it means to share my thoughts. (&lt;a href=&quot;https://fotis.photos/collection/2017/08/13/signal.html&quot;&gt;I have written about that subject in the domain of photography before&lt;/a&gt;). There are some hundred notes spread around my notebooks and chats with co-workers about programming, the people we build things for, and generally our existence in this machine. (Can you tell, the Finnish winter still has a hold on me).&lt;/p&gt;
&lt;p&gt;I have been wanting a home for my tech writing for a while. I tried last year, and I didn’t add much. Then, I thought back to what made the weeklies site so enjoyable for me:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Optimise for adding content&lt;/li&gt;
&lt;li&gt;Use a stack you understand&lt;/li&gt;
&lt;li&gt;Start with the content, and build the rest around it&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;the-prompt&quot; tabindex=&quot;-1&quot;&gt;The prompt&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/new-year-new-blog/#the-prompt&quot; aria-label=&quot;Link to The prompt&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;Many of the topics I have in mind tend to snowball into large, never-ending posts.&lt;/p&gt;
&lt;p&gt;On Saturday, my colleague Juhis asked me a question about accessibility, markup and UX. I wrote a reply on Twitter.&lt;/p&gt;
&lt;p&gt;On Sunday, I was still thinking that I want to explore and document the topic. So, I wrote down &lt;a href=&quot;https://fotis.xyz/posts/linking-to-headings&quot;&gt;“Linking to Headings”&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Then, I took that vision of a blog setup that I loved so much from Tech Weeklies, and plucked it into reality.&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;what%E2%80%99s-in-the-blog%3F&quot; tabindex=&quot;-1&quot;&gt;What’s in the blog?&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/new-year-new-blog/#what%E2%80%99s-in-the-blog%3F&quot; aria-label=&quot;Link to What’s in the blog?&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;Here is a quick summary of what we have, and what I like here.&lt;/p&gt;
&lt;p&gt;I am always amazed by how many hours of human effort go into building the chains of tools and programs that we build. Consider this also an attempt to give credit to some of these people.&lt;/p&gt;
&lt;h3&gt;Eleventy: Data Pipeline and Rendering&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://11ty.io/&quot;&gt;Eleventy&lt;/a&gt; is a simple static-site generator, by &lt;a href=&quot;https://twitter.com/zachleat/&quot;&gt;Zach Leatherman&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The thing I like about Eleventy is how it recognises that data is the key. There are options for data merging, collections are seamless out-of-the-box, and you can even stitch together async sources.&lt;/p&gt;
&lt;p&gt;As for the templating, Eleventy is pretty agnostic. So much, in fact, that it supports all of the following templating languages: nunjucks (the one I use), handlebars, liquid, JS templates, markdown, plain text, JSON, HTML. It has “universal” helpers that can augment each of these.&lt;/p&gt;
&lt;p&gt;I had never touched Nunjucks before, but Eleventy made the transition simpler. Mixing and matching Markdown and Nunjucks makes for a great authoring experience. I can write prose, and fork out to more structured templating when I need more power. For example, I have “pseudo-components” that enable &lt;a href=&quot;https://github.com/fpapado/fotis.xyz/blob/master/src/_includes/components/MdImg.js&quot;&gt;images with fixed aspect ratios&lt;/a&gt; and &lt;a href=&quot;https://github.com/fpapado/fotis.xyz/blob/master/src/_includes/components/Heading.js&quot;&gt;structured and accessible headings&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Another good thing about Eleventy is that it uses Javascript. I use JS every day, and even when I dislike it, I feel confident plugging things together with it. For example, I have to merge a manifest from PostCSS and another one from Rollup. I have a script that merges them and a custom &lt;code&gt;resolveHash&lt;/code&gt; filter that reads the file and translates, say, &lt;code&gt;index.js&lt;/code&gt; to &lt;code&gt;index.abc123.js&lt;/code&gt;. I’ve had to write similar things in Ruby/Jekyll for my photo blog, and I’m still a bit lost.&lt;/p&gt;
&lt;h3&gt;CSS: Tachyons + minimal atomic classes&lt;/h3&gt;
&lt;p&gt;I love &lt;a href=&quot;https://tachyons.io/&quot;&gt;Tachyons&lt;/a&gt;, by &lt;a href=&quot;https://twitter.com/mrmrs_&quot;&gt;Adam Morse&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;At a time when I thought I was utter shit at this frontend thing, it taught me that CSS is fun, and that I, too, could do it. It taught me CSS rules at a granular level and illustrated the inheritance and the cascade (at different points).&lt;/p&gt;
&lt;p&gt;Tachyons also taught me a great deal about design. Scales and palettes are things I can’t imagine starting a site without, these days. Mobile-first design and thinking about different devices is something close at hand when you use the atomic classes.&lt;/p&gt;
&lt;p&gt;There’s more things, that have shaped what I care about: colour contrast, and semantic markup. The Tachyons examples, with the HTML, CSS and demo side-by-side, acknowledging that people &lt;em&gt;will&lt;/em&gt; copy your examples, and so they better be accessible.&lt;/p&gt;
&lt;p&gt;I could write pages on this topic. Some other time, perhaps. I like the atomic classes approach, and I still use it a lot to glue things together. For more editorial content (such as markdown blocks), I use qualified/scoped selectors, such as &lt;code&gt;.article&lt;/code&gt;. Fret not, I still use the scales and palettes!&lt;/p&gt;
&lt;p&gt;I use &lt;a href=&quot;https://github.com/postcss/postcss&quot;&gt;PostCSS&lt;/a&gt; with &lt;a href=&quot;https://github.com/postcss/autoprefixer&quot;&gt;Autoprefixer&lt;/a&gt; to handle vendor prefixes in the compiled CSS.&lt;/p&gt;
&lt;h3&gt;JS: A minimal amount, bundled with Rollup&lt;/h3&gt;
&lt;p&gt;I didn’t add much client-side JS here. That is by design, to keep things lean. It uses very simple selectors and modules. I might need components if I start handling more complex loading states (that lazy Youtube embed…), but for now it’s great.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://rollupjs.org/&quot;&gt;Rolllup&lt;/a&gt; hit v1 recently, and I am impressed by their advanced optimisations. What I really love though, is their vision of ES modules natively, and ways of pushing the standards forward. I don’t use much of that functionality, but I’m glad to have the option.&lt;/p&gt;
&lt;h3&gt;Syntax highlighting&lt;/h3&gt;
&lt;p&gt;Syntax highlighting is handled by &lt;a href=&quot;https://prismjs.com/&quot;&gt;Prism&lt;/a&gt;, by &lt;a href=&quot;https://twitter.com/leaverou&quot;&gt;Lea Verou&lt;/a&gt;. Feels damn bulletproof, and having it on the server works wonders for keeping the site fast.&lt;/p&gt;
&lt;p&gt;The syntax theme is &lt;a href=&quot;https://github.com/ericwbailey/a11y-syntax-highlighting&quot;&gt;prism-a11y-dark&lt;/a&gt; by &lt;a href=&quot;https://twitter.com/ericwbailey/&quot;&gt;Eric Bailey&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;Fonts&lt;/h3&gt;
&lt;p&gt;The text is set in &lt;a href=&quot;https://www.futurefonts.xyz/phantom-foundry/phantom-sans&quot;&gt;Phantom Sans&lt;/a&gt;, by Phantom Foundry.&lt;/p&gt;
&lt;p&gt;It’s “Work In Progress”, much like this site, and I like how it looks. Furthermore, it is a Variable Font, with the weight axis being variable. This means that we only need one font file to load, and need only one extra layout for the page.&lt;/p&gt;
&lt;p&gt;Implementing font loading strategies takes some work. It also adds complexity to maintain. I thought to try something different. I like how minimal the variable font + &lt;code&gt;&amp;lt;link rel=&amp;quot;preload&amp;quot;&amp;gt;&lt;/code&gt; + &lt;code&gt;font-display: swap&lt;/code&gt; can be. One important note: the font file must be small, and Phantom Sans definitely delivers, at 26kB!&lt;/p&gt;
&lt;h3&gt;Colours&lt;/h3&gt;
&lt;p&gt;For Tech Weeklies, we got some stickers that had this beautiful pink/purple palette on them. I tuned the colours to have better contrast, and here we are! I had tried to do the same on my old website, but the palette was too busy.&lt;/p&gt;
&lt;p&gt;(Aside: I would love to have light pink and gold on this page, but contrast on white is bad at best. But perhaps for the dark theme?)&lt;/p&gt;
&lt;h3&gt;Other goodies&lt;/h3&gt;
&lt;p&gt;As I was writing the post on “Linking to Headings”, I wanted to embed a Codepen.&lt;/p&gt;
&lt;p&gt;I realised I could use their new &lt;a href=&quot;https://blog.codepen.io/documentation/prefill-embeds/&quot;&gt;Prefill Embeds&lt;/a&gt; feature. After a couple of hours of fighting nested templates, I got it working! I think it strikes a great balance of offering options to readers, enhancing the authoring experience, and adding demos. I’ll write more about this soon!&lt;/p&gt;
&lt;p&gt;The embed setup also allows the code samples to be accessible in Reader view, RSS feeds etc.&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;wrapping-up&quot; tabindex=&quot;-1&quot;&gt;Wrapping up&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/new-year-new-blog/#wrapping-up&quot; aria-label=&quot;Link to Wrapping up&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;This post is literally more than I have ever written on my blog, phew. It’s been a long couple of months.&lt;/p&gt;
&lt;p&gt;In terms of what’s next, first I want to move some of my notes that people have found valuable. After that, I want to set up a talks page.&lt;/p&gt;
&lt;p&gt;Let me know if there’s anything you’d like to read about :)&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Resilient Code Examples with CodePen</title>
		<link href="https://fotis.xyz/posts/resilient-code-examples/"/>
		<updated>2019-01-22T00:00:00Z</updated>
		<id>https://fotis.xyz/posts/resilient-code-examples/</id>
		<content type="html">&lt;p&gt;At some point through writing &lt;a href=&quot;https://fotis.xyz/posts/linking-to-headings&quot;&gt;my first post on this blog&lt;/a&gt;, I realised that I wanted to have code examples.&lt;/p&gt;
&lt;p&gt;I had taken a “write first, add the infrastructure later” approach, because I wanted to finish writing instead of going down some rabbit holes. So I finished the write-up, and reached the part where I would touch up the code examples.&lt;/p&gt;
&lt;p&gt;There were two main things I wanted to have:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Syntax highlighting&lt;/li&gt;
&lt;li&gt;An easy way to write interactive demos&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I also value accessibility and performance, so I had a few more requirements:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Code samples should be available in the server-rendered markup&lt;/li&gt;
&lt;li&gt;The page should not load heavy scripts without user action&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;My “usual” approach would be to duplicate the samples in the markup and CodePen, something I already do for my talks. Then, depending on how critical I find the demo, I either embed the &lt;code&gt;iframe&lt;/code&gt; or link to the pen. Then I forget about it and inevitably something breaks…&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;enter-prefill-embeds&quot; tabindex=&quot;-1&quot;&gt;Enter Prefill Embeds&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/resilient-code-examples/#enter-prefill-embeds&quot; aria-label=&quot;Link to Enter Prefill Embeds&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;A few days prior to writing my post, &lt;a href=&quot;https://blog.codepen.io/2019/01/17/introducing-prefill-embeds/&quot;&gt;CodePen announced their “Prefill Embeds” feature&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In short, you write markup on your site, and “enhance” it to a full-fledged pen at runtime. I affectionately refer to those as “anonymous pens”.&lt;/p&gt;
&lt;p&gt;To give you an idea, here is what setting it up looks like:&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;div&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;  class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;codepen&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;  data-prefill&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;  data-height&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;400&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;  data-default-tab&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;html,result&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;pre&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; data-lang&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;html&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;container&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;      &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;h1&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;Prefill Embeds are cool&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;h1&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;      &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; href&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;https://fotis.xyz/posts/resilient-code-examples&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;        Read about how you can use them&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;      &amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;pre&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; async&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; src&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;https://static.codepen.io/assets/embed/ei.js&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;benefits&quot; tabindex=&quot;-1&quot;&gt;Benefits&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/resilient-code-examples/#benefits&quot; aria-label=&quot;Link to Benefits&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;I must admit, I had no idea how much I wanted this feature, until I tried it out. In no particular order, here are the possibilities I like:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;No need to keep things in sync (an activity that distracts me, or I always
forget)&lt;/li&gt;
&lt;li&gt;Friendly to Reader mode, Pocket, which I use daily - Friendly to RSS
feeds, &lt;a href=&quot;https://fotis.xyz/feed/feed.xml&quot;&gt;this site has an RSS feed&lt;/a&gt; too, btw ;)&lt;/li&gt;
&lt;li&gt;Printing
(though I should set up some print stylesheets)&lt;/li&gt;
&lt;li&gt;Arguably more accessible than an iframe-by-default; can let the user decide&lt;/li&gt;
&lt;li&gt;No heavy scripts on page load&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;fun-with-templates&quot; tabindex=&quot;-1&quot;&gt;Fun with templates&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/resilient-code-examples/#fun-with-templates&quot; aria-label=&quot;Link to Fun with templates&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;On the blog, I also have syntax highlighting, rendered once on the server, using &lt;a href=&quot;https://prismjs.com/&quot;&gt;Prism&lt;/a&gt;. I use the &lt;a href=&quot;https://github.com/11ty/eleventy-plugin-syntaxhighlight&quot;&gt;syntax highlight shortcode from Eleventy&lt;/a&gt; to add it to
the page.&lt;/p&gt;
&lt;p&gt;I had to make one change to the highlighting short code, to add &lt;code&gt;data-lang&lt;/code&gt; to the &lt;code&gt;pre&lt;/code&gt; tag that it renders. This is for CodePen to pick it up. I could have wrapped it in another &lt;code&gt;pre&lt;/code&gt; tag, and that also seemed to work. That seemed like undefined behaviour, though, so I went with the more “correct-feeling” route. Paired with the modified shortcode, here is the initial
setup that I had:&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;div&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;  class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;codepen&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;  data-prefill&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;  data-height&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;400&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;  data-default-tab&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;html,result&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;  {% highlight &quot;html&quot; %}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;container&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;h1&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;Prefill Embeds are cool&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;h1&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; href&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;https://fotis.xyz/posts/resilient-code-examples&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;      Read about how you can use them&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;  {% endhighlight %}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; async&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; src&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;https://static.codepen.io/assets/embed/ei.js&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;(Aside: you should see the template for putting &lt;em&gt;this&lt;/em&gt; post on the page. Fun times.)&lt;/p&gt;
&lt;p&gt;I am generally a fan of copy-pasting, and I would not be averse to leaving it at that. But, I still wanted to load the iframe on demand, so I decided that I had to dig deeper.&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;loading-on-demand&quot; tabindex=&quot;-1&quot;&gt;Loading on-demand&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/resilient-code-examples/#loading-on-demand&quot; aria-label=&quot;Link to Loading on-demand&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;To their credit, the &lt;a href=&quot;https://blog.codepen.io/documentation/prefill-embeds/&quot;&gt;documentation for Prefill Embeds&lt;/a&gt; have an outline dedicated to loading the pen on demand.&lt;/p&gt;
&lt;p&gt;Given my earlier goals of making &lt;code&gt;iframe&lt;/code&gt;s optional, and giving readers the choice, it made sense to implement that functionality.&lt;/p&gt;
&lt;p&gt;The sketch for the shortcode/pseudo-component would look
like this:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;On the server, be able to define the language for each block&lt;/li&gt;
&lt;li&gt;On the server, render a button that is associated with some id on the pen&lt;/li&gt;
&lt;li&gt;On the client, call &lt;code&gt;window.__CPEmbed(.codepen-later-${id})&lt;/code&gt;, to enhance to an embed.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Templating shortcode&lt;/h3&gt;
&lt;p&gt;I dubbed the shortcode &lt;code&gt;WithCodepen&lt;/code&gt;. I also added some conveniences about different properties of the embed. Here is what the templating composition looks like:&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;{% WithCodepen id=&quot;my-demo&quot;, height=&quot;400&quot; %}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;container&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;h1&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;Prefill Embeds are cool&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;h1&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; href&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;https://fotis.xyz/posts/resilient-codepen-embeds&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;    Read about how you can use them&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;{% endWithCodepen %} &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;There are different ways to implement this. I went with a &lt;a href=&quot;https://www.11ty.io/docs/languages/nunjucks/&quot;&gt;Nunjucks helper&lt;/a&gt; that calls JavaScript template literals. It went well, though the extra spacing from formatters and substitutions was a pain to debug!&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; html &lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt; require&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&#39;common-tags&#39;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7;font-style:italic&quot;&gt;module&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7;font-style:italic&quot;&gt;exports&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#EBA0AC;font-style:italic&quot;&gt;content&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#EBA0AC;font-style:italic&quot;&gt; props&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {})&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; id&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; lazy &lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; true&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; height &lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;400&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; defaultTab &lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;html,result&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; }&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; props&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;  if&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; (lazy &lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x26;&amp;#x26;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; !&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;id) &lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;    throw&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;id is required for lazy-initialised pens in WithCodepen&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; embedIdentifier &lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; `codepen-later-&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;${&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;`&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;  // THIS IS IMPORTANT, stuff breaks with extra &amp;#x3C;pre&gt; being inserted&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;  // due to extra white-space :))))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;  // prettier-ignore&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; htmlContent &lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt; html&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;`&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;${&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;content&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;`&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;  return&lt;/span&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt; html&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;`&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;div&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;      class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;${lazy ? embedIdentifier : &#39;codepen&#39;}&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;      data-prefill&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;      data-height&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;${height}&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;      data-default-tab&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;${defaultTab}&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;      ${&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;htmlContent&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;    ${&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;lazy&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;      ?&lt;/span&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt; html&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;`&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;          &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; data-for&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;${embedIdentifier}&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;makeCpInteractive&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;            Make demo interactive&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;          &amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;        `&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;      :&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;&#39;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;  `&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;client-side-interaction&quot; tabindex=&quot;-1&quot;&gt;Client-side interaction&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/resilient-code-examples/#client-side-interaction&quot; aria-label=&quot;Link to Client-side interaction&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;The &lt;code&gt;id&lt;/code&gt; for the associated pen is available under &lt;code&gt;data-for&lt;/code&gt; in the button. I wrote some Javascript to handle the click events and call the embed function. It is a bit crude, and I’d circle back to it, but it works:&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;// This is a helper for focusing things with tabindex=&quot;-1&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; focusOnElement &lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; from&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;./fix-in-page-links.js&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; BUTTON_SELECTOR &lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;.makeCpInteractive&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;/**&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt; * Button, that when clicked, makes the related code an interactive CodePen.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt; * Works by being associated via data-for&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt; *&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt; * &lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;@&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;see&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF;font-style:italic&quot;&gt; src&lt;/span&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;/includes/WithCodepen.js&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt; * &lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;@&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;see&lt;/span&gt;&lt;span style=&quot;color:#EBA0AC&quot;&gt; https://blog.codepen.io/documentation/prefill-embeds/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt; */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;export&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt; init&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;  let&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; buttons &lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; document&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;querySelectorAll&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(BUTTON_SELECTOR)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;  buttons&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;forEach&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#EBA0AC;font-style:italic&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; =&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;    button&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;addEventListener&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&#39;click&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#EBA0AC;font-style:italic&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; =&gt;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;      const&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; embedIdentifier &lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; button&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;getAttribute&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&#39;data-for&#39;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;      if&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;embedIdentifier) &lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;        console&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;error&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&#39;No embedIdentifier found as data-for&#39;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;      }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;      // The API for looking for and creating embeds&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;      window&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;__CPEmbed&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;`.&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;${&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;embedIdentifier&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;`&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;      // TODO: Evaluate this feature&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;      // Focus the iframe and remove the button&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;      const&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; newEmbed &lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; button&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;previousElementSibling&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;      // Remove the button after the focus moves to the iframe&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;      button&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;addEventListener&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&#39;blur&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#EBA0AC;font-style:italic&quot;&gt;ev&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; =&gt;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;        button&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;remove&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;      }&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;      focusOnElement&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(newEmbed)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;    }&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;  )&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;There is a bit of an open question, on how we’d manage/move focus when clicking on the button. At the moment, I move focus to the embed, and remove the button. I think that moving the focus makes sense to signify what happened, but I’m always a bit wary of that.&lt;/p&gt;
&lt;p&gt;A coworker also suggested adding the functionality to revert the embed. We could do this by saving the initial content, and restoring it later. I have to think more about this.&lt;/p&gt;
&lt;p&gt;You can find &lt;a href=&quot;https://github.com/fpapado/fotis.xyz/blob/master/src/js/MakeCpInteractive.js&quot;&gt;the source for MakeCpInteractive on Github&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;Loading the embed script&lt;/h3&gt;
&lt;p&gt;The embed script seems quite small, at about 5kB gzipped. There is a coarse-grained &lt;code&gt;hasCodePen&lt;/code&gt; frontmatter option in the templates, that adds that script to the page. Loading it on button click seems not worth the effort of latency, but you might prioritise differently if you want.&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;in-practice&quot; tabindex=&quot;-1&quot;&gt;In practice&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/resilient-code-examples/#in-practice&quot; aria-label=&quot;Link to In practice&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;An entire post, and no interactive examples. That doesn’t seem fair. Here is the example from above, rendered with the full shortcode, and the button to make it interactive.&lt;/p&gt;
&lt;p&gt;As a bonus, did I mention you can have multiple “files” in a single pen? Add more &lt;code&gt;&amp;lt;pre&amp;gt;&lt;/code&gt; tags with a &lt;code&gt;data-lang&lt;/code&gt; and they will be added in the respective tab.&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;container&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;h1&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;Prefill Embeds are cool&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;h1&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; href&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;https://fotis.xyz/posts/resilient-code-examples&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;    Read about how you can use them&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;container&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  background-color&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; beige&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;wrapping-up&quot; tabindex=&quot;-1&quot;&gt;Wrapping up&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/resilient-code-examples/#wrapping-up&quot; aria-label=&quot;Link to Wrapping up&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;This functionality really struck a chord with me. From static markup, to readers, RSS feeds, and interactive demos; the content is there, the functionality is layered, the experience adapts. It reminded me why I love the web so much, with a diversity and richness of experience. The word &lt;a href=&quot;https://resilientwebdesign.com/&quot;&gt;resilience&lt;/a&gt; rings in my mind as I write these words down.&lt;/p&gt;
&lt;p&gt;I recently wrote about &lt;a href=&quot;https://fotis.xyz/posts/new-year-new-blog/&quot;&gt;taking a break from coding&lt;/a&gt;, seeking inspiration, and trying to write more of my thoughts down. This functionality makes me feel super excited about what I can share. I hope you are too.&lt;/p&gt;
&lt;p&gt;P.S. I might have stumbled somewhere, or forgotten something, please go easy on me and let me know :)&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>HTML details is awesome</title>
		<link href="https://fotis.xyz/posts/details-is-awesome/"/>
		<updated>2019-01-28T00:00:00Z</updated>
		<id>https://fotis.xyz/posts/details-is-awesome/</id>
		<content type="html">&lt;p&gt;A while back, I read the slides and notes of a talk by &lt;a href=&quot;https://twitter.com/muanchiou&quot;&gt;Mu-An Chiou&lt;/a&gt;, titled &lt;a href=&quot;https://github.com/muan/details-on-details&quot;&gt;“Details on &amp;lt;details&amp;gt;”&lt;/a&gt;. It’s a fantastic overview of how to use the &lt;code&gt;&amp;lt;details&amp;gt;&lt;/code&gt; element of HTML.&lt;/p&gt;
&lt;p&gt;In short, &lt;code&gt;details&lt;/code&gt;, and its pair &lt;code&gt;summary&lt;/code&gt;, are a way to implement native collapsible sections, without relying on Javascript. Toggling content is one of the most common actions on the web, so being able to provide that without scripts is appealing. It is not just collapsible sections though; you can make panels, menus, and other imaginative things with it!&lt;/p&gt;
&lt;p&gt;I had stashed that knowledge at the back of my mind. Then, some weeks ago, I was implementing a collapsible section for the webmentions on this blog:&lt;/p&gt;
&lt;div class=&quot;md-img aspect-ratio aspect-ratio--6x4 bg-light-gray  &quot;&gt;
  &lt;img src=&quot;https://fotis.xyz/img/posts/details-is-awesome-1.jpg&quot; alt=&quot;A webmentions section, with a button to show all comments&quot; loading=&quot;lazy&quot; class=&quot;aspect-ratio--object fit-cover   &quot; /&gt;
&lt;/div&gt;
&lt;p&gt;This seemed like a great use case for details. I would get the native functionality of toggling, and could then work with styling it. Let’s go over how to implement it.&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;implementing-a-%E2%80%9Cshow-all%E2%80%9D-section&quot; tabindex=&quot;-1&quot;&gt;Implementing a “show all” section&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/details-is-awesome/#implementing-a-%E2%80%9Cshow-all%E2%80%9D-section&quot; aria-label=&quot;Link to Implementing a “show all” section&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;h3&gt;Markup&lt;/h3&gt;
&lt;p&gt;You nest &lt;code&gt;&amp;lt;summary&amp;gt;&lt;/code&gt; inside of &lt;code&gt;&amp;lt;details&amp;gt;&lt;/code&gt;. &lt;code&gt;&amp;lt;summary&amp;gt;&lt;/code&gt; is what appears as the “toggle button”, regardless of the section being collapsed or not. Anything after that will be hidden and only appear when the widget is open.&lt;/p&gt;
&lt;p&gt;Here is what an initial attempt at our comments section would look like:&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;details&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;summary&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; Show all (2) &lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;summary&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;ol&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;I am a comment&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;I am another comment.&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;ol&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;details&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Styling&lt;/h3&gt;
&lt;p&gt;There are a couple of extra things to know about styling &lt;code&gt;details&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The arrow is styled with the &lt;code&gt;list-style&lt;/code&gt; properties on &lt;code&gt;summary&lt;/code&gt;, except in Chrome, which uses &lt;code&gt;::-webkit-details-marker&lt;/code&gt;. You could consider resetting them and then relying on a unified &lt;code&gt;::before&lt;/code&gt; selector.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;open&lt;/code&gt; attribute is added when the summary is open. You can query that as &lt;code&gt;details[open]&lt;/code&gt; to style the container further. &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details&quot;&gt;The demo on MDN&lt;/a&gt; shows the open attribute in practice.&lt;/p&gt;
&lt;p&gt;I also found that on Safari, the &lt;code&gt;summary&lt;/code&gt; element cannot be a flexbox container, even if defined in CSS. I wanted to do that to show author images next to the “Show all” text. I added an extra div wrapper inside of summary, to act as the flexbox container.&lt;/p&gt;
&lt;p&gt;After adding some more styles to our details, it can look like this:&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;details&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;details-reset&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;summary&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;summary fg-highlight cursor-default&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;flex-wrapper-for-safari&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;      &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;span&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;Show all (2)&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;span&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;      &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;author-list&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;        &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;author&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;          &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;img&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;            src&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;https://fotis.xyz/img/logo.png&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;            alt&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;            class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;author-image&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;          /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;        &amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;        &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;author&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;          &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;img&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;            src&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;https://fotis.xyz/img/logo.png&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;            alt&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;            class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;author-image&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;          /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;        &amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;      &amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;summary&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;ol&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;I am a comment&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;I am another comment&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;ol&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;details&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;root&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  --highlight&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; #&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;da0993&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;/* Styles and resets for the &amp;#x3C;details&gt; element.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt; * @see &amp;#x3C;https://github.com/primer/primer/blob/master/modules/primer-buttons/lib/button.scss#L206-L213&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;/* Remove marker added by the display: list-item browser default */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;details-reset&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; &gt;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt; summary&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  list-style&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; none&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;/* Remove marker added by details polyfill */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;details-reset&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; &gt;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt; summary&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;before&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  display&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; none&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;/* Remove marker added by Chrome*/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;details-reset&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; &gt;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt; summary&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;-webkit-details-marker&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  display&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; none&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;/* Other styles */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;flex-wrapper-for-safari&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  display&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; flex&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  align-items&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; center&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;fg-highlight&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  color&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt; var&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#EBA0AC&quot;&gt;--highlight&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;cursor-default&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  cursor&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; default&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;author-list&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  display&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; flex&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  margin&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;rem&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;author&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  width&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;rem&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  height&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;rem&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;author-image&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  max-width&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 100%&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  border-radius&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 100%&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  background-color&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; gray&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Focus affordances&lt;/h3&gt;
&lt;p&gt;In reality, our section summary has two distinct elements; the “show all” button, and the profile pictures of commenters. The whole summary is interactable as far as input methods and highlighting are concerned. This makes sense to start with, and is a benefit of using semantic HTML.&lt;/p&gt;
&lt;p&gt;I think we can do a bit better, by enhancing the focus, so that it highlights the action more clearly. If the user focuses (by keyboard or otherwise) on the section, I would like to only highlight the “show all” part. This “nested focus” pattern is something I took out of &lt;a href=&quot;https://inclusive-components.design/collapsible-sections#stylingthebutton&quot;&gt;Heydon Pickering’s “Collapsible Sections” article&lt;/a&gt;.&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;details&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;details-reset&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;summary&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;nested-focus fg-highlight cursor-default&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;flex-wrapper-for-safari&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;      &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;span&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;nested-focus-target&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;Show all (2)&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;span&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;      &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;author-list&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;        &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;author&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;          &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;img&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;            src&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;https://fotis.xyz/img/logo.png&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;            alt&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;            class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;author-image&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;          /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;        &amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;        &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;author&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;          &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;img&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;            src&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;https://fotis.xyz/img/logo.png&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;            alt&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;            class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;author-image&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;          /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;        &amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;      &amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;summary&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;ol&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;I am a comment&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;I am another comment&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;ol&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;details&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;root&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  --highlight&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; #&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;da0993&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;nested-focus&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;focus&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;  /* NOTE: The only good reason to hide an outline is if you enhance it */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  outline&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; none&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;nested-focus&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;focus&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; .&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;nested-focus-target&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  outline&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;px&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; solid &lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;var&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#EBA0AC&quot;&gt;--highlight&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;/* These are the same as above */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;/*&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt; * Styles and resets for the &amp;#x3C;details&gt; element.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt; * @see &amp;#x3C;https://github.com/primer/primer/blob/master/modules/primer-buttons/lib/button.scss#L206-L213&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;/* Remove marker added by the display: list-item browser default */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;details-reset&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; &gt;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt; summary&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  list-style&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; none&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;/* Remove marker added by details polyfill */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;details-reset&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; &gt;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt; summary&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;before&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  display&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; none&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;/* Remove marker added by Chrome */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;details-reset&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; &gt;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt; summary&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;-webkit-details-marker&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  display&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; none&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;/* Other styles */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;flex-wrapper-for-safari&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  display&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; flex&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  align-items&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; center&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;fg-highlight&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  color&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt; var&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#EBA0AC&quot;&gt;--highlight&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;cursor-default&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  cursor&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; default&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;author-list&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  display&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; flex&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  margin&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;rem&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;author&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  width&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;rem&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  height&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;rem&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;author-image&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  max-width&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 100%&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  border-radius&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 100%&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  background-color&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; gray&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Other things to consider would be &lt;code&gt;user-select&lt;/code&gt; and &lt;code&gt;cursor&lt;/code&gt;. &lt;code&gt;user-select&lt;/code&gt; in particular is an open question, so I left it intact. I did give the &lt;code&gt;summary&lt;/code&gt; a &lt;code&gt;cursor: default&lt;/code&gt;, though there are certainly different ways to prioritise.&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;polyfills&quot; tabindex=&quot;-1&quot;&gt;Polyfills&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/details-is-awesome/#polyfills&quot; aria-label=&quot;Link to Polyfills&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;The &lt;a href=&quot;https://github.com/javan/details-element-polyfill&quot;&gt;polyfill for details&lt;/a&gt; is great. It is small in size (just under 1.5kB), and covers IE and Edge well. It is also a good example of a layered polyfill, where parts of the functionality are polyfilled depending on what is supported. Give the source code a read, I learned a bunch from it.&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;accessibility&quot; tabindex=&quot;-1&quot;&gt;Accessibility&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/details-is-awesome/#accessibility&quot; aria-label=&quot;Link to Accessibility&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;a href=&quot;https://www.scottohara.me/blog/2018/09/03/details-and-summary.html&quot;&gt;Scott O’Hara investigated the use of the details element&lt;/a&gt; with various screen reader and browser combinations. I would urge you to read that piece for more information and readouts. A summary would be that screen reader support is good, with a few edge cases pending.&lt;/p&gt;
&lt;p&gt;(I would love to fill more on this after looking into it myself, and checking the status of the bugs mentioned by Scott).&lt;/p&gt;
&lt;p&gt;Apart from Scott’s notes, there are a couple of things I would point out for collapsible sections.&lt;/p&gt;
&lt;h3&gt;Avoid changing the display text&lt;/h3&gt;
&lt;p&gt;You might notice in the example above that I avoided changing the “Show all” text when expanding. You could do this with Javascript, or even some CSS conditional on the &lt;code&gt;open&lt;/code&gt; attribute. Beware though! In toggle buttons, it is common to not change the text, since the state is already communicated via &lt;code&gt;aria-expanded&lt;/code&gt; (&lt;a href=&quot;https://inclusive-components.design/toggle-button/&quot;&gt;Heydon Pickering writes about toggle buttons&lt;/a&gt;). I think collapsible sections with the details element should follow the same idea, since the state is communicated natively.&lt;/p&gt;
&lt;p&gt;If I did want to change the display text, I would try to always expose the same text to screen readers, and keep parity with toggle buttons.&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;details&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;summary&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;    &amp;#x3C;!-- This is exposed to assistive technologies --&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;span&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;visually-hidden&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;Show all (2)&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;span&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;    &amp;#x3C;!-- These will be hidden from assistive technologies --&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;span&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; aria-hidden&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;true&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;summary-open&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;Hide all&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;span&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;span&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; aria-hidden&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;true&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;summary-closed&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;Show all (2)&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;span&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;summary&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;ul&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;I am a comment&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;I am another comment.&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;ul&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;details&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;/* Hide visually, but keep in the tree for AT */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;visually-hidden&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  position&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; absolute &lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;!important&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  height&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;px&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  width&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;px&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  overflow&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; hidden&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  clip&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt; rect&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;px&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;px&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;px&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;px&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  clip&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt; rect&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;px&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;px&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;px&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;px&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;details&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; .&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;summary-open&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  display&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; none&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;details&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;open&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; .&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;summary-open&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  display&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; inline&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;details&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; .&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;summary-closed&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  display&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; inline&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;details&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;open&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; .&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;summary-closed&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  display&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; none&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;However, keeping the &lt;a href=&quot;https://www.w3.org/TR/using-aria/&quot;&gt;rules of ARIA usage&lt;/a&gt; in mind, and gauging the value of this feature, I would not implement it. It is not a big deal if “Show all” persists visually, and I like that the presentation is unified. Also, the arrow is a good indicator already, so if you need this feature, then consider not removing it.&lt;/p&gt;
&lt;h3&gt;Avoid interactive content in &lt;code&gt;summary&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/whatwg/html/issues/2272&quot;&gt;Interactive content in summary is an open question&lt;/a&gt; on the spec. I also would question the need for that. I would not place, say, a &lt;code&gt;button&lt;/code&gt; inside a &lt;code&gt;button&lt;/code&gt;, and in the same spirit I would not nest something interactive inside summary. Your mileage may vary, and it might be a chance to rework the widget, if you have this use case.&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;wrapping-up&quot; tabindex=&quot;-1&quot;&gt;Wrapping up&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/details-is-awesome/#wrapping-up&quot; aria-label=&quot;Link to Wrapping up&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;The details element is a great part of HTML. It offers a lot of commonplace functionality without relying on JS. This is important when it comes to resilience. Between requests failing, or a heavy load on the browser (such as when hydrating server-rendered markup), being able to collapse sections without relying on main scripts is valuable.&lt;/p&gt;
&lt;p&gt;There are even more &lt;a href=&quot;https://github.com/muan/details-on-details#githubs-details-dependent-custom-elements&quot;&gt;interesting uses of details by Github&lt;/a&gt;, such as modals and menus. It has a couple styling hooks of its own, and even some UX questions to explore. The polyfill is well-encompassing, and the accessibility story pretty solid.&lt;/p&gt;
&lt;p&gt;Have you tried using the details element in your projects? How did you find it? Let me know!&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;more-resources&quot; tabindex=&quot;-1&quot;&gt;More resources&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/details-is-awesome/#more-resources&quot; aria-label=&quot;Link to More resources&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/muan/details-on-details#githubs-details-dependent-custom-elements&quot;&gt;Mu-An’s presentation and notes&lt;/a&gt; that set me on this path. It offers a concise explanation and guidance, perfect for bookmarking and referring to, say, when writing an article :)&lt;/li&gt;
&lt;li&gt;The &lt;a href=&quot;https://github.com/muan/details-on-details#githubs-details-dependent-custom-elements&quot;&gt;MDN guide on details&lt;/a&gt; has a good summary (no pun intended)&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://html.spec.whatwg.org/multipage/interactive-elements.html#the-details-element&quot;&gt;The spec for details&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/javan/details-element-polyfill&quot;&gt;The polyfill for details&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Heydon Pickering’s Inclusive Components has a chapter that explains the various &lt;a href=&quot;https://inclusive-components.design/collapsible-sections&quot;&gt;affordances that Collapsible Sections provide&lt;/a&gt;. He also goes into details about how to implement one with Javascript. Give it a read, it is good stuff.&lt;/li&gt;
&lt;/ul&gt;
</content>
	</entry>
	
	<entry>
		<title>An Open Accessibility Audit of “Helsinki as a Service”</title>
		<link href="https://fotis.xyz/posts/accessibility-audit-of-helsinki-as-a-service/"/>
		<updated>2019-09-12T00:00:00Z</updated>
		<id>https://fotis.xyz/posts/accessibility-audit-of-helsinki-as-a-service/</id>
		<content type="html">&lt;p&gt;Helsinki recently launched the &lt;a href=&quot;https://helsinkiasaservice.com/&quot;&gt;City as a Service&lt;/a&gt; campaign. This post explores how to make it more accessible.&lt;/p&gt;
&lt;details class=&quot;mt4 pointer&quot;&gt;
  &lt;summary class=&quot;fw7&quot;&gt;Table of Contents &lt;/summary&gt;
  &lt;ol&gt;
    &lt;li&gt;&lt;a href=&quot;https://fotis.xyz/posts/accessibility-audit-of-helsinki-as-a-service/#motivation&quot;&gt;Motivation&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;https://fotis.xyz/posts/accessibility-audit-of-helsinki-as-a-service/#what-we%E2%80%99ll-be-doing&quot;&gt;What we&#39;ll be doing&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;https://fotis.xyz/posts/accessibility-audit-of-helsinki-as-a-service/#missing-image-alternative-text&quot;&gt;Missing image alternative text&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;https://fotis.xyz/posts/accessibility-audit-of-helsinki-as-a-service/#missing-focus-outlines&quot;&gt;Missing focus outlines&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;https://fotis.xyz/posts/accessibility-audit-of-helsinki-as-a-service/#the-video-modal-button-is-not-operable-or-discoverable&quot;&gt;Video modal button&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;https://fotis.xyz/posts/accessibility-audit-of-helsinki-as-a-service/#colour-contrast-on-application-page&quot;&gt;Colour contrast&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;https://fotis.xyz/posts/accessibility-audit-of-helsinki-as-a-service/#the-document-hierarchy-jumps-around&quot;&gt;Document hierarchy&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;https://fotis.xyz/posts/accessibility-audit-of-helsinki-as-a-service/#issues-with-the-carousel-operation&quot;&gt;Issues with carousel operation&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;https://fotis.xyz/posts/accessibility-audit-of-helsinki-as-a-service/#wrapping-up&quot;&gt;Wrapping up&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;https://fotis.xyz/posts/accessibility-audit-of-helsinki-as-a-service/#thanks&quot;&gt;Thanks&lt;/a&gt;&lt;/li&gt;
  
&lt;/ol&gt;&lt;/details&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;motivation&quot; tabindex=&quot;-1&quot;&gt;Motivation&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/accessibility-audit-of-helsinki-as-a-service/#motivation&quot; aria-label=&quot;Link to Motivation&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;Helsinki, and the tech industry in it, wishes to attract more workers. One of the recent ways they set to achieve that, is the City as a Service initiative. Its website has a video, various quotes and visuals, as well as a list of partners.&lt;/p&gt;
&lt;p&gt;The site outlines some of the best parts of living in Helsinki. I find the techy marketing a bit much (“as a service”…), but I can understand how the content is a condensed summary of why someone would immigrate here. I did, after all, immigrate here as well, didn’t I?&lt;/p&gt;
&lt;p&gt;One of the things that struck me, when browsing the site, is that much of its main content is inaccessible. The images were missing descriptions, the buttons lacked labels, the video modal was out of reach, and the carousel did not have any keyboard-accessible controls.&lt;/p&gt;
&lt;p&gt;That hit close to home. When a friend shared the site with me, my initial reaction was to outline the issues with it in our chat. While that was good, and got some local support from others, I realised that nothing meaningful would happen if I left it there. That is when I got the idea to make an “open accessibility audit” for it. I hope to outline the issues, provide reference solutions, and add my voice of support for these issues.&lt;/p&gt;
&lt;p&gt;I have seen many initiatives over the past years, that celebrate inclusivity on the surface, only to skip making their sites accessible. That seems like a contradiction to me.&lt;/p&gt;
&lt;p&gt;If Helsinki wants to lure tech talent here, then a more accessible website can only facilitate that goal. I believe that we need more perspectives in tech, especially when it comes to accessibility. In an increasingly digitalised society, having inaccessible services can actively exclude people from participating. Most often, the people that shape those services are not solely those who write a specific piece of code, but also the people that are around to question, challenge, and shed light on otherwise invisible potential or risks.&lt;/p&gt;
&lt;p&gt;In other words, we need more disabled people to help shape services. If a site that is meant to invite people is inaccessible, then we (collectively, as an industry and members of society) miss doubly on our goals.&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;what-we%E2%80%99ll-be-doing&quot; tabindex=&quot;-1&quot;&gt;What we’ll be doing&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/accessibility-audit-of-helsinki-as-a-service/#what-we%E2%80%99ll-be-doing&quot; aria-label=&quot;Link to What we’ll be doing&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;We’ll be going through some of the common issues that hinder the accessibility of the site. Note that &lt;strong&gt;this list is not exhaustive&lt;/strong&gt;, and it is &lt;strong&gt;mostly from a markup point of view&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;I am a sighted user, often navigating by keyboard (wanting to get ahead of RSI), but other than that most of the audit revolves around standards and common issues in accessibility. People whose lived experiences differ to mine will have different topics on this list; that is perfectly valid, and I would urge you to listen to them.&lt;/p&gt;
&lt;aside class=&quot;aside&quot;&gt;
  &lt;div class=&quot;aside-wrapper&quot;&gt;
    &lt;h3 class=&quot;aside__title&quot;&gt;Before we dive in&lt;/h3&gt;
    &lt;div class=&quot;aside__content&quot;&gt;    &lt;p&gt;   You might be wondering, “&lt;em&gt;why does this person get to come in and trash the thing we made?&lt;/em&gt;”. It is important for me to point out that this is not criticising a person! It is auditing an artefact on the screen, as well as a system that pays lip service to equality but does not prioritise inclusivity and accessibility in the concrete outcomes.   &lt;/p&gt;    &lt;p&gt;   So, if you are reading this and you have a role that can affect the page, consider this post an invitation for dialogue, or a call to action. As I note throughout the article, there is a collective responsibility for accessible experiences; I think assigning a singular source of blame would be unproductive.   &lt;/p&gt;    &lt;p&gt;   You might also be wondering, why this site, and not something else? Immigration, accessibility, and missing perspectives in tech are topics dear to me. This touches on all three of those topics, so it felt particularly relevant.   &lt;/p&gt; &lt;/div&gt;
  &lt;/div&gt;
&lt;/aside&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;missing-image-alternative-text&quot; tabindex=&quot;-1&quot;&gt;Missing image alternative text&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/accessibility-audit-of-helsinki-as-a-service/#missing-image-alternative-text&quot; aria-label=&quot;Link to Missing image alternative text&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;Many of images on the site lack alternative textual descriptions, so-called “alt-text”. Assistive Technologies (ATs), such as Screen Readers, read the alt text out loud. This helps users of those technologies to make sense of the page.&lt;/p&gt;
&lt;p&gt;If images lack alt text (i.e. the &lt;code&gt;alt&lt;/code&gt; attribute is missing on the &lt;code&gt;img&lt;/code&gt;), then typically the full name of the image gets read out. This is usually meaningless, of the form “abcd1234.jpg”.&lt;/p&gt;
&lt;p&gt;This can be frustrating for a few reasons:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;It is very verbose, and adds noise if the image is &lt;strong&gt;decorative&lt;/strong&gt;;&lt;/li&gt;
&lt;li&gt;People miss out on images that form &lt;strong&gt;content&lt;/strong&gt;;&lt;/li&gt;
&lt;li&gt;Textual alternatives can help convey the meaning and feeling of the page, in an &lt;a href=&quot;https://inclusivedesignprinciples.org/#provide-comparable-experience&quot;&gt;comparable experience&lt;/a&gt; to people who see the images;&lt;/li&gt;
&lt;li&gt;Finally, if all images are nonsensical, it can be frustrating not to know whether you are missing out on something!&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In general, then, an image should:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;If it is content&lt;/strong&gt;, have an alt text describing it;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;If it is decorative&lt;/strong&gt;, have an empty alt text (&lt;code&gt;alt=&amp;quot;&amp;quot;&lt;/code&gt;), so Assistive Technologies (ATs) know to skip them.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Image examples&lt;/h3&gt;
&lt;p&gt;The Companies section has logos. Those lack alt text, meaning that AT users have to guess at the names.&lt;/p&gt;
&lt;div class=&quot;md-img aspect-ratio aspect-ratio--1x1 bg-light-gray  &quot;&gt;
  &lt;img src=&quot;https://fotis.xyz/img/posts/helsinki-as-a-service/partners.png&quot; alt=&quot;Screencap of the list of partners on the site.&quot; loading=&quot;lazy&quot; class=&quot;aspect-ratio--object fit-cover o-pos-center  &quot; /&gt;
&lt;/div&gt;
&lt;p&gt;For example, this is markup for the whim logo:&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;a&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;  _ngcontent-serverapp-c12&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;  class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;logo-container ng-star-inserted&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;  target&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;_blank&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;  href&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;https://whimapp.com/jobs/&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;lib-image&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;    _ngcontent-serverapp-c12&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;    _nghost-serverapp-c16&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;    style&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;--fit:cover;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;img&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;      src&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;//images.ctfassets.net/cegx92j6q58r/2DGqEVRojpxcWSBpxussyl/1b839550e0fc247a2096aa1859896d61/whim_logo.png&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;      class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;ng-star-inserted&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;lib-image&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is a transcript of what it sounds like with a Screen Reader (in this case Orca on Linux, because that is what I had at hand):&lt;/p&gt;
&lt;p&gt;Browsing through the links:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Link, Link, Link, Link&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Diving into the Whim link:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Image
Jobs, image, link&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;In neither of those two cases, do we get the information about the company being “Whim”.&lt;/p&gt;
&lt;p&gt;You might wonder about the “link” announcements. Because the image is the only child of the link and it does not have an alternative text, then the link as a whole does not have descriptive text. These will slightly differ between Screen Readers and browser/Operating System combinations, but are going to be similarly unhelpful.&lt;/p&gt;
&lt;p&gt;Instead, we could write “Whim” as the alt text. We skip the word “logo”, because it is already announced as an image, and it seems closer to the visual indication.&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;&amp;#x3C;!-- Rest of the markup skipped for clarity --&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;img&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;  alt&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;Whim&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;  src&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;//images.ctfassets.net/cegx92j6q58r/2DGqEVRojpxcWSBpxussyl/1b839550e0fc247a2096aa1859896d61/whim_logo.png&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;  class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;ng-star-inserted&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This will get announced as:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Whim, link
Whim, image, link&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;Images in key features&lt;/h3&gt;
&lt;p&gt;The “key features” section has icons next to the main points. You could say that those are decorative. There is definitely a choice to be made. I kind of like having them as content, to convey some of the playfulness of the page.&lt;/p&gt;
&lt;div class=&quot;md-img aspect-ratio aspect-ratio--16x9 bg-light-gray  &quot;&gt;
  &lt;img src=&quot;https://fotis.xyz/img/posts/helsinki-as-a-service/key_features.png&quot; alt=&quot;Screencap of the key features section.&quot; loading=&quot;lazy&quot; class=&quot;aspect-ratio--object fit-cover o-pos-center  &quot; /&gt;
&lt;/div&gt;
&lt;p&gt;For example, “High-quality perks” has a smiling balloon, while “Nordic welfare” has a coffee mug. Those could be “a smiling balloon” and “a coffee mug with warm steam coming off the top”!&lt;/p&gt;
&lt;p&gt;You can &lt;a href=&quot;https://a11yproject.com/posts/alt-text/&quot;&gt;read more about alt texts and how to write them&lt;/a&gt;.&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;missing-focus-outlines&quot; tabindex=&quot;-1&quot;&gt;Missing focus outlines&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/accessibility-audit-of-helsinki-as-a-service/#missing-focus-outlines&quot; aria-label=&quot;Link to Missing focus outlines&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;Some of the links and buttons on the page lack a focus outline.&lt;/p&gt;
&lt;p&gt;For reference, interactable elements on the web have different (pseudo) states. One commonly designed around is “hover”, when the user mouses over an element. Those states typically change the background, border, or outline.&lt;/p&gt;
&lt;p&gt;One state that often goes missing is “focus”. Focus on a page often moves around with the keyboard &lt;kbd&gt;Tab&lt;/kbd&gt; key. Focus can also be moved programmatically, or with other interfaces than a keyboard. The purpose of focus is to indicate what is the current element that the user can operate. For many users, like those who navigate by keyboard, &lt;strong&gt;focus is extremely important&lt;/strong&gt; to be able to locate where they are on a page, and discover which elements are operable.&lt;/p&gt;
&lt;p&gt;Below is an example of the outlines on this blog.&lt;/p&gt;
&lt;div class=&quot;md-img aspect-ratio aspect-ratio--6x4 bg-light-gray  &quot;&gt;
  &lt;img src=&quot;https://fotis.xyz/img/posts/helsinki-as-a-service/outline-example.gif&quot; alt=&quot;&quot; loading=&quot;lazy&quot; class=&quot;aspect-ratio--object fit-cover o-pos-center  &quot; /&gt;
&lt;/div&gt;
&lt;p&gt;Browsers provide default focus outlines. &lt;a href=&quot;https://adrianroselli.com/2017/02/avoid-default-browser-focus-styles.html&quot;&gt;Even those are not always accessible&lt;/a&gt;, but are better than nothing. Yet, quite often, focus is hidden altogether! This is sometimes the result of a stakeholder or implementer having a distaste for when an outline appears for users with a mouse or touch pointer. Other times, it ends up as a blanket “reset” in CSS.&lt;/p&gt;
&lt;p&gt;The fact of the matter is, that &lt;strong&gt;usurping a browser default without an alternative can actively exclude people&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;On the site, the main rectangular links hide the focus outline altogether.
Below is the source for those links, with &lt;code&gt;outline: 0&lt;/code&gt; as the default rule.
With a pointer device, not only do the buttons get a coloured background, but they also get a ripple effect, one I know takes a while to implement in the browser. I feel frustrated, because it is a stark contrast to skipping basic outlines for people who rely on the keyboard.&lt;/p&gt;
&lt;div class=&quot;md-img aspect-ratio aspect-ratio--6x4 bg-light-gray  &quot;&gt;
  &lt;img src=&quot;https://fotis.xyz/img/posts/helsinki-as-a-service/button-outline.jpg&quot; alt=&quot;The source for the rectangular links in the Firefox inspector, with outline 0 as a rule.&quot; loading=&quot;lazy&quot; class=&quot;aspect-ratio--object fit-cover o-pos-center  &quot; /&gt;
&lt;/div&gt;
&lt;p&gt;Other elements, like the list of reasons to live in Helsinki, and the list of sponsors preserve the browser default.&lt;/p&gt;
&lt;p&gt;You can learn more about &lt;a href=&quot;https://www.w3.org/TR/UNDERSTANDING-WCAG20/navigation-mechanisms-focus-visible.html&quot;&gt;focus styles on the Web Content Accessibility Guidelines&lt;/a&gt;. There is also a &lt;a href=&quot;https://hacks.mozilla.org/2019/06/indicating-focus-to-improve-accessibility/&quot;&gt;post by Hidde de Vries on Mozilla Hacks about focus&lt;/a&gt;.&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;the-video-modal-button-is-not-operable-or-discoverable&quot; tabindex=&quot;-1&quot;&gt;The video modal button is not operable or discoverable&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/accessibility-audit-of-helsinki-as-a-service/#the-video-modal-button-is-not-operable-or-discoverable&quot; aria-label=&quot;Link to The video modal button is not operable or discoverable&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;The video is one of the main content of the page (and the campaign).&lt;/p&gt;
&lt;p&gt;There is a button to open a modal for the video at the top of the site. It is styled as a “Play” icon, a triangle in a circle, pointing to the right.&lt;/p&gt;
&lt;div class=&quot;md-img aspect-ratio aspect-ratio--6x4 bg-light-gray  &quot;&gt;
  &lt;img src=&quot;https://fotis.xyz/img/posts/helsinki-as-a-service/play-button.jpg&quot; alt=&quot;&quot; loading=&quot;lazy&quot; class=&quot;aspect-ratio--object fit-cover o-pos-center  &quot; /&gt;
&lt;/div&gt;
&lt;p&gt;While it visually looks like a button, this control is only marked up as a generic container (&lt;code&gt;div&lt;/code&gt; and &lt;code&gt;svg&lt;/code&gt;). As such, it does not expose any specific role or accessible name to Assistive Technologies.&lt;/p&gt;
&lt;p&gt;This is a problem for two reasons:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;It is not discoverable (or, &lt;a href=&quot;https://webaim.org/articles/pour/perceivable&quot;&gt;perceivable&lt;/a&gt;), for many Assistive Technologies users, whose ATs rely on reading the markup to find functionality&lt;/li&gt;
&lt;li&gt;It is also not &lt;a href=&quot;https://webaim.org/articles/pour/operable&quot;&gt;operable&lt;/a&gt;; a &lt;code&gt;div&lt;/code&gt; will not receive &lt;a href=&quot;https://fotis.xyz/posts/accessibility-audit-of-helsinki-as-a-service/#focus&quot;&gt;focus&lt;/a&gt;, and will not open the modal with the &lt;kbd&gt;Enter&lt;/kbd&gt; or &lt;kbd&gt;Space&lt;/kbd&gt; keys.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In practice, this means that only a specific subset of users can open the modal.&lt;/p&gt;
&lt;p&gt;A fix would be to introduce a &lt;code&gt;button&lt;/code&gt;, and attach the &lt;code&gt;click&lt;/code&gt; event handler to that button, instead of a &lt;code&gt;div&lt;/code&gt; or the &lt;code&gt;svg&lt;/code&gt;. The button would also need an accessible name, either through its content, or an &lt;code&gt;aria-label&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;button&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;  aria-label&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;Open video modal&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;  _ngcontent-serverapp-c2&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;  class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;play-button&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;svg&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;    aria-hidden&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;true&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;    focusable&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;false&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;    _ngcontent-serverApp-c2&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;    fill&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;none&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;    height&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;64&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;    viewBox&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;0 0 64 64&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;    width&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;64&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;    xmlns&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;http://www.w3.org/2000/svg&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;    &amp;#x3C;!-- Content skipped for brevity --&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;svg&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;a href=&quot;https://www.sarasoueidan.com/blog/accessible-icon-buttons/#accessible-button-names&quot;&gt;Sara Soueidan has written at length on accessible icon buttons&lt;/a&gt;. Her post goes into the different considerations and possible solutions.&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;modal-operation&quot; tabindex=&quot;-1&quot;&gt;Modal operation&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/accessibility-audit-of-helsinki-as-a-service/#modal-operation&quot; aria-label=&quot;Link to Modal operation&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;The modal that pops up for the video does not trap focus. Focus trapping is the pattern of constraining focus within the modal’s interactable elements. This helps users that rely on keyboard to not end up on content hidden “behind” the modal, or off screen. Similar constraints can apply to what parts of the document get exposed to Assistive Technologies.&lt;/p&gt;
&lt;p&gt;Moreover, while the modal can be exited with the &lt;kbd&gt;Esc&lt;/kbd&gt; key, the X button to close the modal is not marked up as a &lt;code&gt;button&lt;/code&gt;, similar to the notes above.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://modalzmodalzmodalz.com/&quot;&gt;Modals are a contentious issue in front-end&lt;/a&gt;. An option, in this case, might be to skip it altogether, and include the video inline. Doing so might make it more discoverable as well. &lt;a href=&quot;https://www.scottohara.me/blog/2019/03/05/open-dialog.html&quot;&gt;Scott O’Hara has notes on modal accessibility&lt;/a&gt;, that I really like.&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;colour-contrast-on-application-page&quot; tabindex=&quot;-1&quot;&gt;Colour contrast on application page&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/accessibility-audit-of-helsinki-as-a-service/#colour-contrast-on-application-page&quot; aria-label=&quot;Link to Colour contrast on application page&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;The colours in the &lt;a href=&quot;https://helsinkiasaservice.com/apply&quot;&gt;application page&lt;/a&gt; are white text on dark turquoise background (&lt;code&gt;#fff&lt;/code&gt; on &lt;code&gt;#00d7a7&lt;/code&gt;). This has a low &lt;a href=&quot;https://a11yproject.com/posts/what-is-color-contrast/&quot;&gt;color contrast&lt;/a&gt; of &lt;a href=&quot;https://colorable.jxnblk.com/ffffff/00d7a7&quot;&gt;1.86&lt;/a&gt;. A low color contrast can be hard to read for many people. The solution would be to use a darker background. Sometimes, this can be caused by the need to use brand colours. Other parts of the site combine them well, so using one of those combinations is an alternative.&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;the-document-hierarchy-jumps-around&quot; tabindex=&quot;-1&quot;&gt;The document hierarchy jumps around&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/accessibility-audit-of-helsinki-as-a-service/#the-document-hierarchy-jumps-around&quot; aria-label=&quot;Link to The document hierarchy jumps around&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;The HTML heading elements (&lt;code&gt;h1&lt;/code&gt;, &lt;code&gt;h2&lt;/code&gt;, &lt;code&gt;h3&lt;/code&gt; etc.) are meant to provide an &lt;strong&gt;outline&lt;/strong&gt; for the document, almost like a table of contents.&lt;/p&gt;
&lt;p&gt;With that in mind, &lt;code&gt;h1&lt;/code&gt; should be at the top-level, with sub-sections being &lt;code&gt;h2&lt;/code&gt; and so on. What should not happen, is jumping from &lt;code&gt;h1&lt;/code&gt; to, say, &lt;code&gt;h3&lt;/code&gt;, without any intermediate &lt;code&gt;h2&lt;/code&gt;. This can happen oftentimes when only the visual aspect of the headings is considered, but not the intermediate markup.&lt;/p&gt;
&lt;p&gt;The reason for this is that certain ATs, like Screen Readers, can list the headings in a document. If they are well structured, they can aid the user in navigating the site. If they are badly structured, they can confuse or be useless.&lt;/p&gt;
&lt;p&gt;For example, this part of the page at the start has an &lt;code&gt;h5&lt;/code&gt;, and then an &lt;code&gt;h1&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; _ngcontent-serverapp-c2&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;container&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;h5&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; _ngcontent-serverapp-c2&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;ingress ng-star-inserted&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;    Helsinki is calling for demo users&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;h5&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; _ngcontent-serverapp-c2&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;top-pattern&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;h1&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; _ngcontent-serverapp-c2&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;heading ng-star-inserted&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;    Welcome to the World’s First City as a Service&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;h1&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; _ngcontent-serverapp-c2&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;bottom-pattern&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; _ngcontent-serverapp-c2&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;body-text ng-star-inserted&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;    What is the most tech-savvy city on this planet? No idea, but Helsinki just&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;    became the world’s first City as a Service (CaaS). Apply for a free demo and&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;    enjoy an unforgettable trip to Helsinki.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;  &amp;#x3C;!-- The rest is omitted --&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Which could instead be:&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; _ngcontent-serverapp-c2&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;container&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; _ngcontent-serverapp-c2&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;ingress ng-star-inserted&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;    Helsinki is calling for demo users&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; _ngcontent-serverapp-c2&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;top-pattern&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;h1&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; _ngcontent-serverapp-c2&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;heading ng-star-inserted&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;    Welcome to the World’s First City as a Service&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;h1&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; _ngcontent-serverapp-c2&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;bottom-pattern&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; _ngcontent-serverapp-c2&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;body-text ng-star-inserted&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;    What is the most tech-savvy city on this planet? No idea, but Helsinki just&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;    became the world’s first City as a Service (CaaS). Apply for a free demo and&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;    enjoy an unforgettable trip to Helsinki.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;  &amp;#x3C;!-- The rest is omitted --&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;aside class=&quot;aside&quot;&gt;
  &lt;div class=&quot;aside-wrapper&quot;&gt;
    &lt;h3 class=&quot;aside__title&quot;&gt;On CMS&lt;/h3&gt;
    &lt;div class=&quot;aside__content&quot;&gt;  &lt;p&gt; One thing to note, in many of these cases, is that there is probably a Content Management System (CMS) in-between the authoring and the content on screen. It is not always easy to &quot;hard code&quot; fixes like these, or to even check for these mistakes. This is even more prevalent when a simple format, like Markdown, is used for authoring. &lt;/p&gt;  &lt;p&gt; Often, CMSes do not have enough information or tools to decouple visuals from semantics, or to enforce certain document hierarchies. This brings up the topic that this is a systemic issue, rather than an individual one. It is a topic I have encountered often, and I empathise with having to maintain such a system without the mandate/budget/time to fix it. &lt;/p&gt; &lt;/div&gt;
  &lt;/div&gt;
&lt;/aside&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;issues-with-the-carousel-operation&quot; tabindex=&quot;-1&quot;&gt;Issues with the carousel operation&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/accessibility-audit-of-helsinki-as-a-service/#issues-with-the-carousel-operation&quot; aria-label=&quot;Link to Issues with the carousel operation&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;(I left the carousel last, because it had a few issues, and I think they are mostly combinations of those described above. I include these notes here because I believe I have seen the carousel in other City of Helsinki sites. Thus, there might be more systemic problems and solutions to it. Let me know if this assumption is wrong though!)&lt;/p&gt;
&lt;p&gt;Similar to the button for the video modal, the carousel is not operable by keyboard, or exposed as interactable.&lt;/p&gt;
&lt;p&gt;The carousel has left and right arrows, as well as “bullets” that one can click on with a mouse, to operate the carousel.&lt;/p&gt;
&lt;div class=&quot;md-img aspect-ratio aspect-ratio--6x4 bg-light-gray  &quot;&gt;
  &lt;img src=&quot;https://fotis.xyz/img/posts/helsinki-as-a-service/carousel.png&quot; alt=&quot;Screencap of the carousel, with the controls on the side.&quot; loading=&quot;lazy&quot; class=&quot;aspect-ratio--object fit-cover o-pos-center  &quot; /&gt;
&lt;/div&gt;
&lt;p&gt;These controls, however, are only marked up as generic containers (&lt;code&gt;div&lt;/code&gt;s). Those do not expose any specific role or accessible name to Assistive Technologies. Moreover, they cannot be operated by a keyboard because of that.
The carousel can also be operated with the arrow (left/right) keys on a keyboard, but it is unclear to me how someone would discover that.
In practice, this means that only sighted users with a pointer device (mouse, touch, pen etc.) can operate the carousel.&lt;/p&gt;
&lt;p&gt;We will split the issues between the arrow and the bullet list operation.&lt;/p&gt;
&lt;h3&gt;The arrows&lt;/h3&gt;
&lt;p&gt;The issues with the arrows are similar to the notes for buttons above; they are not operable or perceivable.&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;carousel-control-next ng-star-inserted&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; role&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;button&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;span&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; aria-hidden&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;true&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;carousel-control-next-icon&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;span&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;span&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;sr-only&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;Next&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;span&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In this case, it is not that they are marked up as a &lt;code&gt;div&lt;/code&gt;. Rather, they are marked up as an anchor (&lt;code&gt;a&lt;/code&gt;), with &lt;code&gt;role=&amp;quot;button&amp;quot;&lt;/code&gt;. The &lt;code&gt;role&lt;/code&gt; attribute is typically used to change the, well, role of the element that will get announced to Assistive Technologies. It is important to note, that setting the &lt;code&gt;role&lt;/code&gt; does not really change the functionality by itself. Rather, &lt;a href=&quot;https://www.w3.org/TR/wai-aria-practices-1.1/#no_aria_better_bad_aria&quot;&gt;it is a promise that this element will act like a button&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This promise clashes with using it on an anchor tag. An anchor tag is not operable if the &lt;code&gt;href&lt;/code&gt; attribute is missing (it is meant for links, after all). Thus, while the element promises to be a button, it cannot be perceived as such (and thus, focused by keyboard etc.). If someone were to somehow focus on it, I believe that the &lt;kbd&gt;Enter&lt;/kbd&gt; key would work, but I could not get that in my testing.&lt;/p&gt;
&lt;p&gt;An interesting part of the arrows is that they have a label as text, and use an &lt;code&gt;.sr-only&lt;/code&gt; class.&lt;/p&gt;
&lt;p&gt;Typically, an &lt;code&gt;.sr-only&lt;/code&gt; (“screen reader only”) class is a technique to hide an element visually, but keep it accessible in the tree that gets exposed to Assistive Technologies. Another common name for this class is &lt;code&gt;.visually-hidden&lt;/code&gt;. This technique usually involves a combination of positioning and clipping. &lt;a href=&quot;https://a11yproject.com/posts/how-to-hide-content/&quot;&gt;The A11y Project has some information on visually hidden&lt;/a&gt;, and &lt;a href=&quot;https://www.scottohara.me/blog/2017/04/14/inclusively-hidden.html&quot;&gt;Scott O’Hara has written about hiding content&lt;/a&gt; as well.&lt;/p&gt;
&lt;p&gt;Visually hidden content is often used as a technique to provide accessible labels to buttons and icons. Its benefit over, say, &lt;code&gt;aria-label&lt;/code&gt; is that it can get auto-translated by tools like Google Translate, and that it has a more prominent space in the DOM,which can aid maintenance. It is also a way to migrate components to be more accessible, which I believe (and might well be wrong!) is what happens here.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;.sr-only&lt;/code&gt; class on these arrows, however, sets &lt;code&gt;display: none;&lt;/code&gt;. With that declaration, the content of the arrows is hidden both visually and from Assistive Technologies.&lt;/p&gt;
&lt;p&gt;We can verify this directly in a Browser dev tools, for example &lt;a href=&quot;https://developers.google.com/web/tools/chrome-devtools/accessibility/reference#pane&quot;&gt;Chrome accessibility pane&lt;/a&gt; or &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Tools/Accessibility_inspector&quot;&gt;Firefox accessibility inspector&lt;/a&gt;. The arrow has a “button” role, and it does not have an accessible name.&lt;/p&gt;
&lt;div class=&quot;md-img aspect-ratio aspect-ratio--6x4 bg-light-gray  &quot;&gt;
  &lt;img src=&quot;https://fotis.xyz/img/posts/helsinki-as-a-service/arrow-button-inspector.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; class=&quot;aspect-ratio--object fit-cover o-pos-left  &quot; /&gt;
&lt;/div&gt;
&lt;p&gt;One solution would be to amend the &lt;code&gt;.sr-only&lt;/code&gt; class to one of the declarations in the references above. It would probably not break anything visually, since content was hidden before as well, but it might require re-evaluating other components, or coming up with a migration strategy.&lt;/p&gt;
&lt;h3&gt;Bullets&lt;/h3&gt;
&lt;p&gt;The bullets themselves are list items (&lt;code&gt;li&lt;/code&gt;), so while they have some more information, they still are not exposed as interactable.&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;ol&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;carousel-indicators ng-star-inserted&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; id&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;ngb-slide-10&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;ng-star-inserted active&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; id&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;ngb-slide-11&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;ng-star-inserted&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; id&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;ngb-slide-12&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;ng-star-inserted&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; id&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;ngb-slide-13&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;ng-star-inserted&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; id&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;ngb-slide-14&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;ng-star-inserted&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;ol&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;One step might be to change the markup, and add accessible labels to the controls. Note that there are different ways to do this, and that &lt;code&gt;aria-&lt;/code&gt; attributes are often a band-aid on more systemic issues (see &lt;a href=&quot;https://www.sarasoueidan.com/blog/accessible-icon-buttons/&quot;&gt;Sara Soueidan’s article on icon buttons&lt;/a&gt;). In this case, we could opt to add &lt;code&gt;button&lt;/code&gt;s inside the list items.&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;ol&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;carousel-indicators ng-star-inserted&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; aria-label&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;Carousel controls&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; id&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;ngb-slide-10&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;ng-star-inserted active&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; aria-label&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;Jump to slide 1&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;button&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; id&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;ngb-slide-11&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;ng-star-inserted active&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; aria-label&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;Jump to slide 2&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;button&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; id&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;ngb-slide-12&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;ng-star-inserted active&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; aria-label&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;Jump to slide 3&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;button&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; id&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;ngb-slide-13&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;ng-star-inserted active&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; aria-label&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;Jump to slide 4&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;button&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; id&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;ngb-slide-14&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;ng-star-inserted active&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; aria-label&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;Jump to slide 5&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;button&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;ol&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;On the topic of a carousel, it might be desirable to offer a pause/start button, to &lt;a href=&quot;https://inclusivedesignprinciples.org/#give-control&quot;&gt;give control&lt;/a&gt; to the user. An alternative design might be to skip the carousel altogether, and inline the quotes on the page. Maybe those would work just as well!&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;wrapping-up&quot; tabindex=&quot;-1&quot;&gt;Wrapping up&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/accessibility-audit-of-helsinki-as-a-service/#wrapping-up&quot; aria-label=&quot;Link to Wrapping up&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;We have covered a lot of ground! In an initial version of this writeup, I wanted to take the proposals above, and put together a version of the website with them.&lt;/p&gt;
&lt;p&gt;I realised that doing so would not achieve much. I imagine that much of the content is not “hard coded”, but rather comes in from a Content Management System (CMS), as noted previously. If components are being re-used or shared between other properties, it is also likely that the solutions to those would have to be systematic, and adding band-aids on top of them for a specific site would likely lead to it deteriorating further in the future.&lt;/p&gt;
&lt;p&gt;Thus, I would take this opportunity to go the other way, and call back to the note at the start.&lt;/p&gt;
&lt;p&gt;If you are reading this and you have a role that can affect the page, consider this post an invitation for dialogue, or a call to action. The concrete issues are solvable. Ensuring that future efforts are also accessible is a larger undertaking, that I invite you to participate in.&lt;/p&gt;
&lt;p&gt;If you are a designer or developer that is interested in making the web accessible for everyone, I hope this post can give you a good reference for any future work! If part of this post is a sampler, consider the links and references as potential for you to dive into the subject. If you found this useful, I would love to &lt;a href=&quot;https://fotis.xyz/about/#contact&quot;&gt;hear from you&lt;/a&gt;.&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;thanks&quot; tabindex=&quot;-1&quot;&gt;Thanks&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/accessibility-audit-of-helsinki-as-a-service/#thanks&quot; aria-label=&quot;Link to Thanks&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;Many thanks to the &lt;a href=&quot;https://spiceprogram.org/&quot;&gt;Spice program&lt;/a&gt;, by my employer, &lt;a href=&quot;https://www.futurice.com/&quot;&gt;Futurice&lt;/a&gt;. It allows me to allocate my own &lt;a href=&quot;https://www.futurice.com/blog/futurice-professional-volunteering-bonus-extended&quot;&gt;free time and professional expertise for causes that help society&lt;/a&gt;, while being partially compensated for it. Writing this post would have been impossible without this privilege! These are the kind of initiatives that I love in this country.&lt;/p&gt;
&lt;p&gt;Having said the above, bear in mind that the opinions shared here are my own, and not those of my employer. I outlined my reasons in &lt;a href=&quot;https://fotis.xyz/posts/accessibility-audit-of-helsinki-as-a-service/#motivation&quot;&gt;motivation&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;If you have thoughts on this post, &lt;a href=&quot;https://twitter.com/isfotis&quot;&gt;you can reach out on Twitter&lt;/a&gt;. I realise that Twitter is not the best place for nuance, so you can use &lt;a href=&quot;https://fotis.xyz/about/#contact&quot;&gt;my other contact info&lt;/a&gt;, if those offer a better medium.&lt;/p&gt;
&lt;p&gt;If you have read this far, thank you for your time and attention :)&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Keeping Sites Accessible with Types</title>
		<link href="https://fotis.xyz/posts/keeping-sites-accessible-with-types/"/>
		<updated>2019-10-16T12:00:00Z</updated>
		<id>https://fotis.xyz/posts/keeping-sites-accessible-with-types/</id>
		<content type="html">&lt;p&gt;This is an enhanced transcript for a talk I gave at ClojuTre 2019. I have included relevant graphics and code snippets. Clicking on the timestamps in the transcript will play the video at that specific time.&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;topic&quot; tabindex=&quot;-1&quot;&gt;Topic&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/keeping-sites-accessible-with-types/#topic&quot; aria-label=&quot;Link to Topic&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;Accessibility on the web takes effort. The responsibility is split amongst development, design, and really anything that touches the product. On development and design, many of the common issues (color contrast, semantic markup and forms) have known practices and patterns.&lt;/p&gt;
&lt;p&gt;However, there is a problem: HTML is permissive of anything and the semantic patterns often require expertise and research. On a bad day, or a tight deadline, even the most diligent person can miss things.&lt;/p&gt;
&lt;p&gt;The rise of typed functional languages on the frontend affords us an opportunity. We have a chance to encode the values of accessibility in our system, in a way that our coworkers and future selves can avoid these issues automatically, as well as learn about them in a practical way.&lt;/p&gt;
&lt;p&gt;In this talk, I will give a brief introduction to web accessibility, as well as concrete examples that help preserve it in our codebases. After the talk, I hope you’ll have issues for your backlog, as well as the confidence to tackle them!&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Accessibility Notes, Part 1</title>
		<link href="https://fotis.xyz/posts/accessibility-notes-1/"/>
		<updated>2019-12-19T00:00:00Z</updated>
		<id>https://fotis.xyz/posts/accessibility-notes-1/</id>
		<content type="html">&lt;p&gt;At work, I spend much of my time consulting about accessibility. This is done largely internally, taking the form of threads on Slack, direct messages, in-person over tea, or long PR descriptions. Calling those pieces of writing ad-hoc blog posts might be more apt.&lt;/p&gt;
&lt;p&gt;Some of that writing ends up being shared around. However, I find that I end up writing a lot of the same things, with little point of reference, which makes it easy to miss things!&lt;/p&gt;
&lt;p&gt;From a personal perspective, I often end up feeling drained and tired, with little to show for my effort. Given long development cycles and diverse projects, this has worn me down over the past year!&lt;/p&gt;
&lt;p&gt;So, as I start my holidays, I have decided to start writing my notes down on this blog. They might be incomplete or missing specific cases, and the same topic might come up in different note collections. I hope that will give me a better overview of topics that come up. I hope they help you build an intuition for accessibility issues, and give you references to dive in!&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;automated-checking-tools&quot; tabindex=&quot;-1&quot;&gt;Automated Checking Tools&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/accessibility-notes-1/#automated-checking-tools&quot; aria-label=&quot;Link to Automated Checking Tools&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;I really like &lt;a href=&quot;https://accessibilityinsights.io/&quot;&gt;Accessibility Insights, by Microsoft&lt;/a&gt;. They have an automatic mode, that scans a page and outlines common issues. It can also visualise things like Heading Order and so on.&lt;/p&gt;
&lt;p&gt;Perhaps more interesting, the tool has a &lt;a href=&quot;https://accessibilityinsights.io/docs/en/web/getstarted/assessment&quot;&gt;manual mode, Assessment&lt;/a&gt;, that gives you a checklist to go through. I think the manual mode is a great way to build an intuition about accessibility!&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;on-testing-with-screen-readers&quot; tabindex=&quot;-1&quot;&gt;On Testing with Screen Readers&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/accessibility-notes-1/#on-testing-with-screen-readers&quot; aria-label=&quot;Link to On Testing with Screen Readers&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;Testing with a screen reader can be good in a few cases.&lt;/p&gt;
&lt;p&gt;Two common ones for me:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Building an intuition about how the interfaces work&lt;/li&gt;
&lt;li&gt;Testing custom widgets and interactions, particularly whether a widget upholds its role / promise to the user.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I personally do not recommend using a Screen Reader yourself as a primary means of evaluating a website, especially if you do not use one regularly. It is usually better to get Screen Reader / Assistive Technology users to do that instead. I believe that to be a better use of your time, and brings up scenarios you might easily miss!&lt;/p&gt;
&lt;h3&gt;How a Screen Reader User Accesses the Web&lt;/h3&gt;
&lt;p&gt;I love this &lt;a href=&quot;https://www.smashingmagazine.com/2019/02/accessibility-webinar/&quot;&gt;presentation by Léonie Watson, on how she browses the web&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Before we go imagining how people might use our interface, we should know how they concretely do so at the moment!&lt;/p&gt;
&lt;h3&gt;Using a Screen Reader Yourself&lt;/h3&gt;
&lt;p&gt;Macs have the VoiceOver Screen Reader shipped by default. &lt;a href=&quot;https://webaim.org/articles/voiceover/&quot;&gt;WebAim has a guide about using VoiceOver to evaluate accessibility&lt;/a&gt;. They have a lot of good references there! I believe other platforms are more popular for users, such as &lt;a href=&quot;https://webaim.org/articles/nvda/&quot;&gt;NVDA on Windows&lt;/a&gt;&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;alt-text&quot; tabindex=&quot;-1&quot;&gt;Alt text&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/accessibility-notes-1/#alt-text&quot; aria-label=&quot;Link to Alt text&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;h3&gt;Editorial&lt;/h3&gt;
&lt;p&gt;It might be worth including a guide to alt text in editorial inputs. Here are two I like:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;https://axesslab.com/alt-texts/&lt;/li&gt;
&lt;li&gt;https://webaim.org/techniques/alttext/&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Alt text is not for SEO! Do not include random keywords there. Also, you do not need to write “image of…”. Assistive Technologies know to announce them as images already :)&lt;/p&gt;
&lt;p&gt;I am also interested in CMS integrations that can help / “lint” for those issues. I might write about this in the future.&lt;/p&gt;
&lt;h3&gt;Note on alt for developers&lt;/h3&gt;
&lt;p&gt;An image that has a description is marked up as &lt;code&gt;&amp;lt;img alt=&amp;quot;Description of things here&amp;quot; src=&amp;quot;...&amp;quot;/&amp;gt;&lt;/code&gt;. If an image does not have a description, it should have &lt;code&gt;alt=&amp;quot;&amp;quot;&lt;/code&gt;, such as &lt;code&gt;&amp;lt;img alt=&amp;quot;&amp;quot; src=&amp;quot;...&amp;quot; /&amp;gt;&lt;/code&gt;.This is different from not having an &lt;code&gt;alt&lt;/code&gt; at all! Not having an &lt;code&gt;alt&lt;/code&gt; at all will announce the full filename, and is very confusing for users.&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;custom-widgets&quot; tabindex=&quot;-1&quot;&gt;Custom Widgets&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/accessibility-notes-1/#custom-widgets&quot; aria-label=&quot;Link to Custom Widgets&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;Browser built-in widgets tend to work well with Assistive Technologies.
Examples include &lt;code&gt;form&lt;/code&gt;, &lt;code&gt;input&lt;/code&gt; with &lt;code&gt;label&lt;/code&gt;, &lt;code&gt;select&lt;/code&gt;, and of course &lt;code&gt;button&lt;/code&gt;.In cases where a custom widget is required (and “required” is often a point of contention!), the &lt;a href=&quot;https://www.w3.org/TR/wai-aria-practices/&quot;&gt;ARIA Authoring Practices&lt;/a&gt; has documentation on implementing one. Note that the Authoring Practices is &lt;em&gt;not&lt;/em&gt; a specification, and developers should still test and make sure their solutions work.&lt;/p&gt;
&lt;h3&gt;On Modal / Dialog Elements&lt;/h3&gt;
&lt;p&gt;Scott O’Hara, an accessibility expert, has written a bunch about modals:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://developer.paciellogroup.com/blog/2018/06/the-current-state-of-modal-dialog-accessibility/&quot;&gt;The current state of Modal Dialog Accessibility&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.scottohara.me/blog/2019/03/05/open-dialog.html&quot;&gt;Having an open dialog&lt;/a&gt;&lt;a href=&quot;https://www.w3.org/TR/wai-aria-practices/#dialog_modal&quot;&gt;The ARIA Authoring Practices on Modals&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The usual motto of “you might not need this” applies here :)&lt;/p&gt;
&lt;h3&gt;On Custom Select Inputs&lt;/h3&gt;
&lt;p&gt;Custom Selects are used often for styling purposes.&lt;/p&gt;
&lt;p&gt;I should note that the default &lt;code&gt;select&lt;/code&gt; is styleable, and there are documented ways of doing it. &lt;a href=&quot;https://www.filamentgroup.com/lab/select-css.html&quot;&gt;Styling a Select Like it’s 2019, by Scott Jehl&lt;/a&gt; is a very in-depth article about that. I realise that it might be a lot of CSS, but is it really much compared to a custom JavaScript implementation?&lt;/p&gt;
&lt;p&gt;Anyway, for custom widgets, selects are often classified as a listbox, or a combobox. I defer fully to &lt;a href=&quot;https://twitter.com/codingchaos&quot;&gt;Sarah Higley&lt;/a&gt;’s fantastic series on selects:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://www.24a11y.com/2019/select-your-poison/&quot;&gt;&lt;code&gt;&amp;lt;select&amp;gt;&lt;/code&gt; your poison&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.24a11y.com/2019/select-your-poison-part-2/&quot;&gt;&lt;code&gt;&amp;lt;select&amp;gt;&lt;/code&gt; your poison part 2: test all the things&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;on-datepickers&quot; tabindex=&quot;-1&quot;&gt;On Datepickers&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/accessibility-notes-1/#on-datepickers&quot; aria-label=&quot;Link to On Datepickers&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;Datepickers are tricky in a few ways:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Working with different input modes (keyboard, dictation, mouse, touch)&lt;/li&gt;
&lt;li&gt;Working across screens&lt;/li&gt;
&lt;li&gt;One size does not fit all websites! A flight booking might be different from a birthday, might be different from a hotel stay etc.&lt;/li&gt;
&lt;li&gt;Ensuring things stay accessible in the future. That last part is where I see a lot of trouble.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Perhaps the most resilient way to have a Datepicker, is to always have a text field that can be used instead. This fits the &lt;a href=&quot;https://webaim.org/articles/pour/robust&quot;&gt;Robustness principle of Accessibility&lt;/a&gt; very well, and ensures people can at least get through the flow, even if they later encounter an error.&lt;/p&gt;
&lt;p&gt;In terms of references for Datepickers, I have a few links:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://www.24a11y.com/2018/a-new-day-making-a-better-calendar/&quot;&gt;Making a Better Calendar&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://adrianroselli.com/2019/07/maybe-you-dont-need-a-date-picker.html&quot;&gt;Maybe You Don’t Need a Date Picker&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/alphagov/govuk-design-system-backlog/issues/17&quot;&gt;Gov.uk Discussion on Date picker&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;wrapping-up&quot; tabindex=&quot;-1&quot;&gt;Wrapping Up&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/accessibility-notes-1/#wrapping-up&quot; aria-label=&quot;Link to Wrapping Up&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;I hope you found this collection of notes useful!&lt;/p&gt;
&lt;p&gt;If you have thoughts on this post, &lt;a href=&quot;https://twitter.com/isfotis&quot;&gt;you can reach out on Twitter&lt;/a&gt;. I realise that Twitter is not the best place for nuance, so you can use &lt;a href=&quot;https://fotis.xyz/about/#contact&quot;&gt;my other contact info&lt;/a&gt;, if those offer a better medium.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Accessibility Notes, January 2020</title>
		<link href="https://fotis.xyz/posts/accessibility-notes-jan-2020/"/>
		<updated>2020-01-31T00:00:00Z</updated>
		<id>https://fotis.xyz/posts/accessibility-notes-jan-2020/</id>
		<content type="html">&lt;p&gt;At work, I spend much of my time consulting with co-workers about accessibility. This is the second in a series of posts about common topics that come up, or other things I want to share. Let’s dive right in!&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;expandable-menus&quot; tabindex=&quot;-1&quot;&gt;Expandable Menus&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/accessibility-notes-jan-2020/#expandable-menus&quot; aria-label=&quot;Link to Expandable Menus&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;A common topic is menus that expand and collapse, toggling a set of items (typically navigation links below) them.&lt;/p&gt;
&lt;p&gt;When people run into this, and want to make it more accessible, their search brings them to the ARIA &lt;code&gt;menu&lt;/code&gt; and &lt;code&gt;menubutton&lt;/code&gt; roles. While it seems reasonable (“it says menu on the tin” and “semantics are good, right?”), I usually advise against it.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;menu&lt;/code&gt; role is meant for a type of “application”, which in ARIA (and screen reader implementations) implies a specific set of interactions. Screen readers might go into a specific application mode upon encountering a &lt;code&gt;menu&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;As an example, you would probably use the &lt;code&gt;menu&lt;/code&gt; role if you were implementing Google Docs’ top-bar menu (the one that says &lt;code&gt;Files&lt;/code&gt;, &lt;code&gt;Edit&lt;/code&gt; etc.), rather than a hamburger menu, or a menu of sharing options.&lt;/p&gt;
&lt;p&gt;Another reason not to use &lt;code&gt;menu&lt;/code&gt;, in my experience, is that its implementation has a number of moving parts that can go out of sync as a project goes along. As the ARIA Authoring Practices document says, &lt;a href=&quot;https://www.w3.org/TR/wai-aria-practices-1.1/#no_aria_better_bad_aria&quot;&gt;“a role is a promise”&lt;/a&gt;. A &lt;code&gt;menu&lt;/code&gt; widget must act like a &lt;code&gt;menu&lt;/code&gt;, and it turns out there are a few things involved to do that. &lt;a href=&quot;https://www.w3.org/TR/wai-aria-practices-1.1/#menubutton&quot;&gt;You can read the interactions and markup on the ARIA Authoring Practices&lt;/a&gt; guide.&lt;/p&gt;
&lt;p&gt;There are keyboard interactions involved, and a set order of nesting the markup for &lt;code&gt;menu&lt;/code&gt; and &lt;code&gt;menuitems&lt;/code&gt;. Most often, I see &lt;code&gt;menuitems&lt;/code&gt; go on nested child nodes instead of immediate ones. At that point, the implementation is wrong, but it certainly might look right to someone! Even worse, it might look daunting. If a piece of code looks daunting, then people avoid touching it and it only accumulates cruft. That can be dangerous for the accessibility of a project long-term.&lt;/p&gt;
&lt;p&gt;I love this article by &lt;a href=&quot;https://sarahmhigley.com/writing/roles-and-relationships/&quot;&gt;Sarah Higley on Roles and Relationships&lt;/a&gt; and the various moving part of compound widgets. I think she outlines much of the same concerns, better than I could!&lt;/p&gt;
&lt;p&gt;Other people have covered this as well, such as &lt;a href=&quot;https://inclusive-components.design/collapsible-sections/&quot;&gt;Heydon Pickering on Collapsible Sections&lt;/a&gt; and &lt;a href=&quot;https://inclusive-components.design/menus-menu-buttons/&quot;&gt;Menus &amp;amp; Menu Buttons&lt;/a&gt;, which you could read as a more in-depth guide.&lt;/p&gt;
&lt;h3&gt;A concrete alternative&lt;/h3&gt;
&lt;p&gt;Given the above, I usually recommend that people simplify, and use &lt;code&gt;aria-expanded&lt;/code&gt;, with the menu that gets expanded immediately following the button in the markup. A button with &lt;code&gt;aria-expanded&lt;/code&gt; will be announced as “button, menu, collapsed” and “button, menu, expanded”, depending on the state.&lt;/p&gt;
&lt;p&gt;You need to use JavaScript to toggle &lt;code&gt;aria-expanded&lt;/code&gt; from &lt;code&gt;true&lt;/code&gt; to &lt;code&gt;false&lt;/code&gt;, and &lt;code&gt;display: none&lt;/code&gt; or equivalent on the menu. (Again, a role is a promise, so having &lt;code&gt;aria-expanded&lt;/code&gt;, means that it will change on press).&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; aria-expanded&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;false&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; Menu &lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;ul&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;collapsed&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; href&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;/articles&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; Articles &lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; href&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;/about&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; About &lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;ul&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;collapsed&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  display&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; none&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;// Of course, these could be more complex in your site&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;// using a specific class, a wrapper, React events or whatever you want!&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; button &lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; document&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;querySelector&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&#39;[aria-expanded]&#39;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; menuList &lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; document&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;querySelector&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&#39;ul&#39;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; (button) &lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;  button&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;addEventListener&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&#39;click&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#EBA0AC;font-style:italic&quot;&gt;ev&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; =&gt;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;    const&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; expanded &lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; button&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;getAttribute&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&#39;aria-expanded&#39;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;    const&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; nextState &lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; expanded &lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;===&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;true&#39;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; ?&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;false&#39;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; :&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;true&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;    button&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;setAttribute&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&#39;aria-expanded&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; nextState)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;    if&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; (menuList) &lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;      menuList&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;classList&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;toggle&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&#39;collapsed&#39;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;  }&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you wanted to simplify even further, you might ditch that hamburger menu altogether, and go for something horizontally scrollable. That would work even when JavaScript fails / has not loaded.&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;where-to-draw-the-line-with-os%2C-browser%2C-screen-reader-software-and-versions-supported&quot; tabindex=&quot;-1&quot;&gt;Where to draw the line with OS, browser, screen reader software and versions supported&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/accessibility-notes-jan-2020/#where-to-draw-the-line-with-os%2C-browser%2C-screen-reader-software-and-versions-supported&quot; aria-label=&quot;Link to Where to draw the line with OS, browser, screen reader software and versions supported&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;This was &lt;a href=&quot;https://twitter.com/isfotis/status/1217376579896139776&quot;&gt;asked by @JKallunki on Twitter&lt;/a&gt;, when I elicited questions in the beginning of the month. I’ve been thinking about it since!&lt;/p&gt;
&lt;p&gt;Part of the question hinges on what we define as support, so I’ll break it down a bit.&lt;/p&gt;
&lt;p&gt;By saying support, I mean having as a policy that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;We test with these browser and screen reader combinations;&lt;/li&gt;
&lt;li&gt;We commit to fixing bugs that come up in them.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This is especially important when considering custom widgets, such as those in the &lt;a href=&quot;https://www.w3.org/TR/wai-aria-practices-1.1/#browser_and_AT_support&quot;&gt;ARIA Authoring Practices, which you should be testing&lt;/a&gt;. It is also a kind of policy that you could have if you maintain a pattern library / design system / project guideline.&lt;/p&gt;
&lt;p&gt;For that, the &lt;a href=&quot;https://webaim.org/projects/screenreadersurvey8/&quot;&gt;survey on browsers and screen readers from WebAIM&lt;/a&gt; can be a starting point.&lt;/p&gt;
&lt;p&gt;I think part of this exercise would go hand-in-hand with &lt;a href=&quot;https://www.nomensa.com/blog/2009/writing-an-accessibility-statement/&quot;&gt;writing an accessibility statement&lt;/a&gt;. An outline of the level of WCAG compliance you are aiming for, how people can contact you and your plans for addressing known issues, are just as important as the specific combinations of OS &amp;amp; screen reader that you elect to support.&lt;/p&gt;
&lt;h3&gt;Coding to standards&lt;/h3&gt;
&lt;p&gt;I should point out something else too. A big part of accessibility is about coding to standards (aside: I cannot recall where I first heard this, let me know if you have an attribution!). For example, HTML markup, implementing and testing ARIA widgets can take you a long way.&lt;/p&gt;
&lt;p&gt;Working around specific software bugs can have an adverse effect if in the future those bugs change. That also accumulates code, which makes it less likely to change, and so on as above :)&lt;/p&gt;
&lt;p&gt;In other words, for OS &amp;amp; screen reader combinations outside of your defined list, you can be open to receiving bug reports, but might not work around specific bugs. You never know, a report might surface a bug in your implementation, which can improve the experience for other combinations too!&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;accessibility-jam&quot; tabindex=&quot;-1&quot;&gt;Accessibility Jam&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/accessibility-notes-jan-2020/#accessibility-jam&quot; aria-label=&quot;Link to Accessibility Jam&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;I helped start a kind of accessibility help desk at work! We called it “Accessibility Jam”. The idea is to have an ad-hoc communal help desk about accessibility, where people can drop in and out as they want.&lt;/p&gt;
&lt;p&gt;For your bookmarking needs, we have a site at &lt;a href=&quot;https://accessibility-jam.club/&quot;&gt;https://accessibility-jam.club&lt;/a&gt;.&lt;/p&gt;
&lt;div class=&quot;md-img aspect-ratio aspect-ratio--16x9 bg-light-gray  &quot;&gt;
  &lt;img src=&quot;https://fotis.xyz/img/posts/accessibility-notes-jan-2020-jam.png&quot; alt=&quot;The Accessibility Jam website, complete with an illustration of a jar of jam.&quot; loading=&quot;lazy&quot; class=&quot;aspect-ratio--object fit-cover o-pos-left  &quot; /&gt;
&lt;/div&gt;
&lt;p&gt;I hope this gives us a regular space for people to ask questions and find out more about the topic. It also gives me a supply of things to write about!&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;wrapping-up&quot; tabindex=&quot;-1&quot;&gt;Wrapping Up&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/accessibility-notes-jan-2020/#wrapping-up&quot; aria-label=&quot;Link to Wrapping Up&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;I hope you found this collection of notes useful!&lt;/p&gt;
&lt;p&gt;If you have thoughts on this post, &lt;a href=&quot;https://twitter.com/isfotis&quot;&gt;you can reach out on Twitter&lt;/a&gt;. I realise that Twitter is not the best place for nuance, so you can use &lt;a href=&quot;https://fotis.xyz/about/#contact&quot;&gt;my other contact info&lt;/a&gt;, if those offer a better medium.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>HTTPS for Local Sites</title>
		<link href="https://fotis.xyz/posts/https-for-local-sites/"/>
		<updated>2020-07-02T00:00:00Z</updated>
		<id>https://fotis.xyz/posts/https-for-local-sites/</id>
		<content type="html">&lt;p&gt;I recently set up &lt;a href=&quot;https://pi-hole.net/&quot;&gt;pi-hole&lt;/a&gt;, a local DNS sinkhole. It redirects lookups for ad-related domains into the void (and any other domain, via a blocklist). This post is not about pi-hole itself though. Rather, it is about adding HTTPS for the local web interface.&lt;/p&gt;
&lt;p&gt;Let’s define the problem better. The pi-hole runs on a Raspberry Pi, on the local network. It does not listen on the public internet, and its port is not exposed to it. Pi-hole offers an admin interface as a web UI. It is available locally, under its IP address, or a domain that you can configure locally. I would like to have HTTPS, because accessing sensitive data over an unencrypted connection, local as it may be, seems icky.&lt;/p&gt;
&lt;p&gt;In order to enable HTTPS, we need some kind of domain, and a certificate for that domain. We also do not want to go for a self-signed certificate solution.&lt;/p&gt;
&lt;p&gt;We thus have to solve the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Getting a domain to point to our IP&lt;/li&gt;
&lt;li&gt;Getting a certificate for that domain&lt;/li&gt;
&lt;li&gt;Auto-renewing that certificate when it expires&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I will stress the automation part. Historically, I have been &lt;em&gt;really&lt;/em&gt; bad at remembering to update certificates, or restart servers after certificates auto-renew. You might have more consistency than I do!&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;getting-a-domain&quot; tabindex=&quot;-1&quot;&gt;Getting a domain&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/https-for-local-sites/#getting-a-domain&quot; aria-label=&quot;Link to Getting a domain&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;I decided to use a sub-domain of &lt;a href=&quot;https://fotis.xyz/&quot;&gt;fotis.xyz&lt;/a&gt;, in this case &lt;code&gt;pi-hole.fotis.xyz&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;We could then resolve it via a DNS record to our local IP address, or do it per-device via a hosts file. I went with the hosts file, because I only really administrate the pi-hole through my laptop, and I can always access the admin via IP from other devices (albeit unencrypted). This solves the domain issue.&lt;/p&gt;
&lt;p&gt;Worrying about DHCP leases and changing IP for the pi-hole is out of scope for this post :)&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;getting-a-certificate-for-that-domain&quot; tabindex=&quot;-1&quot;&gt;Getting a certificate for that domain&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/https-for-local-sites/#getting-a-certificate-for-that-domain&quot; aria-label=&quot;Link to Getting a certificate for that domain&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;This is the interesting part, where I had gotten stuck in the past. I want to use &lt;a href=&quot;https://letsencrypt.org/&quot;&gt;LetsEncrypt&lt;/a&gt;, because they are awesome. LetsEncrypt uses a mechanism called ACME (Automatic Certificate Management Environment) to issue challenges, that the server must answer to prove that you own the domain.&lt;/p&gt;
&lt;p&gt;The “regular” challenge mechanism, that I was familiar with at least, is over HTTP. The client uses a well-known address like &lt;code&gt;http://&amp;lt;YOUR_DOMAIN&amp;gt;/.well-known/acme-challenge/&amp;lt;TOKEN&amp;gt;&lt;/code&gt; to place the challenge token, which LetsEncrypt then validates. This process can be manual or automated, for example with plugins for popular servers, such as Apache and Nginx.&lt;/p&gt;
&lt;p&gt;However, this does not work for sites that are resolved locally. For example, my local Raspberry Pi only listens on local addresses. The HTTP port 80 is not exposed to the internet. An HTTP ACME challenge would fail, because the Pi cannot be reached. It would also mean that I must resolve the domain to the local address at a public DNS level, instead of locally.&lt;/p&gt;
&lt;p&gt;That’s when I found the &lt;a href=&quot;https://letsencrypt.org/docs/challenge-types/#dns-01-challenge&quot;&gt;DNS Challenge mechanism&lt;/a&gt;. The ACME client makes the request, and gets a challenge token to place in a TXT DNS record (e.g. TXT for &lt;code&gt;_acme-challenge&lt;/code&gt;). LetsEncrypt then validates the presence of that record, to verify our control. This is promising, because the Pi can communicate outwards, and nothing needs to connect to its HTTP port!&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;automation&quot; tabindex=&quot;-1&quot;&gt;Automation&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/https-for-local-sites/#automation&quot; aria-label=&quot;Link to Automation&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;Now, you could copy this TXT record manually, but that sucks for the short renewal period of LetsEncrypt. Historically, as I mentioned, I have been bad at staying on top of it.&lt;/p&gt;
&lt;p&gt;Surprise! Most DNS providers offer an API these days, to add records and so on. So you can perform the addition of the TXT record as part of the challenge pipeline, with some artisanal scripting. This verifies that you have control of the domain, without caring about the IP it resolves to (or requiring the server on that IP to be listening on the internet).&lt;/p&gt;
&lt;aside class=&quot;aside&quot;&gt;
  &lt;div class=&quot;aside-wrapper&quot;&gt;
    &lt;h3 class=&quot;aside__title&quot;&gt;Warning&lt;/h3&gt;
    &lt;div class=&quot;aside__content&quot;&gt;  &lt;p&gt; This has some security implications, such as your web server having access to editing DNS. Depending on the granularity of the API tokens, this can be dangerous! &lt;/p&gt;  &lt;p&gt; &lt;a href=&quot;https://letsencrypt.org/docs/challenge-types/&quot;&gt;The LetsEncrypt documentation outlines the pros and cons of each challenge type&lt;/a&gt;. &lt;/p&gt;  &lt;p&gt; &lt;a href=&quot;https://www.eff.org/deeplinks/2018/02/technical-deep-dive-securing-automation-acme-dns-challenge-validation&quot;&gt;This post by Joona Hoikkala on the EFF blog discusses different mitigation strategies&lt;/a&gt;. &lt;/p&gt; &lt;/div&gt;
  &lt;/div&gt;
&lt;/aside&gt;
&lt;p&gt;To avoid artisanal scripting, and make this reproducible, I used &lt;a href=&quot;https://github.com/acmesh-official/acme.sh&quot;&gt;acme.sh&lt;/a&gt;, an ACME client for the command line. I have used &lt;a href=&quot;https://certbot.eff.org/&quot;&gt;Certbot&lt;/a&gt; in the past, but I was a bit lazy about managing Python this time around! acme.sh has integrations to many DNS providers, including the one I use, &lt;a href=&quot;https://dnsimple.com/&quot;&gt;DNSimple&lt;/a&gt;.&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;a-more-applied-example&quot; tabindex=&quot;-1&quot;&gt;A more applied example&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/https-for-local-sites/#a-more-applied-example&quot; aria-label=&quot;Link to A more applied example&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;The following is a guide (mostly to myself) about setting this up with pi-hole specifically.&lt;/p&gt;
&lt;h3&gt;SSH into the Raspberry Pi&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://www.raspberrypi.org/documentation/remote-access/ssh/&quot;&gt;This guide describes how to access your Raspberry Pi remotely&lt;/a&gt;. All the steps in the following sections are meant to be done on the Pi itself, in a terminal.&lt;/p&gt;
&lt;h3&gt;Install acme.sh&lt;/h3&gt;
&lt;p&gt;First, &lt;a href=&quot;https://github.com/acmesh-official/acme.sh#1-how-to-install&quot;&gt;install acme.sh via their instructions&lt;/a&gt;. I used the “pipe to shell” method, but I know not everyone likes that. Remember to restart the terminal session for it to appear in the PATH.&lt;/p&gt;
&lt;h3&gt;Set up lighttpd&lt;/h3&gt;
&lt;p&gt;We must respond to the host name that we define (e.g. pi-hole.fotis.xyz) from our Raspberry Pi. pi-hole uses &lt;a href=&quot;https://www.lighttpd.net/&quot;&gt;lighttpd&lt;/a&gt; for the HTTP UI already, so it made sense to me to reuse it.&lt;/p&gt;
&lt;p&gt;If you are following along without pi-hole, you might want to configure Nginx or Apache, or also install lighttpd. Whichever option you are comfortable with should work, but the config below is for lighttpd.&lt;/p&gt;
&lt;p&gt;I added the following file under &lt;code&gt;/etc/lighttpd/external.conf&lt;/code&gt;, adapted from &lt;a href=&quot;https://scotthelme.co.uk/securing-dns-across-all-of-my-devices-with-pihole-dns-over-https-1-1-1-1/&quot;&gt;Scott Helme’s post on pi-hole&lt;/a&gt;.&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;# Install this under /etc/lighttpd/external.conf&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;&#92;$HTTP[&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;&quot;host&quot;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; ==&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &quot;pi-hole.fotis.xyz&quot;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;# Ensure the Pi-hole Block Page knows that this is not a blocked domain&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;setenv.add-environment&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;fqdn&quot;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &quot;true&quot;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;# Enable the SSL engine with a LE cert, only for this specific host&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;&#92;$SERVER[&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;&quot;socket&quot;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; ==&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &quot;:443&quot;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;ssl.engine&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &quot;enable&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;ssl.ca-file&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &quot;/home/pi/cert.pem&quot;&lt;/span&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt; # This file does not come right off acme.sh, it is merged from the two files&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;ssl.pemfile&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &quot;/home/pi/merged.pem&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;ssl.honor-cipher-order&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &quot;enable&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;ssl.cipher-list&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &quot;EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;ssl.use-compression&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &quot;disable&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;ssl.use-sslv2&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &quot;disable&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;ssl.use-sslv3&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &quot;disable&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;# Redirect HTTP to HTTPS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;$HTTP&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;scheme&quot;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; == &lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;http&quot;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;$HTTP&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;&quot;host&quot;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; =~&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &quot;._&quot;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;url.redirect&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;._&quot;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &quot;https://%0&lt;/span&gt;&lt;span style=&quot;color:#EBA0AC;font-style:italic&quot;&gt;$0&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Getting the certificate&lt;/h3&gt;
&lt;p&gt;Now we must get the certificate. We want to use the &lt;a href=&quot;https://github.com/acmesh-official/acme.sh/wiki/dnsapi#25-use-dnsimple-api&quot;&gt;DNS challenge mode of acme.sh&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;We first get a token from DNSimple (this will vary on your provider). For DNSimple, it is under https://dnsimple.com/a/{your-acount-id}/account/access_tokens&lt;/p&gt;
&lt;p&gt;I stored it in a &lt;code&gt;.env&lt;/code&gt; file locally on the server:&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;export&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; DNSimple_OAUTH_TOKEN&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;sdfsdfsdfljlbjkljlkjsdfoiwje&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I then &lt;code&gt;source&lt;/code&gt;d that file, to export the variables on the CLI:&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F38BA8;font-style:italic&quot;&gt;source&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; .env&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Finally, we are ready to issue the ACME challenge, and hopefully acme.sh will do the rest, including editing the DNS records:&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;acme.sh&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; --issue&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; --dns&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; dns_dnsimple&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; -d&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; pi-hole.fotis.xyz&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Once it is set up, acme.sh handles auto-renewal via a cron job. No more email snoozing, yay!&lt;/p&gt;
&lt;h3&gt;Installing the certificate&lt;/h3&gt;
&lt;p&gt;acme.sh will store the certificates in its internal folders (under &lt;code&gt;/home/pi/.acme-sh&lt;/code&gt;). We are not supposed to rely on that structure, so it provides an &lt;code&gt;--install-cert&lt;/code&gt; command to move the certificates to the correct place.&lt;/p&gt;
&lt;p&gt;I used the following command&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;/home/pi/.acme.sh/acme.sh&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; --install-cert&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; -d&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; pi-hole.fotis.xyz&lt;/span&gt;&lt;span style=&quot;color:#F5C2E7&quot;&gt; &#92;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; --key-file&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; /home/pi/key.pem&lt;/span&gt;&lt;span style=&quot;color:#F5C2E7&quot;&gt; &#92;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; --fullchain-file&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; /home/pi/cert.pem&lt;/span&gt;&lt;span style=&quot;color:#F5C2E7&quot;&gt; &#92;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; --reloadcmd&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &quot;cat /home/pi/key.pem /home/pi/cert.pem &gt; /home/pi/merged.pem &amp;#x26;&amp;#x26; sudo service lighttpd restart&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Some things to note here. First of all, the &lt;code&gt;home/pi/key.pem&lt;/code&gt; and &lt;code&gt;/home/pi/cert.pem&lt;/code&gt; locations are meant to match the location where lighttpd expects them. I was confused by the terminology of acme.sh and of lighttpd, so I just named them in a way that made sense to me!&lt;/p&gt;
&lt;p&gt;The “reloadcmd” argument is the tricky bit. It will run whenever the new certificate is installed, to prompt the server to use it. This command depends on your server. In my case, &lt;strong&gt;lighttpd needs the private key and chain file to be merged&lt;/strong&gt;, so I do this as part of the setup script.&lt;/p&gt;
&lt;h3&gt;Hosts resolution&lt;/h3&gt;
&lt;p&gt;I edited the hosts file (&lt;code&gt;/etc/hosts&lt;/code&gt;) on my own machine, to point the domain pi-hole.fotis.xyz to the known IP address of the pi-hole.&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;# Replace x.x with your local address :)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;192.168.x.x&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; pi-hole.fotis.xyz&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I can now visit pi-hole.fotis.xyz locally, and see it secured, hooray!&lt;/p&gt;
&lt;div class=&quot;md-img aspect-ratio aspect-ratio--6x4 bg-light-gray  &quot;&gt;
  &lt;img src=&quot;https://fotis.xyz/img/posts/https-for-local-sites/padlock.jpg&quot; alt=&quot;The website with a secure padlock sign, and the raspberry logo in the center.&quot; loading=&quot;lazy&quot; class=&quot;aspect-ratio--object fit-cover o-pos-center  &quot; /&gt;
&lt;/div&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;wrapping-up&quot; tabindex=&quot;-1&quot;&gt;Wrapping up&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/https-for-local-sites/#wrapping-up&quot; aria-label=&quot;Link to Wrapping up&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;I hope this short guide on setting up HTTPS for local sites was useful! In addition to security, many modern browser APIs require HTTPS to function, so I suspect I will be using it again in the near future. Did I miss anything? Have you had a different way of doing this? &lt;a href=&quot;https://fotis.xyz/about#contact&quot;&gt;Get in touch, and let’s talk!&lt;/a&gt;&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
</content>
	</entry>
	
	<entry>
		<title>A toLocaleString Mystery</title>
		<link href="https://fotis.xyz/posts/a-tolocalestring-mystery/"/>
		<updated>2020-07-16T00:00:00Z</updated>
		<id>https://fotis.xyz/posts/a-tolocalestring-mystery/</id>
		<content type="html">&lt;p&gt;Recently, at work, one of our tests started failing. Our site is available in 11 languages, and the months for Azerbaijani (with the Latin script) had inconsistent capitalisation!&lt;/p&gt;
&lt;p&gt;After investigating, and a little bit of good guessing, it turned out to be an issue with the localisation data in the browser and Node.&lt;/p&gt;
&lt;p&gt;This post digs into how I went about investigating that issue, with some diversions along the way. I hope it gives you a fun insight into how localisation data ends up in JavaScript APIs, and how to spot errors!&lt;/p&gt;
&lt;aside class=&quot;aside&quot;&gt;
  &lt;div class=&quot;aside-wrapper&quot;&gt;
    &lt;h3 class=&quot;aside__title&quot;&gt;Numeronyms&lt;/h3&gt;
    &lt;div class=&quot;aside__content&quot;&gt;  &lt;p&gt; Internationalisation and Localisation are commonly referred to as i18n and l10n respectively. These are called numeronyms, representing the start and end letters, as well as the number of letters omitted. For example, &lt;code&gt;i - 18 letters - n&lt;/code&gt;. &lt;/p&gt;  &lt;p&gt; Numeronyms can be useful as a short representation and provide more accurate terms for web search. For the purposes of this post, I&#39;ll type them out long-form, but I wanted to point it out in case you run into it in the links. &lt;/p&gt;  &lt;p&gt; One day, I might shorten my name to Fotis P16s... &lt;/p&gt; &lt;/div&gt;
  &lt;/div&gt;
&lt;/aside&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;the-bug&quot; tabindex=&quot;-1&quot;&gt;The bug&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/a-tolocalestring-mystery/#the-bug&quot; aria-label=&quot;Link to The bug&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;Let’s frame the problem.&lt;/p&gt;
&lt;p&gt;We have a function that provides a list of months, localised for one of the languages and scripts that we support. For English US, that would be “January, February, March…”.&lt;/p&gt;
&lt;p&gt;JavaScript environments, whether web browsers such as Chrome and Firefox, or Node, provide a set of APIs for localisation and internationalisation. Two common ones are the &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl&quot;&gt;&lt;code&gt;Intl&lt;/code&gt; namespace of APIs&lt;/a&gt;, and the &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString&quot;&gt;&lt;code&gt;Date&lt;/code&gt; object with its &lt;code&gt;toLocaleString&lt;/code&gt; method&lt;/a&gt;. We use &lt;code&gt;toLocaleString&lt;/code&gt; specifically to get a localised month, for each month of the calendar.&lt;/p&gt;
&lt;p&gt;However, the result of calling those APIs can vary depending on the data that each browser has available.&lt;/p&gt;
&lt;p&gt;Because that possibility can sometimes be unexpected (especially for people that have not worked with multiple locales or scripts before), last year we added a series of tests to verify the localisation of months.&lt;/p&gt;
&lt;p&gt;Then, at some later point, our tests started failing:&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-diff&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;AssertionError: expected [ Array(12) ] to deeply equal [ Array(12) ]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; expected - actual&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;[&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#F38BA8&quot;&gt;  &quot;yanvar&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;  &quot;Yanvar&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;    &quot;Fevral&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#F38BA8&quot;&gt;  &quot;mart&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;  &quot;Mart&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;    &quot;Aprel&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;    &quot;May&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;    &quot;İyun&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;    &quot;İyul&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;    &quot;Avqust&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;    &quot;Sentyabr&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;    &quot;Oktyabr&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;    &quot;Noyabr&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#F38BA8&quot;&gt;  &quot;dekabr&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;  &quot;Dekabr&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In other words: the months for Azerbaijani with the Latin script, Yanvar (January), Mart (March) and Dekabr (December) were lower case, while all the other months were capitalised.&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;first-step%2C-checking-our-own-function&quot; tabindex=&quot;-1&quot;&gt;First step, checking our own function&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/a-tolocalestring-mystery/#first-step%2C-checking-our-own-function&quot; aria-label=&quot;Link to First step, checking our own function&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;Before going down the path that the data might be wrong, let’s make sure that our own function is not doing anything absurd.&lt;/p&gt;
&lt;p&gt;The function itself is provided below, a small wrapper around calling &lt;code&gt;toLocaleString&lt;/code&gt; for 12 Dates.&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt; getArrayOfMonths&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#EBA0AC;font-style:italic&quot;&gt;localeTag&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;  // Months for Date are 0.=11&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; months &lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 3&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 4&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 5&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 6&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 7&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 8&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 9&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 10&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 11&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;map&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#EBA0AC;font-style:italic&quot;&gt;month&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; =&gt;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;    const&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; dateobj &lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7;font-weight:bold&quot;&gt; new&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt; Date&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt;1970&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; month&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 15&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;    return&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; dateobj&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;toLocaleString&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(localeTag&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; month&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;long&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; }&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;  }&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;  return&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; months&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;(There are subtleties to getting a list of months this way, which may make the results wrong or unidiomatic. In our use, those are fine, but &lt;a href=&quot;https://fotis.xyz/posts/a-tolocalestring-mystery/#appendix%3A-when-this-method-of-getting-months-goes-wrong&quot;&gt;I am listing an example with noun cases at the end of the article&lt;/a&gt;.)&lt;/p&gt;
&lt;p&gt;Running this function in Firefox and Node (with localisation data, more on that later!) brings up the same results:&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;// Node&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;// NODE_ICU_DATA=node_modules/full-icu node&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;// Welcome to Node.js v12.16.3.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; console&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;log&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;getArrayOfMonths&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&#39;az-AZ&#39;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;))&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;[&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;  &#39;yanvar&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;   &#39;Fevral&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;  &#39;mart&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;     &#39;Aprel&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;  &#39;May&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;      &#39;İyun&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;  &#39;İyul&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;     &#39;Avqust&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;  &#39;Sentyabr&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;Oktyabr&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;  &#39;Noyabr&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;   &#39;dekabr&#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;// Firefox&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; console&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;log&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;getArrayOfMonths&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&#39;az-AZ&#39;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;))&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;Array&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt;12&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;) [ &lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;yanvar&quot;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &quot;Fevral&quot;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &quot;mart&quot;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &quot;Aprel&quot;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &quot;May&quot;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &quot;İyun&quot;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &quot;İyul&quot;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &quot;Avqust&quot;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &quot;Sentyabr&quot;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &quot;Oktyabr&quot;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; … ]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Firefox and Node having the same inconsistent capitalisation was already tipping me off.&lt;/strong&gt; They are different engines, so them processing the data in the same odd way seemed too good to be a coincidence.&lt;/p&gt;
&lt;p&gt;Chrome only prints out English months, but that is as-intended, because it does not support Azerbaijani in &lt;code&gt;Intl&lt;/code&gt;/&lt;code&gt;toLocaleString&lt;/code&gt; yet, and I did not specify a fallback.&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;finding-if-a-locale-is-supported-with-intl&quot; tabindex=&quot;-1&quot;&gt;Finding if a locale is supported with Intl&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/a-tolocalestring-mystery/#finding-if-a-locale-is-supported-with-intl&quot; aria-label=&quot;Link to Finding if a locale is supported with Intl&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;The &lt;code&gt;Intl&lt;/code&gt; family of APIs is really powerful. They have a bunch of namespaces and constructors to account for different lingustic artefacts and locales. For example, there is &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat&quot;&gt;&lt;code&gt;Intl.DateTimeFormat&lt;/code&gt;&lt;/a&gt; for formatting dates and times (day month year? month day year? fight!).&lt;/p&gt;
&lt;p&gt;One useful function is &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/supportedLocalesOf&quot;&gt;&lt;code&gt;Intl.DateTimeFormat.supportedLocalesOf&lt;/code&gt;&lt;/a&gt;. It takes an array of locales as &lt;a href=&quot;https://tools.ietf.org/html/bcp47&quot;&gt;BCP 47 language tags&lt;/a&gt;, such as &lt;code&gt;en-GB&lt;/code&gt; (English as used in Great Britan) or &lt;code&gt;el-GR&lt;/code&gt; (Greek as used in Greece) as an argument, and returns an array of the ones that are supported:&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; console&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;log&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(Intl&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;DateTimeFormat&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;supportedLocalesOf&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;([&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&#39;az-AZ&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;en-GB&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;el-GR&#39;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;]))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;[ &lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&#39;az-AZ&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;en-GB&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;el-GR&#39;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; ]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Locales are an interaction of languages, regions and scripts. This post has already too many diversions, and I don’t feel qualified to give you good examples.&lt;/p&gt;
&lt;p&gt;To account for these interactions, BCP 47 tags have optional components for scripts, region or country codes, variants, and also reserved extensions. I found this &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation&quot;&gt;article from MDN on locale identification&lt;/a&gt; useful for a short explanation.&lt;/p&gt;
&lt;p&gt;Azerbaijani (as far as my searching shows, and I might be wrong) has both a Latin and Cyrillic script. In BCP 47 format, these would be &lt;code&gt;az-Latn-AZ&lt;/code&gt; and &lt;code&gt;az-Cyrl-AZ&lt;/code&gt; respectively. As far as I can tell, &lt;code&gt;az-AZ&lt;/code&gt; defaults to Latin, but I am not sure whether this is an artefact of a specific data source.&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;a-past-chrome-bug-with-supportedlocalesof&quot; tabindex=&quot;-1&quot;&gt;A past Chrome bug with supportedLocalesOf&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/a-tolocalestring-mystery/#a-past-chrome-bug-with-supportedlocalesof&quot; aria-label=&quot;Link to A past Chrome bug with supportedLocalesOf&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;When I started seeing issues with Azerbaijani in particular, I was already on my toes about issues with data.&lt;/p&gt;
&lt;p&gt;About a year ago, we had run into a bug with Azerbaijani and Chrome. Chrome claimed it supported Azerbaijani, when asked via &lt;code&gt;supportedLocalesOf&lt;/code&gt;, but would give placeholder months in practice.&lt;/p&gt;
&lt;p&gt;In particular, this was the behaviour from this function back then (circa July 2019):&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; Intl&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;DateTimeFormat&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;supportedLocalesOf&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;([&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&#39;az-AZ&#39;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;])&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;// Means it is supported&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&#39;az-AZ&#39;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt; getArrayOfMonths&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&#39;az-AZ&#39;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;[M0&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; M1&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; M2&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; M3&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; ...&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; M11]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In other words, Chrome claimed to support &lt;code&gt;az-AZ&lt;/code&gt;, but the months were these odd &lt;code&gt;M0&lt;/code&gt; to &lt;code&gt;M11&lt;/code&gt; months, which seemed like internal placeholders. If Azerbaijani was unsupported, I would expect &lt;code&gt;supportedLocalesOf&lt;/code&gt; to not report it, and also the months to be in English GB (because that is my system locale, and I did not specify a fallback).&lt;/p&gt;
&lt;p&gt;After double- and triple-checking with colleagues and different platforms, &lt;a href=&quot;https://bugs.chromium.org/p/chromium/issues/detail?id=984922&quot;&gt;I filed a bug in Chromium&lt;/a&gt;, and it was confirmed! It was eventually fixed, and &lt;code&gt;supportedLocalesOf&lt;/code&gt; reports Azerbaijani as unsupported.&lt;/p&gt;
&lt;p&gt;Long story short, Azerbaijani being unsupported indicates to me that the localisation data might be incomplete.&lt;/p&gt;
&lt;p&gt;I have referenced “the data” multiple times now; let’s dive into what that data is, and where it comes from.&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;localisation-data%3A-icu%2C-cldr%2C-oh-my&quot; tabindex=&quot;-1&quot;&gt;Localisation data: ICU, CLDR, oh my&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/a-tolocalestring-mystery/#localisation-data%3A-icu%2C-cldr%2C-oh-my&quot; aria-label=&quot;Link to Localisation data: ICU, CLDR, oh my&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;Let’s take a few different Intl APIs:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;DateTimeFormat, uhm, formatting (as is bugging us so far)&lt;/li&gt;
&lt;li&gt;Pluralization (e.g. apple, 2 of them = two apples, or more complex changes for languages that differentiate between “one”, “a handful”, and “many”)&lt;/li&gt;
&lt;li&gt;Locale names (e.g. saying that “Greek” is “Ελληνικά” in Greek)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can imagine that all of the underlying data (calendars, names of months, pluralization rules) must be coming from somewhere!&lt;/p&gt;
&lt;p&gt;Indeed, there is a standard resource for these in the &lt;a href=&quot;http://userguide.icu-project.org/icudata&quot;&gt;ICU (International Components for Unicode) data&lt;/a&gt;. Quoting from the site:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;ICU makes use of a wide variety of data tables to provide many of its services. Examples include converter mapping tables, collation rules, transliteration rules, break iterator rules and dictionaries, and other locale data. Additional data can be provided by users, either as customizations of ICU’s data or as new data altogether.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;A related dataset is the &lt;a href=&quot;http://cldr.unicode.org/&quot;&gt;CLDR (Unicode Common Locale Data Repository)&lt;/a&gt;. Quoting again from the site:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The Unicode CLDR provides key building blocks for software to support the world’s languages, with the largest and most extensive standard repository of locale data available. This data is used by a wide spectrum of companies for their software internationalization and localization, adapting software to the conventions of different languages for such common software tasks. It includes: …&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The ICU data-set uses CLDR itself for many things, with a few differences:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Data which is NOT sourced from CLDR includes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Conversion Data&lt;/li&gt;
&lt;li&gt;Break Iterator Dictionary Data ( Thai, CJK, etc )&lt;/li&gt;
&lt;li&gt;Break Iterator Rule Data (as of this writing, it is manually kept in sync with the CLDR datasets)&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;p&gt;Those data come in different formats, such as XML (LDML), categorised by locale (roughly, that I can tell). The &lt;a href=&quot;http://cldr.unicode.org/#TOC-How-to-Use-&quot;&gt;ICU data seems more commonly used by higher-level libraries&lt;/a&gt;, because the format is more compact.&lt;/p&gt;
&lt;p&gt;With this data available, browsers have enough information to provide the richer &lt;code&gt;Intl&lt;/code&gt; and &lt;code&gt;Date&lt;/code&gt; localisation APIs.&lt;/p&gt;
&lt;aside class=&quot;aside&quot;&gt;
  &lt;div class=&quot;aside-wrapper&quot;&gt;
    &lt;h3 class=&quot;aside__title&quot;&gt;Handwaving&lt;/h3&gt;
    &lt;div class=&quot;aside__content&quot;&gt;  &lt;p&gt; Here are some things I am handwaving at this point. &lt;/p&gt;  &lt;p&gt; I use ICU and CLDR rather interchangeably. As far as I can tell, the ICU data is derived from the CLDR data. I found better links for the CLDR sources, so I am digging into those. &lt;/p&gt;  &lt;p&gt; I am also not 100% clear on whether &lt;em&gt;all&lt;/em&gt; browsers use the ICU/CLDR data at the moment, or use some other source. I could not find anything normative about the data source in the specs (I would find that surprising anyway), and I am bad at going through issue trackers. &lt;/p&gt;  &lt;p&gt; I found one tracking issue about Firefox transitioning to the CLDR data, and at least my testing seems to support that. Perhaps the CLDR data version would be useful for browsers to expose? Not as an API, rather an `about:` config or something similar in the UI. &lt;/p&gt;  &lt;p&gt; Node definitely uses the ICU data, and gets its own following section for it. &lt;/p&gt; &lt;/div&gt;
  &lt;/div&gt;
&lt;/aside&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;excerpt-from-the-cldr-data&quot; tabindex=&quot;-1&quot;&gt;Excerpt from the CLDR Data&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/a-tolocalestring-mystery/#excerpt-from-the-cldr-data&quot; aria-label=&quot;Link to Excerpt from the CLDR Data&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;For example, here is the top-level directory structure from one &lt;a href=&quot;https://unicode.org/Public/cldr/35.1/&quot;&gt;download of the CLDR data&lt;/a&gt;:&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; tree -L 1 cldr-common-35.1/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;cldr-common-35.1/common/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;├──&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; annotations&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;├──&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; annotationsDerived&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;├──&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; bcp47&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;├──&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; casing&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;├──&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; collation&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;├──&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; dtd&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;├──&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; main&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;├──&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; properties&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;├──&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; rbnf&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;├──&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; segments&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;├──&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; subdivisions&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;├──&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; supplemental&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;├──&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; transforms&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;├──&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; uca&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;└──&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; validity&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;An excerpt from the &lt;code&gt;main&lt;/code&gt; directory:&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; cldr-exploration tree -L 1 cldr-common-35.1/common/main&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;cldr-common-35.1/common/main&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;├──&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; af_NA.xml&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;├──&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; af.xml&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;├──&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; af_ZA.xml&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;├──&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; agq_CM.xml&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;├──&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; agq.xml&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;├──&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; ak_GH.xml&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;├──&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; ak.xml&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;├──&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; am_ET.xml&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;├──&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; am.xml&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;├──&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; ar_001.xml&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;├──&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; ar_AE.xml&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;├──&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; ar_BH.xml&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And here is part of the data for English (&lt;code&gt;common/main/en.xml&lt;/code&gt;):&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-xml&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;monthWidth&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; type&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;wide&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;month&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; type&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;1&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;January&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;month&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;month&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; type&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;2&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;February&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;month&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;month&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; type&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;3&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;March&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;month&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;month&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; type&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;4&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;April&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;month&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;month&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; type&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;5&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;May&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;month&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;month&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; type&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;6&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;June&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;month&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;month&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; type&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;7&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;July&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;month&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;month&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; type&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;8&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;August&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;month&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;month&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; type&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;9&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;September&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;month&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;month&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; type&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;10&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;October&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;month&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;month&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; type&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;11&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;November&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;month&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;month&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; type&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;12&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;December&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;month&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;monthWidth&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;icu-and-node&quot; tabindex=&quot;-1&quot;&gt;ICU and Node&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/a-tolocalestring-mystery/#icu-and-node&quot; aria-label=&quot;Link to ICU and Node&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;If you have tried to work with internationalisation in Node, you might have run into the ICU data yourself.&lt;/p&gt;
&lt;p&gt;Up until version 13 (a few months ago), Node only had a base English locale loaded. The ICU data takes up space on the order of tens of megabytes, and so Node for the longest time did not come with them installed.&lt;/p&gt;
&lt;p&gt;To get correct localisations in Node, you had to either a) build Node yourself with the &lt;code&gt;full-icu&lt;/code&gt; dataset loaded, or b) install the correct build of the icu data locally, and provide the path via &lt;code&gt;NODE_ICU_DATA&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;It was messy, and probably still exists as an arcane parameter in current and aging codebases. Watch tests fail because &lt;code&gt;NODE_ICU_DATA&lt;/code&gt; is not supplied, ugh.&lt;/p&gt;
&lt;p&gt;Node getting the full ICU data built-in from version 13 was one of my favourite features, and if you’ve read this far, at least someone else might now understand my excitement!&lt;/p&gt;
&lt;p&gt;If you are curious:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/nodejs/node/pull/29522&quot;&gt;The issue for providing ICU data by default&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://nodejs.org/api/intl.html#intl_internationalization_support&quot;&gt;Node’s internationalisation guide&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Either way, now that we have gone through all the abbreviations, we’re in a good spot to find the data and investigate it!&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;digging-into-the-cldr-data&quot; tabindex=&quot;-1&quot;&gt;Digging into the CLDR data&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/a-tolocalestring-mystery/#digging-into-the-cldr-data&quot; aria-label=&quot;Link to Digging into the CLDR data&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;Time to dig into the CLDR data, to validate whether the months in Azerbaijani show up capitalised, uncapitalised, or inconsistent.&lt;/p&gt;
&lt;p&gt;To check for any changes (and in the case of our test, regressions), I downloaded &lt;a href=&quot;http://cldr.unicode.org/index/downloads&quot;&gt;CLDR versions&lt;/a&gt; 35.1, 36.1 and 37.&lt;/p&gt;
&lt;p&gt;I started browsing through the directories and quickly got lost because my search skills are bad.&lt;/p&gt;
&lt;p&gt;I then decided to go with a more drastic approach, and headed to the command line. In my case Gnome Terminal on Linux, but iTerm on MacOS or Windows Subsystem for Linux would work just as well, if you want to follow along.&lt;/p&gt;
&lt;p&gt;There is a nice utility called &lt;a href=&quot;https://github.com/BurntSushi/ripgrep&quot;&gt;&lt;code&gt;ripgrep&lt;/code&gt;&lt;/a&gt; which can search through files very fast. It is written in Rust and is lovely, though mostly I just use it out of habit nowadays.&lt;/p&gt;
&lt;p&gt;Anyway, I went searching through the files. I used “Yanvar” capital case and “yanvar” lower case for the known issues, as well as “Oktyabr” capital case and “oktyabr” lower case as a control.&lt;/p&gt;
&lt;p&gt;The results from ripgrep across three versions follow, and then a long-form explanation of them.&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-shell&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;# Yanvar capital case - 1 result from version 35.1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;  az-AZ-exploration rg &lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;Yanvar&quot;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; cldr&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;**&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;/az.xml&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;cldr-common-35.1/common/main/az.xml&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;1412:&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;month&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; type=&quot;1&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;Yanvar&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;/mont&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;h&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;# Yanvar lower case - two results for version 36.1 and 37, one for 35.1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;  az-AZ-exploration rg &lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;yanvar&quot;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; cldr&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;**&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;/az.xml&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;cldr-common-37.0/common/main/az.xml&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;1360:&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;month&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; type=&quot;1&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;yanvar&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;/mont&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;h&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;1404:&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;month&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; type=&quot;1&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;yanvar&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;/mont&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;h&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;cldr-common-36.1/common/main/az.xml&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;1360:&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;month&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; type=&quot;1&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;yanvar&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;/mont&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;h&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;1404:&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;month&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; type=&quot;1&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;yanvar&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;/mont&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;h&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;cldr-common-35.1/common/main/az.xml&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;1368:&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;month&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; type=&quot;1&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;yanvar&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;/mont&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;h&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;# Oktyabr capital case - one result for each version&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;  az-AZ-exploration rg &lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;Oktyabr&quot;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; cldr&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;**&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;/az.xml&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;cldr-common-37.0/common/main/az.xml&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;1413:&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;month&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; type=&quot;10&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;Oktyabr&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;/mont&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;h&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;cldr-common-36.1/common/main/az.xml&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;1413:&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;month&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; type=&quot;10&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;Oktyabr&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;/mont&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;h&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;cldr-common-35.1/common/main/az.xml&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;1421:&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;month&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; type=&quot;10&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;Oktyabr&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;/mont&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;h&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;# Oktyabr lower case - one result for each version&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;  az-AZ-exploration rg &lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;oktyabr&quot;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; cldr&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;**&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;/az.xml&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;cldr-common-37.0/common/main/az.xml&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;1369:&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;month&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; type=&quot;10&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;oktyabr&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;/mont&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;h&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;cldr-common-36.1/common/main/az.xml&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;1369:&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;month&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; type=&quot;10&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;oktyabr&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;/mont&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;h&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;cldr-common-35.1/common/main/az.xml&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;1377:&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;month&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; type=&quot;10&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;oktyabr&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;/mont&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;h&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We have a winner! From version 36 onward, we get “yanvar” as lower case for January, while “Fevral” for February stays capitalised for all versions. The same pattern repeats with March and December. Version 35, by comparison, has both Yanvar and Fevral (and all the other months) capitalised.&lt;/p&gt;
&lt;h3&gt;Data sources&lt;/h3&gt;
&lt;p&gt;Something I found interesting: the data for months appears in two places, once in a “months” entry, and once in a “calendar” entry (again, for the Gregorian calendar).&lt;/p&gt;
&lt;p&gt;The “months” entry has consistent capitalisation throughout. They are all lower case; “yanvar”, “fevral” and so on.&lt;/p&gt;
&lt;p&gt;This hints to me that Firefox and Node use the “calendar” entry for the names of the months in this case. It makes sense, because if you’ll recall our original function, we go through a &lt;code&gt;Date&lt;/code&gt; object’s &lt;code&gt;toLocaleString&lt;/code&gt;, which deals with dates directly, rather than canonical names or anything of that sort.&lt;/p&gt;
&lt;p&gt;Bear in mind that there might not always be a one-to-one correlation with what the browser does, and the ICU or CLDR data. I think it’s a good place to start, but might not be comprehensive.&lt;/p&gt;
&lt;h3&gt;Changelog, Contributions&lt;/h3&gt;
&lt;p&gt;I was curious as to what changed in version 36 onward.&lt;/p&gt;
&lt;p&gt;Diving into the &lt;a href=&quot;http://cldr.unicode.org/index/downloads/cldr-36&quot;&gt;Changelog for the CLDR data version 36&lt;/a&gt; we find the following line:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Additionally, the following locales had at least a 15% increase in basic coverage: az (Azerbaijani / Latin script), so (Somali / Latin script).&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The inconsistent months might have been entered accidentally, or were caused somehow when the coverage was expanded.&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;update%3A-a-simpler-of-finding-the-data&quot; tabindex=&quot;-1&quot;&gt;Update: A simpler of finding the data&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/a-tolocalestring-mystery/#update%3A-a-simpler-of-finding-the-data&quot; aria-label=&quot;Link to Update: A simpler of finding the data&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;Update, April 14, 2024:&lt;/p&gt;
&lt;p&gt;After version 38.0, the &lt;a href=&quot;https://github.com/unicode-org/cldr-json/tree/main&quot;&gt;unicode-org/cldr-json repository on GitHub&lt;/a&gt; started including JSON versions of the CLDR data. Each version is tagged, so you can find it directly (&lt;a href=&quot;https://github.com/unicode-org/cldr-json/tree/44.1.0?tab=readme-ov-file&quot;&gt;here is CLDR 44.1.0, for example&lt;/a&gt;). These can be viewed directly in the GitHub UI, and can make for a quick gut feeling check.&lt;/p&gt;
&lt;p&gt;I would still suggest finding the &lt;a href=&quot;https://cldr.unicode.org/index/downloads&quot;&gt;changelog in the release notes&lt;/a&gt;, or PRs to the &lt;a href=&quot;https://github.com/unicode-org/cldr&quot;&gt;unicode-org/cldr&lt;/a&gt; repository for more context on changes, since the cldr-json repository does not have that history.&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;future-steps&quot; tabindex=&quot;-1&quot;&gt;Future steps&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/a-tolocalestring-mystery/#future-steps&quot; aria-label=&quot;Link to Future steps&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;This is all many words, for a simple change in our codebase at least: change the test to match the data (3 line change), alongside a description about why that is ok (200 words in the PR, however many words is this post).&lt;/p&gt;
&lt;p&gt;I am not keen on capitalising the months ourselves (today’s hotfix is tomorrow’s footgun), but we might do that specifically for Azerbaijani, with an inverse test case to notify us when the data is updated.&lt;/p&gt;
&lt;p&gt;Another thing I am looking into, is contributing the consistent capitalisation into the CLDR.&lt;/p&gt;
&lt;p&gt;As of April 2024, contributions to CLDR are made by native speakers through a survey tool (which makes sense; who am I to say what the capitalisation of months in Azerbaijani should be!), and bug reports are made through Jira tickets. &lt;a href=&quot;https://github.com/unicode-org/cldr/blob/988cc768ceeabcc1450d3f9fd640f2a66c7c2ad9/CONTRIBUTING.md&quot;&gt;The contributing doc in the cldr repository&lt;/a&gt; describes more of this process.&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;wrapping-up&quot; tabindex=&quot;-1&quot;&gt;Wrapping up&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/a-tolocalestring-mystery/#wrapping-up&quot; aria-label=&quot;Link to Wrapping up&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Long story short: sometimes, it is the data.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This whole process was some of the most fun I’ve had at work this month! I love it when the different layers (specs, JS APIs, JS hosts, CLDR data, bugs, messiness) fall into place. Localisation and internationalisation take a lot of material effort, so diving into it makes me appreciate it much more.&lt;/p&gt;
&lt;p&gt;In this case, I am also fond of our team’s past decisions. We had the tests in place, and had already gone into the ICU/CLDR rabbit hole a year ago, filing the Chrome bug. This was both a time-saver, and brought a smile to my face.&lt;/p&gt;
&lt;p&gt;I hope I managed to impart at least a glimpse of that fun to you, and that you found something interesting here.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://fotis.xyz/about#contact&quot;&gt;I’ll be happy to discuss this post and any linked resources!&lt;/a&gt;&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;appendix%3A-when-this-method-of-getting-months-goes-wrong&quot; tabindex=&quot;-1&quot;&gt;Appendix: When this method of getting months goes wrong&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/a-tolocalestring-mystery/#appendix%3A-when-this-method-of-getting-months-goes-wrong&quot; aria-label=&quot;Link to Appendix: When this method of getting months goes wrong&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;As mentioned many paragraphs ago, our implementation at work goes through a &lt;code&gt;Date&lt;/code&gt; object’s &lt;code&gt;toLocaleString&lt;/code&gt; to get the array of months.&lt;/p&gt;
&lt;p&gt;However, because the formatting happens in the context of a date, languages with different cases might inflect the month.&lt;/p&gt;
&lt;p&gt;When running this function for Greek, we get the following:&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; console&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;log&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;getArrayOfMonths&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&#39;el-GR&#39;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;))&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;[&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;  &#39;Ιανουαρίου&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;  &#39;Φεβρουαρίου&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;  &#39;Μαρτίου&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;     &#39;Απριλίου&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;  &#39;Μαΐου&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;       &#39;Ιουνίου&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;  &#39;Ιουλίου&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;     &#39;Αυγούστου&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;  &#39;Σεπτεμβρίου&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;Οκτωβρίου&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;  &#39;Νοεμβρίου&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;   &#39;Δεκεμβρίου&#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;All of these months are in the genitive case (denoting possession). This is the equivalent of saying “x of January”, “y of February” and so on in English. In our site, we use this function in the context of birthdays, so it ends up being ok! If, however, we wanted to only list the months, it would technically be wrong (we’d need the nominative case). Make sure to test for your use-case, and beware of tutorials only assuming English language rules.&lt;/p&gt;
&lt;p&gt;I am not certain how I would go about listing the months in the nominative, at least with the &lt;code&gt;Date&lt;/code&gt; object. &lt;code&gt;Intl&lt;/code&gt; has a draft (Stage 3) family of APIs called &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames&quot;&gt;&lt;code&gt;Intl.DisplayNames&lt;/code&gt;&lt;/a&gt; that “enables the consistent translation of language, region and script display names”. Would something similar for month names be desirable? I’m not sure! Let me know if you know of an approach.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Autocomplete for new and old passwords</title>
		<link href="https://fotis.xyz/posts/autocomplete-new-password/"/>
		<updated>2020-08-08T00:00:00Z</updated>
		<id>https://fotis.xyz/posts/autocomplete-new-password/</id>
		<content type="html">&lt;p&gt;A “change password” form often has a field for the user’s old/current password, as well as a field for them to select a new one, and perhaps one to confirm it.&lt;/p&gt;
&lt;p&gt;Autocomplete, such as that of passwords by the browser or password managers, often gets tripped up in these cases, prompting to autocomplete the old password for all fields, or not displaying a prompt to generate a password correctly.&lt;/p&gt;
&lt;p&gt;We can give the browser a hint to fix this! The &lt;code&gt;autocomplete&lt;/code&gt; value of &lt;code&gt;current-password&lt;/code&gt; and &lt;code&gt;new-password&lt;/code&gt; on the &lt;code&gt;input&lt;/code&gt; element allows for that. Read more about &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete#Values&quot;&gt;autocomplete new-password on MDN&lt;/a&gt;.&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;form&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;h1&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;Change your password&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;h1&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;label&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; for&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;current-password&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;Current password&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;label&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;input&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;    type&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;password&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;    autocomplete&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;current-password&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;    id&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;current-password&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;    name&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;current-password&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;label&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; for&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;new-password&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;Choose new password&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;label&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;input&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;    type&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;password&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;    autocomplete&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;new-password&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;    id&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;new-password&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;    name&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;new-password&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;label&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; for&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;new-password-confirm&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;Confirm new password&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;label&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;input&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;    type&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;password&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;    autocomplete&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;new-password&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;    id&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;new-password-confirm&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;    name&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;new-password-confirm&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;form&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;/* Mild styling for demo purposes */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;body&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  font-family&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; sans-serif&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  font-size&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 1.25&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;rem&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;label&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;input&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  display&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; block&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  font&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; inherit&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;label&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  margin-top&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;em&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  font-weight&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 700&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;input&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  margin-top&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 0.5&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;em&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  border&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;px&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; solid &lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;111&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;input&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;focus&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  outline&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 3&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;px&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; solid blue&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;prompts&quot; tabindex=&quot;-1&quot;&gt;Prompts&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/autocomplete-new-password/#prompts&quot; aria-label=&quot;Link to Prompts&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;The images below show the different steps in the process, based on the previous demo:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A prompt to fill in the current password&lt;/li&gt;
&lt;li&gt;A prompt to generate a new password&lt;/li&gt;
&lt;li&gt;The new password and its confirmation field being filled in&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;autocomplete-new-password-photo-grid&quot;&gt;
&lt;div class=&quot;md-img aspect-ratio aspect-ratio--16x9 bg-light-gray  &quot;&gt;
  &lt;img src=&quot;https://fotis.xyz/img/posts/autofill-new-passwords/current.png&quot; alt=&quot;A form to choose a new password, with a prompt to fill in the current one.&quot; loading=&quot;lazy&quot; class=&quot;aspect-ratio--object fit-cover   &quot; /&gt;
&lt;/div&gt;
&lt;div class=&quot;md-img aspect-ratio aspect-ratio--16x9 bg-light-gray  &quot;&gt;
  &lt;img src=&quot;https://fotis.xyz/img/posts/autofill-new-passwords/choose-new.png&quot; alt=&quot;A form to choose a new password, with a prompt to generate a new one.&quot; loading=&quot;lazy&quot; class=&quot;aspect-ratio--object fit-cover   &quot; /&gt;
&lt;/div&gt;
&lt;div class=&quot;md-img aspect-ratio aspect-ratio--16x9 bg-light-gray  &quot;&gt;
  &lt;img src=&quot;https://fotis.xyz/img/posts/autofill-new-passwords/new-filled-in.png&quot; alt=&quot;A form to choose a new password, with both the new one and its confirmation filled in.&quot; loading=&quot;lazy&quot; class=&quot;aspect-ratio--object fit-cover   &quot; /&gt;
&lt;/div&gt;
&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>Progressively Enhancing :focus-visible</title>
		<link href="https://fotis.xyz/posts/progressively-enhancing-focus-visible/"/>
		<updated>2021-01-25T00:00:00Z</updated>
		<id>https://fotis.xyz/posts/progressively-enhancing-focus-visible/</id>
		<content type="html">&lt;p&gt;The &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/:focus-visible&quot;&gt;:focus-visible CSS pseudo-class&lt;/a&gt; is a standard way of only showing focus styles for users of input modalities that rely on it. This post gives some background on what it is, and how you might use it without causing harm to users on non-supporting browsers.&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;background-on-focus&quot; tabindex=&quot;-1&quot;&gt;Background on focus&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/progressively-enhancing-focus-visible/#background-on-focus&quot; aria-label=&quot;Link to Background on focus&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;“Focus indicator” broadly refers to focus styling around an interactive element, which is the current element that the user can interact with (Whether using a keyboard,
mouse, switch control and so on). This is critical for users with modalities that serially go through each interactive element, such as by using the &lt;kbd&gt;Tab&lt;/kbd&gt; key on a keyboard, to orient themselves on the page, and predict the outcome of actions. You can read more on focus from &lt;a href=&quot;https://css-tricks.com/focusing-on-focus-styles/&quot;&gt;Eric Bailey on CSS Tricks, “Focusing on focus styles”&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This indicator is most often styled with the &lt;code&gt;:focus&lt;/code&gt; pseudo-class selector. When using custom &lt;code&gt;:focus&lt;/code&gt; styling, browsers typically expose those indicators regardless of how the user is interacting with the page. Sometimes, when using the “default” focus styles, browsers will try to make guesses, and avoid showing the focus indicator. The &lt;code&gt;:focus-visible&lt;/code&gt; pseudo-class is a way of standardising that latter behaviour.&lt;/p&gt;
&lt;p&gt;I would love to write this post in a reasonable amount of time, so I will be brief about why &lt;code&gt;:focus-visible&lt;/code&gt; is around. When an element is styled using &lt;code&gt;:focus&lt;/code&gt;, many stakeholders, whether developers, designers, content editors, middle managers, do not like the focus styles appearing for what they perceive to be unnecessary. In my experience, this is more common when people interact with a touch pointer, such as a smartphone, and see the outline persist on a button. One compelling argument is to avoid the button looking “stuck”, as described in the intro to &lt;a href=&quot;https://developer.paciellogroup.com/blog/2018/03/focus-visible-and-backwards-compatibility/&quot;&gt;“:focus-visible and backwards compatibility”&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This distaste for focus, and its deeper roots — whether &lt;a href=&quot;https://www.youtube.com/watch?v=SDdsD5AmKYA&quot;&gt;ableist thinking&lt;/a&gt;, or a reliance on arbitrary user metrics — has lead to a situation where many CSS stylesheets outright disable focus styles. It is very common, when using or auditing a site, to run into declarations such as &lt;code&gt;*:focus { outline: none !important; }&lt;/code&gt;. Over the years, there have been multiple tricks or workarounds to only selectively show focus styles (I won’t link to any, because in my experience they have pitfalls).&lt;/p&gt;
&lt;p&gt;&lt;code&gt;:focus-visible&lt;/code&gt; gives us a way to keep the focus styling when the browser deems it important. I must stress that this relies on heuristics, and I am still unclear on what multi-modal use of a page looks like with it. There are also open questions about whether vanishing focus indicators can raise barriers for people with cognitive disabilities, and whether there should be a global setting to always match &lt;code&gt;:focus-visible&lt;/code&gt;. &lt;a href=&quot;https://github.com/WICG/focus-visible/issues&quot;&gt;These issues are available on the WICG focus-visible GitHub repository&lt;/a&gt;.&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;using-focus-visible-today&quot; tabindex=&quot;-1&quot;&gt;Using focus-visible today&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/progressively-enhancing-focus-visible/#using-focus-visible-today&quot; aria-label=&quot;Link to Using focus-visible today&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/:focus-visible#browser_compatibility&quot;&gt;&lt;code&gt;:focus-visible&lt;/code&gt; is supported in most modern browsers, in recent versions&lt;/a&gt;. When using it, however, you must take care to not remove &lt;code&gt;:focus&lt;/code&gt; styling altogether, where &lt;code&gt;:focus-visible&lt;/code&gt; is not supported. People matter, whether on older browsers, older versions, specialised browsers, or future browsers!&lt;/p&gt;
&lt;p&gt;With CSS, we can achieve progressive enhancement of &lt;code&gt;:focus&lt;/code&gt; to &lt;code&gt;:focus-visible&lt;/code&gt;, by relying on the &lt;code&gt;:not(:focus-visible)&lt;/code&gt; selector to match and reset styles where &lt;code&gt;:focus-visible&lt;/code&gt; is supported. I originally learned of this technique from &lt;a href=&quot;https://developer.paciellogroup.com/blog/2018/03/focus-visible-and-backwards-compatibility/&quot;&gt;Patrick H. Lauke, “:focus-visible and backwards compatibility”&lt;/a&gt;, and then from &lt;a href=&quot;https://twitter.com/LeaVerou/status/1045768279753666562&quot;&gt;Lea Verou’s tweet on focus-visible&lt;/a&gt;.&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;&amp;#x3C;!-- Sample matching markup --&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; href&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;#&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;Link to test focus&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;Button to test focus&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;/* Styles where only focus is supported */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;focus&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;href&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;]:&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;focus&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  outline&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;px&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; solid blue&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;/* Reset styles where focus-visible&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;is supported (we&#39;ll add them back - in the next block) */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;focus&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;not&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;(:&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;focus-visible&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;href&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;]:&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;focus&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;not&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;(:&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;focus-visible&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  outline&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; none&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;/* The final, focus-visible styles. You could elect to make this even&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;more - obvious, if stakeholders or whomever is pushing against focus styles this&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;- week are now off your back. */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;focus-visible&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;href&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;]:&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;focus-visible&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  outline&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;px&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; solid blue&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If &lt;code&gt;:focus-visible&lt;/code&gt; is not supported, nothing bad happens; the styling is still there as &lt;code&gt;:focus&lt;/code&gt;. As more browsers gain support, the &lt;code&gt;:focus-visible&lt;/code&gt; statements will be in use. &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/:focus-visible&quot;&gt;Read more about :focus-visible on MDN&lt;/a&gt;.&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;what-about-the-polyfill%3F&quot; tabindex=&quot;-1&quot;&gt;What about the polyfill?&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/progressively-enhancing-focus-visible/#what-about-the-polyfill%3F&quot; aria-label=&quot;Link to What about the polyfill?&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;There is the &lt;a href=&quot;https://github.com/WICG/focus-visible&quot;&gt;WICG polyfill for focus-visible&lt;/a&gt;. I generally recommend not using it. Not that it is bad or anything, but I do not see the benefit compared to relying on &lt;code&gt;:focus&lt;/code&gt; and progressive enhancement.&lt;/p&gt;
&lt;p&gt;The polyfill adds extra script weight to the page (script which must traverse the DOM somewhat, so may be heavy), it brings an additional layer of support or quirks, and still requires extra styling classes on top, so it does not change the authoring experience in my view. It can also be painful when shared components or Design System libraries start relying on the polyfill classes, when progressive enhancement would have been a safer choice. This is not a fault of the polyfill, more an issue of process and mindset :)&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;a-sass-mixin&quot; tabindex=&quot;-1&quot;&gt;A Sass mixin&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/progressively-enhancing-focus-visible/#a-sass-mixin&quot; aria-label=&quot;Link to A Sass mixin&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;a href=&quot;https://gist.github.com/fpapado/b9d2487f8c310690ffddaef57405aa86&quot;&gt;I wrote some Sass mixins, to help achieve progressive enhancement consistently&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;These Sass mixins help achieve that aforementioned declaration, for multiple
selectors. There are three separate mixins, two focusing on common use cases,
and a fully custom one:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;focusVisible&lt;/strong&gt;: a generic mixin, giving you “slots”
to decide what to render for &lt;code&gt;:focus&lt;/code&gt;, &lt;code&gt;:focus&lt;/code&gt; reset, and &lt;code&gt;:focus-visible&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;focusVisibleOutline&lt;/strong&gt;: a focusVisible, which only resets the outline. If you
don’t need more custom resets, use this one!&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;focusVisibleBoxShadow&lt;/strong&gt;: a focusVisible, which only resets the box-shadow. Might be easier if you only set/reset box-shadow. For anything more custom, I recommend you write out the CSS long-hand, or create another mixin on top. Super-customisable, very generic mixins are a pain to maintain :D&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Use focusVisibleOutline&lt;/h3&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-scss&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;@include&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt; focusVisibleOutline&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&#39;button&#39;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&#39;a[href]&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  outline&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;px&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; solid blue&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;…which outputs:&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;focus&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;href&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;]:&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;focus&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  outline&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;px&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; solid blue&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;focus&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;not&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;(:&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;focus-visible&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;href&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;]:&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;focus&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;not&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;(:&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;focus-visible&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  outline&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; none&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;focus-visible&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;href&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;]:&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;focus-visible&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  outline&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;px&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; solid blue&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Use focusVisibleBoxShadow:&lt;/h3&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-scss&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;@include&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt; focusVisibleBoxShadow&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&#39;button&#39;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&#39;a[href]&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;  box-shadow&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 4&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;px&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; blue&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Use focusVisible:&lt;/h3&gt;
&lt;p&gt;This is the most customisable version of the mixin, where the mixin defers to the caller, with an argument representing the slot of content being rendered. The key thing here is then checking which slot is being rendered. For example, you can reset box-shadow, border, or anything else. This is how focusVisibleOutline and focusVisibleBoxShadow are implemented!&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: this mixin uses a feature of Sass for passing arguments to content blocks. This feature is, at the time of writing, only supported in Dart Sass (sass on npm). A version of the mixin that does not have the generic version (which requires that feature) is available in the &lt;a href=&quot;https://gist.github.com/fpapado/b9d2487f8c310690ffddaef57405aa86#file-focus_legacy-scss&quot;&gt;focus_legacy.scss file&lt;/a&gt;.&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-scss&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;@include&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt; focusVisible&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&#39;button&#39;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&#39;a[href]&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; using ($slot) &lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;  @if&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt; $slot&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; ==&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; focus &lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;    outline&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;px&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; solid transparent&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;    box-shadow&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 4&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;px&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; blue&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;  @if&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt; $slot&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; ==&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; focusReset &lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;    box-shadow&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; none&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;  @if&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt; $slot&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; ==&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; focusVisible &lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;    box-shadow&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; 4&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;px&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; blue&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;wrapping-up&quot; tabindex=&quot;-1&quot;&gt;Wrapping up&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/progressively-enhancing-focus-visible/#wrapping-up&quot; aria-label=&quot;Link to Wrapping up&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;I hope this look into &lt;code&gt;:focus-visible&lt;/code&gt; has been helpful!&lt;/p&gt;
&lt;p&gt;If you have thoughts on this post, &lt;a href=&quot;https://twitter.com/isfotis&quot;&gt;you can reach out on Twitter&lt;/a&gt;. I realise that Twitter is not the best place for nuance, so you can use &lt;a href=&quot;https://fotis.xyz/about/#contact&quot;&gt;my other contact info&lt;/a&gt;, if those offer a better medium.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Introducing @svg-use</title>
		<link href="https://fotis.xyz/posts/introducing-svg-use/"/>
		<updated>2024-08-23T00:00:00Z</updated>
		<id>https://fotis.xyz/posts/introducing-svg-use/</id>
		<content type="html">&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;summary&quot; tabindex=&quot;-1&quot;&gt;Summary&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/introducing-svg-use/#summary&quot; aria-label=&quot;Link to Summary&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;This post introduces &lt;a href=&quot;https://github.com/fpapado/svg-use&quot;&gt;@svg-use&lt;/a&gt;, a set of tools and bundler plugins, to ergonomically load SVG files as components, via SVG’s &lt;code&gt;&amp;lt;use href&amp;gt;&lt;/code&gt; mechanism.&lt;/p&gt;
&lt;p&gt;First, we look at the current landscape for embedding SVG icons in JS frontends, and especially React components. For the most part, this involves inlining SVG as JS code (also called SVG-in-JS). We analyse the problem space in order to find the issues that inlining solves, and weigh its costs and benefits.&lt;/p&gt;
&lt;p&gt;After that, we introduce &lt;code&gt;&amp;lt;img src&amp;gt;&lt;/code&gt; and SVG’s &lt;code&gt;&amp;lt;use href&amp;gt;&lt;/code&gt;, and where they fit in the problem space. We introduce the &lt;code&gt;@svg-use&lt;/code&gt; toolchain as a way to make &lt;code&gt;&amp;lt;use href&amp;gt;&lt;/code&gt; more ergonomic, in order to make it competitive with inlining.&lt;/p&gt;
&lt;p&gt;Finally, we look toward the future, and investigate how future web standards might facilitate these patterns.&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;the-core-problem&quot; tabindex=&quot;-1&quot;&gt;The core problem&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/introducing-svg-use/#the-core-problem&quot; aria-label=&quot;Link to The core problem&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;A common technique in the JS (and especially React) ecosystem is converting SVG
icons to components, so that they can be imported by JS code.
One common library for this task is &lt;a href=&quot;https://github.com/gregberge/svgr/&quot;&gt;svgr, by Greg Bergé and contributors&lt;/a&gt;. It provides bundler plugins to facilitate converting SVG to JSX. Let’s call
this approach &lt;strong&gt;SVG-in-JS&lt;/strong&gt;, for the sake of comparison.&lt;/p&gt;
&lt;p&gt;To give a concrete example, SVG-in-JS results in a file like this. Note how the SVG paths and shapes are all inlined:&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha has-word-highlights&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt; SvgComponent&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#EBA0AC;font-style:italic&quot;&gt;props&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; =&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;svg&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; width&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;1em&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; height&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;1em&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; viewBox&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;0 0 48 1&quot;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;...&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;props&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot; class=&quot;highlighted-word&quot;&gt;path&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; d&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;M0 0h48v1H0z&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; fill&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;currentColor&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; fillRule&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;evenodd&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;    {&lt;/span&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;/* and possibly other paths / shapes here */&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;svg&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;export&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; default&lt;/span&gt;&lt;span style=&quot;color:#EBA0AC&quot;&gt; SvgComponent&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The SVG-in-JS approach is contrasted with referencing the SVG as an asset, and
using it in &lt;code&gt;img[src]&lt;/code&gt; or in &lt;code&gt;svg &amp;gt; use[href]&lt;/code&gt;. Before we discuss those approaches, let’s look at what problems SVG-in-JS solves.&lt;/p&gt;
&lt;p&gt;The first problem is &lt;strong&gt;theming&lt;/strong&gt; 🎨. By including the SVG inline, one can use regular
HTML attributes and CSS selectors, and inherit custom properties easily. Most
often, this is done to inherit &lt;code&gt;currentColor&lt;/code&gt;, but other more bespoke custom
properties and theming schemes exist.&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha has-word-highlights&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; SvgComponent &lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;./icon.svg&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt; MyComponent&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; ()&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; =&gt;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;  return&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#F5C2E7&quot;&gt;SvgComponent&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot; class=&quot;highlighted-word&quot;&gt;style&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;color: blue;&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; /&gt;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Another problem is &lt;strong&gt;delivery and portability&lt;/strong&gt; 📦. By lifting SVG into the
realm of JS, it can be loaded via ES modules, same as any other JS code. This is
not a particularly big deal for applications, which typically use bundlers that
are capable of referencing assets in the module graph. However, when it comes to
&lt;strong&gt;shareable libraries&lt;/strong&gt;, this provides a delivery mechanism that works anywhere
that JS is supported, without configuration on behalf of the user. This has
the caveat that you need a JSX runtime, such as React, but then again icon libraries are often published in the context of a certain framework.&lt;/p&gt;
&lt;p&gt;In general, &lt;a href=&quot;https://web.dev/articles/bundling-non-js-resources&quot;&gt;referencing assets (such as images or even CSS) from JS is currently
not standardised&lt;/a&gt;. It is thus hard to ship reusable libraries that depend on
assets, at least in a general way, i.e. one that does not assume a specific bundler.&lt;/p&gt;
&lt;p&gt;While this has been true historically, and there is still no standardisation for asset loading, there is a technique that works with (most) current bundlers and all current web browsers. This is called &lt;a href=&quot;https://web.dev/articles/bundling-non-js-resources#ambiguous_relative_urls&quot;&gt;the “new URL scheme” (web.dev article by Ingvar Stepanyan)&lt;/a&gt;:&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;// This is resolved relative to the JS file, instead of the document&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;// bundlers resolve this as well&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; svgUrl &lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7;font-weight:bold&quot;&gt; new&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt; URL&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&#39;./path/to/svg.svg&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; import&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;meta&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;url)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The above technique only solves the delivery 📦 problem though, and does not solve the theming 🎨 problem.&lt;/p&gt;
&lt;p&gt;The SVG-in-JS approach is thus appealing, because it solves real problems in a
relatively simple way. However, it also comes with some drawbacks.&lt;/p&gt;
&lt;h3&gt;Drawbacks of SVG-in-JS&lt;/h3&gt;
&lt;p&gt;By inlining SVGs in JS, we are incurring a number of runtime costs.&lt;/p&gt;
&lt;p&gt;In short:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Each component’s code is parsed multiple times: first as JS, then as HTML
when inserted into the document. This happens for every instance of the component.&lt;/li&gt;
&lt;li&gt;Each SVG icon is duplicated in the DOM for every instance, bloating
the DOM size.&lt;/li&gt;
&lt;li&gt;The size of the SVG icon adds to the JS bundle size. Some common SVG icons can
be large, for example country flags with intricate designs. On a similar note, it is also easy to &lt;strong&gt;accidentally&lt;/strong&gt; inline large SVGs.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All of the points above lead to a delay in meaningful interactivity metrics. &lt;a href=&quot;https://kurtextrem.de/posts/svg-in-js&quot;&gt;This article by Jacob ‘Kurt’ Groß dives into the different drawbacks of SVG-in-JS, as well as different alternatives.&lt;/a&gt;. I highly recommend reading through that article, to understand the tradeoffs.&lt;/p&gt;
&lt;p&gt;I believe that the runtime costs are big enough for many common cases, to
warrant an alternative.&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;a-first-alternative%3A-%3Cimg-src%3E&quot; tabindex=&quot;-1&quot;&gt;A first alternative: &lt;code&gt;&amp;lt;img src&amp;gt;&lt;/code&gt;&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/introducing-svg-use/#a-first-alternative%3A-%3Cimg-src%3E&quot; aria-label=&quot;Link to A first alternative: &amp;lt;img src&amp;gt;&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;A simple approach would be to use an &lt;code&gt;&amp;lt;img src&amp;gt;&lt;/code&gt;, and evaluate how it stacks up against our criteria.&lt;/p&gt;
&lt;p&gt;We can use images as follows:&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;// Current bundlers resolve the URL to a file (or can be configured to do so)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; iconUrl &lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;./path/to/icon.svg&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;// Both bundlers and browsers can resolve this, as above&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; anotherIconUrl &lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7;font-weight:bold&quot;&gt; new&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt; URL&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&#39;./path/to/svg.svg&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; import&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;meta&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;url)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt; MyComponent&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; ()&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; =&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;img&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; src&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;iconUrl&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; alt&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;img&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; src&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;anotherIconUrl&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; loading&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;lazy&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; alt&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;/&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This solves the delivery 📦 problem effectively, both for applications and shareable libraries (via the new URL scheme). The image itself does not exist in the JS bundle, effectively solving the performance considerations.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;img&lt;/code&gt; element is one of the most robust elements, and provides a bunch of flexibility to tune the end-user delivery, such as &lt;code&gt;loading&lt;/code&gt; and &lt;code&gt;fetchPriority&lt;/code&gt;. The &lt;code&gt;img&lt;/code&gt; element can also load cross-origin resources. I consider the &lt;code&gt;img&lt;/code&gt; element the benchmark, when it comes to delivery.&lt;/p&gt;
&lt;p&gt;Unfortunately, the &lt;code&gt;img&lt;/code&gt; element does not address the theming 🎨 problem at all. There is no inheritance of CSS to speak of, so any colours that are present in the original SVG, are those that will be shown to the end-user.&lt;/p&gt;
&lt;p&gt;Thus, the &lt;code&gt;img&lt;/code&gt; element is useful for multi-color SVGs (such as country flags, which I see inlined quite often :/), but is not very useful for UI icons, that should be flexible and themeable.&lt;/p&gt;
&lt;p&gt;(This might change &lt;a href=&quot;https://fotis.xyz/posts/introducing-svg-use/#the-future&quot;&gt;in the future&lt;/a&gt;; more on that later.)&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;svg%E2%80%99s-%3Cuse-href%3E-mechanism&quot; tabindex=&quot;-1&quot;&gt;SVG’s &lt;code&gt;&amp;lt;use href&amp;gt;&lt;/code&gt; mechanism&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/introducing-svg-use/#svg%E2%80%99s-%3Cuse-href%3E-mechanism&quot; aria-label=&quot;Link to SVG’s &amp;lt;use href&amp;gt; mechanism&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/SVG/Element/use&quot;&gt;SVG provides the &lt;code&gt;&amp;lt;use&amp;gt;&lt;/code&gt; element&lt;/a&gt;,
which can reference same-origin external SVGs via the &lt;code&gt;href&lt;/code&gt; attribute.&lt;/p&gt;
&lt;p&gt;Disregarding JS and React for a moment, if we were to reference an SVG with &lt;code&gt;use&lt;/code&gt; in HTML (the “user code”), it would look like this:&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha has-word-highlights has-counters&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;svg&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot; class=&quot;highlighted-word&quot;&gt;viewBox&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;0 0 24 24&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; xmlns&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;http://www.w3.org/2000/svg&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;use&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; href&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot; class=&quot;highlighted-word&quot;&gt;https://example.com/icon.svg&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot; class=&quot;highlighted-word&quot;&gt;someId&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; style&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot; class=&quot;highlighted-word&quot;&gt;color&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;: blue;&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;use&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;svg&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To make the above work, we need a few moving parts:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;(optional) a &lt;code&gt;viewBox&lt;/code&gt;, to allow intrinsic sizing of the outer &lt;code&gt;svg&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;a &lt;code&gt;url&lt;/code&gt; to reference the external SVG by.&lt;/li&gt;
&lt;li&gt;an &lt;code&gt;id&lt;/code&gt; to reference the external SVG by (while SVG 2 allows referencing without an id, that part does not seem supported in browsers).&lt;/li&gt;
&lt;li&gt;a themeing system, to allow us to customise the referenced SVG. This can be
done with &lt;code&gt;currentColor&lt;/code&gt; (for monochromatic icons) or via CSS custom properties,
which can be inherited by the referenced SVG.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The SVG itself (the “asset”) looks like this. Crucially, it is not inlined into the JS bundle, but exists on its own, similar to the &lt;code&gt;img[src]&lt;/code&gt; example above:&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha has-word-highlights&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;svg&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;  xmlns&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;http://www.w3.org/2000/svg&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot; class=&quot;highlighted-word&quot;&gt;viewBox&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;0 0 24 24&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot; class=&quot;highlighted-word&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;use-href-target&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;  stroke&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot; class=&quot;highlighted-word&quot;&gt;currentColor&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;  fill&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;none&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;  stroke-width&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;2&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;line&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; x1&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;5&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; y1&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;12&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; x2&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;19&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; y2&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;12&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;polyline&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; points&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;12 5 19 12 12 19&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;svg&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The core thesis is that the above setup is desirable in terms of its runtime
characteristics (more on that in a moment), but is more tedious to set up than SVG-in-JS, due to the lack of a dedicated toolchain.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;@svg-use&lt;/code&gt; libraries consider the above structure (the “user code” and the
“asset”) as a compilation target, and provide a toolchain for linking the two
together to your JS code.
Before we talk about the implementation, let’s evaluate this solution against the problem space.&lt;/p&gt;
&lt;h3&gt;Pros and cons of &lt;code&gt;&amp;lt;use href&amp;gt;&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;By referencing an external asset, we are avoiding the double-parsing and JS
bundle size costs; we only need to ship a URL and some metadata to the JS
bundle, as well as a wrapper component (for convenience). We are also reducing the DOM size, since a single &lt;code&gt;use&lt;/code&gt; is smaller than most icons, and involves fewer elements.&lt;/p&gt;
&lt;p&gt;Theming 🎨 is achieved via a transform on the SVG, and can often be as simple as
passing down &lt;code&gt;currentColor&lt;/code&gt;. CSS custom properties and &lt;code&gt;currentColor&lt;/code&gt; are
inherited as expected. The theming transform is done statically, and has no
runtime cost.&lt;/p&gt;
&lt;p&gt;The portability 📦 in this approach is good, because you can use the resulting SVGs directly, and not just in React. You could even write out the &lt;code&gt;&amp;lt;use href&amp;gt;&lt;/code&gt; manually if you wanted, or create your own wrapper component, in your framework
of choice.&lt;/p&gt;
&lt;p&gt;Delivery of shared libraries can be reliable, using the &lt;code&gt;new URL&lt;/code&gt; scheme as a transform target. &lt;a href=&quot;https://github.com/fpapado/svg-use/tree/main/examples/shared-library&quot;&gt;The svg-use repository has a relevant example&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;One downside, in terms of delivery, is the &lt;strong&gt;lack of Cross-Origin Resource Sharing (CORS)&lt;/strong&gt; for SVG &lt;code&gt;&amp;lt;use href&amp;gt;&lt;/code&gt; references. This is a
real issue, that can only be reliably solved at &lt;a href=&quot;https://fotis.xyz/posts/introducing-svg-use/#the-future&quot;&gt;the specification level&lt;/a&gt;.
However, SVG-in-JS is often used for local and shared-library SVG use-cases,
which are hosted on the same origin, so the lack of CORS is not an issue for replacing them.&lt;/p&gt;
&lt;p&gt;In case you use a Content Delivery Network (CDN) for your application assets (including JS an SVG), you need some mechanism to rewrite the URLs at build time or at runtime, to point them to a same-origin proxy. This can be more or less efficient, depending on the implementation, and your threshold for accepting that tradeoff might be different to mine. The default &lt;code&gt;@svg-use/react&lt;/code&gt; components enable this functionality.&lt;/p&gt;
&lt;p&gt;In terms of loading strategies, &lt;code&gt;use&lt;/code&gt; is not as flexible as &lt;code&gt;img&lt;/code&gt;. For example, there is no &lt;code&gt;fetchPriority&lt;/code&gt; or &lt;code&gt;loading&lt;/code&gt; specified. This is about on par with inlining, which is eager (and synchronous) by default, and is made lazy via JS &lt;code&gt;import()&lt;/code&gt; calls and related mechanisms. If you have icons that need to be displayed synchronously, then inlining might be the better approach.&lt;/p&gt;
&lt;p&gt;All that said, there are cases where inlining the SVGs or using &lt;code&gt;img[src]&lt;/code&gt; is
the better or simpler approach, depending on your loading patterns. I do not
claim that the &lt;code&gt;&amp;lt;use href&amp;gt;&lt;/code&gt; pattern solves every scenario, but even if it leads
to half of the SVGs no longer being inlined in JS “by default”, it will be a
good step.&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;the-core-solution-in-%40svg-use&quot; tabindex=&quot;-1&quot;&gt;The core solution in &lt;code&gt;@svg-use&lt;/code&gt;&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/introducing-svg-use/#the-core-solution-in-%40svg-use&quot; aria-label=&quot;Link to The core solution in @svg-use&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;Going back to JS and React, assuming some bundler config (&lt;a href=&quot;https://github.com/fpapado/svg-use/tree/main/packages/webpack&quot;&gt;webpack&lt;/a&gt;, &lt;a href=&quot;https://github.com/fpapado/svg-use/tree/main/packages/rollup&quot;&gt;rollup&lt;/a&gt;, &lt;a href=&quot;https://github.com/fpapado/svg-use/tree/main/packages/vite&quot;&gt;vite&lt;/a&gt;), developers would consume the &lt;code&gt;&amp;lt;use href&amp;gt;&lt;/code&gt; structure like this (assuming some bundler config):&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; Component &lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;as&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; ArrowIcon &lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; from&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;./arrow.svg?svgUse&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt; MyComponent&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; ()&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; =&gt;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;  return&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;      &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#F5C2E7&quot;&gt;ArrowIcon&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; color&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;currentColor&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; role&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;img&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; aria-label&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;Continue&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;  )&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;arrow.svg&lt;/code&gt; SVG is transformed and made compatible with &lt;code&gt;&amp;lt;use href&amp;gt;&lt;/code&gt; automatically.&lt;/p&gt;
&lt;p&gt;Developers can also use reusable libraries, without having to configure their bundler. The libraries use the &lt;code&gt;@svg-use&lt;/code&gt; tools as static transforms, emitting the &lt;code&gt;new URL&lt;/code&gt; pattern for the &lt;code&gt;href&lt;/code&gt; under the hood.&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; ArrowIcon &lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; from&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;my-shared-library&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt; MyComponent&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; ()&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; =&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#F5C2E7&quot;&gt;ArrowIcon&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; color&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;currentColor&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; role&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;img&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; aria-label&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;Continue&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;In depth&lt;/h3&gt;
&lt;p&gt;When you write this:&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;  Component &lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;as&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; ArrowIcon&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;  // not necessary to import; shown for demonstration&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;  href&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;  id&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;  viewBox&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; from&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;./arrow.svg?svgUse&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt; MyComponent&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; ()&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; =&gt;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;  return&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;      &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#F5C2E7&quot;&gt;ArrowIcon&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; color&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;currentColor&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; role&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;img&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; aria-label&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;Continue&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;  )&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;With a source &lt;code&gt;arrow.svg&lt;/code&gt; of:&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;svg&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;  xmlns&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;http://www.w3.org/2000/svg&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;  width&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;24&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;  height&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;24&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;  stroke&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;#111&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;  fill&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;none&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;  stroke-width&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;2&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;line&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; x1&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;5&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; y1&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;12&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; x2&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;19&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; y2&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;12&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;polyline&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; points&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;12 5 19 12 12 19&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;svg&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A bundler-specific plugin starts the following chain:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;The plugin resolves &lt;code&gt;./arrow.svg&lt;/code&gt; relative to the file and invokes
&lt;a href=&quot;https://github.com/fpapado/svg-use/tree/main/packages/core&quot;&gt;&lt;code&gt;@svg-use/core&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Core parses &lt;code&gt;./arrow.svg&lt;/code&gt;, to ensure that it fulfils the invariants&lt;/li&gt;
&lt;li&gt;Core extracts the &lt;code&gt;id&lt;/code&gt; and &lt;code&gt;viewBox&lt;/code&gt; of the top-level SVG element&lt;/li&gt;
&lt;li&gt;Core runs a customisable theming transform to turn the SVG element’s fills and strokes
into configurable CSS custom properties (or &lt;code&gt;currentColor&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Core returns the transformed SVG content, and the extracted information&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The plugin emits the transformed SVG as an asset (using the bundler’s
logic), and resolves its would-be URL.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The plugin passes the URL to Core, to create a JS module. This is what the
userland code ultimately sees.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The module exports the extracted properties, and passes them to a “component
factory”, for convenience.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The plugin passes on the JS module to the bundler.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The transformed SVG asset (&lt;code&gt;/assets/arrow-1234.svg&lt;/code&gt;) is this:&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha has-word-highlights&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;svg&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;  xmlns&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;http://www.w3.org/2000/svg&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot; class=&quot;highlighted-word&quot;&gt;viewBox&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;0 0 24 24&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot; class=&quot;highlighted-word&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;use-href-target&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;  stroke&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot; class=&quot;highlighted-word&quot;&gt;var(--svg-use-href-primary, currentColor)&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;  fill&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;none&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt;  stroke-width&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;2&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;line&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; x1&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;5&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; y1&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;12&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; x2&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;19&quot;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; y2&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;12&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;polyline&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; points&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;12 5 19 12 12 19&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;svg&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The ad-hoc JS module is the equivalent of this:&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-tsx&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; createThemedExternalSvg &lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; from&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;@svg-use/react&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;export&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; const&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; id&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;use-href-target&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;export&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; const&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; href&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7;font-weight:bold&quot;&gt; new&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt; URL&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&#39;/assets/arrow-1234.svg&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; import&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;meta&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;url)&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;href&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;export&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; const&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; viewBox&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;0 0 24 24&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;/* createThemedExternalSvg is a component factory function */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;export&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; const&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; Component&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt; createThemedExternalSvg&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; href&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; id&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; viewBox &lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This approach combines convenience (using &lt;code&gt;Component&lt;/code&gt; directly), with
composition (such as using &lt;code&gt;href&lt;/code&gt; and &lt;code&gt;id&lt;/code&gt; to build your own wrapper
components, using &lt;code&gt;href&lt;/code&gt; for preloading etc.). Refer to &lt;a href=&quot;https://github.com/fpapado/svg-use&quot;&gt;the svg-use repository&lt;/a&gt; for more details on customisations, such as the themeing transform.&lt;/p&gt;
&lt;p&gt;The core utilities are composable and easy to extend. Additionally, type safety and user convenience are key; this should be as (or nearly as) convenient as SVG-in-JS.&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;the-future&quot; tabindex=&quot;-1&quot;&gt;The future&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/introducing-svg-use/#the-future&quot; aria-label=&quot;Link to The future&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;I created &lt;code&gt;@svg-use&lt;/code&gt; because I saw a gap in the tooling for adopting the &lt;code&gt;&amp;lt;svg use&amp;gt;&lt;/code&gt; pattern, in a contemporary JS context. However, &lt;strong&gt;my dream is that web standards will pick up some of the rough edges, so that this library will eventually become obsolete (or simply nice-to-have)&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Here are some proposals that I am aware of, that could change the calculus around this library. I am ordering them from “nice to have” to “existential”.&lt;/p&gt;
&lt;h3&gt;JS import attributes&lt;/h3&gt;
&lt;p&gt;JavaScript supports &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import/with&quot;&gt;import attributes&lt;/a&gt;, which allow passing metadata about how a module should be loaded.&lt;/p&gt;
&lt;p&gt;In the previous example, you might have noticed a pesky &lt;code&gt;?svgUse&lt;/code&gt; query parameter suffix in the import. This is used to disambiguate the loading of SVGs in bundlers, between those that use &lt;code&gt;@svg-use&lt;/code&gt; and others.&lt;/p&gt;
&lt;p&gt;Import attributes would make it marginally nicer to write imports:&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; Component &lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;as&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; Arrow &lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; from&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;./arrow.svg?svgUse&amp;#x26;theme=none&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; Component &lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;as&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; Arrow2 &lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; from&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;./arrow-2.svg&#39;&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; with&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; type&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;svgUse&#39;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;, theme&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;none&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; };&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;a href=&quot;https://caniuse.com/?search=import%20attributes&quot;&gt;Import attributes exist in current browsers, except Firefox&lt;/a&gt;. This is not a big deal, because bundlers can transpile them away, and just pass the metadata to the plugins.&lt;/p&gt;
&lt;p&gt;However, I am avoiding them because &lt;a href=&quot;https://github.com/microsoft/TypeScript/issues/46135&quot;&gt;TypeScript does not yet expose type declarations based on import attributes&lt;/a&gt;. Thus, to get type-safety, we still &lt;a href=&quot;https://github.com/fpapado/svg-use/tree/main/packages/webpack#optional-configure-typescript&quot;&gt;use the string-based approach, on the module name&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Do give your thoughts on &lt;a href=&quot;https://github.com/microsoft/TypeScript/issues/46135&quot;&gt;the tracking issue&lt;/a&gt;, if you have them!&lt;/p&gt;
&lt;h3&gt;JS asset references&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;new URL&lt;/code&gt; pattern is neat for referencing relative assets, but it works mostly based on convention. Bundlers treat this as special syntax for resolving assets, but I would love a more concrete syntactic construct, to avoid ambiguities. For example, &lt;a href=&quot;https://github.com/evanw/esbuild/issues/795&quot;&gt;esbuild does not support the new URL pattern&lt;/a&gt;, with some concerns around standardisation.&lt;/p&gt;
&lt;p&gt;There was (is?) &lt;a href=&quot;https://github.com/tc39/proposal-asset-references&quot;&gt;a proposal for asset references in JavaScript&lt;/a&gt;, but it seems to have stalled. Also, it seems to have been written at a time when import attributes did not exist, but I might be wrong.&lt;/p&gt;
&lt;p&gt;There is some other work being done around imports, such as &lt;a href=&quot;https://github.com/tc39/proposal-source-phase-imports&quot;&gt;source phase imports&lt;/a&gt;. While that does not help with assets by itself, I have a gut feeling that the renewed interest in ES loading mechanisms could lead to a proposal for assets down the line.&lt;/p&gt;
&lt;h4&gt;References with &lt;code&gt;import.meta.resolve&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;On the topic of more clear syntactic markers for resolving relative paths, there is &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import.meta/resolve&quot;&gt;the &lt;code&gt;import.meta.resolve&lt;/code&gt; built-in function&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This function resolves a module specifier to a URL, with the current module URL as a base. The resolved URL does not &lt;em&gt;have to&lt;/em&gt; resolve to an actual module, which means we can just as easily reference non-JS assets.&lt;/p&gt;
&lt;p&gt;In other words, these two invocations would be equivalent:&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; assetPath &lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7;font-weight:bold&quot;&gt; new&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt; URL&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&#39;./arrow.svg&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; import&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;meta&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;url)&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;href&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; assetPath2 &lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; import&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;meta&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;resolve&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&#39;./arrow.svg&#39;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import.meta/resolve#comparison_with_new_url&quot;&gt;There are some other subtleties when it comes to resolving bare module specifiers&lt;/a&gt;, but that does not make a difference for our use-case. &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import.meta/resolve#comparison_with_new_url&quot;&gt;Browser support for import.meta.resolve&lt;/a&gt; is not as wide as &lt;code&gt;new URL&lt;/code&gt;, but is still widely supported in current browsers.&lt;/p&gt;
&lt;p&gt;My gut feeling is that &lt;code&gt;import.meta.resolve&lt;/code&gt; could replace &lt;code&gt;new URL&lt;/code&gt; as the build target for &lt;code&gt;svg-use&lt;/code&gt; in the near future, because it seems like a clearer signal of an import dependency. I’m eager to see what bundlers and non-browser environments do with this.&lt;/p&gt;
&lt;h3&gt;SVG crossorigin use&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/w3c/svgwg/issues/707&quot;&gt;If SVG supported crossorigin usage&lt;/a&gt;, then
shipping shared icon libraries on CDNs would be much simpler, without having to
proxy/rewrite the URLs (and avoiding breaking things accidentally). This seems to have stalled, but I might be wrong.&lt;/p&gt;
&lt;h3&gt;SVG 2: referencing SVGs without an id fragment&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://www.w3.org/TR/SVG2/struct.html#UseElement&quot;&gt;According to SVG 2&lt;/a&gt;, you could do this:&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;svg&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;use&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; href&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&quot;arrow.svg&quot;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;use&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#89B4FA&quot;&gt;svg&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;…and have it reference the top-most SVG. This seems specified, but not
implemented.&lt;/p&gt;
&lt;p&gt;This would simplify the need for an &lt;code&gt;id&lt;/code&gt;, and extracting it statically.&lt;/p&gt;
&lt;h3&gt;CSS Linked Parameters&lt;/h3&gt;
&lt;p&gt;If &lt;a href=&quot;https://drafts.csswg.org/css-link-params/&quot;&gt;CSS Linked Parameters&lt;/a&gt; lands, we will be able to pass custom properties to SVGs inside of &lt;code&gt;img[src]&lt;/code&gt;. (I am omitting the syntax, because it is in flux).&lt;/p&gt;
&lt;p&gt;This avoids the setup with &lt;code&gt;svg &amp;gt; use[href]&lt;/code&gt;, in favour of the much simpler
&lt;code&gt;img&lt;/code&gt; element. As mentioned previously, &lt;a href=&quot;https://fotis.xyz/posts/introducing-svg-use/#a-first-alternative%3A-%3Cimg-href%3E&quot;&gt;the &lt;code&gt;img&lt;/code&gt; element is really robust in terms of loading and delivery&lt;/a&gt;. It can already be loaded cross-origin, so this possibly avoids the CDN issues. Since an SVG &lt;code&gt;img&lt;/code&gt; is displayed as a whole, this also avoids the &lt;code&gt;id&lt;/code&gt; issue.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;This is the most promising proposal&lt;/strong&gt;. If it lands in browsers, then this
library will mostly be useful for two things: themeing (taking an ad-hoc &lt;code&gt;svg&lt;/code&gt;
and bringing it into a system), and extracting the intrinsic aspect ratio (the
&lt;code&gt;viewBox&lt;/code&gt;, essentially). The wrappers will adjust their internals, but will
likely not need to change their external interface (hooray!)&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/w3c/csswg-drafts/issues/9872&quot;&gt;This GitHub issue by Lea Verou has more details around CSS Linked Parameters and icons&lt;/a&gt;.&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;wrapping-up&quot; tabindex=&quot;-1&quot;&gt;Wrapping up&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/introducing-svg-use/#wrapping-up&quot; aria-label=&quot;Link to Wrapping up&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;We covered a lot of ground in this post!&lt;/p&gt;
&lt;p&gt;As a summary, we looked at the challenges of delivering assets in JS, specifically the delivery of SVG icons. We looked SVG-in-JS techniques, and weighed their pros and cons, in terms of delivery, theming, ergonomics, and runtime performance. We then looked at the alternatives of &lt;code&gt;&amp;lt;img href&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;use href&amp;gt;&lt;/code&gt;, with a similar lens.&lt;/p&gt;
&lt;p&gt;Finally, we introduced &lt;code&gt;@svg-use&lt;/code&gt;, a toolchain to make the &lt;code&gt;&amp;lt;use href&amp;gt;&lt;/code&gt; pattern more ergonomic and consistent. We also looked at future web specification developments, that could change the calculus around these patterns.&lt;/p&gt;
&lt;p&gt;Please get in touch if you have thoughts about all of this! I am especially interested to hear your use-cases in your applications, and any rough edges that you might spot.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/fpapado/svg-use&quot;&gt;Head on over to the svg-use repository to get started&lt;/a&gt;. Happy coding!&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>The new Cookie Store API</title>
		<link href="https://fotis.xyz/posts/the-new-cookie-store-api/"/>
		<updated>2025-04-14T00:00:00Z</updated>
		<id>https://fotis.xyz/posts/the-new-cookie-store-api/</id>
		<content type="html">&lt;p&gt;Historically, in a browser, programmatic access to cookies has revolved around the &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie&quot;&gt;document.cookie&lt;/a&gt; API, which is simply a string getter/setter. To read a single cookie from that string, you must parse the whole string into a structured format. To write a single cookie to that string, you would have the cookie in a structured format and serialise it to a string, prior to setting &lt;code&gt;document.cookie&lt;/code&gt;. &lt;a href=&quot;https://www.npmjs.com/package/js-cookie&quot;&gt;There are popular npm libraries to make this dance more ergonomic, such as &lt;code&gt;js-cookie&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;However, custom libraries still come at a performance cost. There are still parsing and serialisation costs to pay, and my understanding is that these costs increase as the cookie string becomes larger. I would also note that &lt;code&gt;document.cookie&lt;/code&gt; access is &lt;em&gt;synchronous&lt;/em&gt;. If it ends up in a particularly hot loop, it could impact main thread responsiveness.&lt;/p&gt;
&lt;p&gt;Finally, there has been no single way to keep the cookie string as the source of truth for managing state, because there are no associated change events. This becomes relevant in real-world applications, that might be syncing various system-wide and app-specific user preferences via cookies.&lt;/p&gt;
&lt;p&gt;While this has been true historically, there is a new &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/Cookie_Store_API&quot;&gt;Cookie Store API&lt;/a&gt; in browsers nowadays, that allows structured manipulation of cookies, in a performant way. I say “new”, even though it has existed in Chromium-based browsers for the past 4 years. However, with &lt;a href=&quot;https://developer.apple.com/documentation/safari-release-notes/safari-18_4-release-notes#:~:text=Added%20support%20for%20the%20Cookie%20Store%20API&quot;&gt;Safari 18.4&lt;/a&gt; landing support at the end of March 2025, there are now two browsers shaping this API, making me more comfortable using it as a progressive enhancement.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/mdn/browser-compat-data/issues/26374&quot;&gt;Firefox 137&lt;/a&gt; also seems to support this API, but I was not able to use &lt;code&gt;cookieStore&lt;/code&gt; in my tests on Firefox 137.0.1 (aarch64). It might be landing in Firefox 138 instead.&lt;/p&gt;
&lt;p&gt;Here is the caniuse support table, for reference:&lt;/p&gt;
&lt;p class=&quot;ciu_embed&quot; data-feature=&quot;cookie-store-api&quot; data-periods=&quot;future_1,current,past_1,past_2&quot; data-accessible-colours=&quot;true&quot;&gt;
&lt;picture&gt;
&lt;source type=&quot;image/webp&quot; srcset=&quot;https://caniuse.bitsofco.de/image/cookie-store-api.webp&quot; /&gt;
&lt;source type=&quot;image/png&quot; srcset=&quot;https://caniuse.bitsofco.de/image/cookie-store-api.png&quot; /&gt;
&lt;img src=&quot;https://caniuse.bitsofco.de/image/cookie-store-api.jpg&quot; alt=&quot;Data on support for the cookie-store-api feature across the major browsers from caniuse.com&quot; /&gt;
&lt;/picture&gt;
&lt;/p&gt;
&lt;script src=&quot;https://cdn.jsdelivr.net/gh/ireade/caniuse-embed/public/caniuse-embed.min.js&quot;&gt;&lt;/script&gt;
&lt;p&gt;I see three main benefits to such an API:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;performance (asynchronous access, less serialisation back-and-forth, smaller bundle size)&lt;/li&gt;
&lt;li&gt;using the cookie store directly for state management, avoiding synchronisation bugs&lt;/li&gt;
&lt;li&gt;standardisation as a way to build shared (cookie) SDKs with less per-library variance.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Let’s dive into each of these!&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;how-to-use-it&quot; tabindex=&quot;-1&quot;&gt;How to use it&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/the-new-cookie-store-api/#how-to-use-it&quot; aria-label=&quot;Link to How to use it&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/Cookie_Store_API&quot;&gt;MDN has the goods when it comes to documentation&lt;/a&gt;, but here is a brief example of using &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/CookieStore&quot;&gt;cookieStore&lt;/a&gt;:&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-ts&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;async&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt; setDarkModePreference&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;  try&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;    await&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; cookieStore&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;set&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&#39;theme&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;dark&#39;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;  }&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; catch&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; (err) &lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;    // a nice benefit of the Cookie Store API is immediate errors,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;    // instead of needing to round-trip writing and reading&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;async&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt; resetThemePreference&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;  return&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; cookieStore&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;delete&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&#39;theme&#39;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that all the methods of the &lt;code&gt;CookieStore&lt;/code&gt; interface are asynchronous.&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;part-1%3A-performance&quot; tabindex=&quot;-1&quot;&gt;Part 1: Performance&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/the-new-cookie-store-api/#part-1%3A-performance&quot; aria-label=&quot;Link to Part 1: Performance&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;The string-based interface of &lt;code&gt;document.cookie&lt;/code&gt; is awkward to work with, with a fair amount of back-and-forth from strings to more structured representations. Parsing the cookie string is not trivial, but we can assume that shared ecosystem libraries follow the spec, and are well-tested and fuzzed.&lt;/p&gt;
&lt;p&gt;Libraries can make optimisations, such as exiting early when they find the relevant cookie in the string. &lt;a href=&quot;https://github.com/js-cookie/js-cookie/blob/main/src/api.mjs&quot;&gt;I am a fan of the &lt;code&gt;js-cookie&lt;/code&gt; library, plus their source code makes for a nice read&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Even with optimisations, access to &lt;code&gt;document.cookie&lt;/code&gt; is synchronous. If it ends up in a particularly hot loop, it could impact main thread responsiveness.&lt;/p&gt;
&lt;p&gt;There is also the impact to the bundle size of an application, though &lt;a href=&quot;https://bundlephobia.com/package/js-cookie@3.0.5&quot;&gt;&lt;code&gt;js-cookie&lt;/code&gt; specifically is tiny, at 780B min+gzip&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Overall, a native, async-first way to manipulate cookies would make for a nice performance improvement, even compared to optimised ecosystem libraries.&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;part-2%3A-cookie-state-management&quot; tabindex=&quot;-1&quot;&gt;Part 2: Cookie State Management&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/the-new-cookie-store-api/#part-2%3A-cookie-state-management&quot; aria-label=&quot;Link to Part 2: Cookie State Management&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;While I am a fan of the asynchronous access and the reduced bundle size, I am an even bigger fan of the ‘change’ even that Cookie Store provides:&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-ts&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;cookieStore&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;addEventListener&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&#39;change&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#EBA0AC;font-style:italic&quot;&gt;event&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; =&gt;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;  console&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;log&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(event)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/CookieChangeEvent/CookieChangeEvent&quot;&gt;Here is the reference for CookieChangeEvent&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Imagine we have a web app that allows users to store their site-specific theme preference: &lt;code&gt;light&lt;/code&gt;, &lt;code&gt;dark&lt;/code&gt; and &lt;code&gt;auto&lt;/code&gt; (meaning that it defers to system settings). When the user selects their preference, we want to persist it in a cookie, so that subsequent visits from the server get the correct theme by default. At the same time, different parts of the application might consult the theme mode in JS. How would we ensure that we have a single source of truth?&lt;/p&gt;
&lt;p&gt;Since different parts of the application are interested in the theme information, that state has to be kept somewhere centrally. Ideally, we would have the browser manage the state, since the browser keeps the cookies in the first place. However, the &lt;code&gt;document.cookie&lt;/code&gt; API does not expose a change event, so any part of the UI other than the one making the change would not be able to react to it.&lt;/p&gt;
&lt;p&gt;The next best thing we could do is to manage a mirror of the state ourselves, and make changes through a single blessed setter. In React terms, we could keep a custom Context, either for all cookie values or for a specific one. Here is a sketch for a theme cookie specifically:&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-tsx&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; Cookie &lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;from&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;js-cookie&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; type&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; PropsWithChildren &lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; from&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;react&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;  useCallback&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;  createContext&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;  useContext&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;  useEffect&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;  useMemo&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;  useState&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; from&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;react&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; THEME_COOKIE_NAME&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;theme&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF;font-style:italic&quot;&gt; Theme &lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1;font-style:italic&quot;&gt;light&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&#39;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; |&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1;font-style:italic&quot;&gt;dark&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&#39;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; |&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1;font-style:italic&quot;&gt;auto&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;// Like a setState tuple&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF;font-style:italic&quot;&gt; ContextValue &lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF;font-style:italic&quot;&gt; [Theme&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#EBA0AC;font-style:italic&quot;&gt;theme&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF;font-style:italic&quot;&gt; Theme&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; =&gt;&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; void&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF;font-style:italic&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; ThemeContext&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt; createContext&lt;/span&gt;&lt;span style=&quot;color:#89DCEB&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF;font-style:italic&quot;&gt;ContextValue &lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;|&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF;font-style:italic&quot;&gt; undefined&lt;/span&gt;&lt;span style=&quot;color:#89DCEB&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F38BA8&quot;&gt;undefined&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;export&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt; useThemeState&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; ctx&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt; useContext&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(ThemeContext)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;  if&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;ctx) &lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;    throw&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7;font-weight:bold&quot;&gt; new&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt; Error&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&#39;useThemeState must be used in a ThemeManager tree&#39;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;  return&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; ctx&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;export&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt; ThemeManager&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;({&lt;/span&gt;&lt;span style=&quot;color:#EBA0AC;font-style:italic&quot;&gt; children&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; }&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF;font-style:italic&quot;&gt; PropsWithChildren&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt;theme&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; setStoredTheme&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt; useState&lt;/span&gt;&lt;span style=&quot;color:#89DCEB&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF;font-style:italic&quot;&gt;Theme&lt;/span&gt;&lt;span style=&quot;color:#89DCEB&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;  useEffect&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; =&gt;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;    // NOTE: this is incomplete; in reality you might use a one-off useSyncExternalStore and should also do validation&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;    setStoredTheme&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(Cookie&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt;THEME_COOKIE_NAME&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;))&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;  },&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; [setStoredTheme])&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; setTheme&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt; useCallback&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;    (&lt;/span&gt;&lt;span style=&quot;color:#EBA0AC;font-style:italic&quot;&gt;theme&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF;font-style:italic&quot;&gt; Theme&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; =&gt;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;      Cookie&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;set&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt;THEME_COOKIE_NAME&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; theme)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;      setStoredTheme&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(theme)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;    },&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;    [setStoredTheme]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;  )&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; memoValue&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt; useMemo&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; =&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; [theme&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; setTheme]&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; [theme&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; setTheme])&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;  return&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;    &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#F5C2E7&quot;&gt;ThemeContext.Provider&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; value&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;memoValue&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;children&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#F5C2E7&quot;&gt;ThemeContext.Provider&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;  )&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Modulo some implementation details, this works! After the initial setup, I do not find the mirroring to be a big deal (the React state has to live &lt;em&gt;somewhere&lt;/em&gt; after all), but the opportunity for state to go out of sync worries me from time to time.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;We can now do a bit better, by using the change event&lt;/strong&gt;. Since there is a complete set of APIs to read, write and be notified of changes, we could use React’s built-in syncing mechanisms:&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-tsx&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; useCallback&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; useEffect&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; useState &lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; from&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;react&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; THEME_COOKIE_NAME&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;theme&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF;font-style:italic&quot;&gt; Theme &lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1;font-style:italic&quot;&gt;light&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&#39;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; |&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1;font-style:italic&quot;&gt;dark&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&#39;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; |&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1;font-style:italic&quot;&gt;auto&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;export&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt; useThemeState&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;  // An SSR/hydration snapshot is left as an exercise for the reader&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt;theme&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; setStoredTheme&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt; useState&lt;/span&gt;&lt;span style=&quot;color:#89DCEB&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF;font-style:italic&quot;&gt;Theme &lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;|&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF;font-style:italic&quot;&gt; undefined&lt;/span&gt;&lt;span style=&quot;color:#89DCEB&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F38BA8&quot;&gt;undefined&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; onChange&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt; useCallback&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;    (&lt;/span&gt;&lt;span style=&quot;color:#EBA0AC;font-style:italic&quot;&gt;ev&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF;font-style:italic&quot;&gt; CookieChangeEvent&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; =&gt;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;      const&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; deleted&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; ev&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;deleted&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;find&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#EBA0AC;font-style:italic&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; =&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;name &lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;===&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; THEME_COOKIE_NAME&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;      if&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; (deleted) &lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;        setStoredTheme&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F38BA8&quot;&gt;undefined&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;        return&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;      }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;      const&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; changed&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; ev&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;changed&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;find&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#EBA0AC;font-style:italic&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; =&gt;&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; c&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;name &lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;===&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; THEME_COOKIE_NAME&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;      if&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; (changed) &lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;        setStoredTheme&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(changed&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;value)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;        return&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;      }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;    },&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;    [setStoredTheme]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;  )&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;  useEffect&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; =&gt;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;    cookieStore&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;addEventListener&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&#39;change&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; onChange)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;    return&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; ()&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; =&gt;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;      cookieStore&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;removeEventListener&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&#39;change&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; onChange)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;    };&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;  },&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; [onChange])&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; setTheme&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt; useCallback&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#EBA0AC;font-style:italic&quot;&gt;theme&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF;font-style:italic&quot;&gt; Theme&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; =&gt;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;    cookieStore&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;set&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt;THEME_COOKIE_NAME&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; theme)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;  },&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; [])&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;  return&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; [theme&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; setTheme]&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This allows us to get rid of the context, using cookieStore directly. I initially wanted to use &lt;a href=&quot;https://react.dev/reference/react/useSyncExternalStore&quot;&gt;useSyncExternalStore&lt;/a&gt;, as that would allow ditching the extra &lt;code&gt;useState&lt;/code&gt; altogether. However, &lt;code&gt;useSyncExternalStore&lt;/code&gt; would not take the new value from the change event, but rather from a separate &lt;code&gt;cookieStore.get&lt;/code&gt; call. But since the latter is asynchronous, this does not match the sync requirement of the snapshot function that React expects.&lt;/p&gt;
&lt;p&gt;(A harebrained idea would be to use the synchronous &lt;code&gt;document.cookie&lt;/code&gt; API for the &lt;code&gt;useSyncExternalStore&lt;/code&gt; snapshot, but ehh, I’m not a big fan of mixing the two APIs, given the interop and performance points.)&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;intermission%3A-adopting-cookiestore-api-today&quot; tabindex=&quot;-1&quot;&gt;Intermission: Adopting CookieStore API Today&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/the-new-cookie-store-api/#intermission%3A-adopting-cookiestore-api-today&quot; aria-label=&quot;Link to Intermission: Adopting CookieStore API Today&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;You might be wondering how you can use this API if it is not supported everywhere yet.&lt;/p&gt;
&lt;p&gt;As shown in the theme mode example, it is likely that your application already has a centralised point that mirrors cookie state, and changes are usually tied to user actions. In those cases, you could use the &lt;code&gt;CookieStore&lt;/code&gt; API where available, falling back to your favourite JS userland implementation (like &lt;code&gt;js-cookie&lt;/code&gt;) plus local state management.&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-tsx&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;// It seems reasonable to assume that support for the CookieStore API&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;// is a property of the environment, and we do not need to react dynamically to it :)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; supportsCookieStore&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;cookieStore&#39;&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; in&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; window&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt; ThemeManagerUserland&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; ({&lt;/span&gt;&lt;span style=&quot;color:#EBA0AC;font-style:italic&quot;&gt; children&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; })&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; =&gt;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;  // Does internal book-keeping of the state, as shown previously&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;  return&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#F5C2E7&quot;&gt;ThemeProvider&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; value&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;memoValue&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;children&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#F5C2E7&quot;&gt;ThemeProvider&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;};&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt; ThemeManagerNative&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; ({&lt;/span&gt;&lt;span style=&quot;color:#EBA0AC;font-style:italic&quot;&gt; children&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; })&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; =&gt;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2;font-style:italic&quot;&gt;  // Keeps state backed by cookieStore change events, and passes on the setter&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;  return&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; &amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#F5C2E7&quot;&gt;ThemeProvider&lt;/span&gt;&lt;span style=&quot;color:#F9E2AF&quot;&gt; value&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;memoValue&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;children&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#F5C2E7&quot;&gt;ThemeProvider&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;};&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;export&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; const&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; ThemeManager&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; supportsCookieStore&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  ?&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; ThemeManagerNative&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;  :&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; ThemeManagerUserland&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You might decide to split the hook or fork the logic internally, instead of splitting the providers. It really is up to you and your preferences / what is idiomatic in your application.&lt;/p&gt;
&lt;p&gt;For one-off manipulation of cookies, you can still fall back to a userland implementation, but bear in mind that your call-sites might have to change to be asynchronous, given that the CookieStore API is asynchronous all the way,&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-ts&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; setCookie &lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;as&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; setCookieFallback &lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; from&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;my-favorite-cookie-library&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;export&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; async&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt; setCookie&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#EBA0AC;font-style:italic&quot;&gt;cookie&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; string&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#EBA0AC;font-style:italic&quot;&gt; value&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; string&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;  if&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt;&#39;cookieStore&#39;&lt;/span&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt; in&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; window) &lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;    return&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; cookieStore&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;set&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(cookie&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; value)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;  setCookieFallback&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(cookie&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt; value)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CBA6F7&quot;&gt;  return&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Feel free to make this interface whatever you wish; I made it &lt;code&gt;(string, string)&lt;/code&gt; for the sake of a simple example. The full Cookie Store API also provides a more structured way to set cookies than just a key and a value, via &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/CookieStore/set#options&quot;&gt;an option argument&lt;/a&gt;:&lt;/p&gt;
&lt;pre class=&quot;shiki catppuccin-mocha&quot; style=&quot;background-color:#1e1e2e;color:#cdd6f4&quot;&gt;&lt;code class=&quot;language-ts&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;cookieStore&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#89B4FA;font-style:italic&quot;&gt;set&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;  name&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;theme&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;  value&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;dark&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;  path&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;/&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;  partitioned&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FAB387&quot;&gt; false&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;  sameSite&lt;/span&gt;&lt;span style=&quot;color:#94E2D5&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#A6E3A1&quot;&gt; &#39;strict&#39;&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color:#CDD6F4&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#9399B2&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You would tweak your fallback function interface to account for this form as well, if you need it.&lt;/p&gt;
&lt;p&gt;There are no TypeScript types for the Cookie Store API yet. TypeScript only adds an API to the shared dom types once it is supported by all major browsers, which I find reasonable. Now that Chrome, Safari and Firefox support the API, I’m hoping for the types to be added soon. A good opportunity for an issue and a PR, perhaps…&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;part-3%3A-standardisation&quot; tabindex=&quot;-1&quot;&gt;Part 3: Standardisation&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/the-new-cookie-store-api/#part-3%3A-standardisation&quot; aria-label=&quot;Link to Part 3: Standardisation&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;Finally, one of the last benefits of standardisation, is the process of standardising itself! You might have a family of websites under a shared domain, that all manipulate the same set of cookies. You might decide to make an SDK to share that logic, for example to always validate the cookies values.&lt;/p&gt;
&lt;p&gt;If you use a userland library for this task, you will have to make decisions about the encoding of values (or have the library make them for you). In turn, this might hurt interop with other libraries. For example, &lt;code&gt;js-cookie&lt;/code&gt; spells this out:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;This project is &lt;a href=&quot;http://tools.ietf.org/html/rfc6265#section-4.1.1&quot;&gt;RFC 6265&lt;/a&gt; compliant. All special characters that are not allowed in the cookie-name or cookie-value are encoded with each one’s UTF-8 Hex equivalent using &lt;a href=&quot;http://en.wikipedia.org/wiki/Percent-encoding&quot;&gt;percent-encoding&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The only character in cookie-name or cookie-value that is allowed and still encoded is the percent &lt;code&gt;%&lt;/code&gt; character, it is escaped in order to interpret percent input as literal.&lt;/p&gt;
&lt;p&gt;Please note that the default encoding/decoding strategy is meant to be interoperable &lt;a href=&quot;https://github.com/js-cookie/js-cookie/pull/200#discussion_r63270778&quot;&gt;only between cookies that are read/written by js-cookie&lt;/a&gt;. To override the default encoding/decoding strategy you need to use a converter.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;By using the standard API, you would use the agreed-upon behaviour, whichever it might be. Callers could rely upon that behavior with confidence. I’ll admit that I have not tested how exactly the Cookie Store API does value encoding (yet).&lt;/p&gt;
&lt;p&gt;Depending on your state management and the scope of such an SDK, you might expose specific hooks to notify your application of cookie changes. Instead, you could rely on the standard &lt;code&gt;CookieChangeEvent&lt;/code&gt; to notify the application, simplifying the integration with the SDK.&lt;/p&gt;
&lt;p&gt;It’s good to imagine the future, though I recognise that until adoption is reliably wide, such SDKs will likely paper over the &lt;code&gt;document.cookie&lt;/code&gt; and Cookie Store APIs internally, and not rely on it externally.&lt;/p&gt;
&lt;div class=&quot;heading-with-anchor&quot;&gt;&lt;h2 id=&quot;wrapping-up&quot; tabindex=&quot;-1&quot;&gt;Wrapping up&lt;/h2&gt;
&lt;a class=&quot;header-anchor&quot; href=&quot;https://fotis.xyz/posts/the-new-cookie-store-api/#wrapping-up&quot; aria-label=&quot;Link to Wrapping up&quot;&gt;&lt;svg aria-hidden=&quot;true&quot; width=&quot;1em&quot; height=&quot;1em&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot;&gt;
  &lt;use href=&quot;/img/link.svg#link&quot;&gt;&lt;/use&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;We looked at some of the current ergonomic and performance issues of the &lt;code&gt;document.cookie&lt;/code&gt; API, and introduced the Cookie Store API as a contemporary alternative. We looked at some semi-realistic examples of how cookie manipulation fits with state management in applications, and also imagined what a standard Cookie Store API could mean for the future.&lt;/p&gt;
&lt;p&gt;I hope this gives you enough to experiment with; please get in touch if you have thoughts! I am especially interested to hear use-cases in your applications, and how adoption might look for what you are building.&lt;/p&gt;
</content>
	</entry>
</feed>
