Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

Commit

Permalink
fix: 余計なくblankの削除
Browse files Browse the repository at this point in the history
  • Loading branch information
Sea10wood committed Aug 10, 2024
1 parent 249cef2 commit 15f6c4b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
35 changes: 20 additions & 15 deletions src/pages/home/index.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
import { useEffect, useState } from "react";
import { DefaultButton } from "../../components/ui/Button";
import styles from "./index.module.css";
import { device } from "../../utils/device";
import styles from "./index.module.css";

function Home() {
const [isPcScreen, setIsPcScreen] = useState(window.matchMedia(device.pc).matches);
const [isPcScreen, setIsPcScreen] = useState(
window.matchMedia(device.pc).matches,
);

useEffect(() => {
const mediaQuery = window.matchMedia(device.pc);
const mediaQuery = window.matchMedia(device.pc);

const handleChange = (event: { matches: boolean | ((prevState: boolean) => boolean); }) => {
setIsPcScreen(event.matches);
};
const handleChange = (event: {
matches: boolean | ((prevState: boolean) => boolean);
}) => {
setIsPcScreen(event.matches);
};

mediaQuery.addEventListener('change', handleChange);
return () => {
mediaQuery.removeEventListener('change', handleChange);
};
}, []);
mediaQuery.addEventListener("change", handleChange);
return () => {
mediaQuery.removeEventListener("change", handleChange);
};
}, []);

const handleClick = () => {
window.location.href = isPcScreen ? '/gallery' : '/shooter';
};

window.location.href = isPcScreen ? "/gallery" : "/shooter";
};

return (
<div>
Expand Down Expand Up @@ -51,7 +54,9 @@ function Home() {
height="350"
/>
</div>
<div className={`${styles["go-game"]} ${isPcScreen ? styles["go-game-pc"] : ''}`}>
<div
className={`${styles["go-game"]} ${isPcScreen ? styles["go-game-pc"] : ""}`}
>
<DefaultButton color="red" size="lg" onClick={handleClick}>
射的へ向かう
</DefaultButton>
Expand Down
4 changes: 2 additions & 2 deletions src/utils/device.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const device = {
pc: '(min-width: 1024px)',
};
pc: "(min-width: 1024px)",
};

0 comments on commit 15f6c4b

Please sign in to comment.