Skip to main content

Crate telar_theme_core

Crate telar_theme_core 

Source

Enums§

ControlSize
How large the controls in this part of the tree are, in the sense SwiftUI’s controlSize means: a preference the container expresses and each control interprets, not a size any one of them is given.

Traits§

Theme
ThemeTokens
Opt-in semantic-token contract the built-in component catalogue reads through, so a component can resolve a token without knowing the concrete theme type.

Functions§

active_mode
Non-reactive read of the active mode id, for the hot-reload snapshot bridge.
control_scale
The factor the catalogue’s metric bases carry here — use_control_size resolved to a number, which is the only form a component ever needs it in.
follow_system
Drives the active mode from the OS light/dark preference — light → light, dark → dark — updating live as the OS scheme changes. Installs a reactive effect (kept alive internally) and designates the pair so is_dark/toggle_dark stay consistent. Re-calling replaces the effect (hot reload re-runs setup). A manual set_mode still wins until the next OS change re-drives it.
init_mode
Selects default only when no mode is active yet. Called at app start and after a hot reload so a selection restored by the rsx hot-reload bridge is not clobbered by the default.
is_dark
Reactive: true when the active mode is the designated dark mode. false when it is the light mode, no pair has been set, or a third (unpaired) mode is active. Read this for a sun/moon toggle’s on/off state.
register_mode
Registers a named mode. apply installs the concrete theme when the mode is selected. Re-registering an id replaces its closure, which is expected: hot reload re-runs the app’s setup and re-registers every mode.
set_control_size
Sets the ambient control size. Reactive: everything that read it re-runs, so a switch re-spaces the controls already on screen rather than waiting for whatever rebuilds them.
set_dark
Selects the designated dark (on = true) or light (on = false) mode. No-op if no pair has been set.
set_light_dark
Designates which two registered modes form the light/dark pair. A thin, optional convention over the open mode registry: it does not replace named modes (a third mode like "pastel" stays valid) — it only tells is_dark/set_dark/toggle_dark which ids to flip between. Both ids should also be registered via register_mode. Does not itself change the active mode.
set_mode
Selects a mode: runs its registered apply closure (if one is registered) and publishes the id to the reactive active-mode signal. Setting an unregistered id still updates the signal, so an app may drive the theme from its own effect on use_mode instead of registering closures.
set_system_dark
Reports the OS light/dark preference into the reactive graph. Called by the runner at window creation and whenever the OS scheme changes; drives follow_system.
set_theme
toggle_dark
Flips between the designated light and dark modes. Reads the current scheme non-reactively so it is safe to call from an event handler.
use_control_size
The ambient control size, subscribing the caller.
use_mode
Reactive read of the active mode id — subscribes the caller so a label re-renders on switch. None before any mode is set.
use_theme
use_theme_tokens