Vollbild-Knopf im Startbildschirm hinzufügen
This commit is contained in:
parent
684a430005
commit
07ddd9c91a
72
src/lib/components/shared/FullscreenToggle.svelte
Normal file
72
src/lib/components/shared/FullscreenToggle.svelte
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
<script lang="ts">
|
||||
// Vollbild umschalten via Fullscreen-API. Wird ausgeblendet, wo die API fehlt (z. B. iPhone-Safari).
|
||||
const supported =
|
||||
typeof document !== 'undefined' && typeof document.documentElement.requestFullscreen === 'function';
|
||||
|
||||
let isFullscreen = $state(false);
|
||||
|
||||
function sync() {
|
||||
isFullscreen = !!document.fullscreenElement;
|
||||
}
|
||||
|
||||
$effect(() => {
|
||||
sync();
|
||||
document.addEventListener('fullscreenchange', sync);
|
||||
return () => document.removeEventListener('fullscreenchange', sync);
|
||||
});
|
||||
|
||||
function toggle() {
|
||||
if (document.fullscreenElement) {
|
||||
document.exitFullscreen?.();
|
||||
} else {
|
||||
document.documentElement.requestFullscreen?.().catch(() => {});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if supported}
|
||||
<button
|
||||
class="fs-toggle"
|
||||
type="button"
|
||||
aria-label={isFullscreen ? 'Vollbild beenden' : 'Vollbild'}
|
||||
onclick={toggle}
|
||||
>
|
||||
{#if isFullscreen}
|
||||
<svg width="30" height="30" viewBox="0 0 32 32" aria-hidden="true">
|
||||
<path
|
||||
d="M13 4 L13 13 L4 13 M19 4 L19 13 L28 13 M13 28 L13 19 L4 19 M19 28 L19 19 L28 19"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2.6"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
{:else}
|
||||
<svg width="30" height="30" viewBox="0 0 32 32" aria-hidden="true">
|
||||
<path
|
||||
d="M4 11 L4 4 L11 4 M28 11 L28 4 L21 4 M4 21 L4 28 L11 28 M28 21 L28 28 L21 28"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2.6"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
{/if}
|
||||
</button>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.fs-toggle {
|
||||
width: 64px;
|
||||
height: 64px;
|
||||
border-radius: 50%;
|
||||
background: rgba(255, 255, 255, 0.18);
|
||||
color: var(--c-text-on-dark);
|
||||
display: grid;
|
||||
place-items: center;
|
||||
transition: transform 0.12s ease;
|
||||
}
|
||||
.fs-toggle:active { transform: scale(0.92); }
|
||||
</style>
|
||||
|
|
@ -6,6 +6,7 @@
|
|||
import { play, unlockAudio } from '../audio/soundManager';
|
||||
import NumberCard from '../components/home/NumberCard.svelte';
|
||||
import SoundToggle from '../components/shared/SoundToggle.svelte';
|
||||
import FullscreenToggle from '../components/shared/FullscreenToggle.svelte';
|
||||
import IconButton from '../components/shared/IconButton.svelte';
|
||||
|
||||
function handlePick(t: Target) {
|
||||
|
|
@ -20,6 +21,8 @@
|
|||
<header class="topbar">
|
||||
<SoundToggle />
|
||||
<h1 class="visually-hidden">Zahlzerlegung</h1>
|
||||
<div class="actions">
|
||||
<FullscreenToggle />
|
||||
<IconButton label="Einstellungen" onClick={goSettings}>
|
||||
<svg width="34" height="34" viewBox="0 0 32 32" aria-hidden="true">
|
||||
<path
|
||||
|
|
@ -29,6 +32,7 @@
|
|||
/>
|
||||
</svg>
|
||||
</IconButton>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="cards-grid">
|
||||
|
|
@ -51,6 +55,11 @@
|
|||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
.actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
}
|
||||
.visually-hidden {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user