Browse Source

REFA: extended usage of _hex variable

master
chris 4 days ago
parent
commit
a30941888f
  1. 7
      src/color.js
  2. 14
      src/modifier.js

7
src/color.js

@ -12,7 +12,7 @@ class Color {
#red; #red;
#green; #green;
#blue; #blue;
#hex; _hex;
/** /**
* *
@ -40,7 +40,10 @@ class Color {
* @returns * @returns
*/ */
hex(hexcode) { hex(hexcode) {
this.#hex = hexcode; if (!hexcode.startsWith('#')) {
hexcode = '#' + hexcode;
}
this._hex = hexcode;
return this; return this;
} }
} }

14
src/modifier.js

@ -174,11 +174,15 @@ class Modifier {
* @returns {Modifier} this modifier object * @returns {Modifier} this modifier object
*/ */
background(color) { background(color) {
this._modifications["background-color"] = ( if (color) {
color if (color._hex) {
? color.cssRGBString() this._modifications["background-color"] = color._hex;
: "inherit" } else {
); this._modifications["background-color"] = color.cssRGBString();
}
} else {
this._modifications["background-color"] = "inherit";
}
return this; return this;
} }

Loading…
Cancel
Save