LayoutMain.vue 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { computed, useTemplateRef } from 'vue'
  4. import { useScrollPosition } from '#desktop/composables/useScrollPosition.ts'
  5. import type { BackgroundVariant } from './types.ts'
  6. export interface Props {
  7. backgroundVariant?: BackgroundVariant
  8. noPadding?: boolean
  9. noScrollable?: boolean
  10. }
  11. const props = withDefaults(defineProps<Props>(), {
  12. backgroundVariant: 'tertiary',
  13. })
  14. const scrollContainer = useTemplateRef('scroll-container')
  15. // FIXME: Warning, not reactive! But do we really need that switchable for the same route?
  16. if (!props.noScrollable) useScrollPosition(scrollContainer)
  17. const backgroundVariantClasses = computed(() => {
  18. switch (props.backgroundVariant) {
  19. case 'primary':
  20. return 'bg-blue-50 dark:bg-gray-800'
  21. case 'tertiary':
  22. default:
  23. return 'bg-neutral-50 dark:bg-gray-500'
  24. }
  25. })
  26. </script>
  27. <template>
  28. <main
  29. ref="scroll-container"
  30. class="h-full w-full text-gray-100 dark:text-neutral-400"
  31. :class="[
  32. backgroundVariantClasses,
  33. {
  34. 'p-4': !noPadding,
  35. 'overflow-y-auto': !noScrollable,
  36. 'overflow-y-hidden': noScrollable,
  37. },
  38. ]"
  39. >
  40. <slot />
  41. </main>
  42. </template>