@uniweb/kit 0.19.8 → 0.19.10
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": "@uniweb/kit",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.10",
|
|
4
4
|
"description": "Standard component library for Uniweb foundations",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -43,10 +43,10 @@
|
|
|
43
43
|
"shiki": "^3.0.0",
|
|
44
44
|
"tailwind-merge": "^3.6.0",
|
|
45
45
|
"temml": "^0.13.2",
|
|
46
|
-
"@uniweb/
|
|
47
|
-
"@uniweb/projections": "^0.7.7",
|
|
48
|
-
"@uniweb/schemas": "^0.8.0",
|
|
46
|
+
"@uniweb/projections": "^0.7.10",
|
|
49
47
|
"@uniweb/scene": "^0.1.3",
|
|
48
|
+
"@uniweb/schemas": "^0.9.0",
|
|
49
|
+
"@uniweb/core": "^0.34.0",
|
|
50
50
|
"@uniweb/semantic-parser": "^1.4.1"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SectionBackground — the background the author set on a section, drawn by the runtime's own
|
|
3
|
+
* renderer, for a component that places it itself.
|
|
4
|
+
*
|
|
5
|
+
* The runtime draws a section's background behind every section, so most components need
|
|
6
|
+
* nothing. A component that paints its own — a hero with a built-in gradient, a background
|
|
7
|
+
* that belongs inside a card — declares `background: 'self'` in its `meta.js`, and the runtime
|
|
8
|
+
* then draws none. With this it can still draw what the author chose, wherever it wants,
|
|
9
|
+
* without rebuilding the image, video, gradient and overlay handling.
|
|
10
|
+
*
|
|
11
|
+
* It fills the nearest positioned ancestor (`position: absolute; inset: 0`), so place it inside
|
|
12
|
+
* an element with `position: relative`, before the content.
|
|
13
|
+
*
|
|
14
|
+
* @param {Object} props
|
|
15
|
+
* @param {Object} props.block - The section's block — its `block.background`, normalized by core
|
|
16
|
+
* @param {string} [props.className] - Classes on the background layer
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* function Hero({ content, block }) {
|
|
20
|
+
* return (
|
|
21
|
+
* <section className="relative">
|
|
22
|
+
* <SectionBackground block={block} />
|
|
23
|
+
* <div className="relative z-10">…</div>
|
|
24
|
+
* </section>
|
|
25
|
+
* )
|
|
26
|
+
* }
|
|
27
|
+
*/
|
|
28
|
+
export function SectionBackground({ block, className }) {
|
|
29
|
+
const background = block?.background
|
|
30
|
+
if (!background?.mode) return null
|
|
31
|
+
const Renderer = globalThis.uniweb?.backgroundRenderer
|
|
32
|
+
if (!Renderer) return null
|
|
33
|
+
return <Renderer {...background} className={className} />
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export default SectionBackground
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SectionBackground, default } from './SectionBackground.jsx'
|
|
@@ -89,31 +89,28 @@ export function useThemeData() {
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
|
-
*
|
|
92
|
+
* The color context a section renders in: `'light'`, `'medium'` or `'dark'`.
|
|
93
93
|
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
94
|
+
* A section pinned with `theme:` renders in that context. One that follows the site — no
|
|
95
|
+
* `theme:` — renders in the site's current scheme, so on a dark-scheme site it is `'dark'`.
|
|
96
|
+
* This is how a component reads its context for its own logic, a light or dark logo say:
|
|
97
|
+
* `theme` is a setting of the section, never one of the component's params. ⛔ Until
|
|
98
|
+
* 2026-09-28 a section that follows the site read as `'light'` whatever the scheme.
|
|
96
99
|
*
|
|
97
|
-
* @param {Object} block -
|
|
98
|
-
* @returns {
|
|
100
|
+
* @param {Object} block - The section's Block
|
|
101
|
+
* @returns {'light'|'medium'|'dark'}
|
|
99
102
|
*
|
|
100
103
|
* @example
|
|
101
|
-
* function
|
|
104
|
+
* function Logo({ block }) {
|
|
102
105
|
* const context = useColorContext(block)
|
|
103
|
-
* return <
|
|
106
|
+
* return <img src={context === 'dark' ? '/logo-light.svg' : '/logo.svg'} alt="" />
|
|
104
107
|
* }
|
|
105
108
|
*/
|
|
106
109
|
export function useColorContext(block) {
|
|
107
|
-
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
const validContexts = ['light', 'medium', 'dark']
|
|
112
|
-
if (validContexts.includes(context)) {
|
|
113
|
-
return context
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return 'light'
|
|
110
|
+
const { scheme } = useAppearance()
|
|
111
|
+
const pinned = block?.themeName
|
|
112
|
+
if (pinned === 'light' || pinned === 'medium' || pinned === 'dark') return pinned
|
|
113
|
+
return scheme === 'dark' ? 'dark' : 'light'
|
|
117
114
|
}
|
|
118
115
|
|
|
119
116
|
/**
|
package/src/index.js
CHANGED
|
@@ -40,6 +40,9 @@ export { Asset } from './components/Asset/index.js'
|
|
|
40
40
|
// Data loading
|
|
41
41
|
export { DataPlaceholder } from './components/DataPlaceholder.jsx'
|
|
42
42
|
|
|
43
|
+
// A section's background, for a component that draws it itself (`background: 'self'`)
|
|
44
|
+
export { SectionBackground } from './components/SectionBackground/index.js'
|
|
45
|
+
|
|
43
46
|
// Social
|
|
44
47
|
export {
|
|
45
48
|
SocialIcon,
|
|
@@ -11,6 +11,10 @@
|
|
|
11
11
|
* columns applies as chosen and a wider one shows two equal columns; from `lg` the
|
|
12
12
|
* chosen layout applies whatever its width.
|
|
13
13
|
*
|
|
14
|
+
* ⭐ Each child renders as a section, in a `div`: its own `theme:` and `background:`
|
|
15
|
+
* apply, and it carries the `section-{id}` its theme rules select [2026-09-28]. ⛔ Until
|
|
16
|
+
* then the children rendered bare, and a child's theme and background did nothing.
|
|
17
|
+
*
|
|
14
18
|
* @module @uniweb/kit/styled/ChildGrid
|
|
15
19
|
*/
|
|
16
20
|
|
|
@@ -60,7 +64,7 @@ export function ChildGrid({ from: block, fallback = null, headerRow = false, cla
|
|
|
60
64
|
key={child.id || index}
|
|
61
65
|
className={cn(headerRow && index === 0 && 'md:col-span-full', cellClassName)}
|
|
62
66
|
>
|
|
63
|
-
<ChildBlocks blocks={[child]} />
|
|
67
|
+
<ChildBlocks blocks={[child]} wrapAs="div" />
|
|
64
68
|
</div>
|
|
65
69
|
))}
|
|
66
70
|
</div>
|