<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ryan Yu on Medium]]></title>
        <description><![CDATA[Stories by Ryan Yu on Medium]]></description>
        <link>https://medium.com/@iamryanyu?source=rss-e9a5d6ef359f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*fp0LZ97lmltsts7Mv_mlIA.png</url>
            <title>Stories by Ryan Yu on Medium</title>
            <link>https://medium.com/@iamryanyu?source=rss-e9a5d6ef359f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 15 Nov 2026 11:01:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@iamryanyu/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[An Ultimate Collection of CSS Grid Resources]]></title>
            <link>https://medium.com/@iamryanyu/an-ultimate-collection-of-css-grid-a105e88e7153?source=rss-e9a5d6ef359f------2</link>
            <guid isPermaLink="false">https://medium.com/p/a105e88e7153</guid>
            <category><![CDATA[css-grid]]></category>
            <category><![CDATA[css]]></category>
            <dc:creator><![CDATA[Ryan Yu]]></dc:creator>
            <pubDate>Mon, 11 Sep 2017 12:07:37 GMT</pubDate>
            <atom:updated>2018-10-09T00:40:07.970Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cXZURUeagvhSi-qU4fyHTA.jpeg" /></figure><p>CSS Grid is available on the most of the major browsers now and it is time for us to use this powerful native CSS layout system.</p><p>The collection below will give you all the necessary resources, tutorials, articles and examples to get started with CSS Grid.</p><p>All links below are great but if you are running out of time, I would recommend to check out those links with 👍 first.</p><p>The latest resources comes with 🎉.</p><p>I have built <strong><em>Responsive Mondrian Art</em></strong> with CSS grid. Please check it out and gives me loves if you liked it 💛 🙌</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2Fiamryanyu%2Fembed%2Fpreview%2FrJqYOz%3Fheight%3D600%26slug-hash%3DrJqYOz%26default-tabs%3Dcss%2Cresult%26host%3Dhttps%3A%2F%2Fcodepen.io%26embed-version%3D2&amp;url=https%3A%2F%2Fcodepen.io%2Fiamryanyu%2Ffull%2FrJqYOz%2F&amp;image=https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fi.cdpn.io%2F204808.rJqYOz.small.7cedfa2e-b697-478a-bb5b-da708e58a092.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/38dcf5da45f812e4ecb26367294f7ec7/href">https://medium.com/media/38dcf5da45f812e4ecb26367294f7ec7/href</a></iframe><h3>References</h3><ul><li><a href="https://www.w3.org/TR/css-grid-1/">W3C</a></li><li>👍 <a href="https://tympanus.net/codrops/css_reference/grid/">A Complete Guide to CSS Grid — CoDrops</a></li><li>👍 <a href="https://css-tricks.com/snippets/css/complete-guide-grid/">A Complete Guide to Grid — CSS Tricks</a></li><li><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout">CSS Grid Layout — MDN</a></li><li><a href="https://www.smashingmagazine.com/2018/04/best-practices-grid-layout/">Best Practices With CSS Grid Layout</a></li></ul><h3>Can I Use?</h3><ul><li>👍 <a href="http://caniuse.com/#feat=css-grid">CSS Grid Layout</a></li></ul><h3>Tutorials</h3><ul><li>👍 <a href="https://gridbyexample.com/">Grid by Example</a></li><li><a href="http://varun.ca/css-grid/">Learning CSS Grids</a></li><li>👍 🎬 <a href="https://www.youtube.com/watch?v=jV8B24rSN5o">CSS Grid Layout Crash Course</a></li><li><a href="https://getflywheel.com/layout/css-grid-layouts-how-to/">How to create a simple layout with CSS Grid Layouts</a></li><li>👍 <a href="http://jensimmons.com/post/aug-15-2017/heres-super-quick-way-try-out-css-grid">Here’s a Super Quick Way to Try out CSS Grid</a></li><li><a href="https://www.sitepoint.com/building-trello-layout-css-grid-flexbox/">Building a Trello Layout with CSS Grid and Flexbox</a></li><li><a href="https://tympanus.net/codrops/2017/07/19/css-grid-layout-slideshow/">CSS Grid Layout Slideshow</a></li><li>👍 <a href="https://www.smashingmagazine.com/2017/09/css-grid-gotchas-stumbling-blocks/">CSS Grid Gotchas And Stumbling Blocks</a></li><li><a href="https://hacks.mozilla.org/2017/10/an-introduction-to-css-grid-layout-part-1/">An Introduction to CSS Grid Layout: Part 1</a></li><li>👍 <a href="https://cm.engineering/getting-to-know-css-grid-layout-818e43ca71a5">Getting to know CSS Grid Layout</a></li><li>👍 🎬 <a href="https://laracasts.com/series/css-grids-for-everyone">CSS Grids for Everyone</a></li><li><a href="https://medium.freecodecamp.org/how-to-prototype-websites-quickly-with-css-grid-ffc9cba08583">How to prototype websites quickly with CSS Grid</a></li><li><a href="https://medium.freecodecamp.org/learn-css-grid-in-5-minutes-f582e87b1228">Learn CSS Grid in 5 Minutes</a></li><li><a href="https://mozilladevelopers.github.io/playground/css-grid">Introduction to CSS Grid Layout</a></li><li>🎬 <a href="https://www.youtube.com/watch?v=ojKbYz0iKQE">CSS Grid Explained in 7 Minutes (with diagrams and code)</a></li><li>👍🎬 <a href="https://cssgrid.io/">CSS Grid with Wes Bos</a></li><li><a href="http://www.gridtoflex.com/">Grid to Flex</a></li></ul><h3>Articles &amp; Talks &amp; Examples</h3><ul><li>👍 <a href="https://codepen.io/iamryanyu/details/rJqYOz">Responsive Mondrian Art with CSS Grid</a></li><li><a href="https://www.sitepoint.com/introduction-css-grid-layout-module/">An Introduction to the CSS Grid Layout Module</a></li><li><a href="https://alistapart.com/article/practical-grid">Practical CSS Grid: Adding Grid to an Existing Design</a></li><li><a href="https://cloudfour.com/thinks/first-css-grid-layout/">Case Study: My First Practical CSS Grid Layout</a></li><li><a href="https://una.im/css-grid/#%F0%9F%92%81">3 CSS Grid Features That Make My Heart Flutter</a></li><li><a href="https://14islands.com/blog/2017/03/07/playing-with-CSS-grids/">Playing with CSS Grids</a></li><li>🎧 <a href="http://shoptalkshow.com/episodes/262-css-grid-rachel-andrew-jen-simmons/">CSS Grid with Jen Simmons &amp; Rachel Andrew</a></li><li><a href="https://cloudfour.com/thinks/breaking-out-with-css-grid-layout/">Breaking Out With CSS Grid Layout</a></li><li><a href="https://hacks.mozilla.org/2017/04/replace-bootstrap-layouts-with-css-grid/">Replace Bootstrap Layouts with CSS Grid</a></li><li><a href="https://www.smashingmagazine.com/2016/11/css-grids-flexbox-box-alignment-new-layout-standard/">The New Layout Standard For The Web: CSS Grid, Flexbox And Box Alignment</a></li><li><a href="https://css-tricks.com/will-flattening-html-css-grids/">Will we be flattening our HTML for CSS Grids?</a></li><li><a href="https://getflywheel.com/layout/combine-flexbox-and-css-grids-for-layouts-how-to/">How to combine Flexbox and CSS grids for efficient layouts</a></li><li>🎬 <a href="https://aneventapart.com/news/post/css-grid-layout-by-rachel-andrewan-event-apart-video">CSS Grid Layout by Rachel Andrew — An Event Apart video</a></li><li><a href="https://css-tricks.com/browser-compatibility-css-grid-layouts-simple-sass-mixins/">Browser Compatibility for CSS Grid Layouts with Simple Sass Mixins</a></li><li><a href="https://codepen.io/rrenula/full/LzLXYJ/">Comic book style layout with CSS Grid</a></li><li><a href="https://www.heartinternet.uk/blog/fearless-guide-using-css-grid-today/">A fearless guide to using CSS Grid today</a></li><li>👍 <a href="https://slack.engineering/rebuilding-slack-com-b124c405c193">Rebuilding slack.com</a></li><li><a href="https://www.smashingmagazine.com/2017/10/naming-things-css-grid-layout/">Naming Things In CSS Grid Layout</a></li><li><a href="https://alistapart.com/article/the-story-of-css-grid-from-its-creators">The Story of CSS Grid, from Its Creators</a></li><li><a href="https://codepen.io/johnnycopes/pen/yzQyMp">Monopoly board</a></li><li><a href="http://gedd.ski/post/grid-inspector/">How to Build a Grid Inspector</a></li><li>👍 <a href="https://aerolab.co/blog/flexbox-grids">Flexbox and Grids, your layout’s best friends</a></li><li><a href="https://www.smashingmagazine.com/2017/11/css-grid-supporting-browsers-without-grid/">Using CSS Grid: Supporting Browsers Without Grid</a></li><li><a href="https://css-tricks.com/aspect-ratios-grid-items/">Aspect Ratios for Grid Items</a></li><li><a href="https://css-tricks.com/snippets/css/css-grid-starter-layouts/">CSS Grid Starter Layouts</a></li><li>👍 <a href="https://medium.com/samsung-internet-dev/common-responsive-layouts-with-css-grid-and-some-without-245a862f48df">Common Responsive Layouts with CSS Grid (and some without!)</a></li><li>👍 <a href="https://medium.freecodecamp.org/how-to-make-your-html-responsive-by-adding-a-single-line-of-css-2a62de81e431">How to make your HTML responsive by adding a single line of CSS</a></li><li><a href="https://24ways.org/2017/design-systems-and-css-grid">Design Systems and CSS Grid</a></li><li><a href="https://snook.ca/archives/html_and_css/calendar-css-grid">Calendar with CSS Grid</a></li><li>🎬 <a href="https://www.dotconferences.com/2017/11/benjamin-de-cock-css-grid-in-production">CSS Grid in Production</a></li><li><a href="https://medium.freecodecamp.org/how-to-recreate-mediums-article-layout-with-css-grid-b4608792bad1">How to recreate Medium’s article layout with CSS Grid</a></li><li><a href="http://www.creativebloq.com/features/css-grid-layout-secrets-revealed">CSS Grid Layout secrets revealed</a></li><li><a href="https://medium.freecodecamp.org/11-things-i-learned-reading-the-css-grid-specification-fb3983aa5e0">11 Things I Learned Reading the CSS Grid Specification</a></li><li>🎬 <a href="https://www.youtube.com/watch?v=EEOJZy_Gge4">Designing for 4-sided viewports with CSS Grid</a></li><li><a href="https://medium.freecodecamp.org/introducing-css-gridish-helping-teams-to-adapt-css-grid-today-3e031ab222de">Introducing CSS Gridish: An Open Source Tool to Help Your Team Adapt CSS Grid Today</a></li><li><a href="https://bitsofco.de/github-contribution-graph-css-grid">Recreating the GitHub Contribution Graph with CSS Grid Layout</a></li><li>👍 <a href="https://medium.com/deemaze-software/css-grid-layout-crossed-sections-fca9e956e725">CSS Grid layout — crossed sections</a></li><li><a href="https://css-tricks.com/counting-css-counters-css-grid/">Counting With CSS Counters and CSS Grid</a></li><li><a href="https://www.smashingmagazine.com/2018/02/media-queries-responsive-design-2018/">Using Media Queries For Responsive Design In 2018</a></li><li><a href="https://www.chenhuijing.com/blog/how-i-design-with-css-grid/#%F0%9F%8F%80">How I design with CSS grid</a></li><li>🎬 <a href="https://vimeo.com/254679499">SmashingConf London 2018 — RACHEL ANDREW</a></li><li><a href="https://hacks.mozilla.org/2018/02/css-grid-for-ui-layouts/">CSS Grid for UI Layouts</a></li><li>🎬 <a href="https://www.youtube.com/watch?v=YfIjFeBLhyA">Whitespace on The Web! — with CSS Grid</a></li><li>🎬 <a href="https://www.youtube.com/watch?v=OxrsO4aIjyc">CSS Grid like you are Jan Tschichold</a></li><li><a href="https://www.smashingmagazine.com/2018/02/generated-content-grid-layout/">Styling Empty Cells With Generated Content And CSS Grid Layout</a></li><li>🎬 <a href="https://www.youtube.com/watch?v=ahPRvVyw9Eo">Modern Layouts with CSS Grid: Revolutionizing Visual Design on the Web</a></li><li><a href="https://css-tricks.com/auto-sizing-columns-css-grid-auto-fill-vs-auto-fit/">Auto-Sizing Columns in CSS Grid: `auto-fill` vs `auto-fit`</a></li><li><a href="https://julian.is/article/css-grid-at-scale/">How We Adopted CSS Grid at Scale</a></li><li><a href="https://techblog.commercetools.com/gss-grid-application-layout-in-production-f60c65a05cfa">CSS Grid Application Layout in Production</a></li><li><a href="https://blogs.igalia.com/mrego/2018/04/04/getting-rid-of-grid-prefix-on-css-grid-layout-gutter-properties/">Getting rid of “grid-” prefix on CSS Grid Layout gutter properties</a></li><li><a href="https://css-tricks.com/another-collection-of-interesting-facts-about-css-grid/">Another Collection of Interesting Facts About CSS Grid</a></li><li><a href="https://www.silocreativo.com/en/editorial-design-and-css-grid-inspiration-and-examples/">Editorial Design and CSS Grid: Inspiration and examples</a></li><li><a href="https://codepen.io/michellebarker/post/using-pseudo-elements-with-css-grid">Using pseudo-elements with CSS Grid</a></li><li>🎬 <a href="https://www.youtube.com/watch?v=fVX0xscGP9o">How to use CSS grid today in the real world</a></li><li><a href="https://hiddedevries.nl/en/blog/2018-04-21-more-accessible-markup-with-display-contents">More accessible markup with display: contents</a></li><li><a href="https://rachelandrew.co.uk/archives/2018/04/27/grid-level-2-and-subgrid/">Grid Level 2 and Subgrid</a></li><li><a href="https://codepen.io/michellebarker/post/css-grid-more-flexibility-with-minmax">CSS Grid: More flexibility with minmax()</a></li><li><a href="https://medium.com/deemaze-software/css-grid-responsive-layouts-and-components-eee1badd5a2f">CSS Grid — Responsive layouts and components</a></li><li><a href="https://www.smashingmagazine.com/2018/05/future-of-web-design/">New CSS Features That Are Changing Web Design</a></li><li><a href="https://codepen.io/kizu/pen/LmQmee">Using grids to create copies</a></li><li>🎬 <a href="https://www.youtube.com/watch?v=EashgVqboWo">Overlap on the Web, Graphic Design Made Easy with CSS Grid</a></li><li><a href="https://tympanus.net/codrops/2018/05/23/grid-layout-with-motion-hover/">Grid Layout with Motion Hover Effect and Content Preview</a></li><li><a href="https://www.smashingmagazine.com/2018/05/guide-css-layout/">Getting Started With CSS Layout</a></li><li><a href="https://www.sitepoint.com/css-grid-layout-vs-css-frameworks-debate/">The CSS Grid Layout vs CSS Frameworks Debate</a></li><li>🎬 <a href="https://www.youtube.com/watch?v=jfHNzL5h1Aw">CSS Grid Eliminates Margin Collapsing?!?</a></li><li><a href="https://tobireif.com/demos/grid/">3 CSS Grid Layouts</a></li><li><a href="https://bryanlrobinson.com/blog/2018/06/13/how-to-use-css-grid-to-mix-and-match-design-patterns/">How To: Use CSS Grid to Mix and Match Design Patterns</a></li><li><a href="https://mxb.at/blog/layouts-of-tomorrow/">The Layouts of Tomorrow</a></li><li><a href="https://www.smashingmagazine.com/2018/07/css-grid-2/">CSS Grid Level 2: Here Comes Subgrid</a></li><li><a href="https://css-tricks.com/css-grid-in-ie-css-grid-and-the-new-autoprefixer/">CSS Grid in IE: CSS Grid and the New Autoprefixer</a></li><li><a href="https://webdesign.tutsplus.com/tutorials/the-quirks-of-css-grid-and-absolute-positioning--cms-31437">The Quirks of CSS Grid and Absolute Positioning</a></li><li><a href="https://laurakalbag.com/gallery-grid-with-css-grid/">Gallery Grid With CSS Grid</a></li><li><a href="https://medium.freecodecamp.org/how-to-quickly-prototype-apps-with-css-grid-and-css-variables-8d3d96d68eaa">How to quickly prototype apps with CSS Grid and CSS Variables</a></li><li><a href="https://itnext.io/how-to-build-complicated-grids-using-css-grid-609b1197cf75">How to build complicated grids using CSS grid</a></li><li><a href="https://codepen.io/andybarefoot/full/PBPrex/">Isometric eCommerce CSSGrid</a></li><li>🎬 <a href="https://www.youtube.com/watch?v=0Gr1XSyxZy0">9 Biggest Mistakes with CSS Grid</a></li><li>🎬 <a href="https://www.rachelandrew.co.uk/archives/2018/07/17/should-i-try-to-use-the-ie-version-of-grid-layout-revisited-for-2018/">Should I try to use the IE version of Grid Layout? Revisited for 2018</a></li><li><a href="https://css-tricks.com/dont-use-empty-or-low-content-for-your-design-system-grid-examples/">Don’t use empty or low content for your design system grid examples</a></li><li><a href="https://css-tricks.com/preventing-a-grid-blowout/">Preventing a Grid Blowout</a></li><li><a href="https://www.sitepoint.com/creating-css-grid-layouts/">Creating Layouts with CSS Grid</a></li><li>🎉 <a href="https://uxdesign.cc/creating-horizontal-scrolling-containers-the-right-way-css-grid-c256f64fc585">Creating horizontal scrolling containers the right way [CSS Grid]</a></li></ul><h3>Challenges</h3><ul><li>👍 <a href="http://cssgridgarden.com/">Grid Garden</a></li></ul><h3>Tools &amp; Libraries</h3><ul><li><a href="https://alialaa.github.io/css-grid-cheat-sheet/">CSS Grid Cheat Sheet</a></li><li><a href="https://developers.google.com/web/updates/2017/08/devtools-release-notes#css-grid-highlighting">CSS Grid highlighting</a></li><li><a href="http://griddy.io/">Griddy</a></li><li><a href="https://vmcreative.github.io/Hexi-Flexi-Grid/">Hexi-Flexi Grid</a></li><li><a href="http://www.gridexamples.com/">Grid Examples</a></li><li><a href="https://codepen.io/anthonydugois/full/RpYBmy/">CSS Grid Template Builder</a></li><li><a href="http://cssgr.id/">cssgr.id</a></li><li><a href="https://www.layoutit.com/grid">Layoutit!</a></li><li>👍 <a href="http://grid.malven.co/">GRID: A Simple Visual Cheatsheet for CSS Grid Layout</a></li></ul><h3>❤️ Do you know any good links for CSS Grid?</h3><p>If you would like to share any good CSS grid links, please send me the link in the comment below or through my Twitter <a href="https://twitter.com/iamryanyu">@iamryanyu</a>.</p><p>Learn awesome front-end skills and boost your front-end career at <a href="https://frontend30.com/?utm_source=medium&amp;utm_medium=link&amp;utm_campaign=cssgrid">FrontEnd30.com</a> today 👍</p><figure><a href="https://frontend30.com/?utm_source=medium&amp;utm_medium=banner&amp;utm_campaign=cssgrid"><img alt="" src="https://cdn-images-1.medium.com/max/600/1*oD736QJ8LBY0FEsqFUL2wA.jpeg" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a105e88e7153" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Awesome Button Animation with Vivus JS]]></title>
            <link>https://medium.com/@iamryanyu/awesome-button-animation-with-vivus-js-499bd6de5a48?source=rss-e9a5d6ef359f------2</link>
            <guid isPermaLink="false">https://medium.com/p/499bd6de5a48</guid>
            <category><![CDATA[vivusjs]]></category>
            <category><![CDATA[animation]]></category>
            <category><![CDATA[button]]></category>
            <dc:creator><![CDATA[Ryan Yu]]></dc:creator>
            <pubDate>Sun, 15 May 2016 06:49:25 GMT</pubDate>
            <atom:updated>2016-05-15T06:49:25.389Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*A1DvmhAEc924ienDZC9Rjg.gif" /></figure><p>Few weeks ago, I have shared the step by step guid of how to <a href="https://medium.com/@iamryanyu/web-animation-with-gsap-ea375e5cc940#.qkre016kg">animate SVG with GSAP</a>. In this article, I will show you how to animate a button with Vivus JS which helps you draw SVG line.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2Fiamryanyu%2Fembed%2Fpreview%2FXdQxmb%3Fheight%3D600%26amp%3Bslug-hash%3DXdQxmb%26amp%3Bdefault-tabs%3Dcss%2Cresult%26amp%3Bhost%3Dhttp%253A%252F%252Fcodepen.io%26amp%3Bembed-version%3D2&amp;url=https%3A%2F%2Fcodepen.io%2Fiamryanyu%2Fpen%2FXdQxmb%2F&amp;image=https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fi.cdpn.io%2F204808.XdQxmb.small.8f00da7b-d0e8-4df9-8aba-6c1c120e1f00.png&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/5799a545d08120aa8ff75cd282a6c389/href">https://medium.com/media/5799a545d08120aa8ff75cd282a6c389/href</a></iframe><p>Before reading further, if you are interested in finding out which one to use between CSS and JS for animation, check out my previous article, <a href="http://codepen.io/iamryanyu/pen/XdQxmb/">Face Off: CSS vs JS Animation</a>.</p><h3>Preparation</h3><p>The details of animation are:</p><ul><li>By default, the button will have no background color, but the gray thick border (10px).</li><li>On hover, the background color will appear from the center to outer diagonally. The background animation will not fully cover the whole button but will stop to give a bit of space at the top right and bottom left corner.</li><li>Also on hover, two lines will start to draw. First one starts from the top left and ends at the bottom right. Second one starts from the bottom right and ends at the top left.</li></ul><p>For this animation, we will use with:</p><ul><li>jQuery</li><li>Vivus JS</li><li>OOCSS (to dynamically change the color of the button)</li></ul><h3>Step 1: Initial Button Layout</h3><p>By default, we will show a button with no background color and gray border.</p><h4>HTML</h4><pre>&lt;a href=”#” class=”btn btn-stroke-draw”&gt;<br>  &lt;span class=”btn__txt”&gt;This is&lt;br/&gt;black button&lt;/span&gt;<br>&lt;/a&gt;</pre><h4>SASS</h4><pre>.btn {<br>  background-color: transparent;<br>  border: 0;<br>  display: inline-block;<br>  text-decoration: none;<br>}</pre><pre>.btn-stroke-draw {<br>  height: 113px;<br>  overflow: hidden;<br>  position: relative;<br>  width: 341px;</pre><pre>  &amp;::before {<br>    border: 10px solid $btn-gray-stroke;<br>    content: &#39;&#39;;<br>    height: calc(100% — 20px);<br>    left: 0;<br>    opacity: 1;<br>    position: absolute;<br>    transition: opacity $transition;<br>    width: calc(100% — 20px);<br>  }<br>}</pre><pre>.btn__txt {<br>  text-align: center;<br>  z-index: 1;</pre><pre>  .btn-stroke-draw &amp; {<br>    // Flex container<br>    display: flex;<br>    flex-direction: row;<br>    flex-wrap: nowrap;<br>    justify-content: center;<br>    align-content: center;<br>    align-items: center;<br>    height: 100%;<br>    position: absolute;<br>    text-transform: uppercase;<br>    width: 100%;<br>  }<br>}</pre><p>.btn will reset the button style and .btn-stroke-draw will contain all the initial button styles including the border.</p><h3>Step 2: On Hover, Filling the Background Color</h3><p>For the FS (functional Specifications) #2 above, when you hover on the button, we will fill the background color diagonally. In order to do this, we need to decide the color theme of the button; we will apply the black color for this example.</p><p>For the black color, we will add .btn-black OOCSS in the button element and add black hover styles in SASS.</p><h4>HTML</h4><pre>&lt;a href=”#” class=”btn btn-stroke-draw btn-black”&gt;<br>  &lt;span class=”btn__txt”&gt;This is&lt;br/&gt;black button&lt;/span&gt;<br>&lt;/a&gt;</pre><h4>SASS</h4><pre>.btn-stroke-draw {<br>  &amp;:hover::before {<br>    opacity: 0;<br>  }</pre><pre>  &amp;::after {<br>    content: &#39;&#39;;<br>    height: 0;<br>    left: 50%;<br>    opacity: 0;<br>    position: absolute;<br>    top: 50%;<br>    transform: translateX(-50%) translateY(-50%) rotate(45deg);<br>    transition: all $transition;<br>    width: 100%;<br>  }</pre><pre>  // Overlay color on hover<br>  &amp;.btn-black::after {<br>    background-color: $btn-black-bg;<br>  }</pre><pre>  &amp;:hover::after {<br>    height: 230%;<br>    opacity: 1;<br>  }<br>}</pre><pre>.btn__txt {<br>  // Font Color<br>  .btn-black &amp; {<br>    color: $btn-black-font;<br>    transition: color $transition;<br>  }</pre><pre>  .btn-black:hover &amp; {<br>    color: $btn-black-font-hover;<br>  }<br>}</pre><p>This diagonally filling effect can be found in Codrop, <a href="http://tympanus.net/Development/CreativeButtons/">Creative Button Styles</a>. Basically the effect is happening in ::after pseudo element. By default, you set the ::after with height: 0 and rotate to 45 degree. When you hover on the button, the height will be increased to 230% with transition.</p><h3>Step 3: Draw the Border on Hover</h3><p>For the FS #3 above, we need one more animation, on hover, drawing the border line. To do this, we will use a plugin called <a href="https://maxwellito.github.io/vivus/">Vivus JS</a>. This is a library providing a lot of options for you to draw line on SVG path.</p><p>What we will be doing is we will add a sqare shaped SVG with two paths on top of the ::after pseudo. And then we will add new attribute (data-btnstroke-index) in the button element to assign the index so that we know which button the line should be drawn on.</p><h4>HTML</h4><pre>&lt;a href=”#” class=”btn btn-stroke-draw btn-black” data-btnstroke-index=&quot;0&quot;&gt;<br>  &lt;span class=”btn__txt”&gt;This is&lt;br/&gt;black button&lt;/span&gt;<br>  &lt;svg xmlns=”<a href="http://www.w3.org/2000/svg">http://www.w3.org/2000/svg</a>&quot; version=”1.1&quot; viewbox=”0 0 341 113&quot;&gt;<br>    &lt;path fill=”none” d=”M0 0 H341 V113&quot; stroke-width=”20&quot;&gt;&lt;/path&gt;<br>    &lt;path fill=”none” d=”M341 113 H0 V0&quot; stroke-width=”20&quot;&gt;&lt;/path<br>  &lt;/svg&gt;<br>&lt;/a&gt;</pre><h4>SASS</h4><pre>.btn-stroke-draw {<br>  // Children<br>  svg {<br>    position: absolute;<br>    top: 0;<br>    left: 0;<br>  }</pre><pre>  // Stroke Color<br>  &amp;.btn-black path {<br>    stroke: $btn-black-stroke;<br>  }</pre><pre>  &amp;.btn-red path {<br>    stroke: $btn-red-stroke;<br>  }</pre><pre>  &amp;.btn-blue path {<br>    stroke: $btn-blue-stroke;<br>  }<br>}</pre><h4>JS</h4><pre>jQuery(document).ready(function($) {<br>  var i, vivusEle, vivusItems;<br>  vivusItems = [];<br>  vivusEle = $(‘.btn-stroke-draw svg’);</pre><pre>  i = 0;<br>  while (i &lt; vivusEle.length) {<br>    vivusItems.push(new Vivus(vivusEle[i], {<br>      duration: 30,<br>      type: &#39;async&#39;,<br>      start: &#39;manual&#39;,<br>      animTimingFunction: Vivus.EASE_OUT}));</pre><pre>    i++;<br>  }</pre><pre>  $(‘.btn-stroke-draw’).hover((function() {<br>    var $this, thisBtnIndex;<br>    $this = $(this);<br>    thisBtnIndex = $this.attr(‘data-btnstroke-index’);<br>    vivusItems[thisBtnIndex].stop().play();<br>  }), function() {<br>    var $this, thisBtnIndex;<br>    $this = $(this);<br>    thisBtnIndex = $this.attr(‘data-btnstroke-index’);<br>    vivusItems[thisBtnIndex].stop().play(-1);<br>  });<br>});</pre><p>That’s it. It’s really simple but can produce an awesome effect. If you want to add new color theme, add new OOCSS (e.g., btn-red) and add styles accordingly.</p><p>For the complete code, please check the <a href="http://codepen.io/iamryanyu/pen/XdQxmb/">CodePen page here</a> and if you have any questions, feel free to let me know.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=499bd6de5a48" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tools and Plugins Enhancing Front-end Development]]></title>
            <link>https://medium.com/@iamryanyu/tools-and-plugins-enhancing-front-end-development-a790de0fbc78?source=rss-e9a5d6ef359f------2</link>
            <guid isPermaLink="false">https://medium.com/p/a790de0fbc78</guid>
            <category><![CDATA[web-tools]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[jquery-plugin]]></category>
            <dc:creator><![CDATA[Ryan Yu]]></dc:creator>
            <pubDate>Sun, 08 May 2016 03:51:07 GMT</pubDate>
            <atom:updated>2016-05-08T03:54:35.432Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/440/1*oKzyMUrlSP8AuufJLm_WnQ.jpeg" /><figcaption>Credit to <a href="https://dribbble.com/shots/1460938-Power-Tools">Charlie Waite</a></figcaption></figure><p>Last week, I talked about <a href="https://medium.com/@iamryanyu/front-end-checklist-for-component-development-3d03df064886#.k8y9km6h9">Front-end Checklist for Component Development</a> to help you build solid components. Today, I would like to share some plugins I usually use when I do the front-end development of websites or components.</p><p>Those lists help not only enhance your front-end development workflow, but also improve the quality of your work. Those include:</p><ul><li>Gulp</li><li>Git</li><li>SVG Sprite</li><li>Fastclick</li><li>Hammer JS</li><li>jQuery Validation</li><li>jQuery Waypoint</li><li>GSAP/Velocity JS</li><li>GTM &amp; GA</li></ul><h3>Gulp</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*zkBF6CAxW7w0FwO4HDO5pg.png" /></figure><p><a href="http://gulpjs.com/">Gulp</a> helps you automate front-end tasks for you. If you know <a href="http://gruntjs.com/">Grunt</a>, it’s pretty much the same.</p><p>At <a href="https://www.squiz.net/">Squiz</a>, we have our own Boilerplate with Gulp and it does many jobs for front-end developers. Some of them are:</p><ul><li>Compile SASS to CSS</li><li>Prettify and minify JS and CSS code</li><li>Complie different plugins in one file called plugins.min.js</li><li>Running a web server with gulp serve</li><li>Syncing browsers with <a href="https://www.browsersync.io/">BrowserSync</a></li><li>and many more</li></ul><p>There are a lot of debats which task manager is better, for example Grunt vs Gulp. From my experience, Gulp provides simpler and cleaner configuration logic. If you want to find out more about the comparison, check out <a href="https://medium.com/@preslavrachev/gulp-vs-grunt-why-one-why-the-other-f5d3b398edc4#.rwhbvv29a">this article</a>. Though it’s really up to you which task runner to use.</p><h3>Git</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*YmZM_rA_l_KHTm1Lz6TTDA.png" /></figure><p>The biggest issue, while developing websites or components within a team, is collabration. Let’s say there are several developers are working on the same component, but it’s really hard to compare and merge each other’s work in one final place.</p><p>In the past, there were many methods introduced such as SVN, but the problem with SVN, for example, is the code base is centralised. That means if you cannot reach the main server (for example, no internet), basically you cannot commit.</p><p>However, Git is decentralised and you can keep committing on your local machine.</p><p>These days Git is very common way to collaborate your work with other team members and I believe most of the companies using it.</p><p>Some of the popular Git hosting companies are:</p><ul><li><a href="https://github.com/">GitHub</a></li><li><a href="https://bitbucket.org/">Bitbucket</a></li><li><a href="https://about.gitlab.com/">GitLab</a></li></ul><h3>SVG Sprite</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/243/1*nxKm1FmFWNA9zCcHpkCGBQ.png" /></figure><p>This SVG Sprite workflow has been introduced in my previous article. It helps you create SVG sprite without working on Illustrator and make the workflow much simpler and faster.</p><p>I have been using this workflow for several projects now and it has been working really well so far.</p><p>Check out <a href="https://medium.com/@iamryanyu/svg-sprite-workflow-that-works-f5609d4d6144#.d6ct4rwm9">this article</a> to find out the detailed guide of how it works.</p><h3>Fastclick</h3><p>If you worked on the responsive websites on mobile devices, you may have found that there is 300ms delay between a physical tab and the firing of a click event.</p><p>The delay exists because the mobile browser needs to identify if you intend to do a single tap or double tap. But because of the delay, the interaction on the single tap looks laggy.</p><p>To eliminate this, <a href="https://github.com/ftlabs/fastclick">Fastclick</a> has been developed. For more details, please check their GitHub page.</p><p>Please note though, as of Chrome 32 for Android, the delay will be gone with any sites uses:</p><pre>&lt;meta name=”viewport” content=”width=device-width”&gt;</pre><p>To find out more details about this, please check this article, <a href="https://developers.google.com/web/updates/2013/12/300ms-tap-delay-gone-away?hl=en">300ms tap delay, gone away</a>.</p><h3>Hammer JS</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/529/1*s0LaDb2UKbnt0rgx6HlM8Q.jpeg" /></figure><p>If you want to remove the 300ms delay but also provide richer mobile experience, I highly recommend <a href="http://hammerjs.github.io/">Hammer JS</a>.</p><p>With Hammer JS, you can provide many recognisers such as:</p><ul><li>Pan</li><li>Pinch</li><li>Press</li><li>Rotate</li><li>Swipe</li><li>Tap</li></ul><p>Moreover, each recogniser provides many flexible options. For example, you can set the number of taps and interval for <a href="http://hammerjs.github.io/recognizer-tap/">Tap</a>.</p><p>If you want to use Hammer JS with jQuery, you need to extend it with a <a href="http://hammerjs.github.io/jquery-plugin/">plugin</a>.</p><p>Alternatively, you may also want to check out <a href="https://jquerymobile.com/">jQuery Mobile</a>, though from my experience, it’s a bit heavier than Hammer JS.</p><h3>jQuery Validation</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*6eoQzUaNRj6EO_WbuXHq6w.png" /><figcaption>Credit to <a href="https://dribbble.com/shots/198390-Form-Field-Validation">Fernando Maclen</a></figcaption></figure><p>Every websites contain at least one form. In my opinion, the form is the most important component due to most of the time, it’s directly related to the business objectives. Therefore when you develop a form, there are many things you need to consider and one of them is to properly validate the form before it’s been submitted.</p><p>There are many form validation plugins available, but I found that <a href="https://jqueryvalidation.org/">jQuery Validation</a> provides a quite solid form handling solutions.</p><p>It’s very flexible so you can apply the validation check on many different scenarios such as postcode or telephone number format.</p><p>However, one caveat is that its documentation is quite hard to read and difficult to find. Though once you get used to it, you won’t have much trouble using this plugin.</p><h3>jQuery Waypoint</h3><p>These days a lot of websites provide an interactive experience when you scroll down the page. For example, as you can see from <a href="http://www.involvedigital.com/">this website</a>, the content below the fold appears smoothly when you scroll down the page.</p><p>You can surely write vanilla JS code to detect when a section reached to a certain point in the page, however there is a really nice jQuery plugin called <a href="http://imakewebthings.com/waypoints/">jQuery Waypoint</a>, which can help you save a lot of time and provides many options.</p><p>Here are some awesome examples with Waypoint:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2Fhartless%2Fembed%2Fpreview%2FNGBMBB%3Fheight%3D600%26amp%3Bslug-hash%3DNGBMBB%26amp%3Bdefault-tabs%3Dhtml%2Cresult%26amp%3Bhost%3Dhttp%253A%252F%252Fcodepen.io%26amp%3Bembed-version%3D2&amp;url=https%3A%2F%2Fcodepen.io%2Fhartless%2Fpen%2FNGBMBB&amp;image=https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fi.cdpn.io%2F66006.NGBMBB.small.97c427ed-2e61-4c9f-99b4-e573556a99ce.png&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/08d9bd2401827f8feb8f23253f842737/href">https://medium.com/media/08d9bd2401827f8feb8f23253f842737/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2Fdagman%2Fembed%2Fpreview%2FWwKrgX%3Fheight%3D600%26amp%3Bslug-hash%3DWwKrgX%26amp%3Bdefault-tabs%3Dhtml%2Cresult%26amp%3Bhost%3Dhttp%253A%252F%252Fcodepen.io%26amp%3Bembed-version%3D2&amp;url=https%3A%2F%2Fcodepen.io%2Fdagman%2Fpen%2FWwKrgX&amp;image=https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fi.cdpn.io%2F281455.WwKrgX.small.56df1f06-0c25-4ee0-b1bb-c753efd94b2d.png&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/36872dfeff75139c5572368466a91d18/href">https://medium.com/media/36872dfeff75139c5572368466a91d18/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2Fmandymichael%2Fembed%2Fpreview%2FpyggQd%3Fheight%3D600%26amp%3Bslug-hash%3DpyggQd%26amp%3Bdefault-tabs%3Dhtml%2Cresult%26amp%3Bhost%3Dhttp%253A%252F%252Fcodepen.io%26amp%3Bembed-version%3D2&amp;url=https%3A%2F%2Fcodepen.io%2Fmandymichael%2Fpen%2FpyggQd&amp;image=https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fi.cdpn.io%2F209981.pyggQd.small.cf014dfd-d31d-4d73-bc65-86742f198715.png&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/ad5f8338e5a7c7a6ef5c9d2d0f7aa7fc/href">https://medium.com/media/ad5f8338e5a7c7a6ef5c9d2d0f7aa7fc/href</a></iframe><h3>GSAP/Velocity JS</h3><p>Most of the websites nowadays are built on animation and many animation libraries are available out there.</p><p>When you add animation to your website and components, there are several things you need to consider. To find out more about it, please check out my previous article, <a href="https://medium.com/@iamryanyu/face-off-css-vs-js-animation-c3165ab993df#.qb2je4ruq">Face Off: CSS vs JS Animation</a>.</p><p>My two favourite libraries are</p><ul><li><a href="http://greensock.com/gsap">GSAP</a></li><li><a href="http://julian.com/research/velocity/">Velocity JS</a></li></ul><p>You can see how those two libraries are used from my previous articles too:</p><ul><li><a href="https://medium.com/@iamryanyu/web-animation-with-gsap-ea375e5cc940#.yklvk0wnl">SVG Web Animation with GSAP</a></li><li><a href="https://medium.com/@iamryanyu/front-end-checklist-for-component-development-3d03df064886#.a6r42wfhb">Front-end Checklist for Component Development</a></li></ul><p>Here are two awesome example of animation built on GSAP/Velocity JS.</p><h4>GSAP</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2Fgordonnl%2Fembed%2Fpreview%2Fbyouf%3Fheight%3D600%26amp%3Bslug-hash%3Dbyouf%26amp%3Bdefault-tabs%3Djs%2Cresult%26amp%3Bhost%3Dhttp%253A%252F%252Fcodepen.io%26amp%3Bembed-version%3D2&amp;url=https%3A%2F%2Fcodepen.io%2Fgordonnl%2Ffull%2Fbyouf%2F&amp;image=https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fi.cdpn.io%2F180942.byouf.small.1dc537d9-0708-46c9-bce5-445ba6a5236a.png&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/35c5b3b77b5ad3e2862ffe68d4b9adf0/href">https://medium.com/media/35c5b3b77b5ad3e2862ffe68d4b9adf0/href</a></iframe><h4>Velocity JS</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2Fsol0mka%2Fembed%2Fpreview%2FkzyjJ%3Fheight%3D600%26amp%3Bslug-hash%3DkzyjJ%26amp%3Bdefault-tabs%3Djs%2Cresult%26amp%3Bhost%3Dhttp%253A%252F%252Fcodepen.io%26amp%3Bembed-version%3D2&amp;url=https%3A%2F%2Fcodepen.io%2Fsol0mka%2Fpen%2FkzyjJ&amp;image=https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fi.cdpn.io%2F6859.kzyjJ.small.8ddb6e3b-410a-4550-97f2-80edba022250.png&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/21954d33fed7021bb2731e72c5f58033/href">https://medium.com/media/21954d33fed7021bb2731e72c5f58033/href</a></iframe><h3>GTM &amp; GA</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/338/1*GoE8MwXS-s5kth4fE6AQVw.jpeg" /></figure><p>I am a big fan of analysing data of how users are interacting with my websites or components. In doing so, I can identify which parts need to be improved to provide better user experience.</p><p>There are many tools avaialble to collect data but my favourite tools are <a href="https://www.google.com.au/analytics/tag-manag%E2%80%A6">GTM</a> (Google Tag Manager) with <a href="https://www.google.com.au/analytics/#?modal_activ%E2%80%A6">GA</a> (Google Analytics). Both are available for free and provide huge amount of data.</p><p>I found that a lot of clients/developers just wanted to change some parts of the websites/componets with no reason (e.g., just to make it looking better), but I am strongly against it. I believe changing the websites will directly impact on the user behaviour on the page so there sholud be strong reasons of why and how it should be changed with solid data.</p><p>Some of the common data to collect are:</p><ul><li>How many people clicked on the button in the hero banner</li><li>How many people interacted with the slider</li><li>How many people dropped out on the process of checkout</li><li>How many people scrolled down the page and how far they reached</li><li>and many more</li></ul><h3>Summary</h3><p>Those listed above are just starting point when I develop websites/components. If you know any other awesome tools or plugins, please feel free share with me.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a790de0fbc78" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Front-end Checklist for Component Development]]></title>
            <link>https://medium.com/@iamryanyu/front-end-checklist-for-component-development-3d03df064886?source=rss-e9a5d6ef359f------2</link>
            <guid isPermaLink="false">https://medium.com/p/3d03df064886</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[web-components]]></category>
            <category><![CDATA[front-end-development]]></category>
            <dc:creator><![CDATA[Ryan Yu]]></dc:creator>
            <pubDate>Sat, 30 Apr 2016 00:56:27 GMT</pubDate>
            <atom:updated>2016-04-30T00:56:27.207Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*FzT8545FI8BMNmpVNqLK0w.png" /><figcaption>Credit to <a href="https://dribbble.com/shots/1460605-Generator-for-Startup-Framework-is-Here">Vladimir Kudinov</a></figcaption></figure><p>I have been developing websites for many many years and every single time when I develop components for webpages, I go through my own checklist to prevent to having the components broken/fragile. So far, it has worked pretty well.</p><p>In this article, I would like to share the checklist I use when I develop components. Throughout the article, I will use an accordion as an example.</p><p>The list of the checklist is in order as below:</p><ol><li><strong>Understanding Component</strong></li><li><strong>JS-enabled</strong></li><li><strong>Accessibility</strong></li><li><strong>Responsiveness</strong></li><li><strong>Touch enabled</strong></li><li><strong>Animation</strong></li><li><strong>Browser/Device Compatibility</strong></li><li><strong>Print.css</strong></li><li><strong>QA</strong></li></ol><p>If you have any other suggestions/feedback, please share with me.</p><h3>1. Understanding Component</h3><p>Before I write any code, I always spend some time to understand how the component should work. For example, let’s say we are going to build an accordion looking like:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2Fiamryanyu%2Fembed%2Fpreview%2FqZMLZK%3Fheight%3D600%26amp%3Bslug-hash%3DqZMLZK%26amp%3Bdefault-tabs%3Djs%2Cresult%26amp%3Bhost%3Dhttp%253A%252F%252Fcodepen.io%26amp%3Bembed-version%3D2&amp;url=https%3A%2F%2Fcodepen.io%2Fiamryanyu%2Fpen%2FqZMLZK&amp;image=https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fi.cdpn.io%2F204808.qZMLZK.small.59d77807-1284-4956-b81f-62ae10c62eb6.png&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/6f0d875587dd6b9c16c88e16723dd927/href">https://medium.com/media/6f0d875587dd6b9c16c88e16723dd927/href</a></iframe><p>The FS (functional specifications) for the accordion will be:</p><ol><li>Initially, all of the content boxes are collapsed.</li><li>When clicking upon the header, its child content box will be expanded.</li><li>When it’s expanded, the arrow will rotate 180 degree.</li><li>The content box will be kept expanding even if other content boxes are expanded.</li></ol><h3>2. JS-enabled</h3><p>After I understand how the component should behave, the very first thing I always do is thinking about the scenario when JS is disabled.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*UkeD9YgqyF6s--wUH5-mew.png" /><figcaption>Credit to <a href="https://dribbble.com/shots/755717-Switch">Delacro</a></figcaption></figure><p>Let’s say when we hide all of the content boxes with CSS (display: none;) to satisfy the FS #1 above, users on JS-disabled browsers will never be able to see the content in the content boxes.</p><p>All content boxes of the accordion should be expanded by default and when JS is loaded and detected, you can hide the content boxes with JS.</p><p>One way I usually do is:</p><ol><li>By default, no-js class will be added in the HTML body tag.</li><li>In JS file, I add below code to change the no-js class to js-enabled.</li></ol><pre>$(&#39;body&#39;).removeClass(&#39;no-js&#39;).addClass(&#39;js-enabled&#39;);</pre><p>When the js-enabled class is detected, the content boxes can be hidden.</p><pre>$(&#39;.accordion__content&#39;).hide();</pre><h3>3. Accessibility</h3><p>Secondly, I think about the accessibility. The accessibility should be considered at the early stage of the component development. By doing so, you can much better understand how the component should be built.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*QDaVOtk80X7_06B-fHMr9g.png" /><figcaption>Credit to <a href="http://blogs.adobe.com/dreamweaver/2015/09/making-your-website-design-accessible.html">Adobe</a></figcaption></figure><p>The accordion as an example should contain several ARIA tags to indicate the screen readers what is happening when interacting with the accordion.</p><h4>.accordion__btn — The heading</h4><p>By default, it should contain <strong>aria-expanded=”true”</strong>,<strong> aria-controls=”id of its child content box”</strong> and <strong>title=”heading description”</strong>.</p><pre>&lt;button aria-expanded=”true” aria-controls=”accordion-1&quot; title=”Heading 1&quot;&gt;</pre><p>When JS is loaded, the <strong>aria-expanded</strong> needs to be updated to <strong>false</strong> by JS as we are going to collapse all of the content boxes.</p><pre>&lt;button aria-expanded=”false” aria-controls=”accordion-1&quot; title=”Heading 1&quot;&gt;</pre><h4>.accordion__content — The Content Box</h4><p>By default, <strong>aria-hidden</strong> needs to be <strong>false</strong>. It should also contain <strong>id</strong>.</p><pre>&lt;div id=”accordion-1&quot; aria-hidden=”false”&gt;</pre><p>When JS is loaded, the <strong>aria-hidden</strong> needs to be updated to <strong>true</strong> by JS.</p><pre>&lt;div id=”accordion-1&quot; aria-hidden=”true”&gt;</pre><p><a href="https://twitter.com/heydonworks">heydoneworks</a> shares some great ARIA examples and you can specifically find the example for the accordion <a href="http://heydonworks.com/practical_aria_examples/#progressive-collapsibles">here</a>.</p><p>My company, Squiz, also has developed a great tool to check if your web pages are met with the coding standard and passed the WCAG. It is called <a href="http://squizlabs.github.io/HTML_CodeSniffer/">HTML_CodeSniffer</a>. You should check out and start to use it.</p><h3>4. Responsiveness</h3><p>Once you have better ideas of the accessibility, my next consideration is how the component should work on different breakpoints.</p><p>In Web Directions few weeks ago, <a href="https://twitter.com/beep">Ethan Marcotte</a> and <a href="http://Karen McGrane twitter">Karen McGrane</a> empathised that we need to focus on the content level instead of the page level for the breakpoints.</p><p>I totally agree and have always been focusing on the individual component level when dealing with the breakpoints.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*U7CMfWiAek0iUQZzCIKMyQ.gif" /><figcaption>Credit to <a href="https://dribbble.com/shots/1344651--GIF-Google-Santa-Tracker">UENO</a></figcaption></figure><p>The component should work well independently with any breakpoints and you should not limit the breakpoints only to few page levels, for example, mq-mobile or mq-tablet. What I usually do is to set several breakpoints (e.g., mq-700, mq-900, mq-1200 etc) for each component to make it look great on any container sizes.</p><p>For our accordion example, there is not much required for the responsiveness. Though one thing we can consider is to change the accordion to tabs on bigger container sizes but that’s out of scope in this article.</p><h3>5. Touch enabled</h3><p>Now we have a quite solid idea of how we are going to build the component. Before starting to write any code, we need to know if we should consider the behaviour of the component on touch enabled devices.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*aA7h4IzDUyrmuDHu-wFOQw.gif" /><figcaption>Credit to <a href="https://dribbble.com/shots/1173787-Precomposed-Touch-Gestures">Aaron Wade</a></figcaption></figure><p>Our accordion example won’t need any touch behaviour but most of the time I install <a href="http://hammerjs.github.io/">Hammer JS</a> and use <strong>tap</strong> instead of <strong>click</strong> which prevents some issues on iOS such as the double click event.</p><p>Also it gives you a lot of touch gestures such as pan, pinch, press, rotate and swipe so you can provide richer user experience on touch enabled devices.</p><p>If you are going to use Hammer JS with jQuery, check out <a href="https://github.com/hammerjs/jquery.hammer.js">this plugin</a>.</p><h3>6. Animation</h3><p>Before we code, there is one more thing you need to consider, animation. Adding animation properly to components can improve the usability and make static pages more lively.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*mKo3UjqeOjpcnKKI6iN7ug.gif" /><figcaption>Credit to <a href="https://dribbble.com/shots/2493845-ToFind-Transition-Test">Leo Leung</a></figcaption></figure><p>There are few things you need to consider though when you do animation.</p><ol><li>Always remember, simple is the best. Don’t try to add too many animations; it will rather distract people and significantly decrease the usability.</li><li>The animation should be meaningful. Having animation should indicate something has happend on user’s interaction.</li><li>Use proper technology. Read my previous article, <a href="https://medium.com/@iamryanyu/face-off-css-vs-js-animation-c3165ab993df#.mehemxepr">Face Off: CSS vs JS Animation</a> for more details.</li></ol><p>For our accordion, we need to satisfy #3 FS above so we will rotate the chevron arrow with the spring effect. In my CodePen, I used <a href="http://julian.com/research/velocity/">Velocity JS</a> for the animation.</p><h3>7. Browser/Device Compatibility</h3><p>Now it’s time to write code. Personally I use Jade, SASS and CoffeeScript with jQuery for my personal projects.</p><p>When coding, it is important to always consider the compatibility of different browsers/devices. Especially if you need to support old browsers like IE9, many latest CSS technologies won’t work (e.g., flexbox, calc, transform, transition etc).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*5ES_p0t8P3GN_ZxLk1nq4A.jpeg" /><figcaption>Credit to <a href="https://dribbble.com/shots/2480190-Responsive-Icons">Wassim</a></figcaption></figure><p>One of the examples for our accordion is, on IE9, you cannot rotate the &lt;svg&gt; of chevron icon in the <a href="https://medium.com/@iamryanyu/svg-sprite-workflow-that-works-f5609d4d6144#.3q6auqixc">SVG Sprite</a>. To rotate it, you need to wrap &lt;svg&gt; with &lt;span&gt; and rotate &lt;span&gt; instead of &lt;svg&gt;.</p><p>Consider those compatibility issues and also revisit those mentioned above while coding.</p><h3>8. Print.css</h3><p>We finally built our component. Before we send our awesome component to QA, we need to provide the print.css. The print styling is another long topic but you can check out <a href="https://www.smashingmagazine.com/2011/11/how-to-set-up-a-print-style-sheet/">this article</a> which gives you a good starting point.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*1AiabKbWD_i93C974uQ7ig.jpeg" /><figcaption>Credit to <a href="https://dribbble.com/shots/1264251-Color-Print">Alex Volkov</a></figcaption></figure><p>For our accordion, we need to get rid of the background color and make the font color to black. Also re-draw the borders to divide each box. Finally we will get rid of the icons.</p><h3>9. QA</h3><p>It is always a good idea to ask someone to test components you developed. With fresh eyes, there are always some issues picked up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*Im4JWu7eURuHanvydDgQKw.gif" /></figure><p>So you shall not pass QA?</p><p>If you followed the list above, I am very confident that you should be able to build very solid components and enjoy your work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*Qiu_GZhqLl-U1YFbghTN2A.gif" /></figure><h3>In Summary</h3><p>The lists above are from my own experience and have been worked very well so far. But if you have any other suggestions/comments/questions, I am more than happy to discuss so please leave your thoughts :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d03df064886" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SVG Web Animation with GSAP]]></title>
            <link>https://medium.com/@iamryanyu/web-animation-with-gsap-ea375e5cc940?source=rss-e9a5d6ef359f------2</link>
            <guid isPermaLink="false">https://medium.com/p/ea375e5cc940</guid>
            <category><![CDATA[svg]]></category>
            <category><![CDATA[gsap]]></category>
            <category><![CDATA[animation]]></category>
            <dc:creator><![CDATA[Ryan Yu]]></dc:creator>
            <pubDate>Sun, 24 Apr 2016 10:58:11 GMT</pubDate>
            <atom:updated>2016-04-24T10:58:54.125Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/415/1*Dbhh-b5B7SY5rloup0GxkQ.gif" /></figure><p>At the moment, I am working on new project which requires animating icons. In this article, I will show you how I did the animating on one of the icons with <a href="http://greensock.com/gsap">GSAP</a> (Green Sock Animation Platform).</p><p>The end results would look like below. When you hover over the graph, it will be animated.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2Fiamryanyu%2Fembed%2Fpreview%2FWwKmmQ%3Fheight%3D600%26amp%3Bslug-hash%3DWwKmmQ%26amp%3Bdefault-tabs%3Dhtml%2Cresult%26amp%3Bhost%3Dhttp%253A%252F%252Fcodepen.io%26amp%3Bembed-version%3D2&amp;url=https%3A%2F%2Fcodepen.io%2Fiamryanyu%2Fpen%2FWwKmmQ&amp;image=https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fi.cdpn.io%2F204808.WwKmmQ.small.93b3da2e-890a-43e5-bd62-4f072b7b08e2.png&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/7cc65b93d681d7d096f2d1abf4997140/href">https://medium.com/media/7cc65b93d681d7d096f2d1abf4997140/href</a></iframe><p>When I do some web animation, I usually go with 3 different methods:</p><ul><li>CSS</li><li>Velocity JS</li><li>GSAP</li></ul><p><a href="https://medium.com/@iamryanyu/face-off-css-vs-js-animation-c3165ab993df#.z8rng01cs">Here are in-depth details</a> of when to use CSS animation over JS animation, but in general,</p><ul><li>if it’s something very simple, I go with <strong>CSS.</strong></li><li>if it’s a bit more complex, I go with <strong>Velocity JS.</strong></li><li>if it’s something more complex, I go with <strong>GSAP.</strong></li></ul><h4>What We Need?</h4><p>First of all, we need to prepare few things as listed below:</p><ul><li>SVG code: as we need to animate &lt;path&gt; inside SVG, we need to embed the SVG code in HTML.</li><li>jQuery: as jQuery is a common library, we will use jQuery in this example.</li><li>GSAP: we will animate the icon with GSAP.</li></ul><h4>SVG code</h4><p>The graphic was prepared in Illustrator by our designer at <a href="http://squiz.net/">Squiz</a> and the SVG code was optimised from <a href="https://jakearchibald.github.io/svgomg/">SVGOMG</a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a67d44aab7746fd56a93ebab53e10116/href">https://medium.com/media/a67d44aab7746fd56a93ebab53e10116/href</a></iframe><p>Please note that the classes have been added in each &lt;path&gt; so we can target the specific &lt;path&gt; element with GSAP.</p><h4>jQuery</h4><p>In Codepen, I have added the jQuery (version 2.2.2).</p><h4>GSAP</h4><p>There are two ways you can animate with GSAP:</p><ul><li><a href="https://greensock.com/tweenlite">GSAP TweenLite</a>: you can selectively add features. The biggest advantege over TweenMax is the minimal file size.</li><li><a href="https://greensock.com/tweenmax">GSAP TweenMax</a>: TweenMax includes all the features of TweenLite and also extends TweenLite with more features.</li></ul><p>In this example, we will go with TweenMax (version 1.18.3).</p><h4>The Idea</h4><p>When hovering over the graphic, we will animate that:</p><ul><li>the red bar and yellow bar will be taller. Also the star above each bar will move up</li><li>the green bar will be shorter and the star above the bar will move down</li></ul><p>We will also apply the spring <a href="http://greensock.com/ease-visualizer">easing effect</a>.</p><h4>GSAP</h4><p>To make the bar taller/shorter, we will apply scaleY. To move the start up/down, we will apply translateY. If you want to find out what to use between position x and translateX, refer to <a href="https://medium.com/@iamryanyu/should-i-do-the-animation-with-left-or-translatex-49b65a09cf38#.t18uq6cva">my previous article here</a>.</p><p>Let’s start with the bar animation. To start with, you need to call TweenMax:</p><pre>TweenMax.to(selector, duration, { animation values });</pre><p>For the red bar, let’s send those details below:</p><ul><li>selector: <strong><em>$(‘.graph__bar — red’)</em></strong></li><li>duration: <strong><em>1.2</em></strong></li><li>animation values: <strong><em>scaleY: 1.5</em></strong> and <strong><em>ease: Elastic.easeOut.config(1, 0.2)</em></strong></li></ul><p>For the easing, as mentioned above, we will apply the spring effect. You can find the all supported easing effect from <a href="http://greensock.com/ease-visualizer">Ease Visualizer</a>.</p><p>So the code will look like:</p><pre>TweenMax.to($(&#39;.graph__bar--red&#39;), 1.2, {<br>  scaleY: 1.5,<br>  ease: Elastic.easeOut.config(1, 0.2)<br>});</pre><p>Now when you hover over the graph, you will see the red bar is increasing with the spring effect. However, it doesn’t get taller from the bottom, but insted from the top. To make it taller from the bottom, we need to set the <a href="http://tympanus.net/codrops/css_reference/transform-origin/">transform-origin</a> from the bottom which looks like:</p><pre>transformOrigin: &#39;50% bottom&#39;</pre><p>So the completed code for the red bar looks like:</p><pre>TweenMax.to($(&#39;.graph__bar--red&#39;), 1.2, {<br>  scaleY: 1.5,<br>  transformOrigin: &#39;50% bottom&#39;<br>  ease: Elastic.easeOut.config(1, 0.2)<br>});</pre><p>Now let’s make the yellow bar taller and green bar shorter.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5aa82442dcc6c04d4e7a01902da393ba/href">https://medium.com/media/5aa82442dcc6c04d4e7a01902da393ba/href</a></iframe><p>Now when you hover out, let’s make the bar height to the original value which is 1. This time, we will not apply the transformOrigin because we just want the bars to come back to the original position.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5ccb0cd9bba80c4dec91721a6b763982/href">https://medium.com/media/5ccb0cd9bba80c4dec91721a6b763982/href</a></iframe><p>Let’s put them all together in jQuery hover function and assign the selectors in variables.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1748ab11545866f4f00dcc96150f9df8/href">https://medium.com/media/1748ab11545866f4f00dcc96150f9df8/href</a></iframe><p>Now the bar is animating great! It’s time to move up/down the star. This time we will use Y value which is equivalent to translateY. The code will look something like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/831000d38bc3e0054553e2d9a1edc35f/href">https://medium.com/media/831000d38bc3e0054553e2d9a1edc35f/href</a></iframe><p>Let’s clean up the code by assigning repeated values to variables and combining them all together. The code looks like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2011e30838e526385f658e01f0580d67/href">https://medium.com/media/2011e30838e526385f658e01f0580d67/href</a></iframe><p>That’s all. It’s really simple to animate the icons with GSAP. Refer to <a href="http://greensock.com/docs/#/HTML5/GSAP/TweenMax/">GSAP TweenMax</a> doc to find out more details.</p><p>Also if you have any questions, please feel free to leave your comments.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ea375e5cc940" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SVG Sprite Workflow That Works]]></title>
            <link>https://medium.com/@iamryanyu/svg-sprite-workflow-that-works-f5609d4d6144?source=rss-e9a5d6ef359f------2</link>
            <guid isPermaLink="false">https://medium.com/p/f5609d4d6144</guid>
            <category><![CDATA[css]]></category>
            <category><![CDATA[svg]]></category>
            <category><![CDATA[spritesheet]]></category>
            <dc:creator><![CDATA[Ryan Yu]]></dc:creator>
            <pubDate>Sun, 10 Apr 2016 06:52:51 GMT</pubDate>
            <atom:updated>2017-09-08T02:38:37.320Z</atom:updated>
            <content:encoded><![CDATA[<p><strong><em>Update (08 Sep 2017):</em></strong></p><p>I found that sometimes SVG icons don’t appear on IE11 even if the SVG code looks good. One of the examples is:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/88decb30e3014e669f9d80d4823262b6/href">https://medium.com/media/88decb30e3014e669f9d80d4823262b6/href</a></iframe><p>and the icon should look:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/254/1*qhx-cwElFqsYb-FoY9cBAA.png" /></figure><p>The solution on IE11 is to remove the .st# classes in the &lt;path&gt; 😮 and define the color with CSS explained below.</p><p>So the above SVG code may should look like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0bfaf939c4217e39776c65c3193655ee/href">https://medium.com/media/0bfaf939c4217e39776c65c3193655ee/href</a></iframe><p><strong><em>Update (23 Sep 2016):</em></strong><br>One of my colleagues (Michal Prazuch) noted me that xlink:href is not working on Safari. I have contacted SVG gurus, <a href="https://twitter.com/SaraSoueidan">Sara Soueidan</a> and <a href="https://twitter.com/AmeliasBrain">Amelia</a>, and they suggested to keep using xlink:href for now as it will work in all browsers, old &amp; new.</p><p>And the Safari issue has been logged here early this year:<br><a href="https://bugs.webkit.org/show_bug.cgi?id=153854">https://bugs.webkit.org/show_bug.cgi?id=153854</a></p><p>I will keep an eye on it and keep you all updated.</p><p>The code below has been re-updated to reflect back this update.</p><p><strong><em>Updates (14 Sep 2016):<br></em></strong><a href="https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/xlink:href">xlink:href</a> has been deprecated since SVG 2 so instead use href. The code below has been updated to reflect this update.</p><p><strong><em>Updates (30 Apr 2016):</em></strong><em><br>This article has been listed in </em><a href="http://tympanus.net/codrops/collective/collective-217/"><em>Codrop Collective #217</em></a><em>.</em></p><p>Follow me on <a href="https://twitter.com/iamryanyu">Twitter (@iamryanyu)</a></p><p>This SVG Sprite Workflow has been designed and developed in order to improve the current workflow when creating a CSS spritesheet at <a href="https://www.squiz.net/">Squiz</a>.</p><p>A lot of resources have been researched and studied from the various places and some of them are listed below:</p><ul><li><a href="https://developer.mozilla.org/en-US/docs/Web/SVG/Element/use">https://developer.mozilla.org/en-US/docs/Web/SVG/Element/use</a></li><li><a href="http://tympanus.net/codrops/2015/07/16/styling-svg-use-content-css/">http://tympanus.net/codrops/2015/07/16/styling-svg-use-content-css/</a></li><li><a href="https://css-tricks.com/svg-use-external-source/">https://css-tricks.com/svg-use-external-source/</a></li><li><a href="https://sarasoueidan.com/blog/structuring-grouping-referencing-in-svg/">https://sarasoueidan.com/blog/structuring-grouping-referencing-in-svg/</a></li></ul><p>In addition, I had a great chance to attend the Web Directions - Respond 16 in Sydney (thanks a lot to my company, Squiz, for the ticket) and <a href="http://sarasoueidan.com/">Sara Soueidan</a>, who I am a big fan of, had spoken about SVG &lt;use&gt;. I am really happy that what she said during her speak was exactly same as how I designed this workflow, even the two polyfills.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fFKu-uWGqW19tnp5yrVdhg.jpeg" /><figcaption>With Sara and Flore (Front End Developer at Squiz) in Respond 16 in Sydney</figcaption></figure><p>In this article, when I say “We”, they are not only myself and the front end developers at Squiz, but also anyone using the old CSS sprite method.</p><h3>The Problems</h3><p>At the moment, when we need to display icons, we usually create a CSS spritesheet with SVG and PNG (as a fallback) format. To display the icons, normally, we use CSS properties like:</p><ul><li>background-image</li><li>background-position</li></ul><h4>Problem 1: Extra Work</h4><p>My biggest concern always has been to open the Illustrator when new icon is introduced. This is the extra work I have definitely and always wanted to get rid of and gives the front end developers more time to focus on coding.</p><h4>Problem 2: No Change on Icon Color</h4><p>Another problem is we cannot change the color of icons with CSS. If you wanted to change the icon color on hover, we had to add two identical icons but in different colors. I always thought there must be a way to use only one icon and change the color with CSS, but I had no luck.</p><h4>Problem 3: No Change on Icon Element Color</h4><p>This is not a usual case but sometimes we want to change the color of only one part of the icon with CSS, something like below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/243/1*Kk3zIgRLeoli5tfVeAPy3g.png" /></figure><h3>The Solution</h3><p>To resolve those problems above, what we are going to use is SVG &lt;use&gt;. It will save the front end developers a lot of time by:</p><ul><li>No needing to work on the Illustrator anymore</li><li>Using CSS to change colors instead of from Illustrator</li></ul><p>This Workflow is designed based on Squiz Boilerplate (Gulp version) but I am sure it will work great with your own Boilerplate.</p><h4>Workflow 1 — Install Plugins/Polyfills</h4><p>To start with, we will install 1 Gulp plugin and 2 polyfills.</p><ul><li><a href="https://github.com/jkphl/gulp-svg-sprite"><strong>gulp-svg-sprite</strong></a><strong>: </strong>this plugin will do all the heavy-lifting for us. It will combine all the SVG files and generate one SVG Sprite.<br>And this is the configuration for Gulp:</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/48b5a7c380f7a5b6117758ef4b5ebf90/href">https://medium.com/media/48b5a7c380f7a5b6117758ef4b5ebf90/href</a></iframe><ul><li><a href="https://github.com/Keyamoon/svgxuse"><strong>svgxuse</strong></a>: this polyfill will be used on IE 10 - Edge 12.</li><li><a href="https://github.com/jonathantneal/svg4everybody"><strong>SVG for Everybody</strong></a>: this polyfill will be used on IE 9 and below.</li></ul><h4>Workflow 2 — Boilerplate</h4><ol><li>Create new folder in source/svg-sprite (change the path appropriate for your own structure). When gulp-ing, new file will be created in dist/styles/mysource_files/sprite.svg (or depending on how you set it up in Gulp configuration.</li><li>Include svgxuse and SVG for Everybody in the foot in HTML like below:</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9301cd1bc104873f386ecbce1301632f/href">https://medium.com/media/9301cd1bc104873f386ecbce1301632f/href</a></iframe><p>Please note that SVG for Everybody will be only used on IE 9.</p><h4>Workflow 3 — Prepare SVG Icons</h4><p><em>Note: ask designers to provide you individual icons in SVG format.</em></p><p>With this workflow, we only need to deal with each SVG file individually.</p><ol><li>Let’s get an icon (or icons) from designers (or yourself). Please ask the designer to set the path color in black when they create icons.</li><li>Go to <a href="https://jakearchibald.github.io/svgomg/">SVGOMG</a> and open the icon. In the right menus, keep the options as they are, but except the ‘Merge paths’. Disable it and download.</li><li>Open the SVG file you just downloaded in a text editor. Search for an attribute ‘fill’ and remove them. Save the file.</li><li>Give the appropriate name when you save. The file name will be the ID of the SVG icon and we will use it later.</li><li>Put the SVG files in the source/svg-sprite.</li></ol><h4>Workflow 4 — Add SVG Icons in HTML</h4><p>Now this is the fun part. Let’s start with the basic markup and explore 2 scenarios.</p><p><strong>1. The Basic</strong></p><p>To display the SVG icon, we are going to add &lt;use&gt; element. If you want to know more about &lt;use&gt;, please refer to the resources listed above.</p><p>The very basic markup looks like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/060df27a199a69839ca7a2c3a33daaed/href">https://medium.com/media/060df27a199a69839ca7a2c3a33daaed/href</a></iframe><p>Using href, you can reference to the external file with the ID which is same as the SVG file name.</p><p><strong>2. Scenario 1 — OOCSS with SVG Icon</strong></p><p>Now let’s say you want to style the SVG icons with reset, size and color. To do that, you can simply add classes to &lt;svg&gt; and style them in CSS.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ae48da61eddbd704f8fd411b1bc8ef72/href">https://medium.com/media/ae48da61eddbd704f8fd411b1bc8ef72/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c89988df1d35a85b97e1ac4533eae912/href">https://medium.com/media/c89988df1d35a85b97e1ac4533eae912/href</a></iframe><p><strong>3. Scenario 2 — Change Icon Color of Each Element</strong></p><p>This is a bit more complex and requires extra updates in the SVG file.</p><p>Firstly, you need to go to the individual SVG file and add <strong>fill=”currentColor”</strong> in the path you want to <strong><em>keep</em></strong> the original color.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8dbf5b04d85e1d88886a68096851b236/href">https://medium.com/media/8dbf5b04d85e1d88886a68096851b236/href</a></iframe><p>And now let’s create OOCSS for the different color in HTML.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/522f2f45c5401506f61dd3b672a08e11/href">https://medium.com/media/522f2f45c5401506f61dd3b672a08e11/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/50d276762d75620c532a38c0df5a4fa7/href">https://medium.com/media/50d276762d75620c532a38c0df5a4fa7/href</a></iframe><p>To apply two different colors, you need to apply the fill propery so the path with fill=”currentColor” will be filled with the fill property and the path without it will be filled by the color property.</p><p>There is another occasion like you want to apply multiple colors more than two colors to the SVG icons, but we will ignore that scenario in this article. If you want to know how to do it, please let me know.</p><h4>Workflow 4 — Accessibility with 3 Scenarios</h4><p><strong>1. Link with Title</strong></p><p>Add the title along with &lt;svg&gt; in &lt;a&gt;. Also you don’t want the screen reader keep reading the icons, so add aria-hidden to &lt;svg&gt;.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/765c15a7ddc03073bfbc00533c5dd0ee/href">https://medium.com/media/765c15a7ddc03073bfbc00533c5dd0ee/href</a></iframe><p><strong>2. Link without Title</strong></p><p>Sometimes you don’t want the screen readers to read the title of the link. In that case, remove the title and add aria-label to &lt;a&gt;.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ee5604e04f668b6086e573dabb0522c5/href">https://medium.com/media/ee5604e04f668b6086e573dabb0522c5/href</a></iframe><p><strong>3. No Link</strong></p><p>When this is not a link and you want the screen reader to read out, add &lt;title&gt; inside &lt;svg&gt;. And remove aria-hiddne from &lt;svg&gt;.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/37896ed4139a7af2435ae47132911a00/href">https://medium.com/media/37896ed4139a7af2435ae47132911a00/href</a></iframe><h3>Polyfill</h3><h4>Why 2 Polyfills?</h4><p>As svgxuse performs better than SVG for Everybody, we will use svgxuse for the main polyfill. Please read more details from <a href="https://github.com/Keyamoon/svgxuse">svgxuse GitHub page</a>.</p><p>However, it requires to add SVG sprite as inline (inside HTML right below opening &lt;body&gt;) for IE 9 and it is out of the scope for this workflow at the moment. Even though there are some benefits with inline SVG sprite, our main focus on this workflow is to host our SVG sprite in the external file.</p><p>To resolve this issue, we will call svg4everybody.js only for IE 9.</p><h4>When JS is Disabled?</h4><p>As those polyfills are JS based, when JS is disabled, the icons won’t appear. However, as the purpose of those icons are decorative, it is ok if the icons are not appearing (with additional CSS to style so it still look ok without the icons) unless clients insist to have them displayed when JS is disabled. In that case, we will have to provide the fallback with PNG.</p><h3>Any Feedback/Comments?</h3><p>If you have any questions, feedback, comments or recommendations, please feel free to let me know.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f5609d4d6144" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Face Off: CSS vs JS Animation]]></title>
            <link>https://medium.com/@iamryanyu/face-off-css-vs-js-animation-c3165ab993df?source=rss-e9a5d6ef359f------2</link>
            <guid isPermaLink="false">https://medium.com/p/c3165ab993df</guid>
            <category><![CDATA[web-performance]]></category>
            <category><![CDATA[face-off]]></category>
            <category><![CDATA[web-animation]]></category>
            <dc:creator><![CDATA[Ryan Yu]]></dc:creator>
            <pubDate>Sat, 02 Apr 2016 04:28:46 GMT</pubDate>
            <atom:updated>2016-04-02T04:28:46.529Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*0pBG6dL8e4VQBfjeOLixtQ.jpeg" /></figure><p>Last week I talked with one of my friends who is a senior web developer and he was asking me some web animation questions.</p><p>And I found that many developers still have some confusions between the CSS and JS animation performance so I thought I should bring it up and share it with you.</p><h3><strong>CSS animation performs better than JS animation.</strong></h3><p>When someone says this statement, you should not agree with that, nor just disagree.</p><p>Because the statement above is more than just Yes or No question.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*RwHz5bOR1StmO0glpNGkoQ.gif" /></figure><p>Long time ago, jQuery was introduced and our life became much easier in JS world. However, when it comes down to jQuery animation, our life becomes more complex and slower.</p><p>One of the biggest problems with jQuery animation is that it has no mechanism to avoid ‘Layout Thrashing’.</p><p>If you have read my <a href="https://medium.com/@iamryanyu/should-i-do-the-animation-with-left-or-translatex-49b65a09cf38#.l12t2jien">previous article</a>, changing layout is quite costly.</p><p>But due to its codebase, jQuery animation cannot avoid it.</p><p>If you want to find out more about how to avoid Layout Thrashing, check out this article:<br><a href="http://wilsonpage.co.uk/preventing-layout-thrashing/">http://wilsonpage.co.uk/preventing-layout-thrashing/</a></p><p>Furthermore, jQuery animation needs to serve many purpose beyond animation, so its memory consumption triggers garbage collections in the browser and it causes animations to momentarily stutter.</p><p><strong>So what you are still saying is CSS animation performs better than JS animation?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/325/1*TYVDe3_mXFtPxLqEBNZECg.gif" /></figure><p>When you are comparing CSS animation with <strong>jQuery animation</strong>, the answer is YES.</p><p>However, <strong>JS animation libraries,</strong> which bypass jQuery, deliver great animation performance. My favourite two libraries are <a href="http://julian.com/research/velocity/">Velocity JS</a> and <a href="http://greensock.com/gsap">GSAP</a> (GreenSock Animation Platform).</p><p>Those JS libraries perform much better than CSS especially when you need to deal with huge number of elements at the same time.</p><p>You can compare the performance here:<br><a href="http://codepen.io/GreenSock/pen/pmknI">http://codepen.io/GreenSock/pen/pmknI</a></p><p>Also the biggest benefit using JS library is you have many more options to control than CSS such as chaining, callback, promise etc.</p><p><strong>So now you are saying JS animation performs better than CSS animation?</strong></p><p>It depends…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*gz8Stu_NbzhritsXLazBVw.gif" /></figure><p>JS animation performs similar (sometimes better) level of CSS animation with more controls but they are JS based so when JS is disabled, the animation won’t work.</p><p>My suggestion is:</p><p>Use CSS animation when</p><ul><li>the animation is simple (e.g., button hover animation)</li><li>the animation should work even if JS is disabled (e.g., loading bar)</li></ul><p>Use JS animation when</p><ul><li>the animation requires a complex timeline</li><li>the animation is not supported in CSS or works better with JS animation. For example, slideUp/Down is better and simpler with JS than CSS because with CSS, you need to set the max-height manually.</li></ul><p>So now when someone asks if CSS animation performs better than JS animation, you have much more to talk about :)</p><p>Lastly, get inspired by this amazing animation (and nice music too):<br><a href="http://codepen.io/gordonnl/full/byouf/">http://codepen.io/gordonnl/full/byouf/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c3165ab993df" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Align Last Flex Item to Right]]></title>
            <link>https://medium.com/@iamryanyu/how-to-align-last-flex-item-to-right-73512e4e5912?source=rss-e9a5d6ef359f------2</link>
            <guid isPermaLink="false">https://medium.com/p/73512e4e5912</guid>
            <category><![CDATA[flexbox]]></category>
            <category><![CDATA[alignment]]></category>
            <category><![CDATA[css]]></category>
            <dc:creator><![CDATA[Ryan Yu]]></dc:creator>
            <pubDate>Fri, 25 Mar 2016 01:30:05 GMT</pubDate>
            <atom:updated>2024-10-11T12:21:01.511Z</atom:updated>
            <content:encoded><![CDATA[<p>Few weeks ago I found something interesting with flexbox in W3C and wanted to share it with you.</p><p>I presume you know what flexbox is and how cool it is. I won’t go into details about that but if you want to find out more about flexbox, check this link out:<br><a href="http://tympanus.net/codrops/css_reference/flexbox/">http://tympanus.net/codrops/css_reference/flexbox/</a></p><p>and play here:<br><a href="http://the-echoplex.net/flexyboxes/">http://the-echoplex.net/flexyboxes/</a></p><p>Have you ever wondered how you can put only the last flex item to the right but keep all other items still left?</p><p>Something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*3_w3ge_Z7hVPNEEo3wH_pg.png" /></figure><p>Let’s check out the func spec for flexbox on W3C, especially this section:<br><a href="https://www.w3.org/TR/2012/CR-css3-flexbox-20120918/#auto-margins">https://www.w3.org/TR/2012/CR-css3-flexbox-20120918/#auto-margins</a></p><p>The magic happens with the auto margin. Especially pay closer attention to this line:</p><blockquote><em>Prior to alignment via ‘justify-content’ and ‘align-self’, any positive free space is distributed to auto margins in that dimension.</em></blockquote><p>So if you assign the auto value to the margin property, the positive free space will be taken up.</p><p>Let’s see the screenshot below without any margin set.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*kmIVU4Nr9Ybj5U1LkOE_eA.png" /></figure><p>You will see the free space at the right side of the last flex item.</p><p>And if you apply <strong>margin-left: auto</strong> to the <em>last item</em>, the positive free space will be taken up to the left dimension and the last flex item will be pushed to the right.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/237/1*13GuHQJt7N68Upz4aMnz8Q.gif" /></figure><p>Awesome right? It is very good if you wanted to put the last menu item to the right.</p><p>You can apply the auto value to any directions of margin like left, right, top or bottom.</p><p>And I am sure that you now know what would happen if we apply margin: auto to the second flex item :)</p><p>As always, if you have any questions, please leave your comments.</p><p><a href="https://frontendly.io/?utm_source=medium&amp;utm_medium=link&amp;utm_campaign=lastflexitem">Frontendly</a> is helping you become a really good frontend engineer 🌱🌿🌳</p><figure><a href="https://frontendly.io/?utm_source=medium&amp;utm_medium=banner&amp;utm_campaign=lastflexitem"><img alt="" src="https://cdn-images-1.medium.com/max/981/1*vMyeTcgrwMMKNxOzaRTBkQ.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=73512e4e5912" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Vertical Rhythm — Make Your Web Content More Readable]]></title>
            <link>https://medium.com/@iamryanyu/vertical-rhythm-make-your-web-content-more-readable-cb719e0f77fc?source=rss-e9a5d6ef359f------2</link>
            <guid isPermaLink="false">https://medium.com/p/cb719e0f77fc</guid>
            <category><![CDATA[typography]]></category>
            <category><![CDATA[vertical-rhythm]]></category>
            <category><![CDATA[css]]></category>
            <dc:creator><![CDATA[Ryan Yu]]></dc:creator>
            <pubDate>Sat, 19 Mar 2016 00:58:05 GMT</pubDate>
            <atom:updated>2016-03-19T00:58:05.309Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ehK5DH85TcVv4m0azookAg.jpeg" /><figcaption>Image credits to <a href="https://unsplash.com/photos/tk7OAxsXNL0">Marcus dePaula</a></figcaption></figure><p><strong>What is Vertical Rhythm?</strong></p><p>Vertical Rhythm, originated from print typography, is to make the vertical spaces between elements consistent by <strong><em>repeated patterns</em></strong>.</p><p>If you see a lined paper notebook, there are guidelines so you can write your word straight, but also have repeated gaps between lines. It makes your sentences more readable.</p><p>In print, the guideline is called baseline. In web, there is also a baseline but it works a bit differently compared to print.</p><p>In print, the words are written <strong>ON</strong> the baseline something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*9pq-coXC57z8hJvakn3Txg.png" /></figure><p>However, in web, the words are written <strong>IN</strong> the baseline:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*2RYM9zTiz7UcbXUabkehIg.png" /></figure><p><strong>Why is that?</strong></p><p>It is because the web typography contains the <strong>line-height</strong> property which determines the baseline and it works differently to the print.</p><p><strong>Real Practice in CSS</strong></p><p>You now understand how the typography is displayed in web. It’s time to use it in real practices. There is a good tool you can easily calculate all the numbers so head over to Gridlover here:</p><p><a href="http://www.gridlover.net/try">http://www.gridlover.net/try</a></p><p>There are 3 factors you can change:</p><ul><li>Font size</li><li>Line height</li><li>Scale Factor</li></ul><p>I believe you know what font size and line height are.</p><p>The scale factor is the ratio of headings size. The default scale factor is 1.618 which is the Golden Ratio.</p><p>If you scale it up/down, you will find the headings are <em>relatively</em> increasing/decreasing each other.</p><p>As a common practice, let’s set the figures as below:</p><ul><li>Font size: 16</li><li>Line height: 1.5</li><li>Scale Factor: 1.618</li></ul><p>Now when you see the RHS, you will get all the necessary numbers. The most important properties for Vertical Rhythm are:</p><ul><li>line-height: the space <strong>within</strong> a group such as h1 or p.</li><li>margin top/bottom: the space <strong>between</strong> groups.</li></ul><p>When you change the font-size or line-height values, the values in RHS will be changed. But have you noticed something with the values updated?</p><p>YES! Amazing right? Jaw-dropping!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/250/1*C7OXO7iB3rY7-jx2XfLRYw.jpeg" /></figure><p>If you are still not sure, here we go.</p><p>The updated values have <strong>patterns</strong>. With the initial values I suggested to set above, you will get:</p><p>body {<br> …<br> line-height: 24px;<br> padding: 24px;<br> …<br>}</p><p>h1 {<br> …<br> line-height: 72px;<br> margin-top: 24px;<br> …<br>}</p><p>All the space related values are incremental of 24px! If you update the line-height to 1.2, you will get the values incremental of 19px!</p><p>So the spaces between lines have <strong><em>repeated patterns</em></strong>.</p><p>This is what I meant by repeated patterns at the very beginning. But what’s the deal with the repeated patterns?</p><p>Human loves patterns because patterns are predictable, soothing but not boring. The repeated patterns are used by many different industries such as photography, music, poem, meditation etc etc.</p><p>Look at the photo below. Do you feel calm (but not bored)?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*GwdeeCnRLcHXdQOQTmX05Q.jpeg" /></figure><p>That’s why giving repeated patterns to the typography spaces (also spaces between elements) makes content more readable. This is how Vertical Rhythm can improve web experience.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cb719e0f77fc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SVG Width and Height]]></title>
            <link>https://medium.com/@iamryanyu/svg-with-and-height-563abd940d32?source=rss-e9a5d6ef359f------2</link>
            <guid isPermaLink="false">https://medium.com/p/563abd940d32</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[svg]]></category>
            <category><![CDATA[responsive]]></category>
            <dc:creator><![CDATA[Ryan Yu]]></dc:creator>
            <pubDate>Sun, 13 Mar 2016 04:04:20 GMT</pubDate>
            <atom:updated>2016-04-25T06:27:09.584Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gKlzqr9kJcJY6voEP0yXkA.jpeg" /><figcaption>Image credits to <a href="https://unsplash.com/photos/4Hg8LH9Hoxc">Crew</a></figcaption></figure><p>This week I would like to talk about one very interesting but important aspect of CSS.</p><p>Now let me give you a very simple question and you guess the answer.</p><p>If I type below in html:</p><p>&lt;svg width=“200px” height=“300px”&gt;…&lt;/svg&gt;</p><p>and set the below styles in external css file:</p><p>svg {<br> width: 400px;<br> height: 500px;<br>}</p><p>what would be the final width and height of svg?</p><p>If you say 200px and 300px, then buy me a coffee because you are wrong.<br>If you say 400px and 500px, then buy me a coffee too because you are right.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*hC9vyNuLNRYkCRVMF9BH9w.gif" /></figure><p><strong>What?</strong> <strong>How? Why?</strong></p><p>Let’s see the order of styles in cascade below.</p><p><strong>User Agent Styles &lt; Presentation Attributes &lt; External Styles &lt; Document Styles &lt; Inline Styles &lt; Animation &lt; Override Styles &lt; Computed Styles</strong></p><p>The left is overwritten by right. That means the “Presentation Attributes” are overwritten by all other styles except the “User Agent Styles”.</p><p>Now if we go back to the question above, the width and height of SVG count as low-level “author style sheets” like the “Presentation Attributes”.</p><p>That’s why it is overwritten by other styles including the external styles.</p><p>And it is important to understand this if you are dealing with svg (especially inline svg). Because for whatever reason, such as very low internet connection, if CSS is not loaded, the SVG images <em>without</em> width and height set in the html code will cover the entire viewport.</p><p>To avoid this issue, you always need to set the width and height in svg in html and set the proper (responsive) width and height in CSS overwriting the width and height in html. In that way, when the CSS is not loaded properly, there is still a fallback.</p><p>Hope it helps you when you deal with svg and as always if you have any questions, please feel free to let me know.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=563abd940d32" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>