Skip to content

Commit 4b1886f

Browse files
committed
chore: support rail reverse
1 parent e17adeb commit 4b1886f

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

src/Step.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import cls from 'classnames';
44
import KeyCode from '@rc-component/util/lib/KeyCode';
55
import type { Status, StepItem, StepsProps } from './Steps';
66
import Rail from './Rail';
7+
import { UnstableContext } from './UnstableContext';
78

89
function hasContent<T>(value: T) {
910
return value !== undefined && value !== null;
@@ -57,6 +58,9 @@ export default function Step(props: StepProps) {
5758

5859
const itemCls = `${prefixCls}-item`;
5960

61+
// ==================== Internal Context ====================
62+
const { railFollowPrevStatus } = React.useContext(UnstableContext);
63+
6064
// ========================== Data ==========================
6165
const {
6266
onClick: onItemClick,
@@ -129,8 +133,6 @@ export default function Step(props: StepProps) {
129133
classNames.item,
130134
);
131135

132-
// !hasContent(title) && !hasContent(subTitle) && `${itemCls}-header-empty`
133-
134136
const wrapperNode = (
135137
<div className={cls(`${itemCls}-wrapper`, classNames.itemWrapper)} style={styles.itemWrapper}>
136138
<div className={cls(`${itemCls}-icon`, classNames.itemIcon)} style={styles.itemIcon}>
@@ -154,7 +156,12 @@ export default function Step(props: StepProps) {
154156
)}
155157

156158
{!last && (
157-
<Rail prefixCls={itemCls} classNames={classNames} styles={styles} status={nextStatus} />
159+
<Rail
160+
prefixCls={itemCls}
161+
classNames={classNames}
162+
styles={styles}
163+
status={railFollowPrevStatus ? status : nextStatus}
164+
/>
158165
)}
159166
</div>
160167
{hasContent(mergedContent) && (

src/UnstableContext.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import * as React from 'react';
2+
3+
export interface UnstableContextProps {
4+
/**
5+
* Used for Timeline component `reverse` prop.
6+
* Safe to remove if refactor.
7+
*/
8+
railFollowPrevStatus?: boolean;
9+
}
10+
11+
export const UnstableContext = React.createContext<UnstableContextProps>({});

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ import Step from './Step';
33

44
export { Step };
55
export type { StepsProps };
6+
export { UnstableContext } from './UnstableContext';
67
export default Steps;

0 commit comments

Comments
 (0)