Convert Figma logo to code with AI

lipka logopiecon

A tiny javascript library for generating progress pie charts in your favicon.

2,317
124
2,317
8

Top Related Projects

5,109

A small library for manipulating the favicon, in particular adding alert bubbles and changing images.

Make use of your favicon with badges, images or videos

Quick Overview

Piecon is a tiny JavaScript library that dynamically generates progress pie charts as favicons. It allows developers to display real-time progress or status information directly in the browser tab, providing a subtle yet effective way to communicate updates to users without requiring them to focus on the page content.

Pros

  • Lightweight and easy to integrate into existing projects
  • Provides a non-intrusive way to display progress information
  • Customizable appearance, including colors and size
  • Works across modern browsers

Cons

  • Limited to circular progress indicators only
  • May not be visible on mobile devices or small screens
  • Requires JavaScript to be enabled in the browser
  • Potential for favicon caching issues in some browsers

Code Examples

  1. Basic usage:
Piecon.setProgress(50);

This sets the favicon to display a 50% progress pie chart.

  1. Customizing colors:
Piecon.setOptions({
  color: '#ff0000',
  background: '#ffffff'
});

This changes the progress color to red and the background to white.

  1. Resetting the favicon:
Piecon.reset();

This resets the favicon to its original state.

Getting Started

  1. Include the Piecon library in your HTML:
<script src="https://cdn.jsdelivr.net/npm/piecon@0.5.0/piecon.min.js"></script>
  1. Initialize Piecon with your desired options:
Piecon.setOptions({
  color: '#ff6700',
  background: '#bbb',
  shadow: '#fff',
  fallback: false
});
  1. Update the progress as needed in your application:
function updateProgress(percent) {
  Piecon.setProgress(percent);
}

Now you can call updateProgress(50) to set the favicon to 50% progress, for example.

Competitor Comparisons

5,109

A small library for manipulating the favicon, in particular adding alert bubbles and changing images.

Pros of Tinycon

  • Smaller file size (2.5KB vs 5.5KB for Piecon)
  • Supports more browsers, including older versions of IE
  • Allows custom positioning of the favicon badge

Cons of Tinycon

  • Less customizable appearance for the favicon badge
  • Doesn't support animated favicons like Piecon does
  • Lacks built-in retina display support

Code Comparison

Tinycon:

Tinycon.setBubble(6);

Piecon:

Piecon.setOptions({
  color: '#ff0000',
  background: '#fff',
  fallback: true
});
Piecon.setProgress(60);

Both libraries aim to add dynamic favicon functionality to web applications, but they differ in their approach and feature set. Tinycon focuses on simplicity and broad browser support, while Piecon offers more customization options and animated favicon capabilities. Tinycon's API is more straightforward, requiring just one line of code to set a badge, whereas Piecon allows for more detailed configuration of the favicon's appearance and behavior.

Make use of your favicon with badges, images or videos

Pros of favico.js

  • More feature-rich, offering animations, badges, and video support
  • Supports a wider range of browsers, including older versions
  • Provides more customization options for favicon appearance

Cons of favico.js

  • Larger file size, which may impact page load times
  • More complex API, potentially requiring a steeper learning curve
  • May be considered overkill for simple use cases

Code Comparison

favico.js:

var favicon = new Favico({
    animation : 'slide',
    bgColor : '#d00',
    textColor : '#fff'
});
favicon.badge(5);

piecon:

Piecon.setOptions({
    color: '#ff0000',
    background: '#bbb',
    shadow: '#fff',
    fallback: 'force'
});
Piecon.setProgress(50);

Both libraries allow for customization of favicon appearance, but favico.js offers more advanced features like animations and badges, while piecon focuses primarily on pie chart-style progress indicators. favico.js has a more extensive API, which can be beneficial for complex use cases but may be unnecessary for simpler implementations. piecon, on the other hand, provides a straightforward approach to adding progress indicators to favicons with a smaller footprint and easier integration.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Piecon

Pie charts in your favicon! A tiny javascript library for dynamically generating progress pie charts in your favicons.

Now with retina support!

See the live demo here.

Documentation

Basic usage

Piecon.setProgress(12);
Piecon.setProgress(25);
...
Piecon.reset();

Options

Piecon.setOptions({
  color: '#ff0084', // Pie chart color
  background: '#bbb', // Empty pie chart color
  shadow: '#fff', // Outer ring color
  fallback: false // Toggles displaying percentage in the title bar (possible values - true, false, 'force')
});

Browser Support

Piecon has been tested to work completely in the following browsers (older versions may be supported, but haven't been tested):

  • Chrome 15+
  • Firefox 9+
  • Opera 11+

Currently the library falls back to title updates for the following browsers:

  • Internet Explorer 9
  • Safari 5+

Piecon is retina compatible so you can enjoy pixel-perfect crisp graphics.

License

Licensed under the MIT license.

Credits

Piecon was inspired by Tom's Tinycon.

NPM DownloadsLast 30 Days