navbar compat for compare

This commit is contained in:
tresabhi committed 2026-11-19 11:04:38 -06:00
1 parent eeac6cfe5e
commit 94ec7cfb6f
5 files changed
+25 -19

No files matched your search

@@ -175,19 +175,26 @@ const strings = await api.strings(locale);
const navbar = document.getElementById("navbar-mobile")!;
const tool = document.getElementById("current-tool")!;
const overlay = document.getElementById("navbar-mobile-overlay")!;
let lastScrollY = window.scrollY;
const lastScrollTops = new WeakMap<Element, number>();
window.addEventListener(
// Scroll doesn't bubble, so capturing also catches nested scrollers like tables
document.addEventListener(
"scroll",
() => {
const scrollY = window.scrollY;
(event) => {
const target =
event.target instanceof Element
? event.target
: document.scrollingElement!;
const scrollTop = target.scrollTop;
const lastScrollTop = lastScrollTops.get(target) ?? 0;
if (scrollY === lastScrollY) return;
// Horizontal scrolling leaves scrollTop unchanged, so it's ignored
if (scrollTop === lastScrollTop) return;
navbar.dataset.visible = `${scrollY < lastScrollY}`;
lastScrollY = scrollY;
navbar.dataset.visible = `${scrollTop < lastScrollTop}`;
lastScrollTops.set(target, scrollTop);
},
{ passive: true },
{ capture: true, passive: true },
);
tool.addEventListener("click", () => {
@@ -1,12 +1,13 @@
<script>
const root = document.documentElement;
const media = window.matchMedia("(prefers-color-scheme: dark)");
// TODO: implement light mode here
// const root = document.documentElement;
// const media = window.matchMedia("(prefers-color-scheme: dark)");
function applyTheme(e: MediaQueryList | MediaQueryListEvent) {
root.classList.toggle("dark", e.matches);
root.classList.toggle("light", !e.matches);
}
// function applyTheme(e: MediaQueryList | MediaQueryListEvent) {
// root.classList.toggle("dark", e.matches);
// root.classList.toggle("light", !e.matches);
// }
applyTheme(media);
media.addEventListener("change", applyTheme);
// applyTheme(media);
// media.addEventListener("change", applyTheme);
</script>
@@ -42,7 +42,6 @@ function Root({ children, className, scrollable, ...props }: RootProps) {
return () => observer.disconnect();
}, []);
const content = (
<table ref={table} className={styles.table}>
{children}
@@ -62,6 +62,7 @@ const tool = tools.tanks;
.main {
flex: 1;
min-width: 0;
}
@media screen and (max-width: 80rem) {
@@ -17,8 +17,6 @@
}
.table {
flex: 1;
min-height: 0;
align-self: stretch;
overflow: hidden;