<?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 Stefan Nieuwenhuis on Medium]]></title>
        <description><![CDATA[Stories by Stefan Nieuwenhuis on Medium]]></description>
        <link>https://medium.com/@stefannhs?source=rss-fbbe86fcf55a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*URslGy7d_myY5JhnNox6dQ.jpeg</url>
            <title>Stories by Stefan Nieuwenhuis on Medium</title>
            <link>https://medium.com/@stefannhs?source=rss-fbbe86fcf55a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 07:10:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@stefannhs/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[6 False claims about Web Components]]></title>
            <link>https://stefannhs.medium.com/6-false-claims-about-web-components-641ddff3ba04?source=rss-fbbe86fcf55a------2</link>
            <guid isPermaLink="false">https://medium.com/p/641ddff3ba04</guid>
            <category><![CDATA[html]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-components]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Stefan Nieuwenhuis]]></dc:creator>
            <pubDate>Tue, 01 Jun 2021 13:52:11 GMT</pubDate>
            <atom:updated>2021-06-01T15:07:01.791Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v6w0A6KGQSEbUYjTfFHv7A.jpeg" /></figure><ol><li>Web Components aren’t supported by browsers</li><li>Web Components can’t be used in JavaScript Frameworks and Libraries</li><li>Web Components are dead</li><li>Web Components cannot accept complex data</li><li>You are forced to use Shadow DOM</li><li>Web Components are Google Technology</li></ol><h3>About the author</h3><p>Stefan is a JavaScript Web Developer with more than 10 years of experience. He loves to play sports, read books and occasionally jump out of planes (with a parachute that is).</p><p>☞ If you like this article, please support Stefan by <a href="https://www.buymeacoffee.com/stefannhs">buying him a coffee</a> ❤️.</p><h3>1. Web Components aren’t supported by browsers</h3><p>This screenshot was taken on May 20, 2021, from <a href="https://www.webcomponents.org/">WebComponents.org</a> and most browsers, except for <a href="https://nhswd.com/blog/web-components-101-what-are-web-components/#internet-explorer">IE11</a> and <a href="https://nhswd.com/blog/web-components-101-what-are-web-components/#safari">Safari</a>, offer full support for Web Components.</p><h3>2. Web Components can’t be used in JavaScript Frameworks and Libraries</h3><p>The support for Web Components in frameworks and libraries like Angular and VueJs is excellent and ever-growing! Just a quick peek at <a href="https://custom-elements-everywhere.com/">Custom Elements Everywhere</a> tells you that Custom Elements are fully supported by almost every popular framework and library. The only caveat is React. It does support Web Components, but <a href="https://nhswd.com/blog/web-components-101-what-are-web-components/#web-components-and-framework-support">not entirely</a>.</p><h3>3. Web Components are dead</h3><p>Many people claim that Web Components are dead, not supported completely, and will never find a place in <em>mainstream development</em>, whatever that may be.</p><p>But, in fact, the opposite is true. Custom Elements are more popular than ever! More than <a href="https://nhswd.com/blog/web-components-101-what-are-web-components">10 percent of all page loads in Google Chrome</a> are pages that contain Web Components.</p><p>Besides that, companies like Mc Donalds, Apple, GitHub, Twitter, Google, Salesforce, ING &amp; SAP are using Web Components for both their public-facing applications as internal tools.</p><p>Browser support is flourishing as well as JavaScript framework support. I think that we safely could say: Web Components have never been so alive!</p><h3>4. Web Components cannot accept complex data</h3><p>This idea originates from a fundamental misunderstanding of the DOM and its inner workings. Four misconceptions are:</p><ol><li>Custom Elements are HTML Elements.</li><li>HTML Elements don’t have properties; only attributes.</li><li>Attributes can only be strings.</li><li>Web Components can only accept strings in attributes.</li></ol><p>Custom Elements are indeed HTML Elements but are DOM nodes as well, and because of that, accept complex data as properties, using JavaScript and the DOM.</p><h3>5. You are forced to use Shadow DOM</h3><p>Never used Custom Elements without the Shadow DOM? Think again. Just go to <a href="https://github.com/">GitHub</a>, open the Developer’s console and paste the following code:</p><pre>const isCustomElement = ({ tagName }) =&gt; tagName.includes(`-`);<br>const usesShadowDom = ({ shadowRoot }) =&gt; !!shadowRoot;<br>const allCustomElements = [...document.querySelectorAll(`*`)].filter(<br>  isCustomElement<br>);<br>console.log(`All Custom Elements: ${allCustomElements}`);<br>console.log(<br>  `All Custom Elements w/ Shadow DOM: ${allCustomElements.filter(<br>    usesShadowDom<br>  )}`<br>);</pre><p><a href="https://nhswd.com/blog/web-components-101-what-are-web-components/#3-shadow-dom">Shadow DOM is extremely powerful</a>, because it encapsulates your components and prevents CSS and JavaScript from leaking in and out, but is completely optional. Here’s a simple, and shadowless, example that works perfectly:</p><pre>class ElementWithoutShadowDom extends HTMLElement {<br>  constructor() {<br>    super().innerHTML = `&lt;div&gt;A Custom Element without Shadow DOM&lt;/div&gt;`;<br>  }<br>}</pre><pre>customElements.define(`no-shadow`, ElementWithoutShadowDOM);</pre><h3>6. Web Components are Google Technology</h3><p>The Web Components specs are open standards with multiple contributors and stakeholders.</p><p>For example:</p><ul><li>The <a href="https://github.com/WICG/webcomponents/blob/gh-pages/proposals/html-modules-proposal.md">HTML Module proposal</a> was picked up by Microsoft.</li><li>The <a href="https://github.com/WICG/webcomponents/blob/gh-pages/proposals/Template-Instantiation.md">HTML Template Instantiation</a> was proposed by Apple.</li><li>The <a href="https://github.com/WICG/webcomponents/issues/776">IDE standardization for Web Components initiative</a> was lead by the Visual Studio Code (VSCode) Team.</li></ul><h3>Final thoughts</h3><p>There are lots of false claims about Web Components, and today, we’ve debunked six of them. With support from (almost all) browsers, major JavaScript Frameworks and Libraries, and (big tech) companies, its popularity is growing every day. There is no reason you shouldn’t use it.</p><p>I hope you’ll try this fully native, interoperable, flexible, and reusable technology soon!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=641ddff3ba04" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tutorial: How to create a Web Component?]]></title>
            <link>https://stefannhs.medium.com/tutorial-how-to-create-a-web-component-a378ebab2156?source=rss-fbbe86fcf55a------2</link>
            <guid isPermaLink="false">https://medium.com/p/a378ebab2156</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[web-components]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Stefan Nieuwenhuis]]></dc:creator>
            <pubDate>Tue, 25 May 2021 16:38:38 GMT</pubDate>
            <atom:updated>2021-05-26T14:20:49.112Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*70EeBW0dU3BgkcpWsK6ccw.png" /></figure><p>Welcome back to the Web Components 101 Series! We’re going to discuss the state of Web Components, provide expert advice, give tips and tricks and reveal the inner workings of Web Components.</p><p>In today’s tutorial, we’re going to teach you the fundamentals of Web Components by building a &lt;name-tag&gt; component step by step!</p><p>First, we have to learn the rules. Then, we’re going to set up our development environment.</p><p>Next, we’ll define a new HTML element, going to learn how to pass attributes, create and use the <a href="https://nhswd.com/blog/web-components-101-what-are-web-components/#3-shadow-dom">Shadow DOM</a>, and use <a href="https://nhswd.com/blog/web-components-101-what-are-web-components/#2-html-templates">HTML templates</a>.</p><h3>About the author</h3><p>Stefan is a JavaScript Web Developer with more than 10 years of experience. He loves to play sports, read books and occasionally jump out of planes (with a parachute that is).</p><p>☞ If you like this article, please support me by <a href="https://www.buymeacoffee.com/stefannhs">buying me a coffee</a> ❤️.</p><h3>Other posts in the Web Components 101 series</h3><ul><li><a href="https://nhswd.com/blog/web-components-101-what-are-web-components">What are Web Components?</a></li><li><a href="https://nhswd.com/blog/web-components-101-why-use-web-components">Why use Web Components?</a></li><li><a href="https://nhswd.com/blog/web-components-101-tutorial-how-to-create-a-web-component">[Tutorial] How to create a Web Component?</a> (<em>this post</em>)</li></ul><h3>What are we going to build today?</h3><h3>The basic rules</h3><p>Even Web Components have basic rules and if we play by them, the possibilities are endless! We can even include emojis or non-Latin characters into the names, like &lt;animal-😺&gt; and &lt;char-ッ&gt;.</p><p>These are the rules:</p><ol><li>You can’t register a Custom Element more than once.</li><li>Custom Elements cannot be <a href="https://dev.w3.org/html5/html-author/#start-tag">self-closing</a>.</li><li>To prevent name clashing with existing HTML elements, <a href="https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name">valid names</a> should:</li></ol><ul><li>Always include a hyphen (-) in its name.</li><li>Always be lower case.</li><li>Not contain any uppercase characters.</li></ul><h3>Setting up our development environment</h3><p>For this tutorial, we’re going to use the Components IDE from the good folks at WebComponents.dev. No set up required! Everything is already in place and properly configured, so we can start developing our component straight away. It even comes with <a href="https://storybook.js.org/">Storybook</a> and <a href="https://mochajs.org/">Mocha</a> preinstalled and preconfigured.</p><h3>Steps to set up our dev env</h3><ol><li>Go to the <a href="https://webcomponents.dev/edit/VGwFgdGkk1ayG8xf5p7h">Components IDE</a></li><li>Click the <em>Fork</em> button in the top right of the screen to create your copy.</li><li>Profit! Your environment is set up successfully.</li></ol><h3>Defining a new HTML Element</h3><p>Let’s have a look at index.html.</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>  &lt;head&gt;<br>    &lt;meta charset=&quot;UTF-8&quot; /&gt;<br>    &lt;script src=&quot;./dist/name-tag.js&quot; type=&quot;module&quot;&gt;&lt;/script&gt;  &lt;/head&gt;</pre><pre>  &lt;body&gt;<br>    &lt;h3&gt;Hello World&lt;/h3&gt;<br>    &lt;name-tag&gt;&lt;/name-tag&gt;  &lt;/body&gt;<br>&lt;/html&gt;</pre><p>We include our component with a &lt;script&gt;. This allows us to use our component, just like any other HTML elements in the &lt;body&gt; of our page.</p><p>But we don’t see anything yet, our page is empty. This is because our name tag isn’t a proper HTML Tag (yet). We have to define a new HTML Element and this is done with JavaScript.</p><ol><li>Open name-tag.js and create a class that extends the <a href="https://html.spec.whatwg.org/multipage/dom.html#htmlelement">base HTMLElement class</a>.</li><li>Call super() in the class constructor. Super sets and returns the component&#39;s this scope and ensures that the right property chain is inherited.</li><li>Register our element to the <a href="https://html.spec.whatwg.org/multipage/custom-elements.html#custom-elements-api">Custom Elements Registry</a> to teach the browser about our new component.</li></ol><p>This is how our class should look like:</p><pre>class UserCard extends HTMLElement {<br>  constructor() {<br>    super();<br>  }<br>}</pre><pre>customElements.define(&#39;name-tag&#39;, UserCard);</pre><p>Congrats! You’ve successfully created and registered a new HTML Tag!</p><h3>Passing values to the component with HTML attributes</h3><p>Our name tag doesn’t do anything interesting yet. Let’s change that and display the user’s name, that we pass to the component with an name attribute.</p><blockquote><em>Attributes provide extra information about HTML tags, always come in name/value pairs, and could only contain strings.</em></blockquote><p>First, we have to add an name attribute to the &lt;name-tag&gt; in <em>index.html</em>. This enables us to pass and read the value from our component</p><pre>&lt;name-tag name=&quot;John Doe&quot;&gt;&lt;/name-tag&gt;</pre><p>Now that we’ve passed the attribute, it’s time to retrieve it! We do this with the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttribute">Element.getAttribute() method</a> that we add to the components constructor().</p><p>Finally, we’re able to push the attribute’s value to the component&#39;s inner HTML. Let’s wrap it between a &lt;h3&gt;.</p><p>This is how our components class should look like:</p><pre>class UserCard extends HTMLElement {<br>  constructor() {<br>    super();</pre><pre>    this.innerHTML = `&lt;h3&gt;${this.getAttribute(&#39;name&#39;)}&lt;/h3&gt;`;<br>  }<br>}<br>...</pre><p>Our component now outputs “John Doe”.</p><h3>Add global styling</h3><p>Let’s add some global styling to see what happens.</p><p>Add the following CSS to the &lt;head&gt; in index.html and see that the component&#39;s heading color changes to Rebecca purple:</p><pre>&lt;style&gt;<br>  h3 {<br>    color: rebeccapurple;<br>  }<br>&lt;/style&gt;</pre><h3>Create and use the Shadow DOM</h3><p>Now it’s time to get the Shadow DOM involved! This ensures the encapsulation of our element and prevents CSS and JavaScript from leaking in and out.</p><ol><li>Add this.attachShadow({mode: &#39;open&#39;}); to the component&#39;s constructor (<a href="https://nhswd.com/blog/web-components-101-what-are-web-components/#3-shadow-dom">read more about Shadow DOM modes here</a>).</li><li>We also have to attach our innerHTML to the shadow root. Replace this.innerHTML with this.shadowRoot.innerHTML.</li></ol><p>Here is the diff of our <em>constructor</em>:</p><pre>...<br>constructor() {<br>  super();<br>  this.attachShadow({mode: &#39;open&#39;});<br>- this.innerHTML = `&lt;h3&gt;${this.getAttribute(&#39;name&#39;)}&lt;/h3&gt;`;<br>+ this.shadowRoot.innerHTML = `&lt;h3&gt;${this.getAttribute(&#39;name&#39;)}&lt;/h3&gt;`;<br>}<br>...</pre><p>Notice that the global styling isn’t affecting our component anymore. The Shadow DOM is successfully attached and our component is successfully encapsulated.</p><h3>Create and use HTML Templates</h3><p>The next step is to create and use <a href="https://nhswd.com/blog/web-components-101-what-are-web-components/#2-html-templates">HTML Templates</a>.</p><p>First, we have to create a const template outside our components class in <em>name-tag.js</em>, create a new <em>template</em> element with the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/createElement">Document.createElement() method</a> and assign it to our const.</p><pre>const template = document.createElement(&#39;template&#39;);<br>template.innerHTML = `<br>  &lt;style&gt;<br>    h3 {<br>      color: darkolivegreen; //because I LOVE olives<br>    }<br>  &lt;/style&gt;</pre><pre>  &lt;div class=&quot;name-tag&quot;&gt;<br>    &lt;h3&gt;&lt;/h3&gt;<br>  &lt;/div&gt;<br>`;</pre><p>With the template in place, we’re able to clone it to the components Shadow Root. We have to replace our previous “HTML Template” solution.</p><pre>...</pre><pre>class UserCard extends HTMLElement {<br>  constructor(){<br>    super();<br>    this.attachShadow({mode: &#39;open&#39;});</pre><pre>-   this.shadowRoot.innerHTML = `&lt;h3&gt;${this.getAttribute(&#39;name&#39;)}&lt;/h3&gt;`;<br>+   this.shadowRoot.appendChild(template.content.cloneNode(true));<br>  }<br>}<br>...</pre><h3>What about passing attributes?!</h3><p>Although we’ve added some styles, we see a blank page again. Our attribute values aren’t rendered, so let’s change that.</p><p>We have to get out attribute’s value to the template somehow. We don’t have direct access to the scope of the component in the template, so we have to do it differently.</p><pre>&lt;div class=&quot;name-tag&quot;&gt;<br>  &lt;h3&gt;${this.getAttribute(&#39;name&#39;)}&lt;/h3&gt;<br>&lt;/div&gt;</pre><p>This won’t work since we don’t have access to the component’s scope in the template.</p><p>We have to query the Shadow DOM for the desired HTML Element (i.e. &lt;h3&gt;) and push the value of the attribute to its inner HTML.</p><pre>constructior() {<br>  ...<br>  this.shadowRoot.querySelector(&#39;h3&#39;).innerText = this.getAttribute(&#39;name&#39;);<br>}</pre><p>The result is that we see <em>“John Doe”</em> again on our page and this time, it’s colored differently and the heading on the main page stays Rebecca purple! The styling we’ve applied works like a charm and is contained to the Shadow DOM. Just like we wanted to: No leaking of styles thanks to our component’s encapsulating properties.</p><h3>Bonus: Update styles</h3><p>Update the &lt;style&gt; in the template to make our component look a bit more appealing:</p><pre>.name-tag {<br>  padding: 2em;</pre><pre>  border-radius: 25px;</pre><pre>  background: #f90304;</pre><pre>  font-family: arial;<br>  color: white;<br>  text-align: center;</pre><pre>  box-shadow: 2px 2px 5px 0px rgba(0, 0, 0, 0.75);<br>}</pre><pre>h3 {<br>  padding: 2em 0;<br>  background: white;<br>  color: black;<br>}</pre><pre>p {<br>  font-size: 24px;<br>  font-weight: bold;<br>  text-transform: uppercase;<br>}</pre><h3>Closing thoughts about how to create a Web Component from scratch</h3><p>The game of Web Components has to be played by a handful of basic rules but when played right, the possibilities are endless! Today, we’ve learned step by step how to create a simple, &lt;name-tag&gt; component by defining Custom Elements, passing HTML attributes, connecting the Shadow DOM, defining and cloning HTML templates, and some basic styling with CSS.</p><p>I hope this tutorial was useful and I hope to see you next time!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a378ebab2156" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Web Components 101: Why use Web Components?]]></title>
            <link>https://stefannhs.medium.com/web-components-101-why-use-web-components-a7e809fb5aef?source=rss-fbbe86fcf55a------2</link>
            <guid isPermaLink="false">https://medium.com/p/a7e809fb5aef</guid>
            <category><![CDATA[web-components]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[javascript-frameworks]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Stefan Nieuwenhuis]]></dc:creator>
            <pubDate>Fri, 21 May 2021 15:50:35 GMT</pubDate>
            <atom:updated>2021-05-26T14:14:31.641Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SiM2zvffv3-OYo_Z4L4_og.png" /></figure><p>Welcome back to the Web Components 101 Series! We’re going to discuss the state of Web Components, provide expert advice, give tips and tricks and reveal the inner workings of Web Components.</p><p>In this article, we’ll explain why we’re so excited about Web Components and why you want to use them. We also do some myth-busting along the way. Are you excited already?</p><h3>Posts in the Web Components 101 series</h3><ul><li><a href="https://nhswd.com/blog/web-components-101-what-are-web-components">What are Web Components?</a></li><li><a href="https://nhswd.com/blog/web-components-101-why-use-web-components">Why use Web Components?</a> (<em>this post</em>)</li><li><a href="https://nhswd.com/blog/web-components-101-tutorial-how-to-create-a-web-component">[Tutorial] How to create a Web Component?</a></li></ul><h3>Why use Web Components?</h3><p>JavaScript frameworks offer lots of advantages:</p><ul><li><strong>Save energy</strong>. Modern JavaSCript frameworks are packed with best practices, scaffolding tools, paradigms, and industry standards, which enables us to build and publish an app in no time. It enables developers to focus on actual development instead of the tools and architecture.</li><li><strong>Reusable code</strong>. Components built with a JavaScript framework are interchangeable (within applications using the same framework), so teams don’t have to invent the square wheel twice.</li><li><strong>A common language for everyone</strong>. Using a JavaScript framework generates a common understanding between developers. Everyone <em>“speaks”</em> the same, common language and is on the same page.</li></ul><p>It’s not surprising that almost every JavaScript app is built with a (modern) JavaScript framework or library, so why should we use Web Components instead of using our favorite framework? What problems does providing a native component model solve?</p><h3>(Brand) Consistency</h3><p>Consistent applications offer user-friendly interfaces and have high conversion rates. Inconsistent applications offer the exact opposite and undermine brand consistency. Having your apps split up into component libraries or a Design System, improves brand consistency but if and only if they are compatible with all different tech stacks.</p><p>Web Components, with its web-standards-based APIs, is interchangeable between all different tech stacks and JavaScript frameworks and libraries and provides the perfect technical base for brand consistency throughout all applications.</p><h3>Maintainability</h3><p>Building sustainable and maintainable applications is one of the hardest challenges in Web Development. Code is continuously copied from one (part of the) application to another, essentially creating new versions that have to be maintained indefinitely, which results in maintenance hell.</p><p>Web Components can be maintained by one (team of) developers and shared with others. The maintainers take care of the components, while the consumers can fetch updates automatically (e.g. with <a href="https://npmjs.com/">npm</a>) and continue their work without the fear of maintenance hell.</p><h3>Reusability</h3><p><strong>K</strong>eep <strong>I</strong>t <strong>S</strong>imple <strong>S</strong>tupid, and <strong>D</strong>on’t <strong>R</strong>epeat <strong>Y</strong>ourself are the mantra’s that we keep repeating and is a key part of building comprehensible, maintainable, and reusable apps. It is one of the hardest challenges in web development. With Web Components, we’re solving this by defining markup in JavaScript. The author is free to change the HTML, CSS, and JavaScript, while the consumer can benefit from the changes automatically without the need of upgrading the code manually.</p><h3>Interoperability</h3><p>JavaScript frameworks like Angular, React and VueJs are awesome! They are packed with best practices, scaffolding tools, paradigms, and industry standards, which enable us to build and publish an app in no time, but aren’t very interoperable — they don’t communicate with each other very well. This is because they all have different, non-interchangeable component models.</p><p>Web Components are completely based on web standards and are compatible with (or without) any JavaScript library or framework. That means, that they are completely interoperable between frameworks and applications. It now becomes possible to support multiple applications with UI components from a single codebase (Design Systems and mono repositories).</p><h3>Readability</h3><p>The most important audience for our code is humans (ourselves and other people), as we are the ones who will make or break the program in the future. Unfortunately, this doesn’t always resonate and many HTML pages end up in an expressionless, and unreadable &lt;div/&gt; soup, like Google&#39;s Gmail page:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kQDY-2RDodpBdiqw-aRm1g.png" /></figure><p>Web Components allows us to organize the &lt;div/&gt; soup into comprehensible, readable, semantic-friendly code by creating custom elements wherever we see fit. Here&#39;s an example of how it would look like:</p><pre>&lt;google-mail&gt;<br>  &lt;mail-list&gt;<br>    &lt;mail-item from=&quot;john.doe@company.com&quot;&gt;<br>      &lt;h2&gt;Hello World&lt;/h2&gt;<br>      &lt;article&gt;<br>        &lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit.&lt;/p&gt;<br>      &lt;/article&gt;<br>    &lt;/mail-item&gt;<br>  &lt;/mail-list&gt;<br>&lt;/google-mail&gt;</pre><h3>Full encapsulation</h3><p>The <a href="https://nhswd.com/blog/web-components-101-what-are-web-components/#3-shadow-dom">Shadow DOM</a> allows web browsers to isolate DOM fragments. It means that we don’t have to worry about styles and logic leaking to and from our Web Components. In other words: They are fully encapsulated.</p><h3>Web Components are perfectly compatible with any JavaScript framework of library</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*ebkYvO-Oj3IV82uobIYvJg.png" /></figure><p>As mentioned in <a href="https://nhswd.com/blog/web-components-101-what-are-web-components/#web-components-and-framework-support">the first article of the Web Components 101 Series</a>, the support for Web Components from JavaScript frameworks and libraries is excellent and growing! Web Components can be used with:</p><ul><li>Angular</li><li>AngularJs</li><li>React</li><li>Vue.js</li><li>Svelte</li><li>Vanilla JavaScript</li></ul><h3>Busting myths about Web Components</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*Dp7R3Dldwa7og1CDP1Vjgg.png" /></figure><p>Why not use Web Components? There are a lot of myths about why not to use Web Components. The main reason is that they are built on <a href="https://www.w3.org/TR/">evolving web standards</a>, which have their flaws and limitations. I’ve seen some myths go around and now it’s time to bust them!</p><h3>Web Components can’t be server-side rendered (SRR)</h3><p><strong>Busted!</strong> Since Web Components are based on web standards, they can be server site rendered perfectly. It might be hard to do if you build a solution from scratch, but libraries like <a href="https://github.com/skatejs/ssr">SkateJs</a> and <a href="https://stenciljs.com/">Stencil</a> will do all the heavy lifting for you.</p><h3>Web Components don’t work with JavaScript frameworks/libraries</h3><p>Both true and false. As mentioned in <a href="https://nhswd.com/blog/web-components-101-what-are-web-components/#web-components-and-framework-support">the first article of the Web Components 101 Series</a>, all JavaScript frameworks, except React are fully compatible. React supports Web Components, but passes all data to Custom Elements in the form of HTML attributes. For primitive data this is fine, but the system breaks down when passing rich data, like objects or arrays. Developers will need to reference their Custom Elements using a ref and manually attach event listeners with addEventListener.</p><h3>Web Components aren’t accessible (a11y)</h3><p><strong>Busted!</strong> The main reason why folks think that Web Components aren’t accessible is that HTML content is included in the Shadow DOM and not the main DOM, but in reality, this doesn’t affect accessibility at all! The a11y information is exposed correctly through the <a href="https://www.w3.org/TR/core-aam-1.1/">accessibility API</a> and screenreaders can access content in the Shadow DOM without any difficulties.</p><h3>Web Components aren’t production-ready</h3><p><strong>Busted!</strong> Folks assume that because Web Components are built on evolving web standards, they aren’t production-ready but that’s not true! All W3 standards are continuously evolving and that means that no technology would ever be production-ready, which is nonsense.</p><p>Besides that, <a href="https://dev.to/ionic/apple-just-shipped-web-components-to-production-and-you-probably-missed-it-57pf">Apple</a>, <a href="https://dev.to/ionic/apple-just-shipped-web-components-to-production-and-you-probably-missed-it-57pf">Salesforce</a>, and <a href="https://github.blog/2021-05-04-how-we-use-web-components-at-github/">GitHub</a> are all using Web Components in production. Do you need more proof?</p><h3>Closing thoughts about why we use Web Components</h3><p>Although JavaScript frameworks and libraries offer developers many perks, they have their drawbacks as well and this is where Web Components can fill the gap perfectly. Based on web standards, Web Components are perfect for (brand) consistency, are maintainable, reusable, interoperable, and readable. They are also fully compatible with (or without) any JavaScript framework/library and offer full encapsulation.</p><p>Many myths account for a negative image of Web Components and why folks aren’t using them, but most of them are busted and nothing stands in the way of you using their full potential!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a7e809fb5aef" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Web Components 101: What are Web Components?]]></title>
            <link>https://stefannhs.medium.com/web-components-101-what-are-web-components-c37eeed3d758?source=rss-fbbe86fcf55a------2</link>
            <guid isPermaLink="false">https://medium.com/p/c37eeed3d758</guid>
            <category><![CDATA[web]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[code]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Stefan Nieuwenhuis]]></dc:creator>
            <pubDate>Thu, 20 May 2021 20:21:38 GMT</pubDate>
            <atom:updated>2021-05-26T14:20:33.063Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K_Yi5-HQ2v2cbsPmnrsv7A.png" /></figure><p>Welcome to the Web Components 101 Series! We’re going to discuss the state of Web Components, provide expert advice, give tips and tricks and reveal the inner workings of Web Components.</p><p>Today, more than 10% of all page loads in Google Chrome are pages that contain Web Components! Big tech companies like Apple, Google, and Facebook are also investigating ways of using Web Components in their applications and JavaScript Frameworks (e.g. Angular and React). Quite impressive for a technology officially introduced in 2011 and standardized only recently.</p><p>Web Components are getting more popular every day, that’s why this is the perfect moment to start learning about this awesome technology!</p><h3>About the author</h3><p>Stefan is a JavaScript Web Developer with more than 10 years of experience. He loves to play sports, read books and occasionally jump out of planes (with a parachute that is).</p><p>☞ If you like this article, please support me by <a href="https://www.buymeacoffee.com/stefannhs">buying me a coffee</a> ❤️.</p><h3><strong>Posts in the Web Components 101 series</strong></h3><ul><li><a href="https://nhswd.com/blog/web-components-101-what-are-web-components">What are Web Components?</a> (<em>this post)</em></li><li><a href="https://nhswd.com/blog/web-components-101-why-use-web-components">Why use Web Components?</a></li><li><a href="https://nhswd.com/blog/web-components-101-tutorial-how-to-create-a-web-component">[Tutorial] How to create a Web Component?</a> (<em>this post</em>)</li></ul><h3><strong>What are Web Components?</strong></h3><p>Web Components are full HTML elements with custom templates, APIs and Tag Names. They allow you to create new HTML tags, extend existing HTML tags or extend the components from other developers. They can be used in any web application, are compatible with (or without) any JavaScript library or framework (e.g. React, Angular, Vue.js, Next.js), and will work with [all modern browsers](#web-components-and-browser-support).</p><p>Its foundation is its API, which brings a Web Standards-based way to create reusable components using nothing more than vanilla JavaScript, HTML, and CSS.</p><p>The four Standards used are:</p><ol><li>Custom Elements.</li><li>HTML Templates.</li><li>Shadow DOM.</li><li>ES Modules.</li></ol><p>Let’s have a more detailed look at these Web Standards.</p><h4><strong>1. Custom Elements</strong></h4><p><a href="https://html.spec.whatwg.org/multipage/custom-elements.html#custom-elements">Custom Elements</a> is a set of APIs that allows you to create new HTML tags. With this API, we can instruct the parser on how to properly create an element and how it reacts to changes.</p><p>There are two types of custom elements:</p><p>1. An <strong>autonomous custom element</strong>, which can be used to create completely new HTML elements.</p><p>2. A <strong>customized built-in element</strong> can be used to <em>_extend_</em> existing HTML elements or other Web Components.</p><p>So, the Custom Elements API is very useful for creating new HTML elements and extending existing or other Web Components.</p><h4><strong>2. HTML Templates</strong></h4><p>With HTML templates, we can create reusable code fragments inside a normal HTML flow that aren’t rendered immediately. They can be cloned and inserted in the document during runtime with JavaScript and scripts, and resources inside will not be fetched or executed until the template is stamped out. It also doesn’t matter how many times a template is used, since it’s cloned in the browser and only parsed once; A great performance boost!</p><p>An HTML Template syntax looks like this:</p><p>&lt;template&gt;</p><p>&lt;h1&gt;Web Components 101&lt;/h1&gt;</p><p>&lt;p&gt;HTML Templates are awesome!&lt;/p&gt;</p><p>&lt;/template&gt;</p><p>When the page renders, a template is empty. The contents are stored in a `DocumentFragment` without browsing context. This is done to prevent it from interfering with the rest of the application, meaning that it only renders when requested; Another performance boost!</p><h4><strong>3. Shadow DOM</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g6jZ5iRBiRiH8EWhvTaVjw.png" /><figcaption>The Shadow DOM Logo</figcaption></figure><p>The Shadow DOM API allows web browsers to isolate DOM fragments (including all HTML and CSS) from the main documents DOM tree. Its inner working is almost similar to that of an &lt;iframe/&gt; where the content is isolated from the rest of the document, with the main difference that we still have full control over it.</p><blockquote><strong>What is the DOM?</strong></blockquote><blockquote>With HTML, we’re able to easily create pages that have both presentation and structure. It’s very easy for us humans to understand, but computers need a bit more help: Enter the <strong>D</strong>ocument <strong>O</strong>bject <strong>M</strong>odel, or DOM.</blockquote><blockquote>When the browser loads a web page, it translates the author’s HTML into a data model, which is stored in a tree of nodes. This tree is called the DOM and is a live representation of the page. It has properties, methods and the best part is that it can be manipulated by…JavaScript!</blockquote><p>The Shadow DOM shields its contents from its surrounding environment (a process called encapsulation), which prevents CSS and JavaScript code from leaking from and to a custom element.</p><h4><strong>4. ES Modules</strong></h4><p>Before ES Modules, JavaScript did not have a module system like other programming languages. Developers resorted to using `&lt;script/&gt;` tags to load JavaScript files into their applications and later on, several module definitions started (e.g CommonJS, AMD &amp; UMD) to appear but none matured to a standard. This changed with the introduction of ES Modules and we finally have a standard module system.</p><p>The ES Modules API brings a standardized module system to JavaScript, which provides a way of bundling a collection of features into a library that can be reused in other JavaScript files.</p><h3><strong>Web Components and Browser Support</strong></h3><p>Which browsers support Web Components? Currently, all Evergreen browsers (Chrome, Firefox, and Edge) offer full support for Web Components. That means all APIs (i.e. Custom Elements, HTML Templates, Shadow DOM, and ES Modules) are fully supported!</p><p>This screenshot from <a href="https://webcomponents.org/">WebComponents.org</a> shows the current browser support for Web Components.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X9gCvj3hqOfG5ftIZAMwog.png" /><figcaption>Which browsers support Web Components?</figcaption></figure><p>The exceptions are Internet Explorer 11, and Safari. <a href="https://techcommunity.microsoft.com/t5/microsoft-365-blog/microsoft-365-apps-say-farewell-to-internet-explorer-11-and/ba-p/1591666">Microsoft stops supporting IE11</a> on August 17, 2021, and in the meantime, <a href="https://github.com/WebComponents/webcomponentsjs">polyfills</a> are available to simulate the missing browser capabilities as close as possible. Unfortunately, Safari is falling behind as well and doesn’t support Web Components, nor does Apple plan to fully support it in the future. Polyfills must be used for this browser as well.</p><h3><strong>Closing thoughts about Web Components</strong></h3><p>Modern Web Development becomes more complex every day, and, now that the Web Platform and its standards are maturing, it makes more sense to use them more intensively. Web Components are the perfect example, based on 4 web-standard-based APIs (Custom Elements, HTML Templates, Shadow DOM, and ES Modules).</p><p>Its ever-increasing popularity proofs that Web Components are here to stay and that now is the perfect time to start learning about this amazing technology!</p><p>In the second post of the series, we’re gonna discuss why Web Components are so amazing and why you want to use them.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c37eeed3d758" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GitHub private repositories: A blessing or a curse?]]></title>
            <link>https://stefannhs.medium.com/github-private-repositories-a-blessing-or-a-curse-f231d9c1c225?source=rss-fbbe86fcf55a------2</link>
            <guid isPermaLink="false">https://medium.com/p/f231d9c1c225</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[github]]></category>
            <dc:creator><![CDATA[Stefan Nieuwenhuis]]></dc:creator>
            <pubDate>Wed, 09 Jan 2019 12:45:12 GMT</pubDate>
            <atom:updated>2019-01-10T08:58:03.524Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3GSBlI_I1S1jW_Wn0pkIOg.jpeg" /></figure><p>Yesterday Github <a href="https://blog.github.com/2019-01-07-new-year-new-github/">announced</a> that a free subscription now includes unlimited private repositories. It’s accepted with great applause in the developers community, but is it really such great news?</p><h3>GitHub on Twitter</h3><p>New year, new upgrades. Introducing unlimited free private repositories, and a new unified Enterprise product. https://t.co/6YB1BynM4A</p><h3>Some numbers about GitHub in 2018</h3><p>According to <a href="https://octoverse.github.com/">The State of the Octoverse</a>, GitHub has:</p><ul><li>31M+ active developers;</li><li>2.1M+ active organizations;</li><li>96M+ repositories (both public and private);</li><li>200M+ pull requests created.</li></ul><h3>Collaboration</h3><p>GitHub is the largest community of developers in the world. Most (new) users come from the USA (more than 80%), but in the past year increasing numbers are coming from China, India and the U.K. The role that the company plays in the global collaboration between developers is therefore increasing continuously. The biggest drivers of this success are the open repositories, because every user is capable of contributing. Due to the fact that it’s now possible for GitHub Free users to create unlimited private repositories, the number of open repositories will decrease and this will have adverse effects on the worldwide collaboration between developers.</p><h3>Learning</h3><p>1.1M+ Students, which are verified through the <a href="https://education.github.com/pack">Student Developer Pack</a> application, have learned to code via GitHub. 600K+ are active and the number is still growing. In 2018 the number grew by 18 percent. Besides that 20K+ teachers are using GitHub on a regular basis in their day-to-day jobs. They implement real-world developer workflows and together created more than 200K assignments and more than 18K schools (from high schools, universities, coding bootcamps and beyond) are using Github. They use GitHub and GitHub Classroom to host courses, distribute assignments, and get insight into student progress. And they often end up teaching well beyond their campuses.</p><p>A survey amongst the <a href="https://education.github.community/">GitHub Education Community</a> showed that 48% of students said using GitHub in the classroom helped make them feel like they belonged in the software development field. 31% of surveyed students said using GitHub made them feel “very prepared” for a future internship or career in software development.</p><blockquote>When surveying students who didn’t use GitHub in their classrooms, only 14% said they felt this way.</blockquote><p>Here too, the effects will be clearly visible. The strength of open repositories is that users have the ability to learn from other developers, teachers and institutes as well as to help other users to develop themselves. With the arrival of private repositories, the number of open repositories will decrease, making it more difficult to connect developers. The threshold is greatly increased to share knowledge and learn from each other. It is quite possible that in the future it will be impossible to learn from each other in a free, open way.</p><h3>In conclusion</h3><p>GitHub is all about collaboration, sharing knowledge and learning from each other, but with the advent of unlimited private repositories for GitHub Free users this concept is in danger. With an increase in private repositories, the number of open source projects / repositories will decrease and cooperation between developers worldwide will be made more difficult.</p><p>This will also have a major impact on the way of sharing knowledge and learning from each other. Open repositories have been the way this is done for years, but an increase in private repositories will make this process difficult or impossible.</p><p>The future will tell us whether it actually goes this way and this article is mainly intended to start the discussion and ask us if going private is the way to go.</p><h3>About the author</h3><blockquote><em>☞ If you like this post you can </em><a href="http://buymeacoff.ee/e4dSKLnlC"><em>buy me a coffee</em></a><em>.</em></blockquote><blockquote><em>☞ </em><a href="https://medium.com/@stefannhs"><em>Stefan</em></a><em> reads every response on Medium or reply on </em><a href="https://twitter.com/stefannhs"><em>Twitter</em></a><em>, so don’t hesitate to let him know what you think.</em></blockquote><blockquote><em>☞ To hear from the author in the future, check out his </em><a href="https://github.com/stefannieuwenhuis"><em>GitHub</em></a><em>, </em><a href="https://www.linkedin.com/in/stefannhs/"><em>LinkedIn</em></a><em> profile or </em><a href="https://twitter.com/stefannhs"><em>follow him on Twitter</em></a><em>.</em></blockquote><blockquote><em>☞ </em><strong><em>Please tap or click “♥︎” </em></strong><em>to help to promote this article to others.</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f231d9c1c225" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to build modals with StencilJS?]]></title>
            <link>https://medium.com/stencil-tricks/how-to-build-modals-with-stenciljs-f3e18caf86cf?source=rss-fbbe86fcf55a------2</link>
            <guid isPermaLink="false">https://medium.com/p/f3e18caf86cf</guid>
            <category><![CDATA[html]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[web-components]]></category>
            <category><![CDATA[stenciljs]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Stefan Nieuwenhuis]]></dc:creator>
            <pubDate>Thu, 27 Dec 2018 16:04:35 GMT</pubDate>
            <atom:updated>2019-12-20T19:19:25.091Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*CkGR7IQ0l5A5lzG6" /><figcaption>Photo by <a href="https://unsplash.com/photos/NPsqco-tNR0?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Gavin Allanwood</a> on <a href="https://unsplash.com/search/photos/information-panel?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>How to build modals with Stencil TDD style?</h3><p><em>Stefan helps developers to become Framework Agnostic. If you find his content helpful, you can buy him a coffee </em><a href="https://www.buymeacoffee.com/stefannhs"><em>here</em></a><em> and get his exclusive e-book “10 reasons to go framework-agnostic” for free!</em></p><p>Allow me to show you how to build modals with Stencil.</p><p>Coding with relatively new tools can be challenging due to the lack of (good) tutorials. Especially when you have a specific thing like a modal overlay in mind.</p><p>So, that’s why I’ve decided to build my own modal overlay component with StencilJS and share my experiences and to write this tutorial to help you understand the possibilities of StencilJS.</p><p><em>Check out </em><a href="https://github.com/StefanNieuwenhuis/stenciljs-modal-overlay"><em>this repo</em></a><em> for the source.</em></p><h3>What is Stencil?</h3><p>Stencil is a compiler that generates Web Components which combines the best concepts of the most popular frameworks into a simple build-time tool. It provides extra APIs that makes writing fast components simpler. APIs like Virtual DOM, JSX, and async rendering make fast, powerful components easy to create, while still maintaining 100% compatibility with Web Components.</p><p>The developer experience is also tuned, and comes with live reload and a small dev server baked in to the compiler.</p><p>Stencil was created by the <a href="http://ionicframework.com/">Ionic Framework</a> team to help build faster, more capable components that worked across all major frameworks.</p><h3>Let’s start building a Modal</h3><p>One common and frequently used UI component is a modal window, a content container that displays above the rest of the content and contains a clear call to action. It’s sometimes accompanied by an overlay that covers the rest of the web page or app. And that is what we’re going to build today!</p><h4>Component design</h4><p>The name of our component is: my-component. This is the default name generated by the starter and for convenience and keeping this tutorial in scope, I’ve decided to let the name as is. You’re completely free to rename it at any time.</p><p>The component has the following attributes:</p><ol><li><strong>Open</strong>&lt;boolean&gt;: Shows the modal window component;</li><li><strong>Transparent</strong>&lt;boolean&gt;: Toggles transparency of the overlay;</li></ol><p>The components has the following method:</p><ol><li><strong>render</strong>: Renders content to the screen.</li></ol><h3>Setting up our application</h3><p>Before we can start building our component we have to setup a development environment, which is very easy with the starter, provided by our friends from Stencil.</p><blockquote>Note: You need npm v6 or higher in order to complete this tutorial!</blockquote><p>Stencil can be used to create standalone components, or entire apps. Open a new terminal window and run the following command:</p><pre>npm init stencil</pre><p>After running init you will be provided with a prompt so that you can choose the type of project to start.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*nbd28FNv1Ih2nyX8sbzYqQ.png" /></figure><p>Since we’re building a single component, select the third option, which generates a development environment, installs all necessary dependencies and scaffolds the component’s code.</p><p>The next step is to provide a name for the project. For this tutorial it doesn’t really matter which name you pick. I wanted to be extremely original and named my project: my-modal.</p><p>Stencil provides the developer with a very basic, hello world example to understand a bit better what’s going on and how an application is organized. It’s not in the tutorial’s scope to elaborate on this, but you can read more about this <a href="https://stenciljs.com/docs/my-first-component">here</a>.</p><p>Alright! We’re done setting up our application’s infrastructure!</p><h3>Writing our first tests</h3><p>Since we’re creating a component TDD style, let’s start of right away with writing our first tests.</p><p>Stencil provides many utility functions to help test <a href="https://jestjs.io/">Jest</a> and <a href="https://pptr.dev/">Puppeteer</a>. For example, a component’s Shadow Dom can be queried and tested with the Stencil utility functions built on top of Puppeteer. Tests can not only be provided mock HTML content, but they can also go to URLs of your app which Puppeteer is able to open up and test on Stencil’s dev server.</p><p>The starter generated a test file already (./src/components/my-component/my-component.e2e.ts) , which contains a few basic unit tests to get the gist on testing Web Components. Open this file, study it and replace it with the following content:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/973cd6009e85deb34b0302e4866abc4b/href">https://medium.com/media/973cd6009e85deb34b0302e4866abc4b/href</a></iframe><p>What happened?</p><ol><li>We import the necessary packages from the testing libraries provided in Stencil core.</li><li>We create a my-component element and append it to the DOM. This is done in the beforeEach method, which is called before every unit test.</li><li>We expect that my-component successfully renders in the DOM.</li><li>We expect that we find a div decorated with a class, calledoverlay.</li></ol><p>Let’s run our tests with the following command:</p><pre>npm run test</pre><p>…Only to see that all of them fail. So let’s change that immediately!</p><p>Open ./src/components/my-component/my-component.tsx, study the example code and replace it with the following:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0b09ba650e30410385e12a2563a13eae/href">https://medium.com/media/0b09ba650e30410385e12a2563a13eae/href</a></iframe><p>Notice the following parts of the component:</p><ol><li>The @Component decorator. This decorator provides metadata about our component to the compiler.</li><li>You find a default <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes">ES6 JavaScript Class</a> right under the decorator. This is where you’ll write the bulk of your code to bring the component to life.</li><li>In the class you find the render() function. This is used by the component to render content to the screen. It returns <a href="http://buildwithreact.com/tutorial/jsx">JSX</a>.</li><li>In the html template, you find a <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/slot">&lt;slot/&gt;</a> container, which is a placeholder inside a web component that you can fill with your own markup.</li></ol><p>Learn more about Stencil components <a href="https://stenciljs.com/docs/my-first-component/">here</a>.</p><p>If we run the tests again, they all pass. Hooray! Now it’s time to implement more logic and make our component actually useful.</p><h3>Opening the modal window</h3><p>Before we start implementing the logic for opening the modal, let’s write some more tests.</p><p>We want to cover the following cases:</p><ol><li>It should display the overlay while the modal is open.</li><li>If set, the overlay should be transparent.</li></ol><p>This results in the following test cases, which you need to add to the test file:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f8bfceda3d306fecf8866ad3d91216a0/href">https://medium.com/media/f8bfceda3d306fecf8866ad3d91216a0/href</a></iframe><p>Whoah! What happened here?</p><ol><li>We set different properties (open &amp; transparent) with the component.setProperty() method.</li><li>We wait for the changes made to the component with the waitForChanges() method. Both Stencil and Puppeteer have an asynchronous architecture, which is a good thing for performance. Since all calls are async, it&#39;s required that await page.waitForChanges() is called when changes are made to components.</li><li>We check if the element is decorated with the expected CSS classes.</li></ol><p>Read more about testing Stencil components <a href="https://stenciljs.com/docs/end-to-end-testing">here</a>.</p><p>And, of course, if we run our tests they’ll fail miserably again, so let’s open the component’s code (my-component.tsx) and make the tests pass.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1a277b4730606788496499cd195c8d45/href">https://medium.com/media/1a277b4730606788496499cd195c8d45/href</a></iframe><p>What did we do?</p><ol><li>We’ve added properties open &amp; transparent. They can be recognized by the <a href="https://stenciljs.com/docs/properties">@Prop()</a> decorator, a class that’s imported from @stencil/core.</li><li>We’ve changed our class definition in the HTML template and check if we need to make the modal visible and make the overlay transparent.</li></ol><h3>Closing the modal window</h3><p>In order to close the modal, we need to set the open property to false. We’ll implement a method for that in our sample code later.</p><p>Let’s write the tests necessary and make them pass:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6c2875889adba944243dfec4bc77e05e/href">https://medium.com/media/6c2875889adba944243dfec4bc77e05e/href</a></iframe><p>All tests are in green again and we have a fully operating modal, which looks terrible…</p><p>Add the following styling classes to ./src/components/my-component/my-component.css:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ce188fb45fdd54171573fb61b0208d03/href">https://medium.com/media/ce188fb45fdd54171573fb61b0208d03/href</a></iframe><p>Looks much better now!</p><h3>The proof is in the pudding</h3><p>All what we’ve done is writing tests and make them pass by adding code to the component, but the real proof is to check if it actually works, so let’s update our index.html file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a83c9b8ebc3e4e4bf3e7c16defe642aa/href">https://medium.com/media/a83c9b8ebc3e4e4bf3e7c16defe642aa/href</a></iframe><p>Here we create an instance of the component itself and decorate it with an id in order to be able to access it later on. We also added a button, which act as trigger to open the modal.</p><p>In the script we created two references. One for the modal component and one for the button. Next we’ve created two events to test if opening and closing it works properly.</p><p>Last, but not least, we added an eventListener to the modal itself, which listens for a click event. If it’s triggered, the modal will close.</p><h3>It’s a wrap</h3><p>That’s it! There’s much room to improve this component, like extending the modal content container template with a header and footer, cancel/confirmation buttons, etc. etc. If you see any points for improvement or spot a mistake in my code, please please leave create a pull request or leave a message in the comments!</p><p><em>Feel free to check out the code in </em><a href="https://github.com/StefanNieuwenhuis/stenciljs-modal-overlay"><em>this git repository</em></a><em>.</em></p><h3>About the author</h3><blockquote><em>☞ If you liked this post you can </em><a href="http://buymeacoff.ee/e4dSKLnlC"><em>buy me a coffee</em></a><em>.</em></blockquote><blockquote><em>☞ </em><a href="https://medium.com/@stefannhs"><em>Stefan</em></a><em> reads every response on Medium or reply on </em><a href="https://twitter.com/stefannhs"><em>Twitter</em></a><em>, so don’t hesitate to let him know what you think.</em></blockquote><blockquote><em>☞ To hear from the author in the future, </em><a href="https://gist.github.com/StefanNieuwenhuis/e656983fe50ac8c4ea67fa24cf953996"><em>check out his gists</em></a><em> or </em><a href="https://twitter.com/stefannhs"><em>follow him on Twitter</em></a><em>.</em></blockquote><blockquote><em>☞ </em><strong><em>Please tap or click “♥︎” </em></strong><em>to help to promote this piece to others.</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f3e18caf86cf" width="1" height="1" alt=""><hr><p><a href="https://medium.com/stencil-tricks/how-to-build-modals-with-stenciljs-f3e18caf86cf">How to build modals with StencilJS?</a> was originally published in <a href="https://medium.com/stencil-tricks">Stencil Tricks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to build an image uploader component with StencilJs]]></title>
            <link>https://medium.com/stencil-tricks/how-to-build-an-image-uploader-component-with-stenciljs-8265d4e8e01e?source=rss-fbbe86fcf55a------2</link>
            <guid isPermaLink="false">https://medium.com/p/8265d4e8e01e</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-components]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[stenciljs]]></category>
            <category><![CDATA[html]]></category>
            <dc:creator><![CDATA[Stefan Nieuwenhuis]]></dc:creator>
            <pubDate>Thu, 27 Dec 2018 11:40:58 GMT</pubDate>
            <atom:updated>2019-01-03T14:20:24.010Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*Jt-8nXrDEKNiA4vT" /></figure><p>Allow me to help you to build an image uploader component with StencilJS.</p><p>I was reading <a href="https://medium.freecodecamp.org/how-to-build-a-flexible-image-uploader-component-using-vue-js-2-0-5ee7fc77516">this</a> awesome tutorial by <a href="https://medium.com/u/4f00d661f885">Cathy Ha</a> about how to build an image uploader component with Vue.js. And I asked myself: How to build such a thing with StencilJS?</p><p>As Cathy already stated: Coding with a relatively new tools can be challenging due to the lack of (good) tutorials. Especially when you have a specific thing like an image uploader in mind.</p><p>So, that’s why I’ve decided to build my own image uploader component with StencilJS and share my experiences and to write this tutorial to help you understand the possibilities of StencilJS.</p><p><em>Check out </em><a href="https://github.com/StefanNieuwenhuis/stenciljs-image-upload"><em>this git repo</em></a><em> for the source.</em></p><h3>Things that we’ll implement</h3><p>We’re going to implement the following:</p><ul><li>The component is limited to handle only one file at the time;</li><li>The component checks for a size limit of 1mb and it must be an image;</li><li>We should be able to see an image preview of image;</li><li>The uploaded image needs to be exposed to other components in Blob format;</li></ul><h3>Step 1: Setup</h3><p>Before we can start building our component we have to setup a development environment, which is very easy with the starter repository, provided by our friends at StencilJs.</p><p><em>Note: You need npm v6 or higher!</em></p><pre># initiate a new StencilJs component named: image-uploader<br>git clone https://github.com/ionic-team/stencil-component-starter.git image-uploader</pre><pre># goto the component&#39;s folder<br>cd image-uploader</pre><pre># remove the remote url<br>git remote rm origin</pre><pre># install dependencies<br>npm install</pre><pre># start the live reload server<br>npm start</pre><p>The browser will open automatically and you should see the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a_pL_XYplrtqnzSJt1a5OQ.gif" /></figure><p>Cool! All is there to build our awesome image uploader component. The src folder structure should look like this:</p><pre>└── src<br>    ├── components<br>    |  └── my-component<br>    |      ├── my-component.css<br>    |      ├── my-component.e2e.ts<br>    |      └── my-component.tsx<br>    ├── utils<br>    |   ├── utils.spec.ts<br>    |   └── utils.ts<br>    ├── components.d.ts<br>    └── index.html</pre><h3>Step 2: Create the template</h3><p>The first step is to replace the ‘hello world’ render method in <em>my-component.tsx</em> by StencilJs with our own template, which looks like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2cf40784a8bbd51dc2fba1e5ef89d561/href">https://medium.com/media/2cf40784a8bbd51dc2fba1e5ef89d561/href</a></iframe><p>The template consists out of the following two parts:</p><ol><li>An image upload button, which provides the user with the functionality to select an image and upload it automatically. Notice the `onChange` function, which will fire the upload mechanism, after the user selected an image;</li><li>An uploaded image preview container where the uploaded image will be previewed.</li></ol><p><strong>Warning: </strong>If you still have the application running, it probably throws numerous errors.<strong> </strong>This is because we didn’t implement logic yet and there’s still some StencilJS boilerplate logic out there. But, don’t worry, we’ll fix it asap ;-)</p><h3>Step 3: Make things look more compelling</h3><p>Next is to add some styling to make it look a bit more compelling. Add the following css to <em>my-component.css</em>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f8bada974a826c268a378c7ca1e7b4b5/href">https://medium.com/media/f8bada974a826c268a378c7ca1e7b4b5/href</a></iframe><p>This how it looks like after styling:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h6isFOo82A83z0atXRdzOA.png" /></figure><h3>Step 3: Add logic</h3><p>Now it’s time to add the actual logic to the component. To refresh our minds, here are the <em>“business”</em> requirements again:</p><ul><li>The component is limited to handle only one file at the time;</li><li>The component checks for a size limit of 1mb and it must be an image;</li><li>We should be able to see an image preview of image;</li><li>The uploaded image needs to be exposed to other components in Blob format;</li></ul><p><strong>Upload image handler<br></strong>First we need to handle the upload event, triggered by the upload button and check if the user actually uploaded a single image. If not, we’re going to throw an error message in the console.</p><p>Add a new method, called onInputChange() to the MyComponent class in <em>my-component.tsx. </em>The component’s code will look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/792ea169469a5ec41bf8a9124914a52c/href">https://medium.com/media/792ea169469a5ec41bf8a9124914a52c/href</a></iframe><ol><li>onInputChange() accepts an <a href="https://developer.mozilla.org/en-US/docs/Web/API/FileList">FileList</a> object that contains all the files to be uploaded simultaneously by the user. It can contain multiple images, so we need to check if the number of images uploaded is equal to 1. If not, an error message will be thrown in the console.</li></ol><p><strong>Check image size &amp; type</strong><br>The next step is to check if the image size doesn’t exceed the 1mb limit and if the uploaded file is actually an image.</p><p>We need to add the following properties to the component:</p><pre>const MAX_UPLOAD_SIZE;<br>const ALLOWED_FILE_TYPES;</pre><p>And the following methods:</p><pre>private checkFileSize(size: number): boolean {}<br>private checkFileType(type: string): boolean {}</pre><p>The code will look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a854383aae2919202c545ef226c43731/href">https://medium.com/media/a854383aae2919202c545ef226c43731/href</a></iframe><ol><li>The MAX_UPLOAD_SIZE property defines the maximum file size of the image in bytes. In our case only files smaller then or equal to 1mb (or 1024 bytes) are allowed;</li><li>The ALLOWED_FILE_TYPES property contains a regular expression which defines the accepted file types. In our case images of any type are allowed;</li><li>The checkFileSize() method accepts a number and returns a boolean. True if the file meets the criteria, false if not;</li><li>The checkFileType() method accepts a string and returns a boolean. True if the file meets the criteria, false if not;</li><li>In the onInputChange() method we’ll handle the checks implemented.</li></ol><p><strong>Upload image with HTML5 FileReader Api<br></strong>The next step is actually uploading the image. We’re going to use the HTML5 FileReader Api for that. You can read more about this on <a href="https://developer.mozilla.org/en-US/docs/Web/API/FileReader">MDN</a>.</p><p>First we need to create a method called uploadImage(). Here we’re going to handle the file uploading process. The FileReader Api provides us with a set of helpers which we can implement to know what’s going on before, during and after the upload. We need to implement the following steps:</p><ol><li>Create a new instance of the HtmlReader api;</li><li>Monitor if the upload has started with onloadstart();</li><li>Do the actual uploading with onload();</li><li>Check if the uploading is finished (either in success or failure) with onloadend();</li><li>Trigger an event when the upload has failed with onerror();</li><li>Finally read the contents of the uploaded file and return a data: url, which contains the file’s data.</li></ol><p>The code will look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a5df1d1f334b1e017c757d317120fc56/href">https://medium.com/media/a5df1d1f334b1e017c757d317120fc56/href</a></iframe><p><strong>Image preview</strong><br>After the upload is successful we need to display a preview of the uploaded image. With the uploading method in place, we are actually able to do so. We just need to:</p><ol><li>Access the image preview DOM element;</li><li>Extend the onload() method.</li></ol><p>The code will look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2608c41448677f4779a67b27388bfaa6/href">https://medium.com/media/2608c41448677f4779a67b27388bfaa6/href</a></iframe><ol><li>The elementHost property is decorated with a StencilJS <a href="https://stenciljs.com/docs/decorators#element-decorator">Element Decorator</a>. This is how to get access to the host element within the class instance. This returns an instance of an HTMLElement, so standard DOM methods/events can be used here;</li><li>In theonLoad() method the elementHost property is used to access the DOM element. Note that we first need to access the component’s shadowRoot in order to get access to the container. By default, StencilJS components markup structure, style, and behavior are hidden and separated from other code on the page, so that different parts do not clash, and the code can be kept nice and clean by encapsulating it in its own shadowDOM. Learn more about it <a href="https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_shadow_DOM">here</a>;</li><li>Then we set the data: url as background image of the element.</li></ol><p><strong>Emitting events</strong></p><p>The final step is to expose the uploaded image data to the rest of the application and we’re going to use StencilJS <a href="https://stenciljs.com/docs/events">Event Decorator</a> for that.</p><p>Add a decorated property onUploadCompleted to the class and extend the onLoad() method with the actual emitting of the data.</p><p>The final code will look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/30d23e88ec1b029bbcc82a67aac6b421/href">https://medium.com/media/30d23e88ec1b029bbcc82a67aac6b421/href</a></iframe><ol><li>Components can emit data and events using the StencilJS Event Emitter decorator. It dispatches a <a href="https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Creating_and_triggering_events">CustomEvent</a> for other components to handle. In our case the event dispatches the uploaded image as <a href="https://developer.mozilla.org/en-US/docs/Web/API/Blob">Blob</a>.</li><li>After a successful upload the image blob data will be emitted to the outside world. The event’s name is: onUploadCompleted. This name can be used to capture data emitted by this event.</li></ol><h3>Test the component</h3><p>Open index.html and:</p><ol><li>Add a reference to our component;</li><li>Add an eventListener that listens to the onUploadCompleted event.</li></ol><p>The code will look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/779318e4a4d71136965ee1666cbd8623/href">https://medium.com/media/779318e4a4d71136965ee1666cbd8623/href</a></iframe><p>Just fire up the application (if you haven’t already) with npm start and start uploading!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F8JZxSl9H3gsn9vtfYd%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F8JZxSl9H3gsn9vtfYd%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2F8JZxSl9H3gsn9vtfYd%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="435" frameborder="0" scrolling="no"><a href="https://medium.com/media/3c54d08a66db1187ad7d2693c019a5d5/href">https://medium.com/media/3c54d08a66db1187ad7d2693c019a5d5/href</a></iframe><p>That’s it! There’s much room to improve this component, like passing props to resize the image, handling multiple files or connect it to a backend. If you see any points for improvement or spot a mistake in my code, please please leave a comment!</p><p><em>Feel free to check out the code in </em><a href="https://github.com/StefanNieuwenhuis/stenciljs-image-upload"><em>this git repository</em></a><em>.</em></p><h3>About the author</h3><blockquote><em>☞ If you liked this post you can </em><a href="http://buymeacoff.ee/e4dSKLnlC"><em>buy me a coffee</em></a><em>.</em></blockquote><blockquote><em>☞ </em><a href="https://medium.com/@stefannhs"><em>Stefan</em></a><em> reads every response on Medium or reply on </em><a href="https://twitter.com/stefannhs"><em>Twitter</em></a><em>, so don’t hesitate to let him know what you think.</em></blockquote><blockquote><em>☞ To hear from the author in the future, </em><a href="https://gist.github.com/StefanNieuwenhuis/e656983fe50ac8c4ea67fa24cf953996"><em>check out his gists</em></a><em> or </em><a href="https://twitter.com/stefannhs"><em>follow him on Twitter</em></a><em>.</em></blockquote><blockquote><em>☞ </em><strong><em>Please tap or click “♥︎” </em></strong><em>to help to promote this piece to others.</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8265d4e8e01e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/stencil-tricks/how-to-build-an-image-uploader-component-with-stenciljs-8265d4e8e01e">How to build an image uploader component with StencilJs</a> was originally published in <a href="https://medium.com/stencil-tricks">Stencil Tricks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[3 reasons why I went framework agnostic and why you should do that too]]></title>
            <link>https://stefannhs.medium.com/3-reasons-why-i-went-framework-agnostic-and-why-you-should-do-that-too-f39ba81c6001?source=rss-fbbe86fcf55a------2</link>
            <guid isPermaLink="false">https://medium.com/p/f39ba81c6001</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[front-end-development]]></category>
            <dc:creator><![CDATA[Stefan Nieuwenhuis]]></dc:creator>
            <pubDate>Tue, 07 Aug 2018 13:32:33 GMT</pubDate>
            <atom:updated>2021-05-04T19:43:44.929Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5tDEHh3uPeGJtQSdnCptLQ.jpeg" /></figure><p><em>Stefan helps developers to become Framework Agnostic. If you find his content helpful, you can buy him a coffee </em><a href="https://www.buymeacoffee.com/stefannhs"><em>here</em></a><em> and get his exclusive e-book “10 reasons to go framework-agnostic” for free!</em></p><p>I’m a web developer since 2003 and I’ve seen lot’s of tech stacks come and go. Back then there was no such thing as a JavaScript framework and the language was not as advanced as it is today. It was even considered an inferior language, compared to Java an C (while it actually is a completely different thing). With the introduction of frameworks like React, Angular and VueJs JavaScript finally became mainstream and now the web depends on it.</p><p>Today’s web is impossible to imagine without JavaScript frameworks. Building JavaScript applications with the help of a framework provide lot’s of advantages like:</p><ul><li><strong>Save energy. </strong>Modern JavaScript frameworks are packed with best practices, scaffolding tools, paradigms and industry standards which enables developers to set up an app in no time. It enables developers to focus on developing the actual app in stead of the tools and the architecture required.</li><li><strong>Reusable code.</strong> Components build with a JavaScript framework are interchangeable, so teams don’t have to invent a square wheel twice.</li><li><strong>A common language for teams. </strong>Using a JavaScript framework generates a common understanding between both front- and backend developers. Everyone speaks the same, common language.</li></ul><p>It’s because of these benefits that almost all frontend development teams are using JavaScript frameworks to build apps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*S8i6o8xIxiQ-64RqO45isQ.png" /><figcaption>The big three: ReactJS, Angular and VueJs</figcaption></figure><h3>The other side of the coin…</h3><p>In my time as web developer I’ve worked on numerous projects and a new project always starts with choosing a suitable JavaScript framework. What a perfect way to start a project! A framework will solve all of my problems and will save me a lot of time and energy! Other teammates and even other teams will completely understand the architecture and components I’ve built, Right?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/1*zn9HK_ttabxJXuA7lYOOiA.jpeg" /><figcaption>“A JavaScript framework will solve all of my problems!”</figcaption></figure><p>Let me give you 3 real world examples from companies I worked for:</p><ul><li>I used to work for an, enterprise size, company where multiple frontend development teams worked on different parts of an app. All teams choose Angular as their preferred JavaScript framework. Together they’ve built a shared components library in Angular (v2) to save time, money and energy, but there was a catch. Angular (v4) came out and a few teams did an upgrade. The new version contains some breaking changes and the teams quickly realized that the shared components became useless. The idea of the shared components library was to save time, money and energy, but the opposite was actually the case. Teams have to invest extra time, money and energy in upgrading the shared components library; A waste and a source of frustration.</li><li>Another project I worked on was for another enterprise company that has developed an app in AngularJs. It still works, but the responsible team has moved on and did other projects and so is their tech stack. They moved forward and switched to Angular as their preferred JavaScript framework. New team members are hired and aren’t expected to learn AngularJs anymore. But guess what? That application, built in AngularJs, which still is going strong needs a new feature to provide a better user experience to the customers.</li><li>I worked for a company where multiple frontend development teams, with different tech stacks, worked on different parts of an app. The teams are known to be self steering and very autonomous. A challenge for companies that want to provide a consistent user experience and look-and-feel to end users. The big problem for the teams (and the company) is that components are unexchangeable between teams, which is hugely time-consuming and cost-inefficient.</li></ul><p>The common theme running through these real world examples is inefficiency and I bet that it happens in your company too.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KZkc4nIrFnwol9D3OggP3A.jpeg" /><figcaption>There are lot’s of challenges to face in web development</figcaption></figure><p>The challenge as a company is to increase autonomy within teams and leave them free in the stack choices they make, but in the meantime you also want to produce high-quality products without incurring too much costs.</p><p>The challenge for development teams is not te be hold back by legacy or tech stacks which doesn’t suit the way a team works. Developing must be fun for a team in order to produce high quality apps.</p><p>Companies where development teams building apps with modern JavaScript frameworks like Angular, React or VueJs will face the following challenges:</p><ol><li>Migrating applications to other frameworks or even upgrading them is very time consuming, very costly and very frustrating</li><li>Components can’t be exchanged between teams, resulting in reinventing the wheel several times which results in wasted time, money and energy.</li><li>It’s very time consuming, hence a waste of money and energy, to provide a generic look and feel between different parts of an application developed by several teams with a different tech stack</li></ol><h3>How to face those challenges?</h3><h4><strong>Hello framework agnostic web components!</strong></h4><p><em>Note: If you’re not familiar with framework agnostic web components, there is a very good introduction you can read </em><a href="https://micro-frontends.org/#the-dom-is-the-api"><em>here</em></a><em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*VFpAAEtibhipHMmzCO2Ldg.png" /><figcaption>Web Components</figcaption></figure><p>Framework agnostic components libraries will provide a solution for the challenges described above. The idea of framework agnostic components libraries is pretty simple, but rather complex to do. Development teams are still able to choose a tech stack fit to their needs and develop their part of an app. In that way the autonomy of a teams is guaranteed and productivity will stay enhanced. At the same time a company develops a framework independent components library, which components are interchangeable between development teams. The key to success is the interchangeability between teams and the agnostic character of components.</p><h4>3 reasons why you should switch to framework agnostic components libraries</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*Kou-7bUwEJBirEVAjBQYRw.png" /><figcaption>Using web components with different JavaScript frameworks</figcaption></figure><p>Here is why you should switch to framework agnostic components libraries:</p><ol><li>No more legacy code. It’s very easy to migrate or upgrade your stack, because all the components in the library are framework agnostic. Hence compatible with every tech stack.</li><li>No more reinventing a square wheel over and over again. Components are compatible with every stack, so there is no need to build the same with different tech stacks. Just imagine how much time, money and frustration that will save!</li><li>With generic components it’s easy to provide a uniform look and feel to an application, built by several teams with different tech stacks.</li></ol><h3>About the author</h3><blockquote><em>☞ If you liked this post you can </em><a href="https://www.buymeacoffee.com/stefannhs"><em>buy me a coffee</em></a><em>.</em></blockquote><blockquote><em>☞ </em><a href="https://medium.com/@stefannhs"><em>Stefan</em></a><em> is currently pitching a CFP for #ReactiveConf. To meet and hear him speak: 🌟🌟🌟 </em><a href="https://gist.github.com/StefanNieuwenhuis/e656983fe50ac8c4ea67fa24cf953996"><em>this gist</em></a><em>.</em></blockquote><blockquote><em>☞ </em><a href="https://medium.com/@stefannhs"><em>Stefan</em></a><em> reads every response on Medium or reply on </em><a href="https://twitter.com/stefannhs"><em>Twitter</em></a><em>, so don’t hesitate to let him know what you think.</em></blockquote><blockquote><em>☞ To hear from the author in the future, </em><a href="https://gist.github.com/StefanNieuwenhuis/e656983fe50ac8c4ea67fa24cf953996"><em>check out his gists</em></a><em> or </em><a href="https://twitter.com/stefannhs"><em>follow him on Twitter</em></a><em>.</em></blockquote><blockquote><em>☞ </em><strong><em>Please tap or click “♥︎” </em></strong><em>to help to promote this piece to others.</em></blockquote><h4>More where this came from</h4><p>This story is published in <a href="http://blog.usejournal.com/">Noteworthy</a>, where thousands come every day to learn about the people &amp; ideas shaping the products we love.</p><p>Follow our publication to see more product &amp; design stories featured by the <a href="https://usejournal.com/?utm_source=usejournal.com&amp;utm_medium=blog&amp;utm_campaign=guest_post">Journal</a> team.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f39ba81c6001" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>