
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
maya-cookie-notice-vue
Advanced tools
A simple vue component to accept/reject cookies.
yarn add maya-vue-cookie-notice
or
npm install --save maya-vue-cookie-notice
You'll want to extend `maya-vue-cookie-notice' and override whichever handle methods you need.
<script>
import CookieNotice from 'maya-vue-cookie-notice';
export default {
extends: CookieNotice,
methods: {
handleAcceptedPreference() {
if (document.querySelector('[src^="https://example.com/script.js"]')) {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://example.com/script.js';
document.body.append(script);
}
},
handleRejectedPreference () {
document.getElementById('myThingToRemove').remove();
},
handleAcceptedStatistic() {
// Statistics cookies were accepted
},
handleRejectedStatistic() {
// Statistics cookies were rejected
},
handleAcceptedMarketing() {
// Marketing cookies were accepted
},
handleRejectedMarketing() {
// Marketing cookies were rejected
},
}
}
</script>
Then include your extended version in your app:
import CookieNotice from './my-vue-files/CookieNotice.vue';
new Vue({
el: '#app',
components: {
CookieNotice,
},
});
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.
The following will both be emited from the component and triggered as events on the body
element.
You can use the following slots to provide extra text.
<cookie-notice>
We've got cookies
</cookie-notice>
<cookie-notice>
<template v-slot:options-text>
Please select and accept your tracking preferences:
</template>
</cookie-notice>
<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>
FAQs
Vue component for accepting and rejecting cookies
The npm package maya-cookie-notice-vue receives a total of 2 weekly downloads. As such, maya-cookie-notice-vue popularity was classified as not popular.
We found that maya-cookie-notice-vue demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.