scale-unit
A module for scaling measurements in javascript.
Install
$ npm install scale-unit
Usage
const scale = ; // define a sizeconst baseSize = ; // scale the sizeconst headerSize = ; // unwrap the size const styles = fontSize: ; // 1.5emconst headerStyles = fontSize: ; // 3em // unwrap and scale the sizeconst bigHeaderStyles = fontSize: ; // 4.5em
Defining a scale
scale(unit, multiplier)
Returns an measurement function who's value and unit label are tracked seperately.
const wrapperWidth = ;const textWidth = ;
unit String or Scale. Optional. A string representing the measurement unit or another scale function.
size Number. Optional. A multiplier to scale the input unit, set to 1
if omitted.
Unwrapping a measurement
A measurement is a function that can be unwrapped into a string that can used with a tool like Radium.
measurement(size)
size Number. Optional. A multiplier to scale the input unit, set to 1
if omitted.
const wrapper = maxWidth: // 60emconst textWrapper = maxWidth: // 45em
const textWrapper = maxWidth: // 45em
Sugars
scale(unit)
const em = ; // 1emconst fiveEm = ; // 5emconst fiveEm = ; // 5em
scale(size)
const ten = ; // 10const hundred = ; // 100
License
MIT