-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPIMLLabPage.jsx
More file actions
299 lines (279 loc) · 10.7 KB
/
PIMLLabPage.jsx
File metadata and controls
299 lines (279 loc) · 10.7 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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
import React, { useState, useEffect } from 'react';
import { Link } from 'react-router-dom';
import { motion, AnimatePresence } from 'framer-motion';
import piml from 'piml';
import {
ArrowLeftIcon,
CodeIcon,
EyeIcon,
CopySimpleIcon,
XCircleIcon,
PlayIcon,
FileTextIcon,
CubeIcon,
ArticleIcon,
KanbanIcon,
} from '@phosphor-icons/react';
import { useToast } from '../../hooks/useToast';
import Seo from '../../components/Seo';
import GenerativeArt from '../../components/GenerativeArt';
import ProjectCard from '../../components/ProjectCard';
import LogCard from '../../components/LogCard';
import PostTile from '../../components/PostTile';
import RoadmapCard from '../../components/roadmap/RoadmapCard';
const TEMPLATES = {
project: `(project)
(id) fez-99
(slug) my-cool-project
(title) Quantum Neural Interface
(description) A next-generation interface for neural data processing.
(status) Active
(technologies) React, WebGL, Rust`,
log: `(log)
(id) log-42
(slug) the-great-read
(title) The Design of Everyday Things
(category) Book
(by) Don Norman
(date) 2025-12-21
(rating) 5
(platform) Physical`,
post: `(post)
(slug) live-from-piml-lab
(title) Live Data Stream Protocol
(date) 2025-12-21
(description) Testing the new PIML rendering engine in real-time.
(category) dev
(tags) PIML, React, Experimental`,
roadmap: `(issue)
(id) FEZ-999
(title) Full System Integration
(description) Completing the neural bridge between PIML and React.
(status) Planned
(priority) High
(created_at) 2025-12-21T18:00:00Z`,
};
const PIMLLabPage = () => {
const appName = 'PIML Lab';
const { addToast } = useToast();
const [input, setInput] = useState(TEMPLATES.project);
const [parsedData, setParsedData] = useState(null);
const [error, setError] = useState(null);
useEffect(() => {
try {
const result = piml.parse(input);
setParsedData(result);
setError(null);
} catch (e) {
setError(e.message);
}
}, [input]);
const loadTemplate = (type) => {
setInput(TEMPLATES[type]);
addToast({
title: 'Template Loaded',
message: `Applied ${type.toUpperCase()} schema.`,
});
};
const copyToClipboard = () => {
navigator.clipboard.writeText(input).then(() => {
addToast({
title: 'Copied',
message: 'PIML sequence stored in memory bank.',
});
});
};
const renderPreview = () => {
if (!parsedData) return null;
// Handle different PIML structures based on templates
if (parsedData.project) {
return (
<div className="max-w-2xl mx-auto py-12">
<ProjectCard project={parsedData.project} index={0} isActive={true} />
</div>
);
}
if (parsedData.log) {
return (
<div className="max-w-sm mx-auto py-12">
<LogCard log={parsedData.log} index={0} totalLogs={1} />
</div>
);
}
if (parsedData.post) {
return (
<div className="max-w-md mx-auto py-12">
<PostTile post={parsedData.post} />
</div>
);
}
if (parsedData.issue) {
return (
<div className="max-w-md mx-auto py-12">
<RoadmapCard app={parsedData.issue} />
</div>
);
}
return (
<div className="p-8 border border-white/5 bg-white/[0.01] rounded-sm h-full flex flex-col">
<span className="text-[10px] font-mono text-gray-600 uppercase mb-4 tracking-widest">
Raw_JSON_Output
</span>
<pre className="text-emerald-500 font-mono text-xs overflow-auto h-full scrollbar-hide">
{JSON.stringify(parsedData, null, 2)}
</pre>
</div>
);
};
return (
<div className="min-h-screen bg-[#050505] text-white selection:bg-emerald-500/30 font-sans flex flex-col">
<Seo
title="PIML Lab | Fezcodex"
description="Real-time PIML playground. Write custom markup and see it rendered as Fezcodex components."
keywords={[
'PIML',
'playground',
'editor',
'markup',
'react',
'fezcodex',
]}
/>
<div className="mx-auto max-w-7xl w-full px-6 py-12 md:px-12 flex-grow flex flex-col">
<header className="mb-12">
<Link
to="/apps"
className="group mb-8 inline-flex items-center gap-2 text-xs font-mono text-gray-500 hover:text-white transition-colors uppercase tracking-[0.3em]"
>
<ArrowLeftIcon
weight="bold"
className="transition-transform group-hover:-translate-x-1"
/>
<span>Applications</span>
</Link>
<div className="flex flex-col md:flex-row md:items-end justify-between gap-8">
<div>
<h1 className="text-5xl md:text-7xl font-black tracking-tighter text-white leading-none uppercase flex items-center gap-4 flex-wrap">
{appName}{' '}
<span className="text-[10px] border border-emerald-500/50 text-emerald-500 px-2 py-1 rounded-sm shrink-0 whitespace-nowrap tracking-normal">
Experimental
</span>
</h1>
<p className="text-gray-400 font-mono text-xs uppercase tracking-widest mt-4">
Real-time technical markup visualization protocol.
</p>
</div>
<div className="flex gap-2">
<button
onClick={() => loadTemplate('project')}
className="flex items-center gap-2 px-3 py-2 border border-white/10 hover:bg-white hover:text-black text-[10px] font-bold uppercase transition-all"
>
<CubeIcon /> Project
</button>
<button
onClick={() => loadTemplate('log')}
className="flex items-center gap-2 px-3 py-2 border border-white/10 hover:bg-white hover:text-black text-[10px] font-bold uppercase transition-all"
>
<FileTextIcon /> Log
</button>
<button
onClick={() => loadTemplate('post')}
className="flex items-center gap-2 px-3 py-2 border border-white/10 hover:bg-white hover:text-black text-[10px] font-bold uppercase transition-all"
>
<ArticleIcon /> Post
</button>
<button
onClick={() => loadTemplate('roadmap')}
className="flex items-center gap-2 px-3 py-2 border border-white/10 hover:bg-white hover:text-black text-[10px] font-bold uppercase transition-all"
>
<KanbanIcon /> Issue
</button>
</div>
</div>
</header>
<div className="grid grid-cols-1 lg:grid-cols-2 gap-px bg-white/10 border border-white/10 flex-grow">
{/* Editor Panel */}
<div className="bg-[#050505] p-6 flex flex-col h-full min-h-[500px]">
<div className="flex justify-between items-center mb-4">
<h3 className="font-mono text-[10px] font-bold text-gray-500 uppercase tracking-widest flex items-center gap-2">
<CodeIcon weight="fill" className="text-emerald-500" />
Input_PIML_Sequence
</h3>
<button
onClick={copyToClipboard}
className="text-gray-600 hover:text-white transition-colors"
>
<CopySimpleIcon size={18} />
</button>
</div>
<textarea
value={input}
onChange={(e) => setInput(e.target.value)}
className="flex-grow w-full bg-black/40 border border-white/5 p-6 font-mono text-sm text-gray-300 focus:border-emerald-500/50 focus:outline-none transition-all resize-none scrollbar-hide"
spellCheck="false"
/>
</div>
{/* Preview Panel */}
<div className="bg-[#050505] p-6 flex flex-col h-full relative group">
<div className="absolute inset-0 opacity-[0.02] pointer-events-none grayscale group-hover:opacity-[0.04] transition-opacity">
<GenerativeArt seed="PIML_LAB_VISUAL" className="w-full h-full" />
</div>
<div className="flex justify-between items-center mb-4 relative z-10">
<h3 className="font-mono text-[10px] font-bold text-gray-500 uppercase tracking-widest flex items-center gap-2">
<EyeIcon weight="fill" className="text-emerald-500" />
Live_Render_Buffer
</h3>
<div className="flex items-center gap-2">
<div
className={`w-1.5 h-1.5 rounded-full ${error ? 'bg-red-500' : 'bg-emerald-500'} animate-pulse`}
/>
<span className="text-[9px] font-mono text-gray-600 uppercase">
{error ? 'Sync_Error' : 'Realtime_Sync_Active'}
</span>
</div>
</div>
<div className="flex-grow relative z-10 border border-dashed border-white/5 p-4 overflow-y-auto scrollbar-hide">
<AnimatePresence mode="wait">
{error ? (
<motion.div
initial={{ opacity: 0, y: 10 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0 }}
className="p-6 border border-red-500/20 bg-red-500/5 rounded-sm"
>
<div className="flex items-center gap-3 text-red-500 mb-2">
<XCircleIcon size={20} weight="bold" />
<span className="text-xs font-black uppercase tracking-widest">
Parsing_Failure
</span>
</div>
<p className="text-[10px] font-mono text-red-400/80 leading-relaxed break-words uppercase">
{error}
</p>
</motion.div>
) : (
<motion.div
key={JSON.stringify(parsedData)}
initial={{ opacity: 0, scale: 0.98 }}
animate={{ opacity: 1, scale: 1 }}
className="h-full"
>
{renderPreview()}
</motion.div>
)}
</AnimatePresence>
</div>
</div>
</div>
<footer className="mt-12 pt-6 border-t border-white/10 flex justify-between items-center text-gray-600 font-mono text-[9px] uppercase tracking-[0.3em]">
<div className="flex items-center gap-4">
<PlayIcon weight="fill" className="text-emerald-500" />
<span>PIML_Visualization_Engine_Enabled</span>
</div>
<span>Buffer_Status: Stable</span>
</footer>
</div>
</div>
);
};
export default PIMLLabPage;