Skip to content

Commit

Permalink
Progress: add dashboard progress bar
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiyang committed Jul 12, 2018
1 parent 76cc72e commit 069b9f7
Show file tree
Hide file tree
Showing 7 changed files with 352 additions and 46 deletions.
91 changes: 82 additions & 9 deletions examples/docs/en-US/progress.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
<script>
export default {
data() {
return {
percentage: 0
};
},
methods: {
format(percentage) {
return percentage === 100 ? 'DONE' : `${percentage}%`;
},
increase() {
this.percentage += 10;
if (this.percentage > 100) {
this.percentage = 100;
}
},
decrease() {
this.percentage -= 10;
if (this.percentage < 0) {
this.percentage = 0;
}
}
}
}
</script>

<style>
.demo-box.demo-progress {
.el-progress--line {
Expand All @@ -15,13 +42,22 @@ Progress is used to show the progress of current operation, and inform the user

### Linear progress bar (external percentage)

:::demo Use `percentage` attribute to set the percentage. It's **required** and must be between `0-100`.
:::demo Use `percentage` attribute to set the percentage. It's **required** and must be between `0-100`. You can custom text format by setting `format`.
```html
<el-progress :percentage="0"></el-progress>
<el-progress :percentage="70"></el-progress>
<el-progress :percentage="80" color="#8e71c7"></el-progress>
<el-progress :percentage="50"></el-progress>
<el-progress :percentage="100" :format="format"></el-progress>
<el-progress :percentage="100" status="success"></el-progress>
<el-progress :percentage="50" status="exception"></el-progress>

<script>
export default {
methods: {
format(percentage) {
return percentage === 100 ? 'DONE' : `${percentage}%`;
}
}
};
</script>
```
:::

Expand All @@ -31,9 +67,7 @@ In this case the percentage takes no additional space.

:::demo `stroke-width` attribute decides the `width` of progress bar, and use `text-inside` attribute to put description inside the progress bar.
```html
<el-progress :text-inside="true" :stroke-width="18" :percentage="0"></el-progress>
<el-progress :text-inside="true" :stroke-width="18" :percentage="70"></el-progress>
<el-progress :text-inside="true" :stroke-width="18" :percentage="80" color="rgba(142, 113, 199, 0.7)"></el-progress>
<el-progress :text-inside="true" :stroke-width="18" :percentage="100" status="success"></el-progress>
<el-progress :text-inside="true" :stroke-width="18" :percentage="50" status="exception"></el-progress>
```
Expand All @@ -45,20 +79,59 @@ In this case the percentage takes no additional space.
```html
<el-progress type="circle" :percentage="0"></el-progress>
<el-progress type="circle" :percentage="25"></el-progress>
<el-progress type="circle" :percentage="80" color="#8e71c7"></el-progress>
<el-progress type="circle" :percentage="100" status="success"></el-progress>
<el-progress type="circle" :percentage="50" status="exception"></el-progress>
```
:::

### Dashboard progress bar

:::demo You also can specify `type` attribute to `dashboard` to use dashboard progress bar.

```html

<el-progress type="dashboard" :percentage="percentage"></el-progress>
<div>
<el-button-group>
<el-button icon="el-icon-minus" @click="decrease"></el-button>
<el-button icon="el-icon-plus" @click="increase"></el-button>
</el-button-group>
</div>

<script>
export default {
data() {
return {
percentage: 0
};
},
methods: {
increase() {
this.percentage += 10;
if (this.percentage > 100) {
this.percentage = 100;
}
},
decrease() {
this.percentage -= 10;
if (this.percentage < 0) {
this.percentage = 0;
}
}
}
}
</script>
```
:::

### Attributes
| Attribute | Description | Type | Accepted Values | Default |
| --- | ---- | ---- | ---- | ---- |
| **percentage** | percentage, **required** | number | 0-100 | 0 |
| type | the type of progress bar | string | line/circle | line |
| type | the type of progress bar | string | line/circle/dashboard | line |
| stroke-width | the width of progress bar | number || 6 |
| text-inside | whether to place the percentage inside progress bar, only works when `type` is 'line' | boolean || false |
| status | the current status of progress bar | string | success/exception ||
| status | the current status of progress bar | string | success/exception/warning ||
| color | background color of progress bar. Overrides `status` prop | string |||
| width | the canvas width of circle progress bar | number || 126 |
| show-text | whether to show percentage | boolean || true |
92 changes: 83 additions & 9 deletions examples/docs/es/progress.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
<script>
export default {
data() {
return {
percentage: 0
};
},
methods: {
format(percentage) {
return percentage === 100 ? 'DONE' : `${percentage}%`;
},
increase() {
this.percentage += 10;
if (this.percentage > 100) {
this.percentage = 100;
}
},
decrease() {
this.percentage -= 10;
if (this.percentage < 0) {
this.percentage = 0;
}
}
}
}
</script>

<style>
.demo-box.demo-progress {
.el-progress--line {
Expand All @@ -14,13 +41,23 @@ Progreso es usado para mostrar el estado de la operación actual e informar al u

### Barra de progreso lineal (porcentage externo)

:::demo Usa el atributo `percentage` para asignar el porcentage. Este es **requerido** y tiene que ser un valor entre `0-100`.
:::demo Usa el atributo `percentage` para asignar el porcentage. Este es **requerido** y tiene que ser un valor entre `0-100`. You can custom text format by setting `format`.

```html
<el-progress :percentage="0"></el-progress>
<el-progress :percentage="70"></el-progress>
<el-progress :percentage="80" color="#8e71c7"></el-progress>
<el-progress :percentage="50"></el-progress>
<el-progress :percentage="100" :format="format"></el-progress>
<el-progress :percentage="100" status="success"></el-progress>
<el-progress :percentage="50" status="exception"></el-progress>

<script>
export default {
methods: {
format(percentage) {
return percentage === 100 ? 'DONE' : `${percentage}%`;
}
}
};
</script>
```
:::

Expand All @@ -29,9 +66,7 @@ En este caso el porcentage no toma espacio adicional.

:::demo El atributo `stroke-width` decide el ancho de la barra de progreso, y usa el atributo `text-inside` para poner la descripción dentro de la misma.
```html
<el-progress :text-inside="true" :stroke-width="18" :percentage="0"></el-progress>
<el-progress :text-inside="true" :stroke-width="18" :percentage="70"></el-progress>
<el-progress :text-inside="true" :stroke-width="18" :percentage="80" color="rgba(142, 113, 199, 0.7)"></el-progress>
<el-progress :text-inside="true" :stroke-width="18" :percentage="100" status="success"></el-progress>
<el-progress :text-inside="true" :stroke-width="18" :percentage="50" status="exception"></el-progress>
```
Expand All @@ -43,20 +78,59 @@ En este caso el porcentage no toma espacio adicional.
```html
<el-progress type="circle" :percentage="0"></el-progress>
<el-progress type="circle" :percentage="25"></el-progress>
<el-progress type="circle" :percentage="80" color="#8e71c7"></el-progress>
<el-progress type="circle" :percentage="100" status="success"></el-progress>
<el-progress type="circle" :percentage="50" status="exception"></el-progress>
```
:::

### Dashboard progress bar

:::demo You also can specify `type` attribute to `dashboard` to use dashboard progress bar.

```html

<el-progress type="dashboard" :percentage="percentage"></el-progress>
<div>
<el-button-group>
<el-button icon="el-icon-minus" @click="decrease"></el-button>
<el-button icon="el-icon-plus" @click="increase"></el-button>
</el-button-group>
</div>

<script>
export default {
data() {
return {
percentage: 0
};
},
methods: {
increase() {
this.percentage += 10;
if (this.percentage > 100) {
this.percentage = 100;
}
},
decrease() {
this.percentage -= 10;
if (this.percentage < 0) {
this.percentage = 0;
}
}
}
}
</script>
```
:::

### Atributos
| Atributo | Descripción | Tipo | Valores aceptado | Por defecto |
| ------------ | ---------------------------------------- | ------- | ----------------- | ----------- |
| percentage | porcentaje, requerido | number | 0-100 | 0 |
| type | tipo de barra de progreso | string | line/circle | line |
| type | tipo de barra de progreso | string | line/circle/dashboard | line |
| stroke-width | ancho de la barra de progreso | number || 6 |
| text-inside | mostrar el porcentaje dentro de la barra de progreso, solo funciona cuando `type` es 'line' | boolean || false |
| status | estado actual de la barra de progreso | string | success/exception | |
| status | estado actual de la barra de progreso | string | success/exception/warning ||
| color | color de fondo de la barra de progreso. Sobreescribe la propiedad `status` | string |||
| width | ancho del canvas que contiene la barra de progreso circula | number || 126 |
| show-text | mostrar porcentaje | boolean || true |
95 changes: 84 additions & 11 deletions examples/docs/zh-CN/progress.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
<script>
export default {
data() {
return {
percentage: 0
};
},
methods: {
format(percentage) {
return percentage === 100 ? 'DONE' : `${percentage}%`;
},
increase() {
this.percentage += 10;
if (this.percentage > 100) {
this.percentage = 100;
}
},
decrease() {
this.percentage -= 10;
if (this.percentage < 0) {
this.percentage = 0;
}
}
}
}
</script>

<style>
.demo-box.demo-progress {
.el-progress--line {
Expand All @@ -16,14 +43,23 @@

### 线形进度条 — 百分比外显

:::demo Progress 组件设置`percentage`属性即可,表示进度条对应的百分比,**必填**,必须在 0-100。
:::demo Progress 组件设置`percentage`属性即可,表示进度条对应的百分比,**必填**,必须在 0-100。通过 `format` 属性来指定进度条文字内容。

```html
<el-progress :percentage="0"></el-progress>
<el-progress :percentage="70"></el-progress>
<el-progress :percentage="80" color="#8e71c7"></el-progress>
<el-progress :percentage="50"></el-progress>
<el-progress :percentage="100" :format="format"></el-progress>
<el-progress :percentage="100" status="success"></el-progress>
<el-progress :percentage="50" status="exception"></el-progress>

<script>
export default {
methods: {
format(percentage) {
return percentage === 100 ? 'DONE' : `${percentage}%`;
}
}
};
</script>
```
:::

Expand All @@ -34,9 +70,7 @@
:::demo Progress 组件可通过 `stroke-width` 属性更改进度条的高度,并可通过 `text-inside` 属性来将进度条描述置于进度条内部。

```html
<el-progress :text-inside="true" :stroke-width="18" :percentage="0"></el-progress>
<el-progress :text-inside="true" :stroke-width="18" :percentage="70"></el-progress>
<el-progress :text-inside="true" :stroke-width="18" :percentage="80" color="rgba(142, 113, 199, 0.7)"></el-progress>
<el-progress :text-inside="true" :stroke-width="18" :percentage="100" status="success"></el-progress>
<el-progress :text-inside="true" :stroke-width="18" :percentage="50" status="exception"></el-progress>
```
Expand All @@ -49,20 +83,59 @@
```html
<el-progress type="circle" :percentage="0"></el-progress>
<el-progress type="circle" :percentage="25"></el-progress>
<el-progress type="circle" :percentage="80" color="#8e71c7"></el-progress>
<el-progress type="circle" :percentage="100" status="success"></el-progress>
<el-progress type="circle" :percentage="50" status="exception"></el-progress>
```
:::

### 仪表盘形进度条

:::demo 通过 `type` 属性来指定使用仪表盘形进度条。

```html

<el-progress type="dashboard" :percentage="percentage"></el-progress>
<div>
<el-button-group>
<el-button icon="el-icon-minus" @click="decrease"></el-button>
<el-button icon="el-icon-plus" @click="increase"></el-button>
</el-button-group>
</div>

<script>
export default {
data() {
return {
percentage: 0
};
},
methods: {
increase() {
this.percentage += 10;
if (this.percentage > 100) {
this.percentage = 100;
}
},
decrease() {
this.percentage -= 10;
if (this.percentage < 0) {
this.percentage = 0;
}
}
}
}
</script>
```
:::

### Attributes
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|------------- |---------------- |---------------- |---------------------- |-------- |
| **percentage** | **百分比(必填)** | number | 0-100 | 0 |
| type | 进度条类型 | string | line/circle | line |
| **percentage** | **百分比(必填)** | number | 0-100 | 0 |
| type | 进度条类型 | string | line/circle/dashboard | line |
| stroke-width | 进度条的宽度,单位 px | number || 6 |
| text-inside | 进度条显示文字内置在进度条内(只在 type=line 时可用) | boolean || false |
| status | 进度条当前状态 | string | success/exception ||
| status | 进度条当前状态 | string | success/exception/warning ||
| color | 进度条背景色(会覆盖 status 状态颜色) | string |||
| width | 环形进度条画布宽度(只在 type=circle 时可用) | number | | 126 |
| width | 环形进度条画布宽度(只在 typecircle 或 dashboard 时可用) | number | | 126 |
| show-text | 是否显示进度条文字内容 | boolean || true |
Loading

0 comments on commit 069b9f7

Please sign in to comment.