import React, { useEffect } from 'react'; import { createPortal } from 'react-dom'; import { X } from '@phosphor-icons/react'; import { motion, AnimatePresence } from 'framer-motion'; import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter'; import { MistOrb, MistHorizon } from './mist'; /* a prism style for the mist — cool inks on a pale veil, nothing harsh */ const mistSyntaxTheme = { 'code[class*="language-"]': { color: '#3C4845', background: 'none', textShadow: 'none', }, 'pre[class*="language-"]': { color: '#3C4845', background: 'none', textShadow: 'none', }, comment: { color: '#8A9894', fontStyle: 'italic' }, prolog: { color: '#8A9894' }, doctype: { color: '#8A9894' }, cdata: { color: '#8A9894' }, punctuation: { color: '#5C6B67' }, namespace: { opacity: 0.7 }, property: { color: '#5F837B' }, tag: { color: '#5F837B' }, boolean: { color: '#8FA8BC' }, number: { color: '#8FA8BC' }, constant: { color: '#8FA8BC' }, symbol: { color: '#8FA8BC' }, deleted: { color: '#5C6B67', textDecoration: 'line-through' }, selector: { color: '#5F837B' }, 'attr-name': { color: '#5C6B67' }, string: { color: '#5F837B' }, char: { color: '#5F837B' }, builtin: { color: '#5F837B' }, inserted: { color: '#5F837B' }, operator: { color: '#5C6B67' }, entity: { color: '#5C6B67', cursor: 'help' }, url: { color: '#8FA8BC' }, atrule: { color: '#5F837B' }, 'attr-value': { color: '#5F837B' }, keyword: { color: '#5F837B', fontStyle: 'italic' }, function: { color: '#3C4845', fontWeight: '500' }, 'class-name': { color: '#3C4845', fontWeight: '500' }, regex: { color: '#8FA8BC' }, important: { color: '#5F837B', fontWeight: 'bold' }, variable: { color: '#3C4845' }, bold: { fontWeight: 'bold' }, italic: { fontStyle: 'italic' }, }; const MistCodeModal = ({ isOpen, onClose, children, language }) => { useEffect(() => { if (isOpen) document.body.style.overflow = 'hidden'; else document.body.style.overflow = ''; return () => { document.body.style.overflow = ''; }; }, [isOpen]); return createPortal( {isOpen && ( e.stopPropagation()} initial={{ opacity: 0, y: 12, filter: 'blur(6px)' }} animate={{ opacity: 1, y: 0, filter: 'blur(0px)' }} exit={{ opacity: 0, y: 12, filter: 'blur(6px)' }} transition={{ duration: 0.4, ease: 'easeOut' }} >
source, half-remembered · {language || 'text'}
{children}
read-only · nothing to wake · still here
)}
, document.body, ); }; export default MistCodeModal;