Skip to content

feat(prose): add table styling support#1063

Merged
rfgamaral merged 3 commits into
mainfrom
amix/prose-table-styles
Jun 11, 2026
Merged

feat(prose): add table styling support#1063
rfgamaral merged 3 commits into
mainfrom
amix/prose-table-styles

Conversation

@amix

@amix amix commented Jun 11, 2026

Copy link
Copy Markdown
Member

Follow-up to https://github.com/Doist/comms-web/pull/395#discussion_r3395143218 — Comms now renders GFM tables in messages and should eventually use <Prose> instead of its forked prose CSS, but <Prose> had no table styling.

Short description

  • Adds bordered table styles to <Prose>, with a new public --reactist-prose-table-border custom property (defaults to var(--reactist-divider-primary)).
  • Wide tables scroll horizontally (display: block; width: max-content; max-width: 100%; overflow: auto) instead of stretching the surrounding content, with word-break: normal so cell text doesn't collapse to one character per line under .prose's break-word.
  • Headers are bold and start-aligned, with a th:not([align]) guard so explicit column alignment survives both renderer conventions: marked emits the presentational align attribute (which author CSS would override without the guard), while react-markdown emits inline text-align styles (which win regardless).
  • Cells reset first/last-child block margins so raw HTML tables with block content (e.g. <td><p>…</p></td>) don't get awkward vertical spacing.
  • Adds --reactist-prose-table-header-fill, --reactist-prose-table-row-odd-fill, and --reactist-prose-table-row-even-fill custom properties (all default to transparent) so consumers can color the header row and stripe body rows, demoed in a "Table colors" story.
  • Adds a table (with column alignment) to the Storybook prose example, plus a dedicated width-constrained "Table overflow" story so Chromatic exercises the horizontal-scroll layout at any viewport.

Smoke tested in Storybook in light and dark playground modes and in the overflow story.

Out of scope

  • Keyboard-focusable scrolling for clipped tables in Safari: Prose is CSS-only over HTML it doesn't control, so it can't inject a focusable wrapper or tabindex. Chrome 130+/Firefox handle this natively for scrollers without focusable children; the wrapper belongs at the consumer's renderer level (tracked for the Comms migration). See the resolved review thread for details.

PR Checklist

  • Added tests for bugs / new features (visual coverage via the new Chromatic stories; no unit-testable logic)
  • Updated docs (storybooks, readme)
  • Reviewed and approved Chromatic visual regression tests in CI

🤖 Generated with Claude Code

Tables rendered from Markdown (or raw HTML) inside <Prose> were
unstyled. Add bordered table styles with a public
--reactist-prose-table-border custom property, horizontal scrolling for
wide tables, and start-aligned headers that still respect explicit
column alignment from Markdown renderers.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@amix amix requested a review from rfgamaral June 11, 2026 10:57
@amix amix marked this pull request as ready for review June 11, 2026 10:57

@doistbot doistbot left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This PR introduces robust table styling support to the Prose component, including borders, explicit alignments, and horizontal scrolling for wide tables.

Few things worth tightening:

  • Wrapping the table in a focusable overflow container to ensure horizontal scrolling is accessible to keyboard users.
  • Adding a wider table to the Storybook fixture so Chromatic exercises the new overflow layout path.

Share FeedbackReview Logs

Comment thread src/prose/prose.module.css
Comment thread src/prose/prose-example.ts
The playground example only shows a narrow table, so Chromatic never
exercised the horizontal-scroll layout for wide tables. A dedicated
story renders a table with unbreakable links inside a 400px container,
guaranteeing the overflow path is snapshotted at any viewport size.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@rfgamaral rfgamaral left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me 🚀

But here's one suggestion: add more --reactist-prose-* variables that allow consumers to configure the background color of the header row, and the background color of odd and even rows. We can probably leave the Reactist defaults as transparent/inherit/initial (ask your clanker which one is most suited).

Allow consumers to configure the table header row background and
odd/even body row backgrounds via --reactist-prose-table-header-fill,
--reactist-prose-table-row-odd-fill, and
--reactist-prose-table-row-even-fill. All default to transparent, so
tables render unchanged unless customized.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@amix

amix commented Jun 11, 2026

Copy link
Copy Markdown
Member Author

@rfgamaral great suggestion, I've implemented it. Could you please re-check 🙏

@rfgamaral rfgamaral merged commit b02c094 into main Jun 11, 2026
11 checks passed
@rfgamaral rfgamaral deleted the amix/prose-table-styles branch June 11, 2026 17:55
@rfgamaral

rfgamaral commented Jun 11, 2026

Copy link
Copy Markdown
Member

Looks great, merged it for you, @amix. We should get an automated release of this very soon.

doist-release-bot Bot pushed a commit that referenced this pull request Jun 11, 2026
## [33.1.0](v33.0.1...v33.1.0) (2026-06-11)

### Features

* **prose:** add table styling support ([#1063](#1063)) ([b02c094](b02c094))
@doist-release-bot

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 33.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@doist-release-bot doist-release-bot Bot added the Released PRs that have been merged and released label Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Released PRs that have been merged and released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants