import { View } from "@tarojs/components";
import Taro, { pxTransform } from "@tarojs/taro";
import { BG_COLOR_LIST, TEXT_COLOR_LIST } from "../../lib/model";
import { IProps } from "../../../@types/timeline";
import ClFlex from "../flex";
import { classNames, generateId } from "../../lib";
export default function ClTimeline(props: IProps) {
const times = props.times || [];
const iconColorClassName = color => (color ? TEXT_COLOR_LIST[color] : "");
const iconClassName = icon => (icon ? `cuIcon-${icon}` : "");
const bgColorClassName = color => (color ? BG_COLOR_LIST[color] : "");
const onClick = (index: number) => {
props.onClick && props.onClick(index);
};
const items = times.map((item, index) =>
item.node ? (
{
onClick(index);
}}
>
{item.node}
) : (
{
onClick(index);
}}
>
{item.title}
{item.time}
{item.content
? item.content.map((desc, index) => (
{desc}
))
: ""}
)
);
return (
{items}
);
}
ClTimeline.options = {
addGlobalClass: true
};
ClTimeline.defaultProps = {
times: [],
onClick: () => {}
} as IProps;