npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cookie-consent-tools

v0.1.6

Published

Set of tools to help implement user cookie consent

Downloads

12

Readme

Cookie Consent Tools

Software License Build Status Coveralls github

Set of tools to help implement user cookie consent. See the demo

It provides:

  • a CookieManager module to handle user consent persistence
  • an optional mobile-friendly ConsentBox displayed to the user to give him choice.

Consent Box choice

Installation

npm install cookie-consent-tools
yarn add cookie-consent-tools

Usage

// Import as a Module
import cookieConsentTools from 'cookie-consent-tools';

// Or get it through the window object
var cookieConsentTools = window.cookieConsentTool.default;

// Initialization will look for an existing consent in the cookies
cookieConsentTools.initialize(options);

Options

var options = {
  cookieName: 'cct_choice',
  cookieAttributes: {
    path: '/',
    expires: 365,
    secure: false,
    sameSite: 'strict',
  },
  onConsentLoaded: undefined,
  onConsentUpdated: undefined,
  consentBox: {
    autoDisplay: true,
    container: 'container',
    type: 'message', // or 'choice'
    messages: {
        message: 'This website uses cookies to provide you the best user experience.',
        seeMoreLabel: 'See more...',
        okButton: 'Got it',
        approveButton: 'Allow Cookies',
        declineButton: 'Decline',
    },
    seeMoreLink: {
        href: null,
        target: '_self',
    },
    onOkButtonClick: undefined,
    onApproveButtonClick: undefined,
    onDeclineButtonClick: undefined,
    onShow: undefined,
    onHide: undefined,
  }
});

See the options documentation to have more details about how to use them.

API

Cookie consent tools can be manually managed using methods. See Cookie Manager documentation or Consent Box documentation to have more details.

Executing the Demo App

This library comes with a full demo.

Install local-web-server if you do not have it yet:

npm install -g local-web-server

Then, the demo can be started with:

npm run demo:start

And available at http://127.0.0.1:8000/docs/demo/

Roadmap

This project has to stay light, but some enhancements might be worse the case:

  • Theming support for the Consent Box
  • Splitting the consent into smaller parts to give the user and the developper more flexibility (ad cookies consent, stats cookies consent, etc.)

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

Project status

This project is a side project I created to handle user cookie consent on multiple websites I own. After looking to the existing projects on GitHub, I did not find one which was light, easy to use and detached from companies who where making GDPR compliance their business.

It is honestly the first open-source project I started on my own, and it was the opportunity for me to discover and implement all tools and processes which guarantee quality and support on this kind of project.

Feel free to contribute and share ideas!