2022-11-25 15:57:02 +03:00
|
|
|
<script setup lang="ts">
|
|
|
|
const props = defineProps<{ enabled: boolean }>()
|
|
|
|
|
2022-11-27 10:20:33 +03:00
|
|
|
const showContent = ref(!props.enabled)
|
|
|
|
const toggleContent = useToggle(showContent)
|
|
|
|
|
|
|
|
watchEffect(() => {
|
|
|
|
showContent.value = !props.enabled
|
|
|
|
})
|
2022-11-25 15:57:02 +03:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div v-if="enabled" flex flex-col items-start gap-2>
|
|
|
|
<slot name="spoiler" />
|
|
|
|
<button btn-outline px-2 py-1 text-3 @click="toggleContent()">
|
|
|
|
{{ showContent ? 'Show less' : 'Show more' }}
|
|
|
|
</button>
|
|
|
|
</div>
|
2022-11-27 10:20:33 +03:00
|
|
|
<slot v-if="!enabled || showContent" />
|
2022-11-25 15:57:02 +03:00
|
|
|
</template>
|