LayoutMain.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <!-- Copyright (C) 2012-2025 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { computed, ref, unref } from 'vue'
  4. import { useRoute } from 'vue-router'
  5. import { useStickyHeader } from '#shared/composables/useStickyHeader.ts'
  6. import { headerOptions as header } from '#mobile/composables/useHeader.ts'
  7. import LayoutBottomNavigation from './LayoutBottomNavigation.vue'
  8. import LayoutHeader, { type Props as HeaderProps } from './LayoutHeader.vue'
  9. const route = useRoute()
  10. const title = computed(() => {
  11. return unref(header.value.title) || route.meta.title
  12. })
  13. const showBottomNavigation = computed(() => {
  14. return route.meta.hasBottomNavigation
  15. })
  16. const showHeader = computed(() => {
  17. return route.meta.hasHeader
  18. })
  19. const headerComponent = ref<{ headerElement: HTMLElement }>()
  20. const headerElement = computed(() => {
  21. return headerComponent.value?.headerElement
  22. })
  23. const { stickyStyles } = useStickyHeader([title], headerElement)
  24. </script>
  25. <template>
  26. <div class="flex h-full flex-col">
  27. <LayoutHeader
  28. v-if="showHeader"
  29. ref="headerComponent"
  30. v-bind="header as HeaderProps"
  31. :title="title"
  32. :style="stickyStyles.header"
  33. />
  34. <main
  35. class="flex h-full flex-col"
  36. :style="showHeader ? stickyStyles.body : {}"
  37. >
  38. <!-- let's see how it feels without transition -->
  39. <RouterView />
  40. <div
  41. v-if="showBottomNavigation"
  42. class="h-[calc(var(--safe-bottom,0)+3.5rem)] w-full shrink-0"
  43. />
  44. </main>
  45. <LayoutBottomNavigation v-if="showBottomNavigation" />
  46. </div>
  47. </template>