mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-21 06:10:44 +08:00
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
30 lines
876 B
TypeScript
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);
|
|
},
|
|
};
|
|
}
|