1.0.1 • Published 5 years ago

@ntdalbec/type-scale v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

type-scale

A Node.js library for dealing with HTML/CSS typographic scales

Installation

npm install @ntdalbec/type-scale

Usage

const { TypeScale, Scale } = require("type-scale");

const scale = new TypeScale({ scale: Scale.MajorThird });

console.log(`\
h1: ${scale.h1}
h2: ${scale.h2}
h3: ${scale.h3}
h4: ${scale.h4}
h5: ${scale.h5}
h6: ${scale.h6}
`)

// expected:
// h1:   3.052em
// h2:   2.441em
// h3:   1.953em
// h4:   1.563em
// h5:   1.25em
// h6:   1em
// body: 1em

Classes

TypeScale

Represents a Typographic scale in terms of HTML elements

new TypeScale(options)

ParamTypeDescription
optionsObject
options.scalenumberThe ratio to be used as the scale

typeScale.body : string

typeScale.h6 : string

typeScale.h5 : string

typeScale.h4 : string

typeScale.h3 : string

typeScale.h2 : string

typeScale.h1 : string

typeScale.asCSS() ⇒ string

Get the typographic scale as a CSS string

Returns: string - - A string representing a group of CSS rulesets

Scale : enum

A collection of scales in terms of intervals.

See: https://wikipedia.org/wiki/Interval_(music) for more information
Properties

NameTypeDefaultDescription
Unisonstring11
MinorSecondstring""1.067
MajorSecondstring""1.125
MinorThirdstring""1.2
MajorThirdstring""1.25
PerfectFourthstring""1.333
DiminishedFifthstring""1.4
PerfectFifthstring""1.5
MinorSixthstring""1.6
MajorSixthstring""1.667
MinorSeventhstring""1.75
MajorSeventhstring""1.875
Octavestring22

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT