Skip to content

Commit

Permalink
Dont show empty tables
Browse files Browse the repository at this point in the history
  • Loading branch information
mruwnik committed Feb 20, 2024
1 parent 46b5683 commit 063a19d
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions app/components/Table/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,26 @@ export type ListTableProps = {
className?: string
}

export const ListTable = ({elements, sameTab, className}: ListTableProps) => (
<div className={styles.container + ' bordered' + (className ? ' ' + className : '')}>
{elements.map(({pageid, title, subtitle, hasIcon}, i) => (
<Link
key={`entry-${i}`}
className={styles.entry + ' teal-500 default-bold flex-container'}
to={questionUrl({pageid, title})}
target={sameTab ? undefined : '_blank'}
rel={sameTab ? undefined : 'noopener noreferrer'}
>
<div>
<div>{title}</div>
{subtitle && <div className="grey subtitle">{subtitle}</div>}
</div>
{hasIcon && <ArrowUpRight className="vertically-centered" />}
</Link>
))}
</div>
)
export const ListTable = ({elements, sameTab, className}: ListTableProps) => {
if (!elements || elements.length === 0) return null
return (
<div className={styles.container + ' bordered' + (className ? ' ' + className : '')}>
{elements.map(({pageid, title, subtitle, hasIcon}, i) => (
<Link
key={`entry-${i}`}
className={styles.entry + ' teal-500 default-bold flex-container'}
to={questionUrl({pageid, title})}
target={sameTab ? undefined : '_blank'}
rel={sameTab ? undefined : 'noopener noreferrer'}
>
<div>
<div>{title}</div>
{subtitle && <div className="grey subtitle">{subtitle}</div>}
</div>
{hasIcon && <ArrowUpRight className="vertically-centered" />}
</Link>
))}
</div>
)
}
export default ListTable

0 comments on commit 063a19d

Please sign in to comment.