feat: timeline时间轴支持自定义图标 (#5668)

* fix:折叠器Collapse自定义图标&inputNumber对含后缀生效

* 修改

* 正则修改

* 正则修改

* 正则修改

* feat:将默认px替换为rem 2px===0.125rem

* feat:timeline时间轴支持自定义图标

Co-authored-by: xujiahao01 <xujiahao01@baidu.com>
This commit is contained in:
徐佳豪 2022-11-02 11:02:46 +08:00 committed by GitHub
parent 1a56155632
commit 2bdb5c6a97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

View File

@ -1,6 +1,6 @@
import React, {ReactNode, useState} from 'react';
import {localeable, LocaleProps} from 'amis-core';
import {themeable, ThemeProps} from 'amis-core';
import {themeable, ThemeProps, generateIcon} from 'amis-core';
import {Icon} from './icons';
export interface TimelineItemProps {
@ -111,7 +111,11 @@ export function TimelineItem(props: TimelineItem) {
<div className={cx('TimelineItem-line')}></div>
{icon ? (
<div className={cx('TimelineItem-icon')}>
<Icon icon={icon} className="icon" />
{typeof icon === 'object' ? (
generateIcon(cx, icon as any)
) : (
<Icon icon={icon} className="icon" />
)}
</div>
) : (
<div

View File

@ -97,10 +97,11 @@ export function TimelineCmpt(props: TimelineProps) {
// 处理源数据
const resolveTimelineItems = timelineItemsRow?.map(
(timelineItem: TimelineItemSchema) => {
const {icon, title} = timelineItem;
return {
...timelineItem,
icon: resolveRender('icon', timelineItem.icon),
title: resolveRender('title', timelineItem.title)
icon: typeof icon === 'string' ? filter(icon, data) : icon,
title: resolveRender('title', title)
};
}
);