feat: CopyableCode styles and remove DEV name fallback

This commit is contained in:
GonnaHetzMe committed 2026-03-25 17:25:52 +01:00
1 parent 4cdb712013
commit 5b9ff7acb3
3 files changed
+40 -16

No files matched your search

@@ -61,7 +61,12 @@ export function ArmorPlateDisplay() {
<>
<Text mt="2" color="gray" size="2">
<b>DEV:</b>{" "}
<CopyableCode copy={highlightArmor.name}>
<CopyableCode
copy={highlightArmor.name}
variant="soft"
highContrast
color="gray"
>
{highlightArmor.name}
</CopyableCode>
</Text>
@@ -1,29 +1,37 @@
import { Code, Tooltip } from "@radix-ui/themes";
import { useState, type ReactNode } from "react";
import { Code, Tooltip, type CodeProps } from "@radix-ui/themes";
import { useState } from "react";
import { useLocale } from "../hooks/useLocale";
interface CopyableCodeProps {
export interface CopyableCodeProps extends CodeProps {
copy?: string;
children: ReactNode;
}
export function CopyableCode({ copy, children }: CopyableCodeProps) {
export function CopyableCode({
copy,
onClick,
onPointerLeave,
style,
children,
...props
}: CopyableCodeProps) {
const [copied, setCopied] = useState(false);
const { strings } = useLocale();
return (
<Tooltip open={copied} content={strings.website.common.copy_button.copied}>
<Code
variant="soft"
highContrast
color="gray"
style={{ cursor: copy ? "copy" : "default" }}
onClick={() => {
{...props}
style={{ ...(copy ? { cursor: "copy" } : {}), ...style }}
onClick={(event) => {
onClick?.(event);
if (!copy) return;
navigator.clipboard.writeText(copy);
setCopied(true);
}}
onPointerLeave={() => setCopied(false)}
onPointerLeave={(event) => {
onPointerLeave?.(event);
setCopied(false);
}}
>
{children}
</Code>
@@ -24,6 +24,7 @@ export function MetaSection() {
const protagonist = Duel.use((state) => state.protagonist.tank);
const ClassIcon = classIcons[protagonist.class];
const { locale, strings } = useLocale();
const devName = (protagonist as { dev_name?: string }).dev_name;
return (
<Flex justify="center" mt="-9">
@@ -102,17 +103,27 @@ export function MetaSection() {
<Listing
label={strings.website.tools.tankopedia.meta.dev_id}
>
<CopyableCode copy={`${protagonist.id}`}>
<CopyableCode
copy={`${protagonist.id}`}
variant="soft"
highContrast
color="gray"
>
{protagonist.id}
</CopyableCode>
</Listing>
)}
{developerMode && (
{developerMode && devName && (
<Listing
label={strings.website.tools.tankopedia.meta.dev_name}
>
<CopyableCode copy={protagonist.dev_name}>
{protagonist.dev_name ?? '-'}
<CopyableCode
copy={devName}
variant="soft"
highContrast
color="gray"
>
{devName}
</CopyableCode>
</Listing>
)}