Tag add type props,and optimize style

Tag add type props,and optimize style
This commit is contained in:
梁灏 2016-11-02 17:41:16 +08:00
parent a901da64ed
commit 382c000c8f
8 changed files with 146 additions and 17 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,7 +1,6 @@
<template>
<div v-if="!closed" :class="classes" transition="fade">
<span :class="textClasses"><slot></slot></span>
<Icon v-if="closable" type="ios-close-empty" @click="close"></Icon>
<span :class="dotClasses" v-if="showDot"></span><span :class="textClasses"><slot></slot></span><Icon v-if="closable" type="ios-close-empty" @click="close"></Icon>
</div>
</template>
<script>
@ -21,6 +20,11 @@
validator (value) {
return oneOf(value, ['blue', 'green', 'red', 'yellow']);
}
},
type: {
validator (value) {
return oneOf(value, ['border', 'dot']);
}
}
},
data () {
@ -33,12 +37,20 @@
return [
`${prefixCls}`,
{
[`${prefixCls}-${this.color}`]: !!this.color
[`${prefixCls}-${this.color}`]: !!this.color,
[`${prefixCls}-${this.type}`]: !!this.type,
[`${prefixCls}-closable`]: this.closable
}
]
},
textClasses () {
return `${prefixCls}-text`;
},
dotClasses () {
return `${prefixCls}-dot-inner`;
},
showDot () {
return !!this.type && this.type === 'dot';
}
},
methods: {

View file

@ -7,8 +7,8 @@
line-height: 22px;
margin: 2px 4px 2px 0;
padding: 0 8px;
border-radius: @btn-border-radius-small;
border: 1px solid @border-color-split;
border-radius: @btn-border-radius-small;
background: @background-color-base;
font-size: @tag-font-size;
vertical-align: middle;
@ -17,6 +17,77 @@
cursor: pointer;
//.transition(all @transition-time @ease-in-out);
&-dot{
height: 32px;
line-height: 32px;
border: 1px solid @border-color-split !important;
color: @text-color !important;
background: #fff !important;
padding: 0 12px;
&-inner{
display: inline-block;
width: 12px;
height: 12px;
margin-right: 8px;
border-radius: 50%;
background: @border-color-split;
position: relative;
top: 1px;
}
.@{tag-close-prefix-cls} {
color: #666 !important;
margin-left: 12px !important;
}
}
&-border{
height: 24px;
line-height: 24px;
border: 1px solid @border-color-split !important;
color: @text-color !important;
background: #fff !important;
position: relative;
.@{tag-close-prefix-cls} {
color: #666 !important;
margin-left: 12px !important;
}
&:after{
content: "";
display: none;
width: 1px;
background: @border-color-split;
position: absolute;
top: 0;
bottom: 0;
right: 22px;
}
&.@{tag-prefix-cls}-closable {
&:after{
display: block;
}
.@{tag-close-prefix-cls} {
margin-left: 18px !important;
}
}
&.@{tag-prefix-cls}-blue {
color: @link-color !important;
}
&.@{tag-prefix-cls}-green {
color: @success-color !important;
}
&.@{tag-prefix-cls}-yellow {
color: @warning-color !important;
}
&.@{tag-prefix-cls}-red {
color: @error-color !important;
}
}
&:hover {
opacity: 0.85;
}
@ -38,7 +109,7 @@
.@{tag-close-prefix-cls} {
.iconfont-size-under-12px(20px);
cursor: pointer;
margin-left: 3px;
margin-left: 8px;
color: #666;
opacity: 0.66;
position: relative;
@ -64,25 +135,27 @@
}
}
&-blue {
&-blue,
&-blue&-dot &-dot-inner
{
background: @link-color;
}
&-green {
&-green,
&-green&-dot &-dot-inner
{
background: @success-color;
}
&-yellow {
&-yellow,
&-yellow&-dot &-dot-inner
{
background: @warning-color;
}
&-red {
&-red,
&-red&-dot &-dot-inner
{
background: @error-color;
}
&-close {
width: 0 !important;
padding: 0;
margin: 0;
}
}

View file

@ -37,6 +37,7 @@ li + li {
<li><a v-link="'/step'">Step</a></li>
<li><a v-link="'/switch'">Switch</a></li>
<li><a v-link="'/alert'">Alert</a></li>
<li><a v-link="'/tag'">Tag</a></li>
</ul>
</nav>
<router-view></router-view>

View file

@ -75,6 +75,11 @@ router.map({
component: function (resolve) {
require(['./routers/alert.vue'], resolve);
}
},
'/tag': {
component: function (resolve) {
require(['./routers/tag.vue'], resolve);
}
}
});

View file

@ -5,6 +5,7 @@
<Page :total="40" size="small"></Page>
<Page :total="40" size="small" show-elevator show-sizer></Page>
<Page :total="40" size="small" show-total></Page>
<Page :total="100" show-sizer :page-size="5" :page-size-opts="[5,10,15,20]"></Page>
</template>
<script>
import { Modal, Button, Message, Page } from 'iview';

37
test/routers/tag.vue Normal file
View file

@ -0,0 +1,37 @@
<template>
<Tag>标签一</Tag>
<Tag>标签二</Tag>
<Tag closable>标签三</Tag>
<Tag closable color="blue">标签一</Tag>
<Tag closable color="green">标签二</Tag>
<Tag closable color="red">标签三</Tag>
<Tag closable color="yellow">标签四</Tag>
<br><br>
<Tag type="dot">标签一</Tag>
<Tag type="dot" closable>标签一</Tag>
<Tag type="dot" color="blue">标签一</Tag>
<Tag type="dot" color="blue" closable>标签一</Tag>
<Tag type="dot" color="green">标签一</Tag>
<Tag type="dot" color="green" closable>标签一</Tag>
<Tag type="dot" color="red">标签一</Tag>
<Tag type="dot" color="red" closable>标签一</Tag>
<Tag type="dot" color="yellow">标签一</Tag>
<Tag type="dot" color="yellow" closable>标签一</Tag>
<br><br>
<Tag type="border">标签一</Tag>
<Tag type="border" closable>标签一</Tag>
<Tag type="border" color="blue">标签一</Tag>
<Tag type="border" color="blue" closable>标签一</Tag>
<Tag type="border" color="green">标签一</Tag>
<Tag type="border" color="green" closable>标签一</Tag>
<Tag type="border" color="red">标签一</Tag>
<Tag type="border" color="red" closable>标签一</Tag>
<Tag type="border" color="yellow">标签一</Tag>
<Tag type="border" color="yellow" closable>标签一</Tag>
</template>
<script>
import { Tag } from 'iview';
export default {
components: { Tag }
}
</script>