From 0ab9bdf4ad937913dd3a29dbddf93f09b57deedd Mon Sep 17 00:00:00 2001 From: nsfisis Date: Fri, 21 Mar 2025 00:44:20 +0900 Subject: feat(frontend): make container foldable --- .../FoldableBorderedContainerWithCaption.tsx | 45 ++++++++++++++++++++++ frontend/app/components/Gaming/ProblemColumn.tsx | 14 +++---- .../GolfWatchApps/GolfWatchAppGaming1v1.tsx | 20 +++++----- 3 files changed, 61 insertions(+), 18 deletions(-) create mode 100644 frontend/app/components/FoldableBorderedContainerWithCaption.tsx (limited to 'frontend/app/components') diff --git a/frontend/app/components/FoldableBorderedContainerWithCaption.tsx b/frontend/app/components/FoldableBorderedContainerWithCaption.tsx new file mode 100644 index 0000000..2d21b61 --- /dev/null +++ b/frontend/app/components/FoldableBorderedContainerWithCaption.tsx @@ -0,0 +1,45 @@ +import { faChevronDown, faChevronUp } from "@fortawesome/free-solid-svg-icons"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import React, { useState } from "react"; +import BorderedContainer from "./BorderedContainer"; + +type Props = { + caption: string; + children: React.ReactNode; +}; + +export default function FoldableBorderedContainerWithCaption({ + caption, + children, +}: Props) { + const [isOpen, setIsOpen] = useState(true); + + const handleToggle = () => { + setIsOpen((prev) => !prev); + }; + + return ( + +
+
+
+

{caption}

+
+
+ +
+
+
{children}
+
+
+ ); +} diff --git a/frontend/app/components/Gaming/ProblemColumn.tsx b/frontend/app/components/Gaming/ProblemColumn.tsx index 2a57afd..922cbe7 100644 --- a/frontend/app/components/Gaming/ProblemColumn.tsx +++ b/frontend/app/components/Gaming/ProblemColumn.tsx @@ -1,4 +1,4 @@ -import BorderedContainerWithCaption from "../BorderedContainerWithCaption"; +import FoldableBorderedContainerWithCaption from "../FoldableBorderedContainerWithCaption"; import TitledColumn from "../TitledColumn"; import CodeBlock from "./CodeBlock"; import InlineCode from "./InlineCode"; @@ -16,15 +16,15 @@ export default function ProblemColumn({ }: Props) { return ( - +
 					{description}
 				
-
- + + - - + +

スコアはコード中の全 ASCII @@ -54,7 +54,7 @@ export default function ProblemColumn({ に設定されています。

-
+
); } diff --git a/frontend/app/components/GolfWatchApps/GolfWatchAppGaming1v1.tsx b/frontend/app/components/GolfWatchApps/GolfWatchAppGaming1v1.tsx index 5b975e7..a647214 100644 --- a/frontend/app/components/GolfWatchApps/GolfWatchAppGaming1v1.tsx +++ b/frontend/app/components/GolfWatchApps/GolfWatchAppGaming1v1.tsx @@ -5,7 +5,7 @@ import { latestGameStatesAtom, } from "../../states/watch"; import type { PlayerProfile } from "../../types/PlayerProfile"; -import BorderedContainer from "../BorderedContainer"; +import FoldableBorderedContainerWithCaption from "../FoldableBorderedContainerWithCaption"; import CodeBlock from "../Gaming/CodeBlock"; import LeftTime from "../Gaming/LeftTime"; import ProblemColumn from "../Gaming/ProblemColumn"; @@ -109,12 +109,11 @@ export default function GolfWatchAppGaming1v1({ /> }> - -
- コードサイズ: {codeSizeA} -
+ -
+
}> - -
- コードサイズ: {codeSizeB} -
+ -
+
-- cgit v1.2.3-70-g09d2