1.0.28 • Published 4 years ago

react-favicon-notification v1.0.28

Weekly downloads
-
License
ISC
Repository
github
Last release
4 years ago

react-favicon-notification

React context to show notification on favicon

Demo

Installation

  npm i react-favicon-notification

Usage

Importing context provider

import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App";
import FaviconNotificationContextProvider from "react-favicon-notification";

const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(
  <React.StrictMode>
    <FaviconNotificationContextProvider>
      <App />
    </FaviconNotificationContextProvider>
  </React.StrictMode>
);

// Wrap your application in the providers

Use the custom hook to change the favicon notification config

import { useFaviconNotification } from "react-favicon-notification";

const [config, setConfig] = useFaviconNotification();

function showNotificationIcon() {
  setConfig({ ...config, show: true }); // set 'show' to true in order to see the notifications
}

function incrementNotification() {
  setConfig({ ...config, counter: config.counter + 1 });
}

config properties

propertydefaulttypedescription
counter0number/stringcounter number
innerCirclefalsebooleanhide counter and show a small inner circle
backgroundColor#DB0101stringset the background color
fontColor#FFFstringset the font color
fontFamilyArialstringset the font family
fontWeightboldstringset the font weigth
urlwindow.location.origin/favicon.icostringset the url to get the favicon
positionbottom-rightstringset the position of the notification
showfalsebooleanshow the notificaion circle

Warning: Do not forget to set the show property to true in order to show the notification

1.0.28

4 years ago

1.0.27

4 years ago

1.0.26

4 years ago

1.0.25

4 years ago

1.0.24

4 years ago

1.0.22

4 years ago

1.0.21

4 years ago

1.0.20

4 years ago

1.0.19

4 years ago

1.0.17

4 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago