1.0.2 • Published 3 years ago

react-botw-grid-menu v1.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

react-botw-grid-menu

A react component for rendering a Breath of the Wild style inventory menu.

NPM JavaScript Style Guide

Contents

Install

npm install --save react-botw-grid-menu

Peer Dependencies;

  • React v16 +

Usage

import React, { Component } from 'react'

import { BotwGridMenu } from 'react-botw-grid-menu'

class Example extends Component {
  render() {
    return (
      <BotwGridMenu 
        items={[
          {
            id: "apple",
            name: "Apple",
            quantity: 159,
            icon: <i className="fa fa-apple" />,
            note: "A scrumptious apple.\r\nEat it to restore some hearts.",
          },
          {
            id: "bug",
            name: "Bug",
            quantity: 2,
            icon: <i className="fa fa-bug" />,
            note: "Yum"
          }
        ]}
      />
    )
  }
}

Example usage at https://darylbuckle.github.io/react-botw-menu-components.

Props

BotwGridMenu

PropertyTypeDefaultMandatoryDescription
itemsbotwItem[]trueThe data to display in the grid. View the props for botwItem below.
pageSizenumber20falseThe maximum number of items per page.
pagenumberfalseThe current page number. Specify if you wish to control pagination, otherwise it'll be handled automatically.
loadingbooleanfalsefalseIf true a loading indicator will be displayed. Use when loading ASynchronously.
fillPageWithEmptiesbooleantruefalseWhen this is true the page will be filled with empties.
columnCountnumber?undefinedfalseWhen specified, this number of columns will show. Otherwise the columns will fit the container.
onPageChanged(page) => voidfalseA callback for when navigating to a different page.
onItemActive(item) => voidfalseA callback for when hovering over an item.
onItemInactive(item) => voidfalseA callback for when exiting hover.
onItemSelected(item) => voidfalseA callback for clicking on an item.

botwItem class

PropertyTypeDefaultMandatoryDescription
idstringtrueUnique identifier for the item.
namestringtrueThe name of the item.
quantitynumberfalseQuantity of the item.
imgSrcstringfalseSrc of the image.
iconanyfalseAlternative to ImgSrc. Allows JSX to be used for the image (e.g )
emptybooleanfalsefalseWhether to show an empty item.

License

MIT © DarylBuckle 2020