GithubHelp home page GithubHelp logo

modular-scale's Introduction

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)

[role="main"]
  h1
    @extend .ms-2
  h2
    @extend .ms-1
  h3
    @extend .ms-0

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`
@ionclude modular-scale-classes(6);

[role="main"] {
  h1 { @extend .ms-2; }
  h2 { @extend .ms-1; }
  h3 { @extend .ms-0; }
}

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.

modular-scale's People

Contributors

adamstac avatar codingdesigner avatar scottkellum avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.