import React, { useState, useEffect } from 'react'; import { useParams, Link } from 'react-router-dom'; import type { Theme, SlideLayout } from '../../types/theme'; import { getTheme } from '../../themes'; import './LayoutDetailPage.css'; export const LayoutDetailPage: React.FC = () => { const { themeId, layoutId } = useParams<{ themeId: string; layoutId: string }>(); const [theme, setTheme] = useState(null); const [layout, setLayout] = useState(null); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); const [viewMode, setViewMode] = useState<'template' | 'slots'>('slots'); useEffect(() => { const loadThemeAndLayout = async () => { if (!themeId || !layoutId) { setError('Missing theme ID or layout ID'); setLoading(false); return; } try { setLoading(true); const themeData = await getTheme(themeId); if (!themeData) { setError(`Theme "${themeId}" not found`); return; } const layoutData = themeData.layouts.find((l: SlideLayout) => l.id === layoutId); if (!layoutData) { setError(`Layout "${layoutId}" not found in theme "${themeId}"`); return; } setTheme(themeData); setLayout(layoutData); } catch (err) { setError(err instanceof Error ? err.message : 'Failed to load theme and layout'); } finally { setLoading(false); } }; loadThemeAndLayout(); }, [themeId, layoutId]); if (loading) { return (
Loading layout...
); } if (error) { return (

Error

{error}

← Back to Themes
); } if (!theme || !layout) { return (

Layout Not Found

The requested layout could not be found.

← Back to Themes
); } return (

{layout.name}

{layout.description}

{layout.slots.length} slots from {theme.name} View Full Preview →
{viewMode === 'template' && (

HTML Template

{layout.htmlTemplate}
)} {viewMode === 'slots' && (

Slot Configuration

{layout.slots.map((slot) => (

{slot.id}

{slot.type} {slot.required && Required}
{slot.placeholder && (
Placeholder: {slot.placeholder}
)} {slot.defaultContent && (
Default Content: {slot.defaultContent}
)} {slot.className && (
CSS Class: {slot.className}
)} {slot.style && (
Inline Style: {slot.style}
)} {slot.attributes && Object.keys(slot.attributes).length > 0 && (
Attributes:
{Object.entries(slot.attributes).map(([key, value]) => (
{key}="{value}"
))}
)}
))}
)}
); };