@uniweb/core 1.3.2 → 1.4.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 +3 -3
- package/src/block.js +45 -10
- package/src/page.js +14 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniweb/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Core classes for the Uniweb platform - Uniweb, Website, Page, Block",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"vitest": "^4.1.7"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@uniweb/
|
|
53
|
-
"@uniweb/
|
|
52
|
+
"@uniweb/semantic-parser": "~1.12.2",
|
|
53
|
+
"@uniweb/theming": "~1.2.0"
|
|
54
54
|
},
|
|
55
55
|
"scripts": {
|
|
56
56
|
"test": "vitest run"
|
package/src/block.js
CHANGED
|
@@ -74,22 +74,34 @@ export default class Block {
|
|
|
74
74
|
const blockConfig = blockData.params || blockData.config || {}
|
|
75
75
|
|
|
76
76
|
// ⭐ THE SECTION'S OWN SETTINGS — the names framework reserves in its params
|
|
77
|
-
// (`@uniweb/schemas/section`): `theme`, `background`, `grid`, `vars`, `fetch`.
|
|
78
|
-
// each — the runtime paints the background and the color context around
|
|
79
|
-
// the
|
|
80
|
-
//
|
|
81
|
-
//
|
|
82
|
-
// 2026-09-28]. It reads them from the
|
|
83
|
-
// also received `theme` (the mode),
|
|
84
|
-
// them there. ⛔ An editor's older
|
|
85
|
-
// — is no longer read
|
|
86
|
-
//
|
|
77
|
+
// (`@uniweb/schemas/section`): `theme`, `background`, `grid`, `vars`, `fetch`, `sticky`.
|
|
78
|
+
// Framework applies each — the runtime paints the background and the color context around
|
|
79
|
+
// the component and makes sticky the box that can stick, the page stylesheet applies the
|
|
80
|
+
// section's theme and its component's variables, kit's `ChildGrid` lays out the child
|
|
81
|
+
// sections — so each is lifted onto the block, normalized once for every renderer, and a
|
|
82
|
+
// component NEVER receives one as a param [Diego, 2026-09-28]. It reads them from the
|
|
83
|
+
// block, or through kit. ⛔ Until then a component also received `theme` (the mode),
|
|
84
|
+
// `background` and `vars` as params, and nothing read them there. ⛔ An editor's older
|
|
85
|
+
// envelope — `params.standardOptions` and `params.properties` — is no longer read
|
|
86
|
+
// (2026-09-28): an editor's preview sends a section's params as stored, and no store
|
|
87
|
+
// publishes the envelope. Either name is an ordinary param now.
|
|
87
88
|
const {
|
|
88
89
|
theme: rawTheme, background: rawBg, grid: gridParam, vars: varsParam, fetch: fetchParam,
|
|
90
|
+
sticky: stickyParam,
|
|
89
91
|
...componentParams
|
|
90
92
|
} = blockConfig
|
|
91
93
|
this.properties = componentParams
|
|
92
94
|
|
|
95
|
+
// Whether the section stays in view as the page scrolls — what the author wrote (`true` or
|
|
96
|
+
// `false`; anything else is no answer), else its type's default from `meta.js`, which
|
|
97
|
+
// `initComponent` reads, else not. The runtime applies it to the box that can stick: a
|
|
98
|
+
// component's own markup sits in boxes as tall as itself, where `sticky` cannot move
|
|
99
|
+
// (2026-10-19).
|
|
100
|
+
this.stickySetting = typeof stickyParam === 'boolean' ? stickyParam : null
|
|
101
|
+
this.sticky = this.stickySetting ?? false
|
|
102
|
+
// How far below the top it stays — its type's `top`, a CSS length; null is the very top.
|
|
103
|
+
this.stickyTop = null
|
|
104
|
+
|
|
93
105
|
// The section's theme: `theme.yml`'s own keys scoped to the section — `colors`,
|
|
94
106
|
// `contexts`, `vars` — plus `mode`, the color context it pins. `theme: dark` is the
|
|
95
107
|
// shorthand for `{ mode: dark }`, and a token written beside `mode` applies to the section
|
|
@@ -506,9 +518,32 @@ export default class Block {
|
|
|
506
518
|
this.componentVars = Block.mergeComponentVars(meta.vars, this.sectionVars)
|
|
507
519
|
}
|
|
508
520
|
|
|
521
|
+
// The type's `sticky`: `true`, or `{ default, top }` — the author's value wins.
|
|
522
|
+
const sticky = Block.normalizeStickyDeclaration(meta.sticky)
|
|
523
|
+
this.sticky = this.stickySetting ?? sticky.default
|
|
524
|
+
this.stickyTop = sticky.top
|
|
525
|
+
|
|
509
526
|
return this.Component
|
|
510
527
|
}
|
|
511
528
|
|
|
529
|
+
/**
|
|
530
|
+
* A section type's `sticky` declaration, as `meta.js` may write it: `true` or `false`, or
|
|
531
|
+
* `{ default, top }` — `top` a CSS length, for a type that sits below another sticking
|
|
532
|
+
* element.
|
|
533
|
+
*
|
|
534
|
+
* @param {*} declared
|
|
535
|
+
* @returns {{ default: boolean, top: string|null }}
|
|
536
|
+
*/
|
|
537
|
+
static normalizeStickyDeclaration(declared) {
|
|
538
|
+
if (declared && typeof declared === 'object') {
|
|
539
|
+
return {
|
|
540
|
+
default: declared.default === true,
|
|
541
|
+
top: typeof declared.top === 'string' && declared.top.trim() ? declared.top.trim() : null,
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
return { default: declared === true, top: null }
|
|
545
|
+
}
|
|
546
|
+
|
|
512
547
|
/**
|
|
513
548
|
* Get block properties
|
|
514
549
|
*/
|
package/src/page.js
CHANGED
|
@@ -376,6 +376,20 @@ export default class Page {
|
|
|
376
376
|
return result
|
|
377
377
|
}
|
|
378
378
|
|
|
379
|
+
/**
|
|
380
|
+
* Whether a layout area stays in view as the page scrolls: any of its sections is sticky
|
|
381
|
+
* (`sticky:`, a setting of the section). The runtime makes sticky the box it gives the area;
|
|
382
|
+
* a layout that wraps the area in an element of its own makes THAT element sticky when this
|
|
383
|
+
* is true, since a box sticks only within its parent, and the area's sits in the layout's.
|
|
384
|
+
*
|
|
385
|
+
* @param {string} areaName
|
|
386
|
+
* @returns {boolean}
|
|
387
|
+
*/
|
|
388
|
+
isSticky(areaName) {
|
|
389
|
+
const blocks = this.getLayoutAreas()[areaName]
|
|
390
|
+
return Array.isArray(blocks) && blocks.some((block) => block.sticky)
|
|
391
|
+
}
|
|
392
|
+
|
|
379
393
|
/**
|
|
380
394
|
* Get layout params for this page (merged with defaults at render time)
|
|
381
395
|
* @returns {Object}
|