react-string-color-parser

0.0.9 • Public • Published

Pretty narrow use cases :)

  • npm install react-string-color-parser

Usage example

import Parser from 'react-string-color-parser';
...

<Parser
   tag="span"
   fontSize={16}
   delimiters={[{start: '${', end: '}'}, {start: '--[', end: ']--'}]}
   colors={['yellowgreen', 'tomato', 'skyblue', 'papayawhip']}
   defaultColor="black"
/>

Result Alt text

import Parser from 'react-string-color-parser';
...

<Parser
  colors={['yellowgreen', 'tomato', 'skyblue', 'papayawhip']}
  solidHighlight
  searchWords={['first', 'second']}
/>

Result Alt text

Props

  • tag - HTML tag to wrap string pieces. Default - 'span'

  • delimiters - an array of delimiters for parser to respect when dividing a string.

  • colors - an array of color representations for nested string parts.

  • fontSize - custom font size for input component. Default - 16px

  • defaultColor - a color for nesting depth that out of range due to size of colors array. Default - 'lightsalmon'

  • solidHighlight - A boolean flag defining whether to highlight text with background style. Default - false

  • searchWords - Dynamically treated array of strings to be highlighted when found. When specified - cancels delimiters rule!

  • caseSensitive - a boolean flag to set case sensitivity for searching words

Package Sidebar

Install

npm i react-string-color-parser

Weekly Downloads

0

Version

0.0.9

License

ISC

Unpacked Size

941 kB

Total Files

11

Last publish

Collaborators

  • av29