mirror of
https://github.com/vercel/next-learn.git
synced 2026-06-11 09:51:47 +00:00
35 lines
896 B
JavaScript
35 lines
896 B
JavaScript
import Modal from 'react-modal';
|
|
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
|
|
import { twilight } from 'react-syntax-highlighter/dist/cjs/styles/prism';
|
|
|
|
const customStyles = {
|
|
content: {
|
|
top: '50%',
|
|
left: '50%',
|
|
right: 'auto',
|
|
bottom: 'auto',
|
|
marginRight: '-50%',
|
|
transform: 'translate(-50%, -50%)',
|
|
maxWidth: '100%',
|
|
},
|
|
};
|
|
|
|
Modal.setAppElement('#__next');
|
|
|
|
export default function CodeSampleModal({ isOpen, closeModal }) {
|
|
return (
|
|
<Modal
|
|
isOpen={isOpen}
|
|
onRequestClose={closeModal}
|
|
style={customStyles}
|
|
contentLabel="Code Sample"
|
|
>
|
|
<p>Wonder no more!</p>
|
|
<SyntaxHighlighter language="javascript" style={twilight}>
|
|
{`function printHelloWorld() { \n console.log('Hello World!'); \n}`}
|
|
</SyntaxHighlighter>
|
|
<button onClick={closeModal}>Close</button>
|
|
</Modal>
|
|
);
|
|
}
|