Skip to content

Instantly share code, notes, and snippets.

@forsureitsme
Created March 28, 2022 20:20
Show Gist options
  • Save forsureitsme/76d31903fdd998d77de193b31a4bb4e2 to your computer and use it in GitHub Desktop.
Save forsureitsme/76d31903fdd998d77de193b31a4bb4e2 to your computer and use it in GitHub Desktop.
// option 1
const TableLeftoverSpace = () => {
const hasLeftoverSpace = body.length % header.length !== 0;
if(hasLeftoverSpace) {
return (
<div className={styles[`table-leftover-space`]} />
);
}
};
return (
<div className={styles[`table-wrapper`]} style={{'--columns': header.length}}>
{header.map(TableHeaderItem)}
{body.map(TableBodyItem)}
<TableLeftoverSpace />
</div>
)
// option 2
const hasLeftoverSpace = body.length % header.length !== 0;
return (
<div className={styles[`table-wrapper`]} style={{'--columns': header.length}}>
{header.map(TableHeaderItem)}
{body.map(TableBodyItem)}
{hasLeftoverSpace && (
<div className={styles[`table-leftover-space`]} />
)}
</div>
)
// option 3
return (
<div className={styles[`table-wrapper`]} style={{'--columns': header.length}}>
{header.map(TableHeaderItem)}
{body.map(TableBodyItem)}
{() => {
const hasLeftoverSpace = body.length % header.length !== 0;
if(hasLeftoverSpace) {
return (
<div className={styles[`table-leftover-space`]} />
);
}
}}
</div>
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment