diff --git a/src/components/LockedContent.tsx b/src/components/LockedContent.tsx index 3e54903..4569741 100644 --- a/src/components/LockedContent.tsx +++ b/src/components/LockedContent.tsx @@ -89,7 +89,7 @@ const LocationButton = ({ ) } else { return ( -
+
{atTarget ? (
diff --git a/src/components/ShareButton.tsx b/src/components/ShareButton.tsx new file mode 100644 index 0000000..7588240 --- /dev/null +++ b/src/components/ShareButton.tsx @@ -0,0 +1,54 @@ +import { Button } from "./ui/button" + +const ShareButton = () => { + const shareLink = async () => { + const shareData = { + title: "Konulu Konum", + text: "Sevdiklerinizi şaşırtın!", + url: document.URL + } + + await navigator.share(shareData) + } + + const copyLink = async () => { + try { + await navigator.clipboard.writeText(document.URL) + // @ts-ignore + Toastify({ + text: "Konulu konum kopyalandı.", + duration: 3000, + gravity: "top", // `top` or `bottom` + position: "center", // `left`, `center` or `right` + stopOnFocus: true, // Prevents dismissing of toast on hover + style: { + background: "black", + borderRadius: "6px", + margin: "16px" + }, + onClick: function () {} // Callback after click + }).showToast() + } catch (err: any) { + console.error(err.message) + } + } + + return ( +
+ { + //@ts-expect-error navigator is not always defined + window.navigator.share ? ( + + ) : ( + + ) + } +
+ ) +} + +export default ShareButton diff --git a/src/pages/[id].astro b/src/pages/[id].astro index d7c241a..5c359ce 100644 --- a/src/pages/[id].astro +++ b/src/pages/[id].astro @@ -3,7 +3,7 @@ import '@/styles/globals.css'; import '../styles/locked-page.css'; import Layout from '../layouts/Layout.astro'; -import { Button } from '@/components/ui/button'; +import ShareButton from '../components/ShareButton'; import { Card, CardContent, @@ -81,7 +81,7 @@ const dateFromNow = dayjs.utc(data?.created_at).from(dayjs.utc()); >
- +

Fotoğrafın kilidi şu ana dek {data?.unlocked_counter} kez açıldı