Skip to content

Commit 94658a7

Browse files
committed
Add preview frameless prop
1 parent 6a4fb32 commit 94658a7

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

packages/mdx/dev/content/scrollycoding-preview-jsx.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Create a `next.config.js` file at the root of your project.
2020

2121
Here we use the [_`require("@next/mdx")`_](focus://1,6,8) plugin to set up MDX imports.
2222

23-
<CH.Preview>
23+
<CH.Preview frameless>
2424
<div>Step 1</div>
2525
<div>Step 1</div>
2626
<div>Step 1</div>

packages/mdx/src/mdx-client/preview.tsx

+20-15
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,43 @@ export function Preview({
1717
children,
1818
codeConfig,
1919
style,
20+
frameless,
2021
...rest
2122
}: {
2223
className: string
24+
frameless?: boolean
2325
files: EditorStep["files"]
2426
presetConfig?: PresetConfig
2527
show?: string
2628
style?: React.CSSProperties
2729
children?: React.ReactNode
2830
codeConfig: { theme: EditorTheme }
2931
}) {
32+
const kids = presetConfig ? (
33+
<SandpackPreview
34+
files={files}
35+
presetConfig={presetConfig}
36+
/>
37+
) : (
38+
children
39+
)
3040
return (
3141
<div
3242
className={
3343
"ch-preview" + (className ? " " + className : "")
3444
}
3545
style={style}
3646
>
37-
<MiniBrowser
38-
loadUrl={show}
39-
theme={codeConfig.theme}
40-
{...rest}
41-
children={
42-
presetConfig ? (
43-
<SandpackPreview
44-
files={files}
45-
presetConfig={presetConfig}
46-
/>
47-
) : (
48-
children
49-
)
50-
}
51-
/>
47+
{frameless ? (
48+
kids
49+
) : (
50+
<MiniBrowser
51+
loadUrl={show}
52+
theme={codeConfig.theme}
53+
{...rest}
54+
children={kids}
55+
/>
56+
)}
5257
</div>
5358
)
5459
}

0 commit comments

Comments
 (0)