feat(docs): follow the OS theme, light without JS, System/Light/Dark in the footer
Merged
EV
3d ago+114+114+012345678901234567890123456789-74-74-01234567890123456789
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.
docusaurus.config.ts:colorMode: { defaultMode: 'light', disableSwitch: false, respectPrefersColorScheme: true }(it wasdefaultMode: 'dark'). In 3.10 the inline script resolves "system" withmatchMedia('(prefers-color-scheme: dark)')and uses light when it can't.- Light without JavaScript (CSS fix):
:rootinsrc/css/custom.cssset two dark values,--ifm-font-color-base: #fffand--ifm-background-surface-color: #2a2c39. They applied wheneverdata-themewasn'tdark, which means both without JS (nodata-themeat all) and in light mode.- The base text colour (
body, plus Infima's variables derived from it, such as--ifm-dropdown-link-colorand--ifm-alert-color) was white on the white page wherever nothing more specific set a colour.custom.csspatches.markdownandp, but not the rest. - Infima's surface colour, used for example by dropdown menus, was dark. Without JS the
html[data-theme='light'] .dropdown__menuoverride doesn't apply, so dropdowns stayed dark. :rootis 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.
- The base text colour (
- Footer selector: the light/dark
Footer/ThemeToggle.tsxis replaced byFooter/ThemeSelector.tsx, in the same spot next to the locale dropdown, using the same Tailwind palette and pill shape.- Three
<button type="button">in arole="group"labelled "Theme". Each button has anaria-labelandtitle("System theme", "Light theme", "Dark theme") andaria-pressed. - Built on 3.10's
useColorMode():colorModeChoiceisnullfor System, andsetColorMode(null)selects it. - Uses the classic theme's
Icon/SystemColorMode,Icon/LightModeandIcon/DarkMode.src/theme.d.tsdeclares those three, as it already does for the other@thememodules, becausetsconfiglimitstypestomodule-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.
- Three
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.tsxpassestsc --strictagainst the@docusaurus/theme-common/theme-classic/module-type-aliases3.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