-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
51 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { ReactNode, useState } from "react"; | ||
import { Tooltip } from "react-daisyui"; | ||
|
||
export default function CopyTootrip({ | ||
children, | ||
copyText, | ||
className, | ||
}: { | ||
children: ReactNode; | ||
copyText: string; | ||
className?: string; | ||
}) { | ||
const defaultMsg = "クリックしてコピー"; | ||
const [tooltipMsg, setTooltipMsg] = useState(defaultMsg); | ||
|
||
const handleClick = (/*e: MouseEvent<HTMLDivElement, globalThis.MouseEvent>*/) => { | ||
navigator.clipboard.writeText(copyText); | ||
setTooltipMsg("コピーしました"); | ||
}; | ||
|
||
const handleMouseOut = () => { | ||
setTooltipMsg(defaultMsg); | ||
}; | ||
|
||
const handleMouseOver = (/*e: React.MouseEvent<HTMLDivElement, MouseEvent>*/) => { | ||
setTimeout(() => { | ||
setTooltipMsg(defaultMsg); | ||
}, 2000); | ||
}; | ||
|
||
return ( | ||
<> | ||
<Tooltip | ||
message={tooltipMsg} | ||
onClick={handleClick} | ||
onMouseOut={handleMouseOut} | ||
onMouseOver={handleMouseOver} | ||
className={className} | ||
> | ||
{children} | ||
</Tooltip> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ import classNames from "classnames"; | |
import { useEffect, useState } from "react"; | ||
|
||
import { StorageTool } from "../../class/StorageTool"; | ||
import CopyTootrip from "../../components/CopyBtn"; | ||
import Heading from "../../components/Heading"; | ||
import { Switches } from "../../components/Switches"; | ||
import IsTrue from "../../utils/isTrue"; | ||
|
@@ -27,9 +28,9 @@ export default function Top() { | |
|
||
<ConfigSection name="群馬大学学務課・メディアセンターの方へ"> | ||
<p>このソフトウェアについて問題がある場合は以下のメールアドレスまでご連絡ください。</p> | ||
<a href="mailto:[email protected]" className="btn btn-neutral my-5"> | ||
[email protected] | ||
</a> | ||
<CopyTootrip copyText="[email protected]" className="my-5"> | ||
<button className="btn btn-neutral">[email protected]</button> | ||
</CopyTootrip> | ||
</ConfigSection> | ||
</> | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters