diff --git a/index.d.ts b/index.d.ts index 931f41c0..dab2db41 100644 --- a/index.d.ts +++ b/index.d.ts @@ -153,7 +153,9 @@ declare module '@lightningjs/blits' { export type ComponentBase = { /** - * Check if a component has focus + * Indicates whether the component currently has focus + * + * @returns Boolean */ hasFocus: boolean, @@ -244,11 +246,23 @@ declare module '@lightningjs/blits' { * Deprecated: use `this.$trigger()` instead */ trigger: (key: string) => void - /** * Router instance */ $router: Router + /** + * Dynamically set the size of a component holder node + */ + $size: (dimensions: { + /** + * Component width + */ + w: number, + /** + * Component height + */ + h: number + }) => void } /** diff --git a/src/component/base/utils.js b/src/component/base/utils.js index 298efbfb..6437a2e3 100644 --- a/src/component/base/utils.js +++ b/src/component/base/utils.js @@ -20,6 +20,15 @@ import symbols from '../../lib/symbols.js' import { renderer } from '../../launch.js' export default { + $size: { + value: function (dimensions = { w: 0, h: 0 }) { + this[symbols.holder].set('w', dimensions.w || 0) + this[symbols.holder].set('height', dimensions.h || 0) + }, + writable: false, + enumerable: true, + configurable: false, + }, [symbols.renderer]: { value: () => renderer, writable: false,