This commit is contained in:
chuan_yu
2024-11-22 17:00:58 +08:00
parent 0a502ab93e
commit aa6a33f70a
14 changed files with 6220 additions and 156 deletions

View File

@@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
<title>privy-cross-app</title>
</head>
<body>
<div id="root"></div>

View File

@@ -4,14 +4,19 @@
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"start": "vite",
"build": "tsc -b && vite build",
"lint": "eslint .",
"preview": "vite preview"
"preview": "vite preview",
"prettier": "prettier --write 'src/**/*.{ts,tsx}'"
},
"dependencies": {
"@privy-io/react-auth": "^1.94.3",
"autoprefixer": "^10.4.20",
"react": "^18.3.1",
"react-dom": "^18.3.1"
"react-dom": "^18.3.1",
"react-router": "^7.0.0",
"react-router-dom": "^7.0.0"
},
"devDependencies": {
"@eslint/js": "^9.13.0",
@@ -22,6 +27,9 @@
"eslint-plugin-react-hooks": "^5.0.0",
"eslint-plugin-react-refresh": "^0.4.14",
"globals": "^15.11.0",
"postcss-import": "^16.1.0",
"prettier": "^3.3.3",
"tailwindcss": "^3.4.15",
"typescript": "~5.6.2",
"typescript-eslint": "^8.11.0",
"vite": "^5.4.10"

6111
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

13
postcss.config.js Normal file
View File

@@ -0,0 +1,13 @@
export default {
content: [
"./index.html",
"./src/**/*.{js,ts,jsx,tsx}",
],
theme: {
extend: {},
},
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}

BIN
public/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@@ -1,42 +0,0 @@
#root {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}
.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
transition: filter 300ms;
}
.logo:hover {
filter: drop-shadow(0 0 2em #646cffaa);
}
.logo.react:hover {
filter: drop-shadow(0 0 2em #61dafbaa);
}
@keyframes logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
@media (prefers-reduced-motion: no-preference) {
a:nth-of-type(2) .logo {
animation: logo-spin infinite 20s linear;
}
}
.card {
padding: 2em;
}
.read-the-docs {
color: #888;
}

View File

@@ -1,35 +0,0 @@
import { useState } from 'react'
import reactLogo from './assets/react.svg'
import viteLogo from '/vite.svg'
import './App.css'
function App() {
const [count, setCount] = useState(0)
return (
<>
<div>
<a href="https://vite.dev" target="_blank">
<img src={viteLogo} className="logo" alt="Vite logo" />
</a>
<a href="https://react.dev" target="_blank">
<img src={reactLogo} className="logo react" alt="React logo" />
</a>
</div>
<h1>Vite + React</h1>
<div className="card">
<button onClick={() => setCount((count) => count + 1)}>
count is {count}
</button>
<p>
Edit <code>src/App.tsx</code> and save to test HMR
</p>
</div>
<p className="read-the-docs">
Click on the Vite and React logos to learn more
</p>
</>
)
}
export default App

View File

@@ -1,68 +0,0 @@
:root {
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
line-height: 1.5;
font-weight: 400;
color-scheme: light dark;
color: rgba(255, 255, 255, 0.87);
background-color: #242424;
font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
a {
font-weight: 500;
color: #646cff;
text-decoration: inherit;
}
a:hover {
color: #535bf2;
}
body {
margin: 0;
display: flex;
place-items: center;
min-width: 320px;
min-height: 100vh;
}
h1 {
font-size: 3.2em;
line-height: 1.1;
}
button {
border-radius: 8px;
border: 1px solid transparent;
padding: 0.6em 1.2em;
font-size: 1em;
font-weight: 500;
font-family: inherit;
background-color: #1a1a1a;
cursor: pointer;
transition: border-color 0.25s;
}
button:hover {
border-color: #646cff;
}
button:focus,
button:focus-visible {
outline: 4px auto -webkit-focus-ring-color;
}
@media (prefers-color-scheme: light) {
:root {
color: #213547;
background-color: #ffffff;
}
a:hover {
color: #747bff;
}
button {
background-color: #f9f9f9;
}
}

View File

@@ -1,10 +1,35 @@
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import './index.css'
import App from './App.tsx'
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import "./styles/index.css";
import { PrivyProvider } from "@privy-io/react-auth";
import {
createBrowserRouter,
createRoutesFromElements,
RouterProvider,
} from "react-router-dom";
import { createRoutes } from "./routes/routeDefs.tsx";
createRoot(document.getElementById('root')!).render(
const APP_ID = "cm3sfyo5805w5ncgkld7gj7in";
createRoot(document.getElementById("root")!).render(
<StrictMode>
<App />
<PrivyProvider
appId={APP_ID}
config={{
loginMethods: ["email"],
appearance: {
theme: "light",
accentColor: "#676FFF",
logo: "/logo.png",
},
embeddedWallets: {
createOnLogin: "users-without-wallets",
},
}}
>
<RouterProvider
router={createBrowserRouter(createRoutesFromElements(createRoutes()))}
/>
</PrivyProvider>
</StrictMode>,
)
);

3
src/pages/App/index.tsx Normal file
View File

@@ -0,0 +1,3 @@
export const AppPage = () => {
return <div className='h-screen flex 1'>app</div>;
};

25
src/pages/Login/index.tsx Normal file
View File

@@ -0,0 +1,25 @@
import { useLogin } from "@privy-io/react-auth";
import { useNavigate } from "react-router";
export const LoginPage = () => {
const navigate = useNavigate();
const { login } = useLogin({
onComplete: () => {
navigate("/app");
},
onError: (error) => {
console.log(error);
},
});
return (
<div className="h-screen flex justify-center items-center">
<button
className="bg-blue-100 p-6 text-2xl rounded-3xl"
onClick={() => login()}
>
Login
</button>
</div>
);
};

12
src/routes/routeDefs.tsx Normal file
View File

@@ -0,0 +1,12 @@
import { Route } from "react-router";
import { LoginPage } from "../pages/Login";
import { AppPage } from "../pages/App";
export const createRoutes = (): JSX.Element => {
return (
<Route>
<Route path="/" element={<LoginPage />} />
<Route path="/app" element={<AppPage />} />
</Route>
);
};

4
src/styles/index.css Normal file
View File

@@ -0,0 +1,4 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

8
tailwind.config.js Normal file
View File

@@ -0,0 +1,8 @@
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ["./src/**/*.{js,jsx,ts,tsx}"],
theme: {
extend: {},
},
plugins: [],
};