Skip to content

More flexible Table.Head/Footer with [noCell] prop for better pinCols support#463

Merged
benjitrosch merged 4 commits intodaisyui:mainfrom
AndrewBrough:main
Sep 18, 2024
Merged

More flexible Table.Head/Footer with [noCell] prop for better pinCols support#463
benjitrosch merged 4 commits intodaisyui:mainfrom
AndrewBrough:main

Conversation

@AndrewBrough
Copy link
Copy Markdown
Contributor

@AndrewBrough AndrewBrough commented Sep 13, 2024

Addresses #462

Currently the Table.Head/Body/Row/Footer pattern is very rigid - always wrapping children with th/td tags in Head/Footer. We don't want to break backwards compatibility, so to enable better table customization this PR adds the noCell property to Table.Head, Row and Footer. This prop allows devs to disable internally wrapping th/td tags and pass th/td tags as children manually - but still keep the useful default behaviour.

This is useful because it lets devs pin th tags in a row at any location, not just the first child.

eg.

What you couldn't do but now can with noCell:

<Table pinCols>
  <Table.Head noCell>
    <th></th>
    <td></td>
    <td></td>
    <th></th>
    <td></td>
    <td></td>
  </Table.Head>

  <Table.Body>
    <Table.Row noCell>
      <th></th>
      <td></td>
      <td></td>
      <th></th>
      <td></td>
      <td></td>
    </Table.Row>
  </Table.Body>

  <Table.Footer noCell>
    <th></th>
    <td></td>
    <td></td>
    <th></th>
    <td></td>
    <td></td>
  </Table.Footer>
</Table>

Also updated tests for Table.Head/Row/Footer to cover noCell cases AND updated the story with a robust example with staggered th tags when noCell is enabled.

@netlify
Copy link
Copy Markdown

netlify Bot commented Sep 13, 2024

👷 Deploy Preview for react-daisyui processing.

Name Link
🔨 Latest commit 8459937
🔍 Latest deploy log https://app.netlify.com/sites/react-daisyui/deploys/66e45549f48f9d00087b2ea9

@netlify
Copy link
Copy Markdown

netlify Bot commented Sep 13, 2024

Deploy Preview for react-daisyui ready!

Name Link
🔨 Latest commit 8459937
🔍 Latest deploy log https://app.netlify.com/sites/react-daisyui/deploys/66e45549f48f9d00087b2ea9
😎 Deploy Preview https://deploy-preview-463--react-daisyui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@AndrewBrough AndrewBrough changed the title Fix Table.Head not accepting <Table.Row>, enable pinCols to work with custom children More flexible Table.Head/Footer with [noCell] prop for better pinCols support Sep 13, 2024
@AndrewBrough
Copy link
Copy Markdown
Contributor Author

Note that I didn't end up addressing the original comment I made about Table.Head not letting me pass Table.Row into it as I originally expected - the issue was actually that you can't customize the child cells. I left Table.Head & Footer with a tag within because it wasn't causing issues.

Maybe one day someone would want to pass props into that tr, in which case we could just remove it and make devs have the same structure as Table.Body.

Copy link
Copy Markdown
Collaborator

@benjitrosch benjitrosch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@benjitrosch benjitrosch merged commit 0317ed3 into daisyui:main Sep 18, 2024
This was referenced Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants