From c6092d861cc3fb4d333dd47ec135474b030fb9b4 Mon Sep 17 00:00:00 2001 From: xXJSONDeruloXx Date: Mon, 18 Aug 2025 12:33:26 -0400 Subject: make all sections collapsible --- src/components/ProfileManagement.tsx | 166 +++++++++++++++++++++++++---------- 1 file changed, 119 insertions(+), 47 deletions(-) (limited to 'src/components/ProfileManagement.tsx') diff --git a/src/components/ProfileManagement.tsx b/src/components/ProfileManagement.tsx index 46c507c..4a75484 100644 --- a/src/components/ProfileManagement.tsx +++ b/src/components/ProfileManagement.tsx @@ -1,6 +1,5 @@ import { useState, useEffect } from "react"; import { - PanelSection, PanelSectionRow, Dropdown, DropdownOption, @@ -15,6 +14,7 @@ import { AppOverview, Router } from "@decky/ui"; +import { RiArrowDownSFill, RiArrowUpSFill } from "react-icons/ri"; import { getProfiles, createProfile, @@ -26,6 +26,8 @@ import { } from "../api/lsfgApi"; import { showSuccessToast, showErrorToast } from "../utils/toastUtils"; +const PROFILES_COLLAPSED_KEY = 'lsfg-profiles-collapsed'; + interface TextInputModalProps { title: string; description: string; @@ -108,6 +110,25 @@ export function ProfileManagement({ currentProfile, onProfileChange }: ProfileMa const [selectedProfile, setSelectedProfile] = useState(currentProfile || "decky-lsfg-vk"); const [isLoading, setIsLoading] = useState(false); const [mainRunningApp, setMainRunningApp] = useState(undefined); + + // Initialize with localStorage value, fallback to false (expanded) if not found + const [profilesCollapsed, setProfilesCollapsed] = useState(() => { + try { + const saved = localStorage.getItem(PROFILES_COLLAPSED_KEY); + return saved !== null ? JSON.parse(saved) : false; + } catch { + return false; + } + }); + + // Persist profiles collapse state to localStorage + useEffect(() => { + try { + localStorage.setItem(PROFILES_COLLAPSED_KEY, JSON.stringify(profilesCollapsed)); + } catch (error) { + console.warn('Failed to save profiles collapse state:', error); + } + }, [profilesCollapsed]); // Load profiles on component mount useEffect(() => { @@ -314,56 +335,107 @@ export function ProfileManagement({ currentProfile, onProfileChange }: ProfileMa ]; return ( - - {/* Display currently running game info */} - {mainRunningApp && ( - -
- {mainRunningApp.display_name} running. Close game to change profile. -
-
- )} - - - - - - - + <> + + - - Rename - + Select Profile + - + - - Delete - +
+ setProfilesCollapsed(!profilesCollapsed)} + > + {profilesCollapsed ? ( + + ) : ( + + )} + +
-
+ + {!profilesCollapsed && ( + <> + {/* Display currently running game info */} + {mainRunningApp && ( + +
+ {mainRunningApp.display_name} running. Close game to change profile. +
+
+ )} + + + + + + + + + + Rename + + + + + + Delete + + + + )} + ); } -- cgit v1.2.3