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

bite-consent

v0.0.9

Published

BitConsent is a lightweight React library for managing cookie consent in web applications. Easily integrate a customizable cookie banner with options to view the privacy policy or accept cookies with a single click.

Downloads

8

Readme

Bite Consent

Bite Consent is a lightweight React library for managing cookie consent views with customizable descriptions and actions. It provides an easy way to implement cookie consent functionality in your React applications while ensuring compliance with privacy regulations.

Screenshot 2024-04-27 at 18 43 55

Features

  • Simple integration with React applications
  • Customizable cookie consent banner with description and actions
  • Built-in actions for "Got it" and opening the privacy policy
  • Lightweight and easy to use

Installation

You can install Bite Consent via npm or yarn:

npm install bite-consent

or

yarn add bite-consent

Usage

To use Bite Consent in your React application, you can now also use the useBiteConsent hook:

import React from 'react'
import { useBiteConsent } from 'bite-consent'

function App() {
  const { consentCookie, show, revoke } = useBiteConsent({
    privacyPolicyUrl: 'https://example.com/privacy',
    theme: {
      mode: 'auto'
    }
  })

  return (
    <div className="App">
      <header className="App-header">
        <h1>Welcome to My Website</h1>
      </header>
      <main>{/* Your component content */}</main>
      {consentCookie ? null : <button onClick={show}>Show Consent Banner</button>}
    </div>
  )
}

export default App

BiteConsentOptions

| Name | Type | Default | Description | | ------------------ | ------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | privacyPolicyUrl | string | undefined | The URL to your privacy policy. Required. | | text | string | Hey there! We use cookies to keep things running smoothly on our website and to get to know you better. It helps us make your time here as awesome as possible! ❤️ | Custom text to display in the consent banner. | | visibility | auto | visible | hidden | auto | Specifies the visibility of the consent banner. auto displays the view based on the availability of the consent cookie, whereas visible displays and hidden hides it. | | position | Position | CustomPosition | bottom-left | Sets the position of the consent view on the page. See below for details. | | cookieConfig | CookieConfig | - | Configuration options for consent cookies. See below for details. | | theme | Theme | - | Theme object containing color configurations for the consent view. See below for details. | | onAccept | function | () => void | A function to be called when the user accepts the cookie policy. |

Position

| Type | Description | | -------------- | ------------------------------------------------- | | top-left | Positions the element at the top left corner. | | top-right | Positions the element at the top right corner. | | bottom-left | Positions the element at the bottom left corner. | | bottom-right | Positions the element at the bottom right corner. |

CustomPosition

| Property | Type | Description | | -------- | -------------------- | ---------------------------------------------------------------------------- | | top | number | string | The distance from the top of the container. Accepts number or CSS string. | | left | number | string | The distance from the left of the container. Accepts number or CSS string. | | right | number | string | The distance from the right of the container. Accepts number or CSS string. | | bottom | number | string | The distance from the bottom of the container. Accepts number or CSS string. |

CookieConfig

| Property | Type | Description | | ---------- | --------------------------- | -------------------------------------------------------------------- | | name | string | The name or identifier of the consent cookie. | | maxAge | number | The maximum age of the consent cookie in seconds. | | expires | Date | The expiration date of the consent cookie. | | path | string | The path within the website's domain for which the cookie is valid. | | domain | string | The domain for which the cookie is valid. | | secure | boolean | Indicates if the cookie should only be sent over secure connections. | | sameSite | Strict | Lax | None | The SameSite attribute of the consent cookie. |

Theme

The theme object allows customization of the colors used in the consent banner.

| Property | Type | Description | | -------- | ----------- | ------------------------------------ | | mode | ThemeMode | The theme mode. | | light | ColorSet | Color configurations for light mode. | | dark | ColorSet | Color configurations for dark mode. |

ColorSet Properties:

  • background: Background color of the consent banner.
  • text: Text color of the consent banner.
  • shadow: Box shadow of the consent banner.
  • primaryActionBackground: Background color of primary action buttons.
  • primaryActionHoverBackground: Background color of primary action buttons on hover.
  • primaryActionText: Text color of primary action buttons.
  • secondaryActionBackground: Background color of secondary action buttons.
  • secondaryActionText: Text color of secondary action buttons.
  • secondaryActionHoverBackground: Background color of secondary action buttons on hover.

License

Bite Consent is released under the MIT License.