Skip to content

Allow explicitly passing Prism prop to CodeSurfer #50

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion packages/code-surfer/src/code-surfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ const CodeSurfer = ({
showNumbers,
dark,
theme,
monospace
monospace,
Prism
}) => {
const selectedTokens = new SelectedTokens(step);

return (
<Highlight
{...defaultProps}
Prism={Prism || defaultProps.Prism}
code={code}
language={lang || "jsx"}
theme={theme !== undefined ? theme : dark ? darkTheme : lightTheme}
Expand Down
5 changes: 4 additions & 1 deletion packages/mdx-deck-code-surfer/src/deck-code-surfer-split.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ export default withDeck(
stepsBottom,
title,
showNumbers,
notes
notes,
Prism
} = this.props;
const { step, mode } = this.props.deck;
const currentStepTop =
Expand All @@ -67,6 +68,7 @@ export default withDeck(
code={codeTop}
step={currentStepTop}
showNumbers={showNumbers}
Prism={Prism}
/>
</div>
<div style={{ height: "25px" }} />
Expand All @@ -78,6 +80,7 @@ export default withDeck(
code={codeBottom}
step={currentStepBottom}
showNumbers={showNumbers}
Prism={Prism}
/>
</div>
<div style={{ height: "25px" }} />
Expand Down
3 changes: 2 additions & 1 deletion packages/mdx-deck-code-surfer/src/deck-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import DeckCodeSurfer from "./deck-code-surfer";

class Code extends React.PureComponent {
render() {
const { children, metaString, className } = this.props;
const { children, metaString, className, Prism } = this.props;
const [src, steps] = children.split("\n----");
const language = className.slice(9);
return language === "notes" ? (
Expand All @@ -15,6 +15,7 @@ class Code extends React.PureComponent {
steps={steps}
title={metaString}
lang={language}
Prism={Prism}
/>
);
}
Expand Down