This repository has been archived by the owner on May 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 72
[terra-table] Adding subsections to sections #2112
Merged
Merged
Changes from 53 commits
Commits
Show all changes
54 commits
Select commit
Hold shift + click to select a range
e14fa46
initial changes for adding subsections to table
BenBoersma a6276c7
adding wdio tests and snapshot for default theme
BenBoersma ce6cc6b
added fusion-theme variables, added wdio tests, added jest tests, fix…
BenBoersma b3a7c15
Updating to fix linter errors
BenBoersma cc25304
updated wdio tests
sdadn 7972bd5
Merge branch 'main' into adding-table-subsections
sdadn 86bd928
removed linter comments
sdadn 29bba90
added variables for subsection padding
sdadn 6ee7c59
removed font family
sdadn 586ed87
updated subsection logic
sdadn 1124ed0
updated section logic
sdadn 0318985
added row props const
sdadn 7f12bcb
removed subsection subcomponent
sdadn 86ed45e
added terra-section-header
sdadn cd98a09
added subsection ids
sdadn e273bee
updated section
sdadn 6c7b129
updated theme files
sdadn 2395c42
updated documentation
sdadn 89e070a
Merge branch 'main' into adding-table-subsections
sdadn dfce99f
updated CHANGELOGs
sdadn 6de3e9c
removed subsection tests
sdadn 8eb7b7c
fixed WDIO tests
sdadn 4fc5762
Merge branch 'main' into adding-table-subsections
sdadn 9869403
reformatted tables
sdadn c254deb
Merge branch 'adding-table-subsections' of github.com:cerner/terra-fr…
sdadn b2e0aee
updated lowlight styles
sdadn 040c0f2
Merge branch 'main' into adding-table-subsections
sdadn 71869da
updated snapshots
sdadn 628736e
updated scss
sdadn bc228de
updated styles
sdadn 7fdc45b
updated snapshots
sdadn 66c9105
updated tests
sdadn 44a9dab
trigger build
sdadn e34bc71
Merge branch 'main' into adding-table-subsections
sdadn 950b913
Update table-spec.js
sdadn 2a80f7e
updated package-lock
sdadn baf2d69
removed extra snapshots
sdadn 7e3d034
updated table snapshots
sdadn 3fb73fe
remove old snapshots
sdadn 95b2cf3
update lowlight theme
sdadn 6f81725
updated fusion
sdadn 331e757
updated css
sdadn 796300f
updated css
sdadn b5ce5ae
updated snapshots
sdadn 67b7f7d
linter fixes
sdadn 9270557
linter fixes
sdadn a018196
added constant
sdadn a981a90
updated onCellSelect callback
sdadn e94e26b
updated subsection classame
sdadn d54279f
fix subsection sticky title
sdadn d1c988e
updated data attribute
sdadn 0fc369b
removed redundant css
sdadn a357020
Revert padding
sdadn 8061321
fixed wdio snapshots
sdadn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 68 additions & 55 deletions
123
packages/terra-framework-docs/src/terra-dev-site/doc/table/About.1.doc.mdx
Large diffs are not rendered by default.
Oops, something went wrong.
172 changes: 172 additions & 0 deletions
172
...rk-docs/src/terra-dev-site/test/table/TableWithCollapsibleSectionsAndSubSections.test.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
import React, { useState } from 'react'; | ||
import Table from 'terra-table'; | ||
|
||
const tableData = { | ||
cols: [ | ||
{ | ||
id: 'Column-0', displayName: 'Patient', sortIndicator: 'ascending', isSelectable: true, | ||
}, | ||
{ | ||
id: 'Column-1', displayName: 'Location', isSelectable: true, | ||
}, | ||
{ id: 'Column-2', displayName: 'Illness Severity', isSelectable: true }, | ||
{ id: 'Column-3', displayName: 'Visit' }, | ||
{ id: 'Column-4', displayName: 'Allergy' }, | ||
{ id: 'Column-5', displayName: 'Primary Contact' }, | ||
|
||
], | ||
sections: [{ | ||
id: 'section-0', | ||
isCollapsible: true, | ||
isCollapsed: true, | ||
text: 'Test Section', | ||
subsections: [ | ||
{ | ||
id: 'subsection-0', | ||
text: 'Test SubSection', | ||
rows: [ | ||
{ | ||
id: '1', | ||
cells: [ | ||
{ content: 'Fleck, Arthur' }, | ||
{ content: '1007-MTN' }, | ||
{ content: 'Unstable' }, | ||
{ content: 'Inpatient, 2 months' }, | ||
{ content: '' }, | ||
{ content: 'Quinzell, Harleen' }, | ||
], | ||
}, | ||
{ | ||
id: '2', | ||
cells: [ | ||
{ content: 'Wayne, Bruce' }, | ||
{ content: '1007-MTN-DR' }, | ||
{ content: 'Stable' }, | ||
{ content: 'Outpatient, 2 days' }, | ||
{ content: 'Phytochemicals' }, | ||
{ content: 'Grayson, Richard' }, | ||
], | ||
}, | ||
], | ||
}, | ||
{ | ||
id: 'subsection-1', | ||
text: 'Test SubSection #2', | ||
rows: [ | ||
{ | ||
id: '3', | ||
cells: [ | ||
{ content: 'Fleck, Arthur' }, | ||
{ content: '1007-MTN' }, | ||
{ content: 'Unstable' }, | ||
{ content: 'Inpatient, 2 months' }, | ||
{ content: '' }, | ||
{ content: 'Quinzell, Harleen' }, | ||
], | ||
}, | ||
{ | ||
id: '4', | ||
cells: [ | ||
{ content: 'Wayne, Bruce' }, | ||
{ content: '1007-MTN-DR' }, | ||
{ content: 'Stable' }, | ||
{ content: 'Outpatient, 2 days' }, | ||
{ content: 'Phytochemicals' }, | ||
{ content: 'Grayson, Richard' }, | ||
], | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
{ | ||
id: 'section-1', | ||
isCollapsible: true, | ||
isCollapsed: true, | ||
text: 'Test Section #2', | ||
subsections: [ | ||
{ | ||
id: 'subsection-2', | ||
text: 'Test SubSection', | ||
rows: [ | ||
{ | ||
id: '5', | ||
cells: [ | ||
{ content: 'Parker, Peter' }, | ||
{ content: '1007-MTN' }, | ||
{ content: 'Unstable' }, | ||
{ content: 'Inpatient, 2 months' }, | ||
{ content: '' }, | ||
{ content: 'Octopus, Doctor' }, | ||
], | ||
}, | ||
{ | ||
id: '6', | ||
cells: [ | ||
{ content: 'Stark, Tony' }, | ||
{ content: '1007-MTN-DR' }, | ||
{ content: 'Stable' }, | ||
{ content: 'Outpatient, 2 days' }, | ||
{ content: 'Phytochemicals' }, | ||
{ content: 'America, Captain' }, | ||
], | ||
}, | ||
], | ||
}, | ||
{ | ||
id: 'subsection-3', | ||
text: 'Test SubSection #2', | ||
rows: [ | ||
{ | ||
id: '7', | ||
cells: [ | ||
{ content: 'Parker, Peter' }, | ||
{ content: '1007-MTN' }, | ||
{ content: 'Unstable' }, | ||
{ content: 'Inpatient, 2 months' }, | ||
{ content: '' }, | ||
{ content: 'Octopus, Doctor' }, | ||
], | ||
}, | ||
{ | ||
id: '8', | ||
cells: [ | ||
{ content: 'Stark, Tony' }, | ||
{ content: '1007-MTN-DR' }, | ||
{ content: 'Stable' }, | ||
{ content: 'Outpatient, 2 days' }, | ||
{ content: 'Phytochemicals' }, | ||
{ content: 'America, Captain' }, | ||
], | ||
}, | ||
], | ||
}, | ||
], | ||
}], | ||
}; | ||
|
||
const TableWithCollapsibleSections = () => { | ||
const [tableSections, setTableSections] = useState(tableData.sections); | ||
|
||
const handleSectionSelect = (sectionId) => { | ||
const newSections = [...tableSections]; | ||
const sectionIndex = newSections.findIndex(section => section.id === sectionId); | ||
|
||
if (sectionIndex > -1) { | ||
newSections[sectionIndex].isCollapsed = !newSections[sectionIndex].isCollapsed; | ||
} | ||
|
||
setTableSections(newSections); | ||
}; | ||
|
||
return ( | ||
<Table | ||
id="table-with-sub-sections" | ||
overflowColumns={tableData.cols} | ||
sections={tableSections} | ||
onSectionSelect={handleSectionSelect} | ||
/> | ||
); | ||
}; | ||
|
||
export default TableWithCollapsibleSections; |
135 changes: 135 additions & 0 deletions
135
packages/terra-framework-docs/src/terra-dev-site/test/table/TableWithSubSections.test.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
import React, { useState } from 'react'; | ||
import Table from 'terra-table'; | ||
|
||
const tableData = { | ||
cols: [ | ||
{ | ||
id: 'Column-0', displayName: 'Patient', sortIndicator: 'ascending', isSelectable: true, | ||
}, | ||
{ | ||
id: 'Column-1', displayName: 'Location', isSelectable: true, | ||
}, | ||
{ id: 'Column-2', displayName: 'Illness Severity', isSelectable: true }, | ||
{ id: 'Column-3', displayName: 'Visit' }, | ||
{ id: 'Column-4', displayName: 'Allergy' }, | ||
{ id: 'Column-5', displayName: 'Primary Contact' }, | ||
|
||
], | ||
sections: [{ | ||
id: 'section-0', | ||
text: 'Test Section', | ||
subsections: [ | ||
{ | ||
id: 'subsection-0', | ||
text: 'Test SubSection', | ||
rows: [ | ||
{ | ||
id: '1', | ||
cells: [ | ||
{ content: 'Fleck, Arthur' }, | ||
{ content: '1007-MTN' }, | ||
{ content: 'Unstable' }, | ||
{ content: 'Inpatient, 2 months' }, | ||
{ content: '' }, | ||
{ content: 'Quinzell, Harleen' }, | ||
], | ||
}, | ||
{ | ||
id: '2', | ||
cells: [ | ||
{ content: 'Wayne, Bruce' }, | ||
{ content: '1007-MTN-DR' }, | ||
{ content: 'Stable' }, | ||
{ content: 'Outpatient, 2 days' }, | ||
{ content: 'Phytochemicals' }, | ||
{ content: 'Grayson, Richard' }, | ||
], | ||
}, | ||
], | ||
}, | ||
{ | ||
id: 'subsection-1', | ||
text: 'Test SubSection #2', | ||
rows: [ | ||
{ | ||
id: '3', | ||
cells: [ | ||
{ content: 'Fleck, Arthur' }, | ||
{ content: '1007-MTN' }, | ||
{ content: 'Unstable' }, | ||
{ content: 'Inpatient, 2 months' }, | ||
{ content: '' }, | ||
{ content: 'Quinzell, Harleen' }, | ||
], | ||
}, | ||
{ | ||
id: '4', | ||
cells: [ | ||
{ content: 'Wayne, Bruce' }, | ||
{ content: '1007-MTN-DR' }, | ||
{ content: 'Stable' }, | ||
{ content: 'Outpatient, 2 days' }, | ||
{ content: 'Phytochemicals' }, | ||
{ content: 'Grayson, Richard' }, | ||
], | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
{ | ||
id: 'section-1', | ||
text: 'Test Section #2', | ||
rows: [ | ||
{ | ||
id: '5', | ||
cells: [ | ||
{ content: 'Parker, Peter' }, | ||
{ content: '1007-MTN' }, | ||
{ content: 'Unstable' }, | ||
{ content: 'Inpatient, 2 months' }, | ||
{ content: '' }, | ||
{ content: 'Octopus, Doctor' }, | ||
], | ||
}, | ||
{ | ||
id: '6', | ||
cells: [ | ||
{ content: 'Stark, Tony' }, | ||
{ content: '1007-MTN-DR' }, | ||
{ content: 'Stable' }, | ||
{ content: 'Outpatient, 2 days' }, | ||
{ content: 'Phytochemicals' }, | ||
{ content: 'America, Captain' }, | ||
], | ||
}, | ||
], | ||
}], | ||
}; | ||
|
||
const TableWithSections = () => { | ||
const [tableSections, setTableSections] = useState(tableData.sections); | ||
|
||
const handleSectionSelect = (sectionId) => { | ||
const newSections = [...tableSections]; | ||
const sectionIndex = newSections.findIndex(section => section.id === sectionId); | ||
|
||
if (sectionIndex > -1) { | ||
newSections[sectionIndex].isCollapsed = !newSections[sectionIndex].isCollapsed; | ||
} | ||
|
||
setTableSections(newSections); | ||
}; | ||
|
||
return ( | ||
<Table | ||
id="table-with-sub-sections" | ||
pinnedColumns={tableData.cols.slice(0, 2)} | ||
overflowColumns={tableData.cols.slice(2)} | ||
sections={tableSections} | ||
onSectionSelect={handleSectionSelect} | ||
/> | ||
); | ||
}; | ||
|
||
export default TableWithSections; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add this example to user facing part of the documentation as well, so that users have access to the implementation code example.