LayoutMain.vue 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { computed, provide, ref } from 'vue'
  4. import { MAIN_LAYOUT_KEY } from '#desktop/components/layout/composables/useMainLayoutContainer.ts'
  5. import type { BackgroundVariant } from './types.ts'
  6. export interface Props {
  7. backgroundVariant?: BackgroundVariant
  8. noPadding?: boolean
  9. }
  10. const mainContainer = ref<HTMLElement>()
  11. provide(
  12. MAIN_LAYOUT_KEY,
  13. computed(() => mainContainer.value),
  14. )
  15. const props = withDefaults(defineProps<Props>(), {
  16. backgroundVariant: 'tertiary',
  17. })
  18. const backgroundVariantClasses = computed(() => {
  19. switch (props.backgroundVariant) {
  20. case 'primary':
  21. return 'bg-blue-50 dark:bg-gray-800'
  22. case 'tertiary':
  23. default:
  24. return 'bg-neutral-50 dark:bg-gray-500'
  25. }
  26. })
  27. </script>
  28. <template>
  29. <main
  30. ref="mainContainer"
  31. class="h-full w-full overflow-y-auto text-gray-100 dark:text-neutral-400"
  32. :class="[backgroundVariantClasses, { 'p-4': !noPadding }]"
  33. >
  34. <slot />
  35. </main>
  36. </template>