Files
qbz/src/lib/components/OfflinePlaceholder.svelte
T
vicrodh 373e61f0bd Fix offline mode toggle and add network verification
- Change OfflinePlaceholder icon to use offline.svg instead of Power icon
- Add flex-shrink protection to Toggle component to prevent collapsing
- Add network verification when disabling offline mode:
  - Check network connectivity before switching to online
  - Show semi-transparent overlay during check
  - Revert to offline and show toast if no internet available
- Add check_network Tauri command to verify connectivity
- Add i18n strings for noNetworkToast and checkingNetwork (en/es)
2026-01-15 23:55:45 -06:00

114 lines
2.5 KiB
Svelte

<script lang="ts">
import { Library } from 'lucide-svelte';
import { t } from '$lib/i18n';
import type { OfflineReason } from '$lib/stores/offlineStore';
interface Props {
reason?: OfflineReason | null;
onGoToLibrary?: () => void;
}
let { reason = null, onGoToLibrary }: Props = $props();
</script>
<div class="offline-placeholder" role="alert" aria-live="polite">
<div class="content">
<div class="icon-container" aria-hidden="true">
<img src="/offline.svg" alt="" class="offline-icon" />
</div>
<h2>
{#if reason === 'no_network'}
{$t('offline.noNetwork')}
{:else if reason === 'not_logged_in'}
{$t('offline.notLoggedIn')}
{:else if reason === 'manual_override'}
{$t('offline.manualMode')}
{:else}
{$t('offline.title')}
{/if}
</h2>
<p>
{#if reason === 'no_network'}
{$t('offline.noNetworkMessage')}
{:else if reason === 'not_logged_in'}
{$t('offline.notLoggedInMessage')}
{:else if reason === 'manual_override'}
{$t('offline.manualModeMessage')}
{:else}
{$t('offline.message')}
{/if}
</p>
{#if onGoToLibrary}
<button class="library-button" onclick={onGoToLibrary}>
<Library size={18} />
<span>{$t('offline.goToLibrary')}</span>
</button>
{/if}
</div>
</div>
<style>
.offline-placeholder {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
min-height: 400px;
padding: 48px;
}
.content {
text-align: center;
max-width: 400px;
}
.icon-container {
color: var(--color-text-tertiary);
margin-bottom: 24px;
opacity: 0.6;
}
.offline-icon {
width: 64px;
height: 64px;
filter: brightness(0) invert(0.6);
}
h2 {
font-size: 1.5rem;
font-weight: 600;
color: var(--color-text-primary);
margin: 0 0 12px 0;
}
p {
font-size: 0.95rem;
color: var(--color-text-secondary);
margin: 0 0 24px 0;
line-height: 1.5;
}
.library-button {
display: inline-flex;
align-items: center;
gap: 8px;
padding: 12px 24px;
background: var(--color-primary);
color: var(--color-on-primary);
border: none;
border-radius: 8px;
font-size: 0.95rem;
font-weight: 500;
cursor: pointer;
transition: background 0.2s, transform 0.1s;
}
.library-button:hover {
background: var(--color-primary-hover);
}
.library-button:active {
transform: scale(0.98);
}
</style>