0.0.1 • Published 8 years ago

RockSelect v0.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
8 years ago

RockSelect

Fancy and simple Select option component in react.js

alt tag

Usage

Basic use

You can pass a simple list of string and specify the function that will trigger in every click on the options

// Import dependencies 
import React from 'react'
import { render } from 'react-dom';

// Import RockSelect
import RockSelect from './components/RockSelect'

let foo = ()=>{
  alert('FOO')
}

render(
  <div>
    <RockSelect options={['One', 'Two', 'three']} generalClick={foo} iconClass="icon-code" />
  </div>, document.getElementById('app')
)

Object List items

Or you can pass a list of Objects with the configuration

const OPTIONS = [
  {
    value : 'Option 1',
    click : theAction
  }
]

Full Example

// Import dependencies 
import React from 'react'
import { render } from 'react-dom';

// Import RockSelect
import RockSelect from './components/RockSelect'

let foo = ()=>{
  alert('FOO')
}

let bar = ()=>{
  alert('BAR')
}

let baz = ()=>{
  alert('BAZ')
}

const OPTIONS = [
     { 
        value : 'Option 1',
        click : foo
     },
     { 
        value : 'Option 2',
        click : bar
     },
     { 
        value : 'Option3',
        click : baz
     }
]

render(
  <div>
    <RockSelect options={OPTIONS} iconClass="icon-code" />
  </div>, document.getElementById('app')
)

API

Select props

namedescriptiontypedefault
optionsList of options itemsArray
defaultValueDefault Select optionStringfirst Option in the list
generalClickThis method is triggered, each onClick in any optionsFunction(value)-
iconClassClass applied to icon via font icon or background imageString' '

Development

npm install
npm start

http://localhost:8080/webpack-dev-server/

0.0.1

8 years ago