Bug 1335451 - Tweak thumbnail placeholder colors and make placeholder letters uppercase. r=Gijs, a=lizzard
authorDão Gottwald <dao@mozilla.com>
Wed, 01 Feb 2017 19:35:31 +0100
changeset 480351 0d9d7517318f1ddf27dbadff64fa083de6da67bd
parent 480350 72b706bd282d698bc759e6ff675a16305fe399d3
child 480352 51523138a95eff972a01953746d86341ed1f402a
push id44524
push usermartin.thomson@gmail.com
push dateWed, 08 Feb 2017 05:10:11 +0000
reviewersGijs, lizzard
bugs1335451
milestone52.0
Bug 1335451 - Tweak thumbnail placeholder colors and make placeholder letters uppercase. r=Gijs, a=lizzard MozReview-Commit-ID: 1s2MMPNBA5S
browser/base/content/newtab/sites.js
--- a/browser/base/content/newtab/sites.js
+++ b/browser/base/content/newtab/sites.js
@@ -253,23 +253,24 @@ Site.prototype = {
     }
     let uri = link.imageURI || PageThumbs.getThumbnailURL(this.url);
     thumbnail.style.backgroundImage = 'url("' + uri + '")';
 
     if (THUMBNAIL_PLACEHOLDER_ENABLED &&
         link.type == "history" &&
         link.baseDomain) {
       let placeholder = this._querySelector(".newtab-thumbnail.placeholder");
-      let hue = 0;
+      let charCodeSum = 0;
       for (let c of link.baseDomain) {
-        hue += c.charCodeAt(0);
+        charCodeSum += c.charCodeAt(0);
       }
-      hue %= 256;
-      placeholder.style.backgroundColor = "hsl(" + hue + ",50%,60%)";
-      placeholder.textContent = link.baseDomain.substr(0,1);
+      const COLORS = 16;
+      let hue = Math.round((charCodeSum % COLORS) / COLORS * 360);
+      placeholder.style.backgroundColor = "hsl(" + hue + ",80%,40%)";
+      placeholder.textContent = link.baseDomain.substr(0,1).toUpperCase();
     }
 
     if (link.enhancedImageURI) {
       let enhanced = this._querySelector(".enhanced-content");
       enhanced.style.backgroundImage = 'url("' + link.enhancedImageURI + '")';
 
       if (this.link.type != link.type) {
         this.node.setAttribute("type", "enhanced");