2020-01-29 21:37:25 +02:00
|
|
|
<template>
|
2023-01-15 01:30:29 +02:00
|
|
|
<div class="_panel" :class="[$style.root, { [$style.naked]: naked, [$style.thin]: thin, [$style.hideHeader]: !showHeader, [$style.scrollable]: scrollable, [$style.closed]: !showBody }]">
|
|
|
|
<header v-if="showHeader" ref="header" :class="$style.header">
|
|
|
|
<div :class="$style.title">
|
|
|
|
<span :class="$style.titleIcon"><slot name="icon"></slot></span>
|
|
|
|
<slot name="header"></slot>
|
|
|
|
</div>
|
|
|
|
<div :class="$style.headerSub">
|
|
|
|
<slot name="func" :button-style-class="$style.headerButton"></slot>
|
|
|
|
<button v-if="foldable" :class="$style.headerButton" class="_button" @click="() => showBody = !showBody">
|
2022-12-19 12:01:30 +02:00
|
|
|
<template v-if="showBody"><i class="ti ti-chevron-up"></i></template>
|
|
|
|
<template v-else><i class="ti ti-chevron-down"></i></template>
|
2020-08-13 17:02:43 +03:00
|
|
|
</button>
|
|
|
|
</div>
|
2020-01-29 21:37:25 +02:00
|
|
|
</header>
|
2022-12-30 06:37:14 +02:00
|
|
|
<Transition
|
2023-04-01 07:42:40 +03:00
|
|
|
:enter-active-class="defaultStore.state.animation ? $style.transition_toggle_enterActive : ''"
|
|
|
|
:leave-active-class="defaultStore.state.animation ? $style.transition_toggle_leaveActive : ''"
|
|
|
|
:enter-from-class="defaultStore.state.animation ? $style.transition_toggle_enterFrom : ''"
|
|
|
|
:leave-to-class="defaultStore.state.animation ? $style.transition_toggle_leaveTo : ''"
|
2020-02-08 07:31:51 +02:00
|
|
|
@enter="enter"
|
|
|
|
@after-enter="afterEnter"
|
|
|
|
@leave="leave"
|
|
|
|
@after-leave="afterLeave"
|
|
|
|
>
|
2023-01-15 23:12:43 +02:00
|
|
|
<div v-show="showBody" ref="content" :class="[$style.content, { [$style.omitted]: omitted }]">
|
2020-02-08 07:31:51 +02:00
|
|
|
<slot></slot>
|
2023-01-15 01:30:29 +02:00
|
|
|
<button v-if="omitted" :class="$style.fade" class="_button" @click="() => { ignoreOmit = true; omitted = false; }">
|
2023-04-01 08:01:57 +03:00
|
|
|
<span :class="$style.fadeLabel">{{ i18n.ts.showMore }}</span>
|
2021-04-16 03:41:56 +03:00
|
|
|
</button>
|
2020-02-08 07:31:51 +02:00
|
|
|
</div>
|
2022-12-30 06:37:14 +02:00
|
|
|
</Transition>
|
2020-01-29 21:37:25 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 14:12:00 +03:00
|
|
|
import { defineComponent } from 'vue';
|
2023-04-01 07:42:40 +03:00
|
|
|
import { defaultStore } from '@/store';
|
2023-04-01 08:01:57 +03:00
|
|
|
import { i18n } from '@/i18n';
|
2020-01-29 21:37:25 +02:00
|
|
|
|
2020-10-17 14:12:00 +03:00
|
|
|
export default defineComponent({
|
2020-01-29 21:37:25 +02:00
|
|
|
props: {
|
|
|
|
showHeader: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
2022-07-03 10:17:31 +03:00
|
|
|
default: true,
|
2020-01-29 21:37:25 +02:00
|
|
|
},
|
2021-10-22 18:04:19 +03:00
|
|
|
thin: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
2022-07-03 10:17:31 +03:00
|
|
|
default: false,
|
2021-10-22 18:04:19 +03:00
|
|
|
},
|
2020-01-29 21:37:25 +02:00
|
|
|
naked: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
2022-07-03 10:17:31 +03:00
|
|
|
default: false,
|
2020-01-29 21:37:25 +02:00
|
|
|
},
|
2021-04-16 06:17:22 +03:00
|
|
|
foldable: {
|
2020-01-29 21:37:25 +02:00
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
2022-07-03 10:17:31 +03:00
|
|
|
default: false,
|
2020-01-29 21:37:25 +02:00
|
|
|
},
|
|
|
|
expanded: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
2022-07-03 10:17:31 +03:00
|
|
|
default: true,
|
2020-01-29 21:37:25 +02:00
|
|
|
},
|
2020-07-11 04:13:11 +03:00
|
|
|
scrollable: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
2022-07-03 10:17:31 +03:00
|
|
|
default: false,
|
2020-07-11 04:13:11 +03:00
|
|
|
},
|
2021-04-16 03:41:56 +03:00
|
|
|
maxHeight: {
|
|
|
|
type: Number,
|
|
|
|
required: false,
|
2022-07-03 10:17:31 +03:00
|
|
|
default: null,
|
2021-04-16 03:41:56 +03:00
|
|
|
},
|
2020-01-29 21:37:25 +02:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
showBody: this.expanded,
|
2021-04-16 03:41:56 +03:00
|
|
|
omitted: null,
|
|
|
|
ignoreOmit: false,
|
2023-04-01 07:42:40 +03:00
|
|
|
defaultStore,
|
2020-01-29 21:37:25 +02:00
|
|
|
};
|
|
|
|
},
|
2020-08-13 11:58:16 +03:00
|
|
|
mounted() {
|
|
|
|
this.$watch('showBody', showBody => {
|
2020-10-17 14:12:00 +03:00
|
|
|
const headerHeight = this.showHeader ? this.$refs.header.offsetHeight : 0;
|
|
|
|
this.$el.style.minHeight = `${headerHeight}px`;
|
2020-08-13 11:58:16 +03:00
|
|
|
if (showBody) {
|
2022-07-03 10:17:31 +03:00
|
|
|
this.$el.style.flexBasis = 'auto';
|
2020-08-13 11:58:16 +03:00
|
|
|
} else {
|
2020-10-17 14:12:00 +03:00
|
|
|
this.$el.style.flexBasis = `${headerHeight}px`;
|
2020-08-13 11:58:16 +03:00
|
|
|
}
|
|
|
|
}, {
|
2022-07-03 10:17:31 +03:00
|
|
|
immediate: true,
|
2020-08-13 11:58:16 +03:00
|
|
|
});
|
2021-04-16 03:41:56 +03:00
|
|
|
|
|
|
|
this.$el.style.setProperty('--maxHeight', this.maxHeight + 'px');
|
|
|
|
|
|
|
|
const calcOmit = () => {
|
|
|
|
if (this.omitted || this.ignoreOmit || this.maxHeight == null) return;
|
|
|
|
const height = this.$refs.content.offsetHeight;
|
|
|
|
this.omitted = height > this.maxHeight;
|
|
|
|
};
|
|
|
|
|
|
|
|
calcOmit();
|
|
|
|
new ResizeObserver((entries, observer) => {
|
|
|
|
calcOmit();
|
|
|
|
}).observe(this.$refs.content);
|
2020-08-13 11:58:16 +03:00
|
|
|
},
|
2020-01-29 21:37:25 +02:00
|
|
|
methods: {
|
|
|
|
toggleContent(show: boolean) {
|
2021-04-16 06:17:22 +03:00
|
|
|
if (!this.foldable) return;
|
2020-01-29 21:37:25 +02:00
|
|
|
this.showBody = show;
|
2020-02-08 07:31:51 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
enter(el) {
|
2020-02-08 11:02:28 +02:00
|
|
|
const elementHeight = el.getBoundingClientRect().height;
|
|
|
|
el.style.height = 0;
|
|
|
|
el.offsetHeight; // reflow
|
|
|
|
el.style.height = elementHeight + 'px';
|
2020-02-08 07:31:51 +02:00
|
|
|
},
|
|
|
|
afterEnter(el) {
|
2020-02-08 11:02:28 +02:00
|
|
|
el.style.height = null;
|
2020-02-08 07:31:51 +02:00
|
|
|
},
|
|
|
|
leave(el) {
|
2020-02-08 11:02:28 +02:00
|
|
|
const elementHeight = el.getBoundingClientRect().height;
|
|
|
|
el.style.height = elementHeight + 'px';
|
|
|
|
el.offsetHeight; // reflow
|
|
|
|
el.style.height = 0;
|
2020-02-08 07:31:51 +02:00
|
|
|
},
|
|
|
|
afterLeave(el) {
|
2020-02-08 11:02:28 +02:00
|
|
|
el.style.height = null;
|
2020-02-08 07:31:51 +02:00
|
|
|
},
|
2022-07-03 10:17:31 +03:00
|
|
|
},
|
2020-01-29 21:37:25 +02:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2023-01-15 01:30:29 +02:00
|
|
|
<style lang="scss" module>
|
|
|
|
.transition_toggle_enterActive,
|
|
|
|
.transition_toggle_leaveActive {
|
2022-12-30 08:40:29 +02:00
|
|
|
overflow-y: clip;
|
2020-02-08 07:31:51 +02:00
|
|
|
transition: opacity 0.5s, height 0.5s !important;
|
|
|
|
}
|
2023-01-15 01:30:29 +02:00
|
|
|
.transition_toggle_enterFrom,
|
|
|
|
.transition_toggle_leaveTo {
|
2020-02-08 07:31:51 +02:00
|
|
|
opacity: 0;
|
|
|
|
}
|
|
|
|
|
2023-01-15 01:30:29 +02:00
|
|
|
.root {
|
2020-01-29 21:37:25 +02:00
|
|
|
position: relative;
|
2022-07-13 15:41:06 +03:00
|
|
|
overflow: clip;
|
2022-07-05 16:35:57 +03:00
|
|
|
contain: content;
|
2020-01-29 21:37:25 +02:00
|
|
|
|
|
|
|
&.naked {
|
|
|
|
background: transparent !important;
|
|
|
|
box-shadow: none !important;
|
|
|
|
}
|
|
|
|
|
2020-07-11 04:13:11 +03:00
|
|
|
&.scrollable {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
|
2021-04-16 03:41:56 +03:00
|
|
|
> .content {
|
2020-07-11 04:13:11 +03:00
|
|
|
overflow: auto;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-15 01:30:29 +02:00
|
|
|
&.thin {
|
|
|
|
> .header {
|
|
|
|
> .title {
|
|
|
|
padding: 8px 10px;
|
|
|
|
font-size: 0.9em;
|
2020-01-29 21:37:25 +02:00
|
|
|
}
|
|
|
|
}
|
2023-01-15 01:30:29 +02:00
|
|
|
}
|
|
|
|
}
|
2020-01-29 21:37:25 +02:00
|
|
|
|
2023-01-15 01:30:29 +02:00
|
|
|
.header {
|
|
|
|
position: sticky;
|
|
|
|
top: var(--stickyTop, 0px);
|
|
|
|
left: 0;
|
|
|
|
color: var(--panelHeaderFg);
|
|
|
|
background: var(--panelHeaderBg);
|
|
|
|
border-bottom: solid 0.5px var(--panelHeaderDivider);
|
|
|
|
z-index: 2;
|
|
|
|
line-height: 1.4em;
|
|
|
|
}
|
2020-08-13 17:02:43 +03:00
|
|
|
|
2023-01-15 01:30:29 +02:00
|
|
|
.title {
|
|
|
|
margin: 0;
|
|
|
|
padding: 12px 16px;
|
2020-07-11 04:13:11 +03:00
|
|
|
|
2023-01-15 01:30:29 +02:00
|
|
|
&:empty {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
}
|
2021-07-19 05:36:35 +03:00
|
|
|
|
2023-01-15 01:30:29 +02:00
|
|
|
.titleIcon {
|
|
|
|
margin-right: 6px;
|
|
|
|
}
|
2021-04-16 03:41:56 +03:00
|
|
|
|
2023-01-15 01:30:29 +02:00
|
|
|
.headerSub {
|
|
|
|
position: absolute;
|
|
|
|
z-index: 2;
|
|
|
|
top: 0;
|
|
|
|
right: 0;
|
|
|
|
height: 100%;
|
|
|
|
}
|
2020-08-09 09:51:02 +03:00
|
|
|
|
2023-01-15 01:30:29 +02:00
|
|
|
.headerButton {
|
|
|
|
width: 42px;
|
|
|
|
height: 100%;
|
|
|
|
}
|
2021-04-16 03:41:56 +03:00
|
|
|
|
2023-01-15 01:30:29 +02:00
|
|
|
.content {
|
|
|
|
--stickyTop: 0px;
|
2020-08-09 09:51:02 +03:00
|
|
|
|
2023-01-15 01:30:29 +02:00
|
|
|
&.omitted {
|
|
|
|
position: relative;
|
|
|
|
max-height: var(--maxHeight);
|
|
|
|
overflow: hidden;
|
2020-08-09 09:51:02 +03:00
|
|
|
|
2023-01-15 01:30:29 +02:00
|
|
|
> .fade {
|
|
|
|
display: block;
|
|
|
|
position: absolute;
|
|
|
|
z-index: 10;
|
|
|
|
bottom: 0;
|
|
|
|
left: 0;
|
|
|
|
width: 100%;
|
|
|
|
height: 64px;
|
|
|
|
background: linear-gradient(0deg, var(--panel), var(--X15));
|
2020-07-11 04:13:11 +03:00
|
|
|
|
2023-01-15 01:30:29 +02:00
|
|
|
> .fadeLabel {
|
|
|
|
display: inline-block;
|
|
|
|
background: var(--panel);
|
|
|
|
padding: 6px 10px;
|
|
|
|
font-size: 0.8em;
|
|
|
|
border-radius: 999px;
|
|
|
|
box-shadow: 0 2px 6px rgb(0 0 0 / 20%);
|
2022-12-26 01:40:13 +02:00
|
|
|
}
|
|
|
|
|
2023-01-15 01:30:29 +02:00
|
|
|
&:hover {
|
|
|
|
> .fadeLabel {
|
|
|
|
background: var(--panelHighlight);
|
|
|
|
}
|
|
|
|
}
|
2020-07-11 04:13:11 +03:00
|
|
|
}
|
|
|
|
}
|
2020-01-29 21:37:25 +02:00
|
|
|
}
|
2020-07-12 05:34:45 +03:00
|
|
|
|
2023-01-15 01:30:29 +02:00
|
|
|
@container (max-width: 380px) {
|
|
|
|
.title {
|
|
|
|
padding: 8px 10px;
|
|
|
|
font-size: 0.9em;
|
2020-07-12 05:34:45 +03:00
|
|
|
}
|
|
|
|
}
|
2020-01-29 21:37:25 +02:00
|
|
|
</style>
|