@dargmuesli/nuxt-cookie-control 1.9.9 → 2.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +206 -285
- package/dist/module.cjs +5 -0
- package/dist/module.d.ts +2 -0
- package/dist/module.json +8 -0
- package/dist/module.mjs +6 -0
- package/dist/runtime/components/CookieControl.vue +274 -0
- package/dist/runtime/components/CookieIframe.vue +39 -0
- package/dist/runtime/composables.ts +1 -0
- package/dist/runtime/constants.ts +3 -0
- package/dist/runtime/locale/ar.ts +19 -0
- package/dist/runtime/locale/de.ts +20 -0
- package/dist/runtime/locale/en.ts +19 -0
- package/{locale/es.js → dist/runtime/locale/es.ts} +19 -15
- package/dist/runtime/locale/fr.ts +19 -0
- package/dist/runtime/locale/hr.ts +20 -0
- package/dist/runtime/locale/hu.ts +20 -0
- package/dist/runtime/locale/index.ts +16 -0
- package/{locale/it.js → dist/runtime/locale/it.ts} +19 -15
- package/dist/runtime/locale/ja.ts +19 -0
- package/dist/runtime/locale/nl.ts +20 -0
- package/dist/runtime/locale/no.ts +20 -0
- package/dist/runtime/locale/pt.ts +20 -0
- package/dist/runtime/locale/ru.ts +19 -0
- package/dist/runtime/locale/uk.ts +19 -0
- package/dist/runtime/methods.ts +190 -0
- package/dist/runtime/plugin.ts +35 -0
- package/dist/runtime/styles.css +347 -0
- package/dist/runtime/types.ts +132 -0
- package/dist/types.d.ts +13 -0
- package/package.json +63 -21
- package/components/CookieControl.vue +0 -182
- package/components/CookieIframe.vue +0 -32
- package/lib/module.js +0 -74
- package/lib/plugin.js +0 -206
- package/lib/postinstall.js +0 -1
- package/lib/styles.scss +0 -434
- package/locale/de.js +0 -15
- package/locale/en.js +0 -15
- package/locale/fr.js +0 -15
- package/locale/hr.js +0 -15
- package/locale/hu.js +0 -15
- package/locale/ja.js +0 -15
- package/locale/no.js +0 -16
- package/locale/pt.js +0 -15
- package/locale/ru.js +0 -15
- package/locale/uk.js +0 -15
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import Cookies from 'js-cookie'
|
|
2
|
+
// import { NuxtApp } from 'nuxt/dist/app/nuxt'
|
|
3
|
+
import slugify from 'slugify'
|
|
4
|
+
import { Ref } from 'vue'
|
|
5
|
+
|
|
6
|
+
import { useCookieControl } from './composables'
|
|
7
|
+
import { LOCALE_DEFAULT } from './constants'
|
|
8
|
+
import { Cookie, Locale, ModuleOptions, Translatable } from './types'
|
|
9
|
+
|
|
10
|
+
export const useAcceptNecessary = () => {
|
|
11
|
+
const { cookiesEnabled, isConsentGiven, moduleOptions } = useCookieControl()
|
|
12
|
+
// const nuxtApp = useNuxtApp()
|
|
13
|
+
|
|
14
|
+
return () =>
|
|
15
|
+
acceptNecessary(
|
|
16
|
+
// nuxtApp,
|
|
17
|
+
cookiesEnabled,
|
|
18
|
+
isConsentGiven,
|
|
19
|
+
moduleOptions.cookies?.necessary
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const acceptNecessary = (
|
|
24
|
+
// nuxtApp: NuxtApp,
|
|
25
|
+
enabled: Ref<Cookie[]>,
|
|
26
|
+
consent: Ref<boolean>,
|
|
27
|
+
necessaryCookies: Cookie[] = []
|
|
28
|
+
) => {
|
|
29
|
+
const expires = new Date()
|
|
30
|
+
expires.setFullYear(expires.getFullYear() + 1)
|
|
31
|
+
|
|
32
|
+
const necessaryCookieIds = necessaryCookies.map((necessaryCookie) =>
|
|
33
|
+
getCookieId(necessaryCookie)
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
Cookies.set('cookie_control_enabled_cookies', necessaryCookieIds.join(','), {
|
|
37
|
+
expires,
|
|
38
|
+
})
|
|
39
|
+
Cookies.set('cookie_control_consent', 'true', { expires })
|
|
40
|
+
|
|
41
|
+
consent.value = true
|
|
42
|
+
|
|
43
|
+
if (process.client) {
|
|
44
|
+
setHead(/* nuxtApp, */ enabled.value)
|
|
45
|
+
// callAcceptedFunctions(nuxtApp, enabled.value)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const useResolveTranslatable = (locale = LOCALE_DEFAULT) => {
|
|
50
|
+
return (translatable: Translatable) =>
|
|
51
|
+
resolveTranslatable(translatable, locale)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const resolveTranslatable = (translatable: Translatable, locale?: Locale) => {
|
|
55
|
+
if (typeof translatable === 'string') return translatable
|
|
56
|
+
|
|
57
|
+
if (!locale)
|
|
58
|
+
throw new Error('No locale given for translatable that is not a string.')
|
|
59
|
+
|
|
60
|
+
const result = translatable[locale]
|
|
61
|
+
|
|
62
|
+
if (!result)
|
|
63
|
+
throw new Error(`Could not get translation for locale ${locale}.`)
|
|
64
|
+
|
|
65
|
+
return result
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export const useSetConsent = () => {
|
|
69
|
+
const { isConsentGiven, moduleOptions, cookiesEnabled, cookiesEnabledIds } =
|
|
70
|
+
useCookieControl()
|
|
71
|
+
// const nuxtApp = useNuxtApp()
|
|
72
|
+
return () =>
|
|
73
|
+
setConsent({
|
|
74
|
+
isInit: false,
|
|
75
|
+
// nuxtApp,
|
|
76
|
+
isConsentGiven,
|
|
77
|
+
moduleOptions,
|
|
78
|
+
cookiesEnabled,
|
|
79
|
+
cookiesEnabledIds,
|
|
80
|
+
})
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export const setConsent = ({
|
|
84
|
+
isInit = false,
|
|
85
|
+
// nuxtApp,
|
|
86
|
+
isConsentGiven,
|
|
87
|
+
moduleOptions,
|
|
88
|
+
cookiesEnabled,
|
|
89
|
+
cookiesEnabledIds,
|
|
90
|
+
}: {
|
|
91
|
+
isInit: boolean
|
|
92
|
+
// nuxtApp: NuxtApp
|
|
93
|
+
isConsentGiven: Ref<boolean | undefined>
|
|
94
|
+
moduleOptions: ModuleOptions
|
|
95
|
+
cookiesEnabled: Ref<Cookie[]>
|
|
96
|
+
cookiesEnabledIds: Ref<string[]>
|
|
97
|
+
}) => {
|
|
98
|
+
isConsentGiven.value = Cookies.get('cookie_control_consent') === 'true'
|
|
99
|
+
cookiesEnabled.value = []
|
|
100
|
+
cookiesEnabledIds.value = []
|
|
101
|
+
|
|
102
|
+
if (isConsentGiven.value) {
|
|
103
|
+
const enabledFromCookie = Cookies.get('cookie_control_enabled_cookies')
|
|
104
|
+
|
|
105
|
+
cookiesEnabled.value.push(
|
|
106
|
+
...moduleOptions.cookies.optional.filter((cookieOptional) => {
|
|
107
|
+
return enabledFromCookie?.includes(getCookieId(cookieOptional))
|
|
108
|
+
})
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (moduleOptions.cookies?.necessary)
|
|
113
|
+
cookiesEnabled.value.push(
|
|
114
|
+
...moduleOptions.cookies.necessary.filter((c) => {
|
|
115
|
+
return c.src // || c.onAccept
|
|
116
|
+
})
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
cookiesEnabledIds.value = cookiesEnabled.value.map((cookieEnabled) =>
|
|
120
|
+
getCookieId(cookieEnabled)
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
if (process.client && !isInit) {
|
|
124
|
+
setHead(/* nuxtApp, */ cookiesEnabled.value)
|
|
125
|
+
clearCookies(
|
|
126
|
+
// nuxtApp,
|
|
127
|
+
cookiesEnabledIds.value,
|
|
128
|
+
moduleOptions.cookies.optional
|
|
129
|
+
)
|
|
130
|
+
// callAcceptedFunctions(nuxtApp, cookiesEnabled.value)
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export const getCookieId = (cookie: Cookie) =>
|
|
135
|
+
cookie.id || slugify(resolveTranslatable(cookie.name))
|
|
136
|
+
|
|
137
|
+
export const clearCookies = (
|
|
138
|
+
// nuxtApp: NuxtApp,
|
|
139
|
+
cookiesEnabledIds: string[],
|
|
140
|
+
cookiesOptional: Cookie[]
|
|
141
|
+
) => {
|
|
142
|
+
const cookiesDisabled = cookiesOptional.filter(
|
|
143
|
+
(cookieOptional) => !cookiesEnabledIds.includes(getCookieId(cookieOptional))
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
for (const cookieDisabled of cookiesDisabled) {
|
|
147
|
+
// if (cookieDisabled.onDecline) cookieDisabled.onDecline().call(nuxtApp)
|
|
148
|
+
if (!cookieDisabled.targetCookieIds) continue
|
|
149
|
+
|
|
150
|
+
for (const cookieDisabledId of cookieDisabled.targetCookieIds) {
|
|
151
|
+
Cookies.remove(cookieDisabledId)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (cookieDisabled.src) {
|
|
155
|
+
for (const s of [
|
|
156
|
+
...document.head.querySelectorAll(
|
|
157
|
+
`script[src="${cookieDisabled.src}"]`
|
|
158
|
+
),
|
|
159
|
+
]) {
|
|
160
|
+
s.parentNode?.removeChild(s)
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export const setHead = (/* nuxtApp: NuxtApp, */ enabledCookies: Cookie[]) => {
|
|
167
|
+
const head = document.getElementsByTagName('head')[0]
|
|
168
|
+
|
|
169
|
+
for (const cookieEnabled of enabledCookies) {
|
|
170
|
+
if (!cookieEnabled.src) continue
|
|
171
|
+
|
|
172
|
+
const script = document.createElement('script')
|
|
173
|
+
script.src = cookieEnabled.src
|
|
174
|
+
// script.addEventListener('load', () => {
|
|
175
|
+
// if (cookieEnabled.onAccept) cookieEnabled.onAccept().call(nuxtApp)
|
|
176
|
+
// })
|
|
177
|
+
head.appendChild(script)
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// export const callAcceptedFunctions = (
|
|
182
|
+
// nuxtApp: NuxtApp,
|
|
183
|
+
// cookiesEnabled: Cookie[]
|
|
184
|
+
// ) => {
|
|
185
|
+
// for (const cookieEnabled of cookiesEnabled) {
|
|
186
|
+
// if (!cookieEnabled.onAccept) continue
|
|
187
|
+
|
|
188
|
+
// cookieEnabled.onAccept().call(nuxtApp)
|
|
189
|
+
// }
|
|
190
|
+
// }
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { setConsent } from './methods'
|
|
2
|
+
import { Cookie, State } from './types'
|
|
3
|
+
|
|
4
|
+
import moduleOptions from '#build/cookie-control-options'
|
|
5
|
+
|
|
6
|
+
export default defineNuxtPlugin((_nuxtApp) => {
|
|
7
|
+
// const nuxtApp = useNuxtApp()
|
|
8
|
+
const isConsentGiven = ref<boolean>()
|
|
9
|
+
const cookiesEnabled = ref<Cookie[]>([])
|
|
10
|
+
const cookiesEnabledIds = ref<string[]>([])
|
|
11
|
+
const isModalActive = ref<boolean>()
|
|
12
|
+
|
|
13
|
+
const state = {
|
|
14
|
+
isConsentGiven,
|
|
15
|
+
cookiesEnabled,
|
|
16
|
+
cookiesEnabledIds,
|
|
17
|
+
isModalActive,
|
|
18
|
+
moduleOptions,
|
|
19
|
+
} as State
|
|
20
|
+
|
|
21
|
+
setConsent({
|
|
22
|
+
isInit: !process.client,
|
|
23
|
+
// nuxtApp,
|
|
24
|
+
isConsentGiven,
|
|
25
|
+
moduleOptions,
|
|
26
|
+
cookiesEnabled,
|
|
27
|
+
cookiesEnabledIds,
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
provide: {
|
|
32
|
+
cookies: state,
|
|
33
|
+
},
|
|
34
|
+
}
|
|
35
|
+
})
|
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
.cookieControl__Modal-enter-active, .cookieControl__Modal-leave-active {
|
|
2
|
+
transition: opacity 0.25s;
|
|
3
|
+
}
|
|
4
|
+
.cookieControl__Modal-enter, .cookieControl__Modal-leave-to {
|
|
5
|
+
opacity: 0;
|
|
6
|
+
}
|
|
7
|
+
.cookieControl__Bar--center {
|
|
8
|
+
top: 50%;
|
|
9
|
+
left: 50%;
|
|
10
|
+
transform: translate(-50%, -50%);
|
|
11
|
+
}
|
|
12
|
+
.cookieControl__Bar--center-enter-active, .cookieControl__Bar--top-left-enter-active, .cookieControl__Bar--top-full-enter-active, .cookieControl__Bar--top-right-enter-active, .cookieControl__Bar--bottom-left-enter-active, .cookieControl__Bar--bottom-full-enter-active, .cookieControl__Bar--bottom-right-enter-active, .cookieControl__Bar--center-leave-active, .cookieControl__Bar--top-left-leave-active, .cookieControl__Bar--top-full-leave-active, .cookieControl__Bar--top-right-leave-active, .cookieControl__Bar--bottom-left-leave-active, .cookieControl__Bar--bottom-full-leave-active, .cookieControl__Bar--bottom-right-leave-active {
|
|
13
|
+
transition: transform 0.25s;
|
|
14
|
+
}
|
|
15
|
+
.cookieControl__Bar--top-left-enter, .cookieControl__Bar--top-full-enter, .cookieControl__Bar--top-right-enter, .cookieControl__Bar--top-left-leave-to, .cookieControl__Bar--top-full-leave-to, .cookieControl__Bar--top-right-leave-to {
|
|
16
|
+
transform: translateY(-100%);
|
|
17
|
+
}
|
|
18
|
+
.cookieControl__Bar--bottom-left-enter, .cookieControl__Bar--bottom-full-enter, .cookieControl__Bar--bottom-right-enter, .cookieControl__Bar--bottom-left-leave-to, .cookieControl__Bar--bottom-right-leave-to, .cookieControl__Bar--bottom-full-leave-to {
|
|
19
|
+
transform: translateY(100%);
|
|
20
|
+
}
|
|
21
|
+
.cookieControl__Bar--center-enter, .cookieControl__Bar--center-leave-to {
|
|
22
|
+
transform: translate(-50%, -50%) scale(0.95);
|
|
23
|
+
}
|
|
24
|
+
.cookieControl {
|
|
25
|
+
position: relative;
|
|
26
|
+
z-index: 100000;
|
|
27
|
+
}
|
|
28
|
+
.cookieControl button {
|
|
29
|
+
border: 0;
|
|
30
|
+
outline: 0;
|
|
31
|
+
font-size: 16px;
|
|
32
|
+
cursor: pointer;
|
|
33
|
+
padding: 12px 20px;
|
|
34
|
+
backface-visibility: hidden;
|
|
35
|
+
transition: background-color 200ms, color 200ms;
|
|
36
|
+
}
|
|
37
|
+
.cookieControl__Bar {
|
|
38
|
+
position: fixed;
|
|
39
|
+
background-color: var(--cookie-control-barBackground);
|
|
40
|
+
font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
|
|
41
|
+
}
|
|
42
|
+
.cookieControl__Bar h3, .cookieControl__Bar p {
|
|
43
|
+
color: var(--cookie-control-barTextColor);
|
|
44
|
+
max-width: 900px;
|
|
45
|
+
}
|
|
46
|
+
.cookieControl__Bar h3 {
|
|
47
|
+
margin: 0;
|
|
48
|
+
font-size: 20px;
|
|
49
|
+
}
|
|
50
|
+
.cookieControl__Bar p {
|
|
51
|
+
font-size: 16px;
|
|
52
|
+
margin: 5px 0 0;
|
|
53
|
+
}
|
|
54
|
+
.cookieControl__Bar button {
|
|
55
|
+
color: var(--cookie-control-barButtonColor);
|
|
56
|
+
background-color: var(--cookie-control-barButtonBackground);
|
|
57
|
+
}
|
|
58
|
+
.cookieControl__Bar button:hover {
|
|
59
|
+
color: var(--cookie-control-barButtonHoverColor);
|
|
60
|
+
background-color: var(--cookie-control-barButtonHoverBackground);
|
|
61
|
+
}
|
|
62
|
+
.cookieControl__Bar button + button {
|
|
63
|
+
margin-left: 10px;
|
|
64
|
+
}
|
|
65
|
+
.cookieControl__BarContainer {
|
|
66
|
+
display: flex;
|
|
67
|
+
padding: 20px;
|
|
68
|
+
align-items: flex-end;
|
|
69
|
+
justify-content: space-between;
|
|
70
|
+
}
|
|
71
|
+
.cookieControl__Bar--top-full, .cookieControl__Bar--bottom-full {
|
|
72
|
+
left: 0;
|
|
73
|
+
right: 0;
|
|
74
|
+
}
|
|
75
|
+
.cookieControl__Bar--top-full {
|
|
76
|
+
top: 0;
|
|
77
|
+
}
|
|
78
|
+
.cookieControl__Bar--bottom-full {
|
|
79
|
+
bottom: 0;
|
|
80
|
+
}
|
|
81
|
+
.cookieControl__Bar--center p, .cookieControl__Bar--top-left p, .cookieControl__Bar--top-right p, .cookieControl__Bar--bottom-left p, .cookieControl__Bar--bottom-right p {
|
|
82
|
+
max-width: 400px;
|
|
83
|
+
}
|
|
84
|
+
.cookieControl__Bar--center .cookieControl__BarContainer, .cookieControl__Bar--top-left .cookieControl__BarContainer, .cookieControl__Bar--top-right .cookieControl__BarContainer, .cookieControl__Bar--bottom-left .cookieControl__BarContainer, .cookieControl__Bar--bottom-right .cookieControl__BarContainer {
|
|
85
|
+
flex-direction: column;
|
|
86
|
+
}
|
|
87
|
+
.cookieControl__Bar--center .cookieControl__BarButtons, .cookieControl__Bar--top-left .cookieControl__BarButtons, .cookieControl__Bar--top-right .cookieControl__BarButtons, .cookieControl__Bar--bottom-left .cookieControl__BarButtons, .cookieControl__Bar--bottom-right .cookieControl__BarButtons {
|
|
88
|
+
margin-top: 20px;
|
|
89
|
+
}
|
|
90
|
+
.cookieControl__Bar--top-left, .cookieControl__Bar--top-right {
|
|
91
|
+
top: 20px;
|
|
92
|
+
}
|
|
93
|
+
.cookieControl__Bar--bottom-left, .cookieControl__Bar--bottom-right {
|
|
94
|
+
bottom: 20px;
|
|
95
|
+
}
|
|
96
|
+
.cookieControl__Bar--top-left, .cookieControl__Bar--bottom-left {
|
|
97
|
+
left: 20px;
|
|
98
|
+
}
|
|
99
|
+
.cookieControl__Bar--top-right, .cookieControl__Bar--bottom-right {
|
|
100
|
+
right: 20px;
|
|
101
|
+
}
|
|
102
|
+
.cookieControl__BarButtons {
|
|
103
|
+
display: flex;
|
|
104
|
+
}
|
|
105
|
+
.cookieControl__Modal {
|
|
106
|
+
position: fixed;
|
|
107
|
+
top: 0;
|
|
108
|
+
left: 0;
|
|
109
|
+
right: 0;
|
|
110
|
+
bottom: 0;
|
|
111
|
+
z-index: 1;
|
|
112
|
+
font-size: 0;
|
|
113
|
+
text-align: center;
|
|
114
|
+
}
|
|
115
|
+
.cookieControl__Modal:before {
|
|
116
|
+
content: "";
|
|
117
|
+
min-height: 100vh;
|
|
118
|
+
display: inline-block;
|
|
119
|
+
vertical-align: middle;
|
|
120
|
+
}
|
|
121
|
+
.cookieControl__Modal:after {
|
|
122
|
+
position: absolute;
|
|
123
|
+
content: "";
|
|
124
|
+
top: 0;
|
|
125
|
+
left: 0;
|
|
126
|
+
right: 0;
|
|
127
|
+
bottom: 0;
|
|
128
|
+
z-index: -1;
|
|
129
|
+
opacity: var(--cookie-control-modalOverlayOpacity);
|
|
130
|
+
background-color: var(--cookie-control-modalOverlay);
|
|
131
|
+
}
|
|
132
|
+
.cookieControl__Modal > div {
|
|
133
|
+
font-size: initial;
|
|
134
|
+
padding-top: 80px;
|
|
135
|
+
}
|
|
136
|
+
.cookieControl__Modal button {
|
|
137
|
+
color: var(--cookie-control-modalButtonColor);
|
|
138
|
+
background-color: var(--cookie-control-modalButtonBackground);
|
|
139
|
+
}
|
|
140
|
+
.cookieControl__Modal button:hover {
|
|
141
|
+
color: var(--cookie-control-modalButtonHoverColor);
|
|
142
|
+
background-color: var(--cookie-control-modalButtonHoverBackground);
|
|
143
|
+
}
|
|
144
|
+
.cookieControl__ModalContent {
|
|
145
|
+
position: relative;
|
|
146
|
+
width: 100%;
|
|
147
|
+
padding: 40px;
|
|
148
|
+
max-width: 550px;
|
|
149
|
+
max-height: 80vh;
|
|
150
|
+
text-align: left;
|
|
151
|
+
overflow-y: scroll;
|
|
152
|
+
display: inline-block;
|
|
153
|
+
vertical-align: middle;
|
|
154
|
+
color: var(--cookie-control-modalTextColor);
|
|
155
|
+
background-color: var(--cookie-control-modalBackground);
|
|
156
|
+
}
|
|
157
|
+
.cookieControl__ModalContent *:not(button) {
|
|
158
|
+
color: var(--cookie-control-modalTextColor);
|
|
159
|
+
}
|
|
160
|
+
.cookieControl__ModalContent h3 {
|
|
161
|
+
font-size: 24px;
|
|
162
|
+
margin: 50px 0 25px;
|
|
163
|
+
}
|
|
164
|
+
.cookieControl__ModalContent h3:first-of-type {
|
|
165
|
+
margin-top: 0;
|
|
166
|
+
}
|
|
167
|
+
.cookieControl__ModalContent ul {
|
|
168
|
+
padding: 0;
|
|
169
|
+
font-size: 16px;
|
|
170
|
+
list-style-type: none;
|
|
171
|
+
}
|
|
172
|
+
.cookieControl__ModalContent ul ul {
|
|
173
|
+
padding: 5px 56px 0;
|
|
174
|
+
}
|
|
175
|
+
.cookieControl__ModalContent ul ul li + li {
|
|
176
|
+
margin-top: 5px;
|
|
177
|
+
}
|
|
178
|
+
.cookieControl__ModalContent li {
|
|
179
|
+
align-items: center;
|
|
180
|
+
}
|
|
181
|
+
.cookieControl__ModalContent li + li {
|
|
182
|
+
margin-top: 20px;
|
|
183
|
+
}
|
|
184
|
+
.cookieControl__ModalContent input {
|
|
185
|
+
display: none;
|
|
186
|
+
}
|
|
187
|
+
.cookieControl__ModalContent input:checked + label {
|
|
188
|
+
background-color: var(--cookie-control-checkboxActiveBackground);
|
|
189
|
+
}
|
|
190
|
+
.cookieControl__ModalContent input:checked + label:before {
|
|
191
|
+
background-color: var(--cookie-control-checkboxActiveCircleBackground);
|
|
192
|
+
transform: translate3d(100%, -50%, 0);
|
|
193
|
+
}
|
|
194
|
+
.cookieControl__ModalContent input:checked:disabled + label {
|
|
195
|
+
background-color: var(--cookie-control-checkboxDisabledBackground);
|
|
196
|
+
}
|
|
197
|
+
.cookieControl__ModalContent input:checked:disabled + label:before {
|
|
198
|
+
background-color: var(--cookie-control-checkboxDisabledCircleBackground);
|
|
199
|
+
}
|
|
200
|
+
.cookieControl__ModalContent label {
|
|
201
|
+
position: relative;
|
|
202
|
+
min-width: 36px;
|
|
203
|
+
min-height: 20px;
|
|
204
|
+
font-size: 0;
|
|
205
|
+
display: block;
|
|
206
|
+
margin-right: 20px;
|
|
207
|
+
border-radius: 20px;
|
|
208
|
+
backface-visibility: hidden;
|
|
209
|
+
transition: background-color 200ms;
|
|
210
|
+
background-color: var(--cookie-control-checkboxInactiveBackground);
|
|
211
|
+
}
|
|
212
|
+
.cookieControl__ModalContent label:before {
|
|
213
|
+
position: absolute;
|
|
214
|
+
content: "";
|
|
215
|
+
top: 50%;
|
|
216
|
+
left: 3px;
|
|
217
|
+
width: 15px;
|
|
218
|
+
height: 15px;
|
|
219
|
+
border-radius: 50%;
|
|
220
|
+
transition: transform 200ms;
|
|
221
|
+
transform: translate3d(0, -50%, 0);
|
|
222
|
+
background-color: var(--cookie-control-checkboxInactiveCircleBackground);
|
|
223
|
+
}
|
|
224
|
+
.cookieControl__ModalInputWrapper {
|
|
225
|
+
display: flex;
|
|
226
|
+
align-items: flex-start;
|
|
227
|
+
}
|
|
228
|
+
.cookieControl__ModalCookieName {
|
|
229
|
+
font-weight: bold;
|
|
230
|
+
text-transform: uppercase;
|
|
231
|
+
}
|
|
232
|
+
.cookieControl__ModalCookieName span {
|
|
233
|
+
font-weight: normal;
|
|
234
|
+
text-transform: none;
|
|
235
|
+
}
|
|
236
|
+
.cookieControl__ModalClose {
|
|
237
|
+
position: absolute;
|
|
238
|
+
top: 20px;
|
|
239
|
+
right: 20px;
|
|
240
|
+
}
|
|
241
|
+
.cookieControl__ModalButtons {
|
|
242
|
+
display: flex;
|
|
243
|
+
margin-top: 80px;
|
|
244
|
+
align-items: flex-start;
|
|
245
|
+
}
|
|
246
|
+
.cookieControl__ModalButtons button + button {
|
|
247
|
+
margin-left: 20px;
|
|
248
|
+
}
|
|
249
|
+
.cookieControl__ModalUnsaved {
|
|
250
|
+
position: absolute;
|
|
251
|
+
left: 50%;
|
|
252
|
+
bottom: 40px;
|
|
253
|
+
margin: 0;
|
|
254
|
+
color: var(--cookie-control-modalUnsavedColor);
|
|
255
|
+
font-size: 14px;
|
|
256
|
+
transform: translateX(-50%);
|
|
257
|
+
}
|
|
258
|
+
.cookieControl__BlockedIframe {
|
|
259
|
+
padding: 20px;
|
|
260
|
+
border: 2px solid #ddd;
|
|
261
|
+
}
|
|
262
|
+
.cookieControl__BlockedIframe p, .cookieControl__BlockedIframe a {
|
|
263
|
+
font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
|
|
264
|
+
}
|
|
265
|
+
@media screen and (max-width: 768px) {
|
|
266
|
+
.cookieControl__Bar {
|
|
267
|
+
flex-direction: column;
|
|
268
|
+
left: 0;
|
|
269
|
+
right: 0;
|
|
270
|
+
}
|
|
271
|
+
.cookieControl__Bar p, .cookieControl__Bar h3 {
|
|
272
|
+
max-width: 100%;
|
|
273
|
+
}
|
|
274
|
+
.cookieControl__Bar--top-full, .cookieControl__Bar--top-left, .cookieControl__Bar--top-right {
|
|
275
|
+
top: 0;
|
|
276
|
+
}
|
|
277
|
+
.cookieControl__Bar--bottom-full, .cookieControl__Bar--bottom-left, .cookieControl__Bar--bottom-right {
|
|
278
|
+
bottom: 0;
|
|
279
|
+
}
|
|
280
|
+
.cookieControl__ModalContent {
|
|
281
|
+
position: absolute;
|
|
282
|
+
top: 0;
|
|
283
|
+
left: 0;
|
|
284
|
+
right: 0;
|
|
285
|
+
bottom: 0;
|
|
286
|
+
max-width: none;
|
|
287
|
+
max-height: 100%;
|
|
288
|
+
padding: 80px 20px 20px;
|
|
289
|
+
}
|
|
290
|
+
.cookieControl__BarButtons {
|
|
291
|
+
width: 100%;
|
|
292
|
+
margin-top: 20px;
|
|
293
|
+
flex-direction: column;
|
|
294
|
+
justify-content: center;
|
|
295
|
+
}
|
|
296
|
+
.cookieControl__BarButtons button {
|
|
297
|
+
width: 100%;
|
|
298
|
+
}
|
|
299
|
+
.cookieControl__BarButtons button + button {
|
|
300
|
+
margin: 10px 0 0;
|
|
301
|
+
}
|
|
302
|
+
.cookieControl__BarContainer, .cookieControl__ModalButtons {
|
|
303
|
+
flex-direction: column;
|
|
304
|
+
}
|
|
305
|
+
.cookieControl__ModalButtons button {
|
|
306
|
+
width: 100%;
|
|
307
|
+
}
|
|
308
|
+
.cookieControl__ModalButtons button + button {
|
|
309
|
+
margin: 10px 0 0;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
.cookieControl__ControlButton {
|
|
313
|
+
position: fixed;
|
|
314
|
+
right: 20px;
|
|
315
|
+
bottom: 20px;
|
|
316
|
+
border: 0;
|
|
317
|
+
outline: 0;
|
|
318
|
+
width: 40px;
|
|
319
|
+
height: 40px;
|
|
320
|
+
cursor: pointer;
|
|
321
|
+
min-width: 40px;
|
|
322
|
+
min-height: 40px;
|
|
323
|
+
border-radius: 50%;
|
|
324
|
+
backface-visibility: hidden;
|
|
325
|
+
transition: background-color 200ms;
|
|
326
|
+
box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
|
|
327
|
+
background: var(--cookie-control-controlButtonBackground);
|
|
328
|
+
}
|
|
329
|
+
.cookieControl__ControlButton svg {
|
|
330
|
+
position: absolute;
|
|
331
|
+
top: 50%;
|
|
332
|
+
left: 50%;
|
|
333
|
+
min-width: 24px;
|
|
334
|
+
min-height: 24px;
|
|
335
|
+
max-width: 24px;
|
|
336
|
+
max-height: 24px;
|
|
337
|
+
transition: color 200ms;
|
|
338
|
+
backface-visibility: hidden;
|
|
339
|
+
transform: translate(-50%, -50%);
|
|
340
|
+
color: var(--cookie-control-controlButtonIconColor);
|
|
341
|
+
}
|
|
342
|
+
.cookieControl__ControlButton:hover {
|
|
343
|
+
background-color: var(--cookie-control-controlButtonHoverBackground);
|
|
344
|
+
}
|
|
345
|
+
.cookieControl__ControlButton:hover svg {
|
|
346
|
+
color: var(--cookie-control-controlButtonIconHoverColor);
|
|
347
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { Ref } from 'vue'
|
|
2
|
+
|
|
3
|
+
import en from './locale/en'
|
|
4
|
+
|
|
5
|
+
export enum Locale {
|
|
6
|
+
AR = 'ar',
|
|
7
|
+
DE = 'de',
|
|
8
|
+
EN = 'en',
|
|
9
|
+
ES = 'es',
|
|
10
|
+
FR = 'fr',
|
|
11
|
+
HR = 'hr',
|
|
12
|
+
HU = 'hu',
|
|
13
|
+
IT = 'it',
|
|
14
|
+
JA = 'ja',
|
|
15
|
+
NL = 'nl',
|
|
16
|
+
NO = 'no',
|
|
17
|
+
PT = 'pt',
|
|
18
|
+
RU = 'ru',
|
|
19
|
+
UK = 'uk',
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type PartialRecord<K extends keyof any, T> = Partial<Record<K, T>>
|
|
23
|
+
|
|
24
|
+
export type Translatable = string | PartialRecord<Locale, string>
|
|
25
|
+
|
|
26
|
+
export enum CookieType {
|
|
27
|
+
NECESSARY = 'necessary',
|
|
28
|
+
OPTIONAL = 'optional',
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface Cookie {
|
|
32
|
+
description?: Translatable
|
|
33
|
+
id?: string
|
|
34
|
+
name: Translatable
|
|
35
|
+
// onAccept?: Function
|
|
36
|
+
// onDecline?: Function
|
|
37
|
+
src?: string
|
|
38
|
+
targetCookieIds?: string[]
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface LocaleStrings {
|
|
42
|
+
acceptAll: string
|
|
43
|
+
acceptNecessary: string
|
|
44
|
+
barDescription: string
|
|
45
|
+
barTitle: string
|
|
46
|
+
blockedIframe: string
|
|
47
|
+
close: string
|
|
48
|
+
declineAll: string
|
|
49
|
+
functional: string
|
|
50
|
+
here: string
|
|
51
|
+
manageCookies: string
|
|
52
|
+
necessary: string
|
|
53
|
+
optional: string
|
|
54
|
+
save: string
|
|
55
|
+
unsaved: string
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface ModuleOptions {
|
|
59
|
+
barPosition?:
|
|
60
|
+
| 'top-left'
|
|
61
|
+
| 'top-right'
|
|
62
|
+
| 'top-full'
|
|
63
|
+
| 'bottom-left'
|
|
64
|
+
| 'bottom-right'
|
|
65
|
+
| 'bottom-full'
|
|
66
|
+
colors?: false | Record<string, any>
|
|
67
|
+
cookies: {
|
|
68
|
+
necessary: Cookie[]
|
|
69
|
+
optional: Cookie[]
|
|
70
|
+
}
|
|
71
|
+
isAcceptNecessaryButtonEnabled?: boolean
|
|
72
|
+
isControlButtonEnabled?: boolean
|
|
73
|
+
isCssEnabled?: boolean
|
|
74
|
+
isCssPolyfillEnabled?: boolean
|
|
75
|
+
isDashInDescriptionEnabled?: boolean
|
|
76
|
+
isIframeBlocked?: boolean | { initialState: boolean }
|
|
77
|
+
domain?: string
|
|
78
|
+
locales: Locale[]
|
|
79
|
+
localeTexts: PartialRecord<Locale, LocaleStrings>
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export const DEFAULTS: Required<ModuleOptions> = {
|
|
83
|
+
barPosition: 'bottom-full',
|
|
84
|
+
colors: {
|
|
85
|
+
barBackground: '#000',
|
|
86
|
+
barButtonBackground: '#fff',
|
|
87
|
+
barButtonColor: '#000',
|
|
88
|
+
barButtonHoverBackground: '#333',
|
|
89
|
+
barButtonHoverColor: '#fff',
|
|
90
|
+
barTextColor: '#fff',
|
|
91
|
+
checkboxActiveBackground: '#000',
|
|
92
|
+
checkboxActiveCircleBackground: '#fff',
|
|
93
|
+
checkboxDisabledBackground: '#ddd',
|
|
94
|
+
checkboxDisabledCircleBackground: '#fff',
|
|
95
|
+
checkboxInactiveBackground: '#000',
|
|
96
|
+
checkboxInactiveCircleBackground: '#fff',
|
|
97
|
+
controlButtonBackground: '#fff',
|
|
98
|
+
controlButtonHoverBackground: '#000',
|
|
99
|
+
controlButtonIconColor: '#000',
|
|
100
|
+
controlButtonIconHoverColor: '#fff',
|
|
101
|
+
modalBackground: '#fff',
|
|
102
|
+
modalButtonBackground: '#000',
|
|
103
|
+
modalButtonColor: '#fff',
|
|
104
|
+
modalButtonHoverBackground: '#333',
|
|
105
|
+
modalButtonHoverColor: '#fff',
|
|
106
|
+
modalOverlay: '#000',
|
|
107
|
+
modalOverlayOpacity: 0.8,
|
|
108
|
+
modalTextColor: '#000',
|
|
109
|
+
modalUnsavedColor: '#fff',
|
|
110
|
+
},
|
|
111
|
+
cookies: {
|
|
112
|
+
necessary: [],
|
|
113
|
+
optional: [],
|
|
114
|
+
},
|
|
115
|
+
isAcceptNecessaryButtonEnabled: true,
|
|
116
|
+
isControlButtonEnabled: true,
|
|
117
|
+
isCssEnabled: true,
|
|
118
|
+
isCssPolyfillEnabled: true,
|
|
119
|
+
isDashInDescriptionEnabled: true,
|
|
120
|
+
isIframeBlocked: false,
|
|
121
|
+
domain: '',
|
|
122
|
+
locales: [Locale.EN],
|
|
123
|
+
localeTexts: { en },
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export interface State {
|
|
127
|
+
cookiesEnabled: Ref<Cookie[]>
|
|
128
|
+
cookiesEnabledIds: Ref<string[]>
|
|
129
|
+
isConsentGiven: Ref<boolean>
|
|
130
|
+
isModalActive: Ref<boolean>
|
|
131
|
+
moduleOptions: ModuleOptions
|
|
132
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
|
|
2
|
+
import { ModuleOptions, ModuleHooks, ModuleRuntimeConfig, ModulePublicRuntimeConfig } from './module'
|
|
3
|
+
|
|
4
|
+
declare module '@nuxt/schema' {
|
|
5
|
+
interface NuxtConfig { ['cookieControl']?: Partial<ModuleOptions> }
|
|
6
|
+
interface NuxtOptions { ['cookieControl']?: ModuleOptions }
|
|
7
|
+
interface NuxtHooks extends ModuleHooks {}
|
|
8
|
+
interface RuntimeConfig extends ModuleRuntimeConfig {}
|
|
9
|
+
interface PublicRuntimeConfig extends ModulePublicRuntimeConfig {}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
export { default } from './module'
|