diff --git a/app/[workspace]/project/[projectId]/design/page.tsx b/app/[workspace]/project/[projectId]/design/page.tsx index 9bf5dc5..3441aee 100644 --- a/app/[workspace]/project/[projectId]/design/page.tsx +++ b/app/[workspace]/project/[projectId]/design/page.tsx @@ -555,10 +555,24 @@ function SurfaceSection({ } const patchConfig = (patch: Partial) => setDesignConfig(prev => ({ ...prev, ...patch })); - const hasConfigurator = !!previewId && !!LIBRARY_STYLE_OPTIONS[previewId]; - + const opts = previewId ? LIBRARY_STYLE_OPTIONS[previewId] : null; + const hasConfigurator = !!previewId && !!opts; const isLocked = !!lockedThemeId; + // Ensure parent always knows the currently-displayed theme (even before user clicks) + // so Lock In works immediately without requiring an explicit library click first. + useEffect(() => { + if (!selectedThemeId && previewId) onSelect(previewId); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [previewId]); + + const toggleComponent = (id: string) => { + const next = designConfig.components.includes(id) + ? designConfig.components.filter(c => c !== id) + : [...designConfig.components, id]; + patchConfig({ components: next }); + }; + return (
@@ -605,7 +619,6 @@ function SurfaceSection({ }
- {/* end center scaffold wrapper */} {/* Right β€” controls panel */} @@ -616,7 +629,7 @@ function SurfaceSection({ }}>
- {/* Lock / unlock β€” top of panel */} + {/* 1. Lock / unlock */}
{isLocked ? ( )} @@ -654,37 +667,7 @@ function SurfaceSection({ )}
- {/* Palette (colour) β€” top of mind, shown right after Lock */} - {availableColorThemes.length > 0 && ( -
- Colour -
- {availableColorThemes.map(ct => ( -
- {activeColorTheme && ( - {activeColorTheme.label} - )} -
- )} - - {/* Library β€” simple name buttons */} + {/* 2. Library */}
Library
@@ -717,13 +700,112 @@ function SurfaceSection({
- {/* Design configurator β€” mode, background, nav, header, sections, font */} - {hasConfigurator && !isLocked && ( - + {hasConfigurator && !isLocked && opts && (<> + + {/* 3. Mode */} + + patchConfig({ mode: v })} /> + + + {/* 4. Colour */} + {availableColorThemes.length > 0 && ( +
+ Colour +
+ {availableColorThemes.map(ct => ( +
+ {activeColorTheme && ( + {activeColorTheme.label} + )} +
+ )} + + {/* 5. Font */} + + {opts.fonts.map(f => ( + patchConfig({ font: f.id })} + /> + ))} + + + {/* 6. Background */} + + {opts.backgrounds.map(bg => ( + patchConfig({ background: bg.id })} + /> + ))} + + + {/* 7. Nav */} + + {opts.navStyles.map(n => ( + patchConfig({ nav: n.id })} + /> + ))} + + + {/* 8. Hero */} + + {opts.headerStyles.map(h => ( + patchConfig({ header: h.id })} + /> + ))} + + + {/* 9. Sections */} + + {opts.components.map(c => ( + toggleComponent(c.id)} + /> + ))} + + + )} + + {/* Colour swatches when locked (read-only) */} + {isLocked && availableColorThemes.length > 0 && ( +
+ Colour +
+ {availableColorThemes.map(ct => ( +
+
)}
{/* end inner padding div */} @@ -931,7 +1013,8 @@ export default function DesignPage({ params }: { params: Promise<{ workspace: st }; const handleLock = async (surfaceId: string) => { - const themeId = selectedThemes[surfaceId]; + const surface = ALL_SURFACES.find(s => s.id === surfaceId); + const themeId = selectedThemes[surfaceId] ?? surface?.themes[0]?.id; if (!themeId) return; setSavingLock(surfaceId); try {