Skip to content

Commit

Permalink
Merge branch 'master' of github.com:WeConnect/plasma
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicholas Stamas committed Mar 30, 2017
2 parents ad96ca9 + 436ba9c commit dc130c7
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/components/Table/Table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ class Table extends React.Component {
_.forEach(items, (itemValue, itemIndex) => {
const spanCount = _.get(itemValue[spanKey], 'length');
const columnComponents = [];
const isDisabledRow = itemValue.disabled;

_.forEach(headerKeys, (headerKey) => {
const isInnerKey = _.includes(spannedHeaderKeys, headerKey);
Expand Down Expand Up @@ -281,6 +282,7 @@ class Table extends React.Component {
key={itemIndex}
className={cx({
[style.row]: true,
[style.rowDisabled]: isDisabledRow,
[style.clickable]: clickable,
[style.highlightable]: highlightable,
})}
Expand Down Expand Up @@ -308,6 +310,7 @@ class Table extends React.Component {
key={`${itemIndex}.${i}`}
className={cx({
[style.row]: true,
[style.rowDisabled]: isDisabledRow,
[style.clickable]: clickable,
[style.highlightable]: highlightable,
})}
Expand Down
4 changes: 4 additions & 0 deletions src/components/Table/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@
}
}

.rowDisabled {
background: $cGray700;
}

.clickable {
cursor: pointer;
}
Expand Down
70 changes: 70 additions & 0 deletions stories/Table.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import React from 'react';
import { storiesOf } from '@kadira/storybook';
import Table from '../src/components/Table/Table';

const headerData = [
{ label: 'Header 1', key: 'header1' },
{ label: 'Header 2', key: 'header2' },
{ label: 'Header 3', key: 'header3' },
{ label: 'Header 4', key: 'header4' },
{ label: 'Header 5', key: 'header5' },
];

storiesOf('Table', module).add('default', () => {
const items = [
{
header1: 'Text text text',
header2: 'Text text text',
header3: 'Text text text',
header4: 'Text text text',
header5: 'Text text text',
},
{
header1: 'Text text text',
header2: 'Text text text',
header3: 'Text text text',
header4: 'Text text text',
header5: 'Text text text',
},
];

return (
<Table
empty={false}
emptyText="The table is empty."
headerData={headerData}
items={items}
loading={false}
/>
);
});

storiesOf('Table', module).add('with a disabled row', () => {
const items = [
{
header1: 'Text text text',
header2: 'Text text text',
header3: 'Text text text',
header4: 'Text text text',
header5: 'Text text text',
disabled: true,
},
{
header1: 'Text text text',
header2: 'Text text text',
header3: 'Text text text',
header4: 'Text text text',
header5: 'Text text text',
},
];

return (
<Table
empty={false}
emptyText="The table is empty."
headerData={headerData}
items={items}
loading={false}
/>
);
});
1 change: 1 addition & 0 deletions stories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ import Button from './Button';
import FormField from './FormField';
import Label from './Label';
import TextInput from './TextInput';
import Table from './Table';

0 comments on commit dc130c7

Please sign in to comment.