From 3e04d6c6c2ff39e27cff456c29e9a74d054db8e9 Mon Sep 17 00:00:00 2001 From: Default User Date: Thu, 31 Jul 2025 13:23:15 +0200 Subject: [PATCH] MINOR,FEAT,REFA,DOC,LINT: Update Component.js and FlexContainerComponent.js --- src/component/Component.js | 19 ++++++++++++++++++- src/component/FlexContainerComponent.js | 12 ++++++------ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/component/Component.js b/src/component/Component.js index d78b10e..817126e 100644 --- a/src/component/Component.js +++ b/src/component/Component.js @@ -82,7 +82,7 @@ class Component extends StyleAndScriptStoringComponent { * @param {boolean} horizontal Defines if the Component should overflow horizontally (default: false) * @returns {Component} */ - overflow(vertical = true, horizontal = false ) { + overflow(vertical = true, horizontal = false) { if (vertical || horizontal) { this._modifier.join( new Modifier() @@ -124,6 +124,23 @@ class Component extends StyleAndScriptStoringComponent { return this; } + /** + * Since the "hidden" method call was quite often called as being conditional, + * and to resolve that it needed to be wrapped into an apply (and if condition within that) call. + * This method is purely convinience as it reduces unnecessary code line. + * @experimental + * @convenience + * @param {boolean} [condition=false] + * @param {boolean} [untilFound=false] + * @returns {Component} + */ + hiddenByCondition(condition = false, untilFound = false) { + if (condition) { + return this.hidden(untilFound); + } + return this; + } + /** * Subscribes element under higher_compel group * sets corr. variable true diff --git a/src/component/FlexContainerComponent.js b/src/component/FlexContainerComponent.js index e86f707..6d226a4 100644 --- a/src/component/FlexContainerComponent.js +++ b/src/component/FlexContainerComponent.js @@ -78,10 +78,9 @@ class FlexContainerComponent extends Component { /** * - * @param {number} [recessFraction=0.0] recessFraction a fraction/percentage of the recess + * @param {number} [recessFraction=0.0] recessFraction a fraction/percentage (<1.0) of the recess * that should be left out before distributing the remaining space. - * @param {number} [gapPerChild=1] gapPerChild the gap per child, therefore inbetween children - * that shouldn't be distributed to the children + * @param {number} [gapPerChild=1] gapPerChild the gap per child, therefore the recess between children */ _distributingSpacing(recessFraction = 0.0, gapPerChild = 1) { if (this._children && this._children.length > 1) { @@ -110,13 +109,14 @@ class FlexContainerComponent extends Component { * Distributes the spacing of the childrens evengly, * according to the flexdirection of this component. * By default this will be executed imediately when called. + * The spacing is distributed by: + * 100 - 100 * recessFraction - (children) * gapPerChild * * @param {boolean} [rightNow=true] if set to false it will set properties accordingly * so that the distribution will be executed on generate - * @param {number} [recessFraction=0.0] recessFraction a fraction/percentage of the recess + * @param {number} [recessFraction=0.0] recessFraction a fraction/percentage (<1.0) of the recess * that should be left out before distributing the remaining space. - * @param {number} [gapPerChild=1] gapPerChild the gap per child, therefore inbetween children - * that shouldn't be distributed to the children + * @param {number} [gapPerChild=1] gapPerChild the gap per child, therefore the recess between children * @returns {FlexContainerComponent} */ distibuteSpacingEvenly(rightNow = true, recessFraction = 0.0, gapPerChild = 1) {