diff --git a/components/Project/ProjectGrid.vue b/components/Project/ProjectGrid.vue index 08d5165..84d2ec8 100644 --- a/components/Project/ProjectGrid.vue +++ b/components/Project/ProjectGrid.vue @@ -4,22 +4,32 @@ import type { ProjectShallow } from '~/types' const props = defineProps<{ projects: { title: string, projects: ProjectShallow[] }[] }>() -const { switcher } = storeToRefs(useData()) +const { switcher, filter } = storeToRefs(useData()) -const displayCount = ref(100) -const displayedProjects = computed(() => props.projects.slice(0, displayCount.value)) -function showMoreProjects() { - displayCount.value += 50 +const totalProjectsCount = props.projects.map(g => g.projects.length).reduce((a, b) => a + b, 0) + +function onChangeSort(sortKey: string) { + if (filter.value.sortby === sortKey) { + if (filter.value.sortDirection === 'desc' && filter.value.sortby !== 'score') { + filter.value.sortby = 'score' + filter.value.sortDirection = 'desc' + return + } + filter.value.sortDirection = filter.value.sortDirection === 'asc' ? 'desc' : 'asc' + return + } + filter.value.sortby = sortKey + filter.value.sortDirection = sortKey === 'score' ? 'desc' : 'asc' } -const cardTitles = ref< { label: string, togglable?: boolean, toggled?: boolean }[]>([ - { label: 'Usecase' }, - { label: 'Openess', togglable: true }, - { label: 'Technology', togglable: true }, - { label: 'Privacy', togglable: true }, - { label: 'Ecosystem' }, - { label: 'Links' }, - { label: 'W3PN Score', togglable: true }, +const cardTitles = ref< { label: string, sortKey: string, togglable?: boolean }[]>([ + { label: 'Usecase', sortKey: 'usecase' }, + { label: 'Openess', sortKey: 'openess', togglable: true }, + { label: 'Technology', sortKey: 'technology', togglable: true }, + { label: 'Privacy', sortKey: 'privacy', togglable: true }, + { label: 'Ecosystem', sortKey: 'ecosystem' }, + { label: 'Links', sortKey: 'links' }, + { label: 'W3PN Score', sortKey: 'score', togglable: true }, ]) @@ -71,10 +81,12 @@ const cardTitles = ref< { label: string, togglable?: boolean, toggled?: boolean flex items-center gap-4px - col-span="1 lg:3" + col-span="1 lg:2" + :class="['title' === filter.sortby ? 'text-app-white' : 'text-app-text-grey', 'cursor-pointer']" + @click="onChangeSort('title')" >

@@ -82,8 +94,10 @@ const cardTitles = ref< { label: string, togglable?: boolean, toggled?: boolean

+
+

No Projects found...

+
diff --git a/layouts/default.vue b/layouts/default.vue index 7fa9483..ee29463 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -1,26 +1,22 @@