Skip to content

Commit

Permalink
add Progress
Browse files Browse the repository at this point in the history
  • Loading branch information
icarusion committed Jun 4, 2018
1 parent e466a62 commit e0d5ae3
Show file tree
Hide file tree
Showing 3 changed files with 142 additions and 0 deletions.
50 changes: 50 additions & 0 deletions src/code/progress.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
let code = {};

code.import = `
"usingComponents": {
"i-progress": "../../dist/progress/index"
}
`;
code.usage = `
<view class="progress-item">
<i-progress percent="25"></i-progress>
<i-progress percent="45" status="active"></i-progress>
<i-progress percent="65" status="wrong"></i-progress>
<i-progress percent="100" status="success"></i-progress>
<i-progress percent="25" hide-info></i-progress>
</view>
<view class="progress-item">
<i-progress percent="{{ percent }}" status="{{ status }}"></i-progress>
<i-button bindclick="handleAdd" type="ghost">增加</i-button>
<i-button bindclick="handleReduce" type="ghost">减少</i-button>
</view>
`;

code.js = `
Page({
data: {
percent: 0,
status: 'normal'
},
handleAdd () {
if (this.data.percent === 100) return;
this.setData({
percent: this.data.percent + 10
});
if (this.data.percent === 100) {
this.setData({
status: 'success'
});
}
},
handleReduce () {
if (this.data.percent === 0) return;
this.setData({
percent: this.data.percent - 10,
status: 'normal'
});
}
});
`;

export default code;
7 changes: 7 additions & 0 deletions src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,13 @@ const routers = [
},
component: (resolve) => require(['./views/components/tag.vue'], resolve)
},
{
path: '/components/progress',
meta: {
title: '进度条 Progress'
},
component: (resolve) => require(['./views/components/progress.vue'], resolve)
},
{
path: '*',
redirect: '/'
Expand Down
85 changes: 85 additions & 0 deletions src/views/components/progress.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<template>
<i-article>
<article>
<h1>Progress 进度条</h1>
<Anchor title="概述" h2></Anchor>
<p>展示操作或任务的当前进度,比如上传文件。</p>
<Anchor title="使用指南" h2></Anchor>
<p>在 .json 中引入组件</p>
<i-code bg lang="json">{{ code.import }}</i-code>
<Anchor title="示例" h2></Anchor>
<i-code bg lang="html">{{ code.usage }}</i-code>
<br><br>
<i-code bg lang="js">{{ code.js }}</i-code>
<ad></ad>

<div class="api">
<Anchor title="API" h2></Anchor>
<Anchor title="Progress properties" h3></Anchor>
<table>
<thead>
<tr>
<th>属性</th>
<th>说明</th>
<th>类型</th>
<th>默认值</th>
</tr>
</thead>
<tbody>
<tr>
<td>i-class</td>
<td>自定义 class 类名</td>
<td>String</td>
<td>-</td>
</tr>
<tr>
<td>percent</td>
<td>百分比</td>
<td>Number</td>
<td>0</td>
</tr>
<tr>
<td>status</td>
<td>状态,可选值为 normal、active、wrong、success</td>
<td>String</td>
<td>normal</td>
</tr>
<tr>
<td>stroke-width</td>
<td>进度条的线宽,单位 px</td>
<td>Number</td>
<td>10</td>
</tr>
<tr>
<td>hide-info</td>
<td>隐藏数值或状态图标</td>
<td>Boolean</td>
<td>false</td>
</tr>
</tbody>
</table>
</div>
</article>
</i-article>
</template>
<script>
import iArticle from '../../components/article.vue';
import iCode from 'iCode';
import Demo from '../../components/demo.vue';
import Code from '../../code/progress';
import Anchor from '../../components/anchor.vue';
export default {
components: {
iArticle,
iCode,
Demo,
Anchor
},
data () {
return {
code: Code
}
}
}
</script>

0 comments on commit e0d5ae3

Please sign in to comment.