Skip to content

steps add reverse mode #198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions examples/pages/steps/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,60 @@
</view>
</i-step>
</i-steps>

<view class="one-tag">横向反方向</view>
<i-steps current="{{verticalCurrent}}" reverse>
<i-step>
<view slot="title">
已完成
</view>
<view slot="content">
这里是该步骤的描述信息
</view>
</i-step>
<i-step>
<view slot="title">
进行中
</view>
<view slot="content">
这里是该步骤的描述信息
</view>
</i-step>
<i-step>
<view slot="title">
错误
</view>
<view slot="content">
这里是该步骤的描述信息
</view>
</i-step>
</i-steps>

<view class="one-tag">垂直反方向</view>
<i-steps current="{{verticalCurrent}}" direction="vertical" reverse>
<i-step>
<view slot="title">
已完成
</view>
<view slot="content">
这里是该步骤的描述信息
</view>
</i-step>
<i-step>
<view slot="title">
进行中
</view>
<view slot="content">
这里是该步骤的描述信息
</view>
</i-step>
<i-step>
<view slot="title">
错误
</view>
<view slot="content">
这里是该步骤的描述信息
</view>
</i-step>
</i-steps>
</view>
3 changes: 2 additions & 1 deletion src/step/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ Component({
len : options.len,
index : options.index,
current : options.current,
direction : options.direction
direction : options.direction,
reverse: options.reverse
})
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/step/index.wxml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<view class="i-class i-step-item {{parse.getClass(status,current,index)}} {{ direction === 'vertical' ? 'i-step-vertical' : 'i-step-horizontal' }}" style="{{parse.getItemStyle(len,direction)}}">
<view class="i-class i-step-item {{parse.getClass(status,current,index)}} {{ direction === 'vertical' ? 'i-step-vertical' : 'i-step-horizontal' }}" style="{{parse.getItemStyle(len,direction,reverse)}}">
<view class="i-step-item-ico">
<view class="i-step-ico" wx:if="{{parse.noIco(status,current,index,icon) }}">{{ index+1 }}</view>
<view class="i-step-ico" wx:else>
<i-icon i-class="i-step-ico-in" type="{{parse.getIcoClass(status,icon)}}"></i-icon>
</view>
<view class="i-step-line" wx:if="{{ index !== len - 1 }}"></view>
<view class="i-step-line" wx:if="{{ index !== (!reverse ? len - 1 : 0) }}"></view>
</view>
<view class="i-step-item-main">
<view class="i-step-item-title" wx:if="{{title !== ''}}">
Expand Down Expand Up @@ -44,8 +44,8 @@ module.exports = {
}
return class;
},
getItemStyle : function(len,direction){
if( direction === 'horizontal' ){
getItemStyle : function(len,direction,reverse){
if( direction === 'horizontal' && !reverse ){
return 'width :'+100/len + '%';
}else{
return 'width : 100%;';
Expand Down
9 changes: 7 additions & 2 deletions src/steps/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ Component({
type : String,
//value has horizontal or vertical
value : 'horizontal'
}
},
reverse : {
type : Boolean,
value : false
}
},
relations : {
'../step/index' : {
Expand All @@ -41,7 +45,8 @@ Component({
len : len,
index : index,
current : this.data.current,
direction : this.data.direction
direction : this.data.direction,
reverse : this.data.reverse
});
});
}
Expand Down
12 changes: 12 additions & 0 deletions src/steps/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,16 @@
@import "../styles/_mixins.less";
.i-steps{
width: 100%;
}

.i-steps-horizontal-reverse{
width: 100%;
display: flex;
flex-direction: row-reverse;
}

.i-steps-vertical-reverse{
width: 100%;
display: flex;
flex-direction: column-reverse;
}
2 changes: 1 addition & 1 deletion src/steps/index.wxml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<view class="i-class i-steps">
<view class="i-class {{ !reverse ? 'i-steps' : (direction === 'vertical' ? 'i-steps-vertical-reverse' : 'i-steps-horizontal-reverse') }}">
<slot></slot>
</view>