Compare commits

...

13 Commits
authjs ... main

Author SHA1 Message Date
3370ab6a03 added spinner to signin button
All checks were successful
Vercel Production Deployment / Deploy-Production (push) Successful in 2m28s
2024-05-17 23:22:31 +02:00
6f18a4cb48 fixed css
All checks were successful
Vercel Production Deployment / Deploy-Production (push) Successful in 2m8s
2024-05-17 11:31:09 +02:00
2999c79995 and typo
All checks were successful
Vercel Production Deployment / Deploy-Production (push) Successful in 2m12s
2024-05-17 11:21:51 +02:00
9b32a5e8bb typo
Some checks failed
Vercel Production Deployment / Deploy-Production (push) Has been cancelled
2024-05-17 11:21:12 +02:00
89e39240a1 Merge branch 'main' of https://gitea.rannes.dev/rannes.dev/titles
Some checks failed
Vercel Production Deployment / Deploy-Production (push) Has been cancelled
2024-05-17 11:20:53 +02:00
8daa0f4032 updated readme 2024-05-17 11:20:51 +02:00
fc33072e84 Merge pull request 'Set up next-theme and dark mode with toggle example' (#5) from next-themes into main
Some checks failed
Vercel Production Deployment / Deploy-Production (push) Failing after 48s
Reviewed-on: #5
2024-05-17 09:16:36 +00:00
6dd60de8f4 Set up next-theme and dark mode with toggle example
All checks were successful
Vercel Preview Deployment / Deploy-Preview (push) Successful in 2m7s
2024-05-17 11:16:20 +02:00
77b60eda84 Merge pull request 'added darkmode class in tailwind conf' (#4) from framer-nextui into main
All checks were successful
Vercel Production Deployment / Deploy-Production (push) Successful in 2m2s
Vercel Preview Deployment / Deploy-Preview (push) Successful in 2m8s
Reviewed-on: #4
2024-05-17 09:02:52 +00:00
8a4d912202 added darkmode class in tailwind conf
All checks were successful
Vercel Preview Deployment / Deploy-Preview (push) Successful in 2m23s
2024-05-17 11:02:07 +02:00
1b2ab0aa1b Merge pull request 'set up nextui and framer motion' (#3) from framer-nextui into main
All checks were successful
Vercel Production Deployment / Deploy-Production (push) Successful in 1m51s
Reviewed-on: #3
2024-05-17 08:45:25 +00:00
3c39510aa3 set up nextui and framer motion
All checks were successful
Vercel Preview Deployment / Deploy-Preview (push) Successful in 2m15s
2024-05-17 10:44:41 +02:00
94918c229f Merge pull request 'authjs' (#2) from authjs into main
All checks were successful
Vercel Production Deployment / Deploy-Production (push) Successful in 2m25s
Vercel Preview Deployment / Deploy-Preview (push) Successful in 2m10s
Reviewed-on: #2
2024-05-16 21:42:41 +00:00
10 changed files with 3148 additions and 215 deletions

View File

@ -1,36 +1,15 @@
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). This project is scaffolded with the following:
## Getting Started - Next.js
- Auth.js (nextauth)
- Nextui
- Next-themes
- Tailwind
- Drizzle
- Postgres
First, run the development server: It is deployed to vercel and can be viewed on the following links:
```bash [Preview branches](https://titles-chrqr-christian-rannes-projects.vercel.app/)
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. [Production](https://titles-psi.vercel.app/)
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.
## Learn More
To learn more about Next.js, take a look at the following resources:
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
## Deploy on Vercel
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.

View File

@ -1,33 +1,3 @@
@tailwind base; @tailwind base;
@tailwind components; @tailwind components;
@tailwind utilities; @tailwind utilities;
:root {
--foreground-rgb: 0, 0, 0;
--background-start-rgb: 214, 219, 220;
--background-end-rgb: 255, 255, 255;
}
@media (prefers-color-scheme: dark) {
:root {
--foreground-rgb: 255, 255, 255;
--background-start-rgb: 0, 0, 0;
--background-end-rgb: 0, 0, 0;
}
}
body {
color: rgb(var(--foreground-rgb));
background: linear-gradient(
to bottom,
transparent,
rgb(var(--background-end-rgb))
)
rgb(var(--background-start-rgb));
}
@layer utilities {
.text-balance {
text-wrap: balance;
}
}

View File

@ -1,7 +1,7 @@
import type { Metadata } from "next"; import type { Metadata } from "next";
import { Inter } from "next/font/google"; import { Inter } from "next/font/google";
import "./globals.css"; import "./globals.css";
import { SessionProvider } from "next-auth/react"; import { Providers } from "./providers";
const inter = Inter({ subsets: ["latin"] }); const inter = Inter({ subsets: ["latin"] });
@ -17,7 +17,9 @@ export default function RootLayout({
}>) { }>) {
return ( return (
<html lang="en"> <html lang="en">
<body className={inter.className}>{children}</body> <body className={inter.className}>
<Providers>{children}</Providers>
</body>
</html> </html>
); );
} }

View File

@ -2,13 +2,17 @@ import { getUsers } from "@/drizzle/db";
import SignIn from "@/components/SignIn"; import SignIn from "@/components/SignIn";
import { auth } from "@/auth"; import { auth } from "@/auth";
import { Session } from "next-auth"; import { Session } from "next-auth";
import { ThemeSwitcher } from "@/components/ThemeSwitcher";
export default async function Home() { export default async function Home() {
const users = await getUsers(); const users = await getUsers();
const session: Session | null = await auth(); const session: Session | null = await auth();
return ( return (
<main className="bg-black text-white"> <main className="min-h-screen w-full">
<div className="min-h-screen w-full flex flex-col items-center justify-center">
<SignIn session={session} /> <SignIn session={session} />
<ThemeSwitcher />
</div>
</main> </main>
); );
} }

14
app/providers.tsx Normal file
View File

@ -0,0 +1,14 @@
"use client";
import { NextUIProvider } from "@nextui-org/react";
import { ThemeProvider as NextThemesProvider } from "next-themes";
export function Providers({ children }: { children: React.ReactNode }) {
return (
<NextUIProvider>
<NextThemesProvider attribute="class" defaultTheme="dark">
{children}
</NextThemesProvider>
</NextUIProvider>
);
}

View File

@ -1,31 +1,48 @@
"use client"; "use client";
import { signIn, signOut } from "next-auth/react"; import { signIn, signOut } from "next-auth/react";
import { SyntheticEvent } from "react"; import { SyntheticEvent, useState } from "react";
import { Session } from "next-auth"; import { Session } from "next-auth";
import { Button } from "@nextui-org/button";
import { Spinner } from "@nextui-org/react";
interface SignInProps { interface SignInProps {
session: Session | null; session: Session | null;
} }
export default async function SignIn({ session }: SignInProps) { export default function SignIn({ session }: SignInProps) {
const [loading, setLoading] = useState(false);
const handleSignIn = async (event: SyntheticEvent) => { const handleSignIn = async (event: SyntheticEvent) => {
event.preventDefault(); event.preventDefault();
setLoading(true);
await signIn("github"); await signIn("github");
}; };
const handleSignOut = async (event: SyntheticEvent) => { const handleSignOut = async (event: SyntheticEvent) => {
event.preventDefault(); event.preventDefault();
setLoading(true);
await signOut(); await signOut();
}; };
return session?.user ? ( return (
<>
{session?.user ? (
<form onSubmit={handleSignOut}> <form onSubmit={handleSignOut}>
<button type="submit">Sign out</button> <Button type="submit" disabled={loading}>
Sign out
</Button>
</form> </form>
) : ( ) : (
<form onSubmit={handleSignIn}> <form onSubmit={handleSignIn}>
<button type="submit">Sign in with GitHub</button> {!loading ? (
<Button type="submit" disabled={loading}>
Sign in
</Button>
) : (
<Spinner color="success" />
)}
</form> </form>
)}
</>
); );
} }

View File

@ -0,0 +1,25 @@
// app/components/ThemeSwitcher.tsx
"use client";
import { Button } from "@nextui-org/button";
import { useTheme } from "next-themes";
import { useEffect, useState } from "react";
export function ThemeSwitcher() {
const [mounted, setMounted] = useState(false);
const { theme, setTheme } = useTheme();
useEffect(() => {
setMounted(true);
}, []);
if (!mounted) return null;
return (
<div className="flex gap-2 items-center my-2">
The current theme is: {theme}
<Button onClick={() => setTheme("light")}>Light Mode</Button>
<Button onClick={() => setTheme("dark")}>Dark Mode</Button>
</div>
);
}

3180
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -10,11 +10,17 @@
}, },
"dependencies": { "dependencies": {
"@next/env": "^14.2.3", "@next/env": "^14.2.3",
"@nextui-org/button": "^2.0.31",
"@nextui-org/react": "^2.3.6",
"@nextui-org/system": "^2.1.2",
"@nextui-org/theme": "^2.2.3",
"@types/next-auth": "^3.15.0", "@types/next-auth": "^3.15.0",
"@vercel/postgres": "^0.8.0", "@vercel/postgres": "^0.8.0",
"drizzle-orm": "^0.30.10", "drizzle-orm": "^0.30.10",
"framer-motion": "^11.2.4",
"next": "14.2.3", "next": "14.2.3",
"next-auth": "^5.0.0-beta.18", "next-auth": "^5.0.0-beta.18",
"next-themes": "^0.3.0",
"react": "^18.3.1", "react": "^18.3.1",
"react-dom": "^18.3.1" "react-dom": "^18.3.1"
}, },

View File

@ -1,3 +1,4 @@
import { nextui } from "@nextui-org/theme";
import type { Config } from "tailwindcss"; import type { Config } from "tailwindcss";
const config: Config = { const config: Config = {
@ -5,16 +6,13 @@ const config: Config = {
"./pages/**/*.{js,ts,jsx,tsx,mdx}", "./pages/**/*.{js,ts,jsx,tsx,mdx}",
"./components/**/*.{js,ts,jsx,tsx,mdx}", "./components/**/*.{js,ts,jsx,tsx,mdx}",
"./app/**/*.{js,ts,jsx,tsx,mdx}", "./app/**/*.{js,ts,jsx,tsx,mdx}",
"./node_modules/@nextui-org/theme/dist/components/(button|ripple|spinner).js",
"./node_modules/@nextui-org/theme/dist/**/*.{js,ts,jsx,tsx}",
], ],
theme: { theme: {
extend: { extend: {},
backgroundImage: {
"gradient-radial": "radial-gradient(var(--tw-gradient-stops))",
"gradient-conic":
"conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))",
}, },
}, darkMode: "class",
}, plugins: [nextui()],
plugins: [],
}; };
export default config; export default config;