feat: add one-click coordinate copying

This commit is contained in:
ik
2026-09-11 07:52:07 +07:00
parent 1ffaf7478d
commit 8c94d40766
+11 -1
View File
@@ -32,7 +32,7 @@ const breadcrumbs = spot ? { "@context": "https://schema.org", "@type": "Breadcr
<Layout title={spot ? `Точка ${spot.x}:${spot.y}, ${spot.waterbody} — RF4 Spotter` : "Точка не найдена — RF4 Spotter"} description={spotDescription} noindex={!spot} structuredData={breadcrumbs} errorPage={!spot || unavailable}>
<a class="back" href="/">← Все активные точки</a>
{unavailable || !spot ? <div class="state"><h1>Точка недоступна</h1><p>API не ответил или такой точки нет.</p></div> : <>
<section class="spot-hero"><div><span class="eyebrow">{spot.waterbody}</span><h1>Точка {spot.x}:{spot.y}</h1><p>{spot.description}</p></div><CoordinateRadar x={spot.x} y={spot.y}/></section>
<section class="spot-hero"><div><span class="eyebrow">{spot.waterbody}</span><h1>Точка {spot.x}:{spot.y}</h1><p>{spot.description}</p><button class="coordinate-copy" type="button" data-copy-coordinates={`${spot.x}:${spot.y}`}>Скопировать координаты</button><small class="copy-status" aria-live="polite"></small></div><CoordinateRadar x={spot.x} y={spot.y}/></section>
<div class="periods"><div><strong>{spot.catches_24h}</strong><span>за 24 часа</span></div><div><strong>{spot.catches_3d}</strong><span>за 3 дня</span></div><div><strong>{spot.catches_7d}</strong><span>за 7 дней</span></div></div>
<ActivityTimeline buckets={timeline}/>
<section class="detail-grid">
@@ -44,3 +44,13 @@ const breadcrumbs = spot ? { "@context": "https://schema.org", "@type": "Breadcr
</section>
</>}
</Layout>
<script is:inline>
document.querySelectorAll<HTMLButtonElement>("[data-copy-coordinates]").forEach((button) => {
button.addEventListener("click", async () => {
const value = button.dataset.copyCoordinates || "";
const status = button.parentElement?.querySelector<HTMLElement>(".copy-status");
try { await navigator.clipboard.writeText(value); if (status) status.textContent = "Скопировано"; }
catch { if (status) status.textContent = value; }
});
});
</script>