An open source design system that's fully customizable and agent ready
TypeScript
fix(Markdown): use 8px table cell spacing (#6801)
Cindy Zhang60a8f6d98684
diff --git a/.changeset/markdown-table-cell-spacing.md b/.changeset/markdown-table-cell-spacing.mdnew file mode 100644index 0000000000..354326c542--- /dev/null+++ b/.changeset/markdown-table-cell-spacing.md@@ -0,0 +1,7 @@+---+'@astryxdesign/core': patch+---++[fix] Markdown tables now use the `spacing-2` token (8px) on every header and body cell edge. The tighter inline spacing leaves more room for content in narrow reading columns while keeping rows comfortably readable.++@cixzhangdiff --git a/packages/core/src/Markdown/Markdown.test.tsx b/packages/core/src/Markdown/Markdown.test.tsxindex 92eccf6cfc..f3c33c0474 100644--- a/packages/core/src/Markdown/Markdown.test.tsx+++ b/packages/core/src/Markdown/Markdown.test.tsx@@ -11,11 +11,20 @@ import {} from 'vitest';import {render, screen, fireEvent} from '@testing-library/react';import type {ComponentProps, ReactNode} from 'react';+import * as stylex from '@stylexjs/stylex';import {Markdown} from './Markdown';import type {MarkdownComponents, MarkdownInlinePlugin} from './Markdown';import type {ParseOptions} from './index';import {stubMatchMedia} from '../__tests__/stubMatchMedia';import {parseOutlineFromMarkdown} from '../Outline/parseOutlineFromMarkdown';+import {spacingVars} from '../theme/tokens.stylex';++const tableCellSpacingProbe = stylex.create({+ cell: {+ paddingBlock: spacingVars['--spacing-2'],+ paddingInline: spacingVars['--spacing-2'],+ },+});describe('Markdown', () => {it('renders with role="document"', () => {@@ -495,6 +504,26 @@ describe('Markdown', () => {expect(markdownBlock).not.toHaveAttribute('tabindex');});+ it('uses spacing-2 on every Markdown table cell edge', () => {+ const {container} = render(+ <Markdown>{'| A | B |\n| --- | --- |\n| 1 | 2 |'}</Markdown>,+ );+ const spacingClasses = (+ stylex.props(tableCellSpacingProbe.cell).className ?? ''+ )+ .split(' ')+ .filter(className => className !== '' && !className.includes('__'));+ const cells = container.querySelectorAll('th, td');++ expect(spacingClasses.length).toBeGreaterThan(0);+ expect(cells).toHaveLength(4);+ for (const cell of cells) {+ for (const className of spacingClasses) {+ expect(cell).toHaveClass(className);+ }+ }+ });+it('floors each table column from its own content, in ch', () => {// The floor algorithm: max(4, ceil(longest cell / 2), min(header, 20)),// capped at 24, expressed in `ch` so it follows the reader's font size.diff --git a/packages/core/src/Markdown/Markdown.tsx b/packages/core/src/Markdown/Markdown.tsxindex b8a93abe24..108bf1b04d 100644--- a/packages/core/src/Markdown/Markdown.tsx+++ b/packages/core/src/Markdown/Markdown.tsx@@ -304,6 +304,8 @@ const markdownTableCellStyles = stylex.create({maxWidth: 'none',overflow: 'visible',overflowWrap: 'break-word',+ paddingBlock: spacingVars['--spacing-2'],+ paddingInline: spacingVars['--spacing-2'],wordBreak: 'normal',},headerCell: {@@ -311,6 +313,8 @@ const markdownTableCellStyles = stylex.create({maxWidth: 'none',overflow: 'visible',overflowWrap: 'break-word',+ paddingBlock: spacingVars['--spacing-2'],+ paddingInline: spacingVars['--spacing-2'],textOverflow: 'clip',whiteSpace: 'normal',wordBreak: 'normal',