diff --git a/DESIGN.md b/DESIGN.md index 2b6b1cd..ee4deb6 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -205,9 +205,9 @@ No UI text below 11px. Counts and numbers use tabular figures. Folder paths in t ## Layout -- **Window:** toolbar, optional notices, then the content area. 24px gutter on bars and notices. Controls on bars are 36px high. Spacing steps are 8, 12, 16 and 24px. +- **Window:** the sidebar on the left, the full window height, and a right pane holding the toolbar, optional notices, then the content area. 24px gutter on bars and notices. Controls on bars are 36px high. Spacing steps are 8, 12, 16 and 24px. - **Library:** a virtualised grid of fixed 180×270 covers, 16px gap, columns centred. Only rows near the viewport exist in the DOM, so card size and gap are constants. The Continue banner (180px) and section labels scroll with the grid. -- **Grouping** follows the sort; there is no separate group control. Each group starts on a new row under its own label with a `text-3` count. Empty groups are hidden. Favorites come first as their own group. Hidden games are left out everywhere except the Hidden filter. +- **Grouping** follows the sort; there is no separate group control. Each group starts on a new row under its own label with a `text-3` count. Empty groups are hidden. Favorites come first as their own group. Hidden games are left out everywhere except the Hidden view. | Sort | Groups | | ---------------- | ------------------------------------------------------------------------- | @@ -217,14 +217,24 @@ No UI text below 11px. Counts and numbers use tabular figures. Folder paths in t | Shortest to beat | the same, reversed | | Title | none | -- **Toolbar,** left to right: search, store selector, Installed, active filter chips, Filters, spacer, Sort, Update (only when one is ready), Downloads (only while something downloads), Add a game, Settings. No sidebar. +- **Toolbar,** left to right: search, store selector, Installed, active filter chips, Filters, then Sort, Update (only when one is ready) and Add a game pushed right. When the pane is too narrow it wraps to a second row (8px apart): search grows from 160px up to 380px, the filter chips wrap, and Sort, Update and Add a game wrap together and stay right-aligned. +- **Sidebar** (`Sidebar.svelte`, Sidebar C): 224px, `glass` fill, `glass-line` right border, a `nav` landmark before the right pane. It stays on the game page, the only way to Downloads and Settings. Top to bottom: + - Library with its count, then Favorites with its count only while it holds a game. Rows are 32px, 8px radius, a 17px line icon, 13px `text-2`; the chosen row is `glass-on` and `text` with `aria-current="page"`. Counts are 11px `text-3` tabular figures over the whole library (one card, one game; hidden games only in Hidden's own count), so they don't move while you search. + - A Collections Label heading (11px `text-3`) with a 24px round + on its right. + opens a name field at the top of the list: Enter creates, Escape cancels. + - One 44px row per collection: a stack of up to three covers (20×30, 3px radius, newest in front, each one behind 5px right, 1px up and 15% dimmer; a `glass` tile when it has none), its name and "N games" in 11px `text-3`. The stacks load only after the grid's first covers. Without collections, a 13px `text-2` note in a `glass-line` box says what they are for. Only this list scrolls; the rows above and below stay put. The list keeps 4px of room on every side so the focus ring isn't clipped. + - A ⋯ button on a collection's hover and focus, and the same menu on right-click and Menu or Shift+F10 (`ActionMenu.svelte`): Rename (the field takes the row; Enter or leaving saves, Escape cancels) and Delete…, which asks in the row with focus on Cancel. Deleting moves focus to the next row, else the previous, else +; deleting the chosen collection returns to Library. Create, rename and delete failures show as a red note under the list. + - Hidden with its count, only while it holds a game. + - Pushed to the bottom: Downloads only while something downloads, with its job count and a 3px `accent-2` bar under the label, updated per poll; it opens the Downloads popover to its right. When the last download ends with focus on it or in its popover, focus moves to Settings. Then Settings, which opens the dialog and carries the 8px amber dot only for a real problem: a saved login that stopped working, or a store that was set up and broke. A store never set up raises nothing. + - Library through Hidden, collections included, are one Tab stop on the chosen row (`tabindex` 0 there, -1 on the rest); Up, Down, Home and End move between them. +, Downloads and Settings are their own Tab stops; ⋯ is not, its menu opens from the row with Menu or Shift+F10. Every row's accessible name is its name and count ("Favorites, 14"; "Backlog, 61 games"). When the chosen row goes away (its last favorite or hidden game, or a deleted collection), the view returns to Library and focus that was in the sidebar goes to Library. + - Below 1100px wide (`RAIL_BELOW` in `sidebar.ts`, also used by the grid's first-covers estimate) it is a 64px rail, switched instantly with no width transition because the virtualised grid's columns follow its width: 44px icon-only buttons with 20px icons, collections as their cover stack only (23×34 covers), a 28px `glass-line` rule in place of the Collections heading, + as the 24px round button under the collections, and no ⋯ (right click and Menu or Shift+F10 still open the menu). Each button has a `Tip` with its name and count, on hover and keyboard focus, opening to the right, 16px out, so it never covers the next icon. Menu or Shift+F10 opens a collection's menu beside its icon. Downloads shows its progress as an `accent-2` ring inside the button's edge instead of the bar; the Settings dot sits in the button's top right. The collections list scrolls without a visible scrollbar. While a name field, a delete question or a failure note is open, the full 224px sidebar lies over the content on `surface-2` with `shadow-modal`, so the grid keeps its width; it returns to the rail when that closes (a failure note closes on Escape, when focus leaves the sidebar or when a row is chosen, in either width). +- **Views:** a sidebar row picks a view (Library, Favorites, a collection, Hidden), never a filter: no chip, not "Results". The toolbar's search, filters and sort narrow and order it, and clearing them keeps the view. The label above an ungrouped grid names the view with its count, or Results while search or filters are on. The Continue banner shows only in Library. An empty view with no search or filters on says so in its own words without a Clear button ("No favorites yet…", Library with every game hidden too); a library with no games at all keeps the empty-library state. Choosing a row on the game page closes the page with focus on the row. - **Settings:** a modal panel, max 760px wide, with a 190px section list on the left (stacked under 640px) that works as vertical tabs: only the chosen section shows, from its top. Sections: Accounts (Stores, then Game data with IGDB and SteamGridDB), General, About. Each section is a title, then Label headings over one rounded `glass` group per heading, its rows split by `glass-line` rules. Never a box per row. About opens with the 64px app logo beside Guild and its version, the acronym in small italic `text-3`, one line on what Guild is for, and Source code · GPL-3.0 · Credits (the README's Thanks); its Updates row then says only what the last check found. On Linux a Wine section sits between General and About (Windows never shows it), direction A (2026-11-09): - The top group: an umu-launcher row with Install only while umu is missing, then Proton for Windows games, one menu (Newest, naming the build that is now, then each build) with the subtitle that a game's own choice in Launch options comes first. - Game tools: Gamescope, MangoHud and GameMode, one switch row each (name, one line on what it does), off by default, and a note that a game's own choice in Launch options comes first. A tool that isn't installed shows its switch disabled and "Not installed" in the row, or in the Flatpak the Flathub extension to install. - Proton builds: one row per build, by a readable name where the folder name allows ("Proton-CachyOS 11.0 (v3)", `protonName` in `format.ts`), with an accent "in use" tag on the build games run with, a "Steam" tag on Steam's, its size once measured, and Remove with an inline confirm for Guild's own only. The last row, Install another build, folds out one panel with a GE-Proton / Proton-CachyOS segmented control and that source's releases, each with Install (its percent while it runs) or Installed. - Prefixes: the heading carries the count and total size on the right. One row per game prefix with its name (the copy key and "Game no longer in your library" once the game is gone), its size once measured, and a ⋯ menu with Open folder, winecfg, winetricks (disabled when neither the system nor any Proton build has it; a note under the group says why) and Remove…, which asks in the row that saves in it are lost unless cloud saves are on, with focus on Cancel. - Rows in these two lists are one height, with or without a button. -- **Game page:** covers the content area while the library stays mounted underneath, so its scroll position survives. A column up to 1360px: the 300px hero, a tab row (Overview, DLC, Saves, Launch options, Installation); on Linux, Launch options adds a Proton menu chip (Default follows Settings), also for added games, and never for a native Linux GOG build; then Gamescope, MangoHud and GameMode rows, each a Default / On / Off menu chip (Default follows Settings), for every game including native ones; a tool that isn't installed shows a disabled Off chip and "Not installed". A Windows game's first launch on Linux shows Setting up… in the busy pill, the card badge and Continue until its program runs, with the percent while its Play downloads umu-launcher or GE-Proton first. Once a Windows game has run on Linux, Installation gets a Wine prefix row with Open, winecfg and winetricks (disabled with the same reason as in Settings); never for a native Linux build, and never Remove, which stays in Settings and the uninstall confirm. Its uninstall confirm offers an Also remove its Wine prefix checkbox, off by default, then three fact tiles and an About / Details grid (1.7fr / 1fr). +- **Game page:** covers the right pane's content area, beside the sidebar, while the library stays mounted underneath, so its scroll position survives. A column up to 1360px: the 300px hero, a tab row (Overview, DLC, Saves, Launch options, Installation); on Linux, Launch options adds a Proton menu chip (Default follows Settings), also for added games, and never for a native Linux GOG build; then Gamescope, MangoHud and GameMode rows, each a Default / On / Off menu chip (Default follows Settings), for every game including native ones; a tool that isn't installed shows a disabled Off chip and "Not installed". A Windows game's first launch on Linux shows Setting up… in the busy pill, the card badge and Continue until its program runs, with the percent while its Play downloads umu-launcher or GE-Proton first. Once a Windows game has run on Linux, Installation gets a Wine prefix row with Open, winecfg and winetricks (disabled with the same reason as in Settings); never for a native Linux build, and never Remove, which stays in Settings and the uninstall confirm. Its uninstall confirm offers an Also remove its Wine prefix checkbox, off by default, then three fact tiles and an About / Details grid (1.7fr / 1fr). ## Elevation and shapes @@ -248,16 +258,14 @@ No UI text below 11px. Counts and numbers use tabular figures. Folder paths in t - Focus is a 2px `focus` outline with 2px offset, everywhere. Disabled is 60% opacity. A busy button ("Downloading…", "Queued") is `aria-disabled` so it keeps focus. Play on a card or the Continue banner turns into a busy Launching… pill until the launch command returns, so a second click starts nothing. - Favorites and Settings switches change on click and flip back if the save fails; Settings opens on the last read view and refreshes behind it. - **Chips:** 36px, `glass` fill, `glass-line` border, `text-2`. Selected (`aria-pressed`) is `glass-on`, `glass-on-line`, `text`. - - The Settings chip carries an 8px amber dot only for a real problem: a saved login that stopped working, or a store that was set up and broke. A store never set up raises nothing. - The store selector is one segmented control (a bits-ui `RadioGroup`) listing only the stores the library has games from. It is absent with one store. Arrows (all four), Home and End move to a segment and pick it, wrapping; one segment is the Tab stop. - - The Downloads chip shows progress as a 2px `accent-2` ring that fills clockwise and updates per poll, never per frame. - **Tooltips** (`Tip.svelte`, bits-ui): `surface-2`, `glass-on-line` border, 8px radius, 12px `text`, shadow `0 8px 24px rgb(0 0 0 / .5)` (`--shadow-modal` is for dialogs). One provider in `App.svelte`: hover opens after 500ms, and a neighbour within 300ms opens at once. Keyboard focus opens at once; focus that moves without the keyboard (a dialog handing focus back, a popover focusing its first button) opens none. Fades in 120ms, not under reduced motion. - Use on icon-only buttons (keep the `aria-label`) and on labelled buttons whose hint explains something else. A button that can be disabled gets a `tip-anchor` wrapper (`inline-flex`), since a disabled button fires no pointer events; the wrapper also opens on focus of the button inside. Text that shows less than the tooltip (a file name for its path) gets a plain `Tip`. - Ellipsized text whose tooltip repeats it in full (paths, `.note` lines) uses `truncated`: hover only, no tab stop, and it opens only while the text is actually cut. The game card keeps its native `title`. - **Popovers** (Filters, Sort, Downloads, Notes, the ⋯ menu, Play with): `surface-2`, `glass-on-line` border, 12px radius, modal shadow. - - Filters, Downloads, Update and Notes are bits-ui `Popover`s: focus moves in on open, Tab stays inside, Escape closes only the top one and returns focus to its button, a click outside closes, and mouse Back and Forward leave them open (`keepOnBackForward`). They follow their button, flip and shift to stay inside the window, and don't lock page scroll. Escape in the Filters rename field cancels only the rename. + - Filters, Downloads, Update and Notes are bits-ui `Popover`s: focus moves in on open, Tab stays inside, Escape closes only the top one and returns focus to its button, a click outside closes, and mouse Back and Forward leave them open (`keepOnBackForward`). They follow their button, flip and shift to stay inside the window, and don't lock page scroll. The Filters popover has Status, Your playtime, How long to beat and Has (with more than one store); lists are sidebar views. - Sort, Language (Settings and the install panel), Proton, the install folder menu and Play with are bits-ui `DropdownMenu`s (`ChoiceMenu.svelte`, `PlayButton.svelte`): the caller's chip is the trigger, focus starts on the chosen item, arrows, Home, End and typing a letter move between items, Escape or a pick returns focus to the chip. Mouse Back and Forward leave them open (`keepOnBackForward`). - - A Settings prefix row's ⋯ menu (`ActionMenu.svelte`) is a bits-ui `DropdownMenu` too: focus starts on the first item that can run, a disabled item stays listed, and a pick returns focus to ⋯ (Remove… moves it to the row's Cancel instead). + - A Settings prefix row's ⋯ menu and a sidebar collection's ⋯ menu (`ActionMenu.svelte`) are bits-ui `DropdownMenu`s too; the collection's right-click and Menu key open one instance at the pointer: focus starts on the first item that can run, a disabled item stays listed, and a pick returns focus to ⋯ (Remove… and Delete… move it to the row's Cancel, Rename to its field). - The game menu (`GameMenu.svelte`) is a bits-ui `DropdownMenu` too: on the game page the ⋯ button is its trigger; a card's right-click opens the one instance in `App.svelte` at the pointer, and a grid scroll closes it. Focus starts on the first item. Right opens Add to collection, Left or Escape closes only the submenu. Menu and submenu flip and shift to stay 8px inside the window. Keys typed into the new collection's name stay in the field, and while it is open hovering does not move focus; Escape there cancels only the name. - The import pickers in Settings (Epic, Amazon) are a bits-ui `Combobox` (`GamePicker.svelte`): the Settings field look, the menu look for the list, opening with the first game picked. Typing filters by part of the title and clears the pick, so Import stays disabled until a game is chosen; a query matching nothing shows one row, "No game with that name". Emptying the field brings back the full list with the first game picked. Arrows and Enter pick, Escape closes only the list, and the list sits above the Settings dialog (z-index 50). Mouse Back and Forward leave it open (`keepOnBackForward`). - Bits-ui menus keep Tab inside the menu (WAI-ARIA menu pattern), and open a submenu on hover as well as Right. None lock page scroll (`preventScroll={false}`): bits-ui's lock also turns off pointer events on the page, which swallowed the first click outside, so moving from one open menu to another chip took two clicks. @@ -270,11 +278,11 @@ No UI text below 11px. Counts and numbers use tabular figures. Folder paths in t - Escape or a click outside closes only the top layer (a menu, popover or tooltip opened inside, or Steam log in over Settings) and returns focus to what opened it. Mouse Back and Forward never close a dialog (`keepOnBackForward`), and App ignores them while one is open. - Stacking: Settings and Add a game 20, the install popup and Notes 30, Steam log in 40, menus and the other popovers 50, tooltips 60. - **Cover card:** - - States: installed is full color. Not installed is `saturate(0.5) brightness(0.75)` with a bottom-left glass Install chip. Running gets the green badge and ring. Installing gets a 6px progress strip. Queued and Paused get glass chips. - - In the playtime and length sorts, a stat chip ("38 h played", "~25 h to beat") takes the same spot. + - States: installed is full color. Not installed is `saturate(0.5) brightness(0.75)`, with no chip at rest; its cover button's label says it isn't installed. Running gets the green badge and ring. Installing gets a 6px progress strip. Queued and Paused get glass chips. + - In the playtime and length sorts, a stat chip ("38 h played", "~25 h to beat") sits bottom-left. An installed game with an update gets an Update chip there. - Loading: while the cover loads the card shows `surface-2`, then the cover's average color, then the image fading in over 150ms. - - The store logo sits top-right in a 26px glass circle. - - On hover: lift, white ring, title, and a small Play or Install pill. The hover overlay is absent when idle, not transparent, to keep scrolling cheap. + - The store logos sit top-right, one 26px glass circle per store, at 77% scale and 60% opacity at rest and full size and opacity on hover and focus. + - On hover and focus: lift, white ring, title, and a small pill: the white Play pill when installed, a glass Install pill when not. The hover overlay is absent when idle, not transparent, to keep scrolling cheap. - **Notices:** `glass-strong`, 12px radius, with a dismiss button. Errors get a red border and `error-text` and are `role="alert"`; the others are `role="status"`. - **Fields:** 36px, `glass` fill, `glass-line` border, `text-3` placeholder. Saved secrets show only as a read-only "••••••••" field with "Saved", Replace and Remove; the real value never reaches the UI. - **Toggle:** 40×22 pill, white 18% off, `accent` on, a bits-ui `Switch`; Space and Enter flip it. @@ -318,12 +326,13 @@ No UI text below 11px. Counts and numbers use tabular figures. Folder paths in t ## Owner decisions - The look: last-played art blurred and saturated behind everything, dark glass chrome, white pill for the primary action (2026-11-05). -- Covers carry the real store logo top-right. Not installed means faded, with an Install chip bottom-left (option C). +- Covers carry the real store logo top-right. Not installed means faded, with no chip at rest; Install shows on hover (2026-11-26). - The game page's fact tiles are Playtime, Last played and How long to beat, not size. Size lives in Details. - Settings is a frosted panel with Accounts, General and About, as grouped rows (settings v4, 2026-11-07). Its section list switches sections instead of scrolling to them, and Services moved into Accounts as Game data (2026-11-09). Don't show tool versions there, except when an update is available. - Ambient color can be turned off, which gives a neutral dark gradient. - Add a game is a chip in the toolbar. Covers come from SteamGridDB or a file (2026-11-07). - About header A: logo, name, version and acronym, no Made by and no credit list in the app; Credits links to the README (2026-11-09). +- Sidebar C: Library, Favorites, Collections with cover stacks and Hidden on the left, Downloads and Settings at its bottom; no Home or list view (2026-11-26). - Downloads popover layout F2: one two-line row per download where the row itself is the progress bar (2026-11-07). - Install panel direction A: beside the cover in the library, inline under Install on the game page, real folder and drive space, DLC chosen there (2026-11-09). - Settings → Wine direction A: Proton for Windows games as one menu on top, builds listed with their source, one Install another build panel, prefix actions behind ⋯ (2026-11-09). diff --git a/package.json b/package.json index de1f63e..9812e70 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "build": "vite build", "check": "svelte-check --tsconfig ./tsconfig.app.json && tsc -p tsconfig.node.json", "tauri": "tauri", - "test": "node --test scripts/filters.test.ts scripts/format.test.ts scripts/changelog.test.ts scripts/messages.test.ts scripts/i18n.test.ts scripts/outside.test.ts", + "test": "node --test scripts/filters.test.ts scripts/sidebar.test.ts scripts/format.test.ts scripts/changelog.test.ts scripts/messages.test.ts scripts/i18n.test.ts scripts/outside.test.ts", "bump": "node scripts/bump.ts", "format": "prettier --write .", "format:check": "prettier --check ." diff --git a/scripts/filters.test.ts b/scripts/filters.test.ts index 51a8fa9..c4aa763 100644 --- a/scripts/filters.test.ts +++ b/scripts/filters.test.ts @@ -1,18 +1,7 @@ // node --test scripts/ import { test } from 'node:test' import assert from 'node:assert/strict' -import { - collectionFilter, - filterChips, - filterGroups, - isList, - matches, - removeChip, - storeSegments, - titleMatches, - toggleFilter, - type Filter, -} from '../src/lib/filters.ts' +import { collectionFilter, filterChips, filterGroups, matches, removeChip, storeSegments, titleMatches, toggleFilter, type Filter } from '../src/lib/filters.ts' test('chips follow the popover order, one per filter that is on', () => { assert.deepEqual(filterChips([]), []) @@ -107,37 +96,19 @@ test('the new groups widen inside and narrow across', () => { ) }) -const collections = [ - { id: 3, name: 'Backlog', count: 2 }, - { id: 7, name: 'Co-op', count: 1 }, -] - -test('Lists come after Status: Favorites, each collection, then Hidden', () => { - const lists = filterGroups(collections)[1] - assert.deepEqual(lists, { label: 'Lists', filters: ['favorites', 'collection-3', 'collection-7', 'hidden'] }) - assert.deepEqual(filterGroups([])[1].filters, ['favorites', 'hidden']) - assert.deepEqual( - filterGroups([]).map((g) => g.label), - ['Status', 'Lists', 'Your playtime', 'How long to beat', 'Has'], - ) -}) - -test('list chips are named after the list and come after Status', () => { - const on: Filter[] = ['bothStores', 'hidden', collectionFilter(7), 'notInstalled', 'favorites'] +test('the popover has no Lists group', () => { assert.deepEqual( - filterChips(on, collections).map((c) => c.label), - ['Not installed', 'Favorites', 'Co-op', 'Hidden', 'On more than one store'], + filterGroups().map((g) => g.label), + ['Status', 'Your playtime', 'How long to beat', 'Has'], ) - const left = removeChip(on, filterChips(on, collections)[2]) - assert.deepEqual(left, ['bothStores', 'hidden', 'notInstalled', 'favorites']) - assert.ok(isList('collection-7') && isList('hidden') && !isList('update')) }) -test('lists widen each other and narrow the other groups', () => { +test('the view relies on lists widening each other and narrowing the other groups', () => { const fav = { ...game, favorite: true } const inCoop = { ...game, collections: [7] } const hidden = { ...game, hidden: true, installed: false } assert.ok(matches(fav, ['favorites'], {})) + assert.ok(!matches(game, ['favorites'], {})) assert.ok(!matches(inCoop, ['favorites'], {})) assert.ok(matches(inCoop, ['favorites', collectionFilter(7)], {})) assert.ok(!matches(inCoop, [collectionFilter(3)], {})) @@ -154,10 +125,10 @@ test('more than one store means two or more, of any stores', () => { }) test('the Has group shows only with more than one store in use', () => { - const ids = (multi: boolean) => filterGroups([], multi).flatMap((g) => g.filters) + const ids = (multi: boolean) => filterGroups(multi).flatMap((g) => g.filters) assert.ok(ids(true).includes('bothStores')) assert.ok(!ids(false).includes('bothStores')) - assert.equal(filterGroups([], false).length, filterGroups([]).length - 1) + assert.equal(filterGroups(false).length, filterGroups().length - 1) }) test('store segments: All plus the stores in use, none for a single store', () => { diff --git a/scripts/sidebar.test.ts b/scripts/sidebar.test.ts new file mode 100644 index 0000000..94babfe --- /dev/null +++ b/scripts/sidebar.test.ts @@ -0,0 +1,46 @@ +// node --test scripts/ +import { test } from 'node:test' +import assert from 'node:assert/strict' +import { downloadFraction, fallbackView, viewCount, viewLists, withView } from '../src/lib/sidebar.ts' +import type { Filter } from '../src/lib/filters.ts' +import type { Progress, QueueView } from '../src/lib/bindings.ts' + +const counts = { library: 9, favorites: 2, hidden: 1 } +const collections = [{ id: 3, name: 'Backlog', count: 4, covers: [] }] + +test('the view joins the filters matches() gets', () => { + assert.deepEqual(withView(['notInstalled'], 'collection-3'), ['notInstalled', 'collection-3']) + const f: Filter[] = ['update'] + assert.deepEqual(withView(f, null), f) +}) + +test('the library is asked for the view as its only list', () => { + assert.deepEqual(viewLists(null), []) + assert.deepEqual(viewLists('hidden'), ['hidden']) +}) + +test('a view counts its own games', () => { + assert.equal(viewCount(null, counts, collections), 9) + assert.equal(viewCount('favorites', counts, []), 2) + assert.equal(viewCount('hidden', counts, []), 1) + assert.equal(viewCount('collection-3', counts, collections), 4) +}) + +test('a view whose row is gone falls back to the library', () => { + assert.equal(fallbackView('favorites', { ...counts, favorites: 0 }, []), null) + assert.equal(fallbackView('favorites', counts, []), 'favorites') + assert.equal(fallbackView('hidden', { ...counts, hidden: 0 }, []), null) + assert.equal(fallbackView('collection-3', counts, []), null) + assert.equal(fallbackView('collection-3', counts, collections), 'collection-3') + assert.equal(fallbackView(null, counts, []), null) +}) + +const job = (fraction: number) => ({ fraction }) as Progress + +test('the download fraction is the active job, else the average, else 0', () => { + const queue = (active: string | null) => ({ jobs: [], paused: false, active }) as QueueView + assert.equal(downloadFraction({ a: job(0.2), b: job(0.9) }, queue('b')), 0.9) + assert.ok(Math.abs(downloadFraction({ a: job(0.2), b: job(0.6) }, queue(null)) - 0.4) < 1e-9) + assert.equal(downloadFraction({}, queue(null)), 0) + assert.equal(downloadFraction({ a: job(0.5) }, queue('gone')), 0.5) +}) diff --git a/src-tauri/src/commands/library.rs b/src-tauri/src/commands/library.rs index be5f06e..a6091fb 100644 --- a/src-tauri/src/commands/library.rs +++ b/src-tauri/src/commands/library.rs @@ -103,6 +103,34 @@ pub struct Library { amazon_attention: bool, /// The stores the whole library has a game from, in toolbar order; games the owner added don't count. stores: Vec, + /// For the sidebar's rows. + counts: Counts, +} + +#[derive(Serialize, specta::Type)] +pub struct Counts { + /// Cards that are not hidden. + library: usize, + /// Favorites that are not hidden. + favorites: usize, + hidden: usize, +} + +fn sidebar_counts(entries: &[Entry], games: &[Game], lists: &Lists) -> Counts { + let mut c = Counts { + library: 0, + favorites: 0, + hidden: 0, + }; + for e in entries { + if lists.hidden(e, games) { + c.hidden += 1; + } else { + c.library += 1; + c.favorites += usize::from(lists.favorite(e, games)); + } + } + c } /// `lists` are the Lists filters that are on ("favorites", "hidden", "collection-"); the UI applies @@ -171,6 +199,7 @@ pub fn library( amazon: s.amazon_login, amazon_attention, stores: stores_in_use(&s.games), + counts: sidebar_counts(&s.entries, &s.games, &s.lists), } } @@ -250,6 +279,8 @@ pub struct ViewPrefs { pub async fn load_cache(app: AppHandle) -> Res { blocking(move || { let state = app.state::(); + // Held until the lists are published, so a list change can't be overwritten by an older read. + let turn = state.lists_write.lock().expect("lists lock poisoned"); let conn = cache::db::open(&state.dirs.db)?; let mut games = cache::db::load(&conn)?; view::merge_last_played(&mut games, &cache::db::launches(&conn)?); @@ -261,6 +292,7 @@ pub async fn load_cache(app: AppHandle) -> Res { let mut s = state.lock(); s.ttb = ttb; s.lists = lists; + drop(turn); // A scan that already finished wins over the cache. if s.games.is_empty() { s.games = games; @@ -1863,6 +1895,24 @@ mod tests { (games, entries, lists) } + #[test] + fn sidebar_counts_count_cards_and_leave_hidden_out() { + use crate::view::tests::game; + let games = vec![ + game("a", true, None, None), + game("b", true, None, None), + game("c", true, None, None), + ]; + let entries = entries::group(&games, &HashMap::new()); + let lists = Lists { + favorite: HashSet::from([games[0].key(), games[1].key()]), + hidden: HashSet::from([games[1].key(), games[2].key()]), + ..Lists::default() + }; + let c = sidebar_counts(&entries, &games, &lists); + assert_eq!((c.library, c.favorites, c.hidden), (1, 1, 2)); + } + #[test] fn library_payload_snapshot() { let (games, entries, lists) = payload_games(); @@ -1893,6 +1943,7 @@ mod tests { amazon: None, amazon_attention: false, stores: stores_in_use(&games), + counts: sidebar_counts(&entries, &games, &lists), }; insta::assert_json_snapshot!(library); } diff --git a/src-tauri/src/commands/lists.rs b/src-tauri/src/commands/lists.rs index ee99a08..db8e507 100644 --- a/src-tauri/src/commands/lists.rs +++ b/src-tauri/src/commands/lists.rs @@ -1,7 +1,5 @@ //! Favorites, hidden games and collections. Stored per copy key, so setting one on a game sets every copy. -use std::collections::HashMap; - use serde::Serialize; use tauri::{AppHandle, Manager}; @@ -14,8 +12,10 @@ use crate::msg::Msg; pub struct Collection { id: i64, name: String, - /// Games in it. + /// Games in it, hidden ones left out. count: usize, + /// Up to three entry keys of its games, most recently played first. + covers: Vec, } /// Every copy key of the game with this key. @@ -28,6 +28,8 @@ fn copy_keys(state: &AppState, key: &str) -> Res> { /// Runs a change on the database, then reads the lists again for the library. fn change(app: &AppHandle, f: impl FnOnce(&mut rusqlite::Connection) -> Res) -> Res { let state = app.state::(); + // Held to the publish below, so two changes can't publish their reads out of order. + let _turn = state.lists_write.lock().expect("lists lock poisoned"); let mut conn = open_db(&state).ok_or(msg!(noDb))?; let out = f(&mut conn)?; let lists = cache::db::lists(&conn)?; @@ -67,24 +69,39 @@ pub async fn collections(app: AppHandle) -> Res> { let state = app.state::(); let list = collections_in(&open_db(&state).ok_or(msg!(noDb))?)?; let s = state.lock(); - let mut counts: HashMap = HashMap::new(); - for e in &s.entries { - for id in s.lists.collections(e, &s.games) { - *counts.entry(id).or_default() += 1; - } - } Ok(list .into_iter() - .map(|(id, name)| Collection { - id, - count: counts.get(&id).copied().unwrap_or(0), - name, + .map(|(id, name)| { + let (count, covers) = collection_summary(id, &s.entries, &s.games, &s.lists); + Collection { + id, + name, + count, + covers, + } }) .collect()) }) .await } +/// How many games a collection holds, hidden ones left out, and up to three of their keys, most recently +/// played first. `entries` are in title order, so the stable sort puts never-played ones after, by title. +fn collection_summary( + id: i64, + entries: &[entries::Entry], + games: &[crate::library::Game], + lists: &crate::view::Lists, +) -> (usize, Vec) { + let mut members: Vec<&entries::Entry> = entries + .iter() + .filter(|e| !lists.hidden(e, games) && lists.collections(e, games).contains(&id)) + .collect(); + members.sort_by_key(|e| std::cmp::Reverse(entries::last_played(e, games).map(|p| p.0))); + let covers = members.iter().take(3).map(|e| e.key.clone()).collect(); + (members.len(), covers) +} + /// The name to store: trimmed, not empty, and not another collection's in any case. fn check_name(name: &str, taken: &[(i64, String)], except: Option) -> Res { let name = name.trim(); @@ -174,4 +191,26 @@ mod tests { assert_eq!(check_name("BACKLOG", &taken, Some(1)).unwrap(), "BACKLOG"); assert!(check_name("co-op ", &taken, Some(1)).is_err()); } + + #[test] + fn collection_summary_skips_hidden_and_takes_three_latest_covers() { + use crate::view::tests::game; + use std::collections::{HashMap, HashSet}; + // Titles sort a..e; played 1..4 for a..d, e never, and "b" hidden. + let games: Vec<_> = [("a", 1), ("b", 2), ("c", 3), ("d", 4), ("e", 0)] + .into_iter() + .map(|(t, n)| game(t, true, None, (n > 0).then_some(n))) + .collect(); + let entries = entries::group(&games, &HashMap::new()); + let keys: Vec = games.iter().map(|g| g.key()).collect(); + let lists = crate::view::Lists { + hidden: HashSet::from([keys[1].clone()]), + collections: keys.iter().map(|k| (k.clone(), vec![7])).collect(), + ..Default::default() + }; + let (count, covers) = collection_summary(7, &entries, &games, &lists); + assert_eq!(count, 4); + assert_eq!(covers, [keys[3].clone(), keys[2].clone(), keys[0].clone()]); + assert_eq!(collection_summary(8, &entries, &games, &lists), (0, vec![])); + } } diff --git a/src-tauri/src/commands/mod.rs b/src-tauri/src/commands/mod.rs index 0812411..69d040a 100644 --- a/src-tauri/src/commands/mod.rs +++ b/src-tauri/src/commands/mod.rs @@ -34,6 +34,8 @@ pub struct AppState { dirs: Dirs, http: reqwest::Client, shared: Mutex, + /// Held from reading the lists in SQLite to publishing them in `shared`. Taken before `shared`, never after. + lists_write: Mutex<()>, cover_jobs: tokio::sync::Semaphore, /// Held across every Steam logon (download size, DLC, owned games), so they never stack. steam_size: tokio::sync::Mutex<()>, @@ -157,6 +159,7 @@ impl AppState { status: vec![msg!(loadingLibrary)], ..Shared::default() }), + lists_write: Mutex::new(()), cover_jobs: tokio::sync::Semaphore::new(COVER_JOBS), steam_size: tokio::sync::Mutex::new(()), scans: library::ScanTurns::default(), diff --git a/src-tauri/src/commands/snapshots/launcher__commands__library__tests__library_payload_snapshot.snap b/src-tauri/src/commands/snapshots/launcher__commands__library__tests__library_payload_snapshot.snap index 1055b86..2963dc8 100644 --- a/src-tauri/src/commands/snapshots/launcher__commands__library__tests__library_payload_snapshot.snap +++ b/src-tauri/src/commands/snapshots/launcher__commands__library__tests__library_payload_snapshot.snap @@ -80,5 +80,10 @@ expression: library "steam", "epic", "gog" - ] + ], + "counts": { + "library": 2, + "favorites": 1, + "hidden": 0 + } } diff --git a/src/App.svelte b/src/App.svelte index da70efe..14c5afe 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -41,6 +41,7 @@ } from './lib/bindings' import Ambient from './lib/Ambient.svelte' import Toolbar from './lib/Toolbar.svelte' + import Sidebar from './lib/Sidebar.svelte' import Continue from './lib/Continue.svelte' import Grid from './lib/Grid.svelte' import Detail from './lib/Detail.svelte' @@ -49,7 +50,8 @@ import GameMenu from './lib/GameMenu.svelte' import AddGame from './lib/AddGame.svelte' import NotesPopover, { installedNotes } from './lib/NotesPopover.svelte' - import { collectionFilter, isList, matches, type Filter } from './lib/filters' + import { filterName, matches, type Filter } from './lib/filters' + import { fallbackView, RAIL_BELOW, viewCount, viewLists, withView, type Pop, type View } from './lib/sidebar' import { around, t } from './lib/i18n' import { setLanguage } from './lib/lang.svelte' @@ -59,7 +61,13 @@ let installedOnly = $state(false) /** The Filters popover's extra filters, applied here to the loaded list. */ let filters = $state([]) - let popoverOpen = $state(false) + /** The sidebar's chosen row; never a filter. */ + let view = $state(null) + /** The view the loaded `lib` is for: the grid filters and groups against it, not a newer one still loading. */ + let libView = $state(null) + let pop = $state(null) + /** A popover is open; mouse Back/Forward are ignored meanwhile, as for Settings. */ + const popoverOpen = $derived(pop !== null) let collections = $state([]) let lib = $state({ @@ -76,6 +84,7 @@ amazon: null, amazonAttention: false, stores: [], + counts: { library: 0, favorites: 0, hidden: 0 }, }) let featured = $state(null) let version = $state(0) @@ -100,6 +109,8 @@ let refreshedAt = $state(null) /** The saved library has been read; until then the window stays quiet instead of saying "loading". */ let started = $state(false) + /** The first screen of covers has settled; the sidebar's cover stacks wait for it. */ + let coversReady = $state(false) let benchSpeed = $state(null) /** The benchmark waits for both stores, so it scrolls the whole library. */ let ready = $state(false) @@ -138,9 +149,16 @@ } } + let loads = 0 async function load() { - // Rust needs the Lists filters: Hidden brings hidden games back, and they decide whether favorites go on top. - lib = await api.library(query, store, installedOnly, sort, filters.filter(isList)) + const n = ++loads + const asked = view + // Rust needs the view: Hidden brings hidden games back, and it decides whether favorites go on top. + const got = await api.library(query, store, installedOnly, sort, viewLists(asked)) + // Only the newest request publishes, so a late answer for an earlier view or search can't replace it. + if (n !== loads) return + lib = got + libView = asked version++ // A store the toolbar no longer offers (logged out, or the only one left) stops filtering; so does Has. const multi = lib.stores.length > 1 @@ -154,9 +172,7 @@ const [, f, c] = await Promise.all([load(), api.featured(), commands.collections().catch(() => collections), withSettings && loadSettings()]) featured = f collections = c - // A collection that went away takes its filter along. - const gone = (f: Filter) => f.startsWith('collection-') && !c.some((x) => collectionFilter(x.id) === f) - if (filters.some(gone)) filters = filters.filter((f) => !gone(f)) + view = fallbackView(view, lib.counts, c) } /** The heart fills at once; the reload after moves the game into or out of Favorites. */ @@ -179,7 +195,7 @@ } $effect(() => { - void [query, store, sort, installedOnly, filters] + void [query, store, sort, installedOnly, filters, view] load() }) @@ -335,7 +351,7 @@ async function firstCovers() { // The grid's card pitch (180 px card + 16 px gap, rows 286 px); measured from the window, since the // hidden window may not lay out yet. A few extra covers are harmless. - const cols = Math.max(1, Math.floor((window.innerWidth - 16) / 196)) + const cols = Math.max(1, Math.floor((window.innerWidth - (window.innerWidth < RAIL_BELOW ? 64 : 224) - 16) / 196)) const rows = Math.ceil(window.innerHeight / 286) const covers = lib.games.slice(0, cols * rows).map((g, i) => api.cover(g.key, i)) await Promise.race([Promise.allSettled(covers), new Promise((done) => setTimeout(done, 300))]) @@ -355,6 +371,7 @@ await reload() started = true await firstCovers() + coversReady = true commands.ready() loadSettings() // Holds the flag so a focus event during startup doesn't start a second full refresh. @@ -409,12 +426,13 @@ /** The last page closed this session, for the Forward button. */ let lastClosed: string | null = null - async function closeGame() { + /** `restore` false leaves focus where it is (a sidebar row was chosen). */ + async function closeGame(restore = true) { if (open) lastClosed = open open = null saveConflict = null tint = undefined - const back = opener + const back = restore ? opener : null opener = null // The library is visible again only after the update; a recycled-away card is gone (isConnected). await tick() @@ -444,11 +462,12 @@ // Worked out when the list, the filters or (with "Downloading" on) the progress change; never per frame. // Filtering keeps each group's cards together and drops groups left empty. - const view = $derived.by((): { games: Library['games']; sections: Section[] | null } => { + const grid = $derived.by((): { games: Library['games']; sections: Section[] | null } => { const sections = lib.groups.length ? lib.groups : null - if (filters.length === 0) return { games: lib.games, sections } - const p = filters.includes('downloading') ? progress : {} - const keep = (g: Library['games'][number]) => matches(g, filters, p) + const on = withView(filters, libView) + if (on.length === 0) return { games: lib.games, sections } + const p = on.includes('downloading') ? progress : {} + const keep = (g: Library['games'][number]) => matches(g, on, p) if (!sections) return { games: lib.games.filter(keep), sections } const games: Library['games'] = [] const kept: Section[] = [] @@ -462,7 +481,7 @@ // No favorite left: under Title the rest is one list again. return { games, sections: kept.length === 1 && kept[0].group === 'allGames' ? null : kept } }) - const shown = $derived(view.games) + const shown = $derived(grid.games) /** The hours every card's badge shows while sorting by them: how long to beat or playtime. */ const stat = $derived(sort === 'longestToBeat' || sort === 'shortestToBeat' ? 'ttb' : sort === 'mostPlayed' ? 'playtime' : null) @@ -479,20 +498,22 @@ const cancelDownload = (key: string) => changeQueue(() => commands.cancelInstall(key)) const resumeDownloads = () => changeQueue(commands.resumeDownloads) - /** A store needs the owner: the dot on the Settings button and on Settings' Accounts. */ + /** A store needs the owner: the dot on the Settings row and on Settings' Accounts. */ const attention = $derived(lib.epicAttention || lib.steamAttention || lib.gogAttention || lib.amazonAttention) const ambientHero = $derived(open !== null && tint !== undefined ? tint : (featured?.hero ?? null)) - const showContinue = $derived(featured !== null && query === '' && (settings?.showBanner ?? true)) + const showContinue = $derived(libView === null && featured !== null && query === '' && (settings?.showBanner ?? true)) const BANNER_H = 180 const LABEL_H = 18 // Grouped, each group has its own label row in the grid instead of the one "Library" label. - const headerHeight = $derived((showContinue ? BANNER_H + 24 : 0) + (view.sections ? 0 : LABEL_H)) + const headerHeight = $derived((showContinue ? BANNER_H + 24 : 0) + (grid.sections ? 0 : LABEL_H)) /** The Epic filter with no Epic games at all: say why and offer the fix. */ const epicEmpty = $derived(store === 'epic' && query === '' && !installedOnly && lib.games.length === 0) /** Store, Installed or a Filters filter is on. */ const filtered = $derived(store !== null || installedOnly || filters.length > 0) /** A finished scan found nothing: Rust's lone "no games found" status. */ const noGames = $derived(lib.total === 0 && lib.status.length === 1 && lib.status[0].code === 'noGamesFound') + /** The view's own size, before search and filters. */ + const viewTotal = $derived(viewCount(libView, lib.counts, collections)) @@ -503,190 +524,216 @@
- changeQueue(commands.pauseDownloads)} onresume={resumeDownloads} onmove={(key, up) => changeQueue(() => commands.moveDownload(key, up))} onsettings={() => openSettings()} - onadd={() => openAddGame()} - {update} - appVersion={settings?.appVersion ?? ''} - running={running !== null} - {installing} - {installError} - oninstall={installUpdate} + onchanged={reload} + onnavigate={() => open && closeGame(false)} /> - {#if updatedTo} - {@const notes = installedNotes(updatedTo)} - {@const [before, after] = around('app.updatedTo', 'version')} -
- {before}{updatedTo}{after} - {#if notes} - - - {/if} - -
- {/if} - {#if lib.epicNotice} -
- {t('app.epicLoggedOut')} - - -
- {/if} - {#if error} - - {/if} - - {#if confirming} - - {#key confirming.game.key} - (confirming = null)} - onconfirm={(choice) => { - const { key } = confirming!.game - confirming = null - act('install', key, { choice }) - }} - /> - {/key} - {/if} - -
- -
- {#if shown.length > 0} - + openAddGame()} + {update} + appVersion={settings?.appVersion ?? ''} + running={running !== null} + {installing} + {installError} + oninstall={installUpdate} + /> + + {#if updatedTo} + {@const notes = installedNotes(updatedTo)} + {@const [before, after] = around('app.updatedTo', 'version')} +
+ {before}{updatedTo}{after} + {#if notes} + + + {/if} + +
+ {/if} + {#if lib.epicNotice} +
+ {t('app.epicLoggedOut')} + + +
+ {/if} + {#if error} + + {/if} + + {#if confirming} + + {#key confirming.game.key} + (confirming = null)} + onconfirm={(choice) => { + const { key } = confirming!.game + confirming = null + act('install', key, { choice }) + }} + /> + {/key} + {/if} + +
+ +
+ {#if shown.length > 0} + act('play', key)} + oninstall={install} + oncancel={cancelDownload} + onresume={resumeDownloads} + onfavorite={setFavorite} + onmenu={openCardMenu} + benchSpeed={ready ? benchSpeed : null} + {headerHeight} + > + {#snippet header()} + {#if showContinue && featured} +
+ act('play', key)} + onopen={openGame} + /> +
+ {/if} + {#if !grid.sections} +

+ {query || filtered ? t('app.results') : libView ? filterName(libView, collections) : t('app.library')} + {shown.length} +

+ {/if} + {/snippet} +
+ {:else if epicEmpty && lib.epic === 'noTool'} +
+

{t('app.noLegendary')}

+ {t('app.noLegendaryHint')} +
+ +
+
+ {:else if epicEmpty && lib.epic === 'loggedOut'} +
+

{t('app.epicLoggedOutEmpty')}

+ +
+ {:else if epicEmpty && lib.epic === 'unreachable'} +
+

{t('app.epicUnreachable')}

+ {t('app.epicUnreachableHint')} +
+ {:else if started && lib.counts.library + lib.counts.hidden > 0 && !query && !filtered && viewTotal === 0} + + {#if fallbackView(libView, lib.counts, collections) === libView} +
+

+ {libView === null + ? t('sidebar.allHidden') + : libView === 'favorites' + ? t('sidebar.emptyFavorites') + : libView === 'hidden' + ? t('sidebar.emptyHidden') + : t('sidebar.emptyCollection', { name: filterName(libView, collections) })} +

+
+ {/if} + {:else if started && lib.counts.library + lib.counts.hidden > 0} +
+

{t('app.noMatch')}

+ {query && filtered ? t('app.noMatchQueryFilters', { query }) : query ? t('app.noMatchQuery', { query }) : t('app.noMatchFilters')} +
+ +
+
+ {:else if started && noGames} +
+

{t('app.noGames')}

+ {t('app.noGamesHint')} +
+ + +
+
+ {:else if started} +
+

{lib.status.map(api.message).join('\n')}

+
+ {/if} +
+ {#if open} + act('play', key)} - oninstall={install} oncancel={cancelDownload} onresume={resumeDownloads} - onfavorite={setFavorite} - onmenu={openCardMenu} - benchSpeed={ready ? benchSpeed : null} - {headerHeight} - > - {#snippet header()} - {#if showContinue && featured} -
- act('play', key)} - onopen={openGame} - /> -
- {/if} - {#if !view.sections} -

- {query || store || installedOnly || filters.length ? t('app.results') : t('app.library')} - {shown.length} -

- {/if} - {/snippet} - - {:else if epicEmpty && lib.epic === 'noTool'} -
-

{t('app.noLegendary')}

- {t('app.noLegendaryHint')} -
- -
-
- {:else if epicEmpty && lib.epic === 'loggedOut'} -
-

{t('app.epicLoggedOutEmpty')}

- -
- {:else if epicEmpty && lib.epic === 'unreachable'} -
-

{t('app.epicUnreachable')}

- {t('app.epicUnreachableHint')} -
- {:else if started && lib.total > 0} -
-

{t('app.noMatch')}

- {query && filtered ? t('app.noMatchQueryFilters', { query }) : query ? t('app.noMatchQuery', { query }) : t('app.noMatchFilters')} -
- -
-
- {:else if started && noGames} -
-

{t('app.noGames')}

- {t('app.noGamesHint')} -
- - -
-
- {:else if started} -
-

{lib.status.map(api.message).join('\n')}

-
+ {version} + onback={() => closeGame()} + onerror={(m) => (error = m)} + onchanged={reload} + ontint={(url) => (tint = url)} + onedit={openAddGame} + conflict={saveConflict} + /> {/if}
- {#if open} - (error = m)} - onchanged={reload} - ontint={(url) => (tint = url)} - onedit={openAddGame} - conflict={saveConflict} - /> - {/if}
@@ -746,6 +793,12 @@ z-index: 1; height: 100%; display: flex; + } + + .pane { + flex: 1; + min-width: 0; + display: flex; flex-direction: column; } diff --git a/src/lib/ActionMenu.svelte b/src/lib/ActionMenu.svelte index 4d94b7b..af7d12b 100644 --- a/src/lib/ActionMenu.svelte +++ b/src/lib/ActionMenu.svelte @@ -20,15 +20,18 @@ let { actions, label, + at = null, open = $bindable(), trigger, }: { actions: Action[] /** The menu's accessible name. */ label: string + /** Opens at the pointer (a right-click); otherwise it hangs below `trigger`, right-aligned. */ + at?: { x: number; y: number } | null open: boolean /** The caller's ⋯ button: spread `props` on it. */ - trigger: Snippet<[{ props: Record }]> + trigger?: Snippet<[{ props: Record }]> } = $props() let content = $state(null) @@ -53,16 +56,19 @@ - - {#snippet child({ props })} - {@render trigger({ props })} - {/snippet} - + {#if trigger} + + {#snippet child({ props })} + {@render trigger({ props })} + {/snippet} + + {/if} new DOMRect(at.x, at.y, 0, 0) } : null} + align={at ? 'start' : 'end'} + sideOffset={at ? 0 : 8} collisionPadding={8} preventScroll={false} aria-label={label} diff --git a/src/lib/Card.svelte b/src/lib/Card.svelte index ac35bf0..fbfa5a2 100644 --- a/src/lib/Card.svelte +++ b/src/lib/Card.svelte @@ -27,7 +27,7 @@ game: Card /** Place in the grid; covers are asked in this order. */ index: number - /** Which hours the bottom-left badge shows; it takes Install's place on a game that isn't installed. */ + /** Which hours the bottom-left badge shows. */ stat?: 'playtime' | 'ttb' | null running: boolean /** Its Play is starting. */ @@ -65,7 +65,7 @@ /** The status chip's id: the cover button is described by it. */ const statusId = $props.id() /** A badge or chip shows (the same order as the markup; the progress strip has no text). */ - const hasStatus = $derived(running || !!waiting || (!progress && ((game.installed && game.update) || !!statText || !game.installed))) + const hasStatus = $derived(running || !!waiting || (!progress && ((game.installed && game.update) || !!statText))) let el: HTMLDivElement // undefined: still asking. null: no art, so the title shows. @@ -116,7 +116,7 @@ onpointerleave={() => clearTimeout(resting)} onfocus={() => prefetch(game)} title={game.title} - aria-label={t('common.openGame', { title: game.title })} + aria-label={game.installed ? t('common.openGame', { title: game.title }) : t('card.openNotInstalled', { title: game.title })} aria-describedby={hasStatus ? statusId : undefined} > {#if art === null} @@ -170,11 +170,6 @@ {:else if statText} {statText} - {:else if !game.installed} - - - {t('common.install')} - {/if} {#if !running && (!progress || waiting)} @@ -197,7 +192,7 @@ {t('play.play')} {:else if !game.installed} - @@ -286,7 +281,7 @@ object-fit: cover; } - /* Option C: not installed fades a little, and the chip says what's next. */ + /* Not installed fades a little; Install waits for hover. */ .out .open img { filter: saturate(0.5) brightness(0.75); } @@ -333,6 +328,19 @@ flex-direction: column; gap: 4px; pointer-events: none; + /* Quiet at rest (26px × 0.77 ≈ 20px); transform and opacity keep scrolling composite-only. */ + opacity: 0.6; + transform: scale(0.77); + transform-origin: top right; + transition: + transform 160ms ease-out, + opacity 160ms ease-out; + } + + .card:hover .logos, + .card:focus-within .logos { + opacity: 1; + transform: none; } .logo { @@ -448,6 +456,9 @@ } .glass.small { + display: inline-flex; + align-items: center; + gap: 6px; padding: 6px 14px; border-radius: 999px; font-size: 12px; diff --git a/src/lib/Detail.svelte b/src/lib/Detail.svelte index d547ec8..f49dabe 100644 --- a/src/lib/Detail.svelte +++ b/src/lib/Detail.svelte @@ -578,7 +578,7 @@
{#each kinds as kind (kind)} {/each}
@@ -1505,6 +1505,18 @@ background: var(--glass-on); } + /* A narrow details column shortens a long link name instead of letting the chip stick out. */ + .chips .chip { + max-width: 100%; + } + + .chips .chip span { + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } + .chip[aria-pressed='true'] { background: var(--glass-on); border-color: var(--glass-on-line); diff --git a/src/lib/DownloadsPopover.svelte b/src/lib/DownloadsPopover.svelte index a4fe703..31fe223 100644 --- a/src/lib/DownloadsPopover.svelte +++ b/src/lib/DownloadsPopover.svelte @@ -26,7 +26,7 @@ /** The library as loaded, for titles; a game hidden by the search is asked for once. */ games: Card[] open: boolean - /** The Downloads chip: spread `props` on it. */ + /** The sidebar's Downloads row: spread `props` on it. */ trigger: Snippet<[{ props: Record }]> oncancel: (key: string) => void onpause: () => void @@ -99,7 +99,7 @@ {/snippet} - + {#snippet child({ props, wrapperProps })}
{/snippet} @@ -256,95 +131,4 @@ background: transparent; color: var(--text); } - - .manage { - display: grid; - gap: 2px; - margin-top: 8px; - } - - .row { - display: flex; - align-items: center; - gap: 6px; - min-height: 32px; - font-size: 13px; - } - - .name { - flex: 1; - min-width: 0; - padding: 6px 8px; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - text-align: left; - background: transparent; - } - - .name:hover:not(:disabled), - .x:hover:not(:disabled) { - background: var(--glass-hover); - } - - .x { - width: 28px; - height: 28px; - padding: 0; - flex: none; - border-radius: 999px; - background: transparent; - color: var(--text-3); - font-size: 11px; - } - - .x:hover:not(:disabled) { - color: var(--text); - } - - input { - flex: 1; - height: 28px; - padding: 0 10px; - border-radius: 10px; - background: var(--glass); - border: 1px solid var(--glass-line); - font-size: 13px; - } - - .ask { - flex: 1; - min-width: 0; - color: var(--text); - } - - .small { - flex: none; - height: 28px; - padding: 0 10px; - border-radius: 999px; - background: var(--glass-hover); - border: 1px solid var(--glass-line); - font-size: 13px; - } - - .small:hover:not(:disabled) { - background: var(--glass-on); - } - - .danger { - color: var(--danger-text); - } - - .note { - margin: 4px 8px; - font-size: 13px; - color: var(--text-2); - } - - .problem { - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - } diff --git a/src/lib/Sidebar.svelte b/src/lib/Sidebar.svelte new file mode 100644 index 0000000..829d250 --- /dev/null +++ b/src/lib/Sidebar.svelte @@ -0,0 +1,853 @@ + + +{#snippet row(v: View, label: string, count: number, icon: string)} + + {#snippet children({ props })} + + {/snippet} + +{/snippet} + +{#snippet plus()} + + {#snippet children({ props })} + + {/snippet} + +{/snippet} + + + + + +{#if ctx} + {#key ctx} + + {/key} +{/if} + + diff --git a/src/lib/Tip.svelte b/src/lib/Tip.svelte index 7cf8612..8d192e4 100644 --- a/src/lib/Tip.svelte +++ b/src/lib/Tip.svelte @@ -2,7 +2,19 @@ import { Tooltip } from 'bits-ui' import type { Snippet } from 'svelte' - let { text, truncated = false, children }: { text: string; truncated?: boolean; children: Snippet<[{ props: Record }]> } = $props() + let { + text, + truncated = false, + side = 'top', + sideOffset = 6, + children, + }: { + text: string + truncated?: boolean + side?: 'top' | 'right' | 'bottom' | 'left' + sideOffset?: number + children: Snippet<[{ props: Record }]> + } = $props() let open = $state(false) /** The element the pointer or focus last reached; measured when the tooltip is about to open. */ @@ -40,7 +52,7 @@ {/snippet} - {text} + {text} diff --git a/src/lib/Toolbar.svelte b/src/lib/Toolbar.svelte index 9e2697f..28420c4 100644 --- a/src/lib/Toolbar.svelte +++ b/src/lib/Toolbar.svelte @@ -1,38 +1,26 @@