0.2.4 • Published 3 years ago

@codeparticle/react-list v0.2.4

Weekly downloads
37
License
ISC
Repository
github
Last release
3 years ago

This is a generic list component that accepts a list of items and renders them.

It can accept a custom renderer to replace the default rendered list item component, or just send in styles to style the component to your liking.

Basic Example

import React from 'react';
import List from '@codeparticle/react-list';

const ToDoList = () => {
  const todos = [{
    item: 'Take dog for walk',
    onClick: () => {alert('walking now')}
  }, {
    item: 'Buy groceries',
  }]

  return <List listItems={todos} style={{background: 'green'}} />
}

export default ToDoList;

Using itemRenderer for a custom item component

import React from 'react';
import List from '@codeparticle/react-list';

const CustomItem = ({
  name,
  phoneNumber
}) => {
  return (
    <div>
      <h1>{name}</h1>
      <p>{phoneNumber}</p>
    </div>
  );
};

const ContactList = () => {
  const contacts = [{
    name: 'Batman',
    phoneNumber: '555-5555'
  }, {
    name: 'Superman',
    phoneNumber: '666-6666'
  }];

  return <List listItems={contacts} itemRenderer={CustomItem} />
};

export default ContactList;
Proptypedefaultdescription
listItemsarraynoneThe list of items
containerStylesobjectnoneInline styles for the container
classNamestringnoneClass name for the container. If it exists it will disable the inline styles
itemRendererReact ElementnoneCustom renderer to for the list items
Tagstringultag for container ie ul, ol, dt
titlestringnoneoptional header
Proptypedefaultdescription
itemarraynoneThe content of the list item
classNamestringnoneClass name for the container. If it exists it will disable the inline styles
onClickfunctionnoneonClick for the list item. It is passed the event and will change the cursor to 'pointer' if it exists.
itemStylesobjectnoneinline styles for the list item

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0.2.3

3 years ago

0.2.4

3 years ago

0.2.1

3 years ago

0.2.2

3 years ago

0.2.0

5 years ago

0.1.0

5 years ago