Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | <template>
<transition name="offline-fade">
<div
v-if="!isOnline"
class="offline-indicator"
role="status"
aria-live="polite"
>
<span class="offline-dot" aria-hidden="true"></span>
<span class="offline-text">
<strong>Offline</strong> — showing last-loaded data
</span>
</div>
</transition>
</template>
<script setup>
import { ref, onMounted, onBeforeUnmount } from 'vue';
const isOnline = ref(true);
function update() {
if (typeof navigator === 'undefined') return;
isOnline.value = navigator.onLine;
}
function handleOnline() {
isOnline.value = true;
}
function handleOffline() {
isOnline.value = false;
}
onMounted(() => {
update();
window.addEventListener('online', handleOnline);
window.addEventListener('offline', handleOffline);
});
onBeforeUnmount(() => {
window.removeEventListener('online', handleOnline);
window.removeEventListener('offline', handleOffline);
});
</script>
<style scoped>
.offline-indicator {
position: fixed;
top: calc(env(safe-area-inset-top, 0px) + 8px);
left: 50%;
transform: translateX(-50%);
z-index: 1100;
background: #1f2937;
color: white;
font-size: 13px;
line-height: 1.2;
padding: 8px 14px;
border-radius: 999px;
display: inline-flex;
align-items: center;
gap: 8px;
box-shadow: 0 6px 16px -4px rgba(0, 0, 0, 0.35);
pointer-events: none;
max-width: calc(100vw - 24px);
}
.offline-dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: #f59e0b;
box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.25);
flex-shrink: 0;
}
.offline-text strong {
font-weight: 700;
}
.offline-fade-enter-active,
.offline-fade-leave-active {
transition:
opacity 0.2s ease,
transform 0.2s ease;
}
.offline-fade-enter-from,
.offline-fade-leave-to {
opacity: 0;
transform: translate(-50%, -8px);
}
</style>
|