uni-badge.vue 2.1 KB
Newer Older
郭胜强 已提交
1
<template>
2
	<text class="uni-badge" v-if="text" :class="setClass" @click="onClick()">{{text}}</text>
郭胜强 已提交
3 4 5 6 7
</template>

<script>
	export default {
		props: {
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
			type: {
				type: String,
				default: 'default'
			},
			inverted: {
				type: Boolean,
				default: false
			},
			text: {
				type: String,
				default: ''
			}
		},
		computed: {
			setClass() {
				let classList = ['uni-badge-' + this.type];
				if (this.inverted === true) {
					classList.push('uni-badge-inverted')
				}
				return classList.join(" ")
			}
郭胜强 已提交
29 30 31 32 33 34 35 36 37 38
		},
		methods: {
			onClick() {
				this.$emit('click')
			}
		}
	}
</script>

<style>
39 40 41
	.uni-badge,
	.uni-badge-default {
		font-family: 'Helvetica Neue', Helvetica, sans-serif;
郭胜强 已提交
42 43 44 45 46 47 48 49
		box-sizing: border-box;
		font-size: 12px;
		line-height: 1;
		display: inline-block;
		padding: 3px 6px;
		color: #333;
		border-radius: 100px;
	}
50

郭胜强 已提交
51 52 53 54 55
	.uni-badge.uni-badge-inverted {
		padding: 0 5px 0 0;
		color: #929292;
		background-color: transparent
	}
56

郭胜强 已提交
57 58 59 60
	.uni-badge-primary {
		color: #fff;
		background-color: #007aff
	}
61

郭胜强 已提交
62 63 64 65 66
	.uni-badge-blue.uni-badge-inverted,
	.uni-badge-primary.uni-badge-inverted {
		color: #007aff;
		background-color: transparent
	}
67

郭胜强 已提交
68 69 70 71 72
	.uni-badge-green,
	.uni-badge-success {
		color: #fff;
		background-color: #4cd964;
	}
73

郭胜强 已提交
74 75 76 77 78
	.uni-badge-green.uni-badge-inverted,
	.uni-badge-success.uni-badge-inverted {
		color: #4cd964;
		background-color: transparent
	}
79

郭胜强 已提交
80 81 82 83 84
	.uni-badge-warning,
	.uni-badge-yellow {
		color: #fff;
		background-color: #f0ad4e
	}
85

郭胜强 已提交
86 87 88 89 90
	.uni-badge-warning.uni-badge-inverted,
	.uni-badge-yellow.uni-badge-inverted {
		color: #f0ad4e;
		background-color: transparent
	}
91

郭胜强 已提交
92 93 94 95 96
	.uni-badge-danger,
	.uni-badge-red {
		color: #fff;
		background-color: #dd524d
	}
97

郭胜强 已提交
98 99 100 101 102
	.uni-badge-danger.uni-badge-inverted,
	.uni-badge-red.uni-badge-inverted {
		color: #dd524d;
		background-color: transparent
	}
103

郭胜强 已提交
104 105 106 107 108
	.uni-badge-purple,
	.uni-badge-royal {
		color: #fff;
		background-color: #8a6de9
	}
109

郭胜强 已提交
110 111 112 113 114
	.uni-badge-purple.uni-badge-inverted,
	.uni-badge-royal.uni-badge-inverted {
		color: #8a6de9;
		background-color: transparent
	}
115
</style>