Skip to content

Commit 9ee311e

Browse files
Macraheeliftikhar5
Mac
authored andcommitted
column layout component
1 parent 9cc5c45 commit 9ee311e

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

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

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,14 @@ import { messageInstance } from "lowcoder-design/src/components/GlobalInstances"
3535
import { BoolControl } from "comps/controls/boolControl";
3636
import { BoolCodeControl, NumberControl, StringControl } from "comps/controls/codeControl";
3737

38-
import { useContext } from "react";
38+
import { useContext, useEffect } from "react";
3939
import { EditorContext } from "comps/editorState";
4040

4141
import { disabledPropertyView, hiddenPropertyView } from "comps/utils/propertyUtils";
4242
import { DisabledContext } from "comps/generators/uiCompBuilder";
43+
import { ThemeContext } from "@lowcoder-ee/comps/utils/themeContext";
44+
import { CompTypeContext } from "@lowcoder-ee/comps/utils/compTypeContext";
45+
import { setInitialCompStyles } from "@lowcoder-ee/comps/utils/themeUtil";
4346

4447
const ContainWrapper = styled.div<{
4548
$style: ContainerStyleType & {
@@ -95,8 +98,8 @@ const childrenMap = {
9598
rowGap: withDefault(StringControl, "20px"),
9699
templateColumns: withDefault(StringControl, "1fr 1fr"),
97100
columnGap: withDefault(StringControl, "20px"),
98-
style: withDefault(styleControl(ContainerStyle), {}),
99-
columnStyle: withDefault(styleControl(ResponsiveLayoutColStyle),{borderWidth:'1px'})
101+
style: styleControl(ContainerStyle, 'style'),
102+
columnStyle: styleControl(ResponsiveLayoutColStyle , 'columnStyle')
100103
};
101104

102105
type ViewProps = RecordConstructorToView<typeof childrenMap>;
@@ -178,6 +181,23 @@ const ColumnLayout = (props: ColumnLayoutProps) => {
178181

179182
export const ResponsiveLayoutBaseComp = (function () {
180183
return new UICompBuilder(childrenMap, (props, dispatch) => {
184+
185+
const theme = useContext(ThemeContext);
186+
const compType = useContext(CompTypeContext);
187+
const compTheme = theme?.theme?.components?.[compType];
188+
const styleProps: Record<string, any> = {};
189+
['style', 'columnStyle'].forEach((key: string) => {
190+
styleProps[key] = (props as any)[key];
191+
});
192+
193+
useEffect(() => {
194+
setInitialCompStyles({
195+
dispatch,
196+
compTheme,
197+
styleProps,
198+
});
199+
}, []);
200+
181201
return (
182202
<ColumnLayout {...props} dispatch={dispatch} />
183203
);

0 commit comments

Comments
 (0)