@aftonbladet/stylizr

Takes a text and a styles-array in the article format and converts it into react components

Stats

stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
@aftonbladet/stylizr
Minified + gzip package size for @aftonbladet/stylizr in KB

Readme

stylizr

Takes a text and a styles-array and converts it by calling the handlers supplied when creating a stylizr instance.

Usage

// stylizr-instance.js
import React from 'react';
import stylizr from 'stylizr';

const stylizrInstance = stylizr({
    'style:em': (text, key) => <em key={key}>{text}</em> 
});

export default stylizrInstance;

// ---- 

// another-file.js
import React from 'react';
import ReactDOM from 'react-dom';
import stylizr from './stylizr-instance';

ReactDOM.render(
    <MyComponent>{
        stylizr('This is my text', [{
            offset: 5, 
            length: 2, 
            type: 'style:em'
        }])
    }</MyComponent>,
    document.getElementById('react-root')
);

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.