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

@binarypaw/react-cookie-consent

v0.1.10-alpha

Published

A react cookie consent library

Downloads

29

Readme

Cookie consent

In times of GDPR and other data protection regulations, managing cookies decently has become more and more important. This library should make this process a bit easier for your website. React-cookie-consent is a frontend library that allows users of your website to configure cookies. It does not prevent your website from setting cookies without consent but it does provide you with a list of cookies that the user agreed to.

Installation

Add the library to you project with the following command: npm install @binarypaw/react-cookie-consent

Usage

The library exposes one react component which must be added to the top-level of your application. Make sure to include the separate css file being delivered.

import React from "react";
import { CookieConsent } from "@binarypaw/react-cookie-consent";
import "@binarypaw/react-cookie-consent/dist/cookieConsent.css";

function App() {
	return (
		<>
			<CookieConsent />
			<div>Your content</div>
		</>
	);
}

You want a fast start? Have a look at our example. All component props are documented in the properties section

Example

import React from "react";
import { CookieConsent } from "@binarypaw/react-cookie-consent";
import "@binarypaw/react-cookie-consent/dist/cookieConsent.css";

function App() {
	const name = "BinaryPaw";
	const preamble = "We bake great cookies ;)";
	const privacyLink = "https://example.com";
	const cookies = [{
		group: "General",
		name: "APSID",
		desc: "This cookie refers to the current session we use to identify your machine.",
		consent: false,
		mandatory: true,
	}];
	const thirdParties = [{
		name: "Rainbow",
		desc: "The rainbow service uses cookies to make your website look like a rainbow",
		privacyLink: "https://example.com",
		optOutLink: "https://example.com",
	}];
	const handleSave = (cookies) => {
		console.log(cookies);
	};

	return (
	<CookieConsent
		name={name}
		preamble={preamble}
		privacyPolicyLink={privacyLink}
		cookies={cookies}
		thirdPartyProvider={thirdParties}
		onSave={handleSave}
	/>
	);
}

Properties

| Name | Description | Type | Default | | ------------------------------------------ | ---------------------------------------------------------------- | --------------------- | ------- | | name | your websites name | string | n/a | | activated? | activates/deactivates the whole cookie-consent | boolean | true | | language? | language for prewritten texts | "en" or "de" | "en" | | preamble | short description explaining what cookies are used for | string | n/a | | privacyPolicyLink | privacy policy link of your website | string | n/a | | cookiePolicyLink? | cookie policy link of your website | string | n/a | | cookies? | all the cookies your website uses | ICookie[] | [] | | thirdPartyProvider? | list of all third-party providers | IThirdPartyProvider[] | [] | | onSave? | function is being called when the user saves it's cookie choices | Function | n/a | | colors? | Changes preset colors | IThemeColors | n/a |

name

Choose any name which is then being displayed on the cookie-consent banner.

activated?

Deactivates or activates the whole cookie-consent library.

language?

Defines the language for all pre-written texts for example buttons.

preamble

The preamble describes the usage of your cookies and must make the user aware that more information can be found in the cookie or privacy policy.

privacyPolicyLink

The weblink to your privacy policy.

cookiePolicyLink?

The weblink to your cookie policy.

cookies?

An array of all cookies being used by your website.

[{
	name:  string;
	group:  string;
	consent:  boolean;
	mandatory:  boolean;
	desc:  string;
}]

thirdPartyProvider?

An array of all third-party providers which your website makes use of.

tpye URLString = `https://${string}.${string}` // normal web url

[{
	name:  string;
	desc:  string;
	privacyLink: URLString;
	optOutLink: URLString;
}]

onSave?

This function will be called every time the user saves his cookie settings. The first parameter of the function is the whole list of cookies. function onSave(cookies: Array<ICookie>) {...}

colors?

The colors prop let's you edit every color used by the theme in order to make it fit with your own custom theme.

type ColorString = `#${string}` // 6-digit hex-code

{
	text?:  ColorString;
	secondary?:  ColorString;
	bg?:  ColorString;
	accept?:  ColorString;
	decline?:  ColorString;
	accent?:  ColorString;
}

License

Cookie-Consent is licensed under EPL 2.0. Read more here: EPL 2.0.