1.0.2 • Published 5 years ago

react-styled-typography v1.0.2

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

React-Styled-Typography

Description

The Typography component uses styled-components behind and sets the styles passed by props. The component will return an html tag defined in it's props with some extra features.

Installation

$ npm install react-styled-typography
$ yarn add react-styled-typography

Usage


Basic usage

import React, { Component } from 'react';
import Typography from 'react-styled-typography';

Class App extends Component {
    render() {
        return(
            <div>
                <Typography variant="h1" fontSize="10" color="#000">Hey, I am a h1 tag</Typography>
                <Typography variant="h2" fontSize="10" color="#000">Hey, I am a h2 tag</Typography>
                <Typography variant="h3" fontSize="10" color="#000">Hey, I am a h3 tag</Typography>
                <Typography variant="h4" fontSize="10" color="#000">Hey, I am a h4 tag</Typography>
                <Typography variant="h5" fontSize="10" color="#000">Hey, I am a h5 tag</Typography>
                <Typography variant="h6" fontSize="10" color="#000">Hey, I am a h6 tag</Typography>
                <Typography variant="p" fontSize="10" color="#000">Hey, I am a p tag</Typography>
                <Typography variant="pre" fontSize="10" color="#000">Hey, I am a pre tag</Typography>
            </div>
        )
    }
}

Using css and media sizes

import React, { Component } from 'react';
import Typography from 'react-styled-typography';

Class App extends Component {
    render() {
        return(
            <div>
                <Typography
                    variant="h1"  
                    css={`
                        color: red;
                        margin:4rem auto;
                    `}>Hey, I have css styles</Typography>
                
                <Typography 
                    color="black"
                    mediaCSS={[500,`
                                color: blue;
                                font-size: 22px;
                            `]}>Changes at smaller screens</Typography>

                <Typography desktopCSS={`
                        color: yellow;
                    `} 
                    fontSize="10" 
                    color="#000">desktopCSS</Typography>

                    <Typography tabletCSS={`
                        color: green;
                        font-size: 30px;
                    `} 
                    fontSize="10" 
                    color="#000">tabletCSS</Typography>

                    <Typography phoneCSS={`
                        color: orange;
                      

                    `} 
                    fontSize="10" 
                    color="purple">phoneCSS</Typography>
               
            </div>
        )
    }
}

Helpers

import React, { Component } from 'react';
import Typography from 'react-styled-typography';

Class App extends Component {
    render() {
        return(
            <div>
                <Typography truncate="60px">This text is going to be truncated </Typography>
                
                 <Typography 
      fontSize="10" 
      clampin={{
          height:"20px",
          type:"dots", 
          lineSize:"10px"}}
      css={"width: 40px"} 
      
      color="#000"> This awesome property allows limiting of the contents of a block container to the specified number of lines.</Typography>
    
            </div>
        )
    }
}

API

PropsTypeDescriptionExample
colorStringFont Color#ffffff
variantStringTag: h1, h2, h3, h4, h5, h6, p, prevariant="h1" return a h1 tag
marginTStringMargin Top. Sets value in pixelsmarginT="10", sets margin-top: 10px
marginRStringMargin Right. Sets value in pixelsmarginR="10", sets margin-right: 10px
marginBStringMargin Bottom. Sets value in pixelsmarginB="10", sets margin-bottom: 10px
marginLStringMargin Left. Sets value in pixelsmarginL="10", sets margin-left: 10px
alignStringText Align. left, right, centeralign="center"
fontSizeStringFont Size. Sets value in pixelsfontSize="10, sets font-size: 10px
classNameStringClass NameclassName="heading1"
underlineBooleanSets text-decoration: underlineunderline={true}
weightStringFont Weightweight: 500, sets font-weight: 500
fontStyleStringFont Style: normal, italic, oblique, initial, inheritfontStyle="italic", sets font-style: italic
truncateStringTrucante texttruncate:100, trucates text with a length of 100px
clampinJSONMultiline Trucate (type dots,fade)truncate:{height:"20px",type:"dots", lineSize:"10px"}, truncate 2 lines of 10px each with dots
cssStringCSS style/*css styles*/
mediaCSSArray 2CSS style media500,/*css string*/ sets a breaking point of 500px and applies the styles of the string
desktopCSSStringCSS style media 990px screens/*css string*/ applies the styles of the string
tabletCSSStringCSS style media size 700px screens/*css string*/ applies the styles of the string
phoneCSSStringCSS style media size 500px screens/*css string*/ applies the styles of the string

Contribute

Show your heart and support by giving a ⭐. Any suggestions are welcome !

License

Licensed under MIT

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago