mirror of https://github.com/ElemeFE/element
support tag color property
parent
998dcce225
commit
8917704392
|
@ -34,7 +34,7 @@ Used for marking and selection.
|
||||||
|
|
||||||
### Basic usage
|
### Basic usage
|
||||||
|
|
||||||
::: demo Use the `type` attribute to define Tag's type.
|
::: demo Use the `type` attribute to define Tag's type. In addition, the `color` attribute can be used to set the background color of the Tag.
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<el-tag>Tag One</el-tag>
|
<el-tag>Tag One</el-tag>
|
||||||
|
@ -93,6 +93,7 @@ Used for marking and selection.
|
||||||
| closable | whether Tab can be removed | boolean | — | false |
|
| closable | whether Tab can be removed | boolean | — | false |
|
||||||
| close-transition | whether the removal animation is disabled | boolean | — | false |
|
| close-transition | whether the removal animation is disabled | boolean | — | false |
|
||||||
| hit | whether Tag has a highlighted border | boolean | — | false |
|
| hit | whether Tag has a highlighted border | boolean | — | false |
|
||||||
|
| color | background color of the tag | string | — | — |
|
||||||
|
|
||||||
|
|
||||||
### Events
|
### Events
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
|
|
||||||
### 基础用法
|
### 基础用法
|
||||||
|
|
||||||
:::demo 由`type`属性来定义,该属性可选填。
|
:::demo 由`type`属性来选择tag的类型,也可以通过`color`属性来自定义背景色。
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<el-tag>标签一</el-tag>
|
<el-tag>标签一</el-tag>
|
||||||
|
@ -93,6 +93,7 @@
|
||||||
| closable | 是否可关闭 | boolean | — | false |
|
| closable | 是否可关闭 | boolean | — | false |
|
||||||
| close-transition | 是否禁用关闭时的渐变动画 | boolean | — | false |
|
| close-transition | 是否禁用关闭时的渐变动画 | boolean | — | false |
|
||||||
| hit | 是否有边框描边 | boolean | — | false |
|
| hit | 是否有边框描边 | boolean | — | false |
|
||||||
|
| color | 背景色 | string | — | — |
|
||||||
|
|
||||||
|
|
||||||
### Events
|
### Events
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
<transition :name="closeTransition ? '' : 'el-zoom-in-center'">
|
<transition :name="closeTransition ? '' : 'el-zoom-in-center'">
|
||||||
<span
|
<span
|
||||||
class="el-tag"
|
class="el-tag"
|
||||||
:class="[type ? 'el-tag--' + type : '', {'is-hit': hit}]">
|
:class="[type ? 'el-tag--' + type : '', {'is-hit': hit}]"
|
||||||
|
:style="{backgroundColor: color}">
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
<i class="el-tag__close el-icon-close"
|
<i class="el-tag__close el-icon-close"
|
||||||
v-if="closable"
|
v-if="closable"
|
||||||
|
@ -18,7 +19,8 @@
|
||||||
closable: Boolean,
|
closable: Boolean,
|
||||||
type: String,
|
type: String,
|
||||||
hit: Boolean,
|
hit: Boolean,
|
||||||
closeTransition: Boolean
|
closeTransition: Boolean,
|
||||||
|
color: String
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleClose(event) {
|
handleClose(event) {
|
||||||
|
|
|
@ -440,7 +440,6 @@
|
||||||
-------------------------- */
|
-------------------------- */
|
||||||
--tag-padding: 0 5px;
|
--tag-padding: 0 5px;
|
||||||
--tag-fill: var(--border-color-hover);
|
--tag-fill: var(--border-color-hover);
|
||||||
--tag-border: var(--border-color-hover);
|
|
||||||
--tag-color: var(--color-white);
|
--tag-color: var(--color-white);
|
||||||
--tag-close-color: #666;
|
--tag-close-color: #666;
|
||||||
--tag-font-size: 12px;
|
--tag-font-size: 12px;
|
||||||
|
|
|
@ -7,12 +7,13 @@
|
||||||
background-color: var(--tag-fill);
|
background-color: var(--tag-fill);
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
padding: var(--tag-padding);
|
padding: var(--tag-padding);
|
||||||
height: 22px;
|
height: 24px;
|
||||||
line-height: @height;
|
line-height: calc(@height - 2);
|
||||||
font-size: var(--tag-font-size);
|
font-size: var(--tag-font-size);
|
||||||
color: var(--tag-color);
|
color: var(--tag-color);
|
||||||
border-radius: var(--tag-border-radius);
|
border-radius: var(--tag-border-radius);
|
||||||
border: 1px solid var(--tag-border);
|
box-sizing: border-box;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
|
||||||
& .el-icon-close {
|
& .el-icon-close {
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
|
|
|
@ -78,4 +78,13 @@ describe('Tag', () => {
|
||||||
}, true);
|
}, true);
|
||||||
expect(vm.$el.classList.contains('md-fade-center')).to.be.false;
|
expect(vm.$el.classList.contains('md-fade-center')).to.be.false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('color', () => {
|
||||||
|
vm = createVue({
|
||||||
|
template: `
|
||||||
|
<el-tag color="rgb(0, 0, 0)"></el-tag>
|
||||||
|
`
|
||||||
|
}, true);
|
||||||
|
expect(vm.$el.style.backgroundColor).to.equal('rgb(0, 0, 0)');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue