-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔀 Merge #1990 into deploy/rinkeby
- Loading branch information
Showing
5 changed files
with
140 additions
and
69 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 |
---|---|---|
@@ -1,93 +1,130 @@ | ||
<template> | ||
<div | ||
v-if="showBanner" | ||
class="z-[500] w-full h-[40px] overflow-hidden flex items-center justify-center text-white bg-like-green relative" | ||
> | ||
<div class="h-[24px] overflow-hidden relative"> | ||
<div class="scrolling-content"> | ||
<div | ||
v-for="(message, index) in repeatedMessages" | ||
:key="index" | ||
class="h-[24px] text-[14px] flex items-center justify-center" | ||
> | ||
{{ message }} | ||
</div> | ||
</div> | ||
</div> | ||
<Transition @enter="handleBannerEnter" @leave="handleBannerLeave"> | ||
<div | ||
v-if="isShowBanner" | ||
:class="[ | ||
'relative', | ||
'top-0', | ||
'z-[500]', | ||
'flex', | ||
'items-center', | ||
'justify-center', | ||
<ButtonV2 | ||
preset="plain" | ||
size="small" | ||
class="absolute translate-y-[-50%] right-[12px] top-1/2" | ||
@click="closeBanner" | ||
'overflow-hidden', | ||
'w-full', | ||
'h-[40px]', | ||
'text-white', | ||
'bg-like-green', | ||
]" | ||
> | ||
<IconClose class="transform scale-75 laptop:scale-100" /> | ||
</ButtonV2> | ||
</div> | ||
<Transition name="scroll-up"> | ||
<div | ||
:key="activeMessage" | ||
:class="[ | ||
'absolute', | ||
'inset-0', | ||
'flex', | ||
'justify-center', | ||
'items-center', | ||
'text-[14px]', | ||
'text-center', | ||
]" | ||
v-text="activeMessage" | ||
/> | ||
</Transition> | ||
|
||
<ButtonV2 | ||
preset="plain" | ||
size="small" | ||
class="absolute translate-y-[-50%] right-[12px] top-1/2" | ||
@click="closeBanner" | ||
> | ||
<IconClose class="transform scale-75 laptop:scale-100" /> | ||
</ButtonV2> | ||
</div> | ||
</Transition> | ||
</template> | ||
|
||
<script> | ||
const LAST_CLOSED_AT_KEY = 'site-top-banner-last-closed-at'; | ||
export default { | ||
name: 'SiteTopBanner', | ||
props: { | ||
messages: { | ||
type: Array, | ||
default: () => [], | ||
}, | ||
interval: { | ||
type: Number, | ||
default: 4000, | ||
}, | ||
}, | ||
data() { | ||
return { | ||
messages: [ | ||
this.$t('christmas_campaign_text_1'), | ||
this.$t('christmas_campaign_text_2'), | ||
this.$t('christmas_campaign_text_3'), | ||
], | ||
showBanner: true, | ||
isShowBanner: false, | ||
activeMessageIndex: 0, | ||
}; | ||
}, | ||
computed: { | ||
repeatedMessages() { | ||
return this.messages.concat(this.messages); | ||
activeMessage() { | ||
return this.messages[this.activeMessageIndex]; | ||
}, | ||
}, | ||
created() { | ||
this.checkBannerStatus(); | ||
mounted() { | ||
this.showBannerIfPossible(); | ||
}, | ||
beforeDestroy() { | ||
this.clearInterval(); | ||
}, | ||
methods: { | ||
handleBannerEnter(el, done) { | ||
this.$gsap.gsap.from(el, { | ||
height: 0, | ||
duration: 0.5, | ||
onComplete: done, | ||
}); | ||
}, | ||
handleBannerLeave(el, done) { | ||
this.$gsap.gsap.to(el, { | ||
height: 0, | ||
duration: 0.5, | ||
onComplete: done, | ||
}); | ||
}, | ||
nextMessage() { | ||
this.activeMessageIndex = | ||
(this.activeMessageIndex + 1) % this.messages.length; | ||
}, | ||
clearInterval() { | ||
if (this.messageInterval) { | ||
clearInterval(this.messageInterval); | ||
this.messageInterval = null; | ||
} | ||
}, | ||
closeBanner() { | ||
this.showBanner = false; | ||
this.isShowBanner = false; | ||
try { | ||
window.localStorage.setItem('bannerClosedTime', Date.now()); | ||
} catch (error) {} | ||
window.localStorage.setItem(LAST_CLOSED_AT_KEY, Date.now()); | ||
} finally { | ||
this.clearInterval(); | ||
} | ||
}, | ||
checkBannerStatus() { | ||
showBannerIfPossible() { | ||
try { | ||
const lastClosedTime = window.localStorage.getItem('bannerClosedTime'); | ||
const lastClosedTime = window.localStorage.getItem(LAST_CLOSED_AT_KEY); | ||
const oneDay = 24 * 60 * 60 * 1000; | ||
if (lastClosedTime && Date.now() - lastClosedTime < oneDay) { | ||
this.showBanner = false; | ||
if (!lastClosedTime || Date.now() - lastClosedTime >= oneDay) { | ||
this.isShowBanner = true; | ||
this.messageInterval = setInterval(this.nextMessage, this.interval); | ||
} | ||
} catch (error) {} | ||
} catch {} | ||
}, | ||
}, | ||
}; | ||
</script> | ||
|
||
<style scoped> | ||
.scrolling-content { | ||
display: flex; | ||
flex-direction: column; | ||
animation: scrollUp 12s cubic-bezier(0.7, 0, 0.25, 1) infinite; | ||
} | ||
@keyframes scrollUp { | ||
0%, | ||
16.666% { | ||
transform: translateY(0%); | ||
} | ||
33.333%, | ||
50% { | ||
transform: translateY(-16.666%); | ||
} | ||
66.666%, | ||
83.333% { | ||
transform: translateY(-33.333%); | ||
} | ||
100% { | ||
transform: translateY(-50%); | ||
} | ||
} | ||
</style> |
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,15 @@ | ||
<template> | ||
<SiteTopBanner | ||
:messages="[ | ||
$t('christmas_campaign_text_1'), | ||
$t('christmas_campaign_text_2'), | ||
$t('christmas_campaign_text_3'), | ||
]" | ||
/> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: 'SiteTopBannerForChristmas', | ||
}; | ||
</script> |
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