-
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.
- Loading branch information
Showing
6 changed files
with
121 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<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> | ||
|
||
<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> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
data() { | ||
return { | ||
messages: ['🎄聖誕限時 全店9折優惠', '於付款頁面輸入優惠碼”CHRISTMAS10”'], | ||
showBanner: true, | ||
}; | ||
}, | ||
computed: { | ||
repeatedMessages() { | ||
return [...this.messages, ...this.messages]; | ||
}, | ||
}, | ||
methods: { | ||
closeBanner() { | ||
this.showBanner = false; | ||
try { | ||
window.localStorage.setItem('bannerClosedTime', Date.now()); | ||
} catch (error) {} | ||
}, | ||
checkBannerStatus() { | ||
try { | ||
const lastClosedTime = window.localStorage.getItem('bannerClosedTime'); | ||
const oneDay = 24 * 60 * 60 * 1000; | ||
if (lastClosedTime && Date.now() - lastClosedTime < oneDay) { | ||
this.showBanner = false; | ||
} | ||
} catch (error) {} | ||
}, | ||
}, | ||
created() { | ||
Check warning on line 59 in src/components/ChristmasCampaign/banner.vue GitHub Actions / CI
|
||
this.checkBannerStatus(); | ||
}, | ||
}; | ||
</script> | ||
|
||
<style scoped> | ||
.scrolling-content { | ||
display: flex; | ||
flex-direction: column; | ||
animation: scrollUp 10s linear infinite; | ||
} | ||
@keyframes scrollUp { | ||
0%, | ||
25% { | ||
transform: translateY(0%); | ||
} | ||
50%, | ||
75% { | ||
transform: translateY(-25%); | ||
} | ||
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
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
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