<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Rebecca Davidsson on Medium]]></title>
        <description><![CDATA[Stories by Rebecca Davidsson on Medium]]></description>
        <link>https://medium.com/@rebeccadavidsson3?source=rss-714811c5cb7f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*w2j-7xbWNsmsMIBo0pz47Q.jpeg</url>
            <title>Stories by Rebecca Davidsson on Medium</title>
            <link>https://medium.com/@rebeccadavidsson3?source=rss-714811c5cb7f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 00:54:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rebeccadavidsson3/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[JavaScript-Free Dialogs and Popovers with New Invoker Commands]]></title>
            <link>https://medium.com/@rebeccadavidsson3/javascript-free-dialogs-and-popovers-with-new-invoker-commands-ee5265fd8cf4?source=rss-714811c5cb7f------2</link>
            <guid isPermaLink="false">https://medium.com/p/ee5265fd8cf4</guid>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[html]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[frontend-development]]></category>
            <dc:creator><![CDATA[Rebecca Davidsson]]></dc:creator>
            <pubDate>Wed, 16 Oct 2024 11:22:15 GMT</pubDate>
            <atom:updated>2024-10-22T10:47:16.180Z</atom:updated>
            <content:encoded><![CDATA[<p>Many simple interactions, like opening popups, dialogs, or controlling media, traditionally require JavaScript, adding complexity and potential bugs. The <strong>Invoker Commands API</strong> is a new, experimental feature in HTML that allows you to control interactions in an accessible way with elements like dialogs, popovers, and even video controls without writing any JavaScript.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KEtHqzBrMaQVFkY0iRFsxQ.png" /></figure><p>⚠️Warning! This is an experimental feature still in development. If you want to give it a try yourself, you can enable the Experimental Web Platform features after going to chrome://flags in Chrome Canary.</p><h4>Why should you care about Invoker Commands?</h4><p>In short: using invoker commands lets you delete some legacy JavaScript! Using this functionality enables you to, for example, open a popup or implement a counter without writing any JavaScript. Overall, invoker commands solve multiple problems by:</p><ul><li><strong>Reducing JavaScript Dependence</strong>: Handles interactions like opening dialogs or popovers with HTML attributes, cutting down the need for JavaScript.</li><li><strong>Improving Accessibility</strong>: Automatically adds ARIA attributes and manages focus, simplifying accessible design.</li><li><strong>Minimizing Code Complexity</strong>: Less code means easier debugging and maintenance.</li><li><strong>Boosting Performance</strong>: Fewer scripts lead to faster page loads.</li></ul><h4>How does it work?</h4><p>You add special attributes to your HTML elements, commandfor and command. The commandfor attribute links an element to the element you want to control. The command attribute tells the Invoker what to do. <br>In the example below, you only need these three lines, no JavaScript required:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nb861gimlMRVTEAwf36CyA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*WstsSwjILf1mvwZqan8Vhw.gif" /></figure><p>The commandfor references to the id of the button, and the command specifies the action for the related element.</p><h4>Popovers and dialogs</h4><p>The OpenUI working group initially started with this functionality for popover and dialog elements, making it very easy to open and close a dialog without any JavaScript and in an accessible way, like this dialog:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uyXVO3GnprjwDWH19BwovQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*Zm0J1T0YW5wc6wol7HGshA.gif" /></figure><p>For popovers it works out of the box too. Here you can use the new <a href="https://developer.mozilla.org/en-US/docs/Web/API/Popover_API"><strong>Popover API</strong></a> that lets you create a popover by adding the popover attribute to your element. By using the popovertarget attribute, you can tell the browser that if a button is interacted with, it should open the element linked by the popovertarget value. This enables accessible and reliable popovers, eliminating the need for extra JavaScript. For example:</p><pre>&lt;button popovertarget=&quot;popover1&quot;&gt;Open Popover&lt;/button&gt;<br>&lt;div id=&quot;popover1&quot; popover&gt;Some popover content...&lt;/div&gt;</pre><p>While the popovertarget attribute works well for popovers, it doesn&#39;t extend the same benefits to other interactive elements like &lt;dialog&gt;, &lt;details&gt;, &lt;video&gt;, or &lt;input type=&quot;file&quot;&gt;. The invoker commands API attempts to support for such elements, allowing for a consistent, JavaScript-free experience across more interactive elements, like this example below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qnfErL0-_dTCKmO4tyUWaw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*GAN9TS-NQSf0cbVri0virQ.gif" /></figure><p><em>Sidenote</em>: I added some anchor-position styling here on the popover to give it a position under the button. In combination with @position-try , you can easily get more control over the resposiveness and position of your popup. Do check out the CSS anchor-position property if you haven’t used it yet.</p><h4>Custom commands</h4><p>If you want to make your own custom commands, you can! Start them with two dashes ( — ) like this: --more-tacos . Remember that if you see nothing happening, it is probably because you (1) completely forgot to add a command, (2) misspelled your command or (3) used an invalid command because of wrong syntax or because it’s just not possible. More information about when a command is valid can be found on the <a href="https://open-ui.org/components/invokers.explainer/">OpenUI explainer</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*6nipOVH3BikVt6L7mtOKeA.gif" /></figure><p>For custom commands, you do need some JavaScript:</p><pre>document.getElementById(&quot;more-tacos&quot;).addEventListener(&quot;command&quot;, (e) =&gt; {<br>  if (e.command === &quot;--more&quot;) {<br>      const grid = document.getElementById(&quot;grid&quot;);<br>      grid.appendChild(document.createElement(&#39;div&#39;))<br>  }<br>});</pre><p>Also a small detour here from the main subject: I used the CSS at-rule@starting-style here to animate in and out. With starting-style, it is super easy to create simple animations when toggling display: none. You just define the ‘starting state’, which is opacity: 0 (see example below). That’s all!</p><pre>  @starting-style {<br>      opacity: 0;<br>      scale: 1.1;<br>  }<br><br>  &amp;[hidden] {<br>      opacity: 0;<br>      scale: .9;<br>      display: none;<br>      transition-duration: .3s;<br>  }</pre><p>However, the custom commands also bring me to the question when you should <strong>NOT </strong>use invoker commands. I guess the answer is: when you are about to introduce (complex) JavaScript. If you get to the point that invoker commands are not sufficient for what you need and you need to add loads of JavaScript to make it work, it could become complex when you consider the loading strategy. For instance, consider the situation when someone triggers the command before the script adds the listener, during the time between the element rendering and the script execution. Also, using a custom command is not really that different to just adding a click event listener.</p><h4>Accessibility</h4><p>Invoker commands are designed to make elements more accessible by providing ARIA attributes and improving keyboard navigation.</p><ul><li><strong>ARIA attributes:</strong> Invoker commands will add certain ARIA attributes to buttons implicitly, improving accessibility without requiring manual implementation.</li><li><strong>Focus restoration:</strong> When a dialog or popover closes, focus will be returned to the button that opened it, improving keyboard navigation.</li><li><strong>Custom commands:</strong> For custom commands, developers must manually assign appropriate ARIA markup to ensure accessibility. Developers should still be aware of the accessibility requirements for custom commands and ensure that all elements have a command attribute.</li></ul><h4>Future roadmap</h4><p>Work is ongoing to fully support play/pause commands for the video element. Also, there have been suggestions for new functions such as <a href="https://github.com/openui/open-ui/issues/916">invoking picture-in-picture</a>. Furthermore, accessibility is also still being worked on by the OpenUI group, like the focus trap.</p><h4>Conclusion</h4><p>Invoker commands offer a simple approach to HTML interactions, eliminating the need for JavaScript in many common scenarios. By simply adding specific attributes to elements, developers can easily control dialogs and popovers (in combination with the new Popover API) without writing one line of code of JavaScript. While still experimental, this feature holds potential for simplifying web development and improving accessibility. However, it’s essential to weigh the complexity of JavaScript-heavy implementations against the benefits to determine the most suitable approach.</p><p>The taco example <a href="https://rebeccadavidsson.github.io/invoker-commands/">can be found here</a>. Remember you must enable the Experimental Web Platform features after going to chrome://flags in Chrome Canary to see it work. The code to buy more tacos can be found <a href="https://github.com/rebeccadavidsson/invoker-commands">here on GitHub</a>.</p><p><em>Credits to the OpenUI group for working on this new feature!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ee5265fd8cf4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How CSS Can Break Accessibility]]></title>
            <link>https://medium.com/@rebeccadavidsson3/how-css-can-break-accessibility-8f2aab1f20f5?source=rss-714811c5cb7f------2</link>
            <guid isPermaLink="false">https://medium.com/p/8f2aab1f20f5</guid>
            <category><![CDATA[css]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[accessibility]]></category>
            <category><![CDATA[web]]></category>
            <dc:creator><![CDATA[Rebecca Davidsson]]></dc:creator>
            <pubDate>Fri, 13 Sep 2024 06:27:54 GMT</pubDate>
            <atom:updated>2024-09-13T08:22:30.330Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LayTnrx1HihcUx8JeqcB7A.png" /></figure><p>When we think about accessibility, CSS might not be the first thing that comes to mind. If you’re not careful, CSS can actually <em>break</em> accessibility, making your site harder to use for people with disabilities. Here are some common examples where CSS can go wrong:</p><ol><li>Using list-style: none wrongly</li><li>Using display: contents on semantic elements</li><li>Removing focus outline on links</li><li>Setting a small line-height</li><li>Using pixels for font-size</li><li>Using hover-only interactions</li></ol><h4>Removing List Semantics with list-style: none ❌</h4><p>Lists (&lt;ul&gt; or &lt;ol&gt;) rely on their default styles to be recognized by screen readers. When you use list-style: none, you might accidentally hide important information, especially in browsers like Safari. This can make it harder for screen readers to understand the content.</p><pre>/* Risky: Removes list role semantics in Safari */<br>ul {<br>  list-style: none;<br>}</pre><p>To avoid this, ensure you’re not relying solely on CSS and, when necessary, add ARIA roles to restore the missing semantics ✅:</p><pre>ul[role=&quot;list&quot;] {<br>  list-style: none;<br>}</pre><h4>Using display: contents on semantic elements ❌</h4><p>While display: contents can simplify your HTML by removing unnecessary wrappers, it can also break accessibility. It may break accessibility by removing the element itself from the accessibility tree. The children remain accessible, but this can disrupt the DOM structure screen readers rely on.</p><p>For instance, applying display: contents to a meaningful element like a &lt;button&gt; or &lt;form&gt; can break their intended roles:</p><pre>button {<br>  display: contents; /* Bad idea! */<br>}</pre><p>Instead, use display: contents only on non-semantic elements like &lt;div&gt; or &lt;span&gt;, where it won&#39;t affect meaningful interactions. ✅</p><h4>Removing focus outline on links ❌</h4><p>Removing the focus outline on interactive elements, like anchor tags (&lt;a&gt;), can seriously harm accessibility. The focus outline is essential for users who rely on keyboard navigation, as it shows which element is currently selected. If you use outline: none; without providing an alternative focus indicator, it becomes difficult—if not impossible—for keyboard users to navigate your site.</p><p>In some cases, even if the focus outline isn’t removed, styling elements in ways that mimic or obscure the focus indicator can be just as harmful.</p><pre>/* Removes the focus indicator, making it inaccessible */<br>a:focus {<br>  outline: none;<br>}<br><br>/* The focus indicator may blend with the outline, <br>   making it hard to tell which element is currently focused. */<br>a {<br>  outline: thin dotted black;<br>}<br><br>/* If you add a thick border that matches the focus indicator color, <br>   such as a solid black border on a black outline, <br>   the focus outline may become nearly invisible */<br>a {<br>  border: medium solid black;<br>}</pre><p>Always ensure focus indicators are both visible and distinguishable. This is also <a href="https://www.w3.org/TR/2016/NOTE-WCAG20-TECHS-20161007/F78">a WCAG criterion</a>. ✅</p><h4>Setting a small line-height ❌</h4><p>Browsers default to a line height of around 1.2. For better readability, the <a href="https://www.w3.org/WAI/WCAG21/Understanding/text-spacing.html">WCAG</a> recommends a minimum of 1.5 for paragraph text. This helps individuals with low vision and cognitive conditions, such as dyslexia, by improving text legibility and reducing visual clutter. When using a unitless value (e.g., line-height: 1.5;), the line height will scale proportionately if the text size is increased, ensuring that content remains readable even when zoomed in ✅.</p><h4>Using pixels for font-size ❌</h4><p>Using fixed font sizes, like px, locks the text size, preventing it from adjusting to a user&#39;s browser or system preferences. This can make your website difficult to read for people with visual impairments who need to enlarge text. To avoid this issue, use relative units such as em or rem, which scale with the user’s settings, making your content more flexible and accessible.</p><pre>/* Fixed size with pixels - NOT accessible */<br>body {<br>  font-size: 16px;<br>}</pre><pre>/* Relative size with rem - More accessible */<br>body {<br>  font-size: 1rem;<br>}</pre><p>Using rem ensures that the text will scale according to the user&#39;s base font size, improving accessibility without breaking your design ✅.</p><h4>Hover-only interactions</h4><p>Hover-only interactions can be a pain for people who can’t use a mouse. And tooltips? You’ll probably end up with more frustration than information. And let’s not even get started on the labyrinth of ARIA attributes and JavaScript magic required to make them fully accessible. That could be a whole book, and I’m pretty sure someone’s already written it. However, to make your website more accessible, it’s essential to provide alternative methods for triggering hover-based actions, such as keyboard shortcuts or touch events.</p><h4>Conclusion</h4><p>When it comes to accessibility, CSS is not something to forget. Removing list semantics with list-style: none might make things look cleaner, but it also strips away essential information for screen readers. Similarly, properties like display: contents and removing focus outlines can make navigation a nightmare for keyboard users.</p><p>Instead of locking your text in a pixel prison, use relative units like rem to keep things flexible. And for clear, readable content, stick to a line height of 1.5. By avoiding these CSS pitfalls, you&#39;ll keep your site accessible and user-friendly for everyone!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8f2aab1f20f5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Biome: The Faster Lint and Formatting Alternative to Prettier]]></title>
            <link>https://medium.com/navara/biome-the-faster-lint-and-formatting-alternative-to-prettier-12fcf8b122b9?source=rss-714811c5cb7f------2</link>
            <guid isPermaLink="false">https://medium.com/p/12fcf8b122b9</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[frontend]]></category>
            <dc:creator><![CDATA[Rebecca Davidsson]]></dc:creator>
            <pubDate>Fri, 12 Jan 2024 13:07:08 GMT</pubDate>
            <atom:updated>2024-01-12T13:07:08.879Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9_Ec3RQdTce_0jk7zLZeYw.png" /></figure><h3>Biome: The Next Generation of Code Formatting and Linting</h3><h4>Prettier has been widely used by developers to format code. Recently, a much faster alternative was released: Biome.</h4><p>For years, Prettier has been widely used by developers to format code for JavaScript, TypeScript, JSON and many more. However, there was one drawback: performance. Biome, a new open-source toolchain for web development, tackles this problem by combining a faster formatter and linter.</p><p>Built on Rust, it is renowned for its speed and efficiency and has <strong>many performance benefits</strong> compared to Prettier. Recently, Biome won the <a href="https://biomejs.dev/blog/biome-wins-prettier-challenge/">Prettier challenge</a> that was launched by one of Prettier’s creators. The challenge was to write a prettier-compliant pretty printer in Rust.</p><p>Biome is significantly faster, producing more consistent and predictable formatting. Its error messages are also more informative and helpful, making it easier to identify and rectify formatting issues.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ej4zmVx7GwefVHXBw_i4xg.png" /></figure><h4><strong>A linter and formatter in one tool</strong></h4><p>Biome can be used to perform a variety of tasks, including analyzing, formatting, and linting your code. By using the check command you can run both the lint and format option.</p><pre>npx @biomejs/biome check --apply &lt;files&gt;</pre><p>I’ve found Biome’s linter to be more proactive than Prettier’s, catching potential bugs and errors early on, preventing them from becoming major issues. The linter immediately finds several potential issues, including unused variables and misplaced parentheses. These issues are resolved quickly and easily, leaving code cleaner and more organized.</p><h4>Key features of Biome</h4><ul><li><strong>Speed and Efficiency:</strong> Built on the Rust programming language, Biome boasts exceptional performance.</li><li><strong>Simplicity</strong>: Biome eliminates the need for complex configuration, allowing developers to start using it right away without extensive setup. Yet, it provides extensive options for fine-tuning its behavior to suit individual preferences.</li><li><strong>Scalability:</strong> Biome is designed to handle projects of any size, ensuring that its performance remains consistent regardless of the code base’s complexity.</li><li><strong>IDE Integration</strong>: Biome integrates seamlessly with popular IDEs and code editors, such as VS Code and IntelliJ IDEA. It also offers extensibility through plugins and hooks.</li><li><strong>Error Reporting and Diagnostics</strong>: Biome provides detailed and contextual error messages that guide developers toward identifying and resolving issues quickly.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*DF9k4pigyJB3gTYN1eR4zA.png" /><figcaption>Biome provides detailed error messages to identify problems.</figcaption></figure><h4><strong>Accessibility</strong></h4><p>Checking for accessibility in HTML is becoming more and more important for web development. Biome does a great job at identifying accessibility issues. It provides easy-to-understand error messages and offers potential solutions for them. I want to bring up two examples.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*swi5AEZlK-Jo_nOR-is_YA.png" /><figcaption>Biome shows what should be fixed in the div.</figcaption></figure><p>In the example above, Biome points out what exactly should be fixed in the incorrect usage of role=&quot;slider&quot;.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_ccTa-nYWD-gett7B8RwmA.png" /></figure><p>For the example above, Biome gives solutions for a fix. This makes it easier to identify and fix issues during development.</p><h4><strong>Benchmarks of Biome vs Prettier</strong></h4><p>Biome has made <a href="https://github.com/biomejs/biome/blob/main/benchmark/README.md">a repository</a> dedicated to running benchmarks that compare it to Prettier and parallel-prettier. The benchmarks involve formatting a collection of JavaScript and TypeScript files of varying sizes and complexities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XIkR16oOPCGGotiAR7dtTA.png" /><figcaption>Formatting and linting <a href="https://github.com/biomejs/biome/blob/main/benchmark/README.md">speed results </a>of different tools compared to Biome</figcaption></figure><p>The benchmark <a href="https://github.com/biomejs/biome/blob/main/benchmark/README.md">results</a> consistently show that Biome outperforms Prettier in both formatting and linting. Biome is significantly faster than Prettier and dprint for formatting and faster than ESLint for linting.</p><p><em>Good to note here: the benchmark uses </em><em>— max-diagnostics=0 when running Biome, which means that Biome only prints the diagnostic count, whereas ESLint prints a line for each lint error.</em></p><h4>Should you switch to Biome right now?</h4><p>While Biome offers promising features, it is currently in its early stages of development and there are <strong>still some limitations</strong>.</p><p><strong>Biome has less type-checked lint rules</strong></p><p>The incredible speed comes at a price: Rust-based linters currently lack the comprehensiveness of type-checked lint rules provided by ESLint. This means that while they can identify syntax errors and common style issues, they may miss problems that rely on type information.</p><p>Rust-based linters are still missing a piece of the puzzle when it comes to<strong> type checking</strong>, a feature that ESLint + typescript-eslint does have. On the other hand, as of January 2024, Biome does include <a href="https://github.com/biomejs/biome/discussions/3#typescript-eslint">64 typescript-eslint rules</a>, but these rules don’t cover all the<a href="https://typescript-eslint.io/rules/"> typescript-eslint rules</a>. For example, in contrast to typescript-eslint:</p><ul><li>Biome lacks the prefer-readonly rule, which enforces marking private members as readonly if they are never modified outside of the constructor.</li><li>It also lacks the explicit-function-return-type rule, which requires explicit return type declarations for all functions, even if they always return the same type.</li></ul><p>And there are some other examples of rules that Biome does not have. However, Biome is still being developed and more rules are being added.</p><p>So, which approach should you choose? If performance is critical and you’re willing to make some small trade-offs in typescript-eslint rules, then Biome could be a good option. If you need complete type-checking in your project, stay with Prettier and ESlint and wait until Biome is developed further.</p><p><strong>Nx support</strong></p><p>While there is no official announcement regarding nx support for Biome, the new toolchain for web projects, it’s possible that such integration could be developed in the future…</p><p><strong>Prettier is also becoming faster</strong></p><p>While Biome is a solid option, Prettier is also likely to get a speed boost in the future. This will be achieved by optimizing its parsing engine, AST representations, whitespace handling, and leveraging hardware acceleration. So, if you’re happy with Prettier, you’re probably also good to stick with it.</p><h4>Conclusion</h4><p>As Biome continues to evolve, I believe it has the potential to optimize the way we develop web applications. Its focus on performance, compatibility, and ease of use makes it a compelling choice for developers. In the future, I see that Biome has the potential to become the standard toolchain for web development.</p><p>If you want to set up Biome in your project, it’s done in a few seconds. Go to <a href="https://biomejs.dev/guides/getting-started/">biomejs.dev</a> for more details about setting up Biome. There is also a <a href="https://biomejs.dev/playground/">playground</a> to get to know the formatter.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=12fcf8b122b9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/navara/biome-the-faster-lint-and-formatting-alternative-to-prettier-12fcf8b122b9">Biome: The Faster Lint and Formatting Alternative to Prettier</a> was originally published in <a href="https://medium.com/navara">NAVARA</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Chrome DevTools Updates You Can’t Miss in 2023]]></title>
            <link>https://medium.com/navara/chrome-devtools-updates-you-cant-miss-in-2023-6acccff5960?source=rss-714811c5cb7f------2</link>
            <guid isPermaLink="false">https://medium.com/p/6acccff5960</guid>
            <category><![CDATA[css]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[chrome]]></category>
            <category><![CDATA[frontend]]></category>
            <dc:creator><![CDATA[Rebecca Davidsson]]></dc:creator>
            <pubDate>Sun, 24 Sep 2023 13:35:14 GMT</pubDate>
            <atom:updated>2023-09-27T08:28:42.912Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*A5FEwEOms5Bo0q_q" /><figcaption>Photo by <a href="https://unsplash.com/@growtika?utm_source=medium&amp;utm_medium=referral">Growtika</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>In the Chrome 116–117 release, a number of new features are introduced that developers will love, such as HTTP mocking.</h4><p>A number of new features are introduced in Chrome 116–117 that will definitely improve the developer experience in Chrome, such as <strong>HTTP mocking</strong> directly in DevTools.</p><h3>HTTP mocking in Chrome 🔥</h3><p>HTTP mocking is a technique that allows you to simulate HTTP responses. This can be useful for a variety of purposes, such as prototyping, debugging, and testing.</p><p>To use HTTP mocking, simply open the DevTools network panel and right-click on the request that you want to mock. Then, select “Override content” from the context menu:</p><figure><img alt="Dropdown with the override http request option in Chrome Devtools" src="https://cdn-images-1.medium.com/max/1024/1*_xJ02oGopIjErvdJM5uHGg.png" /></figure><p>This will open a dialog box where you can enter the mock response. You can enter JSON, XML, HTML, or any other type of data that you want the server to return.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X-ZXbZg4AOzcKPWxtluhag.png" /></figure><p>Don’t forget to click the “Save” button once you have entered the mock response. Chrome will then use this mock response whenever the request is made. You see a purple circle in your Network panel whenever a resource is overwritten.</p><ul><li>✅ <strong>No more waiting for the backend API to be deployed</strong>: HTTP mocking can be used to prototype new web apps without having to wait for the backend API to be developed. You can now simulate the API responses and test your app locally!</li><li>✅ <strong>(Performance) testing</strong>: it can be used to test the performance of your web app by simulating different types of network conditions. For example, you can use HTTP mocking to simulate a slow network connection or a packet loss. in addition, you can use it to test behavior at a large amount of traffic or when a website is under attack.</li></ul><h3>Highlighting more updates</h3><ul><li><strong>CSS animations editor </strong>and other CSS updates: You can now easily preview animations and edit animation timelines.</li><li><strong>Debug priority fetches</strong>: You can now debug priority fetches by showing the fetch priority for each request in the DevTools network panel.</li><li><strong>Prefetch pages</strong>: A new feature called “prefetch pages” allows you to prefetch pages that are likely to be visited next. This can improve the performance of web applications by reducing the time it takes to load pages.</li><li><strong>Array grouping: </strong>You can group the elements of an array based on the values returned by a callback function.</li><li><strong>Debug missing CSS styles</strong>: Debugging missing CSS styles is now easier by providing a new panel in DevTools that shows all of the missing styles for a given page.</li></ul><p>In addition, there are multiple other updates such as better syntax highlighting for source code and the option to hide annoying Chrome extension logs. Next to the http mocking feature, I’m enthusiastic about some of the CSS animation updates, which I will cover in the next paragraph.</p><h3>CSS animation updates</h3><p>Another notable new feature is the ability to <strong>edit animation timelines</strong>. This allows you to fine-tune the timing of your animation and to create complex animations with multiple keyframes.</p><figure><img alt="CSS animation timeline editor in Chrome Devtools" src="https://cdn-images-1.medium.com/max/600/1*D6xzyvx72vkYHkfQf5I_eA.gif" /></figure><h4>CSS transition animation on exit</h4><p>Before I dive into this new feature, I will start with an exit animation example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*hR6ymrpRlo9o_aMtSEaEFQ.gif" /><figcaption>Example of an<a href="https://developer.chrome.com/blog/entry-exit-animations/"> exit animation</a></figcaption></figure><p>It is not unlikely that you would want to remove a DOM node (with a timeout) after an exit animation is finished. Now you have the ability to animate display and content-visibility on a keyframe timeline!</p><h4>Animate entry animations with a new CSS rule</h4><p>In the example above, a new feature @starting-style is used to animate the entry effect from display: none and was then added into the top-layer. Chrome then uses this to look up a style on an element before it is open, called the ‘before-open’ state. We then have three states: before-open, is-open and exiting state:</p><pre>/* Before-open state*/<br>@starting-style {<br>  .item {<br>    opacity: 0;<br>    transform: scale(0);<br>  }<br>}<br><br>/* Is-open state */<br>.item {<br>  display: grid;<br>  overflow: hidden;<br>  opacity: 1;<br>  transform: scale(1);<br>  transition: opacity 0.5s, transform 0.5s, display 0.5s allow-discrete;<br>}<br><br>/* Exit state */<br>.is-deleting {<br>  opacity: 0;<br>  display: none;<br>  transform: scale(0.5) skewX(50deg) translateX(-25vw);<br>}</pre><p>Notice the transition-behavior property with the allow-discrete keyword in this example, which is used to to enable the transition of display.</p><p><em>Read more about new CSS features brought to Chrome 116–117 such as animating the overlay property </em><a href="https://developer.chrome.com/blog/entry-exit-animations/"><em>here</em></a><em>.</em></p><h3>Network panel improvements</h3><ul><li>See the <strong>changes in fetch priority</strong> for network events. This can be helpful for debugging performance issues and understanding how fetch priorities affect network requests.</li><li><strong>Prefetch pages</strong>: you can prefetch pages that are likely to be visited next. This can improve the performance of web applications by reducing the time it takes to load pages.</li><li><strong>Hide annoying Chrome extension warnings </strong>in your console. This can make the Network panel less cluttered and easier to use. A way more peaceful console.</li><li><strong>Readable HTTP status codes</strong>. DevTools now displays human-readable descriptions for HTTP status codes, making it easier to understand what they mean.</li></ul><h3>Array grouping with JS</h3><p>In older versions of Chrome, you had to use a for-loop to iterate over the array and group the elements based on the values returned by a callback function, which was just too much work. <strong>Before:</strong></p><pre>const products = [<br>  { name: &quot;Banana&quot;, category: &quot;Fruit&quot; },<br>  { name: &quot;Orange&quot;, category: &quot;Fruit&quot; },<br>  { name: &quot;Peanut butter&quot;, category: &quot;Best products ever&quot; },<br>];</pre><pre>// Grouping products by category<br>const groupedProducts = {};<br>for (const product of products) {<br>  const category = product.category;<br>  if (!groupedProducts[category]) {<br>    groupedProducts[category] = [];<br>  }<br>  groupedProducts[category].push(product);<br>}</pre><p><strong>After: </strong>Now we can replace this by using groupBy() in one line:</p><pre>const groupedProducts = Object.groupBy(product, ({ category }) =&gt; category);</pre><h3>Conclusion</h3><p>The new features in Chrome 116 and 117 make the browser even more powerful. HTTP mocking, in particular, is a powerful tool that can save developers and testers a significant amount of time and effort. You can simply mock the responses of your backend API to simulate different scenarios directly in the browser. Some other great updates in CSS animations are added, as well as great updates in the Network tab. I’m already excited for some of the next updates in version 118.</p><p><em>Resources: </em><a href="https://developer.chrome.com/blog/new-in-devtools-116/"><em>New in DevTools 116</em></a><em> , </em><a href="https://developer.chrome.com/blog/new-in-devtools-117/"><em>New in DevTools 117</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6acccff5960" width="1" height="1" alt=""><hr><p><a href="https://medium.com/navara/chrome-devtools-updates-you-cant-miss-in-2023-6acccff5960">Chrome DevTools Updates You Can’t Miss in 2023</a> was originally published in <a href="https://medium.com/navara">NAVARA</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Storybook Tests vs. E2E Tests: Finding the Perfect Balance]]></title>
            <link>https://medium.com/@rebeccadavidsson3/storybook-tests-vs-e2e-tests-finding-the-perfect-balance-d3943a4e7b70?source=rss-714811c5cb7f------2</link>
            <guid isPermaLink="false">https://medium.com/p/d3943a4e7b70</guid>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[nx]]></category>
            <category><![CDATA[storybook]]></category>
            <category><![CDATA[cypress]]></category>
            <category><![CDATA[testing]]></category>
            <dc:creator><![CDATA[Rebecca Davidsson]]></dc:creator>
            <pubDate>Tue, 05 Sep 2023 15:52:34 GMT</pubDate>
            <atom:updated>2023-09-07T06:27:49.089Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U59chHgSTlloa7qBgwR2iA.png" /><figcaption>Image by <a href="https://github.com/storybookjs/storybook">Storybook</a></figcaption></figure><h4>Storybooks interaction tests are a great way to test UI components. Should we replace all our e2e tests with Storybook tests?</h4><p>Maintaining e2e tests is always a great big fuss. They become flaky with updates and and they always seem to break when you least expected it.</p><p>But then I discovered Storybook interaction testing. It’s a way to test user interactions with your components in a controlled environment. It’s fast, reliable, and it’s perfect for small UI components. As much as I am a fan of (Cypress) e2e tests, I see there are quite some cases where the Storybook interaction tests could be a better choice for testing individual small components.</p><h3><strong>Storybook interaction testing</strong></h3><p>What I personally think is a very powerful feature is the ability to pause, go forward and go backwards. It allows you to step through your tests one step at a time. This can be very helpful for debugging tests, as it allows you to see exactly what is happening at each step. Also, if you have a public Storybook instance hosted somewhere, the tests are also visible. A big benefit here is the ability to view the component you’re testing in a real browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/595/1*g4g52gv_zM_YpPUgOOovZQ.gif" /><figcaption>Easily pause, go forward and go backwards with Storybook interaction tests</figcaption></figure><p>This example types some text into the input field, and checks whether the error message is visible. The tests are written by adding a play function to the story of that component. <em>A detailed instruction about how to set up interaction tests can be found </em><a href="https://storybook.js.org/docs/react/writing-tests/interaction-testing"><em>here</em></a><em>.</em></p><pre>buttonStory.play = async ({ canvasElement }) =&gt; {<br>  const canvas = within(canvasElement);<br><br>  const inputField = canvas.getByTestId(&#39;input-field&#39;);<br><br>  await userEvent.click(inputField);<br><br>  await userEvent.type(inputField, &#39;Too long text&#39;);<br><br>  await expect(canvas.getByText(&#39;Text is too long&#39;)).toBeInTheDocument();<br>};</pre><p>The same test could be written in Playwright or Cypress as the example below.</p><pre>describe(&#39;Input form&#39;,  ()  =&gt; {<br>  it(&#39;Should show error message when the text is too long&#39;, () =&gt; {<br>    cy.visit(&#39;/iframe.html?id=button-component&#39;);<br><br>    cy.get(&quot;#input-field&quot;).click();<br><br>    cy.get(&quot;#input-field&quot;).type(&#39;Too long text&#39;);<br><br>    cy.get(&#39;.error-message&#39;).should(&#39;be.visible&#39;);<br> <br>  })<br>});</pre><h3>Should you choose interaction tests or e2e tests?</h3><p>Using e2e tests with Storybook requires developers to maintain two projects: e2e tests and Storybook itself. Using interaction tests, developers can integrate tests directly into the stories they are already creating. In this way, developers don’t have to switch between Storybook and a separate e2e test, which makes the development proces easier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1016/1*fWqli6bBwal3cH3batDtLQ.png" /><figcaption>Comparing e2e tests and Storybook interaction tests</figcaption></figure><h4>Benefits of Storybook interaction tests</h4><ul><li><strong>Understandable tests. </strong>The tests are easy to read and to understand. Also, if you have a Storybook instance hosted somewhere, the tests are also visible here, making it very transparent what is tested and what not.</li><li><strong>Good developer experience. </strong>All files are in one place, there are no separate projects and there is hardly any configuration needed to run the tests.</li><li><strong>Performance. </strong>The tests are reliable and fast. In comparison to most e2e tests, they are also less flaky.</li></ul><h4>Downsides of Storybook interaction tests</h4><ul><li><strong>Limited selectors</strong>. They can only select elements by a limited number of selectors, such as id, text, role or placeholder-text. This can be limiting if the element you want to select does not have an id or text that is unique. They can also not select elements by their CSS selector, which is often used in e2e tests.</li><li><strong>Test reports. </strong>If a test fails, the test-runner does provide detailed information about what went wrong, but it’s not as clear as with e2e tests. With e2e tests, it is also possible to capture screenshots of failing tests and to configure output formatting. There is however an <a href="https://github.com/storybookjs/test-runner?ref=storybookblog.ghost.io#experimental-test-hook-api">experimental test hook API</a> that lets you add extra configuration, enabling snapshots, url interception and more.</li><li><strong>Limited to one component.</strong> It is not possible to do integration tests. The tests are really meant to test individual UI components. However, this can also be seen as a benefit since this can beneficial for code consistency where there is a clear split: interaction tests for individual UI components and e2e tests for more complex elements.</li></ul><p>The best type of test for you depends on your needs. If you need to test the full functionality of your application, then e2e tests are the way to go. They can test the entire application, including how the different components interact with each other.</p><p>If you’re only testing small UI components, then Storybook interaction tests are a better option. They are much faster and more reliable than e2e tests. They’re also much easier to write and maintain, as they don’t require changes to the application code. In short: <strong>choose interaction tests for small UI components, and choose e2e tests for more complex tests.</strong></p><h3><strong>Automating interaction tests</strong></h3><p>It’s clear that interaction tests can be very interesting for small UI components, but it would be even better if they also integrate in your test automation pipeline. I will cover the example given by Storybook using a pipeline to build Storybook and run tests with the test-runner.</p><p>First, you will have to install <a href="https://storybook.js.org/docs/react/writing-tests/test-runner">@storybook/test-runner</a> , add a script to your package.json and run test-storybook without any additional configuration.</p><pre>{<br>  &quot;scripts&quot;: {<br>    &quot;test-storybook&quot;: &quot;test-storybook&quot;<br>  }<br>}</pre><p>Then, if you’re using a CI environment you can adjust up your pipeline. The pipeline needs to have the steps to install Playwright, it has to build storybook into the storybook-static directory (or any other specified directory) and then serves a simple server to run the test-runner.</p><pre>job:<br>  test:<br>    steps:<br>      - name: Install dependencies<br>        run: yarn<br>      - name: Install Playwright<br>        run: npx playwright install --with-deps<br>      - name: Build Storybook<br>        run: yarn build-storybook --quiet<br>      - name: Serve Storybook and run tests<br>        run: |<br>          npx concurrently -k -s first -n &quot;SB,TEST&quot; -c &quot;magenta,blue&quot; \<br>            &quot;npx http-server storybook-static --port 6006 --silent&quot; \<br>            &quot;npx wait-on tcp:6006 &amp;&amp; yarn test-storybook&quot;</pre><h4>Running tests in an nx monorepo</h4><p>Of course nx has developed an integration for interaction tests. They can be generated using the --interactionTests flag when generating storybook-configuration. This will automatically add the play function (used as ‘interaction test’) and generate a test-storybook target in your project.json .</p><pre>nx g @nx/angular:storybook-configuration project-name - interactionTests=true</pre><p>After adding an interaction test to your project, you can simply run the tests by first running nx storybook project-name followed by nx test-storybook project-name . If you’re using this in a pipeline, the target can be adjusted in your project.json :</p><pre>// project-name/project.json<br>&quot;test-storybook&quot;: {<br>  &quot;executor&quot;: &quot;nx:run-commands&quot;,<br>  &quot;options&quot;: {<br>    &quot;command&quot;: &quot;test-storybook-ci project-name&quot;<br>  }<br>}</pre><pre>// package.json <br>{<br>  &quot;scripts&quot;: {<br>    &quot;test-storybook-ci&quot;: &quot;npx concurrently -k -s first -n &quot;SB,TEST&quot; \<br>      &quot;npx http-server storybook-static/project-name --port 6006 --silent&quot; \<br>      &quot;npx wait-on tcp:6006 &amp;&amp; yarn test-storybook project-name&quot;<br>  }<br>}</pre><p>In this example, the script is now hardcoded to always run test-storybook project-name. You can adjust your script to only run yarn test-storybook against a specific (affected) project. <br>Storybook interaction tests have been live for a while now, but it’s noticeable that nx is not really up to date yet with this feature. As you can see in the example above, there is no nx runner to test storybook, forcing us to use other libraries to serve and test storybook. Also, when using nx: keep in mind that if you already have e2e tests setup, make sure that you don’t test components twice with e2e tests and interaction tests.</p><p>In short: <strong>choose interaction tests for small UI components, and choose e2e tests for more complex tests. </strong>Seriously, <a href="https://storybook.js.org/docs/react/writing-tests/interaction-testing">Storybook 7’s interactive play function</a> is a great way to test your UI. It’s easy to use, reliable, and maintainable, but it cannot replace all e2e tests. If you’re not using it already, I encourage you to give it a try! Also, don’t forget that Storybook offers more UI tests such as <a href="https://storybook.js.org/docs/react/writing-tests/snapshot-testing">snapshot tests</a> and <a href="https://storybook.js.org/docs/react/writing-tests/accessibility-testing">accessibility tests</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d3943a4e7b70" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[New & Upcoming CSS Features In 2023]]></title>
            <link>https://medium.com/navara/new-upcoming-css-features-2023-ba44d8a45993?source=rss-714811c5cb7f------2</link>
            <guid isPermaLink="false">https://medium.com/p/ba44d8a45993</guid>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[web-design]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Rebecca Davidsson]]></dc:creator>
            <pubDate>Mon, 07 Aug 2023 18:23:58 GMT</pubDate>
            <atom:updated>2023-09-04T07:06:30.695Z</atom:updated>
            <content:encoded><![CDATA[<h4>Anchor positioning, new pseudo-classes, and more!</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0JzKxar5ynDPS8qcNLpwHg.jpeg" /><figcaption>Anchor positioning in CSS</figcaption></figure><p>The <a href="https://www.w3.org/groups/wg/css/">CSS Working Group</a> is working on a number of exciting new features and CSS properties. These include features like anchor positioning, features for shapes, scroll snap, and new audio pseudo-classes.</p><h3>Anchor Positioning</h3><p>CSS Anchor Positioning is an experimental new CSS feature that allows you to position an element relative to another element on the page. This is done by using the anchor-position property. For example, the following code would position an element 10px to the left of the anchor element:</p><pre>.element {<br>  anchor-position: my-anchor left 10px;<br>}</pre><p>CSS Anchor Positioning is a powerful new feature that can be used to create a variety of interactive elements, such as tooltips, modals, and popovers. It makes tooltips even more dynamic. Here is a small example that shows how to anchor positioning to create a tooltip:</p><pre>&lt;div id=&quot;anchor&quot;&gt;This is the anchor element&lt;/div&gt;<br>&lt;div id=&quot;tooltip&quot;&gt;This is the tooltip&lt;/div&gt;</pre><pre>#tooltip {<br>    position: absolute;<br>    display: none;<br>    anchor-position: my-anchor top 10px;<br>  }<br>#anchor:hover #tooltip {<br>    display: block;<br>  }</pre><p>This code will create a tooltip that is positioned 10px above the anchor element when the anchor element is hovered over.</p><p>Another example from <a href="https://developer.chrome.com/blog/tether-elements-to-each-other-with-css-anchor-positioning/#focus-and-follow">developers.chrome.com</a> uses anchor positioning to track a visual indicator for the focused input fields. As you can see, the anchor can deal with multiple positions and layouts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*zK23S0cQhkbhhVNTHMnFlw.gif" /><figcaption><a href="https://developer.chrome.com/blog/tether-elements-to-each-other-with-css-anchor-positioning/#focus-and-follow">Focus and follow</a> using CSS anchor-position</figcaption></figure><p>In the future, we will be able to position an element relative to multiple anchor elements:</p><pre>.anchor1 {<br>  anchor-name: anchor1;<br>}<br>.anchor2 {<br>  anchor-name: anchor2;<br>}<br>.positioned {<br>  position: absolute;<br>  top: 0;<br>  left: 0;<br>  anchor: anchor1, anchor2;<br>}</pre><p>An example of multiple handlers for one element is the chart below, where the tooltips are anchored by combining it with the max and min values of the chart (source: <a href="https://developer.chrome.com/blog/tether-elements-to-each-other-with-css-anchor-positioning/#bar-chart-calc">developers.chrome.com</a>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*v7Da3Upqlr8Z9iSTc4nokA.gif" /><figcaption><a href="https://developer.chrome.com/blog/tether-elements-to-each-other-with-css-anchor-positioning/#bar-chart-calc">Tracking bar chart</a> values with CSS anchor position</figcaption></figure><p>Some other examples of how CSS anchor positioning can be used:</p><ul><li>Elements that follow the user as they scroll down the page.</li><li>Accordions that expand and collapse when the user clicks on a button.</li><li>Resize images based on multiple anchor-position s.</li><li>Modal dialogs that appear over the rest of the page.</li><li>Even more dynamic tooltips!</li></ul><p><em>Note that as of August 2023, anchor-positioning is still an experimental feature. You can test </em><a href="https://www.google.com/chrome/canary/"><em>Chrome Canary</em></a><em>!</em></p><h3>New features for shapes</h3><p>With CSS Shapes we don’t mean creating a div of 100 by 100 pixels and filling it read to create a square… CSS Shapes is a real thing that allows you to easily create complex shapes with CSS.</p><p>The shape-outside property has already been developed a while ago. This lets you create shapes that are relative to a specific location on the page. For example, you could create a circle that is centered on the top-left corner of the page:</p><pre>.circle {<br>  shape-outside: circle(50px at 10px 10px);<br>}</pre><p>But this is just the beginning. There are more shapes such as triangles, trapezoids, or polygons. You can make it as complex as you want.</p><pre>.triangle {<br>  shape-outside: triangle(50px, 0, 50px, 100px, 0, 100px);<br>}</pre><p>Other new features:</p><ul><li><strong>shape-inside</strong> which can be used to create shapes that are filled with images or other content.</li><li><strong>shape-image</strong> which can be used to create shapes that are responsive to the size of the element.</li><li><strong>shape-overflow</strong> which can be used to create shapes that are clipped or that have content that flows outside of the shape. In the following example shape-overflow: clip will allow the content to overflow the shape, but it will be constrained to the stroke box of the element:</li></ul><pre>.shape {<br>  shape-image: url(https://example.com/image.png);<br>  shape-overflow: clip;<br>}</pre><p><em>Note that as of August 2023, these features are still in draft phase.</em></p><h3>New features for scroll snap</h3><p>I personally really like the scroll snap feature, as it makes the scrolling experience much smoother and it is very easy to implement. If you haven’t worked with scroll-snap before, here is an example of how you can use CSS Scroll Snap to create a snap-to-scrolling behavior for an element:</p><pre>.my-element {<br>  scroll-snap-type: mandatory;<br>  scroll-snap-points-x: repeat(50px, 100px);<br>}</pre><p>This code will create an element that snaps to every 50px on the x-axis and every 100px on the y-axis.</p><p>Scroll snap has been live for a while now, but there are a few of new features that are somewhat new:</p><ul><li><strong>Scroll snap align</strong>: The new scroll-snap-align property allows you to control how an element is aligned when it snaps to a snap position. For example, you can use this property to ensure that an element is always aligned to the top, bottom, center, or left/right of the scroll container. Also in the example below, you can see that there is support for scroll snap in both axes.</li></ul><pre>.container {<br>  overflow-x: scroll;<br>  overflow-y: scroll;<br>  scroll-snap-type: both mandatory; // Support both axes<br>  scroll-snap-align: center;<br>}</pre><ul><li><strong>Better support for touch devices</strong>: making it easier to snap to snap positions using touch gestures.</li></ul><pre>.container {<br>  scroll-snap-type: both mandatory;<br>  scroll-snap-touch-snap-points: true;<br>}</pre><h3>Audio pseudo-classes</h3><p>As part of the Selectors Level 4 update, there are some pseudo-classes added that represent loaded images and videos.</p><p>When it comes to media playback, the :playing, :paused, and :seeking pseudo-classes seem very useful. This is great because we can now easily style these elements to create a more interactive and engaging user experience.</p><p>Another section deals with media loading states and includes :buffering and :stalled. These classes indicate to users that the media will continue playing once loading issues are resolved. Also the pseudo-classes :muted and :volume-locked will be added. These pseudo-classes are a nice way to provide visual feedback, keep users informed, and work with different styling, such as in the following example:</p><pre>video {<br>  opacity: 1;<br>}<br>video:buffering {<br>  background-color: #ccc;<br>  opacity: 0.5;<br>}</pre><p>Overall, these CSS pseudo-classes could be very practical. They’ll be a valuable addition to our web development toolkit, making it easier to handle media elements and improve the overall user experience on our websites. I’m looking forward to using them.</p><p><em>As of August 2023, some of these functions are only available for Safari.</em></p><h3>Current-element pseudo-class</h3><p>The :current pseudo-class is straightforward; it represents the element that is currently being displayed or an ancestor of that element. We could use this to create styles that respond to the user&#39;s current position in a specific element.</p><p>For example, the following rule could be used to highlight the paragraph or anchor element that is being read aloud in a speech rendering of the document:</p><pre>:current(p, a) {<br>  background: yellow;<br>}</pre><p>In addition, the :past and :future pseudo-classes also offer interesting possibilities, representing elements that occur entirely before or after the :current element. The :past pseudo-class represents any element that is defined to occur entirely prior to a :current element. The :future pseudo-class however, represents the element after.</p><h3>New features for subgrid</h3><p>CSS Subgrids are a feature of CSS Grid Layout that allows you to create nested grids within a single grid container, and there are new features coming! A small recap; here is an example of how you can create a subgrid:</p><pre>.my-grid {<br>  display: grid;<br>  grid-template-columns: repeat(2, 1fr);<br>}<br>.my-subgrid {<br>  display: grid;<br>  grid-template-columns: repeat(2, 50px);<br>}<br>.my-grid &gt; .my-subgrid {<br>  grid-column: 1 / 2;<br>}</pre><pre>Grid Container<br>   Column 1<br>       Subgrid<br>         Row 1<br>         Row 2<br>   Column 2</pre><p>As you can see, the subgrid is nested within the grid container. The subgrid has its own grid layout, which is independent of the grid layout of the grid container.</p><p>A new feature of subgrids is <strong>named grid lines. </strong>You will be able to name grid lines on your grid and then position items based on those names rather than the line number, such as in this example:</p><pre>.grid {<br>  display: grid;<br>  grid-template-names: a b c;<br>}<br>.grid .item.a {<br>  grid-column: a;<br>}<br>.grid .item.b {<br>  grid-column: b;<br>}<br>.grid .item.c {<br>  grid-column: c;<br>}</pre><p>Another one is <strong>subgrid alignment </strong>of a child grid to align the grid with the parent grid:</p><pre>.grid {<br>  display: grid;<br>  grid-template-columns: 1fr 1fr;<br>  grid-template-rows: 1fr 1fr 1fr;<br>}<br>.grid .item {<br>  background-color: #ccc;<br>  border: 1px solid black;<br>}<br>.grid .item &gt; .child-grid {<br>  grid-template-columns: 1fr 1fr;<br>  grid-template-rows: 1fr 1fr;<br>  grid-alignment: start start;<br>}</pre><p>The grid-alignment property can be used to align a child grid with its parent. In this example, the child grid is aligned with the parent grid on both the horizontal and vertical axes.</p><p><strong>One downside of subgrids: they can be hard to debug. </strong>If they become hard to debug: use a grid inspector to visualize the layout. In the inspector panel, you will see a number of different tabs. One of the tabs will be the “Grid” tab. The Grid tab will show you a visualization of the layout of the CSS grid. The visualization will show you the grid lines, the grid tracks, and the grid items.</p><p>Overall, I believe that CSS Subgrids are a valuable tool that can be used to create complex and responsive layouts and I am excited to see how they are used in the future with these new features.</p><p><em>Note that as of August, subgrids are not yet supported by all browsers!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ba44d8a45993" width="1" height="1" alt=""><hr><p><a href="https://medium.com/navara/new-upcoming-css-features-2023-ba44d8a45993">New &amp; Upcoming CSS Features In 2023</a> was originally published in <a href="https://medium.com/navara">NAVARA</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>