<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Andrej Mlinarević on Medium]]></title>
        <description><![CDATA[Stories by Andrej Mlinarević on Medium]]></description>
        <link>https://medium.com/@amlinarev?source=rss-b7bdb173ce0c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*MvO8hxLWmNN85Rrv-bX92g.jpeg</url>
            <title>Stories by Andrej Mlinarević on Medium</title>
            <link>https://medium.com/@amlinarev?source=rss-b7bdb173ce0c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 10:01:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@amlinarev/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Set up typographic defaults using Sass & Compass Vertical Rhythm — volume 2 ]]></title>
            <link>https://medium.com/@amlinarev/set-up-typographic-defaults-using-sass-compass-vertical-rhythm-volume-2-8e51498c3713?source=rss-b7bdb173ce0c------2</link>
            <guid isPermaLink="false">https://medium.com/p/8e51498c3713</guid>
            <dc:creator><![CDATA[Andrej Mlinarević]]></dc:creator>
            <pubDate>Wed, 02 Apr 2014 23:12:41 GMT</pubDate>
            <atom:updated>2014-04-08T07:34:18.832Z</atom:updated>
            <content:encoded><![CDATA[<h4>This article is an updated version of my previous article “Using Sass &amp; Compass Vertical Rhythm to set up typography defaults in a project”. This time the new Sass 3.3 Maps was used to build the typographic system.</h4><h3>Meet Typomatic — a Sass &amp; Compass based typographic kit</h3><p>Since my last article got a lot of great comments and recommendations, I decided to round up everything in a <a href="https://github.com/andrejmlinarevic/typomatic">GitHub repo — Typomatic</a> to get better community feedbacks and keep the code up to date. The repo is under construction, feel free to contribute!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MwfXhOeAJDNSsr4nRvzH6A.png" /><figcaption>Typomatic demo</figcaption></figure><h3><strong>The prerequisites — Compass Vertical Rhythm + Sass Maps</strong></h3><p>Since we’ll be setting our font-sizes in REM units with pixel fallbacks, we have to use the prerelease version of <a href="http://beta.compass-style.org/">Compass 1.0</a> (until a stable version is available) and it’s Vertical Rhythm module with the new <a href="http://sass-lang.com/">Sass 3</a>.3+ with Sass Maps support.</p><h3>Typographic scale</h3><p>A typographic scale of a web project is a scale of different font sizes used for various purposes like body text, buttons, labels, input fields etc.</p><p>The whole idea of this approach is to have an unified and connected typographic scale across our whole site or app. I needed a really practical way of utilising the superb Compass Vertical Rhythm module without repeating myself (keepin’ the whole thing DRY).</p><p>For this example, we’ll use the 1:1250 typographic scale (Major Third). You can use a scale of your choice, or make up a new scale — it’s all up to you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/629/1*eKaGwuR5Zl1l052YRhW7Hg.png" /><figcaption>A 1:1250 typographic scale (source: <a href="http://type-scale.com/">http://type-scale.com/</a>)</figcaption></figure><p>The base font size of my choice is 20px (1rem). Multiplying the base font size with the 1:1250 ratio gives us a nicely contrasted but subtle scale. Rounding it all up we get a list of proportional sizes: 13px, 16px, 20px, 25px, 31px, 39px, 49px.</p><h3>Setting up Compass Vertical Rhythm</h3><p>A quick setup is needed for the Compass Vertical Rhythm. The <em>base-font-size </em>is the desired 20px, while the <em>base-line-height</em> is 32px for a cosy reading experience. The units in this case are <em>rems </em>without pixel fallbacks.</p><pre>$base-font-size: 20px;<br>$base-line-height: 32px;<br>$rhythm-unit: &quot;rem&quot;;<br>$rem-with-px-fallback: false;</pre><h3><strong>Setting up the environment using Sass Maps instead of variables</strong></h3><p>In the first article I wrote Sass variables were used to set up different font sizes. With the release of <a href="http://viget.com/extend/sass-maps-are-awesome">Sass Maps</a> in the Sass 3.3 version we can now group our variables in a map as values.</p><p>Let’s define all of the font size variations in our scale — <em>tiny</em>, <em>small</em>, <em>base</em>, <em>medium</em>, <em>large</em>, <em>xlarge </em>and <em>xxlarge </em>in a Sass Map. We can even extend the maps with more parameters like letter-spacing etc, but that’s another story.</p><p>In the <em>config.scss</em> file font size variations are kept as a nested map with multiple values (<em>font-size</em> and <em>base-lines</em>).</p><pre><br>$type-scale: (<br>  tiny: (<br>    font-size: 13px,<br>    base-lines: 0.5<br>  ),<br>  small: (<br>    font-size: 16px,<br>    base-lines: 0.75<br>   ),<br>  base: (<br>   font-size: $base-font-size,<br>   base-lines: 1<br>  ),<br>  medium: (<br>    font-size: 25px,<br>    base-lines: 1<br>  ),<br>  large: (<br>    font-size: 31px,<br>    base-lines: 1<br>  ),<br>  xlarge: (<br>    font-size: 39px,<br>    base-lines: 1.5<br>  ),<br>  xxlarge: (<br>    font-size: 49px,<br>    base-lines: 2 <br>  )<br>);</pre><h3>Getting the data from the nested map and feeding it in a type-scale mixin</h3><p>The whole point of the project is to achieve a modular typographic scaling system, we need to utilise the Sass goodness to get the type scaling functionality running in a mixin.</p><p>Since there is no native Sass way (at least not to my knowledge) of getting a deep value from a multi level map, <a href="https://gist.github.com/jlong/8760275">I’ve used a nice little function from J.W.Long that does the trick</a>. The function is implemented in the <em>functions.scss</em> file in the project.</p><p>The <em>typomatic.scss </em>file is where all the magic happens with a super simple <em>type-scale</em> mixin. The mixin takes two argumens, <em>$scale </em>and <em>$map</em>. The scale is the defined scale of the type (small, big etc.). The map is the name of the Sass map that holds the data — you can feed it with as many maps as you wish and generate different scales.</p><pre><a href="http://twitter.com/mixin">@mixin</a> type-scale($scale, $map: $type-scale) {<br>  $font-size: map-fetch($map, $scale font-size);<br>  $base-lines: map-fetch($map, $scale base-lines);<br>  <a href="http://twitter.com/include">@include</a> adjust-font-size-to($font-size, $base-lines);<br>}</pre><h3>Styling the elements</h3><p>A basic website or web app usually has several levels of headings (h1, h2, h3…), paragraphs, various lists and other typographic elements that have a font-size and a line-height that need attention.</p><p>All we now have to do is <em>@include </em>the <em>type-scale</em> mixin to an element of our choice!</p><pre>h1 {<br>  <a href="http://twitter.com/include">@include</a> type-scale(xxlarge);<br>}<br>h2 {<br>  <a href="http://twitter.com/include">@include</a> type-scale(xlarge);<br>}<br>small {<br>  <a href="http://twitter.com/include">@include</a> type-scale(small);<br>}</pre><h3><strong>Have an idea how to make Typomatic better? Contribute on GitHub!</strong></h3><p>The Typomatic offical <a href="https://github.com/andrejmlinarevic/typomatic">GitHub repository</a> is ready and running. I would love to see your contributions &amp; comments.</p><p>Cheers,</p><p>Andrej<br><a href="http://twitter.com/amlinarev">@amlinarev</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8e51498c3713" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A simple and nice list Sass mixin — using  em&en dashes. ]]></title>
            <link>https://medium.com/@amlinarev/a-simple-and-nice-list-sass-mixin-using-em-en-dashes-ae4e2584618f?source=rss-b7bdb173ce0c------2</link>
            <guid isPermaLink="false">https://medium.com/p/ae4e2584618f</guid>
            <dc:creator><![CDATA[Andrej Mlinarević]]></dc:creator>
            <pubDate>Mon, 27 Jan 2014 22:48:27 GMT</pubDate>
            <atom:updated>2014-01-27T22:53:55.950Z</atom:updated>
            <content:encoded><![CDATA[<h4>The default browser styles for the bulleted lists are a bit boring and not really pretty. Let’s fix that up with a quick Sass mixin by using em dashes before the text. </h4><p>Let’s set up some basic variables first. The <em>$list-nice-dash</em> is an option between an en-dash and an em-dash respectively. Use <em>$list-nice-generate-html-class</em> variable for HTML class generation for the list (for further reuse).</p><pre>$list-nice-dash: &quot;em-dash&quot;; // or &quot;en-dash&quot;<br>$list-nice-generate-html-class: true;</pre><p>And here goes the mixin. It utilised the CSS <em>::before</em> pseudo element and a <em>content</em> attribute to add dashes before the text in the list.</p><pre><a href="http://twitter.com/mixin">@mixin</a> list-nice($dash: $list-nice-dash) {<br>   list-style: none none;<br>   position: relative;<br>   padding: 0; // reset normalize.css padding<br>   &amp; &gt; * {<br>      padding-left: 2em;<br>      margin-bottom: 1em;<br>      &amp;:before {<br>         position: absolute;<br>         left: .3em;<br>      }<br>    }<br>    <a href="http://twitter.com/if">@if</a> $dash == em-dash {<br>    &amp; &gt; * {<br>       &amp;:before {<br>          content: ‘\2014&#39;;<br>          }<br>       }<br>    }<br>    <a href="http://twitter.com/if">@if</a> $dash == en-dash {<br>    &amp; &gt; * {<br>       &amp;:before {<br>          content: ‘\2013&#39;;<br>          }<br>       }<br>    }<br>}</pre><p>I’ve used the * selector to make the mixin reusable on UL’s, OL’s and DL’s, also on other elements that need to look like a nice list.</p><p>To output the CSS class in the .css file we use a simple <em>@if</em> and <em>@include</em> the mixin in the class. Really simple stuff.</p><pre><a href="http://twitter.com/if">@if</a> $list-nice-generate-html-class == true {<br>    .list-nice {<br>        <a href="http://twitter.com/include">@include</a> list-nice;<br>    }<br>}</pre><p>That’s about it! For more Sass resources &amp; info follow me on @amlinarev.</p><p>Cheers,</p><p>And</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae4e2584618f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Sass & Compass Vertical Rhythm to set up typography defaults in a project.]]></title>
            <link>https://medium.com/@amlinarev/using-sass-compass-vertical-rhythm-to-set-up-typography-defaults-in-a-project-34fe2f1d2c02?source=rss-b7bdb173ce0c------2</link>
            <guid isPermaLink="false">https://medium.com/p/34fe2f1d2c02</guid>
            <dc:creator><![CDATA[Andrej Mlinarević]]></dc:creator>
            <pubDate>Tue, 14 Jan 2014 09:32:46 GMT</pubDate>
            <atom:updated>2014-04-03T07:02:11.699Z</atom:updated>
            <content:encoded><![CDATA[<h4>Good typography is the key to a successful web interface. It shapes the aesthetics and gives life to it’s content. This post is a overview of the typographic base used in some of my projects written in Sass and using Compass for it’s superb vertical rhythm mixins.</h4><blockquote>Before reading one must be aware of a newer, <a href="https://medium.com/p/8e51498c3713">updated version of this article</a> that utilises Sass Maps to achieve the same effect.</blockquote><p>The basic variables for the type settings are the $base-font-size, $base-line-height and $rhythm-unit. They are set in <em>pixels </em>for the <a href="http://beta.compass-style.org/reference/compass/typography/vertical_rhythm/">Compass vertical rhythm</a> to use as default values, then later on coverted to <em>rems </em>with pixel fallback (available in <a href="http://beta.compass-style.org/">Compass 1.0.0.alpha</a>).</p><h3>Setting up the basic variables.</h3><blockquote>// The base font size<br>$base-font-size: 18px;<br>// Base line height<br>$base-line-height: 30px;<br>// Rhythm unit (Compass vertical rhythm)<br>$rhythm-unit: “rem”;</blockquote><p>Pretty straightforward, right? Let’s set up the basics — base font size, it’s weight and color.</p><blockquote>$base-font-family: “Source Sans Pro”, “Helvetica Neue”, Helvetica, Arial, sans-serif;<br>$base-font-weight: 400;<br>$base-font-color: #303033;</blockquote><h3>Creating the type scale</h3><p>From here it get’s interesting. Every project has a typographic hierarchy, depending on the scale of the project, setting the sizes as variables is a practical way of keeping track (and changing, adjusting) of the type sizes at any moment.</p><p>You can use the <a href="http://modularscale.com/">http://modularscale.com/</a> to generate your font sizes. In this example, I used the perfect fourth (3:4) ratio with the base font size of 18px. Using the generator gives us a nice list of sizes, we round them up and get — 10, 14, 18, 24, 32, 43.</p><p>Now that we have our type scale, we can add them to the variables. For my projects I use the <em>tiny</em>, <em>small</em>, <em>base</em>, <em>medium</em>, <em>large</em> and <em>xlarge </em>sizes. You could add more sizes to the mix, but you should consider is it really necessary and will the users see a difference in two headings that are 2-3px different?</p><p>Always set up the leading for a every font size to avoid line collisions in the longer, multi-line paragraphs and headings. The fonts are set pixels, and then converted to rems with pixel fallbacks via Compass vertical rhythm <em>@include adjust-font-size-to()</em> mixin. The leading size depends on your typeface, and you should test the headings and the paragraphs before making the decisions. The <em>@include adjust-leading-to()</em> mixin takes care the rem calculations (and pixel fallbacks) for you.</p><pre>$tiny-font-size: 10px;<br>$tiny-font-leading: 0.75;<br>$small-font-size: 14px;<br>$small-font-leading: 0.75;<br>$base-font-size: 18px;<br>$base-font-leading: 1;<br>$medium-font-size: 24px;<br>$medium-font-leading: 1.25;<br>$large-font-size: 32px;<br>$large-font-leading: 1.25;<br>$xlarge-font-size: 43px;<br>$xlarge-font-leading: 1.5;</pre><h3>Generating the type scale</h3><p>For bigger projects, I create a <em>really</em> simple Sass mixin with all my type sizes to make it easy to inject the sizes in other elements. Depending on the desired type size, it uses the adjust-font-size and adjust-leading-to with the corresponding variables for different sizes.</p><pre>@mixin typeSize($size) {<br> @if $size == &quot;tiny&quot; {<br>  @include adjust-font-size-to($tiny-font-size);<br>  @include adjust-leading-to($tiny-font-leading);<br> }<br> @if $size == &quot;small&quot; {<br>  @include adjust-font-size-to($small-font-size);<br>  @include adjust-leading-to($small-font-leading);<br> }<br> @if $size == &quot;base&quot; {<br>  @include adjust-font-size-to($base-font-size);<br>  @include adjust-leading-to($base-font-leading);<br> }<br> @if $size == &quot;medium&quot; {<br>  @include adjust-font-size-to($medium-font-size);<br>  @include adjust-leading-to($medium-font-leading);<br> }<br> @if $size == &quot;large&quot; {<br>  @include adjust-font-size-to($large-font-size);<br>  @include adjust-leading-to($large-font-leading);<br> }<br> @if $size == &quot;xlarge&quot; {<br>  @include adjust-font-size-to($xlarge-font-size);<br>  @include adjust-leading-to($xlarge-font-leading);<br> }<br>}</pre><h3>Utilising DRY principles with Sass placeholders</h3><p>DRY stand for Don’t Repeat Yourself. Sass placeholders are an excellent example of the DRY philosophy. I won’t get into details on placeholders, if you haven’t used them you should, more info can be found <a href="http://krasimirtsonev.com/blog/article/Sass-mixins-extends-and-placeholders-differences-use-cases">here</a>.</p><p>First we create the font-weight placeholders for different font weights — obviously.</p><pre>// Type weights</pre><pre>%t-ultrastrong {<br> font-weight: 900;<br>}<br>%t-strong {<br> font-weight: 700;<br>}<br>%t-regular {<br> font-weight: 400;<br>}<br>%t-light {<br> font-weight: 300;<br>}<br>%t-ultralight {<br> font-weight: 200;<br>}</pre><p>Then we create different placeholders for different sizes, and additionally the classes for every size.</p><pre>// Type size variants </pre><pre>%t-tiny {<br> @include typeSize(tiny);<br>}<br>%t-small {<br> @include typeSize(small);<br>}<br>%t-base {<br> @include typeSize(base);<br>}<br>%t-medium {<br> @include typeSize(medium);<br>}<br>%t-large {<br> @include typeSize(large);<br>}<br>%t-xlarge {<br> @include typeSize(xlarge);<br>}<br>.t-tiny {<br> @include typeSize(tiny);<br>}<br>.t-small {<br> @include typeSize(small);<br>}<br>.t-base {<br> @include typeSize(base);<br>}<br>.t-medium {<br> @include typeSize(medium);<br>}<br>.t-large {<br> @include typeSize(large);<br>}<br>.t-xlarge {<br> @include typeSize(xlarge);<br>}</pre><pre>// Type — headings</pre><pre>#{headings(4)} {<br> margin: 0;<br>}<br>h1 {<br> @extend %t-xlarge;<br>}<br>h2 {<br> @extend %t-large;<br>}<br>h3 {<br> @extend %t-medium;<br>}<br>h4 {<br> @extend %t-base;</pre><p>Creating the placeholders gives us the possibility to use the <em>@extend</em> directive on any of our elements and save valuable lines of CSS and reduce repetition and redundancy. For example, if we have a <em>paragraph </em>in the <em>header </em>that need to look like an <em>h2 we </em>simply write the following:</p><pre>header &gt; p {<br>  @extend %t-large<br>}</pre><p>For all the other elements the procedure is the same.</p><pre>p {<br> @extend %t-base;<br> @extend %t-light;<br>}<br>small {<br> @extend %t-small;<br>}<br>strong, b {<br> @extend %t-strong;<br>}</pre><p>Using the @extend directive we can apply the font sizes and weights to all of our elements, and utilize the typeSize @mixin for including of the styles in the elements.</p><h3>Using Breakpoint to scale the type for different devices</h3><p>Text on smaller screens like smartphones and tablets is generally read from a smaller distance and the type sizes must be adjusted for a better reading experience.</p><p>I currently use the great <a href="http://breakpoint-sass.com/">Breakpoint-sass</a> module for creating all sorts of breakpoints. I won’t go trough the installation process of Breakpoint, it’s fairly straightforward and well documented on their website.</p><p>To create a break point using Breakpoint-sass we simply use the breakpoint mixin, $small-screen-width is a width or a min-width of your choice.</p><pre>@include breakpoint($small-screen-width)</pre><p>We’ve used our modular scale to get our type size scale, but for our application we would like to make the type smaller on a device with a screen width of 420px, for example. The great part of having a modular scale is that we can shift the size scale depending on the user’s device.</p><p>Our modular scale from the beginning of the post is:</p><ul><li>10 px — tiny font size</li><li>14 px — small font size</li><li>18 px— base font size</li><li>24 px— medium font size</li><li>32 px— large font size</li><li>43 px — xlarge font size</li></ul><p>Let’s move the scale to set the base font size to 14px for small screens. We take down the font size of every (except <em>tiny</em>, which is tiny enough) for a modular scale level. <em>Small</em> becomes <em>tiny</em>, <em>base</em> becomes <em>small</em> etc.</p><ul><li>10 px — tiny font size</li><li>10 px — small font size</li><li>14 px— base font size</li><li>18 px— medium font size</li><li>24 px— large font size</li><li>32 px — xlarge font size</li></ul><p>I’ve restructered the mixin from the beginning of the post to utilise the Breakpoint-sass module.</p><pre><a href="http://twitter.com/mixin">@mixin</a> responsiveTypeSize($size) {<br> <a href="http://twitter.com/if">@if</a> $size == &quot;tiny&quot; {<br>  <a href="http://twitter.com/include">@include</a> adjust-font-size-to($tiny-font-size, $tiny-font-leading);<br> }<br> <a href="http://twitter.com/if">@if</a> $size == &quot;small&quot; {<br>  <a href="http://twitter.com/include">@include</a> adjust-font-size-to($tiny-font-size, $tiny-font-leading);<br>  <a href="http://twitter.com/include">@include</a> breakpoint($small-screen-width) {<br>   <a href="http://twitter.com/include">@include</a> adjust-font-size-to($tiny-font-size, $tiny-font-leading);<br>  }<br> }<br> <a href="http://twitter.com/if">@if</a> $size == &quot;base&quot; {<br>  <a href="http://twitter.com/include">@include</a> adjust-font-size-to($small-font-size, $small-font-leading);<br>  <a href="http://twitter.com/include">@include</a> breakpoint($small-screen-width) {<br>   <a href="http://twitter.com/include">@include</a> adjust-font-size-to($base-font-size, $base-font-leading);<br>  }<br> }<br> <a href="http://twitter.com/if">@if</a> $size == &quot;medium&quot; {<br>  <a href="http://twitter.com/include">@include</a> adjust-font-size-to($base-font-size, $base-font-leading);<br>  <a href="http://twitter.com/include">@include</a> breakpoint($small-screen-width) {<br>   <a href="http://twitter.com/include">@include</a> adjust-font-size-to($medium-font-size, $medium-font-leading);<br>  }<br> }<br> <a href="http://twitter.com/if">@if</a> $size == &quot;large&quot; {<br>  <a href="http://twitter.com/include">@include</a> adjust-font-size-to($medium-font-size, $medium-font-leading);<br>  <a href="http://twitter.com/include">@include</a> breakpoint($small-screen-width) {<br>   <a href="http://twitter.com/include">@include</a> adjust-font-size-to($large-font-size, $large-font-leading);<br>  }<br> }<br> <a href="http://twitter.com/if">@if</a> $size == &quot;xlarge&quot; {<br>  <a href="http://twitter.com/include">@include</a> adjust-font-size-to($large-font-size, $large-font-leading);<br>  <a href="http://twitter.com/include">@include</a> breakpoint($small-screen-width) {<br>   <a href="http://twitter.com/include">@include</a> adjust-font-size-to($xlarge-font-size, $xlarge-font-leading);<br>  }<br> }<br>}</pre><p>Simple as that ☺ All of our type sizes have their mobile first “small-screen” equivalent. All of the headings, the paragraphs, lists and other typographic elements have two sizes — scaled on the modular scale.</p><p>This blogpost is a <em>work in progress</em>, and will be updated as I find out better ways of handling the typography on the web.</p><p>Let me know what you think!</p><p>Since Sass 3.3 is out I have been actively working on improving this method using Sass Maps. Stay tuned — the article is comming soon.</p><p>Follow <a href="http://twitter.com/amlinarev">@amlinarev</a> for more #sass goodness.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=34fe2f1d2c02" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>