No description, website, or topics provided.
Ruby
Pull request Compare This branch is 179 commits behind modularscale:2.x.
Fetching latest commit…
Cannot retrieve the latest commit at this time.

readme.mdown

Sassy Modular Scale

Put down the calculator and let Sass do the work.

Sassy Modular Scale is a Sass based mixin that calculates the incremental values of the modular scale in proportion to a set size and ratio. It was inspired by and adapted from Tim Brown's modularscale.com.

Sassy Modular Scale can be used as a Compass extension and can be installed as a Ruby gem.

Installation

Usage requires Sass. Visit sass-lang.com to learn more and install.

gem install modular-scale

Add require 'modular-scale' to your Compass config file.

Import the file into your stylesheets: @import 'modular-scale';

Alternative installation (without Compass)

Compass provides a way for Sass mixins to be easily required into a project, but we also support the following:

  • Copy either stylesheets/_modular-scale.sass or stylesheets/_modular-scale.scss into your project's Sass directory
  • Import the file into your Sass stylesheet to access the mixins and functions. For example, @import vendor/modular-scale

Usage

Modular-scale should primarily be used as a function. Simply pass it through in place of any value to generate a value based on a modular scale.

width: modular-scale(2); // two up the modular scale
width: ms(2); // Shorthand for the line above
width: modular-scale(2, 1em); // two up the modular scale with a base size of 1em
width: modular-scale(2, 1em, $octave); // Same as above but on an octave scale

You can output a list to your terminal to help you find out what values are on your scale.

@include modular-scale-list($start, $end, $base-size, $ratio);

By default, it writes 0-20 on the scale. You can also use shorthand to make things more efficient.

@include ms-list; // shorthand without attributes
@include ms-list($start, $end, $base-size, $ratio); // shorthand with attributes

As a side effect of the modular-scale functions a exponent function is also available.

@include exponent($base, $exponent);

Sassy Modular Scale can be used as a function, mixin or a mixin that generates a range of classes to @extend.

// Use as a function. Fill in the multiple, base-size, and ratio
height: modular-scale(7, 16px, $golden);

This method will generate a range of classes to @extend

@include modular-scale-classes(6);

h1 { @extend .ms-2; }
h2 { @extend .ms-1; }
h3 { @extend .ms-0; }

You can also 'lace' multiple ratios together by passing them in as a list (space-separated)

.lace {
  width: ms(7, 16px, $golden $fourth);
}

You can also set the $base-size variable to a list to interrelate two significant known sizes in your design note: the starting point of the scale will always be the lowest value in this list

.multibases {
  width: ms(7, 16px 300px, $golden);
}

You can use multiple $base-sizes and multiple $ratios together

.multibase-multiratio {
  width: ms(7, 16px 300px, $golden $fourth);
}

Ratios

Below is a list of Ratios to choose from. By default, the variable $ratio is set to $golden.

  • $golden: 1.618
  • $double-octave: (4 / 1)
  • $major-twelfth: (3 / 1)
  • $major-eleventh: (8 / 3)
  • $major-tenth: (5 / 2)
  • $octave: (2 / 1)
  • $major-seventh: (15 / 8)
  • $minor-seventh: (16 / 9)
  • $major-sixth: (5 / 3)
  • $minor-sixth: (8 / 5)
  • $fifth: (3 / 2)
  • $augfourth: (1 / √2)
  • $fourth: (4 / 3)
  • $major-third: (5 / 4)
  • $minor-third: (6 / 5)
  • $major-second: (9 / 8)
  • $minor-second: (16 / 15)

Inspiration

Sassy Modular Scale was adapted from modularscale.com by Tim Brown (@nicewebtype). Tim also wrote a supporting article at A List Apart titled "More Meaningful Typography". Additional inspiration goes to Robert Bringhurst, author of "The Elements of Typographic Style" - specifically Chapter 8 titled "Shaping the Page"

License

Copyright (c) 2011 Scott Kellum (@scottkellum), Adam Stacoviak (@adamstac) and Mason Wendell (@canarymason)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

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 OR COPYRIGHT HOLDERS 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.