Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ボタンを実装 #116

Merged
merged 1 commit into from
Oct 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 26 additions & 19 deletions src/components/PageTransitionButton.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useRouter } from "next/router";
import { motion } from "framer-motion";
import { useState } from "react";

export const PageTransitionButton = ({
buttonText,
Expand All @@ -9,38 +10,44 @@ export const PageTransitionButton = ({
nextPage: string;
}) => {
const router = useRouter();
const [isClicked, setIsClicked] = useState(false);

const handleClick = () => {
setIsClicked(true);
router.push("/contents/" + nextPage, undefined, { scroll: false });
return;
};

return (
<div onClick={handleClick}>
<motion.div
style={{
width: "8vw",
height: "4vw",
backgroundColor: "white",
display: "flex",
alignItems: "center", // 垂直方向の中央寄せ
justifyContent: "center", // 水平方向の中央寄せ
cursor: "pointer",
backgroundColor: "white",
textAlign: "center",
verticalAlign: "middle",
textDecoration: "none",
position: "relative",
margin: "auto",
width: "18vw",
height: "6vw",
padding: "0.5vw 5vw",
fontWeight: "bold",
borderRadius: "1.2vw",
color: "#27acd9",
border: "0.5vw solid #27acd9",
fontSize: "2.5vw",
}}
initial={{
boxShadow: "0.7vw 0.7vw #27acd9",
}}
whileTap={{
scale: 0.8,
boxShadow: "0 0 1vw rgba(0, 0, 0, 0.3)",
animate={{
boxShadow: isClicked ? "0vw 0vw #27acd9" : "0.7vw 0.7vw #27acd9",
}}
>
<p
style={{
display: "flex",
justifyContent: "center",
alignItems: "center",
height: "100%",
color: "black",
fontSize: "1.3vw",
}}
>
{buttonText}
</p>
{buttonText}
</motion.div>
</div>
);
Expand Down
Loading