-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(default-theme): added cookie bar (#1102)
- Loading branch information
Showing
3 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<template> | ||
<SfTopBar v-if="displayCookieBar" class="sw-cookie-bar" data-cy="cookie-bar"> | ||
<template #left> | ||
<div class="cookie-info"> | ||
<SwCookieBarContent /> | ||
</div> | ||
</template> | ||
<template #right> | ||
<SwButton class="btton" data-cy="accept-cookies" @click="acceptCookies"> | ||
Got it! | ||
</SwButton> | ||
</template> | ||
</SfTopBar> | ||
</template> | ||
|
||
<script> | ||
import { SfTopBar } from "@storefront-ui/vue" | ||
import SwButton from "@/components/atoms/SwButton" | ||
const SwCookieBarContent = () => import("@/components/gdpr/SwCookieBarContent") | ||
export default { | ||
name: "SwCookieBar", | ||
components: { | ||
SfTopBar, | ||
SwButton, | ||
SwCookieBarContent, | ||
}, | ||
data() { | ||
return { | ||
displayCookieBar: false, | ||
} | ||
}, | ||
mounted() { | ||
const res = localStorage.getItem("gdpr-cookie-notification-accepted") | ||
if (res !== "true") { | ||
this.displayCookieBar = true | ||
} | ||
}, | ||
methods: { | ||
acceptCookies() { | ||
localStorage.setItem("gdpr-cookie-notification-accepted", true) | ||
this.displayCookieBar = false | ||
}, | ||
}, | ||
} | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
@import "@/assets/scss/variables"; | ||
.sw-cookie-bar ::v-deep.sf-top-bar__container { | ||
height: auto; | ||
} | ||
.sw-cookie-bar { | ||
--top-bar-background: var(--c-black-lighten); | ||
box-sizing: border-box; | ||
color: var(--c-white); | ||
width: 100%; | ||
.btton { | ||
height: 40px; | ||
transition: color 0.33s; | ||
margin-left: var(--spacer-base); | ||
} | ||
} | ||
</style> |
31 changes: 31 additions & 0 deletions
31
packages/default-theme/components/gdpr/SwCookieBarContent.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<template> | ||
<div class="cookie-description"> | ||
<p> | ||
This site uses cookies. Read our cookies policy. | ||
|
||
<!-- <SfLink class="link" :link="$i18n.path()"> | ||
cookies policy. | ||
</SfLink> --> | ||
</p> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { SfLink } from "@storefront-ui/vue" | ||
export default { | ||
name: "SwCookieBarDescription", | ||
components: { SfLink }, | ||
} | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
.cookie-description { | ||
padding: var(--spacer-xs) 0; | ||
.link { | ||
margin-left: var(--spacer-xs); | ||
font-size: var(--font-xs); | ||
color: var(--c-white); | ||
} | ||
} | ||
</style> |
d7a0c03
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: