-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #193 from benoitdemaegdt/feat_news-banner
Ajout d'une bannière de news
- Loading branch information
Showing
3 changed files
with
70 additions
and
10 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,34 @@ | ||
<template> | ||
<div class="relative isolate flex items-center gap-x-6 overflow-hidden bg-lvv-blue-100 px-6 py-2.5 sm:px-3.5 sm:before:flex-1"> | ||
<div class="absolute left-[max(-7rem,calc(50%-52rem))] top-1/2 -z-10 -translate-y-1/2 transform-gpu blur-2xl" aria-hidden="true"> | ||
<div class="aspect-[577/310] w-[36.0625rem] bg-gradient-to-r from-[#C84271] to-[#9089fc] opacity-70" style="clip-path: polygon(74.8% 41.9%, 97.2% 73.2%, 100% 34.9%, 92.5% 0.4%, 87.5% 0%, 75% 28.6%, 58.5% 54.6%, 50.1% 56.8%, 46.9% 44%, 48.3% 17.4%, 24.7% 53.9%, 0% 27.9%, 11.9% 74.2%, 24.9% 54.1%, 68.6% 100%, 74.8% 41.9%)" /> | ||
</div> | ||
<div class="absolute left-[max(45rem,calc(50%+8rem))] top-1/2 -z-10 -translate-y-1/2 transform-gpu blur-2xl" aria-hidden="true"> | ||
<div class="aspect-[577/310] w-[36.0625rem] bg-gradient-to-r from-[#ff80b5] to-[#9089fc] opacity-30" style="clip-path: polygon(74.8% 41.9%, 97.2% 73.2%, 100% 34.9%, 92.5% 0.4%, 87.5% 0%, 75% 28.6%, 58.5% 54.6%, 50.1% 56.8%, 46.9% 44%, 48.3% 17.4%, 24.7% 53.9%, 0% 27.9%, 11.9% 74.2%, 24.9% 54.1%, 68.6% 100%, 74.8% 41.9%)" /> | ||
</div> | ||
<div class="flex flex-wrap items-center gap-x-4 gap-y-2"> | ||
<div class="text-sm leading-6 text-gray-900"> | ||
<strong class="font-semibold">3 nov. 2023</strong><svg viewBox="0 0 2 2" class="mx-2 inline h-0.5 w-0.5 fill-current" aria-hidden="true"><circle cx="1" cy="1" r="1" /></svg> | ||
</div> | ||
<div> | ||
Un tronçon de la Voie Lyonnaise 2 terminé ! | ||
</div> | ||
<NuxtLink to="/historique" class="flex-none text-lvv-blue-600 py-1 text-sm font-semibold hover:underline"> | ||
Lire l'annonce <span aria-hidden="true">→</span> | ||
</NuxtLink> | ||
</div> | ||
<div class="flex flex-1 justify-end"> | ||
<button type="button" class="-m-3 p-3 focus-visible:outline-offset-[-4px]" @click="close"> | ||
<span class="sr-only">Dismiss</span> | ||
<Icon name="mdi:close" class="h-5 w-5" aria-hidden="true" /> | ||
</button> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
const emit = defineEmits(['close']); | ||
function close() { | ||
emit('close'); | ||
} | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,34 @@ | ||
<template> | ||
<div> | ||
<NewsBanner v-if="!isNewsBannerClosed" @close="closeNewsBanner" /> | ||
<AppHeader class="sticky top-0" /> | ||
<slot /> | ||
<AppFooter /> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
const isNewsBannerClosed = ref(false); | ||
onMounted(() => { | ||
// if the banner was closed more than 7 days ago, show it again | ||
const newsBannerClosedAt = localStorage.getItem('newsBannerClosedAt'); | ||
if (newsBannerClosedAt) { | ||
const newsBannerClosedAtDate = new Date(newsBannerClosedAt); | ||
const now = new Date(); | ||
const diffInMilliseconds = now - newsBannerClosedAtDate; | ||
const diffInHours = diffInMilliseconds / (1000 * 60 * 60); | ||
if (diffInHours > 24 * 7) { | ||
localStorage.removeItem('isNewsBannerClosed'); | ||
localStorage.removeItem('newsBannerClosedAt'); | ||
} | ||
} | ||
isNewsBannerClosed.value = localStorage.getItem('isNewsBannerClosed') === 'true'; | ||
}); | ||
function closeNewsBanner() { | ||
isNewsBannerClosed.value = true; | ||
localStorage.setItem('isNewsBannerClosed', 'true'); | ||
localStorage.setItem('newsBannerClosedAt', new Date().toISOString()); | ||
} | ||
</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