2022-11-25 15:57:02 +03:00
|
|
|
<script setup lang="ts">
|
2024-03-05 17:48:58 +03:00
|
|
|
const props = defineProps<{
|
|
|
|
enabled?: boolean
|
|
|
|
filter?: boolean
|
|
|
|
isDM?: boolean
|
|
|
|
sensitiveNonSpoiler?: boolean
|
|
|
|
}>()
|
2022-11-25 15:57:02 +03:00
|
|
|
|
2023-05-05 19:12:07 +03:00
|
|
|
const expandSpoilers = computed(() => {
|
|
|
|
const expandCW = currentUser.value ? getExpandSpoilersByDefault(currentUser.value.account) : false
|
|
|
|
const expandMedia = currentUser.value ? getExpandMediaByDefault(currentUser.value.account) : false
|
2023-05-04 23:29:47 +03:00
|
|
|
|
2023-05-05 19:12:07 +03:00
|
|
|
return !props.filter // always prevent expansion if filtered
|
|
|
|
&& ((props.sensitiveNonSpoiler && expandMedia)
|
|
|
|
|| (!props.sensitiveNonSpoiler && expandCW))
|
|
|
|
})
|
|
|
|
|
|
|
|
const hideContent = props.enabled || props.sensitiveNonSpoiler
|
|
|
|
const showContent = ref(expandSpoilers.value ? true : !hideContent)
|
2022-11-27 10:20:33 +03:00
|
|
|
const toggleContent = useToggle(showContent)
|
|
|
|
|
|
|
|
watchEffect(() => {
|
2023-05-05 19:12:07 +03:00
|
|
|
showContent.value = expandSpoilers.value ? true : !hideContent
|
2022-11-27 10:20:33 +03:00
|
|
|
})
|
2023-05-05 19:12:07 +03:00
|
|
|
function getToggleText() {
|
|
|
|
if (props.sensitiveNonSpoiler)
|
|
|
|
return 'status.spoiler_media_hidden'
|
|
|
|
return props.filter ? 'status.filter_show_anyway' : 'status.spoiler_show_more'
|
|
|
|
}
|
2022-11-25 15:57:02 +03:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2023-05-05 19:12:07 +03:00
|
|
|
<div v-if="hideContent" flex flex-col items-start>
|
2023-01-08 10:49:32 +03:00
|
|
|
<div class="content-rich" p="x-4 b-2.5" text-center text-secondary w-full border="~ base" border-0 border-b-dotted border-b-3 mt-2>
|
2022-11-30 05:07:13 +03:00
|
|
|
<slot name="spoiler" />
|
|
|
|
</div>
|
2023-01-23 22:33:21 +03:00
|
|
|
<div flex="~ gap-1 center" w-full :mb="isDM && !showContent ? '4' : ''" mt="-4.5">
|
2024-01-01 19:48:52 +03:00
|
|
|
<button btn-text px-2 py-1 rounded-lg :bg="isDM ? 'transparent' : 'base'" flex="~ center gap-2" :class="showContent ? '' : 'filter-saturate-0 hover:filter-saturate-100'" :aria-expanded="showContent" @click="toggleContent()">
|
2022-11-30 05:07:13 +03:00
|
|
|
<div v-if="showContent" i-ri:eye-line />
|
|
|
|
<div v-else i-ri:eye-close-line />
|
2023-05-05 19:12:07 +03:00
|
|
|
{{ showContent ? $t('status.spoiler_show_less') : $t(getToggleText()) }}
|
2022-11-30 05:07:13 +03:00
|
|
|
</button>
|
|
|
|
</div>
|
2022-11-25 15:57:02 +03:00
|
|
|
</div>
|
2023-05-05 19:12:07 +03:00
|
|
|
<slot v-if="!hideContent || showContent" />
|
2022-11-25 15:57:02 +03:00
|
|
|
</template>
|