<?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[Frontend and beyond - Medium]]></title>
        <description><![CDATA[web development done right - Medium]]></description>
        <link>https://medium.com/frontend-and-beyond?source=rss----27eafcee5d9c---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*HsJ-1M0B21iLI57h.jpeg</url>
            <title>Frontend and beyond - Medium</title>
            <link>https://medium.com/frontend-and-beyond?source=rss----27eafcee5d9c---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 18:15:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/frontend-and-beyond" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Hardest bug to find. So far…]]></title>
            <link>https://medium.com/@alexey_komov/hardest-bug-to-find-so-far-c80824bbc828?source=rss----27eafcee5d9c---4</link>
            <guid isPermaLink="false">https://medium.com/p/c80824bbc828</guid>
            <dc:creator><![CDATA[Alexey Komov]]></dc:creator>
            <pubDate>Mon, 05 Sep 2016 10:59:24 GMT</pubDate>
            <atom:updated>2016-09-07T20:52:11.047Z</atom:updated>
            <content:encoded><![CDATA[<h4>Be wary… Closure compiler related post. And, by accident, my first post on medium. So be wary even more. 😆</h4><p>For a months I was designing and developing my own app, which undoubtedly could be considered as large javascript application. The story of developing and being enlightened with ideas is most surely a story of itself, so maybe it will be told some time in the future. For now it’ll be enough to say that choice of <a href="https://code.google.com/p/closure-library/">closure library</a> and <a href="https://developers.google.com/closure/compiler/">closure compiler</a> was only logical for an app of such scale.</p><p>Most development time was spent working with code in uncompiled form, though I did some compilation runs just to see what size compiled code would have. It was actually fun to see how code grew to 50k, then to 70k and then to dreadful — for that point — 100k. Then I added gzip ant task on top of compile task, just to easy myself that ungzipped size is not that important, but gzipped size is.</p><p>So it was finally time to compile whole application and to see if compilation broke any functionality.</p><p>And it did.</p><blockquote>Uncaught TypeError: boolean is not a function</blockquote><p>What was considered a boolean, mapped through source map in Chrome to perfectly looking function:</p><blockquote>this.mainPaneBuilder_ = new rflect.cal.ui.MainPaneBuilder(this.viewManager_, …)</blockquote><p>That said, compiler at that stage was generating 109 warnings, most of them were of private properties being overridden and class methods being incorrectly overridden, too. So at first, I tried to remove every and each warning, just to be sure that compiler do not complain. It was one strange thing though: —debug (dash-dash-debug) option was producing error-less compiled code.</p><p>So I removed each warning except one, coming from loader class:</p><blockquote>WARNING — Bad type annotation. Unknown type rflect.cal.Loader * @this {rflect.cal.Loader} ^</blockquote><p>You may notice @this directive here. That’s because earlier compiler was complaining that my non-constructor, plain object has methods that reference “this” in them. And I didn’t want to get rid of “this” inside those methods. You see, Loader is just plain object here.</p><pre>goog.provide(&#39;rflect.cal.Loader&#39;);</pre><pre>goog.require(&#39;goog.events&#39;);<br>goog.require(&#39;rflect.Debug&#39;);<br>goog.require(&#39;rflect.cal.Main&#39;);</pre><pre><br>/**<br> * Binds creation of cal instance to load events.<br> * <a href="http://twitter.com/this">@this</a> {rflect.cal.Loader}<br> */<br>rflect.cal.Loader.main = function() {<br> goog.events.listenOnce(window, &#39;load&#39;, function(aEvent) {<br> // Load event will fire later than dom ready.<br> if (!this.documentLoaded_)<br> this.calInstance_ = new rflect.cal.Main();<br> }, false, this);</pre><pre> goog.events.listenOnce(window, &#39;DOMContentLoaded&#39;, function(aEvent) {<br> this.documentLoaded_ = true;<br> this.calInstance_ = new rflect.cal.Main();<br> }, false, this);</pre><pre> goog.events.listenOnce(window, &#39;unload&#39;, function(aEvent) {<br> if (this.calInstance_)<br> this.calInstance_.dispose();<br> }, false, this);<br>};</pre><p>But warning was about unknown type, isn’t it? I recalled that previous such cases were solved by adding <em>deps.js</em> file to compilation, as suggested <a href="http://code.google.com/p/closure-library/wiki/FrequentlyAskedQuestions#When_I_compile_with_type-checking_on,_I_get_warnings_about_%22">here</a>. But for this particular case it didn’t help, so I forgot about it for a while.</p><p>So, I was at the point when compiler emitted one warning ignored by me and erroneous compiled code. Hm…</p><p>Next thing I remembered that with —debug directive code was working. So in compiler source code I opened method which added options to compilation.</p><pre>public void setDebugOptionsForCompilationLevel(CompilerOptions     options) { <br>  options.anonymousFunctionNaming =      AnonymousFunctionNamingPolicy.UNMAPPED;<br>  options.generatePseudoNames = true;<br>  options.removeClosureAsserts = false;<br>  // Don’t shadow variables as it is too confusing.<br>  options.shadowVariables = false;<br>}</pre><p>So there are 4 possibilities which could be responsible for broken code. By rebuilding compiler with different options on/off, I tracked one that was responsible: essential one — variable renaming (options.generatePseudoNames being false).</p><p>Then I tried to search variable name (“Rk” most of the time, but there were different namings) without source map, in compiled code. And… voila, I spotted such a piece (by luck, just because it was at the very end of compiled file):</p><pre>function Vl() {<br>  Ub(window, “load”, function() {<br>    this.Rk || (this.Vg = new Tl)<br> }, !1, this);<br>  Ub(window, “DOMContentLoaded”, function() {<br>    this.Rk = !0;<br>    this.Vg = new Tl<br> }, !1, this);<br> Ub(window, “unload”, function() {<br>    this.Vg &amp;&amp; this.Vg.K()<br> }, !1, this)<br>} </pre><p>Do you see any familiarity here? :) It was compiled code for loader, which, here, used “this” to assign property “Rk”. Now what we see:</p><ol><li>Initially, in uncompiled file “this” inside of plain object was ok, because object existed.</li><li>After compilation, object was dissolved, and its method became global function, which assigned “Rk” to global space, which, by turn, clobbered some another “Rk” property (in my case, constructor function) which became boolean, true one!</li><li>Compilation with —debug statement worked because names won’t collide, being derived from original ones, like “$rflect$cal$Loader$main$$”.</li><li>When I redesigned loader as class with constructor and prototype, not only it removed error, but also strange warning of unknown type.</li></ol><p>So morals here: do not use “this” inside of plain objects, but only in constructors and prototypes. This I knew and it was told <a href="https://developers.google.com/closure/compiler/docs/limitations">here</a>. But what I didn’t know is that @this directive won’t help to preserve object to which “this” is pointing! It’ll just silence compiler. So my version of this rule is — do not ever use “this” outside of constructors and prototype methods AND do not attempt to silence compiler by @this directive.</p><p>Hoped you were enjoying the reading. Thanks for attention. See ya.</p><p>I’m Alexey Komov — front-end developer and web enthusiast, interested in core and definitive Web things. Please share your thoughts about article. And you may contact me <a href="http://alexeykomov.me/">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c80824bbc828" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[It’s 2014 — where is my backendless CMS?]]></title>
            <link>https://medium.com/@martinmuzatko/its-2014-where-is-my-backendless-cms-a3de2d147f60?source=rss----27eafcee5d9c---4</link>
            <guid isPermaLink="false">https://medium.com/p/a3de2d147f60</guid>
            <dc:creator><![CDATA[Martin Muzatko]]></dc:creator>
            <pubDate>Thu, 22 May 2014 14:47:58 GMT</pubDate>
            <atom:updated>2014-05-22T19:30:32.313Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9Rl--x_OhmmSHaSqxGvYeg.jpeg" /></figure><h4>Please stop the madness</h4><p>Wordpress, TYPO3, and all other great CMS have a huge backend to give you the opportunity to change every last bit of your website to your needs.</p><p>As a frontenddev who regularely works with a lot of content to digest, reorganize and publish for clients or other projects, I still struggle with the decision of a decent system that deals with the important background stuff (accounts, API, revision, newsletter, blog, security) and leaves all the frontend freedom to me.</p><p>Sometimes I wonder why I even bother to use a CMS anymore. When clients refuse to learn about editing content in the CMS of choice, or do not care about content that much nevertheless. Organizing content site-by-site, content area for content area is not only exhausting, but also a very unproductive way to get things done.</p><p>A valid reason for this could be, that we expect our CMS to do <strong>anything </strong>for us.</p><p>Should we either use a mediocre solution for <strong>everything </strong>or a good solution for one thing at a time? Most clients are happy with a blog/page mix. If we want more, we need to look for plugins, addons or widgets. Or even worse: use another service that we can <em>hopefully </em>adapt to the same style as the current mainwebsite has. So if our client needs a shop, maybe a newsletter opt-in, throw in another contact form, we soon have a clutter of shopify, mailchimp and other third-party software. Well done. This is not the way.</p><h3><strong>The Dream — a new concept to organize content in the way we love to.</strong></h3><p>Did you ever happen to hit refresh on the frontend after every insertion to see, if the content as inserted looks any good? Medium is very good at this: the editing and the result are almost identical. This is because the markup is done via the nice selection-tool and some on-hover icons to add embeds/images. Medium does this not via toolbars, widgets or similar that display all possibilities you have at one time.</p><p>If we strip our toolbelt down to something more simple, we can create something thats easy to use but powerful.</p><blockquote>A few mockups later</blockquote><p>If I were going to create a CMS, this is how I would begin to plan it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XFWvkyYDPyPVeyzh8s8nVg.jpeg" /><figcaption>Created with Balsamiq Mockups — their software is awesome!</figcaption></figure><p><strong>Core principles:<br>Layout</strong>, <strong>Module </strong>and <strong>Content </strong>editing.</p><p>The possibly most impressive editing tool to demonstrate, would be the <strong>modules.</strong></p><p>The underlying idea of this, is that modules can have as many content areas as you need. You build them with HTML via your templating engine of choice (<a href="http://smarty.net/">Smarty</a>, <a href="http://twig.sensiolabs.org/">Twig</a> or <a href="https://github.com/NamelessCoder/fluid">Fluid</a> maybe) where you set content areas that can be edited in the frontend. What kind of media it contains (text, images, date, etc) and where they get displayed in the markup.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MnHK7gVd7psZx9ZzFBUubw.jpeg" /><figcaption>Example of a bootstrap slider implementation</figcaption></figure><p>There is a CMS called Fireball, it’s developed to live on top of the Woltlab Community Framework. It makes use of the concept of having modules you can repeatedly use all over the website. See Example.</p><p>The light blue area is a rows-module that is selected. You can move it around via drag and drop, add another row via the + in the upper right corner, delete and of course also copy it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TAEB0dg-W_n85kEBPQbTaQ.jpeg" /><figcaption>How awesome would it be to add new rows at the click of a button?</figcaption></figure><p>Want to copy it to another page? We know how to copy on our desktop environments with the help of our keyboard, I could think about something similar: select the module, press ctrl and then drag it to the desired navigation item, and it would presumably land in the first available main content area. Want a cross reference where both items stay the same when you edit just one? ctrl+shift+drag it somewhere. It works so nicely in windows or other Desktop UIs, why not use the same idea for the web? It’s not only easy, on top of that — it would be intuitive to move around and add new stuff. I am not quite sure if I should make use of a selfmade context menu.</p><p>This Frontend/Backend-in-one solution would be javascript-heavy. At least for the editing.</p><p>Some predefined modules:</p><p>Rows, Page Navigation, Breadcrumbs, Language Selector, Article with or without Comment section, Slider, etc etc.</p><p>You could even restrict some modules to some parent-modules. There is no use for lists in tables and vice versa.</p><h4><strong>Content Editing as we know it</strong></h4><p>Not much to say on this one: There is already a library for a medium.com similar editor: <a href="https://github.com/daviferreira/medium-editor">https://github.com/daviferreira/medium-editor</a>.</p><h4><strong>Layout</strong></h4><p>Usually, this is the first thing you do when you are done with the content: you decide which content goes where. The only thing I can think of is that you can set which parts repeat across other pages. Like navigation, header together with logo + slogan and subscription opt-in. The main content area could have an element that is always present in the same layout.</p><p>By now, we have covered all aspects of professional flexible templates:</p><p>We have a layout, partials and the actual content. We can easily change it to our needs.</p><p>TYPO3 Fluid is awesome in the way it organizes the layout:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*A71SnJ9Ho-HDuQxRXDgDGg.jpeg" /></figure><h3>Conclusion</h3><p>There are still a few points open. For example: how to deal with hidden navigation items. Overall, I would really love to use something that is this easy to modify and expand. I always struggled with the existing Systems to add my custom stuff in a quick manner, without polluting RTF editors with my HTML, which is not well editable for clients. Another issue is, that making a CMS this easy to use, would perhaps empower our clients to fuck the whole website up very easily.</p><p>We also havn’t covered how we would set different sizes on rows — for now it’s only even sized container.</p><p>Please let me know what you think about it, and if you either believe that this idea has a future or not.</p><h3>Kudos</h3><p>This article is a created as a response to <a href="https://twitter.com/noBackend">@nobackend</a> ( <a href="http://nobackend.org/">http://nobackend.org/</a> )</p><h3>Twitter / martinmuzatko: @noBackend are there already ...</h3><p>@noBackend are there already backendless CMS out there? I&#39;m planning to create one to get rid of the frustration once and for all.</p><h3>Twitter / noBackend: @martinmuzatko not that I&#39;m ...</h3><p>@noBackend are there already backendless CMS out there? I&#39;m planning to create one to get rid of the frustration once and for all.</p><h3>Further Read</h3><p>I recommend this one: Brad Frost on Modular Frontend: <a href="http://bradfrostweb.com/blog/post/atomic-web-design/">http://bradfrostweb.com/blog/post/atomic-web-design/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a3de2d147f60" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The natural evolution of user interface design]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@luisvieira_gmr/the-natural-evolution-of-user-interface-design-fe76f0355c75?source=rss----27eafcee5d9c---4"><img src="https://cdn-images-1.medium.com/max/2520/1*ypK3Knbw_o0mEpgML9yesQ.jpeg" width="2520"></a></p><p class="medium-feed-snippet">The modern movement of the web</p><p class="medium-feed-link"><a href="https://medium.com/@luisvieira_gmr/the-natural-evolution-of-user-interface-design-fe76f0355c75?source=rss----27eafcee5d9c---4">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@luisvieira_gmr/the-natural-evolution-of-user-interface-design-fe76f0355c75?source=rss----27eafcee5d9c---4</link>
            <guid isPermaLink="false">https://medium.com/p/fe76f0355c75</guid>
            <dc:creator><![CDATA[Luis Vieira]]></dc:creator>
            <pubDate>Sun, 23 Feb 2014 15:43:49 GMT</pubDate>
            <atom:updated>2014-02-23T20:04:05.225Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[6 Analytics Tools for Web & Mobile Apps ]]></title>
            <link>https://medium.com/@andottto/6-analytics-tools-for-web-and-mobile-apps-7a5b88552740?source=rss----27eafcee5d9c---4</link>
            <guid isPermaLink="false">https://medium.com/p/7a5b88552740</guid>
            <dc:creator><![CDATA[Ashli]]></dc:creator>
            <pubDate>Fri, 08 Apr 2016 10:08:12 GMT</pubDate>
            <atom:updated>2014-06-04T20:21:15.605Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1001/desat/multiply/blue/60/overlay/blue/1*8_329GJTqUIo-J-he5bYxA.png" /></figure><h4>Tools to help you track everything in your mobile app or web app that aren’t Google Analytics. </h4><p><em>Excerpt from</em><a href="http://autosend.io/analytics-tools-web-mobile/"><em> 64 App Analytics Tools for Web and Mobile Apps</em></a><em> post on </em><a href="http://autosend.io/"><em>Autosend.io</em></a></p><p>Every web or mobile app team needs to know how well they’re doing. And it’s hard to do without a good analytics tools. If you want to track how well you’re <a href="http://autosend.io/how-to-onboard-users-email-sms-push/">onboarding your app users</a> or test <a href="http://autosend.io/ab-testing-tools-mobile-apps/">how well your A/B tests are performing</a>, there’s an analytics tool for you. There are <a href="http://autosend.io/analytics-tools-web-mobile/">dozens of mobile and web app analytics tools around</a>, but there are only a few standouts.</p><p>In the meantime, let’s go over a few tools you may not know about to help you track everything you need to make your mobile app or web app business successful.</p><p>TL;DR: If you want to see <a href="http://autosend.io/analytics-tools-web-mobile/">a list of 60+ app analytics tools for your mobile app or web app go here</a>.</p><ol><li><a href="https://heapanalytics.com/"><strong>Heap</strong></a> — If you need a tool to work on your website and in your mobile app, Heap just may be your option. Heap is a cross-platform mobile and web app analytics tool that helps you track anything from taps and clicks to form submissions and users. Heap is definitely an analytics tool for marketers since it doesn’t even require code to setup. Right now, Heap is only available on web and iOS platforms, but I’m sure they’ll expand in the future.</li><li><a href="http://trak.io/"><strong>Trak.io</strong></a> — Trak.io is an analytics tool for web apps. But Trak.io isn’t the typical app analytics tool that only measures page visits and referral sources. With Trak.io you can see everything you user has ever done in your app. This helps you locate bottlenecks or pain points in your app that kill your conversions. Trak.io seems easy to setup and also tracks things like your app revenue, user retention rates, and more in one place.</li><li><a href="https://www.woopra.com/"><strong>Woopra</strong></a> — Woopra is a good looking website analytics tool that helps you keep track of all your website’s activity. If you’ve ever wanted to know how long your users stay on a certain page or even where your new visitors and users are coming from, Woopra can show you. Woopra is very comparable to Google Analytics as far as the data it can provide. But it’s simpler to use, beautiful, and defaults to real-time.</li><li><a href="https://www.inspectlet.com/"><strong>Inspectlet</strong></a> — Inspectlet is the last analytics tool on the list for web apps. Inspectlet helps you see what your users are seeing when they visit your site with heatmaps. If you’ve ever wondered if your web app users scroll down the page to use a particular feature, this is the tool for you. Inspectlet also has many other awesome features like real-time analytics and recorded user-sessions that help you get a real view on what users want in your app.</li><li><a href="http://count.ly/"><strong>Countly</strong></a><strong> </strong>— Countly is a nice looking analytics <a href="http://autosend.io/mobile-app-development-resources-guide/">tool for mobile apps</a>. With Countly you can track almost everything in your mobile app. You can get stats on how many users are actively using your app right now, get a breakdown on which platform each app user is on, and even see which carrier they’re using. Basically, if you’re <a href="http://autosend.io/should-my-app-be-free-or-paid/,%20">charging for anything in your app (and you should be</a>), you need to use an analytics tool to help you optimize your mobile app. Oh, did I mention Countly is open-source?</li><li><a href="http://heatdata.com/"><strong>HeatData</strong></a> — The mobile space is maturing quickly and mobile app development teams are finally getting the tools websites and web apps have used for years. Heatdata is an example of this. Heatdata is a heatmaps tool for mobile apps. Let’s say you wanted to know if your mobile app users actually tapped on a “below the fold” submit button in your app. A good mobile app heatmaps tool like Heatdata can show you if they did. Heatdata is also available to use on your mobile website since it requires you to install Javascript code in your app to work.</li></ol><p>Clearly, there are many more analytics tools available to mobile and web app teams than listed above. But as you can see, there’s an analytics <a href="http://autosend.io/mobile-alternatives-to-web-tools/">tool available for anything you want to do on any platform</a>.</p><p><strong>If you liked this, you may also like:</strong></p><p><a href="http://autosend.io/mobile-alternatives-to-web-tools/">60 Equivalent tools for Web apps and Mobile Apps</a></p><p><a href="http://autosend.io/testflight-alternatives/">10 Beta Testing Apps for Mobile Apps</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a5b88552740" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Gulp.js to ember-cli]]></title>
            <link>https://medium.com/@cullymason/from-gulp-js-to-ember-cli-450f1ffb1967?source=rss----27eafcee5d9c---4</link>
            <guid isPermaLink="false">https://medium.com/p/450f1ffb1967</guid>
            <dc:creator><![CDATA[Cully Mason]]></dc:creator>
            <pubDate>Tue, 13 May 2014 22:19:05 GMT</pubDate>
            <atom:updated>2014-05-14T17:44:03.353Z</atom:updated>
            <content:encoded><![CDATA[<h4>a how &amp; why</h4><blockquote>Full disclaimer: I am not pretending to be an expert, so I am open to your input. Be nice ☺</blockquote><p>Today started out frustrating. I reviewed some code several times that I had written and it looked correct. I kept getting the same errors over and over again. Despite my best efforts, I couldn’t even get my Ember app to render. I decided to close everything, take a break and revisit this later. Right as I was closing all of my windows and tabs, I realized something infuriating — I had mistyped something in a handlebars template earlier and gulp just quit. There was no warning. Just a silent error. Why wouldn’t it just keep trying to compile until I fixed the error? This was not the first time this had happened.</p><p>My first intuition was just to find some <a href="https://www.npmjs.org/package/gulp-plumber">plugin</a> (thanks @<a href="https://twitter.com/jonkoops">JonKoops</a>) that would fix this problem as I’m sure I am not the first this has happened to. However, I had just watched a <a href="http://confreaks.com/videos/3307-emberconf2014-software-productivity-and-ember-ember-cli">video</a> of <a href="https://twitter.com/stefanpenner">Stefan Penner</a> on <a href="https://github.com/stefanpenner/ember-cli">ember-cli</a> and it looked promising. It looked like it solved the problem mentioned above and also it looked like it would address a few more of my fears of switching away from gulp.</p><p>I was apprehensive to switch to ember-cli. Truthfully, I had a build solution that worked, it just didn’t work well. And ember-cli is still considered a work in progress. What if I spend a bunch of time switching code to only end up in a similar situation? At least I am familiar with the the situation I am in now. Also, ember-cli was built on top of <a href="https://github.com/broccolijs/broccoli">broccoli</a>. I know many people are in love with broccoli, but would it really be worth learning yet another build tool? And I know es6 is cool, but my project doesn’t implement it at all. I am not that familiar with it in the first place. How hard would it be to convert all of my old code to use it?</p><p>I decided to only give myself the first half of the day to try to convert my project from a custom gulpjs build to an ember-cli build. If I could not get it done, I would just try using it on some future project.</p><p>In less than 4 hours I had completely replicated the project with ember-cli. And it worked.</p><p>Am I happy I switched to using ember-cli? Was it worth it? Absolutely. Here’s why:</p><h3>Installation is a breeze</h3><pre><strong>npm</strong> install -g ember-cli</pre><pre><strong>ember</strong> new <em>projectName</em><br><strong>cd</strong> <em>projectName</em><br><strong>ember</strong> server</pre><p>done. With just a few commands, My project had been scaffolded, any dependencies had been brought in with <a href="http://bower.io/">bower</a>, those dependencies as well as your source code were compiled with broccoli, a server was started and it has autoload built in. As a bonus, all of your code is scrubbed with jshint (which quickly reminded me that I don’t like to use semicolons). I do not know if it gets any easier than that.</p><h3>ES6 and the Ember Resolver are awesome</h3><p>Like I mentioned earlier, I was scared to dive into the foreign world of ES6. What is a transpiler anyway? But if you take the time to read through the <a href="http://iamstef.net/ember-cli/">ember-cli</a>, you will realize that with the help of the Ember Resolver, the changes you will have to make are pretty common sense. Plus the <a href="https://github.com/cavneb/loom-generators-ember-appkit">generators</a> built into ember-cli give you a pretty good starting point. Let’s walk through a simple example.</p><p>Say you wanted to create a controller for the comments section for a given post for your app. So you type:</p><pre>ember generate controller post/comments</pre><blockquote>This messed me up when I first started. Notice how you don’t type ‘ember generate <strong>postComments</strong>’<em> </em>but <strong>post/comments</strong><em>.</em> Anything that is nested in your app will be nested in the command.</blockquote><p>It will ask you whether you want to create an array controller, object controller or neither. Once you make your choice, under the controllers folder, ember-cli will create a folder named <em>post</em> and a file named <em>comments.js.</em> If you open up the <em>comments.js</em> file, you will see the following:</p><pre>var PostCommentsController = Ember.ObjectController.extend({</pre><pre>});</pre><pre>export default PostCommentsController;</pre><p>Which isn’t much different than what I am used to:</p><pre>App.PostCommentsController = Ember.ObjectController.extend({</pre><pre>});</pre><p>Once I realized how similar the code was, a majority of my move to ember-cli was just a copy and paste job with a few caveats:</p><ol><li>The <a href="http://iamstef.net/ember-cli/#naming-conventions">naming convention</a> is a bit different than what I am used to. If something in your app is multiple words, name the file with hyphens, and inside the app use camelCase. <strong>Also, all filenames are lowercase</strong>. So if you want to create a route called “My Awesome Site”, the file would be called my-awesome-site.js and you would export MyAwesomeSiteRoute.</li><li>Because you aren’t putting everything in the global App namespace, things like mixins are handled a little differently. Say you wanted to write a mixin to ensure that the comments from the controller above are filterable. So you would type <em>ember generate mixin filterable. </em>Of course under the<em> mixins/filterable.js </em>you get this:</li></ol><pre>var filterable = Ember.Mixin.create({});<br>export default filterable;</pre><p>To use it, you need to <em>import</em> it into your controller file. So it looks like this:</p><pre><strong>import filterable from “appName/mixins/filterable”;</strong></pre><pre>var PostCommentsController = Ember.ObjectController.extend(<strong>filterable</strong>,{<br>});<br>export default PostCommentsController;</pre><p>If you look at the <a href="http://iamstef.net/ember-cli/#using-modules">docs</a>, there are a few ways to import your mixins, helpers and such. I found what made the most sense was to base your path on what you called your app.</p><blockquote><strong><em>Note:</em></strong> <em>If you forgot what you called your app, you can see under your index.html file in the statement </em>window.projectName = require(‘<strong>project-name</strong>/app’)[‘default’].create(ENV.APP);</blockquote><h3>When your controller has needs</h3><p>If you have a controller that depends on another controller, you typically type:</p><pre>needs: [‘postComments’]</pre><p>As stated in the <a href="http://iamstef.net/ember-cli/#naming-conventions">docs</a>, because of the way files are nested using ember-cli, you would need to make a few minor changes:</p><pre>needs: [<strong>“post/comments”</strong>],<br>postComments: Ember.computed.alias(‘controllers.post/comments’)</pre><p>and whenever you need it, you can use it like any other property:</p><pre>var commentsController = this.get(‘postComments’);</pre><h3>What about ember-data?</h3><p>When you create a new project, the beta for ember-data is included and using it is <a href="http://iamstef.net/ember-cli/#ember-data">well documented</a>.</p><h4>Creating Models</h4><p>The ember-cli generator does not include models but it is straight forward to create yourself. If you wanted to create a Post model, you would create a post.js file in the models folder that looks like this</p><pre>export default DS.Model.extend({<br>// attributes go here<br>});</pre><p>With only that code, how does Ember know that it is a Model for a Post? The Ember resolver is smart enough to know that since you placed post.js in the Models folder, that it must be a Model named Post. In fact, this works for other parts of your app like your Controller and Route files.</p><h4>Adapters and Serializers</h4><p>Even though ember-cli didn’t generate folders for adapters or serializers, you can create them yourself. An adapter for your Post model would reside in app/adapters/post.js. Application wide adapters and serializers will be contained in the their appropriate folders in a file named application.js.</p><h4>Fixtures</h4><p>Because my project had previously been in production, I didn’t need to use the fixture adapter, but I have previously. I would say this is probably where the documentation is a bit lacking (or I probably just missed it) but nonetheless here is how to get up and running with fixtures:</p><ol><li>I created an <em>application.js</em> in the <em>app/adapters</em> folder that contains a single line: <em>export default DS.FixtureAdapter.extend();</em></li><li>Lets say you need fixtures for A Task Model. Under your <em>app/models</em> directory, you would create a file called <em>task.js </em>that looks like this:</li></ol><pre>var Task = DS.Model.extend({<br> title: DS.attr(‘string’),<br> description: DS.attr(‘string’),<br>});</pre><pre><strong>Task.reopenClass({<br> FIXTURES: [<br> { id: 1, title: ‘Title A’, description: ‘Body A’, owner: 1 },<br> { id: 2, title: ‘Title B’, description: ‘Body B’, owner: 2 }</strong></pre><pre><strong> ]<br>});</strong></pre><pre>export default Task;</pre><p>After that, you are up and running with fixtures.</p><h3>Bower is your friend again</h3><p>I think bower, in concept, is awesome. I always start out using it. But unfortunately, as my project becomes larger I tend to forget about it. Because you don’t use globals with ember-cli I was a bit worried how using outside scripts would work. As it turns out, it is very straight forward. In my current project I use a <a href="https://github.com/SheetJS/js-xls">tool</a> that reads excel files. In order to use it, I use bower to pull in the dependency. Then in my Brocfile, tell broccoli where it can be found like so:</p><pre>app.import(‘vendor/js-xls/xls.js’);</pre><p>And that was it.</p><h4>Using Ember.js Beta</h4><p>Ember-cli only pulled in 1.5.1. No problem. I just opened up my bower.json and changed the ember line to:</p><pre>“ember”: “<strong>1.6.0-beta.3</strong>&quot;</pre><p>and it just worked.</p><h3>Done?</h3><p>Once I was done converting my code I simply typed <em>ember build</em> and all of my code was compiled and minified into a <em>dist</em> directory.</p><h3>Theres more..</h3><p>But, this is getting a bit long. Really switching to ember-cli from a tool like grunt or gulp is very painless. The biggest “hurdle” if you want to call it that, was naming everything appropriately and in true Ember.js style, the error messages are extremely helpful. The best part is that through the migration to ember-cli, I ended up with code that was better organized and cleaner. Also, the build times are insanely fast.</p><p>Even better, after I got done converting my project, I had an idea for a component that I never really hammered out because I didn’t want to go through the hassle of setting up a new project for just a component. With ember-cli, that was just a generator away.</p><h3>The road ahead</h3><p>There are a few things that I didn’t fully get to try or figure out but will investigate in the future:</p><ul><li><strong>Testing</strong>. I know this is bad, but I never really fooled with it on my ember apps because it took so much time to set up. At first glance, ember-cli appears to offer a very approachable way to get into testing. Several of the generators also generate a test file.</li><li><strong>SASS/CSS/Bootstrap</strong> I just ran out of time. I know ember-cli can <a href="http://iamstef.net/ember-cli/#asset-compilation">do it</a>, but for now I just included bootstrap inside my app/styles folder.</li></ul><p>Hopefully this will help others make the same migration I have. I cannot see myself going back to anything else. The pace at which ember-cli is improving is insane and is only getting better. If you have any questions, please feel free to reach out to me on <a href="https://twitter.com/cullymason">Twitter</a>. I am by no means an expert, but I will do my best. As always Ember has an excelent support community and there is a very useful #ember-cli channel on freenode.</p><p>Cheers.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=450f1ffb1967" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Javascript UI components for the masses]]></title>
            <link>https://medium.com/@jdandrade/javascript-ui-components-for-the-masses-f02472f40be1?source=rss----27eafcee5d9c---4</link>
            <guid isPermaLink="false">https://medium.com/p/f02472f40be1</guid>
            <dc:creator><![CDATA[Juan David Andrade]]></dc:creator>
            <pubDate>Sat, 10 May 2014 02:01:15 GMT</pubDate>
            <atom:updated>2014-05-10T03:50:26.922Z</atom:updated>
            <content:encoded><![CDATA[<h4>Building UI components without dependencies.</h4><p>The idea of this article is to understand how Javascript has been used over the time to create user interfaces or commonly named UI components. These components are carousels, modal windows, tooltips, accordions, tabs, form validators, etc.</p><h4>The beginning</h4><p>At the beginning developers worked with just raw javascript to build these widgets. At some point of the front end development, talented developers built excellent libraries/frameworks/toolkits like jQuery, Prototype, MooTools, Dojo, Underscore, etc. These libraries have contributed to improve the front end development workflow in many aspects, like DOM manipulation, animations and transitions, navigation, skinning, ajax requests, etc, and also to deal with cross browsing. So, at this point UI components were improved with the help of these frameworks.</p><h4>MV*</h4><p>Later, due to the need to create more robust solutions to deal with complex front end architectures, developers have ported some Design Patterns to JS and MV* frameworks were created to handle that logic, where Backbone, Angular and Ember are the most predominant competitors over the Internet.</p><p>The goal of MV* is to give structure (Controller/Presenter/ViewController), presentation (View) and data (Model) and to deal with the navigation through a website (Router).</p><p>This is a great pattern to build an <a href="http://en.wikipedia.org/wiki/Single-page_application">SPA</a> or a large website with a complex front end functionality.</p><h4>Front-end Frameworks</h4><p>Front-end frameworks (<a href="http://getbootstrap.com/">Bootstrap</a>, <a href="http://foundation.zurb.com/">Foundation</a>) are boilerplates to easily build web sites and prototypes. Both frameworks have grid systems, utilities, components/plugins that help developers with layouts and UI components.</p><h4>UI Components nowadays</h4><p>These days, many developers don’t recognize the line between what is feature of the core architecture of a site and what is a single component (e.g. modal, tooltip, carousel). I will try to explain it with a simple example:</p><p>Developer A is building a website using <a href="http://backbonejs.org/">Backbone</a> and he needs to include a carousel component inside a page. He could take different ways to implement that feature:</p><p>a. Using a third-party library plugin.<br>b. Using a front-end framework like bootstrap or foundation.<br>c. Developing the feature inside the View (In this case, the View is a ViewController created using BackboneJS).</p><h4>The Problem</h4><p>As I said in the introduction, my idea is to explain why these implementations will bring an overhead to the project.</p><p>Developer A needs to include a carousel component, it is just a user interface widget, not a complex application.</p><p>a. Using a third-party library plugin: this library could have more third-party dependencies like jQuery, Underscore, etc.</p><p>b. Using a front-end framework: <a href="http://getbootstrap.com/javascript/#carousel">Bootstrap Carousel</a> and <a href="http://foundation.zurb.com/docs/components/orbit.html">Foundation Slider </a>also could have more dependencies like jQuery, Modernizr, etc.</p><p>c. Developing the feature inside a Backbone View: I believe that a UI component or any kind of component should accomplish a simple rule: <strong>reusability</strong>.</p><h4>The Solution</h4><p>Currently W3C is working in <a href="http://w3c.github.io/webcomponents/explainer/">Web Components</a> to create widgets or components following Web Standards and best practices. We know this will be the best solution to build components reducing architectural mistakes. But this is a Draft, and this means we can’t use it right now. For the moment, we can use an excellent library, <a href="http://www.polymer-project.org/">Polymer Project</a>.</p><p>Other developers are trying to build solutions from a different perspective, as <a href="http://absurdjs.com/pages/client-side-components/">AbsurdJS</a>. Really? I don’t think parsing CSS as a javascript literal object is a good idea. This goes against web standards and best practices. But I admire this library is trying to propose a solution, an idea.</p><h3>My Solution</h3><p>Front End Development has been improved over the last years, and we can see this progress in the evolution of browsers like Chrome, Firefox and now Internet Explorer 11. This helps us to have a better compatibility between browsers and use native JS functionalities to avoid the excessive use of third-parties like jQuery, Zepto, etc. You can see <a href="http://youmightnotneedjquery.com/">“You might not need jQuery”</a> to understand how some functionalities can be developed with raw javascript.</p><p>To build UI components you can back to basics, you could follow a simple and basic structure to develop a widget instead of generating too much dependencies and a lot of complexity. To start building a component this structure could work:</p><pre>css/carousel.css<br>js/carousel.js<br>index.html (include the markup of the component where you will need it)</pre><p>Following with the example, this will be the code included into the HTML:</p><pre>&lt;div class=&quot;carousel&quot;&gt;<br> &lt;ul class=&quot;carousel-items&quot;&gt;<br>   &lt;li&gt;&lt;img src=&quot;<a href="http://dummyimage.com/500x160/165599/ffffff&amp;text=1">http://dummyimage.com/500x160/165599/ffffff&amp;text=1</a>&quot; alt=&quot;&quot;&gt;&lt;/li&gt;<br>   &lt;li&gt;&lt;img src=&quot;<a href="http://dummyimage.com/500x160/165599/ffffff&amp;text=2">http://dummyimage.com/500x160/165599/ffffff&amp;text=2</a>&quot; alt=&quot;&quot;&gt;&lt;/li&gt;<br>   &lt;li&gt;&lt;img src=&quot;<a href="http://dummyimage.com/500x160/165599/ffffff&amp;text=3">http://dummyimage.com/500x160/165599/ffffff&amp;text=3</a>&quot; alt=&quot;&quot;&gt;&lt;/li&gt;<br>   &lt;li&gt;&lt;img src=&quot;<a href="http://dummyimage.com/500x160/165599/ffffff&amp;text=4">http://dummyimage.com/500x160/165599/ffffff&amp;text=4</a>&quot; alt=&quot;&quot;&gt;&lt;/li&gt;<br>   &lt;li&gt;&lt;img src=&quot;<a href="http://dummyimage.com/500x160/165599/ffffff&amp;text=5">http://dummyimage.com/500x160/165599/ffffff&amp;text=5</a>&quot; alt=&quot;&quot;&gt;&lt;/li&gt;<br> &lt;/ul&gt;<br>&lt;/div&gt;</pre><p>And what if you need to support older browsers like IE8. A good idea will be to integrate a library to avoid cross-browsing issues. You could be use for example jQuery or Dojo. So, Why I can just use jQuery to prevent browser issues with the widget?. Then you must ask this: What if I have to integrate the component within a website that works with Prototype, or Moo Tools?. I think this is a good reason to avoid these libraries for your widgets. The use of a third-party could lead to a <a href="http://en.wikipedia.org/wiki/Coupling_%28computer_programming%29">tightly coupled</a> component. Here you can detect another important feature of a component: <strong>Flexibility.</strong></p><p>To handle this situation, we can modify our basic structure to:</p><pre>css/carousel.css<br><strong>**js/helpers.js</strong> (a constructor/module/object with basic functions to support only DOM operations and some operations you will need)<br>js/carousel.js<br>index.html (include the markup of the component where you will need it)</pre><p>**If you want you can develop helpers inside <strong>carousel.js</strong> or use a task runner to concatenate and minify these scripts.</p><p>With this structure, you have three key factors to have a simple and functional UI component:</p><ul><li><strong>Reusability: </strong>You just need to plug and play the component where you need.</li><li><strong>Flexibility: </strong>You don’t have any dependencies for your component.</li><li><strong>Adaptability: </strong>With this structure easily you could convert the component to a Web Component.</li></ul><p>To illustrate deeply this concept, I have developed a Carousel component called <a href="http://jandrade.github.io/carouseljs/"><strong>carouseljs</strong></a><strong>. </strong>You can go to the website to see the component in action, and go to the repository to see how is built.</p><p><strong>Website</strong>: <a href="http://jandrade.github.io/carouseljs/">http://jandrade.github.io/carouseljs/</a><br><strong>Github Project</strong>: <a href="https://github.com/jandrade/carouseljs/">https://github.com/jandrade/carouseljs/</a></p><h3>Conclusion</h3><p>You can adopt the use of modern capabilities of Web Components using Polymer, integrate UI toolkits like<a href="http://jqueryui.com/"> jQuery UI</a>, use Front end Frameworks like bootstrap or foundation, or if you want to go deeper and make some cool and flexible components, you can develop your own libraries. It depends on your needs and your ability to learn, contribute and share your knowledge with the community.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f02472f40be1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MongoDB Relations]]></title>
            <link>https://medium.com/@dis_is_patrick/mongodb-relations-26201385b919?source=rss----27eafcee5d9c---4</link>
            <guid isPermaLink="false">https://medium.com/p/26201385b919</guid>
            <dc:creator><![CDATA[Pat Whitrock]]></dc:creator>
            <pubDate>Wed, 07 May 2014 20:58:11 GMT</pubDate>
            <atom:updated>2014-06-06T21:08:19.638Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ml2CaYENKRj4ThrLKDYoIA.png" /></figure><h4>Embedding and referencing docucments</h4><p>Mongo’s relations are the NoSQL equivalent of associations found in relational databases. While serving a similar purpose and appearing similar in implementation, they do behave differently.</p><h3>NoSQL relations vs RDBMS associations</h3><p>Relations associate data from one model with data from another model. On a high level, this is precisely what RDBMS associations are for. However, the way in which data is associated in NoSQL is quite different.</p><p>In traditional relational databases, associations are used to relate data from one table to another. MongoDB and similar NoSQL databases are document-oriented (there are no tables), so relationships are drawn between document-objects instead.</p><p><strong>ActiveRecord</strong></p><pre>class Post &lt; ActiveRecord::Base<br>  belongs_to :author<br>  has_many :comments<br>end</pre><p><strong>Mongoid (referencing)</strong></p><pre>class Post<br>  include Mongoid::Document<br>  belongs_to :author<br>  has_many :comments<br>end</pre><p><strong>Mongoid (embedding)</strong></p><pre>class Post<br>  include Mongoid::Document<br>  embedded_in :author<br>  embeds_many :comments<br>end</pre><p>All of the classes above implement basic one-to-many relationships in which an author has many posts and a post has many comments. One could say that <em>embedded_in </em>and <em>embeds_many </em>are the equivalent of <em>belongs_to</em> and <em>has_many</em>, but this would be an oversimplification.</p><h4><strong>ActiveRecord</strong></h4><p>Relational databases handle associations through the use of foreign keys referencing a unique row in another table. For example, a <em>post</em> would have an <em>author_id </em>referencing the ID of the record in the a<em>uthors</em> table to which it belongs. If an <em>author</em> has multiple <em>posts</em>, multiple <em>post</em> records would have the same <em>author_id</em>. <em>Authors</em> do not have <em>post_ids</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/666/1*N--OFHhEC155ulYfHhPQGQ.png" /><figcaption>Relational database schema</figcaption></figure><h4><strong>Mongoid References</strong></h4><p>One way NoSQL databases handle one to many relationships is through references. Referencing is more similar to associations in relational databases than embedding (the pattern we will discuss next). References also utilize foreign keys, however they point from one document to another, rather than a record in one table to a record in another table.</p><pre><em>// An author document.</em><br>{<br>  &quot;_id&quot; : ObjectId(&quot;4d3ed089fb60ab534684b7e9&quot;),<br>  &quot;name&quot; : &quot;Pat Whitrock&quot;<br>}<br><br><em>// A post document.</em><br>{<br>  &quot;_id&quot; : ObjectId(&quot;4d3ed089fb60ab534684b7e0&quot;),<br>  &quot;author_id&quot; : ObjectId(&quot;4d3ed089fb60ab534684b7e9&quot;),<br>  &quot;name&quot; : &quot;Mongo Stuff&quot;<br>}<br><br><em>// A comment document.<br></em>{<br>  &quot;_id&quot; : ObjectId(&quot;4d3ed089fb60ab534684b7e8&quot;),<br>  &quot;post_id&quot; : ObjectId(&quot;4d3ed089fb60ab534684b7e0&quot;),<br>  &quot;content&quot; : &quot;Lots of stuff about Mongo.&quot;<br>}</pre><h4><strong>Mongoid Embeds</strong></h4><p>Another way NoSQL databases handle this sort of one to many relationship is through embedding documents. One document is embedded within another, resulting in what is basically a giant hash. For example, the <em>author</em> document would embed many <em>post</em> documents and each <em>post </em>document would embed many <em>comment</em> documents. Each <em>author</em> document is a hash containing an array of <em>post</em> documents, each containing an array of <em>comment</em> documents.</p><pre><em>// An author document.</em><br>{<br>  &quot;_id&quot; : ObjectId(&quot;4d3ed089fb60ab534684b7e9&quot;),<br>  &quot;name&quot; : &quot;Pat Whitrock&quot;,<br>  &quot;posts&quot; : [<br>    // <em>An embedded post document.</em><br>    {<br>      &quot;_id&quot; : ObjectId(&quot;4d3ed089fb60ab534684b7e0&quot;),<br>      &quot;name&quot; : &quot;Mongo Stuff&quot;,<br>      &quot;comments&quot; : [<br>        // <em>An embedded comment document.</em><br>        {<br>          &quot;_id&quot; : ObjectId(&quot;4d3ed089fb60ab534684b7e8&quot;),<br>          &quot;content&quot; : &quot;Lots of stuff about Mongo.&quot;<br>        }<br>      ]<br>    }<br>  ]<br>}</pre><h4>Embedding vs Referencing</h4><p>Why is it necessary for Mongo to have multiple ways of defining the same one to many relationship when ORMs like ActiveRecord require only one? Both embedding and referencing are valid options, but each caters more to specific use cases. There are a few things to consider before deciding.</p><p>Will your data be referred to from multiple locations? If you need to access your data from multiple locations, you’re probably better off using references. If your data is only useful in relation to its parent document, embedding is the way to go.</p><p>Also important to consider are data consistency and document size. MongoDB documents can are limited to a maximum size of 4MB, however it’s unlikely that this is a problem you would encounter early on.</p><p>This post is originally from my <a href="http://pat-whitrock.github.io/">technical blog</a>. You can find the original post <a href="http://pat-whitrock.github.io/blog/2014/05/07/mongodb-relations/">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=26201385b919" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Considering a Static Site Tool? Learn Gulp.]]></title>
            <link>https://medium.com/@wtc/considering-a-static-site-tool-learn-gulp-2fd5f9821fc4?source=rss----27eafcee5d9c---4</link>
            <guid isPermaLink="false">https://medium.com/p/2fd5f9821fc4</guid>
            <dc:creator><![CDATA[Andrew Colclough]]></dc:creator>
            <pubDate>Mon, 14 Apr 2014 16:45:12 GMT</pubDate>
            <atom:updated>2014-04-24T14:16:32.839Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/desat/multiply/teal/60/overlay/teal/1*ON7X6ZutSFAITF3ng4FTCQ.png" /></figure><h4>So easy, a designer could do it</h4><blockquote>Wait…I’m a designer. Did I just burn myself?!?</blockquote><p>We have been using Gulp.js on a new project at work, and I’m now using it to power and build my own projects. I’m writing this article to help even non-technical people (I am a designer by schooling) understand Gulp. We are going to build a static site tool because I think the best way to learn is to build something useful.</p><h3>Why a static site tool?</h3><p>I tend to like static site generators because they are excellent for rapid prototyping, and I have been using them for my own website because I like that level of control. If you are like me, you may tend to get frustrated trying to reengineer or refit someone else&#39;s system into your own. Also, I really don’t like meddling with an intermediary abstraction layer or admin interface (typical in a CMS like Wordpress), and I don’t need a database or other features many solutions provide.</p><blockquote>My ideal admin interface is the code itself.</blockquote><p>With that said, I don’t want to return to 1996 either. I want to leverage the power of my favorite stuff like <a href="http://sass-lang.com/">Sass</a>, <a href="http://jade-lang.com/">Jade</a>, or <a href="https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet">Markdown</a>. Previously, I have used great tools like <a href="http://awardwinningfjords.com/2009/10/22/middleman.html">Middleman</a>, <a href="http://staticmatic.rubyforge.org/">StaticMatic</a>, <a href="http://nanoc.ws/">nanoc</a>, and lately my current site was built with <a href="http://ruhoh.com/">Ruhoh</a>. Let me say right-away that there is <strong>nothing at all</strong> wrong with any of these tools. In fact, I strongly recommend considering them yourself. However, as I have wrapped my head around Gulp, I believe it may be the best fit for my needs, doing exactly what I need, and not a lot more.</p><h3>Learn by building</h3><p>Since this will already be a bit long, I’m not going to get into setting up Gulp in this post. There are <a href="http://andy-carter.com/blog/a-beginners-guide-to-the-task-runner-gulp">many</a> <a href="http://www.codefellows.org/blogs/quick-intro-to-gulp-js">excellent</a> <a href="http://markgoodyear.com/2014/01/getting-started-with-gulp/">introductions</a> out there already. I <em>can</em> say, you will need <a href="http://nodejs.org/">Node</a>, <a href="https://github.com/gulpjs/gulp">Gulp</a>, and probably <a href="https://www.ruby-lang.org/en/">Ruby</a>. (However, If you do run into trouble getting this going, please <a href="https://twitter.com/wtc">bug me about it</a>. I’d love to help!). Instead, I am going focus on using Gulp to setup a static site “framework.”</p><blockquote>Get excited: My current gulpfile is only 110 lines long.</blockquote><p>…that includes comments.</p><p>Now, before we get too far, it is important to understand one more thing about Gulp:</p><blockquote>One plugin for one job</blockquote><p>Similar to Grunt, Gulp has a <a href="http://gulpjs.com/plugins/">collection of plugins</a> which each serve a single focused purpose. These <em>plugins</em> can be piped together in a gulp <em>task</em> to do a more complicated job. I think you will find (as I did) that this approach is incredibly straightforward, and you need not fully comprehend the technicality of <a href="https://github.com/substack/stream-handbook">node.js streams </a>(fascinating though…) before you can start using gulp.</p><h3>Let’s build a tiny static site tool</h3><p>Here’s the checklist of what we want:</p><ul><li>Templates and partials</li><li>Sass</li><li>A preview server for development</li><li>An automated Watch that uses Livereload</li></ul><p>Our goal is to create a single gulp <em>task</em> that can do all of this at once. However, we need to create a task for each specific job first.</p><h3>Templates and partials</h3><p>As I said, Gulp <em>tasks</em> can be collections of <em>plugins</em>, but you can think of them like simple recipes. The first recipe a static site tool needs is a way to include partial html files into other template files. Ain’t no way in the ‘verse I’m repeating myself with things like nav, header, footer, etc. My recipe for this looks like:</p><ul><li>Get my template file out of this bin</li><li>Include some partial files</li><li>Rename it</li><li>Drop the new file into this other bin</li><li>Tell my browser to refresh</li><li>Notify me that this job was completed</li></ul><p>Got that? Now see if you can map that concept to the real code which executes these jobs in exactly that order:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EmlgtxaORNjhex8QGS7nbA.png" /><figcaption>Sorry Medium, I want code highlighting</figcaption></figure><p>If you aren’t familiar with this type of code, here’s the longer explanation.</p><p>The core plugin for this job is <a href="https://www.npmjs.org/package/gulp-file-include">gulp-file-include</a>. It grabs files and plops them wherever you place an @@include. In my index.tpl.html file I have stuff like:</p><pre>&lt;header&gt;<br> &lt;h1 class=&quot;nx-header&quot;&gt; Style Guidelines and Examples&lt;/h1&gt;<br> &lt;/header&gt;<br> <br> @@include(&#39;./templates/_nav.html&#39;)<br> &lt;main&gt;<br> @@include(&#39;./templates/_type.html&#39;)<br> @@include(&#39;./templates/_layout.html&#39;)</pre><pre>...etc...</pre><h4>Where are the files</h4><p>Now, first I recommend establishing your paths (telling gulp where the files are) outside of your tasks so you can easily modify your file structure.</p><pre>var paths = {<br> templates: ‘./templates/’,<br> sass: ‘css/source/’<br>};</pre><p>I follow a simple naming convention for template files to keep me from confusing them with generated output files. Any file that has a .tpl in it maps directly to an output file with the same name, minus the .tpl. If I want an <strong>index.html </strong>file, then the template for it is in /templates/ and it is named <strong>index.tpl.html.</strong></p><p>Partial files follow the standard naming convention using an underscore like <strong>_nav.html.</strong></p><h4>Naming the task</h4><pre>gulp.task(&#39;fileinclude&#39;, function() {</pre><p>This first line names the task “fileinclude” so I can call this recipe later when I want it to execute. You can name a task whatever you want: e.g. <em>coverMePorkins</em>. However, I name tasks based on what core job they do, and in this case it happens to be the name of the core gulp plugin I intend to use.</p><h4>Getting the files</h4><pre>return gulp.src(path.join(paths.templates, &#39;*.tpl.html&#39;))</pre><p>This line establishes where the file is that you want gulp to get. In this case I want all files in /templates/ that end with *.tpl.html. path.join() simply connects the first part (directory) with the second part (file-name). If you were wondering why I use path.join instead of the simple javascript: <em>paths.templates + ‘*.tpl.html’, </em><a href="http://stackoverflow.com/questions/9756567/do-you-need-to-use-path-join-in-node-js">here is a great explanation</a>. (Props to my js hacker friend <a href="https://twitter.com/ckknight">Cameron</a> for that.)</p><h4>Running gulp-file-include</h4><pre> .pipe(fileinclude())</pre><p>At the beginning of a gulpfile we have instructions on which plugins to use. Typically we store a plugin like <em>gulp-file-include</em> in an object simply called <em>fileinclude</em>. Therefore, this line of code asks the core gulp-file-include plugin to run and insert any partials in my template file.</p><h4>Renaming the template</h4><pre>.pipe(rename({<br> extname: &quot;&quot;<br> }))<br> .pipe(rename({<br> extname: &quot;.html&quot;<br> }))</pre><p>Huge shout-out to my design <a href="https://twitter.com/The_Lela">partner in crime</a> <a href="http://laurenkodai.com/">Lauren</a> for this bit. This uses a plugin called <a href="https://www.npmjs.org/package/gulp-rename">gulp-rename</a> to strip off the .tpl from index.tpl.html. The first <em>rename</em> replaces the .html extension with nothing, then the second replaces the <em>new</em> extension (now .tpl) with .html. So now we have a file just called <em>index.html</em> with my html chunks inserted into it.</p><h4>Where do you want this new file?</h4><pre>.pipe(gulp.dest(&#39;./&#39;))</pre><p>This places the generated and renamed file <em>index.html</em> into the root of my project. (As a site gets more complicated — you may want generated files to be placed someplace totally different like /dist.)</p><h4>Hey browser! Something happened!</h4><pre>.pipe(livereload(server))</pre><p>This uses <a href="https://github.com/vohof/gulp-livereload">gulp-livereload</a> to tell my browser (which is running the Livereload <a href="http://livereload.com/">extension</a>) something changed and it should refresh now that the output file has been saved.</p><h4>“We have clearance, Clarence.”</h4><pre>.pipe(notify({ message: &#39;Includes: included&#39; }));</pre><p>This uses <a href="https://www.npmjs.org/package/gulp-notify">gulp-notify</a> to inform me (This uses OSX’s notification center. If you are on a windows system you can use <a href="https://www.npmjs.org/package/gulp-notify-growl">gulp-notify-growl</a>.) that everything went down successfully.</p><p>That task is complete.</p><h3><strong>Compile Sass into CSS</strong></h3><p>Now that I have explained the <em>fileinclude</em> task, a task for compiling Sass should look pretty familiar:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7TFUJ1cYyOp2OAAiRS7jcw.png" /><figcaption>Different, but the same</figcaption></figure><p>This uses a different collection of gulp plugins, but works in exactly the same manner. The core plugin for compiling Sass is <a href="https://www.npmjs.org/package/gulp-sass">gulp-sass</a> (which uses Libsass), and you may note we pass it a couple of formatting options (e.g. style: ‘expanded’). The plugin <a href="https://www.npmjs.org/package/gulp-autoprefixer">gulp-autoprefixer</a> totally <em>pwns</em> browser prefixing so I don’t have to worry about that in my Sass files. The task outputs into my /css directory, tells the browser to reload, and again, messages me that it worked.</p><h3>A simple server for previewing</h3><p>We definitely want a quick way to look at what we are building. For this I use a server plugin called <a href="https://www.npmjs.org/package/gulp-connect">gulp-connect</a>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/740/1*0jbeHwG_CVOTx7SX_pfMEQ.png" /><figcaption>Port 1337…really? What kind of dorky nerd…oh yeah. We are talking about programming. nm.</figcaption></figure><p>This task is simply called <em>connect</em>, and it will serve up whatever files you target from your project to <a href="http://localhost:1337/">http://localhost:1337</a>. Of course you can serve your stuff to whatever port number you choose. I can’t totally remember, but I think I disabled livereload for this task because I was having trouble getting it to work the way I wanted — and I ended up calling it in my <em>watch</em> task later. Speaking of…</p><h3>A watch task</h3><p>Where normal tasks run on command and stop when finished, the point of a watch task is to run constantly, <em>watching</em> for changes to certain files (e.g. Saving a Sass file) and then kick off other tasks, such as the ones we have already created. Having a solid watch task can greatly increase the efficiency of your workflow. Why waste time manually running tasks or reloading your browser when you can automate?</p><p>My watch task has two parts, because I prefer to use Libsass, but certain features of Sass 3.3.4 are not fully implemented. In <a href="https://gist.github.com/andrewdc/10659265">my project</a> I have another task called <em>rubysass</em> which uses Ruby to compile. At this point I want to be able to use either as needed. This is a great demonstration of the power of Gulp since you can write straight Javascript. Rather than have two nearly identical watch tasks, I create a <em>function</em> and pass it which Sass compile task to use:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3z9ik7kMIZMh9mK33Qjnag.png" /><figcaption>I can pass in different tasks to this watch function. One uses Ruby Sass, one uses Libsass.</figcaption></figure><pre>function watchStuff(task) {</pre><p>First I name the function and give it a way to pass in the Sass compile task I want.</p><h4>Livereload</h4><pre> server.listen(35729, function (err) {<br>  if (err) {<br>   return console.error(err) <br>  };</pre><p>Then <em>server </em>refers to a node plugin for live reload called <a href="https://www.npmjs.org/package/tiny-lr">tiny-lr</a>. We tell <em>server </em>what port to listen on (35729 is the Livereload default) and allow for errors to be reported to the console.</p><h4>Watch what? Do what?</h4><pre> //Watch task for sass<br> gulp.watch(path.join(paths.sass, &#39;**/*.scss&#39;), [task]);</pre><p>A gulp.watch typically works like:</p><ol><li>What do you want me to watch?</li><li>What do you want me to do when I see something happen?</li></ol><p>First I watch my Sass directory for any changes to files that end with .scss. When detected — we run the [task] that is passed into the function (Libsass or Ruby Sass).</p><pre> // watch task for gulp-file-include<br> gulp.watch(path.join(paths.templates, &#39;**/*.html&#39;), [&#39;fileinclude&#39;]);</pre><p>The second watch listens for changes to files in my templates directory, and runs the <em>fileinclude</em> task we wrote at the beginning when it detects a change.</p><p>Note that I am not doing anything in my watch function but running other tasks. In the spirit of <em>one tool for one job, </em>I like to keep my functions and tasks fairly focused.</p><p>Lastly, we need to create two other tasks that tell my <em>watchStuff </em>function which Sass compile task I want my to use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/1*HPtFpHNKTpwPZKh3-AFvAw.png" /><figcaption>My default task is Libsass because I would like to use it as soon as it is updated. My alternate uses Ruby Sass.</figcaption></figure><p>The first task, just called <em>watch </em>runs the <em>watchStuff</em> function and passes in the Sass task we wrote above. The <em>rubywatch </em>runs another similar task (I haven’t shown here) that simply uses a different Sass compiler.</p><h3>Do all the things</h3><p>All of these tasks are great, but as I said in the beginning, we really don’t want to have to run each of them separately every time we want something done. Let’s create a master task to kick off our other tasks for us.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8J4_7UQDzW8z4PHhBKNcPg.png" /><figcaption>Default to the most common and most useful collection of tasks.</figcaption></figure><p>It is always a good idea to have a default gulp task. This is the task which runs by simply entering <em>gulp </em>without any taskname<em>. </em>I set my most commonly used tasks as my default. Therefore, I start by running the <em>fileinclude</em> task first to make sure the latest html changes are rendered. Next I do the same with my Sass files. After that I start up my preview server at <a href="http://localhost:1337/">http://localhost:1337</a> with <em>connect. </em>Finally I kick off my default <em>watch </em>which will start Livereload and continue to automatically run my <em>fileinclude</em> and <em>sass</em> tasks.</p><p>My alternate task is nearly identical but is called <em>useruby</em> and runs my <em>rubywatch</em> instead. Since it isn’t the default, it is run with:</p><pre>gulp useruby</pre><p>Any tasks we have created can be run in this fashion. For example, If you simply need a one time Sass compile you could run:</p><pre>gulp sass</pre><p>And with that, we have basically all the things that I use on a day to day basis to build stuff quickly and efficiently.</p><h3>We are just getting started</h3><p>As you might have guessed, there are <a href="http://markgoodyear.com/2014/01/getting-started-with-gulp/">many more things</a> that Gulp can do. (I mentioned Jade before, and you can easily write a task to wrangle jade files) I’m certainly no expert, so this has been a fun learning experience for me as well. As a tool, I am continually adding and refactoring my gulpfile (feel free to view/steal what I currently have <a href="https://gist.github.com/andrewdc/10659265">in this gist</a>. ) to do more things. At some point I intend to create a tiny vanilla package out of this tool that can help me and others quickly get a site up and running.</p><p>I can say I have been impressed with how simply I (designer, remember…) can get Gulp to do what I want. The code is <em>not</em> obscure or arcane and I love that I can easily write tasks to do exactly the jobs I need.</p><p>I think it is worth your time to give it a shot. If you run into problems, or have ideas and suggestions, <a href="https://twitter.com/wtc">drop me a line</a>. I would love to hear other people’s experiences using Gulp.</p><p>-adc</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2fd5f9821fc4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Your application is like a ballet performance]]></title>
            <link>https://medium.com/@72lions/your-application-is-like-a-ballet-performance-f404f4f83311?source=rss----27eafcee5d9c---4</link>
            <guid isPermaLink="false">https://medium.com/p/f404f4f83311</guid>
            <dc:creator><![CDATA[Thodoris Tsiridis]]></dc:creator>
            <pubDate>Tue, 24 Mar 2015 16:21:37 GMT</pubDate>
            <atom:updated>2014-06-25T15:46:49.636Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w54ZcnFW2n__ddtFj1u7mg.jpeg" /></figure><h4>Why all developers who build user interfaces should understand motion design.</h4><p>A lot of developers might disagree with me but it is my belief that if you are a developer who is building user interfaces, you should understand and respect motion design.</p><p>When we add transitions and animations to our UI components, we are doing it for a few different reasons. Some of them are:</p><ul><li>Guide the user’s eye and attention.</li><li>Create a feeling of continuation of where you were and where you are going.</li><li>Explain possible interaction.</li><li>Apply physical characteristics to our objects.</li><li>Appeal.</li></ul><p>Whenever I think about motion design in UIs I imagine a ballet performance. Your view is the stage and your buttons, titles, images etc are your performers.</p><p>Like in a ballet, every performer has a role to play. They exists inside the stage. But also every performer needs to appear at the right time so that there is a flow that the audience can follow.</p><p>Now, imagine that you go to see a ballet and all performers walk onto the stage, just stand there and then they just leave. Boring right?</p><p>But, what if those dancers would gracefully come onto the stage? Wouldn’t that be less boring and a bit more beautiful?</p><p>OK, the performance begins. Suddenly all the performers at the same time appear on the stage and they start dancing. The audience probably won’t know where to focus. More importantly the performance starts to feel chaotic and not graceful.</p><p>That leads me to my next point; timing is everything. For me timing means two things:</p><ul><li>How fast something should happen.</li><li>When should it happen.</li></ul><p>When performers appear on the stage, they usually do it in a specific order and manner so that the audience can keep up with what is going on and follow the story. Also the speed of which a performer is moving and dancing gives specific characteristics to that person. For example, if a performer is moving fast then we get a feeling of urgency, importance. You should try to apply the same rules everywhere in your application.</p><p>Another important thing is how we interact with our UI components. You should think of a button as a performer. You wouldn’t want to interact with different performers and have them do nothing, right? By creating a UI component that reacts to the way you interact with it, we give it physical characteristics and we help the user understand what to expect from that component. Plus we make it more interesting and appealing.</p><p>Finally, every performer has some physical characteristics. Each one has a size, mass, friction etc, and all of them affect the way it moves and behaves on stage. Same applies for your components. Next time you want to animate a UI component, think about these characteristics and how they will affect the animation.</p><p>We should all try and bring to life our applications. Always think of every button, image etc as a living organism with physical characteristics that the user can interact with. Build interesting organisms that help the user understand how to interact with your application. Use these organisms to guide the attention of the user and don’t forget to have fun while doing so!</p><p>If you like to learn more about design in motion then you can have a look at the following resources:</p><ul><li><a href="http://www.ui-transitions.com/#categories">http://www.ui-transitions.com/#categories</a></li><li><a href="http://www.smashingmagazine.com/2012/10/30/motion-and-animation-a-new-mobile-ux-design-material/">http://www.smashingmagazine.com/2012/10/30/motion-and-animation-a-new-mobile-ux-design-material/</a></li><li><a href="http://www.slideshare.net/antoniodepasquale/design-in-motion-the-new-frontier-of-interaction-design">http://www.slideshare.net/antoniodepasquale/design-in-motion-the-new-frontier-of-interaction-design</a></li></ul><p>For inspiration:</p><ul><li><a href="http://marcus-experiments.tumblr.com/">http://marcus-experiments.tumblr.com/</a></li><li><a href="http://the12principles.tumblr.com/">http://the12principles.tumblr.com/</a></li><li><a href="http://littlebigdetails.com/">http://littlebigdetails.com/</a></li><li><a href="http://motiongraphics.nu/">http://motiongraphics.nu/</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f404f4f83311" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Aligning type to baseline the right way using SASS]]></title>
            <link>https://medium.com/@razvanonofrei/aligning-type-to-baseline-the-right-way-using-sass-e258fce47a9b?source=rss----27eafcee5d9c---4</link>
            <guid isPermaLink="false">https://medium.com/p/e258fce47a9b</guid>
            <dc:creator><![CDATA[Razvan Onofrei]]></dc:creator>
            <pubDate>Mon, 14 Apr 2014 16:22:49 GMT</pubDate>
            <atom:updated>2016-09-22T14:53:31.383Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yALlUpRb5FYZKfR5v1vYbg.jpeg" /></figure><h4>Vertical rhythm is one thing; baseline is another.</h4><p>Typography is an important part of web design nowadays and free services like Google Web Fonts or Adobe’s Typekit make custom fonts on the web a commodity.</p><p>Let’s take it slow and start with a core principle of typography, <strong>vertical rhythm</strong>. Vertical rhythm is about spacing body text or, more generally, vertical stacked elements, in a consistent manner to give structure and hierarchy to your content.</p><p>Some use the body text’s line-height as the measuring unit for the vertical rhythm. But using half of this value is a better choice because it can give you more reliability on automatic calculation of <strong>line-height</strong> for different font sizes using mixins.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*DEM9DfEm5dQE46r3kolcxA.png" /><figcaption>vertical rhythm</figcaption></figure><p>The <strong>baseline</strong> on the other hand implies that content spread in multiple columns is horizontally aligned.</p><p>These two key principles will always ensure your content with structure, hierarchy, and consistency, and make your body text more readable (concepts like optimal line length, modular scale or white-space are not the subject of this article).</p><p>Even though vertical rhythm and baseline grids are fundamental in print, the way the web evolved made these concepts unknown or not fully understood by a big part of the web designers/developers out there. If you want to get deeper in understanding these principles you can check out <a href="http://www.smashingmagazine.com/2012/12/17/css-baseline-the-good-the-bad-and-the-ugly/">this awesome article</a> on Smashing Magazine (also check the resources at the bottom of the article).</p><p>The article on Smashing takes you through each and every step of understanding and implementing a baseline grid in your site. Setting a vertical rhythm shouldn&#39;t be very hard. There are many tools out there that can even generate the CSS for setting your vertical rhythm on the scale you choose.</p><blockquote>The baseline is the imaginary line upon which a line of text rests.</blockquote><p>There is one problem with most of these tools: they bring the <strong>baseline </strong>concept into discussion without really tackling the problem.</p><p>In typography, the baseline is the imaginary line upon which a line of text rests. And it has to be aligned with the grid we use for establishing our vertical rhythm. That’s it.</p><p>But here comes the tricky part. We all know how <em>line-height </em>works and that the text will always be vertically aligned to its middle, NOT to the baseline.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*D1yG96Jd4i0cyvcIPGtSnQ.png" /><figcaption>line-height behavior</figcaption></figure><p>We have to find a consistent way of shifting every bit of text the exact amount it needs to get to the baseline, and also not to break the vertical rhythm of the other elements on the page.</p><p>You may say “Well… that’s easy!”. You just need to subtract the <strong>font size</strong> from the <strong>line height</strong>, divide it by two and move the text downwards by that amount. That may be true but not quite. There is a catch: <strong>font size</strong> is not the same with the <strong>cap height</strong>.</p><blockquote>In typography, cap height refers to the height of a capital letter above the baseline for a particular typeface.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*Evl1-1IJzcH9aWu-cjGa0w.png" /><figcaption>Visual explanation of the cap-height</figcaption></figure><p>Now the math wouldn&#39;t be that hard. But we can’t really know what the <strong>cap height </strong>is. That means we have to find that value by trial and error. If you’re lucky you may find info on the <strong>em unit </strong>and <strong>cap height </strong>of a specific font on the web. But for most fonts you’ll have to guess or measure it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*aR7f1upZB6mNHaFQ4zTBKg.png" /><figcaption>desired outcome</figcaption></figure><p>So, how do we find out the distance we need to shift the text down with? The cap-height will always be the same relatively to the font-size.</p><blockquote>font-size * (line-height - cap-height) / 2</blockquote><p>Now that we have that value, we need to move the text downwards. There are two ways of doing it. We can do this by setting <strong>position: relative</strong> on every element and then set the <strong>top</strong> property to our amount. By using position: relative we ensure that moving a bit of text downwards doesn&#39;t break the vertical rhythm of the other elements on the page. I don’t really like this approach, but if your page is pretty simple, without complicated design elements you can go with this one.</p><p>A better way to do it is by using the <strong>padding-top</strong>. This would break the vertical rhythm for the elements below the one we’re working on, so we need to find a way to avoid that. We could set <strong>margin-bottom </strong>to the negative value of the padding to compensate it, and use padding-bottom, or border-bottom to put some space between it and the element below.</p><p>Harry Roberts wrote an article some time ago on <a href="http://csswizardry.com/2012/06/single-direction-margin-declarations/">single-direction margins declaration</a> and vertical rhythm that is worth taking a look at. Using his approach you can subtract the amount you need from the margin-bottom, and move it to padding-top.</p><p>Let’s imagine a simple scenario to test this out. I’ll define my sizes in pixels, but remember that preferably, the line-height and cap-height will be unit-less values relative to the font-size.</p><blockquote>font-size = 16px;<br>line-height = 24px (1.5);<br>cap-height = 12px (0.75);</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*X6DXV9nN5pmKVfC2Is6NFQ.png" /></figure><p>This means that we need to move the text down by 6px. And assuming that all your elements have a declared margin-bottom value of 24px, you need to set <strong>padding-top </strong>to<strong> 6px</strong> and overwrite the <strong>margin-bottom</strong> value to <strong>18px</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*Bh-p7oqCv1WBXxmje9qRYA.png" /></figure><p>These are pretty meticulous calculation and you may not fancy doing them each and every time you need to set font-size to an element. Here’s where SASS comes in to place. Using SASS you can automate this and not have to worry about vertical rhythm or baseline when you’re developing. You still have to find that cap-height to font-size ratio for each font you use, but that’s the easy part.</p><p>I&#39;ve created <a href="https://gist.github.com/razwan/10662500">this Gist</a> with the <em>mixin</em> you can use to set your body text to a baseline grid. You can always add some <a href="http://www.sitepoint.com/css3-rem-units/"><strong>rem</strong></a> flavor to your declarations (not only for text, but for margins and padding also), and also a way to align your font sizes to a modular scale but that’s up to you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e258fce47a9b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>