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

Card issue #265

Merged
merged 3 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
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
60 changes: 60 additions & 0 deletions web/src/components/BanLandscape.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { useCallback, useEffect, useState } from "react";

const BanLandscape = () => {
const [isLandscape, setIsLandscape] = useState(false);

const checkOrientation = useCallback(() => {
const userAgent = navigator.userAgent;
const isMobile = /iPhone|Android|Mobile/i.test(userAgent);
if (isMobile) {
setIsLandscape(window.innerHeight < window.innerWidth);
} else {
setIsLandscape(false); // モバイルデバイスでない場合は常に縦画面扱い
}
}, []);

useEffect(() => {
checkOrientation();
window.addEventListener("resize", checkOrientation);
return () => {
window.removeEventListener("resize", checkOrientation);
};
}, [checkOrientation]);

return (
<div style={{ position: "relative", width: "100%", height: "100%" }}>
{isLandscape && (
<div
style={{
position: "fixed",
top: 0,
left: 0,
right: 0,
bottom: 0,
backgroundColor: "rgba(0, 0, 0, 0.7)",
display: "flex",
justifyContent: "center",
alignItems: "center",
zIndex: 1000,
}}
>
<div
style={{
backgroundColor: "white",
padding: "20px",
borderRadius: "10px",
boxShadow: "0 2px 10px rgba(0, 0, 0, 0.5)",
textAlign: "center",
fontSize: "20px",
color: "#333",
}}
>
このアプリは縦画面で使用してください
</div>
</div>
)}
</div>
);
};

export default BanLandscape;
4 changes: 2 additions & 2 deletions web/src/components/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const CardFront = ({ displayedUser }: CardProps) => {
border: "2px solid #3596C6",
padding: "10px",
height: "100%",
overflow: "scroll",
overflow: "hidden",
}}
>
<div
Expand Down Expand Up @@ -116,7 +116,7 @@ const CardBack = ({ displayedUser }: CardProps) => {
border: "2px solid #3596C6",
padding: "10px",
height: "100%",
overflow: "scroll",
overflow: "hidden",
}}
>
<div style={{ display: "flex", justifyContent: "center" }}>
Expand Down
1 change: 1 addition & 0 deletions web/src/components/DraggableCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export const DraggableCard = ({
handleDragEnd();
}}
style={{ x: dragX, y: dragY, padding: "10px" }}
whileTap={{ scale: 0.95 }}
>
<Card displayedUser={displayedUser} />
</motion.div>
Expand Down
2 changes: 2 additions & 0 deletions web/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import "@fontsource/roboto/500.css";
import "@fontsource/roboto/700.css";
import { CssBaseline } from "@mui/material";
import App from "./App";
import BanLandscape from "./components/BanLandscape";
import { AlertProvider } from "./components/common/alert/AlertProvider";
import { ModalProvider } from "./components/common/modal/ModalProvider";
import AuthProvider from "./firebase/auth/AuthProvider";
Expand All @@ -19,6 +20,7 @@ ReactDOM.createRoot(root).render(
<CssBaseline />
<AlertProvider>
<ModalProvider>
<BanLandscape />
<App />
</ModalProvider>
</AlertProvider>
Expand Down
Loading