aboutsummaryrefslogtreecommitdiffhomepage
path: root/frontend/app/components/Gaming/CodePopover.tsx
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-03-29 01:51:53 +0900
committernsfisis <nsfisis@gmail.com>2025-03-29 01:51:53 +0900
commit3ea0b8e93ea2735feacc8b7253bc0b32a5aa2bb6 (patch)
treec4766f3f0c23cedd80bf8d8042516ba428645e99 /frontend/app/components/Gaming/CodePopover.tsx
parent7e94e4d2f8ccce36165cd5f2a092a2ba7645d69c (diff)
downloadiosdc-japan-2025-albatross-3ea0b8e93ea2735feacc8b7253bc0b32a5aa2bb6.tar.gz
iosdc-japan-2025-albatross-3ea0b8e93ea2735feacc8b7253bc0b32a5aa2bb6.tar.zst
iosdc-japan-2025-albatross-3ea0b8e93ea2735feacc8b7253bc0b32a5aa2bb6.zip
feat: show code in ranking page
Diffstat (limited to 'frontend/app/components/Gaming/CodePopover.tsx')
-rw-r--r--frontend/app/components/Gaming/CodePopover.tsx43
1 files changed, 43 insertions, 0 deletions
diff --git a/frontend/app/components/Gaming/CodePopover.tsx b/frontend/app/components/Gaming/CodePopover.tsx
new file mode 100644
index 0000000..a574a77
--- /dev/null
+++ b/frontend/app/components/Gaming/CodePopover.tsx
@@ -0,0 +1,43 @@
+import { Popover } from "@base-ui-components/react/popover";
+import { faCode, faXmark } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { calcCodeSize } from "../../states/play";
+import BorderedContainer from "../BorderedContainer";
+import CodeBlock from "../Gaming/CodeBlock";
+
+type Props = {
+ code: string;
+};
+
+export default function CodePopover({ code }: Props) {
+ const codeSize = calcCodeSize(code);
+
+ return (
+ <Popover.Root>
+ <Popover.Trigger>
+ <FontAwesomeIcon icon={faCode} fixedWidth />
+ </Popover.Trigger>
+ <Popover.Portal>
+ <Popover.Positioner>
+ <Popover.Popup>
+ <BorderedContainer className="grow flex flex-col gap-4">
+ <div className="flex flex-row gap-2 items-center">
+ <div className="grow font-semibold text-lg">
+ コードサイズ: {codeSize}
+ </div>
+ <Popover.Close className="p-1 bg-gray-50 border-1 border-gray-300 rounded-sm">
+ <FontAwesomeIcon
+ icon={faXmark}
+ fixedWidth
+ className="text-gray-500"
+ />
+ </Popover.Close>
+ </div>
+ <CodeBlock code={code} language="php" />
+ </BorderedContainer>
+ </Popover.Popup>
+ </Popover.Positioner>
+ </Popover.Portal>
+ </Popover.Root>
+ );
+}