platypush/platypush/backend/http/webapp/src/components/elements/DropdownItem.vue

89 lines
1.4 KiB
Vue
Raw Normal View History

2020-12-26 15:03:12 +01:00
<template>
2021-07-20 01:35:21 +02:00
<div class="row item" :class="itemClass" @click="clicked">
<div class="col-2 icon" v-if="iconClass?.length || iconUrl?.length">
<Icon :class="iconClass" :url="iconUrl" />
2020-12-26 15:03:12 +01:00
</div>
<div class="text" :class="{'col-10': iconClass != null}" v-text="text" />
2020-12-26 15:03:12 +01:00
</div>
</template>
<script>
import Icon from "@/components/elements/Icon";
2020-12-26 15:03:12 +01:00
export default {
name: "DropdownItem",
components: {Icon},
2020-12-26 15:03:12 +01:00
props: {
iconClass: {
type: String,
},
iconUrl: {
type: String,
},
2020-12-26 15:03:12 +01:00
text: {
type: String,
},
disabled: {
type: Boolean,
default: false,
},
2021-07-20 01:35:21 +02:00
itemClass: {
type: String,
}
2020-12-26 15:03:12 +01:00
},
methods: {
clicked(event) {
if (this.disabled)
return false
2020-12-26 15:03:12 +01:00
this.$parent.$emit('click', event)
if (!this.$parent.keepOpenOnItemClick)
this.$parent.visible = false
2020-12-26 15:03:12 +01:00
}
}
}
</script>
<style lang="scss" scoped>
.item {
display: flex;
padding: .5em .25em;
cursor: pointer;
align-items: center;
&:hover {
background: $hover-bg;
}
&.selected {
font-weight: bold;
}
2020-12-26 15:03:12 +01:00
&.disabled {
color: $dropdown-disabled-color;
cursor: initial;
}
.icon {
display: inline-flex;
align-items: center;
max-width: 2em;
}
::v-deep(.icon-container) {
width: 2em;
display: inline-flex;
align-items: center;
.icon {
margin: 0 1.5em 0 .5em;
}
2020-12-26 15:03:12 +01:00
}
}
</style>