Skip to content

Commit

Permalink
Merge pull request #214 from lightning-js/dev
Browse files Browse the repository at this point in the history
Release 1.10.0
  • Loading branch information
michielvandergeest authored Nov 8, 2024
2 parents 4154b41 + 93d6ab9 commit b475bd0
Show file tree
Hide file tree
Showing 14 changed files with 114 additions and 25 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## v1.10.0

_8 nov 2024_

- Fixed issue with back button not bubbling to App component after last page in router history is popped
- Added `align-items` attribute to Layout component
- Fixed issue with watching nested state variables and global state
- Upgraded to renderer 2.6.2
- Fixed issue with white background for Elements with falsy src attribute
- Fixed issue with calling focus on component that already is focussed


## v1.9.2

_5 nov 2024_
Expand Down
8 changes: 8 additions & 0 deletions docs/built-in/layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ In order to align vertically use `<Layout direction="vertical"></Layout>`. And u

By default the Layout-component places each Element directly besides (or below) the previous one. By adding the `gap`-attribute you can control how much space will be added between each Element or Component. The `gap`-attribute accepts a number in pixels.

### Aligning items

The layout component positions its children based on the provided direction (`horizontal` or `vertical`). With the `align-items`-attribute you can specify how to align the children on the opposite axis:

- `start` (the default value) - aligns the children in the _top_ for horizontal layouts, and on the _left_ for vertical layouts
- `center` - align the children in the center
- `end` - aligns the children in the _bottom_ for horizontal layouts, and on the _right_ for vertical layouts

### Dynamic dimensions

For the Layout component to work properly, the direct children all need to have dimensions (i.e `w` and `h` attributes). The exception here being Text elements.
Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lightningjs/blits",
"version": "1.9.2",
"version": "1.10.0",
"description": "Blits: The Lightning 3 App Development Framework",
"bin": "bin/index.js",
"exports": {
Expand Down Expand Up @@ -50,7 +50,7 @@
},
"dependencies": {
"@lightningjs/msdf-generator": "^1.1.0",
"@lightningjs/renderer": "^2.6.0"
"@lightningjs/renderer": "^2.6.2"
},
"repository": {
"type": "git",
Expand Down
6 changes: 6 additions & 0 deletions packages/create-blits/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## v1.3.0

_08 Nov 2024_

- Added favicon to boilerplate project

## v1.2.0

_22 Oct 2024_
Expand Down
32 changes: 32 additions & 0 deletions packages/create-blits/boilerplate/common/public/assets/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions packages/create-blits/boilerplate/js/default/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<style>
html, body, * { padding: 0; margin: 0}
</style>
<link rel="icon" href="public/assets/favicon.svg" type="image/svg">
</head>
<body>
<div id="app"></div>
Expand Down
1 change: 1 addition & 0 deletions packages/create-blits/boilerplate/ts/default/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<style>
html, body, * { padding: 0; margin: 0}
</style>
<link rel="icon" href="public/assets/favicon.svg" type="image/svg">
</head>
<body>
<div id="app"></div>
Expand Down
4 changes: 2 additions & 2 deletions packages/create-blits/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/create-blits/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lightningjs/create-blits",
"version": "1.2.0",
"version": "1.3.0",
"description": "Create a new Lightning 3 Blits App",
"bin": "bin/index.js",
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion src/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ const Component = (name = required('name'), config = required('config')) => {
for (let i = 0; i < watcherkeysLength; i++) {
let target = this
let key = watcherkeys[i]
const watchKey = key
// when dot notation used, find the nested target
if (key.indexOf('.') > -1) {
const keys = key.split('.')
Expand All @@ -190,7 +191,7 @@ const Component = (name = required('name'), config = required('config')) => {
effect((force = false) => {
const newValue = target[key]
if (old !== newValue || force === true) {
this[symbols.watchers][key].apply(this, [newValue, old])
this[symbols.watchers][watchKey].apply(this, [newValue, old])
old = newValue
}
})
Expand Down
7 changes: 5 additions & 2 deletions src/components/RouterView.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@ export default () =>
},
},
input: {
back() {
Router.back()
back(e) {
const navigating = Router.back()
if (navigating === false) {
this.parent.$focus(e)
}
},
},
})
46 changes: 35 additions & 11 deletions src/engines/L3/element.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,23 @@ import Settings from '../../settings.js'

const layoutFn = function (config) {
let offset = 0
const xy = config.direction === 'vertical' ? 'y' : 'x'
const wh = config.direction === 'vertical' ? 'height' : 'width'
const opositeWh = config.direction === 'vertical' ? 'width' : 'height'
const position = config.direction === 'vertical' ? 'y' : 'x'
const oppositePosition = config.direction === 'vertical' ? 'x' : 'y'
const oppositeMount = config.direction === 'vertical' ? 'mountX' : 'mountY'
const dimension = config.direction === 'vertical' ? 'height' : 'width'
const oppositeDimension = config.direction === 'vertical' ? 'width' : 'height'

const children = this.children
const childrenLength = children.length
let otherDimension = 0
const gap = config.gap || 0
for (let i = 0; i < childrenLength; i++) {
const node = children[i]
node[xy] = offset
node[position] = offset
// todo: temporary text check, due to 1px width of empty text node
if (wh === 'width') {
if (dimension === 'width') {
offset += node.width + (node.width !== ('text' in node ? 1 : 0) ? gap : 0)
} else if (wh === 'height') {
} else if (dimension === 'height') {
offset +=
'text' in node
? node.width > 1
Expand All @@ -48,11 +50,25 @@ const layoutFn = function (config) {
? node.height + gap
: 0
}
otherDimension = Math.max(otherDimension, node[opositeWh])
otherDimension = Math.max(otherDimension, node[oppositeDimension])
}
// adjust the size of the layout container
this[wh] = offset - gap
this[opositeWh] = otherDimension
this[dimension] = offset - gap
this[oppositeDimension] = otherDimension

const align = {
start: 0,
end: 1,
center: 0.5,
}[config['align-items'] || 'start']

if (align !== 0) {
for (let i = 0; i < childrenLength; i++) {
const node = children[i]
node[oppositePosition] = otherDimension
node[oppositeMount] = align
}
}
}

const isTransition = (value) => {
Expand Down Expand Up @@ -146,7 +162,7 @@ const propsTransformer = {
set src(v) {
this.props['src'] = v
if (this.raw['color'] === undefined) {
this.props['color'] = 0xffffffff
this.props['color'] = this.props['src'] ? 0xffffffff : 0x00000000
}
},
set texture(v) {
Expand Down Expand Up @@ -225,7 +241,15 @@ const propsTransformer = {
}
},
set show(v) {
this.props['alpha'] = v ? 1 : 0
if (v) {
this.props['alpha'] = 1
this.props['width'] = this.raw['w'] || this.raw['width']
this.props['height'] = this.raw['h'] || this.raw['height']
} else {
this.props['alpha'] = 0
this.props['width'] = 0
this.props['height'] = 0
}
},
set alpha(v) {
this.props['alpha'] = v
Expand Down
1 change: 1 addition & 0 deletions src/focus.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export default {
return focusedComponent
},
set(component, event) {
if (component === focusedComponent) return
clearTimeout(setFocusTimeout)
focusedComponent && focusedComponent !== component.parent && focusedComponent.unfocus()
focusChain.reverse().forEach((cmp) => cmp.unfocus())
Expand Down

0 comments on commit b475bd0

Please sign in to comment.