Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@avensio/cookie-consent
Advanced tools
This is an internationalized ([vue-i18n](https://vue-i18n.intlify.dev/)) Cookie Consent component for [vue 3](https://vuejs.org/).
This is an internationalized (vue-i18n) Cookie Consent component for vue 3.
The first category must be the essentials
category. Only Cookies in this first category are accepted per default and can't be declined.
All Cookies of other categories are declined per default.
For each Cookie you can pass optional onAccepted
and onDenied
functions, to hand in some code, which will be executed after save selection
or save all
is clicked.
Translations for the passed categories and cookies must be provided, when switching a language.
Only the translation file for the current language value is fetched and further translations gets loaded, when switching the language with vue-i18n
.
The legacy
flag of i18n must be set to false
:
const i18n = createI18n({
legacy: false
})
Before the component gets mounted to the DOM, a global Consents
object is attached to the window
object and, therefore, can be globally accessed.
Consents.hasAccepted
: has consent already been given?Consents.ids
: an array of objects with 2 keys each (categoryId
and cookieId
)Consents.storagePrefix
: with this property it's possible to change the prefix used for storing the individuell consentsconsent
)Consents.storageConsentsKey
: with this property the storage key of all consents can be customizedconsents
) (Cookie name and localStorage
key)Consents.set(categoryId: number, cookieId: number, value: boolean): void
Consents.get(categoryId: number, cookieId: number): boolean
Consents.clear()
localStorage
, delete the Cookie and call all onDenied()
functionsinterface Props {
categories: Array<Category>;
requiredLinks: RequiredLinksProps;
links?: Array<Link>;
useMetaCookie?: boolean; // false
animationDuration?: string; // '1.5s'
minimizeAnimationDuration?: string; // '1s'
hideDuration?: string; // '1s'
storagePrefix?: string; // 'consent'
storageConsentsKey?: string; // 'consents'
maskContent?: boolean; // true
maskColor?: string; // '#47494E'
}
categories
and the privacy
and imprint
links are required component properties.
To add more links to the bottom of the main component view, you can provide additional links
.
By default, the consent is persisted to the localStorage. To also set a cookie, set useMetaCookie
to true.
animationDuration
, minimizeAnimationDuration
and hideDuration
can be set to change the default animation durations.
With storagePrefix
and storageConsentsKey
the keys for persistence can be changed.
By default, the content of the page gets masked when the consent appears. To disable the masking, set maskContent
to false; to change the mask color, set a color with maskColor
.
interface Category {
id: string;
label: string;
description?: string;
cookies?: Array<Cookie>;
}
interface RequiredLinksProps {
privacy: Link;
impress: Link;
}
interface Link {
title: string;
href: string;
}
interface Cookie {
id: string;
name: string;
purpose: string;
provider?: string;
cookieName?: string;
cookieValidityPeriod?: string;
onAccepted?: Function;
onDenied?: Function;
privacyURL?: string;
links?: Array<Link>;
hosts?: string;
}
Import the CSS Style Declarations and the component with
import '@avensio/cookie-consent/style.css'
import CookieConsent from '@avensio/cookie-consent'
For component properties see here
Full Usage Example:
<script setup>
import '@avensio/cookie-consent/style.css'
import CookieConsent from '@avensio/cookie-consent'
const obj = {
requiredLinks: {
privacy: {
title: 'Privacy',
href: '/privacy'
},
impress: {
title: 'Imprint',
href: '/imprint'
}
},
categories: [
{
id: 'essential',
label: 'Essential',
description: 'Essential Cookies are needed for the website to function properly.',
cookies: [
{
id: 'session-cookie',
name: 'Session Cookie',
provider: 'Owner of the Website',
purpose: 'Saves as anynomous user the items in the shopping card and as authenticated user also additional infos',
cookieName: 'SESSION',
cookieValidityPeriod: '2 hours'
}
]
}
]
}
</script>
<template>
<CookieConsent :categories="obj.categories" :required-links="obj.requiredLinks" />
</template>
The language codes are listed in IANA Subtag Registry (see also IANA Protocols (Language Tags) and taken from Wikipedia | List of ISO-639-1 codes.
Every translation block of this Cookie-Consent is named after the appropriate ISO-639-1 code.
In sum 32 languages are supported, mostly from the EU and some others like arabic, indian, russian and chinese.
The source language for the translations is German. All translations were made with google translate and deepl. For some translations also Leo was used.
FAQs
This is an internationalized ([vue-i18n](https://vue-i18n.intlify.dev/)) Cookie Consent component for [vue 3](https://vuejs.org/).
We found that @avensio/cookie-consent demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.