LayoutContent.vue 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { computed } from 'vue'
  4. import CommonBreadcrumb from '#desktop/components/CommonBreadcrumb/CommonBreadcrumb.vue'
  5. import type { BreadcrumbItem } from '#desktop/components/CommonBreadcrumb/types.ts'
  6. import CommonHelpText from '#desktop/components/CommonPageHelp/CommonHelpText.vue'
  7. import CommonPageHelp from '#desktop/components/CommonPageHelp/CommonPageHelp.vue'
  8. import LayoutBottomBar from '#desktop/components/layout/LayoutBottomBar.vue'
  9. import LayoutMain from '#desktop/components/layout/LayoutMain.vue'
  10. import { useTransitionConfig } from '#desktop/composables/useTransitionConfig.ts'
  11. import type { ContentWidth } from './types'
  12. export interface Props {
  13. breadcrumbItems: BreadcrumbItem[]
  14. width?: ContentWidth
  15. helpText?: string[] | string
  16. /**
  17. * Hides `default slot` content and shows help text if provided
  18. */
  19. showInlineHelp?: boolean
  20. }
  21. const props = withDefaults(defineProps<Props>(), {
  22. width: 'full',
  23. showInlineHelp: false,
  24. })
  25. const maxWidth = computed(() =>
  26. props.width === 'narrow' ? '600px' : undefined,
  27. )
  28. const { durations } = useTransitionConfig()
  29. </script>
  30. <template>
  31. <div class="flex max-h-screen flex-col">
  32. <LayoutMain>
  33. <div
  34. data-test-id="layout-wrapper"
  35. class="flex grow flex-col gap-3"
  36. :style="{ maxWidth }"
  37. >
  38. <div class="flex items-center justify-between">
  39. <CommonBreadcrumb :items="breadcrumbItems" />
  40. <div
  41. v-if="$slots.headerRight || helpText || $slots.helpPage"
  42. class="flex gap-4 ltr:text-left rtl:text-right"
  43. >
  44. <CommonPageHelp
  45. v-if="!showInlineHelp && (helpText || $slots.helpPage)"
  46. >
  47. <slot name="helpPage">
  48. <CommonHelpText :help-text="helpText" />
  49. </slot>
  50. </CommonPageHelp>
  51. <slot name="headerRight" />
  52. </div>
  53. </div>
  54. <Transition :duration="durations.normal" name="fade" mode="out-in">
  55. <slot v-if="!showInlineHelp" />
  56. <slot v-else name="helpPage">
  57. <CommonHelpText :help-text="helpText" />
  58. </slot>
  59. </Transition>
  60. </div>
  61. </LayoutMain>
  62. <LayoutBottomBar v-if="$slots.bottomBar">
  63. <slot name="bottomBar" />
  64. </LayoutBottomBar>
  65. </div>
  66. </template>