<?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[Developing with Sass - Medium]]></title>
        <description><![CDATA[For developers and designers who are writing about Sass and SCSS - Medium]]></description>
        <link>https://medium.com/developing-with-sass?source=rss----410936115607---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Developing with Sass - Medium</title>
            <link>https://medium.com/developing-with-sass?source=rss----410936115607---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 18:40:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/developing-with-sass" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Creating a Dead Simple Sass Mixin to Handle Responsive Breakpoints]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/developing-with-sass/creating-a-dead-simple-sass-mixin-to-handle-responsive-breakpoints-889927b37740?source=rss----410936115607---4"><img src="https://cdn-images-1.medium.com/max/2600/1*CpAv-lj5o2JHXQYkgIMftg.jpeg" width="3888"></a></p><p class="medium-feed-snippet">Simplifying syntax and responsive code organization</p><p class="medium-feed-link"><a href="https://medium.com/developing-with-sass/creating-a-dead-simple-sass-mixin-to-handle-responsive-breakpoints-889927b37740?source=rss----410936115607---4">Continue reading on Developing with Sass »</a></p></div>]]></description>
            <link>https://medium.com/developing-with-sass/creating-a-dead-simple-sass-mixin-to-handle-responsive-breakpoints-889927b37740?source=rss----410936115607---4</link>
            <guid isPermaLink="false">https://medium.com/p/889927b37740</guid>
            <dc:creator><![CDATA[Tim Knight]]></dc:creator>
            <pubDate>Wed, 13 May 2015 01:10:20 GMT</pubDate>
            <atom:updated>2014-09-17T17:50:45.899Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Practical Sass Loops]]></title>
            <link>https://medium.com/developing-with-sass/practical-sass-loops-eb442a4b0f19?source=rss----410936115607---4</link>
            <guid isPermaLink="false">https://medium.com/p/eb442a4b0f19</guid>
            <dc:creator><![CDATA[Tim Knight]]></dc:creator>
            <pubDate>Wed, 13 May 2015 01:09:58 GMT</pubDate>
            <atom:updated>2014-03-28T12:04:26.220Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k6hODyXpkf0QKcLHT-ogeA.jpeg" /></figure><h4>Using loops within Sass 3.3 to generate link icons</h4><p>I’m an absolute advocate for Sass (I’m talking about <a href="http://sass-lang.com/">Syntactically Awesome Stylesheets</a>, but other kinds of sass are just as entertaining). I was first introduced to it while programming Rails and have since adapted it to every web project workflow I have—whether easy to accommodate or not.</p><p>Recently while speaking with a designer friend of mine we started talking about practical uses for the @each, @for, and @while functionality within the language. While common to developers, I’ve found many designers have trouble seeing their helpfulness within the UI portion of web construction.</p><blockquote>Is it really practical?</blockquote><p>First it’s important to point out that conditional flows and loops are extremely important and practical when developing mixins and modular functionality within your Sass projects, but what I wanted to do was answer the question, “Is there a practical way that the average designer could understand the benefits of having loops in Sass?”</p><h3>Understanding the Basics</h3><p>Before I get started, it’s important to understand a few concepts about CSS and Sass. First, attribute selectors in CSS allow us to select a element based on an attribute of that element outside of just its ID or class. For example:</p><pre>&lt;a href=&quot;http://www.facebook.com&quot;&gt;Facebook.com&lt;/a&gt;</pre><p>The href would be an attribute containing a value of “http://www.facebook.com”. While there are several different attribute selectors, here are three of the most commonly supported.</p><pre><strong>Begins with:</strong> a[href^=&quot;http://&quot;] { }<br><em>Matches an href attribute that begins with &#39;http://&#39;.</em></pre><pre><strong>Includes:</strong> a[href*=&quot;facebook&quot;] { }<br><em>Matches an href attribute that contains the text &#39;facebook&#39; anywhere in the value.</em></pre><pre><strong>Ends with:</strong> a[href$=&quot;.com&quot;] { }<br><em>Matches an href attribute that ends with the value &#39;.com&#39;.</em></pre><p>I’ll be using the “includes” and “ends with” selectors throughout this Sass exploration.</p><p>One final thing I want to make sure you’re familiar with are Sass placeholders. Basically a placeholder is a snippet of code that isn’t included in your code unless you’ve specifically called it to be added to another selector. Similar to a mixin, but without attributes, placeholders let you consolidate your selectors with similar functionality. For example:</p><pre>%message {<br>  font-weight: bold;<br>  padding: 5px 10px;<br>  text-align: center;<br>}</pre><pre>.error-message {<br>  <a href="http://twitter.com/extend">@extend</a> %message;<br>  color: red;<br>}</pre><pre>.success-message {<br>  <a href="http://twitter.com/extend">@extend</a> %message;<br>  color: green;<br>}</pre><p>Compiles into…</p><pre>.error-message, .success-message {<br>  font-weight: bold;<br>  padding: 5px 10px;<br>  text-align: center;<br>}</pre><pre>.error-message { color: red; }<br>.success-message { color: green; }</pre><blockquote>Using Sass placeholders and @extends keeps your code cleaner by consolidating the selectors into a single declaration.</blockquote><h3>User Profile Social Links</h3><p>Even with the availability of <a href="http://fontawesome.io/">font</a> <a href="http://symbolset.com/icons">icon</a> libraries, it’s not unusual to see a list of social image icons within a user’s profile page. Often accounting for those images can be annoying if they are simply included as images on a page. So we’ll use Sass to simplify the process for us and create them as backgrounds in our profile based on the links.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/1*qsBbfBSf5wZNs-ze6ir6Cw.png" /><figcaption>An example of social links on our sample user profile</figcaption></figure><p>Let’s take a look at our markup…</p><pre>&lt;ul class=&quot;social-links&quot;&gt;<br>  &lt;li&gt;&lt;a href=&quot;<a href="http://www.facebook.com/">http://www.facebook.com/</a>user/&quot;&gt;Facebook&lt;/a&gt;&lt;/li&gt;<br>  &lt;li&gt;&lt;a href=&quot;<a href="http://www.twitter.com/">http://www.twitter.com</a>/user/&quot;&gt;Twitter&lt;/a&gt;&lt;/li&gt;<br>  &lt;li&gt;&lt;a href=&quot;<a href="http://www.linkedin.com/">http://www.linkedin.com/</a>user/&quot;&gt;LinkedIn&lt;/a&gt;&lt;/li&gt;<br>  &lt;li&gt;&lt;a href=&quot;<a href="http://plus.google.com/">http://plus.google.com/</a>user/&quot;&gt;Google+&lt;/a&gt;&lt;/li&gt;<br>&lt;/ul&gt;</pre><p>Now, for the Sass. Let’s start by making a list of the social services we want our application to support.</p><pre>$social-links: &quot;facebook&quot;, &quot;linkedin&quot;, &quot;twitter&quot;, &quot;google&quot;;</pre><p>We’ll want to put our images in /images/social/ for this example and name each image after the service: facebook.png, linkedin.png, twitter.png, and google.png.</p><p>Now, let’s set some defaults on our icons with a placeholder, remember to use % to start it off.</p><pre>%icon-settings {<br>  padding-left: 20px;<br>  background-repeat: no-repeat;<br>  background-position: left center;<br>}</pre><p>Finally, we’ll look through our list of services, extend our icon settings, and output our background icons.</p><pre><a href="http://twitter.com/each">@each</a> $link in $social-links {<br>  a[href*=&quot;#{$link}&quot;] {<br>    <a href="http://twitter.com/extend">@extend</a> %icon-settings;<br>    background-image: url(https://medium.com/images/social/#{$link}.png);<br>  }<br>}</pre><p>Looping through our list we use the “includes” attribute selector to find and assign links with the service keywords and give them a background icon of their associated logo. This generates our final CSS.</p><pre>a[href*=&quot;facebook&quot;], a[href*=&quot;linkedin&quot;], a[href*=&quot;twitter&quot;], a[href*=&quot;google&quot;] {<br>  padding-left: 20px;<br>  background-repeat: no-repeat;<br>  background-position: left center;<br>}</pre><pre>a[href*=&quot;facebook&quot;] {<br>  background-image: url(https://medium.com/images/social/facebook.png);<br>}</pre><pre>a[href*=&quot;linkedin&quot;] {<br>  background-image: url(https://medium.com/images/social/linkedin.png);<br>}</pre><pre>a[href*=&quot;twitter&quot;] {<br>  background-image: url(https://medium.com/images/social/twitter.png);<br>}</pre><pre>a[href*=&quot;google&quot;] {<br>  background-image: url(https://medium.com/images/social/google.png);<br>}</pre><h3>File Download Links</h3><p>Social media links aren’t the only way we can style a list using a loop. Common intranets or websites with various file downloads might contain a descriptive filetype icon to show the visitor the type of file they’ll be downloading when clicking the link.</p><p>Our process is nearly the exact same as our social links except we’ll now use the “ends with” attribute selector.</p><pre>$file-types: &quot;doc&quot;, &quot;xls&quot;, &quot;rtf&quot;, &quot;pdf&quot;, &quot;zip&quot;;</pre><pre>%icon-settings { ... }</pre><pre><a href="http://twitter.com/each">@each</a> $file in $file-types {<br>  a[href$=&quot;#{$file}&quot;] {<br>    <a href="http://twitter.com/extend">@extend</a> %icon-settings;<br>    background-image: url(https://medium.com/images/files/#{$file}.png);<br>  }<br>}</pre><h3>Don’t Make It Complicated</h3><p>Sure there may be more practical uses of loops outside of mixins for UI advantages with Sass, but I wanted to write about an example that would be approachable by even those unfamiliar with Sass or other preprocessors. The most important thing in any programming language is to avoid being clever at the risk of readability. Simplify your code to its core purpose and take advantage of language features appropriately. But more importantly, have fun doing it.</p><blockquote>“Simplicity is about subtracting the obvious and adding the meaningful.”<br>― <strong>John Maeda</strong></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eb442a4b0f19" width="1" height="1" alt=""><hr><p><a href="https://medium.com/developing-with-sass/practical-sass-loops-eb442a4b0f19">Practical Sass Loops</a> was originally published in <a href="https://medium.com/developing-with-sass">Developing with Sass</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Refactoring My “Simple” Sass Breakpoint Mixin]]></title>
            <link>https://medium.com/developing-with-sass/refactoring-my-simple-sass-breakpoint-mixin-71205dd6badd?source=rss----410936115607---4</link>
            <guid isPermaLink="false">https://medium.com/p/71205dd6badd</guid>
            <dc:creator><![CDATA[Tim Knight]]></dc:creator>
            <pubDate>Thu, 11 Sep 2014 12:55:30 GMT</pubDate>
            <atom:updated>2014-11-22T04:59:57.375Z</atom:updated>
            <content:encoded><![CDATA[<p><em>When something about your code just isn’t right, refactor it for clarity</em></p><p>It was just a few months ago when I wrote my concept for a <a href="https://medium.com/@timknight/creating-a-dead-simple-sass-mixin-to-handle-responsive-breakpoints-889927b37740">Dead Simple Sass Mixin to Handle Responsive Breakpoints</a> and as I continued to use it, I realized there was something that didn’t feel right — hidden complexity in the form of cleverness.</p><blockquote>“Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage to move in the opposite direction.”<br>~ <strong>E.F. Schumacher</strong></blockquote><p>When I first wrote the mixin I was trying to simplify how I wrote specific breakpoints when working in a Bootstrap project, so for me it just made sense to hardcode Bootstrap-based labels (xs, sm, md, and lg) right into the mixin. Of course, what if I wanted to specify a custom breakpoint? Well that was easy too, you just setup a minimum or a maximum value and it was all taken care of for you.</p><pre>@include breakpoint($min: 992px) { ... }</pre><p>To account for this I would check the “type” of the input being submitted for the first attribute using Sass’s type-of function. This would help me determine which flow to take through the mixin. But is it all necessary? Could there be an even easier way to make a breakpoint mixin where the input was a consistent type but more flexible?</p><h3>Setting Breakpoints with Maps</h3><p>Since the mixin was using essentially a string value that was based around Bootstrap’s labels, Sass 3.3 and the new maps feature seemed to be a perfect way to define these attributes. This also decoupled the mixin from Bootstrap specific labeling and allows me to change frameworks without necessarily rewriting the mixin itself.</p><pre>$xs: ( max:  767px );<br>$sm: ( min:  768px );<br>$md: ( min:  992px );<br>$lg: ( min: 1200px );</pre><p>While I looked at the various map options I then decided since the $sm and the $md breakpoint actually exist in the middle of other breakpoints there would be conditions where I would want to specifically target one of them without it bleeding into the breakpoints above it. So I added two more default maps.</p><pre>$sm-only: ( min: map-get($sm, min), max: map-get($md, min) — 1 );<br>$md-only: ( min: map-get($md, min), max: map-get($lg, min) - 1 );</pre><p>This would assign two new maps of $sm-only and $md-only, grabbing the min value of the $sm and $md maps and setting the max to one less pixel than the breakpoint larger. This way I could edit the $sm and $md breakpoints without having to worry about editing these as well.</p><h3>Building Out the Query Statement</h3><p>The media query essentially has three possible conditions depending on what values are in the map. There is min only, max only, and min and max collectively. As I broke down the conditional checking it made sense that the only real result of having both min and max was the inclusion of the word “and” in the media query.</p><pre>@media screen and (min-width: ...) <strong>and</strong> (max-width: ...) { }</pre><p>So rather than having multiple if/elseif conditionals that write out the complete result it seemed to make more sense to append onto the query based on the results of each condition.</p><pre><a href="http://twitter.com/mixin">@mixin</a> breakpoint($map) {<br>  $query: “”;<br>  <a href="http://twitter.com/if">@if</a> map-has-key($map, min) {<br>    $query: append($query, “(min-width: #{map-get($map, min)})”)<br>  }<br>  <a href="http://twitter.com/if">@if</a> map-has-key($map, min) and map-has-key($map, max) { <br>    $query: append($query, “and”)<br>  }<br>  <a href="http://twitter.com/if">@if</a> map-has-key($map, max) { <br>    $query: append($query, “(max-width: #{map-get($map, max)})”) <br>  }<br>  <a href="http://twitter.com/media">@media</a> screen and #{$query} { <a href="http://twitter.com/content">@content</a>; }<br>}</pre><p>This way we start off with a blank query and slowly build onto that query only the items that we need. Doing it these way removes any duplication within the various conditions that existed in the previous version.</p><p>Altogether not only is the weight of the mixin much leaner, but with the attributes found in maps it makes even more expansive and clear as well. Remember too, that I use xs, sm, md, and lg because of my workflow. Those values could just as easily be mobile, table, desktop, and widescreen.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f876e3dcc76cd9f572f9808bdb014818/href">https://medium.com/media/f876e3dcc76cd9f572f9808bdb014818/href</a></iframe><blockquote>“Our life is frittered away by detail. Simplify, simplify.”<br>~ <strong>Henry David Thoreau</strong></blockquote><p><em>I’m a User Experience Architect, musician, and martial artist trying to redefine how we prototype web applications working at </em><a href="http://www.twitter.com/gravityfreedom"><em>GravityFree</em></a><em> in Florida.</em></p><p><em>If you’ve enjoyed this post, please hit “</em><strong><em>recommend</em></strong><em>” and please say hello and introduce yourself on </em><a href="https://twitter.com/timknight"><em>Twitter</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=71205dd6badd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/developing-with-sass/refactoring-my-simple-sass-breakpoint-mixin-71205dd6badd">Refactoring My “Simple” Sass Breakpoint Mixin</a> was originally published in <a href="https://medium.com/developing-with-sass">Developing with Sass</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>