@@ -19,6 +19,7 @@ import {
1919 InteractiveSelector ,
2020 interactiveDisplayNames ,
2121} from "./interactive-selector" ;
22+ import StructureSelector from "./structure-selector" ;
2223
2324interface ThemeEditorProps {
2425 draftTheme : Theme ;
@@ -111,6 +112,11 @@ const typographyCategories: TypographyCategory[] = [
111112 } ,
112113] ;
113114
115+ const structureDisplayNames : Record < string , string > = {
116+ page : "Page" ,
117+ section : "Section" ,
118+ } as const ;
119+
114120function ThemeEditor ( { draftTheme, onClose, onSave } : ThemeEditorProps ) {
115121 const [ theme , setTheme ] = useState < Theme > ( draftTheme ) ;
116122 const [ navigationStack , setNavigationStack ] = useState < NavigationItem [ ] > (
@@ -256,19 +262,39 @@ function ThemeEditor({ draftTheme, onClose, onSave }: ThemeEditorProps) {
256262 type = {
257263 currentItem . id as "button" | "link" | "card" | "input"
258264 }
259- value = { theme . interactives [ currentItem . id ] }
260- onChange = { async ( value ) => {
261- const updatedInteractives = {
262- ...theme . interactives ,
263- [ currentItem . id ] : value ,
264- } ;
265- setTheme ( {
266- ...theme ,
267- interactives : updatedInteractives ,
268- } ) ;
265+ theme = { theme }
266+ onChange = { async ( updatedTheme ) => {
267+ setTheme ( updatedTheme ) ;
269268 await updateThemeCategory (
270269 "interactives" ,
271- updatedInteractives as unknown as Record <
270+ updatedTheme . interactives as unknown as Record <
271+ string ,
272+ string
273+ > ,
274+ ) ;
275+ } }
276+ />
277+ ) ;
278+ }
279+
280+ // Check if current item is a structure item
281+ if (
282+ parentItem ?. id === "structure" &&
283+ currentItem . id in theme . structure
284+ ) {
285+ return (
286+ < StructureSelector
287+ title = {
288+ structureDisplayNames [ currentItem . id ] ||
289+ capitalize ( currentItem . id )
290+ }
291+ type = { currentItem . id as "page" | "section" }
292+ theme = { theme }
293+ onChange = { async ( updatedTheme ) => {
294+ setTheme ( updatedTheme ) ;
295+ await updateThemeCategory (
296+ "structure" ,
297+ updatedTheme . structure as unknown as Record <
272298 string ,
273299 string
274300 > ,
@@ -409,6 +435,31 @@ function ThemeEditor({ draftTheme, onClose, onSave }: ThemeEditorProps) {
409435 ) }
410436 </ div >
411437 ) ;
438+ case "structure" :
439+ return (
440+ < div className = "space-y-1 p-2" >
441+ { Object . keys ( structureDisplayNames ) . map ( ( structure ) => (
442+ < button
443+ key = { structure }
444+ onClick = { ( ) =>
445+ navigateTo ( {
446+ id : structure ,
447+ label :
448+ structureDisplayNames [ structure ] ||
449+ capitalize ( structure ) ,
450+ } )
451+ }
452+ className = "w-full flex items-center justify-between px-3 py-2 text-xs rounded-md hover:bg-muted transition-colors group"
453+ >
454+ < span className = "group-hover:text-foreground transition-colors" >
455+ { structureDisplayNames [ structure ] ||
456+ capitalize ( structure ) }
457+ </ span >
458+ < ExpandMoreRight className = "h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors" />
459+ </ button >
460+ ) ) }
461+ </ div >
462+ ) ;
412463 default :
413464 return (
414465 < p className = "text-xs text-muted-foreground p-2" >
0 commit comments