From 39bc827aaf095145aa973289e2f79a6355f1b168 Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Tue, 12 Apr 2022 20:58:14 +0530 Subject: [PATCH] Invert operation for dark theme --- scripts/postcss/color.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/postcss/color.js b/scripts/postcss/color.js index f61dac1e..b1ef7073 100644 --- a/scripts/postcss/color.js +++ b/scripts/postcss/color.js @@ -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();