Skip to content

feat(table): fold a record into column groups on small devices - #2138

Merged
markdumay merged 1 commit into
mainfrom
feat/wrap-column-groups
Aug 23, 2026
Merged

feat(table): fold a record into column groups on small devices#2138
markdumay merged 1 commit into
mainfrom
feat/wrap-column-groups

Conversation

@markdumay

Copy link
Copy Markdown
Collaborator

Summary

Adds wrap-cols to the table shortcode: a comma-separated column count per rendered row, so a record folds into groups and stacks as a card on small devices instead of dropping only its last column.

2,4,1 across seven columns keeps # and Name on the lead row, folds four badges onto a row of their own, and gives the description the last.

Consumes gethinode/mod-simple-datatables#298, released in v4.2.0 and bumped here.

Why

wrap folds one column, which is not enough for a table with many columns. A seven-column catalog table still measured 487px against a 358px container on a 390px viewport after its description was folded — the remaining columns are each narrow, but there are too many of them. Folding the badge columns as a group removes the horizontal scroll rather than reducing it: the same table now measures 342px in a 342px container.

Both wrap paths

A plain table folds server-side in render-table.html with display utilities and no JavaScript; a data table folds in the browser, because simple-datatables owns that DOM. The group list reaches the render hook through the page store, the way the caption and the data-table flag already do.

colspan counts the lead group rather than every column. The folded headings are display: none and contribute no column, so spanning the full count reaches past the grid and the folded row's stripe and bottom border stop part way across the table.

Striping

The stripe alternates per record, so a record of N rows has a period of 2N. nth-of-type accepts no custom property, so the rules are emitted per row count rather than parameterised, and only past the default two — which the existing .table-wrap selector already covers, so tables that carry no count class are untouched.

Group layout

A folded group lays its values out in equal columns that drop to as many as fit. Four fixed columns across a 390px viewport are ~74px each, narrower than a label like "Warehouse" — and a rendered badge is wider than its bare text — so a fixed count breaks values mid-word. auto-fit lays four values out 2×2 on a phone and 4-across when there is room.

Values fill their track rather than being sized to content, so a column the author centred or right-aligned keeps that alignment after folding; left is simply what text-align already resolves to.

The layout wrapper sits inside the cell, never on it: a display of grid or flex on a td takes it out of the table formatting context and colspan stops applying with it.

Validation

A group list is refused unless every entry is a positive integer and the total matches the column count. A list left stale when a column is added falls back to wrapping the last column only, rather than folding on stale boundaries and silently dropping or duplicating a column.

Testing

Five fixtures in exampleSite/content/en/table-demo.md, driven in a browser against released modules only at 390px and 1440px:

Fixture Result
Three groups, data table table-wrap-3, 3 rows/record, folded rows full width, 4 chips, no overflow
Three groups, plain table identical — both paths agree
Stale list (2,4 of 7), data table falls back to table-wrap, 2 rows/record
Stale list, plain table identical
Existing default wrap unchanged, no row-count class

At 1440px the three-group tables are unwrapped with all seven headers and seven cells per row, and sorting by Name still reorders correctly — the row model is never touched.

pnpm lint and pnpm test:templates pass.

Follow-up

Docs for the new argument are ready in gethinode/mod-docs and will be raised once this ships in v3.23.0 — that PR's example passes wrap-cols, which an older theme would not recognise.

`wrap` moves the last column onto a row of its own, which is not enough for a
table with many columns: a seven-column catalog table still measured 487px
against a 358px container on a 390px viewport, because the remaining columns are
each narrow but there are too many of them.

`wrap-cols` takes a column count per rendered row, so a record stacks as a card
instead. `2,4,1` keeps the first two columns on the lead row, folds the next four
onto a row of their own and gives the last the final row. That removes the
horizontal scroll rather than reducing it.

Both wrap paths implement it. A plain table folds server-side in the render hook
with display utilities, a data table in the browser through
mod-simple-datatables; the group list reaches the hook through the page store,
the way the caption and the data-table flag already do.

The striping is recomputed per row count: the stripe alternates per record, so a
record of N rows has a period of 2N. `nth-of-type` accepts no custom property, so
the rules are emitted per count rather than parameterised, and only past the
default two, which the existing selector already covers.

A folded group lays its values out in equal columns that drop to as many as fit.
Four fixed columns across a 390px viewport are ~74px each, narrower than a label
like "Warehouse" - and a rendered badge is wider than its bare text - so a fixed
count breaks values mid-word. Values fill their track so a column the author
centred or right-aligned keeps that after folding.
@netlify

netlify Bot commented Aug 23, 2026

Copy link
Copy Markdown

Deploy Preview for gethinode-demo ready!

Name Link
🔨 Latest commit dab5a21
🔍 Latest deploy log https://app.netlify.com/projects/gethinode-demo/deploys/6a8b172897d9b00008595de1
😎 Deploy Preview https://deploy-preview-2138--gethinode-demo.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 project configuration.

@markdumay
markdumay merged commit 76e5b32 into main Aug 23, 2026
17 checks passed
@markdumay

Copy link
Copy Markdown
Collaborator Author

🎉 This PR is included in version 3.23.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant