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/ConfigurationSection.tsx | 162 ++++++++++++++++++++----------- src/components/Content.tsx | 16 +-- src/components/ProfileManagement.tsx | 166 +++++++++++++++++++++++--------- 3 files changed, 233 insertions(+), 111 deletions(-) (limited to 'src') diff --git a/src/components/ConfigurationSection.tsx b/src/components/ConfigurationSection.tsx index 92d1867..51fe47c 100644 --- a/src/components/ConfigurationSection.tsx +++ b/src/components/ConfigurationSection.tsx @@ -15,6 +15,7 @@ interface ConfigurationSectionProps { } const WORKAROUNDS_COLLAPSED_KEY = 'lsfg-workarounds-collapsed'; +const CONFIG_COLLAPSED_KEY = 'lsfg-config-collapsed'; export function ConfigurationSection({ config, @@ -30,6 +31,16 @@ export function ConfigurationSection({ } }); + // Initialize with localStorage value, fallback to false (expanded) if not found + const [configCollapsed, setConfigCollapsed] = useState(() => { + try { + const saved = localStorage.getItem(CONFIG_COLLAPSED_KEY); + return saved !== null ? JSON.parse(saved) : false; + } catch { + return false; + } + }); + // Persist workarounds collapse state to localStorage useEffect(() => { try { @@ -39,6 +50,15 @@ export function ConfigurationSection({ } }, [workaroundsCollapsed]); + // Persist config collapse state to localStorage + useEffect(() => { + try { + localStorage.setItem(CONFIG_COLLAPSED_KEY, JSON.stringify(configCollapsed)); + } catch (error) { + console.warn('Failed to save config collapse state:', error); + } + }, [configCollapsed]); + return ( <> @@ -68,69 +94,93 @@ export function ConfigurationSection({ - {/* FPS Multiplier */} - - - onConfigChange(FLOW_SCALE, value)} - /> +
+ setConfigCollapsed(!configCollapsed)} + > + {configCollapsed ? ( + + ) : ( + + )} + +
- - 0 ? ` (${config.dxvk_frame_rate} FPS)` : ' (Off)'}`} - description="Base framerate cap for DirectX games, before frame multiplier. (Requires game restart to apply)" - value={config.dxvk_frame_rate} - min={0} - max={60} - step={1} - onChange={(value) => onConfigChange(DXVK_FRAME_RATE, value)} - /> - + {!configCollapsed && ( + <> + {/* FPS Multiplier */} + - - onConfigChange(EXPERIMENTAL_PRESENT_MODE, value ? "fifo" : "mailbox")} - /> - + + onConfigChange(FLOW_SCALE, value)} + /> + - - onConfigChange(PERFORMANCE_MODE, value)} - /> - + + 0 ? ` (${config.dxvk_frame_rate} FPS)` : ' (Off)'}`} + description="Base framerate cap for DirectX games, before frame multiplier. (Requires game restart to apply)" + value={config.dxvk_frame_rate} + min={0} + max={60} + step={1} + onChange={(value) => onConfigChange(DXVK_FRAME_RATE, value)} + /> + - {/* - onConfigChange(NO_FP16, value)} - /> - */} + + onConfigChange(EXPERIMENTAL_PRESENT_MODE, value ? "fifo" : "mailbox")} + /> + - - onConfigChange(HDR_MODE, value)} - /> - + + onConfigChange(PERFORMANCE_MODE, value)} + /> + + + {/* + onConfigChange(NO_FP16, value)} + /> + */} + + + onConfigChange(HDR_MODE, value)} + /> + + + )} {/* Workarounds Section */} diff --git a/src/components/Content.tsx b/src/components/Content.tsx index 7815951..142f111 100644 --- a/src/components/Content.tsx +++ b/src/components/Content.tsx @@ -93,6 +93,14 @@ export function Content() { + {/* Configuration Section - only show if installed */} + {isInstalled && ( + + )} + {/* Profile Management - only show if installed */} {isInstalled && ( )} - {/* Configuration Section - only show if installed */} - {isInstalled && ( - - )} - 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