import React from 'react'; import PropTypes from 'prop-types'; import {withInfo} from '@storybook/addon-info'; import Button from 'app/components/button'; import GridEditable from 'app/components/gridEditable'; const COLUMN_ORDER = [ { key: 'farm', name: 'farm', width: -1, }, { key: 'count(apple)', name: 'apples sold', width: -1, }, { key: 'count(banana)', name: 'banana sold', width: -1, }, ]; const COLUMN_SORT_BY = [ { key: 'count(apple)', order: -1, }, ]; const DATA = [ { farm: 'Old McDonalds', 'count(apple)': 100, 'count(banana)': 500, 'count(cherry)': 200, 'count(date)': 400, 'count(eggplant)': 600, }, { farm: 'Animal Farm', 'count(apple)': 900, 'count(banana)': 600, 'count(cherry)': 200, 'count(date)': 500, 'count(eggplant)': 700, }, { farm: 'Avocado Toast Farm', 'count(apple)': 700, 'count(banana)': 600, 'count(cherry)': 500, 'count(date)': 400, 'count(eggplant)': 500, }, ]; class GridParent extends React.Component { static propTypes = { withHeader: PropTypes.bool, title: PropTypes.string, }; state = { columnOrder: [...COLUMN_ORDER], columnSortBy: [...COLUMN_SORT_BY], }; handleResizeColumn = (index, newColumn) => { const columnOrder = [...this.state.columnOrder]; columnOrder[index] = {...columnOrder[index], width: newColumn.width}; this.setState({columnOrder}); }; render() { const {withHeader, title} = this.props; const headerButtons = withHeader ? () => : null; return ( ); } } export default { title: 'UI/GridEditable', }; export const Default = withInfo('Render a simple resizable table')(() => (

Basic Table

)); Default.story = { name: 'default', }; export const WithAHeader = withInfo('Include a header and action buttons')(() => (

Table with title & header buttons

)); WithAHeader.story = { name: 'with a header', }; export const IsLoading = withInfo('')(() => (

Loading

)); IsLoading.story = { name: 'isLoading', }; export const IsError = withInfo('')(() => (

Error

)); IsError.story = { name: 'isError', };