From f3025fed714777e48776f9277eb42ee9448e9f72 Mon Sep 17 00:00:00 2001 From: wappon28dev Date: Thu, 5 Oct 2023 03:18:21 +0900 Subject: [PATCH] =?UTF-8?q?Add:=20=E3=83=9C=E3=82=A4=E3=83=9C=E5=AF=AE?= =?UTF-8?q?=E3=82=AD=E3=83=A3=E3=83=A9=E3=82=AF=E3=82=BF=E3=83=BC=E3=81=AE?= =?UTF-8?q?=E5=91=BC=E7=A7=B0=E3=81=AE=E3=82=B3=E3=83=94=E3=83=BC=E6=A9=9F?= =?UTF-8?q?=E8=83=BD=20+=20=E3=83=AA=E3=83=95=E3=82=A1=E3=82=AF=E3=82=BF?= =?UTF-8?q?=E3=83=AA=E3=83=B3=E3=82=B0=20(#168)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Hiroshiba --- src/components/layout.scss | 25 +- src/pages/dormitory.tsx | 2 +- .../{call_names/index.tsx => call_names.tsx} | 216 ++++++++++++------ 3 files changed, 167 insertions(+), 76 deletions(-) rename src/pages/dormitory/{call_names/index.tsx => call_names.tsx} (53%) diff --git a/src/components/layout.scss b/src/components/layout.scss index 8a0240cb..c6227ba1 100644 --- a/src/components/layout.scss +++ b/src/components/layout.scss @@ -892,6 +892,7 @@ $call-names-cell-width-column: 190px; position: sticky; top: 0; left: 0; + z-index: 1; } th, @@ -932,10 +933,32 @@ $call-names-cell-width-column: 190px; flex-direction: column; justify-content: center; + position: relative; + + // コピーボタン + .icon { + @extend .m-1; + + visibility: hidden; + position: absolute; + height: 1rem; + width: 1rem; + top: 0; + right: 0; + + &.selected { + visibility: visible; + } + } + &:hover { // NOTE: ちらつくので border ではなく outline outline: 2px solid; border-radius: $radius; + + .icon { + visibility: visible; + } } } } @@ -950,7 +973,7 @@ $call-names-cell-width-column: 190px; // 左上のセル &.origin { width: $call-names-cell-width-column; - z-index: 1; + z-index: 2; border-right: $call-names-border; } diff --git a/src/pages/dormitory.tsx b/src/pages/dormitory.tsx index ba8eb27f..0820613c 100644 --- a/src/pages/dormitory.tsx +++ b/src/pages/dormitory.tsx @@ -285,7 +285,7 @@ const Dormitory: React.FC = ({ setShowingHeader }) => {

関連コンテンツ

- ) + const [selectedCallName, setSelectedCallName] = useState() + const [showCopiedIcon, setShowCopiedIcon] = useState(false) + + const callNameInfo = callNameInfos[characterKey] + const characterInfo = characterInfos[characterKey] + const outlineStyle: CSSProperties = { + outlineColor: characterInfo.color, } - function getColumn(characterKey: CharacterKey): ReactElement { - const callNameInfo = callNameInfos[characterKey] - const characterInfo = characterInfos[characterKey] + useEffect(() => { + if (selectedCallName == undefined) return + + const timer = setTimeout(() => { + setShowCopiedIcon(false) + }, 1500) - const outlineStyle: CSSProperties = { - outlineColor: characterInfo.color, + return () => { + clearTimeout(timer) } + }, [showCopiedIcon, selectedCallName]) + + function copyToClipboard(event: MouseEvent): void { + const callName = event.currentTarget.innerText + + setSelectedCallName(callName) + navigator.clipboard.writeText(callName) + setShowCopiedIcon(true) + } + + function Cell({ + callName, + externalClassName, + }: { + callName: string + externalClassName?: string + }): ReactElement { + const isSelected = selectedCallName === callName && showCopiedIcon return ( - <> - {characterKeys.map(_characterKey => { - const callName = callNameInfo[_characterKey] - - return ( - -
- {(() => { - if (characterKey === _characterKey) { - return callNameInfo.me.map(part => ( -

- {part} -

- )) - } - - if (callName == undefined) { - return ( -

- ? -

- ) - } - - return callName.split("/").map(part => ( -

- {part} +

+ + + + {callName} +

+ ) + } + + return ( + <> + {characterKeys.map(_characterKey => { + const callName = callNameInfo[_characterKey] + + return ( + +
+ {(() => { + if (_characterKey === characterKey) { + return callNameInfo.me.map(part => ( + + )) + } + + if (callName == undefined) { + return ( +

+ ?

+ ) + } + + return callName + .split("/") + .map(part => ( + )) - })()} -
- - ) - })} - -
- {callNameInfo.you.map(part => ( -

- {part} -

- ))} -
- - + })()} +
+ + ) + })} + +
+ {callNameInfo.you.map(part => ( + + ))} +
+ + + ) +} + +export default function CallNamesPage() { + const { characterInfos } = useDetailedCharacterInfo() + const { characterKeys } = useContext(CharacterContext) + + function CharacterImage({ + characterKey, + }: { + characterKey: CharacterKey + }): ReactElement { + const characterInfo = characterInfos[characterKey] + return ( + {characterInfo.name} ) } @@ -138,7 +211,7 @@ export default function CallNamesPage() { return ( - {getCharacterImage(characterKey)} +

+ - {getCharacterImage(characterKey)} +

- {getColumn(characterKey)} + ) })}