2023-07-27 08:31:52 +03:00
|
|
|
<!--
|
|
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2023-01-15 23:06:28 +02:00
|
|
|
<template>
|
|
|
|
<div ref="content" :class="[$style.content, { [$style.omitted]: omitted }]">
|
|
|
|
<slot></slot>
|
|
|
|
<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>
|
2023-01-15 23:06:28 +02:00
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2023-12-07 07:42:09 +02:00
|
|
|
import { onMounted, onUnmounted, shallowRef, ref } from 'vue';
|
2023-09-19 10:37:43 +03:00
|
|
|
import { i18n } from '@/i18n.js';
|
2023-01-15 23:06:28 +02:00
|
|
|
|
|
|
|
const props = withDefaults(defineProps<{
|
2023-04-04 04:45:01 +03:00
|
|
|
maxHeight?: number;
|
2023-01-15 23:06:28 +02:00
|
|
|
}>(), {
|
|
|
|
maxHeight: 200,
|
|
|
|
});
|
|
|
|
|
2023-12-07 07:42:09 +02:00
|
|
|
const content = shallowRef<HTMLElement>();
|
|
|
|
const omitted = ref(false);
|
|
|
|
const ignoreOmit = ref(false);
|
2023-01-15 23:06:28 +02:00
|
|
|
|
2023-05-31 19:00:55 +03:00
|
|
|
const calcOmit = () => {
|
2023-12-07 07:42:09 +02:00
|
|
|
if (omitted.value || ignoreOmit.value) return;
|
|
|
|
omitted.value = content.value.offsetHeight > props.maxHeight;
|
2023-05-31 19:00:55 +03:00
|
|
|
};
|
2023-01-15 23:06:28 +02:00
|
|
|
|
2023-05-31 19:00:55 +03:00
|
|
|
const omitObserver = new ResizeObserver((entries, observer) => {
|
2023-01-15 23:06:28 +02:00
|
|
|
calcOmit();
|
2023-05-31 19:00:55 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
calcOmit();
|
2023-12-07 07:42:09 +02:00
|
|
|
omitObserver.observe(content.value);
|
2023-05-31 19:00:55 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
onUnmounted(() => {
|
|
|
|
omitObserver.disconnect();
|
2023-01-15 23:06:28 +02:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" module>
|
|
|
|
.content {
|
|
|
|
--stickyTop: 0px;
|
|
|
|
|
|
|
|
&.omitted {
|
|
|
|
position: relative;
|
|
|
|
max-height: v-bind("props.maxHeight + 'px'");
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
|
|
> .fade {
|
|
|
|
display: block;
|
|
|
|
position: absolute;
|
|
|
|
z-index: 10;
|
|
|
|
bottom: 0;
|
|
|
|
left: 0;
|
|
|
|
width: 100%;
|
|
|
|
height: 64px;
|
2023-10-16 03:05:34 +03:00
|
|
|
//background: linear-gradient(0deg, var(--panel), var(--X15));
|
2023-01-15 23:06:28 +02:00
|
|
|
|
|
|
|
> .fadeLabel {
|
|
|
|
display: inline-block;
|
|
|
|
background: var(--panel);
|
|
|
|
padding: 6px 10px;
|
|
|
|
font-size: 0.8em;
|
2023-10-31 20:44:34 +02:00
|
|
|
border-radius: var(--radius-ellipse);
|
2023-01-15 23:06:28 +02:00
|
|
|
box-shadow: 0 2px 6px rgb(0 0 0 / 20%);
|
|
|
|
}
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
> .fadeLabel {
|
|
|
|
background: var(--panelHighlight);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|