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

maya-cookie-notice-vue

v3.0.3

Published

Vue component for accepting and rejecting cookies

Downloads

4

Readme

Vue Cookie Notice

A simple vue component to accept/reject cookies.

Note

V3.0.0 introduces TypeScript and Vue3 support. If you need Vue 2 support, use v2.x.x.

Installation

yarn add maya-cookie-notice-vue

or

npm install --save maya-cookie-notice-vue

Usage

You'll want to extend `maya-cookie-notice-vue' and override whichever handle methods you need.

The example below grants consent for analytics storage when statistic cookies are enabled.

<script lang="ts">
import CookieNotice from 'maya-cookie-notice-vue';

export default {
  extends: CookieNotice,

  methods: {
    handleAcceptedStatistic() {
      if (typeof gtag !== 'undefined' && gtag) {
        gtag('consent', 'update', {
          analytics_storage: 'granted',
          wait_for_update: 500,
          region: ['GB'],
        });
      }
    },
    handleRejectedStatistic() {
      if (typeof gtag !== 'undefined' && gtag) {
        gtag('consent', 'update', {
          analytics_storage: 'denied',
          wait_for_update: 0,
          region: ['GB'],
        });
      }
    },

    handleAcceptedPreference() {
      // Preference cookies were accepted
    },

    handleRejectedPreference () {
      // Preference cookies were rejected
    },

    handleAcceptedMarketing() {
      // Marketing cookies were accepted
    },

    handleRejectedMarketing() {
      // Marketing cookies were rejected
    },
  }
}
</script>

Then include your extended version in your app:

import App from './App.vue';
import CookieNotice from './my-vue-files/CookieNotice.vue';

const app = createApp(App);
app.component('cookie-notice', CookieNotice);
app.mount('#app');

When the user scrolls down, that will be taken as implied consent (your text in the default slot should reflect this).

The user can then choose to accept all the cookies or use the options button to filter the cookies or reject all of them.

Props

  • preference-cookies
  • statistic-cookies
  • marketing-cookies
  • label-class
  • wrapper-class
  • btn-wrapper-class
  • options-wrapper-class
  • options-btn-wrapper-class
  • accept-btn-class
  • accept-btn-text
  • reject-btn-class
  • reject-btn-text
  • options-btn-class
  • options-btn-text
  • save-btn-class
  • save-btn-text
  • cookie-name
  • reset-selector
  • body-preference-accepted-class
  • body-preference-rejected-class
  • body-statistic-accepted-class
  • body-statistic-rejected-class
  • body-marketing-accepted-class
  • body-marketing-rejected-class

Events

The following will both be emited from the component and triggered as events on the body element.

  • preferencecookiesaccepted
  • preferencecookiesrejected
  • statisticcookiesaccepted
  • statisticcookiesrejected
  • marketingcookiesaccepted
  • marketingcookiesrejected

Slots

You can use the following slots to provide extra text.

Default slot

<cookie-notice>
  We've got cookies
</cookie-notice>

Options Text

<cookie-notice>
  <template v-slot:options-text>
    Please select and accept your tracking preferences:
  </template>
</cookie-notice>

Descriptions

<cookie-notice>
  <template v-slot:required-cookies-description>
    Cookies for basic website functionality. These can't be turned off.
  </template>
  <template v-slot:preference-cookies-description>
    Cookies to store your preferences.
  </template>
  <template v-slot:statistics-cookies-description>
    Cookies to track how our site is being used in order to improve our service.
  </template>
  <template v-slot:marketing-cookies-description>
    Cookies used by us and our advertising partners to provide you with personalised advertising.
  </template>
</cookie-notice>

Development

To compile before distribution, run ./compile. This will use vue-compile to convert the TS to JS.

Note: this does strip out the type information so a better solution should be found.