2.0.0 • Published 5 years ago

favicon-badge v2.0.0

Weekly downloads
32
License
MIT
Repository
github
Last release
5 years ago

Badgable FavIcon

This project makes it possible to badge the favicon of the current page. You can play with a demo here.

Usage

Include the "FavIconBadge.js" file in your project.

Run

npm install favicon-badge

and then, if using WebPack:

import "FavIconBadge";

or if using VanillaJS

<script type="text/javascript" src="path/to/FavIconBadge.js"></script>

To use, simply add a <favicon-badge/> tag to the <head> of your document.

<!-- Badges the favicon for the current page with a '1' -->
<favicon-badge src="/favicon.png" badge="1" />

API

The API provides methods for controlling and customizing the badge.

AttributeTypeDescription
srcstringThe url of the favicon to display. This must be set in order for a favicon to be displayed.
badgestring |int |booleanThe badge to display. See badge values for more detail.
badgeColorstringA string representing the color of the badge. Defaults to #FF0000. Not used if `badgeBackgroundSrc is set.
textColorstringA string represnting the color of the text on the badge. Defaults to #000000.
badgeBackgroundSrcstringUrl for an image to display as the badge background. Used instead of badgeColor.
badgeSizenumberThe size of the badge. Should be between 0 and 16. Defaults to 10.

Badge Values

An attempt has been made to provide sensible defaults for different badge values.

Badge ValueShows BadgeShows Text
""YN
trueYN
falseNN
0NN
[1-9]YY
"\w+"YY
2.0.0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago