Skip to content

Commit 727630a

Browse files
Macraheeliftikhar5
Mac
authored andcommitted
responsiveLayout component
1 parent 736ad03 commit 727630a

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

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

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { NameGenerator } from "comps/utils";
2121
import { Section, controlItem, sectionNames } from "lowcoder-design";
2222
import { HintPlaceHolder } from "lowcoder-design";
2323
import _ from "lodash";
24-
import React from "react";
24+
import React, { useEffect } from "react";
2525
import styled from "styled-components";
2626
import { IContainer } from "../containerBase/iContainer";
2727
import { SimpleContainerComp } from "../containerBase/simpleContainerComp";
@@ -42,6 +42,9 @@ import { EditorContext } from "comps/editorState";
4242

4343
import { disabledPropertyView, hiddenPropertyView } from "comps/utils/propertyUtils";
4444
import { DisabledContext } from "comps/generators/uiCompBuilder";
45+
import { ThemeContext } from "@lowcoder-ee/comps/utils/themeContext";
46+
import { CompTypeContext } from "@lowcoder-ee/comps/utils/compTypeContext";
47+
import { setInitialCompStyles } from "@lowcoder-ee/comps/utils/themeUtil";
4548

4649
const RowWrapper = styled(Row)<{
4750
$style: ResponsiveLayoutRowStyleType;
@@ -91,9 +94,9 @@ const childrenMap = {
9194
autoHeight: AutoHeightControl,
9295
rowBreak: withDefault(BoolControl, false),
9396
matchColumnsHeight: withDefault(BoolControl, true),
94-
style: withDefault(styleControl(ResponsiveLayoutRowStyle), {}),
95-
columnStyle: withDefault(styleControl(ResponsiveLayoutColStyle), {}),
96-
animationStyle:styleControl(AnimationStyle),
97+
style: styleControl(ResponsiveLayoutRowStyle , 'style'),
98+
columnStyle: styleControl(ResponsiveLayoutColStyle , 'columnStyle'),
99+
animationStyle:styleControl(AnimationStyle , 'animationStyle'),
97100
columnPerRowLG: withDefault(NumberControl, 4),
98101
columnPerRowMD: withDefault(NumberControl, 2),
99102
columnPerRowSM: withDefault(NumberControl, 1),
@@ -185,6 +188,24 @@ const ResponsiveLayout = (props: ResponsiveLayoutProps) => {
185188

186189
export const ResponsiveLayoutBaseComp = (function () {
187190
return new UICompBuilder(childrenMap, (props, dispatch) => {
191+
192+
const theme = useContext(ThemeContext);
193+
const compType = useContext(CompTypeContext);
194+
const compTheme = theme?.theme?.components?.[compType];
195+
const styleProps: Record<string, any> = {};
196+
['style', 'animationStyle', 'columnStyle'].forEach((key: string) => {
197+
styleProps[key] = (props as any)[key];
198+
});
199+
200+
useEffect(() => {
201+
setInitialCompStyles({
202+
dispatch,
203+
compTheme,
204+
styleProps,
205+
});
206+
}, []);
207+
208+
188209
return (
189210
<ResponsiveLayout {...props} dispatch={dispatch} />
190211
);

0 commit comments

Comments
 (0)