From 819d68d403137df93eda018b10553e35e1e010fd Mon Sep 17 00:00:00 2001 From: ENT8R Date: Sat, 19 May 2018 11:28:05 +0200 Subject: [PATCH 01/11] Add warning for low contrast and equal colors --- LICENSE.md | 1 + src/_locales/de/messages.json | 8 ++++ src/_locales/en/messages.json | 8 ++++ src/common/common.css | 8 ++++ src/common/common.js | 4 +- src/common/img/warning-dark.svg | 6 +++ src/common/variables.css | 6 +++ src/options.html | 4 ++ src/options.js | 78 +++++++++++++++++++++++++++++++-- 9 files changed, 118 insertions(+), 5 deletions(-) create mode 100644 src/common/img/warning-dark.svg diff --git a/LICENSE.md b/LICENSE.md index b315d508..79025ac9 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -95,6 +95,7 @@ The icons `assets/qr-icon*.svg` (used in `src/icons/icon-small-*.svg`) are made * [`common/img/info-dark.svg`](common/img/info-dark.svg) by Mozilla, license: [MPL v2.0](https://www.mozilla.org/en-US/MPL/2.0/) * [`common/img/info-light.svg`](common/img/info-light.svg) by Mozilla, license: [MPL v2.0](https://www.mozilla.org/en-US/MPL/2.0/) * [`common/img/open-in-new.svg`](common/img/open-in-new.svg) by Mozilla, license: [MPL v2.0](https://www.mozilla.org/en-US/MPL/2.0/) +* [`common/img/warning-dark.svg`](common/img/warning-dark.svg) by Mozilla, license: [MPL v2.0](https://www.mozilla.org/en-US/MPL/2.0/) The MPLv2.0 license is reproduced below: diff --git a/src/_locales/de/messages.json b/src/_locales/de/messages.json index 641bd3bf..3f0ddafc 100644 --- a/src/_locales/de/messages.json +++ b/src/_locales/de/messages.json @@ -62,6 +62,14 @@ "message": "Bist du sicher, dass du alle Optionen zurücksetzen willst?", "description": "The message shown, when the user is prompted to confirm the resetting of all options" }, + "lowContrastRatio": { + "message": "Das Kontrastverhältnis zwischen der Farbe des QR-Codes und dem Hintergrund ist wahrscheinlich zu niedrig um von QR-Code-Scannern erkannt zu werden", + "desription": "The message shown when the contrast ratio is too low" + }, + "sameColor": { + "message": "Die Farbe des QR-Codes und des Hintergrunds ist identisch. Das solltest du ändern!", + "description": "The message shown when the color for the QR code and the background are equal" + }, // tips "tipYouLikeAddon": { diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index ac907fcb..e6ed6570 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -62,6 +62,14 @@ "message": "Are you sure that you want to reset all options?", "description": "The message shown, when the user is prompted to confirm the resetting of all options" }, + "lowContrastRatio": { + "message": "The contrast ratio between the QR code color and the background might be too low to be recognized by QR code readers", + "desription": "The message shown when the contrast ratio is too low" + }, + "sameColor": { + "message": "The background and the foreground color are equal. You should change this!", + "description": "The message shown when the color for the QR code and the background are equal" + }, // tips "tipYouLikeAddon": { diff --git a/src/common/common.css b/src/common/common.css index bbf1ad5f..49610d12 100644 --- a/src/common/common.css +++ b/src/common/common.css @@ -150,6 +150,11 @@ a:active { background-color: var(--green-50); } +.warning { + color: var(--yellow-90); + background-color: var(--yellow-50); +} + /* message box action button */ .message-action-button { margin-left: 8px; @@ -188,6 +193,9 @@ a:active { .success::before { background-image: url('/common/img/check.svg'); } +.warning::before { + background-image: url('/common/img/warning-dark.svg'); +} .icon-dismiss { box-sizing: content-box; diff --git a/src/common/common.js b/src/common/common.js index b2ca10ff..44d29911 100644 --- a/src/common/common.js +++ b/src/common/common.js @@ -732,7 +732,7 @@ const MessageHandler = (function () {// eslint-disable-line no-unused-vars if (typeof args[0] === "boolean") { isDismissable = args.shift(); } - if (typeof args[0] !== undefined && args[0].text !== undefined && args[0].action !== undefined) { + if (typeof args[0] !== "undefined" && args[0].text !== "undefined" && args[0].action !== "undefined") { actionButton = args.shift(); } @@ -770,7 +770,7 @@ const MessageHandler = (function () {// eslint-disable-line no-unused-vars elActionButton.textContent = browser.i18n.getMessage(actionButton.text) || actionButton.text; elActionButton.classList.remove("invisible"); - } else { + } else if (elActionButton) { elActionButton.classList.add("invisible"); } diff --git a/src/common/img/warning-dark.svg b/src/common/img/warning-dark.svg new file mode 100644 index 00000000..e6fa6e5c --- /dev/null +++ b/src/common/img/warning-dark.svg @@ -0,0 +1,6 @@ + + + + diff --git a/src/common/variables.css b/src/common/variables.css index a2545cd3..b64675a3 100644 --- a/src/common/variables.css +++ b/src/common/variables.css @@ -19,6 +19,12 @@ --green-80: #006504; --green-90: #003706; + --yellow-50: #ffe900; + --yellow-60: #d7b600; + --yellow-70: #a47f00; + --yellow-80: #715100; + --yellow-90: #3e2800; + --red-60: #d70022; --grey-20: #ededf0; diff --git a/src/options.html b/src/options.html index 89200389..4b73fd47 100644 --- a/src/options.html +++ b/src/options.html @@ -35,6 +35,10 @@ An error happened. +