Mixins / API

foldkit-mixins/theme/runtime

The run-time half of Themes: showing a named theme on the root element, keeping the choice, and hearing another tab's. It imports no style code, so a page built with foldkit-mixins/vite's modules (no compiler in the browser) can switch themes; Themes.make in themes.ts is the compiled half and returns a ThemeNames. Which theme is active is the application's Model's fact: applyTheme is the Command's effect that shows it, chooseTheme shows it and keeps it, and themeScript shows the kept one in the head of the next page before the first paint.

Functions

applyThemeShows name on the root element, as a Command's effect: the initial theme removes the attribute, so the root's own declarations apply.
chooseThemeShows name, as applyTheme does, and keeps it under key for the next visit, as a Command's effect: the initial theme keeps nothing. Storage that throws still…
themeChangesThe theme another tab chose, each time it does: what its chooseTheme kept under key, with a name no theme has, a removed key and anything else read as the…
themeScriptThe text of a <script> for the document's head: it shows the theme whose name is kept under key, so a reader who chose one never sees the initial theme for…

Values

THEME_KEYThe storage key a chosen theme's name is kept under, unless one is given.

Interfaces

ThemeNamesWhat the functions here need of a set of named themes: its names and where the active one is shown.