Skip to content

Commit

Permalink
add mobile viewing block
Browse files Browse the repository at this point in the history
  • Loading branch information
moe-dev committed Dec 18, 2024
1 parent bed1022 commit f52b04f
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 0 deletions.
50 changes: 50 additions & 0 deletions examples/react-components/src/app/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,53 @@ body {
.sonner-toaster > div {
pointer-events: auto;
}
.mobile-warning {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
padding: 16px;
background: rgba(255, 255, 255, 0.8);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background-image: url("../../public/grid.svg");
background-size: cover;
background-repeat: no-repeat;
background-position: center;
}

.mobile-content {
text-align: center;
}
.warning-text {
margin-bottom: 20px;
font-size: 1.2rem;
font-weight: bold;
}

.continueButton {
padding: 10px 16px 10px 16px;
gap: 8px;
color: #ffffff;
width: 50%;
font-size: 1rem;
background: var(--Greyscale-900, #2b2f33);
border: 1px solid var(--Greyscale-800, #3f464b);
border-radius: 8px;
cursor: pointer;
transition: 0.3s ease;
}

.continueButton:disabled {
color: var(--Greyscale-700, #a2a7ae);
background: #ffffff;
border-color: var(--Greyscale-400, #a2a7ae);
cursor: not-allowed;
}

.continueButton:hover {
background-color: var(--Greyscale-700, #4a4f55);
}
32 changes: 32 additions & 0 deletions examples/react-components/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export default function AuthPage() {
router.push("/dashboard");
};
const { turnkey } = useTurnkey();
const [isMobile, setIsMobile] = useState(false);
const [showContent, setShowContent] = useState(!isMobile);
const [configOrder, setConfigOrder] = useState([
"socials",
"email",
Expand All @@ -67,6 +69,16 @@ export default function AuthPage() {
},
});

useEffect(() => {
const checkMobile = () => {
setIsMobile(window.innerWidth <= 768);
setShowContent(window.innerWidth > 768);
};
checkMobile();
window.addEventListener("resize", checkMobile);
return () => window.removeEventListener("resize", checkMobile);
}, []);

useEffect(() => {
const manageSession = async () => {
if (turnkey) {
Expand Down Expand Up @@ -164,6 +176,26 @@ export default function AuthPage() {
setConfigOrder(reorderedConfig);
};

if (isMobile && !showContent) {
return (
<main>
<div className="mobile-warning">
<div className="mobile-content">
<div className="warning-text">
For the best experience, please view this demo on a desktop.
</div>
<button
className="continueButton"
onClick={() => setShowContent(true)}
>
Continue Anyway
</button>
</div>
</div>
</main>
);
}

return (
<main className="main">
<Navbar />
Expand Down

0 comments on commit f52b04f

Please sign in to comment.