@@ -21,7 +21,10 @@ import { hasIcon } from "comps/utils";
21
21
import { RefControl } from "comps/controls/refControl" ;
22
22
23
23
import { EditorContext } from "comps/editorState" ;
24
- import React , { useContext } from "react" ;
24
+ import React , { useContext , useEffect } from "react" ;
25
+ import { ThemeContext } from "@lowcoder-ee/comps/utils/themeContext" ;
26
+ import { CompTypeContext } from "@lowcoder-ee/comps/utils/compTypeContext" ;
27
+ import { setInitialCompStyles } from "@lowcoder-ee/comps/utils/themeUtil" ;
25
28
26
29
const Link = styled ( Button ) < {
27
30
$style : LinkStyleType ;
@@ -85,13 +88,30 @@ const LinkTmpComp = (function () {
85
88
onEvent : ButtonEventHandlerControl ,
86
89
disabled : BoolCodeControl ,
87
90
loading : BoolCodeControl ,
88
- style : migrateOldData ( styleControl ( LinkStyle ) , fixOldData ) ,
89
- animationStyle :styleControl ( AnimationStyle ) ,
91
+ style : migrateOldData ( styleControl ( LinkStyle , 'style' ) , fixOldData ) ,
92
+ animationStyle : styleControl ( AnimationStyle , 'animationStyle' ) ,
90
93
prefixIcon : IconControl ,
91
94
suffixIcon : IconControl ,
92
95
viewRef : RefControl < HTMLElement > ,
93
96
} ;
94
- return new UICompBuilder ( childrenMap , ( props ) => {
97
+ return new UICompBuilder ( childrenMap , ( props , dispatch ) => {
98
+ const theme = useContext ( ThemeContext ) ;
99
+ const compType = useContext ( CompTypeContext ) ;
100
+ const compTheme = theme ?. theme ?. components ?. [ compType ] ;
101
+
102
+ const styleProps : Record < string , any > = { } ;
103
+ [ 'style' , 'animationStyle' ] . forEach ( ( key : string ) => {
104
+ styleProps [ key ] = ( props as any ) [ key ] ;
105
+ } ) ;
106
+
107
+ useEffect ( ( ) => {
108
+ setInitialCompStyles ( {
109
+ dispatch,
110
+ compTheme,
111
+ styleProps,
112
+ } ) ;
113
+ } , [ ] ) ;
114
+
95
115
// chrome86 bug: button children should not contain only empty span
96
116
const hasChildren = hasIcon ( props . prefixIcon ) || ! ! props . text || hasIcon ( props . suffixIcon ) ;
97
117
return (
0 commit comments