<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Nikki Massaro Kauffman</title>
    <description>The latest articles on DEV Community by Nikki Massaro Kauffman (@nikkimk).</description>
    <link>https://dev.to/nikkimk</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F406070%2F80f44fa9-9317-4835-93a7-1bc154868d55.png</url>
      <title>DEV Community: Nikki Massaro Kauffman</title>
      <link>https://dev.to/nikkimk</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nikkimk"/>
    <language>en</language>
    <item>
      <title>Converting UTF (including emoji) to HTML</title>
      <dc:creator>Nikki Massaro Kauffman</dc:creator>
      <pubDate>Fri, 30 Jul 2021 20:09:59 +0000</pubDate>
      <link>https://dev.to/nikkimk/converting-utf-including-emoji-to-html-x1f92f-4951</link>
      <guid>https://dev.to/nikkimk/converting-utf-including-emoji-to-html-x1f92f-4951</guid>
      <description>&lt;p&gt;Sometimes my coworker likes to mention things just to get my mind stuck on them. Take the text from &lt;a href="https://github.com/elmsln/issues/issues/748" rel="noopener noreferrer"&gt;this request&lt;/a&gt;: &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Because of some limitations both in UTF-8 and mysql (less a concern for us now but still..) it would probably be good to have some kind of &lt;code&gt;simple-emoji&lt;/code&gt; type of tag. Similar to how we have &lt;code&gt;simple-icon&lt;/code&gt;, a &lt;code&gt;simple-icon&lt;/code&gt;could be used to provide minor tweaks / accounting for emojis in a consistent way.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So last night I worked on translating UTF (including emoji) into their HTML entities.&lt;/p&gt;

&lt;h2&gt;
  
  
  Basic Unicode to HTML Entity Conversion
&lt;/h2&gt;

&lt;p&gt;I started with started with an adapted version of this &lt;a href="https://stackoverflow.com/questions/784586/convert-special-characters-to-html-in-javascript#answer-784765" rel="noopener noreferrer"&gt;conversion logic&lt;/a&gt; to convert any character that is not part of the &lt;a href="https://tutorial.eyehunts.com/js/get-the-unicode-value-of-character-javascript-example-code/" rel="noopener noreferrer"&gt;127 ASCII characters&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;utf2Html(str){
  let result = '', 

    //converts unicode decimal value into an HTML entity
    decimal2Html = (num) =&amp;gt; `&amp;amp;#${num};`,

    //converts a character into an HTML entity 
    char2Html = (char) =&amp;gt; {
      //ASCII character or html entity from character code
      return char.charCodeAt() &amp;gt; 127 ? decimal2Html(char.charCodeAt()) : char;
    };

  //check each character
  [...str].forEach(char=&amp;gt;{
    result += char2Html(char);
  });

  return result;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If we want to check this function (quite literally by dropping a UTF-8 checkmark ✓ into the function), its character code 10003 is the same as it's unicode value so it can be used to generate correct HTML entity &lt;code&gt;&amp;amp;#10003;&lt;/code&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem with Emoji Conversion
&lt;/h2&gt;

&lt;p&gt;While the function above works on UTF-8 special characters, it won't work all of the emoji we have available today. I found a really good explanation for in a post called &lt;a href="https://flaviocopes.com/javascript-unicode/" rel="noopener noreferrer"&gt;Unicode in Javascript&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Take the 🤯 emoji, for example. &lt;/p&gt;

&lt;p&gt;The character code for this emoji is 55357, so the entity returned by the function above would be &lt;code&gt;&amp;amp;#55357;&lt;/code&gt;, which does not work. &lt;/p&gt;

&lt;p&gt;The unicode value for 🤯 is actually 129327 (or 0001 1111 1001 0010 1111 in binary). In order to express this character as in it's 16-bit form, it is split into a &lt;em&gt;surrogate pair&lt;/em&gt; of 16-bit units, in string form as &lt;code&gt;\uD83E\uDD2F&lt;/code&gt; (according this handy &lt;a href="http://www.russellcottrell.com/greek/utilities/SurrogatePairCalculator.htm" rel="noopener noreferrer"&gt;Surrogate Pair Calculator&lt;/a&gt;)--🤯 &lt;/p&gt;

&lt;p&gt;So in order to get the correct value, we need to know:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;if a character is one of these surrogate pair emojis, and&lt;/li&gt;
&lt;li&gt;how to calculate a surrogate pair's value.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Determining if an Emoji is a Surrogate Pair
&lt;/h3&gt;

&lt;p&gt;The JavaScript string length for any type of character is 1.&lt;br&gt;
It is the same for characters, symbols and emoji&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;JavaScript&lt;/th&gt;
&lt;th&gt;Result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;'t'.length&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;'✓'.length&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;&lt;code&gt;'🤯'.length&lt;/code&gt;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;1&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;But if I use the spread operator (...) to get length, I can see that my emoji is made of a surrogate pair. &lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;JavaScript&lt;/th&gt;
&lt;th&gt;Result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;[...'t'].length&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;[...'✓'].length&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;&lt;code&gt;[...'🤯'].length&lt;/code&gt;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;2&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;That means that I can tell which characters are surrogate pairs if &lt;code&gt;[...char].length &amp;gt; 1&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;utf2Html(str){
  let result = '', 

    //converts unicode decimal value into an HTML entity
    decimal2Html = (num) =&amp;gt; `&amp;amp;#${num};`,

    //converts a character into an HTML entity 
    char2Html = (char) =&amp;gt; {
      let item = `${char}`;

      //spread operator can detect emoji surrogate pairs 
      if([...item].length &amp;gt; 1) {
        //TODO calculate a surrogate pair's value
      }

      //ASCII character or html entity from character code
      return char.charCodeAt() &amp;gt; 127 ? decimal2Html(char.charCodeAt()) : char;
    };

  //check each character
  [...str].forEach(char=&amp;gt;{
    result += char2Html(char);
  });

  return result;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice I left a &lt;code&gt;//TODO&lt;/code&gt; comment about calculating the pair. We'll tackle that next...&lt;/p&gt;

&lt;h3&gt;
  
  
  Calculating a Surrogate Pair's Unicode Value
&lt;/h3&gt;

&lt;p&gt;I couldn't find a good post for converting a surrogate pair to it's unicode value, so instead followed these steps for &lt;a href="https://answers.unity.com/questions/1718161/how-do-i-convert-from-unicode-to-surrogate-pairs.html#answer-container-1718186" rel="noopener noreferrer"&gt;converting from unicode to surrogate pairs&lt;/a&gt; in reverse:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;#&lt;/th&gt;
&lt;th&gt;Step&lt;/th&gt;
&lt;th&gt;🤯 Example&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;Get the value of &lt;em&gt;each part of the pair&lt;/em&gt;.&lt;/td&gt;
&lt;td&gt;55358 / 56623&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;Convert each value to a binary number.&lt;/td&gt;
&lt;td&gt;1101100000111110 / 1101110100101111&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;Take the last 10 digits of each number.&lt;/td&gt;
&lt;td&gt;0000111110 / 0100101111&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;Concatenate the two binary numbers a single 20-bit binary number.&lt;/td&gt;
&lt;td&gt;00001111100100101111&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;Convert 20-bit number to a decimal number.&lt;/td&gt;
&lt;td&gt;63791&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;Add 0x10000 to the new number.&lt;/td&gt;
&lt;td&gt;129327&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  The Completed UTF (Including Emoji) to HTML Function
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;utf2Html(str){
  let result = '', 
    //converts unicode decimal value into an HTML entity
    decimal2Html = (num) =&amp;gt; `&amp;amp;#${num};`,
    //converts a character into an HTML entity 
    char2Html = (char) =&amp;gt; {
      let item = `${char}`;

      //spread operator can detect emoji surrogate pairs 
      if([...item].length &amp;gt; 1) {

        //handle and convert utf surrogate pairs
        let concat = '';

        //for each part of the pair
        for(let i = 0; i &amp;lt; 2; i++){

          //get the character code value 
          let dec = char[i].charCodeAt(),
            //convert to binary 
            bin = dec.toString(2),
            //take the last 10 bits
            last10 = bin.slice(-10);
            //concatenate into 20 bit binary
            concat = concat + last10,
            //add 0x10000 to get unicode value
            unicode = parseInt(concat,2) + 0x10000;
        }

        //html entity from unicode value
        return decimal2Html(unicode); 
      }

      //ASCII character or html entity from character code
      return char.charCodeAt() &amp;gt; 127 ? decimal2Html(char.charCodeAt()) : char;
    };

  //check each character
  [...str].forEach(char=&amp;gt;{
    result += char2Html(char);
  });

  return result;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Update
&lt;/h2&gt;

&lt;p&gt;Thanks to a &lt;a href="https://dev.tocomment"&gt;comment&lt;/a&gt; by &lt;a href="https://dev.to/lukeshiru"&gt;LUKE知る&lt;/a&gt;, I have an even simpler way to do this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export function utf2Html(str) {
  return [...str].map((char) =&amp;gt; char.codePointAt() &amp;gt; 127 ? `&amp;amp;#${char.codePointAt()};` : char).join('');
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2frm0hvhq2uo15htpxr2.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2frm0hvhq2uo15htpxr2.jpg" alt="Mind blown meme: Problems Saving Unicode, Convert Symbols to HTML, Many Emoji are Surrogate Pairs, Convert Symbols &amp;amp; Emoji to HTML" width="500" height="703"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>unicode</category>
      <category>emoji</category>
      <category>utf8</category>
    </item>
    <item>
      <title>Using Unbundled Web Components for Dynamic Imports</title>
      <dc:creator>Nikki Massaro Kauffman</dc:creator>
      <pubDate>Fri, 23 Oct 2020 13:53:18 +0000</pubDate>
      <link>https://dev.to/nikkimk/using-unbundled-web-components-for-dynamically-imports-30m1</link>
      <guid>https://dev.to/nikkimk/using-unbundled-web-components-for-dynamically-imports-30m1</guid>
      <description>&lt;p&gt;If you've been following along with this series of baby steps, you have already tried &lt;a href="https://dev.to/nikkimk/using-a-custom-element-2mda"&gt;using a custom element&lt;/a&gt; with our CDN's "magic script", but now you have found other web components you want to use, so you'll need to make your own "magic script" to dynamically import unbundled web components. (See &lt;a href="https://dev.to/btopro/series/7803"&gt;this series on unbundled-webcomponents&lt;/a&gt; for more info.)&lt;/p&gt;

&lt;p&gt;This post will walk you through collecting your unbundled web components and generating a "magic script".&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cwAkHC21--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ef5g01yi5yzzzhou53tp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cwAkHC21--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ef5g01yi5yzzzhou53tp.png" alt="elmsln/unbundled-webcomponents on GitHub"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Set Up a Clone of unbundled-webcomponents
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Install &lt;a href="https://classic.yarnpkg.com/en/docs/install/"&gt;yarn&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Clone the unbundled-webcomponents project:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone https://github.com/elmsln/unbundled-webcomponents.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Go to the &lt;code&gt;unbundled-webcomponents&lt;/code&gt; directory:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd unbundled-webcomponents
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Find Your Components on npm
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;From &lt;a href="https://www.npmjs.com"&gt;npm&lt;/a&gt; search for the &lt;code&gt;accent-card&lt;/code&gt;. &lt;/li&gt;
&lt;li&gt;Note that accent-card is listed as &lt;code&gt;@lrnwebcomponents/accent-card&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;Note that import statement that appears under &lt;strong&gt;Usage&lt;/strong&gt; is &lt;code&gt;import '@lrnwebcomponents/accent-card/accent-card.js'&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Repeat steps 1-3 with other the components you wish to use. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xdu2jS_r--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/cimhgspetpwlrkbqwtsa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xdu2jS_r--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/cimhgspetpwlrkbqwtsa.png" alt="accent-card on npm"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Add the Web Components You Want
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;From your &lt;code&gt;unbundled-webcomponents&lt;/code&gt; directory add accent-card to your list of dependencies in &lt;code&gt;unbundled-webcomponents/package.json&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn add @lrnwebcomponents/accent-card
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Inside &lt;code&gt;unbundled-webcomponents/dist/app.js&lt;/code&gt; file add the Javascript import:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import '@lrnwebcomponents/accent-card/accent-card.js'
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Repeat steps 1-2 with other the components you wish to use. &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2bFiSuel--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/3pvk4q2o1g8a76li0x1u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2bFiSuel--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/3pvk4q2o1g8a76li0x1u.png" alt="unbundled-webcomponents/dist/app.js file"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Building Your "Magic Script" and Curating Your Component Javascript Files
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;From your &lt;code&gt;unbundled-webcomponents&lt;/code&gt;, install your components and dependencies:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn install
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;From your &lt;code&gt;unbundled-webcomponents&lt;/code&gt;, build your &lt;code&gt;dist&lt;/code&gt; folder:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn run build
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Upload the &lt;code&gt;local-path-to-your/unbundled-webcomponents/dist&lt;/code&gt; folder to a server location.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Using Your Very Own "Magic Script"
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Add the following script to your page(s):&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;script&amp;gt;
window.__appCDN="https://path.to.your/unbundled-webcomponents";
&amp;lt;/script&amp;gt;
&amp;lt;script src="https://path.to.your/unbundled-webcomponents/build.js"&amp;gt;&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Use the web components you selected to your HTML pages, just as you did in &lt;a href="https://dev.to/nikkimk/using-a-custom-element-2mda"&gt;my first post&lt;/a&gt;: &lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;accent-card accent-color="red" dark horizontal image-src="https://webcomponents.psu.edu/styleguide/elements/accent-card/demo/images/image1.jpg"&amp;gt;
&amp;lt;h1 slot="heading"&amp;gt;Look at this card&amp;lt;/h1&amp;gt;
&amp;lt;div slot="content"&amp;gt;This is the card content.&amp;lt;/div&amp;gt;
&amp;lt;/accent-card&amp;gt;
``

&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The more you use web components, the more uses you will find for them. In the not too distant future, I'll put something together on how to make your own.&lt;/p&gt;

</description>
      <category>webcomponents</category>
    </item>
    <item>
      <title>Finding Web Components</title>
      <dc:creator>Nikki Massaro Kauffman</dc:creator>
      <pubDate>Thu, 22 Oct 2020 13:18:43 +0000</pubDate>
      <link>https://dev.to/nikkimk/finding-web-components-1ih</link>
      <guid>https://dev.to/nikkimk/finding-web-components-1ih</guid>
      <description>&lt;p&gt;If you've been following along with this series of baby steps, you have already tried &lt;a href="https://dev.to/nikkimk/using-a-custom-element-2mda"&gt;using a custom element&lt;/a&gt;. So far you've only used the web components that we have documented at &lt;a href="http://webcomponents.psu.edu" rel="noopener noreferrer"&gt;webcomponents.psu.edu&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This post will get you to find other web components.&lt;/p&gt;

&lt;h2&gt;
  
  
  Finding Web Component Design Systems
&lt;/h2&gt;

&lt;p&gt;If you're interested in finding a design system, the open-wc keeps a list of &lt;a href="https://open-wc.org/guide/component-libraries.html" rel="noopener noreferrer"&gt;web component libraries&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F0mu5xek3bjtclqfwr1jn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F0mu5xek3bjtclqfwr1jn.png" alt="open-wc's list of  Web Component Libraries"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;From open-wc's list of web component libraries, click on the link for Adobe's &lt;a href="https://opensource.adobe.com/spectrum-web-components/" rel="noopener noreferrer"&gt;Spectrum Web Components&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Use the left menu to find the &lt;a href="https://opensource.adobe.com/spectrum-web-components/components/card" rel="noopener noreferrer"&gt;card component&lt;/a&gt;. &lt;/li&gt;
&lt;li&gt;Check out the documentation and demo for the card (sp-card).&lt;/li&gt;
&lt;li&gt;Use the left menu to look at the rest of this library.&lt;/li&gt;
&lt;li&gt;Go back to open-wc's list of web component libraries and explore more.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fmfnmdvqgaoe131251zdo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fmfnmdvqgaoe131251zdo.png" alt="sp-card on Adobe's Spectrum Web Components library"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Browse some the list and try some of the demos.&lt;/p&gt;

&lt;h3&gt;
  
  
  Searching by Component
&lt;/h3&gt;

&lt;p&gt;If you're searching for a component to solve a specific problem, try searching &lt;a href="https://www.webcomponents.org" rel="noopener noreferrer"&gt;webcomponents.org&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F7a4bdm43qb16cr2cjhx2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F7a4bdm43qb16cr2cjhx2.png" alt="paper-slider page on webcomponents.org"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;From webcomponents.org, use the search to find a slider.&lt;/li&gt;
&lt;li&gt;From the search results, select &lt;a href="https://www.webcomponents.org/element/@polymer/paper-slider" rel="noopener noreferrer"&gt;paper-slider&lt;/a&gt;. You will be taken to a page describing the paper-slider element.&lt;/li&gt;
&lt;li&gt;From the paper-slider page, you can click the &lt;a href="https://www.webcomponents.org/element/@polymer/paper-slider/demo/demo/index.html" rel="noopener noreferrer"&gt;Demo&lt;/a&gt; link to see the slider demo and its HTML. &lt;/li&gt;
&lt;li&gt;Search for webcomponents.org for other web component UI elements that you might want to use.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Once you've found the web components you want to use, you'll need to make your own "magic script" to dynamically import the Javascript files for your collection. Learn how in my next post.&lt;/p&gt;

</description>
      <category>webcomponents</category>
    </item>
    <item>
      <title>Using a Custom Element</title>
      <dc:creator>Nikki Massaro Kauffman</dc:creator>
      <pubDate>Wed, 21 Oct 2020 20:47:12 +0000</pubDate>
      <link>https://dev.to/nikkimk/using-a-custom-element-2mda</link>
      <guid>https://dev.to/nikkimk/using-a-custom-element-2mda</guid>
      <description>&lt;p&gt;Recently I gave a lightning talk for the &lt;a href="https://membership.highedweb.org/" rel="noopener noreferrer"&gt;HighEdWeb Associations&lt;/a&gt;'s annual conference called &lt;a href="https://docs.google.com/presentation/d/1dpGPjjWmUZ6m_1ti2nf2tPZPdAjtz3jfiatE8CMZpeU" rel="noopener noreferrer"&gt;"Old School HTML with Modern Web Components"&lt;/a&gt; making the case for web components. &lt;/p&gt;

&lt;p&gt;Since then I've been getting lots of follow-up questions about how to get started. I think what scares most people off of them is that we often start with how to make your own, which is honestly doesn't give you the immediate return on your learning investment. So what I've decided to do a series that starts at a much easier and more immediately rewarding point.&lt;/p&gt;

&lt;p&gt;For newcomers dependencies, bundling, and polyfills are a bit intimidating, so for now, let's use a script where all of that has been taken care of for you. To that end, let's with the simplest most useful task: using an existing web component with a single script. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Add the Javascript. We have a CDN for the web components we use. Add the following script to any HTML page:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;script&amp;gt; 
window.__appCDN="https://cdn.webcomponents.psu.edu/cdn/"; &amp;lt;/script&amp;gt;
&amp;lt;script src="https://cdn.webcomponents.psu.edu/cdn/build.js"&amp;gt;&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Use the custom element HTML. For example, try accent-card:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;accent-card accent-color="red" dark horizontal image-src="https://webcomponents.psu.edu/styleguide/elements/accent-card/demo/images/image1.jpg"&amp;gt;
&amp;lt;h1 slot="heading"&amp;gt;Look at this card&amp;lt;/h1&amp;gt;
&amp;lt;div slot="content"&amp;gt;This is the card content.&amp;lt;/div&amp;gt;
&amp;lt;/accent-card&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Make some changes. Check out the &lt;a href="https://webcomponents.psu.edu/styleguide/?path=/story/layout-card--accent-card-story" rel="noopener noreferrer"&gt;accent-card demo&lt;/a&gt; to learn how to change the card's accent-color, orientation, heading, content, and more. &lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fii8ukdey07nhb5ya5u8p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fii8ukdey07nhb5ya5u8p.png" alt="Accent Card demo with an arrow pointing to the panel on the right and the demo/HTML on the left"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Try more custom elements. Browse our CDN to try more:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://webcomponents.psu.edu/styleguide/?path=/story/media-figure--a-11-y-figure-story" rel="noopener noreferrer"&gt;a11y-figure&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://webcomponents.psu.edu/styleguide/?path=/story/media-video--a-11-y-media-player-story" rel="noopener noreferrer"&gt;a11y-media-player for video&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://webcomponents.psu.edu/styleguide/?path=/story/media-youtube--a-11-y-media-player-youtube-story" rel="noopener noreferrer"&gt;a11y-media-player for YouTube&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://webcomponents.psu.edu/styleguide/?path=/story/navigation-tabs--a-11-y-tabs-story" rel="noopener noreferrer"&gt;a11y-tabs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://webcomponents.psu.edu/styleguide/?path=/story/navigation-collapse--a-11-y-collapse-story" rel="noopener noreferrer"&gt;a11y-collapse&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://webcomponents.psu.edu/styleguide/?path=/story/navigation-card--nav-card-story" rel="noopener noreferrer"&gt;nav-card&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Next you'll learn how to make your own magic script for dynamically importing web components.&lt;/p&gt;

</description>
      <category>webcomponents</category>
    </item>
  </channel>
</rss>
