Light and dark theme switch
The site's theme switch, the one in the footer. It changes the theme state in three places inside a view transition; the sound, the vibration and the fade start on the same frame.
Source · GitHubThe switch changes three things: the 'fhfs-theme' entry in localStorage, the data-theme attribute and the 'fhfs:theme' event, and multiple instances of the switch stay in sync through that event. The change is wrapped in document.startViewTransition, which globals.css sets to a 1.2s cross-fade: the whole page fades between an old and a new snapshot, and elements are not recoloured one by one. On the same frame there is a synthesised square-wave click (one AudioContext, created on the first click, with no audio file) and a 10ms vibration; this is the only place on the site that uses sound and vibration together. The server does not know the theme, so it renders the light theme first and reads the real value in a layout effect; in a passive effect, readers in dark mode would see one frame of the switch in the wrong state.
Source
Source files on GitHub: