colored & linked name for registered users

This commit is contained in:
Nathaniel Tampus
2023-04-05 23:37:07 +08:00
parent d01bb43004
commit 8d7ad6161f
3 changed files with 70 additions and 9 deletions

View File

@@ -183,13 +183,33 @@ export default function ArchivedGame({ game }: { game: Game }) {
function getPlayerHtml(side: "top" | "bottom") { function getPlayerHtml(side: "top" | "bottom") {
const blackHtml = ( const blackHtml = (
<div className="flex w-full flex-col justify-center"> <div className="flex w-full flex-col justify-center">
<span className="font-bold">{game.black?.name}</span> <a
className={
"font-bold" +
(typeof game.black?.id === "number" ? " text-primary link-hover" : " cursor-default")
}
href={typeof game.black?.id === "number" ? `/user/${game.black?.name}` : undefined}
target="_blank"
rel="noreferrer"
>
{game.black?.name}
</a>
<span className="flex items-center gap-1 text-xs">black</span> <span className="flex items-center gap-1 text-xs">black</span>
</div> </div>
); );
const whiteHtml = ( const whiteHtml = (
<div className="flex w-full flex-col justify-center"> <div className="flex w-full flex-col justify-center">
<span className="font-bold">{game.white?.name}</span> <a
className={
"font-bold" +
(typeof game.white?.id === "number" ? " text-primary link-hover" : " cursor-default")
}
href={typeof game.white?.id === "number" ? `/user/${game.white?.name}` : undefined}
target="_blank"
rel="noreferrer"
>
{game.white?.name}
</a>
<span className="flex items-center gap-1 text-xs">white</span> <span className="flex items-center gap-1 text-xs">white</span>
</div> </div>
); );

View File

@@ -360,9 +360,17 @@ export default function GamePage({ initialLobby }: { initialLobby: Game }) {
function getPlayerHtml(side: "top" | "bottom") { function getPlayerHtml(side: "top" | "bottom") {
const blackHtml = ( const blackHtml = (
<div className="flex w-full flex-col justify-center"> <div className="flex w-full flex-col justify-center">
<span className={lobby.black?.name ? "font-bold" : ""}> <a
className={
(lobby.black?.name ? "font-bold" : "") +
(typeof lobby.black?.id === "number" ? " text-primary link-hover" : " cursor-default")
}
href={typeof lobby.black?.id === "number" ? `/user/${lobby.black?.name}` : undefined}
target="_blank"
rel="noreferrer"
>
{lobby.black?.name || "(no one)"} {lobby.black?.name || "(no one)"}
</span> </a>
<span className="flex items-center gap-1 text-xs"> <span className="flex items-center gap-1 text-xs">
black black
{lobby.black?.connected === false && ( {lobby.black?.connected === false && (
@@ -373,9 +381,17 @@ export default function GamePage({ initialLobby }: { initialLobby: Game }) {
); );
const whiteHtml = ( const whiteHtml = (
<div className="flex w-full flex-col justify-center"> <div className="flex w-full flex-col justify-center">
<span className={lobby.white?.name ? "font-bold" : ""}> <a
className={
(lobby.white?.name ? "font-bold" : "") +
(typeof lobby.white?.id === "number" ? " text-primary link-hover" : " cursor-default")
}
href={typeof lobby.white?.id === "number" ? `/user/${lobby.white?.name}` : undefined}
target="_blank"
rel="noreferrer"
>
{lobby.white?.name || "(no one)"} {lobby.white?.name || "(no one)"}
</span> </a>
<span className="flex items-center gap-1 text-xs"> <span className="flex items-center gap-1 text-xs">
white white
{lobby.white?.connected === false && ( {lobby.white?.connected === false && (
@@ -691,7 +707,22 @@ export default function GamePage({ initialLobby }: { initialLobby: Game }) {
<span> <span>
{m.author.id && ( {m.author.id && (
<span> <span>
<span className="font-bold">{m.author.name}</span>:{" "} <a
className={
"font-bold" +
(typeof m.author.id === "number"
? " text-primary link-hover"
: " cursor-default")
}
href={
typeof m.author.id === "number" ? `/user/${m.author.name}` : undefined
}
target="_blank"
rel="noreferrer"
>
{m.author.name}
</a>
:{" "}
</span> </span>
)} )}
<span>{m.message}</span> <span>{m.message}</span>

View File

@@ -24,8 +24,18 @@ export default async function PublicGames() {
{games && games.length > 0 ? ( {games && games.length > 0 ? (
games.map((game) => ( games.map((game) => (
<tr key={game.code} className="group"> <tr key={game.code} className="group">
<td>{game.host?.name}</td> <td className={typeof game.host?.id === "number" ? "text-primary" : ""}>
<td> {game.host?.name}
</td>
<td
className={
typeof (game.host?.id === game.white?.id
? game.black?.id
: game.white?.id) === "number"
? "text-primary"
: ""
}
>
{(game.host?.id === game.white?.id ? game.black?.name : game.white?.name) || ""} {(game.host?.id === game.white?.id ? game.black?.name : game.white?.name) || ""}
</td> </td>
<th> <th>