comand-component-library 4.1.2 → 4.1.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "comand-component-library",
3
- "version": "4.1.2",
3
+ "version": "4.1.4",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "license": "GPL-3.0-only",
@@ -19,6 +19,7 @@
19
19
  // import mixins
20
20
  import I18n from "../mixins/I18n"
21
21
  import DefaultMessageProperties from "../mixins/CmdGoogleMaps/DefaultMessageProperties"
22
+ import {setCookieDisclaimerCookie, getCookieDisclaimerCookie} from "../utils/cookie"
22
23
 
23
24
  export default {
24
25
  name: "CmdGoogleMaps",
@@ -49,6 +50,11 @@ export default {
49
50
  required: true
50
51
  }
51
52
  },
53
+ mounted() {
54
+ if(getCookieDisclaimerCookie().includes("google-maps")) {
55
+ this.cookiesAccepted = true
56
+ }
57
+ },
52
58
  computed: {
53
59
  locateAddress() {
54
60
  if(this.address) {
@@ -62,6 +68,7 @@ export default {
62
68
  },
63
69
  methods: {
64
70
  acceptCookies() {
71
+ setCookieDisclaimerCookie(["google-maps"])
65
72
  this.cookiesAccepted = true
66
73
  this.$emit("click", this.cookiesAccepted)
67
74
  }
@@ -232,9 +232,11 @@ export default {
232
232
  // toggle classes to overwrite media-query styles for color-schemes
233
233
  const htmlTag = document.documentElement
234
234
  if (this.darkMode) {
235
- htmlTag.classList.replace("light-mode", "dark-mode")
235
+ htmlTag.classList.remove("light-mode")
236
+ htmlTag.classList.add("dark-mode")
236
237
  } else {
237
- htmlTag.classList.replace("dark-mode", "light-mode")
238
+ htmlTag.classList.remove("dark-mode")
239
+ htmlTag.classList.add("light-mode")
238
240
  }
239
241
 
240
242
  // emits custom events from html-tag
package/src/index.js CHANGED
@@ -65,6 +65,7 @@ export { default as DirFancybox } from '@/directives/fancybox'
65
65
  // export functions
66
66
  export { createUuid, createHtmlId } from '@/utils/common'
67
67
  export { getFileExtension } from '@/utils/getFileExtension'
68
+ export { setCookieDisclaimerCookie, getCookieDisclaimerCookie } from '@/utils/cookie'
68
69
 
69
70
  // export composables
70
71
  export { useSequence } from '@/composables/sequence'
@@ -0,0 +1,28 @@
1
+ const cookieDisclaimerCookieName = "acceptedCookies"
2
+
3
+ function setCookieDisclaimerCookie(listOfAcceptedCookies, daysToExpire = 365) {
4
+ const cookie = [...getCookieDisclaimerCookie(), ...listOfAcceptedCookies].join(",")
5
+ let expires = ""
6
+ const date = new Date()
7
+ date.setTime(date.getTime() + daysToExpire * 24 * 60 * 60 * 1000)
8
+ expires = "; expires=" + date.toUTCString()
9
+ document.cookie = cookieDisclaimerCookieName + "=" + encodeURIComponent(cookie) + expires + "; SameSite=strict; path=/"
10
+ }
11
+
12
+ function getCookieDisclaimerCookie() {
13
+ const cookie = document.cookie.split(";").map((cookie)=> {
14
+ return cookie.trim()
15
+ }).find((cookie) => {
16
+ return cookie.startsWith(cookieDisclaimerCookieName + "=")
17
+ })
18
+
19
+ if(cookie) {
20
+ const indexOfEqualSign = cookie.indexOf("=")
21
+ return decodeURIComponent(cookie.slice(indexOfEqualSign + 1)).split(",")
22
+ }
23
+
24
+ return []
25
+ }
26
+
27
+ export {setCookieDisclaimerCookie, getCookieDisclaimerCookie}
28
+