Skip to content

Commit 7ae946d

Browse files
Macraheeliftikhar5
Mac
authored andcommitted
Integration & Extension component
1 parent 3129b13 commit 7ae946d

File tree

2 files changed

+48
-6
lines changed

2 files changed

+48
-6
lines changed

client/packages/lowcoder/src/comps/comps/customComp/customComp.tsx

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ import { trans } from "i18n";
1414
import { EditorContext } from "comps/editorState";
1515
import { AnimationStyle, AnimationStyleType, CustomStyle, CustomStyleType } from "@lowcoder-ee/comps/controls/styleControlConstants";
1616
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";
1720

1821
// TODO: eventually to embedd in container so we have styling?
1922
// TODO: support different starter templates for different frameworks (react, ANT, Flutter, Angular, etc)
@@ -219,11 +222,29 @@ function InnerCustomComponent(props: IProps) {
219222
const childrenMap = {
220223
model: jsonObjectStateControl(defaultModel),
221224
code: withDefault(StringControl, defaultCode),
222-
style: styleControl(CustomStyle),
223-
animationStyle:styleControl(AnimationStyle),
225+
style: styleControl(CustomStyle , 'style'),
226+
animationStyle:styleControl(AnimationStyle , 'animationStyle'),
224227
};
225228

226229
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+
227248
const { code, model } = props;
228249
return (
229250
<InnerCustomComponent

client/packages/lowcoder/src/comps/comps/iframeComp.tsx

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ import { hiddenPropertyView } from "comps/utils/propertyUtils";
1010
import { trans } from "i18n";
1111
import log from "loglevel";
1212

13-
import { useContext } from "react";
13+
import { useContext, useEffect } from "react";
1414
import { EditorContext } from "comps/editorState";
15+
import { CompTypeContext } from "../utils/compTypeContext";
16+
import { ThemeContext } from "@lowcoder-ee/index.sdk";
17+
import { setInitialCompStyles } from "../utils/themeUtil";
1518

1619
const Wrapper = styled.div<{$style: IframeStyleType; $animationStyle:AnimationStyleType}>`
1720
width: 100%;
@@ -45,10 +48,28 @@ let IFrameCompBase = new UICompBuilder(
4548
allowMicrophone: BoolControl,
4649
allowCamera: BoolControl,
4750
allowPopup: BoolControl,
48-
style: styleControl(IframeStyle),
49-
animationStyle: styleControl(AnimationStyle),
51+
style: styleControl(IframeStyle , 'style'),
52+
animationStyle: styleControl(AnimationStyle , 'animationStyle'),
5053
},
51-
(props) => {
54+
(props , dispatch) => {
55+
56+
const theme = useContext(ThemeContext);
57+
const compType = useContext(CompTypeContext);
58+
const compTheme = theme?.theme?.components?.[compType];
59+
const styleProps: Record<string, any> = {};
60+
['style','animationStyle'].forEach((key: string) => {
61+
styleProps[key] = (props as any)[key];
62+
});
63+
64+
useEffect(() => {
65+
setInitialCompStyles({
66+
dispatch,
67+
compTheme,
68+
styleProps,
69+
});
70+
}, []);
71+
72+
5273
const sandbox = ["allow-scripts", "allow-same-origin"];
5374
props.allowSubmitForm && sandbox.push("allow-forms");
5475
props.allowDownload && sandbox.push("allow-downloads");

0 commit comments

Comments
 (0)