@uniweb/core 0.7.33 → 0.7.34
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 +3 -3
- package/src/theme.js +41 -52
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniweb/core",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.34",
|
|
4
4
|
"description": "Core classes for the Uniweb platform - Uniweb, Website, Page, Block",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"vitest": "^4.1.7"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@uniweb/theming": "0.1.
|
|
37
|
-
"@uniweb/semantic-parser": "1.1.
|
|
36
|
+
"@uniweb/theming": "0.1.15",
|
|
37
|
+
"@uniweb/semantic-parser": "1.1.21"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
40
|
"test": "vitest run"
|
package/src/theme.js
CHANGED
|
@@ -13,28 +13,6 @@ const SHADE_LEVELS = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950]
|
|
|
13
13
|
// Valid color contexts
|
|
14
14
|
const VALID_CONTEXTS = ['light', 'medium', 'dark']
|
|
15
15
|
|
|
16
|
-
// Default semantic tokens by context
|
|
17
|
-
const DEFAULT_CONTEXT_TOKENS = {
|
|
18
|
-
light: {
|
|
19
|
-
bg: 'var(--neutral-50)',
|
|
20
|
-
text: 'var(--neutral-950)',
|
|
21
|
-
heading: 'var(--neutral-900)',
|
|
22
|
-
link: 'var(--primary-600)',
|
|
23
|
-
},
|
|
24
|
-
medium: {
|
|
25
|
-
bg: 'var(--neutral-100)',
|
|
26
|
-
text: 'var(--neutral-950)',
|
|
27
|
-
heading: 'var(--neutral-900)',
|
|
28
|
-
link: 'var(--primary-600)',
|
|
29
|
-
},
|
|
30
|
-
dark: {
|
|
31
|
-
bg: 'var(--neutral-900)',
|
|
32
|
-
text: 'var(--neutral-50)',
|
|
33
|
-
heading: 'white',
|
|
34
|
-
link: 'var(--primary-400)',
|
|
35
|
-
},
|
|
36
|
-
}
|
|
37
|
-
|
|
38
16
|
/**
|
|
39
17
|
* Theme class for runtime theme access
|
|
40
18
|
*/
|
|
@@ -154,40 +132,42 @@ export default class Theme {
|
|
|
154
132
|
// Context Access
|
|
155
133
|
// ============================================================
|
|
156
134
|
|
|
157
|
-
|
|
158
|
-
*
|
|
135
|
+
/*
|
|
136
|
+
* REMOVED 2026-07-28: getContextToken(context, token) and
|
|
137
|
+
* getContextTokens(context), plus the DEFAULT_CONTEXT_TOKENS table backing
|
|
138
|
+
* them. Read this before reintroducing either.
|
|
159
139
|
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
140
|
+
* They were unreachable-by-design rather than merely stale. A lookup keyed on
|
|
141
|
+
* (context, token) answers "what does the .context-<name> class set by
|
|
142
|
+
* default?", but the question callers ask is "what colour is --heading HERE",
|
|
143
|
+
* and those diverge for two reasons no such lookup can see:
|
|
163
144
|
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*/
|
|
168
|
-
getContextToken(context, token) {
|
|
169
|
-
// Check custom context tokens first
|
|
170
|
-
const customContext = this._contexts[context]
|
|
171
|
-
if (customContext && customContext[token]) {
|
|
172
|
-
return customContext[token]
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
// Fall back to defaults
|
|
176
|
-
const defaults = DEFAULT_CONTEXT_TOKENS[context]
|
|
177
|
-
return defaults?.[token] || null
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* Get all tokens for a context
|
|
145
|
+
* - a section's own `theme:` overrides, emitted as `#section-{id} { … }` by
|
|
146
|
+
* @uniweb/theming's buildSectionOverrides;
|
|
147
|
+
* - the active site scheme, where `.scheme-dark` redefines the root tokens.
|
|
182
148
|
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
149
|
+
* So a correct-looking answer would still be wrong whenever a section
|
|
150
|
+
* overrides tokens or the visitor is in dark mode — the failure being a
|
|
151
|
+
* confident wrong value, not an error. (The table had also drifted: it held
|
|
152
|
+
* `bg`/`text`, retired in favour of `section`/`body`, and four tokens where
|
|
153
|
+
* the live set is ~25. Repopulating it would have made a misleading API look
|
|
154
|
+
* trustworthy, which is worse than leaving it visibly incomplete.)
|
|
155
|
+
*
|
|
156
|
+
* What to use instead:
|
|
157
|
+
* - an actually-resolved value (canvas, SVG, a chart matching the theme):
|
|
158
|
+
* getComputedStyle(el).getPropertyValue('--heading') — this accounts for
|
|
159
|
+
* both section overrides and the active scheme, which no static table can;
|
|
160
|
+
* - the defaults table itself (tooling, a theme editor):
|
|
161
|
+
* getDefaultContextTokens() from @uniweb/theming, which owns it;
|
|
162
|
+
* - ordinary component styling: the CSS variables directly. Reading tokens
|
|
163
|
+
* into JS to branch on them is the `isDark ? … : …` pattern semantic
|
|
164
|
+
* tokens exist to remove.
|
|
165
|
+
*
|
|
166
|
+
* SHADE_LEVELS below is duplicated from @uniweb/theming too, and was left
|
|
167
|
+
* deliberately: both copies are identical and the 11-step scale is fixed by
|
|
168
|
+
* the design, so there is no drift to prevent — noted so the next reader
|
|
169
|
+
* knows it was considered rather than missed.
|
|
185
170
|
*/
|
|
186
|
-
getContextTokens(context) {
|
|
187
|
-
const defaults = DEFAULT_CONTEXT_TOKENS[context] || {}
|
|
188
|
-
const custom = this._contexts[context] || {}
|
|
189
|
-
return { ...defaults, ...custom }
|
|
190
|
-
}
|
|
191
171
|
|
|
192
172
|
/**
|
|
193
173
|
* Get the CSS class name for a context
|
|
@@ -423,6 +403,15 @@ export default class Theme {
|
|
|
423
403
|
* point here; everything that consumes the model (runtime boot, kit's
|
|
424
404
|
* useAppearance) imports THIS one.
|
|
425
405
|
*
|
|
406
|
+
* A warning is not a mechanism, and this one has been tested: while it stood,
|
|
407
|
+
* a SECOND shared table in this same file — DEFAULT_CONTEXT_TOKENS, duplicating
|
|
408
|
+
* @uniweb/theming's — drifted to retired token names and lost twenty entries
|
|
409
|
+
* without anyone noticing, because nothing called the two methods that read it.
|
|
410
|
+
* It was removed 2026-07-28 (see the note where it sat). Treat the lockstep
|
|
411
|
+
* above as a live obligation with a track record, not a formality: if you find
|
|
412
|
+
* yourself copying a value out of @uniweb/theming into this file, that is the
|
|
413
|
+
* moment this comment is for.
|
|
414
|
+
*
|
|
426
415
|
* @param {Object} appearance - the resolved theme.yml `appearance:` block
|
|
427
416
|
* @returns {boolean}
|
|
428
417
|
*/
|