-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Hey. I'm struggling to implement theme switcher using this library.
Here's my code snippet:
import { Editor } from "prism-react-editor"
import { BasicSetup } from "prism-react-editor/setups"
import "prism-react-editor/prism/languages/jsx"
import "prism-react-editor/prism/languages/tsx"
import "prism-react-editor/languages"
import "prism-react-editor/layout.css"
// import "prism-react-editor/themes/github-dark.css"
// import "prism-react-editor/themes/github-light.css"
import { loadTheme } from "prism-react-editor/themes"
// Required by the basic setup
import "prism-react-editor/search.css"
import { useEffect, useLayoutEffect } from "react"
interface CodeEditorProps {
language: string
theme: string
}
export default function CodeEditor({ language, theme }: CodeEditorProps) {
useEffect(() => {
loadTheme("github-dark")
}, [])
return (
<main className="grow overflow-auto github">
<Editor
language={language}
value={`const foo: string = 'bar';\nfunction greet(name: string): string {\n return 'Hello, ' + name;\n}\nconsole.log(greet('World'));\n${"console.log(foo);\n".repeat(100)}`} // Long content to test scrolling
style={{
height: "100%",
fontSize: "16px",
}}
>
{(editor) => <BasicSetup editor={editor} />}
</Editor>
</main>
)
}Using this example styles are not working at all :(
Any tips how to get it working? It would be nice to have some example inside readme :)
Cheers!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels