react-honeycomb-v2
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

react-honeycomb-v2

React Honeycomb is a library for displaying lists as hexagonal honeycombs in React applications.

Installation

To install the library using npm run the following command in your terminal:

npm install react-honeycomb-v2

Alternatively, if you're using yarn, run:

yarn add react-honeycomb-v2

Usage

Currently the library provides two kinds of Honeycomb components: Honeycomb (a.k.a Static Honeycomb) and ResponsiveHoneycomb.

Static Honeycomb

Honeycomb component generates a grid with a given number of columns regardless of the available space. It's suitable for the cases when you're sure about how many columns you are going to need or you want to have control over the responsiveness by manipulating the columns prop with your own rules.

import { Honeycomb, Hexagon } from 'react-honeycomb';
const MY_ITEMS = [ { name: 'a', value: '1', name: 'b', value: '2' } ]

<Honeycomb
  columns={5}
  size={SIZE_OF_HEXAGON_SIDE}
  items={MY_ITEMS}
  renderItem={(item) => (
    <Hexagon className='awesome-class-name'>
        {renderItem(item.value)}
    </Hexagon>
  )}
/>;

Responsive Honeycomb

ResponsiveHoneycomb component tries to fit as many columns as its container allows by attaching a ResizeObzerver to the container element (which results in a possible performance overhead). It would suit you if you need to fill all available horizontal space with the list items.

import { ResponsiveHoneycomb, Hexagon } from 'react-honeycomb';

<ResponsiveHoneycomb
  defaultWidth={1024}
  size={SIZE_OF_HEXAGON_SIDE}
  items={MY_ITEMS}
  renderItem={(item) => (
    <Hexagon className='awesome-class-name'>
        {renderItem(item)}
    </Hexagon>
  )}
/>;

Examples

Contribution

The project was initially created just as a quick experiment, so it may have bugs or be missing some features. Don’t be shy to open a pull request if you feel like making it better. If you want to make a significant change, it would be better to open an issue first to discuss the details.

Package Sidebar

Install

npm i react-honeycomb-v2

Weekly Downloads

136

Version

1.0.0

License

MIT

Unpacked Size

10.9 kB

Total Files

16

Last publish

Collaborators

  • akshay-kapstan