Skip to content
This repository was archived by the owner on Aug 25, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/textual_summary/generic_table_row.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const renderMultivalue = function renderMultivalue(values, onClick) {
<tr onClick={e => onClick(item, e)} key={i} className={item.link ? '' : 'no-hover'} title={item.title}>
<td style={{ border: 0, margin: 0, padding: 0 }}>
<IconOrImage icon={item.icon} image={item.image} title={item.title} />
{item.value}
{`${item.value}`}
</td>
</tr>
))
Expand All @@ -22,7 +22,7 @@ const renderMultivalue = function renderMultivalue(values, onClick) {
};

const renderValue = function renderValue(value, onClick) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small nitpick. You don't have to write const functionName = function functionName(...), you can replace it with const functionName = (...) => {}. The function definition after the = is useless. I have noticed that you are using this very often.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or you can write just function renderValue(value, onClick) { which is probably the best, if it's not just simple function with one liner as return otherwise go ahead and use const functionName = (...) => ({some: object})

return Array.isArray(value) ? renderMultivalue(value, onClick) : <span> {value}</span>;
return Array.isArray(value) ? renderMultivalue(value, onClick) : <span> {`${value}`}</span>;
};

export default function GenericTableRow(props) {
Expand All @@ -48,7 +48,7 @@ GenericTableRow.propTypes = {
image: PropTypes.string,
icon: PropTypes.string,
label: PropTypes.any,
value: PropTypes.oneOfType([PropTypes.array, PropTypes.string]),
value: PropTypes.oneOfType([PropTypes.array, PropTypes.string, PropTypes.number, PropTypes.bool]),
}).isRequired,
onClick: PropTypes.func.isRequired,
};
Expand Down
4 changes: 2 additions & 2 deletions src/textual_summary/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import TextualRow from './textual_row';
* Outer array elements are rows, inner array elements are groups.
*/
export const TextualSummary = props => (
<React.Fragment>
<div className="row">
{
props.summary.map((bigGroup, i) => (
<TextualRow onClick={props.onClick} key={i} groups={bigGroup} />
))
}
</React.Fragment>
</div>
);

TextualSummary.propTypes = {
Expand Down
3 changes: 2 additions & 1 deletion src/textual_summary/stories/GenericGroup.stories.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import React from 'react';
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import GenericGroup from '../generic_group';
import { genericGroupData } from '../data/generic_group';

storiesOf('TextualSummary', module)
.add('GenericGroup', () => {
return (
<GenericGroup items={genericGroupData.items} title={genericGroupData.title} onClick={e => null} />
<GenericGroup items={genericGroupData.items} title={genericGroupData.title} onClick={action('onClick')} />
);
})
;
3 changes: 2 additions & 1 deletion src/textual_summary/stories/MultilinkTable.stories.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import MultilinkTable from '../multilink_table';
import { multilinkTableData } from '../data/multilink_table';

Expand All @@ -9,7 +10,7 @@ storiesOf('TextualSummary', module)
<MultilinkTable
title={multilinkTableData.title}
items={multilinkTableData.items}
onClick={e => null}
onClick={action('onClick')}
/>
);
})
Expand Down
3 changes: 2 additions & 1 deletion src/textual_summary/stories/TableListView.stories.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import TableListView from '../table_list_view';
import { tableListViewData } from '../data/table_list_view';

Expand All @@ -12,7 +13,7 @@ storiesOf('TextualSummary', module)
values={tableListViewData.values}
colOrder={tableListViewData.colOrder}
rowLabel='View the table'
onClick={(e) => null}
onClick={action('onClick')}
/>
);
})
Expand Down
2 changes: 1 addition & 1 deletion src/textual_summary/table_list_view.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const simpleRow = (row, i, colOrder) => (

const clickableRow = (row, i, colOrder, rowLabel, onClick) => (
<tr key={i} onClick={e => onClick(row, e)}>
{colOrder.map((col, j) => <td key={j} title={rowLabel}>{row[col]}</td>)}
{colOrder.map((col, j) => <td key={j} title={rowLabel}>{`${row[col]}`}</td>)}
</tr>
);

Expand Down
6 changes: 1 addition & 5 deletions src/textual_summary/textual_group.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,7 @@ const renderComponent = (props) => {
};

export default function TextualGroup(props) {
return (
<div className="col-md-11 col-lg-6">
{renderComponent(props)}
</div>
);
return renderComponent(props);
}

renderComponent.propTypes = {
Expand Down
2 changes: 1 addition & 1 deletion src/textual_summary/textual_row.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import TextualGroup from './textual_group';

export default function TextualRow(props) {
return (
<div className="row">
<div className="col-md-12 col-lg-6">
{
props.groups.map(group => (
<TextualGroup onClick={props.onClick} key={group.title} group={group} />
Expand Down