@resolve-components/theme 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,58 @@
1
+ // =============================================================================
2
+ // Resolve Components — Theme Registration
3
+ // =============================================================================
4
+
5
+ @use 'sass:map';
6
+ @use 'sass:meta';
7
+ @use 'theming-variables' as vars;
8
+ @use 'functions' as fn;
9
+ @use 'mapping' as mp;
10
+
11
+ /// Register a theme into the global theme registry.
12
+ ///
13
+ /// Merging order (lowest to highest priority):
14
+ /// 1. Component mapping ($rc-mapping) — base defaults
15
+ /// 2. Parent theme values (if $parent-name is provided)
16
+ /// 3. Current theme values ($theme)
17
+ ///
18
+ /// @param {Map} $theme - The theme variable map.
19
+ /// @param {String} $name - Unique theme name (e.g. 'default', 'dark').
20
+ /// @param {String|null} $parent-name - Parent theme to inherit from.
21
+ /// @return {Map} Updated global $rc-themes map.
22
+ @function rc-register-theme($theme, $name, $parent-name: null) {
23
+ // Start with the component mapping as the base layer
24
+ $merged: mp.$rc-mapping;
25
+
26
+ // If inheriting from a parent theme, merge parent values
27
+ @if $parent-name != null {
28
+ @if map.has-key(vars.$rc-themes, $parent-name) {
29
+ $parent-theme: map.get(vars.$rc-themes, $parent-name);
30
+ $merged: map.merge($merged, $parent-theme);
31
+ } @else {
32
+ @warn 'rc-register-theme: parent theme "#{$parent-name}" not found. Registering "#{$name}" without parent.';
33
+ }
34
+ }
35
+
36
+ // Merge the current theme on top (highest priority)
37
+ $merged: map.merge($merged, $theme);
38
+
39
+ // Store in global registry
40
+ @return fn.rc-map-set(vars.$rc-themes, $name, $merged);
41
+ }
42
+
43
+ /// Get a registered theme by name.
44
+ /// @param {String} $name - Theme name.
45
+ /// @return {Map} The theme variable map.
46
+ @function rc-get-registered-theme($name) {
47
+ @return map.get(vars.$rc-themes, $name);
48
+ }
49
+
50
+ /// Get the list of enabled theme names.
51
+ /// If $rc-enabled-themes is empty, returns all registered theme names.
52
+ /// @return {List} Theme names.
53
+ @function rc-get-enabled-themes() {
54
+ @if length(vars.$rc-enabled-themes) > 0 {
55
+ @return vars.$rc-enabled-themes;
56
+ }
57
+ @return map.keys(vars.$rc-themes);
58
+ }
@@ -0,0 +1,30 @@
1
+ // =============================================================================
2
+ // Resolve Components — Theming Variables (Global State)
3
+ // =============================================================================
4
+ // These mutable globals are the backbone of the theming engine.
5
+ // $rc-themes is a SCSS map-of-maps: { 'default': (...), 'dark': (...) }
6
+ // Every theme registration appends to this map.
7
+ // =============================================================================
8
+
9
+ /// When true, the theming engine emits CSS custom properties (recommended).
10
+ /// When false, it falls back to duplicated SCSS output per theme.
11
+ $rc-enable-css-custom-properties: true !default;
12
+
13
+ /// Master registry of all registered themes.
14
+ /// Structure: ( 'theme-name': ( variable-name: value, ... ), ... )
15
+ $rc-themes: () !default;
16
+
17
+ /// List of theme names to include in output. Empty = all registered.
18
+ $rc-enabled-themes: () !default;
19
+
20
+ /// Current theme name being processed (set during compilation).
21
+ $rc-theme-name: null !default;
22
+
23
+ /// Current theme map being processed.
24
+ $rc-theme: () !default;
25
+
26
+ /// How theme values are resolved: 'lazy-process' or 'pre-process'.
27
+ $rc-theme-process-mode: 'lazy-process' !default;
28
+
29
+ /// Pre-processed theme (all aliases resolved to terminal values).
30
+ $rc-processed-theme: () !default;