1.1.1 • Published 4 years ago

react-capsules v1.1.1

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

react-capsules-lib

A plug & play api for bullet lists in React with Dnd feature.

NPM JavaScript Style Guide

Install

npm install --save react-capsules

Components and props

Main Components

  1. ReactBulletDnd
  2. ReactBulletDnd.Item
  3. ReactBulletDnd.TextInput
ComponentsApiDescriptionRequired
ReactBulletDnddataPass the data to be displayed in capsulesfalse
sethook that changes the datafalse
styleStyle for the componentfalse
ReactBulletDnd.ItemitemText to display on every capsuletrue
positionIndex of the item in the array to add dnd feature.false
styleStyle for the capsulefalse
iconIcon for the cancel button.false
ReactBulletDnd.TextInputstyleStyle for the inputfalse
addItemcallback when enter is pressed for adding new data.true

Usage

import React, { useState } from 'react'

import ReactBulletDnd from 'react-capsules'
import 'react-capsules-lib/dist/index.css'
import cancel from './cancel.png'

const App = () => {
  const [items, setItems] = useState([
    'Android development',
    'React Js',
    'MongoDb',
    'MySql Programming',
    'Node Js',
    'JavaScript',
    'Firebase'
  ])

  const onItemAdded = (item) => {
    const copyItems = JSON.parse(JSON.stringify(items))
    copyItems.push(item)
    setItems(copyItems)
  }

  return (
    <div className='App'>
      <ReactBulletDnd data={items} set={setItems} style={/* Container Style */}>
        {items.map((item, index) => (
          <ReactBulletDnd.Item
            item={item}
            key={index}
            position={index}
            style={/* Item style */}
            icon={cancel}
          />
        ))}
        <ReactBulletDnd.TextInput
          style={/* Input style */}
          addItem={onItemAdded}
        />
      </ReactBulletDnd>
    </div>
  )
}

export default App

License

MIT © Gaurav2048

1.1.1

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago