Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow multiple patterns per question #22

Merged
merged 3 commits into from
Jun 6, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Update Pattern column cell render to support multiple patterns
  • Loading branch information
Sean Prashad authored and Sean Prashad committed Jun 6, 2020
commit a29c373ea2ce237b43f49291bb6133c6cb5b44ba
22 changes: 14 additions & 8 deletions src/components/Table/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,20 @@ const Table = () => {
{
Header: 'Pattern',
accessor: 'pattern',
Cell: cellInfo => (
<div>
{`${cellInfo.row.original.pattern}`.replace(/,/g, ', ')}
</div>
),
Cell: cellInfo => {
const patterns = `${cellInfo.row.original.pattern}`
.split(',')
.map(pattern => {
return (
<Badge key={pattern} className={pattern} pill>
{pattern}
</Badge>
);
});

return <Row className="patterns">{patterns}</Row>;
},

Filter: SelectColumnFilter,
},
{
Expand Down Expand Up @@ -177,9 +186,6 @@ const Table = () => {
columns,
data,
defaultColumn,
initialState: {
sortBy: [{ id: 'pattern' }],
},
},
useFilters,
useSortBy,
Expand Down
3 changes: 2 additions & 1 deletion src/components/Table/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
background-color: #d9534f;
}

.companies {
.companies,
.patterns {
justify-content: space-evenly;
margin: 0;
}
Expand Down