Skip to content

feat(Markdown, CodeBlock): contentWidth, collapsible code blocks, compact header - #1289

Merged
cixzhang merged 1 commit into
mainfrom
navi/feat/markdown-nits
Apr 11, 2026
Merged

cixzhang merged 1 commit into
mainfrom
navi/feat/markdown-nits

Conversation

@cixzhang

@cixzhang cixzhang commented Apr 11, 2026 •

Copy link
Copy Markdown
Contributor

Changes

Markdown

  • contentWidth prop (default: 680px) — constrains prose content (paragraphs, headings, lists, blockquotes) to a readable line width. Tables and code blocks expand to full container width.
  • Uses StyleX dynamic styles (not CSS custom properties) for the prose max-width and table min-width.
  • Tables: width: auto, min-width: contentWidth (dynamic), max-width: 100%
  • Code blocks use isCollapsible instead of maxHeight

CodeBlock

  • Collapsible code blocks — isCollapsible prop with collapsibleThreshold (default: 10 lines). Starts expanded; header becomes clickable to collapse the code body into just the header bar. Uses grid-template-rows animation (same pattern as ToolCalls, SideNav, Attachments).
  • Compact header without line numbers — no border-bottom divider, tighter padding
  • Sticky header inside scroll container
  • Header order: <title> — <language> (filename first)
  • Chevron next to label using XDSIcon chevronDown, matches ToolCalls convention (down = expanded, up = collapsed)
  • Copy button: marginInlineEnd: -8px for optical alignment
  • isolation: isolate on root for stacking context

Reverted (for later)

  • Image skeleton + fade-in loading

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Apr 11, 2026
@github-actions

github-actions Bot commented Apr 11, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

Modified Components

CodeBlock · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 710B N/A
Lines of Code N/A 1296 -
Complexity N/A Very High (79) -
Markdown · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 1.1KB N/A
Lines of Code N/A 1756 -
Complexity N/A Very High (155) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@xds/core 15.0KB 23.6KB 3.6KB

Accessibility Audit

Status: 3 accessibility violation(s) found — 1 critical, 2 serious.

XDSCodeBlock - 1 issue(s)
  • 🟠 serious: Ensure elements that have scrollable content are accessible by keyboard
    • Rule: scrollable-region-focusable · Affects 1/13 stories · Learn more
    • WCAG: 2.1.1, 2.1.3 (Level A)
XDSMarkdown - 2 issue(s)
  • 🔴 critical: Ensure an element's role supports its ARIA attributes
    • Rule: aria-allowed-attr · Affects 4/6 stories · Learn more
    • WCAG: 4.1.2 (Level A)
  • 🟠 serious: Ensure interactive controls are not nested as they are not always announced by screen readers or can cause focus problems for assistive technologies
    • Rule: nested-interactive · Affects 1/6 stories · Learn more
    • WCAG: 4.1.2 (Level A)

Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@cixzhang
cixzhang force-pushed the navi/feat/markdown-nits branch 4 times, most recently from 8dd7457 to 8feca7d Compare April 11, 2026 22:35
@cixzhang cixzhang changed the title feat(Markdown, CodeBlock): contentWidth prop + compact header feat(Markdown, CodeBlock): contentWidth, collapsible code blocks, compact header Apr 11, 2026
… line numbers

CodeBlock:
- Without line numbers: compact header padding, no border-bottom divider
- With line numbers: unchanged (full padding + divider)

Markdown:
- New contentWidth prop — constrains prose content (paragraphs, headings,
  lists, blockquotes) to a readable width while tables and code blocks
  expand to the full container width
- Uses CSS custom property (--xds-markdown-content-width) so it works
  without wrapper elements
@cixzhang
cixzhang force-pushed the navi/feat/markdown-nits branch from 8feca7d to 1688b2d Compare April 11, 2026 22:49
@cixzhang
cixzhang enabled auto-merge (squash) April 11, 2026 22:51
@cixzhang
cixzhang merged commit b815273 into main Apr 11, 2026
15 checks passed
josephfarina added a commit that referenced this pull request Apr 12, 2026
…ix Chat @example

Found during Night Watch doc review (2026-04-12).

- Fix XDSChatTokenizedText @example: remove blank lines and JS comments
  inside code block (reintroduced by #1249)
- Add xds-chat-layout theming target to Chat.doc.mjs (new in #1249)
- Add missing Markdown props: contentWidth, contentAlign, sources,
  citationStyle (from #1289, #1290)
- Add missing CodeBlock props: isCollapsible, collapsibleThreshold
- Add Thumbnail theming section (xds-thumbnail target)
- Add Thumbnail common props: xstyle, className, style, data-testid
- Add Thumbnail docsZh and docsDense translations
- Add Thumbnail accessibility section

Co-authored-by: Navi <[email protected]>
cixzhang added a commit that referenced this pull request Apr 26, 2026
… line numbers (#1289)

CodeBlock:
- Without line numbers: compact header padding, no border-bottom divider
- With line numbers: unchanged (full padding + divider)

Markdown:
- New contentWidth prop — constrains prose content (paragraphs, headings,
  lists, blockquotes) to a readable width while tables and code blocks
  expand to the full container width
- Uses CSS custom property (--xds-markdown-content-width) so it works
  without wrapper elements

Co-authored-by: Navi <[email protected]>
cixzhang added a commit that referenced this pull request Jun 21, 2026
… line numbers (#1289)

CodeBlock:
- Without line numbers: compact header padding, no border-bottom divider
- With line numbers: unchanged (full padding + divider)

Markdown:
- New contentWidth prop — constrains prose content (paragraphs, headings,
  lists, blockquotes) to a readable width while tables and code blocks
  expand to the full container width
- Uses CSS custom property (--xds-markdown-content-width) so it works
  without wrapper elements

Co-authored-by: Navi <[email protected]>
cixzhang added a commit that referenced this pull request Jun 21, 2026
… line numbers (#1289)

CodeBlock:
- Without line numbers: compact header padding, no border-bottom divider
- With line numbers: unchanged (full padding + divider)

Markdown:
- New contentWidth prop — constrains prose content (paragraphs, headings,
  lists, blockquotes) to a readable width while tables and code blocks
  expand to the full container width
- Uses CSS custom property (--xds-markdown-content-width) so it works
  without wrapper elements
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant