Skip to content

Commit 66c3395

Browse files
committed
fix(content): stop wide markdown tables breaking the mobile layout
Library and blog posts render GFM tables straight into the prose container with no width bound. Comparison tables run up to nine columns, so on a phone the table set the article's content width and body copy was clipped at both edges with no way to scroll to it — the table simply ran off the canvas. 19 of 20 library posts contain a table. Wraps tables in an `overflow-x-auto` container so that scrolling is confined to the table's own axis, and gives the table a `min-w` so columns do not crush to one word per line inside it. Both surfaces share `mdxComponents`, so this covers blog posts too. Also adds `lib/**` to Tailwind's content globs. `lib/content/mdx.tsx` emits classes like any component, but only `app`, `components`, and `pages` were scanned, so a class unique to that file was silently never generated — `min-w-[520px]` here, and already `list-outside`, `text-[19px]`, and `text-[0.9em]` on the existing paragraph and list styles. Verified against a real browser: without the glob the rule is absent and computed `min-width` stays `0px`. Generated CSS grows 538 bytes minified (+0.26%), all additions, nothing removed.
1 parent 54c3e1c commit 66c3395

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

apps/sim/lib/content/mdx.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,21 @@ export const mdxComponents: MDXRemoteProps['components'] = {
122122
/>
123123
)
124124
},
125+
/**
126+
* GFM comparison tables run up to nine columns of prose, which no phone can
127+
* fit. Without a scroll container the table sets the page's content width and
128+
* the whole article scrolls sideways, clipping body copy at both edges. The
129+
* wrapper confines that scrolling to the table's own axis.
130+
*
131+
* `min-w` keeps columns from collapsing to one word per line inside the
132+
* scroll area — narrow enough that tables which already fit (two or three
133+
* columns on a tablet, anything on desktop) never gain a scrollbar.
134+
*/
135+
table: ({ className, ...props }: any) => (
136+
<div className='my-6 w-full overflow-x-auto'>
137+
<table {...props} className={clsx('my-0 min-w-[520px]', className)} />
138+
</div>
139+
),
125140
figure: (props: any) => (
126141
<figure {...props} className={clsx('my-8 overflow-hidden rounded-lg', props.className)} />
127142
),

apps/sim/tailwind.config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ export default {
1313
'./pages/**/*.{js,ts,jsx,tsx,mdx}',
1414
'./components/**/*.{js,ts,jsx,tsx,mdx}',
1515
'./app/**/*.{js,ts,jsx,tsx,mdx}',
16+
/**
17+
* `lib/content/mdx.tsx` styles rendered blog/library markdown, so it emits
18+
* classes like any component does. Without this glob Tailwind only
19+
* generates the ones that happen to appear in a scanned file too, and a
20+
* class unique to this directory silently resolves to nothing.
21+
*/
22+
'./lib/**/*.{js,ts,jsx,tsx,mdx}',
1623
'../../packages/emcn/src/**/*.{js,ts,jsx,tsx}',
1724
'../../packages/workflow-renderer/src/**/*.{js,ts,jsx,tsx}',
1825
'!./app/node_modules/**',

0 commit comments

Comments
 (0)