From 892869637fe28bdc5a1d015b68004e40bd3990a7 Mon Sep 17 00:00:00 2001 From: Brandon Oxendine Date: Tue, 15 Sep 2026 15:08:27 +0200 Subject: [PATCH] Animate the repo list and filter button --- src/components/AddRepoButton.svelte | 5 +- src/components/AppSidebar.svelte | 16 ++- src/components/SidebarRepoList.svelte | 182 ++++++++++++++++++-------- 3 files changed, 145 insertions(+), 58 deletions(-) diff --git a/src/components/AddRepoButton.svelte b/src/components/AddRepoButton.svelte index b159edf48..ca88e30da 100644 --- a/src/components/AddRepoButton.svelte +++ b/src/components/AddRepoButton.svelte @@ -112,7 +112,10 @@ onclick={() => { onclick(); }} - active={popoverExpanded}> + active={popoverExpanded} + styleWidth="1.5rem" + styleHeight="1.5rem" + stylePadding="0"> {/snippet} diff --git a/src/components/AppSidebar.svelte b/src/components/AppSidebar.svelte index 0f1ec5ce4..f774eff9c 100644 --- a/src/components/AppSidebar.svelte +++ b/src/components/AppSidebar.svelte @@ -590,26 +590,34 @@ : 'Collapse'} sidebar ({toggleShortcut})" keyShortcuts={isMac() ? "Meta+b" : "Control+b"} onclick={toggleSidebar} - stylePadding="0 4px"> + styleWidth="1.5rem" + styleHeight="1.5rem" + stylePadding="0"> diff --git a/src/components/SidebarRepoList.svelte b/src/components/SidebarRepoList.svelte index 3b8c98d88..b651bcccd 100644 --- a/src/components/SidebarRepoList.svelte +++ b/src/components/SidebarRepoList.svelte @@ -178,22 +178,43 @@ // (the controls growing above it) is left to the shared layout transition. let allReposHeaderEl = $state(); let headerFirst: FlipSnapshot | undefined; - const HEADER_FLIP = { selector: "[data-flip]", animateHeight: true }; + const HEADER_FLIP_MS = 200; + const HEADER_FLIP = { + selector: "[data-flip]", + animateHeight: true, + durationMs: HEADER_FLIP_MS, + }; + + // FLIP translates the element back from its destination, so the pointer that + // clicked it keeps it hovered and a grey square slides across the header + // instead of an icon. The fill is dropped for the duration. + let headerFlipping = $state(false); + let headerFlipTimeout: ReturnType | undefined; $effect.pre(() => { // Measure before the DOM reflows for the new state. - // eslint-disable-next-line @typescript-eslint/no-unused-expressions + /* eslint-disable @typescript-eslint/no-unused-expressions */ sidebarCollapsed.value; + filterOpen; + /* eslint-enable @typescript-eslint/no-unused-expressions */ headerFirst = captureFlip(allReposHeaderEl, HEADER_FLIP); }); $effect(() => { // ...and play once it has. - // eslint-disable-next-line @typescript-eslint/no-unused-expressions + /* eslint-disable @typescript-eslint/no-unused-expressions */ sidebarCollapsed.value; + filterOpen; + /* eslint-enable @typescript-eslint/no-unused-expressions */ playFlip(allReposHeaderEl, headerFirst, HEADER_FLIP); + + headerFlipping = true; + if (headerFlipTimeout !== undefined) clearTimeout(headerFlipTimeout); + headerFlipTimeout = setTimeout(() => { + headerFlipping = false; + }, HEADER_FLIP_MS); }); const ANIMATION_DURATION_MS = 220; @@ -249,6 +270,20 @@ }; } + // `slide` cannot roll this list up: it animates `height`, which never applies + // to a `flex: 1` item. `max-height` clamps one, and `--unroll-height` holds + // the scroll area at full size so the rows are clipped, not reflowed. + function unroll(node: Element, { duration }: { duration: number }) { + const height = (node as HTMLElement).offsetHeight; + + return { + duration, + easing: cubicOut, + css: (t: number) => + `max-height: ${t * height}px; overflow: hidden; --unroll-height: ${height}px;`, + }; + } + function withPinAnimation(fn: () => void) { animatingPinnedList = true; if (animationTimeout !== undefined) clearTimeout(animationTimeout); @@ -459,6 +494,17 @@ padding: 0; overflow: visible; } + /* Owns the flex sizing so `unroll` can clamp the scroll area inside. */ + .repos-scroll { + flex: 1; + min-height: 0; + margin-top: -0.5rem; + } + /* A height, not `flex: 1`, which the scroll area sets inline and would win: + mid-transition `unroll` pins this so the wrapper clips it. */ + .repos-scroll > :global(*) { + height: var(--unroll-height, 100%); + } .section-header { font: var(--txt-body-m-regular); @@ -482,15 +528,30 @@ flex: 1; min-width: 0; } - .section-header-actions { - display: flex; - align-items: center; - gap: 0.25rem; + /* Moved by `order`, not in the markup: the FLIP matches by element identity, + so the button has to stay one element across the toggle. */ + .filter-action { + order: 1; + /* Promoted for good: the FLIP promotes it only for the move, and handing + the layer back at the end re-rounds its position by a pixel. */ + will-change: transform; + } + .filter-action.open { + order: -1; + /* Lines the icon up with the rows below the header's 0.5rem padding. */ + margin-left: -0.25rem; + } + .add-repo-action { + order: 2; } /* No room on the rail; the repo rows below stand on their own there. */ .section-header.mini { display: none; } + .section-header.flipping .filter-button:hover, + .section-header.flipping :global(.button:hover) { + background-color: transparent; + } .filter-button { display: flex; @@ -504,6 +565,13 @@ color: var(--color-text-secondary); cursor: pointer; } + /* The same 1.5rem square as every other icon button in the sidebar. */ + .filter-action .filter-button { + width: 1.5rem; + height: 1.5rem; + padding: 0; + margin-left: 0; + } .filter-button:hover { color: var(--color-text-primary); background-color: var(--color-surface-subtle); @@ -763,6 +831,10 @@ .icon-hover { grid-area: 1 / 1; transition: opacity 150ms ease; + /* Promoted for good, for the same reason the filter button is: the fade + puts these on a layer of their own only while it runs, and handing them + back at the end re-rounds their position by a pixel. */ + will-change: opacity; } .icon-hover { opacity: 0; @@ -877,6 +949,7 @@ bind:this={allReposHeaderEl} class="section-header" class:mini={sidebarCollapsed.value} + class:flipping={headerFlipping} onclick={() => { if (!filterOpen) { reposExpanded.value = !reposExpanded.value; @@ -896,15 +969,6 @@ class="section-header-label" onclick={e => e.stopPropagation()} role="none"> - {/if} - - {#if !filterOpen} - e.stopPropagation()} role="none"> - - - {/if} - e.stopPropagation()} - role="none"> - - + e.stopPropagation()} + role="none"> + + + e.stopPropagation()} + role="none"> + @@ -1084,23 +1154,29 @@ {/snippet} -{#if reposExpanded.value && !sidebarCollapsed.value} - -
- {#each unpinnedFilteredRepos as repo (repo.rid)} -
clearUnseeding(repo.rid)}> - {@render repoRowInner(repo, false)} +{#if !sidebarCollapsed.value} + {#if reposExpanded.value} +
+ +
+ {#each unpinnedFilteredRepos as repo (repo.rid)} +
clearUnseeding(repo.rid)}> + {@render repoRowInner(repo, false)} +
+ {/each}
- {/each} +
- + {/if} {/if} {#if drag.draggedRepo}