Skip to content

Commit

Permalink
Merge pull request #224 from lightning-js/dev
Browse files Browse the repository at this point in the history
Release v1.11.0
  • Loading branch information
michielvandergeest authored Nov 19, 2024
2 parents ba8f8aa + 34f884e commit e558cd4
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 18 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
# Changelog

## v1.11.0

_19 nov 2024_

- Added support for splitting up translation file per language
- Added hasFocus property to ComponentBase type
- Fixed issue with alpha during router transitions


## v1.10.1

_15 nov 2024_

- Upgraded to renderer 2.7.1
- Added documentation on Router


## v1.10.0

_8 nov 2024_
Expand Down
5 changes: 5 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ declare module '@lightningjs/blits' {
}

export type ComponentBase = {
/**
* Check if a component has focus
*/
hasFocus: boolean,

/**
* Listen to events emitted by other components
*/
Expand Down
4 changes: 2 additions & 2 deletions 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 package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lightningjs/blits",
"version": "1.10.1",
"version": "1.11.0",
"description": "Blits: The Lightning 3 App Development Framework",
"bin": "bin/index.js",
"exports": {
Expand Down
54 changes: 39 additions & 15 deletions src/plugins/language.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,45 @@ export default {
)

const setLanguage = (language) => {
// define the dictionary
dictionary = translations[language] || {}
// set the current language in the reactive state
state.language = language

// warnings
if (Object.keys(translations).length === 0) {
Log.warn(
'No translations loaded. Please load a file with translations or specify a translations object manually'
)
}
if (language in translations === false) {
Log.warn(`Language ${language} not available in the loaded translations`)
const warningMsg =
Object.keys(translations).length === 0
? 'No translations loaded. Please load a file with translations or specify a translations object manually'
: language in translations === false
? `Language ${language} not available in the loaded translations`
: false
if (warningMsg) {
Log.warn(warningMsg)
// set the current language in the reactive state
state.language = language
} else {
setDict(language).then(() => {
state.language = language
})
}
}

const setDict = (language) => {
return new Promise((resolve) => {
const translationObj = translations[language]
if (typeof translationObj === 'object') {
dictionary = translationObj
resolve()
} else if (typeof translationObj === 'string') {
fetchJson(translationObj)
.then((result) => {
// save the translations for this language (to prevent loading twice)
translations[language] = result
// define the dictionary
dictionary = result
resolve()
})
.catch((e) => {
Log.error(e)
})
}
})
}

const loadLanguageFile = (filePath) => {
return fetchJson(filePath)
.then((result) => {
Expand All @@ -65,8 +88,9 @@ export default {

const setTranslations = (translationsObject) => {
translations = translationsObject
dictionary = translations[state.language] || {}
state.loaded++
setDict(state.language).then(() => {
state.loaded++
})
}

if ('file' in options) {
Expand Down
19 changes: 19 additions & 0 deletions src/router/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,25 @@ export const navigate = async function () {
}
} else {
holder = view[symbols.holder]

// Check, whether cached view holder's alpha prop is exists in transition or not
let hasAlphaProp = false
if (route.transition.before) {
if (Array.isArray(route.transition.before)) {
for (let i = 0; i < route.transition.before.length; i++) {
if (route.transition.before[i].prop === 'alpha') {
hasAlphaProp = true
break
}
}
} else if (route.transition.before.prop === 'alpha') {
hasAlphaProp = true
}
}
// set holder alpha when alpha prop is not exists in route transition
if (hasAlphaProp === false) {
holder.set('alpha', 1)
}
}

this[symbols.children].push(view)
Expand Down

0 comments on commit e558cd4

Please sign in to comment.