@aftonbladet/stylizr

1.1.1 • Public • Published

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')
);

Dependencies (0)

    Dev Dependencies (8)

    Package Sidebar

    Install

    npm i @aftonbladet/stylizr

    Weekly Downloads

    207

    Version

    1.1.1

    License

    UNLICENSED

    Last publish

    Collaborators

    • aftonbladet