-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #143 from edx/aakbar/PROD-2462
feat: add enrollmentv2
- Loading branch information
Showing
9 changed files
with
764 additions
and
1 deletion.
There are no files selected for viewing
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,100 @@ | ||
import React from 'react'; | ||
import { useTable, useExpanded, useSortBy } from 'react-table'; | ||
import PropTypes from 'prop-types'; | ||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; | ||
import { faSortDown, faSortUp } from '@fortawesome/free-solid-svg-icons'; | ||
|
||
export default function Table({ | ||
columns, data, renderRowSubComponent, styleName, | ||
}) { | ||
const { | ||
getTableProps, | ||
getTableBodyProps, | ||
headerGroups, | ||
rows, | ||
prepareRow, | ||
visibleColumns, | ||
} = useTable( | ||
{ | ||
columns, | ||
data, | ||
}, | ||
useSortBy, | ||
useExpanded, // Using useExpanded to track the expanded state | ||
); | ||
|
||
return ( | ||
<> | ||
<table {...getTableProps()} className={styleName}> | ||
<thead> | ||
{headerGroups.map(headerGroup => ( | ||
<tr {...headerGroup.getHeaderGroupProps()}> | ||
{headerGroup.headers.map(column => ( | ||
<th {...column.getHeaderProps(column.sortable && column.getSortByToggleProps())}> | ||
{column.render('Header')} | ||
<span> | ||
{/* eslint-disable-next-line no-nested-ternary */} | ||
{column.isSorted | ||
? column.isSortedDesc | ||
? <FontAwesomeIcon icon={faSortDown} /> | ||
: <FontAwesomeIcon icon={faSortUp} /> | ||
: ''} | ||
</span> | ||
</th> | ||
))} | ||
</tr> | ||
))} | ||
</thead> | ||
<tbody {...getTableBodyProps()}> | ||
{rows.map((row) => { | ||
prepareRow(row); | ||
return ( | ||
<React.Fragment {...row.getRowProps()}> | ||
<tr> | ||
{row.cells.map(cell => ( | ||
<td {...cell.getCellProps()}>{cell.render('Cell')}</td> | ||
))} | ||
</tr> | ||
{/* | ||
If the row is in an expanded state, render a row with a | ||
column that fills the entire length of the table. | ||
*/} | ||
{row.isExpanded ? ( | ||
<tr> | ||
<td colSpan={visibleColumns.length}> | ||
{/* | ||
Inside it, call our renderRowSubComponent function. In reality, | ||
you could pass whatever you want as props to | ||
a component like this, including the entire | ||
table instance. | ||
it's merely a rendering option we created for ourselves | ||
*/} | ||
{renderRowSubComponent({ row })} | ||
</td> | ||
</tr> | ||
) : null} | ||
</React.Fragment> | ||
); | ||
})} | ||
</tbody> | ||
</table> | ||
<br /> | ||
</> | ||
); | ||
} | ||
|
||
Table.propTypes = { | ||
columns: PropTypes.arrayOf(PropTypes.shape({ | ||
header: PropTypes.string.isRequired, | ||
accessor: PropTypes.string.isRequired, | ||
sortable: PropTypes.bool, | ||
})).isRequired, | ||
data: PropTypes.arrayOf(PropTypes.object).isRequired, | ||
renderRowSubComponent: PropTypes.func, | ||
styleName: PropTypes.string, | ||
}; | ||
|
||
Table.defaultProps = { | ||
renderRowSubComponent: null, | ||
styleName: null, | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,42 @@ | ||
|
||
// Reverting the container width to 1440px to keep the support tools styling consistent | ||
// See https://github.com/edx/paragon/pull/533 for paragon breaking change | ||
|
||
.container-fluid { | ||
max-width: 1440px; | ||
max-width: 1440px; | ||
} | ||
|
||
.custom-table { | ||
font-size: small; | ||
width: 100%; | ||
th { | ||
margin: 0; | ||
padding: 0.5rem; | ||
border-bottom: 1px solid black; | ||
} | ||
td { | ||
margin: 0; | ||
padding: 0.5rem; | ||
border-bottom: 1px solid silver; | ||
} | ||
} | ||
|
||
.custom-expander-table { | ||
font-size: small; | ||
margin-left: 10%; | ||
th { | ||
margin: 0; | ||
padding: 0.5rem; | ||
background-color: lightgray; | ||
border-bottom: 0px; | ||
} | ||
td { | ||
margin: 0; | ||
padding: 0.5rem; | ||
border-bottom: 0px; | ||
} | ||
} | ||
|
||
.text-center { | ||
margin: auto; | ||
} |
Oops, something went wrong.