<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Simon Vrachliotis 🏄🏀💻😍</title>
    <description>The latest articles on DEV Community by Simon Vrachliotis 🏄🏀💻😍 (@simonswiss).</description>
    <link>https://dev.to/simonswiss</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F131220%2Fdfc19a0e-e000-4c91-a138-af6ee95021b9.jpg</url>
      <title>DEV Community: Simon Vrachliotis 🏄🏀💻😍</title>
      <link>https://dev.to/simonswiss</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/simonswiss"/>
    <language>en</language>
    <item>
      <title>Full re-write in 10 days with tachyons and functional CSS: A case study (Part 4)</title>
      <dc:creator>Simon Vrachliotis 🏄🏀💻😍</dc:creator>
      <pubDate>Fri, 02 Aug 2019 22:20:48 +0000</pubDate>
      <link>https://dev.to/simonswiss/full-re-write-in-10-days-with-tachyons-and-functional-css-a-case-study-part-4-4b11</link>
      <guid>https://dev.to/simonswiss/full-re-write-in-10-days-with-tachyons-and-functional-css-a-case-study-part-4-4b11</guid>
      <description>&lt;h3&gt;
  
  
  This is the final chapter of a 4-post series, taking you through a website refactoring process using &lt;a href="https://tachyons.io"&gt;tachyons&lt;/a&gt;.
&lt;/h3&gt;

&lt;h3&gt;
  
  
  On the menu
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://dev.to/simonswiss/full-re-write-in-10-days-with-tachyons-and-functional-css-a-case-study-part-1-3dkm"&gt;Why re-write in the first place?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/simonswiss/full-re-write-in-10-days-with-tachyons-and-functional-css-a-case-study-part-2-2opg"&gt;What even is functional CSS?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/simonswiss/full-re-write-in-10-days-with-tachyons-and-functional-css-a-case-study-part-3-1k4"&gt;The refactoring process, step by step&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The aftermath: key learnings and recommendations&lt;/strong&gt; (you are here! 👋)&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Chapter 4: The aftermath - key learnings and recommendation
&lt;/h2&gt;

&lt;p&gt;In this final post, I try to share some insights about things I have learned throughout the refactoring process. Things I learned while working with functional CSS and hanging around this specific ecosystem.&lt;/p&gt;

&lt;p&gt;I'll start by addressing a few doubts or pain points that people seem to have quite often.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. How do you deal with the repeating classes and overwhelming, "ugly" HTML markup?
&lt;/h2&gt;

&lt;p&gt;Nobody likes to type the same classes over and over, or copy/paste things around. Besides being time consuming, it's the opposite of being DRY. It can put you in a world of pain when you decide to make some global changes to your UI.&lt;/p&gt;

&lt;h3&gt;
  
  
  Template abstractions to the rescue.
&lt;/h3&gt;

&lt;p&gt;When working with functional CSS, I strongly recommend you bring a templating language of some kind to your workflow. It makes a world of difference.&lt;/p&gt;

&lt;p&gt;As soon as you find a repetitive class pattern - and trust me, you will! - abstract it away in a variable. I like to refer to this process as the creation of "&lt;strong&gt;class combo&lt;/strong&gt;" helpers.&lt;/p&gt;

&lt;h3&gt;
  
  
  Show me how!
&lt;/h3&gt;

&lt;p&gt;Let's take some code straight from the &lt;a href="http://tachyons.io/"&gt;tachyons.io&lt;/a&gt; component library section.&lt;/p&gt;

&lt;p&gt;The component in question is a "contact list" and looks like so:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--e9IgLTyn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/y36eo0fnjwfnucur5ojv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--e9IgLTyn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/y36eo0fnjwfnucur5ojv.png" alt="Contact list UI component from the Tachyons.io website"&gt;&lt;/a&gt;&lt;/p&gt;

Contact List from the tachyons component library




&lt;p&gt;Let's have a look at the raw HTML + tachyons markup. Yes, it may look ugly to you:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;





&lt;blockquote&gt;
&lt;p&gt;Whoaaaa. My eyes!!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;There are a lot of classes here. Trust me, &lt;strong&gt;there can be many more&lt;/strong&gt;, depending on what you're building.&lt;/p&gt;

&lt;p&gt;Assuming we may use this component in multiple places across our project, we have many good reasons to want to make this HTML cleaner and modular.&lt;/p&gt;

&lt;h2&gt;
  
  
  Building class combos.
&lt;/h2&gt;

&lt;p&gt;Time to abstract away some of that repetitive markup.&lt;/p&gt;

&lt;p&gt;You can do this with any templating language of your choice. In this case, I'll use &lt;a href="https://twig.symfony.com/"&gt;Twig&lt;/a&gt;, since this was the language used during the refactoring. If you don't know Twig, you should still be okay to follow.&lt;/p&gt;

&lt;p&gt;Don't worry too much about the syntax, focus on the concepts.&lt;/p&gt;

&lt;p&gt;Deciding what classes to abstract away is a whole other topic, which I'll touch on later. For now we'll just take the &lt;em&gt;relatively long&lt;/em&gt; class combinations and store them within a &lt;strong&gt;combo&lt;/strong&gt; &lt;em&gt;object&lt;/em&gt;:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;This allows us to output the long string wherever we want by reaching for the object property, like so:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;li class="{{ combo.listItem }}"&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Let's implement that in our HTML:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;





&lt;blockquote&gt;
&lt;p&gt;What?! Isn't that besides the point? You just lost the declarative aspect of functional CSS!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Hold your thoughts for a second. Let me clean this code up a bit more and then address this very valid point.&lt;/p&gt;

&lt;p&gt;This next step is not related to functional CSS, but is a good idea to implement whenever working with repeating blocks of HTML.&lt;/p&gt;

&lt;p&gt;We can clearly see a repeating pattern within each &lt;code&gt;&amp;lt;li&amp;gt;&lt;/code&gt; element. Let's fix that by first extracting the &lt;strong&gt;data&lt;/strong&gt; from the markup.&lt;/p&gt;

&lt;p&gt;I'll set an array of contacts like so:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;





&lt;p&gt;We can now rewrite our entire component in a pretty compelling loop that outputs one block of HTML for each index in the contacts array, making the code much tighter, readable:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;





&lt;blockquote&gt;
&lt;p&gt;Well done, champ. You've just recreated semantic classes. Way to chase your own tail! 😒&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ywd0WAtD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/7du9dj5otvfa3cdycn0c.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ywd0WAtD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/7du9dj5otvfa3cdycn0c.gif" alt="Cat chasing its own tail in circles"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You are right. We went full cycle. Why not just write semantic class names in the first place?&lt;/p&gt;

&lt;p&gt;Well, while the HTML now looks somewhat similar to what you would get with a regular CSS approach, there is a &lt;strong&gt;huge difference&lt;/strong&gt; in the way the styles are applied.&lt;/p&gt;

&lt;p&gt;Instead of styling my &lt;code&gt;listItem&lt;/code&gt; with its own CSS declarations, the styles are composed from multiple helper classes. I can create dozens, hundreds of components with this method, &lt;strong&gt;without having to write a single extra line of CSS&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;This is still functional CSS under the hood.&lt;/p&gt;




&lt;h2&gt;
  
  
  Trade-offs, again.
&lt;/h2&gt;

&lt;p&gt;This technique is definitely not a silver bullet. Like everything you do in web development, you need to be evaluating &lt;em&gt;trade-offs&lt;/em&gt; and see what works best for you.&lt;/p&gt;

&lt;p&gt;Here's a mini break down of trade-offs I can think of with this abstraction technique:&lt;/p&gt;

&lt;h3&gt;
  
  
  Pros
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;makes code cleaner, faster to write&lt;/li&gt;
&lt;li&gt;improve consistency, using same styling in multiple places&lt;/li&gt;
&lt;li&gt;greatly improves ease of global modifications. Change in one place, update everywhere&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Cons
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;takes away the declarative nature of style classes&lt;/li&gt;
&lt;li&gt;somewhat couples classes together, killing some of the "one-thing-only" ideology (I learned the hard way!)&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Lesson learned with class combo abstraction
&lt;/h2&gt;

&lt;p&gt;I fell in love with this technique. It gave me the power of building web components that are self-contained, highly reusable and consistent.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In the excitement, I possibly went a bit overboard, and got a bit too "abstraction-happy".&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Looking back, here's a rule of thumb that could be very useful to you, if you're going down that route:&lt;/p&gt;

&lt;h2&gt;
  
  
  Don't abstract the outside vertical spacing!
&lt;/h2&gt;

&lt;p&gt;In other words, feel free to abstract away the &lt;em&gt;background-colour, border-radius, padding&lt;/em&gt; of a given module, but leave things like margin-bottom out of the equation.&lt;/p&gt;

&lt;p&gt;Same for a headline. Abstract things like &lt;em&gt;font-size, line-height&lt;/em&gt; but don't you touch the vertical padding / margin around it.&lt;/p&gt;

&lt;p&gt;See my example below if this is not clear.&lt;/p&gt;

&lt;h2&gt;
  
  
  What about consistent vertical rhythm?
&lt;/h2&gt;

&lt;p&gt;Even if you feel like the bottom margin is part of the module and should be consistently applied, it somehow belongs "outside" the module. And should be treated separately.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You'll run into edge cases where you need to display the same module without a bottom margin, because of the specific context you're trying to display it in.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You could override your margins by applying different margins before your combo, but that's starting to get messy.&lt;/p&gt;

&lt;p&gt;This lead me to a fair amount of refactoring. I ended up removing vertical spacing from my go-to style combos, and started applying them &lt;strong&gt;in addition&lt;/strong&gt; to the class combo.&lt;/p&gt;

&lt;h3&gt;
  
  
  Here's what it looks like
&lt;/h3&gt;

&lt;p&gt;In the below example, the &lt;em&gt;margin-top&lt;/em&gt; and &lt;em&gt;margin-bottom&lt;/em&gt; are "hard-coded" within the combo:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Instead, I suggest you leave these margins outside of the combo:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;





&lt;p&gt;That's a good example of a good trade-off balance. We keep a degree of modularity / composition, while abstracting away the majority of the repeating classes. I could leverage my combo class in two different scenarios, and it's quite readable and declarative.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. How do you customise tachyons?
&lt;/h2&gt;

&lt;p&gt;There is an important concept to grasp: tachyons is not an "all or nothing" solution. It's not a UI framework like &lt;a href="https://getbootstrap.com/"&gt;Bootstrap&lt;/a&gt; or &lt;a href="https://foundation.zurb.com/"&gt;Foundation&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Tachyons is a systematic, consistent methodology to write functional CSS classes. In that sense, it is virtually infinitely flexible.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Tachyons proposes a consistent naming convention, and encourages you to follow the lead.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Here are a two important things you need to know when working with tachyons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You can and should turn off the parts you don't need, extend the parts you want to push further.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;There is no right or wrong way of extending tachyons - the key is to understand the implications of whatever method you choose to adopt.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The way I did it.
&lt;/h2&gt;

&lt;p&gt;After some good amount of thinking and tinkering, I decided to &lt;strong&gt;not touch any of the core tachyons files&lt;/strong&gt;. Even if the author of the library invites you to dig into it and "make it your own".&lt;/p&gt;

&lt;p&gt;Why? This makes sure implementing updates is never an issue.&lt;/p&gt;

&lt;p&gt;Instead, I opted to create a &lt;code&gt;tachyons-extend&lt;/code&gt; folder that I load after the core tachyons modules. Here's what my Sass pipeline looks like (I am using the &lt;code&gt;tachyons-sass&lt;/code&gt; version of the toolkit, which also exists in different flavours).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IorwFV8A--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/6ed99yhjwfqur6aj530i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IorwFV8A--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/6ed99yhjwfqur6aj530i.png" alt="Screenshot of CSS file imports"&gt;&lt;/a&gt;&lt;/p&gt;

The pipeline setup. I never customise the core tachyons files.




&lt;p&gt;In &lt;code&gt;tachyons-extend&lt;/code&gt;, I can write brand new tachyons-like modules for areas of the CSS spec that are not (yet) covered by the toolkit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Extending a module
&lt;/h2&gt;

&lt;p&gt;In some cases, I just want to extend a core module. An example is the &lt;code&gt;max-widths&lt;/code&gt; module, where we needed more flexibility.&lt;/p&gt;

&lt;p&gt;I created a file with the same name in my &lt;code&gt;tachyons-extend&lt;/code&gt; folder, and just added more declarations following the same naming convention:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EKQvFMTj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/93luduqctb9o3splicv2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EKQvFMTj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/93luduqctb9o3splicv2.png" alt="Screenshot of CSS code for the max-width classes"&gt;&lt;/a&gt;&lt;/p&gt;

Extending the `max-widths` module.




&lt;p&gt;As a result, I can access any class of the core &lt;code&gt;max-widths&lt;/code&gt; module, as well as the extensions I created, without ever touching the core code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Rewriting a module
&lt;/h2&gt;

&lt;p&gt;Sometimes, a specific module is needed doesn't really do what you need, or does too much. Extending on top of it doesn't make sense in that context.&lt;/p&gt;

&lt;p&gt;When that happens, I usually comment that module out in the core pipeline, and recreate a custom version of it in my extend folder.&lt;/p&gt;

&lt;p&gt;I have done this for the &lt;code&gt;box-shadows&lt;/code&gt; module - which styles I mostly didn't plan to use, but still needed box-shadow helpers:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PN1IaGsh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/rrk2k392748s2i5elkvn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PN1IaGsh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/rrk2k392748s2i5elkvn.png" alt="Screenshot of CSS code for the box shadow classes"&gt;&lt;/a&gt;&lt;/p&gt;

The core `box-shadows` module, not needed.

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--i8gr89Wp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/hvneotwesfbqb3bz789z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--i8gr89Wp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/hvneotwesfbqb3bz789z.png" alt="Screenshot of commenting out a CSS import"&gt;&lt;/a&gt;&lt;/p&gt;

The module is commented out in the core pipeline.

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--A1CSfLe9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/jqs8x43rhdlu3lggm272.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--A1CSfLe9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/jqs8x43rhdlu3lggm272.png" alt="Screenshot of custom shadows CSS code"&gt;&lt;/a&gt;&lt;/p&gt;

A custom `tachyons-extend/box-shadow` module is created.

&lt;p&gt;Again, I modify the behaviour / usability of tachyons, without touching any of the core files. The only &lt;em&gt;modification&lt;/em&gt; I do is comment out some partials in the master tachyons file.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. What about good ol' regular, non-functional CSS?
&lt;/h2&gt;

&lt;p&gt;This is one thing that often confuses people. There are many discussions about this around functional CSS.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Let's make it clear: functional CSS does not prevent you from writing regular CSS in parallel.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It is absolutely okay to write non-functional CSS styles. Actually, there will probably be places where you need to.&lt;/p&gt;

&lt;p&gt;Tachyons doesn't really impose anything on you. All it tries to do is give you ways to avoid repetition and limit the creation of custom CSS to a very small minimum.&lt;/p&gt;

&lt;h2&gt;
  
  
  Write your own CSS when needed. But keep this in mind:
&lt;/h2&gt;

&lt;p&gt;Specificity is almost non-existant in functional CSS. By design. It's a &lt;strong&gt;feature&lt;/strong&gt; of the system.&lt;/p&gt;

&lt;p&gt;But is also has an implication. You need to think critically before write any custom CSS. The minute you bring a degree of specificity, you'll start overriding your functional classes.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If you know exactly what you're doing and why you want global styles in specific areas, by all means go ahead.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It's up to you to find the right balance of global CSS and functional classes that works best with your system. &lt;strong&gt;Trade-offs&lt;/strong&gt;, again.&lt;/p&gt;




&lt;p&gt;Pfeeew, that was a lot! Hopefully you're not asleep yet.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7NZAmNIp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/zkf86qzuyckop6y7o6sz.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7NZAmNIp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/zkf86qzuyckop6y7o6sz.gif" alt="GIF of a kitten falling asleep while sitting"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We're almost there. The last thing I want to share with you is answering the two questions: Would you do it all over again? What would you do differently?&lt;/p&gt;




&lt;h2&gt;
  
  
  Would I do it all over again?
&lt;/h2&gt;

&lt;p&gt;To say the least, this refactoring was a bit of a gamble.&lt;/p&gt;

&lt;p&gt;I did spend some time reasoning about the benefits of using tachyons before going ahead, but certainly not long enough to foresee some major problems it might lead us to.&lt;/p&gt;

&lt;p&gt;As mentioned in my introduction, &lt;strong&gt;refactoring was not an option&lt;/strong&gt;. There is only so much a human brain can cope with.&lt;/p&gt;

&lt;p&gt;Would I do it again? &lt;strong&gt;Absolutely&lt;/strong&gt;. I am yet to hit a wall or reach a point where I see my handle on the codebase slip away. I feel like I can take any BAU or new design and implement it very quickly without adding much complexity, if any.&lt;/p&gt;

&lt;p&gt;Learning tachyons classes can be done in a weekend. Once you master them, building stuff is so straightforward it straight-up feels like a joke. Bringing a team up to speed with a tachyons codebase is as smooth as it can get.&lt;/p&gt;

&lt;h2&gt;
  
  
  What would I do differently the second time?
&lt;/h2&gt;

&lt;p&gt;Here's an important bit of advice for you. This is probably the biggest mistake I made in the entire process:&lt;/p&gt;

&lt;h3&gt;
  
  
  Build mobile-first components, from the get go. Don't wait.
&lt;/h3&gt;

&lt;p&gt;When working with functional CSS, you're spending 99% of your time in HTML. You're productivity is incredibly high, because your brain doesn't need to handle any context switching between markup and stylesheet.&lt;/p&gt;

&lt;p&gt;You stay in the same file, lock in and get stuff done.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You're working so fast, it becomes far too easy to get caught in the "let's build it on desktop first, then go through it again at different breakpoints" approach.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Making this mistake lead me to a fair amount of time going through the entire website again on mobile, doing tweaks everywhere.&lt;/p&gt;

&lt;p&gt;And here's the real twist: &lt;strong&gt;tachyons is written in a mobile-first architecture&lt;/strong&gt;. Base class names apply to everything - and mobile by default. Extended, responsive class names for larger screens override the base classes, by design.&lt;/p&gt;

&lt;p&gt;They are not more specific, they are just &lt;em&gt;loaded after the base classes&lt;/em&gt; in each module, and therefore win the battle by "just enough".&lt;/p&gt;

&lt;h2&gt;
  
  
  Why is this such a big deal?
&lt;/h2&gt;

&lt;p&gt;Say you've used a consistent vertical spacing of &lt;code&gt;mv5&lt;/code&gt; across the site, between sections.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;mv5&lt;/code&gt; class applies vertical margins like so:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.mv5&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;margin-top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;8rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;margin-bottom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;8rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You build the whole desktop site thinking it's a good vertical rhythm base for your project.&lt;/p&gt;

&lt;p&gt;Later, you look at it on mobile and realise that in this context, this vertical spacing is &lt;strong&gt;way too big&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The thing is you cannot override that class with a mobile-specific class. You need to do it the other way around (there are valid reasons for that).&lt;/p&gt;

&lt;p&gt;You need to transform the classes in all the places where you used &lt;code&gt;mv5&lt;/code&gt; to something that declares the mobile spacing first, then modifies that spacing on bigger screens.&lt;/p&gt;

&lt;p&gt;You go from:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;section&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"mv5"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    ...
&lt;span class="nt"&gt;&amp;lt;/section&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;to:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;section&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"mv4 mv5-ns"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    ...
&lt;span class="nt"&gt;&amp;lt;/section&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We now apply a vertical margin of &lt;em&gt;level 4&lt;/em&gt; on the modular scale for mobile, and &lt;em&gt;level 5&lt;/em&gt; for the &lt;strong&gt;not-small&lt;/strong&gt; breakpoint and up.&lt;/p&gt;

&lt;p&gt;The CSS output would be equivalent to this:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;section&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;margin-top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;4rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;margin-bottom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;4rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;@media&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;min-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;40rem&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;  
    &lt;span class="nt"&gt;section&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nl"&gt;margin-top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;8rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nl"&gt;margin-bottom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;8rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;






&lt;p&gt;Such a small change doesn't seem like a big deal. &lt;strong&gt;At large scale, it will be&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If you effectively wrote the entire desktop site in &lt;strong&gt;mobile&lt;/strong&gt; classes, you're up for some refactoring to transform your code to responsive.&lt;/p&gt;

&lt;p&gt;Again, the use of templates and re-usable components can limit the damage of this mistake to a minimum.&lt;/p&gt;

&lt;p&gt;But here's a good final lesson. &lt;strong&gt;Think mobile-first, right away&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Closing words
&lt;/h2&gt;

&lt;p&gt;If you've been reading all along up to this point, &lt;strong&gt;congratulations and thank you&lt;/strong&gt;!&lt;/p&gt;

&lt;p&gt;I hope that throughout this series, I was able to make a case for the valid benefits of using a library like tachyons.&lt;/p&gt;

&lt;p&gt;If anything, take this as a real-life case study of what I'd call a successful website refactoring. Ever since we moved to tachyons, I feel like I have a real cognitive grasp on the codebase, and am able to handle day-to-day business requests and changes with incredible ease.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Functional CSS is not a fit for every taste and every team. In our particular context, I personally found it to be bringing an incredible amount of benefits, without showing any signs of major drawbacks.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you're aware of a huge drawback of functional CSS I failed to discover up to now, I'd love to hear about it.&lt;/p&gt;

&lt;p&gt;Let's start a discussion!&lt;/p&gt;

</description>
      <category>css</category>
      <category>bem</category>
      <category>utilityclasses</category>
      <category>atomiccss</category>
    </item>
    <item>
      <title>Full re-write in 10 days with tachyons and functional CSS: A case study (Part 3)</title>
      <dc:creator>Simon Vrachliotis 🏄🏀💻😍</dc:creator>
      <pubDate>Fri, 02 Aug 2019 21:36:27 +0000</pubDate>
      <link>https://dev.to/simonswiss/full-re-write-in-10-days-with-tachyons-and-functional-css-a-case-study-part-3-1k4</link>
      <guid>https://dev.to/simonswiss/full-re-write-in-10-days-with-tachyons-and-functional-css-a-case-study-part-3-1k4</guid>
      <description>&lt;h3&gt;
  
  
  This is the third chapter of a 4-post series, taking you through a website refactoring process using tachyons. It's about time to get started with this re-write!
&lt;/h3&gt;

&lt;h3&gt;
  
  
  On the menu
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://dev.to/simonswiss/full-re-write-in-10-days-with-tachyons-and-functional-css-a-case-study-part-1-3dkm"&gt;Why re-write in the first place?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/simonswiss/full-re-write-in-10-days-with-tachyons-and-functional-css-a-case-study-part-2-2opg"&gt;What even is functional CSS?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The refactoring process, step by step&lt;/strong&gt; (you are here! 👋)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/simonswiss/full-re-write-in-10-days-with-tachyons-and-functional-css-a-case-study-part-4-4b11"&gt;The aftermath: key learnings and recommendations&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Chapter 3: The refactoring process, step by step.
&lt;/h2&gt;

&lt;p&gt;Ok. Here we are, finally.&lt;/p&gt;

&lt;p&gt;Well, almost. Let me start by setting the stage here.&lt;/p&gt;

&lt;p&gt;We're a couple of days before Christmas. Everyone is leaving on holiday. I have been demanding a two-week window to do some major refactoring, and it looks like the Christmas and New Year break is my "one shot" to get it done.&lt;/p&gt;

&lt;p&gt;I get a chance to &lt;em&gt;get in the zone&lt;/em&gt;, get some isolation and focus on that one task only, while the office (and BAU) is in shutdown mode.&lt;/p&gt;

&lt;p&gt;At this point, I don't have a clear idea of how much I'll be able to refactor over the break. I've done enough research and reasoning around tachyons to know it can solve our tech debt problems. I just don't know how complex the transition from our current CSS to the new system will be. How long it's going to take.&lt;/p&gt;

&lt;h2&gt;
  
  
  A very nerdy holiday season
&lt;/h2&gt;

&lt;p&gt;I am sitting in the car with my laptop.&lt;/p&gt;

&lt;p&gt;My wife is driving us and our two young kids to Mudgee, a country town 5 hours inland from Sydney, where we're starting a 6-week camping journey throughout New South Wales.&lt;/p&gt;

&lt;p&gt;You got that right. I'll be conducting my entire refactoring process while being on the road, in some areas with little to no internet.&lt;/p&gt;

&lt;p&gt;Sounds like a plan!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kuOsx1Y6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/jl4d01oncdudutq65mqh.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kuOsx1Y6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/jl4d01oncdudutq65mqh.jpg" alt="Camping setup (tent and car in the nature) in Newnes in the Blue Mountains, my remote office for a few days"&gt;&lt;/a&gt;&lt;/p&gt;

My "on the road" office.

&lt;p&gt;Out of topic, but this reminds me of that controversial tweet that came out. I giggled as I read it in the middle of a major Christmas Day refactoring session:&lt;/p&gt;


&lt;blockquote class="ltag__twitter-tweet"&gt;

  &lt;div class="ltag__twitter-tweet__main"&gt;
    &lt;div class="ltag__twitter-tweet__header"&gt;
      &lt;img class="ltag__twitter-tweet__profile-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--e2FPgKfK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/profile_images/846386052910637056/tWGT0XAz_normal.jpg" alt="Joe McCann profile image"&gt;
      &lt;div class="ltag__twitter-tweet__full-name"&gt;
        Joe McCann
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__username"&gt;
        @joemccann
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__twitter-logo"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--B8bbACBj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/twitter-99c56e7c338b4d5c17d78f658882ddf18b0bbde5b3f42f84e7964689e7e8fb15.svg" alt="twitter logo"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__body"&gt;
      The best software developers I know are always hacking over the holidays.&lt;br&gt;&lt;br&gt;True story.
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__date"&gt;
      18:50 PM - 24 Dec 2016
    &lt;/div&gt;


    &lt;div class="ltag__twitter-tweet__actions"&gt;
      &lt;a href="https://twitter.com/intent/tweet?in_reply_to=812732099027419139" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="/assets/twitter-reply-action.svg" alt="Twitter reply action"&gt;
      &lt;/a&gt;
      &lt;a href="https://twitter.com/intent/retweet?tweet_id=812732099027419139" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="/assets/twitter-retweet-action.svg" alt="Twitter retweet action"&gt;
      &lt;/a&gt;
      131
      &lt;a href="https://twitter.com/intent/like?tweet_id=812732099027419139" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="/assets/twitter-like-action.svg" alt="Twitter like action"&gt;
      &lt;/a&gt;
      391
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/blockquote&gt;


&lt;p&gt;I certainly don't pretend to be the best developer. Joe McCann doesn't know me. But I was sure as heck hacking over the holidays! 😂&lt;/p&gt;




&lt;p&gt;And, here we go.&lt;/p&gt;

&lt;p&gt;I'll break the process down in a few steps or milestones I went through, in a chronological way.&lt;/p&gt;

&lt;h2&gt;
  
  
  The starting point
&lt;/h2&gt;

&lt;p&gt;Our "legacy" CSS is composed of the &lt;a href="https://foundation.zurb.com/"&gt;Foundation&lt;/a&gt; framework and a large amount of custom BEM modules.&lt;/p&gt;

&lt;p&gt;Our website is running on the beautiful &lt;a href="https://craftcms.com/"&gt;CraftCMS&lt;/a&gt;, which uses &lt;a href="https://twig.symfony.com/"&gt;Twig&lt;/a&gt; as a templating engine. More later on why using a templating language matters.&lt;/p&gt;

&lt;p&gt;Getting started is a tricky one. The website needs to be operational when office re-opens, otherwise BAU will take over again, and my tachyons GIT branch will never see the light.&lt;/p&gt;

&lt;p&gt;How do I gradually implement tachyons without putting the website in "demolition site" mode?&lt;/p&gt;

&lt;h2&gt;
  
  
  Step1 : tachyons as "sugar on top"
&lt;/h2&gt;

&lt;p&gt;After some thinking and discussing in the tachyons slack, I decide to simply load tachyons at the &lt;strong&gt;very end&lt;/strong&gt; of my stylesheet.&lt;/p&gt;

&lt;p&gt;This allows me to use a few tachyons helper classes for padding, color, etc, without running the risk of breaking anything else.&lt;/p&gt;

&lt;p&gt;If I don't use the helper classes, &lt;strong&gt;nothing happens&lt;/strong&gt;. It feels pretty safe. I can get a feel for tachyons without taking much of a gamble.&lt;/p&gt;

&lt;p&gt;Within an hour of work, I am blown away. I am able to &lt;strong&gt;remove huge chunks of legacy CSS&lt;/strong&gt; and replace it with simple tachyons classes. Removing CSS is one of the hardest thing to do in web development, and I am moving incredibly fast. This is truly remarkable. I am giggling.&lt;/p&gt;




&lt;p&gt;I try to explain this to my non-dev wife - who is still driving - but she doesn't really get a sense of why it's such a big deal. 😂&lt;/p&gt;

&lt;h2&gt;
  
  
  It's so easy, it almost feels like a joke.
&lt;/h2&gt;

&lt;p&gt;I take any given BEM module partial. I find the HTML template for this module, and just rebuild it in tachyons.&lt;/p&gt;

&lt;p&gt;I comment out an entire custom CSS partial and move onto the next one. It still works. This is ridiculous.&lt;/p&gt;

&lt;p&gt;I was expecting to just replace some margins, padding, font-sizes and weighs, but here I am, writing entirely tachyons-powered components. With incredible ease.&lt;/p&gt;

&lt;h2&gt;
  
  
  Enjoy it while it lasts.
&lt;/h2&gt;

&lt;p&gt;At some point, I notice that my progress will eventually slow down.&lt;/p&gt;

&lt;p&gt;I start to notice more and more places where my tachyons classes don't work. Buttons have unexpected hover states, spacing is a bit off.&lt;/p&gt;

&lt;p&gt;I realise that I am trying to fight some Foundation classes, that have more specificity than tachyons and therefore win.&lt;/p&gt;

&lt;p&gt;If I try to comment out Foundation, I can see some of my nice tachyons modules look weird. They were inheriting some styles from Foundation, and don't look the same without them.&lt;/p&gt;

&lt;p&gt;First lesson learned. If you plan to remove the underlying CSS framework at some point - which is my plan - don't wait too long before you do it.&lt;/p&gt;

&lt;p&gt;Which leads me to step 2.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Going "all-out"
&lt;/h2&gt;

&lt;p&gt;It's still very early in the first week. I have plenty of time. I decide to create a new branch called &lt;code&gt;kill-foundation&lt;/code&gt; in which I comment out everything.&lt;/p&gt;

&lt;p&gt;I want to see what things will really look like when i get rid of all the legacy CSS.&lt;/p&gt;

&lt;p&gt;But first, let me say this: working while camping and watching your family enjoy a holiday, is a beautiful thing. I highly recommend you try it if you have a chance.&lt;/p&gt;


&lt;blockquote class="ltag__twitter-tweet"&gt;
      &lt;div class="ltag__twitter-tweet__media"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IzpUc6m_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/media/C0pEvm0UkAAHT7Y.jpg" alt="unknown tweet media content"&gt;
      &lt;/div&gt;

  &lt;div class="ltag__twitter-tweet__main"&gt;
    &lt;div class="ltag__twitter-tweet__header"&gt;
      &lt;img class="ltag__twitter-tweet__profile-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--zYiX6u2i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/profile_images/1160929863/n510426211_274341_6220_normal.jpg" alt="Simon Vrachliotis 🏄🏀💻😍 profile image"&gt;
      &lt;div class="ltag__twitter-tweet__full-name"&gt;
        Simon Vrachliotis 🏄🏀💻😍
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__username"&gt;
        @simonswiss
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__twitter-logo"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--B8bbACBj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/twitter-99c56e7c338b4d5c17d78f658882ddf18b0bbde5b3f42f84e7964689e7e8fb15.svg" alt="twitter logo"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__body"&gt;
      Three hours into my work day, my 4-year old son brings me a biscuit, an apple and three shells from the beach. 😍🙌 &lt;a href="https://twitter.com/hashtag/remotework"&gt;#remotework&lt;/a&gt; &lt;a href="https://twitter.com/hashtag/camping"&gt;#camping&lt;/a&gt; &lt;a href="https://twitter.com/hashtag/kids"&gt;#kids&lt;/a&gt; 
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__date"&gt;
      00:13 AM - 27 Dec 2016
    &lt;/div&gt;


    &lt;div class="ltag__twitter-tweet__actions"&gt;
      &lt;a href="https://twitter.com/intent/tweet?in_reply_to=813538351160565760" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="/assets/twitter-reply-action.svg" alt="Twitter reply action"&gt;
      &lt;/a&gt;
      &lt;a href="https://twitter.com/intent/retweet?tweet_id=813538351160565760" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="/assets/twitter-retweet-action.svg" alt="Twitter retweet action"&gt;
      &lt;/a&gt;
      2
      &lt;a href="https://twitter.com/intent/like?tweet_id=813538351160565760" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="/assets/twitter-like-action.svg" alt="Twitter like action"&gt;
      &lt;/a&gt;
      14
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/blockquote&gt;





&lt;p&gt;Okay, back to our refactoring.&lt;/p&gt;

&lt;p&gt;So, I go ahead and &lt;strong&gt;comment out all the CSS partials&lt;/strong&gt; except tachyons.&lt;/p&gt;

&lt;p&gt;And I watch the website explode.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Hey, it's not that bad, actually!"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Sure, the website is broken as hell. What do you expect, I just removed almost 200kb of custom CSS.&lt;/p&gt;

&lt;p&gt;But, it's not &lt;em&gt;that&lt;/em&gt; bad. Ironically, some parts of the typography and vertical rhythm feel more consistent. This tells me something about tech debt and custom CSS declarations all over the place. 😂&lt;/p&gt;

&lt;h2&gt;
  
  
  Grid layouts are the most obvious
&lt;/h2&gt;

&lt;p&gt;The first thing I decide to fix - because it's by far the most obvious - is all the places were we relied on Foundation's columns.&lt;/p&gt;

&lt;p&gt;While tachyons is &lt;a href="https://github.com/tachyons-css/tachyons/issues/212"&gt;perfectly capable of handling grids&lt;/a&gt; in many different ways, I make the call to use another library called &lt;a href="http://flexboxgrid.com/"&gt;Flexboxgrid&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Flexboxgrid does one thing: it provides you with a super versatile grid system using, well... flexbox (who would have guessed!). If you're familiar with bootstrap's classes, you're going to like it.&lt;/p&gt;

&lt;p&gt;Flexboxgrid has a small footprint and makes re-building the grid layouts a breeze. In my books, and taking my designer colleague in consideration, it definitely warrants the addition of 14kb (non g-zipped) to the build.&lt;/p&gt;

&lt;h2&gt;
  
  
  One module at a time.
&lt;/h2&gt;

&lt;p&gt;Once the grid layouts are back in place, I feel very confident. I look at sections of the site and &lt;em&gt;know&lt;/em&gt; exactly how to build them in tachyons.&lt;/p&gt;

&lt;p&gt;So I get to work, starting with the homepage.&lt;/p&gt;

&lt;p&gt;And I complete the homepage within a couple of hours. Boom 💥.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1NVT8UAA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/3f1ppglyulg51d9h7y8z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1NVT8UAA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/3f1ppglyulg51d9h7y8z.png" alt="Snippet of slack discussion where I get super excited about this utility-first CSS approach"&gt;&lt;/a&gt;&lt;/p&gt;

Getting excited in slack




&lt;p&gt;If I still had any doubt that I could pull off the entire rebuild over the holiday, I am now &lt;strong&gt;very confident&lt;/strong&gt; that the site will be ready when I come back in the office.&lt;/p&gt;




&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jk6h_Ln---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/z97ydevicyutwokkgtsh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jk6h_Ln---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/z97ydevicyutwokkgtsh.png" alt="Snippet of slack discussion"&gt;&lt;/a&gt;&lt;/p&gt;

Confidence is rapidly growing




&lt;p&gt;I still can't get over how fast building modules becomes once you're fluent in tachyons. It's mindblowing. And you get this incredible sense that &lt;strong&gt;nothing is getting more complex&lt;/strong&gt; as you move forward.&lt;/p&gt;

&lt;p&gt;It all becomes predictable, and that's a very empowering feeling.&lt;/p&gt;




&lt;h2&gt;
  
  
  And then, one day..
&lt;/h2&gt;

&lt;p&gt;On the 4th of January 2017, &lt;strong&gt;10 days after Christmas&lt;/strong&gt;, I pushed the new build to our pre-prod environment.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fQ99BGBL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/gxj9sltiumndc7j0mpd6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fQ99BGBL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/gxj9sltiumndc7j0mpd6.png" alt="Snippet of slack discussion showing when I pushed the new site to pre-prod"&gt;&lt;/a&gt;&lt;/p&gt;

I did it! With a fair bit of extra time left, too.




&lt;h2&gt;
  
  
  The verdict
&lt;/h2&gt;

&lt;p&gt;In the 4th and final chapter, we'll dive a bit deeper in tachyons-specific learnings and recommendations.&lt;/p&gt;

&lt;p&gt;For now, let's make a few general observations.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Not a 100% design match
&lt;/h2&gt;

&lt;p&gt;The new version of the website is &lt;strong&gt;not a 100% match&lt;/strong&gt; of the legacy site. Nor did it ever pretend to be.&lt;/p&gt;

&lt;p&gt;The main purpose of the re-build was to get rid of tech debt. I tried to make the site look the same, while trying to standardise some components to a more consistent overall look and feel.&lt;/p&gt;

&lt;p&gt;In some places, the site is not as good as it used to be. But in many places, &lt;strong&gt;it's better&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Overall, it definitely needs a polish. While I have an eye for design, I don't come remotely close to skills of SocietyOne's very own design director (and close friend), Mr &lt;a href="https://twitter.com/m4ttbx"&gt;Matt Barron&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;edit: fun fact, Matt and I are now colleagues again at &lt;a href="https://thinkmill.com.au"&gt;Thinkmill&lt;/a&gt;&lt;/em&gt; 🙌&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Significantly less buggy
&lt;/h2&gt;

&lt;p&gt;The whole thing feels so much more stable. I cannot stress this enough.&lt;/p&gt;

&lt;p&gt;Immutable, single-purpose functional CSS classes mean that if you do &lt;br&gt;
things right, there is literally no risk of &lt;a href="https://giphy.com/gifs/WM3HX2cZ3zTry"&gt;accidental overrides&lt;/a&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Onboarding team members is easy
&lt;/h2&gt;

&lt;p&gt;One of the first assumption people do about tachyons is that it's going to be impossible for anyone else to work on your code, unless they learn tachyons.&lt;/p&gt;

&lt;p&gt;Well, that's true. And that's true for &lt;strong&gt;any codebase&lt;/strong&gt;. Thinking you can jump in any codebase and just &lt;strong&gt;know&lt;/strong&gt; what to do without having to learn the system is.. delusional.&lt;/p&gt;

&lt;p&gt;I &lt;strong&gt;strongly disagree&lt;/strong&gt; to this argument. And I'm Swiss - we tend to remain neutral most of the time.&lt;/p&gt;

&lt;p&gt;While I concede that templates look confusing at first, you see things with a completely different angle once you become fluent with the tachyons syntax.&lt;/p&gt;

&lt;p&gt;It doesn't take long to memorise tachyons classes. Trust me, it would take &lt;strong&gt;much longer&lt;/strong&gt; for you to make sense of all the custom BEM modules we had in place before that.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. Removed context switching makes you SO fast
&lt;/h2&gt;

&lt;p&gt;When working with functional CSS, the HTML is very declarative and self sufficient. It tells you exactly how things are going to look, without having to lookup CSS stylesheets to figure it out.&lt;/p&gt;

&lt;p&gt;Being able to work in one file without ever switching context in your brain &lt;strong&gt;yields incredible gains in productivity&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;You hear similar comments from React or Vue developers. They love working within one self contained component file. They call it the &lt;strong&gt;real separation of concerns&lt;/strong&gt;, and not separation of languages.&lt;/p&gt;




&lt;h2&gt;
  
  
  5. Huge reduction in CSS bundle
&lt;/h2&gt;

&lt;p&gt;Without worrying about performance at all, the CSS bundle when first pushing to &lt;code&gt;pre-prod&lt;/code&gt; turned out to be &lt;strong&gt;less than 50% of the original bundle size&lt;/strong&gt;.&lt;/p&gt;


&lt;blockquote class="ltag__twitter-tweet"&gt;
      &lt;div class="ltag__twitter-tweet__media"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--svZu0uiM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/media/C1SYYCOVIAEaa1V.jpg" alt="unknown tweet media content"&gt;
      &lt;/div&gt;

  &lt;div class="ltag__twitter-tweet__main"&gt;
    &lt;div class="ltag__twitter-tweet__header"&gt;
      &lt;img class="ltag__twitter-tweet__profile-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--zYiX6u2i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/profile_images/1160929863/n510426211_274341_6220_normal.jpg" alt="Simon Vrachliotis 🏄🏀💻😍 profile image"&gt;
      &lt;div class="ltag__twitter-tweet__full-name"&gt;
        Simon Vrachliotis 🏄🏀💻😍
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__username"&gt;
        @simonswiss
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__twitter-logo"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--B8bbACBj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/twitter-99c56e7c338b4d5c17d78f658882ddf18b0bbde5b3f42f84e7964689e7e8fb15.svg" alt="twitter logo"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__body"&gt;
      Two weeks ago, I started refactoring the &lt;a href="https://twitter.com/mysocietyone"&gt;@mysocietyone&lt;/a&gt; website with &lt;a href="https://twitter.com/tachyons_css"&gt;@tachyons_css&lt;/a&gt; to cull CSS tech debt. Not finished yet, but great stats!🎉 
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__date"&gt;
      00:45 AM - 04 Jan 2017
    &lt;/div&gt;


    &lt;div class="ltag__twitter-tweet__actions"&gt;
      &lt;a href="https://twitter.com/intent/tweet?in_reply_to=816445330065457152" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="/assets/twitter-reply-action.svg" alt="Twitter reply action"&gt;
      &lt;/a&gt;
      &lt;a href="https://twitter.com/intent/retweet?tweet_id=816445330065457152" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="/assets/twitter-retweet-action.svg" alt="Twitter retweet action"&gt;
      &lt;/a&gt;
      3
      &lt;a href="https://twitter.com/intent/like?tweet_id=816445330065457152" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="/assets/twitter-like-action.svg" alt="Twitter like action"&gt;
      &lt;/a&gt;
      12
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/blockquote&gt;
 




&lt;h2&gt;
  
  
  6. Cognitive load is ridiculously low
&lt;/h2&gt;

&lt;p&gt;I feel like &lt;strong&gt;no BAU can stop us&lt;/strong&gt; now.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Put it this way - tachyons as a toolkit for BAU lets you do things that are as easy as slapping inline-styles, but are fundamentally different in the impact they have on the rest of your codebase.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I'm sure you've all been there: a stakeholder (or client) wants to take a section of the site and move it up higher on the page.&lt;/p&gt;

&lt;p&gt;It sounds like a "minor change" for some people. As a designer/developer, though, you see some of the issues it can brings to the mix.&lt;/p&gt;

&lt;p&gt;Maybe the section had a green background. You've been asked to move it right under another green background section. It doesn't work well at all there. Spacing is completely off now, and the margin-top needs to go away.&lt;/p&gt;

&lt;p&gt;In these types of situation, it could be easy to be tempted to just slam an inline-style like &lt;code&gt;&amp;lt;div style="margin-top: 0;"&amp;gt;&lt;/code&gt; and call it a day.&lt;/p&gt;

&lt;p&gt;Functional CSS is somewhat similar (but completely different, although that point is often misunderstood) to inline-styles. In that sense, you can apply the same effect to your section with &lt;code&gt;&amp;lt;div class="mt0"&amp;gt;&lt;/code&gt; without any of the negative effects of applying inline-styles.&lt;/p&gt;

&lt;p&gt;If you still need some margin top on mobile, but not on larger screens, you could do &lt;code&gt;&amp;lt;div class="mt2 mt0-ns"&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Good luck doing that with *inline-*styles.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Functional CSS enforces being DRY and modular
&lt;/h2&gt;

&lt;p&gt;I heard many people claim that functional CSS is for lazy people, or people who don't understand CSS enough to use it well.&lt;/p&gt;

&lt;p&gt;I couldn't disagree more.&lt;/p&gt;

&lt;p&gt;The way I see it, functional CSS forces you to think "modularity" when writing your HTML. No one enjoys copying and pasting the same classes over and over in an HTML document.&lt;/p&gt;

&lt;p&gt;To avoid this, you need to step up your "architecture" game and think of ways to make your HTML components re-usable as much as possible.&lt;/p&gt;

&lt;p&gt;Things like storing content in a data array, writing loops to output a repeating block of HTML have a huge impact when it comes to maintaining your code.&lt;/p&gt;

&lt;p&gt;Tachyons has definitely made me dig deeper into modular templating techniques. The web is pointing towards &lt;strong&gt;web components&lt;/strong&gt; from all angles. It's good to embrace this mindset.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Extracting your content from your markup, making it as much back-end agnostic as possible, is a good thing. It makes you a better developer.&lt;br&gt;
Functional CSS makes you think in components, systems. Not pages.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Did I &lt;a href="http://atomicdesign.bradfrost.com/chapter-1/"&gt;just sound like Brad Frost&lt;/a&gt;?&lt;/p&gt;




&lt;h2&gt;
  
  
  So what, functional CSS has no drawbacks?
&lt;/h2&gt;

&lt;p&gt;Functional CSS is probably not perfect. It's most definitely not to the taste of everybody.&lt;/p&gt;

&lt;p&gt;The initial negative reactions on the &lt;em&gt;ugly looking&lt;/em&gt; HTML, loss of &lt;em&gt;semantic classes&lt;/em&gt; are common, because they are real facts.&lt;/p&gt;

&lt;p&gt;You can only see past these reactions if you give it some thought and evaluate trade-offs.&lt;/p&gt;

&lt;p&gt;Being a web developer is &lt;strong&gt;all about evaluating trade-offs&lt;/strong&gt;. How much benefits do you need to get from a system or methodology to overcome the perceived negatives?&lt;/p&gt;

&lt;p&gt;If I had to summarise my experience with functional CSS in one paragraph, it would be this:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"The benefits I get from using functional CSS, in terms of reduced cognitive load, self-describing declarative HTML markup and huge productivity boost, are simply amazing. They overcome by far the few negatives that this approach brings to the mix. I'd take that trade-off any day of the week."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And I did.&lt;/p&gt;

&lt;p&gt;See you in the &lt;a href="https://dev.to/simonswiss/full-re-write-in-10-days-with-tachyons-and-functional-css-a-case-study-part-4-4b11"&gt;final chapter&lt;/a&gt; for some tachyons-specific observations, suggestions and lessons learned!&lt;/p&gt;

</description>
      <category>css</category>
      <category>utilityclasses</category>
      <category>atomiccss</category>
      <category>bem</category>
    </item>
    <item>
      <title>Full re-write in 10 days with tachyons and functional CSS: A case study (Part 2)</title>
      <dc:creator>Simon Vrachliotis 🏄🏀💻😍</dc:creator>
      <pubDate>Fri, 02 Aug 2019 20:59:40 +0000</pubDate>
      <link>https://dev.to/simonswiss/full-re-write-in-10-days-with-tachyons-and-functional-css-a-case-study-part-2-2opg</link>
      <guid>https://dev.to/simonswiss/full-re-write-in-10-days-with-tachyons-and-functional-css-a-case-study-part-2-2opg</guid>
      <description>&lt;h3&gt;
  
  
  This is the second chapter of a 4-post series, taking you through a website refactoring process using tachyons, in which we take a look at what functional CSS is and why it can be useful.
&lt;/h3&gt;

&lt;h3&gt;
  
  
  On the menu
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://dev.to/simonswiss/full-re-write-in-10-days-with-tachyons-and-functional-css-a-case-study-part-1-3dkm"&gt;Why re-write in the first place?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What even is functional CSS?&lt;/strong&gt; (you are here! 👋)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/simonswiss/full-re-write-in-10-days-with-tachyons-and-functional-css-a-case-study-part-3-1k4"&gt;The refactoring process, step by step&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/simonswiss/full-re-write-in-10-days-with-tachyons-and-functional-css-a-case-study-part-4-4b11"&gt;The aftermath: key learnings and recommendations&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Chapter 2: What even is functional CSS?
&lt;/h2&gt;

&lt;p&gt;So, what is this buzz all about? What does functional CSS even mean?&lt;/p&gt;

&lt;p&gt;You may also have heard of &lt;em&gt;atomic&lt;/em&gt; CSS or &lt;em&gt;immutable&lt;/em&gt; CSS. These refer to the same thing. If you're familiar with &lt;a href="https://drboolean.gitbooks.io/mostly-adequate-guide-old/content/ch3.html"&gt;pure functions&lt;/a&gt; in functional programming, you should be able to grasp the concept quickly.&lt;/p&gt;




&lt;blockquote&gt;
&lt;p&gt;A pure function is a function that, given the same input, will always return the same output and does not have any observable side effect.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;~ Dr. Boolean, Mostly Adequate Guide to Functional Programming&lt;/p&gt;




&lt;p&gt;Think of it as breaking your CSS into small, &lt;em&gt;"do-one-thing-only-and-do-it-well"&lt;/em&gt; classes. Think lego blocks. Combine a bunch of these classes together and you can create just about any style you want.&lt;/p&gt;

&lt;p&gt;This radically different approach to writing CSS is challenging a lot of established best practices. It won't be love at first sight.&lt;/p&gt;

&lt;p&gt;At first glance, it does seem like a &lt;strong&gt;terrible idea&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  A basic example
&lt;/h2&gt;

&lt;p&gt;Let's say you want to build an warning box with a red-ish background, some padding and white coloured text.&lt;/p&gt;

&lt;h3&gt;
  
  
  The "traditional" way
&lt;/h3&gt;

&lt;p&gt;You'd probably want to write some HTML like this:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;In your CSS file, you could do this:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;You'd end up with something like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ln_bpTb---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/qmbiu3zwvvgg91457u0w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ln_bpTb---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/qmbiu3zwvvgg91457u0w.png" alt="Warning UI built with traditional CSS"&gt;&lt;/a&gt;&lt;/p&gt;

Traditional CSS warning box

&lt;p&gt;All is well.&lt;/p&gt;

&lt;p&gt;Let's now take a look at what the equivalent would look like functional CSS land.&lt;/p&gt;

&lt;h3&gt;
  
  
  The "functional CSS" way
&lt;/h3&gt;

&lt;p&gt;Let's split the "looks" of this box series of small, single purpose &lt;em&gt;attributes&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Well, I kinda did it earlier. It has:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a &lt;em&gt;red-ish&lt;/em&gt; background,&lt;/li&gt;
&lt;li&gt;some &lt;em&gt;vertical padding&lt;/em&gt;,&lt;/li&gt;
&lt;li&gt;some slightly larger &lt;em&gt;horizontal padding&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;white&lt;/em&gt; text.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's write a single class for each of these attributes:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;We can then use these classes to "compose" our warning box:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;The result looks exactly the same:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---yO5H3S---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/l1zsjfrw6hkkh5nthmn0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---yO5H3S---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/l1zsjfrw6hkkh5nthmn0.png" alt="Warning UI built with utility classes"&gt;&lt;/a&gt;&lt;/p&gt;

Functional CSS warning box

&lt;p&gt;I can hear you scream!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Eeeeeewwwww. Why?!"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I told you. &lt;strong&gt;Terrible&lt;/strong&gt; idea. The first version is clearly the better way to code this warning box.&lt;/p&gt;

&lt;p&gt;Bear with me for a bit.&lt;/p&gt;

&lt;p&gt;Let's now build a button for our UI. In traditional CSS, I would do something like this:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;and&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;We'd get this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pGEO6eOJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/5pfds2n9we0h4zp4b7xr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pGEO6eOJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/5pfds2n9we0h4zp4b7xr.png" alt="Button created with traditional CSS"&gt;&lt;/a&gt;&lt;/p&gt;

Traditional CSS button

&lt;p&gt;In functional CSS, i'd to that:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;and&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Again, we get the same result:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--B465WIkF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/ozx8eyhtblrh9u4o8sdg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--B465WIkF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/ozx8eyhtblrh9u4o8sdg.png" alt="Button created with utility classes"&gt;&lt;/a&gt;&lt;/p&gt;

Functional CSS button

&lt;blockquote&gt;
&lt;p&gt;"I still don't get it", you say.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;These are two small and purposely naive examples, but hopefully you're able to see a few trends happening here.&lt;/p&gt;

&lt;p&gt;In the traditional CSS examples, we have already somehow &lt;strong&gt;repeated ourselves&lt;/strong&gt;. Both the warning and button components share similar colours and padding, but we declared these properties twice.&lt;/p&gt;

&lt;p&gt;Yes, we could have written the CSS differently. Yes, it doesn't matter much at this scale.&lt;/p&gt;

&lt;p&gt;But imagine that you're building 80 components. They will all need background colours, text colours, spacing… and &lt;strong&gt;chances are you'll declare these in CSS for each and every component&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Want to see how many times you declared, say, a font-size on your website? Go ahead and run it through &lt;a href="http://cssstats.com"&gt;http://cssstats.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here are the stats for Medium.com on CSS Stats:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--d4xT_9sr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/lg613qmt9jig76f7rtif.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--d4xT_9sr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/lg613qmt9jig76f7rtif.png" alt="CSS stats from the Medium.com website"&gt;&lt;/a&gt;&lt;/p&gt;

CSS stats for Medium.com from cssstats.com




&lt;p&gt;In contrast, the functional CSS warning box and button components use the &lt;strong&gt;same core of CSS classes&lt;/strong&gt;, which is only written &lt;strong&gt;once&lt;/strong&gt; in CSS. We only had to add the border-radius property.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The promise of functional CSS is, if you write just enough clever functional CSS classes to mix and match, you should be able to build almost any component without writing new CSS.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This is exactly what toolkits like &lt;a href="https://basscss.com/"&gt;basscss&lt;/a&gt; and &lt;a href="https://tachyons.io"&gt;tachyons&lt;/a&gt; bring to the table.&lt;/p&gt;

&lt;h2&gt;
  
  
  A lot of opinions, not many facts
&lt;/h2&gt;

&lt;p&gt;Functional CSS is guaranteed to trigger a lot of very strong opinions.&lt;/p&gt;

&lt;p&gt;If you want a recent example of this, I invite you to read &lt;a href="https://medium.com/@johnpolacek/kiss-my-classname-a-counterpoint-3ca41f0aed1a#.7g6p8h2wu"&gt;this post by John Polacek&lt;/a&gt;. You'll be able to reverse-engineer your way to the initial post by Adam Morse I have linked to in chapter 1.&lt;/p&gt;

&lt;p&gt;For that reason, I have no doubt some of you have stopped reading by now. Some are screaming at their screen:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"What about semantic classnames?"&lt;/p&gt;

&lt;p&gt;"Your HTML will be polluted with thousands of little classnames and unreadable to other developers!"&lt;/p&gt;

&lt;p&gt;"So, you're saying that if I am writing an unordered list, each &lt;code&gt;&amp;lt;li&amp;gt;&lt;/code&gt; element needs to have 7 classes applied to it? Are you fo' real?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;One thing I noted during my research on tachyons: there are a lot more opinions out there than there are facts or case studies. A lot of these opinions come from a &lt;strong&gt;gut reaction&lt;/strong&gt;, without giving it a real thought.&lt;/p&gt;

&lt;p&gt;These are perfectly valid reactions. My initial reaction was the exact same!&lt;/p&gt;

&lt;h2&gt;
  
  
  This is why I am writing this series.
&lt;/h2&gt;

&lt;p&gt;I want to share my real-life experience working with functional CSS and going through a complete refactoring with tachyons.&lt;/p&gt;

&lt;p&gt;I think I have a little more insights than just gut reactions. I know I made a few key learnings that could be beneficial to other developers.&lt;/p&gt;

&lt;p&gt;See you in &lt;a href="https://dev.to/simonswiss/full-re-write-in-10-days-with-tachyons-and-functional-css-a-case-study-part-3-1k4"&gt;chapter 3&lt;/a&gt;, where we go through the actual refactoring process!&lt;/p&gt;

</description>
      <category>css</category>
      <category>utilityfirstcss</category>
      <category>atomiccss</category>
      <category>bem</category>
    </item>
    <item>
      <title>Full re-write in 10 days with tachyons and functional CSS: A case study (Part 1)</title>
      <dc:creator>Simon Vrachliotis 🏄🏀💻😍</dc:creator>
      <pubDate>Fri, 02 Aug 2019 11:01:14 +0000</pubDate>
      <link>https://dev.to/simonswiss/full-re-write-in-10-days-with-tachyons-and-functional-css-a-case-study-part-1-3dkm</link>
      <guid>https://dev.to/simonswiss/full-re-write-in-10-days-with-tachyons-and-functional-css-a-case-study-part-1-3dkm</guid>
      <description>

&lt;h3&gt;
  
  
  This is the beginning of a 4-post series, taking you through a website refactoring process using &lt;a href="https://tachyons.io"&gt;tachyons&lt;/a&gt;, a functional CSS toolkit that is guaranteed to trigger very strong opinions [insert Dave Rupert's hot drama soundboard effect].
&lt;/h3&gt;

&lt;h3&gt;
  
  
  On the menu
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Why re-write in the first place?&lt;/strong&gt; (you are here! 👋)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/simonswiss/full-re-write-in-10-days-with-tachyons-and-functional-css-a-case-study-part-2-2opg"&gt;What even is functional CSS?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/simonswiss/full-re-write-in-10-days-with-tachyons-and-functional-css-a-case-study-part-3-1k4"&gt;The refactoring process, step by step&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/simonswiss/full-re-write-in-10-days-with-tachyons-and-functional-css-a-case-study-part-4-4b11"&gt;The aftermath: key learnings and recommendations&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;&lt;strong&gt;The series is ported from Medium (Hackernoon publication), and was originally written in February 2017.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The website in question is SocietyOne, an Australian marketplace lending company where I (used to) work as the front-end lead.&lt;/p&gt;

&lt;p&gt;Let's begin!&lt;/p&gt;




&lt;h2&gt;
  
  
  Chapter 1: Why re-write in the first place?
&lt;/h2&gt;

&lt;p&gt;The marketplace lending industry is fairly new and things are moving fast.&lt;/p&gt;

&lt;p&gt;We're a very small team. We designed and developed our "new" website about two years ago, and have been maintaining and evolving the codebase in a very iterative process.&lt;/p&gt;

&lt;p&gt;We planned things carefully. Adopted the BEM methodology to organise our styles. Things were working great for us.&lt;/p&gt;

&lt;p&gt;We were writing beautiful, clean modules. We had a good understanding of our codebase. Up to a certain point.&lt;/p&gt;

&lt;p&gt;I love BEM. I think it's a great way to organise your CSS and does a good job at keeping specificity relatively low. What BEM (and most other CSS architecture methodologies) doesn't really help with is dealing with &lt;strong&gt;accumulating technical debt&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Our growing company went through a lot of churn. New people, new opinions, new strategies. This generates a lot of minor - and major - change requests. This phenomenon, commonly known as BAU (business as usual), is one of the biggest drivers of technical debt in a codebase.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Start of the End
&lt;/h2&gt;

&lt;p&gt;BAU requests often coming with a "can we have it done today" deadline, as a developer you run a high risk of reaching out for questionable techniques at some point.&lt;/p&gt;

&lt;p&gt;It might be an extra class at the bottom of a stylesheet, or a copy/paste of a module with a few tweaks here and there instead of carefully crafted "BEM modifiers".&lt;/p&gt;

&lt;p&gt;Before you know it, you're considering introducing a &lt;a href="https://csswizardry.com/2013/04/shame-css/"&gt;shame.css&lt;/a&gt; file in your repo. Dare I say, you may even reach for an &lt;em&gt;inline-style hack&lt;/em&gt;. 😱&lt;br&gt;
And then, things get out of hands.&lt;/p&gt;

&lt;p&gt;It doesn't take many hotfix hacks to throw a huge spanner in your beautiful CSS wheel. And as real-life BAU requests continue, you can only witness your handle on the codebase slip away further and further. 😓&lt;/p&gt;

&lt;h2&gt;
  
  
  When things reach a tipping point
&lt;/h2&gt;

&lt;p&gt;In the weeks leading up to Christmas 2016, I felt like things were reaching a tipping point. Tech debt was becoming a serious problem, and there was no sign of BAU slowing down. Quite the opposite, actually.&lt;/p&gt;

&lt;p&gt;I was losing a lot of sleep over this increasingly worrying situation. I remember being close to the edge of the "burnout cliff". Dangerously close.&lt;/p&gt;

&lt;h2&gt;
  
  
  What now?
&lt;/h2&gt;

&lt;p&gt;Something needed to happen. &lt;em&gt;Some&lt;/em&gt; thing.&lt;/p&gt;

&lt;p&gt;One day, totally out of the blue, my colleague showed me that intriguing thing he stumbled upon, called tachyons.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Looking back, this very moment may have played a huge role in preserving my mental health.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I had never heard of tachyons before. I had a look. My initial thought was: "Meh, look at all these classes in the HTML. Ugh". I moved on.&lt;/p&gt;

&lt;p&gt;A lot of people - if not everyone - have the exact same initial thought.&lt;/p&gt;

&lt;p&gt;And they &lt;strong&gt;move on&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A couple of days later, I read this &lt;a href="https://mrmrs.cc/writing/scalable-css/"&gt;spectacular blog post by Adam Morse&lt;/a&gt; (the creator of tachyons). That article resonated with me so much that I decided to give that tachyons thing a second look.&lt;/p&gt;

&lt;p&gt;The more I thought about this functional CSS approach, the more it made sense. My head started to buzz with excitement and hope.&lt;/p&gt;

&lt;p&gt;In the &lt;a href="https://dev.to/simonswiss/full-re-write-in-10-days-with-tachyons-and-functional-css-a-case-study-part-2-2opg"&gt;next chapter&lt;/a&gt;, I'll show you why!&lt;/p&gt;

</description>
      <category>css</category>
      <category>utilityfirst</category>
      <category>atomic</category>
      <category>bem</category>
    </item>
  </channel>
</rss>
