@symbo.ls/scratch 3.7.5 → 3.8.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.
package/dist/cjs/set.js CHANGED
@@ -19,6 +19,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  var set_exports = {};
20
20
  __export(set_exports, {
21
21
  VALUE_TRANSFORMERS: () => VALUE_TRANSFORMERS,
22
+ changeGlobalTheme: () => changeGlobalTheme,
22
23
  set: () => set,
23
24
  setEach: () => setEach,
24
25
  setValue: () => setValue
@@ -84,6 +85,20 @@ const setEach = (factoryName, props) => {
84
85
  });
85
86
  return CONFIG[lowerName] || CONFIG[factoryName];
86
87
  };
88
+ const changeGlobalTheme = (newTheme) => {
89
+ const CONFIG = (0, import_factory.getActiveConfig)();
90
+ CONFIG.globalTheme = newTheme;
91
+ for (const key in CONFIG.CSS_VARS) {
92
+ if (key.startsWith("--theme-")) delete CONFIG.CSS_VARS[key];
93
+ }
94
+ for (const key in CONFIG.CSS_MEDIA_VARS) {
95
+ delete CONFIG.CSS_MEDIA_VARS[key];
96
+ }
97
+ if (CONFIG.theme) {
98
+ setEach("theme", CONFIG.theme);
99
+ }
100
+ return CONFIG;
101
+ };
87
102
  const SET_OPTIONS = {};
88
103
  const set = (recivedConfig, options = SET_OPTIONS) => {
89
104
  let CONFIG = (0, import_factory.getActiveConfig)();
package/dist/esm/set.js CHANGED
@@ -72,6 +72,20 @@ const setEach = (factoryName, props) => {
72
72
  });
73
73
  return CONFIG[lowerName] || CONFIG[factoryName];
74
74
  };
75
+ const changeGlobalTheme = (newTheme) => {
76
+ const CONFIG = getActiveConfig();
77
+ CONFIG.globalTheme = newTheme;
78
+ for (const key in CONFIG.CSS_VARS) {
79
+ if (key.startsWith("--theme-")) delete CONFIG.CSS_VARS[key];
80
+ }
81
+ for (const key in CONFIG.CSS_MEDIA_VARS) {
82
+ delete CONFIG.CSS_MEDIA_VARS[key];
83
+ }
84
+ if (CONFIG.theme) {
85
+ setEach("theme", CONFIG.theme);
86
+ }
87
+ return CONFIG;
88
+ };
75
89
  const SET_OPTIONS = {};
76
90
  const set = (recivedConfig, options = SET_OPTIONS) => {
77
91
  let CONFIG = getActiveConfig();
@@ -154,6 +168,7 @@ const set = (recivedConfig, options = SET_OPTIONS) => {
154
168
  };
155
169
  export {
156
170
  VALUE_TRANSFORMERS,
171
+ changeGlobalTheme,
157
172
  set,
158
173
  setEach,
159
174
  setValue
@@ -468,6 +468,7 @@ var SmblsScratch = (() => {
468
468
  applyTypographySequence: () => applyTypographySequence,
469
469
  breakpoints: () => breakpoints,
470
470
  cases: () => cases,
471
+ changeGlobalTheme: () => changeGlobalTheme,
471
472
  changeLightness: () => changeLightness,
472
473
  checkIfBoxSize: () => checkIfBoxSize,
473
474
  color: () => color,
@@ -2839,6 +2840,20 @@ var SmblsScratch = (() => {
2839
2840
  });
2840
2841
  return CONFIG2[lowerName] || CONFIG2[factoryName];
2841
2842
  };
2843
+ var changeGlobalTheme = (newTheme) => {
2844
+ const CONFIG2 = getActiveConfig();
2845
+ CONFIG2.globalTheme = newTheme;
2846
+ for (const key in CONFIG2.CSS_VARS) {
2847
+ if (key.startsWith("--theme-")) delete CONFIG2.CSS_VARS[key];
2848
+ }
2849
+ for (const key in CONFIG2.CSS_MEDIA_VARS) {
2850
+ delete CONFIG2.CSS_MEDIA_VARS[key];
2851
+ }
2852
+ if (CONFIG2.theme) {
2853
+ setEach("theme", CONFIG2.theme);
2854
+ }
2855
+ return CONFIG2;
2856
+ };
2842
2857
  var SET_OPTIONS = {};
2843
2858
  var set = (recivedConfig, options = SET_OPTIONS) => {
2844
2859
  let CONFIG2 = getActiveConfig();
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@symbo.ls/scratch",
3
3
  "description": "Φ / CSS framework and methodology.",
4
4
  "author": "symbo.ls",
5
- "version": "3.7.5",
5
+ "version": "3.8.0",
6
6
  "files": [
7
7
  "dist",
8
8
  "*.js",
@@ -33,8 +33,8 @@
33
33
  "prepublish": "npm run build && npm run copy:package:cjs"
34
34
  },
35
35
  "dependencies": {
36
- "@domql/utils": "^3.7.5",
37
- "@symbo.ls/smbls-utils": "^3.7.5",
36
+ "@domql/utils": "^3.8.0",
37
+ "@symbo.ls/smbls-utils": "^3.8.0",
38
38
  "color-contrast-checker": "^1.5.0"
39
39
  },
40
40
  "gitHead": "9fc1b79b41cdc725ca6b24aec64920a599634681",
package/src/set.js CHANGED
@@ -92,6 +92,28 @@ export const setEach = (factoryName, props) => {
92
92
  return CONFIG[lowerName] || CONFIG[factoryName]
93
93
  }
94
94
 
95
+ export const changeGlobalTheme = (newTheme) => {
96
+ const CONFIG = getActiveConfig()
97
+ CONFIG.globalTheme = newTheme
98
+
99
+ // Clear theme-related CSS vars
100
+ for (const key in CONFIG.CSS_VARS) {
101
+ if (key.startsWith('--theme-')) delete CONFIG.CSS_VARS[key]
102
+ }
103
+
104
+ // Clear all CSS_MEDIA_VARS (media queries + data-theme selectors)
105
+ for (const key in CONFIG.CSS_MEDIA_VARS) {
106
+ delete CONFIG.CSS_MEDIA_VARS[key]
107
+ }
108
+
109
+ // Re-process all themes with the new globalTheme
110
+ if (CONFIG.theme) {
111
+ setEach('theme', CONFIG.theme)
112
+ }
113
+
114
+ return CONFIG
115
+ }
116
+
95
117
  const SET_OPTIONS = {}
96
118
 
97
119
  export const set = (recivedConfig, options = SET_OPTIONS) => {