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
applyTheme | Shows name on the root element, as a Command's effect: the initial theme removes the attribute, so the root's own declarations apply. |
chooseTheme | Shows 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… |
themeChanges | The 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… |
themeScript | The 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_KEY | The storage key a chosen theme's name is kept under, unless one is given. |
Interfaces
ThemeNames | What the functions here need of a set of named themes: its names and where the active one is shown. |