2.0.2 • Published 1 month ago

@schibsted/niche-stylizr v2.0.2

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
1 month ago

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

1 month ago

2.0.1

3 months ago

2.0.0

10 months ago