Skip to content

Commit 6f2c343

Browse files
Theme: apply theme styles in timeline comp
1 parent 33fd130 commit 6f2c343

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

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

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ import { timelineDate, timelineNode, TimelineDataTooltip } from "./timelineConst
4747
import { convertTimeLineData } from "./timelineUtils";
4848
import { default as Timeline } from "antd/es/timeline";
4949
import { EditorContext } from "comps/editorState";
50+
import { ThemeContext } from "@lowcoder-ee/comps/utils/themeContext";
51+
import { CompTypeContext } from "@lowcoder-ee/comps/utils/compTypeContext";
52+
import { setInitialCompStyles } from "@lowcoder-ee/comps/utils/themeUtil";
5053

5154
const EventOptions = [
5255
clickEvent,
@@ -64,7 +67,7 @@ const childrenMap = {
6467
reverse: BoolControl,
6568
pending: withDefault(StringControl, trans("timeLine.defaultPending")),
6669
onEvent: eventHandlerControl(EventOptions),
67-
style: styleControl(TimeLineStyle),
70+
style: styleControl(TimeLineStyle, 'style'),
6871
clickedObject: valueComp<timelineNode>({ title: "" }),
6972
clickedIndex: valueComp<number>(0),
7073
};
@@ -89,6 +92,22 @@ const TimelineComp = (
8992
) => {
9093
const { value, dispatch, style, mode, reverse, onEvent } = props;
9194
const [icons, setIcons] = useState<React.ReactNode[]>([]);
95+
const theme = useContext(ThemeContext);
96+
const compType = useContext(CompTypeContext);
97+
const compTheme = theme?.theme?.components?.[compType];
98+
99+
const styleProps: Record<string, any> = {};
100+
['style'].forEach((key: string) => {
101+
styleProps[key] = (props as any)[key];
102+
});
103+
104+
useEffect(() => {
105+
setInitialCompStyles({
106+
dispatch,
107+
compTheme,
108+
styleProps,
109+
});
110+
}, []);
92111

93112
useEffect(() => {
94113
const loadIcons = async () => {

0 commit comments

Comments
 (0)