commit 8f885c75572a9e7057c26ff049cfb4f0cc9f8338 Author: David Fifield david@bamsoftware.com Date: Mon Jul 22 22:54:01 2019 -0600
Set an "error" class instead of hardcoding a text color. --- proxy/init-badge.js | 2 +- proxy/static/embed.css | 7 ++++++- proxy/static/popup.js | 13 +++++++++++-- proxy/webext/embed.js | 2 +- 4 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/proxy/init-badge.js b/proxy/init-badge.js index 4a331c3..443e879 100644 --- a/proxy/init-badge.js +++ b/proxy/init-badge.js @@ -16,7 +16,7 @@ class BadgeUI extends UI { missingFeature(missing) { this.popup.setImgSrc('off'); this.popup.setStatusText("Snowflake is off"); - this.popup.setStatusDesc(missing, 'firebrick'); + this.popup.setStatusDesc(missing, true); this.popup.hideButton(); }
diff --git a/proxy/static/embed.css b/proxy/static/embed.css index 990f7ec..3eac1a7 100644 --- a/proxy/static/embed.css +++ b/proxy/static/embed.css @@ -1,4 +1,5 @@ body { + color: black; margin: 10px; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; width: 300px; @@ -17,11 +18,15 @@ body { }
.b a { - color: black; + color: inherit; display: inline-block; text-decoration: none; }
+.error { + color: firebrick; +} + .learn:before { content : " "; display: block; diff --git a/proxy/static/popup.js b/proxy/static/popup.js index 7060054..994debd 100644 --- a/proxy/static/popup.js +++ b/proxy/static/popup.js @@ -1,5 +1,14 @@ /* exported Popup */
+// Add or remove a class from elem.classList, depending on cond. +function setClass(elem, className, cond) { + if (cond) { + elem.classList.add(className); + } else { + elem.classList.remove(className); + } +} + class Popup { constructor() { this.div = document.getElementById('active'); @@ -13,9 +22,9 @@ class Popup { setStatusText(txt) { this.statustext.innerText = txt; } - setStatusDesc(desc, color) { + setStatusDesc(desc, error) { this.statusdesc.innerText = desc; - this.statusdesc.style.color = color || 'black'; + setClass(this.statusdesc, 'error', error); } hideButton() { document.querySelector('.button').style.display = 'none'; diff --git a/proxy/webext/embed.js b/proxy/webext/embed.js index e1364bf..6571843 100644 --- a/proxy/webext/embed.js +++ b/proxy/webext/embed.js @@ -11,7 +11,7 @@ port.onMessage.addListener((m) => { if (missingFeature) { popup.setImgSrc('off'); popup.setStatusText("Snowflake is off"); - popup.setStatusDesc("WebRTC feature is not detected.", 'firebrick'); + popup.setStatusDesc("WebRTC feature is not detected.", true); popup.hideButton(); return; }