2020-06-25 15:34:03 +00:00
|
|
|
<template>
|
|
|
|
<div
|
|
|
|
:class="labelClass"
|
|
|
|
:style="{ background: bgColor, color: textColor }"
|
|
|
|
:title="description"
|
|
|
|
>
|
|
|
|
<span v-if="!href">{{ title }}</span>
|
|
|
|
<a v-else :href="href" :style="{ color: textColor }">{{ title }}</a>
|
|
|
|
<i v-if="showIcon" class="label--icon" :class="icon" @click="onClick" />
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
2020-10-18 18:02:22 +00:00
|
|
|
import { getContrastingTextColor } from 'shared/helpers/ColorHelper';
|
2020-06-25 15:34:03 +00:00
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
title: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
description: {
|
|
|
|
type: String,
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
href: {
|
|
|
|
type: String,
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
bgColor: {
|
|
|
|
type: String,
|
|
|
|
default: '#1f93ff',
|
|
|
|
},
|
|
|
|
small: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
showIcon: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
icon: {
|
|
|
|
type: String,
|
|
|
|
default: 'ion-close',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
textColor() {
|
2020-10-18 18:02:22 +00:00
|
|
|
return getContrastingTextColor(this.bgColor);
|
2020-06-25 15:34:03 +00:00
|
|
|
},
|
|
|
|
labelClass() {
|
|
|
|
return `label ${this.small ? 'small' : ''}`;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onClick() {
|
|
|
|
this.$emit('click', this.title);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
@import '~dashboard/assets/scss/variables';
|
|
|
|
|
|
|
|
.label {
|
2021-05-05 11:16:23 +00:00
|
|
|
font-weight: var(--font-weight-medium);
|
|
|
|
margin-right: var(--space-smaller);
|
|
|
|
margin-bottom: var(--space-smaller);
|
2020-06-25 15:34:03 +00:00
|
|
|
|
|
|
|
&.small {
|
2021-05-05 11:16:23 +00:00
|
|
|
font-size: var(--font-size-micro);
|
|
|
|
|
|
|
|
.label--icon {
|
|
|
|
font-size: var(--font-size-nano);
|
|
|
|
}
|
2020-06-25 15:34:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
a {
|
|
|
|
&:hover {
|
|
|
|
text-decoration: underline;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.label--icon {
|
|
|
|
cursor: pointer;
|
2021-05-05 11:16:23 +00:00
|
|
|
font-size: var(--font-size-micro);
|
2020-06-25 15:34:03 +00:00
|
|
|
}
|
|
|
|
</style>
|