Invert operation for dark theme

This commit is contained in:
RMidhunSuresh 2022-04-12 20:58:14 +05:30
parent bb9954a36c
commit 39bc827aaf
1 changed files with 10 additions and 1 deletions

View File

@ -16,8 +16,17 @@ limitations under the License.
const offColor = require("off-color").offColor;
module.exports.derive = function (value, operation, argument) {
module.exports.derive = function (value, operation, argument, isDark) {
const argumentAsNumber = parseInt(argument);
if (isDark) {
// For dark themes, invert the operation
if (operation === 'darker') {
operation = "lighter";
}
else if (operation === 'lighter') {
operation = "darker";
}
}
switch (operation) {
case "darker": {
const newColorString = offColor(value).darken(argumentAsNumber / 100).hex();