@uniweb/runtime 1.5.2 → 1.5.3
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/ssr.js +4 -6
- package/dist/ssr.js.map +1 -1
- package/package.json +3 -3
- package/src/sticky-top.js +4 -7
- package/src/under-header.js +15 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniweb/runtime",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.3",
|
|
4
4
|
"description": "Minimal runtime for loading Uniweb foundations",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"node": ">=22.12"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@uniweb/
|
|
40
|
-
"@uniweb/
|
|
39
|
+
"@uniweb/core": "~1.6.8",
|
|
40
|
+
"@uniweb/theming": "~1.3.2"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@vitejs/plugin-react": "^4.5.2",
|
package/src/sticky-top.js
CHANGED
|
@@ -65,19 +65,16 @@ function drawnHeight(box) {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
|
-
* How tall the header lying over the page's opening section is, in px —
|
|
69
|
-
* header on such a page, null on a page with no section under the header.
|
|
68
|
+
* How tall the header lying over the page's opening section is, in px — null on a page with none.
|
|
70
69
|
*
|
|
71
70
|
* @param {Document} doc
|
|
72
71
|
* @returns {number|null}
|
|
73
72
|
*/
|
|
74
73
|
export function measureHeaderOverlay(doc) {
|
|
75
74
|
const box = doc.querySelector('[data-uw-header="over"]')
|
|
76
|
-
|
|
77
|
-
//
|
|
78
|
-
|
|
79
|
-
// ⛔ Until 2026-11-06 it kept the declared height, padding the section for a header not there.
|
|
80
|
-
return doc.querySelector('[data-uw-under-header]') ? 0 : null
|
|
75
|
+
// A page under the header whose layout drew no header has no box to measure, and the page's
|
|
76
|
+
// stylesheet pads its section by nothing (`underHeaderProps`).
|
|
77
|
+
return box ? Math.round(drawnHeight(box) * 100) / 100 : null
|
|
81
78
|
}
|
|
82
79
|
|
|
83
80
|
/**
|
package/src/under-header.js
CHANGED
|
@@ -28,6 +28,9 @@ export const HEADER_HEIGHT = '--uw-header-height'
|
|
|
28
28
|
/** What the browser measured, on the root, which the opening section's value defers to. */
|
|
29
29
|
export const MEASURED_HEADER_HEIGHT = '--uw-header-measured'
|
|
30
30
|
|
|
31
|
+
/** The header types' declared height, on the opening section's wrapper: the value before measuring. */
|
|
32
|
+
export const DECLARED_HEADER_HEIGHT = '--uw-header-declared'
|
|
33
|
+
|
|
31
34
|
/**
|
|
32
35
|
* Whether the page's header lies over its opening section, and how tall the header is before the
|
|
33
36
|
* browser measures it: the `height` its sections' types declare, else `0px` until measured.
|
|
@@ -37,9 +40,8 @@ export const MEASURED_HEADER_HEIGHT = '--uw-header-measured'
|
|
|
37
40
|
*/
|
|
38
41
|
export function headerOverlay(page) {
|
|
39
42
|
const first = page?.getBodyBlocks?.()?.[0]
|
|
40
|
-
if (!first?.
|
|
41
|
-
const header = page.getLayoutAreas
|
|
42
|
-
if (!Array.isArray(header) || header.length === 0) return null
|
|
43
|
+
if (!first?.liesUnderHeader?.()) return null
|
|
44
|
+
const header = page.getLayoutAreas().header
|
|
43
45
|
const heights = header.map((block) => block?.height).filter(Boolean)
|
|
44
46
|
const height = heights.length === 0 ? '0px' : heights.length === 1 ? heights[0] : `calc(${heights.join(' + ')})`
|
|
45
47
|
return { height }
|
|
@@ -88,15 +90,22 @@ export function headerAreaProps(wrapper, overlay) {
|
|
|
88
90
|
}
|
|
89
91
|
|
|
90
92
|
/**
|
|
91
|
-
* What the opening section's wrapper adds when the header lies over it: the header's
|
|
92
|
-
*
|
|
93
|
+
* What the opening section's wrapper adds when the header lies over it: the header type's declared
|
|
94
|
+
* height, and the mark the page's stylesheet keys on.
|
|
95
|
+
*
|
|
96
|
+
* ⭐ THE STYLESHEET GIVES THE SECTION ITS `--uw-header-height` (`@uniweb/theming`): what the browser
|
|
97
|
+
* measured, else the declared height, on a page where a header box lies over it
|
|
98
|
+
* (`[data-uw-header="over"]`), and `0px` on one where none does — a layout that draws no header on
|
|
99
|
+
* the page. A rule rather than this style, since only the rendered page holds that answer, and so
|
|
100
|
+
* the first paint, the prerender's included, pads by what is there. ⛔ Until 2026-11-06 the section
|
|
101
|
+
* was padded by the declared height whatever the layout drew, until the browser measured.
|
|
93
102
|
*
|
|
94
103
|
* @param {{ height: string }} overlay - `headerOverlay(page)`
|
|
95
104
|
* @returns {{ style: Object, 'data-uw-under-header': string }}
|
|
96
105
|
*/
|
|
97
106
|
export function underHeaderProps(overlay) {
|
|
98
107
|
return {
|
|
99
|
-
style: { [
|
|
108
|
+
style: { [DECLARED_HEADER_HEIGHT]: overlay.height },
|
|
100
109
|
'data-uw-under-header': '',
|
|
101
110
|
}
|
|
102
111
|
}
|