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

Vercel react components [DO NOT MERGE] #458

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
6 changes: 3 additions & 3 deletions examples/react-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
"@mui/material": "^6.1.5",
"@noble/hashes": "1.4.0",
"@solana/web3.js": "^1.95.8",
"@turnkey/sdk-browser": "workspace:*",
"@turnkey/sdk-react": "workspace:*",
"@turnkey/sdk-server": "workspace:*",
"@turnkey/sdk-browser": "^1.11.0",
"@turnkey/sdk-react": "^2.00",
"@turnkey/sdk-server": "^1.7.0",
"@types/node": "20.3.1",
"@types/react": "18.2.14",
"@types/react-dom": "18.2.6",
Expand Down
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);
}
38 changes: 38 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,22 @@ export default function AuthPage() {
},
});

useEffect(() => {
const checkMobile = () => {
const userAgent = navigator.userAgent || navigator.vendor;
const mobileRegex =
/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i;
setIsMobile(mobileRegex.test(userAgent.toLowerCase()));
};
checkMobile();
window.addEventListener("resize", checkMobile);
return () => window.removeEventListener("resize", checkMobile);
}, []);
useEffect(() => {
if (isMobile) {
setShowContent(false);
}
}, [isMobile]);
useEffect(() => {
const manageSession = async () => {
if (turnkey) {
Expand Down Expand Up @@ -164,6 +182,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
6 changes: 3 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading