diff options
Diffstat (limited to 'web/src/lib/ui/decks/AbilityCardZoom.svelte')
| -rw-r--r-- | web/src/lib/ui/decks/AbilityCardZoom.svelte | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/web/src/lib/ui/decks/AbilityCardZoom.svelte b/web/src/lib/ui/decks/AbilityCardZoom.svelte new file mode 100644 index 0000000..dc5e258 --- /dev/null +++ b/web/src/lib/ui/decks/AbilityCardZoom.svelte @@ -0,0 +1,71 @@ +<!-- + The ability-card zoom (the reference `AbilityCardZoom`): the current + card at ~2.5x scale, tap (or Escape) to close. +--> +<script lang="ts"> + import type { MonsterAbilityCard as AbilityCard } from '$lib/protocol/types'; + import type { StatMonster } from '$lib/game/line/statApplier'; + import MonsterAbilityCard from '../cards/MonsterAbilityCard.svelte'; + + const DEFAULT_ZOOM = 2.5; + + let { + card, + stat, + fh, + flying = false, + open = $bindable(true) + }: { + card: AbilityCard; + stat: StatMonster | null; + fh: boolean; + flying?: boolean; + open?: boolean; + } = $props(); + + // Fit the card into the viewport (the reference shrinks the zoom to fit). + function scaleFor(): number { + if (typeof window === 'undefined') return DEFAULT_ZOOM; + const w = window.innerWidth; + const h = window.innerHeight; + let zoom = Math.min( + DEFAULT_ZOOM, + (w - 80) / 142.4, + (h - 120) / 94.4 + ); + return Math.max(zoom, 0.5); + } + const scale = $state(scaleFor()); +</script> + +{#if open} + <div + class="zoom" + role="dialog" + aria-modal="true" + onclick={() => (open = false)} + onkeydown={(e) => e.key === 'Escape' && (open = false)} + > + <MonsterAbilityCard + {card} + {stat} + {fh} + {flying} + scale={scale} + applyStats={false} + /> + </div> +{/if} + +<style> + .zoom { + position: fixed; + inset: 0; + z-index: 40; + display: flex; + align-items: center; + justify-content: center; + background: rgba(0, 0, 0, 0.75); + cursor: pointer; + } +</style> |
