From 81d4fe7b7fc977e08f00ba61aff6e760a65f2550 Mon Sep 17 00:00:00 2001 From: Daniel Kluge Date: Wed, 22 Jun 2022 22:07:46 +0200 Subject: [PATCH] Colors are only saved when contrast high enough --- lib/commands/definitions.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/commands/definitions.ts b/lib/commands/definitions.ts index 073c3c0..d3436d0 100644 --- a/lib/commands/definitions.ts +++ b/lib/commands/definitions.ts @@ -293,13 +293,16 @@ const save: Command = { const currentColors = getColors(); const color = new Color(currentColors[0]); - if(color.contrast(new Color("#000")) === 1 || color.alpha() < 0.1) result.push("Skipping saving the color because it's too dark."); - else window.localStorage.setItem("color", currentColors[0]); + if(color.contrast(new Color("#000")) < 1.1 || color.alpha() < 0.1) result.push("Skipping saving the color because it's too dark."); + else { + window.localStorage.setItem("color", currentColors[0]); + result.push("Color saved to local storage."); + } const history = cmdIf.callbacks?.getCmdHistory ? cmdIf.callbacks.getCmdHistory() : []; window.localStorage.setItem("history", JSON.stringify(history)); - result.push("Colors and history saved to storage."); + result.push("History saved to storage."); return result; } else { return printSyntax(save);