Skip to content

Commit 40c3074

Browse files
Theme: apply theme styles in list/grid view
1 parent 8942536 commit 40c3074

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

client/packages/lowcoder/src/comps/comps/listViewComp/listView.tsx

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { BackgroundColorContext } from "comps/utils/backgroundColorContext";
44
import _ from "lodash";
55
import { ConstructorToView, deferAction } from "lowcoder-core";
66
import { HintPlaceHolder, ScrollBar, pageItemRender } from "lowcoder-design";
7-
import { RefObject, useContext, createContext, useMemo, useRef } from "react";
7+
import { RefObject, useContext, createContext, useMemo, useRef, useEffect } from "react";
88
import ReactResizeDetector from "react-resize-detector";
99
import styled from "styled-components";
1010
import { checkIsMobile } from "util/commonUtils";
@@ -19,6 +19,10 @@ import { ContextContainerComp } from "./contextContainerComp";
1919
import { ListViewImplComp } from "./listViewComp";
2020
import { getCurrentItemParams, getData } from "./listViewUtils";
2121
import { AnimationStyleType } from "@lowcoder-ee/index.sdk";
22+
import { CompTypeContext } from "@lowcoder-ee/comps/utils/compTypeContext";
23+
import { ThemeContext } from "@lowcoder-ee/comps/utils/themeContext";
24+
import { setInitialCompStyles } from "@lowcoder-ee/comps/utils/themeUtil";
25+
import { childrenToProps } from "@lowcoder-ee/comps/generators/multi";
2226

2327
const ListViewWrapper = styled.div<{ $style: any; $paddingWidth: string,$animationStyle:AnimationStyleType }>`
2428
height: 100%;
@@ -274,6 +278,25 @@ export function ListView(props: Props) {
274278
const maxWidth = editorState.getAppSettings().maxWidth;
275279
const isMobile = checkIsMobile(maxWidth);
276280
const paddingWidth = isMobile ? "4px" : "16px";
281+
282+
const childrenProps = childrenToProps(comp.children);
283+
const theme = useContext(ThemeContext);
284+
const compType = useContext(CompTypeContext);
285+
const compTheme = theme?.theme?.components?.[compType];
286+
287+
const styleProps: Record<string, any> = {};
288+
['style', 'animationStyle'].forEach((key: string) => {
289+
styleProps[key] = (childrenProps as any)[key];
290+
});
291+
292+
useEffect(() => {
293+
setInitialCompStyles({
294+
dispatch: comp.dispatch,
295+
compTheme,
296+
styleProps,
297+
});
298+
}, []);
299+
277300
// log.debug("renders: ", renders);
278301
return (
279302
<BackgroundColorContext.Provider value={style.background}>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ const childrenMap = {
5252
scrollbars: withDefault(BoolControl, false),
5353
showBorder: BoolControl,
5454
pagination: withDefault(PaginationControl, { pageSize: "6" }),
55-
style: styleControl(ListViewStyle),
56-
animationStyle: styleControl(AnimationStyle),
55+
style: styleControl(ListViewStyle, 'style'),
56+
animationStyle: styleControl(AnimationStyle, 'animationStyle'),
5757
horizontal: withDefault(BoolControl, false),
5858
minHorizontalWidth: withDefault(RadiusControl, '100px'),
5959
};

0 commit comments

Comments
 (0)