0.3.0 • Published 6 years ago

react-hovertable v0.3.0

Weekly downloads
165
License
-
Repository
github
Last release
6 years ago

react-hovertable NPM version Build Status Dependency Status

react hovertable to select column and row in a table!

Installation

$ npm install --save react-hovertable

Usage

import React from 'react';
import ReactDOM from 'react-dom';
import HoverTable from '../src';

const onClick = (e, data) => {
  console.log('click', e, data);
};

const onMouseOver = (e, data) => {
  console.log('onMouseOver', e, data);
};

const onMouseOut = e => {
  console.log(e);
};

ReactDOM.render(
  <HoverTable
    column={12}
    row={12}
    width={300}
    height={300}
    onClick={onClick}
    showDimension={true} // show dimension or not
    onMouseOut={onMouseOut}
    onMouseOver={onMouseOver}
    />
, document.getElementById('root'));

for more usage, see docs folder

Demo

LIVE DEMO

Props

propstyperequireddefaultdescription
widthnumbertrue350the width of hovertable
heightnumbertrue350the height of hovertable
rownumbertrue12how many rows in hovertable
columnnumbertrue12how many columns in hovertable
selectedRownumberfalsenullselected row
selectedColumnnumberfalsenullselected column
onMouseOverfunctionfalse() => {}this will be trigger when mouse over, with two params, e: event object, data: {rowNumber, columnNumber, rollHeight, cellHeight}
onMouseOutfunctionfalse() => {}this will be trigger when mouse out
onClickfunctionfalse() => {}this will be trigger when mouse over, with two params, e: event object, data: {rowNumber, columnNumber, rollHeight, cellHeight}
showDimensionbooleanfalsetrueshow dimension div or not
themestringfalsedarksee styles folder in src for more theme options

Example

clone the repository

node devServer.js
// open http://localhost:9393

Maintainer

chilijung

License

MIT © Canner