Result: add result component (#21171)
This commit is contained in:
parent
6bbc046563
commit
09e789bad2
|
@ -85,5 +85,6 @@
|
|||
"skeleton-item": "./packages/skeleton-item/index.js",
|
||||
"empty": "./packages/empty/index.js",
|
||||
"descriptions": "./packages/descriptions/index.js",
|
||||
"descriptions-item": "./packages/descriptions-item/index.js"
|
||||
"descriptions-item": "./packages/descriptions-item/index.js",
|
||||
"result": "./packages/result/index.js"
|
||||
}
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
## Result
|
||||
|
||||
Used to give feedback on the result of user's operation or access exception.
|
||||
|
||||
### Basic usage
|
||||
|
||||
:::demo
|
||||
|
||||
```html
|
||||
<el-row>
|
||||
<el-col :sm="12" :lg="6">
|
||||
<el-result icon="success" title="Success Tip" subTitle="Please follow the instructions">
|
||||
<template slot="extra">
|
||||
<el-button type="primary" size="medium">Back</el-button>
|
||||
</template>
|
||||
</el-result>
|
||||
</el-col>
|
||||
<el-col :sm="12" :lg="6">
|
||||
<el-result icon="warning" title="Warning Tip" subTitle="Please follow the instructions">
|
||||
<template slot="extra">
|
||||
<el-button type="primary" size="medium">Back</el-button>
|
||||
</template>
|
||||
</el-result>
|
||||
</el-col>
|
||||
<el-col :sm="12" :lg="6">
|
||||
<el-result icon="error" title="Error Tip" subTitle="Please follow the instructions">
|
||||
<template slot="extra">
|
||||
<el-button type="primary" size="medium">Back</el-button>
|
||||
</template>
|
||||
</el-result>
|
||||
</el-col>
|
||||
<el-col :sm="12" :lg="6">
|
||||
<el-result icon="info" title="Info Tip" subTitle="Please follow the instructions">
|
||||
<template slot="extra">
|
||||
<el-button type="primary" size="medium">Back</el-button>
|
||||
</template>
|
||||
</el-result>
|
||||
</el-col>
|
||||
</el-row>
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
### Customized content
|
||||
|
||||
:::demo
|
||||
|
||||
```html
|
||||
<el-result title="404" subTitle="Sorry, request error">
|
||||
<template slot="icon">
|
||||
<el-image src="https://shadow.elemecdn.com/app/element/hamburger.9cf7b091-55e9-11e9-a976-7f4d0b07eef6.png"></el-image>
|
||||
</template>
|
||||
<template slot="extra">
|
||||
<el-button type="primary" size="medium">Back</el-button>
|
||||
</template>
|
||||
</el-result>
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
### Result Attributes
|
||||
|
||||
| Attribute | Description | Type | Accepted Values | Default |
|
||||
|------------- |---------------- |---------------- |---------------------- |-------- |
|
||||
| title | title | string | — | — |
|
||||
| sub-title | sub title | string | — | — |
|
||||
| icon | icon type | string | success / warning / info / error | info |
|
||||
|
||||
### Result Slots
|
||||
|
||||
| Name | Description |
|
||||
|------|--------|
|
||||
| icon | custom icon |
|
||||
| title | custom title |
|
||||
| subTitle | custom sub title |
|
||||
| extra | custom extra area |
|
|
@ -0,0 +1,76 @@
|
|||
## Result
|
||||
|
||||
Used to give feedback on the result of user's operation or access exception.
|
||||
|
||||
### Basic usage
|
||||
|
||||
:::demo
|
||||
|
||||
```html
|
||||
<el-row>
|
||||
<el-col :sm="12" :lg="6">
|
||||
<el-result icon="success" title="Success Tip" subTitle="Please follow the instructions">
|
||||
<template slot="extra">
|
||||
<el-button type="primary" size="medium">Back</el-button>
|
||||
</template>
|
||||
</el-result>
|
||||
</el-col>
|
||||
<el-col :sm="12" :lg="6">
|
||||
<el-result icon="warning" title="Warning Tip" subTitle="Please follow the instructions">
|
||||
<template slot="extra">
|
||||
<el-button type="primary" size="medium">Back</el-button>
|
||||
</template>
|
||||
</el-result>
|
||||
</el-col>
|
||||
<el-col :sm="12" :lg="6">
|
||||
<el-result icon="error" title="Error Tip" subTitle="Please follow the instructions">
|
||||
<template slot="extra">
|
||||
<el-button type="primary" size="medium">Back</el-button>
|
||||
</template>
|
||||
</el-result>
|
||||
</el-col>
|
||||
<el-col :sm="12" :lg="6">
|
||||
<el-result icon="info" title="Info Tip" subTitle="Please follow the instructions">
|
||||
<template slot="extra">
|
||||
<el-button type="primary" size="medium">Back</el-button>
|
||||
</template>
|
||||
</el-result>
|
||||
</el-col>
|
||||
</el-row>
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
### Customized content
|
||||
|
||||
:::demo
|
||||
|
||||
```html
|
||||
<el-result title="404" subTitle="Sorry, request error">
|
||||
<template slot="icon">
|
||||
<el-image src="https://shadow.elemecdn.com/app/element/hamburger.9cf7b091-55e9-11e9-a976-7f4d0b07eef6.png"></el-image>
|
||||
</template>
|
||||
<template slot="extra">
|
||||
<el-button type="primary" size="medium">Back</el-button>
|
||||
</template>
|
||||
</el-result>
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
### Result Attributes
|
||||
|
||||
| Attribute | Description | Type | Accepted Values | Default |
|
||||
|------------- |---------------- |---------------- |---------------------- |-------- |
|
||||
| title | title | string | — | — |
|
||||
| sub-title | sub title | string | — | — |
|
||||
| icon | icon type | string | success / warning / info / error | info |
|
||||
|
||||
### Result Slots
|
||||
|
||||
| Name | Description |
|
||||
|------|--------|
|
||||
| icon | custom icon |
|
||||
| title | custom title |
|
||||
| subTitle | custom sub title |
|
||||
| extra | custom extra area |
|
|
@ -0,0 +1,76 @@
|
|||
## Result
|
||||
|
||||
Used to give feedback on the result of user's operation or access exception.
|
||||
|
||||
### Basic usage
|
||||
|
||||
:::demo
|
||||
|
||||
```html
|
||||
<el-row>
|
||||
<el-col :sm="12" :lg="6">
|
||||
<el-result icon="success" title="Success Tip" subTitle="Please follow the instructions">
|
||||
<template slot="extra">
|
||||
<el-button type="primary" size="medium">Back</el-button>
|
||||
</template>
|
||||
</el-result>
|
||||
</el-col>
|
||||
<el-col :sm="12" :lg="6">
|
||||
<el-result icon="warning" title="Warning Tip" subTitle="Please follow the instructions">
|
||||
<template slot="extra">
|
||||
<el-button type="primary" size="medium">Back</el-button>
|
||||
</template>
|
||||
</el-result>
|
||||
</el-col>
|
||||
<el-col :sm="12" :lg="6">
|
||||
<el-result icon="error" title="Error Tip" subTitle="Please follow the instructions">
|
||||
<template slot="extra">
|
||||
<el-button type="primary" size="medium">Back</el-button>
|
||||
</template>
|
||||
</el-result>
|
||||
</el-col>
|
||||
<el-col :sm="12" :lg="6">
|
||||
<el-result icon="info" title="Info Tip" subTitle="Please follow the instructions">
|
||||
<template slot="extra">
|
||||
<el-button type="primary" size="medium">Back</el-button>
|
||||
</template>
|
||||
</el-result>
|
||||
</el-col>
|
||||
</el-row>
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
### Customized content
|
||||
|
||||
:::demo
|
||||
|
||||
```html
|
||||
<el-result title="404" subTitle="Sorry, request error">
|
||||
<template slot="icon">
|
||||
<el-image src="https://shadow.elemecdn.com/app/element/hamburger.9cf7b091-55e9-11e9-a976-7f4d0b07eef6.png"></el-image>
|
||||
</template>
|
||||
<template slot="extra">
|
||||
<el-button type="primary" size="medium">Back</el-button>
|
||||
</template>
|
||||
</el-result>
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
### Result Attributes
|
||||
|
||||
| Attribute | Description | Type | Accepted Values | Default |
|
||||
|------------- |---------------- |---------------- |---------------------- |-------- |
|
||||
| title | title | string | — | — |
|
||||
| sub-title | sub title | string | — | — |
|
||||
| icon | icon type | string | success / warning / info / error | info |
|
||||
|
||||
### Result Slots
|
||||
|
||||
| Name | Description |
|
||||
|------|--------|
|
||||
| icon | custom icon |
|
||||
| title | custom title |
|
||||
| subTitle | custom sub title |
|
||||
| extra | custom extra area |
|
|
@ -0,0 +1,76 @@
|
|||
## Result 结果
|
||||
|
||||
用于对用户的操作结果或者异常状态做反馈。
|
||||
|
||||
### 基础用法
|
||||
|
||||
:::demo
|
||||
|
||||
```html
|
||||
<el-row>
|
||||
<el-col :sm="12" :lg="6">
|
||||
<el-result icon="success" title="成功提示" subTitle="请根据提示进行操作">
|
||||
<template slot="extra">
|
||||
<el-button type="primary" size="medium">返回</el-button>
|
||||
</template>
|
||||
</el-result>
|
||||
</el-col>
|
||||
<el-col :sm="12" :lg="6">
|
||||
<el-result icon="warning" title="警告提示" subTitle="请根据提示进行操作">
|
||||
<template slot="extra">
|
||||
<el-button type="primary" size="medium">返回</el-button>
|
||||
</template>
|
||||
</el-result>
|
||||
</el-col>
|
||||
<el-col :sm="12" :lg="6">
|
||||
<el-result icon="error" title="错误提示" subTitle="请根据提示进行操作">
|
||||
<template slot="extra">
|
||||
<el-button type="primary" size="medium">返回</el-button>
|
||||
</template>
|
||||
</el-result>
|
||||
</el-col>
|
||||
<el-col :sm="12" :lg="6">
|
||||
<el-result icon="info" title="信息提示" subTitle="请根据提示进行操作">
|
||||
<template slot="extra">
|
||||
<el-button type="primary" size="medium">返回</el-button>
|
||||
</template>
|
||||
</el-result>
|
||||
</el-col>
|
||||
</el-row>
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
### 自定义内容
|
||||
|
||||
:::demo
|
||||
|
||||
```html
|
||||
<el-result title="404" subTitle="抱歉,请求错误">
|
||||
<template slot="icon">
|
||||
<el-image src="https://shadow.elemecdn.com/app/element/hamburger.9cf7b091-55e9-11e9-a976-7f4d0b07eef6.png"></el-image>
|
||||
</template>
|
||||
<template slot="extra">
|
||||
<el-button type="primary" size="medium">返回</el-button>
|
||||
</template>
|
||||
</el-result>
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
### Result Attributes
|
||||
|
||||
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|
||||
|------------- |---------------- |---------------- |---------------------- |-------- |
|
||||
| title | 标题 | string | — | — |
|
||||
| sub-title | 二级标题 | string | — | — |
|
||||
| icon | 图标类型 | string | success / warning / info / error | info |
|
||||
|
||||
### Result Slots
|
||||
|
||||
| Name | 说明 |
|
||||
|------|--------|
|
||||
| icon | 自定义图标 |
|
||||
| title | 自定义标题 |
|
||||
| subTitle | 自定义二级标题 |
|
||||
| extra | 自定义底部额外区域 |
|
|
@ -188,6 +188,10 @@
|
|||
{
|
||||
"path": "/descriptions",
|
||||
"title": "Descriptions 描述列表"
|
||||
},
|
||||
{
|
||||
"path": "/result",
|
||||
"title": "Result 结果"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -494,6 +498,10 @@
|
|||
{
|
||||
"path": "/descriptions",
|
||||
"title": "Descriptions"
|
||||
},
|
||||
{
|
||||
"path": "/result",
|
||||
"title": "Result"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -804,6 +812,10 @@
|
|||
{
|
||||
"path": "/descriptions",
|
||||
"title": "Descriptions"
|
||||
},
|
||||
{
|
||||
"path": "/result",
|
||||
"title": "Result"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -1114,6 +1126,10 @@
|
|||
{
|
||||
"path": "/descriptions",
|
||||
"title": "Descriptions"
|
||||
},
|
||||
{
|
||||
"path": "/result",
|
||||
"title": "Result"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
import Result from './src/index.vue';
|
||||
|
||||
/* istanbul ignore next */
|
||||
Result.install = function(Vue) {
|
||||
Vue.component(Result.name, Result);
|
||||
};
|
||||
|
||||
export default Result;
|
|
@ -0,0 +1,13 @@
|
|||
<template>
|
||||
<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
|
||||
<path
|
||||
d="M24,4 C35.045695,4 44,12.954305 44,24 C44,35.045695 35.045695,44 24,44 C12.954305,44 4,35.045695 4,24 C4,12.954305 12.954305,4 24,4 Z M32.57818,15.42182 C32.0157534,14.8593933 31.1038797,14.8593933 30.541453,15.42182 L30.541453,15.42182 L24.0006789,21.9625941 L17.458547,15.42182 C16.8961203,14.8593933 15.9842466,14.8593933 15.42182,15.42182 C14.8593933,15.9842466 14.8593933,16.8961203 15.42182,17.458547 L15.42182,17.458547 L21.9639519,23.9993211 L15.42182,30.541453 C14.8593933,31.1038797 14.8593933,32.0157534 15.42182,32.57818 C15.9842466,33.1406067 16.8961203,33.1406067 17.458547,32.57818 L17.458547,32.57818 L24.0006789,26.0360481 L30.541453,32.57818 C31.1038797,33.1406067 32.0157534,33.1406067 32.57818,32.57818 C33.1406067,32.0157534 33.1406067,31.1038797 32.57818,30.541453 L32.57818,30.541453 L26.0374059,23.9993211 L32.57818,17.458547 C33.1406067,16.8961203 33.1406067,15.9842466 32.57818,15.42182 Z"
|
||||
/>
|
||||
</svg>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'IconError'
|
||||
};
|
||||
</script>
|
|
@ -0,0 +1,13 @@
|
|||
<template>
|
||||
<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
|
||||
<path
|
||||
d="M24,4 C35.045695,4 44,12.954305 44,24 C44,35.045695 35.045695,44 24,44 C12.954305,44 4,35.045695 4,24 C4,12.954305 12.954305,4 24,4 Z M24,19 L21,19 C20.1715729,19 19.5,19.6715729 19.5,20.5 C19.5,21.3284271 20.1715729,22 21,22 L21,22 L22.5,22 L22.5,31 L21,31 C20.1715729,31 19.5,31.6715729 19.5,32.5 C19.5,33.3284271 20.1715729,34 21,34 L21,34 L27,34 C27.8284271,34 28.5,33.3284271 28.5,32.5 C28.5,31.6715729 27.8284271,31 27,31 L27,31 L25.5,31 L25.5,20.5 C25.5,19.6715729 24.8284271,19 24,19 L24,19 Z M24,13 C22.8954305,13 22,13.8954305 22,15 C22,16.1045695 22.8954305,17 24,17 C25.1045695,17 26,16.1045695 26,15 C26,13.8954305 25.1045695,13 24,13 Z"
|
||||
/>
|
||||
</svg>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'IconInfo'
|
||||
};
|
||||
</script>
|
|
@ -0,0 +1,13 @@
|
|||
<template>
|
||||
<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
|
||||
<path
|
||||
d="M24,4 C35.045695,4 44,12.954305 44,24 C44,35.045695 35.045695,44 24,44 C12.954305,44 4,35.045695 4,24 C4,12.954305 12.954305,4 24,4 Z M34.5548098,16.4485711 C33.9612228,15.8504763 32.9988282,15.8504763 32.4052412,16.4485711 L32.4052412,16.4485711 L21.413757,27.5805811 L21.413757,27.5805811 L21.4034642,27.590855 C21.0097542,27.9781674 20.3766105,27.9729811 19.9892981,27.5792711 L19.9892981,27.5792711 L15.5947588,23.1121428 C15.0011718,22.514048 14.0387772,22.514048 13.4451902,23.1121428 C12.8516033,23.7102376 12.8516033,24.6799409 13.4451902,25.2780357 L13.4451902,25.2780357 L19.6260786,31.5514289 C20.2196656,32.1495237 21.1820602,32.1495237 21.7756472,31.5514289 L21.7756472,31.5514289 L34.5548098,18.614464 C35.1483967,18.0163692 35.1483967,17.0466659 34.5548098,16.4485711 Z"
|
||||
/>
|
||||
</svg>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'IconSuccess'
|
||||
};
|
||||
</script>
|
|
@ -0,0 +1,13 @@
|
|||
<template>
|
||||
<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
|
||||
<path
|
||||
d="M24,4 C35.045695,4 44,12.954305 44,24 C44,35.045695 35.045695,44 24,44 C12.954305,44 4,35.045695 4,24 C4,12.954305 12.954305,4 24,4 Z M24,31 C22.8954305,31 22,31.8954305 22,33 C22,34.1045695 22.8954305,35 24,35 C25.1045695,35 26,34.1045695 26,33 C26,31.8954305 25.1045695,31 24,31 Z M24,14 C23.1715729,14 22.5,14.6715729 22.5,15.5 L22.5,15.5 L22.5,27.5 C22.5,28.3284271 23.1715729,29 24,29 C24.8284271,29 25.5,28.3284271 25.5,27.5 L25.5,27.5 L25.5,15.5 C25.5,14.6715729 24.8284271,14 24,14 Z"
|
||||
/>
|
||||
</svg>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'IconWarning'
|
||||
};
|
||||
</script>
|
|
@ -0,0 +1,65 @@
|
|||
<template>
|
||||
<div class="el-result">
|
||||
<div class="el-result__icon">
|
||||
<slot name="icon">
|
||||
<component :is="iconElement" :class="iconElement" />
|
||||
</slot>
|
||||
</div>
|
||||
<div v-if="title || $slots.title" class="el-result__title">
|
||||
<slot name="title">
|
||||
<p>{{ title }}</p>
|
||||
</slot>
|
||||
</div>
|
||||
<div v-if="subTitle || $slots.subTitle" class="el-result__subtitle">
|
||||
<slot name="subTitle">
|
||||
<p>{{ subTitle }}</p>
|
||||
</slot>
|
||||
</div>
|
||||
<div v-if="$slots.extra" class="el-result__extra">
|
||||
<slot name="extra"></slot>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import IconSuccess from './icon-success.vue';
|
||||
import IconError from './icon-error.vue';
|
||||
import IconWarning from './icon-warning.vue';
|
||||
import IconInfo from './icon-info.vue';
|
||||
|
||||
const IconMap = {
|
||||
success: 'icon-success',
|
||||
warning: 'icon-warning',
|
||||
error: 'icon-error',
|
||||
info: 'icon-info'
|
||||
};
|
||||
|
||||
export default {
|
||||
name: 'ElResult',
|
||||
components: {
|
||||
[IconSuccess.name]: IconSuccess,
|
||||
[IconError.name]: IconError,
|
||||
[IconWarning.name]: IconWarning,
|
||||
[IconInfo.name]: IconInfo
|
||||
},
|
||||
props: {
|
||||
title: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
subTitle: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
icon: {
|
||||
type: String,
|
||||
default: 'info'
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
iconElement() {
|
||||
const icon = this.icon;
|
||||
return icon && IconMap[icon] ? IconMap[icon] : 'icon-info';
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
|
@ -6,7 +6,7 @@
|
|||
<slot v-if="loading" name="template">
|
||||
<el-skeleton-item
|
||||
v-for="item in rows"
|
||||
:key="item"
|
||||
:key="`${i}-${item}`"
|
||||
:class="{
|
||||
'el-skeleton__paragraph': item !== 1,
|
||||
'is-first': item === 1,
|
||||
|
|
|
@ -987,6 +987,19 @@ $--skeleton-to-color: #e6e6e6 !default;
|
|||
--------------- */
|
||||
$--svg-monochrome-grey: #DCDDE0 !default;
|
||||
|
||||
/* Result
|
||||
-------------------------- */
|
||||
$--result-padding: 40px 30px !default;
|
||||
$--result-icon-font-size: 64px !default;
|
||||
$--result-title-font-size: 20px !default;
|
||||
$--result-title-margin-top: 20px !default;
|
||||
$--result-subtitle-margin-top: 10px !default;
|
||||
$--result-extra-margin-top: 30px !default;
|
||||
$--result-info-color: $--color-info !default;
|
||||
$--result-success-color: $--color-success !default;
|
||||
$--result-warning-color: $--color-warning !default;
|
||||
$--result-danger-color: $--color-danger !default;
|
||||
|
||||
/* Break-point
|
||||
--------------------------*/
|
||||
$--sm: 768px !default;
|
||||
|
|
|
@ -83,3 +83,4 @@
|
|||
@import "./empty.scss";
|
||||
@import "./descriptions.scss";
|
||||
@import "./descriptions-item.scss";
|
||||
@import "./result.scss";
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
@import 'mixins/mixins';
|
||||
@import 'common/var';
|
||||
|
||||
@include b(result) {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
text-align: center;
|
||||
box-sizing: border-box;
|
||||
padding: $--result-padding;
|
||||
|
||||
@include e(icon) {
|
||||
svg {
|
||||
width: $--result-icon-font-size;
|
||||
height: $--result-icon-font-size;
|
||||
}
|
||||
}
|
||||
|
||||
@include e(title) {
|
||||
margin-top: $--result-title-margin-top;
|
||||
|
||||
p {
|
||||
margin: 0;
|
||||
font-size: $--result-title-font-size;
|
||||
color: $--color-text-primary;
|
||||
line-height: 1.3;
|
||||
}
|
||||
}
|
||||
|
||||
@include e(subtitle) {
|
||||
margin-top: $--result-subtitle-margin-top;
|
||||
|
||||
p {
|
||||
margin: 0;
|
||||
font-size: $--font-size-base;
|
||||
color: $--color-text-regular;
|
||||
line-height: 1.3;
|
||||
}
|
||||
}
|
||||
|
||||
@include e(extra) {
|
||||
margin-top: $--result-extra-margin-top;
|
||||
}
|
||||
|
||||
.icon-success {
|
||||
fill: $--result-success-color;
|
||||
}
|
||||
|
||||
.icon-error {
|
||||
fill: $--result-danger-color;
|
||||
}
|
||||
|
||||
.icon-info {
|
||||
fill: $--result-info-color;
|
||||
}
|
||||
|
||||
.icon-warning {
|
||||
fill: $--result-warning-color;
|
||||
}
|
||||
}
|
|
@ -87,6 +87,7 @@ import SkeletonItem from '../packages/skeleton-item/index.js';
|
|||
import Empty from '../packages/empty/index.js';
|
||||
import Descriptions from '../packages/descriptions/index.js';
|
||||
import DescriptionsItem from '../packages/descriptions-item/index.js';
|
||||
import Result from '../packages/result/index.js';
|
||||
import locale from 'element-ui/src/locale';
|
||||
import CollapseTransition from 'element-ui/src/transitions/collapse-transition';
|
||||
|
||||
|
@ -173,6 +174,7 @@ const components = [
|
|||
Empty,
|
||||
Descriptions,
|
||||
DescriptionsItem,
|
||||
Result,
|
||||
CollapseTransition
|
||||
];
|
||||
|
||||
|
@ -299,5 +301,6 @@ export default {
|
|||
SkeletonItem,
|
||||
Empty,
|
||||
Descriptions,
|
||||
DescriptionsItem
|
||||
DescriptionsItem,
|
||||
Result
|
||||
};
|
||||
|
|
|
@ -12,7 +12,7 @@ describe('Descriptions', () => {
|
|||
{
|
||||
template: `
|
||||
<el-descriptions title="title" extra="extra">
|
||||
<el-descriptions-item v-for="item in 4"></el-descriptions-item>
|
||||
<el-descriptions-item v-for="item in 4" :key="item"></el-descriptions-item>
|
||||
</el-descriptions>
|
||||
`
|
||||
},
|
||||
|
@ -29,8 +29,8 @@ describe('Descriptions', () => {
|
|||
{
|
||||
template: `
|
||||
<el-descriptions border>
|
||||
<el-descriptions-item v-for="item in 3" :label="item">{{ item }}</el-descriptions-item>
|
||||
</el-descriptions
|
||||
<el-descriptions-item v-for="item in 3" :label="item" :key="item">{{ item }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
`
|
||||
},
|
||||
true
|
||||
|
@ -44,7 +44,7 @@ describe('Descriptions', () => {
|
|||
{
|
||||
template: `
|
||||
<el-descriptions border label-class-name="label-class-name" content-class-name="content-class-name">
|
||||
<el-descriptions-item v-for="item in 3" :label="item">{{ item }}</el-descriptions-item>
|
||||
<el-descriptions-item v-for="item in 3" :label="item" :key="item">{{ item }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
`
|
||||
},
|
||||
|
@ -58,7 +58,7 @@ describe('Descriptions', () => {
|
|||
vm = createVue({
|
||||
template: `
|
||||
<el-descriptions :column="5" :border="border">
|
||||
<el-descriptions-item v-for="item in 10" :label="item">{{ item }}</el-descriptions-item>
|
||||
<el-descriptions-item v-for="item in 10" :label="item" :key="item">{{ item }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
`,
|
||||
data() {
|
||||
|
@ -79,7 +79,7 @@ describe('Descriptions', () => {
|
|||
|
||||
template: `
|
||||
<el-descriptions :column="5" :direction="direction" border>
|
||||
<el-descriptions-item v-for="item in 10" :label="item">{{ item }}</el-descriptions-item>
|
||||
<el-descriptions-item v-for="item in 10" :label="item" :key="item">{{ item }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
`,
|
||||
data() {
|
||||
|
@ -102,7 +102,7 @@ describe('Descriptions', () => {
|
|||
template: `
|
||||
<el-descriptions>
|
||||
<template slot="title">title</template>
|
||||
<el-descriptions-item v-for="item in 10" :label="item">{{ item }}</el-descriptions-item>
|
||||
<el-descriptions-item v-for="item in 10" :label="item" :key="item">{{ item }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
`
|
||||
}, true);
|
||||
|
|
|
@ -0,0 +1,120 @@
|
|||
import { createVue, destroyVM, waitImmediate } from '../util';
|
||||
|
||||
const AXIOM = 'Rem is the best girl';
|
||||
|
||||
describe('Result', () => {
|
||||
|
||||
let vm;
|
||||
afterEach(() => {
|
||||
destroyVM(vm);
|
||||
});
|
||||
|
||||
it('render test', () => {
|
||||
vm = createVue({
|
||||
template: '<el-result />'
|
||||
}, true);
|
||||
expect(vm.$el.querySelector('.el-result__icon')).to.exist;
|
||||
expect(Array.from(vm.$el.classList)).to.contain('el-result');
|
||||
});
|
||||
|
||||
it('should render title props', () => {
|
||||
vm = createVue({
|
||||
template: '<el-result :title="title"/>',
|
||||
data() {
|
||||
return {
|
||||
title: AXIOM
|
||||
};
|
||||
}
|
||||
}, true);
|
||||
expect(vm.$el.querySelector('.el-result__title').innerText).to.be.equal(AXIOM);
|
||||
});
|
||||
|
||||
it('should render sub-title props', () => {
|
||||
vm = createVue({
|
||||
template: '<el-result :sub-title="subTitle"/>',
|
||||
data() {
|
||||
return {
|
||||
subTitle: AXIOM
|
||||
};
|
||||
}
|
||||
}, true);
|
||||
expect(vm.$el.querySelector('.el-result__subtitle').innerText).to.be.equal(AXIOM);
|
||||
});
|
||||
|
||||
it('should render icon props', async() => {
|
||||
vm = createVue({
|
||||
template: '<el-result :icon="icon"/>',
|
||||
data() {
|
||||
return {
|
||||
icon: 'success'
|
||||
};
|
||||
}
|
||||
}, true);
|
||||
expect(vm.$el.querySelector('.el-result__icon svg')).to.exist;
|
||||
expect(Array.from(vm.$el.querySelector('.el-result__icon svg').classList)).to.contain('icon-success');
|
||||
vm.icon = 'error';
|
||||
await waitImmediate();
|
||||
expect(vm.$el.querySelector('.el-result__icon svg')).to.exist;
|
||||
expect(Array.from(vm.$el.querySelector('.el-result__icon svg').classList)).to.contain('icon-error');
|
||||
vm.icon = 'warning';
|
||||
await waitImmediate();
|
||||
expect(vm.$el.querySelector('.el-result__icon svg')).to.exist;
|
||||
expect(Array.from(vm.$el.querySelector('.el-result__icon svg').classList)).to.contain('icon-warning');
|
||||
vm.icon = 'info';
|
||||
await waitImmediate();
|
||||
expect(vm.$el.querySelector('.el-result__icon svg')).to.exist;
|
||||
expect(Array.from(vm.$el.querySelector('.el-result__icon svg').classList)).to.contain('icon-info');
|
||||
});
|
||||
|
||||
it('should render icon slots', () => {
|
||||
vm = createVue({
|
||||
template: '<el-result><template slot="icon">{{icon}}</template></el-result>',
|
||||
data() {
|
||||
return {
|
||||
icon: AXIOM
|
||||
};
|
||||
}
|
||||
}, true);
|
||||
expect(vm.$el.querySelector('.el-result__icon')).to.exist;
|
||||
expect(vm.$el.querySelector('.el-result__icon').innerText).to.be.equal(AXIOM);
|
||||
});
|
||||
|
||||
it('should render title slots', () => {
|
||||
vm = createVue({
|
||||
template: '<el-result><template slot="title">{{title}}</template></el-result>',
|
||||
data() {
|
||||
return {
|
||||
title: AXIOM
|
||||
};
|
||||
}
|
||||
}, true);
|
||||
expect(vm.$el.querySelector('.el-result__title')).to.exist;
|
||||
expect(vm.$el.querySelector('.el-result__title').innerText).to.be.equal(AXIOM);
|
||||
});
|
||||
|
||||
it('should render sub-title slots', () => {
|
||||
vm = createVue({
|
||||
template: '<el-result><template slot="subTitle">{{subTitle}}</template></el-result>',
|
||||
data() {
|
||||
return {
|
||||
subTitle: AXIOM
|
||||
};
|
||||
}
|
||||
}, true);
|
||||
expect(vm.$el.querySelector('.el-result__subtitle')).to.exist;
|
||||
expect(vm.$el.querySelector('.el-result__subtitle').innerText).to.be.equal(AXIOM);
|
||||
});
|
||||
|
||||
it('should render extra slots', () => {
|
||||
vm = createVue({
|
||||
template: '<el-result><template slot="extra">{{extra}}</template></el-result>',
|
||||
data() {
|
||||
return {
|
||||
extra: AXIOM
|
||||
};
|
||||
}
|
||||
}, true);
|
||||
expect(vm.$el.querySelector('.el-result__extra')).to.exist;
|
||||
expect(vm.$el.querySelector('.el-result__extra').innerText).to.be.equal(AXIOM);
|
||||
});
|
||||
});
|
|
@ -87,6 +87,7 @@ import { ElEmpty } from './empty'
|
|||
import { ElSpinner } from './spinner'
|
||||
import { ElDescriptions } from './descriptions'
|
||||
import { ElDescriptionsItem } from './descriptions-item'
|
||||
import { ElResult } from './result'
|
||||
|
||||
export interface InstallationOptions {
|
||||
locale: any,
|
||||
|
@ -371,4 +372,7 @@ export class Spinner extends ElSpinner {}
|
|||
export class Descripitions extends ElDescriptions {}
|
||||
|
||||
/** Description Item Component */
|
||||
export class DescripitionsItem extends ElDescriptionsItem {}
|
||||
export class DescripitionsItem extends ElDescriptionsItem {}
|
||||
|
||||
/** Result Component */
|
||||
export class Result extends ElResult {}
|
|
@ -0,0 +1,33 @@
|
|||
import { ElementUIComponent } from './component'
|
||||
import { VNode } from 'vue'
|
||||
|
||||
interface ElResultSlots {
|
||||
/* title slot: custom title */
|
||||
title: VNode[]
|
||||
|
||||
/* icon slot: custom icon */
|
||||
icon: VNode[]
|
||||
|
||||
/* subTitle slot: custom sub title */
|
||||
subTitle: VNode[]
|
||||
|
||||
/* extra slot: custom extra area, display on the top right */
|
||||
extra: VNode[]
|
||||
|
||||
[key: string]: VNode[]
|
||||
}
|
||||
|
||||
/** Used to give feedback on the result of user's operation or access exception. **/
|
||||
export declare class ElResult extends ElementUIComponent {
|
||||
|
||||
/* title */
|
||||
title: string
|
||||
|
||||
/* sub title */
|
||||
subTitle: string
|
||||
|
||||
/* icon type */
|
||||
icon: 'success' | 'warning' | 'info' | 'error'
|
||||
|
||||
$slots: ElResultSlots
|
||||
}
|
Loading…
Reference in New Issue