0.2.1 • Published 5 years ago

vue-index-styler v0.2.1

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

vue-index-styler

Vue.js 2.X component styling text by index.

Demo:

Install

npm install vue-js-modal --save

or

yarn add vue-js-modal --save

How to use

import IndexStyler from 'vue-index-styler'

Vue.use(IndexStyler)

Example use

<IndexStyler
  rawText="~~~~~~~~~~~~~~~~~~~"
  :indexObjects="[
    {
      start: 1,
      end: 3,
      style: {
        color: 'white',
        backgroundColor: 'red'
      }
    },
    {
      start: 4,
      end: 8,
      style: {
        backgroundColor: 'pink',
        borderRadius: '5px'
      }
    }
  ]"
/>

Props

NameRequiredTypeDefaultDescription
rawTexttrueStringstyled text
indexObjectstrueArrayindexObject, indexObject, ・・・・ * IndexObject detail is below.
textContainerIdfalseString'styled-text-container'id of div involving styled text.
defaultStylefalseObjectAll indexeObjects are applied. Format is same as indexObject.style.
defaultHtmlAttributesfalseObjectAll indexeObjects are applied. Format is same as indexObject.htmlAttributes.
isFirstChar0falseBooleantruewhich to count rawText from 0 or 1.
isSlicedInvolvingEndIndexfalseBooleantruewhich to involve indexObject.endIndex or not.
isIndexObjectsWatchedfalseBooleanfalsewhich to watch indexObjects change or not.

IndexObject

PropertyRequiredTypeDefaultExample Value
startIndextrueNumber1
endIndextrueNumber3
stylefalseObject{ color: 'red', backgroundColor: 'yellow', fontSize: '12px' }
htmlAttributesfalseObject{ id: '~', class: '~~' }