2021-08-26 10:55:19 +00:00
|
|
|
<template>
|
2022-04-25 23:26:57 +00:00
|
|
|
<div
|
|
|
|
class="tag-wrapper rounded d-inline-flex"
|
|
|
|
:class="{ 'px-3': size == 'normal',
|
|
|
|
'py-1': size == 'normal',
|
|
|
|
'm-2': size == 'normal',
|
|
|
|
'px-2': size == 'sm',
|
|
|
|
'py-0': size == 'sm',
|
2023-04-04 18:09:36 +00:00
|
|
|
'mx-1': size == 'sm',
|
2022-04-25 23:26:57 +00:00
|
|
|
}"
|
|
|
|
:style="{ backgroundColor: item.color, fontSize: size == 'sm' ? '0.7em' : '1em' }"
|
2021-08-26 10:55:19 +00:00
|
|
|
>
|
|
|
|
<span class="tag-text">{{ displayText }}</span>
|
|
|
|
<span v-if="remove != null" class="ps-1 btn-remove" @click="remove(item)">
|
|
|
|
<font-awesome-icon icon="times" />
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2022-12-27 22:27:23 +00:00
|
|
|
/**
|
2023-08-11 07:46:41 +00:00
|
|
|
* @typedef {import('./TagsManager.vue').Tag} Tag
|
|
|
|
*/
|
2022-12-27 22:27:23 +00:00
|
|
|
|
2021-08-26 10:55:19 +00:00
|
|
|
export default {
|
|
|
|
props: {
|
2023-08-11 07:46:41 +00:00
|
|
|
/**
|
|
|
|
* Object representing tag
|
2022-12-27 22:27:23 +00:00
|
|
|
* @type {Tag}
|
|
|
|
*/
|
2021-08-26 10:55:19 +00:00
|
|
|
item: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
2022-06-01 23:32:05 +00:00
|
|
|
/** Function to remove tag */
|
2021-08-26 10:55:19 +00:00
|
|
|
remove: {
|
|
|
|
type: Function,
|
|
|
|
default: null,
|
|
|
|
},
|
2022-06-01 23:32:05 +00:00
|
|
|
/**
|
|
|
|
* Size of tag
|
2022-12-27 22:27:23 +00:00
|
|
|
* @type {"normal" | "small"}
|
2022-06-01 23:32:05 +00:00
|
|
|
*/
|
2021-08-26 10:55:19 +00:00
|
|
|
size: {
|
|
|
|
type: String,
|
|
|
|
default: "normal",
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
displayText() {
|
2022-05-26 08:52:18 +00:00
|
|
|
if (this.item.value === "" || this.item.value === undefined) {
|
2021-08-26 10:55:19 +00:00
|
|
|
return this.item.name;
|
|
|
|
} else {
|
|
|
|
return `${this.item.name}: ${this.item.value}`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-04-13 16:30:32 +00:00
|
|
|
};
|
2021-08-26 10:55:19 +00:00
|
|
|
</script>
|
|
|
|
|
2021-09-06 06:15:23 +00:00
|
|
|
<style lang="scss" scoped>
|
2021-08-26 10:55:19 +00:00
|
|
|
.tag-wrapper {
|
|
|
|
color: white;
|
2021-09-06 06:15:23 +00:00
|
|
|
opacity: 0.85;
|
|
|
|
|
|
|
|
.dark & {
|
|
|
|
opacity: 1;
|
|
|
|
}
|
2021-08-26 10:55:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.tag-text {
|
|
|
|
padding-bottom: 1px !important;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
overflow: hidden;
|
|
|
|
white-space: nowrap;
|
|
|
|
}
|
|
|
|
|
|
|
|
.btn-remove {
|
|
|
|
font-size: 0.9em;
|
|
|
|
line-height: 24px;
|
|
|
|
opacity: 0.3;
|
|
|
|
}
|
|
|
|
|
|
|
|
.btn-remove:hover {
|
|
|
|
opacity: 1;
|
|
|
|
}
|
|
|
|
</style>
|