-
Notifications
You must be signed in to change notification settings - Fork 22
feat: leaderboard collection filter #1446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+258
−37
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
64ea865
feat: leaderboard collection filter
gaspergrom ff79bc3
feat: collection filter layout
gaspergrom 151f0dc
feat: collection fixes
gaspergrom 7924868
Merge branch 'main' into feature/leaderboard-collection-filtering
gaspergrom 7311729
feat: sticky search
gaspergrom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
147 changes: 147 additions & 0 deletions
147
frontend/app/components/modules/leaderboards/components/filters/collections-filter.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,147 @@ | ||
| <!-- | ||
| Copyright (c) 2025 The Linux Foundation and each contributor. | ||
| SPDX-License-Identifier: MIT | ||
| --> | ||
| <template> | ||
| <lfx-dropdown-select | ||
| v-model="selectedCollection" | ||
| :width="props.width" | ||
| :match-width="props.matchWidth" | ||
| dropdown-class="max-h-80" | ||
| placement="bottom-end" | ||
| > | ||
| <template #trigger="{ selectedOption }"> | ||
| <lfx-dropdown-selector | ||
| :size="props.size" | ||
| :type="props.type" | ||
| class="!rounded-full flex items-center justify-center w-full" | ||
| > | ||
| <div class="flex items-center gap-2"> | ||
| <lfx-icon | ||
| name="rectangle-history" | ||
| :size="16" | ||
| /> | ||
| <span class="text-sm text-neutral-900 truncate"> | ||
| {{ selectedOption.label || 'All collections' }} | ||
| </span> | ||
| </div> | ||
| </lfx-dropdown-selector> | ||
| </template> | ||
|
|
||
| <template #default> | ||
| <!-- All collections option --> | ||
| <lfx-dropdown-item | ||
| value="all" | ||
| label="All collections" | ||
| /> | ||
|
|
||
| <lfx-dropdown-separator /> | ||
|
|
||
| <!-- Search input --> | ||
| <lfx-dropdown-search | ||
| v-model="searchQuery" | ||
| placeholder="Search collections..." | ||
| lazy | ||
| /> | ||
|
|
||
| <lfx-dropdown-separator /> | ||
|
|
||
| <!-- Collections list --> | ||
| <div | ||
| v-if="isPending" | ||
| class="py-8 flex justify-center" | ||
| > | ||
| <lfx-spinner /> | ||
| </div> | ||
|
|
||
| <div | ||
| v-else-if="!collections.length && searchQuery" | ||
| class="py-4 px-3 text-sm text-neutral-500 text-center" | ||
| > | ||
| No collections found | ||
| </div> | ||
|
|
||
| <template v-else> | ||
| <lfx-dropdown-item | ||
| v-for="collection in collections" | ||
| :key="collection.id" | ||
| :value="collection.slug" | ||
| :label="collection.name" | ||
| /> | ||
| </template> | ||
| </template> | ||
| </lfx-dropdown-select> | ||
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import { computed, ref, watch } from 'vue'; | ||
| import LfxDropdownSelect from '~/components/uikit/dropdown/dropdown-select.vue'; | ||
| import LfxDropdownSelector from '~/components/uikit/dropdown/dropdown-selector.vue'; | ||
| import LfxDropdownItem from '~/components/uikit/dropdown/dropdown-item.vue'; | ||
| import LfxDropdownSearch from '~/components/uikit/dropdown/dropdown-search.vue'; | ||
| import LfxDropdownSeparator from '~/components/uikit/dropdown/dropdown-separator.vue'; | ||
| import LfxIcon from '~/components/uikit/icon/icon.vue'; | ||
| import type { Collection } from '~~/types/collection'; | ||
| import type { Pagination } from '~~/types/shared/pagination'; | ||
| import { COLLECTIONS_API_SERVICE } from '~/components/modules/collection/services/collections.api.service'; | ||
| import LfxSpinner from '~/components/uikit/spinner/spinner.vue'; | ||
|
|
||
| const props = withDefaults( | ||
| defineProps<{ | ||
| modelValue?: string; | ||
| width?: string; | ||
| matchWidth?: boolean; | ||
| size?: 'medium' | 'small'; | ||
| type?: 'transparent' | 'filled'; | ||
| }>(), | ||
| { | ||
| modelValue: '', | ||
| width: '350px', | ||
| matchWidth: false, | ||
| size: 'medium', | ||
| type: 'transparent', | ||
| }, | ||
| ); | ||
|
|
||
| const emit = defineEmits<{ | ||
| (e: 'update:modelValue', value: string): void; | ||
| }>(); | ||
|
|
||
| const selectedCollection = computed({ | ||
| get: () => props.modelValue, | ||
| set: (value: string) => emit('update:modelValue', value), | ||
| }); | ||
|
|
||
| const searchQuery = ref(''); | ||
| const collections = ref<Collection[]>([]); | ||
| const isPending = ref(false); | ||
|
|
||
| // Fetch collections from API | ||
| const fetchCollections = async () => { | ||
| isPending.value = true; | ||
| try { | ||
| const response = await COLLECTIONS_API_SERVICE.searchCollections(searchQuery.value); | ||
| collections.value = (response as Pagination<Collection>).data || []; | ||
| } catch (error) { | ||
| console.error('Error fetching collections:', error); | ||
| collections.value = []; | ||
| } finally { | ||
| isPending.value = false; | ||
| } | ||
| }; | ||
|
|
||
| // Watch for search query changes | ||
| watch( | ||
| () => searchQuery.value, | ||
| () => { | ||
| fetchCollections(); | ||
| }, | ||
| { immediate: true }, | ||
| ); | ||
| </script> | ||
|
|
||
| <script lang="ts"> | ||
| export default { | ||
| name: 'LfxCollectionsFilter', | ||
| }; | ||
| </script> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.