diff --git a/app/components/BlitzScreen.tsx b/app/components/BlitzScreen.tsx index f66a366..f018d37 100644 --- a/app/components/BlitzScreen.tsx +++ b/app/components/BlitzScreen.tsx @@ -2,6 +2,7 @@ import { useBlitzGame } from "../../lib/useBlitzGame"; import { ArticleView } from "./ArticleView"; +import { ShareBar } from "./ShareBar"; function fmtLeft(s: number): string { const m = Math.floor(s / 60); @@ -67,6 +68,7 @@ export function BlitzScreen({ onBack }: { onBack: () => void }) { ))} +
+ {game.phase === "won" && result && ( + + )} ); diff --git a/app/components/HomeScreen.tsx b/app/components/HomeScreen.tsx index 31432b9..0d0d21e 100644 --- a/app/components/HomeScreen.tsx +++ b/app/components/HomeScreen.tsx @@ -67,9 +67,9 @@ export function HomeScreen({ const today = useDailyStats(); return ( -
+
{/* Topbar */} -
+
@@ -93,6 +93,7 @@ export function HomeScreen({
{/* Hero */} +
{/* Form */} -
+
{error && (
{error} @@ -207,6 +208,7 @@ export function HomeScreen({
+
); } diff --git a/app/components/ShareBar.tsx b/app/components/ShareBar.tsx new file mode 100644 index 0000000..a1e0eae --- /dev/null +++ b/app/components/ShareBar.tsx @@ -0,0 +1,105 @@ +"use client"; + +import { useState } from "react"; + +type ShareBarProps = { + text: string; // texte du tweet/post +}; + +export function ShareBar({ text }: ShareBarProps) { + const [copied, setCopied] = useState(false); + const url = "https://wikirush.xyz"; + const encoded = encodeURIComponent(text + "\n" + url); + + const links = [ + { + label: "X", + href: `https://x.com/intent/tweet?text=${encoded}`, + icon: ( + + + + ), + }, + { + label: "LinkedIn", + href: `https://www.linkedin.com/shareArticle?mini=true&url=${encodeURIComponent(url)}&title=${encodeURIComponent("WikiRush")}&summary=${encodeURIComponent(text)}`, + icon: ( + + + + ), + }, + { + label: "WhatsApp", + href: `https://wa.me/?text=${encoded}`, + icon: ( + + + + ), + }, + ]; + + function copyToClipboard() { + navigator.clipboard.writeText(text + "\n" + url).then(() => { + setCopied(true); + setTimeout(() => setCopied(false), 2000); + }); + } + + return ( +
+ + Partager + +
+ {links.map(({ label, href, icon }) => ( + + {icon} + {label} + + ))} + +
+
+ ); +} diff --git a/app/components/SoloScreen.tsx b/app/components/SoloScreen.tsx index 3e47f2a..c2ce350 100644 --- a/app/components/SoloScreen.tsx +++ b/app/components/SoloScreen.tsx @@ -3,6 +3,7 @@ import { useEffect, useRef } from "react"; import { ArticleView } from "./ArticleView"; import { Breadcrumbs } from "./Breadcrumbs"; +import { ShareBar } from "./ShareBar"; import type { Puzzle } from "../../lib/types"; type SoloPhase = "setup" | "playing" | "won"; @@ -77,6 +78,7 @@ export function SoloScreen({ ))}
+