Skip to content

Commit 3a30ee3

Browse files
committed
improvement(blog): match code blocks and inline code to the in-app editor tokens
1 parent 6a2e8bc commit 3a30ee3

2 files changed

Lines changed: 21 additions & 11 deletions

File tree

apps/sim/lib/content/code.tsx

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
'use client'
22

3-
import { Code } from '@sim/emcn'
3+
import { Code, chipFieldSurfaceClass, cn } from '@sim/emcn'
44

55
interface CodeBlockProps {
66
code: string
77
language: 'javascript' | 'json' | 'python'
88
}
99

10+
/**
11+
* Blog code block. Renders through emcn's read-only `Code.Viewer` wearing the exact same
12+
* `chipFieldSurfaceClass` surface the in-app code editor uses (the custom-tools `CodeEditor`),
13+
* so a fenced block in a post matches the real editor: same Prism theme, gutter, and font, on
14+
* the same theme-following surface (`--surface-5`/`--border-1`, rounded-lg) — no forced dark,
15+
* all from existing design tokens.
16+
*/
1017
export function CodeBlock({ code, language }: CodeBlockProps) {
1118
return (
12-
<div className='dark w-full overflow-hidden rounded-md border border-[var(--border)] bg-[var(--code-bg)] text-sm'>
13-
<Code.Viewer
14-
code={code}
15-
showGutter
16-
language={language}
17-
className='[&_pre]:!pb-0 m-0 rounded-none border-0 bg-transparent'
18-
/>
19-
</div>
19+
<Code.Viewer
20+
code={code}
21+
showGutter
22+
language={language}
23+
className={cn(chipFieldSurfaceClass, 'w-full overflow-hidden text-sm')}
24+
/>
2025
)
2126
}

apps/sim/lib/content/mdx.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,16 +182,21 @@ export const mdxComponents: MDXRemoteProps['components'] = {
182182
}
183183
return <pre {...props} className={clsx('my-4 overflow-x-auto rounded-lg', props.className)} />
184184
},
185+
// Inline code chip — matches the rich markdown editor's `.rich-markdown-prose code` exactly
186+
// (--surface-5 fill, Martian Mono, 0.875em, 4px radius, 0.125rem/0.375rem padding, no border).
185187
code: (props: any) => {
186188
if (!props.className) {
187189
return (
188190
<code
189191
{...props}
190192
className={clsx(
191-
'rounded bg-[var(--surface-hover)] px-1.5 py-0.5 font-mono font-normal text-[0.9em] text-[var(--text-primary)]',
193+
'rounded-[4px] bg-[var(--surface-5)] px-[0.375rem] py-[0.125rem] font-normal text-[0.875em] text-[var(--text-primary)]',
192194
props.className
193195
)}
194-
style={{ fontWeight: 400 }}
196+
style={{
197+
fontFamily: 'var(--font-martian-mono, ui-monospace, monospace)',
198+
fontWeight: 400,
199+
}}
195200
/>
196201
)
197202
}

0 commit comments

Comments
 (0)