feat(docs): follow the OS theme, light without JS, System/Light/Dark in the footer

Merged
EV
3d ago
+114-74

What

docs-website/ only. docs.traduora.co follows the visitor's OS theme, falls back to light, and has a System / Light / Dark selector in the footer on every page. The ever.team marketing footer already works this way.

  1. docusaurus.config.ts: colorMode: { defaultMode: 'light', disableSwitch: false, respectPrefersColorScheme: true } (it was defaultMode: 'dark'). In 3.10 the inline script resolves "system" with matchMedia('(prefers-color-scheme: dark)') and uses light when it can't.
  2. Light without JavaScript (CSS fix): :root in src/css/custom.css set two dark values, --ifm-font-color-base: #fff and --ifm-background-surface-color: #2a2c39. They applied whenever data-theme wasn't dark, which means both without JS (no data-theme at all) and in light mode.
    • The base text colour (body, plus Infima's variables derived from it, such as --ifm-dropdown-link-color and --ifm-alert-color) was white on the white page wherever nothing more specific set a colour. custom.css patches .markdown and p, but not the rest.
    • Infima's surface colour, used for example by dropdown menus, was dark. Without JS the html[data-theme='light'] .dropdown__menu override doesn't apply, so dropdowns stayed dark.
    • :root is the light palette again.
    • The white base text moves under [data-theme='dark'].
    • The surface colour is removed. Infima's html[data-theme='dark'] already overrode it, so dark mode renders as before.
  3. Footer selector: the light/dark Footer/ThemeToggle.tsx is replaced by Footer/ThemeSelector.tsx, in the same spot next to the locale dropdown, using the same Tailwind palette and pill shape.
    • Three <button type="button"> in a role="group" labelled "Theme". Each button has an aria-label and title ("System theme", "Light theme", "Dark theme") and aria-pressed.
    • Built on 3.10's useColorMode(): colorModeChoice is null for System, and setColorMode(null) selects it.
    • Uses the classic theme's Icon/SystemColorMode, Icon/LightMode and Icon/DarkMode. src/theme.d.ts declares those three, as it already does for the other @theme modules, because tsconfig limits types to module-type-aliases.
    • With useIsBrowser(), nothing is pressed in the server HTML or before hydration. After hydration, System is pressed until the visitor picks a theme.

There are no new dependencies and no lockfile change.

Left as is

The swizzled navbar keeps its own light/dark toggles (Navbar/RightMenu.tsx, Navbar/MobileMenu.tsx). They still work: each sets an explicit light or dark choice, and the footer selector is the way back to System.

Checked

  • ThemeSelector.tsx passes tsc --strict against the @docusaurus/theme-common / theme-classic / module-type-aliases 3.10.2 typings. That check ran on TS 5.6 from an existing install; nothing was installed here.
  • Not built or tried in a browser. Nothing was built locally, and this repo's PR CI doesn't build the docs, so the dev deployment is the first render.

šŸ¤– Generated with Claude Code