2021-05-05 17:23:23 +00:00
|
|
|
<template>
|
|
|
|
<div :class="labelClass" :style="labelStyle" :title="description">
|
2022-06-20 09:39:22 +00:00
|
|
|
<span v-if="icon" class="label-action--button">
|
2021-12-01 05:03:18 +00:00
|
|
|
<fluent-icon :icon="icon" size="12" class="label--icon" />
|
2022-06-20 09:39:22 +00:00
|
|
|
</span>
|
|
|
|
<span
|
2022-12-19 16:54:20 +00:00
|
|
|
v-if="variant === 'smooth' && title && !icon"
|
2022-06-20 09:39:22 +00:00
|
|
|
:style="{ background: color }"
|
|
|
|
class="label-color-dot"
|
|
|
|
/>
|
2021-05-05 17:23:23 +00:00
|
|
|
<span v-if="!href">{{ title }}</span>
|
|
|
|
<a v-else :href="href" :style="anchorStyle">{{ title }}</a>
|
2021-12-01 05:03:18 +00:00
|
|
|
<button
|
|
|
|
v-if="showClose"
|
2022-06-20 09:39:22 +00:00
|
|
|
class="label-close--button "
|
2021-12-01 05:03:18 +00:00
|
|
|
:style="{ color: textColor }"
|
|
|
|
@click="onClick"
|
|
|
|
>
|
|
|
|
<fluent-icon icon="dismiss" size="12" class="close--icon" />
|
|
|
|
</button>
|
2021-05-05 17:23:23 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
2021-05-24 07:13:03 +00:00
|
|
|
import { getContrastingTextColor } from '@chatwoot/utils';
|
2021-12-01 05:03:18 +00:00
|
|
|
|
2021-05-05 17:23:23 +00:00
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
title: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
description: {
|
|
|
|
type: String,
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
href: {
|
|
|
|
type: String,
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
bgColor: {
|
|
|
|
type: String,
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
small: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
showClose: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
icon: {
|
|
|
|
type: String,
|
|
|
|
default: '',
|
|
|
|
},
|
2022-06-20 09:39:22 +00:00
|
|
|
color: {
|
|
|
|
type: String,
|
|
|
|
default: '',
|
|
|
|
},
|
2021-05-05 17:23:23 +00:00
|
|
|
colorScheme: {
|
|
|
|
type: String,
|
|
|
|
default: '',
|
|
|
|
},
|
2022-06-20 09:39:22 +00:00
|
|
|
variant: {
|
|
|
|
type: String,
|
|
|
|
default: '',
|
|
|
|
},
|
2021-05-05 17:23:23 +00:00
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
textColor() {
|
2022-06-20 09:39:22 +00:00
|
|
|
if (this.variant === 'smooth') return '';
|
|
|
|
return this.color || getContrastingTextColor(this.bgColor);
|
2021-05-05 17:23:23 +00:00
|
|
|
},
|
|
|
|
labelClass() {
|
2022-09-02 12:37:17 +00:00
|
|
|
return `label ${this.colorScheme} ${this.variant} ${
|
|
|
|
this.small ? 'small' : ''
|
|
|
|
}`;
|
2021-05-05 17:23:23 +00:00
|
|
|
},
|
|
|
|
labelStyle() {
|
|
|
|
if (this.bgColor) {
|
2021-05-27 02:54:29 +00:00
|
|
|
return {
|
|
|
|
background: this.bgColor,
|
|
|
|
color: this.textColor,
|
|
|
|
border: `1px solid ${this.bgColor}`,
|
|
|
|
};
|
2021-05-05 17:23:23 +00:00
|
|
|
}
|
|
|
|
return {};
|
|
|
|
},
|
|
|
|
anchorStyle() {
|
|
|
|
if (this.bgColor) {
|
|
|
|
return { color: this.textColor };
|
|
|
|
}
|
|
|
|
return {};
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onClick() {
|
|
|
|
this.$emit('click', this.title);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
@import '~dashboard/assets/scss/variables';
|
|
|
|
|
|
|
|
.label {
|
2021-12-01 05:03:18 +00:00
|
|
|
display: inline-flex;
|
|
|
|
align-items: center;
|
2021-05-05 17:23:23 +00:00
|
|
|
font-weight: var(--font-weight-medium);
|
|
|
|
margin-right: var(--space-smaller);
|
|
|
|
margin-bottom: var(--space-smaller);
|
2022-06-20 09:39:22 +00:00
|
|
|
padding: var(--space-smaller);
|
|
|
|
background: var(--s-50);
|
|
|
|
color: var(--s-800);
|
|
|
|
border: 1px solid var(--s-75);
|
|
|
|
height: var(--space-medium);
|
2021-05-05 17:23:23 +00:00
|
|
|
|
|
|
|
&.small {
|
2022-12-19 16:54:20 +00:00
|
|
|
font-size: var(--font-size-mini);
|
2022-06-20 09:39:22 +00:00
|
|
|
padding: var(--space-micro) var(--space-smaller);
|
|
|
|
line-height: 1.2;
|
2022-12-19 16:54:20 +00:00
|
|
|
height: var(--space-two);
|
2021-05-05 17:23:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.label--icon {
|
|
|
|
cursor: pointer;
|
2022-12-19 16:54:20 +00:00
|
|
|
}
|
|
|
|
.label-color-dot {
|
2021-12-01 05:03:18 +00:00
|
|
|
margin-right: var(--space-smaller);
|
2021-05-05 17:23:23 +00:00
|
|
|
}
|
2021-12-01 05:03:18 +00:00
|
|
|
|
2021-05-05 17:23:23 +00:00
|
|
|
&.small .label--icon,
|
|
|
|
&.small .close--icon {
|
|
|
|
font-size: var(--font-size-nano);
|
|
|
|
}
|
|
|
|
|
|
|
|
a {
|
|
|
|
font-size: var(--font-size-mini);
|
|
|
|
&:hover {
|
|
|
|
text-decoration: underline;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Color Schemes */
|
|
|
|
&.primary {
|
|
|
|
background: var(--w-100);
|
|
|
|
color: var(--w-900);
|
|
|
|
border: 1px solid var(--w-200);
|
|
|
|
a {
|
|
|
|
color: var(--w-900);
|
|
|
|
}
|
2022-09-02 12:37:17 +00:00
|
|
|
.label-color-dot {
|
|
|
|
background: var(--w-600);
|
|
|
|
}
|
2021-05-05 17:23:23 +00:00
|
|
|
}
|
|
|
|
&.secondary {
|
|
|
|
background: var(--s-100);
|
|
|
|
color: var(--s-900);
|
|
|
|
border: 1px solid var(--s-200);
|
|
|
|
a {
|
|
|
|
color: var(--s-900);
|
|
|
|
}
|
2022-09-02 12:37:17 +00:00
|
|
|
.label-color-dot {
|
|
|
|
background: var(--s-600);
|
|
|
|
}
|
2021-05-05 17:23:23 +00:00
|
|
|
}
|
|
|
|
&.success {
|
|
|
|
background: var(--g-100);
|
|
|
|
color: var(--g-900);
|
|
|
|
border: 1px solid var(--g-200);
|
|
|
|
a {
|
|
|
|
color: var(--g-900);
|
|
|
|
}
|
2022-09-02 12:37:17 +00:00
|
|
|
.label-color-dot {
|
|
|
|
background: var(--g-600);
|
|
|
|
}
|
2021-05-05 17:23:23 +00:00
|
|
|
}
|
|
|
|
&.alert {
|
|
|
|
background: var(--r-100);
|
|
|
|
color: var(--r-900);
|
|
|
|
border: 1px solid var(--r-200);
|
|
|
|
a {
|
|
|
|
color: var(--r-900);
|
|
|
|
}
|
2022-09-02 12:37:17 +00:00
|
|
|
.label-color-dot {
|
|
|
|
background: var(--r-600);
|
|
|
|
}
|
2021-05-05 17:23:23 +00:00
|
|
|
}
|
|
|
|
&.warning {
|
|
|
|
background: var(--y-100);
|
|
|
|
color: var(--y-900);
|
2022-04-11 11:57:28 +00:00
|
|
|
border: 1px solid var(--y-200);
|
2021-05-05 17:23:23 +00:00
|
|
|
a {
|
|
|
|
color: var(--y-900);
|
|
|
|
}
|
2022-09-02 12:37:17 +00:00
|
|
|
.label-color-dot {
|
|
|
|
background: var(--y-900);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&.smooth {
|
|
|
|
background: transparent;
|
2022-12-17 21:11:28 +00:00
|
|
|
border: 1px solid var(--s-100);
|
|
|
|
color: var(--s-700);
|
2021-05-05 17:23:23 +00:00
|
|
|
}
|
|
|
|
}
|
2021-12-01 05:03:18 +00:00
|
|
|
|
2022-06-20 09:39:22 +00:00
|
|
|
.label-close--button {
|
|
|
|
color: var(--s-800);
|
|
|
|
margin-bottom: var(--space-minus-micro);
|
|
|
|
margin-left: var(--space-smaller);
|
|
|
|
border-radius: var(--border-radius-small);
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
background: var(--s-100);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-01 05:03:18 +00:00
|
|
|
.label-action--button {
|
2022-12-19 16:54:20 +00:00
|
|
|
display: flex;
|
|
|
|
margin-right: var(--space-smaller);
|
2021-12-01 05:03:18 +00:00
|
|
|
}
|
2022-06-20 09:39:22 +00:00
|
|
|
|
|
|
|
.label-color-dot {
|
|
|
|
display: inline-block;
|
2022-12-19 16:54:20 +00:00
|
|
|
width: var(--space-slab);
|
|
|
|
height: var(--space-slab);
|
2022-06-20 09:39:22 +00:00
|
|
|
border-radius: var(--border-radius-small);
|
|
|
|
margin-right: var(--space-smaller);
|
2022-12-19 16:54:20 +00:00
|
|
|
box-shadow: var(--shadow-small);
|
|
|
|
}
|
|
|
|
.label.small .label-color-dot {
|
|
|
|
width: var(--space-small);
|
|
|
|
height: var(--space-small);
|
|
|
|
border-radius: var(--border-radius-small);
|
|
|
|
box-shadow: var(--shadow-small);
|
2022-06-20 09:39:22 +00:00
|
|
|
}
|
2021-05-05 17:23:23 +00:00
|
|
|
</style>
|