Sassiin
Sassiin is the CSS authoring framework for rapid web development. It is the only Sass framework that really takes advantage of all the latest features of Sass (3.4 and up). Sassiin's amazing breakpoint system combined with declaration handlers, call-time generated variables and media query aware placeholders takes the CSS development to the next level. Please give it a go and let me know your thoughts!
Contents
1. Easy Installation
NPM or Bower
i. Install withnpm i --save-dev sassiin
I you have not installed Bower yet, follow the instructions on Bower website.
If this is the first time you use Bower, you might want to create project specific manifest file bower.json. Change to your project directory and run the following command:
bower init
You can install Sassiin by running the following command:
bower install sassiin --save-dev
ii. Import Sassiin
Last step is to import _sassiin.scss in every file that requires Sassiin, usually in your project's main Sass file:
2 Usage Instructions
i. Media Queries
Media query generation is made easy in Sassiin. Let's say that we wanted to create a horizontal navigation menu which is hidden in small resolution devices and in print. The navigation menu also becomes vertical in medium resolution devices. This is how we would do it in Sassiin:
.navigation
Generated CSS will look as follows:
{ } { }
In Sassiin underscore character means "or". A string followed by two numbers is converted to min-max-range. Single number is converted to min-width and single string generated as is. As an example:
.navigation
Results in:
{ }
ii. Breakpoints
Breakpoint system is one of the most important features of Sassiin. With it stylesheet development could not be any easier. There are two types of breakpoints; breakpoints with at least one dimension and breakpoints without any dimensions.
To be continued...
iii. Variables
There are few reasons why I decided to add a variable system to Sassiin. Firstly, I wanted to circumvent problems caused by global variables. Secondly, I wanted to have an option to define variables generated on call-time by one or more mutator functions. Thirdly, I wanted to make the use of a variable, media query aware.
a. No To Global Scope
In Sassiin get-function is used to retrieve and set-mixin to store key-value-pairs. This is how we use them:
; // @return red
You can also store multiple key-value-pairs at once:
; ; // @return red ; // @return green
Also when you are retrieving a value with get-function and the value for given key is not found, you can define the returned default value. This is how you do it:
; // @return this is default value
b. Custom Scope
Sassiin let's you define scope for key-value-pairs.
; // @return red ; // @return blue
c. Media Query Awareness
Let's see an example of how variables are media query aware in Sassiin.
; body
The result is as follows:
{ } { } { }
As you can see, the line height is different for small devices just like we wanted.
d. Mutator Function
The reason why people use Sass is that it allows you to create reusable stylesheets that are customizable with variables. Sass is pretty flexible but there is a one little problem. I'm quite sure that I'm not the only one adding my variables inside a map. The reason why I'm doing this is to keep the global scope clean. Let's say that I wanted to create three variables, one for primary color, one for darker version of it and one more to control the amount of primary color's brightness reduction. Now how do we do this with Sass maps?
; ; ;
There goes the readability... Now let's see how this is done with Sassiin using functions as mutator functions:
("@get" primary-color-darken-amount))); ;
Pretty neat huh?
iv. Handlers
Sassiin's handler system allows you to attach handler functions on CSS declarations. Let's have an example. First, let's make a handler function which adds common browser prefixes to each processed property:
The next step is to register the handler:
The code tells Sassiin to only attach the handler on the given list of properties. Sassiin handlers are called by using _ mixin:
The generated CSS will look as follows:
-);-);-);-););
v. Placeholders
Sassiin's placeholder system is quite awesome. That's because Sassiin let's you create media query aware placeholders. As an example, let's first create a placeholder which hides element visually:
As you can see placeholder is a simple mixin that uses placeholder and extend mixins. Now let's see how the placeholder is used.
.hidden-heading .hidden-element .hidden-link
What Sassiin does is that it automagically extends the correct placeholder based on the unique ID generated for each media query. The result is as follows:
{}
3 TODO
- Describe functions and mixins by adding @description annotation to them
- Documentation
- Tests
4 Author
Lauri Tunnela is a young and passionate B.Eng. from Finland. He does everything from embedded C development to front-end web development. Lauri loves to build tools that make software development fast and easy for everyone. He hopes you to use Sassiin as you see fit. Although, as its developer he would be more than happy to know where you've used it and what are your thoughts about it! For contact details see Lauri's profile.
5 License
Sassiin is licensed under The MIT License (MIT).
Copyright (c) 2015 Lauri Tunnela