From 3c2cc7568d8a2aad686b663720957605aaabc1a8 Mon Sep 17 00:00:00 2001 From: kk <138403498+kirushkinx@users.noreply.github.com> Date: Thu, 16 Apr 2026 16:44:52 +0300 Subject: [PATCH] feat: add collapsible library groups in app (#5739) * feat: add collapsible library groups in app * feat: use accordion rather than custom --------- Co-authored-by: Calum H. Co-authored-by: Calum H. (IMB11) --- .../src/components/GridDisplay.vue | 103 ++++++------------ packages/assets/generated-icons.ts | 4 +- packages/ui/src/components/base/Accordion.vue | 27 ++++- .../ui/src/stories/base/Accordion.stories.ts | 29 +++++ 4 files changed, 88 insertions(+), 75 deletions(-) diff --git a/apps/app-frontend/src/components/GridDisplay.vue b/apps/app-frontend/src/components/GridDisplay.vue index 68bea3895..3d6dc42a1 100644 --- a/apps/app-frontend/src/components/GridDisplay.vue +++ b/apps/app-frontend/src/components/GridDisplay.vue @@ -10,6 +10,7 @@ import { TrashIcon, } from '@modrinth/assets' import { + Accordion, DropdownSelect, formatLoader, injectNotificationManager, @@ -133,12 +134,33 @@ const state = useStorage( { group: 'Group', sortBy: 'Name', + collapsedGroups: [], }, localStorage, { mergeDefaults: true }, ) const search = ref('') +const collapsedSectionKeys = computed(() => new Set(state.value.collapsedGroups ?? [])) + +const getSectionKey = (sectionName) => `${state.value.group}:${sectionName}` + +const isSectionCollapsed = (sectionName) => { + return collapsedSectionKeys.value.has(getSectionKey(sectionName)) +} + +const setSectionCollapsed = (sectionName, collapsed) => { + const sectionKey = getSectionKey(sectionName) + const collapsedSections = new Set(state.value.collapsedGroups ?? []) + + if (collapsed) { + collapsedSections.add(sectionKey) + } else { + collapsedSections.delete(sectionKey) + } + + state.value.collapsedGroups = [...collapsedSections] +} const filteredResults = computed(() => { const { group = 'Group', sortBy = 'Name' } = state.value @@ -280,18 +302,21 @@ const filteredResults = computed(() => { {{ selected }} -
-
-

{{ instanceSection.key }}

- -
+
{ @contextmenu.prevent.stop="(event) => handleRightClick(event, instance.path)" />
-
+ @@ -316,73 +341,7 @@ const filteredResults = computed(() => {