Skip to content
Merged
Changes from all commits
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
38 changes: 31 additions & 7 deletions src/components/Table/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ const Table = () => {
{
Header: 'Questions',
accessor: 'questions',
disableSortBy: true,
Cell: cellInfo => {
return (
<NavLink
Expand Down Expand Up @@ -189,6 +190,7 @@ const Table = () => {
{
Header: 'Solutions',
accessor: 'solutions',
disableSortBy: true,
Cell: cellInfo => {
const url = cellInfo.row.original.premium
? `${cellInfo.row.original.url}/`
Expand Down Expand Up @@ -234,6 +236,7 @@ const Table = () => {
);
},
accessor: 'pattern',
disableSortBy: true,
Cell: cellInfo => {
const patterns = `${cellInfo.row.original.pattern}`
.split(',')
Expand Down Expand Up @@ -261,6 +264,7 @@ const Table = () => {
{
Header: 'Difficulty',
accessor: 'difficulty',
disableSortBy: true,
Cell: cellInfo => (
<Row>
<Badge
Expand All @@ -276,15 +280,27 @@ const Table = () => {
{
Header: () => {
return (
<div style={{ whiteSpace: 'nowrap' }}>
Companies{' '}
<span data-tip="Companies retrieved from Leetcode Premium (May 2021)">
<FaQuestionCircle />
</span>
</div>
<>
<div
style={{ whiteSpace: 'nowrap', display: 'inline-block' }}
>
Companies{' '}
<span data-tip="Companies retrieved from Leetcode Premium (May 2021)">
<FaQuestionCircle />
</span>
</div>
</>
);
},
accessor: 'companies',
sortType: (a, b) => {
if (a.original.companies.length === b.original.companies.length) {
return 0;
}
return a.original.companies.length > b.original.companies.length
? 1
: -1;
},
Cell: cellInfo => {
const companies = cellInfo.row.original.companies.map(company => {
return (
Expand Down Expand Up @@ -333,7 +349,15 @@ const Table = () => {
<tr {...headerGroup.getHeaderGroupProps()}>
{headerGroup.headers.map(column => (
<th {...column.getHeaderProps()}>
{column.render('Header')}
<div {...column.getSortByToggleProps({ title: null })}>
{column.render('Header')}
{/* eslint-disable-next-line no-nested-ternary */}
{column.isSorted
? column.isSortedDesc
? ' 🔽'
: ' 🔼'
: ''}
</div>
<div>{column.canFilter ? column.render('Filter') : null}</div>
</th>
))}
Expand Down