class
Opal::ThemeStore
- Opal::ThemeStore
- Reference
- Object
Overview
Registry and preset repository for UI semantic themes.
Includes 16 calibrated presets, JSON serialization/deserialization for custom user themes,
reactive .on_change subscription hooks, and accessibility contrast auditing.
Defined in:
opal/style/theme_store.crClass Method Summary
-
.all : Array(Theme)
Returns all registered themes.
-
.clear_listeners : Nil
Clears all change listeners
-
.contrast_analysis(theme : Theme) : Hash(String, Float64)
Calculates WCAG 2.1 contrast ratios for key UI color pairings in a theme.
-
.current : Theme
Returns the currently active global theme.
-
.current=(theme : Theme | Symbol | String) : Theme
Sets the currently active global theme and notifies subscribers.
-
.export_json(theme : Theme) : String
Exports a theme to a JSON string representation.
-
.export_kv(theme : Theme) : String
Exports a theme to a clean, human-readable key-value (.theme) string.
-
.get(name : Symbol | String) : Theme
Fetches a theme by name, falling back to catppuccin_mocha or default.
-
.has?(name : Symbol | String) : Bool
Checks if a theme exists by name.
-
.import_json(json_str : String) : Theme
Imports a theme from a JSON string representation.
-
.import_kv(kv_str : String) : Theme
Imports a theme from a key-value (.theme) string representation.
-
.load_file(path : String) : Theme
Loads a theme from either a JSON (.json) or key-value (.theme) file.
-
.names : Array(String)
Returns names of all registered themes.
-
.on_change(&block : Theme -> Nil) : Nil
Registers a listener callback invoked whenever the active theme changes.
-
.register(theme : Theme) : Theme
Registers a theme in the store.
-
.save_file(theme : Theme, path : String) : Nil
Saves a theme to a file on disk (auto-detects JSON or KV based on file extension).
Class Method Detail
Calculates WCAG 2.1 contrast ratios for key UI color pairings in a theme.
Sets the currently active global theme and notifies subscribers.
Exports a theme to a JSON string representation.
Exports a theme to a clean, human-readable key-value (.theme) string.
Fetches a theme by name, falling back to catppuccin_mocha or default.
Imports a theme from a JSON string representation.
Imports a theme from a key-value (.theme) string representation.
Loads a theme from either a JSON (.json) or key-value (.theme) file.
Registers a listener callback invoked whenever the active theme changes.
Saves a theme to a file on disk (auto-detects JSON or KV based on file extension).