@@ -14,6 +14,9 @@ import { trans } from "i18n";
14
14
import { EditorContext } from "comps/editorState" ;
15
15
import { AnimationStyle , AnimationStyleType , CustomStyle , CustomStyleType } from "@lowcoder-ee/comps/controls/styleControlConstants" ;
16
16
import { styleControl } from "@lowcoder-ee/comps/controls/styleControl" ;
17
+ import { ThemeContext } from "@lowcoder-ee/comps/utils/themeContext" ;
18
+ import { CompTypeContext } from "@lowcoder-ee/comps/utils/compTypeContext" ;
19
+ import { setInitialCompStyles } from "@lowcoder-ee/comps/utils/themeUtil" ;
17
20
18
21
// TODO: eventually to embedd in container so we have styling?
19
22
// TODO: support different starter templates for different frameworks (react, ANT, Flutter, Angular, etc)
@@ -219,11 +222,29 @@ function InnerCustomComponent(props: IProps) {
219
222
const childrenMap = {
220
223
model : jsonObjectStateControl ( defaultModel ) ,
221
224
code : withDefault ( StringControl , defaultCode ) ,
222
- style : styleControl ( CustomStyle ) ,
223
- animationStyle :styleControl ( AnimationStyle ) ,
225
+ style : styleControl ( CustomStyle , 'style' ) ,
226
+ animationStyle :styleControl ( AnimationStyle , 'animationStyle' ) ,
224
227
} ;
225
228
226
229
const CustomCompBase = new UICompBuilder ( childrenMap , ( props , dispatch ) => {
230
+
231
+
232
+ const theme = useContext ( ThemeContext ) ;
233
+ const compType = useContext ( CompTypeContext ) ;
234
+ const compTheme = theme ?. theme ?. components ?. [ compType ] ;
235
+ const styleProps : Record < string , any > = { } ;
236
+ [ 'style' , 'animationStyle' ] . forEach ( ( key : string ) => {
237
+ styleProps [ key ] = ( props as any ) [ key ] ;
238
+ } ) ;
239
+
240
+ useEffect ( ( ) => {
241
+ setInitialCompStyles ( {
242
+ dispatch,
243
+ compTheme,
244
+ styleProps,
245
+ } ) ;
246
+ } , [ ] ) ;
247
+
227
248
const { code, model } = props ;
228
249
return (
229
250
< InnerCustomComponent
0 commit comments