Created
March 28, 2022 20:20
-
-
Save forsureitsme/76d31903fdd998d77de193b31a4bb4e2 to your computer and use it in GitHub Desktop.
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
// 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