No description, website, or topics provided.
Pull request Compare This branch is 185 commits behind modularscale:2.x.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
stylesheets
test
.gitignore
.rvmrc
Gemfile
Gemfile.lock
Rakefile
modular-scale.gemspec
readme.mdown

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

Then add require 'modular-scale' to your Compass config file.

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

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

Examples using the Sass syntax:

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

// Use as a mixin. Fill in the property, multiple, base-size, and ratio
+modular-scale(line-height, 1, 14px, $golden)

// This method will generate a range of classes to `@extend`
+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, 14px, $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, 14px 300px, $golden)

// You can use multiple $base-sizes and multiple $ratios together
.multibase-multiratio
  width: ms(7, 14px 300px, $golden $fourth)

Examples using the SCSS syntax:

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

// Use as a mixin. Fill in the property, multiple, base-size, and ratio
@include modular-scale(line-height, 1, 14px, $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, 14px, $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, 14px 300px, $golden);
}

// You can use multiple $base-sizes and multiple $ratios together
.multibase-multiratio {
  width: ms(7, 14px 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
  • $octave: 2 / 1
  • $major-seventh: 15 / 8
  • $minor-seventh: 16 / 9
  • $major-sixth: 5 / 3
  • $minor-sixth: 8 / 5
  • $fifth: 3 / 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.