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

@havlasme/react-cookie-consent

v2.0.0

Published

react cookie consent

Downloads

7

Readme

react-cookie-consent

npm version npm download Apache-2.0 license semantic release language grade

React Cookie Consent.

Demo

a minimal demo is in the example directory:

npm run serve:example

Installation

npm install --save @havlasme/react-cookie-consent

or use yarn:

yarn add @havlasme/react-cookie-consent

Usage

import cookie consent component:

import { CookieConsent } from '@havlasme/react-cookie-consent'

optionally import cookie consent stylesheet:

import '@havlasme/react-cookie-consent/dist/react-cookie-consent.min.css'

sample:

<CookieConsent version={20220201} onSubmit={handleSubmit}>
    <h4 className="cc-title">
        Cookie Consent
    </h4>

    <div className="cc-description">
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur maximus, eros in rhoncus volutpat, metus diam malesuada velit, quis suscipit
        lacus ligula eget arcu. Duis tempor leo eget leo tristique hendrerit. Proin luctus lobortis libero, et lacinia libero suscipit et. Phasellus
        venenatis metus ut velit maximus, eget lacinia arcu ultrices.
    </div>

    <div className="cc-privacy-policy">
        Read more in
        <a href="#">privacy policy</a>
    </div>

    <CookieConsent.Category checked={true} disabled={true} name="technical" title="Technical">
        <div className="cc-category-description">
            Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris congue commodo purus, nec semper orci hendrerit eget. Nam in purus eget
            neque feugiat consequat id eget odio.
        </div>

        <CookieConsent.Cookie name="cc:consent" expiration="Persistent" type="HTML">
            Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut pellentesque placerat massa, eu molestie diam aliquam vitae.
        </CookieConsent.Cookie>
    </CookieConsent.Category>

    <CookieConsent.Category name="analytical" title="Analytical">
        <div className="cc-category-description">
            Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent mollis rutrum hendrerit. Quisque quis dui id lorem elementum consectetur
            a ut orci. Suspendisse aliquet sit amet justo nec viverra. Suspendisse potenti.
        </div>

        <CookieConsent.Cookie name="analytical1" expiration="1 year" type="HTTP">
            Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nunc arcu, tincidunt ac ligula in, tempor consectetur arcu. Mauris nec
            magna finibus, efficitur nunc id, pretium nunc.
        </CookieConsent.Cookie>

        <CookieConsent.Cookie name="analytical2" expiration="1 minute" type="HTTP">
            Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse ultricies luctus aliquet. Duis nec urna sit amet eros pharetra auctor
            et sit amet leo. Sed interdum blandit lorem. Maecenas facilisis ut ante et scelerisque.
        </CookieConsent.Cookie>
    </CookieConsent.Category>

    <CookieConsent.Category name="marketing" title="Marketing">
        <div className="cc-category-description">
            Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris lacinia ultrices pellentesque. Proin sodales ac tellus in volutpat.
            Curabitur semper tempor dolor vitae posuere. Pellentesque ultrices orci vel scelerisque molestie. Curabitur eget arcu et dolor maximus
            lacinia. Aenean nec turpis ut lectus gravida semper at varius mauris. Sed eget eleifend purus.
        </div>

        <CookieConsent.Cookie name="marketing1" expiration="3 month" type="HTTP">
            Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec augue neque, lobortis eu leo ac, mattis ullamcorper odio. Fusce elementum
            leo nibh, eu tristique augue vestibulum sed.
        </CookieConsent.Cookie>
    </CookieConsent.Category>
</CookieConsent>

Component

CookieConsent

The cookie consent main component, used to position cookie consent on the screen.

| prop name | description | default value | example value | |------------|--------------------------------------------|---------------------|---------------------------------| | className | the class name | N/A | "class1 class2" | | expiration | the cookie consent expiration (in seconds) | 31536000 (1 year) | 2592000 | | open | is the cookie consent expanded? | false | true | | persist | the cookie consent persistence key | "cc:consent" | "cookie-consent" | | version | the cookie consent version | N/A | 20220201 | | onSubmit | the submit event callback | N/A | (value) => console.log(event) |

CookieConsent.Category

The cookie consent category component, used to describe cookie category.

| prop name | description | default value | example value | |------------|--------------------------------------------------------|---------------|---------------------------------| | checked | is the cookie category control checked? | false | true | | className | the class name | N/A | "class1 class2" | | disabled | is the cookie category control disabled? | false | true | | name | the cookie category name, used as identity in response | N/A | "analytical" | | title | the cookie category title | N/A | "Analytical" | | onChange | the change event callback | N/A | (event) => console.log(event) |

CookieConsent.Cookie

The cookie consent cookie component, used to describe cookie inside category.

| prop name | description | default value | example value | |------------|------------------------|---------------|-------------------| | className | the class name | N/A | "class1 class2" | | expiration | the cookie expiration | N/A | "1 month" | | name | the cookie name | N/A | "cc:consent" | | type | the cookie type | N/A | "HTTP" |

CookieConsent.Portal

The cookie consent portal component, used to displace the cookie consent DOM node outside the parent component DOM hierarchy.

Styling

the cookie consent component can be styled using css:

| variable | description | default value | |-----------------------------------------|-------------------------------------------|-----------------------------| | --cc-theme-background | the cookie consent component background | #FFFFFF | | --cc-theme-color | the cookie consent component text color | #000000 | | --cc-theme-portal-background | the portal component background | rgba(255, 255, 255, 0.25) | | --cc-theme-checkbox-active-background | the checkbox background in active state | #0D6EFD | | --cc-theme-checkbox-inactive-background | the checkbox background in inactive state | #DDDDDD | | --cc-theme-checkbox-control | the checkbox control color | #FFFFFF | | --cc-theme-partition | the category / cookie partition color | #DDDDDD |