Spaces:
Running
Running
community route added search users/ get friends find friends friend request block users api implemented.
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- chess-frontend/actions/friend.ts +20 -0
- chess-frontend/app/(protected)/community/_components/blocked-tab.tsx +48 -0
- chess-frontend/app/(protected)/community/_components/community-client.tsx +129 -0
- chess-frontend/app/(protected)/community/_components/community-shared.tsx +277 -0
- chess-frontend/app/(protected)/community/_components/community-types.ts +87 -0
- chess-frontend/app/(protected)/community/_components/find-players-tab.tsx +31 -0
- chess-frontend/app/(protected)/community/_components/friends-tab.tsx +47 -0
- chess-frontend/app/(protected)/community/_components/requests-tab.tsx +61 -0
- chess-frontend/app/(protected)/community/_components/search-users-form.tsx +51 -0
- chess-frontend/app/(protected)/community/page.tsx +36 -0
- chess-frontend/app/(protected)/game/[id]/_components/active-board.tsx +8 -3
- chess-frontend/app/(protected)/game/[id]/_components/game-chat.tsx +98 -0
- chess-frontend/app/(protected)/game/[id]/_components/game-over-overlay.tsx +6 -2
- chess-frontend/app/(protected)/game/[id]/_components/game-sidebar.tsx +3 -0
- chess-frontend/app/(protected)/game/[id]/_components/move-list.tsx +2 -3
- chess-frontend/app/(protected)/game/[id]/_components/player-card.tsx +2 -1
- chess-frontend/app/(protected)/history/_components/game-history-with-board.tsx +1 -22
- chess-frontend/app/(protected)/history/page.tsx +22 -3
- chess-frontend/app/globals.css +16 -15
- chess-frontend/app/layout.tsx +4 -4
- chess-frontend/bun.lock +14 -14
- chess-frontend/components.json +2 -2
- chess-frontend/components/navbar/navlinks.tsx +1 -1
- chess-frontend/components/navbar/user-dropdown.tsx +2 -5
- chess-frontend/components/ui/avatar.tsx +1 -1
- chess-frontend/components/ui/badge.tsx +1 -1
- chess-frontend/components/ui/button.tsx +8 -6
- chess-frontend/components/ui/command.tsx +192 -0
- chess-frontend/components/ui/dialog.tsx +168 -0
- chess-frontend/components/ui/dropdown-menu.tsx +10 -10
- chess-frontend/components/ui/field.tsx +6 -6
- chess-frontend/components/ui/input-group.tsx +156 -0
- chess-frontend/components/ui/input.tsx +1 -1
- chess-frontend/components/ui/label.tsx +1 -1
- chess-frontend/components/ui/sonner.tsx +5 -5
- chess-frontend/components/ui/table.tsx +3 -3
- chess-frontend/components/ui/tabs.tsx +3 -3
- chess-frontend/components/ui/textarea.tsx +18 -0
- chess-frontend/hooks/use-websocket.ts +15 -1
- chess-frontend/lib/constants/get-initials.ts +11 -0
- chess-frontend/lib/constants/safe-fetch.ts +25 -0
- chess-frontend/next.config.ts +1 -3
- chess-frontend/package.json +4 -2
- chess-frontend/store/socket-provider.tsx +11 -4
- chess-frontend/store/use-game-store.ts +15 -0
- chess-frontend/types/auth.ts +39 -41
- chess-frontend/types/chess.ts +38 -0
- chess-frontend/types/friends.ts +22 -0
- chess-frontend/types/history.ts +23 -0
- chess-frontend/types/index.ts +4 -0
chess-frontend/actions/friend.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use server";
|
| 2 |
+
|
| 3 |
+
import { safeFetch } from "@/lib/constants/safe-fetch";
|
| 4 |
+
import { GetFriend, SearchFriend } from "@/types/friends";
|
| 5 |
+
|
| 6 |
+
export async function getFriends(): Promise<GetFriend[] | null> {
|
| 7 |
+
const friends = await safeFetch<GetFriend[]>("/friends?limit=50");
|
| 8 |
+
|
| 9 |
+
if (!friends?.length) return null;
|
| 10 |
+
|
| 11 |
+
return friends;
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
export async function searchUsers(query: string) {
|
| 15 |
+
const result = await safeFetch<SearchFriend[]>(`/friends/search?q=${query}`);
|
| 16 |
+
|
| 17 |
+
if (!result?.length) return null;
|
| 18 |
+
|
| 19 |
+
return result;
|
| 20 |
+
}
|
chess-frontend/app/(protected)/community/_components/blocked-tab.tsx
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { Slash } from "lucide-react";
|
| 2 |
+
import { STUB_BLOCKED } from "./community-types";
|
| 3 |
+
import { PlayerCard } from "./community-shared";
|
| 4 |
+
|
| 5 |
+
export function BlockedTab() {
|
| 6 |
+
return (
|
| 7 |
+
<div className="flex flex-col gap-4">
|
| 8 |
+
{STUB_BLOCKED.length === 0 ? (
|
| 9 |
+
// <EmptyState
|
| 10 |
+
// icon={ShieldOff}
|
| 11 |
+
// title="No STUB_BLOCKED players"
|
| 12 |
+
// sub="Players you block won't be able to send you messages or challenges."
|
| 13 |
+
// />
|
| 14 |
+
<div></div>
|
| 15 |
+
) : (
|
| 16 |
+
<>
|
| 17 |
+
<p
|
| 18 |
+
className="text-xs text-zinc-500"
|
| 19 |
+
style={{ fontFamily: "'Fira Code', monospace" }}
|
| 20 |
+
>
|
| 21 |
+
{STUB_BLOCKED.length} block
|
| 22 |
+
</p>
|
| 23 |
+
<div className="flex flex-col gap-2">
|
| 24 |
+
{STUB_BLOCKED.map((b) => (
|
| 25 |
+
<PlayerCard
|
| 26 |
+
key={b.id}
|
| 27 |
+
player={b}
|
| 28 |
+
actions={
|
| 29 |
+
<button
|
| 30 |
+
className="flex items-center gap-1.5 px-3 h-8 rounded-xl text-xs transition-all hover:bg-red-500/20"
|
| 31 |
+
style={{
|
| 32 |
+
background: "rgba(239,68,68,0.1)",
|
| 33 |
+
color: "#f87171",
|
| 34 |
+
border: "1px solid rgba(239,68,68,0.2)",
|
| 35 |
+
fontFamily: "'Fira Code', monospace",
|
| 36 |
+
}}
|
| 37 |
+
>
|
| 38 |
+
<Slash size={11} /> Unblock
|
| 39 |
+
</button>
|
| 40 |
+
}
|
| 41 |
+
/>
|
| 42 |
+
))}
|
| 43 |
+
</div>
|
| 44 |
+
</>
|
| 45 |
+
)}
|
| 46 |
+
</div>
|
| 47 |
+
);
|
| 48 |
+
}
|
chess-frontend/app/(protected)/community/_components/community-client.tsx
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client";
|
| 2 |
+
|
| 3 |
+
import { Users, Search, Bell, UserX } from "lucide-react";
|
| 4 |
+
import { motion } from "framer-motion";
|
| 5 |
+
|
| 6 |
+
import { STUB_FRIENDS, STUB_REQUESTS, STUB_BLOCKED } from "./community-types";
|
| 7 |
+
import { FriendsTab } from "./friends-tab";
|
| 8 |
+
import { FindPlayersTab } from "./find-players-tab";
|
| 9 |
+
import { RequestsTab } from "./requests-tab";
|
| 10 |
+
import { BlockedTab } from "./blocked-tab";
|
| 11 |
+
import { cn } from "@/lib/utils";
|
| 12 |
+
import { usePathname, useRouter, useSearchParams } from "next/navigation";
|
| 13 |
+
|
| 14 |
+
const TABS = [
|
| 15 |
+
{
|
| 16 |
+
id: "friends",
|
| 17 |
+
label: "Friends",
|
| 18 |
+
icon: Users,
|
| 19 |
+
badge: STUB_FRIENDS.length,
|
| 20 |
+
content: FriendsTab,
|
| 21 |
+
},
|
| 22 |
+
{
|
| 23 |
+
id: "find",
|
| 24 |
+
label: "Find Players",
|
| 25 |
+
icon: Search,
|
| 26 |
+
badge: null,
|
| 27 |
+
content: FindPlayersTab,
|
| 28 |
+
},
|
| 29 |
+
{
|
| 30 |
+
id: "requests",
|
| 31 |
+
label: "Requests",
|
| 32 |
+
icon: Bell,
|
| 33 |
+
badge: STUB_REQUESTS.length,
|
| 34 |
+
content: RequestsTab,
|
| 35 |
+
},
|
| 36 |
+
{
|
| 37 |
+
id: "blocked",
|
| 38 |
+
label: "Blocked",
|
| 39 |
+
icon: UserX,
|
| 40 |
+
badge: STUB_BLOCKED.length > 0 ? STUB_BLOCKED.length : null,
|
| 41 |
+
content: BlockedTab,
|
| 42 |
+
},
|
| 43 |
+
] as const;
|
| 44 |
+
|
| 45 |
+
export function CommunityNav({ active }: { active: string }) {
|
| 46 |
+
const router = useRouter();
|
| 47 |
+
const pathname = usePathname();
|
| 48 |
+
const searchParams = useSearchParams();
|
| 49 |
+
|
| 50 |
+
const handleTabChange = (id: string) => {
|
| 51 |
+
const params = new URLSearchParams(searchParams);
|
| 52 |
+
params.set("tab", id);
|
| 53 |
+
router.replace(`${pathname}?${params.toString()}`);
|
| 54 |
+
};
|
| 55 |
+
return (
|
| 56 |
+
<>
|
| 57 |
+
<div className="mb-8">
|
| 58 |
+
<h1
|
| 59 |
+
className="text-2xl font-bold text-white tracking-tight mb-1"
|
| 60 |
+
style={{
|
| 61 |
+
fontFamily: "'DM Sans', sans-serif",
|
| 62 |
+
letterSpacing: "-0.03em",
|
| 63 |
+
}}
|
| 64 |
+
>
|
| 65 |
+
Community
|
| 66 |
+
</h1>
|
| 67 |
+
<p className="text-sm text-zinc-500">
|
| 68 |
+
Manage your connections, discover players, handle requests.
|
| 69 |
+
</p>
|
| 70 |
+
</div>
|
| 71 |
+
<div
|
| 72 |
+
className="flex gap-1 p-1 rounded-2xl mb-6"
|
| 73 |
+
style={{
|
| 74 |
+
background: "rgba(255,255,255,0.04)",
|
| 75 |
+
border: "1px solid rgba(255,255,255,0.07)",
|
| 76 |
+
}}
|
| 77 |
+
>
|
| 78 |
+
{TABS.map(({ id, label, icon: Icon, badge }) => {
|
| 79 |
+
const isActive = active === id;
|
| 80 |
+
return (
|
| 81 |
+
<button
|
| 82 |
+
key={id}
|
| 83 |
+
onClick={() => handleTabChange(id)}
|
| 84 |
+
className={cn(
|
| 85 |
+
"relative rounded-full px-3 py-1.5 text-sm font-semibold text-white outline-sky-400 transition focus-visible:outline-2 flex-1 flex items-center justify-center gap-1.5 h-9 cursor-pointer",
|
| 86 |
+
active === id ? "" : "hover:text-white/60",
|
| 87 |
+
)}
|
| 88 |
+
style={{
|
| 89 |
+
WebkitTapHighlightColor: "transparent",
|
| 90 |
+
}}
|
| 91 |
+
>
|
| 92 |
+
{active === id && (
|
| 93 |
+
<motion.span
|
| 94 |
+
layoutId="bubble"
|
| 95 |
+
className="absolute inset-0 z-10 bg-white mix-blend-difference"
|
| 96 |
+
style={{
|
| 97 |
+
borderRadius: 9999,
|
| 98 |
+
background: isActive
|
| 99 |
+
? "rgba(255,255,255,0.1)"
|
| 100 |
+
: "transparent",
|
| 101 |
+
fontFamily: "'DM Sans', sans-serif",
|
| 102 |
+
border: isActive
|
| 103 |
+
? "1px solid rgba(255,255,255,0.12)"
|
| 104 |
+
: "1px solid transparent",
|
| 105 |
+
}}
|
| 106 |
+
transition={{ type: "spring", bounce: 0.2, duration: 0.6 }}
|
| 107 |
+
/>
|
| 108 |
+
)}
|
| 109 |
+
<Icon size={13} />
|
| 110 |
+
<span className="hidden sm:inline">{label}</span>
|
| 111 |
+
{badge != null && badge > 0 && (
|
| 112 |
+
<span
|
| 113 |
+
className="absolute -top-1 -right-1 min-w-4 h-4 rounded-full flex items-center justify-center text-[9px] font-bold px-1"
|
| 114 |
+
style={{
|
| 115 |
+
background:
|
| 116 |
+
id === "requests" ? "#f97316" : "rgba(255,255,255,0.15)",
|
| 117 |
+
color: id === "requests" ? "#fff" : "#a1a1aa",
|
| 118 |
+
}}
|
| 119 |
+
>
|
| 120 |
+
{badge}
|
| 121 |
+
</span>
|
| 122 |
+
)}
|
| 123 |
+
</button>
|
| 124 |
+
);
|
| 125 |
+
})}
|
| 126 |
+
</div>
|
| 127 |
+
</>
|
| 128 |
+
);
|
| 129 |
+
}
|
chess-frontend/app/(protected)/community/_components/community-shared.tsx
ADDED
|
@@ -0,0 +1,277 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { Check, Search, Swords, Trophy, UserPlus, UserX } from "lucide-react";
|
| 2 |
+
import { getInitials } from "@/lib/constants/get-initials";
|
| 3 |
+
import { GetFriend, SearchFriend } from "@/types/friends";
|
| 4 |
+
|
| 5 |
+
export function getAvatarHue(name: string) {
|
| 6 |
+
return [...name].reduce((a, c) => a + c.charCodeAt(0), 0) % 360;
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
export function winRate(w: number, l: number, d: number) {
|
| 10 |
+
const t = w + l + d;
|
| 11 |
+
return t === 0 ? 0 : Math.round((w / t) * 100);
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
export function Avatar({
|
| 15 |
+
player,
|
| 16 |
+
size = 40,
|
| 17 |
+
}: {
|
| 18 |
+
player: {
|
| 19 |
+
name: string;
|
| 20 |
+
image: string | null;
|
| 21 |
+
};
|
| 22 |
+
size?: number;
|
| 23 |
+
}) {
|
| 24 |
+
const hue = getAvatarHue(player.name);
|
| 25 |
+
return (
|
| 26 |
+
<div className="relative shrink-0" style={{ width: size, height: size }}>
|
| 27 |
+
<div
|
| 28 |
+
className="rounded-full flex items-center justify-center font-bold text-xs"
|
| 29 |
+
style={{
|
| 30 |
+
width: size,
|
| 31 |
+
height: size,
|
| 32 |
+
background: player.image ? undefined : `hsl(${hue},45%,32%)`,
|
| 33 |
+
color: `hsl(${hue},80%,82%)`,
|
| 34 |
+
fontFamily: "'Fira Code', monospace",
|
| 35 |
+
overflow: "hidden",
|
| 36 |
+
}}
|
| 37 |
+
>
|
| 38 |
+
{player.image ? (
|
| 39 |
+
<img
|
| 40 |
+
src={player.image}
|
| 41 |
+
alt={player.name}
|
| 42 |
+
className="w-full h-full object-cover"
|
| 43 |
+
/>
|
| 44 |
+
) : (
|
| 45 |
+
getInitials(player.name)
|
| 46 |
+
)}
|
| 47 |
+
</div>
|
| 48 |
+
{/* {player.online !== undefined && (
|
| 49 |
+
<span
|
| 50 |
+
className="absolute bottom-0 right-0 rounded-full border-2"
|
| 51 |
+
style={{
|
| 52 |
+
width: size * 0.28,
|
| 53 |
+
height: size * 0.28,
|
| 54 |
+
background: player.online ? "#22c55e" : "#52525b",
|
| 55 |
+
borderColor: "#0d0d10",
|
| 56 |
+
}}
|
| 57 |
+
/>
|
| 58 |
+
)} */}
|
| 59 |
+
</div>
|
| 60 |
+
);
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
export function StatBar({
|
| 64 |
+
wins,
|
| 65 |
+
losses,
|
| 66 |
+
draws,
|
| 67 |
+
}: {
|
| 68 |
+
wins: number;
|
| 69 |
+
losses: number;
|
| 70 |
+
draws: number;
|
| 71 |
+
}) {
|
| 72 |
+
const t = wins + losses + draws || 1;
|
| 73 |
+
return (
|
| 74 |
+
<div className="flex gap-0.5 h-1 w-full rounded-full overflow-hidden">
|
| 75 |
+
<div style={{ width: `${(wins / t) * 100}%`, background: "#22c55e" }} />
|
| 76 |
+
<div style={{ width: `${(draws / t) * 100}%`, background: "#eab308" }} />
|
| 77 |
+
<div style={{ width: `${(losses / t) * 100}%`, background: "#ef4444" }} />
|
| 78 |
+
</div>
|
| 79 |
+
);
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
export function FriendCard({
|
| 83 |
+
player,
|
| 84 |
+
actions,
|
| 85 |
+
}: {
|
| 86 |
+
player: GetFriend;
|
| 87 |
+
actions: React.ReactNode;
|
| 88 |
+
}) {
|
| 89 |
+
return (
|
| 90 |
+
<div
|
| 91 |
+
className="flex items-center gap-3 px-4 py-3 rounded-2xl group transition-all duration-150"
|
| 92 |
+
style={{
|
| 93 |
+
background: "rgba(255,255,255,0.03)",
|
| 94 |
+
border: "1px solid rgba(255,255,255,0.06)",
|
| 95 |
+
}}
|
| 96 |
+
>
|
| 97 |
+
<Avatar
|
| 98 |
+
player={{
|
| 99 |
+
name: player.name,
|
| 100 |
+
image: player.image,
|
| 101 |
+
}}
|
| 102 |
+
size={44}
|
| 103 |
+
/>
|
| 104 |
+
|
| 105 |
+
<div className="flex-1 min-w-0 flex flex-col gap-1">
|
| 106 |
+
<div className="flex items-baseline gap-2">
|
| 107 |
+
<span
|
| 108 |
+
className="text-sm font-semibold text-white truncate"
|
| 109 |
+
style={{ fontFamily: "'DM Sans', sans-serif" }}
|
| 110 |
+
>
|
| 111 |
+
{player.name}
|
| 112 |
+
</span>
|
| 113 |
+
<span
|
| 114 |
+
className="text-[11px] text-zinc-500 truncate"
|
| 115 |
+
style={{ fontFamily: "'Fira Code', monospace" }}
|
| 116 |
+
>
|
| 117 |
+
@{player.username}
|
| 118 |
+
</span>
|
| 119 |
+
</div>
|
| 120 |
+
<div className="flex items-center gap-2">
|
| 121 |
+
<div className="flex items-center gap-1">
|
| 122 |
+
<Trophy size={10} className="text-amber-400" />
|
| 123 |
+
<span
|
| 124 |
+
className="text-xs font-bold text-amber-400"
|
| 125 |
+
style={{ fontFamily: "'Fira Code', monospace" }}
|
| 126 |
+
>
|
| 127 |
+
{player.rating}
|
| 128 |
+
</span>
|
| 129 |
+
</div>
|
| 130 |
+
<span className="text-zinc-700 text-xs">·</span>
|
| 131 |
+
<span
|
| 132 |
+
className="text-[11px] text-zinc-500"
|
| 133 |
+
style={{ fontFamily: "'Fira Code', monospace" }}
|
| 134 |
+
>
|
| 135 |
+
{winRate(player.wins, player.losses, player.draws)}% WR
|
| 136 |
+
</span>
|
| 137 |
+
</div>
|
| 138 |
+
<StatBar
|
| 139 |
+
wins={player.wins}
|
| 140 |
+
losses={player.losses}
|
| 141 |
+
draws={player.draws}
|
| 142 |
+
/>
|
| 143 |
+
</div>
|
| 144 |
+
|
| 145 |
+
<div className="flex items-center gap-1.5 shrink-0">{actions}</div>
|
| 146 |
+
</div>
|
| 147 |
+
);
|
| 148 |
+
}
|
| 149 |
+
export function PlayerCard({ player }: { player: SearchFriend }) {
|
| 150 |
+
return (
|
| 151 |
+
<div
|
| 152 |
+
className="flex items-center gap-3 px-4 py-3 rounded-2xl group transition-all duration-150"
|
| 153 |
+
style={{
|
| 154 |
+
background: "rgba(255,255,255,0.03)",
|
| 155 |
+
border: "1px solid rgba(255,255,255,0.06)",
|
| 156 |
+
}}
|
| 157 |
+
>
|
| 158 |
+
<Avatar
|
| 159 |
+
player={{
|
| 160 |
+
name: player.name,
|
| 161 |
+
image: player.image,
|
| 162 |
+
}}
|
| 163 |
+
size={44}
|
| 164 |
+
/>
|
| 165 |
+
|
| 166 |
+
<div className="flex-1 min-w-0 flex flex-col gap-1">
|
| 167 |
+
<div className="flex items-baseline gap-2">
|
| 168 |
+
<span
|
| 169 |
+
className="text-sm font-semibold text-white truncate"
|
| 170 |
+
style={{ fontFamily: "'DM Sans', sans-serif" }}
|
| 171 |
+
>
|
| 172 |
+
{player.name}
|
| 173 |
+
</span>
|
| 174 |
+
<span
|
| 175 |
+
className="text-[11px] text-zinc-500 truncate"
|
| 176 |
+
style={{ fontFamily: "'Fira Code', monospace" }}
|
| 177 |
+
>
|
| 178 |
+
@{player.username}
|
| 179 |
+
</span>
|
| 180 |
+
</div>
|
| 181 |
+
<div className="flex items-center gap-2">
|
| 182 |
+
<div className="flex items-center gap-1">
|
| 183 |
+
<Trophy size={10} className="text-amber-400" />
|
| 184 |
+
<span
|
| 185 |
+
className="text-xs font-bold text-amber-400"
|
| 186 |
+
style={{ fontFamily: "'Fira Code', monospace" }}
|
| 187 |
+
>
|
| 188 |
+
{player.rating}
|
| 189 |
+
</span>
|
| 190 |
+
</div>
|
| 191 |
+
<span className="text-zinc-700 text-xs">·</span>
|
| 192 |
+
</div>
|
| 193 |
+
</div>
|
| 194 |
+
|
| 195 |
+
<div className="flex items-center gap-1.5 shrink-0">
|
| 196 |
+
<IconBtn icon={Swords} label="Challenge to game" variant="amber" />
|
| 197 |
+
<IconBtn icon={UserPlus} label="Send friend request" variant="green" />
|
| 198 |
+
<IconBtn icon={UserX} label="Block user" variant="red" />
|
| 199 |
+
</div>
|
| 200 |
+
</div>
|
| 201 |
+
);
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
export function IconBtn({
|
| 205 |
+
icon: Icon,
|
| 206 |
+
label,
|
| 207 |
+
variant = "default",
|
| 208 |
+
}: {
|
| 209 |
+
icon: React.ElementType;
|
| 210 |
+
label: string;
|
| 211 |
+
onClick?: () => void;
|
| 212 |
+
variant?: "default" | "green" | "red" | "amber";
|
| 213 |
+
}) {
|
| 214 |
+
const colors = {
|
| 215 |
+
default: {
|
| 216 |
+
bg: "rgba(255,255,255,0.07)",
|
| 217 |
+
hover: "rgba(255,255,255,0.13)",
|
| 218 |
+
color: "#a1a1aa",
|
| 219 |
+
},
|
| 220 |
+
green: {
|
| 221 |
+
bg: "rgba(34,197,94,0.12)",
|
| 222 |
+
hover: "rgba(34,197,94,0.22)",
|
| 223 |
+
color: "#4ade80",
|
| 224 |
+
},
|
| 225 |
+
red: {
|
| 226 |
+
bg: "rgba(239,68,68,0.1)",
|
| 227 |
+
hover: "rgba(239,68,68,0.2)",
|
| 228 |
+
color: "#f87171",
|
| 229 |
+
},
|
| 230 |
+
amber: {
|
| 231 |
+
bg: "rgba(234,179,8,0.1)",
|
| 232 |
+
hover: "rgba(234,179,8,0.2)",
|
| 233 |
+
color: "#fbbf24",
|
| 234 |
+
},
|
| 235 |
+
}[variant];
|
| 236 |
+
|
| 237 |
+
return (
|
| 238 |
+
<button
|
| 239 |
+
title={label}
|
| 240 |
+
className="w-8 h-8 rounded-xl flex items-center justify-center transition-all duration-150"
|
| 241 |
+
style={{
|
| 242 |
+
background: false ? colors.hover : colors.bg,
|
| 243 |
+
color: colors.color,
|
| 244 |
+
}}
|
| 245 |
+
>
|
| 246 |
+
<Icon size={14} />
|
| 247 |
+
</button>
|
| 248 |
+
);
|
| 249 |
+
}
|
| 250 |
+
|
| 251 |
+
export function EmptyState({
|
| 252 |
+
icon: Icon,
|
| 253 |
+
title,
|
| 254 |
+
sub,
|
| 255 |
+
}: {
|
| 256 |
+
icon: React.ElementType;
|
| 257 |
+
title: string;
|
| 258 |
+
sub: string;
|
| 259 |
+
}) {
|
| 260 |
+
return (
|
| 261 |
+
<div className="flex flex-col items-center gap-3 py-16">
|
| 262 |
+
<div
|
| 263 |
+
className="w-14 h-14 rounded-2xl flex items-center justify-center"
|
| 264 |
+
style={{ background: "rgba(255,255,255,0.04)" }}
|
| 265 |
+
>
|
| 266 |
+
<Icon size={24} className="text-zinc-600" />
|
| 267 |
+
</div>
|
| 268 |
+
<p
|
| 269 |
+
className="text-sm font-semibold text-zinc-400"
|
| 270 |
+
style={{ fontFamily: "'DM Sans', sans-serif" }}
|
| 271 |
+
>
|
| 272 |
+
{title}
|
| 273 |
+
</p>
|
| 274 |
+
<p className="text-xs text-zinc-600 text-center max-w-55">{sub}</p>
|
| 275 |
+
</div>
|
| 276 |
+
);
|
| 277 |
+
}
|
chess-frontend/app/(protected)/community/_components/community-types.ts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { GetFriend } from "@/types/friends";
|
| 2 |
+
|
| 3 |
+
export const STUB_FRIENDS: GetFriend[] = [
|
| 4 |
+
{
|
| 5 |
+
id: "1",
|
| 6 |
+
name: "Arjun Mehta",
|
| 7 |
+
username: "arjunm99",
|
| 8 |
+
rating: 1420,
|
| 9 |
+
wins: 88,
|
| 10 |
+
losses: 44,
|
| 11 |
+
draws: 12,
|
| 12 |
+
image: null,
|
| 13 |
+
createdAt: new Date(),
|
| 14 |
+
},
|
| 15 |
+
{
|
| 16 |
+
id: "2",
|
| 17 |
+
name: "Priya Singh",
|
| 18 |
+
username: "priyaS",
|
| 19 |
+
rating: 1105,
|
| 20 |
+
wins: 34,
|
| 21 |
+
losses: 21,
|
| 22 |
+
draws: 5,
|
| 23 |
+
image: null,
|
| 24 |
+
createdAt: new Date(),
|
| 25 |
+
},
|
| 26 |
+
{
|
| 27 |
+
id: "3",
|
| 28 |
+
name: "Rohit Tomar",
|
| 29 |
+
username: "tomarrohit3240",
|
| 30 |
+
rating: 979,
|
| 31 |
+
wins: 10,
|
| 32 |
+
losses: 28,
|
| 33 |
+
draws: 6,
|
| 34 |
+
image: null,
|
| 35 |
+
createdAt: new Date(),
|
| 36 |
+
},
|
| 37 |
+
{
|
| 38 |
+
id: "4",
|
| 39 |
+
name: "Sneha Verma",
|
| 40 |
+
username: "sneha_v",
|
| 41 |
+
rating: 1680,
|
| 42 |
+
wins: 201,
|
| 43 |
+
losses: 77,
|
| 44 |
+
draws: 33,
|
| 45 |
+
image: null,
|
| 46 |
+
createdAt: new Date(),
|
| 47 |
+
},
|
| 48 |
+
];
|
| 49 |
+
|
| 50 |
+
export const STUB_REQUESTS: GetFriend[] = [
|
| 51 |
+
{
|
| 52 |
+
id: "5",
|
| 53 |
+
name: "Karan Nair",
|
| 54 |
+
username: "knair_chess",
|
| 55 |
+
rating: 1250,
|
| 56 |
+
wins: 55,
|
| 57 |
+
losses: 40,
|
| 58 |
+
draws: 8,
|
| 59 |
+
image: null,
|
| 60 |
+
createdAt: new Date(),
|
| 61 |
+
},
|
| 62 |
+
{
|
| 63 |
+
id: "6",
|
| 64 |
+
name: "Divya Patel",
|
| 65 |
+
username: "div_patel",
|
| 66 |
+
rating: 870,
|
| 67 |
+
wins: 12,
|
| 68 |
+
losses: 18,
|
| 69 |
+
draws: 2,
|
| 70 |
+
image: null,
|
| 71 |
+
createdAt: new Date(),
|
| 72 |
+
},
|
| 73 |
+
];
|
| 74 |
+
|
| 75 |
+
export const STUB_BLOCKED: GetFriend[] = [
|
| 76 |
+
{
|
| 77 |
+
id: "7",
|
| 78 |
+
name: "Toxic GM",
|
| 79 |
+
username: "toxicgm123",
|
| 80 |
+
rating: 2100,
|
| 81 |
+
wins: 500,
|
| 82 |
+
losses: 10,
|
| 83 |
+
draws: 5,
|
| 84 |
+
image: null,
|
| 85 |
+
createdAt: new Date(),
|
| 86 |
+
},
|
| 87 |
+
];
|
chess-frontend/app/(protected)/community/_components/find-players-tab.tsx
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { EmptyState, PlayerCard } from "./community-shared";
|
| 2 |
+
import { searchUsers } from "@/actions/friend";
|
| 3 |
+
import { SearchUsersForm } from "./search-users-form";
|
| 4 |
+
import { Search } from "lucide-react";
|
| 5 |
+
|
| 6 |
+
export async function FindPlayersTab({ query }: { query: string }) {
|
| 7 |
+
const results = query ? await searchUsers(query) : null;
|
| 8 |
+
|
| 9 |
+
return (
|
| 10 |
+
<div className="flex flex-col gap-4">
|
| 11 |
+
<SearchUsersForm query={query} placeholder="Type the name or username" />
|
| 12 |
+
{!query ? (
|
| 13 |
+
<div className="text-center py-10 text-zinc-500">
|
| 14 |
+
Type a name or username to search all players.
|
| 15 |
+
</div>
|
| 16 |
+
) : !results ? (
|
| 17 |
+
<EmptyState
|
| 18 |
+
icon={Search}
|
| 19 |
+
title="No results found"
|
| 20 |
+
sub={`No users match "${query}". Try a different name or username.`}
|
| 21 |
+
/>
|
| 22 |
+
) : (
|
| 23 |
+
<div className="flex flex-col gap-2">
|
| 24 |
+
{results.map((p) => (
|
| 25 |
+
<PlayerCard key={p.id} player={p} />
|
| 26 |
+
))}
|
| 27 |
+
</div>
|
| 28 |
+
)}
|
| 29 |
+
</div>
|
| 30 |
+
);
|
| 31 |
+
}
|
chess-frontend/app/(protected)/community/_components/friends-tab.tsx
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { Swords, MessageSquare, UserMinus, Users } from "lucide-react";
|
| 2 |
+
import {
|
| 3 |
+
PlayerCard,
|
| 4 |
+
IconBtn,
|
| 5 |
+
EmptyState,
|
| 6 |
+
FriendCard,
|
| 7 |
+
} from "./community-shared";
|
| 8 |
+
import { getFriends } from "@/actions/friend";
|
| 9 |
+
import { SearchUsersForm } from "./search-users-form";
|
| 10 |
+
|
| 11 |
+
export async function FriendsTab({ query }: { query: string }) {
|
| 12 |
+
const friends = await getFriends();
|
| 13 |
+
|
| 14 |
+
return (
|
| 15 |
+
<div className="flex flex-col gap-4">
|
| 16 |
+
<SearchUsersForm query={query} placeholder="Find friend" />
|
| 17 |
+
{!friends ? (
|
| 18 |
+
<EmptyState
|
| 19 |
+
icon={Users}
|
| 20 |
+
title="No friends yet"
|
| 21 |
+
sub="Search for players and send friend requests to get started."
|
| 22 |
+
/>
|
| 23 |
+
) : (
|
| 24 |
+
<div className="flex flex-col gap-2">
|
| 25 |
+
{friends.map((f) => (
|
| 26 |
+
<FriendCard
|
| 27 |
+
key={f.id}
|
| 28 |
+
player={f}
|
| 29 |
+
actions={
|
| 30 |
+
<>
|
| 31 |
+
<IconBtn icon={Swords} label="Challenge" variant="amber" />
|
| 32 |
+
<IconBtn icon={MessageSquare} label="Message" />
|
| 33 |
+
<IconBtn
|
| 34 |
+
icon={UserMinus}
|
| 35 |
+
label="Remove friend"
|
| 36 |
+
variant="red"
|
| 37 |
+
// onClick={() => removeFriend(f.id)}
|
| 38 |
+
/>
|
| 39 |
+
</>
|
| 40 |
+
}
|
| 41 |
+
/>
|
| 42 |
+
))}
|
| 43 |
+
</div>
|
| 44 |
+
)}
|
| 45 |
+
</div>
|
| 46 |
+
);
|
| 47 |
+
}
|
chess-frontend/app/(protected)/community/_components/requests-tab.tsx
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client";
|
| 2 |
+
|
| 3 |
+
import * as React from "react";
|
| 4 |
+
import { Bell, Check, X } from "lucide-react";
|
| 5 |
+
import { STUB_REQUESTS } from "./community-types";
|
| 6 |
+
import { EmptyState, PlayerCard, IconBtn } from "./community-shared";
|
| 7 |
+
|
| 8 |
+
export function RequestsTab() {
|
| 9 |
+
const [requests, setRequests] = React.useState(STUB_REQUESTS);
|
| 10 |
+
|
| 11 |
+
const accept = (id: string) =>
|
| 12 |
+
setRequests((p) => p.filter((r) => r.id !== id));
|
| 13 |
+
const decline = (id: string) =>
|
| 14 |
+
setRequests((p) => p.filter((r) => r.id !== id));
|
| 15 |
+
|
| 16 |
+
return (
|
| 17 |
+
<div className="flex flex-col gap-4">
|
| 18 |
+
{requests.length === 0 ? (
|
| 19 |
+
// <EmptyState
|
| 20 |
+
// icon={Bell}
|
| 21 |
+
// title="No pending requests"
|
| 22 |
+
// sub="When someone sends you a friend request, it'll show up here."
|
| 23 |
+
// />
|
| 24 |
+
<div></div>
|
| 25 |
+
) : (
|
| 26 |
+
<>
|
| 27 |
+
<p
|
| 28 |
+
className="text-xs text-zinc-500"
|
| 29 |
+
style={{ fontFamily: "'Fira Code', monospace" }}
|
| 30 |
+
>
|
| 31 |
+
{requests.length} pending
|
| 32 |
+
</p>
|
| 33 |
+
<div className="flex flex-col gap-2">
|
| 34 |
+
{/* {requests.map((r) => (
|
| 35 |
+
<PlayerCard
|
| 36 |
+
key={r.id}
|
| 37 |
+
player={r}
|
| 38 |
+
actions={
|
| 39 |
+
<>
|
| 40 |
+
<IconBtn
|
| 41 |
+
icon={Check}
|
| 42 |
+
label="Accept"
|
| 43 |
+
variant="green"
|
| 44 |
+
onClick={() => accept(r.id)}
|
| 45 |
+
/>
|
| 46 |
+
<IconBtn
|
| 47 |
+
icon={X}
|
| 48 |
+
label="Decline"
|
| 49 |
+
variant="red"
|
| 50 |
+
onClick={() => decline(r.id)}
|
| 51 |
+
/>
|
| 52 |
+
</>
|
| 53 |
+
}
|
| 54 |
+
/>
|
| 55 |
+
))} */}
|
| 56 |
+
</div>
|
| 57 |
+
</>
|
| 58 |
+
)}
|
| 59 |
+
</div>
|
| 60 |
+
);
|
| 61 |
+
}
|
chess-frontend/app/(protected)/community/_components/search-users-form.tsx
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client";
|
| 2 |
+
|
| 3 |
+
import { Search } from "lucide-react";
|
| 4 |
+
import { usePathname, useRouter, useSearchParams } from "next/navigation";
|
| 5 |
+
import { useState } from "react";
|
| 6 |
+
|
| 7 |
+
export function SearchUsersForm({
|
| 8 |
+
placeholder,
|
| 9 |
+
query,
|
| 10 |
+
}: {
|
| 11 |
+
placeholder: string;
|
| 12 |
+
query: string;
|
| 13 |
+
}) {
|
| 14 |
+
const router = useRouter();
|
| 15 |
+
const pathname = usePathname();
|
| 16 |
+
const searchParams = useSearchParams();
|
| 17 |
+
|
| 18 |
+
const [text, setText] = useState(query);
|
| 19 |
+
|
| 20 |
+
const handleSubmit = (e: React.SubmitEvent<HTMLFormElement>) => {
|
| 21 |
+
e.preventDefault();
|
| 22 |
+
const params = new URLSearchParams(searchParams);
|
| 23 |
+
if (text) {
|
| 24 |
+
params.set("q", text);
|
| 25 |
+
} else {
|
| 26 |
+
params.delete("q");
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
router.replace(`${pathname}?${params.toString()}`, { scroll: false });
|
| 30 |
+
};
|
| 31 |
+
|
| 32 |
+
return (
|
| 33 |
+
<form className="relative" onSubmit={handleSubmit}>
|
| 34 |
+
<Search
|
| 35 |
+
size={13}
|
| 36 |
+
className="absolute left-3 top-1/2 -translate-y-1/2 text-zinc-600 pointer-events-none"
|
| 37 |
+
/>
|
| 38 |
+
<input
|
| 39 |
+
placeholder={placeholder}
|
| 40 |
+
className="w-full h-10 rounded-xl pl-9 pr-4 text-sm text-white placeholder:text-zinc-600 outline-none transition-all"
|
| 41 |
+
onChange={(e) => setText(e.target.value)}
|
| 42 |
+
value={text}
|
| 43 |
+
style={{
|
| 44 |
+
background: "rgba(255,255,255,0.05)",
|
| 45 |
+
border: "1px solid rgba(255,255,255,0.08)",
|
| 46 |
+
fontFamily: "'DM Sans', sans-serif",
|
| 47 |
+
}}
|
| 48 |
+
/>
|
| 49 |
+
</form>
|
| 50 |
+
);
|
| 51 |
+
}
|
chess-frontend/app/(protected)/community/page.tsx
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { getFriends } from "@/actions/friend";
|
| 2 |
+
import { BlockedTab } from "./_components/blocked-tab";
|
| 3 |
+
import { CommunityNav } from "./_components/community-client";
|
| 4 |
+
import { FindPlayersTab } from "./_components/find-players-tab";
|
| 5 |
+
import { FriendsTab } from "./_components/friends-tab";
|
| 6 |
+
import { RequestsTab } from "./_components/requests-tab";
|
| 7 |
+
|
| 8 |
+
export default async function CommunityPage({
|
| 9 |
+
searchParams,
|
| 10 |
+
}: {
|
| 11 |
+
searchParams: Promise<{ tab?: string; q: string }>;
|
| 12 |
+
}) {
|
| 13 |
+
const { tab, q } = await searchParams;
|
| 14 |
+
const active = tab || "friends";
|
| 15 |
+
const query = q || "";
|
| 16 |
+
|
| 17 |
+
return (
|
| 18 |
+
<div
|
| 19 |
+
className="min-h-screen w-full"
|
| 20 |
+
style={{
|
| 21 |
+
background: "#0d0d10",
|
| 22 |
+
fontFamily: "'DM Sans', sans-serif",
|
| 23 |
+
}}
|
| 24 |
+
>
|
| 25 |
+
<div className="fixed inset-0 pointer-events-none opacity-[0.025]" />
|
| 26 |
+
<div className="relative max-w-2xl mx-auto px-4 py-10">
|
| 27 |
+
<CommunityNav active={active} />
|
| 28 |
+
|
| 29 |
+
{active === "friends" && <FriendsTab query={query} />}
|
| 30 |
+
{active === "find" && <FindPlayersTab query={query} />}
|
| 31 |
+
{active === "requests" && <RequestsTab />}
|
| 32 |
+
{active === "blocked" && <BlockedTab />}
|
| 33 |
+
</div>
|
| 34 |
+
</div>
|
| 35 |
+
);
|
| 36 |
+
}
|
chess-frontend/app/(protected)/game/[id]/_components/active-board.tsx
CHANGED
|
@@ -65,16 +65,18 @@ export function ActiveBoard({
|
|
| 65 |
{promotionMove && (
|
| 66 |
<>
|
| 67 |
<div
|
| 68 |
-
className="absolute inset-0 z-40
|
| 69 |
onClick={() => setPromotionMove(null)}
|
| 70 |
onContextMenu={(e) => {
|
| 71 |
e.preventDefault();
|
| 72 |
setPromotionMove(null);
|
| 73 |
}}
|
|
|
|
| 74 |
/>
|
| 75 |
<div
|
| 76 |
-
className="absolute z-50 flex flex-col
|
| 77 |
style={{
|
|
|
|
| 78 |
top: 0,
|
| 79 |
left: `${
|
| 80 |
isWhite
|
|
@@ -103,7 +105,10 @@ export function ActiveBoard({
|
|
| 103 |
)}
|
| 104 |
|
| 105 |
{lastMoveRejectedReason && (
|
| 106 |
-
<div
|
|
|
|
|
|
|
|
|
|
| 107 |
{lastMoveRejectedReason}
|
| 108 |
</div>
|
| 109 |
)}
|
|
|
|
| 65 |
{promotionMove && (
|
| 66 |
<>
|
| 67 |
<div
|
| 68 |
+
className="absolute inset-0 z-40"
|
| 69 |
onClick={() => setPromotionMove(null)}
|
| 70 |
onContextMenu={(e) => {
|
| 71 |
e.preventDefault();
|
| 72 |
setPromotionMove(null);
|
| 73 |
}}
|
| 74 |
+
style={{ backgroundColor: "rgba(0, 0, 0, 0.2)" }}
|
| 75 |
/>
|
| 76 |
<div
|
| 77 |
+
className="absolute z-50 flex flex-col shadow-2xl rounded overflow-hidden"
|
| 78 |
style={{
|
| 79 |
+
backgroundColor: "#f4f4f5", // zinc-100
|
| 80 |
top: 0,
|
| 81 |
left: `${
|
| 82 |
isWhite
|
|
|
|
| 105 |
)}
|
| 106 |
|
| 107 |
{lastMoveRejectedReason && (
|
| 108 |
+
<div
|
| 109 |
+
className="absolute top-2 left-1/2 -translate-x-1/2 text-white text-xs px-3 py-1.5 rounded-full whitespace-nowrap"
|
| 110 |
+
style={{ backgroundColor: "rgba(220, 38, 38, 0.9)" }}
|
| 111 |
+
>
|
| 112 |
{lastMoveRejectedReason}
|
| 113 |
</div>
|
| 114 |
)}
|
chess-frontend/app/(protected)/game/[id]/_components/game-chat.tsx
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client";
|
| 2 |
+
|
| 3 |
+
import { useState, useRef, useEffect } from "react";
|
| 4 |
+
import { useGameStore } from "@/store/use-game-store";
|
| 5 |
+
import { useSocket } from "@/store/socket-provider";
|
| 6 |
+
import { cn, scrollClass } from "@/lib/utils";
|
| 7 |
+
|
| 8 |
+
interface GameChatProps {
|
| 9 |
+
gameId: string;
|
| 10 |
+
isPlayer: boolean;
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
export function GameChat({ gameId, isPlayer }: GameChatProps) {
|
| 14 |
+
const [input, setInput] = useState("");
|
| 15 |
+
const chatMessages = useGameStore((s) => s.chatMessages);
|
| 16 |
+
const { sendChatMessage, joinGameChat } = useSocket();
|
| 17 |
+
const scrollRef = useRef<HTMLDivElement>(null);
|
| 18 |
+
|
| 19 |
+
useEffect(() => {
|
| 20 |
+
if (scrollRef.current) {
|
| 21 |
+
scrollRef.current.scrollTop = scrollRef.current.scrollHeight;
|
| 22 |
+
}
|
| 23 |
+
}, [chatMessages]);
|
| 24 |
+
|
| 25 |
+
useEffect(() => {
|
| 26 |
+
if (!joinGameChat) return;
|
| 27 |
+
joinGameChat(gameId);
|
| 28 |
+
}, [gameId]);
|
| 29 |
+
|
| 30 |
+
const handleSend = (e: React.SubmitEvent<HTMLFormElement>) => {
|
| 31 |
+
e.preventDefault();
|
| 32 |
+
if (!input.trim() || !isPlayer) return;
|
| 33 |
+
sendChatMessage(gameId, input.trim());
|
| 34 |
+
setInput("");
|
| 35 |
+
};
|
| 36 |
+
|
| 37 |
+
return (
|
| 38 |
+
<div className="flex flex-col h-70 border-t border-zinc-800/40 w-full bg-zinc-950/50">
|
| 39 |
+
<div
|
| 40 |
+
className={cn(
|
| 41 |
+
"flex-1 overflow-y-auto p-3 space-y-2 no-scrollbar",
|
| 42 |
+
scrollClass,
|
| 43 |
+
)}
|
| 44 |
+
ref={scrollRef}
|
| 45 |
+
>
|
| 46 |
+
{chatMessages.length === 0 ? (
|
| 47 |
+
<p className="text-zinc-500 text-xs italic text-center mt-2">
|
| 48 |
+
No messages yet. Be the first to say hi!
|
| 49 |
+
</p>
|
| 50 |
+
) : (
|
| 51 |
+
chatMessages.map((msg, idx) => {
|
| 52 |
+
return (
|
| 53 |
+
<div
|
| 54 |
+
key={msg.id || idx}
|
| 55 |
+
className="flex items-start gap-2 text-sm mb-3"
|
| 56 |
+
>
|
| 57 |
+
{msg.sender.image ? (
|
| 58 |
+
<img
|
| 59 |
+
src={msg.sender.image}
|
| 60 |
+
alt={msg.sender.username}
|
| 61 |
+
className="w-6 h-6 rounded object-cover bg-zinc-800 shrink-0"
|
| 62 |
+
/>
|
| 63 |
+
) : (
|
| 64 |
+
<div className="w-6 h-6 rounded bg-zinc-800 flex items-center justify-center shrink-0 text-xs font-bold text-zinc-400">
|
| 65 |
+
{msg.sender.username.charAt(0).toUpperCase()}
|
| 66 |
+
</div>
|
| 67 |
+
)}
|
| 68 |
+
<div className="flex flex-col leading-tight">
|
| 69 |
+
<span className="font-semibold text-zinc-400 text-xs mb-0.5">
|
| 70 |
+
{msg.sender.username}
|
| 71 |
+
</span>
|
| 72 |
+
<span className="text-zinc-200 wrap-break-word">
|
| 73 |
+
{msg.content}
|
| 74 |
+
</span>
|
| 75 |
+
</div>
|
| 76 |
+
</div>
|
| 77 |
+
);
|
| 78 |
+
})
|
| 79 |
+
)}
|
| 80 |
+
</div>
|
| 81 |
+
<form
|
| 82 |
+
onSubmit={handleSend}
|
| 83 |
+
className="p-2 border-t border-zinc-800/40 flex gap-2"
|
| 84 |
+
>
|
| 85 |
+
<input
|
| 86 |
+
type="text"
|
| 87 |
+
value={input}
|
| 88 |
+
onChange={(e) => setInput(e.target.value)}
|
| 89 |
+
placeholder={
|
| 90 |
+
isPlayer ? "Send a message..." : "Chat is for players only"
|
| 91 |
+
}
|
| 92 |
+
disabled={!isPlayer}
|
| 93 |
+
className="flex-1 bg-zinc-900 border border-zinc-800 text-sm text-white px-3 py-1.5 rounded focus:outline-none focus:ring-1 focus:ring-zinc-600 transition-shadow disabled:opacity-60 disabled:cursor-not-allowed"
|
| 94 |
+
/>
|
| 95 |
+
</form>
|
| 96 |
+
</div>
|
| 97 |
+
);
|
| 98 |
+
}
|
chess-frontend/app/(protected)/game/[id]/_components/game-over-overlay.tsx
CHANGED
|
@@ -35,7 +35,7 @@ export function GameOverOverlay({
|
|
| 35 |
|
| 36 |
let headline = "Draw";
|
| 37 |
let headlineColor = "text-zinc-400";
|
| 38 |
-
if (isAbandoned) {
|
| 39 |
headline = "Aborted";
|
| 40 |
headlineColor = "text-zinc-500";
|
| 41 |
} else if (winnerColor) {
|
|
@@ -48,8 +48,12 @@ export function GameOverOverlay({
|
|
| 48 |
: isDraw
|
| 49 |
? "Game drawn"
|
| 50 |
: `${winnerColor} won`;
|
| 51 |
-
|
|
|
|
| 52 |
subtitle += ` by ${gameOver.reason.toLowerCase()}`;
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
return (
|
| 55 |
<div className="absolute inset-0 bg-black/70 flex items-center justify-center rounded-sm z-50">
|
|
|
|
| 35 |
|
| 36 |
let headline = "Draw";
|
| 37 |
let headlineColor = "text-zinc-400";
|
| 38 |
+
if (isAbandoned && !gameOver.winnerId) {
|
| 39 |
headline = "Aborted";
|
| 40 |
headlineColor = "text-zinc-500";
|
| 41 |
} else if (winnerColor) {
|
|
|
|
| 48 |
: isDraw
|
| 49 |
? "Game drawn"
|
| 50 |
: `${winnerColor} won`;
|
| 51 |
+
|
| 52 |
+
if (gameOver.reason && !isAbandoned) {
|
| 53 |
subtitle += ` by ${gameOver.reason.toLowerCase()}`;
|
| 54 |
+
} else if (isAbandoned && winnerColor) {
|
| 55 |
+
subtitle = `${winnerColor} won (abandoned)`;
|
| 56 |
+
}
|
| 57 |
|
| 58 |
return (
|
| 59 |
<div className="absolute inset-0 bg-black/70 flex items-center justify-center rounded-sm z-50">
|
chess-frontend/app/(protected)/game/[id]/_components/game-sidebar.tsx
CHANGED
|
@@ -8,6 +8,7 @@ import { IncomingDrawOffer } from "./incoming-draw-offer";
|
|
| 8 |
import { ActiveGameControls } from "./active-game-controls";
|
| 9 |
import { RematchControls } from "./rematch-controls";
|
| 10 |
import { FlipButton } from "./flip-button";
|
|
|
|
| 11 |
|
| 12 |
interface GameSidebarProps {
|
| 13 |
activeGame: ActiveGame;
|
|
@@ -61,6 +62,8 @@ export function GameSidebar({
|
|
| 61 |
</div>
|
| 62 |
)}
|
| 63 |
</div>
|
|
|
|
|
|
|
| 64 |
</div>
|
| 65 |
);
|
| 66 |
}
|
|
|
|
| 8 |
import { ActiveGameControls } from "./active-game-controls";
|
| 9 |
import { RematchControls } from "./rematch-controls";
|
| 10 |
import { FlipButton } from "./flip-button";
|
| 11 |
+
import { GameChat } from "./game-chat";
|
| 12 |
|
| 13 |
interface GameSidebarProps {
|
| 14 |
activeGame: ActiveGame;
|
|
|
|
| 62 |
</div>
|
| 63 |
)}
|
| 64 |
</div>
|
| 65 |
+
|
| 66 |
+
<GameChat gameId={activeGame.gameId} isPlayer={isPlayer} />
|
| 67 |
</div>
|
| 68 |
);
|
| 69 |
}
|
chess-frontend/app/(protected)/game/[id]/_components/move-list.tsx
CHANGED
|
@@ -31,8 +31,8 @@ interface MoveButtonProps {
|
|
| 31 |
|
| 32 |
function SanText({ san, color }: { san: string; color: "w" | "b" }) {
|
| 33 |
const pieceIcons = {
|
| 34 |
-
w: { K: "
|
| 35 |
-
b: { K: "
|
| 36 |
};
|
| 37 |
|
| 38 |
const pieceMatch = san.match(/^([KQRBN])(.*)$/);
|
|
@@ -168,7 +168,6 @@ export function MoveList({
|
|
| 168 |
}: MoveListProps) {
|
| 169 |
const scrollContainerRef = useRef<HTMLDivElement>(null);
|
| 170 |
const pairs = parsePgnWithTimes(pgn, timeControl);
|
| 171 |
-
console.log({ pairs });
|
| 172 |
|
| 173 |
useEffect(() => {
|
| 174 |
if (!scrollContainerRef.current) return;
|
|
|
|
| 31 |
|
| 32 |
function SanText({ san, color }: { san: string; color: "w" | "b" }) {
|
| 33 |
const pieceIcons = {
|
| 34 |
+
w: { K: "♚", Q: "♛", R: "♜", B: "♝", N: "♞" },
|
| 35 |
+
b: { K: "♔", Q: "♕", R: "♖", B: "♗", N: "♘" },
|
| 36 |
};
|
| 37 |
|
| 38 |
const pieceMatch = san.match(/^([KQRBN])(.*)$/);
|
|
|
|
| 168 |
}: MoveListProps) {
|
| 169 |
const scrollContainerRef = useRef<HTMLDivElement>(null);
|
| 170 |
const pairs = parsePgnWithTimes(pgn, timeControl);
|
|
|
|
| 171 |
|
| 172 |
useEffect(() => {
|
| 173 |
if (!scrollContainerRef.current) return;
|
chess-frontend/app/(protected)/game/[id]/_components/player-card.tsx
CHANGED
|
@@ -4,6 +4,7 @@ import { GameStateUser, PLAYER_COLOR } from "@/types/chess";
|
|
| 4 |
import { Clock } from "./clock";
|
| 5 |
import { cn } from "@/lib/utils";
|
| 6 |
import Link from "next/link";
|
|
|
|
| 7 |
|
| 8 |
interface PlayerCardProps {
|
| 9 |
player: GameStateUser;
|
|
@@ -44,7 +45,7 @@ export function PlayerCard({
|
|
| 44 |
isWhite ? "bg-zinc-800 text-zinc-400" : "bg-zinc-800 text-zinc-400",
|
| 45 |
)}
|
| 46 |
>
|
| 47 |
-
{player.username
|
| 48 |
</div>
|
| 49 |
)}
|
| 50 |
|
|
|
|
| 4 |
import { Clock } from "./clock";
|
| 5 |
import { cn } from "@/lib/utils";
|
| 6 |
import Link from "next/link";
|
| 7 |
+
import { getInitials } from "@/lib/constants/get-initials";
|
| 8 |
|
| 9 |
interface PlayerCardProps {
|
| 10 |
player: GameStateUser;
|
|
|
|
| 45 |
isWhite ? "bg-zinc-800 text-zinc-400" : "bg-zinc-800 text-zinc-400",
|
| 46 |
)}
|
| 47 |
>
|
| 48 |
+
{getInitials(player.username)}
|
| 49 |
</div>
|
| 50 |
)}
|
| 51 |
|
chess-frontend/app/(protected)/history/_components/game-history-with-board.tsx
CHANGED
|
@@ -4,28 +4,7 @@ import { GameboardSnapshot } from "./gameboard-snapshot";
|
|
| 4 |
import { redirect } from "next/dist/client/components/navigation";
|
| 5 |
import { getUserFromSession } from "@/actions/session";
|
| 6 |
import { cn, scrollClass } from "@/lib/utils";
|
| 7 |
-
|
| 8 |
-
export type Player = {
|
| 9 |
-
id: string;
|
| 10 |
-
username: string;
|
| 11 |
-
currentRating: number;
|
| 12 |
-
matchRating: number;
|
| 13 |
-
diff: number;
|
| 14 |
-
};
|
| 15 |
-
|
| 16 |
-
export type GameRecord = {
|
| 17 |
-
id: string;
|
| 18 |
-
status: GameStatus;
|
| 19 |
-
timeControl: string;
|
| 20 |
-
createdAt: string;
|
| 21 |
-
winnerId: string | null;
|
| 22 |
-
result: string;
|
| 23 |
-
finalFen: string;
|
| 24 |
-
pgn: string;
|
| 25 |
-
moveTimes: number[];
|
| 26 |
-
white: Player;
|
| 27 |
-
black: Player;
|
| 28 |
-
};
|
| 29 |
|
| 30 |
const PIECE_VALUES: Record<string, number> = { p: 1, n: 3, b: 3, r: 5, q: 9 };
|
| 31 |
const PIECE_GLYPHS: Record<string, string> = {
|
|
|
|
| 4 |
import { redirect } from "next/dist/client/components/navigation";
|
| 5 |
import { getUserFromSession } from "@/actions/session";
|
| 6 |
import { cn, scrollClass } from "@/lib/utils";
|
| 7 |
+
import { GameRecord } from "@/types/history";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
const PIECE_VALUES: Record<string, number> = { p: 1, n: 3, b: 3, r: 5, q: 9 };
|
| 10 |
const PIECE_GLYPHS: Record<string, string> = {
|
chess-frontend/app/(protected)/history/page.tsx
CHANGED
|
@@ -1,10 +1,29 @@
|
|
| 1 |
import { api } from "@/lib/clients/server";
|
| 2 |
import { GameBoardWithHistory } from "./_components/game-history-with-board";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
const HistoryPage = async () => {
|
| 5 |
-
const
|
| 6 |
-
|
| 7 |
-
|
| 8 |
return <GameBoardWithHistory games={games} />;
|
| 9 |
};
|
| 10 |
|
|
|
|
| 1 |
import { api } from "@/lib/clients/server";
|
| 2 |
import { GameBoardWithHistory } from "./_components/game-history-with-board";
|
| 3 |
+
import { ApiResponse } from "@/types";
|
| 4 |
+
import { GameRecord } from "@/types/history";
|
| 5 |
+
|
| 6 |
+
async function getHistory() {
|
| 7 |
+
try {
|
| 8 |
+
const res = await api("/games/history?limit=50");
|
| 9 |
+
|
| 10 |
+
if (!res.ok) return null;
|
| 11 |
+
|
| 12 |
+
const { data }: ApiResponse<GameRecord[]> = await res.json();
|
| 13 |
+
|
| 14 |
+
if (!data?.length) return null;
|
| 15 |
+
|
| 16 |
+
return data;
|
| 17 |
+
} catch (error) {
|
| 18 |
+
console.error("Fetch failed:", error);
|
| 19 |
+
return null;
|
| 20 |
+
}
|
| 21 |
+
}
|
| 22 |
|
| 23 |
const HistoryPage = async () => {
|
| 24 |
+
const games = await getHistory();
|
| 25 |
+
if (!games) return null;
|
| 26 |
+
|
| 27 |
return <GameBoardWithHistory games={games} />;
|
| 28 |
};
|
| 29 |
|
chess-frontend/app/globals.css
CHANGED
|
@@ -7,7 +7,7 @@
|
|
| 7 |
@theme inline {
|
| 8 |
--color-background: var(--background);
|
| 9 |
--color-foreground: var(--foreground);
|
| 10 |
-
--font-sans: var(--font-
|
| 11 |
--font-mono: var(--font-mono);
|
| 12 |
--color-sidebar-ring: var(--sidebar-ring);
|
| 13 |
--color-sidebar-border: var(--sidebar-border);
|
|
@@ -45,11 +45,10 @@
|
|
| 45 |
--radius-2xl: calc(var(--radius) * 1.8);
|
| 46 |
--radius-3xl: calc(var(--radius) * 2.2);
|
| 47 |
--radius-4xl: calc(var(--radius) * 2.6);
|
|
|
|
| 48 |
}
|
| 49 |
|
| 50 |
:root {
|
| 51 |
-
--background: oklch(1 0 0);
|
| 52 |
-
--foreground: oklch(0.145 0 0);
|
| 53 |
--card: oklch(1 0 0);
|
| 54 |
--card-foreground: oklch(0.145 0 0);
|
| 55 |
--popover: oklch(1 0 0);
|
|
@@ -66,11 +65,11 @@
|
|
| 66 |
--border: oklch(0.922 0 0);
|
| 67 |
--input: oklch(0.922 0 0);
|
| 68 |
--ring: oklch(0.708 0 0);
|
| 69 |
-
--chart-1: oklch(0.
|
| 70 |
-
--chart-2: oklch(0.
|
| 71 |
-
--chart-3: oklch(0.
|
| 72 |
-
--chart-4: oklch(0.
|
| 73 |
-
--chart-5: oklch(0.
|
| 74 |
--radius: 0.625rem;
|
| 75 |
--sidebar: oklch(0.985 0 0);
|
| 76 |
--sidebar-foreground: oklch(0.145 0 0);
|
|
@@ -80,6 +79,8 @@
|
|
| 80 |
--sidebar-accent-foreground: oklch(0.205 0 0);
|
| 81 |
--sidebar-border: oklch(0.922 0 0);
|
| 82 |
--sidebar-ring: oklch(0.708 0 0);
|
|
|
|
|
|
|
| 83 |
}
|
| 84 |
|
| 85 |
.dark {
|
|
@@ -101,11 +102,11 @@
|
|
| 101 |
--border: oklch(1 0 0 / 10%);
|
| 102 |
--input: oklch(1 0 0 / 15%);
|
| 103 |
--ring: oklch(0.556 0 0);
|
| 104 |
-
--chart-1: oklch(0.
|
| 105 |
-
--chart-2: oklch(0.
|
| 106 |
-
--chart-3: oklch(0.
|
| 107 |
-
--chart-4: oklch(0.
|
| 108 |
-
--chart-5: oklch(0.
|
| 109 |
--sidebar: oklch(0.205 0 0);
|
| 110 |
--sidebar-foreground: oklch(0.985 0 0);
|
| 111 |
--sidebar-primary: oklch(0.488 0.243 264.376);
|
|
@@ -124,6 +125,6 @@
|
|
| 124 |
@apply bg-background text-foreground;
|
| 125 |
}
|
| 126 |
html {
|
| 127 |
-
@apply font-
|
| 128 |
}
|
| 129 |
-
}
|
|
|
|
| 7 |
@theme inline {
|
| 8 |
--color-background: var(--background);
|
| 9 |
--color-foreground: var(--foreground);
|
| 10 |
+
--font-sans: var(--font-sans);
|
| 11 |
--font-mono: var(--font-mono);
|
| 12 |
--color-sidebar-ring: var(--sidebar-ring);
|
| 13 |
--color-sidebar-border: var(--sidebar-border);
|
|
|
|
| 45 |
--radius-2xl: calc(var(--radius) * 1.8);
|
| 46 |
--radius-3xl: calc(var(--radius) * 2.2);
|
| 47 |
--radius-4xl: calc(var(--radius) * 2.6);
|
| 48 |
+
--font-heading: var(--font-sans);
|
| 49 |
}
|
| 50 |
|
| 51 |
:root {
|
|
|
|
|
|
|
| 52 |
--card: oklch(1 0 0);
|
| 53 |
--card-foreground: oklch(0.145 0 0);
|
| 54 |
--popover: oklch(1 0 0);
|
|
|
|
| 65 |
--border: oklch(0.922 0 0);
|
| 66 |
--input: oklch(0.922 0 0);
|
| 67 |
--ring: oklch(0.708 0 0);
|
| 68 |
+
--chart-1: oklch(0.87 0 0);
|
| 69 |
+
--chart-2: oklch(0.556 0 0);
|
| 70 |
+
--chart-3: oklch(0.439 0 0);
|
| 71 |
+
--chart-4: oklch(0.371 0 0);
|
| 72 |
+
--chart-5: oklch(0.269 0 0);
|
| 73 |
--radius: 0.625rem;
|
| 74 |
--sidebar: oklch(0.985 0 0);
|
| 75 |
--sidebar-foreground: oklch(0.145 0 0);
|
|
|
|
| 79 |
--sidebar-accent-foreground: oklch(0.205 0 0);
|
| 80 |
--sidebar-border: oklch(0.922 0 0);
|
| 81 |
--sidebar-ring: oklch(0.708 0 0);
|
| 82 |
+
--background: oklch(1 0 0);
|
| 83 |
+
--foreground: oklch(0.145 0 0);
|
| 84 |
}
|
| 85 |
|
| 86 |
.dark {
|
|
|
|
| 102 |
--border: oklch(1 0 0 / 10%);
|
| 103 |
--input: oklch(1 0 0 / 15%);
|
| 104 |
--ring: oklch(0.556 0 0);
|
| 105 |
+
--chart-1: oklch(0.87 0 0);
|
| 106 |
+
--chart-2: oklch(0.556 0 0);
|
| 107 |
+
--chart-3: oklch(0.439 0 0);
|
| 108 |
+
--chart-4: oklch(0.371 0 0);
|
| 109 |
+
--chart-5: oklch(0.269 0 0);
|
| 110 |
--sidebar: oklch(0.205 0 0);
|
| 111 |
--sidebar-foreground: oklch(0.985 0 0);
|
| 112 |
--sidebar-primary: oklch(0.488 0.243 264.376);
|
|
|
|
| 125 |
@apply bg-background text-foreground;
|
| 126 |
}
|
| 127 |
html {
|
| 128 |
+
@apply font-sans;
|
| 129 |
}
|
| 130 |
+
}
|
chess-frontend/app/layout.tsx
CHANGED
|
@@ -1,12 +1,12 @@
|
|
| 1 |
import type { Metadata } from "next";
|
| 2 |
-
import { Raleway } from "next/font/google";
|
| 3 |
|
| 4 |
import { cn, scrollClass } from "@/lib/utils";
|
| 5 |
import "./globals.css";
|
| 6 |
import { Toaster } from "@/components/ui/sonner";
|
| 7 |
import Navbar from "@/components/navbar/navbar";
|
| 8 |
|
| 9 |
-
const
|
| 10 |
|
| 11 |
export const metadata: Metadata = {
|
| 12 |
title: "Chess",
|
|
@@ -19,11 +19,11 @@ export default async function RootLayout({
|
|
| 19 |
children: React.ReactNode;
|
| 20 |
}) {
|
| 21 |
return (
|
| 22 |
-
<html lang="en" className={
|
| 23 |
<body
|
| 24 |
className={cn(
|
| 25 |
"min-h-screen flex flex-col bg-black",
|
| 26 |
-
|
| 27 |
scrollClass,
|
| 28 |
)}
|
| 29 |
>
|
|
|
|
| 1 |
import type { Metadata } from "next";
|
| 2 |
+
import { Raleway, Geist } from "next/font/google";
|
| 3 |
|
| 4 |
import { cn, scrollClass } from "@/lib/utils";
|
| 5 |
import "./globals.css";
|
| 6 |
import { Toaster } from "@/components/ui/sonner";
|
| 7 |
import Navbar from "@/components/navbar/navbar";
|
| 8 |
|
| 9 |
+
const geist = Geist({subsets:['latin'],variable:'--font-sans'});
|
| 10 |
|
| 11 |
export const metadata: Metadata = {
|
| 12 |
title: "Chess",
|
|
|
|
| 19 |
children: React.ReactNode;
|
| 20 |
}) {
|
| 21 |
return (
|
| 22 |
+
<html lang="en" className={cn("font-sans", geist.variable)}>
|
| 23 |
<body
|
| 24 |
className={cn(
|
| 25 |
"min-h-screen flex flex-col bg-black",
|
| 26 |
+
geist.className,
|
| 27 |
scrollClass,
|
| 28 |
)}
|
| 29 |
>
|
chess-frontend/bun.lock
CHANGED
|
@@ -9,14 +9,16 @@
|
|
| 9 |
"chess.js": "^1.4.0",
|
| 10 |
"class-variance-authority": "^0.7.1",
|
| 11 |
"clsx": "^2.1.1",
|
| 12 |
-
"
|
|
|
|
|
|
|
| 13 |
"next": "16.1.6",
|
| 14 |
"next-themes": "^0.4.6",
|
| 15 |
"radix-ui": "^1.4.3",
|
| 16 |
"react": "19.2.3",
|
| 17 |
"react-chessboard": "^5.10.0",
|
| 18 |
"react-dom": "19.2.3",
|
| 19 |
-
"shadcn": "^4.
|
| 20 |
"sonner": "^2.0.7",
|
| 21 |
"tailwind-merge": "^3.5.0",
|
| 22 |
"tw-animate-css": "^1.4.0",
|
|
@@ -38,8 +40,6 @@
|
|
| 38 |
"packages": {
|
| 39 |
"@alloc/quick-lru": ["@alloc/quick-lru@5.2.0", "", {}, "sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw=="],
|
| 40 |
|
| 41 |
-
"@antfu/ni": ["@antfu/ni@25.0.0", "", { "dependencies": { "ansis": "^4.0.0", "fzf": "^0.5.2", "package-manager-detector": "^1.3.0", "tinyexec": "^1.0.1" }, "bin": { "na": "bin/na.mjs", "ni": "bin/ni.mjs", "nr": "bin/nr.mjs", "nci": "bin/nci.mjs", "nlx": "bin/nlx.mjs", "nun": "bin/nun.mjs", "nup": "bin/nup.mjs" } }, "sha512-9q/yCljni37pkMr4sPrI3G4jqdIk074+iukc5aFJl7kmDCCsiJrbZ6zKxnES1Gwg+i9RcDZwvktl23puGslmvA=="],
|
| 42 |
-
|
| 43 |
"@babel/code-frame": ["@babel/code-frame@7.29.0", "", { "dependencies": { "@babel/helper-validator-identifier": "^7.28.5", "js-tokens": "^4.0.0", "picocolors": "^1.1.1" } }, "sha512-9NhCeYjq9+3uxgdtp20LSiJXJvN0FeCtNGpJxuMFZ1Kv3cWUNb6DOhJwUvcVCzKGR66cw4njwM6hrJLqgOwbcw=="],
|
| 44 |
|
| 45 |
"@babel/compat-data": ["@babel/compat-data@7.29.0", "", {}, "sha512-T1NCJqT/j9+cn8fvkt7jtwbLBfLC/1y1c7NtCeXFRgzGTsafi68MRv8yzkYSapBnFA6L3U2VSc02ciDzoAJhJg=="],
|
|
@@ -520,8 +520,6 @@
|
|
| 520 |
|
| 521 |
"ansi-styles": ["ansi-styles@4.3.0", "", { "dependencies": { "color-convert": "^2.0.1" } }, "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg=="],
|
| 522 |
|
| 523 |
-
"ansis": ["ansis@4.2.0", "", {}, "sha512-HqZ5rWlFjGiV0tDm3UxxgNRqsOTniqoKZu0pIAfh7TZQMGuZK+hH0drySty0si0QXj1ieop4+SkSfPZBPPkHig=="],
|
| 524 |
-
|
| 525 |
"argparse": ["argparse@2.0.1", "", {}, "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q=="],
|
| 526 |
|
| 527 |
"aria-hidden": ["aria-hidden@1.2.6", "", { "dependencies": { "tslib": "^2.0.0" } }, "sha512-ik3ZgC9dY/lYVVM++OISsaYDeg1tb0VtP5uL3ouh1koGOaUMDPpbFIei4JkFimWUFPn90sbMNMXQAIVOlnYKJA=="],
|
|
@@ -600,6 +598,8 @@
|
|
| 600 |
|
| 601 |
"clsx": ["clsx@2.1.1", "", {}, "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA=="],
|
| 602 |
|
|
|
|
|
|
|
| 603 |
"code-block-writer": ["code-block-writer@13.0.3", "", {}, "sha512-Oofo0pq3IKnsFtuHqSF7TqBfr71aeyZDVJ0HpmqB7FBM2qEigL0iPONSCZSO9pE9dZTAxANe5XHG9Uy0YMv8cg=="],
|
| 604 |
|
| 605 |
"color-convert": ["color-convert@2.0.1", "", { "dependencies": { "color-name": "~1.1.4" } }, "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ=="],
|
|
@@ -792,6 +792,8 @@
|
|
| 792 |
|
| 793 |
"forwarded": ["forwarded@0.2.0", "", {}, "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow=="],
|
| 794 |
|
|
|
|
|
|
|
| 795 |
"fresh": ["fresh@2.0.0", "", {}, "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A=="],
|
| 796 |
|
| 797 |
"fs-extra": ["fs-extra@11.3.4", "", { "dependencies": { "graceful-fs": "^4.2.0", "jsonfile": "^6.0.1", "universalify": "^2.0.0" } }, "sha512-CTXd6rk/M3/ULNQj8FBqBWHYBVYybQ3VPBw0xGKFe3tuH7ytT6ACnvzpIQ3UZtB8yvUKC2cXn1a+x+5EVQLovA=="],
|
|
@@ -804,8 +806,6 @@
|
|
| 804 |
|
| 805 |
"fuzzysort": ["fuzzysort@3.1.0", "", {}, "sha512-sR9BNCjBg6LNgwvxlBd0sBABvQitkLzoVY9MYYROQVX/FvfJ4Mai9LsGhDgd8qYdds0bY77VzYd5iuB+v5rwQQ=="],
|
| 806 |
|
| 807 |
-
"fzf": ["fzf@0.5.2", "", {}, "sha512-Tt4kuxLXFKHy8KT40zwsUPUkg1CrsgY25FxA2U/j/0WgEDCk3ddc/zLTCCcbSHX9FcKtLuVaDGtGE/STWC+j3Q=="],
|
| 808 |
-
|
| 809 |
"generator-function": ["generator-function@2.0.1", "", {}, "sha512-SFdFmIJi+ybC0vjlHN0ZGVGHc3lgE0DxPAT0djjVg+kjOnSqclqmj0KQ7ykTOLP6YxoqOvuAODGdcHJn+43q3g=="],
|
| 810 |
|
| 811 |
"gensync": ["gensync@1.0.0-beta.2", "", {}, "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg=="],
|
|
@@ -1042,7 +1042,7 @@
|
|
| 1042 |
|
| 1043 |
"lru-cache": ["lru-cache@5.1.1", "", { "dependencies": { "yallist": "^3.0.2" } }, "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w=="],
|
| 1044 |
|
| 1045 |
-
"lucide-react": ["lucide-react@
|
| 1046 |
|
| 1047 |
"magic-string": ["magic-string@0.30.21", "", { "dependencies": { "@jridgewell/sourcemap-codec": "^1.5.5" } }, "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ=="],
|
| 1048 |
|
|
@@ -1070,6 +1070,10 @@
|
|
| 1070 |
|
| 1071 |
"minimist": ["minimist@1.2.8", "", {}, "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA=="],
|
| 1072 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1073 |
"ms": ["ms@2.1.3", "", {}, "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="],
|
| 1074 |
|
| 1075 |
"msw": ["msw@2.12.10", "", { "dependencies": { "@inquirer/confirm": "^5.0.0", "@mswjs/interceptors": "^0.41.2", "@open-draft/deferred-promise": "^2.2.0", "@types/statuses": "^2.0.6", "cookie": "^1.0.2", "graphql": "^16.12.0", "headers-polyfill": "^4.0.2", "is-node-process": "^1.2.0", "outvariant": "^1.4.3", "path-to-regexp": "^6.3.0", "picocolors": "^1.1.1", "rettime": "^0.10.1", "statuses": "^2.0.2", "strict-event-emitter": "^0.5.1", "tough-cookie": "^6.0.0", "type-fest": "^5.2.0", "until-async": "^3.0.2", "yargs": "^17.7.2" }, "peerDependencies": { "typescript": ">= 4.8.x" }, "optionalPeers": ["typescript"], "bin": { "msw": "cli/index.js" } }, "sha512-G3VUymSE0/iegFnuipujpwyTM2GuZAKXNeerUSrG2+Eg391wW63xFs5ixWsK9MWzr1AGoSkYGmyAzNgbR3+urw=="],
|
|
@@ -1136,8 +1140,6 @@
|
|
| 1136 |
|
| 1137 |
"p-locate": ["p-locate@5.0.0", "", { "dependencies": { "p-limit": "^3.0.2" } }, "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw=="],
|
| 1138 |
|
| 1139 |
-
"package-manager-detector": ["package-manager-detector@1.6.0", "", {}, "sha512-61A5ThoTiDG/C8s8UMZwSorAGwMJ0ERVGj2OjoW5pAalsNOg15+iQiPzrLJ4jhZ1HJzmC2PIHT2oEiH3R5fzNA=="],
|
| 1140 |
-
|
| 1141 |
"parent-module": ["parent-module@1.0.1", "", { "dependencies": { "callsites": "^3.0.0" } }, "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g=="],
|
| 1142 |
|
| 1143 |
"parse-json": ["parse-json@5.2.0", "", { "dependencies": { "@babel/code-frame": "^7.0.0", "error-ex": "^1.3.1", "json-parse-even-better-errors": "^2.3.0", "lines-and-columns": "^1.1.6" } }, "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg=="],
|
|
@@ -1258,7 +1260,7 @@
|
|
| 1258 |
|
| 1259 |
"setprototypeof": ["setprototypeof@1.2.0", "", {}, "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw=="],
|
| 1260 |
|
| 1261 |
-
"shadcn": ["shadcn@4.
|
| 1262 |
|
| 1263 |
"sharp": ["sharp@0.34.5", "", { "dependencies": { "@img/colour": "^1.0.0", "detect-libc": "^2.1.2", "semver": "^7.7.3" }, "optionalDependencies": { "@img/sharp-darwin-arm64": "0.34.5", "@img/sharp-darwin-x64": "0.34.5", "@img/sharp-libvips-darwin-arm64": "1.2.4", "@img/sharp-libvips-darwin-x64": "1.2.4", "@img/sharp-libvips-linux-arm": "1.2.4", "@img/sharp-libvips-linux-arm64": "1.2.4", "@img/sharp-libvips-linux-ppc64": "1.2.4", "@img/sharp-libvips-linux-riscv64": "1.2.4", "@img/sharp-libvips-linux-s390x": "1.2.4", "@img/sharp-libvips-linux-x64": "1.2.4", "@img/sharp-libvips-linuxmusl-arm64": "1.2.4", "@img/sharp-libvips-linuxmusl-x64": "1.2.4", "@img/sharp-linux-arm": "0.34.5", "@img/sharp-linux-arm64": "0.34.5", "@img/sharp-linux-ppc64": "0.34.5", "@img/sharp-linux-riscv64": "0.34.5", "@img/sharp-linux-s390x": "0.34.5", "@img/sharp-linux-x64": "0.34.5", "@img/sharp-linuxmusl-arm64": "0.34.5", "@img/sharp-linuxmusl-x64": "0.34.5", "@img/sharp-wasm32": "0.34.5", "@img/sharp-win32-arm64": "0.34.5", "@img/sharp-win32-ia32": "0.34.5", "@img/sharp-win32-x64": "0.34.5" } }, "sha512-Ou9I5Ft9WNcCbXrU9cMgPBcCK8LiwLqcbywW3t4oDV37n1pzpuNLsYiAV8eODnjbtQlSDwZ2cUEeQz4E54Hltg=="],
|
| 1264 |
|
|
@@ -1334,8 +1336,6 @@
|
|
| 1334 |
|
| 1335 |
"tiny-invariant": ["tiny-invariant@1.3.3", "", {}, "sha512-+FbBPE1o9QAYvviau/qC5SE3caw21q3xkvWKBtja5vgqOWIHHJ3ioaq1VPfn/Szqctz2bU/oYeKd9/z5BL+PVg=="],
|
| 1336 |
|
| 1337 |
-
"tinyexec": ["tinyexec@1.0.2", "", {}, "sha512-W/KYk+NFhkmsYpuHq5JykngiOCnxeVL8v8dFnqxSD8qEEdRfXk1SDM6JzNqcERbcGYj9tMrDQBYV9cjgnunFIg=="],
|
| 1338 |
-
|
| 1339 |
"tinyglobby": ["tinyglobby@0.2.15", "", { "dependencies": { "fdir": "^6.5.0", "picomatch": "^4.0.3" } }, "sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ=="],
|
| 1340 |
|
| 1341 |
"tldts": ["tldts@7.0.25", "", { "dependencies": { "tldts-core": "^7.0.25" }, "bin": { "tldts": "bin/cli.js" } }, "sha512-keinCnPbwXEUG3ilrWQZU+CqcTTzHq9m2HhoUP2l7Xmi8l1LuijAXLpAJ5zRW+ifKTNscs4NdCkfkDCBYm352w=="],
|
|
|
|
| 9 |
"chess.js": "^1.4.0",
|
| 10 |
"class-variance-authority": "^0.7.1",
|
| 11 |
"clsx": "^2.1.1",
|
| 12 |
+
"cmdk": "^1.1.1",
|
| 13 |
+
"framer-motion": "^12.38.0",
|
| 14 |
+
"lucide-react": "^1.7.0",
|
| 15 |
"next": "16.1.6",
|
| 16 |
"next-themes": "^0.4.6",
|
| 17 |
"radix-ui": "^1.4.3",
|
| 18 |
"react": "19.2.3",
|
| 19 |
"react-chessboard": "^5.10.0",
|
| 20 |
"react-dom": "19.2.3",
|
| 21 |
+
"shadcn": "^4.1.2",
|
| 22 |
"sonner": "^2.0.7",
|
| 23 |
"tailwind-merge": "^3.5.0",
|
| 24 |
"tw-animate-css": "^1.4.0",
|
|
|
|
| 40 |
"packages": {
|
| 41 |
"@alloc/quick-lru": ["@alloc/quick-lru@5.2.0", "", {}, "sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw=="],
|
| 42 |
|
|
|
|
|
|
|
| 43 |
"@babel/code-frame": ["@babel/code-frame@7.29.0", "", { "dependencies": { "@babel/helper-validator-identifier": "^7.28.5", "js-tokens": "^4.0.0", "picocolors": "^1.1.1" } }, "sha512-9NhCeYjq9+3uxgdtp20LSiJXJvN0FeCtNGpJxuMFZ1Kv3cWUNb6DOhJwUvcVCzKGR66cw4njwM6hrJLqgOwbcw=="],
|
| 44 |
|
| 45 |
"@babel/compat-data": ["@babel/compat-data@7.29.0", "", {}, "sha512-T1NCJqT/j9+cn8fvkt7jtwbLBfLC/1y1c7NtCeXFRgzGTsafi68MRv8yzkYSapBnFA6L3U2VSc02ciDzoAJhJg=="],
|
|
|
|
| 520 |
|
| 521 |
"ansi-styles": ["ansi-styles@4.3.0", "", { "dependencies": { "color-convert": "^2.0.1" } }, "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg=="],
|
| 522 |
|
|
|
|
|
|
|
| 523 |
"argparse": ["argparse@2.0.1", "", {}, "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q=="],
|
| 524 |
|
| 525 |
"aria-hidden": ["aria-hidden@1.2.6", "", { "dependencies": { "tslib": "^2.0.0" } }, "sha512-ik3ZgC9dY/lYVVM++OISsaYDeg1tb0VtP5uL3ouh1koGOaUMDPpbFIei4JkFimWUFPn90sbMNMXQAIVOlnYKJA=="],
|
|
|
|
| 598 |
|
| 599 |
"clsx": ["clsx@2.1.1", "", {}, "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA=="],
|
| 600 |
|
| 601 |
+
"cmdk": ["cmdk@1.1.1", "", { "dependencies": { "@radix-ui/react-compose-refs": "^1.1.1", "@radix-ui/react-dialog": "^1.1.6", "@radix-ui/react-id": "^1.1.0", "@radix-ui/react-primitive": "^2.0.2" }, "peerDependencies": { "react": "^18 || ^19 || ^19.0.0-rc", "react-dom": "^18 || ^19 || ^19.0.0-rc" } }, "sha512-Vsv7kFaXm+ptHDMZ7izaRsP70GgrW9NBNGswt9OZaVBLlE0SNpDq8eu/VGXyF9r7M0azK3Wy7OlYXsuyYLFzHg=="],
|
| 602 |
+
|
| 603 |
"code-block-writer": ["code-block-writer@13.0.3", "", {}, "sha512-Oofo0pq3IKnsFtuHqSF7TqBfr71aeyZDVJ0HpmqB7FBM2qEigL0iPONSCZSO9pE9dZTAxANe5XHG9Uy0YMv8cg=="],
|
| 604 |
|
| 605 |
"color-convert": ["color-convert@2.0.1", "", { "dependencies": { "color-name": "~1.1.4" } }, "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ=="],
|
|
|
|
| 792 |
|
| 793 |
"forwarded": ["forwarded@0.2.0", "", {}, "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow=="],
|
| 794 |
|
| 795 |
+
"framer-motion": ["framer-motion@12.38.0", "", { "dependencies": { "motion-dom": "^12.38.0", "motion-utils": "^12.36.0", "tslib": "^2.4.0" }, "peerDependencies": { "@emotion/is-prop-valid": "*", "react": "^18.0.0 || ^19.0.0", "react-dom": "^18.0.0 || ^19.0.0" }, "optionalPeers": ["@emotion/is-prop-valid", "react", "react-dom"] }, "sha512-rFYkY/pigbcswl1XQSb7q424kSTQ8q6eAC+YUsSKooHQYuLdzdHjrt6uxUC+PRAO++q5IS7+TamgIw1AphxR+g=="],
|
| 796 |
+
|
| 797 |
"fresh": ["fresh@2.0.0", "", {}, "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A=="],
|
| 798 |
|
| 799 |
"fs-extra": ["fs-extra@11.3.4", "", { "dependencies": { "graceful-fs": "^4.2.0", "jsonfile": "^6.0.1", "universalify": "^2.0.0" } }, "sha512-CTXd6rk/M3/ULNQj8FBqBWHYBVYybQ3VPBw0xGKFe3tuH7ytT6ACnvzpIQ3UZtB8yvUKC2cXn1a+x+5EVQLovA=="],
|
|
|
|
| 806 |
|
| 807 |
"fuzzysort": ["fuzzysort@3.1.0", "", {}, "sha512-sR9BNCjBg6LNgwvxlBd0sBABvQitkLzoVY9MYYROQVX/FvfJ4Mai9LsGhDgd8qYdds0bY77VzYd5iuB+v5rwQQ=="],
|
| 808 |
|
|
|
|
|
|
|
| 809 |
"generator-function": ["generator-function@2.0.1", "", {}, "sha512-SFdFmIJi+ybC0vjlHN0ZGVGHc3lgE0DxPAT0djjVg+kjOnSqclqmj0KQ7ykTOLP6YxoqOvuAODGdcHJn+43q3g=="],
|
| 810 |
|
| 811 |
"gensync": ["gensync@1.0.0-beta.2", "", {}, "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg=="],
|
|
|
|
| 1042 |
|
| 1043 |
"lru-cache": ["lru-cache@5.1.1", "", { "dependencies": { "yallist": "^3.0.2" } }, "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w=="],
|
| 1044 |
|
| 1045 |
+
"lucide-react": ["lucide-react@1.7.0", "", { "peerDependencies": { "react": "^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0" } }, "sha512-yI7BeItCLZJTXikmK4KNUGCKoGzSvbKlfCvw44bU4fXAL6v3gYS4uHD1jzsLkfwODYwI6Drw5Tu9Z5ulDe0TSg=="],
|
| 1046 |
|
| 1047 |
"magic-string": ["magic-string@0.30.21", "", { "dependencies": { "@jridgewell/sourcemap-codec": "^1.5.5" } }, "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ=="],
|
| 1048 |
|
|
|
|
| 1070 |
|
| 1071 |
"minimist": ["minimist@1.2.8", "", {}, "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA=="],
|
| 1072 |
|
| 1073 |
+
"motion-dom": ["motion-dom@12.38.0", "", { "dependencies": { "motion-utils": "^12.36.0" } }, "sha512-pdkHLD8QYRp8VfiNLb8xIBJis1byQ9gPT3Jnh2jqfFtAsWUA3dEepDlsWe/xMpO8McV+VdpKVcp+E+TGJEtOoA=="],
|
| 1074 |
+
|
| 1075 |
+
"motion-utils": ["motion-utils@12.36.0", "", {}, "sha512-eHWisygbiwVvf6PZ1vhaHCLamvkSbPIeAYxWUuL3a2PD/TROgE7FvfHWTIH4vMl798QLfMw15nRqIaRDXTlYRg=="],
|
| 1076 |
+
|
| 1077 |
"ms": ["ms@2.1.3", "", {}, "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="],
|
| 1078 |
|
| 1079 |
"msw": ["msw@2.12.10", "", { "dependencies": { "@inquirer/confirm": "^5.0.0", "@mswjs/interceptors": "^0.41.2", "@open-draft/deferred-promise": "^2.2.0", "@types/statuses": "^2.0.6", "cookie": "^1.0.2", "graphql": "^16.12.0", "headers-polyfill": "^4.0.2", "is-node-process": "^1.2.0", "outvariant": "^1.4.3", "path-to-regexp": "^6.3.0", "picocolors": "^1.1.1", "rettime": "^0.10.1", "statuses": "^2.0.2", "strict-event-emitter": "^0.5.1", "tough-cookie": "^6.0.0", "type-fest": "^5.2.0", "until-async": "^3.0.2", "yargs": "^17.7.2" }, "peerDependencies": { "typescript": ">= 4.8.x" }, "optionalPeers": ["typescript"], "bin": { "msw": "cli/index.js" } }, "sha512-G3VUymSE0/iegFnuipujpwyTM2GuZAKXNeerUSrG2+Eg391wW63xFs5ixWsK9MWzr1AGoSkYGmyAzNgbR3+urw=="],
|
|
|
|
| 1140 |
|
| 1141 |
"p-locate": ["p-locate@5.0.0", "", { "dependencies": { "p-limit": "^3.0.2" } }, "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw=="],
|
| 1142 |
|
|
|
|
|
|
|
| 1143 |
"parent-module": ["parent-module@1.0.1", "", { "dependencies": { "callsites": "^3.0.0" } }, "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g=="],
|
| 1144 |
|
| 1145 |
"parse-json": ["parse-json@5.2.0", "", { "dependencies": { "@babel/code-frame": "^7.0.0", "error-ex": "^1.3.1", "json-parse-even-better-errors": "^2.3.0", "lines-and-columns": "^1.1.6" } }, "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg=="],
|
|
|
|
| 1260 |
|
| 1261 |
"setprototypeof": ["setprototypeof@1.2.0", "", {}, "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw=="],
|
| 1262 |
|
| 1263 |
+
"shadcn": ["shadcn@4.1.2", "", { "dependencies": { "@babel/core": "^7.28.0", "@babel/parser": "^7.28.0", "@babel/plugin-transform-typescript": "^7.28.0", "@babel/preset-typescript": "^7.27.1", "@dotenvx/dotenvx": "^1.48.4", "@modelcontextprotocol/sdk": "^1.26.0", "@types/validate-npm-package-name": "^4.0.2", "browserslist": "^4.26.2", "commander": "^14.0.0", "cosmiconfig": "^9.0.0", "dedent": "^1.6.0", "deepmerge": "^4.3.1", "diff": "^8.0.2", "execa": "^9.6.0", "fast-glob": "^3.3.3", "fs-extra": "^11.3.1", "fuzzysort": "^3.1.0", "https-proxy-agent": "^7.0.6", "kleur": "^4.1.5", "msw": "^2.10.4", "node-fetch": "^3.3.2", "open": "^11.0.0", "ora": "^8.2.0", "postcss": "^8.5.6", "postcss-selector-parser": "^7.1.0", "prompts": "^2.4.2", "recast": "^0.23.11", "stringify-object": "^5.0.0", "tailwind-merge": "^3.0.1", "ts-morph": "^26.0.0", "tsconfig-paths": "^4.2.0", "validate-npm-package-name": "^7.0.1", "zod": "^3.24.1", "zod-to-json-schema": "^3.24.6" }, "bin": { "shadcn": "dist/index.js" } }, "sha512-qNQcCavkbYsgBj+X09tF2bTcwRd8abR880bsFkDU2kMqceMCLAm5c+cLg7kWDhfh1H9g08knpQ5ZEf6y/co16g=="],
|
| 1264 |
|
| 1265 |
"sharp": ["sharp@0.34.5", "", { "dependencies": { "@img/colour": "^1.0.0", "detect-libc": "^2.1.2", "semver": "^7.7.3" }, "optionalDependencies": { "@img/sharp-darwin-arm64": "0.34.5", "@img/sharp-darwin-x64": "0.34.5", "@img/sharp-libvips-darwin-arm64": "1.2.4", "@img/sharp-libvips-darwin-x64": "1.2.4", "@img/sharp-libvips-linux-arm": "1.2.4", "@img/sharp-libvips-linux-arm64": "1.2.4", "@img/sharp-libvips-linux-ppc64": "1.2.4", "@img/sharp-libvips-linux-riscv64": "1.2.4", "@img/sharp-libvips-linux-s390x": "1.2.4", "@img/sharp-libvips-linux-x64": "1.2.4", "@img/sharp-libvips-linuxmusl-arm64": "1.2.4", "@img/sharp-libvips-linuxmusl-x64": "1.2.4", "@img/sharp-linux-arm": "0.34.5", "@img/sharp-linux-arm64": "0.34.5", "@img/sharp-linux-ppc64": "0.34.5", "@img/sharp-linux-riscv64": "0.34.5", "@img/sharp-linux-s390x": "0.34.5", "@img/sharp-linux-x64": "0.34.5", "@img/sharp-linuxmusl-arm64": "0.34.5", "@img/sharp-linuxmusl-x64": "0.34.5", "@img/sharp-wasm32": "0.34.5", "@img/sharp-win32-arm64": "0.34.5", "@img/sharp-win32-ia32": "0.34.5", "@img/sharp-win32-x64": "0.34.5" } }, "sha512-Ou9I5Ft9WNcCbXrU9cMgPBcCK8LiwLqcbywW3t4oDV37n1pzpuNLsYiAV8eODnjbtQlSDwZ2cUEeQz4E54Hltg=="],
|
| 1266 |
|
|
|
|
| 1336 |
|
| 1337 |
"tiny-invariant": ["tiny-invariant@1.3.3", "", {}, "sha512-+FbBPE1o9QAYvviau/qC5SE3caw21q3xkvWKBtja5vgqOWIHHJ3ioaq1VPfn/Szqctz2bU/oYeKd9/z5BL+PVg=="],
|
| 1338 |
|
|
|
|
|
|
|
| 1339 |
"tinyglobby": ["tinyglobby@0.2.15", "", { "dependencies": { "fdir": "^6.5.0", "picomatch": "^4.0.3" } }, "sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ=="],
|
| 1340 |
|
| 1341 |
"tldts": ["tldts@7.0.25", "", { "dependencies": { "tldts-core": "^7.0.25" }, "bin": { "tldts": "bin/cli.js" } }, "sha512-keinCnPbwXEUG3ilrWQZU+CqcTTzHq9m2HhoUP2l7Xmi8l1LuijAXLpAJ5zRW+ifKTNscs4NdCkfkDCBYm352w=="],
|
chess-frontend/components.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"$schema": "https://ui.shadcn.com/schema.json",
|
| 3 |
-
"style": "radix-
|
| 4 |
"rsc": true,
|
| 5 |
"tsx": true,
|
| 6 |
"tailwind": {
|
|
@@ -10,7 +10,7 @@
|
|
| 10 |
"cssVariables": true,
|
| 11 |
"prefix": ""
|
| 12 |
},
|
| 13 |
-
"iconLibrary": "
|
| 14 |
"rtl": false,
|
| 15 |
"aliases": {
|
| 16 |
"components": "@/components",
|
|
|
|
| 1 |
{
|
| 2 |
"$schema": "https://ui.shadcn.com/schema.json",
|
| 3 |
+
"style": "radix-nova",
|
| 4 |
"rsc": true,
|
| 5 |
"tsx": true,
|
| 6 |
"tailwind": {
|
|
|
|
| 10 |
"cssVariables": true,
|
| 11 |
"prefix": ""
|
| 12 |
},
|
| 13 |
+
"iconLibrary": "lucide",
|
| 14 |
"rtl": false,
|
| 15 |
"aliases": {
|
| 16 |
"components": "@/components",
|
chess-frontend/components/navbar/navlinks.tsx
CHANGED
|
@@ -4,7 +4,7 @@ const links = [
|
|
| 4 |
{ name: "Play", href: "/" },
|
| 5 |
{ name: "Leaderboard", href: "/leaderboard" },
|
| 6 |
{ name: "History", href: "/history" },
|
| 7 |
-
{ name: "
|
| 8 |
];
|
| 9 |
|
| 10 |
export function NavLinks() {
|
|
|
|
| 4 |
{ name: "Play", href: "/" },
|
| 5 |
{ name: "Leaderboard", href: "/leaderboard" },
|
| 6 |
{ name: "History", href: "/history" },
|
| 7 |
+
{ name: "Community", href: "/community" },
|
| 8 |
];
|
| 9 |
|
| 10 |
export function NavLinks() {
|
chess-frontend/components/navbar/user-dropdown.tsx
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
| 9 |
DropdownMenuTrigger,
|
| 10 |
} from "@/components/ui/dropdown-menu";
|
| 11 |
import { ChevronDown, User, Settings, LogOut } from "lucide-react";
|
|
|
|
| 12 |
|
| 13 |
type UserDropdownProps = {
|
| 14 |
user: {
|
|
@@ -58,11 +59,7 @@ export function UserDropdown({ user, onSignOut }: UserDropdownProps) {
|
|
| 58 |
className="object-cover"
|
| 59 |
/>
|
| 60 |
<AvatarFallback className="rounded-full bg-zinc-800 text-[11px] font-bold text-zinc-400">
|
| 61 |
-
{user.name
|
| 62 |
-
?.split(" ")
|
| 63 |
-
.map((n) => n[0])
|
| 64 |
-
.join("")
|
| 65 |
-
.toUpperCase()}
|
| 66 |
</AvatarFallback>
|
| 67 |
</Avatar>
|
| 68 |
|
|
|
|
| 9 |
DropdownMenuTrigger,
|
| 10 |
} from "@/components/ui/dropdown-menu";
|
| 11 |
import { ChevronDown, User, Settings, LogOut } from "lucide-react";
|
| 12 |
+
import { getInitials } from "@/lib/constants/get-initials";
|
| 13 |
|
| 14 |
type UserDropdownProps = {
|
| 15 |
user: {
|
|
|
|
| 59 |
className="object-cover"
|
| 60 |
/>
|
| 61 |
<AvatarFallback className="rounded-full bg-zinc-800 text-[11px] font-bold text-zinc-400">
|
| 62 |
+
{getInitials(user.name)}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
</AvatarFallback>
|
| 64 |
</Avatar>
|
| 65 |
|
chess-frontend/components/ui/avatar.tsx
CHANGED
|
@@ -94,7 +94,7 @@ function AvatarGroupCount({
|
|
| 94 |
<div
|
| 95 |
data-slot="avatar-group-count"
|
| 96 |
className={cn(
|
| 97 |
-
"relative flex size-8 shrink-0 items-center justify-center rounded-full bg-muted text-
|
| 98 |
className
|
| 99 |
)}
|
| 100 |
{...props}
|
|
|
|
| 94 |
<div
|
| 95 |
data-slot="avatar-group-count"
|
| 96 |
className={cn(
|
| 97 |
+
"relative flex size-8 shrink-0 items-center justify-center rounded-full bg-muted text-sm text-muted-foreground ring-2 ring-background group-has-data-[size=lg]/avatar-group:size-10 group-has-data-[size=sm]/avatar-group:size-6 [&>svg]:size-4 group-has-data-[size=lg]/avatar-group:[&>svg]:size-5 group-has-data-[size=sm]/avatar-group:[&>svg]:size-3",
|
| 98 |
className
|
| 99 |
)}
|
| 100 |
{...props}
|
chess-frontend/components/ui/badge.tsx
CHANGED
|
@@ -5,7 +5,7 @@ import { Slot } from "radix-ui"
|
|
| 5 |
import { cn } from "@/lib/utils"
|
| 6 |
|
| 7 |
const badgeVariants = cva(
|
| 8 |
-
"group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-
|
| 9 |
{
|
| 10 |
variants: {
|
| 11 |
variant: {
|
|
|
|
| 5 |
import { cn } from "@/lib/utils"
|
| 6 |
|
| 7 |
const badgeVariants = cva(
|
| 8 |
+
"group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!",
|
| 9 |
{
|
| 10 |
variants: {
|
| 11 |
variant: {
|
chess-frontend/components/ui/button.tsx
CHANGED
|
@@ -5,7 +5,7 @@ import { Slot } from "radix-ui"
|
|
| 5 |
import { cn } from "@/lib/utils"
|
| 6 |
|
| 7 |
const buttonVariants = cva(
|
| 8 |
-
"group/button inline-flex shrink-0 items-center justify-center rounded-
|
| 9 |
{
|
| 10 |
variants: {
|
| 11 |
variant: {
|
|
@@ -23,12 +23,14 @@ const buttonVariants = cva(
|
|
| 23 |
size: {
|
| 24 |
default:
|
| 25 |
"h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
| 26 |
-
xs: "h-6 gap-1 rounded-
|
| 27 |
-
sm: "h-7 gap-1 rounded-
|
| 28 |
-
lg: "h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-
|
| 29 |
icon: "size-8",
|
| 30 |
-
"icon-xs":
|
| 31 |
-
|
|
|
|
|
|
|
| 32 |
"icon-lg": "size-9",
|
| 33 |
},
|
| 34 |
},
|
|
|
|
| 5 |
import { cn } from "@/lib/utils"
|
| 6 |
|
| 7 |
const buttonVariants = cva(
|
| 8 |
+
"group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
| 9 |
{
|
| 10 |
variants: {
|
| 11 |
variant: {
|
|
|
|
| 23 |
size: {
|
| 24 |
default:
|
| 25 |
"h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
| 26 |
+
xs: "h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
|
| 27 |
+
sm: "h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
|
| 28 |
+
lg: "h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
| 29 |
icon: "size-8",
|
| 30 |
+
"icon-xs":
|
| 31 |
+
"size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
|
| 32 |
+
"icon-sm":
|
| 33 |
+
"size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg",
|
| 34 |
"icon-lg": "size-9",
|
| 35 |
},
|
| 36 |
},
|
chess-frontend/components/ui/command.tsx
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client";
|
| 2 |
+
|
| 3 |
+
import * as React from "react";
|
| 4 |
+
import { Command as CommandPrimitive } from "cmdk";
|
| 5 |
+
|
| 6 |
+
import { cn } from "@/lib/utils";
|
| 7 |
+
import {
|
| 8 |
+
Dialog,
|
| 9 |
+
DialogContent,
|
| 10 |
+
DialogDescription,
|
| 11 |
+
DialogHeader,
|
| 12 |
+
DialogTitle,
|
| 13 |
+
} from "@/components/ui/dialog";
|
| 14 |
+
import { InputGroup, InputGroupAddon } from "@/components/ui/input-group";
|
| 15 |
+
import { SearchIcon, CheckIcon } from "lucide-react";
|
| 16 |
+
|
| 17 |
+
function Command({
|
| 18 |
+
className,
|
| 19 |
+
...props
|
| 20 |
+
}: React.ComponentProps<typeof CommandPrimitive>) {
|
| 21 |
+
return (
|
| 22 |
+
<CommandPrimitive
|
| 23 |
+
data-slot="command"
|
| 24 |
+
className={cn(
|
| 25 |
+
"flex size-full flex-col overflow-hidden rounded-xl! bg-popover p-1 text-popover-foreground",
|
| 26 |
+
className,
|
| 27 |
+
)}
|
| 28 |
+
{...props}
|
| 29 |
+
/>
|
| 30 |
+
);
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
function CommandDialog({
|
| 34 |
+
title = "Command Palette",
|
| 35 |
+
description = "Search for a command to run...",
|
| 36 |
+
children,
|
| 37 |
+
className,
|
| 38 |
+
showCloseButton = false,
|
| 39 |
+
...props
|
| 40 |
+
}: React.ComponentProps<typeof Dialog> & {
|
| 41 |
+
title?: string;
|
| 42 |
+
description?: string;
|
| 43 |
+
className?: string;
|
| 44 |
+
showCloseButton?: boolean;
|
| 45 |
+
}) {
|
| 46 |
+
return (
|
| 47 |
+
<Dialog {...props}>
|
| 48 |
+
<DialogHeader className="sr-only">
|
| 49 |
+
<DialogTitle>{title}</DialogTitle>
|
| 50 |
+
<DialogDescription>{description}</DialogDescription>
|
| 51 |
+
</DialogHeader>
|
| 52 |
+
<DialogContent
|
| 53 |
+
className={cn(
|
| 54 |
+
"top-1/3 translate-y-0 overflow-hidden rounded-xl! p-0 bg-black",
|
| 55 |
+
className,
|
| 56 |
+
)}
|
| 57 |
+
showCloseButton={showCloseButton}
|
| 58 |
+
>
|
| 59 |
+
{children}
|
| 60 |
+
</DialogContent>
|
| 61 |
+
</Dialog>
|
| 62 |
+
);
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
function CommandInput({
|
| 66 |
+
className,
|
| 67 |
+
...props
|
| 68 |
+
}: React.ComponentProps<typeof CommandPrimitive.Input>) {
|
| 69 |
+
return (
|
| 70 |
+
<div data-slot="command-input-wrapper" className="p-1 pb-0">
|
| 71 |
+
<InputGroup className="h-8! rounded-lg! border-input/30 bg-input/30 shadow-none! *:data-[slot=input-group-addon]:pl-2!">
|
| 72 |
+
<CommandPrimitive.Input
|
| 73 |
+
data-slot="command-input"
|
| 74 |
+
className={cn(
|
| 75 |
+
"w-full text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",
|
| 76 |
+
className,
|
| 77 |
+
)}
|
| 78 |
+
{...props}
|
| 79 |
+
/>
|
| 80 |
+
<InputGroupAddon>
|
| 81 |
+
<SearchIcon className="size-4 shrink-0 opacity-50" />
|
| 82 |
+
</InputGroupAddon>
|
| 83 |
+
</InputGroup>
|
| 84 |
+
</div>
|
| 85 |
+
);
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
function CommandList({
|
| 89 |
+
className,
|
| 90 |
+
...props
|
| 91 |
+
}: React.ComponentProps<typeof CommandPrimitive.List>) {
|
| 92 |
+
return (
|
| 93 |
+
<CommandPrimitive.List
|
| 94 |
+
data-slot="command-list"
|
| 95 |
+
className={cn(
|
| 96 |
+
"no-scrollbar max-h-72 scroll-py-1 overflow-x-hidden overflow-y-auto outline-none",
|
| 97 |
+
className,
|
| 98 |
+
)}
|
| 99 |
+
{...props}
|
| 100 |
+
/>
|
| 101 |
+
);
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
function CommandEmpty({
|
| 105 |
+
className,
|
| 106 |
+
...props
|
| 107 |
+
}: React.ComponentProps<typeof CommandPrimitive.Empty>) {
|
| 108 |
+
return (
|
| 109 |
+
<CommandPrimitive.Empty
|
| 110 |
+
data-slot="command-empty"
|
| 111 |
+
className={cn("py-6 text-center text-sm", className)}
|
| 112 |
+
{...props}
|
| 113 |
+
/>
|
| 114 |
+
);
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
function CommandGroup({
|
| 118 |
+
className,
|
| 119 |
+
...props
|
| 120 |
+
}: React.ComponentProps<typeof CommandPrimitive.Group>) {
|
| 121 |
+
return (
|
| 122 |
+
<CommandPrimitive.Group
|
| 123 |
+
data-slot="command-group"
|
| 124 |
+
className={cn(
|
| 125 |
+
"overflow-hidden p-1 text-foreground **:[[cmdk-group-heading]]:px-2 **:[[cmdk-group-heading]]:py-1.5 **:[[cmdk-group-heading]]:text-xs **:[[cmdk-group-heading]]:font-medium **:[[cmdk-group-heading]]:text-muted-foreground",
|
| 126 |
+
className,
|
| 127 |
+
)}
|
| 128 |
+
{...props}
|
| 129 |
+
/>
|
| 130 |
+
);
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
function CommandSeparator({
|
| 134 |
+
className,
|
| 135 |
+
...props
|
| 136 |
+
}: React.ComponentProps<typeof CommandPrimitive.Separator>) {
|
| 137 |
+
return (
|
| 138 |
+
<CommandPrimitive.Separator
|
| 139 |
+
data-slot="command-separator"
|
| 140 |
+
className={cn("-mx-1 h-px bg-border", className)}
|
| 141 |
+
{...props}
|
| 142 |
+
/>
|
| 143 |
+
);
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
function CommandItem({
|
| 147 |
+
className,
|
| 148 |
+
children,
|
| 149 |
+
...props
|
| 150 |
+
}: React.ComponentProps<typeof CommandPrimitive.Item>) {
|
| 151 |
+
return (
|
| 152 |
+
<CommandPrimitive.Item
|
| 153 |
+
data-slot="command-item"
|
| 154 |
+
className={cn(
|
| 155 |
+
"group/command-item relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none in-data-[slot=dialog-content]:rounded-lg! data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-selected:bg-muted data-selected:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-selected:*:[svg]:text-foreground",
|
| 156 |
+
className,
|
| 157 |
+
)}
|
| 158 |
+
{...props}
|
| 159 |
+
>
|
| 160 |
+
{children}
|
| 161 |
+
<CheckIcon className="ml-auto opacity-0 group-has-data-[slot=command-shortcut]/command-item:hidden group-data-[checked=true]/command-item:opacity-100" />
|
| 162 |
+
</CommandPrimitive.Item>
|
| 163 |
+
);
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
function CommandShortcut({
|
| 167 |
+
className,
|
| 168 |
+
...props
|
| 169 |
+
}: React.ComponentProps<"span">) {
|
| 170 |
+
return (
|
| 171 |
+
<span
|
| 172 |
+
data-slot="command-shortcut"
|
| 173 |
+
className={cn(
|
| 174 |
+
"ml-auto text-xs tracking-widest text-muted-foreground group-data-selected/command-item:text-foreground",
|
| 175 |
+
className,
|
| 176 |
+
)}
|
| 177 |
+
{...props}
|
| 178 |
+
/>
|
| 179 |
+
);
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
export {
|
| 183 |
+
Command,
|
| 184 |
+
CommandDialog,
|
| 185 |
+
CommandInput,
|
| 186 |
+
CommandList,
|
| 187 |
+
CommandEmpty,
|
| 188 |
+
CommandGroup,
|
| 189 |
+
CommandItem,
|
| 190 |
+
CommandShortcut,
|
| 191 |
+
CommandSeparator,
|
| 192 |
+
};
|
chess-frontend/components/ui/dialog.tsx
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client"
|
| 2 |
+
|
| 3 |
+
import * as React from "react"
|
| 4 |
+
import { Dialog as DialogPrimitive } from "radix-ui"
|
| 5 |
+
|
| 6 |
+
import { cn } from "@/lib/utils"
|
| 7 |
+
import { Button } from "@/components/ui/button"
|
| 8 |
+
import { XIcon } from "lucide-react"
|
| 9 |
+
|
| 10 |
+
function Dialog({
|
| 11 |
+
...props
|
| 12 |
+
}: React.ComponentProps<typeof DialogPrimitive.Root>) {
|
| 13 |
+
return <DialogPrimitive.Root data-slot="dialog" {...props} />
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
function DialogTrigger({
|
| 17 |
+
...props
|
| 18 |
+
}: React.ComponentProps<typeof DialogPrimitive.Trigger>) {
|
| 19 |
+
return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
function DialogPortal({
|
| 23 |
+
...props
|
| 24 |
+
}: React.ComponentProps<typeof DialogPrimitive.Portal>) {
|
| 25 |
+
return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} />
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
function DialogClose({
|
| 29 |
+
...props
|
| 30 |
+
}: React.ComponentProps<typeof DialogPrimitive.Close>) {
|
| 31 |
+
return <DialogPrimitive.Close data-slot="dialog-close" {...props} />
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
function DialogOverlay({
|
| 35 |
+
className,
|
| 36 |
+
...props
|
| 37 |
+
}: React.ComponentProps<typeof DialogPrimitive.Overlay>) {
|
| 38 |
+
return (
|
| 39 |
+
<DialogPrimitive.Overlay
|
| 40 |
+
data-slot="dialog-overlay"
|
| 41 |
+
className={cn(
|
| 42 |
+
"fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",
|
| 43 |
+
className
|
| 44 |
+
)}
|
| 45 |
+
{...props}
|
| 46 |
+
/>
|
| 47 |
+
)
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
function DialogContent({
|
| 51 |
+
className,
|
| 52 |
+
children,
|
| 53 |
+
showCloseButton = true,
|
| 54 |
+
...props
|
| 55 |
+
}: React.ComponentProps<typeof DialogPrimitive.Content> & {
|
| 56 |
+
showCloseButton?: boolean
|
| 57 |
+
}) {
|
| 58 |
+
return (
|
| 59 |
+
<DialogPortal>
|
| 60 |
+
<DialogOverlay />
|
| 61 |
+
<DialogPrimitive.Content
|
| 62 |
+
data-slot="dialog-content"
|
| 63 |
+
className={cn(
|
| 64 |
+
"fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
| 65 |
+
className
|
| 66 |
+
)}
|
| 67 |
+
{...props}
|
| 68 |
+
>
|
| 69 |
+
{children}
|
| 70 |
+
{showCloseButton && (
|
| 71 |
+
<DialogPrimitive.Close data-slot="dialog-close" asChild>
|
| 72 |
+
<Button
|
| 73 |
+
variant="ghost"
|
| 74 |
+
className="absolute top-2 right-2"
|
| 75 |
+
size="icon-sm"
|
| 76 |
+
>
|
| 77 |
+
<XIcon
|
| 78 |
+
/>
|
| 79 |
+
<span className="sr-only">Close</span>
|
| 80 |
+
</Button>
|
| 81 |
+
</DialogPrimitive.Close>
|
| 82 |
+
)}
|
| 83 |
+
</DialogPrimitive.Content>
|
| 84 |
+
</DialogPortal>
|
| 85 |
+
)
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
function DialogHeader({ className, ...props }: React.ComponentProps<"div">) {
|
| 89 |
+
return (
|
| 90 |
+
<div
|
| 91 |
+
data-slot="dialog-header"
|
| 92 |
+
className={cn("flex flex-col gap-2", className)}
|
| 93 |
+
{...props}
|
| 94 |
+
/>
|
| 95 |
+
)
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
function DialogFooter({
|
| 99 |
+
className,
|
| 100 |
+
showCloseButton = false,
|
| 101 |
+
children,
|
| 102 |
+
...props
|
| 103 |
+
}: React.ComponentProps<"div"> & {
|
| 104 |
+
showCloseButton?: boolean
|
| 105 |
+
}) {
|
| 106 |
+
return (
|
| 107 |
+
<div
|
| 108 |
+
data-slot="dialog-footer"
|
| 109 |
+
className={cn(
|
| 110 |
+
"-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 sm:flex-row sm:justify-end",
|
| 111 |
+
className
|
| 112 |
+
)}
|
| 113 |
+
{...props}
|
| 114 |
+
>
|
| 115 |
+
{children}
|
| 116 |
+
{showCloseButton && (
|
| 117 |
+
<DialogPrimitive.Close asChild>
|
| 118 |
+
<Button variant="outline">Close</Button>
|
| 119 |
+
</DialogPrimitive.Close>
|
| 120 |
+
)}
|
| 121 |
+
</div>
|
| 122 |
+
)
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
function DialogTitle({
|
| 126 |
+
className,
|
| 127 |
+
...props
|
| 128 |
+
}: React.ComponentProps<typeof DialogPrimitive.Title>) {
|
| 129 |
+
return (
|
| 130 |
+
<DialogPrimitive.Title
|
| 131 |
+
data-slot="dialog-title"
|
| 132 |
+
className={cn(
|
| 133 |
+
"font-heading text-base leading-none font-medium",
|
| 134 |
+
className
|
| 135 |
+
)}
|
| 136 |
+
{...props}
|
| 137 |
+
/>
|
| 138 |
+
)
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
function DialogDescription({
|
| 142 |
+
className,
|
| 143 |
+
...props
|
| 144 |
+
}: React.ComponentProps<typeof DialogPrimitive.Description>) {
|
| 145 |
+
return (
|
| 146 |
+
<DialogPrimitive.Description
|
| 147 |
+
data-slot="dialog-description"
|
| 148 |
+
className={cn(
|
| 149 |
+
"text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",
|
| 150 |
+
className
|
| 151 |
+
)}
|
| 152 |
+
{...props}
|
| 153 |
+
/>
|
| 154 |
+
)
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
export {
|
| 158 |
+
Dialog,
|
| 159 |
+
DialogClose,
|
| 160 |
+
DialogContent,
|
| 161 |
+
DialogDescription,
|
| 162 |
+
DialogFooter,
|
| 163 |
+
DialogHeader,
|
| 164 |
+
DialogOverlay,
|
| 165 |
+
DialogPortal,
|
| 166 |
+
DialogTitle,
|
| 167 |
+
DialogTrigger,
|
| 168 |
+
}
|
chess-frontend/components/ui/dropdown-menu.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import * as React from "react"
|
|
| 4 |
import { DropdownMenu as DropdownMenuPrimitive } from "radix-ui"
|
| 5 |
|
| 6 |
import { cn } from "@/lib/utils"
|
| 7 |
-
import { CheckIcon,
|
| 8 |
|
| 9 |
function DropdownMenu({
|
| 10 |
...props
|
|
@@ -43,7 +43,7 @@ function DropdownMenuContent({
|
|
| 43 |
data-slot="dropdown-menu-content"
|
| 44 |
sideOffset={sideOffset}
|
| 45 |
align={align}
|
| 46 |
-
className={cn("z-50 max-h-(--radix-dropdown-menu-content-available-height) w-(--radix-dropdown-menu-trigger-width) min-w-32 origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-
|
| 47 |
{...props}
|
| 48 |
/>
|
| 49 |
</DropdownMenuPrimitive.Portal>
|
|
@@ -73,7 +73,7 @@ function DropdownMenuItem({
|
|
| 73 |
data-inset={inset}
|
| 74 |
data-variant={variant}
|
| 75 |
className={cn(
|
| 76 |
-
"group/dropdown-menu-item relative flex cursor-default items-center gap-
|
| 77 |
className
|
| 78 |
)}
|
| 79 |
{...props}
|
|
@@ -95,7 +95,7 @@ function DropdownMenuCheckboxItem({
|
|
| 95 |
data-slot="dropdown-menu-checkbox-item"
|
| 96 |
data-inset={inset}
|
| 97 |
className={cn(
|
| 98 |
-
"relative flex cursor-default items-center gap-
|
| 99 |
className
|
| 100 |
)}
|
| 101 |
checked={checked}
|
|
@@ -139,7 +139,7 @@ function DropdownMenuRadioItem({
|
|
| 139 |
data-slot="dropdown-menu-radio-item"
|
| 140 |
data-inset={inset}
|
| 141 |
className={cn(
|
| 142 |
-
"relative flex cursor-default items-center gap-
|
| 143 |
className
|
| 144 |
)}
|
| 145 |
{...props}
|
|
@@ -170,7 +170,7 @@ function DropdownMenuLabel({
|
|
| 170 |
data-slot="dropdown-menu-label"
|
| 171 |
data-inset={inset}
|
| 172 |
className={cn(
|
| 173 |
-
"px-
|
| 174 |
className
|
| 175 |
)}
|
| 176 |
{...props}
|
|
@@ -185,7 +185,7 @@ function DropdownMenuSeparator({
|
|
| 185 |
return (
|
| 186 |
<DropdownMenuPrimitive.Separator
|
| 187 |
data-slot="dropdown-menu-separator"
|
| 188 |
-
className={cn("-mx-1 h-px bg-border", className)}
|
| 189 |
{...props}
|
| 190 |
/>
|
| 191 |
)
|
|
@@ -226,13 +226,13 @@ function DropdownMenuSubTrigger({
|
|
| 226 |
data-slot="dropdown-menu-sub-trigger"
|
| 227 |
data-inset={inset}
|
| 228 |
className={cn(
|
| 229 |
-
"flex cursor-default items-center gap-
|
| 230 |
className
|
| 231 |
)}
|
| 232 |
{...props}
|
| 233 |
>
|
| 234 |
{children}
|
| 235 |
-
<
|
| 236 |
</DropdownMenuPrimitive.SubTrigger>
|
| 237 |
)
|
| 238 |
}
|
|
@@ -244,7 +244,7 @@ function DropdownMenuSubContent({
|
|
| 244 |
return (
|
| 245 |
<DropdownMenuPrimitive.SubContent
|
| 246 |
data-slot="dropdown-menu-sub-content"
|
| 247 |
-
className={cn("z-50 min-w-[96px] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-
|
| 248 |
{...props}
|
| 249 |
/>
|
| 250 |
)
|
|
|
|
| 4 |
import { DropdownMenu as DropdownMenuPrimitive } from "radix-ui"
|
| 5 |
|
| 6 |
import { cn } from "@/lib/utils"
|
| 7 |
+
import { CheckIcon, ChevronRightIcon } from "lucide-react"
|
| 8 |
|
| 9 |
function DropdownMenu({
|
| 10 |
...props
|
|
|
|
| 43 |
data-slot="dropdown-menu-content"
|
| 44 |
sideOffset={sideOffset}
|
| 45 |
align={align}
|
| 46 |
+
className={cn("z-50 max-h-(--radix-dropdown-menu-content-available-height) w-(--radix-dropdown-menu-trigger-width) min-w-32 origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:overflow-hidden data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", className )}
|
| 47 |
{...props}
|
| 48 |
/>
|
| 49 |
</DropdownMenuPrimitive.Portal>
|
|
|
|
| 73 |
data-inset={inset}
|
| 74 |
data-variant={variant}
|
| 75 |
className={cn(
|
| 76 |
+
"group/dropdown-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive",
|
| 77 |
className
|
| 78 |
)}
|
| 79 |
{...props}
|
|
|
|
| 95 |
data-slot="dropdown-menu-checkbox-item"
|
| 96 |
data-inset={inset}
|
| 97 |
className={cn(
|
| 98 |
+
"relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
| 99 |
className
|
| 100 |
)}
|
| 101 |
checked={checked}
|
|
|
|
| 139 |
data-slot="dropdown-menu-radio-item"
|
| 140 |
data-inset={inset}
|
| 141 |
className={cn(
|
| 142 |
+
"relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
| 143 |
className
|
| 144 |
)}
|
| 145 |
{...props}
|
|
|
|
| 170 |
data-slot="dropdown-menu-label"
|
| 171 |
data-inset={inset}
|
| 172 |
className={cn(
|
| 173 |
+
"px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7",
|
| 174 |
className
|
| 175 |
)}
|
| 176 |
{...props}
|
|
|
|
| 185 |
return (
|
| 186 |
<DropdownMenuPrimitive.Separator
|
| 187 |
data-slot="dropdown-menu-separator"
|
| 188 |
+
className={cn("-mx-1 my-1 h-px bg-border", className)}
|
| 189 |
{...props}
|
| 190 |
/>
|
| 191 |
)
|
|
|
|
| 226 |
data-slot="dropdown-menu-sub-trigger"
|
| 227 |
data-inset={inset}
|
| 228 |
className={cn(
|
| 229 |
+
"flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
| 230 |
className
|
| 231 |
)}
|
| 232 |
{...props}
|
| 233 |
>
|
| 234 |
{children}
|
| 235 |
+
<ChevronRightIcon className="ml-auto" />
|
| 236 |
</DropdownMenuPrimitive.SubTrigger>
|
| 237 |
)
|
| 238 |
}
|
|
|
|
| 244 |
return (
|
| 245 |
<DropdownMenuPrimitive.SubContent
|
| 246 |
data-slot="dropdown-menu-sub-content"
|
| 247 |
+
className={cn("z-50 min-w-[96px] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-lg bg-popover p-1 text-popover-foreground shadow-lg ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", className )}
|
| 248 |
{...props}
|
| 249 |
/>
|
| 250 |
)
|
chess-frontend/components/ui/field.tsx
CHANGED
|
@@ -30,7 +30,7 @@ function FieldLegend({
|
|
| 30 |
data-slot="field-legend"
|
| 31 |
data-variant={variant}
|
| 32 |
className={cn(
|
| 33 |
-
"mb-
|
| 34 |
className
|
| 35 |
)}
|
| 36 |
{...props}
|
|
@@ -106,7 +106,7 @@ function FieldLabel({
|
|
| 106 |
<Label
|
| 107 |
data-slot="field-label"
|
| 108 |
className={cn(
|
| 109 |
-
"group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-data-checked:border-primary/30 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:rounded-
|
| 110 |
"has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col",
|
| 111 |
className
|
| 112 |
)}
|
|
@@ -120,7 +120,7 @@ function FieldTitle({ className, ...props }: React.ComponentProps<"div">) {
|
|
| 120 |
<div
|
| 121 |
data-slot="field-label"
|
| 122 |
className={cn(
|
| 123 |
-
"flex w-fit items-center gap-2 text-
|
| 124 |
className
|
| 125 |
)}
|
| 126 |
{...props}
|
|
@@ -133,7 +133,7 @@ function FieldDescription({ className, ...props }: React.ComponentProps<"p">) {
|
|
| 133 |
<p
|
| 134 |
data-slot="field-description"
|
| 135 |
className={cn(
|
| 136 |
-
"text-left text-
|
| 137 |
"last:mt-0 nth-last-2:-mt-1",
|
| 138 |
"[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",
|
| 139 |
className
|
|
@@ -155,7 +155,7 @@ function FieldSeparator({
|
|
| 155 |
data-slot="field-separator"
|
| 156 |
data-content={!!children}
|
| 157 |
className={cn(
|
| 158 |
-
"relative -my-2 h-5 text-
|
| 159 |
className
|
| 160 |
)}
|
| 161 |
{...props}
|
|
@@ -216,7 +216,7 @@ function FieldError({
|
|
| 216 |
<div
|
| 217 |
role="alert"
|
| 218 |
data-slot="field-error"
|
| 219 |
-
className={cn("text-
|
| 220 |
{...props}
|
| 221 |
>
|
| 222 |
{content}
|
|
|
|
| 30 |
data-slot="field-legend"
|
| 31 |
data-variant={variant}
|
| 32 |
className={cn(
|
| 33 |
+
"mb-1.5 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base",
|
| 34 |
className
|
| 35 |
)}
|
| 36 |
{...props}
|
|
|
|
| 106 |
<Label
|
| 107 |
data-slot="field-label"
|
| 108 |
className={cn(
|
| 109 |
+
"group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-data-checked:border-primary/30 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:rounded-lg has-[>[data-slot=field]]:border *:data-[slot=field]:p-2.5 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10",
|
| 110 |
"has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col",
|
| 111 |
className
|
| 112 |
)}
|
|
|
|
| 120 |
<div
|
| 121 |
data-slot="field-label"
|
| 122 |
className={cn(
|
| 123 |
+
"flex w-fit items-center gap-2 text-sm leading-snug font-medium group-data-[disabled=true]/field:opacity-50",
|
| 124 |
className
|
| 125 |
)}
|
| 126 |
{...props}
|
|
|
|
| 133 |
<p
|
| 134 |
data-slot="field-description"
|
| 135 |
className={cn(
|
| 136 |
+
"text-left text-sm leading-normal font-normal text-muted-foreground group-has-data-horizontal/field:text-balance [[data-variant=legend]+&]:-mt-1.5",
|
| 137 |
"last:mt-0 nth-last-2:-mt-1",
|
| 138 |
"[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",
|
| 139 |
className
|
|
|
|
| 155 |
data-slot="field-separator"
|
| 156 |
data-content={!!children}
|
| 157 |
className={cn(
|
| 158 |
+
"relative -my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2",
|
| 159 |
className
|
| 160 |
)}
|
| 161 |
{...props}
|
|
|
|
| 216 |
<div
|
| 217 |
role="alert"
|
| 218 |
data-slot="field-error"
|
| 219 |
+
className={cn("text-sm font-normal text-destructive", className)}
|
| 220 |
{...props}
|
| 221 |
>
|
| 222 |
{content}
|
chess-frontend/components/ui/input-group.tsx
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client"
|
| 2 |
+
|
| 3 |
+
import * as React from "react"
|
| 4 |
+
import { cva, type VariantProps } from "class-variance-authority"
|
| 5 |
+
|
| 6 |
+
import { cn } from "@/lib/utils"
|
| 7 |
+
import { Button } from "@/components/ui/button"
|
| 8 |
+
import { Input } from "@/components/ui/input"
|
| 9 |
+
import { Textarea } from "@/components/ui/textarea"
|
| 10 |
+
|
| 11 |
+
function InputGroup({ className, ...props }: React.ComponentProps<"div">) {
|
| 12 |
+
return (
|
| 13 |
+
<div
|
| 14 |
+
data-slot="input-group"
|
| 15 |
+
role="group"
|
| 16 |
+
className={cn(
|
| 17 |
+
"group/input-group relative flex h-8 w-full min-w-0 items-center rounded-lg border border-input transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-disabled:bg-input/80 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5",
|
| 18 |
+
className
|
| 19 |
+
)}
|
| 20 |
+
{...props}
|
| 21 |
+
/>
|
| 22 |
+
)
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
const inputGroupAddonVariants = cva(
|
| 26 |
+
"flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4",
|
| 27 |
+
{
|
| 28 |
+
variants: {
|
| 29 |
+
align: {
|
| 30 |
+
"inline-start":
|
| 31 |
+
"order-first pl-2 has-[>button]:ml-[-0.3rem] has-[>kbd]:ml-[-0.15rem]",
|
| 32 |
+
"inline-end":
|
| 33 |
+
"order-last pr-2 has-[>button]:mr-[-0.3rem] has-[>kbd]:mr-[-0.15rem]",
|
| 34 |
+
"block-start":
|
| 35 |
+
"order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2",
|
| 36 |
+
"block-end":
|
| 37 |
+
"order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2",
|
| 38 |
+
},
|
| 39 |
+
},
|
| 40 |
+
defaultVariants: {
|
| 41 |
+
align: "inline-start",
|
| 42 |
+
},
|
| 43 |
+
}
|
| 44 |
+
)
|
| 45 |
+
|
| 46 |
+
function InputGroupAddon({
|
| 47 |
+
className,
|
| 48 |
+
align = "inline-start",
|
| 49 |
+
...props
|
| 50 |
+
}: React.ComponentProps<"div"> & VariantProps<typeof inputGroupAddonVariants>) {
|
| 51 |
+
return (
|
| 52 |
+
<div
|
| 53 |
+
role="group"
|
| 54 |
+
data-slot="input-group-addon"
|
| 55 |
+
data-align={align}
|
| 56 |
+
className={cn(inputGroupAddonVariants({ align }), className)}
|
| 57 |
+
onClick={(e) => {
|
| 58 |
+
if ((e.target as HTMLElement).closest("button")) {
|
| 59 |
+
return
|
| 60 |
+
}
|
| 61 |
+
e.currentTarget.parentElement?.querySelector("input")?.focus()
|
| 62 |
+
}}
|
| 63 |
+
{...props}
|
| 64 |
+
/>
|
| 65 |
+
)
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
const inputGroupButtonVariants = cva(
|
| 69 |
+
"flex items-center gap-2 text-sm shadow-none",
|
| 70 |
+
{
|
| 71 |
+
variants: {
|
| 72 |
+
size: {
|
| 73 |
+
xs: "h-6 gap-1 rounded-[calc(var(--radius)-3px)] px-1.5 [&>svg:not([class*='size-'])]:size-3.5",
|
| 74 |
+
sm: "",
|
| 75 |
+
"icon-xs":
|
| 76 |
+
"size-6 rounded-[calc(var(--radius)-3px)] p-0 has-[>svg]:p-0",
|
| 77 |
+
"icon-sm": "size-8 p-0 has-[>svg]:p-0",
|
| 78 |
+
},
|
| 79 |
+
},
|
| 80 |
+
defaultVariants: {
|
| 81 |
+
size: "xs",
|
| 82 |
+
},
|
| 83 |
+
}
|
| 84 |
+
)
|
| 85 |
+
|
| 86 |
+
function InputGroupButton({
|
| 87 |
+
className,
|
| 88 |
+
type = "button",
|
| 89 |
+
variant = "ghost",
|
| 90 |
+
size = "xs",
|
| 91 |
+
...props
|
| 92 |
+
}: Omit<React.ComponentProps<typeof Button>, "size"> &
|
| 93 |
+
VariantProps<typeof inputGroupButtonVariants>) {
|
| 94 |
+
return (
|
| 95 |
+
<Button
|
| 96 |
+
type={type}
|
| 97 |
+
data-size={size}
|
| 98 |
+
variant={variant}
|
| 99 |
+
className={cn(inputGroupButtonVariants({ size }), className)}
|
| 100 |
+
{...props}
|
| 101 |
+
/>
|
| 102 |
+
)
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
function InputGroupText({ className, ...props }: React.ComponentProps<"span">) {
|
| 106 |
+
return (
|
| 107 |
+
<span
|
| 108 |
+
className={cn(
|
| 109 |
+
"flex items-center gap-2 text-sm text-muted-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",
|
| 110 |
+
className
|
| 111 |
+
)}
|
| 112 |
+
{...props}
|
| 113 |
+
/>
|
| 114 |
+
)
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
function InputGroupInput({
|
| 118 |
+
className,
|
| 119 |
+
...props
|
| 120 |
+
}: React.ComponentProps<"input">) {
|
| 121 |
+
return (
|
| 122 |
+
<Input
|
| 123 |
+
data-slot="input-group-control"
|
| 124 |
+
className={cn(
|
| 125 |
+
"flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0 dark:bg-transparent dark:disabled:bg-transparent",
|
| 126 |
+
className
|
| 127 |
+
)}
|
| 128 |
+
{...props}
|
| 129 |
+
/>
|
| 130 |
+
)
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
function InputGroupTextarea({
|
| 134 |
+
className,
|
| 135 |
+
...props
|
| 136 |
+
}: React.ComponentProps<"textarea">) {
|
| 137 |
+
return (
|
| 138 |
+
<Textarea
|
| 139 |
+
data-slot="input-group-control"
|
| 140 |
+
className={cn(
|
| 141 |
+
"flex-1 resize-none rounded-none border-0 bg-transparent py-2 shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0 dark:bg-transparent dark:disabled:bg-transparent",
|
| 142 |
+
className
|
| 143 |
+
)}
|
| 144 |
+
{...props}
|
| 145 |
+
/>
|
| 146 |
+
)
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
export {
|
| 150 |
+
InputGroup,
|
| 151 |
+
InputGroupAddon,
|
| 152 |
+
InputGroupButton,
|
| 153 |
+
InputGroupText,
|
| 154 |
+
InputGroupInput,
|
| 155 |
+
InputGroupTextarea,
|
| 156 |
+
}
|
chess-frontend/components/ui/input.tsx
CHANGED
|
@@ -8,7 +8,7 @@ function Input({ className, type, ...props }: React.ComponentProps<"input">) {
|
|
| 8 |
type={type}
|
| 9 |
data-slot="input"
|
| 10 |
className={cn(
|
| 11 |
-
"h-8 w-full min-w-0 rounded-
|
| 12 |
className
|
| 13 |
)}
|
| 14 |
{...props}
|
|
|
|
| 8 |
type={type}
|
| 9 |
data-slot="input"
|
| 10 |
className={cn(
|
| 11 |
+
"h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",
|
| 12 |
className
|
| 13 |
)}
|
| 14 |
{...props}
|
chess-frontend/components/ui/label.tsx
CHANGED
|
@@ -13,7 +13,7 @@ function Label({
|
|
| 13 |
<LabelPrimitive.Root
|
| 14 |
data-slot="label"
|
| 15 |
className={cn(
|
| 16 |
-
"flex items-center gap-2 text-
|
| 17 |
className
|
| 18 |
)}
|
| 19 |
{...props}
|
|
|
|
| 13 |
<LabelPrimitive.Root
|
| 14 |
data-slot="label"
|
| 15 |
className={cn(
|
| 16 |
+
"flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
|
| 17 |
className
|
| 18 |
)}
|
| 19 |
{...props}
|
chess-frontend/components/ui/sonner.tsx
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
|
| 3 |
import { useTheme } from "next-themes"
|
| 4 |
import { Toaster as Sonner, type ToasterProps } from "sonner"
|
| 5 |
-
import {
|
| 6 |
|
| 7 |
const Toaster = ({ ...props }: ToasterProps) => {
|
| 8 |
const { theme = "system" } = useTheme()
|
|
@@ -13,19 +13,19 @@ const Toaster = ({ ...props }: ToasterProps) => {
|
|
| 13 |
className="toaster group"
|
| 14 |
icons={{
|
| 15 |
success: (
|
| 16 |
-
<
|
| 17 |
),
|
| 18 |
info: (
|
| 19 |
<InfoIcon className="size-4" />
|
| 20 |
),
|
| 21 |
warning: (
|
| 22 |
-
<
|
| 23 |
),
|
| 24 |
error: (
|
| 25 |
-
<
|
| 26 |
),
|
| 27 |
loading: (
|
| 28 |
-
<
|
| 29 |
),
|
| 30 |
}}
|
| 31 |
style={
|
|
|
|
| 2 |
|
| 3 |
import { useTheme } from "next-themes"
|
| 4 |
import { Toaster as Sonner, type ToasterProps } from "sonner"
|
| 5 |
+
import { CircleCheckIcon, InfoIcon, TriangleAlertIcon, OctagonXIcon, Loader2Icon } from "lucide-react"
|
| 6 |
|
| 7 |
const Toaster = ({ ...props }: ToasterProps) => {
|
| 8 |
const { theme = "system" } = useTheme()
|
|
|
|
| 13 |
className="toaster group"
|
| 14 |
icons={{
|
| 15 |
success: (
|
| 16 |
+
<CircleCheckIcon className="size-4" />
|
| 17 |
),
|
| 18 |
info: (
|
| 19 |
<InfoIcon className="size-4" />
|
| 20 |
),
|
| 21 |
warning: (
|
| 22 |
+
<TriangleAlertIcon className="size-4" />
|
| 23 |
),
|
| 24 |
error: (
|
| 25 |
+
<OctagonXIcon className="size-4" />
|
| 26 |
),
|
| 27 |
loading: (
|
| 28 |
+
<Loader2Icon className="size-4 animate-spin" />
|
| 29 |
),
|
| 30 |
}}
|
| 31 |
style={
|
chess-frontend/components/ui/table.tsx
CHANGED
|
@@ -12,7 +12,7 @@ function Table({ className, ...props }: React.ComponentProps<"table">) {
|
|
| 12 |
>
|
| 13 |
<table
|
| 14 |
data-slot="table"
|
| 15 |
-
className={cn("w-full caption-bottom text-
|
| 16 |
{...props}
|
| 17 |
/>
|
| 18 |
</div>
|
|
@@ -57,7 +57,7 @@ function TableRow({ className, ...props }: React.ComponentProps<"tr">) {
|
|
| 57 |
<tr
|
| 58 |
data-slot="table-row"
|
| 59 |
className={cn(
|
| 60 |
-
"border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",
|
| 61 |
className
|
| 62 |
)}
|
| 63 |
{...props}
|
|
@@ -98,7 +98,7 @@ function TableCaption({
|
|
| 98 |
return (
|
| 99 |
<caption
|
| 100 |
data-slot="table-caption"
|
| 101 |
-
className={cn("mt-4 text-
|
| 102 |
{...props}
|
| 103 |
/>
|
| 104 |
)
|
|
|
|
| 12 |
>
|
| 13 |
<table
|
| 14 |
data-slot="table"
|
| 15 |
+
className={cn("w-full caption-bottom text-sm", className)}
|
| 16 |
{...props}
|
| 17 |
/>
|
| 18 |
</div>
|
|
|
|
| 57 |
<tr
|
| 58 |
data-slot="table-row"
|
| 59 |
className={cn(
|
| 60 |
+
"border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",
|
| 61 |
className
|
| 62 |
)}
|
| 63 |
{...props}
|
|
|
|
| 98 |
return (
|
| 99 |
<caption
|
| 100 |
data-slot="table-caption"
|
| 101 |
+
className={cn("mt-4 text-sm text-muted-foreground", className)}
|
| 102 |
{...props}
|
| 103 |
/>
|
| 104 |
)
|
chess-frontend/components/ui/tabs.tsx
CHANGED
|
@@ -25,7 +25,7 @@ function Tabs({
|
|
| 25 |
}
|
| 26 |
|
| 27 |
const tabsListVariants = cva(
|
| 28 |
-
"group/tabs-list inline-flex w-fit items-center justify-center rounded-
|
| 29 |
{
|
| 30 |
variants: {
|
| 31 |
variant: {
|
|
@@ -63,7 +63,7 @@ function TabsTrigger({
|
|
| 63 |
<TabsPrimitive.Trigger
|
| 64 |
data-slot="tabs-trigger"
|
| 65 |
className={cn(
|
| 66 |
-
"relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-
|
| 67 |
"group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent",
|
| 68 |
"data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground",
|
| 69 |
"after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100",
|
|
@@ -81,7 +81,7 @@ function TabsContent({
|
|
| 81 |
return (
|
| 82 |
<TabsPrimitive.Content
|
| 83 |
data-slot="tabs-content"
|
| 84 |
-
className={cn("flex-1 text-
|
| 85 |
{...props}
|
| 86 |
/>
|
| 87 |
)
|
|
|
|
| 25 |
}
|
| 26 |
|
| 27 |
const tabsListVariants = cva(
|
| 28 |
+
"group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none",
|
| 29 |
{
|
| 30 |
variants: {
|
| 31 |
variant: {
|
|
|
|
| 63 |
<TabsPrimitive.Trigger
|
| 64 |
data-slot="tabs-trigger"
|
| 65 |
className={cn(
|
| 66 |
+
"relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 dark:text-muted-foreground dark:hover:text-foreground group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
| 67 |
"group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent",
|
| 68 |
"data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground",
|
| 69 |
"after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100",
|
|
|
|
| 81 |
return (
|
| 82 |
<TabsPrimitive.Content
|
| 83 |
data-slot="tabs-content"
|
| 84 |
+
className={cn("flex-1 text-sm outline-none", className)}
|
| 85 |
{...props}
|
| 86 |
/>
|
| 87 |
)
|
chess-frontend/components/ui/textarea.tsx
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react"
|
| 2 |
+
|
| 3 |
+
import { cn } from "@/lib/utils"
|
| 4 |
+
|
| 5 |
+
function Textarea({ className, ...props }: React.ComponentProps<"textarea">) {
|
| 6 |
+
return (
|
| 7 |
+
<textarea
|
| 8 |
+
data-slot="textarea"
|
| 9 |
+
className={cn(
|
| 10 |
+
"flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-transparent px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",
|
| 11 |
+
className
|
| 12 |
+
)}
|
| 13 |
+
{...props}
|
| 14 |
+
/>
|
| 15 |
+
)
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
export { Textarea }
|
chess-frontend/hooks/use-websocket.ts
CHANGED
|
@@ -85,6 +85,12 @@ export function useWebSocket(user: User) {
|
|
| 85 |
store.setRematchOfferSent(DRAW_OFFER.DECLINE);
|
| 86 |
setTimeout(() => store.setRematchOfferSent(null), 5000);
|
| 87 |
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
}
|
| 89 |
} catch (err) {
|
| 90 |
console.error("[WS] Failed to parse message:", err);
|
|
@@ -110,7 +116,6 @@ export function useWebSocket(user: User) {
|
|
| 110 |
wsRef.current = ws;
|
| 111 |
|
| 112 |
ws.onopen = () => {
|
| 113 |
-
console.log("[WS] Connected, requesting sync...");
|
| 114 |
store.setConnection(WS_CONNECTION_STATUS.CONNECTED);
|
| 115 |
|
| 116 |
ws.send(JSON.stringify({ type: WsMessageType.SYNC_GAME }));
|
|
@@ -237,6 +242,15 @@ export function useWebSocket(user: User) {
|
|
| 237 |
|
| 238 |
send(WsMessageType.LEAVE_SPECTATOR, { gameId });
|
| 239 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 240 |
}),
|
| 241 |
[connect, send],
|
| 242 |
);
|
|
|
|
| 85 |
store.setRematchOfferSent(DRAW_OFFER.DECLINE);
|
| 86 |
setTimeout(() => store.setRematchOfferSent(null), 5000);
|
| 87 |
break;
|
| 88 |
+
case WsMessageType.NEW_GAME_CHAT:
|
| 89 |
+
store.addChatMessage(msg.payload);
|
| 90 |
+
break;
|
| 91 |
+
case WsMessageType.PLAYER_RECONNECTED:
|
| 92 |
+
case WsMessageType.PLAYER_DISCONNECTED:
|
| 93 |
+
break;
|
| 94 |
}
|
| 95 |
} catch (err) {
|
| 96 |
console.error("[WS] Failed to parse message:", err);
|
|
|
|
| 116 |
wsRef.current = ws;
|
| 117 |
|
| 118 |
ws.onopen = () => {
|
|
|
|
| 119 |
store.setConnection(WS_CONNECTION_STATUS.CONNECTED);
|
| 120 |
|
| 121 |
ws.send(JSON.stringify({ type: WsMessageType.SYNC_GAME }));
|
|
|
|
| 242 |
|
| 243 |
send(WsMessageType.LEAVE_SPECTATOR, { gameId });
|
| 244 |
},
|
| 245 |
+
sendChatMessage: (gameId: string, content: string) => {
|
| 246 |
+
send(WsMessageType.SEND_GAME_CHAT, { gameId, content });
|
| 247 |
+
},
|
| 248 |
+
joinGameChat: (gameId: string) => {
|
| 249 |
+
send(WsMessageType.JOIN_GAME_CHAT, { gameId });
|
| 250 |
+
},
|
| 251 |
+
leaveGameChat: (gameId: string) => {
|
| 252 |
+
send(WsMessageType.LEAVE_GAME_CHAT, { gameId });
|
| 253 |
+
},
|
| 254 |
}),
|
| 255 |
[connect, send],
|
| 256 |
);
|
chess-frontend/lib/constants/get-initials.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export function getInitials(name?: string): string {
|
| 2 |
+
if (!name || typeof name !== "string") return "";
|
| 3 |
+
|
| 4 |
+
return name
|
| 5 |
+
.trim()
|
| 6 |
+
.split(/\s+/)
|
| 7 |
+
.filter(Boolean)
|
| 8 |
+
.map((word) => word[0])
|
| 9 |
+
.join("")
|
| 10 |
+
.toUpperCase();
|
| 11 |
+
}
|
chess-frontend/lib/constants/safe-fetch.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { api } from "../clients/server";
|
| 2 |
+
|
| 3 |
+
type ApiResponse<T> = {
|
| 4 |
+
data: T;
|
| 5 |
+
};
|
| 6 |
+
|
| 7 |
+
export async function safeFetch<T>(
|
| 8 |
+
url: string,
|
| 9 |
+
options?: RequestInit,
|
| 10 |
+
): Promise<T | null> {
|
| 11 |
+
try {
|
| 12 |
+
const res = await api(url, options);
|
| 13 |
+
|
| 14 |
+
if (!res.ok) return null;
|
| 15 |
+
|
| 16 |
+
const json: ApiResponse<T> = await res.json();
|
| 17 |
+
|
| 18 |
+
if (!json?.data) return null;
|
| 19 |
+
|
| 20 |
+
return json.data;
|
| 21 |
+
} catch (error) {
|
| 22 |
+
console.error(`Fetch failed for ${url}:`, error);
|
| 23 |
+
return null;
|
| 24 |
+
}
|
| 25 |
+
}
|
chess-frontend/next.config.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
| 1 |
import type { NextConfig } from "next";
|
| 2 |
|
| 3 |
-
const nextConfig: NextConfig = {
|
| 4 |
-
/* config options here */
|
| 5 |
-
};
|
| 6 |
|
| 7 |
export default nextConfig;
|
|
|
|
| 1 |
import type { NextConfig } from "next";
|
| 2 |
|
| 3 |
+
const nextConfig: NextConfig = {};
|
|
|
|
|
|
|
| 4 |
|
| 5 |
export default nextConfig;
|
chess-frontend/package.json
CHANGED
|
@@ -13,14 +13,16 @@
|
|
| 13 |
"chess.js": "^1.4.0",
|
| 14 |
"class-variance-authority": "^0.7.1",
|
| 15 |
"clsx": "^2.1.1",
|
| 16 |
-
"
|
|
|
|
|
|
|
| 17 |
"next": "16.1.6",
|
| 18 |
"next-themes": "^0.4.6",
|
| 19 |
"radix-ui": "^1.4.3",
|
| 20 |
"react": "19.2.3",
|
| 21 |
"react-chessboard": "^5.10.0",
|
| 22 |
"react-dom": "19.2.3",
|
| 23 |
-
"shadcn": "^4.
|
| 24 |
"sonner": "^2.0.7",
|
| 25 |
"tailwind-merge": "^3.5.0",
|
| 26 |
"tw-animate-css": "^1.4.0",
|
|
|
|
| 13 |
"chess.js": "^1.4.0",
|
| 14 |
"class-variance-authority": "^0.7.1",
|
| 15 |
"clsx": "^2.1.1",
|
| 16 |
+
"cmdk": "^1.1.1",
|
| 17 |
+
"framer-motion": "^12.38.0",
|
| 18 |
+
"lucide-react": "^1.7.0",
|
| 19 |
"next": "16.1.6",
|
| 20 |
"next-themes": "^0.4.6",
|
| 21 |
"radix-ui": "^1.4.3",
|
| 22 |
"react": "19.2.3",
|
| 23 |
"react-chessboard": "^5.10.0",
|
| 24 |
"react-dom": "19.2.3",
|
| 25 |
+
"shadcn": "^4.1.2",
|
| 26 |
"sonner": "^2.0.7",
|
| 27 |
"tailwind-merge": "^3.5.0",
|
| 28 |
"tw-animate-css": "^1.4.0",
|
chess-frontend/store/socket-provider.tsx
CHANGED
|
@@ -31,6 +31,10 @@ type SocketContextType = {
|
|
| 31 |
acceptRematch: (gameId: string, timeControl: string) => void;
|
| 32 |
spectateGame: (gameId: string) => void;
|
| 33 |
leaveSpectator: (gameId: string) => void;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
};
|
| 35 |
|
| 36 |
const SocketContext = createContext<SocketContextType | null>(null);
|
|
@@ -113,14 +117,19 @@ export function SocketProvider({
|
|
| 113 |
acceptRematch: wsApi.acceptRematch,
|
| 114 |
spectateGame: wsApi.spectateGame,
|
| 115 |
leaveSpectator: wsApi.leaveSpectator,
|
|
|
|
|
|
|
|
|
|
| 116 |
}),
|
| 117 |
[wsApi],
|
| 118 |
);
|
| 119 |
|
| 120 |
return (
|
| 121 |
<SocketContext.Provider value={contextValue}>
|
| 122 |
-
{isTransitioning ?
|
| 123 |
-
|
|
|
|
|
|
|
| 124 |
<div className="flex flex-col items-center gap-4 animate-pulse">
|
| 125 |
<span className="text-6xl drop-shadow-lg select-none">♟</span>
|
| 126 |
<p className="text-zinc-400 font-mono text-sm font-semibold tracking-widest uppercase">
|
|
@@ -128,8 +137,6 @@ export function SocketProvider({
|
|
| 128 |
</p>
|
| 129 |
</div>
|
| 130 |
</div>
|
| 131 |
-
) : (
|
| 132 |
-
children
|
| 133 |
)}
|
| 134 |
</SocketContext.Provider>
|
| 135 |
);
|
|
|
|
| 31 |
acceptRematch: (gameId: string, timeControl: string) => void;
|
| 32 |
spectateGame: (gameId: string) => void;
|
| 33 |
leaveSpectator: (gameId: string) => void;
|
| 34 |
+
|
| 35 |
+
joinGameChat: (gameId: string) => void;
|
| 36 |
+
sendChatMessage: (gameId: string, content: string) => void;
|
| 37 |
+
leaveGameChat: (gameId: string) => void;
|
| 38 |
};
|
| 39 |
|
| 40 |
const SocketContext = createContext<SocketContextType | null>(null);
|
|
|
|
| 117 |
acceptRematch: wsApi.acceptRematch,
|
| 118 |
spectateGame: wsApi.spectateGame,
|
| 119 |
leaveSpectator: wsApi.leaveSpectator,
|
| 120 |
+
joinGameChat: wsApi.joinGameChat,
|
| 121 |
+
sendChatMessage: wsApi.sendChatMessage,
|
| 122 |
+
leaveGameChat: wsApi.leaveGameChat,
|
| 123 |
}),
|
| 124 |
[wsApi],
|
| 125 |
);
|
| 126 |
|
| 127 |
return (
|
| 128 |
<SocketContext.Provider value={contextValue}>
|
| 129 |
+
<div className={isTransitioning ? "hidden" : "contents"}>{children}</div>
|
| 130 |
+
|
| 131 |
+
{isTransitioning && (
|
| 132 |
+
<div className="fixed inset-0 z-50 min-h-screen flex items-center justify-center bg-zinc-950 text-white">
|
| 133 |
<div className="flex flex-col items-center gap-4 animate-pulse">
|
| 134 |
<span className="text-6xl drop-shadow-lg select-none">♟</span>
|
| 135 |
<p className="text-zinc-400 font-mono text-sm font-semibold tracking-widest uppercase">
|
|
|
|
| 137 |
</p>
|
| 138 |
</div>
|
| 139 |
</div>
|
|
|
|
|
|
|
| 140 |
)}
|
| 141 |
</SocketContext.Provider>
|
| 142 |
);
|
chess-frontend/store/use-game-store.ts
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
| 15 |
DRAW_OFFER,
|
| 16 |
WS_CONNECTION_STATUS,
|
| 17 |
RematchOfferState,
|
|
|
|
| 18 |
} from "@/types/chess";
|
| 19 |
import { User } from "@/types/auth";
|
| 20 |
|
|
@@ -32,6 +33,7 @@ interface GameStore {
|
|
| 32 |
rematchOfferSent: DRAW_OFFER.SENT | DRAW_OFFER.DECLINE | null;
|
| 33 |
lastMoveRejectedReason: string | null;
|
| 34 |
showAnimations: boolean;
|
|
|
|
| 35 |
|
| 36 |
setConnection: (status: WsConnectionStatus) => void;
|
| 37 |
setUser: (user: User | null) => void;
|
|
@@ -51,6 +53,7 @@ interface GameStore {
|
|
| 51 |
handleMoveMade: (p: MoveMadePayload) => void;
|
| 52 |
handleMoveRejected: (reason: string) => void;
|
| 53 |
handleGameOver: (p: GameOverState) => void;
|
|
|
|
| 54 |
resetGame: () => void;
|
| 55 |
}
|
| 56 |
|
|
@@ -68,6 +71,7 @@ export const useGameStore = create<GameStore>((set) => ({
|
|
| 68 |
rematchOfferSent: null,
|
| 69 |
lastMoveRejectedReason: null,
|
| 70 |
showAnimations: true,
|
|
|
|
| 71 |
|
| 72 |
setConnection: (connectionStatus) => set({ connectionStatus }),
|
| 73 |
setUser: (user) => set({ user }),
|
|
@@ -90,6 +94,7 @@ export const useGameStore = create<GameStore>((set) => ({
|
|
| 90 |
gameOver: null,
|
| 91 |
rematchOffer: null,
|
| 92 |
rematchOfferSent: null,
|
|
|
|
| 93 |
activeGame: {
|
| 94 |
gameId: p.gameId,
|
| 95 |
fen: p.fen,
|
|
@@ -179,6 +184,15 @@ export const useGameStore = create<GameStore>((set) => ({
|
|
| 179 |
rematchOfferSent: null,
|
| 180 |
})),
|
| 181 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
resetGame: () =>
|
| 183 |
set({
|
| 184 |
activeGame: null,
|
|
@@ -190,5 +204,6 @@ export const useGameStore = create<GameStore>((set) => ({
|
|
| 190 |
drawOfferSent: null,
|
| 191 |
rematchOffer: null,
|
| 192 |
rematchOfferSent: null,
|
|
|
|
| 193 |
}),
|
| 194 |
}));
|
|
|
|
| 15 |
DRAW_OFFER,
|
| 16 |
WS_CONNECTION_STATUS,
|
| 17 |
RematchOfferState,
|
| 18 |
+
ChatMessagePayload,
|
| 19 |
} from "@/types/chess";
|
| 20 |
import { User } from "@/types/auth";
|
| 21 |
|
|
|
|
| 33 |
rematchOfferSent: DRAW_OFFER.SENT | DRAW_OFFER.DECLINE | null;
|
| 34 |
lastMoveRejectedReason: string | null;
|
| 35 |
showAnimations: boolean;
|
| 36 |
+
chatMessages: ChatMessagePayload[];
|
| 37 |
|
| 38 |
setConnection: (status: WsConnectionStatus) => void;
|
| 39 |
setUser: (user: User | null) => void;
|
|
|
|
| 53 |
handleMoveMade: (p: MoveMadePayload) => void;
|
| 54 |
handleMoveRejected: (reason: string) => void;
|
| 55 |
handleGameOver: (p: GameOverState) => void;
|
| 56 |
+
addChatMessage: (msg: ChatMessagePayload) => void;
|
| 57 |
resetGame: () => void;
|
| 58 |
}
|
| 59 |
|
|
|
|
| 71 |
rematchOfferSent: null,
|
| 72 |
lastMoveRejectedReason: null,
|
| 73 |
showAnimations: true,
|
| 74 |
+
chatMessages: [],
|
| 75 |
|
| 76 |
setConnection: (connectionStatus) => set({ connectionStatus }),
|
| 77 |
setUser: (user) => set({ user }),
|
|
|
|
| 94 |
gameOver: null,
|
| 95 |
rematchOffer: null,
|
| 96 |
rematchOfferSent: null,
|
| 97 |
+
chatMessages: [], // Clear chat when a new game starts
|
| 98 |
activeGame: {
|
| 99 |
gameId: p.gameId,
|
| 100 |
fen: p.fen,
|
|
|
|
| 184 |
rematchOfferSent: null,
|
| 185 |
})),
|
| 186 |
|
| 187 |
+
addChatMessage: (msg: ChatMessagePayload) =>
|
| 188 |
+
set((state) => {
|
| 189 |
+
if (state.activeGame?.gameId !== msg.gameId) {
|
| 190 |
+
return state;
|
| 191 |
+
}
|
| 192 |
+
const { gameId, ...rest } = msg;
|
| 193 |
+
return { chatMessages: [...state.chatMessages, rest] };
|
| 194 |
+
}),
|
| 195 |
+
|
| 196 |
resetGame: () =>
|
| 197 |
set({
|
| 198 |
activeGame: null,
|
|
|
|
| 204 |
drawOfferSent: null,
|
| 205 |
rematchOffer: null,
|
| 206 |
rematchOfferSent: null,
|
| 207 |
+
chatMessages: [],
|
| 208 |
}),
|
| 209 |
}));
|
chess-frontend/types/auth.ts
CHANGED
|
@@ -1,54 +1,52 @@
|
|
| 1 |
-
import * as z from "zod"
|
| 2 |
|
| 3 |
export const loginSchema = z.object({
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
),
|
| 22 |
});
|
| 23 |
|
| 24 |
export type LoginInput = z.infer<typeof loginSchema>;
|
| 25 |
|
| 26 |
-
|
| 27 |
export type User = {
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
};
|
| 41 |
|
| 42 |
export type AuthResponse = {
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
};
|
| 49 |
|
| 50 |
export type LoginResponse = {
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
};
|
|
|
|
| 1 |
+
import * as z from "zod";
|
| 2 |
|
| 3 |
export const loginSchema = z.object({
|
| 4 |
+
email: z
|
| 5 |
+
.string({ error: "Email is required" })
|
| 6 |
+
.min(1, "Email is required")
|
| 7 |
+
.trim()
|
| 8 |
+
.toLowerCase()
|
| 9 |
+
.refine((val) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(val), {
|
| 10 |
+
error: "Must be a valid email address",
|
| 11 |
+
}),
|
| 12 |
+
password: z
|
| 13 |
+
.string({ error: "Password is required" })
|
| 14 |
+
.min(1, "Password is required")
|
| 15 |
+
.min(8, "Must be at least 8 characters")
|
| 16 |
+
.max(128, "Must not exceed 128 characters")
|
| 17 |
+
.regex(
|
| 18 |
+
/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]/,
|
| 19 |
+
"Must contain uppercase, lowercase, number, and special character",
|
| 20 |
+
),
|
|
|
|
| 21 |
});
|
| 22 |
|
| 23 |
export type LoginInput = z.infer<typeof loginSchema>;
|
| 24 |
|
|
|
|
| 25 |
export type User = {
|
| 26 |
+
id: string;
|
| 27 |
+
email: string;
|
| 28 |
+
name: string;
|
| 29 |
+
username: string;
|
| 30 |
+
wins: number;
|
| 31 |
+
losses: number;
|
| 32 |
+
draws: number;
|
| 33 |
+
image: string | null;
|
| 34 |
+
rating: number;
|
| 35 |
+
emailVerified: boolean;
|
| 36 |
+
createdAt: Date;
|
| 37 |
+
updatedAt?: Date;
|
| 38 |
};
|
| 39 |
|
| 40 |
export type AuthResponse = {
|
| 41 |
+
user: User;
|
| 42 |
+
session: {
|
| 43 |
+
token: string;
|
| 44 |
+
expiresAt: string;
|
| 45 |
+
};
|
| 46 |
};
|
| 47 |
|
| 48 |
export type LoginResponse = {
|
| 49 |
+
user: User;
|
| 50 |
+
token: string;
|
| 51 |
+
redirect: boolean;
|
| 52 |
+
};
|
chess-frontend/types/chess.ts
CHANGED
|
@@ -25,7 +25,18 @@ export enum WsMessageType {
|
|
| 25 |
GAME_STATE = "GAME_STATE",
|
| 26 |
SPECTATE_GAME = "SPECTATE_GAME",
|
| 27 |
LEAVE_SPECTATOR = "LEAVE_SPECTATOR",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
ERROR = "ERROR",
|
|
|
|
|
|
|
| 29 |
}
|
| 30 |
|
| 31 |
export enum GameStatus {
|
|
@@ -111,6 +122,16 @@ export type RematchOfferState = z.infer<typeof RematchOfferStateSchema>;
|
|
| 111 |
|
| 112 |
export type DrawOfferState = z.infer<typeof DrawOfferStateSchema>;
|
| 113 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
export const GameStateUserSchema = PlayerInfoSchema.extend({
|
| 115 |
timeLeftMs: z.number(),
|
| 116 |
capturedPieces: z.array(z.string()).optional().default([]),
|
|
@@ -124,6 +145,11 @@ export const MoveMadeUserSchema = z.object({
|
|
| 124 |
capturedPieces: z.array(z.string()).optional().default([]),
|
| 125 |
});
|
| 126 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
export const GameStartedPayloadSchema = z.object({
|
| 128 |
gameId: z.string(),
|
| 129 |
fen: z.string(),
|
|
@@ -244,6 +270,18 @@ export const ServerMessageSchema = z.discriminatedUnion("type", [
|
|
| 244 |
type: z.literal(WsMessageType.ERROR),
|
| 245 |
payload: z.union([z.string(), z.object({ message: z.string() })]),
|
| 246 |
}),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 247 |
]);
|
| 248 |
|
| 249 |
export type ServerMessage = z.infer<typeof ServerMessageSchema>;
|
|
|
|
| 25 |
GAME_STATE = "GAME_STATE",
|
| 26 |
SPECTATE_GAME = "SPECTATE_GAME",
|
| 27 |
LEAVE_SPECTATOR = "LEAVE_SPECTATOR",
|
| 28 |
+
|
| 29 |
+
SEND_GAME_CHAT = "SEND_GAME_CHAT",
|
| 30 |
+
NEW_GAME_CHAT = "NEW_GAME_CHAT",
|
| 31 |
+
RECEIVE_CHAT_MESSAGE = "RECEIVE_CHAT_MESSAGE",
|
| 32 |
+
CHAT_MESSAGE_ACK = "CHAT_MESSAGE_ACK",
|
| 33 |
+
|
| 34 |
+
JOIN_GAME_CHAT = "JOIN_GAME_CHAT",
|
| 35 |
+
LEAVE_GAME_CHAT = "LEAVE_GAME_CHAT",
|
| 36 |
+
|
| 37 |
ERROR = "ERROR",
|
| 38 |
+
PLAYER_RECONNECTED = "PLAYER_RECONNECTED",
|
| 39 |
+
PLAYER_DISCONNECTED = "PLAYER_DISCONNECTED",
|
| 40 |
}
|
| 41 |
|
| 42 |
export enum GameStatus {
|
|
|
|
| 122 |
|
| 123 |
export type DrawOfferState = z.infer<typeof DrawOfferStateSchema>;
|
| 124 |
|
| 125 |
+
export const ChatMessageSchema = z.object({
|
| 126 |
+
id: z.string().optional(),
|
| 127 |
+
gameId: z.string().optional(),
|
| 128 |
+
sender: PlayerInfoSchema,
|
| 129 |
+
content: z.string(),
|
| 130 |
+
createdAt: z.union([z.string(), z.number(), z.date()]).optional(),
|
| 131 |
+
});
|
| 132 |
+
|
| 133 |
+
export type ChatMessagePayload = z.infer<typeof ChatMessageSchema>;
|
| 134 |
+
|
| 135 |
export const GameStateUserSchema = PlayerInfoSchema.extend({
|
| 136 |
timeLeftMs: z.number(),
|
| 137 |
capturedPieces: z.array(z.string()).optional().default([]),
|
|
|
|
| 145 |
capturedPieces: z.array(z.string()).optional().default([]),
|
| 146 |
});
|
| 147 |
|
| 148 |
+
export const PlayerConnectionPayloadSchema = z.object({
|
| 149 |
+
color: z.string(),
|
| 150 |
+
userId: z.string(),
|
| 151 |
+
});
|
| 152 |
+
|
| 153 |
export const GameStartedPayloadSchema = z.object({
|
| 154 |
gameId: z.string(),
|
| 155 |
fen: z.string(),
|
|
|
|
| 270 |
type: z.literal(WsMessageType.ERROR),
|
| 271 |
payload: z.union([z.string(), z.object({ message: z.string() })]),
|
| 272 |
}),
|
| 273 |
+
z.object({
|
| 274 |
+
type: z.literal(WsMessageType.NEW_GAME_CHAT),
|
| 275 |
+
payload: ChatMessageSchema,
|
| 276 |
+
}),
|
| 277 |
+
z.object({
|
| 278 |
+
type: z.literal(WsMessageType.PLAYER_RECONNECTED),
|
| 279 |
+
payload: PlayerConnectionPayloadSchema,
|
| 280 |
+
}),
|
| 281 |
+
z.object({
|
| 282 |
+
type: z.literal(WsMessageType.PLAYER_DISCONNECTED),
|
| 283 |
+
payload: PlayerConnectionPayloadSchema,
|
| 284 |
+
}),
|
| 285 |
]);
|
| 286 |
|
| 287 |
export type ServerMessage = z.infer<typeof ServerMessageSchema>;
|
chess-frontend/types/friends.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { User } from "./auth";
|
| 2 |
+
|
| 3 |
+
export enum FriendStatus {
|
| 4 |
+
PENDING = "PENDING",
|
| 5 |
+
ACCEPTED = "ACCEPTED",
|
| 6 |
+
REJECTED = "REJECTED",
|
| 7 |
+
BLOCKED = "BLOCKED",
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
export type GetFriend = Omit<User, "email" | "emailVerified" | "updatedAt">;
|
| 11 |
+
|
| 12 |
+
export type SearchFriend = Omit<
|
| 13 |
+
GetFriend,
|
| 14 |
+
"wins" | "losses" | "draws" | "createdAt"
|
| 15 |
+
> & {
|
| 16 |
+
friendStatus:
|
| 17 |
+
| FriendStatus.PENDING
|
| 18 |
+
| FriendStatus.ACCEPTED
|
| 19 |
+
| FriendStatus.REJECTED
|
| 20 |
+
| FriendStatus.BLOCKED
|
| 21 |
+
| null;
|
| 22 |
+
};
|
chess-frontend/types/history.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { GameStatus } from "./chess";
|
| 2 |
+
|
| 3 |
+
export type Player = {
|
| 4 |
+
id: string;
|
| 5 |
+
username: string;
|
| 6 |
+
currentRating: number;
|
| 7 |
+
matchRating: number;
|
| 8 |
+
diff: number;
|
| 9 |
+
};
|
| 10 |
+
|
| 11 |
+
export type GameRecord = {
|
| 12 |
+
id: string;
|
| 13 |
+
status: GameStatus;
|
| 14 |
+
timeControl: string;
|
| 15 |
+
createdAt: string;
|
| 16 |
+
winnerId: string | null;
|
| 17 |
+
result: string;
|
| 18 |
+
finalFen: string;
|
| 19 |
+
pgn: string;
|
| 20 |
+
moveTimes: number[];
|
| 21 |
+
white: Player;
|
| 22 |
+
black: Player;
|
| 23 |
+
};
|
chess-frontend/types/index.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export type ApiResponse<T> = {
|
| 2 |
+
success: boolean;
|
| 3 |
+
data: T;
|
| 4 |
+
};
|