Refactor filter buttons in FilterDrawer for improved styling and functionality; add FilterPlatformBtn component.

This commit is contained in:
zurdi
2025-11-27 16:55:31 +00:00
parent 1902900ca2
commit 08df8e3255
9 changed files with 117 additions and 95 deletions

View File

@@ -11,11 +11,10 @@ import FilterDuplicatesBtn from "@/components/Gallery/AppBar/common/FilterDrawer
import FilterFavoritesBtn from "@/components/Gallery/AppBar/common/FilterDrawer/FilterFavoritesBtn.vue";
import FilterMatchStateBtn from "@/components/Gallery/AppBar/common/FilterDrawer/FilterMatchStateBtn.vue";
import FilterMissingBtn from "@/components/Gallery/AppBar/common/FilterDrawer/FilterMissingBtn.vue";
import FilterPlatformBtn from "@/components/Gallery/AppBar/common/FilterDrawer/FilterPlatformBtn.vue";
import FilterPlayablesBtn from "@/components/Gallery/AppBar/common/FilterDrawer/FilterPlayablesBtn.vue";
import FilterRaBtn from "@/components/Gallery/AppBar/common/FilterDrawer/FilterRaBtn.vue";
import FilterVerifiedBtn from "@/components/Gallery/AppBar/common/FilterDrawer/FilterVerifiedBtn.vue";
import MissingFromFSIcon from "@/components/common/MissingFromFSIcon.vue";
import PlatformIcon from "@/components/common/Platform/PlatformIcon.vue";
import storeGalleryFilter from "@/stores/galleryFilter";
import storePlatforms from "@/stores/platforms";
import storeRoms from "@/stores/roms";
@@ -64,7 +63,6 @@ const {
selectedStatus,
filterStatuses,
selectedPlatform,
filterPlatforms,
selectedRegion,
filterRegions,
selectedLanguage,
@@ -324,11 +322,9 @@ onMounted(async () => {
class="bg-surface rounded mt-4 mb-2 pa-1 unset-height"
>
<v-list tabindex="-1">
<template v-if="showSearchBar && xs">
<v-list-item>
<SearchTextField :tabindex="activeFilterDrawer ? 0 : -1" />
</v-list-item>
</template>
<v-list-item v-if="showSearchBar && xs">
<SearchTextField :tabindex="activeFilterDrawer ? 0 : -1" />
</v-list-item>
<v-list-item>
<FilterMatchStateBtn :tabindex="activeFilterDrawer ? 0 : -1" />
<FilterFavoritesBtn
@@ -354,82 +350,21 @@ onMounted(async () => {
/>
<FilterRaBtn class="mt-2" :tabindex="activeFilterDrawer ? 0 : -1" />
</v-list-item>
<v-list-item
v-if="showPlatformsFilter"
:tabindex="activeFilterDrawer ? 0 : -1"
>
<v-autocomplete
v-model="selectedPlatform"
:tabindex="activeFilterDrawer ? 0 : -1"
hide-details
prepend-inner-icon="mdi-controller"
clearable
:label="t('common.platform')"
variant="outlined"
density="comfortable"
:items="filterPlatforms"
@update:model-value="
nextTick(() => emitter?.emit('filterRoms', null))
"
>
<template #item="{ props, item }">
<v-list-item
v-bind="props"
class="py-4"
:title="item.raw.name ?? ''"
:subtitle="item.raw.fs_slug"
>
<template #prepend>
<PlatformIcon
:key="item.raw.slug"
:size="35"
:slug="item.raw.slug"
:name="item.raw.name"
:fs-slug="item.raw.fs_slug"
/>
</template>
<template #append>
<MissingFromFSIcon
v-if="item.raw.missing_from_fs"
text="Missing platform from filesystem"
chip
chip-label
chip-density="compact"
class="ml-2"
/>
<v-chip class="ml-2" size="x-small" label>
{{ item.raw.rom_count }}
</v-chip>
</template>
</v-list-item>
</template>
<template #chip="{ item }">
<v-chip>
<PlatformIcon
:key="item.raw.slug"
:slug="item.raw.slug"
:name="item.raw.name"
:fs-slug="item.raw.fs_slug"
:size="20"
class="mr-2"
/>
{{ item.raw.name }}
</v-chip>
</template>
</v-autocomplete>
<v-list-item v-if="showPlatformsFilter">
<FilterPlatformBtn :tabindex="activeFilterDrawer ? 0 : -1" />
</v-list-item>
<v-list-item
v-for="filter in filters"
:key="filter.label"
:tabindex="activeFilterDrawer ? 0 : -1"
>
<v-autocomplete
<v-select
v-model="filter.selected.value"
:tabindex="activeFilterDrawer ? 0 : -1"
hide-details
clearable
:label="filter.label"
variant="solo-filled"
variant="outlined"
density="comfortable"
:items="filter.items.value"
@update:model-value="

View File

@@ -35,7 +35,7 @@ function setState(state: string | null) {
<template>
<div
class="d-flex align-center justify-space-between py-2 px-4 rounded-lg border"
class="d-flex align-center justify-space-between py-2"
:class="{ 'opacity-50': fetchTotalRoms > 10000 }"
>
<div class="d-flex align-center">
@@ -64,7 +64,9 @@ function setState(state: string | null) {
:disabled="fetchTotalRoms > 10000"
@update:model-value="setState"
>
<v-btn value="all" size="small">All</v-btn>
<v-btn value="all" size="small"
><v-icon size="x-large">mdi-cancel</v-icon>
</v-btn>
<v-tooltip text="Show duplicate ROMs only" location="bottom">
<template #activator="{ props }">
<v-btn

View File

@@ -31,9 +31,7 @@ function setState(state: string | null) {
</script>
<template>
<div
class="d-flex align-center justify-space-between py-2 px-4 rounded-lg border"
>
<div class="d-flex align-center justify-space-between py-2">
<div class="d-flex align-center">
<v-icon
:color="currentState !== 'all' ? 'primary' : 'grey-lighten-1'"
@@ -59,7 +57,9 @@ function setState(state: string | null) {
variant="outlined"
@update:model-value="setState"
>
<v-btn value="all" size="small">All</v-btn>
<v-btn value="all" size="small"
><v-icon size="x-large">mdi-cancel</v-icon>
</v-btn>
<v-tooltip text="Show favorite ROMs only" location="bottom">
<template #activator="{ props }">
<v-btn value="favorites" size="small" v-bind="props">

View File

@@ -38,9 +38,7 @@ function setMatchState(state: string) {
</script>
<template>
<div
class="d-flex align-center justify-space-between py-2 px-4 rounded-lg border"
>
<div class="d-flex align-center justify-space-between py-2">
<div class="d-flex align-center">
<v-icon
:color="matchState !== 'all' ? 'primary' : 'grey-lighten-1'"
@@ -66,7 +64,9 @@ function setMatchState(state: string) {
variant="outlined"
@update:model-value="setMatchState"
>
<v-btn value="all" size="small"> All </v-btn>
<v-btn value="all" size="small"
><v-icon size="x-large">mdi-cancel</v-icon>
</v-btn>
<v-tooltip :text="t('platform.show-matched')" location="bottom">
<template #activator="{ props }">
<v-btn value="matched" size="small" v-bind="props">

View File

@@ -31,9 +31,7 @@ function setState(state: string | null) {
</script>
<template>
<div
class="d-flex align-center justify-space-between py-2 px-4 rounded-lg border"
>
<div class="d-flex align-center justify-space-between py-2">
<div class="d-flex align-center">
<v-icon
:color="currentState !== 'all' ? 'primary' : 'grey-lighten-1'"
@@ -59,7 +57,9 @@ function setState(state: string | null) {
variant="outlined"
@update:model-value="setState"
>
<v-btn value="all" size="small">All</v-btn>
<v-btn value="all" size="small"
><v-icon size="x-large">mdi-cancel</v-icon>
</v-btn>
<v-tooltip text="Show missing ROMs only" location="bottom">
<template #activator="{ props }">
<v-btn value="missing" size="small" v-bind="props">

View File

@@ -0,0 +1,81 @@
<script setup lang="ts">
import type { Emitter } from "mitt";
import { storeToRefs } from "pinia";
import { inject, nextTick } from "vue";
import { useI18n } from "vue-i18n";
import MissingFromFSIcon from "@/components/common/MissingFromFSIcon.vue";
import PlatformIcon from "@/components/common/Platform/PlatformIcon.vue";
import storeGalleryFilter from "@/stores/galleryFilter";
import type { Events } from "@/types/emitter";
defineProps<{
tabindex?: number;
}>();
const { t } = useI18n();
const galleryFilterStore = storeGalleryFilter();
const { selectedPlatform, filterPlatforms } = storeToRefs(galleryFilterStore);
const emitter = inject<Emitter<Events>>("emitter");
</script>
<template>
<v-select
v-model="selectedPlatform"
:tabindex="tabindex"
hide-details
:label="t('common.platform')"
clearable
variant="outlined"
density="comfortable"
:items="filterPlatforms"
@update:model-value="nextTick(() => emitter?.emit('filterRoms', null))"
>
<template #prepend-inner>
<v-icon class="ml-2 mr-1">mdi-controller</v-icon>
</template>
<template #item="{ props, item }">
<v-list-item
v-bind="props"
class="py-4"
:title="item.raw.name ?? ''"
:subtitle="item.raw.fs_slug"
>
<template #prepend>
<PlatformIcon
:key="item.raw.slug"
:size="35"
:slug="item.raw.slug"
:name="item.raw.name"
:fs-slug="item.raw.fs_slug"
/>
</template>
<template #append>
<MissingFromFSIcon
v-if="item.raw.missing_from_fs"
text="Missing platform from filesystem"
chip
chip-label
chip-density="compact"
class="ml-2"
/>
<v-chip class="ml-2" size="x-small" label>
{{ item.raw.rom_count }}
</v-chip>
</template>
</v-list-item>
</template>
<template #chip="{ item }">
<v-chip>
<PlatformIcon
:key="item.raw.slug"
:slug="item.raw.slug"
:name="item.raw.name"
:fs-slug="item.raw.fs_slug"
:size="20"
class="mr-2"
/>
{{ item.raw.name }}
</v-chip>
</template>
</v-select>
</template>

View File

@@ -35,7 +35,7 @@ function setState(state: string | null) {
<template>
<div
class="d-flex align-center justify-space-between py-2 px-4 rounded-lg border"
class="d-flex align-center justify-space-between py-2"
:class="{ 'opacity-50': fetchTotalRoms > 10000 }"
>
<div class="d-flex align-center">
@@ -64,7 +64,9 @@ function setState(state: string | null) {
:disabled="fetchTotalRoms > 10000"
@update:model-value="setState"
>
<v-btn value="all" size="small">All</v-btn>
<v-btn value="all" size="small"
><v-icon size="x-large">mdi-cancel</v-icon>
</v-btn>
<v-tooltip text="Show playable ROMs only" location="bottom">
<template #activator="{ props }">
<v-btn

View File

@@ -33,7 +33,7 @@ function setState(state: string | null) {
<template>
<div
class="d-flex align-center justify-space-between py-2 px-4 rounded-lg border"
class="d-flex align-center justify-space-between py-2"
:class="{ 'opacity-50': fetchTotalRoms > 10000 }"
>
<div class="d-flex align-center">
@@ -62,7 +62,9 @@ function setState(state: string | null) {
:disabled="fetchTotalRoms > 10000"
@update:model-value="setState"
>
<v-btn value="all" size="small">All</v-btn>
<v-btn value="all" size="small"
><v-icon size="x-large">mdi-cancel</v-icon>
</v-btn>
<v-tooltip text="Show ROMs with RetroAchievements only" location="bottom">
<template #activator="{ props }">
<v-btn

View File

@@ -31,9 +31,7 @@ function setState(state: string | null) {
</script>
<template>
<div
class="d-flex align-center justify-space-between py-2 px-4 rounded-lg border"
>
<div class="d-flex align-center justify-space-between py-2">
<div class="d-flex align-center">
<v-icon
:color="currentState !== 'all' ? 'primary' : 'grey-lighten-1'"
@@ -59,7 +57,9 @@ function setState(state: string | null) {
variant="outlined"
@update:model-value="setState"
>
<v-btn value="all" size="small">All</v-btn>
<v-btn value="all" size="small"
><v-icon size="x-large">mdi-cancel</v-icon>
</v-btn>
<v-tooltip text="Show verified ROMs only" location="bottom">
<template #activator="{ props }">
<v-btn value="verified" size="small" v-bind="props">