Skip to content

Commit 15c788e

Browse files
ooo1lcc
andauthored
feat: optimize sequence timeline (#217)
Co-authored-by: cc <ronglong.crl@alibaba-inc.com>
1 parent 928a146 commit 15c788e

2 files changed

Lines changed: 20 additions & 17 deletions

File tree

src/designs/structures/sequence-timeline.tsx

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ import type { BaseStructureProps } from './types';
1515
export interface SequenceTimelineProps extends BaseStructureProps {
1616
gap?: number;
1717
lineOffset?: number;
18+
showStepLabels?: boolean;
1819
}
1920

2021
export const SequenceTimeline: ComponentType<SequenceTimelineProps> = (
2122
props,
2223
) => {
23-
const { Title, Item, data, gap = 10, options } = props;
24+
const { Title, Item, data, gap = 10, showStepLabels = true, options } = props;
2425
const { title, desc, items = [] } = data;
2526

2627
const titleContent = Title ? <Title title={title} desc={desc} /> : null;
@@ -90,20 +91,22 @@ export const SequenceTimeline: ComponentType<SequenceTimelineProps> = (
9091
const nodeY = itemY + itemBounds.height / 2;
9192
const indexes = [index];
9293

93-
decorElements.push(
94-
<Text
95-
x={stepLabelX}
96-
y={nodeY}
97-
width={70}
98-
fontSize={18}
99-
fontWeight="bold"
100-
alignHorizontal="left"
101-
alignVertical="middle"
102-
fill={palette[index % palette.length]}
103-
>
104-
{`STEP ${index + 1}`}
105-
</Text>,
106-
);
94+
if (showStepLabels) {
95+
decorElements.push(
96+
<Text
97+
x={stepLabelX}
98+
y={nodeY}
99+
width={70}
100+
fontSize={18}
101+
fontWeight="bold"
102+
alignHorizontal="left"
103+
alignVertical="middle"
104+
fill={palette[index % palette.length]}
105+
>
106+
{`STEP ${index + 1}`}
107+
</Text>,
108+
);
109+
}
107110

108111
itemElements.push(
109112
<Item

src/templates/built-in.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ const BUILT_IN_TEMPLATES: Record<string, TemplateOptions> = {
210210
'sequence-timeline-plain-text': {
211211
design: {
212212
title: 'default',
213-
structure: { type: 'sequence-timeline' },
213+
structure: { type: 'sequence-timeline', showStepLabels: false },
214214
items: [{ type: 'plain-text' }],
215215
},
216216
},
@@ -231,7 +231,7 @@ const BUILT_IN_TEMPLATES: Record<string, TemplateOptions> = {
231231
'sequence-timeline-simple': {
232232
design: {
233233
title: 'default',
234-
structure: { type: 'sequence-timeline', gap: 20 },
234+
structure: { type: 'sequence-timeline', gap: 20, showStepLabels: false },
235235
items: [{ type: 'simple', positionV: 'middle' }],
236236
},
237237
},

0 commit comments

Comments
 (0)