From 45ba67c8278804e7f38a5e96fe6aaf2379e962fe Mon Sep 17 00:00:00 2001 From: Michel Roegl-Brunner Date: Fri, 7 Nov 2025 12:58:22 +0100 Subject: [PATCH] Add minimize buttons to FilterBar and Newest Scripts sections - Add minimize/collapse functionality to FilterBar component - Add minimize/collapse functionality to Newest Scripts section - Hide Newest Scripts section when user is searching, filtering, or viewing a category - Both sections can now be minimized to save screen space --- src/app/_components/FilterBar.tsx | 105 ++++++++++++++++++---------- src/app/_components/ScriptsGrid.tsx | 92 +++++++++++++++--------- 2 files changed, 126 insertions(+), 71 deletions(-) diff --git a/src/app/_components/FilterBar.tsx b/src/app/_components/FilterBar.tsx index 6b10f07..37c4f35 100644 --- a/src/app/_components/FilterBar.tsx +++ b/src/app/_components/FilterBar.tsx @@ -41,6 +41,7 @@ export function FilterBar({ }: FilterBarProps) { const [isTypeDropdownOpen, setIsTypeDropdownOpen] = useState(false); const [isSortDropdownOpen, setIsSortDropdownOpen] = useState(false); + const [isMinimized, setIsMinimized] = useState(false); const updateFilters = (updates: Partial) => { onFiltersChange({ ...filters, ...updates }); @@ -98,44 +99,17 @@ export function FilterBar({ {!isLoadingFilters && (

Filter Scripts

- -
- )} - - {/* Search Bar */} -
-
-
- - - -
- updateFilters({ searchQuery: e.target.value })} - className="block w-full rounded-lg border border-input bg-background py-3 pr-10 pl-10 text-sm leading-5 text-foreground placeholder-muted-foreground focus:border-primary focus:placeholder-muted-foreground focus:ring-2 focus:ring-primary focus:outline-none" - /> - {filters.searchQuery && ( +
+ - )} +
-
+ )} - {/* Filter Buttons */} -
+ {/* Filter Content - Conditionally rendered based on minimized state */} + {!isMinimized && !isLoadingFilters && ( + <> + {/* Search Bar */} +
+
+
+ + + +
+ updateFilters({ searchQuery: e.target.value })} + className="block w-full rounded-lg border border-input bg-background py-3 pr-10 pl-10 text-sm leading-5 text-foreground placeholder-muted-foreground focus:border-primary focus:placeholder-muted-foreground focus:ring-2 focus:ring-primary focus:outline-none" + /> + {filters.searchQuery && ( + + )} +
+
+ + {/* Filter Buttons */} +
{/* Updateable Filter */} )}
+ + )} {/* Click outside to close dropdowns */} {(isTypeDropdownOpen || isSortDropdownOpen) && ( diff --git a/src/app/_components/ScriptsGrid.tsx b/src/app/_components/ScriptsGrid.tsx index 9319063..0a4fbdf 100644 --- a/src/app/_components/ScriptsGrid.tsx +++ b/src/app/_components/ScriptsGrid.tsx @@ -34,6 +34,7 @@ export function ScriptsGrid({ onInstallScript }: ScriptsGridProps) { }); const [saveFiltersEnabled, setSaveFiltersEnabled] = useState(false); const [isLoadingFilters, setIsLoadingFilters] = useState(true); + const [isNewestMinimized, setIsNewestMinimized] = useState(false); const gridRef = useRef(null); const { data: scriptCardsData, isLoading: githubLoading, error: githubError, refetch } = api.scripts.getScriptCardsWithCategories.useQuery(); @@ -689,8 +690,8 @@ export function ScriptsGrid({ onInstallScript }: ScriptsGridProps) { onViewModeChange={setViewMode} /> - {/* Newest Scripts Carousel - Always show when there are newest scripts */} - {newestScripts.length > 0 && ( + {/* Newest Scripts Carousel - Only show when no search, filters, or category is active */} + {newestScripts.length > 0 && !hasActiveFilters && !selectedCategory && (
@@ -698,39 +699,64 @@ export function ScriptsGrid({ onInstallScript }: ScriptsGridProps) { Newest Scripts - - {newestScripts.length} recently added - -
- -
-
- {newestScripts.map((script, index) => { - if (!script || typeof script !== 'object') { - return null; - } - - const uniqueKey = `newest-${script.slug ?? 'unknown'}-${script.name ?? 'unnamed'}-${index}`; - - return ( -
-
- - {/* NEW badge */} -
- NEW -
-
-
- ); - })} +
+ + {newestScripts.length} recently added + +
+ + {!isNewestMinimized && ( +
+
+ {newestScripts.map((script, index) => { + if (!script || typeof script !== 'object') { + return null; + } + + const uniqueKey = `newest-${script.slug ?? 'unknown'}-${script.name ?? 'unnamed'}-${index}`; + + return ( +
+
+ + {/* NEW badge */} +
+ NEW +
+
+
+ ); + })} +
+
+ )}
)}