Piotr Sikora - Logo - Automatyzacja procesów | AI | JavaScript | Front End | Team Leader
  • Home
  • Services
    • Process Automation
    • AI for Lawyers
  • Blog
  • Quotes
  • Contact
PL/EN

LazySass: Emmet-Based Mixins in Sass

  • Home
  • Blog
  • LazySass: Emmet-Based Mixins in Sass
LazySass: Emmet-Based Mixins in Sass

By Piotr Sikora

  • css

  • 3 min read

Table of Contents

  • LazySASS The idea
  • Next step - LazySASS extended
  • Let’s summarize
  • LazySASS

I’m so lazy that I forgot to write any post on this website for last few months… And this post will be about my laziness as well :).

Ive been working on my blog’s new skin for last few months - last few months because of lots of projects on board. What I’ve made during working on this projects was creating own small framework. This is not that kind of frameworks which are worldwide known like Foundation or Bootstrap. It is rather related with writing own atomic mixins in SASS to smaller down the code flood in the project. I’ve based it on Emmet project a little bit and counting of units from Foundation project (pixels to rems).

LazySASS The idea

Project was started during writing of my book "Professional CSS3" (published by PACKT Publishing) and was called as a single file _shorts.sass. It was a collection of short forms of well known CSS rules.

=tdn
    text-decoration: none

=tdu
    text-decoration: uppercase

=tac
    text-align: center

=tar
    text-align: right

=tal
    text-align: left

=ttu
    text-transform: uppercase

=ttl
    text-transform: lowercase

=di
    display: inline

=db
    display: block

=dib
    display: inline-block

=m0a
    margin: 0 auto

It was used to shorten the most known CSS rules in final code like:

.className
  +di // display: inline-block
  +tac // text-align: center
  +ttu // text-transform: uppercase

Yeah… pretty small change and… unreadable. Creates additional stack of unknown rules… looks like additional new language. But who is not working with EMMET (previously known as ZenCoding)? It’s not another new language just based on EMMET basics.

Next step - LazySASS extended

Next problem which for me was the most repeatable were correct units. Ive sticked to REM instead of Pixels which made layout more adjustable. Ive been using remCalc() which was changing pixels to REM’s. But the problem is repeating of this function. Lets define remCalc in SASS:

@function remCalc($value)
   $rem: $value / 16px
   @return #{$rem}rem

So each time when I wanted to apply the REM value I needed to invoke function:

h1
  font-size: remCalc(32px)

This generated:

h1 {
  font-size: 2rem;
}

But… what if I wanted to change the font for example to 21px and it gives me 1.3125rem? In inspector its hard to multiply it and know what was the base of this equation. Ive been moving from one unit to another but it could be based on one variable kept globally and one mixin:

$UNIT_REM: true // pixels / rems

@function _countUnits($value)
  @if ($UNIT_REM)
    $rem: $value / 16px
    @return #{$rem}rem
  @else
    @return $value

Now we need to apply mixins which converts pixels to rems like this:

=mt($value)
  margin-top: _countUnits($value)

=ml($value)
  margin-left: _countUnits($value)

=mr($value)
  margin-right: _countUnits($value)

=mb($value)
  margin-bottom: _countUnits($value)

Each time when you want to change it to pixels you are setting $UNIT_REM to false. Now it is easier to inspect the size units.

Let’s summarize

So now when you want to describe element you can use code like this:

.single_article__book__content
  +posa
  +t(0px)
  +w(470px)

.single_article__book__img
  +r(0px)
  +t(0px)
  +fr
  +posr

... will compile to:

.single_article__book__content {
  position: absolute;
  top: 0;
  width: 465px;
}
.single_article__book__img {
  right: 0;
  top: 0;
  float: right;
  position: relative;
}

…or:

.single_article__book__content {
  position: absolute;
  top: 0rem;
  width: 29.375rem;
}

.single_article__book__img {
  right: 0rem;
  top: 0rem;
  float: right;
  position: relative;
}

… in case of setted units to REM’s.

LazySASS

Code of LazySASS is available here: https://github.com/fedojo/LazySASS/blob/master/_shorts.sass!

Share this article

TwitterLinkedInFacebook

Tags:

  • #css

  • #emmet

  • #sass

  • #scss

Categories

after-hours(1)AI(7)ai-en(1)angular(4)automatic-tests(1)Automation(2)cryptography(1)css(8)CyberSecurity(2)Development(6)DevOps(1)events(3)javascript(11)n8n(10)ollama(1)security(2)seo(1)

Recent Posts

Testing Kimi Code: First Impressions from Web and CLI

Development

Testing Kimi Code: First Impressions from Web and CLI

Why You Shouldn't Cram Multiple Webhooks Into One n8n Workflow

Automation

Why You Shouldn't Cram Multiple Webhooks Into One n8n Workflow

DRY, WET, AHA: Finding the Right Balance in Code Reuse

Development

DRY, WET, AHA: Finding the Right Balance in Code Reuse

API vs Webhook: Understanding the Difference

Development

API vs Webhook: Understanding the Difference

RTCROS Framework: Structure Your Prompts for Better AI Results

AI

RTCROS Framework: Structure Your Prompts for Better AI Results

About Me

Piotr Sikora - Process Automation | AI | n8n | Python | JavaScript

Piotr Sikora

Process Automation Specialist

I implement automation that saves time and money, streamlines operations, and increases the predictability of results. Specializing in process automation, AI implementation, and workflow optimization using n8n, Python, and JavaScript.

n8n Workflows

n8n workflow automation templates

Explore my workflow templates on n8n. Ready-to-use automations for blog management, data collection, and AI-powered content processing.

3Workflow Templates
View Templates

• Auto-Categorize Blog Posts with AI

• Collect LinkedIn Profiles

• Export WordPress Posts for SEO

Tags

activepiecesafter-hoursahrefsaiAI cost reductionai-agentsai-automationangularantigravityapiAqua Securityarcade-gamesarchitectureautomationbackendbest-practicescadillacs-and-dinosaurschatbotchatgptCI/CD
“An intellectual says a simple thing in a hard way, an artist says a hard thing in a simple way.”
Charles Bukowski
View more quotes

Similar Articles

Discover more related content

Professional CSS by Piotr Sikora

Professional CSS by Piotr Sikora

It's been a long time... I should tell about this book.

Master SASS Installation with This Quick Guide

Master SASS Installation with This Quick Guide

Ever dreamed of variables or functions in CSS? The easiest way to get them is by using a preprocessor like SASS.

3 April 2014
Pure CSS Collapsible Elements: Create Accordion

Pure CSS Collapsible Elements: Create Accordion

Learn how to create collapsible elements and accordion components using pure CSS-no JavaScript needed

Piotr Sikora | ai | n8n | javascript | python

Let's get to know each other!

Get in touch with me
Piotr Sikora | Process Automation  | AI Implementation 🤖 | Technology Consulting
Quick links
  • Home
  • Blog
  • Contact
Contact
  • piotr.sikora.ck@gmail.com
  • +48 505 684 661

© Piotr Sikora 2026 | All Rights Reserved