-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLuxeSidePanel.jsx
More file actions
151 lines (137 loc) · 5.1 KB
/
LuxeSidePanel.jsx
File metadata and controls
151 lines (137 loc) · 5.1 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import React, { useEffect, useState } from 'react';
import { motion, AnimatePresence } from 'framer-motion';
import { XIcon, InfoIcon } from '@phosphor-icons/react';
import { useSidePanel } from '../context/SidePanelContext';
import LuxeArt from './LuxeArt';
const LuxeSidePanel = () => {
const {
isOpen,
closeSidePanel,
panelTitle,
panelContent,
panelWidth,
setPanelWidth,
} = useSidePanel();
const [isResizing, setIsResizing] = useState(false);
// Close on escape key
useEffect(() => {
const handleKeyDown = (event) => {
if (event.key === 'Escape' && isOpen) {
closeSidePanel();
}
};
window.addEventListener('keydown', handleKeyDown);
return () => window.removeEventListener('keydown', handleKeyDown);
}, [isOpen, closeSidePanel]);
// Handle resizing
useEffect(() => {
const handleMouseMove = (e) => {
if (!isResizing) return;
const newWidth = window.innerWidth - e.clientX;
if (newWidth > 350 && newWidth < window.innerWidth * 0.85) {
setPanelWidth(newWidth);
}
};
const handleMouseUp = () => {
setIsResizing(false);
};
if (isResizing) {
window.addEventListener('mousemove', handleMouseMove);
window.addEventListener('mouseup', handleMouseUp);
document.body.style.cursor = 'ew-resize';
document.body.style.userSelect = 'none';
} else {
document.body.style.cursor = 'default';
document.body.style.userSelect = 'auto';
}
return () => {
window.removeEventListener('mousemove', handleMouseMove);
window.removeEventListener('mouseup', handleMouseUp);
document.body.style.cursor = 'default';
document.body.style.userSelect = 'auto';
};
}, [isResizing, setPanelWidth]);
const variants = {
open: { x: 0, opacity: 1 },
closed: { x: '100%', opacity: 1 },
};
return (
<AnimatePresence>
{isOpen && (
<>
{/* Backdrop with Luxe blur */}
<motion.div
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
onClick={closeSidePanel}
className="fixed inset-0 bg-[#F5F5F0]/80 backdrop-blur-sm z-[100]"
/>
<motion.div
initial="closed"
animate="open"
exit="closed"
variants={variants}
transition={{ type: 'spring', stiffness: 200, damping: 35 }}
style={{ width: panelWidth }}
className="fixed top-0 right-0 h-full bg-white border-l border-black/5 shadow-2xl z-[110] flex flex-col overflow-hidden"
>
{/* Background Texture */}
<div className="absolute inset-0 opacity-[0.2] pointer-events-none">
<LuxeArt
seed={panelTitle}
className="w-full h-full"
transparent={true}
/>
</div>
{/* Resize Handle */}
<div
onMouseDown={(e) => {
setIsResizing(true);
e.preventDefault();
}}
className="absolute left-0 top-0 bottom-0 w-1.5 cursor-ew-resize hover:bg-[#8D4004]/20 transition-all z-[120]"
/>
{/* Header */}
<div className="relative z-10 flex items-center justify-between p-10 border-b border-black/5 bg-[#FAFAF8]">
<div className="flex flex-col gap-1.5 min-w-0 pr-4">
<span className="font-outfit text-[9px] text-[#8D4004] uppercase tracking-[0.4em] font-bold">
Reference Panel
</span>
<h2 className="text-3xl font-playfairDisplay italic text-[#1A1A1A] leading-tight">
{panelTitle}
</h2>
</div>
<button
onClick={closeSidePanel}
className="p-2 text-[#1A1A1A]/20 hover:text-[#8D4004] transition-colors flex-shrink-0"
>
<XIcon size={24} weight="light" />
</button>
</div>
{/* Content Area */}
<div className="relative z-10 flex-1 overflow-y-auto p-10 custom-scrollbar text-[#1A1A1A]/80 font-outfit leading-relaxed text-base">
<div className="space-y-8">{panelContent}</div>
</div>
{/* Panel Footer */}
<div className="relative z-10 p-6 border-t border-black/5 bg-[#FAFAF8] flex items-center justify-between">
<div className="flex items-center gap-3 text-black/20 font-outfit text-[9px] uppercase tracking-[0.3em]">
<InfoIcon
weight="light"
size={14}
className="text-[#8D4004]/40"
/>
<span>Structural Node // {Math.round(panelWidth)}PX</span>
</div>
<div className="flex gap-2">
<div className="w-1.5 h-1.5 bg-[#8D4004]/40 rounded-full animate-pulse" />
<div className="w-1.5 h-1.5 bg-black/5 rounded-full" />
</div>
</div>
</motion.div>
</>
)}
</AnimatePresence>
);
};
export default LuxeSidePanel;