feat(arco/Timeline): add slots

This commit is contained in:
xzdry 2022-10-17 14:18:00 +08:00
parent c4a7f6355a
commit ed9e207f4d

View File

@ -64,26 +64,44 @@ export const Timeline = implementRuntimeComponent({
properties: TimelinePropsSpec,
state: TimelineStateSpec,
methods: {},
slots: {},
slots: {
content: {
slotProps: Type.Object({
content: Type.String(),
}),
},
label: {
slotProps: Type.Object({
label: Type.String(),
}),
},
},
styleSlots: ['content'],
events: [],
},
})(props => {
const { items, ...cProps } = getComponentProps(props);
const { elementRef, customStyle } = props;
const { elementRef, customStyle, slotsElements } = props;
return (
<BaseTimeline ref={elementRef} className={css(customStyle?.content)} {...cProps}>
{items?.map((item, idx) => (
<BaseTimeline.Item
key={idx}
label={item.label}
label={
slotsElements?.label?.({ label: item.label }, undefined, `content_${idx}`) ||
item.label
}
dotColor={item.dotColor}
lineType={item.lineType}
lineColor={item.lineColor}
dotType={item.dotType}
>
{item.content}
{slotsElements?.content?.(
{ content: item.content },
undefined,
`content_${idx}`
) || item.content}
</BaseTimeline.Item>
))}
</BaseTimeline>