LayoutMain.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <!-- Copyright (C) 2012-2024 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 v-if="showBottomNavigation" class="BottomNavigationPadding"></div>
  41. </main>
  42. <LayoutBottomNavigation v-if="showBottomNavigation" />
  43. </div>
  44. </template>
  45. <style scoped>
  46. .BottomNavigationPadding {
  47. @apply w-full shrink-0;
  48. height: calc(var(--safe-bottom, 0) + theme('height.14'));
  49. }
  50. </style>