Beispiel #1
0
function getFallbackColors(favicon_colors) {
  let backgroundColor = DEFAULT_FALLBACK_BG_COLOR;

  if (favicon_colors && favicon_colors[0]) {
    backgroundColor = favicon_colors[0].color;
  }

  return {
    backgroundColor: utils.toRGBString(backgroundColor),
    color: utils.getBlackOrWhite(...backgroundColor)
  };
}
 site => {
   const {favicon, parsedUrl, label} = selectSiteProperties(site);
   const backgroundRGB = getBackgroundRGB(site);
   const backgroundColor = site.background_color || toRGBString(...backgroundRGB, favicon ? BACKGROUND_FADE : 1);
   const fontColor = getBlackOrWhite(...backgroundRGB);
   const firstLetter = prettyUrl(parsedUrl.hostname)[0];
   return {
     url: site.url,
     favicon,
     firstLetter,
     backgroundColor,
     fontColor,
     label
   };
 }
 site => {
   const favicon = site.favicon_url || site.favicon;
   const parsedUrl = site.parsedUrl || urlParse(site.url || "") ;
   const label = prettyUrl(parsedUrl.hostname);
   const backgroundRGB = getBackgroundRGB(site);
   const backgroundColor = site.background_color || toRGBString(...backgroundRGB, favicon ? BACKGROUND_FADE : 1);
   const fontColor = getBlackOrWhite(...backgroundRGB);
   const firstLetter = prettyUrl(parsedUrl.hostname)[0];
   return {
     url: site.url,
     favicon,
     firstLetter,
     backgroundColor,
     fontColor,
     label
   };
 }
Beispiel #4
0
 it("should return white for a dark color", () => {
   assert.equal(utils.getBlackOrWhite(40, 44, 52), "white");
 });
Beispiel #5
0
 it("should return black for a light color", () => {
   assert.equal(utils.getBlackOrWhite(230, 210, 210), "black");
 });