Skip to content

Add preview frameless prop #225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/mdx/dev/content/scrollycoding-preview-jsx.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Create a `next.config.js` file at the root of your project.

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

<CH.Preview>
<CH.Preview frameless>
<div>Step 1</div>
<div>Step 1</div>
<div>Step 1</div>
Expand Down
35 changes: 20 additions & 15 deletions packages/mdx/src/mdx-client/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,43 @@ export function Preview({
children,
codeConfig,
style,
frameless,
...rest
}: {
className: string
frameless?: boolean
files: EditorStep["files"]
presetConfig?: PresetConfig
show?: string
style?: React.CSSProperties
children?: React.ReactNode
codeConfig: { theme: EditorTheme }
}) {
const kids = presetConfig ? (
<SandpackPreview
files={files}
presetConfig={presetConfig}
/>
) : (
children
)
return (
<div
className={
"ch-preview" + (className ? " " + className : "")
}
style={style}
>
<MiniBrowser
loadUrl={show}
theme={codeConfig.theme}
{...rest}
children={
presetConfig ? (
<SandpackPreview
files={files}
presetConfig={presetConfig}
/>
) : (
children
)
}
/>
{frameless ? (
kids
) : (
<MiniBrowser
loadUrl={show}
theme={codeConfig.theme}
{...rest}
children={kids}
/>
)}
</div>
)
}
Expand Down