Spaces:
Paused
Paused
File size: 6,487 Bytes
6f8b03d | 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 | /**
* 🚀 QUICK START INTEGRATION EXAMPLE
* Sådan integrerer du Neural Ascension + Data & Indsigter widgets
*/
import React, { useState } from 'react';
import { Rocket, Database, Menu, X } from 'lucide-react';
// Import Neural Ascension Widgets
import {
MasterControl,
SEGA,
THG,
SCE,
NSQI,
PTAM,
CDMM,
APD,
MSH,
QEK,
CCA,
NeuralAscensionWidgets
} from './widgets/NeuralAscension';
// Import Data & Indsigter
import DataInsightsHub from './widgets/DataInsightsHub';
// Widget Registry - Kombiner alle widgets
export const COMPLETE_WIDGET_REGISTRY = [
...NeuralAscensionWidgets,
{
id: 'DataInsightsHub',
name: 'Data & Indsigter Central',
category: 'data',
path: './widgets/DataInsightsHub',
icon: 'Database',
defaultSize: { w: 12, h: 6 },
description: 'Omfattende adgang til alle data, arkiver og biblioteker'
}
];
// Menu Struktur
export const MENU_CATEGORIES = [
{
id: 'neural-ascension',
name: 'Neural Ascension',
icon: Rocket,
description: '10 Transformation Points - Cosmic Cognitive Singularity',
widgets: NeuralAscensionWidgets
},
{
id: 'data-insights',
name: 'Data & Indsigter',
icon: Database,
description: 'Omfattende data management og AI-powered insights',
widgets: [COMPLETE_WIDGET_REGISTRY.find(w => w.id === 'DataInsightsHub')]
}
];
// Widget Component Map
export const WIDGET_COMPONENTS = {
// Neural Ascension
MasterControl,
SEGA,
THG,
SCE,
NSQI,
PTAM,
CDMM,
APD,
MSH,
QEK,
CCA,
// Data & Indsigter
DataInsightsHub
};
// Example Implementation: Widget Selector Modal
export function WidgetSelectorModal({ isOpen, onClose, onSelectWidget }) {
const [selectedCategory, setSelectedCategory] = useState('neural-ascension');
if (!isOpen) return null;
const currentCategory = MENU_CATEGORIES.find(c => c.id === selectedCategory);
return (
<div className="fixed inset-0 bg-black/80 flex items-center justify-center z-50">
<div className="bg-gray-900 rounded-lg w-[90vw] max-w-6xl h-[80vh] flex flex-col">
{/* Header */}
<div className="p-6 border-b border-gray-700 flex items-center justify-between">
<h2 className="text-2xl font-bold text-white">Select Widget</h2>
<button onClick={onClose} className="text-gray-400 hover:text-white">
<X />
</button>
</div>
<div className="flex flex-1 overflow-hidden">
{/* Sidebar - Categories */}
<div className="w-64 bg-gray-800/50 p-4 overflow-y-auto">
<h3 className="text-sm font-semibold text-gray-400 mb-3">CATEGORIES</h3>
{MENU_CATEGORIES.map(category => (
<button
key={category.id}
onClick={() => setSelectedCategory(category.id)}
className={`w-full text-left p-3 rounded-lg mb-2 transition-all ${
selectedCategory === category.id
? 'bg-blue-600 text-white'
: 'bg-gray-700/50 text-gray-300 hover:bg-gray-700'
}`}
>
<div className="flex items-center gap-2 mb-1">
<category.icon className="w-4 h-4" />
<span className="font-semibold">{category.name}</span>
</div>
<p className="text-xs text-gray-400">{category.description}</p>
</button>
))}
</div>
{/* Main Area - Widgets */}
<div className="flex-1 p-6 overflow-y-auto">
<h3 className="text-xl font-bold text-white mb-4">{currentCategory?.name}</h3>
<div className="grid grid-cols-3 gap-4">
{currentCategory?.widgets.map(widget => (
<button
key={widget.id}
onClick={() => {
onSelectWidget(widget);
onClose();
}}
className="bg-gray-800 hover:bg-gray-700 p-4 rounded-lg border border-gray-700 hover:border-blue-500 transition-all text-left"
>
<h4 className="font-semibold text-white mb-2">{widget.name}</h4>
<p className="text-sm text-gray-400">{widget.description}</p>
<div className="mt-3 text-xs text-blue-400">
{widget.defaultSize.w}x{widget.defaultSize.h} grid
</div>
</button>
))}
</div>
</div>
</div>
</div>
</div>
);
}
// Example Implementation: Widget Renderer
export function WidgetRenderer({ widgetId, ...props }) {
const WidgetComponent = WIDGET_COMPONENTS[widgetId];
if (!WidgetComponent) {
return (
<div className="h-full bg-red-900/20 border border-red-500 rounded-lg p-4 flex items-center justify-center">
<p className="text-red-400">Widget '{widgetId}' not found</p>
</div>
);
}
return <WidgetComponent {...props} />;
}
// Example Usage in App
export function ExampleApp() {
const [isModalOpen, setIsModalOpen] = useState(false);
const [activeWidgets, setActiveWidgets] = useState([]);
const handleSelectWidget = (widget) => {
setActiveWidgets(prev => [...prev, {
id: widget.id + '-' + Date.now(),
widgetType: widget.id,
...widget.defaultSize
}]);
};
return (
<div className="h-screen bg-black text-white">
{/* Top Bar */}
<div className="h-16 bg-gray-900 border-b border-gray-800 flex items-center px-6 justify-between">
<h1 className="text-xl font-bold">WidgeTDC Neural Platform</h1>
<button
onClick={() => setIsModalOpen(true)}
className="bg-blue-600 hover:bg-blue-700 px-4 py-2 rounded-lg flex items-center gap-2"
>
<Menu className="w-4 h-4" />
Add Widget
</button>
</div>
{/* Widget Grid */}
<div className="p-6 grid grid-cols-12 gap-4">
{activeWidgets.map(widget => (
<div
key={widget.id}
className={`col-span-${widget.w} row-span-${widget.h} h-96`}
>
<WidgetRenderer widgetId={widget.widgetType} />
</div>
))}
</div>
{/* Widget Selector Modal */}
<WidgetSelectorModal
isOpen={isModalOpen}
onClose={() => setIsModalOpen(false)}
onSelectWidget={handleSelectWidget}
/>
</div>
);
}
export default ExampleApp;
|