@lightningjs/blits 0.4.2 → 0.5.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ # v0.5.0
4
+
5
+ _23 nov 2023_
6
+
7
+ - Introduced `wordwrap` and `maxlines` attributes on the Text-component, replacing the previous `w` and `h` attributes (breaking change!)
8
+
3
9
  # v0.4.2
4
10
 
5
11
  _22 nov 2023_
@@ -31,6 +31,6 @@
31
31
  "vite": "^4.0.4"
32
32
  },
33
33
  "dependencies": {
34
- "@lightningjs/blits": "^0.4.2"
34
+ "@lightningjs/blits": "^0.5.0"
35
35
  }
36
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightningjs/blits",
3
- "version": "0.4.2",
3
+ "version": "0.5.0",
4
4
  "description": "Blits: The Lightning 3 App Development Framework",
5
5
  "bin": "bin/index.cjs",
6
6
  "exports": {
@@ -31,8 +31,8 @@ export default () =>
31
31
  letterSpacing="$letterspacing"
32
32
  stretch="$stretch"
33
33
  contain="$_contain"
34
- :w="$w"
35
- :h="$h"
34
+ :wordWrap="$wordwrap"
35
+ :maxLines="$maxlines"
36
36
  :textAlign="$align"
37
37
  @loaded="$@loaded"
38
38
  @error="$@error"
@@ -54,15 +54,18 @@ export default () =>
54
54
  'letterspacing',
55
55
  'stretch',
56
56
  'align',
57
- 'w',
58
- 'h',
57
+ 'wordwrap',
58
+ 'maxlines',
59
59
  'contain',
60
60
  '@loaded',
61
61
  '@error',
62
62
  ],
63
63
  computed: {
64
64
  _contain() {
65
- return this.contain || (this.w && this.h ? 'both' : this.w ? 'width' : 'none')
65
+ return (
66
+ this.contain ||
67
+ (this.wordwrap && this.maxlines ? 'both' : this.wordwrap ? 'width' : 'none')
68
+ )
66
69
  },
67
70
  },
68
71
  })
package/src/element.js CHANGED
@@ -54,6 +54,8 @@ const transformations = {
54
54
  delete props.h
55
55
  'z' in props && (props.zIndex = props.z)
56
56
  delete props.z
57
+ 'wordWrap' in props && (props.width = props.wordWrap)
58
+ delete props.wordWrap
57
59
  },
58
60
  parent(props) {
59
61
  if (props.parent === 'root') {
@@ -161,6 +163,12 @@ const transformations = {
161
163
  texture(props, setProperties) {
162
164
  this.src(props, setProperties)
163
165
  },
166
+ maxLines(props, setProperties, element) {
167
+ if (props.maxLines) {
168
+ props.height = props.maxLines * element.node.fontSize
169
+ }
170
+ delete props.maxLines
171
+ },
164
172
  }
165
173
 
166
174
  const Element = {
@@ -217,7 +225,7 @@ const Element = {
217
225
 
218
226
  transformations.remap(props)
219
227
  if (transformations[prop]) {
220
- transformations[prop](props, this.setProperties)
228
+ transformations[prop](props, this.setProperties, this)
221
229
  }
222
230
 
223
231
  Object.keys(props).forEach((prop) => {