@@ -12,7 +12,7 @@ import {
12
12
RightPanelContentWrapper ,
13
13
} from "pages/editor/right/styledComponent" ;
14
14
import { tableDragClassName } from "pages/tutorials/tutorialsConstant" ;
15
- import React , { useEffect , useMemo , useState } from "react" ;
15
+ import React , { Fragment , useEffect , useMemo , useState } from "react" ;
16
16
import styled from "styled-components" ;
17
17
import {
18
18
BaseSection ,
@@ -162,8 +162,8 @@ export const ThemeCompPanel = (props: any) => {
162
162
setSelectedComp ( compType ) ;
163
163
const compKey = genRandomKey ( ) ;
164
164
let { comp, defaultDataFn } = compInfo ;
165
-
166
- const compData = parseCompType ( compType )
165
+ let newComp : any ;
166
+
167
167
if ( compInfo . lazyLoad ) {
168
168
comp = ( await import ( `../../../comps/${ compInfo . compPath ! } ` ) ) [ compInfo . compName ! ] ;
169
169
const {
@@ -175,32 +175,32 @@ export const ThemeCompPanel = (props: any) => {
175
175
const module = await import ( `../../../comps/${ defaultDataFnPath } .tsx` ) ;
176
176
defaultDataFn = module [ defaultDataFnName ] ;
177
177
}
178
- const newComp = new comp ! ( { } ) ;
179
- const compChildrens = newComp . children ;
180
- const styleChildrenKeys = Object . keys ( compChildrens ) . filter ( child => child . toLowerCase ( ) . endsWith ( 'style' ) ) ;
181
- let styleChildrens : Record < string , any > = { } ;
182
- styleChildrenKeys . forEach ( ( childKey : string ) => {
183
- styleChildrens [ childKey ] = compChildrens [ childKey ] ;
184
- } )
185
- setStyleChildrens ( styleChildrens ) ;
178
+ newComp = new comp ! ( { } ) ;
186
179
} else {
187
180
comp = compInfo . comp ;
188
- let newComp = new comp ! ( {
181
+ newComp = new comp ! ( {
189
182
dispatch : ( action ) => {
190
183
if ( newComp ) {
191
184
newComp = newComp . reduce ( action ) ;
192
185
}
193
186
} ,
194
187
} ) as any ;
195
188
await newComp . load ( ) ;
189
+ }
196
190
197
-
191
+ if ( newComp ) {
198
192
const compChildrens = newComp . children ;
199
- const styleChildrenKeys = Object . keys ( compChildrens ) . filter ( child => child . toLowerCase ( ) . endsWith ( 'style' ) || child . toLowerCase ( ) . endsWith ( 'styles ') ) ;
193
+ let styleChildrenKeys = Object . keys ( compChildrens ) . filter ( child => child . toLowerCase ( ) . endsWith ( 'style' ) ) ;
200
194
let styleChildrens : Record < string , any > = { } ;
201
195
styleChildrenKeys . forEach ( ( childKey : string ) => {
202
196
styleChildrens [ childKey ] = compChildrens [ childKey ] ;
203
197
} )
198
+ if ( compChildrens . container ) {
199
+ styleChildrenKeys = Object . keys ( compChildrens . container . children ) . filter ( child => child . toLowerCase ( ) . endsWith ( 'style' ) ) ;
200
+ styleChildrenKeys . forEach ( ( childKey : string ) => {
201
+ styleChildrens [ childKey ] = compChildrens . container . children [ childKey ] ;
202
+ } )
203
+ }
204
204
setStyleChildrens ( styleChildrens ) ;
205
205
}
206
206
@@ -277,7 +277,7 @@ export const ThemeCompPanel = (props: any) => {
277
277
< >
278
278
{ Object . keys ( styleChildrens || { } ) ?. map ( ( styleKey : string ) => {
279
279
return (
280
- < >
280
+ < Fragment key = { styleKey } >
281
281
< h4 >
282
282
{ sectionNames . hasOwnProperty ( styleKey )
283
283
? sectionNames [ styleKey as keyof typeof sectionNames ]
@@ -286,12 +286,12 @@ export const ThemeCompPanel = (props: any) => {
286
286
</ h4 >
287
287
< ThemeSettingsCompStyles
288
288
styleOptions = { Object . keys ( styleChildrens ?. [ styleKey ] . children ) }
289
- defaultStyle = { theme . components ?. [ selectedComp ] || { } }
289
+ defaultStyle = { { ... theme . components ?. [ selectedComp ] ?. [ styleKey ] || { } } }
290
290
configChange = { ( params ) => {
291
- props . onCompStyleChange ( selectedComp , params ) ;
291
+ props . onCompStyleChange ( selectedComp , styleKey , params ) ;
292
292
} }
293
293
/>
294
- </ >
294
+ </ Fragment >
295
295
)
296
296
} ) }
297
297
</ >
@@ -304,7 +304,7 @@ export const ThemeCompPanel = (props: any) => {
304
304
return (
305
305
< PreviewApp
306
306
style = { {
307
- height : "500px " ,
307
+ height : "600px " ,
308
308
minWidth : "auto" ,
309
309
width : "100%" ,
310
310
} }
@@ -341,11 +341,9 @@ export const ThemeCompPanel = (props: any) => {
341
341
{ compList }
342
342
</ PropertySectionContext . Provider >
343
343
</ RightPanelContentWrapper >
344
- { /* <Divider type="vertical" style={{height: "510px"}}/> */ }
345
344
< div style = { { flex : "1" } } >
346
345
{ appPreview }
347
346
</ div >
348
- { /* <Divider type="vertical" style={{height: "510px"}}/> */ }
349
347
< div style = { {
350
348
width : "280px" ,
351
349
padding : "12px" ,
0 commit comments