Skip to content

Commit 485af62

Browse files
committed
fix: code modal black font
1 parent 898e797 commit 485af62

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/components/CodeModal.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { motion, AnimatePresence } from 'framer-motion';
44
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
55
import { customTheme } from '../utils/customTheme';
66

7-
const CodeModal = ({ isOpen, onClose, children }) => {
7+
const CodeModal = ({ isOpen, onClose, children, language }) => {
88
useEffect(() => {
99
if (isOpen) {
1010
document.body.style.overflow = 'hidden';
@@ -27,7 +27,7 @@ const CodeModal = ({ isOpen, onClose, children }) => {
2727
exit={{ opacity: 0 }}
2828
>
2929
<motion.div
30-
className="relative bg-gray-800 rounded-lg shadow-lg p-6 w-3/4 h-3/4"
30+
className="relative bg-gray-800 rounded-lg shadow-lg p-6 w-3/4 h-3/4 prose prose-xl prose-dark max-w-none"
3131
onClick={(e) => e.stopPropagation()}
3232
initial={{ scale: 0.8, opacity: 0 }}
3333
animate={{ scale: 1, opacity: 1 }}
@@ -42,7 +42,7 @@ const CodeModal = ({ isOpen, onClose, children }) => {
4242
</button>
4343
<SyntaxHighlighter
4444
style={customTheme}
45-
language="jsx"
45+
language={language}
4646
PreTag="pre"
4747
className="overflow-auto h-full"
4848
codeTagProps={{

src/pages/BlogPostPage.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ const CodeBlock = ({
8686
<div className="relative">
8787
<div className="absolute top-2 right-2 flex gap-2">
8888
<button
89-
onClick={() => openModal(String(children).replace(/\n$/, ''))}
89+
onClick={() => openModal(String(children).replace(/\n$/, ''), match[1])}
9090
className="text-white bg-gray-700 p-1 rounded opacity-75 hover:opacity-100"
9191
>
9292
<ArrowsOutSimple size={20} />
@@ -126,9 +126,11 @@ const BlogPostPage = () => {
126126
const contentRef = useRef(null);
127127
const [isModalOpen, setIsModalToOpen] = useState(false);
128128
const [modalContent, setModalContent] = useState('');
129+
const [modalLanguage, setModalLanguage] = useState('jsx'); // Default to jsx
129130

130-
const openModal = (content) => {
131+
const openModal = (content, language) => {
131132
setModalContent(content);
133+
setModalLanguage(language);
132134
setIsModalToOpen(true);
133135
};
134136

@@ -352,7 +354,7 @@ const BlogPostPage = () => {
352354
</div>
353355
</div>
354356
</div>
355-
<CodeModal isOpen={isModalOpen} onClose={closeModal}>
357+
<CodeModal isOpen={isModalOpen} onClose={closeModal} language={modalLanguage}>
356358
{modalContent}
357359
</CodeModal>
358360
</div>

0 commit comments

Comments
 (0)