Skip to content

Commit f42e8e7

Browse files
author
FalkWolsky
committed
Changes for AntIcon, Timeline Component
1 parent 8bb4242 commit f42e8e7

File tree

8 files changed

+70
-29
lines changed

8 files changed

+70
-29
lines changed

client/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.3.0
1+
2.3.1

client/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
},
7171
"dependencies": {
7272
"@lottiefiles/react-lottie-player": "^3.5.3",
73+
"@remixicon/react": "^4.1.1",
7374
"@testing-library/react": "^14.1.2",
7475
"@testing-library/user-event": "^14.5.1",
7576
"@types/styled-components": "^5.1.34",

client/packages/lowcoder-design/src/components/edit.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ const TextInput = styled(Input)<InputProps & { $hasPrefix?: boolean }>`
6868
border: none;
6969
padding: 0 8px 0 4px;
7070
padding-left: ${(props) => (props.$hasPrefix ? "28px" : "4px")};
71-
color: #ffffff;
71+
color: #444444;
7272
line-height: 28px;
7373
font-size: 14px;
7474

client/packages/lowcoder/src/comps/comps/timelineComp/antIcon.tsx renamed to client/packages/lowcoder-design/src/icons/antIcon.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1581,3 +1581,24 @@ export const ANTDICON = {
15811581
zoominoutlined: <ZoomInOutlined />,
15821582
zoomoutoutlined: <ZoomOutOutlined />,
15831583
};
1584+
1585+
1586+
// Function to dynamically import icons
1587+
export const loadAntDIcon = async (iconName: string) => {
1588+
if (!iconName) return null;
1589+
1590+
try {
1591+
const module = await import(`@ant-design/icons`);
1592+
const IconComponent = (module as any)[iconName];
1593+
if (IconComponent) {
1594+
// Return the icon component if found
1595+
return <IconComponent />;
1596+
} else {
1597+
console.error(`Icon ${iconName} not found in @ant-design/icons`);
1598+
return null;
1599+
}
1600+
} catch (error) {
1601+
console.error(`Error loading icon ${iconName}:`, error);
1602+
return null;
1603+
}
1604+
};

client/packages/lowcoder-design/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,5 @@ export * from "./components/toolTip";
4949
export * from "./components/video";
5050

5151
export * from "./icons";
52+
53+
export * from "./icons/antIcon";

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

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,19 @@
1-
import React, { useEffect, useState } from "react";
1+
import React, { useEffect, useState, useContext } from "react";
22
import { default as Button } from "antd/es/button";
3-
// 渲染组件到编辑器
43
import {
54
changeChildAction,
65
DispatchType,
76
CompAction,
87
RecordConstructorToView,
98
} from "lowcoder-core";
10-
// 文字国际化转换api
119
import { trans } from "i18n";
12-
// 右侧属性栏总框架
1310
import { UICompBuilder, withDefault } from "../../generators";
14-
// 右侧属性子框架
1511
import { Section, sectionNames } from "lowcoder-design";
16-
// 指示组件是否隐藏的开关
1712
import { hiddenPropertyView } from "comps/utils/propertyUtils";
18-
// 右侧属性开关
19-
2013
import { BoolControl } from "comps/controls/boolControl";
21-
import { stringExposingStateControl } from "comps/controls/codeStateControl"; //文本并暴露值
14+
import { stringExposingStateControl } from "comps/controls/codeStateControl";
2215
import { dropdownControl } from "comps/controls/dropdownControl";
23-
import { styleControl } from "comps/controls/styleControl"; //样式输入框
16+
import { styleControl } from "comps/controls/styleControl";
2417
import { alignControl } from "comps/controls/alignControl";
2518
import { AutoHeightControl } from "comps/controls/autoHeightControl";
2619
import { jsonValueExposingStateControl } from "comps/controls/codeStateControl";
@@ -34,35 +27,25 @@ import {
3427
NumberControl,
3528
StringControl,
3629
} from "comps/controls/codeControl";
37-
// 事件控制
3830
import {
3931
clickEvent,
4032
eventHandlerControl,
4133
} from "comps/controls/eventHandlerControl";
42-
43-
// 引入样式
4434
import {
4535
TimeLineStyle,
4636
heightCalculator,
4737
widthCalculator,
4838
marginCalculator,
4939
} from "comps/controls/styleControlConstants";
50-
// 初始化暴露值
5140
import { stateComp, valueComp } from "comps/generators/simpleGenerators";
52-
// 组件对外暴露属性的api
5341
import {
5442
NameConfig,
5543
NameConfigHidden,
5644
withExposingConfigs,
5745
} from "comps/generators/withExposing";
58-
5946
import { timelineDate, timelineNode, TimelineDataTooltip } from "./timelineConstants";
6047
import { convertTimeLineData } from "./timelineUtils";
6148
import { default as Timeline } from "antd/es/timeline";
62-
63-
import { ANTDICON } from "./antIcon"; // todo: select icons to not import all icons
64-
65-
import { useContext } from "react";
6649
import { EditorContext } from "comps/editorState";
6750

6851
const EventOptions = [
@@ -86,18 +69,44 @@ const childrenMap = {
8669
clickedIndex: valueComp<number>(0),
8770
};
8871

72+
// Utility function to dynamically load Ant Design icons
73+
const loadIcon = async (iconName: string) => {
74+
if (!iconName) return null;
75+
try {
76+
const module = await import(`@ant-design/icons`);
77+
const IconComponent = (module as any)[iconName];
78+
return IconComponent ? <IconComponent /> : null;
79+
} catch (error) {
80+
console.error(`Error loading icon ${iconName}:`, error);
81+
return null;
82+
}
83+
};
84+
8985
const TimelineComp = (
9086
props: RecordConstructorToView<typeof childrenMap> & {
9187
dispatch: (action: CompAction) => void;
9288
}
9389
) => {
9490
const { value, dispatch, style, mode, reverse, onEvent } = props;
91+
const [icons, setIcons] = useState<React.ReactNode[]>([]);
92+
93+
useEffect(() => {
94+
const loadIcons = async () => {
95+
const iconComponents = await Promise.all(
96+
value.map((node) =>
97+
node.dot ? loadIcon(node.dot) : Promise.resolve(null)
98+
)
99+
);
100+
setIcons(iconComponents);
101+
};
102+
103+
loadIcons();
104+
}, [value]);
105+
95106
const timelineItems = value.map((value: timelineNode, index: number) => ({
96107
key: index,
97108
color: value?.color,
98-
dot: value?.dot && ANTDICON.hasOwnProperty(value?.dot.toLowerCase())
99-
? ANTDICON[value?.dot.toLowerCase() as keyof typeof ANTDICON]
100-
: "",
109+
dot: icons[index] || "",
101110
label: (
102111
<span style={{ color: value?.lableColor || style?.lableColor }}>
103112
{value?.label}
@@ -125,10 +134,8 @@ const TimelineComp = (
125134
</p>
126135
</>
127136
)
128-
}
129-
))
137+
}));
130138

131-
// TODO:parse px string
132139
return (
133140
<div
134141
style={{

client/packages/lowcoder/src/pages/common/headerStartDropdown.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ export function HeaderStartDropdown(props: { setEdit: () => void }) {
154154
)}
155155
>
156156
<EditTextWrapper
157-
style={{ width: "fit-content", maxWidth: "288px", padding: "0 8px" }}
157+
style={{ width: "fit-content", maxWidth: "288px", padding: "0 8px"}}
158158
disabled={showAppSnapshot}
159159
>
160160
{isModule && (

client/yarn.lock

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3387,6 +3387,15 @@ __metadata:
33873387
languageName: node
33883388
linkType: hard
33893389

3390+
"@remixicon/react@npm:^4.1.1":
3391+
version: 4.1.1
3392+
resolution: "@remixicon/react@npm:4.1.1"
3393+
peerDependencies:
3394+
react: ">=18.2.0"
3395+
checksum: 59b05b91ad9335ae531b2927ceb7c5930ec5afcdabb5d96461d3181e1f794ddbdd4a899e85eb66f1a5341f55132898b6f680f51643bd7bd7244a741f44beb0b7
3396+
languageName: node
3397+
linkType: hard
3398+
33903399
"@rjsf/antd@npm:^5.15.1":
33913400
version: 5.15.1
33923401
resolution: "@rjsf/antd@npm:5.15.1"
@@ -11921,6 +11930,7 @@ __metadata:
1192111930
"@babel/preset-env": ^7.20.2
1192211931
"@babel/preset-typescript": ^7.18.6
1192311932
"@lottiefiles/react-lottie-player": ^3.5.3
11933+
"@remixicon/react": ^4.1.1
1192411934
"@rollup/plugin-typescript": ^8.5.0
1192511935
"@testing-library/jest-dom": ^5.16.5
1192611936
"@testing-library/react": ^14.1.2

0 commit comments

Comments
 (0)