115 refactor dynamic page component

This commit is contained in:
survellow
2023-12-26 17:47:15 +01:00
parent 0d3aff5a7e
commit 0b695e6a78
4 changed files with 90 additions and 59 deletions

View File

@ -0,0 +1,63 @@
<script lang="ts" setup>
import { computed, useSlots } from 'vue';
defineProps<{
hideContent: Boolean,
headline: String,
subTitle?: String,
icon?: String,
}>()
const slots = useSlots()
const hasSlot = (name:string) => {
return !!slots[name];
}
const hasContent = computed(() => {
return hasSlot('content')
})
</script>
<template>
<div
class="flex flex-column align-items-center transition-all transition-duration-500 transition-ease-in-out mt-0"
:class="{'md:mt-8': hideContent}"
>
<div class="flex align-items-center justify-content-center gap-2 mx-2">
<h3 class="text-4xl">
{{ headline }}
</h3>
<i
v-if="icon"
:class="icon"
style="font-size: 2rem"
></i>
</div>
<div
v-if="subTitle"
class="flex justify-content-center"
>
<h5 class="text-2xl m-2">{{ subTitle }}</h5>
</div>
<div
class="flex flex-wrap mx-0 gap-2 my-4 w-full lg:w-8"
>
<slot
name="selection"
class="flex-1 m-0"
></slot>
</div>
<div
v-if="hasContent"
:class="
[hideContent?
['opacity-0', 'pointer-events-none', 'h-1rem', 'overflow-hidden'] :
['opacity-100', 'transition-all', 'transition-duration-500', 'transition-ease-in-out']
,
'w-full', 'lg:w-8']"
>
<slot
name="content"
></slot>
</div>
</div>
</template>