Skip to content

Commit 5399727

Browse files
authored
Update to shadcn/ui (vercel#38)
1 parent 365328a commit 5399727

40 files changed

+2303
-4280
lines changed

Diff for: .env.local.example

-13
This file was deleted.

Diff for: .eslintrc.json

-3
This file was deleted.

Diff for: .gitignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ yarn-debug.log*
2525
yarn-error.log*
2626
.pnpm-debug.log*
2727

28-
# local env files
29-
.env*.local
28+
# env files
29+
.env*
3030

3131
# vercel
3232
.vercel

Diff for: LICENSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2023 Vercel, Inc.
3+
Copyright (c) 2024 Vercel, Inc.
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

Diff for: README.md

+6-11
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,25 @@
1-
<picture>
2-
<source media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/9113740/201498864-2a900c64-d88f-4ed4-b5cf-770bcb57e1f5.png">
3-
<source media="(prefers-color-scheme: light)" srcset="https://user-images.githubusercontent.com/9113740/201498152-b171abb8-9225-487a-821c-6ff49ee48579.png">
4-
<img alt="Shows all of the tools in the stack for this template, also listed in the README file." src="https://user-images.githubusercontent.com/9113740/201498152-b171abb8-9225-487a-821c-6ff49ee48579.png">
5-
</picture>
6-
71
<div align="center"><strong>Next.js 14 Admin Dashboard Template</strong></div>
82
<div align="center">Built with the Next.js App Router</div>
93
<br />
104
<div align="center">
115
<a href="http://admin-dash-template.vercel.sh/">Demo</a>
126
<span> · </span>
13-
<a href="https://vercel.com/templates/next.js/admin-dashboard-tailwind-planetscale-react-nextjs">Clone & Deploy</a>
7+
<a href="https://vercel.com/templates/next.js/admin-dashboard-tailwind-postgres-react-nextjs">Clone & Deploy</a>
148
<span>
159
</div>
1610

1711
## Overview
1812

1913
This is a starter template using the following stack:
2014

21-
- Framework - [Next.js 14](https://nextjs.org/14)
15+
- Framework - [Next.js 14](https://nextjs.org/)
2216
- Language - [TypeScript](https://www.typescriptlang.org)
2317
- Auth - [NextAuth.js](https://next-auth.js.org)
24-
- Database - [Vercel Postgres](https://vercel.com/postgres)
18+
- Database - [Postgres](https://vercel.com/postgres)
2519
- Deployment - [Vercel](https://vercel.com/docs/concepts/next.js/overview)
2620
- Styling - [Tailwind CSS](https://tailwindcss.com)
27-
- Components - [Tremor](https://www.tremor.so)
21+
- Components - [Shadcn UI](https://ui.shadcn.com/)
2822
- Analytics - [Vercel Analytics](https://vercel.com/analytics)
29-
- Linting - [ESLint](https://eslint.org)
3023
- Formatting - [Prettier](https://prettier.io)
3124

3225
This template uses the new Next.js App Router. This includes support for enhanced layouts, colocation of components, tests, and styles, component-level data fetching, and more.
@@ -52,6 +45,8 @@ Insert a row for testing:
5245
INSERT INTO users (id, email, name, username) VALUES (1, '[email protected]', 'Me', 'username');
5346
```
5447

48+
Copy the `.env.example` file to `.env` and update the values.
49+
5550
Finally, run the following commands to start the development server:
5651

5752
```

Diff for: app/actions.ts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
'use server';
2+
3+
import { deleteUserById } from '@/lib/db';
4+
import { revalidatePath } from 'next/cache';
5+
6+
export async function deleteUser(userId: number) {
7+
await deleteUserById(userId);
8+
revalidatePath('/');
9+
}

Diff for: app/api/auth/[...nextauth]/route.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
export { GET, POST } from '../../../auth';
2-
export const runtime = 'edge';
1+
export { GET, POST } from '@/lib/auth';

Diff for: app/auth.ts

-17
This file was deleted.

Diff for: app/dismiss-button.tsx

-20
This file was deleted.

Diff for: app/globals.css

+73
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,76 @@
11
@tailwind base;
22
@tailwind components;
33
@tailwind utilities;
4+
5+
@layer base {
6+
:root {
7+
--background: 0 0% 100%;
8+
--foreground: 222.2 84% 4.9%;
9+
10+
--card: 0 0% 100%;
11+
--card-foreground: 222.2 84% 4.9%;
12+
13+
--popover: 0 0% 100%;
14+
--popover-foreground: 222.2 84% 4.9%;
15+
16+
--primary: 222.2 47.4% 11.2%;
17+
--primary-foreground: 210 40% 98%;
18+
19+
--secondary: 210 40% 96.1%;
20+
--secondary-foreground: 222.2 47.4% 11.2%;
21+
22+
--muted: 210 40% 96.1%;
23+
--muted-foreground: 215.4 16.3% 46.9%;
24+
25+
--accent: 210 40% 96.1%;
26+
--accent-foreground: 222.2 47.4% 11.2%;
27+
28+
--destructive: 0 84.2% 60.2%;
29+
--destructive-foreground: 210 40% 98%;
30+
31+
--border: 214.3 31.8% 91.4%;
32+
--input: 214.3 31.8% 91.4%;
33+
--ring: 222.2 84% 4.9%;
34+
35+
--radius: 0.5rem;
36+
}
37+
38+
.dark {
39+
--background: 222.2 84% 4.9%;
40+
--foreground: 210 40% 98%;
41+
42+
--card: 222.2 84% 4.9%;
43+
--card-foreground: 210 40% 98%;
44+
45+
--popover: 222.2 84% 4.9%;
46+
--popover-foreground: 210 40% 98%;
47+
48+
--primary: 210 40% 98%;
49+
--primary-foreground: 222.2 47.4% 11.2%;
50+
51+
--secondary: 217.2 32.6% 17.5%;
52+
--secondary-foreground: 210 40% 98%;
53+
54+
--muted: 217.2 32.6% 17.5%;
55+
--muted-foreground: 215 20.2% 65.1%;
56+
57+
--accent: 217.2 32.6% 17.5%;
58+
--accent-foreground: 210 40% 98%;
59+
60+
--destructive: 0 62.8% 30.6%;
61+
--destructive-foreground: 210 40% 98%;
62+
63+
--border: 217.2 32.6% 17.5%;
64+
--input: 217.2 32.6% 17.5%;
65+
--ring: 212.7 26.8% 83.9%;
66+
}
67+
}
68+
69+
@layer base {
70+
* {
71+
@apply border-border;
72+
}
73+
body {
74+
@apply bg-background text-foreground;
75+
}
76+
}

Diff for: app/infinite-scroll.ts

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { useEffect, useRef, useState } from 'react';
2+
3+
export function useInfiniteScroll(onIntersect: () => void) {
4+
const sentinelRef = useRef<HTMLElement | null>(null);
5+
const [observer, setObserver] = useState<IntersectionObserver | null>(null);
6+
7+
useEffect(() => {
8+
if (observer) {
9+
observer.disconnect();
10+
}
11+
12+
const obs = new IntersectionObserver(
13+
([entry]) => {
14+
if (entry.isIntersecting) {
15+
onIntersect();
16+
}
17+
},
18+
{
19+
rootMargin: '50px 0px 0px 0px'
20+
}
21+
);
22+
23+
setObserver(obs);
24+
25+
if (sentinelRef.current) {
26+
obs.observe(sentinelRef.current);
27+
}
28+
29+
return () => obs.disconnect();
30+
}, [onIntersect]);
31+
32+
return sentinelRef;
33+
}

Diff for: app/layout.tsx

+50-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import './globals.css';
22

3+
import Link from 'next/link';
34
import { Analytics } from '@vercel/analytics/react';
4-
import Nav from './nav';
5-
import Toast from './toast';
6-
import { Suspense } from 'react';
5+
import { Logo, SettingsIcon, UsersIcon, VercelLogo } from '@/components/icons';
6+
import { User } from './user';
7+
import { NavItem } from './nav-item';
78

89
export const metadata = {
910
title: 'Next.js App Router + NextAuth + Tailwind CSS',
1011
description:
11-
'A user admin dashboard configured with Next.js, Postgres, NextAuth, Tailwind CSS, TypeScript, ESLint, and Prettier.'
12+
'A user admin dashboard configured with Next.js, Postgres, NextAuth, Tailwind CSS, TypeScript, and Prettier.'
1213
};
1314

1415
export default function RootLayout({
@@ -18,13 +19,52 @@ export default function RootLayout({
1819
}) {
1920
return (
2021
<html lang="en" className="h-full bg-gray-50">
21-
<body className="h-full">
22-
<Suspense>
23-
<Nav />
24-
</Suspense>
25-
{children}
22+
<body>
23+
<div className="grid min-h-screen w-full lg:grid-cols-[280px_1fr]">
24+
<div className="hidden border-r bg-gray-100/40 lg:block dark:bg-gray-800/40">
25+
<div className="flex h-full max-h-screen flex-col gap-2">
26+
<div className="flex h-[60px] items-center border-b px-5">
27+
<Link
28+
className="flex items-center gap-2 font-semibold"
29+
href="/"
30+
>
31+
<Logo />
32+
<span className="">ACME</span>
33+
</Link>
34+
</div>
35+
<div className="flex-1 overflow-auto py-2">
36+
<nav className="grid items-start px-4 text-sm font-medium">
37+
<NavItem href="/">
38+
<UsersIcon className="h-4 w-4" />
39+
Users
40+
</NavItem>
41+
<NavItem href="/settings">
42+
<SettingsIcon className="h-4 w-4" />
43+
Settings
44+
</NavItem>
45+
<NavItem href="https://vercel.com/templates/next.js/admin-dashboard-tailwind-postgres-react-nextjs">
46+
<VercelLogo className="h-4 w-4" />
47+
Deploy
48+
</NavItem>
49+
</nav>
50+
</div>
51+
</div>
52+
</div>
53+
<div className="flex flex-col">
54+
<header className="flex h-14 lg:h-[60px] items-center gap-4 border-b bg-gray-100/40 px-6 dark:bg-gray-800/40 justify-between lg:justify-end">
55+
<Link
56+
className="flex items-center gap-2 font-semibold lg:hidden"
57+
href="/"
58+
>
59+
<Logo />
60+
<span className="">ACME</span>
61+
</Link>
62+
<User />
63+
</header>
64+
{children}
65+
</div>
66+
</div>
2667
<Analytics />
27-
<Toast />
2868
</body>
2969
</html>
3070
);

Diff for: app/loading.tsx

-13
This file was deleted.

Diff for: app/nav-item.tsx

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
'use client';
2+
3+
import clsx from 'clsx';
4+
import Link from 'next/link';
5+
import { usePathname } from 'next/navigation';
6+
7+
export function NavItem({
8+
href,
9+
children
10+
}: {
11+
href: string;
12+
children: React.ReactNode;
13+
}) {
14+
const pathname = usePathname();
15+
16+
return (
17+
<Link
18+
href={href}
19+
className={clsx(
20+
'flex items-center gap-3 rounded-lg px-3 py-2 text-gray-900 transition-all hover:text-gray-900 dark:text-gray-50 dark:hover:text-gray-50',
21+
{
22+
'bg-gray-100 dark:bg-gray-800': pathname === href
23+
}
24+
)}
25+
>
26+
{children}
27+
</Link>
28+
);
29+
}

Diff for: app/nav.tsx

-7
This file was deleted.

0 commit comments

Comments
 (0)