From ab1a4a6c2bc0e85673a7a18bbe58f169b1938409 Mon Sep 17 00:00:00 2001 From: DomWane Date: Thu, 3 Oct 2024 15:59:25 +0200 Subject: [PATCH] feat: added hidden columns prop --- components/Card.vue | 13 +++++++++-- components/Project/ProjectGridGroup.vue | 20 ++++++++++++++--- components/Project/ProjectGridGroupSort.vue | 25 +++++++++++++++++---- 3 files changed, 49 insertions(+), 9 deletions(-) diff --git a/components/Card.vue b/components/Card.vue index 462a1ad..95910e5 100644 --- a/components/Card.vue +++ b/components/Card.vue @@ -3,6 +3,7 @@ import type { ProjectRating, ProjectShallow } from '~/types' const props = defineProps<{ project: ProjectShallow + hiddenColumns?: string[] }>() const { switcher, ecosystems, filter } = storeToRefs(useData()) @@ -11,6 +12,14 @@ const isLargeScreen = useMediaQuery('(min-width: 1024px)') const ratings: { label: string, type: string, rating: ProjectRating }[] = (props.project.ratings || []).map(rating => ({ label: rating.name, type: 'rating', rating: rating })) const ecosystem: { label: string[], type: string } = { label: ecosystems.value.filter(e => (props.project.ecosystem || []).includes(e.id)).map(e => e.icon!), type: 'ecosystem' } const projectItems: { label: string | string[], type: string, rating?: ProjectRating }[] = [{ label: props.project.usecases || [], type: 'array' }, ...ratings, ecosystem, { label: [props.project.website || '', props.project.github || '', props.project.twitter || ''], type: 'links' }] + +const { width } = useWindowSize() +const visibleColumnsCount = computed(() => { + if (width.value >= 1024) + return projectItems.filter(item => item.rating?.type ? !props.hiddenColumns?.includes(item.rating.type) : true).length + 4 + else + return 2 +})