Spaces:
Running
Running
File size: 5,362 Bytes
1d68c54 | 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 | # UI Migration Guide: index.html β Next.js
## β
COMPLETED
### 1. **CSS Design Tokens**
- β
Created design token mapping in `globals.css`
- All color variables, fonts, and spacing preserved
- Ready for selective integration
### 2. **JSX Conversion**
- β
Created `/ui/app/page-landing.tsx`
- Converted HTML β React JSX components
- `class` β `className`
- Canvas refs with `useEffect` lifecycle
- All sections: hero, overview, simulation, architecture, metrics
### 3. **Canvas Initialization**
- β
Added `useRef` hooks for canvas elements
- β
Wrapped canvas logic in `useEffect`
- β
TODO placeholders for actual drawing logic
---
## π INTEGRATION STEPS
### Step 1: Apply index.html CSS to globals.css
Your `globals.css` has old styles. Update it with index.html theme:
```bash
# Option A: Keep existing structure, add index.html CSS as override
# Option B: Replace entire globals.css with index.html styles (RECOMMENDED)
```
The `page-landing.tsx` expects these CSS classes:
- Layout: `nav`, `section`, `footer`
- Components: `card`, `btn-primary`, `btn-secondary`, `metric-block`
- Utilities: `anim-1`, `divider`, `hero-stats`
### Step 2: Choose Integration Strategy
**Option A: Use Landing Page Separately** β
(SIMPLEST)
```
/app/page.tsx β Your existing interactive app
/app/landing.tsx β New static landing (page-landing.tsx)
/app/layout.tsx β Wrap both
```
**Option B: Replace page.tsx Completely** (if landing is the main page)
```
/app/page.tsx β Replace with page-landing.tsx
/app/mission/page.tsx β Move existing components to subfolder
```
**Option C: Hybrid** (recommended)
```
/app/page.tsx β Dynamic switcher (landing vs mission)
/app/landing.tsx β page-landing.tsx
/app/components/* β Existing components
```
---
## π¨ CSS INTEGRATION
### Required Classes from index.html:
```css
/* Navigation */
nav, .nav-logo, .nav-links, .nav-badge
/* Hero Section */
#hero, .hero-content, .hero-tag, .hero-ctas
.btn-primary, .btn-secondary
/* Cards */
.cards-grid, .card, .card-id, .card-title, .card-footer
/* Simulation */
.sim-wrapper, .sim-topbar, .sim-body, .sim-panel
.agent-row, .trust-bar-bg, .trust-bar-fill
.metric-block, .metric-value
/* Architecture */
.arch-node, .arch-flow
/* Metrics */
.metric-block, .metric-grid
/* Footer */
footer, .footer-left, .footer-right
/* Animations */
@keyframes pulse-dot, fadeInUp
.anim-1, .anim-2, .anim-3, .anim-4, .anim-5
```
---
## πΌοΈ CANVAS MIGRATION
The new `page-landing.tsx` has placeholders:
```typescript
function initHeroCanvas(canvas: HTMLCanvasElement) {
// TODO: Copy canvas.js logic from index.html
// The neural network grid visualization
}
function initSimCanvas(canvas: HTMLCanvasElement) {
// TODO: Copy canvas.js logic from index.html
// The orchestrator network visualization
}
```
**To migrate canvas logic:**
1. Find the inline `<script>` block in `index.html` (lines ~1710+)
2. Extract the two IIFE functions:
- Hero canvas: Neural network grid
- Sim canvas: Orchestrator network
3. Paste into `initHeroCanvas()` and `initSimCanvas()`
4. Update canvas size handling for React
---
## β¨ FEATURES NOT YET IMPLEMENTED
These are hooks for future work - marked with `TODO`:
- [ ] Canvas drawing logic (detailed in "Canvas Migration" above)
- [ ] Button click handlers (Launch Mission, Read Docs)
- [ ] Live metrics updates (currently static)
- [ ] Specialist status animation
- [ ] Episode log scrolling (right panel)
---
## π FILE STRUCTURE AFTER MIGRATION
```
/ui
βββ app/
β βββ layout.tsx (unchanged)
β βββ page.tsx (existing - interactive mode)
β βββ page-landing.tsx (NEW - landing page)
β βββ globals.css (UPDATED with index.html styles)
β βββ components/
β β βββ Landing.tsx
β β βββ MissionControl.tsx
β β βββ ...
β βββ hooks/
β βββ useSentinel.ts
βββ index.html (ARCHIVE - no longer needed after migration)
βββ .env (unchanged)
βββ package.json (unchanged)
```
---
## π QUICK START
1. **Update globals.css** with index.html styles (or use the CSS I provided)
2. **Keep page-landing.tsx** as new file (or rename to page.tsx if replacing)
3. **Migrate canvas logic** from index.html `<script>` section
4. **Test**: Visit `http://localhost:3000/` or `/landing` depending on routing
---
## β
DONE vs π§ TODO
| Part | Status | Notes |
|------|--------|-------|
| HTML β JSX | β
| page-landing.tsx ready |
| CSS Variables | β
| Design tokens extracted |
| Layout/Structure | β
| All sections preserved |
| Canvas Setup | β
| useRef + useEffect ready |
| Canvas Drawing | π§ | TODO - copy from index.html |
| Button Handlers | π§ | TODO - implement event handlers |
| Live Updates | π§ | TODO - connect to API/state |
| Animations | β
| @keyframes preserved in CSS |
---
## NEXT: What You Need to Do
1. **Decision**: Keep separate landing page or replace main page?
2. **CSS**: Merge index.html styles into `globals.css`
3. **Canvas**: Copy drawing logic from `index.html` `<script>` into the TODO functions
4. **Test**: Run `npm run dev` and verify visual parity
Need help with any step? π
|