|
| 1 | +<template> |
| 2 | + <div class="banner banner-vuejsconf" v-if="isVisible"> |
| 3 | + <a href="https://conf.vuejs.de/?utm_source=vuejs&utm_medium=referral&utm_campaign=banner-placement&utm_content=banner" |
| 4 | + target="_blank"> |
| 5 | + <picture> |
| 6 | + <source media="(min-width:1200px)" srcset="/vuejsde-conf/vuejsdeconf_banner_large.png" /> |
| 7 | + <source media="(min-width:920px)" srcset="/vuejsde-conf/vuejsdeconf_banner_medium.png" /> |
| 8 | + <img src="/vuejsde-conf/vuejsdeconf_banner_small.png" alt="" /> |
| 9 | + </picture> |
| 10 | + </a> |
| 11 | + <div class="close-btn" @click.stop.prevent="closeBanner"> |
| 12 | + <span class="close">×</span> |
| 13 | + </div> |
| 14 | + </div> |
| 15 | +</template> |
| 16 | + |
| 17 | +<script setup lang="ts"> |
| 18 | +import { ref, onMounted } from 'vue' |
| 19 | +
|
| 20 | +const isVisible = ref(false) |
| 21 | +
|
| 22 | +const nameStorage = 'VUEJSDECONF-BANNER-MAY-2024' |
| 23 | +
|
| 24 | +const resetLayoutTopHeight = () => { |
| 25 | + document.documentElement.classList.add('banner-dismissed') |
| 26 | +} |
| 27 | +
|
| 28 | +const closeBanner = () => { |
| 29 | + // Hide the banner |
| 30 | + isVisible.value = false |
| 31 | + // Save action in the local storage |
| 32 | + localStorage.setItem(nameStorage, String(true)) |
| 33 | + resetLayoutTopHeight() |
| 34 | +} |
| 35 | +
|
| 36 | +onMounted(() => { |
| 37 | + isVisible.value = !localStorage.getItem(nameStorage) |
| 38 | +
|
| 39 | + if (!isVisible.value) { |
| 40 | + resetLayoutTopHeight() |
| 41 | + } |
| 42 | +}) |
| 43 | +</script> |
| 44 | +<style> |
| 45 | +html:not(.banner-dismissed) { |
| 46 | + --vp-layout-top-height: 60px; |
| 47 | +} |
| 48 | +</style> |
| 49 | +<style scoped> |
| 50 | +.banner { |
| 51 | + position: fixed; |
| 52 | + z-index: var(--vp-z-index-layout-top); |
| 53 | + box-sizing: border-box; |
| 54 | + top: 0; |
| 55 | + left: 0; |
| 56 | + right: 0; |
| 57 | + height: var(--vp-layout-top-height); |
| 58 | + line-height: 0; |
| 59 | + text-align: center; |
| 60 | + font-size: 12px; |
| 61 | + font-weight: 600; |
| 62 | + color: #fff; |
| 63 | +} |
| 64 | +
|
| 65 | +.banner-dismissed .banner { |
| 66 | + display: none; |
| 67 | +} |
| 68 | +
|
| 69 | +a { |
| 70 | + text-decoration: underline; |
| 71 | +} |
| 72 | +
|
| 73 | +.banner-vuejsconf { |
| 74 | + background: linear-gradient(90deg, #fff 50%, #43b883 50%); |
| 75 | +} |
| 76 | +
|
| 77 | +.banner-vuejsconf a { |
| 78 | + display: inline-block; |
| 79 | + margin: 0 auto; |
| 80 | +} |
| 81 | +
|
| 82 | +.banner-vuejsconf .close-btn { |
| 83 | + top: 10px; |
| 84 | + right: 10px; |
| 85 | + z-index: 99; |
| 86 | + position: absolute; |
| 87 | + border-radius: 50%; |
| 88 | + padding: 10px; |
| 89 | + cursor: pointer; |
| 90 | +} |
| 91 | +</style> |
0 commit comments