<rss
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:admin="http://webns.net/mvcb/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
version="2.0">

  <channel>

    <title>Recent &amp; Good Blog Posts on CodePen</title>

    <link>https://codepen.io/posts/</link>

    <description/>

    <dc:language>en</dc:language>

    <dc:creator>nospam@codepen.io</dc:creator>

    <dc:rights>Copyright 2018</dc:rights>

    <dc:date>
      2018-11-26T12:58:19-07:00
    </dc:date>

      <item>

  <title>Short note on role none or presentation?</title>

  <link>https://codepen.io/stevef/post/none-or-presentation</link>
  <guid>https://codepen.io/stevef/post/none-or-presentation</guid>

  <dc:creator>steve faulkner</dc:creator>

  <description>
    <![CDATA[
    <h1>none or presentation?</h1>

<p>
  <strong>Do either work across browsers and Screen Readers?</strong>
</p>

<p>Details on <a href="https://www.w3.org/TR/using-aria/#ariapresentation">Use of <code>role=presentation</code> or <code>role=none</code></a></p>

<h2>Short answer is:</h2>

<ul>
<li>All <strong><em>modern browsers</em></strong> support both <code>role="none"</code> and <code>role="presentation"</code></li>
<li>Internet Explorer 11 supports <code>role="presentation"</code> only</li>
<li>JAWS 2019 works around IE's lack and so <strong>supports</strong> <code>role="none"</code></li>
<li>NVDA 2018.2.1 does not work around IE's lack of support and so <strong>does not support</strong> <code>role="none"</code></li>
<li>Although Edge 17.17134 supports both, Narrator appears to <strong>not take notice</strong> of either.</li>
<li>NVDA and JAWS <strong>work as expected</strong> with Firefox 64.0b12 (64-bit) and Chrome Version 70.0.3538.110 (Official Build) (64-bit).</li>
<li>VoiceOver with Safari 12.01 and Chrome Version 67.0.3396 on macOS Sierra <strong>works as expected</strong>.</li>
</ul>

<h2>Try for yourself:</h2>

<p><p data-slug-hash="dQKjVg" data-default-tab="result" data-height="300" data-theme-id="0" class="codepen"></p></p>

    ]]>
  </description>

  <dc:subject>Short note on role none or presentation?</dc:subject>

  <dc:date>
    2018-11-26T12:58:19-07:00
  </dc:date>

</item>

      <item>

  <title>Beware the “Components Are LEGOs” Metaphor</title>

  <link>https://codepen.io/tigt/post/beware-the-components-are-legos-metaphor</link>
  <guid>https://codepen.io/tigt/post/beware-the-components-are-legos-metaphor</guid>

  <dc:creator>Taylor Hunt</dc:creator>

  <description>
    <![CDATA[
    <p>Metaphors have power. Mind which ones you prioritize.</p>

<hr />

<p>LEGOs are rigid plastic with only one interface: the <a href="https://lego.wikia.com/wiki/Stud">stud</a>.</p>

<p>LEGOs do not reconfigure to fit a screen.</p>

<p>LEGOs do not stretch to accommodate their contents.</p>

<p>LEGOs are inaccessible to the blind (colors) and motor-impaired (assembling, disassembling).</p>

<p>LEGOs can be <a href="http://thebrickblogger.com/2011/09/lego-brick-separator-new-version/">notoriously difficult to separate</a>.</p>

<p>LEGOs cannot join with unofficial materials/pieces or they risk discoloration, deformation, and getting broke. This includes sunlight.</p>

<p>If you need a piece that LEGO doesn’t make, you are out of luck.</p>

<p>If you need a <em><strong>color</strong></em> that LEGO doesn’t make, you are out of luck.</p>

<p>Nobody is allowed to create stuff that works with LEGO pieces other than LEGO.</p>

<p>LEGOs that change state, have memories, or are otherwise useful are banished to other, more advanced brand names, like <a href="https://en.wikipedia.org/wiki/Lego_Technic">Technic</a> and <a href="https://en.wikipedia.org/wiki/Lego_Mindstorms_NXT">Mindstorms/NXT</a>.</p>

<hr />

<p>Web components (not Web Components™) are not quite like LEGOs.</p>

<p>In fact, they’re very different.</p>

<p>LEGOs are toys, as it turns out.</p>

    ]]>
  </description>

  <dc:subject>Beware the “Components Are LEGOs” Metaphor</dc:subject>

  <dc:date>
    2018-11-09T06:33:00-07:00
  </dc:date>

</item>

      <item>

  <title>Theming with CSS variables in RGBA</title>

  <link>https://codepen.io/finnhvman/post/theming-with-css-variables-in-rgba</link>
  <guid>https://codepen.io/finnhvman/post/theming-with-css-variables-in-rgba</guid>

  <dc:creator>Ben Szabo</dc:creator>

  <description>
    <![CDATA[
    <p>
  <em>CSS variables are pretty well-supported nowadays across browsers. The global feature coverage is <a rel="nofollow" href="https://caniuse.com/#feat=css-variables">above 87.5%</a> at the time of writing.</em>
</p>

<h1>Theming apps</h1>

<p>A not so surprising use-case of CSS variables is theming apps. Think of Twitter for example where you can specify the color of your profile. This color and its shades appear on many elements: links, buttons, borders, highlights, etc. Take a look at my annotated twitter profile:</p>

<p><img src="https://res.cloudinary.com/finnhvman/image/upload/v1541935449/twitter.jpg" alt="Screenshot of twitter annotating themed elements" /> <em>Themed elements on Twitter (...oh yeah, <a rel="nofollow" href="https://twitter.com/finnhvman">follow me</a>)</em></p>

<p>When you customize your profile, you only have to specify one color, the rest is magically taken care of. I like the simplicity and ease of use of this concept, and I wanted something similar when I started thinking about making <a rel="nofollow" href="https://codepen.io/collection/nZKBZe/">Pure CSS Material Components</a> themeable. So the question was how to create a palette out of a color?</p>

<p>There are at least a few different answers to this, but I had some restrictions. As I was working on a CSS only library, using JavaScript was out of scope. Another thing was adhering to the <a rel="nofollow" href="https://material.io/design/introduction/">Material Design Guidelines</a> as much as possible.</p>

<h1>Coding</h1>

<p>Most of the time Material specifies using semi-transparent versions of colors. This led me to the <a rel="nofollow" href="https://css-tricks.com/the-power-of-rgba/"><code>rgba()</code> functional notation</a> which can be used to create "shades" of a solid color through manipulating the alpha channel. The following snippet specifies the text color to be <strong>red</strong>, but <strong>half-transparent</strong>:</p>

<pre>
  <code class="css">.text {
  color: rgba(255, 0, 0, 0.5);
}
</code>
</pre>

<p>Similar results can be achieved with the <a rel="nofollow" href="https://css-tricks.com/almanac/properties/o/opacity/">opacity property</a>. However it always applies to the whole element (and its children), while a semi-transparent color can be applied on text, border, background, box-shadow, etc. separately.</p>

<p>Next, I extracted a variable for the RGB color from the declaration above. <a rel="nofollow" href="https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_variables">CSS variables</a> can hold any value, and luckily they resolve within the <code>rgba()</code> functional notation so the following snippet works just fine:</p>

<pre>
  <code class="css">:root {
  --my-color-rgb: 255, 0, 0; 
}

.text {
  color: rgba(var(--my-color-rgb), 0.5);
}
</code>
</pre>

<p>CSS variables also have the <a rel="nofollow" href="https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_variables#Custom_Property_fallback_values">fallback feature</a>. So why not use it? It is a great fit for providing default color if the referred variable is undefined. Putting everything together produces something like this:</p>

<pre>
  <code class="css">.text {
  color: rgba(var(--my-color-rgb, 255, 0, 0), 0.5);
}
</code>
</pre>

<h1>HSLA alternative</h1>

<p>The HSL (and HSLA) color space is getting more popular lately, probably because it aligns more with the human color perception. The <a rel="nofollow" href="https://css-tricks.com/yay-for-hsla/"><code>hsla()</code> functional notation</a> adds more opportunites to theming: you can take a hue then saturate/desaturate it, lighten/darken it, or make it more transparent. The above described method could look something like this in HSLA:</p>

<pre>
  <code class="css">:root {
  --my-color-hue: 0;
}

.text {
  color: hsla(var(--my-color-hue, 0), 100%, 50%, 0.5);
}
</code>
</pre>

<p>Although the HSLA alternative would work flawlessly, I didn't use it in my case. RGBA is completing the task perfectly, and maybe developers are more familiar with RGB than HSL.</p>

<h1>Demo time!</h1>

<p>I wired this whole concept into my component library. So when there's need for customization one would only have to define one or two variables at top level to create a whole new flavor or even a night mode of their app. Try the sliders under "Colors":</p>

<p><p data-slug-hash="zMKagM" data-default-tab="result" data-height="600" data-theme-id="0" class="codepen"></p></p>

<p>Further demos using the component library:</p>

<ul>
<li><a rel="nofollow" href="https://codepen.io/finnhvman/pen/jQbVeR">Material Registration Form</a> (Amber flavor)</li>
<li><a rel="nofollow" href="https://codepen.io/finnhvman/pen/oPwXRa">Duplicate Word Finder</a> (Default colored, I used it for proofreading this post :)</li>
<li><a rel="nofollow" href="https://codepen.io/finnhvman/pen/Yrzyvx">HTML and JSON Aware Pig Latin Translator</a> (Default colored)</li>
</ul>

<h1>Browser Support</h1>

<p>If you liked the demos and would like to implement a similar concept, I have some good news. This works in Chrome, Safari, Firefox, Samsung Internet and Edge. However, I should warn you about some difficulties. It turned out that Safari is not handling the CSS variable with fallback in <code>rgba()</code> in some cases. These cases are the shorthand or shorthandish properties like <code>border</code> and <code>box-shadow</code>. The workaround for this is to create some intermediate variable like:</p>

<pre>
  <code class="css">:root {
  --my-color-rgb: 255, 0, 0; 
}

.text {
  --intermediate: rgba(var(--my-color-rgb, 255, 0, 0), 0.5);
  border: solid 1px var(--intermediate);
}
</code>
</pre>

<p>CSS variables are also locally scoped, so defining <code>--intermediate</code> in <code>.text</code> won't pollute the global scope.</p>

<blockquote>
<p>Yeah, but you forgot that IE11 does not support CSS variables!</p>
</blockquote>

<p>You might say. Well you can do multiple things about it. First, I suggest reading <a rel="nofollow" href="https://medium.com/@burger.neal/the-end-of-life-of-internet-explorer-11-12736f9ff75f">The End of Life of Internet Explorer 11
</a>. Second, if you are still not convinced then you can inline your variables with <a rel="nofollow" href="https://postcss.org/">PostCSS</a>.</p>

<h1>Final thoughts</h1>

<p>When I created Pure CSS Material Components I wanted a lean, easy to use, but accurate component library. Making it themeable was a step that could lead to more complexity. I was also aware that Sass, Less or Stylus were already capable of solving this problem, but I think that's an obstacle for developers who don't use these preprocessors. CSS variables helped me keep things simple and stick to a native solution.</p>

<p>
  <em>Thanks for reading, I hope this post inspires you to try out CSS variables!</em>
</p>

    ]]>
  </description>

  <dc:subject>Theming with CSS variables in RGBA</dc:subject>

  <dc:date>
    2018-12-02T18:08:55-07:00
  </dc:date>

</item>

      <item>

  <title>Checkbox Toggle Switches Are Confusing UI</title>

  <link>https://codepen.io/marcusconnor/post/checkbox-toggle-switches-are-confusing-ui</link>
  <guid>https://codepen.io/marcusconnor/post/checkbox-toggle-switches-are-confusing-ui</guid>

  <dc:creator>Marcus Connor</dc:creator>

  <description>
    <![CDATA[
    <p><strong>TLDR:</strong> <em>Checkbox toggle switches don't work the way they appear. Use a rocker toggle switch or a proper sliding switch. Example at the bottom.</em></p>

<h2>The Problem With Checkbox Toggle Switches</h2>

<p>Most checkbox toggle switches created with CSS are confusing UI because they do not function like their real-world counterparts. When I encounter a toggle switch in my iPad settings I slide it over with my finger. Voilà, it works properly just like the real-world toggle on the side of the iPad. Often when I encounter the same toggle switch on the web I slide it over with my mouse and it doesn't work. It doesn't work because it's meant to be pushed like a button; but it doesn't appear as a button.</p>

<p>
  <img src="https://i.imgur.com/mL4O9iO.jpg" alt="iPad Toggle Switches" />
</p>

<h3>Looks Like a Range Slider</h3>

<p>To make matters worse HTML has actual sliders which look just like these toggles. If you want to make a sliding form element you could use the <code>input[type="range"]</code> element. It does not make sense to style a checkbox to look like a sliding range input, but that's what is being done all over the Internet. YouTube uses a sliding toggle for autoplay, and it works as a sliding toggle - it doesn't use a checkbox.</p>

<p>
  <img src="https://i.imgur.com/Fiu3WFY.png" alt="YouTube Toggle" />
</p>

<h2>The Rocker Switch Solution</h2>

<p>The rocker switch is a real-life toggle that functions as a button. By styling a checkbox to look like a rocker toggle switch you retain its real-world functionality. This is not the only solution or even the best solution, but it does a better job of conveying a click (or tap) by looking like a button rather than looking like a slider. It's also fun to click (or tap).</p>

<p><p data-slug-hash="QJNvMa" data-default-tab="result" data-height="300" data-theme-id="0" class="codepen"></p></p>

<p>I created the above pen to demonstrate the checkbox rocker switch. I look forward to seeing more creative solutions to use in place of checkbox toggle switches.</p>

    ]]>
  </description>

  <dc:subject>Checkbox Toggle Switches Are Confusing UI</dc:subject>

  <dc:date>
    2018-11-08T17:10:00-07:00
  </dc:date>

</item>

      <item>

  <title>CodePen Chicago: October 23rd, 2018 at Backstop Solutions</title>

  <link>https://codepen.io/brianmontanaweb/post/codepen-chicago-october-23rd-2018-at-backstop-solutions</link>
  <guid>https://codepen.io/brianmontanaweb/post/codepen-chicago-october-23rd-2018-at-backstop-solutions</guid>

  <dc:creator>Brian Montana</dc:creator>

  <description>
    <![CDATA[
    <h1>Codetober Scares!</h1>

<p>The CodePen Chicago Halloween event was held at Backstop Solutions for the third year in a row! They provided food, drinks and space; it was much appreciated. We had a lot of attendees presenting their spooky pens from CSS characters to JavaScript web games, we had it all!</p>

<p>Since this is the last one of the year, stay tuned for the next announcement and we plan to do in the future!
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/283591/20181023-codepen-chicago-halloween-007.jpg" alt="Smiling Halloween light with blurred smaller lights in front" /></p>

<h2>Presenters:</h2>

<h4>Ola Giwa</h4>

<p><a href="https://codepen.io/OG">Ola</a> showed characters made only with CSS and explained the process of blocking out the shapes before filling in the colors. Check out the Mario Ghost and Koala.</p>

<p>
  <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/283591/20181023-codepen-chicago-halloween-014.jpg" alt="Ola typing on MacBook in front of projector" />
</p>

<p data-height="351" data-theme-id="17637" data-slug-hash="ReVVxa" data-default-tab="css,result" class="codepen">See the Pen <a href="https://codepen.io/OG/pen/ReVVxa/">Mario Ghost</a> by OG (<a href="https://codepen.io/OG">@OG</a>) on <a href="https://codepen.io">CodePen</a>.</p>



<p data-height="527" data-theme-id="17637" data-slug-hash="KGNLZE" data-default-tab="css,result" class="codepen">See the Pen <a href="https://codepen.io/OG/pen/KGNLZE/">CSS Image</a> by OG (<a href="https://codepen.io/OG">@OG</a>) on <a href="https://codepen.io">CodePen</a>.</p>



<h4>Frederick Wells</h4>

<p><a href="https://codepen.io/pandabrand">Fred</a> created an SVG mask of Zora and talked about how it was built in Illustrator then updated as a mask for the image of Zora.</p>

<p>
  <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/283591/20181023-codepen-chicago-halloween-017.jpg" alt="Fred in front of the projector screen with his hand raised" />
</p>

<p data-height="300" data-theme-id="17637" data-slug-hash="Oovaym" data-default-tab="css,result" class="codepen">See the Pen <a href="https://codepen.io/pandabrand/pen/Oovaym/">Zora</a> by Frederick Wells (<a href="https://codepen.io/pandabrand">@pandabrand</a>) on <a href="https://codepen.io">CodePen</a>.</p>



<h4>Marvin Cespedes</h4>

<p><a href="https://codepen.io/mcespo">Marvin</a> explored the Web Animation API and made a walking Dry Bones that moves from side to side :D</p>

<p data-height="300" data-theme-id="17637" data-slug-hash="rqryMM" data-default-tab="css,result" class="codepen">See the Pen <a href="https://codepen.io/mcespo/pen/rqryMM/">Dry Bones</a> by Marvin Cespedes (<a href="https://codepen.io/mcespo">@mcespo</a>) on <a href="https://codepen.io">CodePen</a>.</p>



<h4>Sean Codes</h4>

<p><a href="https://codepen.io/sean_codes">Sean's</a> pen was the scariest thing shown, an OS update! Just install... or you'll be haunted forever!</p>

<p>
  <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/283591/20181023-codepen-chicago-halloween-021.jpg" alt="A projected image of the display of Sean&#39;s pen" />
</p>

<p data-height="300" data-theme-id="17637" data-slug-hash="aayXEm" data-default-tab="css,result" class="codepen">See the Pen <a href="https://codepen.io/sean_codes/pen/aayXEm/">updates available</a> by sean_codes (<a href="https://codepen.io/sean_codes">@sean_codes</a>) on <a href="https://codepen.io">CodePen</a>.</p>



<h4>Colt Borg</h4>

<p>Which witch hat to pick? <a href="https://codepen.io/coltborg">Colt's</a> Vue pen is an example of a Single Page App(SPA) that swaps out the hat on the witch when you make your selection!</p>

<p>
  <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/283591/20181023-codepen-chicago-halloween-023.jpg" alt="Colt with projector light over his face in black and white" />
</p>

<p data-height="625" data-theme-id="17637" data-slug-hash="Bqygdq" data-default-tab="html,result" class="codepen">See the Pen <a href="https://codepen.io/coltborg/pen/Bqygdq/">Witch Hat App</a> by Colt Borg (<a href="https://codepen.io/coltborg">@coltborg</a>) on <a href="https://codepen.io">CodePen</a>.</p>



<h4>Brian Montana</h4>

<p><a href="https://codepen.io/brianmontanaweb">I</a> showed a pen that used fractals that randomized the length of the branches and at the end draw leaves with a curated array of fall colors.</p>

<p>
  <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/283591/20181023-codepen-chicago-halloween-024.jpg" alt="Project with Brian&#39;s pen displayed on it" />
</p>

<p data-height="300" data-theme-id="17637" data-slug-hash="pxZJgr" data-default-tab="result" class="codepen">See the Pen <a href="https://codepen.io/brianmontanaweb/pen/pxZJgr/">Fall trees</a> by Brian Montana (<a href="https://codepen.io/brianmontanaweb">@brianmontanaweb</a>) on <a href="https://codepen.io">CodePen</a>.</p>



<h4>Jeremy Kahn</h4>

<p>This web game by <a href="https://codepen.io/jeremyckahn">Jeremy</a> was a learning process to explore flex box, you can buy items, plant them and check out your inventory!</p>

<p>
  <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/283591/20181023-codepen-chicago-halloween-027.jpg" alt="Jeremy with projector light typing on a laptop" />
</p>

<p>
  <a href="https://jeremyckahn.github.io/farmhand/">Farmhand</a>
</p>

<h4>Austin Andrews</h4>

<p><a href="https://codepen.io/templarian">Andrew</a> showed Material Design Icons documentation for React and how to use the components, lots of interesting compounding, check it out!</p>

<p>
  <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/283591/20181023-codepen-chicago-halloween-030.jpg" alt="Austin pointing to the projector" />
</p>

<p>
  <a href="https://templarian.github.io/@mdi/react/">MDI Demo</a>
</p>

<h2>Photo Gallery:</h2>

<p>
  <a href="https://photos.app.goo.gl/tjJ61Gtmze4j6Zxc8">CodePen Chicago at Backstop Solutions</a>
</p>

<h2>Thank you!</h2>

<p>Thanks to Colt, Andy and Backstop Solutions for the space, food and being wonderful hosts! Thank you to Marvin for the photos and to Austin for the MDI posts again!</p>

    ]]>
  </description>

  <dc:subject>CodePen Chicago: October 23rd, 2018 at Backstop Solutions</dc:subject>

  <dc:date>
    2018-11-06T19:54:15-07:00
  </dc:date>

</item>

      <item>

  <title>Use cases for SVG  in web design</title>

  <link>https://codepen.io/Stefany93/post/use-cases-for-svg-in-web-design</link>
  <guid>https://codepen.io/Stefany93/post/use-cases-for-svg-in-web-design</guid>

  <dc:creator>Stefany Newman</dc:creator>

  <description>
    <![CDATA[
    <ul>
<li><strong>Logos</strong></li>
</ul>

<p>If your logo isn't SVG, you should convert ASAP. <a href="https://watb.co.uk/5-reasons-you-should-be-using-svgs-over-pngs/">There are plenty of articles</a> outlining how much more useful SVG logos are from their PNG counterparts.
<a href="https://caniuse.com/#search=img%20svg">Browser support</a> is awesome for inline and externally linked SVGs.</p>

<ul>
<li><strong>Icons</strong></li>
</ul>

<p>I made the switch from font icons to SVG and I couldn't be happier. There is still debate whether you should <a href="https://css-tricks.com/pretty-good-svg-icon-system/">inline</a> or <a href="https://tomhazledine.com/inline-svg-icon-sprites/">sprite</a> the icons, I think it depends on the project. It is so much more semantic to use SVG icons, since you are literally placing an icon rather than using a font glyph. I get mad when I see PNG icons! I can barely recognize them from these pixels!</p>

<p>
  <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/303790/png-icons.jpg" alt="" />
</p>

<p>
  <em>PNG icons look blurry when scaled</em>
</p>

<ul>
<li><strong>Image Maps</strong></li>
</ul>

<p>I remember how hellish those were to code correctly pre responsive design era and they still are. But with SVG, it is way more semantic since you have a text node with a clickable link and that's it!. And you can highlight the link with a pinch of CSS and have cool animation if you like! Not to mention the benefits of accessibility.</p>

<p>
  <code>&lt;a xlink:href="http://example.com"&gt;
    &lt;text&gt;Click me!&lt;/text&gt;
&lt;/a&gt;</code>
</p>

<p>In one website re-design project, we had a PNG image map of apartment buildings with the numbered flats so when users would hover the unit number will be highlighted and they will be redirected to the apartment details. The problem was, this image was created 10 years ago and it looked awful on mobile - even on desktop it was pixelated. But the project manager needed it on the page with the same functionality. </p>

<p>I came up with the idea of two SVG images - one for desktop/tablet and another for phone. Making them clickable was a piece of cake - just add <code>a:xlink</code> elements! No <code>position:absolute</code> hacks! As for accessibility, in this case, the link text wasn't very descriptive - just the apartment number. But that's where <code>aria-label</code> comes to the rescue!</p>

<ul>
<li><strong>Floor Plans</strong></li>
</ul>

<p>Floor plans sketches are excellent in SVG. They mostly consist of boxes, numbers and are black &amp; white - nothing fancy, and they will look super crisp in SVG and will load incredible fast on mobile (which is where you mostly spend your time looking for a new apartment anyways)</p>

<p><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/303790/Sample_Floorplan.jpg" alt="" />]</p>

<p>
  <em>Floor plans can be converted into SVG thus decreasing their size</em>
</p>

<p>Don't just stop at floor plans! Any time a simple sketch it presented on a site, it is an excellent candidate for SVG!</p>

<ul>
<li><strong>Complex Animations</strong></li>
</ul>

<p>When a simple CSS <code>transition</code> property on a <code>div</code> won't cut it (or it will take a lot of time to code) use SVG to create fancy animations. Then it is simply a matter of moving nodes/paths either with CSS and/or JS. Easy and semantic.</p>

<p><img src="https://envylabs.com/1d392619125b920b6c0ccc38da827baa.svg" alt="" />
<em>SVG animation by <a href="https://envylabs.com/">Envy Labs</a></em></p>

<ul>
<li><strong>No-Image Image</strong>
You have seen these images when you browse e-stores, "No image available" images that sometimes look blurry. I used SVG last time I needed such a placeholder and it looked awesome! Not to mention how lightweight it was.</li>
</ul>

    ]]>
  </description>

  <dc:subject>Use cases for SVG  in web design</dc:subject>

  <dc:date>
    2018-11-15T17:32:14-07:00
  </dc:date>

</item>

      <item>

  <title>One Hundred Sparks</title>

  <link>https://codepen.io/mariemosley/post/one-hundred-sparks</link>
  <guid>https://codepen.io/mariemosley/post/one-hundred-sparks</guid>

  <dc:creator>Marie Mosley</dc:creator>

  <description>
    <![CDATA[
    <p>The <a href="https://codepen.io/spark/100">100th issue of The CodePen Spark</a> went out this morning 🎉</p>

<p>
  <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/652/Screenshot%202018-10-29%2011.55.09.png" alt="" />
</p>

<p>That's means it's been 100 weeks since we started sending a weekly newsletter packed with front-end inspiration to hundreds of thousands of devs around the world. Whew!</p>

<p>Though nothing at CodePen is a true solo project, I think it's fair to say The Spark is my domain — I select the content for it and write it each week. It's my favorite thing I do at work. </p>

<p>So, I'm taking this milestone as an opportunity to share a little behind-the-scenes look at how The Spark is made, and reminisce a bit. </p>

<h3>The Spark Alumni</h3>

<p>I can't celebrate a milestone like this without a shoutout to two CodePen alumni: <a href="https://twitter.com/twholman">Tim Holman</a>, who came up with the idea and built the original system we used to create and send the newsletter. And <a href="https://twitter.com/jake_albaugh">Jake Albaugh</a>, who built the CMS and email system we use to create and send The Spark today. </p>

<p>You can hear Tim talking about the very earliest days of The Spark in 📻<a href="https://blog.codepen.io/2016/12/12/113-codepen-spark/">CodePen Radio #113: The CodePen Spark</a>, which aired the week after the first issue went out. </p>

<p>Later, Jake was on the show to talk about designing and building the ETL system we use for The Spark in 📻<a href="https://blog.codepen.io/2018/01/16/157-etl/">CodePen Radio #157: ETL</a>.</p>

<h3>Gathering Sparks</h3>

<p>The goal is to <strong>spark</strong> people's minds with inspiration or new information that makes them want to create, or learn something new. I keep that in mind as I select the content for each issue. </p>

<p>Every issue of The Spark is a mixture of what was popular on CodePen through the week, and things that I feel should get more attention. </p>

<figure>
  <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/652/cascading-silk-screen.png" />
  <figcaption>"css (cascading silk screen)" by Daniel Warren in <a href="https://codepen.io/spark/84">Spark #84</a></figcaption>
</figure>

<p>To keep things fresh, I try to keep it scoped to things that were created in the week since the previous Spark went out. </p>

<p>The Spark is also a chance to show off the work of the CodePen community at large — I love finding Twitch streams, posts on personal websites, and Medium and Dev.to posts to share.</p>

<figure>
  <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/652/level-up-selector-skills.png" />
  <figcaption>David Gwyer's Medium post "Level Up Your CSS Selector Skills" in <a href="https://codepen.io/spark/80">Spark #80</a></figcaption>
</figure>

<p>Sometimes I'll include things that we <em>didn't</em> pick for the homepage, but wanted to. Some front-end experiments need a little extra context. For example, a Pen where all the interesting stuff is happening in the console. Other things need a bit of "fair warning", like when they ask for webcam access, or automatically play sounds or music. We're not able to add that kind of "heads up" to the homepage grid, but we <em>can</em> include it in The Spark.</p>

<h3>Captions</h3>

<p>Captions are my chance to zoom in to the details and share tidbits that might not always come through on the home page. I can use a caption to highlight interesting technologies or techniques, or give the backstory on where a design idea came from. </p>

<p>I like to use the creator's own words (from the "Description" of the Pen/Project/Collection) when they're available. Sometimes a good description is what makes me choose something for The Spark, so don't forget to fill in that field 😉</p>

<p>And of course, I write a lot of captions from scratch. Here's my favorite I wrote this year, for Cassie Evans' "Shy blob -  Face detection" in <a href="https://codepen.io/spark/82">Spark #82</a>. </p>

<figure>
  <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/652/shy-blob-caption.png" />
  <figcaption>
    "Cassie Evans' lil blob dance like no one is watching — but *only* if no one is watching! If you peek (through your webcam) this shy blob will stop boppin' and start blushin'."
  </figcaption>
</figure>

<h3>Titles</h3>

<p>I love writing the titles for each issue.</p>

<p>Usually, I go with 3-part alliteration, like "<a href="https://codepen.io/spark/87">Melody, Maps, and Mood"</a>. But if I can't find a starting-letter match across 3 different entries in the issue, I go with something thematic that ties the week together, like <a href="https://codepen.io/spark/44">"Time, Perspective, and Expansion"</a>. </p>

<p>And, like every headline writer, I've learned some lessons about truncation the hard way....</p>

<figure>
  <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/652/truncation.png" />
  <figcaption>"Buildings, Bouquets, and Butt....." wasn't exactly the tone I was aiming for. </figcaption>
</figure>

<h3>Tools</h3>

<p>I have a couple tools that are indespensible for putting together The Spark.</p>

<h4>Slack</h4>

<p>Through the week, I save things I'm considering for The Spark in our #newsletter channel in our internal Slack. Since CodePen is fully remote we all live in Slack, so it felt like the natural place to gather up our favorites from the week. I use the "pin to channel" feature to create a list of links right inside the channel. </p>

<h4>Images</h4>

<p>For still screenshots, I use the built-in macOS screenshot feature and crop it down to size in Preview. Nothing fancy!</p>

<p>Gifs are where it gets tricky. Getting both a good loop <em>and</em> a small filesize presents a challenge. Luckily I have a great tool for that. </p>

<figure>
  <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/652/giphy-loop.png" />
  <figcaption>cutting a loop with Giphy Capture</figcaption>
</figure>

<p>I use <a href="https://giphy.com/apps/giphycapture">Giphy Capture</a>. The controls for creating a loop are very intuitive, and it has great export options. I export the gif at a low frame rate to keep its size small. Then, I run it through <a href="https://imageoptim.com/mac">ImageOptim</a> to compress it further.</p>

<h4>ETL</h4>

<p>When I'm ready to add an item to The Spark, I post it through the CMS Jake created. </p>

<p>
  <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/652/spark-backstage.png" alt="" />
</p>

<p>The great thing about this setup is that once the issue is complete, it generates JSON that includes all of the content I manually added to the issue, plus every upcoming event from the Meetups page and all of the current listings from our Jobs board. I used to have to copy those all in manually, which was really slow and typo-prone. </p>

<h4>To Hundreds More!</h4>

<p>Though 100 is a fun round number, it still feels like we're just getting started with what The Spark can be. I'm looking forward to making new discoveries and sharing new sparks of inspiration ✨</p>

<p>I'd really love to share more long-form writing about front-end development with embedded Pens, and more collections. If you're making those things, let us know! You can share them with us on Twitter <a href="https://twitter.com/codepen">@CodePen</a>, or in our Spectrum community at <a href="https://spectrum.chat/codepen">spectrum.chat/codepen</a>. </p>

    ]]>
  </description>

  <dc:subject>One Hundred Sparks</dc:subject>

  <dc:date>
    2018-10-29T16:59:34-07:00
  </dc:date>

</item>

      <item>

  <title>Smart animations with custom properties</title>

  <link>https://codepen.io/equinusocio/post/smart-animations-with-custom-properties</link>
  <guid>https://codepen.io/equinusocio/post/smart-animations-with-custom-properties</guid>

  <dc:creator>Mattia Astorino</dc:creator>

  <description>
    <![CDATA[
    <p>A few days ago I was talking with a friend about the most popular CSS libraries to integrate simple animations into a project. After a bit of research these names emerged, including the most popular <strong>Animate.css</strong> and <strong>AnimeJS</strong>:</p>

<ul>
<li><strong>Animate.css</strong> - <a rel="noopener" href="https://daneden.github.io/animate.css/">https://daneden.github.io/animate.css/</a></li>
<li><strong>Animejs</strong> - <a rel="noopener" href="http://animejs.com/">http://animejs.com/</a></li>
<li><strong>Magic animations</strong> - <a rel="noopener" href="https://www.minimamente.com/example/magic_animations/">https://www.minimamente.com/example/magic_animations/</a></li>
<li><strong>Hover</strong> - <a rel="noopener" href="http://ianlunn.github.io/Hover/">http://ianlunn.github.io/Hover/</a></li>
<li><strong>Anijs</strong> - <a rel="noopener" href="http://anijs.github.io/">http://anijs.github.io/</a></li>
</ul>

<p>What amazed me most is that some of these libraries, especially those CSS, were introduced several years ago. Although CSS now allows us to find better results and write simpler and more efficient code, these libraries seem timeless (do you remember jQuery?) and only few people really give importance to the complexities that these bring with them once included into our project; especially if we have to take into account weight and performance. For example, a question that we should all ask ourselves, is:</p>

<blockquote>
<p>Does it make sense to include the entire library if I need only 3 animations?</p>
</blockquote>

<p>The answer is obviously <em>no</em>, and to overcome this, some people "copy" (👮🏻) the individual keyframes and use them independently from the library itself. If you use <a rel="noopener" href="https://postcss.org/">PostCSS</a> (and you should) there is a plugin that allows you to conditionally import the keyframes you want, when you need them.</p>

<h2>The problem</h2>

<p>Almost all of these CSS libraries provide a set of classes to which a specific animation is assigned. So, to apply a <em>fade from bottom</em> animation we will add the relative class to the HTML element, then customising it through CSS:</p>

<pre>
  <code class="html">&lt;progress class="fadeFromBottom"&gt;&lt;/progress&gt;

&lt;style&gt;
  .fadeFromBottom {
    animation-duration: 2s; /* This may require !important 👀 */
    animation-delay: 0.5s;
  }
&lt;/style&gt;
</code>
</pre>

<p>As is easily to understand, this means that for each imported animation (for example, the direction is managed with a different class) there is a corresponding CSS class and to customise it we must overwrite the code, sometime using the <em>!important</em> (❗️) keyword, resulting in a not-so-much scalable code.</p>

<p>How can we therefore evolve this approach using today's tools?</p>

<h2> Continue reading on:</h2>

<blockquote>
<p><a rel="nofollow" href="https://equinsuocha.io/blog/smart-animations-with-custom-properties">https://equinsuocha.io/blog/smart-animations-with-custom-properties</a></p>
</blockquote>

    ]]>
  </description>

  <dc:subject>Smart animations with custom properties</dc:subject>

  <dc:date>
    2018-10-16T12:14:34-07:00
  </dc:date>

</item>

      <item>

  <title>Tips for a Good Time When Extending CSS</title>

  <link>https://codepen.io/tomhodgins/post/tips-for-a-good-time-when-extending-css</link>
  <guid>https://codepen.io/tomhodgins/post/tips-for-a-good-time-when-extending-css</guid>

  <dc:creator>Tommy Hodgins</dc:creator>

  <description>
    <![CDATA[
    <p>Each of the points below have lived on a whiteboard in my house for months. I see them each day as I think about how CSS can be extended, and what the best way to design extensions to the web platform are, and I think there's truth inside them that can help you avoid some of the pitfalls others have encountered when trying to extend languages.</p>

<h2>1. Don't camp on platform names as you extend</h2>

<p>This means as you're trying to add new features to a language, avoid using any syntax that could possibly ever be added to the language you're working with in the future.</p>

<blockquote>
<p>Example: Some CSS preprocessors have had issues with <code>min()</code> and <code>max()</code> support in CSS because they invented their own <code>min()</code> and <code>max()</code> functions to do something slightly different. Oops!</p>
</blockquote>

<h2>2. Don't try to predict the future</h2>

<p>This means build what you need today and support what you need to support, but don't try to predict what will be standardized in the future, and doubly extra-don't tell people they're 'writing future syntax today'. The future is hard to predict and sometimes one person's misunderstanding can propagate through to an entire industry.</p>

<blockquote>
<p>Example: CSSNext claimed to let you use tomorrow's CSS syntax today, and much of the CSSNext functionality was based on a misunderstanding of a dead specification for <code>@apply</code>. There was a dream spec for something called <code>@apply</code> that was only ever intended for ShadowDOM, and the author realized it was flawed and killed it - but not before it was taken and mistakenly applied to light DOM, and thousands of developers got into the habit of using this dead, never-proposed shadowDOM-only feature in a way that was never intended. Now the entire CSSNext project and all code written with it has been deprecated, and 'postcss-preset-env' now claims to let you use tomorrow's CSS today, this time without <code>@apply</code>. Oops!</p>
</blockquote>

<h2>3. Prefer HTML/CSS/JS over custom syntaxes</h2>

<p>The specifications for what valid HTML is, or what valid CSS is, or what valid JS is are published. You can look them up and build a parser that successfully parses these languages. However many tool makers don't do this. Famously, SCSS struggles with just about every new CSS feature that gets added, and based on the limitations of its design and the features we know are coming down the CSS pipeline, we can expect many more breaking changes to come.</p>

<blockquote>
<p>Example: SCSS isn't a superset of CSS but is a CSS-like language that can be parsed into CSS. But it also chokes on perfect valid CSS syntax as well, <code>h1 { font-size: max(10px, 1vw); }</code> is a simple example, and if you say "Hey that's valid, but it's a new feature!" fine, this also breaks it and it's been around for years: <code>@supports (--general-enclosed()) { html { background: lime; } }</code> Oops!</p>
</blockquote>

<h2>4. Abstract HOW you do, not WHAT you do (aka abstract your process, not your product)</h2>

<p>When extending a language, don't abstract the pieces you're working with to the point that it's not obvious what's going on, automate your labour but keep your workflow close to the thing you're actually working on. Let your abstraction carry you effortlessly to the place where you need to do your work for maximum effectiveness, rather than trying to abstract the work away from you.</p>

<blockquote>
<p>Example: Some CSS-in-JS systems abstract styling so far they're almost impossible to debug, because what you as the author are typing to conjure up styles on an element and the styles that are being put onto the element have little relation to each other. You're not using the tool to help you make your work easier, you're at the mercy of whatever the tool lets you do. Oops!</p>
</blockquote>

    ]]>
  </description>

  <dc:subject>Tips for a Good Time When Extending CSS</dc:subject>

  <dc:date>
    2018-10-16T16:29:58-07:00
  </dc:date>

</item>

      <item>

  <title>How to Import a 3D Blender Object into a Three.js Project as a glTF File</title>

  <link>https://codepen.io/matthewmain/post/how-to-import-a-3d-blender-object-into-a-three-js-project-as-a-gltf-file</link>
  <guid>https://codepen.io/matthewmain/post/how-to-import-a-3d-blender-object-into-a-three-js-project-as-a-gltf-file</guid>

  <dc:creator>Matthew Main</dc:creator>

  <description>
    <![CDATA[
    <p><p data-slug-hash="YJwoVy" data-default-tab="result" data-height="600" data-theme-id="0" class="codepen"></p></p>

<p>
  <br />
</p>

<p>If you’re coding 3D visualizations with <a href="https://threejs.org/">Three.js</a>, sooner or later you’ll want to move beyond using the library’s basic native shapes to using complex custom 3D objects wrapped in UV mapped material.</p>

<p><a href="https://www.blender.org/">Blender</a> is a fantastic free open-source software for creating beautiful 3D objects. Since Three.js <a href="https://github.com/mrdoob/three.js/issues/12903">dropped support of its Blender exporter plugin</a> in favor of relying on its glTF loader, exporting via the popular and versatile glTF file format is now the way to go for bringing Blender objects into your Three.js projects.</p>

<p>
  <br />
</p>

<p>
  <img src="https://cdn-images-1.medium.com/max/1600/1*6MeYOWqCYECyQCo-Jp1VgA.png" alt="" />
</p>

<p>
  <br />
</p>

<p>This tutorial will walk through each step from creating a Three.js-compatible UV-wrapped 3D object in Blender to loading the object into a Three.js scene. Here’s what we’ll cover:</p>

<p>
  <br />
</p>

<p>
  <strong>
    <a href="https://codepen.io/matthewmain/post/how-to-import-a-3d-blender-object-into-a-three-js-project-as-a-gltf-file#part-1-creating-a-threejs-compatible-uv-mapped-3d-object-in-blender-0">Part 1: Creating a Three.js-Compatible UV Mapped 3D Object in Blender</a>
  </strong>
</p>

<p>
  <strong>
    <a href="https://codepen.io/matthewmain/post/how-to-import-a-3d-blender-object-into-a-three-js-project-as-a-gltf-file#part-2-importing-the-uv-image-into-blender-as-gltf-material-1">Part 2: Importing the UV Image into Blender as glTF Material</a>
  </strong>
</p>

<p>
  <strong>
    <a href="https://codepen.io/matthewmain/post/how-to-import-a-3d-blender-object-into-a-three-js-project-as-a-gltf-file#part-3-exporting-the-gltf-file-from-blender-2">Part 3: Exporting the glTF file from Blender</a>
  </strong>
</p>

<p>
  <strong>
    <a href="https://codepen.io/matthewmain/post/how-to-import-a-3d-blender-object-into-a-three-js-project-as-a-gltf-file#part-4-loading-the-gltf-file-into-a-threejs-scene-3">Part 4: Loading the glTF file into a Three.js Scene</a>
  </strong>
</p>

<p>
  <br />
  <br />
  <br />
  <br />
</p>

<h1>Part 1: Creating a Three.js-Compatible UV Mapped 3D Object in Blender</h1>

<p>
  <br />
</p>

<p>This tutorial will use <strong><em>Bus Derby</em></strong>, a 3D browser-based video game built with Three.js, to provide examples for each step. The game and all of the source code can be found <a href="https://codepen.io/matthewmain/pen/YJwoVy">right here on CodePen</a>, or <a href="https://github.com/matthewmain/bus_derby">here on GitHub</a>, for reference. (If you're into design, the UI case study is also available <a href="https://www.behance.net/gallery/71417175/Bus-Derby">on Behance here</a>.)</p>

<p>We’ll be using this bus image as a model to base our 3D Blender object on.</p>

<p>
  <img src="https://cdn-images-1.medium.com/max/1600/1*LNtagHNpXK79piSowXR6FQ.jpeg" alt="" />
</p>

<p>To begin, you’ll first need to have a 3D object shaped in Blender. This tutorial won’t cover the details of using the software to create shapes. If you’re new to Blender, there are tons of existing tutorials to bring you up to speed. I’d recommend this YouTube <a href="https://www.youtube.com/watch?v=JYj6e-72RDs">Blender Beginner Tutorial</a>. When I began the Bus Derby project, I’d barely heard of Blender, and the series gave me the know-how to create this bus body shape below, which we’ll be using as an example.</p>

<p>
  <img src="https://cdn-images-1.medium.com/max/1600/1*ZNZYtw69Y_HCmlcXHwQkSg.png" alt="" />
</p>

<p>
  <br />
</p>

<p>
  <strong>Unwrapping UVs in Blender to Create a UV map</strong>
</p>

<p>If you’re already familiar with unwrapping UVs, go ahead and skip down to <a href="https://codepen.io/matthewmain/post/how-to-import-a-3d-blender-object-into-a-three-js-project-as-a-gltf-file#part-2-importing-the-uv-image-into-blender-as-gltf-material-1">Part 2</a>. If not, the first step you'll need to take toward UV unwrapping in Blender is to open a new area as a "UV/Image Editor".</p>

<p>
  <img src="https://cdn-images-1.medium.com/max/1600/1*XqtBkWj3bI62i9bzkDUxyw.png" alt="" />
</p>

<p>Hit TAB to toggle into <em>Edit</em> mode, then “A” to select all. Hit “U” (for unwrap), then select <em>Smart UV Project</em>. Hit “Okay” to accept the default settings. This will automatically unwrap the UVs and place them on the UV map.</p>

<p>
  <img src="https://cdn-images-1.medium.com/max/1600/1*pz5Gov5hClUZ87Bo5Ex80A.png" alt="" />
</p>

<p>(Alternatively, for more control over how Blender unwraps the UV, you can designate seams. Select the edges where you’d like the seams to be, hit CONTROL-E, then select "Mark Seams". Seams will appear as red edges. When all of the seams are marked, hit “U”, then select Unwrap.)</p>

<p>
  <br />
</p>

<p>
  <strong>Exporting the UV Map as a PNG file</strong>
</p>

<p>Position the segments on the UV Map in a way that will be easy to work with when creating the images. Group them by their expected color and arrange them relationally so it’s clear how each segment corresponds to the 3D shape. (Select the “island” mode to easily select and move isolated segments.)</p>

<p>
  <img src="https://cdn-images-1.medium.com/max/1600/1*hbsgZxVxrq_raCNT7kMYIw.png" alt="" />
</p>

<p>Hit “A” to make sure the the entire map is selected. Open the “UVs” menu at the bottom of the UV/Image Editor area, and select <em>Export UV Layout</em>. Enter the name and location for the file, then click the “Export UV Layout” button. This will export a .png image of the UV map outlines over a transparent background.</p>

<p>
  <br />
</p>

<p>
  <strong>Creating the UV Image with Image Editing Software</strong>
</p>

<p>Open the exported .png file in any image editing software like Sketch, Illustrator, or Photoshop. Add a new image layer beneath the UV map, and fill in the outlines with any combination of color, illustration, or photos. When you’re done with the image, hide or delete the UV map layer, and export as a new image file to the same directory as the .blend file.</p>

<p>
  <img src="https://cdn-images-1.medium.com/max/2000/1*yrgNLGFG3uW8dUtRq7wydg.png" alt="" />
</p>

<p>
  <br />
  <br />
</p>

<h1>Part 2: Importing the UV Image into Blender as glTF Material</h1>

<p>
  <br />
</p>

<p>To import the UV image .png into Blender in a way that will be compatible with exporting to Three.js, we’ll need to bring the <a href="https://github.com/KhronosGroup/glTF-Blender-Exporter">KhronosGroup glTF Blender Exporter plugin</a>. To do so, clone or download the exporter from GitHub into the same directory as the .blend file, and unzip it.</p>

<p>
  <img src="https://cdn-images-1.medium.com/max/1600/1*oS7C6Z127ycythxVVxGDlw.png" alt="" />
</p>

<p>Back in Blender, append the glTF Blender Exporter file’s <em>glTF Metallic Roughness</em> material. To do this, go to <em>File &gt; Append</em>, then navigate to <em>glTF-Blender-Exporter-master/pbrnode/glTF2.blend/NodeTree</em>, and select the <em>glTF Metalic Roughness</em> material. (We’ll use this material in the tutorial, but if you want you can repeat this step to append the <em>glTF Specular Glossiness</em> material as well, which is also compatible with Three.js)</p>

<p>
  <img src="https://cdn-images-1.medium.com/max/1600/1*BUCeXe_ng3sjUPC0k1Oq0w.png" alt="" />
</p>

<p>Select <em>Cycles Render</em> from the menu on the top bar.</p>

<p>
  <img src="https://cdn-images-1.medium.com/max/1600/1*x4IU3PSJCGdRUfD7WpxjDA.png" alt="" />
</p>

<p>Now, open another new area as a <em>Node Editor</em>.</p>

<p>
  <img src="https://cdn-images-1.medium.com/max/1600/1*oXOfxlEJ7k-dJAM8wlDQnQ.png" alt="" />
</p>

<p>In the <em>Properties</em> panel on the right side of the Blender interface, select the <em>Material</em> display, and give the material a recognizable name. We’ll call it “bus_material” here.</p>

<p>
  <img src="https://cdn-images-1.medium.com/max/1600/1*p2xsoduOMcOVWjxByarmdA.png" alt="" />
</p>

<p>In the node editor, Add a new Metallic Roughness glTF material node. To do this, go to <em>Add &gt; Group &gt; glTF Metallic Roughess</em>, and place the new glTF Metallic Roughness node.</p>

<p>
  <img src="https://cdn-images-1.medium.com/max/1600/1*ZMbsknDZm_Sm2iS0-A43UQ.png" alt="" />
</p>

<p>Delete the “Diffuse BSDF node”. Just select it, then hit “X”.</p>

<p>Add a new image texture node. Go to <em>Add &gt; Texture &gt; Image Texture</em>, and place the new node. Then, on the new image texture node, go to <em>Open &gt; select UV image</em>, and select your UV Image file.</p>

<p>
  <img src="https://cdn-images-1.medium.com/max/1600/1*ef8DeCu2CZ0-eIJhzWYvhQ.png" alt="" />
</p>

<p>Connect the Image Texture node’s <em>Color</em> and <em>Alpha</em> connectors to the glTF Metallic Roughness node’s <em>BaseColor</em> and <em>Alpha</em> connectors, respectively. Connect the glTF Metallic Roughness node’s <em>Shader</em> connector to the Material Output node’s <em>Surface</em> connector.</p>

<p>
  <img src="https://cdn-images-1.medium.com/max/1600/1*aWd2wUK98M-ftH5mD7SRlg.png" alt="" />
</p>

<p>In the 3D view editor, you should now see the UV image projected onto the 3D shape. Looking pretty damn good.</p>

<p>
  <img src="https://cdn-images-1.medium.com/max/1600/1*Po7_cDHWKGK7SXJekG_Tug.png" alt="" />
</p>

<p>Adjust the <em>MetallicFactor</em> and <em>RoughnessFactor</em> on the glTF Metallic Roughness node to taste.</p>

<p>
  <br />
  <br />
</p>

<h1>Part 3: Exporting the glTF file from Blender</h1>

<p>
  <br />
</p>

<p>For this next step, to send the object to your Three.js project, we’ll first need to point Blender to the KhronosGroup glTF Blender Exporter script. To do this, go to <em>File &gt; User Preferences</em> to open the User <em>Preferences</em> window. Under the File tab, click the “Scripts” folder icon. Navigate to <em>glTF-Blender-Exporter-master/scripts</em>, and click the “Accept” button. Click the “Save User Settings” button. Close the User Preferences window.</p>

<p>
  <img src="https://cdn-images-1.medium.com/max/1600/1*Ai9K11BLT7qeB9DhG5Wsyw.png" alt="" />
</p>

<p>Save, close Blender, and re-open Blender for the plugin to persist.</p>

<p>Add the glTF 2.0 format to Blender. Go back to <em>File &gt; User Preferences</em>. This time, open the “Add-ons” tab. Use the search bar to search for “glTF”, then check “Import-Export: glTF 2.0 format”. Click the “Save User Settings” button. Close the window.</p>

<p>
  <img src="https://cdn-images-1.medium.com/max/1600/1*TDI46En5t02N5RReALfqoQ.png" alt="" />
</p>

<p>Now we’re ready to export the glTF as a Three.js-compatible .glb file. Go to <em>File &gt; Export &gt; glTF 2.0 (.glb)</em>. Check “Export all layers”, “Export materials”, “Export texture coordinates”, “Export normals”, and any other properties you’ll need to include for your project. Give the file an appropriate name. I’m calling mine “bus_body_green.glb”. Navigate to wherever you want to save the file, and click the “Export glTF 2.0 binary” button.</p>

<p>
  <img src="https://cdn-images-1.medium.com/max/1600/1*4ysY3Kwo_JLwoNlwb4hqYA.png" alt="" />
</p>

<p>
  <br />
  <br />
</p>

<h1>Part 4: Loading the glTF file into a Three.js Scene</h1>

<p>
  <br />
</p>

<p>And now at last we’re ready to load the 3D object into your Three.js project. (Have a look at the <a href="https://codepen.io/matthewmain/pen/KxQaMb">Bus Derby example here on CodePen</a> or <a href="https://github.com/matthewmain/bus_derby">here on Github</a> for fuller context of the code.)</p>

<p>In your Three.js app’s index HTML file, add the <a href="https://threejs.org/docs/#examples/loaders/GLTFLoader">Three.js glTF loader</a> library source.</p>

<pre>
  <code>&lt;script src=”https://cdn.rawgit.com/mrdoob/three.js/master/examples/js/loaders/GLTFLoader.js"&gt;&lt;/script&gt;
</code>
</pre>

<p>Create a new glTF loader object. Load the .glb file and apply the 3D object (which lives at <code>gltf.scene.children[0]</code>) to an object that will be added to the scene. Position and scale as needed.</p>

<pre>
  <code>var loader = new THREE.GLTFLoader();
loader.load(
   "https://s3-us-west-2.amazonaws.com/s.cdpn.io/409445/bus_body_green.glb",
   function ( gltf ) {
      var scale = 5.6;
      bus.body = gltf.scene.children[0];
      bus.body.name = “body”;
      bus.body.rotation.set ( 0, -1.5708, 0 );
      bus.body.scale.set (.5,.5,.5);
      bus.body.position.set ( 0, 3.6, 0 );
      bus.body.castShadow = true;
      bus.frame.add(bus.body);
   },
);

scene.add( bus.frame )
</code>
</pre>

<p>
  <br />
</p>

<p>That’s it! You’ve brought your 3D Blender object into your Three.js project. You’re good to go. :)</p>

<p>
  <br />
</p>

<p>
  <img src="https://cdn-images-1.medium.com/max/1600/1*HTkdmVGTk8Wrl1qJPyu9tw.png" alt="" />
</p>

<p>
  <br />
  <br />
</p>

<p>And, finally, here's the completed <em>Bus Derby</em> pen live.</p>

<p><p data-slug-hash="YJwoVy" data-default-tab="result" data-height="600" data-theme-id="0" class="codepen"></p></p>

<p>
  <br />
  <br />
</p>

<p>
  <em>Matthew Main is a UI &amp; Digital Designer in New York. Follow on <a href="https://twitter.com/mtthwwmn">Twitter</a> or <a href="https://github.com/matthewmain">GitHub</a>. <a href="https://medium.com/@matthewmain/how-to-import-a-3d-blender-object-into-a-three-js-project-as-a-gltf-file-5a67290f65f2">Read this tutorial on Medium here</a>.</em>
</p>

    ]]>
  </description>

  <dc:subject>How to Import a 3D Blender Object into a Three.js Project as a glTF File</dc:subject>

  <dc:date>
    2018-12-03T04:10:27-07:00
  </dc:date>

</item>


  </channel>

</rss>
