Skip to content

Commit

Permalink
Merge pull request #225 from code-hike/frameless-preview
Browse files Browse the repository at this point in the history
Add preview frameless prop
  • Loading branch information
pomber authored Jul 15, 2022
2 parents 6a4fb32 + 94658a7 commit ed3116e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
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

0 comments on commit ed3116e

Please sign in to comment.