@commonpub/layer 0.63.0 → 0.64.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commonpub/layer",
3
- "version": "0.63.0",
3
+ "version": "0.64.0",
4
4
  "type": "module",
5
5
  "main": "./nuxt.config.ts",
6
6
  "files": [
@@ -54,15 +54,15 @@
54
54
  "vue-router": "^4.3.0",
55
55
  "zod": "^4.3.6",
56
56
  "@commonpub/auth": "0.8.0",
57
- "@commonpub/config": "0.19.0",
58
57
  "@commonpub/editor": "0.7.11",
59
- "@commonpub/schema": "0.35.0",
58
+ "@commonpub/config": "0.19.0",
60
59
  "@commonpub/docs": "0.6.3",
61
60
  "@commonpub/learning": "0.5.2",
62
61
  "@commonpub/server": "2.82.0",
63
- "@commonpub/ui": "0.10.0",
64
62
  "@commonpub/protocol": "0.13.0",
65
- "@commonpub/explainer": "0.7.15"
63
+ "@commonpub/explainer": "0.7.15",
64
+ "@commonpub/ui": "0.11.0",
65
+ "@commonpub/schema": "0.35.0"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@testing-library/jest-dom": "^6.9.1",
@@ -155,14 +155,45 @@ async function removeTheme(themeId: string): Promise<void> {
155
155
  // --- Create / Capture / Import ---
156
156
 
157
157
  function createBlank(): void {
158
+ // "New custom theme" forks the CURRENTLY ACTIVE theme so you start from the
159
+ // look on screen, not a blank Classic slate. (It previously seeded an empty,
160
+ // base-parented theme — which is why saving reverted everything to Classic.)
161
+ const active = instanceDefault.value;
162
+ const customId = parseCustomThemeId(active);
163
+
164
+ // Active theme is itself a custom theme → copy its stored tokens directly
165
+ // (computed-style capture can't reconstruct a custom theme's full set).
166
+ if (customId && themesApi.data.value) {
167
+ const src = themesApi.data.value.custom.find((t) => t.id === customId);
168
+ if (src) {
169
+ const seed = {
170
+ id: nextAvailableId(`${src.id}-copy`),
171
+ name: `${src.name} (copy)`,
172
+ description: src.description ?? '',
173
+ family: 'custom',
174
+ isDark: src.isDark,
175
+ parentTheme: src.parentTheme,
176
+ tokens: { ...src.tokens },
177
+ };
178
+ sessionStorage.setItem('cpub-theme-editor-seed', JSON.stringify(seed));
179
+ router.push('/admin/theme/edit/__new');
180
+ return;
181
+ }
182
+ }
183
+
184
+ // Built-in / registered active theme → capture its applied tokens so the new
185
+ // theme reproduces the current look (a custom theme renders as base + tokens,
186
+ // so a complete capture is what keeps it from falling back to Classic).
187
+ const detected = detectAppliedOverrides();
188
+ const isBuiltInParent = themesApi.data.value?.builtIn.some((t) => t.id === active) ?? false;
158
189
  const seed = {
159
190
  id: nextAvailableId('my-theme'),
160
191
  name: 'My theme',
161
- description: '',
192
+ description: detected.count ? `Forked from the active theme (${detected.count} tokens).` : '',
162
193
  family: 'custom',
163
- isDark: false,
164
- parentTheme: 'base',
165
- tokens: {},
194
+ isDark: detected.isDark,
195
+ parentTheme: isBuiltInParent ? active : 'base',
196
+ tokens: detected.tokens,
166
197
  };
167
198
  sessionStorage.setItem('cpub-theme-editor-seed', JSON.stringify(seed));
168
199
  router.push('/admin/theme/edit/__new');