Bug 1335451 - Tweak thumbnail placeholder colors and make placeholder letters uppercase. r?gijs
MozReview-Commit-ID: 1s2MMPNBA5S
--- 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");