zammad/app/frontend/apps/desktop/components/CommonTable/composables/useSkeletonLoadingCount.ts
2026-01-02 15:41:09 +02:00

22 lines
636 B
TypeScript

// Copyright (C) 2012-2026 Zammad Foundation, https://zammad-foundation.org/
import { useWindowSize } from '@vueuse/core'
import { computed, type ComputedRef, type Ref } from 'vue'
export const useSkeletonLoadingCount = (
count: Ref<number | undefined> | ComputedRef<number | undefined>,
) => {
const { height: screenHeight } = useWindowSize()
const visibleSkeletonLoadingCount = computed(() => {
const maxVisibleRowCount = Math.ceil(screenHeight.value / 40)
if (count.value && count.value > maxVisibleRowCount) return maxVisibleRowCount
return count.value
})
return {
visibleSkeletonLoadingCount,
}
}