-
Notifications
You must be signed in to change notification settings - Fork 258
feat: added row number along side of grades table #8089
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
base: master
Are you sure you want to change the base?
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ export const defaultNoDataText = () => I18n.t("table.no_data"); | |
| const columnHelper = createColumnHelper(); | ||
| export const SELECTION_COLUMN_ID = "select"; | ||
| const FILTER_VARIANT_SELECT = "select"; | ||
| const ROW_NUMBER_GUTTER_WIDTH = 40; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Define this as a CSS variable in |
||
|
|
||
| export const expanderColumn = columnHelper.display({ | ||
| id: "expander", | ||
|
|
@@ -173,9 +174,11 @@ export default function Table({ | |
| }); | ||
|
|
||
| const centerTotalSize = table.getCenterTotalSize(); | ||
| const tableTotalSize = centerTotalSize + ROW_NUMBER_GUTTER_WIDTH; | ||
| const rows = table.getRowModel().rows; | ||
|
|
||
| const tableHeaders = ( | ||
| <div className="rt-thead -header" style={{minWidth: centerTotalSize}}> | ||
| <div className="rt-thead -header" style={{minWidth: tableTotalSize}}> | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Overall this is great, but looking through the tables on various pages I'm not sure we should apply this universally. Can you please add a |
||
| {table.getHeaderGroups().map(headerGroup => ( | ||
| <div className="rt-tr" role="row" key={headerGroup.id}> | ||
| {headerGroup.headers.map(header => ( | ||
|
|
@@ -200,7 +203,7 @@ export default function Table({ | |
| [table, finalColumns] | ||
| ); | ||
| const tableFilters = showFilters && ( | ||
| <div className="rt-thead -filters" style={{minWidth: centerTotalSize}}> | ||
| <div className="rt-thead -filters" style={{minWidth: tableTotalSize}}> | ||
| {table.getHeaderGroups().map(headerGroup => ( | ||
| <div className="rt-tr" role="row" key={headerGroup.id}> | ||
| {headerGroup.headers.map(header => ( | ||
|
|
@@ -222,12 +225,18 @@ export default function Table({ | |
| ); | ||
|
|
||
| return ( | ||
| <div className="Table -highlight" style={{maxHeight: "500px"}}> | ||
| <div | ||
| className="Table -highlight" | ||
| style={{ | ||
| maxHeight: "500px", | ||
| "--row-number-gutter-width": `${ROW_NUMBER_GUTTER_WIDTH}px`, | ||
| }} | ||
| > | ||
| <div className="rt-table" role="grid"> | ||
| {tableHeaders} | ||
| {tableFilters} | ||
| <div className="rt-tbody" style={{minWidth: centerTotalSize}}> | ||
| {table.getRowModel().rows.map(row => ( | ||
| <div className="rt-tbody" style={{minWidth: tableTotalSize}}> | ||
| {rows.map(row => ( | ||
| <TableRow | ||
| row={row} | ||
| isExpanded={row.getIsExpanded()} | ||
|
|
@@ -241,7 +250,7 @@ export default function Table({ | |
| columns={finalColumns} | ||
| /> | ||
| ))} | ||
| {loading && table.getRowModel().rows.length > 0 && ( | ||
| {loading && rows.length > 0 && ( | ||
| <div | ||
| className="loading-spinner" | ||
| style={{ | ||
|
|
@@ -267,7 +276,7 @@ export default function Table({ | |
| /> | ||
| </div> | ||
| )} | ||
| {!table.getRowModel().rows.length && | ||
| {!rows.length && | ||
| (loading ? ( | ||
| <div className="loading-spinner"> | ||
| <Grid | ||
|
|
||
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.
In terms of styling, please have this be the same background colour as the header cells. Also please apply this background colour to the full header rows as well (so that the empty top-left corners still appear have the background colours applied.