Colors are only saved when contrast high enough

This commit is contained in:
Daniel Kluge 2022-06-22 22:07:46 +02:00
parent eb0031bf87
commit 81d4fe7b7f

View File

@ -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);