├── .editorconfig
├── LICENSE
├── README.md
├── index.css
├── index.js
└── package.json
/.editorconfig:
--------------------------------------------------------------------------------
1 | # editorconfig.org
2 | root = true
3 |
4 | [*]
5 | indent_style = tabs
6 | indent_size = 2
7 | end_of_line = lf
8 | charset = utf-8
9 | trim_trailing_whitespace = true
10 | insert_final_newline = false
11 |
12 | [*.{md,markdown}]
13 | # Allow
from Markdown
14 | trim_trailing_whitespace = false
15 |
16 | [*.json]
17 | indent_style = spaces
18 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
11 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
12 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
13 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
14 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
15 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
16 | SOFTWARE.
17 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Modular Scale
2 |
3 | A modular scale is a list of values that share the same relationship. These values are often used to size type and create a sense of harmony in a design. Proportions within modular scales are all around us from the spacing of the joints on our fingers to branches on trees. These natural proportions have been used since the time of the ancient Greeks in architecture and design and can be a tremendously helpful tool to leverage for web designers.
4 |
5 | Ems work especially well with modular scales as their recursive properties mimic modular scales making them more predictable and easier to manage. Pixels and other units work just fine and breakpoints in responsive web design can naturally fall on your scale to create better relevance to your text as all the values in your layout harmonize with each other.
6 |
7 | To get started, you need to select a ratio and a base value. The base value is usually your text font size or 1em. This base size paired with a ratio such as the golden ratio or any musical proportion will create your scale of values which all share this proportion.
8 |
9 | ## Install
10 | - `npm install css-modularscale`
11 | - then, in your css:
12 | `@import "css-modularscale"`
13 |
14 | ## Compatability
15 | `css-modularscale` is created with future CSS syntax in mind. For more information about CSS variables and the spec, consult [The W3C's Working Draft on the topic](http://www.w3.org/TR/css-variables/).
16 | You can use any CSS "postprocessor" that has support for custom properties, such as [PostCSS](https://github.com/postcss) or [Rework](https://github.com/reworkcss/). If you want to get started fast, I recommend checking out the [CSSNext project](https://github.com/cssnext/cssnext).
17 |
18 | ## Usage
19 |
20 | Modular Scale has two default variables that you should place with your other site wide variables. `--ms-base` is usually your font size or `1rem`. `--ms-ratio` is the factor of change between each number so if the ratio is `1.5` then each number in the sequence will be 1.5 times that of the previous number.
21 |
22 | ```css
23 | :root {
24 | --ms-base: 1em;
25 | --ms-ratio: var(--golden);
26 | }
27 | ```
28 |
29 | Modular-scale is used as a custom property. Simply pass it through in place of any value to use a value based on a modular scale.
30 |
31 | ```scss
32 | font-size: var(--ms2); // two up the modular scale
33 | ```
34 |
35 | ## Ratios
36 |
37 | Modular scale includes functions for a number of classic design and musical scale ratios. You can add your own ratios as well.
38 |
39 | By default, the variable `--ms-ratio` is set to `--golden`.
40 |
41 |
Function | Ratio | Decimal value |
---|---|---|
--phi | 1:1.618 | 1.618 |
--golden | 1:1.618 | 1.618 |
--double-octave | 1:4 | 4 |
--major-twelfth | 1:3 | 3 |
--major-eleventh | 3:8 | 2.667 |
--major-tenth | 2:5 | 2.5 |
--octave | 1:2 | 2 |
--major-seventh | 8:15 | 1.875 |
--minor-seventh | 9:16 | 1.778 |
--major-sixth | 3:5 | 1.667 |
--minor-sixth | 5:8 | 1.6 |
--fifth | 2:3 | 1.5 |
--augmented-fourth | 1:√2 | 1.414 |
--fourth | 3:4 | 1.333 |
--major-third | 4:5 | 1.25 |
--minor-third | 5:6 | 1.2 |
--major-second | 8:9 | 1.125 |
--minor-second | 15:16 | 1.067 |