Code Monkey home page Code Monkey logo

hat's Introduction

HAT

A light set of helpers for updating title and favicons dynamically.

Examples

See examples here

Installation

npm i @space-kit/hat

Helpers

Add a count in title

import { setTitleCount } from '@space-kit/hat';

setTitleCount(10) // updates title as `(10) your title text`  

Add a counter to title

import { titleCounter } from '@space-kit/hat';

const increment = titleCounter(0, 'Hello');

increment() // updates title as `(1) your title text`  

Add a rolling title

import { rollingTitle } from '@space-kit/hat';

rollingTitle('A very long text') // start a rolling title 

Update favicon with an svg

Updates favicon with an svg.

import { svgFavicon } from '@space-kit/hat';

const svgLogo = '<svg>yoursvg</svg>`;

svgFavicon(svgLogo); // set svg icon as favicon

Update favicon with an svg

Replaces {{count}} in an svg with a dynamic counter value, Suitable for chat apps to show unread messages inside favicon.

import { svgFaviconCounter } from '@space-kit/hat';

/**
 * Replace {{count}} with counter value
*/
const svgLogo = '<svg>{{count}}</svg>';

const incrementFavicon = svgFaviconCounter(svgString);

incrementFavicon(); // increments count inside favicon

Development

Build

npm run build

Test

npm run test

Release

npm publish

hat's People

Contributors

ashikmeerankutty avatar dependabot[bot] avatar

Stargazers

Roman avatar Jeremy avatar Abhijith Vijayan avatar Alex Mathew avatar Shamin avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.