diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-09-17 18:59:32 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-09-17 18:59:32 +0900 |
| commit | 516e81953173ced9209ebea955b86da589e5f2f6 (patch) | |
| tree | 242e7fa138983bd17e293c86b9055c148439d847 /frontend/app/components/Gaming | |
| parent | 611d93ea8a5dcc7dd92ec412e8fb28078438b31b (diff) | |
| download | iosdc-japan-2025-albatross-516e81953173ced9209ebea955b86da589e5f2f6.tar.gz iosdc-japan-2025-albatross-516e81953173ced9209ebea955b86da589e5f2f6.tar.zst iosdc-japan-2025-albatross-516e81953173ced9209ebea955b86da589e5f2f6.zip | |
feat(frontend): do not show copy button if code is empty
Diffstat (limited to 'frontend/app/components/Gaming')
| -rw-r--r-- | frontend/app/components/Gaming/CodeBlock.tsx | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/frontend/app/components/Gaming/CodeBlock.tsx b/frontend/app/components/Gaming/CodeBlock.tsx index 360f352..f1516ed 100644 --- a/frontend/app/components/Gaming/CodeBlock.tsx +++ b/frontend/app/components/Gaming/CodeBlock.tsx @@ -25,16 +25,18 @@ export default function CodeBlock({ code, language }: Props) { return ( <div className="relative"> - <button - onClick={handleCopy} - className="absolute top-2 right-2 z-10 px-2 py-1 bg-white border border-gray-300 rounded shadow-md hover:bg-gray-100 transition-colors" - title="コードをコピーする" - > - <FontAwesomeIcon icon={faCopy} className="text-gray-600" /> - {showCopied && ( - <span className="ml-1 text-xs text-blue-600">Copied!</span> - )} - </button> + {code !== "" && ( + <button + onClick={handleCopy} + className="absolute top-2 right-2 z-10 px-2 py-1 bg-white border border-gray-300 rounded shadow-md hover:bg-gray-100 transition-colors" + title="コードをコピーする" + > + <FontAwesomeIcon icon={faCopy} className="text-gray-600" /> + {showCopied && ( + <span className="ml-1 text-xs text-blue-600">Copied!</span> + )} + </button> + )} <pre className="h-full w-full p-2 bg-gray-50 rounded-lg border border-gray-300 whitespace-pre-wrap break-words"> {nodes === null ? <code>{code}</code> : nodes} </pre> |
