Browse Source

REFA: extended usage of _hex variable

master
chris 3 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;
#green;
#blue;
#hex;
_hex;
/**
*
@ -40,7 +40,10 @@ class Color {
* @returns
*/
hex(hexcode) {
this.#hex = hexcode;
if (!hexcode.startsWith('#')) {
hexcode = '#' + hexcode;
}
this._hex = hexcode;
return this;
}
}

14
src/modifier.js

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

Loading…
Cancel
Save