Skip to content

Commit

Permalink
Revert "feat(Steps): add renderStep prop (AntmJS#670)"
Browse files Browse the repository at this point in the history
This reverts commit 2ca9353.
  • Loading branch information
MrXiangXvFan committed Aug 9, 2024
1 parent a4f0596 commit 94a0c22
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 103 deletions.
40 changes: 0 additions & 40 deletions packages/vantui/src/steps/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,46 +131,6 @@ function Demo() {
}
```

### 自定义渲染 Step 内容

可以通过设置 `renderStep` 属性来自定义每个步骤的渲染内容。

```jsx
const steps = [
{
text: '步骤一',
desc: '描述信息',
},
{
text: '步骤二',
desc: '描述信息',
},
{
text: '步骤三',
desc: '描述信息',
},
]

const renderStep = (step) => (
<>
<View>{step.text}</View>
<View>自定义 Step 内容</View>
</>
)

function Demo() {
return (
<Steps
steps={steps}
active={1}
direction="vertical"
activeColor="#ee0a24"
renderStep={renderStep}
/>
)
}
```

### StepsProps [[详情]](https://github.com/AntmJS/vantui/tree/main/packages/vantui/types/steps.d.ts)

| 参数 | 说明 | 类型 | 默认值 | 必填 |
Expand Down
36 changes: 0 additions & 36 deletions packages/vantui/src/steps/demo/demo5.tsx

This file was deleted.

5 changes: 0 additions & 5 deletions packages/vantui/src/steps/demo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import Demo1 from './demo1'
import Demo2 from './demo2'
import Demo3 from './demo3'
import Demo4 from './demo4'
import Demo5 from './demo5'

export default class Index extends Component {
constructor(props) {
Expand All @@ -32,10 +31,6 @@ export default class Index extends Component {
<DemoBlock title="竖向步骤条" padding>
<Demo4 />
</DemoBlock>

<DemoBlock title="自定义渲染 Step 内容" padding>
<Demo5 />
</DemoBlock>
</DemoPage>
)
}
Expand Down
11 changes: 2 additions & 9 deletions packages/vantui/src/steps/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export function getStatus(index: number, active: any) {
export function Steps(props: StepsProps) {
const {
steps = [],
renderStep,
active = 0,
direction = 'horizontal',
activeColor = GREEN,
Expand Down Expand Up @@ -66,14 +65,8 @@ export function Steps(props: StepsProps) {
className="van-step__title"
style={index === active ? 'color: ' + activeColor : ''}
>
{renderStep ? (
renderStep(item)
) : (
<>
<View>{item.text}</View>
<View className="desc-class">{item.desc}</View>
</>
)}
<View>{item.text}</View>
<View className="desc-class">{item.desc}</View>
</View>
<View className="van-step__circle-container">
{index !== active ? (
Expand Down
20 changes: 7 additions & 13 deletions packages/vantui/types/steps.d.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
import { FunctionComponent } from 'react'
import { ViewProps, ITouchEvent } from '@tarojs/components'

export interface Step {
index?: number
desc: React.ReactNode
text: string
activeIcon?: string
inactiveIcon?: string
}

export interface StepsProps extends ViewProps {
/**
* @description icon统一class的前缀
Expand All @@ -17,11 +9,13 @@ export interface StepsProps extends ViewProps {
/**
* @description Step 配置项数组
*/
steps?: Step[]
/**
* @description 自定义 Step 渲染
*/
renderStep?: (step: Step) => React.ReactNode
steps?: {
index?: number
desc: React.ReactNode
text: string
activeIcon?: string
inactiveIcon?: string
}[]
/**
* @description 当前步骤
* @default 0
Expand Down

0 comments on commit 94a0c22

Please sign in to comment.