Super easy to use Sass mixins to establish a typographic system with modular scale and vertical rhythm. Based on the Gridlover app.
Gridlover gives you adjustable css for font sizes, line heights and margins. The default css output is for body, p and h1 - h4 headings, but you can of course apply your adjusted values to any element by editing the css later.
Go play around with the awesome Gridlover app!
It's so much fun! :D
Sassy-Gridlover consists of 3 configurable variables:
$baseFontSize;
$baseLineHeight;
$scaleFactor;
and 3 mixins:
@mixin sassy-gridlover-body();
@mixin sassy-gridlover-heading();
@mixin sassy-gridlover-margins();
These are the 3 functionalities of the Gridlover app that you (should) have been playing with.
Import _sassy-gridlover.scss
to your main style sheet.
@import "sassy-gridlover";
Change the configurable variables values in _config.scss
to your liking.
// Scale factor variables.
// Don't change these variables!
$minorSecond: 1.067;
$majorSecond: 1.125;
$minorThird: 1.2;
$majorThird: 1.25;
$perfectFourth: 1.333;
$augmentedFourth: 1.414;
$perfectFifth: 1.5;
$minorSixth: 1.6;
$goldenSection: 1.618;
$majorSixth: 1.667;
$minorSeventh: 1.778;
$majorSeventh: 1.875;
$octave: 2;
$majorTenth: 2.5;
$majorEleventh: 2.667;
$majorTwelfth: 3;
$doubleOctave: 4;
// Default font size.
// Don't change this variable!
$defaultFontSize: 16;
// Configurable variables.
// Ok... You can change these variables! :D
$baseFontSize: 18;
$baseLineHeight: 1.2;
$scaleFactor: $goldenSection;
By default, all the mixins will only output px
. But you can also choose to output rem
.
To use in <body>
.
Outputs font-size
and line-height
.
@mixin sassy-gridlover-body($fontSize: $baseFontSize, $rem: false)
Accepts 2 arguments:
$fontSize
: Specifies the base font size (without unit, just a number).$rem
: Outputs rem units iftrue
(false
by default).
To use in headings <h1> - <h4>
.
Outputs font-size
, line-height
, margin-bottom
and margin-top
.
@mixin sassy-gridlover-heading($step, $rem: false)
Accepts 2 arguments:
$step
:<h1>
→$step: 3
<h2>
→$step: 2
<h3>
→$step: 1
<h4>
→$step: 0
$rem
: Outputs rem units iftrue
(false
by default).
To use in <p>
, <ul>
, <ol>
, <pre>
, <table>
, <blockquote>
, etc.
Outputs margin-bottom
and margin-top
.
@mixin sassy-gridlover-margins($rem: false)
Accepts 1 argument:
$rem
: Outputs rem units iftrue
(false
by default).
###SCSS
@import "sassy-gridlover.scss";
body {
@include sassy-gridlover-body($baseFontSize, true);
}
h1 {
@include sassy-gridlover-heading(3, true);
}
h2 {
@include sassy-gridlover-heading(2, true);
}
h3 {
@include sassy-gridlover-heading(1, true);
}
h4 {
@include sassy-gridlover-heading(0, true);
}
p, ul, ol, pre, table, blockquote {
@include sassy-gridlover-margins(true);
}
###CSS OUTPUT
body {
font-size: 18px;
line-height: 22px;
font-size: 1.125rem;
line-height: 1.375rem; }
h1 {
font-size: 76px;
line-height: 88px;
margin-bottom: 22px;
margin-top: 44px;
font-size: 4.75rem;
line-height: 5.5rem;
margin-bottom: 1.375rem;
margin-top: 2.75rem; }
h2 {
font-size: 47px;
line-height: 66px;
margin-bottom: 22px;
margin-top: 44px;
font-size: 2.9375rem;
line-height: 4.125rem;
margin-bottom: 1.375rem;
margin-top: 2.75rem; }
h3 {
font-size: 29px;
line-height: 44px;
margin-bottom: 22px;
margin-top: 22px;
font-size: 1.8125rem;
line-height: 2.75rem;
margin-bottom: 1.375rem;
margin-top: 1.375rem; }
h4 {
font-size: 18px;
line-height: 22px;
margin-bottom: 22px;
margin-top: 22px;
font-size: 1.125rem;
line-height: 1.375rem;
margin-bottom: 1.375rem;
margin-top: 1.375rem; }
p, ul, ol, pre, table, blockquote {
margin-bottom: 22px;
margin-top: 22px;
margin-bottom: 1.375rem;
margin-top: 1.375rem; }
- Gridlover app - The tool to establish a typographic system with modular scale and vertical rhythm.
- Knife - Nail vertical rhythm, modular scale, and REMs like a boss with this simple set of SASS/SCSS variables, functions and mixins.
- gridlover-mixin - A mixin to generate modular scale and vertical rhythm for your typography.
Thanks to:
- Gridlover app - Created by Tuomas Jomppanen & Ville Vanninen.
- Sassy-math © 2012 - For the
@function exponent()
. Created by Sam Richard, Mario Valencia and Scott Kellum
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.
In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to http://unlicense.org/