<?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[PatternFly Elements - Medium]]></title>
        <description><![CDATA[An open-source, flexible design system using web components. - Medium]]></description>
        <link>https://medium.com/patternfly-elements?source=rss----29df2a6b1aa6---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>PatternFly Elements - Medium</title>
            <link>https://medium.com/patternfly-elements?source=rss----29df2a6b1aa6---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 25 Nov 2026 04:59:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/patternfly-elements" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[Prefixing: the eternal question]]></title>
            <link>https://medium.com/patternfly-elements/prefixing-the-eternal-question-893baf03c8b?source=rss----29df2a6b1aa6---4</link>
            <guid isPermaLink="false">https://medium.com/p/893baf03c8b</guid>
            <category><![CDATA[prefix]]></category>
            <category><![CDATA[design-systems]]></category>
            <category><![CDATA[web-components]]></category>
            <dc:creator><![CDATA[castastrophe]]></dc:creator>
            <pubDate>Fri, 28 May 2021 19:21:26 GMT</pubDate>
            <atom:updated>2021-06-01T14:51:56.631Z</atom:updated>
            <content:encoded><![CDATA[<p>In the world of design systems, prefixing has become the norm; and with good reason. Prefixing offers a way to quickly identify from which codebase a particular style or element derives so we can easily debug environments with multiple sources. I’ve seen this advantage win out time and time again on <a href="http://redhat.com">redhat.com</a>, where we have pages built from Drupal templates, pattern systems, web components, and a smattering of code from custom libraries.</p><h3>What do we risk by not prefixing?</h3><p>My spouse is also a developer and shared this great example with me of what we risk when we don’t use prefixing in our code. He was building an animation for <a href="https://arcade.redhat.com/">arcade.redhat.com</a> based on this example from <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Animations/Using_CSS_animations">MDN</a>. When he opened the page in other browsers it looked great, but in Firefox the animation wasn’t working. After lots of debugging, he narrowed it down to a conflict in animation naming with his favorite password manager plugin, KeePass. Neither animation was using prefixing and had incidentally chosen the same name, leading to this unfortunate collision. (He <a href="https://github.com/keepassxreboot/keepassxc-browser/pull/1335">opened a PR</a>.)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*A18b3tXP2G02vWlL9MxfiQ.jpeg" /></figure><h3>What <em>can</em> we prefix?</h3><p>Down to brass tacks; what kinds of things can be prefixed? (Notice I say <em>can</em> and not necessarily <em>should</em>.)</p><ul><li>Classes</li><li>IDs</li><li>Animations</li><li>Custom element tag names (they require a dash anyway so why not start with your library’s prefix?)</li><li>Attributes (definite pros and cons to taking prefixing down this far but I’ll address them below)</li><li>Custom properties (this is a whole topic unto itself)</li></ul><h3><strong>Naming is hard</strong></h3><p>Design systems are my bread and butter so my first example comes from our webrh library; webrh is a set of twig-based templates using schema to define the CMS UI. The rendered results for the call-to-action component looks like:</p><figure><img alt="&lt;div class=”rh-cta — component” align=”left” type=”primary”&gt; &lt;a class=”rh-cta-link” href=”#” title=”Lorem ipsum”&gt;This is my test&lt;/a&gt; &lt;/div&gt;" src="https://cdn-images-1.medium.com/max/1024/1*9Vm8QBLD3TTcLVnLHTALGw.png" /><figcaption>Example of rh-prefixed classes inside the webrh call-to-action component.</figcaption></figure><p>In webrh, we prefix all our classes with rh. This was one of the early design systems at Red Hat, so we were able to corner the rh namespace, but normally I wouldn’t recommend going quite so generic because you’re likely to run into conflicts with other projects choosing the same prefix. Prefixing becomes a lot less useful if all our codebases pick the same prefix!</p><p>If you poke around pages on <a href="http://redhat.com">dotcom</a>, you’ll see a lot of rh prefixed classes: rh-group--layout , rh-standard-header--component, rh-raw , etc. Let’s look more closely at an rh-generic--component we might see on the site:</p><figure><img alt="&lt;div class=”rh-generic — component”&gt; &lt;p&gt;We’ve been here for more than 25 years, and we’re here to help you face your business challenges head-on.&lt;/p&gt; &lt;div class=”rc-cta-secondary”&gt; &lt;a href=”#”&gt;Build a hybrid cloud&lt;/a&gt; &lt;/div&gt; &lt;div class=”rc-cta-secondary”&gt; &lt;a href=”#”&gt;Develop cloud-native apps&lt;/a&gt; &lt;/div&gt; &lt;/div&gt;" src="https://cdn-images-1.medium.com/max/1024/1*RRtz7n5JI3O-okwQKb5x2A.png" /><figcaption>Example of nested prefixing.</figcaption></figure><p>Inside our rh-generic--component class we see two rc-cta-secondary elements. The rh-generic--component is the webrh design system’s wrapper class for the CMS WYSIWYG. Inside the WYSIWYG, Drupal offers a way to inject custom styles via a drop-down interface and those custom styles live inside the WYSIWYG module. Most of our rc prefixed classes on dotcom originate from Drupal. Now when we’re debugging styles, if we see an issue with an rc prefixed call-to-action on the site, we know to go to our Drupal codebase rather than our design system, even though visually, they might look the same to the end-user.</p><p>This scales beautifully too. We have pages on dotcom featuring patterns with WYSIWYG content layered next to shared nodes and raw custom bands with styles originating from our internal studio team or even external agencies. These prefixes make it easy for even non-developers to triage where bug reports should be routed.</p><h3>When shouldn’t we prefix?</h3><p>Alright so I’ve convinced you, right?</p><figure><img alt="PREFIX ALL THE THINGS (meme with very energetic cartoon)" src="https://cdn-images-1.medium.com/max/500/1*lH_82-Km-xdKfkw3NELQ4w.png" /><figcaption>Join the prefix army!</figcaption></figure><p>Let’s see this energy in action:</p><figure><img alt="&lt;div class=”rh-cta — component” rh-align=”left” rh-type=”primary” id=”rh-custom-component”&gt; &lt;a class=”rh-cta-link” href=”#” title=”Lorem ipsum”&gt;This is my test&lt;/a&gt; &lt;/div&gt;" src="https://cdn-images-1.medium.com/max/1024/1*_MQS6j7uI4qqxpawbbx4kQ.png" /><figcaption>Highly prefixed example of templated code</figcaption></figure><p>Okay, this isn’t terrible but imagine this everywhere on the page. It’s not the <em>best</em>. It definitely ensures maximum protection from conflicting code but a lot less readable. My suggestion is to drop attribute prefixing but make a contract with publishers to your codebase that all their styles must be attached to a class. That means none of this:</p><figure><img alt="[align=”left”] { background-color: hotpink; text-align: center; }" src="https://cdn-images-1.medium.com/max/1024/1*onhIsWg71Yl6Z1D-98_4ug.png" /><figcaption>CSS naughtiness at it’s best</figcaption></figure><p>That’s just mean. Honestly, don’t apply random styles to an attribute that isn’t related to the name of the attribute or what the value is. In all seriousness, even if you’re just applying text-align: left to this attribute, you can’t be sure all uses of [align=&quot;left&quot;] relate only to text. Maybe someone else is using it on an element to left align their flex layout. This is why I suggest, no matter how intuitive you think it is, please include the class context with your styles.</p><figure><img alt=".rh-cta — component[align=”left”] { text-align: left; }" src="https://cdn-images-1.medium.com/max/1024/1*ctTTM2wumxaXZLNF-v8BlA.png" /><figcaption>So much better, I feel safe now.</figcaption></figure><h3>Web components</h3><p>Drum roll please…the real question, do we prefix web components?</p><p>Well, the obvious option for prefixing web components is the tag name. It requires a dash anyway so why not carve out that first text string for your library’s prefix? The likelihood that there are multiple web component libraries in place on your site is probably slim, but prefixing the tag takes away part of the struggle with naming simple web components like button or chip when you can do pfe-button or pfe-chip and not have to make up a more complicated name just to get that dash in place.</p><h4>It depends</h4><p>Where else do web components need prefixing? It all depends on your approach.</p><p>There are a lot of different ways to come at rendering a web component. Some components fetch data and thus only use the shadow DOM for rendering, while others function as a means of gently upgrading and styling light DOM content.</p><p>Let’s look at the first approach — a component that has its template entirely in the shadow DOM, no slots, no copying content from the light DOM:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fcodepen.io%2Fcastastrophee%2Fembed%2Fpreview%2FNWpaaLY%3Fdefault-tabs%3Djs%252Cresult%26height%3D600%26host%3Dhttps%253A%252F%252Fcodepen.io%26slug-hash%3DNWpaaLY&amp;display_name=CodePen&amp;url=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fcodepen.io%2Fcastastrophee%2Fpen%2FNWpaaLY&amp;image=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fassets.codepen.io%2F172171%2Finternal%2Fscreenshots%2Fpens%2FNWpaaLY.default.png%3Ffit%3Dcover%26format%3Dauto%26ha%3Dfalse%26height%3D540%26quality%3D75%26v%3D2%26version%3D1622216914%26width%3D960&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/c2e43573604c5a1afee366b4eea5e27f/href">https://medium.com/media/c2e43573604c5a1afee366b4eea5e27f/href</a></iframe><p>This component, pfe-avatar, accepts a name as an attribute and uses that to programmatically create a unique pattern to display as an avatar with an image is not provided. No light DOM intervention or styling necessary. Our entire template looks like this (minus the style tag):</p><figure><img alt="&lt;canvas&gt;&lt;/canvas&gt; &lt;img&gt;" src="https://cdn-images-1.medium.com/max/1024/1*b3oi1QoTCRdGdQpdsnsW9g.png" /></figure><p>Do we really need the canvas or img tags to include class names or IDs? Since they’re in the shadow DOM and protected from any external undue influence, my advice would be no. The shadow DOM is appropriately semantic and there are no duplicate tags to contend with so prefixing doesn’t necessarily make sense.</p><p>Even attributes on this component like pattern and shape don’t require prefixes because they don’t collide with any global HTML attributes and there’s no way for external styles attached to pattern=&quot;squares&quot; to bleed into the shadow DOM.</p><p>Let’s look at an example where the web component is responsible for providing gentle styles to the light DOM. We can take a couple of approaches to accomplish this:</p><p>1.Applying styles from the shadow DOM to the light DOM using :slotted . This is a limited approach in that :slotted only has access to the direct children of the component. How do we, for example, style the a tag nested inside the p tag?</p><p>2. Applying styles by copying the style tag from the shadow template to the light DOM and wrapping those styles in a prefixed class such as .pfe-c-content which is applied to the web component on upgrade. These styles are fairly weak in that external styles can override them but that might be desirable to allow customizations.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fcodepen.io%2Fcastastrophee%2Fembed%2Fpreview%2FJjWrOYK%3Fdefault-tabs%3Djs%252Cresult%26height%3D600%26host%3Dhttps%253A%252F%252Fcodepen.io%26slug-hash%3DJjWrOYK&amp;display_name=CodePen&amp;url=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fcodepen.io%2Fcastastrophee%2Fpen%2FJjWrOYK&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/1cc0273c242421d2716438df7d1cea3b/href">https://medium.com/media/1cc0273c242421d2716438df7d1cea3b/href</a></iframe><p>3. For those situations where you want to protect your light DOM fully from external influence, you can go so far as to copy the entire contents of the component into the shadow DOM and leave off the slot. No prefixing is needed here in the stylesheet because the contents are fully scoped. Any classes or external styles applied to the light DOM will no longer work once migrated.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fcodepen.io%2Fcastastrophee%2Fembed%2Fpreview%2FqBrPojr%3Fdefault-tabs%3Djs%252Cresult%26height%3D600%26host%3Dhttps%253A%252F%252Fcodepen.io%26slug-hash%3DqBrPojr&amp;display_name=CodePen&amp;url=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fcodepen.io%2Fcastastrophee%2Fpen%2FqBrPojr&amp;image=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fassets.codepen.io%2F172171%2Finternal%2Fscreenshots%2Fpens%2FqBrPojr.default.png%3Ffit%3Dcover%26format%3Dauto%26ha%3Dfalse%26height%3D540%26quality%3D75%26v%3D2%26version%3D1622228949%26width%3D960&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/7208ad760b99c705dacd70aa20bba8b5/href">https://medium.com/media/7208ad760b99c705dacd70aa20bba8b5/href</a></iframe><h3>Play nice</h3><p>Whether you choose to prefix or not, it often boils down to your code being able to coexist peacefully with other projects. Other than that, go forth and conquer! You got this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*1ztVc0kchLecRVMr_urXFA.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=893baf03c8b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/patternfly-elements/prefixing-the-eternal-question-893baf03c8b">Prefixing: the eternal question</a> was originally published in <a href="https://medium.com/patternfly-elements">PatternFly Elements</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PatternFly Elements theming hooks:  Using CSS variables in a component]]></title>
            <link>https://medium.com/patternfly-elements/patternfly-elements-theming-hooks-using-css-variables-in-a-component-4e8c481f86b6?source=rss----29df2a6b1aa6---4</link>
            <guid isPermaLink="false">https://medium.com/p/4e8c481f86b6</guid>
            <category><![CDATA[theming]]></category>
            <category><![CDATA[web-components]]></category>
            <category><![CDATA[html]]></category>
            <category><![CDATA[css]]></category>
            <dc:creator><![CDATA[Kendall Totten]]></dc:creator>
            <pubDate>Tue, 25 Aug 2020 12:06:47 GMT</pubDate>
            <atom:updated>2020-09-24T22:28:54.555Z</atom:updated>
            <content:encoded><![CDATA[<h3>Theming hooks: Using CSS variables to trick-out your web components</h3><h4>CSS variables, a.k.a. <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/--*">custom properties</a>, are a fantastic way to allow web components to be easily themed by page authors.</h4><p><a href="https://github.com/patternfly/patternfly-elements">PatternFly Elements</a> web components have a standard way of stacking variables and fallback values to provide default colors, but additionally we include “theming hooks”, or places for developers who are using these components to change colors, spacing, typography and more.</p><p>For example, here’s a CSS property within a the pfe-cta web component. The browser will look for these CSS variables in the order they are defined. If a variable is empty, it will ignore it and move onto the next one.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bca2eaf5763a6e80a96c307130d28b1c/href">https://medium.com/media/bca2eaf5763a6e80a96c307130d28b1c/href</a></iframe><p>So the browser will look for these things, in this order:</p><ol><li>A component-specific local variable, empty by default.</li><li>A <a href="https://github.com/starryeyez024/patternfly-theme/blob/prerelease-1.0/dist/theme.css#L61">theme variable</a>, which impacts most components, empty by default.</li><li>A fallback value, in case both variables are empty. This is the default.</li></ol><h3>Empty local variables</h3><p>Leaving local variables empty means there is less specificity needed to override them. For example, in order to override the active tab highlight color within the pfe-tabs component, you’d only need to set a new value of a variable at the :root level instead of having to specify a CSS selector. This is desirable because using a CSS selector requires knowledge of which HTML tag or class to use, and it can create specificity battles.</p><pre>// This<br>:root {<br>  --pfe-tabs--BorderColor: purple;<br>}</pre><pre>// Not this<br>pfe-tab {<br>  --pfe-tabs--BorderColor: purple;<br>}</pre><p>When building web components, remember that CSS variables have a <a href="https://lisilinhart.info/posts/css-variables-performance">performance impact</a>, so we should err on the side of only including them when necessary. If a local variable is not needed, your CSS can be simplified to use a theme variable only, then a fallback:</p><pre>font-size: var(--pf-global--font-size, 16px));<br>                    ^ theme variable    ^ fallback value</pre><p>Or if a component has unique spacing between two items, for example the 3px between the call-to-action text and the arrow, then a theme variable is not necessary. In this case, you could include a local variable only, should you want that to be a hook for overrides.</p><pre>margin: var(--pf-cta--Margin, 3px); <br>             <em>^ local variable  ^ fallback value</em></pre><p>Or go basic, and simply code the spacer without any variables, if it’s not needed.</p><pre>margin: 3px; <br>         <em>^ value only</em></pre><h3>Awesome Functions</h3><p>You might think this sounds like a lot of extra work when building the component, but fortunately we have some helpful functions to do the heavy lifting for us.</p><blockquote><a href="https://youtu.be/67tMXmatn3c">Watch a demo video</a><strong> of how to use the </strong><strong>pfe-local and the pfe-var functions to easily build the variables stack!</strong></blockquote><h4>How does the pfe-var function work?</h4><p>The <a href="https://github.com/patternfly/patternfly-elements/blob/v1.0.0-prerelease.55/elements/pfe-sass/functions/_custom-properties.scss#L72">pfe-var</a> function returns that useful CSS variable stack for you, both with the correctly named theme variables and fallback value which is stored in the one of the <a href="https://github.com/patternfly/patternfly-elements/tree/master/elements/pfe-sass/maps">pfe-sass/maps</a>.</p><p>For example, asking the function to go look up the <a href="https://github.com/patternfly/patternfly-elements/blob/master/elements/pfe-sass/maps/_colors.scss#L58">ui-accent color</a> for you is so much easier than hunting through a list of variables to find the right one.</p><pre>// Sass:</pre><pre>.foo {<br>   color: pfe-var(ui-accent);<br>}</pre><pre>// CSS:</pre><pre>.foo { <br>    color: var(--pfe-theme--color--ui-accent, #06c);<br>}</pre><p>If you don’t happen to know the name of the color you need, you can browse the <a href="https://patternfly.github.io/patternfly-elements/theme/theme-palette/">documentation page</a>, or take a peek at the /_temp directory inside of pfe-styles, assuming you are compiling locally. This will be pulling values directly from the sass maps, so it’s guaranteed to be accurate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gg-_CtBUypcI8ZJrVk1KRw.png" /><figcaption>pfe-styles/_temp/pfe-colors.css is a great source of truth.</figcaption></figure><h4>How does the pfe-local function work?</h4><p>The <a href="https://github.com/patternfly/patternfly-elements/blob/master/elements/pfe-sass/functions/_custom-properties.scss#L105">pfe-local</a> function is a great workhorse that does several things. It builds a variable stack beginning with a local variable (using the key from the $LOCAL-VARIABLES map), which has no value, or is empty; this is important to allowing designers and developers using the web components to be able to create customizations. Next it looks to the $LOCAL-VARIABLES map, usually found at the top of the component file, to find out what value(s) to print as a fallback.</p><pre>$LOCAL-VARIABLES: (<br>   BackgroundColor:   transparent,<br>   highlight:         pfe-var(ui-accent)<br>);</pre><p>If the value in the map is just a string, it will just print the plain fallback:</p><pre>background-color: var(--pfe-tabs--BackgroundColor, transparent);</pre><p>But if the value is a pfe-var function, it will print both the theme variable, and then the fallback value.</p><pre>border-bottom-color: (--pfe-tabs--highlight, var(--pfe-theme--color--ui-accent, #e00));</pre><p><strong>Pro tip: </strong>add @include pfe-local-debug; to any component sass file to print the full list of local variables.</p><p>If, at this point, you’re convinced this sounds like a good idea overall, but when you are theming a component, it can be tricky to know <strong><em>when</em></strong> to add local variables. You can start by asking some questions:</p><h3>Does normal CSS (from the page) already do the job?</h3><p>PatternFly Elements strives to allow components to inherit all typography properties (font-family, font-size, font-style, font-variant, font-weight, line-height, <a href="https://stackoverflow.com/questions/5612302/which-css-properties-are-inherited">etc</a>.) from the normal CSS cascade, as these properties may be inherited even by shadow DOM elements. — <a href="https://css-tricks.com/styling-in-the-shadow-dom-with-css-shadow-parts/"><em>source, CSS Tricks</em></a></p><p>Check out this great <a href="https://codepen.io/castastrophee/pen/YzwgXXr">codepen by @castastrophe</a> to see this in action.</p><p>Here are some additional rules of thumb:</p><ul><li>If you are providing other styles for items within the Shadow DOM that may need to be overridden, you must also provide hook(s) via CSS custom properties.</li><li>Slotted content should not be directly styled by the component (i.e. the content areas within a card, tabs, or accordion, etc).</li><li>There is also a set of default styles you can choose to include with your components as a part of the pfe-styles component. One of the stylesheets, <a href="https://github.com/patternfly/patternfly-elements/blob/v1.0.0-prerelease.54/elements/pfe-styles/dist/pfe-base.css">pfe-base.css</a>, provides some global light DOM styles which may be useful.</li></ul><h3>Does the theme layer already do the job?</h3><p>Some variables do not exist at the theme level and will need to be created locally within the component. For instance, if you would like to make a component width customizable, you’d probably need to create a special local variable for that, as there likely would not be an appropriate theme variable. However, <a href="https://patternfly.github.io/patternfly-elements/theme/theme-palette/">there are many theme variables available</a>, so be sure to check first.</p><p>Remember, page builders *can* scope global theme variables to a particular component if needed:</p><pre>pfe-tabs {<br>  --pfe-theme--color--ui-accent: pink;<br>}</pre><p>However it’s worth noting that if you override a theme-level variable, even scoped to a particular component, it will still cascade down to any nested components, so be cognizant of whether or not that is desirable. If the component is likely to contain other components, that could be a good reason to add a local variable.</p><p>One instance of a commonly needed variable is the background-color of a particular component. If you override the theme level variable:<br>--pfe-theme-color-surface-complement: blue; that would impact many components since its a theme level color . So you may want to make it easier to override the one component color independently, such as<br>--pfe-icon-BackgroundColor: blue; which will only impact the icon component.</p><h3>Should this property be customizable at all?</h3><p>This might be a conversation with the design team. Try to assess what an author might need to change in order to make the component look like the rest of their page. Usually color is a big one, but again, they may be able to use theme-level variables to achieve that.</p><p>A component like pfe-badge for instance, has unique colors which are not derived from the theme, so maybe unique variables are needed in case the color for “warning” matches the author’s branding, they would need to change that.</p><p>Consider, though, that one of the goals of PatternFly Elements web components is to create page UI elements that are visually similar. So if everything is customizable, you may lose traction in this area.</p><h3>Does the component have variants or states that need to redefine a property ?</h3><p>The pfe-cta is a good example of a component with attributes like pfe-type and pfe-variant. Since these attributes need to change multiple values at once, it makes it easier to expose these properties as CSS variables, and redefine the values (instead of re-defining the properties over and over). This also has an impact on specificity, which is intentional.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3938cb433652497da2e9281e6c137aea/href">https://medium.com/media/3938cb433652497da2e9281e6c137aea/href</a></iframe><p>To set the value of a property to a local variable with Sass functions, you can utilize the pfe-local function, and then pass in the name of the variable defined in the component’s $LOCAL-VARIABLES map, such as color.</p><pre>color:   pfe-local(Color);</pre><p>Assuming you have a key value pair of color: #003366; in your $LOCAL-VARIABLES map, the compiled CSS will look like this:</p><pre>color: var(--pfe-cta--Color--focus, #003366));</pre><p>To set the value of a property to a theme variable with Sass functions, you can utilize the <a href="https://github.com/patternfly/patternfly-elements/blob/master/elements/pfe-sass/functions/_custom-properties.scss#L72">pfe-var</a> function, and then pass in the name of the variable defined in any of the <a href="https://github.com/patternfly/patternfly-elements/tree/master/elements/pfe-sass/maps">pfe-sass/maps</a> such as <a href="https://github.com/patternfly/patternfly-elements/blob/master/elements/pfe-sass/maps/_colors.scss#L59">ui-accent</a> or <a href="https://github.com/patternfly/patternfly-elements/blob/master/elements/pfe-sass/maps/_general.scss#L25">ui--border-width</a>.</p><pre>color:   pfe-var(ui-base--hover--on-dark);</pre><p>And that’s it! Massive kudos to <a href="https://github.com/castastrophe">@castastrophe</a> for writing the awesome Sass <a href="https://github.com/patternfly/patternfly-elements/blob/master/elements/pfe-sass/mixins/_custom-properties.scss">mixins</a> and <a href="https://github.com/patternfly/patternfly-elements/blob/master/elements/pfe-sass/functions/_custom-properties.scss">functions</a> that make all this much easier within PatternFly Elements.</p><p>If you have questions or feedback, we’d love to hear about it, either here on Medium or in the <a href="https://github.com/patternfly/patternfly-elements/issues">PatternFly Elements issue queue.</a> Thanks for reading, and be sure to check out the other blog post about how <a href="https://medium.com/p/4c8d40cbcab7">CSS “Broadcast” Variables”</a> make for some contextually-aware components. Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4e8c481f86b6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/patternfly-elements/patternfly-elements-theming-hooks-using-css-variables-in-a-component-4e8c481f86b6">PatternFly Elements theming hooks:  Using CSS variables in a component</a> was originally published in <a href="https://medium.com/patternfly-elements">PatternFly Elements</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PatternFly Elements theming hooks: CSS “Broadcast” Variables]]></title>
            <link>https://medium.com/patternfly-elements/patternfly-elements-theming-hooks-css-broadcast-variables-4c8d40cbcab7?source=rss----29df2a6b1aa6---4</link>
            <guid isPermaLink="false">https://medium.com/p/4c8d40cbcab7</guid>
            <category><![CDATA[css]]></category>
            <category><![CDATA[web-components]]></category>
            <category><![CDATA[theming]]></category>
            <dc:creator><![CDATA[Kendall Totten]]></dc:creator>
            <pubDate>Tue, 25 Aug 2020 12:05:45 GMT</pubDate>
            <atom:updated>2020-09-25T13:05:04.978Z</atom:updated>
            <content:encoded><![CDATA[<h3>Contextually-aware web components</h3><h4>The secret is CSS custom properties, a.k.a. “broadcast” variables, which are like a radio station sending out a signal. Other elements can choose to “tune in” or not.</h4><p>Before we dig in, let’s back up a bit and cover the general idea of contextually-aware components. In <a href="https://github.com/patternfly/patternfly-elements">PatternFly Elements</a> web components, all layout components (i.e. card, band, tabs, etc.) can change their background colors, so they must communicate information about that change so that nested content can make necessary updates to retain readability. We call this “context” and the three values PatternFly Element components currently support are “light”, “dark”, and “saturated”.</p><p>For example, if you place a pfe-cta (call-to-action) inside a pfe-card with a teal background, the CTA component needs to be aware of this new context in order to render the type in a color which is readable on that background. The same is true of other HTML elements such as paragraphs, headings, and links.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3KnezsJqD4X1uNJadHm4aw.gif" /><figcaption><em>The text and the CTA in the teal card automatically change colors because of the </em><em>on=&quot;saturated</em><em>” context, which then triggers broadcast variables in the CTAs.</em></figcaption></figure><h4>How does context work?</h4><ul><li>On a layout component, such as pfe-card, if you set the pfe-color attribute to something like pfe-color=&quot;complement&quot; this causes a bright background color to be set on the layout, like teal.<br>&lt;pfe-card pfe-color=&quot;complement&quot;&gt;&lt;/pfe-card&gt;</li><li>In those same layout components, when we set the styles for that background color, we should also set a —-theme variable like this:</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f78c183550db4fc07d6df2c579368f58/href">https://medium.com/media/f78c183550db4fc07d6df2c579368f58/href</a></iframe><ul><li>The JavaScript in the layout component “sees” that variable and in turn prints the on attribute on the card. The final result is: <br>&lt;pfe-card pfe-color=”accent” on=”saturated”&gt;&lt;/pfe-card&gt;. Also note that the--theme variable continues to cascade downwards, unless it’s overridden. This is why it’s important to update the --theme variable any time the background color is updated.</li><li>The CSS style block in the shadow DOM of pfe-card comes with a set of variables which are associated with the on attribute. This is where the “broadcast” variables come in. Remember, other HTML elements can choose to “tune in” (or use) these variables, or not.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d31ef2335b996b99fecfd473886d4048/href">https://medium.com/media/d31ef2335b996b99fecfd473886d4048/href</a></iframe><ul><li>Any element in the light DOM of the pfe-card, like paragraphs, can pick up the broadcast variables because the pfe-card component includes this property:color: var( — pfe-broadcasted — text,#333);<br>In order for links to be styled properly, a global stylesheet must have styles like this a { color: var( — pfe-broadcasted — link, #06c);} (this can be found in <a href="https://github.com/patternfly/patternfly-elements/blob/v1.0.0-prerelease.54/elements/pfe-styles/dist/pfe-base.css">pfe-base.css</a>).</li><li>Other components, like pfe-cta, nested inside the card will also inherit the —-theme CSS variable (a.k.a. custom properties) because they also adhere to the standard cascade. The pfe-cta will “listen” for the value of —-theme and apply its own on attribute automatically, which can then be used, as needed, to change its own colors.<br>&lt;pfe-cta on=”saturated”&gt;. Before &amp; after:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/381/0*eUY-YQW873Ez9GEo" /></figure><p>Now if you are creating a new PFE component, you’ll want an easy way to set all this up. To do this with Sass functions, you can utilize the <a href="https://github.com/patternfly/patternfly-elements/blob/master/elements/pfe-sass/functions/_custom-properties.scss#L151">pfe-broadcasted</a> function, and then pass in the name of the variable such as link or text.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/22d83ef55b0cd8b590a9dda2a48f3032/href">https://medium.com/media/22d83ef55b0cd8b590a9dda2a48f3032/href</a></iframe><p>Notice that the result is first a local variable, then a global broadcast variable (if present), and finally a fallback hex color.</p><blockquote><em>Side note, if you haven’t yet, be sure to check out our related blog post about </em><a href="https://medium.com/p/4e8c481f86b6"><em>why we use empty local variables as theming hooks</em></a><em>.</em></blockquote><p>If you are building a “container” component that can contain other components, like a band, card, or tab set, then you will need to provide the value of the broadcasted variables. You can easily do this with the <a href="https://github.com/patternfly/patternfly-elements/blob/master/elements/pfe-sass/mixins/_custom-properties.scss#L31">pfe-set-broadcast-theme</a> mixin.</p><p>In this example, we are setting the background color of the pfe-tab-panel to a dark background color, so we also want to change the value of the broadcast variables. Include the pfe-set-broadcast-theme mixin, and in the first argument, pass in the context you need, either “light”, “dark”, or “saturated”, then the Sass mixin will return all the theme variables and fallback values you need.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/71f0964caa364dfecb3964ca698aa4e9/href">https://medium.com/media/71f0964caa364dfecb3964ca698aa4e9/href</a></iframe><p>That’s it! Contextual theming made easy! Kudos to <a href="https://github.com/castastrophe">@castastrophe</a> for writing the awesome Sass <a href="https://github.com/patternfly/patternfly-elements/blob/master/elements/pfe-sass/mixins/_custom-properties.scss">mixins</a> and <a href="https://github.com/patternfly/patternfly-elements/blob/master/elements/pfe-sass/functions/_custom-properties.scss">functions</a> that make all this much easier within PatternFly Elements.</p><p>If you have questions or feedback, we’d love to hear about it, either here on Medium or in the <a href="https://github.com/patternfly/patternfly-elements/issues">PatternFly Elements issue queue.</a> Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4c8d40cbcab7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/patternfly-elements/patternfly-elements-theming-hooks-css-broadcast-variables-4c8d40cbcab7">PatternFly Elements theming hooks: CSS “Broadcast” Variables</a> was originally published in <a href="https://medium.com/patternfly-elements">PatternFly Elements</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Web Components and SEO]]></title>
            <link>https://medium.com/patternfly-elements/web-components-and-seo-58227413e072?source=rss----29df2a6b1aa6---4</link>
            <guid isPermaLink="false">https://medium.com/p/58227413e072</guid>
            <category><![CDATA[seo]]></category>
            <category><![CDATA[patternfly]]></category>
            <category><![CDATA[web-components]]></category>
            <dc:creator><![CDATA[Kyle Buchanan]]></dc:creator>
            <pubDate>Fri, 15 Nov 2019 14:43:56 GMT</pubDate>
            <atom:updated>2021-05-14T12:53:02.340Z</atom:updated>
            <content:encoded><![CDATA[<p>We all understand how important SEO is and how crucial it is for crawlers to be able to understand our content in our sites and apps. I work at Red Hat on the <a href="https://access.redhat.com">Customer Portal</a>, our support and documentation site, and over the last 90 days, <strong>72% of our referred traffic has come from search engines</strong>. That’s a big number. So our technology choices on how we deliver content to our users really matters.</p><p>We’ve been heavily investing in developing web components, specifically with the <a href="https://patternflyelements.org">PatternFly Elements</a> project, to deliver a more consistent look and feel to our users across all of the Red Hat web properties. In the process of developing these components, our SEO teams wanted to make sure that using web components on our sites and apps wouldn’t negatively impact the SEO performance of our pages. So we put together a quick test that looked at three different component architecture approaches for developing web components.</p><h3>The test</h3><p>We set up a simple page at <a href="https://youthful-jang-0343f5.netlify.com/">https://youthful-jang-0343f5.netlify.com/</a> for validation. There are three components on the page that all have the same job of delivering an H2 with some text. The <a href="https://github.com/kylebuch8/web-components-test">code for these tests live on GitHub</a>. The goal is to see how different search engine bots crawl web components and to see if changing the architecture changes how the bots see the content. For this test, we have used the webmaster tools in Google, Bing, and Yandex to see how the pages are indexed.</p><h3>Three different component architecture approaches</h3><h4><a href="https://github.com/kylebuch8/web-components-test/blob/master/scripts/wc-components.js#L1">Light DOM Approach</a></h4><p>The component is just a shadow root with a slot that will accept anything. This is the primary approach that the <a href="https://patternflyelements.org">PatternFly Elements</a> project uses.</p><pre>class WcHeaderLightDom extends HTMLElement {<br>  constructor() {<br>    super();<br><br>    this.attachShadow({ mode: &quot;open&quot; });<br>    this.shadowRoot.innerHTML = `<br>      &lt;style&gt;<br>        :host {<br>          display: block;<br>        }<br>      &lt;/style&gt;<br>      &lt;slot&gt;&lt;/slot&gt;<br>    `;<br>  }<br>}<br><br>window.customElements.define(&quot;wc-header-light-dom&quot;, WcHeaderLightDom);</pre><p>We created an instance of wc-header-light-dom in our markup like this.</p><pre>&lt;wc-header-light-dom&gt;<br>  &lt;h2&gt;Header in the Light DOM&lt;/h2&gt;<br>&lt;/wc-header-light-dom&gt;</pre><h4><a href="https://github.com/kylebuch8/web-components-test/blob/master/scripts/wc-components.js#L19">Shadow DOM with a Slot Approach</a></h4><p>The component has a shadow root with an H2 and a slot inside the H2 for the text.</p><pre>class WcHeaderJustSlot extends HTMLElement {<br>  constructor() {<br>    super();<br><br>    this.attachShadow({ mode: &quot;open&quot; });<br>    this.shadowRoot.innerHTML = `<br>      &lt;style&gt;<br>        :host {<br>          display: block;<br>        }<br>      &lt;/style&gt;<br>      &lt;h2&gt;&lt;slot&gt;&lt;/slot&gt;&lt;/h2&gt;<br>    `;<br>  }<br>}<br><br>window.customElements.define(&quot;wc-header-just-slot&quot;, WcHeaderJustSlot);</pre><p>We created an instance of wc-header-just-slot in our markup like this.</p><pre>&lt;wc-header-just-slot&gt;<br>  Header with Just a Slot<br>&lt;/wc-header-just-slot&gt;</pre><h4><a href="https://github.com/kylebuch8/web-components-test/blob/master/scripts/wc-components.js#L37">Attribute Approach</a></h4><p>The component has a shadow root with an H2 and no slot. We observe the “text” attribute and when the attribute changes, we set the textContent property of the H2 in the shadow root. This is pretty similar to how a lot of Polymer components are built.</p><pre>class WcHeaderNoSlot extends HTMLElement {<br>  static get observedAttributes() {<br>    return [&quot;text&quot;];<br>  }<br><br>  constructor() {<br>    super();<br><br>    this.attachShadow({ mode: &quot;open&quot; });<br>    this.shadowRoot.innerHTML = `<br>      &lt;style&gt;<br>        :host {<br>          display: block;<br>        }<br>      &lt;/style&gt;<br>      &lt;h2&gt;&lt;/h2&gt;<br>    `;<br>  }<br><br>  attributeChangedCallback(attr, oldValue, newValue) {<br>    this.shadowRoot.querySelector(&quot;h2&quot;).textContent = newValue;<br>  }<br>}<br><br>window.customElements.define(&quot;wc-header-no-slot&quot;, WcHeaderNoSlot);</pre><p>We created an instance of wc-header-no-slot in our markup like this.</p><pre>&lt;wc-header-no-slot text=&quot;Header without a Slot&quot;&gt;&lt;/wc-header-no-slot&gt;</pre><p>The end result is a page with three different components that all display an H2 to the user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zHHMQQBMora88A_WQJiNtw.png" /></figure><h3>The results</h3><h4>Google</h4><p>Googlebot renders all three approaches exactly as the user would see it on the web. Googlebot is executing JavaScript so all three web components look alike.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GQxL0GbIUOkNlpFXe3iuVA.png" /></figure><p><strong>Result: PASS with all three approaches!</strong></p><h4>Bing</h4><p>Bingbot renders only renders the Light DOM Approach correctly. The Shadow DOM with a Slot Approach at least renders the text but it has no semantic value. The Attribute Approach isn’t rendered at all. Bingbot is not executing JavaScript so the results we see are expected.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ONvFBuH_bHRCbeNLRrAb_Q.png" /></figure><p><strong>Result: Partial Pass</strong></p><p>Bingbot doesn’t execute JavaScript so it’s only looking at the markup that’s on the page when the page first loads. Since the Light DOM Approach is using an H2 in the light DOM, we’re still getting the semantic value that we’re looking for from this approach. The other two approaches can have a negative impact on your search performance.</p><h4>Yandex</h4><p>When we used the Audit pages for mobile compatibility tool, we saw that Yandex also does not appear to be running JavaScript. The Light DOM Approach is rendering the way we’d expect, but the Shadow DOM with a Slot Approach just shows text with no semantic value and the Attribute Approach doesn’t render at all.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wzBHgrlo5QIl6tYC" /></figure><p><strong>Result: Partial Pass</strong></p><p>Yandex, Bing, and all other search engine crawlers that don’t execute JavaScript will look like this.</p><h4>A look at all of the search engine crawlers</h4><p>This screenshot where I isolated the plain JS column for the sake of visibility, you can see that only Google and Ask.com crawlers execute JavaScript.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vi18iYMYsLaMtEoWoi67bw.png" /><figcaption>From 2018, source: <a href="https://moz.com/blog/search-engines-ready-for-javascript-crawling">https://moz.com/blog/search-engines-ready-for-javascript-crawling</a></figcaption></figure><h3>What does this mean for developing and consuming web components?</h3><p>As a developer or consumer of web components, there are two things to consider before jumping right in: context and your search engine traffic.</p><h4>Context matters</h4><p>Is your site a marketing site where click-throughs from search engines are tied to generating revenue for your company? If so, you’d probably be most interested in developing and consuming web components that rely on light DOM to deliver your message. This way the semantic value of your content is still crawlable by search engines. Making sure the heading level tags, the links, and other tags are in the light DOM is vital so that <strong>all crawlers</strong> can understand the content. So the Light DOM Approach is a must for you.</p><p>Is your site an app that lives behind authentication? If so, light DOM might not hold as much value for you. For the most part, a web crawler isn’t going to have access to your content and you can also rely on users having JavaScript turned on (there’s some debate about this though). So the Shadow DOM with a Slot Approach or the Attribute Approach, or a combination of the two, could work for you.</p><h4>Your search engine traffic matters</h4><p>If you find that 99% of your search engine traffic is coming from Google, you can definitely get away with the Shadow DOM with a Slot Approach and the Attribute Approach.</p><p>However, if your content needs to be crawlable for all search engines, the Light DOM Approach is the best way to go. For example, at Red Hat, we get a pretty sizable amount of traffic from Bing. So we can’t just ignore that major portion of our traffic.</p><p>Just take a look at this picture that was taken at Pubcon, a social media and search engine optimization conference, in Las Vegas in October, 2019. As the title of the slide clearly states, Bing is bigger than you think.</p><h3>JP Sherman 302 Redirect ➡️ PTO on Twitter</h3><p>Re a conversation we had last week :) @KyleBuchanan8 I care about @bing https://t.co/UeCYMZ2T8y</p><h3>PatternFly Elements and the Light DOM Approach</h3><p>The approach we’ve taken with <a href="https://patternflyelements.org">PatternFly Elements</a> has primarily been the Light DOM Approach. Our components are meant to be used in both marketing and app contexts. Given that context, we need search engines to be able to crawl our content. If you look at <a href="https://github.com/patternfly/patternfly-elements/blob/master/elements/pfe-accordion/demo/index.html#L69">pfe-accordion</a>, or <a href="https://github.com/patternfly/patternfly-elements/blob/master/elements/pfe-tabs/demo/index.html#L61">pfe-tabs</a>, or <a href="https://github.com/patternfly/patternfly-elements/blob/master/elements/pfe-modal/demo/index.html#L24">pfe-modal</a>, you’ll see how we put the content with its semantic value in the light DOM.</p><p>I’m not saying that our approach with <a href="https://patternflyelements.org">PatternFly Elements</a> is perfect, but treating content as king in our components and using light DOM helps us address the SEO issues I’ve presented here. And yes, pre-rendering tools like <a href="https://prerender.io/">prerender.io</a> can help, but I don’t think we can expect all of the sites and apps that use <a href="https://patternflyelements.org">PatternFly Elements</a> or other web components to use a service like prerender.io for crawlers that don’t execute JavaScript.</p><h3>Wrap up</h3><p>In the end, our SEO team was satisfied with the approach that we’ve been taking with PatternFly Elements and they’ve been able to verify that we have not negatively impacted the SEO performance of our pages and apps at Red Hat.</p><p>Whether you’re building or consuming web components in your pages and apps, the way the components are built can really impact SEO. Google and Ask.com are the only two crawlers that are currently executing JavaScript. All of the rest are just looking at the markup when the page loads. So remember that the context of your site or app and the search engines that you need to support can guide you in developing and consuming web components.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=58227413e072" width="1" height="1" alt=""><hr><p><a href="https://medium.com/patternfly-elements/web-components-and-seo-58227413e072">Web Components and SEO</a> was originally published in <a href="https://medium.com/patternfly-elements">PatternFly Elements</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Testing your PatternFly Element in React]]></title>
            <link>https://medium.com/patternfly-elements/testing-your-patternfly-element-in-react-4eb92ffa4c40?source=rss----29df2a6b1aa6---4</link>
            <guid isPermaLink="false">https://medium.com/p/4eb92ffa4c40</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[patternfly]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[web-components]]></category>
            <dc:creator><![CDATA[Kyle Buchanan]]></dc:creator>
            <pubDate>Thu, 14 Nov 2019 14:47:13 GMT</pubDate>
            <atom:updated>2019-11-14T14:47:13.335Z</atom:updated>
            <content:encoded><![CDATA[<p>We’ve built PatternFly Elements to work in most frontend frameworks and React is one of the frameworks that we formally support. So, we must test our components in React.</p><h3>Prerequisites</h3><p>You’ll need to have <a href="https://github.com/facebook/create-react-app">create-react-app</a> installed, or you can use <a href="https://www.npmjs.com/package/npx">npx</a>, and we’ll need to generate a new application using create-react-app. We’ll use npx since it’s easiest.</p><pre>npx create-react-app pfe-react-test-app<br>cd pfe-react-test-app<br>npm start</pre><p>I also like to clear up the src/App.js file in the React app so I have a clean slate for testing the component that I’m developing. The src/App.js file should look like this.</p><pre>import React from &#39;react&#39;;</pre><pre>function App() {<br>  return (<br>    &lt;div&gt;</pre><pre>    &lt;/div&gt;<br>  );<br>}</pre><pre>export default App;</pre><h3>Link your component</h3><p>Use npm link to reference the component locally. First, all of our components depend on pfelement so we need to make sure we use npm link to bring it into our project. My PatternFly Elements repository is located at ~/Documents/GitHub/patternfly-elements.</p><p>From the pfe-react-test-app directory, I run the following.</p><pre>npm link ~/Documents/GitHub/patternfly-elements/elements/pfelement</pre><p>This links a local version of pfelement component into the node_modules directory of my new React app. Next, I can npm link any of the other components into the project.</p><p>For example, if I wanted to test pfe-accordion in my project, from the pfe-react-test-app directory, I would run the following.</p><pre>npm link ~/Documents/GitHub/patternfly-elements/elements/pfe-accordion</pre><h3>Add the component</h3><p>In src/App.js import your component.</p><pre>import React from &#39;react&#39;;<br><strong>import &quot;</strong><a href="http://twitter.com/patternfly/pfe-accordion"><strong>@patternfly/pfe-accordion</strong></a><strong>&quot;;</strong></pre><pre>function App() {<br>  return (<br>    &lt;div&gt;<br>      <br>    &lt;/div&gt;<br>  );<br>}</pre><pre>export default App;</pre><p>Then add your markup to the same file.</p><pre>import React from &quot;react&quot;;<br>import &quot;<a href="http://twitter.com/patternfly/pfe-accordion">@patternfly/pfe-accordion</a>&quot;;</pre><pre>function App() {<br>  return (<br>    &lt;div&gt;<br>      <strong>&lt;pfe-accordion&gt;<br>        &lt;pfe-accordion-header&gt;<br>          &lt;h3&gt;First accordion header&lt;/h3&gt;<br>        &lt;/pfe-accordion-header&gt;<br>        &lt;pfe-accordion-panel&gt;<br>          &lt;p&gt;First accordion panel.&lt;/p&gt;<br>        &lt;/pfe-accordion-panel&gt;<br>        &lt;pfe-accordion-header&gt;<br>          &lt;h3&gt;Second accordion header&lt;/h3&gt;<br>        &lt;/pfe-accordion-header&gt;<br>        &lt;pfe-accordion-panel&gt;<br>          &lt;p&gt;Second accordion panel.&lt;/p&gt;<br>        &lt;/pfe-accordion-panel&gt;<br>      &lt;/pfe-accordion&gt;</strong><br>    &lt;/div&gt;<br>  );<br>}</pre><pre>export default App;</pre><p>Then begin testing your component.</p><h3>Things to look for</h3><h4>Does the component render properly?</h4><p>Fortunately for us, using web components with React is much easier than Angular. We’re not going to have any issues with the connectedCallback like we do with Angular. Instead, we should just be checking that the component renders properly and that the proper classes and attributes have been added to our component. For example, did pfe-accordion get the proper aria attributes added to it when it upgraded? Did pfe-accordion get a pfelement attribute on upgrade? And so on.</p><h4>Can you work with the element’s API if it has one?</h4><p>For example, would you be able to call the expand API from src/App.js? Would you be all to call theexpandAll or collapseAll methods on pfe-accordion?</p><h4>Can you use data binding to update content or attributes?</h4><p>In the example above where we are testing pfe-accordion, would I be able to iterate over an array of heading and panel data and have the pfe-accordion still display properly?</p><p>To see an example of how I’d test pfe-accordion in React, check out the sample I created on CodeSandbox. I tested rendering, data binding for the content, and I created a React ref so I could work with the pfe-accordion API.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fcodesandbox.io%2Fembed%2Fpfelements-react-testing-wi3fh%3Ffontsize%3D14%26theme%3Ddark&amp;url=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fcodesandbox.io%2Fs%2Fpfelements-react-testing-wi3fh%3Ffontsize%3D14%26theme%3Ddark&amp;image=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fcodesandbox.io%2Fapi%2Fv1%2Fsandboxes%2Fwi3fh%2Fscreenshot.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codesandbox" width="1000" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/c854ffb01831205efd3312e5e9804dae/href">https://medium.com/media/c854ffb01831205efd3312e5e9804dae/href</a></iframe><h3>Wrap up</h3><p>That should be enough to get you started. Ultimately, we’d like to automate all of this. But for now, we’re doing our testing manually.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4eb92ffa4c40" width="1" height="1" alt=""><hr><p><a href="https://medium.com/patternfly-elements/testing-your-patternfly-element-in-react-4eb92ffa4c40">Testing your PatternFly Element in React</a> was originally published in <a href="https://medium.com/patternfly-elements">PatternFly Elements</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Testing Your PatternFly Element in Angular]]></title>
            <link>https://medium.com/patternfly-elements/testing-your-patternfly-element-in-angular-40624ce1bc54?source=rss----29df2a6b1aa6---4</link>
            <guid isPermaLink="false">https://medium.com/p/40624ce1bc54</guid>
            <category><![CDATA[angular2]]></category>
            <category><![CDATA[web-components]]></category>
            <category><![CDATA[patternfly]]></category>
            <category><![CDATA[testing]]></category>
            <dc:creator><![CDATA[Kyle Buchanan]]></dc:creator>
            <pubDate>Thu, 24 Oct 2019 15:21:15 GMT</pubDate>
            <atom:updated>2019-10-24T15:21:15.661Z</atom:updated>
            <content:encoded><![CDATA[<p>We’ve built PatternFly Elements to work in most frontend frameworks and Angular is one of the frameworks that we formally support. So, we must test our components in Angular.</p><h3>Prerequisites</h3><p>You’ll need to have the <a href="https://cli.angular.io/">Angular CLI</a> installed and we’ll need to generate a new application using the cli.</p><pre>ng new pfe-test-app<br>cd pfe-test-app<br>npm run start </pre><h3>Setup</h3><p>Before we go any further, we need to make sure Angular is ready to use web components. In src/app/app.module.ts , you need to import CUSTOM_ELEMENTS_SCHEMA from @angular/core and you need to add the CUSTOM_ELEMENTS_SCHEMA to the schemas array.</p><pre>import { BrowserModule } from &#39;<a href="http://twitter.com/angular/platform-browser">@angular/platform-browser</a>&#39;;<br>import { NgModule, <strong>CUSTOM_ELEMENTS_SCHEMA</strong> } from &#39;<a href="http://twitter.com/angular/core">@angular/core</a>&#39;;</pre><pre>import { AppComponent } from &#39;./app.component&#39;;</pre><pre><a href="http://twitter.com/NgModule">@NgModule</a>({<br>  declarations: [<br>    AppComponent<br>  ],<br>  imports: [<br>    BrowserModule<br>  ],<br>  providers: [],<br>  bootstrap: [AppComponent],<br>  <strong>schemas: [CUSTOM_ELEMENTS_SCHEMA]</strong><br>})<br>export class AppModule { }</pre><h3>Link your component</h3><p>Use npm link to reference the component locally. First, all of our components depend on pfelement so we need to make sure we use npm link to bring it into our project. My PatternFly Elements repository is located at ~/Documents/GitHub/patternfly-elements.</p><p>From the pfe-test-app directory, I run the following.</p><pre>npm link ~/Documents/GitHub/patternfly-elements/elements/pfelement</pre><p>This links a local version of pfelement component into the node_modules directory of my Angular app. Next, I can npm link any of the other components into the project.</p><p>For example, if I wanted to test pfe-accordion in my project, from the pfe-test-app directory, I would run the following.</p><pre>npm link ~/Documents/GitHub/patternfly-elements/elements/pfe-accordion</pre><h3>Add the component</h3><p>In src/app/app.component.ts import your component.</p><pre>import { Component } from &#39;<a href="http://twitter.com/angular/core">@angular/core</a>&#39;;<br><strong>import &quot;</strong><a href="http://twitter.com/patternfly/pfe-select"><strong>@patternfly/pfe-</strong></a><strong>accordion&quot;;</strong></pre><pre><a href="http://twitter.com/Component">@Component</a>({<br>  selector: &#39;app-root&#39;,<br>  templateUrl: &#39;./app.component.html&#39;,<br>  styleUrls: [&#39;./app.component.css&#39;]<br>})<br>export class AppComponent {<br>  title = &#39;my-dream-app&#39;;<br>}</pre><p>Then add your markup to src/app/app.component.html.</p><pre>&lt;pfe-accordion&gt;<br>  &lt;pfe-accordion-header&gt;<br>    &lt;h3&gt;Why do wizards need money if they could just create it?&lt;/h3&gt;<br>  &lt;/pfe-accordion-header&gt;<br>  &lt;pfe-accordion-panel&gt;<br>    &lt;p&gt;There is legislation that decides what you can conjure and what you can not. Because things that you conjure out of thin air will not last, it is illegal in the wizarding world.&lt;/p&gt;<br>  &lt;/pfe-accordion-panel&gt;<br>  &lt;pfe-accordion-header&gt;<br>    &lt;h3&gt;Why doesn&#39;t Harry have a portrait of his parents?&lt;/h3&gt;<br>  &lt;/pfe-accordion-header&gt;<br>  &lt;pfe-accordion-panel&gt;<br>    &lt;p&gt;&lt;a href=&quot;#&quot;&gt;The characters in the portraits&lt;/a&gt; are not actually ghosts. They mainly are there just to repeat common phrases or serve as a general &lt;a href=&quot;foobarbaz.com&quot;&gt;representation of the individual&lt;/a&gt; they depict. A portrait of his parents would not be of much help to Harry.&lt;/p&gt;<br>  &lt;/pfe-accordion-panel&gt;<br>&lt;/pfe-accordion&gt;</pre><p>Then begin testing your component.</p><h3>Things to look for</h3><h4>Does the component render properly?</h4><p>Angular is a bit tricky in that when a web component’s connectedCallback runs, Angular will have stripped out any of the light DOM and will put it back later. So if your component is reading the light DOM in the connectedCallback, it will appear that your component has zero children in the light DOM.</p><p>To learn a bit more about this issue and how you can get around it, check out this post on how to build “<a href="https://medium.com/patternfly-elements/more-resilientweb-components-in-angular-or-anywhere-else-with-mutationobserver-72a91cd7cf22">More Resilient Web Components in Angular (or anywhere else) with MutationObserver</a>.”</p><h4>Can you work with the element’s API if it has one?</h4><p>For example, would you be able to call the expand API from app.component.ts?</p><h4>Can you use data binding to update content or attributes?</h4><p>If I were testing pfe-tabs, I’d want to test that I can use data binding to update the selected-index attribute on pfe-tabs to change the open tab.</p><h3>Wrap up</h3><p>That should be enough to get you started. Ultimately, we’d like to automate all of this. But for now, we’re doing our testing manually.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=40624ce1bc54" width="1" height="1" alt=""><hr><p><a href="https://medium.com/patternfly-elements/testing-your-patternfly-element-in-angular-40624ce1bc54">Testing Your PatternFly Element in Angular</a> was originally published in <a href="https://medium.com/patternfly-elements">PatternFly Elements</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using PatternFly Elements (web components) in your React App]]></title>
            <link>https://medium.com/patternfly-elements/using-patternfly-elements-web-components-in-your-react-app-fe079be262ed?source=rss----29df2a6b1aa6---4</link>
            <guid isPermaLink="false">https://medium.com/p/fe079be262ed</guid>
            <category><![CDATA[web-components]]></category>
            <category><![CDATA[patternfly-elements]]></category>
            <category><![CDATA[patternfly]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Kyle Buchanan]]></dc:creator>
            <pubDate>Tue, 18 Jun 2019 18:23:14 GMT</pubDate>
            <atom:updated>2020-12-11T21:24:16.220Z</atom:updated>
            <content:encoded><![CDATA[<p>To get web components to work with React it’s pretty easy and straightforward. If you’d like to follow along, go ahead and <a href="https://codesandbox.io/s/new">create a new React CodeSandbox on codesandbox.io</a>. The React sandbox uses <a href="https://github.com/facebook/create-react-app">create-react-app</a> to scaffold an app and you can view your changes in real-time right in the web app. With CodeSandbox, you can also add any npm dependency with just a few button clicks. If you want to run this app locally, you can <a href="https://github.com/kylebuch8/patternfly-elements-with-react">clone the repository on GitHub</a>.</p><p>“Using PatternFly Elements in your React App” is broken down into four sections</p><ul><li>Initial setup</li><li>Adding PatternFly Elements (web components)</li><li>Interacting with our web components API</li><li>Adding icing on the cake</li></ul><p>Each section will show you exactly what you need to do with code snippets and an accompanying CodeSandbox that you can edit or fork.</p><h3>Initial setup</h3><p>First, we need to add the web component polyfills so we can support IE11 and Edge. If we were building this app locally, we’d want to install the web components polyfills from npm using yarn.</p><pre>yarn add @webcomponents/webcomponentsjs</pre><p>But if you’re using CodeSandbox, you can just expand the dependencies menu in the Explorer region on the left side of the page, click “Add Dependency”, search for “@webcomponents/webcomponentsjs”, and click on the result of the search. After the dependency is installed, add these two lines at the top of the index.js file in the /src/ directory.</p><pre>import React from &#39;react&#39;;<br>import ReactDOM from &#39;react-dom&#39;;<br><strong>import &quot;</strong><a href="http://twitter.com/webcomponents/webcomponentsjs"><strong>@webcomponents/webcomponentsjs</strong></a><strong>/custom-elements-es5-adapter&quot;;<br>import &quot;</strong><a href="http://twitter.com/webcomponents/webcomponentsjs"><strong>@webcomponents/webcomponentsjs</strong></a><strong>/webcomponents-bundle&quot;;</strong></pre><h3>Adding PatternFly Elements (web components)</h3><p>With the setup complete, let’s add a couple of <a href="https://patternflyelements.org/">PatternFly Elements</a> web components to our application to make sure everything is hooked up properly. We’re going to add a card (<a href="https://patternflyelements.org/components/card/">pfe-card</a>) and a call-to-action button (<a href="https://patternflyelements.org/components/call-to-action/">pfe-cta</a>). Later, we’ll add an accordion (<a href="https://patternflyelements.org/components/accordion/">pfe-accordion</a>) and some CSS to help with our layout (<a href="https://patternflyelements.org/layout/">pfe-layouts</a>).</p><p>Once again, if we were building this app locally, we’d install our dependencies from npm using yarn.</p><pre>yarn add @patternfly/pfe-card @patternfly/pfe-cta</pre><p>But if you’re using CodeSandbox, just search for “@patternfly/pfe-card” and “@patternfly/pfe-cta”.</p><p>In our index.js file in the /src/ directory, let’s add the import statements for our components to the top of the file.</p><pre>import React from &quot;react&quot;;<br>import ReactDOM from &quot;react-dom&quot;;<br>import &quot;@webcomponents/webcomponentsjs/custom-elements-es5-adapter&quot;;<br>import &quot;@webcomponents/webcomponentsjs/webcomponents-bundle&quot;;<br><strong>import &quot;@patternfly/pfe-card&quot;;<br>import &quot;@patternfly/pfe-cta&quot;;</strong><br>import &quot;./styles.css&quot;;</pre><p>Let’s add some simple markup in the App function in theindex.js file to see that our pfe-card and pfe-cta are working.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2a1195ea41b1990ae3a6b85488facd11/href">https://medium.com/media/2a1195ea41b1990ae3a6b85488facd11/href</a></iframe><p>Below is the accompanying CodeSandbox to see that our initial setup is correct and that we’ve successfully added our web components to our app.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fcodesandbox.io%2Fembed%2Fw3zhw%3Ffontsize%3D14&amp;url=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fcodesandbox.io%2Fs%2Fw3zhw%3Ffontsize%3D14&amp;image=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fcodesandbox.io%2Fapi%2Fv1%2Fsandboxes%2Fw3zhw%2Fscreenshot.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codesandbox" width="1000" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/afcdf0f70a5b5c83e475919e4b326508/href">https://medium.com/media/afcdf0f70a5b5c83e475919e4b326508/href</a></iframe><p>Now that we have a card and a call-to-action, let’s add an accordion (pfe-accordion) to our app to spice things up a bit. If we were building this app locally, we’d install our dependencies from npm using yarn.</p><pre>yarn add @patternfly/pfe-accordion</pre><p>If you’re using CodeSandbox, just search for “@patternfly/pfe-accordion”.</p><p>After installing pfe-accordion, add the markup to the App function in the index.js file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0c27a41bfa231e21528f925a458f2492/href">https://medium.com/media/0c27a41bfa231e21528f925a458f2492/href</a></iframe><p>And we have to import pfe-accordion in index.js.</p><pre>import React from &quot;react&quot;;<br>import ReactDOM from &quot;react-dom&quot;;<br>import &quot;@webcomponents/webcomponentsjs/custom-elements-es5-adapter&quot;;<br>import &quot;@webcomponents/webcomponentsjs/webcomponents-bundle&quot;;<br>import &quot;@patternfly/pfe-card&quot;;<br>import &quot;@patternfly/pfe-cta&quot;;<br><strong>import &quot;@patternfly/pfe-accordion&quot;;</strong><br>import &quot;./styles.css&quot;;</pre><p>Below is the accompanying CodeSandbox for adding pfe-accordion to our app.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fcodesandbox.io%2Fembed%2F3po3u%3Ffontsize%3D14&amp;url=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fcodesandbox.io%2Fs%2F3po3u%3Ffontsize%3D14&amp;image=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fcodesandbox.io%2Fapi%2Fv1%2Fsandboxes%2F3po3u%2Fscreenshot.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codesandbox" width="1000" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/33671212c634018c016fdda8ab0080b0/href">https://medium.com/media/33671212c634018c016fdda8ab0080b0/href</a></iframe><h3>Interacting with our web components API</h3><p>After adding our accordion, let’s say that we’d like to have the first panel of the accordion open up after the page loads. To work with the accordion, there are a few things that we need to hook up.</p><p>First, let’s import useRef and useEffect.</p><pre>import React, { useRef, useEffect } from &quot;react&quot;;</pre><p>Now let’s create a React Ref so we can work with the pfe-accordion DOM API. To learn more about Refs and the DOM in React, <a href="https://reactjs.org/docs/refs-and-the-dom.html">check out their documentation</a>. We’ll start by creating a new ref inside our App function.</p><pre>function App() {<br>  const accordion = useRef();</pre><pre>  useEffect(() =&gt; {<br>    accordion.current.toggle(0);<br>  });</pre><pre>  return (</pre><pre>  );<br>}</pre><p>Next, let’s add all of our markup from the App function we had previously to our return method. We’ll also want to add a ref attribute to the opening tag of pfe-accordion and set it equal to {accordion}.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c54a896666190c15686463ecd75fb6cd/href">https://medium.com/media/c54a896666190c15686463ecd75fb6cd/href</a></iframe><p>Finally, let’s call the toggle method on the pfe-accordion DOM API so we can open the first panel of the accordion when the page loads. So we need to update the useEffect callback.</p><pre>...<br>useEffect(() =&gt; {<br>  accordion.current.toggle(0);<br>});<br>...</pre><p>Now, when the page loads, the accordion will have the first panel opened. Below is the accompanying CodeSandbox.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fcodesandbox.io%2Fembed%2F5clsc%3Ffontsize%3D14&amp;url=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fcodesandbox.io%2Fs%2F5clsc%3Ffontsize%3D14&amp;image=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fcodesandbox.io%2Fapi%2Fv1%2Fsandboxes%2F5clsc%2Fscreenshot.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codesandbox" width="1000" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/d5720820cfbdb98e4c7be41f30e6aa45/href">https://medium.com/media/d5720820cfbdb98e4c7be41f30e6aa45/href</a></iframe><h3>Adding icing on the cake</h3><p>Right now our app has a single card (pfe-card) with a call-to-action (pfe-cta) link inside it. Beneath that, we have an accordion (pfe-accordion) with the first panel opening after the page loads. Let’s make things look a bit nicer by adding in a few more cards and a grid for layout (pfe-layouts).</p><p>We’ll start by installing pfe-styles, which contains pfe-layouts, into our app. If we were building this app locally, we’d install our dependencies from npm using yarn.</p><pre>yarn add @patternfly/pfe-styles</pre><p>If you’re using CodeSandbox, search for “@patternfly/pfe-styles”.</p><p>Next, in index.js, let’s import the pfe-layouts stylesheet.</p><pre>import React, { Component } from &quot;react&quot;;<br>import ReactDOM from &quot;react-dom&quot;;<br>import &quot;@patternfly/pfe-card&quot;;<br>import &quot;@patternfly/pfe-accordion&quot;;<br>import &quot;@patternfly/pfe-cta&quot;;<br><strong>import &quot;@patternfly/pfe-styles/dist/pfe-layouts.min.css&quot;;</strong><br>import &quot;./styles.css&quot;;</pre><p>Finally, we’ll add the classes we need in our section of cards in the index.js file so we have three cards across on screens wider than or equal to 992px, two cards across on screens wider than or equal to 576px, and one card across on smaller screens.</p><pre>&lt;div className=&quot;pfe-l-grid pfe-m-gutters pfe-m-all-12-col-on-xs pfe-m-all-6-col-on-sm pfe-m-all-4-col-on-lg&quot;&gt;<br>   ... cards are in here<br>&lt;/div&gt;</pre><p>If all of the classes above look confusing and don’t make any sense, don’t worry about it. We’ll write a post that explains how to use pfe-layouts. If you’re still curious <a href="https://patternflyelements.org/layout/">check out pfe-layouts</a> to getter a better understanding of the classes above.</p><p>The end result of adding pfe-layouts and a grid is in the CodeSandbox below.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fcodesandbox.io%2Fembed%2Fipu2u%3Ffontsize%3D14&amp;url=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fcodesandbox.io%2Fs%2Fipu2u%3Ffontsize%3D14&amp;image=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fcodesandbox.io%2Fapi%2Fv1%2Fsandboxes%2Fipu2u%2Fscreenshot.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codesandbox" width="1000" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/12db854e712c72b048cf6301e8fc1507/href">https://medium.com/media/12db854e712c72b048cf6301e8fc1507/href</a></iframe><p>I realize that may have been a lot. So let’s recap what we did.</p><ol><li>Initial Setup: Added the web component polyfills</li><li>Adding PatternFly Elements (web components): Added the following web components as dependencies in our app: pfe-card, pfe-cta, and pfe-accordion</li><li>Adding PatternFly Elements (web components): Imported the web components into our index.js file</li><li>Adding PatternFly Elements (web components): Added the markup for our components in index.js</li><li>Interacting with our web components API: Created a reference to the accordion so we could open the first panel after the page loads</li><li>Adding icing on the cake: Added pfe-layouts to create a grid for our cards</li></ol><h3>Wrap up</h3><p>So there you have it. We’ve added web components to our React app and gained the benefits of using portable, pre-made components that can also be used in other frameworks like Angular and Vue. If your app is written in Angular or Vue, check out our other two posts: “<a href="https://medium.com/patternfly-elements/using-patternfly-elements-web-components-in-your-angular-app-4b18b1c9c363">Using PatternFly Elements in your Angular App</a>” and “<a href="https://medium.com/patternfly-elements/using-patternfly-elements-web-components-in-your-vue-app-340fc9a9d7e5">Using PatternFly Elements in your Vue App</a>.”</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fe079be262ed" width="1" height="1" alt=""><hr><p><a href="https://medium.com/patternfly-elements/using-patternfly-elements-web-components-in-your-react-app-fe079be262ed">Using PatternFly Elements (web components) in your React App</a> was originally published in <a href="https://medium.com/patternfly-elements">PatternFly Elements</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using PatternFly Elements (web components) in your Vue App]]></title>
            <link>https://medium.com/patternfly-elements/using-patternfly-elements-web-components-in-your-vue-app-340fc9a9d7e5?source=rss----29df2a6b1aa6---4</link>
            <guid isPermaLink="false">https://medium.com/p/340fc9a9d7e5</guid>
            <category><![CDATA[patternfly-elements]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[patternfly]]></category>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[web-components]]></category>
            <dc:creator><![CDATA[Kyle Buchanan]]></dc:creator>
            <pubDate>Tue, 18 Jun 2019 18:22:30 GMT</pubDate>
            <atom:updated>2020-12-11T21:39:13.386Z</atom:updated>
            <content:encoded><![CDATA[<p>To get web components to work with Vue, it’s pretty easy and straightforward. If you’d like to follow along, go ahead and <a href="https://codesandbox.io/s/vue">create a new Vue CodeSandbox on codesandbox.io</a>. The Vue sandbox uses the <a href="https://cli.vuejs.org/">vue-cli</a> to scaffold an app and you can view your changes in real-time right in the web app. With CodeSandbox, you can also add any npm dependency with just a few button clicks. If you want to run this app locally, you can <a href="https://github.com/kylebuch8/patternfly-elements-with-vue">clone the repository on GitHub</a>.</p><p>“Using PatternFly Elements in your Vue App” is broken down into four sections</p><ul><li>Initial setup</li><li>Adding PatternFly Elements (web components)</li><li>Interacting with our web components API</li><li>Adding icing on the cake</li></ul><p>Each section will show you exactly what you need to do with code snippets and an accompanying CodeSandbox that you can edit or fork.</p><h3>Initial setup</h3><p>First, we need to add the web component polyfills so we can support IE11 and Edge. If we were building this app locally, we’d want to install the web components polyfills from npm.</p><pre>npm install --save @webcomponents/webcomponentsjs</pre><p>But if you’re using CodeSandbox, you can just expand the dependencies menu in the Explorer region on the left side of the page, click “Add Dependency”, search for “@webcomponents/webcomponentsjs”, and click on the result of the search. After the dependency is installed, add these two lines at the top of the main.js file in the /src/ directory.</p><pre>import Vue from &quot;vue&quot;;<br>import App from &quot;./App.vue&quot;;<br><strong>import &quot;@webcomponents/webcomponentsjs/custom-elements-es5-adapter&quot;;<br>import &quot;@webcomponents/webcomponentsjs/webcomponents-loader&quot;;</strong></pre><h3>Adding PatternFly Elements (web components)</h3><p>With the setup complete, let’s add a couple of <a href="https://patternflyelements.org/">PatternFly Elements</a> web components to our application to make sure everything is hooked up properly. We’re going to add a card (<a href="https://patternflyelements.org/components/card/">pfe-card</a>) and a call-to-action button (<a href="https://patternflyelements.org/components/call-to-action/">pfe-cta</a>). Later, we’ll add an accordion (<a href="https://patternflyelements.org/components/accordion/">pfe-accordion</a>) and some CSS to help with our layout (<a href="https://patternflyelements.org/layout/">pfe-layouts</a>).</p><p>Once again, if we were building this app locally, we’d install our dependencies from npm.</p><pre>npm install --save @patternfly/pfe-card @patternfly/pfe-cta</pre><p>But if you’re using CodeSandbox, just search for “@patternfly/pfe-card” and “@patternfly/pfe-cta”.</p><p>In our HelloWorld.vue file in the /src/components/ directory, let’s add the import statements for our components to the top of the &lt;script&gt; tag in the file.</p><pre>&lt;script&gt;<br><strong>import &quot;@patternfly/pfe-card&quot;;<br>import &quot;@patternfly/pfe-cta&quot;;</strong></pre><pre>export default {<br>  name: &quot;HelloWorld&quot;,<br>  props: {<br>    msg: String<br>  }<br>};<br>&lt;/script&gt;</pre><p>Let’s add some simple markup in the template section of theHellowWorld.vue file to see that our pfe-card and pfe-cta are working.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/491201d87656571dee8913ae99ff3c9c/href">https://medium.com/media/491201d87656571dee8913ae99ff3c9c/href</a></iframe><p>Below is the accompanying CodeSandbox to see that our initial setup is correct and that we’ve successfully added our web components to our app.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fcodesandbox.io%2Fembed%2F3tsdk%3Ffontsize%3D14&amp;url=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fcodesandbox.io%2Fs%2F3tsdk%3Ffontsize%3D14&amp;image=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fcodesandbox.io%2Fapi%2Fv1%2Fsandboxes%2F3tsdk%2Fscreenshot.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codesandbox" width="1000" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/c8c0c8e57daa29c7643f9a8e85ce7d08/href">https://medium.com/media/c8c0c8e57daa29c7643f9a8e85ce7d08/href</a></iframe><p>Now that we have a card and a call-to-action, let’s add an accordion (pfe-accordion) to our app to spice things up a bit. If we were building this app locally, we’d install our dependencies from npm.</p><pre>npm install --save @patternfly/pfe-accordion</pre><p>If you’re using CodeSandbox, just search for “@patternfly/pfe-accordion”.</p><p>After installing pfe-accordion, add the markup to the template section in the HelloWorld.vue file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0c27a41bfa231e21528f925a458f2492/href">https://medium.com/media/0c27a41bfa231e21528f925a458f2492/href</a></iframe><p>And we have to import pfe-accordion in the &lt;script&gt; tag inHellowWorld.vue.</p><pre>&lt;script&gt;<br>import &quot;@patternfly/pfe-card&quot;;<br>import &quot;@patternfly/pfe-cta&quot;;<br><strong>import &quot;@patternfly/pfe-accordion&quot;;</strong></pre><pre>export default {<br>  name: &quot;HelloWorld&quot;,<br>  props: {<br>    msg: String<br>  }<br>};<br>&lt;/script&gt;</pre><p>Below is the accompanying CodeSandbox for adding pfe-accordion to our app.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fcodesandbox.io%2Fembed%2Fz5ckd%3Ffontsize%3D14%26module%3D%252Fsrc%252Fcomponents%252FHelloWorld.vue&amp;url=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fcodesandbox.io%2Fs%2Fz5ckd%3Ffontsize%3D14%26module%3D%252Fsrc%252Fcomponents%252FHelloWorld.vue&amp;image=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fcodesandbox.io%2Fapi%2Fv1%2Fsandboxes%2Fz5ckd%2Fscreenshot.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codesandbox" width="1000" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/0871586f7415927f3cb8a72d296f5ca6/href">https://medium.com/media/0871586f7415927f3cb8a72d296f5ca6/href</a></iframe><h3>Interacting with our web components API</h3><p>After adding our accordion, let’s say that we’d like to have the first panel of the accordion open up after the page loads. To work with the accordion, there’s just one thing we need to do.</p><p>In our HelloWorld component, all we need to do is add the mounted lifecycle callback, use this.$el.querySelector to locate the pfe-accordion, and then call the toggle method on the pfe-accordion DOM API.</p><pre>&lt;script&gt;<br>import &quot;@patternfly/pfe-card&quot;;<br>import &quot;@patternfly/pfe-cta&quot;;<br>import &quot;@patternfly/pfe-accordion&quot;;</pre><pre>export default {<br>  name: &quot;HelloWorld&quot;,<br>  props: {<br>    msg: String<br>  },<br>  <strong>mounted: function() {<br>    this.$el.querySelector(&quot;pfe-accordion&quot;).toggle(0);<br>  }</strong><br>};<br>&lt;/script&gt;</pre><p>This should open the first panel of the accordion when the page loads. Below is the accompanying CodeSandbox.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fcodesandbox.io%2Fembed%2Fnde96%3Ffontsize%3D14%26module%3D%252Fsrc%252Fcomponents%252FHelloWorld.vue&amp;url=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fcodesandbox.io%2Fs%2Fnde96%3Ffontsize%3D14%26module%3D%252Fsrc%252Fcomponents%252FHelloWorld.vue&amp;image=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fcodesandbox.io%2Fapi%2Fv1%2Fsandboxes%2Fnde96%2Fscreenshot.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codesandbox" width="1000" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/d8b33cb515ada1c53cc470f10a6bc446/href">https://medium.com/media/d8b33cb515ada1c53cc470f10a6bc446/href</a></iframe><h3>Adding icing on the cake</h3><p>Right now our app has a single card (pfe-card) with a call-to-action (pfe-cta) link inside it. Beneath that, we have an accordion (pfe-accordion) with the first panel opening after the page loads. Let’s make things look a bit nicer by adding in a few more cards and a grid for layout (pfe-layouts).</p><p>We’ll start by installing pfe-styles, which contains pfe-layouts, into our app. If we were building this app locally, we’d install our dependencies from npm.</p><pre>npm install --save @patternfly/pfe-styles</pre><p>If you’re using CodeSandbox, search for “@patternfly/pfe-styles”.</p><p>Next, in HelloWorld.vue, let’s import the pfe-layouts stylesheet.</p><pre>&lt;script&gt;<br>import &quot;@patternfly/pfe-card&quot;;<br>import &quot;@patternfly/pfe-cta&quot;;<br>import &quot;@patternfly/pfe-accordion&quot;;<br><strong>import &quot;</strong><a href="http://twitter.com/patternfly/pfe-layouts"><strong>@patternfly/pfe-</strong></a><strong>styles/dist/pfe-layouts.min.css&quot;;</strong></pre><pre>export default {<br>  name: &quot;HelloWorld&quot;,<br>  props: {<br>    msg: String<br>  },<br>  mounted: function() {<br>    this.$el.querySelector(&quot;pfe-accordion&quot;).toggle(0);<br>  }<br>};<br>&lt;/script&gt;</pre><p>Finally, we’ll add the classes we need in our section of cards in the HelloWorld.vue file so we have three cards across on screens wider than or equal to 992px, two cards across on screens wider than or equal to 576px, and one card across on smaller screens.</p><pre>&lt;div className=&quot;pfe-l-grid pfe-m-gutters pfe-m-all-12-col-on-xs pfe-m-all-6-col-on-sm pfe-m-all-4-col-on-lg&quot;&gt;<br>   ... cards are in here<br>&lt;/div&gt;</pre><p>If all of the classes above look confusing and don’t make any sense, don’t worry about it. We’ll write a post that explains how to use pfe-layouts. If you’re still curious <a href="https://patternflyelements.org/layout/">check out pfe-layouts</a> to getter a better understanding of the classes above.</p><p>The end result of adding pfe-layouts and a grid is in the CodeSandbox below.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fcodesandbox.io%2Fembed%2Fx84on%3Ffontsize%3D14%26module%3D%252Fsrc%252Fcomponents%252FHelloWorld.vue&amp;url=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fcodesandbox.io%2Fs%2Fx84on%3Ffontsize%3D14%26module%3D%252Fsrc%252Fcomponents%252FHelloWorld.vue&amp;image=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fcodesandbox.io%2Fapi%2Fv1%2Fsandboxes%2Fx84on%2Fscreenshot.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codesandbox" width="1000" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/553dda9d089165d18abc96bec50dc82b/href">https://medium.com/media/553dda9d089165d18abc96bec50dc82b/href</a></iframe><p>I realize that may have been a lot. So let’s recap what we did.</p><ol><li>Initial Setup: Added the web component polyfills</li><li>Adding PatternFly Elements (web components): Added the following web components as dependencies in our app: pfe-card, pfe-cta, and pfe-accordion</li><li>Adding PatternFly Elements (web components): Imported the web components into our HelloWorld.vue file</li><li>Adding PatternFly Elements (web components): Added the markup for our components in HelloWorld.vue</li><li>Interacting with our web components API: Created a reference to the accordion so we could open the first panel after the page loads</li><li>Adding icing on the cake: Added pfe-layouts to create a grid for our cards</li></ol><h3>Wrap up</h3><p>So there you have it. We’ve added web components to our Vue app and gained the benefits of using portable, pre-made components that can also be used in other frameworks like Angular and React. If your app is written in Angular or React, check out our other two posts: “<a href="https://medium.com/patternfly-elements/using-patternfly-elements-web-components-in-your-angular-app-4b18b1c9c363">Using PatternFly Elements in your Angular App</a>” and “<a href="https://medium.com/patternfly-elements/using-patternfly-elements-web-components-in-your-react-app-fe079be262ed">Using PatternFly Elements in your React App</a>.”</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=340fc9a9d7e5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/patternfly-elements/using-patternfly-elements-web-components-in-your-vue-app-340fc9a9d7e5">Using PatternFly Elements (web components) in your Vue App</a> was originally published in <a href="https://medium.com/patternfly-elements">PatternFly Elements</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using PatternFly Elements (web components) in your Angular App]]></title>
            <link>https://medium.com/patternfly-elements/using-patternfly-elements-web-components-in-your-angular-app-4b18b1c9c363?source=rss----29df2a6b1aa6---4</link>
            <guid isPermaLink="false">https://medium.com/p/4b18b1c9c363</guid>
            <category><![CDATA[angular2]]></category>
            <category><![CDATA[patternfly]]></category>
            <category><![CDATA[web-components]]></category>
            <category><![CDATA[patternfly-elements]]></category>
            <dc:creator><![CDATA[Kyle Buchanan]]></dc:creator>
            <pubDate>Tue, 18 Jun 2019 18:21:55 GMT</pubDate>
            <atom:updated>2020-12-11T21:24:47.101Z</atom:updated>
            <content:encoded><![CDATA[<p>To get web components to work with Angular, there are a few steps that we need to take. If you’d like to follow along, go ahead and <a href="https://codesandbox.io/s/angular">create a new Angular CodeSandbox on codesandbox.io</a>. The Angular sandbox uses the <a href="https://cli.angular.io/">angular-cli</a> to scaffold an app and you can view your changes in real-time right in the web app. With CodeSandbox, you can also add any npm dependency with just a few button clicks. If you want to run this app locally, you can <a href="https://github.com/kylebuch8/patternfly-elements-with-angular">clone the repository on GitHub</a>.</p><p>“Using PatternFly Elements in your Angular App” is broken down into four sections</p><ul><li>Initial setup</li><li>Adding PatternFly Elements (web components)</li><li>Interacting with our web components API</li><li>Adding icing on the cake</li></ul><p>Each section will show you exactly what you need to do with code snippets and an accompanying CodeSandbox that you can edit or fork.</p><h3>Initial setup</h3><p>First, we need to import the CUSTOM_ELEMENTS_SCHEMA to our app. The CUSTOM_ELEMENTS_SCHEMA allows us to use custom element tags in our application. In the /src/app/ directory, open up the app.module.ts file and update the second import statement to the following.</p><pre>import { NgModule, <strong>CUSTOM_ELEMENTS_SCHEMA</strong> } from &quot;@angular/core&quot;;</pre><p>Then we need to add a schemas array in the NgModule declaration with[CUSTOM_ELEMENTS_SCHEMA] as the value.</p><pre>@NgModule({<br>  declarations: [AppComponent],<br>  imports: [BrowserModule],<br>  providers: [],<br>  bootstrap: [AppComponent],<br>  <strong>schemas: [CUSTOM_ELEMENTS_SCHEMA]</strong><br>})</pre><p>Next, we need to add the web component polyfills to the polyfills.ts file at the root of our application. If we were building this app locally, we’d want to install the web components polyfills from npm.</p><pre>npm install --save @webcomponents/webcomponentsjs</pre><p>But if you’re using CodeSandbox, you can just expand the dependencies menu in the Explorer region on the left side of the page, click “Add Dependency”, search for “@webcomponents/webcomponentsjs”, and click on the result of the search. After the dependency is installed, add these two lines at the bottom of the polyfills.ts file in the /src/ directory.</p><pre>import &quot;@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js&quot;;<br>import &quot;@webcomponents/webcomponentsjs/webcomponents-loader.js&quot;;</pre><h3>Adding PatternFly Elements (web components)</h3><p>With the setup complete, let’s add a couple of <a href="https://patternflyelements.org/">PatternFly Elements</a> web components to our application to make sure everything is hooked up properly. We’re going to add a card (<a href="https://patternflyelements.org/components/card/">pfe-card</a>) and a call-to-action button (<a href="https://patternflyelements.org/components/call-to-action/">pfe-cta</a>). Later, we’ll add an accordion (<a href="https://patternflyelements.org/components/accordion/">pfe-accordion</a>) and some CSS to help with our layout (<a href="https://patternflyelements.org/layout/">pfe-layouts</a>).</p><p>Once again, if we were building this app locally, we’d install our dependencies from npm.</p><pre>npm install @patternfly/pfe-card @patternfly/pfe-cta</pre><p>But if you’re using CodeSandbox, just search for “@patternfly/pfe-card” and “@patternfly/pfe-cta”.</p><p>In our app.component.ts file in the /src/app/ directory, let’s add the import statements for our components to the top of the file.</p><pre>import { Component } from &quot;@angular/core&quot;;<br><strong>import &quot;@patternfly/pfe-card&quot;;<br>import &quot;@patternfly/pfe-cta&quot;;</strong></pre><p>Let’s add some simple markup to our app.component.html file to see that our pfe-card and pfe-cta are working.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/456448115bc3f0084790f345317dc619/href">https://medium.com/media/456448115bc3f0084790f345317dc619/href</a></iframe><p>Below is the accompanying CodeSandbox to see that our initial setup is correct and that we’ve successfully added our web components to our app.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fcodesandbox.io%2Fembed%2Foqmyl%3Ffontsize%3D14%26module%3D%252Fsrc%252Fapp%252Fapp.component.ts&amp;url=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fcodesandbox.io%2Fs%2Foqmyl%3Ffontsize%3D14%26module%3D%252Fsrc%252Fapp%252Fapp.component.ts&amp;image=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fcodesandbox.io%2Fapi%2Fv1%2Fsandboxes%2Foqmyl%2Fscreenshot.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codesandbox" width="1000" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/abc9b3b70c23ddb83d87340543c0bae7/href">https://medium.com/media/abc9b3b70c23ddb83d87340543c0bae7/href</a></iframe><p>Now that we have a card and a call-to-action, let’s add an accordion (pfe-accordion) to our app to spice things up a bit. If we were building this app locally, we’d install our dependencies from npm.</p><pre>npm install --save @patternfly/pfe-accordion</pre><p>If you’re using CodeSandbox, just search for “@patternfly/pfe-accordion”.</p><p>After installing pfe-accordion, add the markup to app.component.html.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c6756fb48b77ef7251a8cb13a2cc9421/href">https://medium.com/media/c6756fb48b77ef7251a8cb13a2cc9421/href</a></iframe><p>And we have to import pfe-accordion in app.component.ts.</p><pre>import { Component } from &quot;@angular/core&quot;;<br>import &quot;@patternfly/pfe-card&quot;;<br>import &quot;@patternfly/pfe-cta&quot;;<strong><br>import &quot;@patternfly/pfe-accordion&quot;;</strong></pre><p>Below is the accompanying CodeSandbox for adding pfe-accordion to our app.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fcodesandbox.io%2Fembed%2F2r0vp%3Ffontsize%3D14%26module%3D%252Fsrc%252Fapp%252Fapp.component.ts&amp;url=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fcodesandbox.io%2Fs%2F2r0vp%3Ffontsize%3D14%26module%3D%252Fsrc%252Fapp%252Fapp.component.ts&amp;image=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fcodesandbox.io%2Fapi%2Fv1%2Fsandboxes%2F2r0vp%2Fscreenshot.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codesandbox" width="1000" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/c38a1d6f3e1ebc7390b74526034adec2/href">https://medium.com/media/c38a1d6f3e1ebc7390b74526034adec2/href</a></iframe><h3>Interacting with our web components API</h3><p>After adding our accordion, let’s say that we’d like to have the first panel of the accordion open up after the page loads. To work with the accordion, there are a few things that we need to hook up.</p><p>First, in the markup for our accordion, we need to add an id so we have something to reference in our component’s code. In the app.component.html file, add the “#accordion” id to the pfe-accordion.</p><pre>&lt;pfe-accordion <strong>#accordion</strong>&gt;</pre><p>Second, we need to get a reference to the accordion in app.component.ts. We do this by importing ViewChild and ElementRef into our component. The import statements at the top of the file should look like this.</p><pre>import { Component, <strong>ViewChild, ElementRef</strong> } from &quot;@angular/core&quot;;<br>import &quot;@patternfly/pfe-card&quot;;<br>import &quot;@patternfly/pfe-cta&quot;;<br>import &quot;@patternfly/pfe-accordion&quot;;</pre><p>Finally, we update the AppComponent class to include a reference to our accordion and we use the ngAfterViewInit lifecycle callback to call the toggle method on the accordion.</p><pre>export class AppComponent {<br>  @ViewChild(&quot;accordion&quot;) accordion: ElementRef;</pre><pre>  ngAfterViewInit() {<br>    this.accordion.nativeElement.toggle(0);<br>  }<br>}</pre><p>Now, when the page loads, the accordion will have the first panel opened. Below is the accompanying CodeSandbox.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fcodesandbox.io%2Fembed%2Flg3nx%3Ffontsize%3D14%26module%3D%252Fsrc%252Fapp%252Fapp.component.ts&amp;url=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fcodesandbox.io%2Fs%2Flg3nx%3Ffontsize%3D14%26module%3D%252Fsrc%252Fapp%252Fapp.component.ts&amp;image=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fcodesandbox.io%2Fapi%2Fv1%2Fsandboxes%2Flg3nx%2Fscreenshot.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codesandbox" width="1000" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/cc6724f2ebcc365fcd1711658427cfed/href">https://medium.com/media/cc6724f2ebcc365fcd1711658427cfed/href</a></iframe><h3>Adding icing on the cake</h3><p>Right now our app has a single card (pfe-card) with a call-to-action (pfe-cta) link inside it. Beneath that, we have an accordion (pfe-accordion) with the first panel opening after the page loads. Let’s make things look a bit nicer by adding in a few more cards and a grid for layout (pfe-layouts).</p><p>We’ll start by installing pfe-styles, which includes pfe-layouts, into our app. If we were building this app locally, we’d install our dependencies from npm.</p><pre>npm install --save @patternfly/pfe-styles</pre><p>If you’re using CodeSandbox, search for “@patternfly/pfe-styles”.</p><p>Next, in the root of our app, we’ll add a reference to the pfe-layouts css in the .angular-cli.json file in the styles array.</p><pre>{<br>  &quot;apps&quot;: [<br>    {<br>      &quot;root&quot;: &quot;src&quot;,<br>      &quot;outDir&quot;: &quot;dist&quot;,<br>      &quot;assets&quot;: [&quot;assets&quot;, &quot;favicon.ico&quot;],<br>      &quot;index&quot;: &quot;index.html&quot;,<br>      &quot;main&quot;: &quot;main.ts&quot;,<br>      &quot;polyfills&quot;: &quot;polyfills.ts&quot;,<br>      &quot;prefix&quot;: &quot;app&quot;,<br>      &quot;styles&quot;: [<br>        &quot;styles.css&quot;,<br>        <strong>&quot;node_modules/@patternfly/pfe-styles/dist/pfe-layouts.min.css&quot;</strong><br>      ],<br>      &quot;scripts&quot;: [],<br>      &quot;environmentSource&quot;: &quot;environments/environment.ts&quot;,<br>      &quot;environments&quot;: {<br>        &quot;dev&quot;: &quot;environments/environment.ts&quot;,<br>        &quot;prod&quot;: &quot;environments/environment.prod.ts&quot;<br>      }<br>    }<br>  ]<br>}</pre><p>Finally, we’ll add the classes we need in our section of cards in the app.component.html file so we have three cards across on screens wider than or equal to 992px, two cards across on screens wider than or equal to 576px, and one card across on smaller screens.</p><pre>&lt;div class=&quot;pfe-l-grid pfe-m-gutters pfe-m-all-12-col-on-xs pfe-m-all-6-col-on-sm pfe-m-all-4-col-on-lg&quot;&gt;<br>   ... cards are in here<br>&lt;/div&gt;</pre><p>If all of the classes above look confusing and don’t make any sense, don’t worry about it. We’ll write a post that explains how to use pfe-layouts. If you’re still curious <a href="https://patternflyelements.org/layout/">check out pfe-layouts</a> to getter a better understanding of the classes above.</p><p>The end result of adding pfe-layouts and a grid is in the CodeSandbox below.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fcodesandbox.io%2Fembed%2F7srhv%3Ffontsize%3D14%26module%3D%252Fsrc%252Fapp%252Fapp.component.html&amp;url=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fcodesandbox.io%2Fs%2F7srhv%3Ffontsize%3D14%26module%3D%252Fsrc%252Fapp%252Fapp.component.html&amp;image=https%3A%2F%2Ffd.xuwubk.eu.org%3A443%2Fhttps%2Fcodesandbox.io%2Fapi%2Fv1%2Fsandboxes%2F7srhv%2Fscreenshot.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codesandbox" width="1000" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/bfcc3d83e06ba2415bcc5275ff143a71/href">https://medium.com/media/bfcc3d83e06ba2415bcc5275ff143a71/href</a></iframe><p>I realize that may have been a lot. So let’s recap what we did.</p><ol><li>Initial Setup: Added support for web components to our app by adding the CUSTOM_ELEMENTS_SCHEMA schema to the NgModule declaration</li><li>Initial Setup: Added the web component polyfills</li><li>Adding PatternFly Elements (web components): Added the following web components as dependencies in our app: pfe-card, pfe-cta, and pfe-accordion</li><li>Adding PatternFly Elements (web components): Imported the web components into our app.component.ts file</li><li>Adding PatternFly Elements (web components): Added the markup for our components in app.component.html</li><li>Interacting with our web components API: Created a reference to the accordion so we could open the first panel after the page loads</li><li>Adding icing on the cake: Added pfe-layouts to create a grid for our cards</li></ol><h3>Wrap up</h3><p>So there you have it. We’ve added web components to our Angular app and gained the benefits of using portable, pre-made components that can also be used in other frameworks like React and Vue. If your app is written in React or Vue, check out our other two posts: “<a href="https://medium.com/patternfly-elements/using-patternfly-elements-web-components-in-your-react-app-fe079be262ed">Using PatternFly Elements in your React App</a>” and “<a href="https://medium.com/patternfly-elements/using-patternfly-elements-web-components-in-your-vue-app-340fc9a9d7e5">Using PatternFly Elements in your Vue App</a>.”</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4b18b1c9c363" width="1" height="1" alt=""><hr><p><a href="https://medium.com/patternfly-elements/using-patternfly-elements-web-components-in-your-angular-app-4b18b1c9c363">Using PatternFly Elements (web components) in your Angular App</a> was originally published in <a href="https://medium.com/patternfly-elements">PatternFly Elements</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PatternFly Elements | How to build a demo component]]></title>
            <link>https://medium.com/patternfly-elements/patternfly-elements-how-to-build-a-demo-component-448c32069a21?source=rss----29df2a6b1aa6---4</link>
            <guid isPermaLink="false">https://medium.com/p/448c32069a21</guid>
            <category><![CDATA[web-components]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[patternfly]]></category>
            <dc:creator><![CDATA[castastrophe]]></dc:creator>
            <pubDate>Tue, 30 Apr 2019 19:08:37 GMT</pubDate>
            <atom:updated>2019-04-30T19:08:39.096Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to build a demo component</h3><p><a href="https://github.com/patternfly/patternfly-elements">PatternFly Elements</a> is an exciting new approach for building web components to meet our front-end needs at Red Hat and beyond (yay open source!). To that end, when learning a new coding concept, I like to get my hands typing as quickly as possible. Here are a few links to coding templates that can get you started right now. Below, I’ll describe a little bit of the differences between how the templates are written and how the repo works.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6TbBJFAxhhi6K5WAbY5aCg.png" /></figure><h3>What they are and how they work</h3><h3><a href="https://codepen.io/castastrophee/project/editor/AYwvko">CodePen project | PatternFly Elements template</a></h3><p>A project on CodePen is comprised of multiple files and it runs compilation to generate the preview. This demo has more working parts but is a closer representation of building a component in the repo.</p><ul><li>demo-theme | This folder contains the theming file which can be used to demonstrate how to theme components.</li><li>pfe-sass | This contains the helper sass for the project should you choose to include it.</li><li><strong>pfe-thing</strong> | Rename this to your component name (i.e., pfe-card, pfe-button, etc.). This contains the template file (pfe-thing.html.js), the styles (pfe-thing.scss), and the definition and functionality (pfe-thing.js).</li><li>pfelement | This is the root class, do not edit this file unless you <em>super()</em> know what you’re doing (get it? #dadjoke).</li><li>index.html | This is the demo file. Use this to preview your hard work!</li></ul><h3><a href="https://codepen.io/castastrophee/pen/LXKOWQ">CodePen | PatternFly Elements template</a></h3><p>This link is to a standard pen on CodePen. Pens are comprised of HTML, CSS, and JavaScript and tends to be a much quicker, easier demoing tool. For simple tests or examples, I recommend using this template as projects are limited in the free CodePen accounts and this will be easier to show and share with others.</p><h3>How they differ from the real thing</h3><p>As neither of these pens are running the PatternFly Elements build tools nor can they contain much architecture, a few shortcuts were made of which you should be aware.</p><h3>In the project pen…</h3><ul><li>All of the helper sass is contained in 1 file. This is because projects are limited in the number of files they support (in free accounts) so for brevity, I concatenated all our tooling into 1 file. In the repo, these tools would live in pfe-sass and use partials to pull in smaller files organized by type (function, mixin, variable, etc.).</li><li>The template html file is declared as a JavaScript file so that it could be easily imported into the main class. In the PatternFly Elements repo, the template is a standard html file and it is injected into the main class using a build step.</li><li>Styles are imported in PatternFly Elements using the same build task that injects the html. Styles are compiled and rendered inside a style tag in the template. In this demo, the styles are injected using a link in the template to the CSS file.</li></ul><h3>In the standard pen…</h3><ul><li>To allow the user to build styles in Sass, the styles are injected using a query selector from the main class to grab them from their CodePen generated style tag.</li><li>There is no PatternFly Elements root class in this example for simplicity. This demo pen uses a standard Custom Element approach to define and inject the component.</li><li>The template is defined and attached to a variable in the JS file.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=448c32069a21" width="1" height="1" alt=""><hr><p><a href="https://medium.com/patternfly-elements/patternfly-elements-how-to-build-a-demo-component-448c32069a21">PatternFly Elements | How to build a demo component</a> was originally published in <a href="https://medium.com/patternfly-elements">PatternFly Elements</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>