2020-10-17 13:12:00 +02:00
|
|
|
<template>
|
2021-04-10 17:03:31 +02:00
|
|
|
<div class="fdidabkb" :class="{ center }" :style="`--height:${height};`" :key="key">
|
2020-12-19 02:55:52 +01:00
|
|
|
<transition :name="$store.state.animation ? 'header' : ''" mode="out-in" appear>
|
2021-08-05 15:43:14 +02:00
|
|
|
<div class="buttons left" v-if="backButton">
|
2021-08-16 11:11:15 +02:00
|
|
|
<button class="_button button back" @click.stop="$emit('back')" @touchstart="preventDrag" v-tooltip="$ts.goBack"><i class="fas fa-chevron-left"></i></button>
|
2021-08-05 15:43:14 +02:00
|
|
|
</div>
|
2020-10-17 13:12:00 +02:00
|
|
|
</transition>
|
|
|
|
<template v-if="info">
|
|
|
|
<div class="titleContainer">
|
2021-08-05 15:43:14 +02:00
|
|
|
<i v-if="info.icon" class="icon" :class="info.icon"></i>
|
|
|
|
<MkAvatar v-else-if="info.avatar" class="avatar" :user="info.avatar" :disable-preview="true" :show-indicator="true"/>
|
|
|
|
|
2020-12-29 03:33:21 +01:00
|
|
|
<div class="title">
|
2021-08-05 15:43:14 +02:00
|
|
|
<MkUserName v-if="info.userName" :user="info.userName" :nowrap="false" class="title"/>
|
|
|
|
<div v-else-if="info.title" class="title">{{ info.title }}</div>
|
|
|
|
<div class="subtitle" v-if="info.subtitle">
|
|
|
|
{{ info.subtitle }}
|
|
|
|
</div>
|
2020-12-29 03:33:21 +01:00
|
|
|
</div>
|
2020-10-17 13:12:00 +02:00
|
|
|
</div>
|
2021-08-05 15:43:14 +02:00
|
|
|
<div class="buttons right">
|
2021-04-10 06:38:24 +02:00
|
|
|
<template v-if="info.actions && showActions">
|
2021-08-16 11:11:15 +02:00
|
|
|
<button v-for="action in info.actions" class="_button button" :class="{ highlighted: action.highlighted }" @click.stop="action.handler" @touchstart="preventDrag" v-tooltip="action.text"><i :class="action.icon"></i></button>
|
2021-04-10 06:38:24 +02:00
|
|
|
</template>
|
2021-08-16 11:11:15 +02:00
|
|
|
<button v-if="shouldShowMenu" class="_button button" @click.stop="showMenu" @touchstart="preventDrag" v-tooltip="$ts.menu"><i class="fas fa-ellipsis-h"></i></button>
|
|
|
|
<button v-if="closeButton" class="_button button" @click.stop="$emit('close')" @touchstart="preventDrag" v-tooltip="$ts.close"><i class="fas fa-times"></i></button>
|
2021-04-10 06:38:24 +02:00
|
|
|
</div>
|
2020-10-17 13:12:00 +02:00
|
|
|
</template>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { defineComponent } from 'vue';
|
2021-08-08 05:19:10 +02:00
|
|
|
import { popupMenu } from '@client/os';
|
2021-04-10 16:52:45 +02:00
|
|
|
import { url } from '@client/config';
|
2020-10-17 13:12:00 +02:00
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
props: {
|
|
|
|
info: {
|
|
|
|
required: true
|
|
|
|
},
|
2021-08-05 15:43:14 +02:00
|
|
|
menu: {
|
|
|
|
required: false
|
|
|
|
},
|
|
|
|
backButton: {
|
2020-10-17 13:12:00 +02:00
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
2021-08-05 15:43:14 +02:00
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
closeButton: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
2020-10-17 13:12:00 +02:00
|
|
|
},
|
2021-02-14 14:26:07 +01:00
|
|
|
center: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: true,
|
|
|
|
},
|
2020-10-17 13:12:00 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
2021-04-10 06:38:24 +02:00
|
|
|
showActions: false,
|
2020-10-17 13:12:00 +02:00
|
|
|
height: 0,
|
2021-04-10 17:03:31 +02:00
|
|
|
key: 0,
|
2020-10-17 13:12:00 +02:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
2021-04-10 06:38:24 +02:00
|
|
|
computed: {
|
2021-08-05 15:43:14 +02:00
|
|
|
shouldShowMenu() {
|
2021-04-10 06:38:24 +02:00
|
|
|
if (this.info.actions != null && !this.showActions) return true;
|
|
|
|
if (this.info.menu != null) return true;
|
|
|
|
if (this.info.share != null) return true;
|
2021-08-05 15:43:14 +02:00
|
|
|
if (this.menu != null) return true;
|
2021-04-10 06:38:24 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-10-17 13:12:00 +02:00
|
|
|
watch: {
|
2021-04-10 17:03:31 +02:00
|
|
|
info() {
|
|
|
|
this.key++;
|
|
|
|
},
|
2020-10-17 13:12:00 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
mounted() {
|
|
|
|
this.height = this.$el.parentElement.offsetHeight + 'px';
|
2021-04-10 06:38:24 +02:00
|
|
|
this.showActions = this.$el.parentElement.offsetWidth >= 500;
|
2020-10-17 13:12:00 +02:00
|
|
|
new ResizeObserver((entries, observer) => {
|
|
|
|
this.height = this.$el.parentElement.offsetHeight + 'px';
|
2021-04-10 06:38:24 +02:00
|
|
|
this.showActions = this.$el.parentElement.offsetWidth >= 500;
|
2020-10-17 13:12:00 +02:00
|
|
|
}).observe(this.$el);
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
2021-04-10 05:40:50 +02:00
|
|
|
share() {
|
2021-04-10 16:52:45 +02:00
|
|
|
navigator.share({
|
|
|
|
url: url + this.info.path,
|
|
|
|
...this.info.share,
|
|
|
|
});
|
2021-04-10 05:40:50 +02:00
|
|
|
},
|
|
|
|
|
2021-08-05 15:43:14 +02:00
|
|
|
showMenu(ev) {
|
2021-04-11 05:31:24 +02:00
|
|
|
let menu = this.info.menu ? this.info.menu() : [];
|
|
|
|
if (!this.showActions && this.info.actions) {
|
|
|
|
menu = [...this.info.actions.map(x => ({
|
|
|
|
text: x.text,
|
|
|
|
icon: x.icon,
|
|
|
|
action: x.handler
|
|
|
|
})), menu.length > 0 ? null : undefined, ...menu];
|
|
|
|
}
|
2021-04-10 05:40:50 +02:00
|
|
|
if (this.info.share) {
|
|
|
|
if (menu.length > 0) menu.push(null);
|
|
|
|
menu.push({
|
|
|
|
text: this.$ts.share,
|
2021-04-20 16:22:59 +02:00
|
|
|
icon: 'fas fa-share-alt',
|
2021-04-10 05:40:50 +02:00
|
|
|
action: this.share
|
|
|
|
});
|
|
|
|
}
|
2021-08-05 15:43:14 +02:00
|
|
|
if (this.menu) {
|
|
|
|
if (menu.length > 0) menu.push(null);
|
|
|
|
menu = menu.concat(this.menu);
|
|
|
|
}
|
2021-08-08 05:19:10 +02:00
|
|
|
popupMenu(menu, ev.currentTarget || ev.target);
|
2021-08-16 11:11:15 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
preventDrag(ev) {
|
|
|
|
ev.stopPropagation();
|
2021-04-10 05:40:50 +02:00
|
|
|
}
|
2020-10-17 13:12:00 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2020-11-28 04:15:22 +01:00
|
|
|
<style lang="scss" scoped>
|
2020-10-17 13:12:00 +02:00
|
|
|
.fdidabkb {
|
2021-08-05 15:43:14 +02:00
|
|
|
display: flex;
|
|
|
|
|
2021-02-14 14:26:07 +01:00
|
|
|
&.center {
|
|
|
|
text-align: center;
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2021-04-10 05:40:50 +02:00
|
|
|
> .titleContainer {
|
|
|
|
margin: 0 auto;
|
|
|
|
}
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2021-08-05 15:43:14 +02:00
|
|
|
> .buttons {
|
|
|
|
&.right {
|
|
|
|
margin-left: 0;
|
|
|
|
}
|
|
|
|
}
|
2020-10-17 13:12:00 +02:00
|
|
|
}
|
|
|
|
|
2021-04-10 06:38:24 +02:00
|
|
|
> .buttons {
|
2021-08-05 15:43:14 +02:00
|
|
|
--margin: 8px;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
height: var(--height);
|
|
|
|
margin: 0 var(--margin);
|
2021-04-10 06:38:24 +02:00
|
|
|
|
2021-08-05 15:43:14 +02:00
|
|
|
&.right {
|
|
|
|
margin-left: auto;
|
|
|
|
}
|
|
|
|
|
|
|
|
&:empty {
|
2021-04-10 06:38:24 +02:00
|
|
|
width: var(--height);
|
|
|
|
}
|
2021-08-05 15:43:14 +02:00
|
|
|
|
|
|
|
> .button {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
height: calc(var(--height) - (var(--margin) * 2));
|
|
|
|
width: calc(var(--height) - (var(--margin) * 2));
|
|
|
|
box-sizing: border-box;
|
|
|
|
position: relative;
|
|
|
|
border-radius: 5px;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
background: rgba(0, 0, 0, 0.05);
|
|
|
|
}
|
|
|
|
|
|
|
|
&.highlighted {
|
|
|
|
color: var(--accent);
|
|
|
|
}
|
|
|
|
}
|
2020-10-17 13:12:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
> .titleContainer {
|
2021-08-05 15:43:14 +02:00
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
2020-10-17 13:12:00 +02:00
|
|
|
overflow: auto;
|
|
|
|
white-space: nowrap;
|
2021-08-05 15:43:14 +02:00
|
|
|
text-align: left;
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2021-08-05 15:43:14 +02:00
|
|
|
> .avatar {
|
|
|
|
$size: 32px;
|
2020-10-17 13:12:00 +02:00
|
|
|
display: inline-block;
|
2021-08-05 15:43:14 +02:00
|
|
|
width: $size;
|
|
|
|
height: $size;
|
2020-10-17 13:12:00 +02:00
|
|
|
vertical-align: bottom;
|
2021-08-05 15:43:14 +02:00
|
|
|
margin: 0 8px;
|
|
|
|
pointer-events: none;
|
|
|
|
}
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2021-08-05 15:43:14 +02:00
|
|
|
> .icon {
|
|
|
|
margin-right: 8px;
|
|
|
|
}
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2021-08-05 15:43:14 +02:00
|
|
|
> .title {
|
|
|
|
min-width: 0;
|
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
white-space: nowrap;
|
|
|
|
line-height: 1.1;
|
|
|
|
|
|
|
|
> .subtitle {
|
|
|
|
opacity: 0.6;
|
|
|
|
font-size: 0.8em;
|
|
|
|
font-weight: normal;
|
|
|
|
white-space: nowrap;
|
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
2020-10-17 13:12:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|