Code Monkey home page Code Monkey logo

react-alphabet-sorter's Introduction

react-alphabet-sorter

Reactjs component for alphabetical sorting.

#Example

In dev mode

yarn
yarn start

Or see live-demo

react-alphabet-sorter

#Install

yarn react-alphabet-sorter --save

Usage

Sorter takes an array of values, which are passed in "asGroup" option and sorted by their label.

import React from 'react'
import AlpabetSorter from 'react-alphabet-sorter'

const data = [
  { value: 1, label: 'Audi'},
  { value: 2, label: 'Honda'},
  { value: 3, label: 'Hundai'},
  { value: 4, label: 'BMW'},
  { value: 5, label: 'Bentley'},
  { value: 7, label: 'Opel'},
  { value: 8, label: 'Mersedes'},
  { value: 9, label: 'Akura'},
  { value: 10, label: 'Porshe'},
  { value: 11, label: 'Kia'},
  { value: 12, label: 'ВАЗ'}
]

export default class Demo extends React.Component {
  render() {
    return (
      <div>
        <h2>Simple list</h2>

        <AlpabetSorter
          asGroup={data}
          asName='usage_example'
          type='radio'
          handleCheck={this.handleSorter} />
      </div>
    )
  }

  handleSorter = (selected) => {
    console.log(selected)
  }
}

Options

Properties Type Default Description
asGroup array [] array of data
asName string 'sorter' value, which is passed to the html attribute "name" (for component with props "radio" and "checkbox")
selected array [] sets selected elements after init
type string 'text' defines component view type and layout. Sorter have 4 type: "radio"(will be rendered as collection of input "radio"), "checkbox"(will be rendered as collection of input "checkbox"), "link"(will be rendered as collection of links), "text"(will be rendered as collection of text nodes)
itemOptions object {} object with custom properties, which is passed to sorter items
labelKey string 'label' key, which is used to find item label
valueKey string 'value' key, which is used to find item value
navigator boolean true defines whether to show the alphabetical signs
chunkLength number undefined defines whether to show the list items or chunks
chunkByLetter boolean undefined allow make chunks by letter
handleCheck function undefined callback, which fires after click or change item. Receives 1 argument: array of selected items

react-alphabet-sorter's People

Contributors

elistratovroman avatar britt avatar oyeanuj avatar

Watchers

Rob Sawyer avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.