1.0.1 • Published 4 years ago

modular-scale-styled v1.0.1

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

Modular Scale Styled

An easy-to-use library for creating meaningful typography

NPM

Install

npm install --save modular-scale-styled

Basic usage

import React from 'react'

import MSStyled, { Scale, Text } from 'modular-scale-styled'

const options = {
    base: 16,              // is the base size in px
    ratio: Scale.GOLDEN    // is the chosen scale
}

const App = () => {
    return (
        <MSStyled options={options}>
            {/* the size parameter means the size within the scale */}
            <Text size={5}>Meaningful Typography</Text>
            <Text size={4}>Meaningful Typography</Text>
            <Text size={3}>Meaningful Typography</Text>
            <Text size={2}>Meaningful Typography</Text>
            <Text size={1}>Meaningful Typography</Text>
            <Text size={0}>Meaningful Typography</Text>
            <Text size={-1}>Meaningful Typography</Text>
            <Text size={-2}>Meaningful Typography</Text>
        </MSStyled>
    )
}

Creating a custom component

import React from 'react'

import MSStyled, { Scale, Text } from 'modular-scale-styled'
import styled from "styled-components";

const options = {
    base: 16,   
    ratio: Scale.GOLDEN
}

const MyCustomText= styled(Text)`
  color: #e51818;
  background-color: rebeccapurple;
`;

const App = () => {
    return (
        <MSStyled options={options}>
            <MyCustomText size={4}>Meaningful Typography</MyCustomText>
        </MSStyled>
    )
}

Supported scales

ScaleValue
Minor Second1.067
Major Second1.125
Minor Third1.2
Major Third1.25
Perfect Fourth1.333
Aug Fourth / Dim Fifth1.414
Perfect Fifth1.5
Minor Sixth1.6
Golden Section1.618
Major Sixth1.667
Minor Seventh1.778
Major Seventh1.875
Octave2
Major Tenth2.5
Major Eleventh2.667
Major Twelfth3
Double Octave4

License

MIT © divinoborges

Follow me on Twitter @divinoborges_