2020-08-09 09:51:02 +03:00
|
|
|
<template>
|
2022-12-28 02:32:22 +02:00
|
|
|
<div class="ssazuxis">
|
2021-11-19 12:36:12 +02:00
|
|
|
<header class="_button" :style="{ background: bg }" @click="showBody = !showBody">
|
2020-08-09 09:51:02 +03:00
|
|
|
<div class="title"><slot name="header"></slot></div>
|
|
|
|
<div class="divider"></div>
|
|
|
|
<button class="_button">
|
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-09 09:51:02 +03:00
|
|
|
</button>
|
|
|
|
</header>
|
2022-12-30 06:37:14 +02:00
|
|
|
<Transition
|
2022-12-24 01:46:30 +02:00
|
|
|
:name="$store.state.animation ? 'folder-toggle' : ''"
|
2020-08-09 09:51:02 +03:00
|
|
|
@enter="enter"
|
|
|
|
@after-enter="afterEnter"
|
|
|
|
@leave="leave"
|
|
|
|
@after-leave="afterLeave"
|
|
|
|
>
|
|
|
|
<div v-show="showBody">
|
|
|
|
<slot></slot>
|
|
|
|
</div>
|
2022-12-30 06:37:14 +02:00
|
|
|
</Transition>
|
2020-08-09 09:51:02 +03:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 14:12:00 +03:00
|
|
|
import { defineComponent } from 'vue';
|
2022-05-01 16:51:07 +03:00
|
|
|
import tinycolor from 'tinycolor2';
|
2023-01-07 03:13:02 +02:00
|
|
|
import { miLocalStorage } from '@/local-storage';
|
2020-08-09 09:51:02 +03:00
|
|
|
|
2023-01-07 03:13:02 +02:00
|
|
|
const miLocalStoragePrefix = 'ui:folder:' as const;
|
2020-10-17 14:12:00 +03:00
|
|
|
|
|
|
|
export default defineComponent({
|
2020-08-09 09:51:02 +03:00
|
|
|
props: {
|
|
|
|
expanded: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
2022-12-22 09:01:59 +02:00
|
|
|
default: true,
|
2020-08-09 09:51:02 +03:00
|
|
|
},
|
2020-10-17 14:12:00 +03:00
|
|
|
persistKey: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
2022-12-22 09:01:59 +02:00
|
|
|
default: null,
|
2020-10-17 14:12:00 +03:00
|
|
|
},
|
2020-08-09 09:51:02 +03:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2021-10-10 09:19:16 +03:00
|
|
|
bg: null,
|
2023-01-07 03:13:02 +02:00
|
|
|
showBody: (this.persistKey && miLocalStorage.getItem(`${miLocalStoragePrefix}${this.persistKey}`)) ? (miLocalStorage.getItem(`${miLocalStoragePrefix}${this.persistKey}`) === 't') : this.expanded,
|
2020-08-09 09:51:02 +03:00
|
|
|
};
|
|
|
|
},
|
2020-10-17 14:12:00 +03:00
|
|
|
watch: {
|
|
|
|
showBody() {
|
|
|
|
if (this.persistKey) {
|
2023-01-07 03:13:02 +02:00
|
|
|
miLocalStorage.setItem(`${miLocalStoragePrefix}${this.persistKey}`, this.showBody ? 't' : 'f');
|
2020-10-17 14:12:00 +03:00
|
|
|
}
|
2022-12-22 09:01:59 +02:00
|
|
|
},
|
2020-10-17 14:12:00 +03:00
|
|
|
},
|
2021-10-10 09:19:16 +03:00
|
|
|
mounted() {
|
|
|
|
function getParentBg(el: Element | null): string {
|
|
|
|
if (el == null || el.tagName === 'BODY') return 'var(--bg)';
|
|
|
|
const bg = el.style.background || el.style.backgroundColor;
|
|
|
|
if (bg) {
|
|
|
|
return bg;
|
|
|
|
} else {
|
|
|
|
return getParentBg(el.parentElement);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const rawBg = getParentBg(this.$el);
|
|
|
|
const bg = tinycolor(rawBg.startsWith('var(') ? getComputedStyle(document.documentElement).getPropertyValue(rawBg.slice(4, -1)) : rawBg);
|
|
|
|
bg.setAlpha(0.85);
|
|
|
|
this.bg = bg.toRgbString();
|
|
|
|
},
|
2020-08-09 09:51:02 +03:00
|
|
|
methods: {
|
|
|
|
toggleContent(show: boolean) {
|
|
|
|
this.showBody = show;
|
|
|
|
},
|
|
|
|
|
|
|
|
enter(el) {
|
|
|
|
const elementHeight = el.getBoundingClientRect().height;
|
|
|
|
el.style.height = 0;
|
|
|
|
el.offsetHeight; // reflow
|
|
|
|
el.style.height = elementHeight + 'px';
|
|
|
|
},
|
|
|
|
afterEnter(el) {
|
|
|
|
el.style.height = null;
|
|
|
|
},
|
|
|
|
leave(el) {
|
|
|
|
const elementHeight = el.getBoundingClientRect().height;
|
|
|
|
el.style.height = elementHeight + 'px';
|
|
|
|
el.offsetHeight; // reflow
|
|
|
|
el.style.height = 0;
|
|
|
|
},
|
|
|
|
afterLeave(el) {
|
|
|
|
el.style.height = null;
|
|
|
|
},
|
2022-12-22 09:01:59 +02:00
|
|
|
},
|
2020-08-09 09:51:02 +03:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.folder-toggle-enter-active, .folder-toggle-leave-active {
|
2022-12-30 08:40:29 +02:00
|
|
|
overflow-y: clip;
|
2020-08-09 09:51:02 +03:00
|
|
|
transition: opacity 0.5s, height 0.5s !important;
|
|
|
|
}
|
2020-10-17 14:12:00 +03:00
|
|
|
.folder-toggle-enter-from {
|
2020-08-09 09:51:02 +03:00
|
|
|
opacity: 0;
|
|
|
|
}
|
|
|
|
.folder-toggle-leave-to {
|
|
|
|
opacity: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.ssazuxis {
|
|
|
|
position: relative;
|
|
|
|
|
|
|
|
> header {
|
|
|
|
display: flex;
|
|
|
|
position: relative;
|
2021-04-13 21:34:56 +03:00
|
|
|
z-index: 10;
|
|
|
|
position: sticky;
|
|
|
|
top: var(--stickyTop, 0px);
|
2021-09-17 16:39:15 +03:00
|
|
|
padding: var(--x-padding);
|
2021-08-11 16:34:45 +03:00
|
|
|
-webkit-backdrop-filter: var(--blur, blur(8px));
|
|
|
|
backdrop-filter: var(--blur, blur(20px));
|
2020-08-09 09:51:02 +03:00
|
|
|
|
|
|
|
> .title {
|
2022-12-24 01:46:30 +02:00
|
|
|
display: grid;
|
|
|
|
place-content: center;
|
2020-08-09 09:51:02 +03:00
|
|
|
margin: 0;
|
2020-10-17 14:12:00 +03:00
|
|
|
padding: 12px 16px 12px 0;
|
2020-08-09 09:51:02 +03:00
|
|
|
|
2021-04-20 17:22:59 +03:00
|
|
|
> i {
|
2020-08-09 09:51:02 +03:00
|
|
|
margin-right: 6px;
|
|
|
|
}
|
|
|
|
|
|
|
|
&:empty {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .divider {
|
|
|
|
flex: 1;
|
|
|
|
margin: auto;
|
|
|
|
height: 1px;
|
|
|
|
background: var(--divider);
|
|
|
|
}
|
|
|
|
|
|
|
|
> button {
|
2020-10-17 14:12:00 +03:00
|
|
|
padding: 12px 0 12px 16px;
|
2020-08-09 09:51:02 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-12-27 11:31:05 +02:00
|
|
|
|
2022-12-27 11:35:56 +02:00
|
|
|
@container (max-width: 500px) {
|
2022-12-27 11:31:05 +02:00
|
|
|
.ssazuxis {
|
|
|
|
> header {
|
|
|
|
> .title {
|
|
|
|
padding: 8px 10px 8px 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-08-09 09:51:02 +03:00
|
|
|
</style>
|