Skip to content

A teaser countdown, and a nav that collapses

I put a teaser countdown on 6umi.net. Along with it, I changed the top nav, which used to wrap on phones, so that whatever doesn't fit gets collapsed. I'll skip the backstory and only write down the parts worth reusing.

Countdown

The countdown on the landing page

  • DDd HHh MMm SSs on both the landing page (Next.js) and the board (Streamlit). Once it hits 0, it counts up the elapsed time
  • Running JS every second in Streamlit: st.html doesn't execute scripts. If you pass the whole HTML to st.iframe, it runs, and it doesn't trigger a Streamlit rerun either
  • The display freezes for 2 seconds, then jumps by 2: setTimeout fires a few ms after the second boundary. If you compute the remaining seconds with Math.floor, a late tick shows one less, so it stalls and then jumps. Math.round fixes it. I did this on both the landing page and the board

360px. なごみ is a dropdown

320px. The links that don't fit and Docs are collapsed into ⋯

  • Collapse the trailing items that don't fit into ⋯ (priority+). Measure each item's width with ResizeObserver and show only as many as fit. It doesn't depend on the number of items, screen width, or font
  • Don't set collapsed items to display:none. Their width becomes 0 and you can't measure them. Put them somewhere off-screen and give them aria-hidden
  • Submenus are one level deep. I grouped the board's pages under なごみ
  • This is one of the common ways to handle phones. You can also put everything into a ≡ menu
  • Hiding the top nav of the embedded Streamlit app: if the parent page has a nav, you end up with two. ?nav=0 sets st.navigation(position="hidden"). Keep all pages registered so ?page= links still work. A raw <a href> inside the iframe does a full reload and drops the flag, so re-append nav=0 to the links

Created 2026-10-13 · Updated 2026-11-07 · Machine-translated from the Japanese original.