@@ -10,6 +10,7 @@ import {
1010 TrashIcon ,
1111} from ' @modrinth/assets'
1212import {
13+ Accordion ,
1314 DropdownSelect ,
1415 formatLoader ,
1516 injectNotificationManager ,
@@ -133,12 +134,33 @@ const state = useStorage(
133134 {
134135 group: ' Group' ,
135136 sortBy: ' Name' ,
137+ collapsedGroups: [],
136138 },
137139 localStorage,
138140 { mergeDefaults: true },
139141)
140142
141143const search = ref (' ' )
144+ const collapsedSectionKeys = computed (() => new Set (state .value .collapsedGroups ?? []))
145+
146+ const getSectionKey = (sectionName ) => ` ${ state .value .group } :${ sectionName} `
147+
148+ const isSectionCollapsed = (sectionName ) => {
149+ return collapsedSectionKeys .value .has (getSectionKey (sectionName))
150+ }
151+
152+ const setSectionCollapsed = (sectionName , collapsed ) => {
153+ const sectionKey = getSectionKey (sectionName)
154+ const collapsedSections = new Set (state .value .collapsedGroups ?? [])
155+
156+ if (collapsed) {
157+ collapsedSections .add (sectionKey)
158+ } else {
159+ collapsedSections .delete (sectionKey)
160+ }
161+
162+ state .value .collapsedGroups = [... collapsedSections]
163+ }
142164
143165const filteredResults = computed (() => {
144166 const { group = ' Group' , sortBy = ' Name' } = state .value
@@ -280,18 +302,21 @@ const filteredResults = computed(() => {
280302 < span class = " font-semibold text-secondary" > {{ selected }}< / span>
281303 < / DropdownSelect>
282304 < / div>
283- < div
305+ < Accordion
284306 v- for = " instanceSection in Array.from(filteredResults, ([key, value]) => ({
285307 key,
286308 value,
287309 }))"
288310 : key= " instanceSection.key"
311+ : divider= " instanceSection.key !== 'None'"
312+ : open- by- default= " !isSectionCollapsed(instanceSection.key)"
289313 class = " row"
314+ @on- open= " setSectionCollapsed(instanceSection.key, false)"
315+ @on- close= " setSectionCollapsed(instanceSection.key, true)"
290316 >
291- < div v- if = " instanceSection.key !== 'None'" class = " divider" >
292- < p> {{ instanceSection .key }}< / p>
293- < hr aria- hidden= " true" / >
294- < / div>
317+ < template v- if = " instanceSection.key !== 'None'" #title>
318+ < span class = " text-base" > {{ instanceSection .key }}< / span>
319+ < / template>
295320 < section class = " instances" >
296321 < Instance
297322 v- for = " instance in instanceSection.value"
@@ -301,7 +326,7 @@ const filteredResults = computed(() => {
301326 @contextmenu .prevent .stop = " (event) => handleRightClick(event, instance.path)"
302327 / >
303328 < / section>
304- < / div >
329+ < / Accordion >
305330 < ConfirmDeleteInstanceModal ref= " confirmModal" @delete = " deleteProfile" / >
306331 < ContextMenu ref= " instanceOptions" @option- clicked= " handleOptionsClick" >
307332 < template #play> < PlayIcon / > Play < / template>
@@ -316,73 +341,7 @@ const filteredResults = computed(() => {
316341< / template>
317342< style lang= " scss" scoped>
318343.row {
319- display: flex;
320- flex- direction: column;
321- align- items: flex- start;
322344 width: 100 % ;
323-
324- .divider {
325- display: flex;
326- justify- content: space- between;
327- align- items: center;
328- width: 100 % ;
329- gap: 1rem ;
330- margin- bottom: 1rem ;
331-
332- p {
333- margin: 0 ;
334- font- size: 1rem ;
335- white- space: nowrap;
336- color: var (-- color- contrast);
337- }
338-
339- hr {
340- background- color: var (-- color- gray);
341- height: 1px ;
342- width: 100 % ;
343- border: none;
344- }
345- }
346- }
347-
348- .header {
349- display: flex;
350- flex- direction: row;
351- flex- wrap: wrap;
352- justify- content: space- between;
353- gap: 1rem ;
354- align- items: inherit;
355- margin: 1rem 1rem 0 ! important;
356- padding: 1rem ;
357- width: calc (100 % - 2rem );
358-
359- .iconified - input {
360- flex- grow: 1 ;
361-
362- input {
363- min- width: 100 % ;
364- }
365- }
366-
367- .sort - dropdown {
368- width: 10rem ;
369- }
370-
371- .filter - dropdown {
372- width: 15rem ;
373- }
374-
375- .group - dropdown {
376- width: 10rem ;
377- }
378-
379- .labeled_button {
380- display: flex;
381- flex- direction: row;
382- align- items: center;
383- gap: 0 .5rem ;
384- white- space: nowrap;
385- }
386345}
387346
388347.instances {
0 commit comments