From 25f92c9b0bf8752236f0864716a55e948dcb3085 Mon Sep 17 00:00:00 2001 From: ddidderr Date: Tue, 19 May 2026 20:47:01 +0200 Subject: [PATCH] feat(ui): add smallest-first size sort The redesign only offered a largest-first size sort. Keep the existing `size` preference value as largest for compatibility with saved settings and add a new ascending size key for users who want to find small downloads first. The sort menu now exposes both size directions and the sorter handles the new smallest-first option directly. Test Plan: - git diff --check Refs: user redesign nitpick about Size (smallest) sort --- .../lanspread-tauri-deno-ts/src/components/topbar/SortMenu.tsx | 1 + crates/lanspread-tauri-deno-ts/src/lib/gameState.ts | 2 ++ crates/lanspread-tauri-deno-ts/src/lib/types.ts | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/lanspread-tauri-deno-ts/src/components/topbar/SortMenu.tsx b/crates/lanspread-tauri-deno-ts/src/components/topbar/SortMenu.tsx index 0cc9369..60de955 100644 --- a/crates/lanspread-tauri-deno-ts/src/components/topbar/SortMenu.tsx +++ b/crates/lanspread-tauri-deno-ts/src/components/topbar/SortMenu.tsx @@ -6,6 +6,7 @@ import { GameSort } from '../../lib/types'; const OPTIONS: ReadonlyArray<{ key: GameSort; label: string }> = [ { key: 'az', label: 'Name (A–Z)' }, { key: 'size', label: 'Size (largest)' }, + { key: 'sizeAsc', label: 'Size (smallest)' }, { key: 'status', label: 'Status' }, ]; diff --git a/crates/lanspread-tauri-deno-ts/src/lib/gameState.ts b/crates/lanspread-tauri-deno-ts/src/lib/gameState.ts index 6c8015b..63f20b0 100644 --- a/crates/lanspread-tauri-deno-ts/src/lib/gameState.ts +++ b/crates/lanspread-tauri-deno-ts/src/lib/gameState.ts @@ -209,6 +209,8 @@ export const applyFilterAndSort = ( return [...list].sort((a, b) => a.name.localeCompare(b.name)); case 'size': return [...list].sort((a, b) => b.size - a.size); + case 'sizeAsc': + return [...list].sort((a, b) => a.size - b.size); case 'status': return [...list].sort(compareByState); } diff --git a/crates/lanspread-tauri-deno-ts/src/lib/types.ts b/crates/lanspread-tauri-deno-ts/src/lib/types.ts index d744f1a..782d3ec 100644 --- a/crates/lanspread-tauri-deno-ts/src/lib/types.ts +++ b/crates/lanspread-tauri-deno-ts/src/lib/types.ts @@ -60,7 +60,7 @@ export interface GamesListPayload { export type GameFilter = 'all' | 'local' | 'installed'; /** Library sort order. */ -export type GameSort = 'az' | 'size' | 'status'; +export type GameSort = 'az' | 'size' | 'sizeAsc' | 'status'; /** Visual state of a card. Derived from install/download flags. */ export type DerivedState = 'installed' | 'local' | 'none' | 'busy';