From 09e5271dfbfc22e8a4899e25a75e6b604be29f07 Mon Sep 17 00:00:00 2001 From: Michess Date: Tue, 14 Apr 2026 07:49:59 +0200 Subject: [PATCH] feat: redesign homepage layout and fix invite links MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Homepage: Grid-Layout mit 3 Karten (Spiel erstellen, KI, Freunde/Beitreten) statt vertikalem Stack mit Dividers - CreateGame: kompakteres Styling, auf Deutsch, in Primary-Card integriert - Einladungslink: APP_URL statt hardcoded ches.su in GamePage und CopyLink - JoinGame: URL-Parsing für beliebige Domains (nicht nur ches.su) Co-Authored-By: Claude Sonnet 4.6 --- client/src/app/page.tsx | 91 ++++++++++++++--------- client/src/components/game/GamePage.tsx | 12 +-- client/src/components/home/CreateGame.tsx | 30 ++++---- client/src/components/home/JoinGame.tsx | 4 +- client/src/components/user/CopyLink.tsx | 12 +-- client/src/config.ts | 2 +- 6 files changed, 83 insertions(+), 68 deletions(-) diff --git a/client/src/app/page.tsx b/client/src/app/page.tsx index d199083..8ab2d09 100644 --- a/client/src/app/page.tsx +++ b/client/src/app/page.tsx @@ -6,51 +6,74 @@ import PublicGames from "@/components/home/PublicGames/PublicGames"; import Link from "next/link"; import { useSession } from "@/context/session"; - export default function Home() { const { user } = useSession(); + const isLoggedIn = user?.id && typeof user.id === "number"; return ( -
- +
-
+ {/* Hauptaktionen */} +
- {/* Against AI */} -
-

Gegen KI spielen

- - ♟ Gegen Stockfish spielen - -
- -
oder
- - {/* Friends */} - {user?.id && typeof user.id === "number" && ( - <> -
-

Freunde

- - 👥 Freunde verwalten - +
+
+

♟ Spiel erstellen

+

Erstelle eine Partie und teile den Einladungslink mit Freunden

+
+
-
oder
- - )} - -
-

Per Einladung beitreten

- +
-
oder
- -
-

Spiel erstellen

- +
+
+

🤖 Gegen KI spielen

+

Fordere Stockfish auf verschiedenen Stufen heraus — von Anfänger bis Meister

+
+ Jetzt spielen +
+
+ +
+
+ {isLoggedIn ? ( + <> +

👥 Freunde

+

Freunde hinzufügen, verwalten und zu einer Partie einladen

+
+ Freunde verwalten +
+ + ) : ( + <> +

🔗 Einladung annehmen

+

Einladungslink oder Code eingeben um beizutreten

+ + + )} +
+
+
+ + {/* Öffentliche Spiele + Beitreten */} +
+
+ +
+ {isLoggedIn && ( +
+
+

🔗 Einladung annehmen

+

Link oder Code eingeben

+ +
+
+ )} +
+
); } diff --git a/client/src/components/game/GamePage.tsx b/client/src/components/game/GamePage.tsx index 751f118..b97a867 100644 --- a/client/src/components/game/GamePage.tsx +++ b/client/src/components/game/GamePage.tsx @@ -22,7 +22,7 @@ import { Chess } from "chess.js"; import type { ClearPremoves } from "react-chessboard"; import { Chessboard } from "react-chessboard"; -import { API_URL } from "@/config"; +import { API_URL, APP_URL } from "@/config"; import { io } from "socket.io-client"; import { lobbyReducer, squareReducer } from "./reducers"; @@ -408,12 +408,8 @@ export default function GamePage({ initialLobby }: { initialLobby: Game }) { } function copyInvite() { - const text = `https://ches.su/${lobby.endReason ? `archive/${lobby.id}` : initialLobby.code}`; - if ("clipboard" in navigator) { - navigator.clipboard.writeText(text); - } else { - document.execCommand("copy", true, text); - } + const text = `${APP_URL}/${lobby.endReason ? `archive/${lobby.id}` : initialLobby.code}`; + navigator.clipboard.writeText(text).catch(() => {}); setCopiedLink(true); setTimeout(() => { setCopiedLink(false); @@ -586,7 +582,7 @@ export default function GamePage({ initialLobby }: { initialLobby: Game }) { onClick={copyInvite} > - ches.su/{lobby.endReason ? `archive/${lobby.id}` : initialLobby.code} + {APP_URL.replace(/^https?:\/\//, "")}/{lobby.endReason ? `archive/${lobby.id}` : initialLobby.code}
copied to clipboard diff --git a/client/src/components/home/CreateGame.tsx b/client/src/components/home/CreateGame.tsx index 839c08a..547c1aa 100644 --- a/client/src/components/home/CreateGame.tsx +++ b/client/src/components/home/CreateGame.tsx @@ -33,35 +33,35 @@ export default function CreateGame() { } return ( -
-