@lightningjs/blits 1.11.0 → 1.12.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/.github/workflows/deploy-docs.yml +1 -1
- package/CHANGELOG.md +7 -0
- package/blits.d.ts +6 -0
- package/docs/built-in/layout.md +29 -1
- package/docs/plugins/global_app_state.md +21 -0
- package/index.d.ts +3 -0
- package/package.json +1 -1
- package/src/engines/L3/element.js +9 -4
- package/src/plugins/theme.js +1 -1
- package/src/router/router.js +1 -1
|
@@ -19,7 +19,7 @@ jobs:
|
|
|
19
19
|
--retry 2 \
|
|
20
20
|
--retry-delay 5 \
|
|
21
21
|
${{ secrets.WEBSITE_DEPLOY_URL }})
|
|
22
|
-
if [ "$response" -
|
|
22
|
+
if [ "$response" -ge 200 ] && [ "$response" -lt 300 ]; then
|
|
23
23
|
echo "Deployment triggered successfully"
|
|
24
24
|
else
|
|
25
25
|
echo "Failed to trigger deployment. Status code: $response"
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v1.12.0
|
|
4
|
+
|
|
5
|
+
- Fixed `$hasFocus` state variable not being set when navigating back to a page with `keepAlive` enabled
|
|
6
|
+
- Added `@updated`-event to Layout component
|
|
7
|
+
- Fixed issue with simple config for Theme plugin
|
|
8
|
+
|
|
9
|
+
|
|
3
10
|
## v1.11.0
|
|
4
11
|
|
|
5
12
|
_19 nov 2024_
|
package/blits.d.ts
ADDED
package/docs/built-in/layout.md
CHANGED
|
@@ -63,7 +63,35 @@ And of course you can nest _vertical_ Layouts inside a _horizontal_ one - and vi
|
|
|
63
63
|
|
|
64
64
|
### Transitioning layouts
|
|
65
65
|
|
|
66
|
-
The `<Layout>`-component can also take into account when dimensions of children change with a transition applied to it. The component will recalculate the position of its children as the transition progresses, making sure that elements are always perfectly positioned relative to one another.
|
|
66
|
+
The `<Layout>`-component can also take into account when dimensions of children change with a transition applied to it (i.e. `<Element :w.transition="$myWidth">`). The component will recalculate the position of its children as the transition progresses, making sure that elements are always perfectly positioned relative to one another.
|
|
67
|
+
|
|
68
|
+
### Updated event
|
|
69
|
+
|
|
70
|
+
The `<Layout>`-tag automatically updates its dimensions based on the dimensions of its children. After each update in the children, the an `updated`-event is emitted on the `<Layout>`-tag. It will receive the current dimensions of the layout.
|
|
71
|
+
|
|
72
|
+
You can tap into this event by adding an `@updated`-attribute to the `<Layout />`-tag and refer to a method in your Component logic.
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
```js
|
|
76
|
+
export default Blits.Component('LayoutUpdate', {
|
|
77
|
+
template: `
|
|
78
|
+
<Element>
|
|
79
|
+
<Layout @updated="$layoutUpdate">
|
|
80
|
+
<Element :w="$width" h="40" color="red" />
|
|
81
|
+
<Element :w="$width" h="40" color="blue" />
|
|
82
|
+
<Element :w="$width" h="40" color="green" />
|
|
83
|
+
</Layout>
|
|
84
|
+
</Element>
|
|
85
|
+
`,
|
|
86
|
+
methods: {
|
|
87
|
+
layoutUpdate(dimensions, el) {
|
|
88
|
+
console.log(`Layout (${el.nodeId}) dimensions updated! Width: ${dimensions.w}, Height: ${dimensions.h}`)
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
})
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
> Please be aware that the `@updated` event can fire multiple times. The size of the Layout-tag is recalculated for each change in children. Also note that the `@updated` event does not guarantee a change in dimensions. It is possible that it fires for a children update, but remains the same size.
|
|
67
95
|
|
|
68
96
|
## Performance
|
|
69
97
|
|
|
@@ -75,3 +75,24 @@ The second `$`-sign is needed, since the appState plugin itself is prefixed with
|
|
|
75
75
|
|
|
76
76
|
In order to read or update variables on the global app state inside the component logic, you can access the entire state via `this.$appState`.
|
|
77
77
|
|
|
78
|
+
### Watching global state
|
|
79
|
+
|
|
80
|
+
Similar to component state, you can watch for changes in the global state as well. You can to refer to global state variables using _dot-notation_ in the watcher function name, and _prefixing_ it with `$appState`. This means that you need to define your watcher as a `String`, matching one of the examples below, depending on your style preference.
|
|
81
|
+
|
|
82
|
+
```js
|
|
83
|
+
Blits.Component('MyComponent', {
|
|
84
|
+
template: `
|
|
85
|
+
<Element>
|
|
86
|
+
<Text :content="$$appState.loggedIn ? $$appState.user.name : 'Not logged in'" />
|
|
87
|
+
</Element>
|
|
88
|
+
`,
|
|
89
|
+
watch: {
|
|
90
|
+
'$appState.fooBar'(v, old) {
|
|
91
|
+
console.log(`$appState.fooBar changed from ${old} to ${v}`)
|
|
92
|
+
},
|
|
93
|
+
'$appState.my.nested.data': function(v, old) {
|
|
94
|
+
console.log(`My nested App state data changed!`)
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
})
|
|
98
|
+
```
|
package/index.d.ts
CHANGED
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
* SPDX-License-Identifier: Apache-2.0
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
+
// blits file type reference
|
|
19
|
+
/// <reference path="./blits.d.ts" />
|
|
20
|
+
|
|
18
21
|
import {type ShaderEffect as RendererShaderEffect, type WebGlCoreShader} from '@lightningjs/renderer'
|
|
19
22
|
|
|
20
23
|
declare module '@lightningjs/blits' {
|
package/package.json
CHANGED
|
@@ -30,7 +30,7 @@ const layoutFn = function (config) {
|
|
|
30
30
|
const dimension = config.direction === 'vertical' ? 'height' : 'width'
|
|
31
31
|
const oppositeDimension = config.direction === 'vertical' ? 'width' : 'height'
|
|
32
32
|
|
|
33
|
-
const children = this.children
|
|
33
|
+
const children = this.node.children
|
|
34
34
|
const childrenLength = children.length
|
|
35
35
|
let otherDimension = 0
|
|
36
36
|
const gap = config.gap || 0
|
|
@@ -53,8 +53,8 @@ const layoutFn = function (config) {
|
|
|
53
53
|
otherDimension = Math.max(otherDimension, node[oppositeDimension])
|
|
54
54
|
}
|
|
55
55
|
// adjust the size of the layout container
|
|
56
|
-
this[dimension] = offset - gap
|
|
57
|
-
this[oppositeDimension] = otherDimension
|
|
56
|
+
this.node[dimension] = offset - gap
|
|
57
|
+
this.node[oppositeDimension] = otherDimension
|
|
58
58
|
|
|
59
59
|
const align = {
|
|
60
60
|
start: 0,
|
|
@@ -69,6 +69,11 @@ const layoutFn = function (config) {
|
|
|
69
69
|
node[oppositeMount] = align
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
+
|
|
73
|
+
// emit an updated event
|
|
74
|
+
if (config['@updated'] !== undefined) {
|
|
75
|
+
config['@updated']({ w: this.node.width, h: this.node.height }, this)
|
|
76
|
+
}
|
|
72
77
|
}
|
|
73
78
|
|
|
74
79
|
const isTransition = (value) => {
|
|
@@ -363,7 +368,7 @@ const Element = {
|
|
|
363
368
|
}
|
|
364
369
|
|
|
365
370
|
if (props.__layout === true) {
|
|
366
|
-
this.triggerLayout = layoutFn.bind(this
|
|
371
|
+
this.triggerLayout = layoutFn.bind(this)
|
|
367
372
|
}
|
|
368
373
|
|
|
369
374
|
if (this.config.parent.props !== undefined && this.config.parent.props.__layout === true) {
|
package/src/plugins/theme.js
CHANGED
|
@@ -72,7 +72,7 @@ export default {
|
|
|
72
72
|
// theme get function when current theme is modified
|
|
73
73
|
state.current
|
|
74
74
|
if (themeMap[key] !== undefined) return themeMap[key]
|
|
75
|
-
const value = getValueByDotNotation(themes[state.current], themes[base], key)
|
|
75
|
+
const value = getValueByDotNotation(themes[state.current], themes[base] || null, key)
|
|
76
76
|
if (value !== undefined) {
|
|
77
77
|
// store the value for next time
|
|
78
78
|
themeMap[key] = value
|
package/src/router/router.js
CHANGED
|
@@ -195,7 +195,7 @@ export const navigate = async function () {
|
|
|
195
195
|
previousFocus = Focus.get()
|
|
196
196
|
|
|
197
197
|
// set focus to the view that we're routing to
|
|
198
|
-
focus ?
|
|
198
|
+
focus ? focus.$focus() : view.$focus()
|
|
199
199
|
|
|
200
200
|
// apply before settings to holder element
|
|
201
201
|
if (route.transition.before) {
|