-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLuxeCodeModal.jsx
More file actions
122 lines (113 loc) · 4.63 KB
/
LuxeCodeModal.jsx
File metadata and controls
122 lines (113 loc) · 4.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import React, { useEffect } from 'react';
import { createPortal } from 'react-dom';
import { X, Code, ClipboardText } from '@phosphor-icons/react';
import { motion, AnimatePresence } from 'framer-motion';
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
import { coy } from 'react-syntax-highlighter/dist/esm/styles/prism';
import LuxeArt from './LuxeArt';
import { useToast } from '../hooks/useToast';
const LuxeCodeModal = ({ isOpen, onClose, children, language }) => {
const { addToast } = useToast();
useEffect(() => {
if (isOpen) {
document.body.style.overflow = 'hidden';
} else {
document.body.style.overflow = '';
}
return () => {
document.body.style.overflow = '';
};
}, [isOpen]);
const handleCopy = () => {
navigator.clipboard.writeText(children).then(() => {
addToast({
title: 'Archive Synchronized',
message: 'Code snippet copied to local clipboard.',
type: 'success',
});
});
};
return createPortal(
<AnimatePresence>
{isOpen && (
<motion.div
className="fixed inset-0 bg-[#F5F5F0]/95 backdrop-blur-md flex justify-center items-center z-[1000] p-4 md:p-12"
onClick={onClose}
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
>
<motion.div
className="relative bg-white border border-black/5 rounded-sm shadow-[0_40px_120px_-20px_rgba(0,0,0,0.2)] w-full max-w-6xl h-[85vh] flex flex-col overflow-hidden"
onClick={(e) => e.stopPropagation()}
initial={{ scale: 0.98, opacity: 0, y: 20 }}
animate={{ scale: 1, opacity: 1, y: 0 }}
exit={{ scale: 0.98, opacity: 0, y: 20 }}
transition={{ type: 'spring', damping: 35, stiffness: 200 }}
>
<div className="absolute inset-0 opacity-[0.03] pointer-events-none">
<LuxeArt
seed="CODE_EXPANSION"
className="w-full h-full mix-blend-multiply"
/>
</div>
{/* Header */}
<div className="relative z-10 flex items-center justify-between p-6 md:p-8 border-b border-black/5 bg-[#FAFAF8]">
<div className="flex flex-col">
<span className="font-outfit text-[9px] uppercase tracking-[0.4em] text-[#8D4004] font-bold">
Technical Specification
</span>
<h2 className="font-playfairDisplay italic text-2xl text-[#1A1A1A] flex items-center gap-3">
<Code size={24} weight="light" className="text-[#8D4004]" />
{language?.toUpperCase() || 'SOURCE'}
</h2>
</div>
<div className="flex items-center gap-4">
<button
onClick={handleCopy}
className="flex items-center gap-2 px-5 py-2 bg-white hover:bg-[#1A1A1A] text-[#1A1A1A]/60 hover:text-white border border-black/10 rounded-full transition-all text-[10px] uppercase tracking-widest font-bold"
>
<ClipboardText size={16} /> Copy
</button>
<button
onClick={onClose}
className="group p-2 text-[#1A1A1A]/20 hover:text-[#8D4004] transition-colors"
>
<X size={24} weight="light" />
</button>
</div>
</div>
{/* Content */}
<div className="flex-1 overflow-auto relative z-10 custom-scrollbar bg-white p-2">
<SyntaxHighlighter
style={coy}
language={language}
PreTag="div"
customStyle={{
margin: 0,
padding: '2rem',
background: 'transparent',
fontSize: '0.95rem',
lineHeight: '1.7',
}}
showLineNumbers={true}
>
{children}
</SyntaxHighlighter>
</div>
{/* Footer */}
<div className="relative z-10 px-8 py-3 border-t border-black/5 bg-[#FAFAF8] flex justify-between items-center font-outfit text-[9px] uppercase tracking-[0.3em] text-black/20">
<span>Refined Syntax Presentation</span>
<div className="flex items-center gap-2">
<span className="w-1 h-1 bg-[#8D4004]/30 rounded-full animate-pulse" />
<span>Archive Online</span>
</div>
</div>
</motion.div>
</motion.div>
)}
</AnimatePresence>,
document.body,
);
};
export default LuxeCodeModal;