<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: jmckenney</title>
    <description>The latest articles on Forem by jmckenney (@jmckenney).</description>
    <link>https://forem.com/jmckenney</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F108603%2Fcb2b45c3-b344-4d43-b069-87700c5b8400.jpg</url>
      <title>Forem: jmckenney</title>
      <link>https://forem.com/jmckenney</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/jmckenney"/>
    <language>en</language>
    <item>
      <title>Web Component Style Encapsulation In 5 Minutes</title>
      <dc:creator>jmckenney</dc:creator>
      <pubDate>Sun, 10 Mar 2019 02:14:15 +0000</pubDate>
      <link>https://forem.com/jmckenney/web-component-style-encapsulation-in-5-minutes-1ihj</link>
      <guid>https://forem.com/jmckenney/web-component-style-encapsulation-in-5-minutes-1ihj</guid>
      <description>&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;Since the dawn of the data webs (well, shortly after the dawn), every ui element was governed solely and entirely by one overarching style cascade. What happens when you want to carefully protect an area of your UI from css overrides? &lt;/p&gt;

&lt;h2&gt;
  
  
  The Solution
&lt;/h2&gt;

&lt;p&gt;Shadow DOM. Shadow DOM touches on many topics under the umbrella of web components and also provides JS encapsulation. Today we are going to hone in on a few key aspects of style encapsulation.&lt;/p&gt;

&lt;p&gt;Custom elements by themselves provide only a minimal amount of change from the historic methods of styling. In the following example you will see that because a custom element is unique in name, a style author can utilize the custom element quote/unquote namespace to provide a healthy amount of specificity to custom styling thereby offering a minimal amount of protection from css overrides.&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/web-component-style-encapsulation-1?" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;As you can see, the &lt;code&gt;p&lt;/code&gt; styling was overrideen by the &lt;code&gt;parent-element p&lt;/code&gt; styling. Please take note that lit-element enables Shadow DOM by default and the example above disabled that via the &lt;code&gt;createRenderRoot()&lt;/code&gt; override. This enabled us to utilize lit-element while still showing a Custom Element without Shadow DOM enabled.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Big Reveal
&lt;/h2&gt;

&lt;p&gt;Now we get our example of style encapsulation. &lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/web-component-style-encapsulation-2?" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;A few questions may come to mind after looking at this example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Why does it say &lt;code&gt;Hello World&lt;/code&gt; rather than the template's string of &lt;code&gt;Style me carefully&lt;/code&gt;?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The answer is due to the magic of &lt;code&gt;slot&lt;/code&gt;s. Notice how the browser treats this area somewhat like a symlink in linux file systems. Though the node lives inside the shadow root, the content and styles reference the link back in the light DOM. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Why are we able to style the slotted content from outside, but we are unable to style the content existing inside the Shadow DOM that doesn't reference slotted content?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Shadow DOM protects, slots allow for styling. This is starting to get fun.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff62ktr7qafh9qna0x7tc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff62ktr7qafh9qna0x7tc.png" alt="It's like a symlink"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Styling API
&lt;/h2&gt;

&lt;p&gt;Now we have this clean and beautiful specification that allows us to continue composing html elements together while simultaneously encapsulating styles. I have to hand it to the specification creators for browsers. This had to have taken a lot of forethought and creativity. &lt;/p&gt;

&lt;p&gt;In the event that the author of the encapsulated area wants to allow branding and some styling to be brought in from the outside, the spec has options for this as demonstrated below.&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://stackblitz.com/edit/web-component-style-encapsulation-3?" width="100%" height="500"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;In the next article I'll discuss how web components also provide a way to encapsulate JavaScript. Keep a look out for a video walkthrough of this article.&lt;/p&gt;

&lt;h2&gt;
  
  
  Credit Where Credit Is Due
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://gist.github.com/praveenpuglia/0832da687ed5a5d7a0907046c9ef1813" rel="noopener noreferrer"&gt;https://gist.github.com/praveenpuglia/0832da687ed5a5d7a0907046c9ef1813&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webcomponents</category>
      <category>javascript</category>
      <category>encapsulation</category>
      <category>cssvariables</category>
    </item>
    <item>
      <title>Web Component Course Brainstorming</title>
      <dc:creator>jmckenney</dc:creator>
      <pubDate>Thu, 28 Feb 2019 14:41:11 +0000</pubDate>
      <link>https://forem.com/jmckenney/web-component-course-brainstorming-2be6</link>
      <guid>https://forem.com/jmckenney/web-component-course-brainstorming-2be6</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fd5p6ad7sko6w13632t4l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fd5p6ad7sko6w13632t4l.png" alt="Course Brainstorm"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It has begun.&lt;/p&gt;

</description>
      <category>webcomponents</category>
      <category>javascript</category>
      <category>course</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Web Components, Overview, Ep. 1</title>
      <dc:creator>jmckenney</dc:creator>
      <pubDate>Sat, 02 Feb 2019 17:54:51 +0000</pubDate>
      <link>https://forem.com/jmckenney/web-components-overview-ep-1-2b7b</link>
      <guid>https://forem.com/jmckenney/web-components-overview-ep-1-2b7b</guid>
      <description>

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/Vs-ko-UaWUQ"&gt; &lt;/iframe&gt;&lt;/p&gt;


</description>
      <category>webcomponents</category>
      <category>customelements</category>
      <category>shadowdom</category>
      <category>webdev</category>
    </item>
    <item>
      <title>You might think you made your site accessible...</title>
      <dc:creator>jmckenney</dc:creator>
      <pubDate>Mon, 07 Jan 2019 03:52:21 +0000</pubDate>
      <link>https://forem.com/jmckenney/you-might-think-you-made-your-site-accessible-56i</link>
      <guid>https://forem.com/jmckenney/you-might-think-you-made-your-site-accessible-56i</guid>
      <description>&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/j9RyZMKAFqc"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;NVDA:&lt;br&gt;
&lt;a href="https://www.nvaccess.org/download/"&gt;https://www.nvaccess.org/download/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;JAWS:&lt;br&gt;
&lt;a href="https://www.freedomscientific.com/Pro"&gt;https://www.freedomscientific.com/Pro&lt;/a&gt;...&lt;/p&gt;

&lt;p&gt;WCAG 2.1 Guidelines&lt;br&gt;
&lt;a href="https://www.w3.org/TR/WCAG21/"&gt;https://www.w3.org/TR/WCAG21/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Deque University&lt;br&gt;
&lt;a href="https://dequeuniversity.com/"&gt;https://dequeuniversity.com/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Axe extension:&lt;br&gt;
&lt;a href="https://chrome.google.com/webstore/detail/axe/lhdoppojpmngadmnindnejefpokejbdd"&gt;https://chrome.google.com/webstore/detail/axe/lhdoppojpmngadmnindnejefpokejbdd&lt;/a&gt;&lt;/p&gt;

</description>
      <category>a11y</category>
      <category>wcag</category>
    </item>
    <item>
      <title>Bootcamp Grad Interview - Was it Worth it?</title>
      <dc:creator>jmckenney</dc:creator>
      <pubDate>Mon, 10 Dec 2018 15:28:55 +0000</pubDate>
      <link>https://forem.com/jmckenney/bootcamp-grad-interview---was-it-worth-it-252c</link>
      <guid>https://forem.com/jmckenney/bootcamp-grad-interview---was-it-worth-it-252c</guid>
      <description>&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/Ox65cbIZd30"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>bootcamp</category>
      <category>bootcamps</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Firebase and Jest Testing, Episode 3</title>
      <dc:creator>jmckenney</dc:creator>
      <pubDate>Tue, 06 Nov 2018 03:38:14 +0000</pubDate>
      <link>https://forem.com/jmckenney/firebase-and-jest-testing-episode-3-51ka</link>
      <guid>https://forem.com/jmckenney/firebase-and-jest-testing-episode-3-51ka</guid>
      <description>&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/ajU_vchf7A4"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>firebase</category>
      <category>jest</category>
      <category>testing</category>
    </item>
    <item>
      <title>Firebase + Jest Testing Episode 2</title>
      <dc:creator>jmckenney</dc:creator>
      <pubDate>Wed, 31 Oct 2018 04:33:53 +0000</pubDate>
      <link>https://forem.com/jmckenney/firebase--jest-testing-episode-2-5e7a</link>
      <guid>https://forem.com/jmckenney/firebase--jest-testing-episode-2-5e7a</guid>
      <description>&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/zr-VqecEcc8"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Brian and Josh take the next step in adding Jest unit tests to a Firebase web app.&lt;/p&gt;

</description>
      <category>jest</category>
      <category>firebase</category>
      <category>javascript</category>
      <category>babel</category>
    </item>
    <item>
      <title>Jest testing with a hernia</title>
      <dc:creator>jmckenney</dc:creator>
      <pubDate>Mon, 22 Oct 2018 15:19:13 +0000</pubDate>
      <link>https://forem.com/jmckenney/jest-testing-with-a-hernia-2dmk</link>
      <guid>https://forem.com/jmckenney/jest-testing-with-a-hernia-2dmk</guid>
      <description>&lt;p&gt;Josh and Brian cover the basics of adding tests to a small app that was put together quickly as an experiment.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/asnKfTTuRgM"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>jest</category>
      <category>firebase</category>
      <category>webpack</category>
      <category>npm</category>
    </item>
  </channel>
</rss>
