Skip to content

Commit a19df59

Browse files
fix: updated timeline
1 parent 501e00d commit a19df59

File tree

2 files changed

+40
-38
lines changed

2 files changed

+40
-38
lines changed

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

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { useEffect, useState } from "react";
2+
import { Button } from "antd";
23
// 渲染组件到编辑器
34
import {
45
changeChildAction,
@@ -87,6 +88,42 @@ const TimelineComp = (
8788
}
8889
) => {
8990
const { value, dispatch, style, mode, reverse, onEvent } = props;
91+
const timelineItems = value.map((value: timelineNode, index: number) => ({
92+
key: index,
93+
color: value?.color,
94+
dot: value?.dot && ANTDICON.hasOwnProperty(value?.dot.toLowerCase())
95+
? ANTDICON[value?.dot.toLowerCase() as keyof typeof ANTDICON]
96+
: "",
97+
label: (
98+
<span style={{ color: value?.lableColor || style?.lableColor }}>
99+
{value?.label}
100+
</span>
101+
),
102+
children: (
103+
<>
104+
<Button
105+
type="link"
106+
onClick={(e) => {
107+
e.preventDefault();
108+
dispatch(changeChildAction("clickedObject", value, false));
109+
dispatch(changeChildAction("clickedIndex", index, false));
110+
onEvent("click");
111+
}}
112+
style={{
113+
cursor: "pointer",
114+
color: value?.titleColor || style?.titleColor,
115+
}}
116+
>
117+
<b>{value?.title}</b>
118+
</Button>
119+
<p style={{ color: value?.subTitleColor || style?.subTitleColor }}>
120+
{value?.subTitle}
121+
</p>
122+
</>
123+
)
124+
}
125+
))
126+
90127
// TODO:parse px string
91128
return (
92129
<div
@@ -112,43 +149,8 @@ const TimelineComp = (
112149
</span>
113150
)
114151
}
115-
>
116-
{value.map((value: timelineNode, index: number) => (
117-
<Timeline.Item
118-
key={index}
119-
color={value?.color}
120-
dot={
121-
value?.dot && ANTDICON.hasOwnProperty(value?.dot.toLowerCase())
122-
? ANTDICON[value?.dot.toLowerCase() as keyof typeof ANTDICON]
123-
: ""
124-
}
125-
label={
126-
<span style={{ color: value?.lableColor || style?.lableColor }}>
127-
{value?.label}
128-
</span>
129-
}
130-
>
131-
<a
132-
href=""
133-
onClick={(e) => {
134-
e.preventDefault();
135-
dispatch(changeChildAction("clickedObject", value, false));
136-
dispatch(changeChildAction("clickedIndex", index, false));
137-
onEvent("click");
138-
}}
139-
style={{
140-
cursor: "pointer",
141-
color: value?.titleColor || style?.titleColor,
142-
}}
143-
>
144-
<b>{value?.title}</b>
145-
</a>
146-
<p style={{ color: value?.subTitleColor || style?.subTitleColor }}>
147-
{value?.subTitle}
148-
</p>
149-
</Timeline.Item>
150-
))}
151-
</Timeline>
152+
items={timelineItems}
153+
/>
152154
</div>
153155
);
154156
};

client/packages/lowcoder/src/util/keyUtils.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ function normalizeKey(e: React.KeyboardEvent | KeyboardEvent) {
8686
return v;
8787
}
8888
for (const p of codePrefixes) {
89-
if (code.length === p.length + 1 && code.startsWith(p)) {
89+
if (code?.length === p.length + 1 && code?.startsWith(p)) {
9090
return code.slice(p.length);
9191
}
9292
}

0 commit comments

Comments
 (0)