Files
radicle-explorer/desktop/src/lib/overflowFade.ts
T
Brandon Oxendine 7dd1ad2e55 Keep list search usable in narrow windows
The patch and issue list topbars decided whether to show filter labels
from the viewport width, which ignores the sidebar. With the search
input open, the filters left it almost no room, and in narrower
windows the actions were pushed past the window edge.

Make the topbar a size container and show filter labels based on its
own width. While searching, collapse inactive filters to icons and give
the input a fixed width. When there is still not enough room, the
filters scroll and fade out at the clipped edge.

Fixes: 0d6def4600
2026-10-20 13:34:00 +02:00

30 lines
876 B
TypeScript

const fadeWidth = "3rem";
export function overflowFade(node: HTMLElement) {
function update() {
const start = node.scrollLeft > 0;
const end = node.scrollLeft + node.clientWidth < node.scrollWidth - 1;
const mask =
start || end
? `linear-gradient(to right, ${start ? "transparent" : "black"} 0, black ${start ? fadeWidth : "0"}, black calc(100% - ${end ? fadeWidth : "0px"}), ${end ? "transparent" : "black"} 100%)`
: "";
node.style.maskImage = mask;
node.style.webkitMaskImage = mask;
}
const observer = new ResizeObserver(update);
observer.observe(node);
for (const child of node.children) {
observer.observe(child);
}
node.addEventListener("scroll", update, { passive: true });
update();
return {
destroy() {
observer.disconnect();
node.removeEventListener("scroll", update);
},
};
}