|
@ -34,7 +34,7 @@ class Modifier { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Sets the modifications for widht and height to 100%. |
|
|
* Sets the modifications for widht and height to 100%. |
|
|
* @returns {Modifier} this modifier object |
|
|
* @returns {Modifier | ChainableModifier} this modifier object |
|
|
*/ |
|
|
*/ |
|
|
fillMaxSize(widthFraction = 1, heightFraction = 1) { |
|
|
fillMaxSize(widthFraction = 1, heightFraction = 1) { |
|
|
return this.fillMaxWidth(widthFraction) |
|
|
return this.fillMaxWidth(widthFraction) |
|
@ -44,7 +44,7 @@ class Modifier { |
|
|
/** |
|
|
/** |
|
|
* Sets the modification for width to the given fraction of 1 (default 1 := 100%). |
|
|
* Sets the modification for width to the given fraction of 1 (default 1 := 100%). |
|
|
* @param {number} fraction |
|
|
* @param {number} fraction |
|
|
* @returns {Modifier} this modifier object |
|
|
* @returns {Modifier | ChainableModifier} this modifier object |
|
|
*/ |
|
|
*/ |
|
|
fillMaxWidth(fraction = 1) { |
|
|
fillMaxWidth(fraction = 1) { |
|
|
this._modifications["width"] = (100 * fraction) + "%"; |
|
|
this._modifications["width"] = (100 * fraction) + "%"; |
|
@ -55,7 +55,7 @@ class Modifier { |
|
|
/** |
|
|
/** |
|
|
* Sets the modification for height to the given fraction of 1 (default 1 := 100%). |
|
|
* Sets the modification for height to the given fraction of 1 (default 1 := 100%). |
|
|
* @param {number} fraction |
|
|
* @param {number} fraction |
|
|
* @returns {Modifier} this modifier object |
|
|
* @returns {Modifier | ChainableModifier} this modifier object |
|
|
*/ |
|
|
*/ |
|
|
fillMaxHeight(fraction = 1) { |
|
|
fillMaxHeight(fraction = 1) { |
|
|
this._modifications["height"] = (100 * fraction) + "%"; |
|
|
this._modifications["height"] = (100 * fraction) + "%"; |
|
@ -133,7 +133,7 @@ class Modifier { |
|
|
return this; |
|
|
return this; |
|
|
} else { |
|
|
} else { |
|
|
let modSub = new DimensionsChain(this); |
|
|
let modSub = new DimensionsChain(this); |
|
|
if (modify instanceof Number && modify > 0) { |
|
|
if (Number.isInteger(modify) && modify > 0) { |
|
|
return modSub.all(modify).ensureModifier(); |
|
|
return modSub.all(modify).ensureModifier(); |
|
|
} |
|
|
} |
|
|
// case dimension is number but < 0 or dimensions == null or anything else
|
|
|
// case dimension is number but < 0 or dimensions == null or anything else
|
|
@ -146,7 +146,7 @@ class Modifier { |
|
|
* Currently the padding will always be set |
|
|
* Currently the padding will always be set |
|
|
* to the most recent padding/padding. |
|
|
* to the most recent padding/padding. |
|
|
* @param {Padding | number | undefined} modify as in modifiers |
|
|
* @param {Padding | number | undefined} modify as in modifiers |
|
|
* @returns {Modifier} this modifier object |
|
|
* @returns {Modifier | PaddingChain} this modifier object |
|
|
*/ |
|
|
*/ |
|
|
padding(modify = null) { |
|
|
padding(modify = null) { |
|
|
if (modify instanceof Sides && !(modify instanceof Padding)) { |
|
|
if (modify instanceof Sides && !(modify instanceof Padding)) { |
|
@ -177,7 +177,7 @@ class Modifier { |
|
|
* it is recommended to use padding and to stick to that as often as possible. |
|
|
* it is recommended to use padding and to stick to that as often as possible. |
|
|
* Padding values take affect inside/within the element. |
|
|
* Padding values take affect inside/within the element. |
|
|
* @param {Margin | number | undefined} modify |
|
|
* @param {Margin | number | undefined} modify |
|
|
* @returns {Modifier} this modifier object |
|
|
* @returns {Modifier | MarginChain} this modifier object |
|
|
*/ |
|
|
*/ |
|
|
margin(modify = null) { |
|
|
margin(modify = null) { |
|
|
if (modify instanceof Sides && !(modify instanceof Margin)) { |
|
|
if (modify instanceof Sides && !(modify instanceof Margin)) { |
|
@ -205,7 +205,7 @@ class Modifier { |
|
|
* If no color is given/specified the styling will be set to "inherit" |
|
|
* If no color is given/specified the styling will be set to "inherit" |
|
|
* and use the color setting from (one of) the parent. |
|
|
* and use the color setting from (one of) the parent. |
|
|
* @param {Color} color |
|
|
* @param {Color} color |
|
|
* @returns {Modifier} this modifier object |
|
|
* @returns {Modifier | ChainableModifier} this modifier object |
|
|
*/ |
|
|
*/ |
|
|
background(color) { |
|
|
background(color) { |
|
|
if (color) { |
|
|
if (color) { |
|
@ -225,7 +225,7 @@ class Modifier { |
|
|
* If no color is given/specified the styling will be set to "inherit" |
|
|
* If no color is given/specified the styling will be set to "inherit" |
|
|
* and use the color setting from (one of) the parent. |
|
|
* and use the color setting from (one of) the parent. |
|
|
* @param {Color} color |
|
|
* @param {Color} color |
|
|
* @returns {Modifier} this modifier object |
|
|
* @returns {Modifier | ChainableModifier} this modifier object |
|
|
*/ |
|
|
*/ |
|
|
color(color) { |
|
|
color(color) { |
|
|
this._modifications["color"] = ( |
|
|
this._modifications["color"] = ( |
|
@ -246,7 +246,7 @@ class Modifier { |
|
|
* @todo finish second parameter "modifications" - logic |
|
|
* @todo finish second parameter "modifications" - logic |
|
|
* |
|
|
* |
|
|
* @param modifier The "new" Modifier |
|
|
* @param modifier The "new" Modifier |
|
|
* @returns {Modifier} The "old/current" Modifier, |
|
|
* @returns {Modifier | ChainableModifier} The "old/current" Modifier, |
|
|
* extended with the modifications of the given Modifier. |
|
|
* extended with the modifications of the given Modifier. |
|
|
*/ |
|
|
*/ |
|
|
join(modifier, modifications = {}) { |
|
|
join(modifier, modifications = {}) { |
|
@ -271,7 +271,7 @@ class Modifier { |
|
|
* |
|
|
* |
|
|
* @param {string} key a css style rule |
|
|
* @param {string} key a css style rule |
|
|
* @param {string} value the corresponding value to the css style rule |
|
|
* @param {string} value the corresponding value to the css style rule |
|
|
* @returns {Modifier} this modifier object |
|
|
* @returns {Modifier | ChainableModifier} this modifier object |
|
|
*/ |
|
|
*/ |
|
|
setStyleRule(key, value) { |
|
|
setStyleRule(key, value) { |
|
|
this._modifications[key] = value; |
|
|
this._modifications[key] = value; |
|
@ -281,7 +281,7 @@ class Modifier { |
|
|
/** |
|
|
/** |
|
|
* |
|
|
* |
|
|
* @param {StylePropertyMap} rulemap |
|
|
* @param {StylePropertyMap} rulemap |
|
|
* @returns {Modifier} |
|
|
* @returns {Modifier | ChainableModifier} |
|
|
*/ |
|
|
*/ |
|
|
addStyleRuleMap(rulemap) { |
|
|
addStyleRuleMap(rulemap) { |
|
|
for (const ruleKey of Object.keys(rulemap)) { |
|
|
for (const ruleKey of Object.keys(rulemap)) { |
|
@ -293,7 +293,7 @@ class Modifier { |
|
|
/** |
|
|
/** |
|
|
* |
|
|
* |
|
|
* @param {string} key |
|
|
* @param {string} key |
|
|
* @returns {Modifier} this modifier object |
|
|
* @returns {Modifier | ChainableModifier} this modifier object |
|
|
*/ |
|
|
*/ |
|
|
removeStyleRule(key) { |
|
|
removeStyleRule(key) { |
|
|
this._removeMods.push(key); |
|
|
this._removeMods.push(key); |
|
@ -341,7 +341,7 @@ class Modifier { |
|
|
return this; |
|
|
return this; |
|
|
} else { |
|
|
} else { |
|
|
let modSub = new BorderChain(this); |
|
|
let modSub = new BorderChain(this); |
|
|
if (modify instanceof Number && modify > 0) { |
|
|
if (Number.isInteger(modify) && modify > 0) { |
|
|
return modSub.width(modify).ensureModifier(); |
|
|
return modSub.width(modify).ensureModifier(); |
|
|
} |
|
|
} |
|
|
return modSub; |
|
|
return modSub; |
|
@ -373,7 +373,7 @@ class Modifier { |
|
|
return this; |
|
|
return this; |
|
|
} else { |
|
|
} else { |
|
|
let modSub = new ShapeChain(this); |
|
|
let modSub = new ShapeChain(this); |
|
|
if (modify instanceof Number && modify > 0) { |
|
|
if (Number.isInteger(modify) && modify > 0) { |
|
|
return modSub.all(modify).ensureModifier(); |
|
|
return modSub.all(modify).ensureModifier(); |
|
|
} |
|
|
} |
|
|
return modSub; |
|
|
return modSub; |
|
@ -487,7 +487,7 @@ class ChainableModifier extends Modifier { |
|
|
* @returns {ChainableModifier | DimensionsChainedModifier} |
|
|
* @returns {ChainableModifier | DimensionsChainedModifier} |
|
|
*/ |
|
|
*/ |
|
|
dimensions(modify = null) { |
|
|
dimensions(modify = null) { |
|
|
if (modify instanceof Dimensions || modify instanceof Number) { |
|
|
if (modify instanceof Dimensions || Number.isInteger(modify)) { |
|
|
return super.dimensions(modify); |
|
|
return super.dimensions(modify); |
|
|
} |
|
|
} |
|
|
return new DimensionsChainedModifier(this); |
|
|
return new DimensionsChainedModifier(this); |
|
@ -523,12 +523,12 @@ class ChainableModifier extends Modifier { |
|
|
* @inheritdoc |
|
|
* @inheritdoc |
|
|
* |
|
|
* |
|
|
* @override |
|
|
* @override |
|
|
* @param {Shape | number | undefined} [Shape=null] shape |
|
|
* @param {Shape | number | undefined} [modify=null] modify |
|
|
* @returns {ChainableModifier | ShapeChainedModifier} |
|
|
* @returns {ChainableModifier | ShapeChainedModifier} |
|
|
*/ |
|
|
*/ |
|
|
clip(shape = null) { |
|
|
clip(modify = null) { |
|
|
if (shape instanceof Shape || shhaape instanceof Number) { |
|
|
if (modify instanceof Shape || Number.isInteger(modify)) { |
|
|
return super.clip(shape); |
|
|
return super.clip(modify); |
|
|
} |
|
|
} |
|
|
return new ShapeChainedModifier(this); |
|
|
return new ShapeChainedModifier(this); |
|
|
} |
|
|
} |
|
@ -539,12 +539,12 @@ class ChainableModifier extends Modifier { |
|
|
* @inheritdoc |
|
|
* @inheritdoc |
|
|
* |
|
|
* |
|
|
* @override |
|
|
* @override |
|
|
* @param {Border | number | undefined} [border=null] border |
|
|
* @param {Border | number | undefined} [modify=null] modify |
|
|
* @returns {ChainableModifier | BorderChainedModifier} |
|
|
* @returns {ChainableModifier | BorderChainedModifier} |
|
|
*/ |
|
|
*/ |
|
|
border(border = null) { |
|
|
border(modify = null) { |
|
|
if (border instanceof Border || border instanceof Number) { |
|
|
if (modify instanceof Border || Number.isInteger(modify)) { |
|
|
return super.border(border); |
|
|
return super.border(modify); |
|
|
} |
|
|
} |
|
|
return new BorderChainedModifier(this); |
|
|
return new BorderChainedModifier(this); |
|
|
} |
|
|
} |
|
|