Skip to content

Commit

Permalink
Enhancement to showcase how to use row data in CustomCell component (#…
Browse files Browse the repository at this point in the history
…511)

* Enhancement to showcase how to use row data in CustomCell component

* Bump version as patch release
  • Loading branch information
rgaban authored Dec 8, 2021
1 parent f1f09e5 commit 91925ef
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@launchpadlab/lp-components",
"version": "5.4.5",
"version": "5.4.6",
"engines": {
"node": "^8.0.0 || ^10.13.0 || ^12.0.0"
},
Expand Down
17 changes: 17 additions & 0 deletions stories/tables/sortable-table.story.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ function CustomCell({ value }) {
)
}

function CustomCellWithRowData({ data: { name, active } }) {
const checkIfActive = (active) => {
if (active === 'yes') return 'active'
return 'not active'
}
return (
<td style={{ color: colorForStatus(active) }}>{name} is {checkIfActive(active)}</td>
)
}

// eslint-disable-next-line react/prop-types
function CustomRow({ data: { active }, children }) {
return (
Expand Down Expand Up @@ -91,6 +101,13 @@ storiesOf('SortableTable', module)
<Column name="active" component={CustomCell} />
</SortableTable>
))
.add('with custom cell component and its row data', () => (
<SortableTable data={tableData}>
<Column name="name" />
<Column name="age" />
<Column name="active" component={CustomCellWithRowData} />
</SortableTable>
))
.add('with custom row component', () => (
<SortableTable data={tableData} rowComponent={CustomRow}>
<Column name="name" />
Expand Down

0 comments on commit 91925ef

Please sign in to comment.