Skip to content

Commit

Permalink
init完成 添加shadcn
Browse files Browse the repository at this point in the history
  • Loading branch information
floatGray committed Nov 21, 2023
1 parent 11b3e83 commit 95e66f3
Show file tree
Hide file tree
Showing 15 changed files with 1,507 additions and 379 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ yarn-error.log*

# local env files
.env*.local
.env

# vercel
.vercel
Expand Down
7 changes: 7 additions & 0 deletions app/(auth)/(routes)/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const AuthLayout = ({ children }: { children: React.ReactNode }) => {
return (
<div className="h-full flex justify-center items-center">{children}</div>
);
};

export default AuthLayout;
5 changes: 5 additions & 0 deletions app/(auth)/(routes)/sign-in/[[...sign-in]]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { SignIn } from '@clerk/nextjs';

export default function Page() {
return <SignIn />;
}
5 changes: 5 additions & 0 deletions app/(auth)/(routes)/sign-up/[[...sign-up]]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { SignUp } from '@clerk/nextjs';

export default function Page() {
return <SignUp />;
}
9 changes: 9 additions & 0 deletions app/(main)/(routes)/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { UserButton } from '@clerk/nextjs';

export default function Home() {
return (
<div className="flex flex-col">
<UserButton afterSignOutUrl="/" />
</div>
);
}
85 changes: 70 additions & 15 deletions app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,81 @@
@tailwind components;
@tailwind utilities;

html,
body,
:root {
--foreground-rgb: 0, 0, 0;
--background-start-rgb: 214, 219, 220;
--background-end-rgb: 255, 255, 255;
height: 100%;
}

@media (prefers-color-scheme: dark) {
@layer base {
:root {
--foreground-rgb: 255, 255, 255;
--background-start-rgb: 0, 0, 0;
--background-end-rgb: 0, 0, 0;
--background: 0 0% 100%;
--foreground: 20 14.3% 4.1%;

--card: 0 0% 100%;
--card-foreground: 20 14.3% 4.1%;

--popover: 0 0% 100%;
--popover-foreground: 20 14.3% 4.1%;

--primary: 24 9.8% 10%;
--primary-foreground: 60 9.1% 97.8%;

--secondary: 60 4.8% 95.9%;
--secondary-foreground: 24 9.8% 10%;

--muted: 60 4.8% 95.9%;
--muted-foreground: 25 5.3% 44.7%;

--accent: 60 4.8% 95.9%;
--accent-foreground: 24 9.8% 10%;

--destructive: 0 84.2% 60.2%;
--destructive-foreground: 60 9.1% 97.8%;

--border: 20 5.9% 90%;
--input: 20 5.9% 90%;
--ring: 20 14.3% 4.1%;

--radius: 0.5rem;
}

.dark {
--background: 20 14.3% 4.1%;
--foreground: 60 9.1% 97.8%;

--card: 20 14.3% 4.1%;
--card-foreground: 60 9.1% 97.8%;

--popover: 20 14.3% 4.1%;
--popover-foreground: 60 9.1% 97.8%;

--primary: 60 9.1% 97.8%;
--primary-foreground: 24 9.8% 10%;

--secondary: 12 6.5% 15.1%;
--secondary-foreground: 60 9.1% 97.8%;

--muted: 12 6.5% 15.1%;
--muted-foreground: 24 5.4% 63.9%;

--accent: 12 6.5% 15.1%;
--accent-foreground: 60 9.1% 97.8%;

--destructive: 0 62.8% 30.6%;
--destructive-foreground: 60 9.1% 97.8%;

--border: 12 6.5% 15.1%;
--input: 12 6.5% 15.1%;
--ring: 24 5.7% 82.9%;
}
}

body {
color: rgb(var(--foreground-rgb));
background: linear-gradient(
to bottom,
transparent,
rgb(var(--background-end-rgb))
)
rgb(var(--background-start-rgb));
@layer base {
* {
@apply border-border;
}
body {
@apply bg-background text-foreground;
}
}
25 changes: 14 additions & 11 deletions app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
import type { Metadata } from 'next'
import { Inter } from 'next/font/google'
import './globals.css'
import type { Metadata } from 'next';
import { Open_Sans } from 'next/font/google';
import './globals.css';
import { ClerkProvider } from '@clerk/nextjs';

const inter = Inter({ subsets: ['latin'] })
const font = Open_Sans({ subsets: ['latin'] });

export const metadata: Metadata = {
title: 'Create Next App',
title: '团队聊天',
description: 'Generated by create next app',
}
};

export default function RootLayout({
children,
}: {
children: React.ReactNode
children: React.ReactNode;
}) {
return (
<html lang="en">
<body className={inter.className}>{children}</body>
</html>
)
<ClerkProvider>
<html lang="en">
<body className={font.className}>{children}</body>
</html>
</ClerkProvider>
);
}
113 changes: 0 additions & 113 deletions app/page.tsx

This file was deleted.

16 changes: 16 additions & 0 deletions components.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "default",
"rsc": true,
"tsx": true,
"tailwind": {
"config": "tailwind.config.js",
"css": "app/globals.css",
"baseColor": "stone",
"cssVariables": true
},
"aliases": {
"components": "@/components",
"utils": "@/lib/utils"
}
}
56 changes: 56 additions & 0 deletions components/ui/button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import * as React from "react"
import { Slot } from "@radix-ui/react-slot"
import { cva, type VariantProps } from "class-variance-authority"

import { cn } from "@/lib/utils"

const buttonVariants = cva(
"inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
{
variants: {
variant: {
default: "bg-primary text-primary-foreground hover:bg-primary/90",
destructive:
"bg-destructive text-destructive-foreground hover:bg-destructive/90",
outline:
"border border-input bg-background hover:bg-accent hover:text-accent-foreground",
secondary:
"bg-secondary text-secondary-foreground hover:bg-secondary/80",
ghost: "hover:bg-accent hover:text-accent-foreground",
link: "text-primary underline-offset-4 hover:underline",
},
size: {
default: "h-10 px-4 py-2",
sm: "h-9 rounded-md px-3",
lg: "h-11 rounded-md px-8",
icon: "h-10 w-10",
},
},
defaultVariants: {
variant: "default",
size: "default",
},
}
)

export interface ButtonProps
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
VariantProps<typeof buttonVariants> {
asChild?: boolean
}

const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
({ className, variant, size, asChild = false, ...props }, ref) => {
const Comp = asChild ? Slot : "button"
return (
<Comp
className={cn(buttonVariants({ variant, size, className }))}
ref={ref}
{...props}
/>
)
}
)
Button.displayName = "Button"

export { Button, buttonVariants }
6 changes: 6 additions & 0 deletions lib/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { type ClassValue, clsx } from "clsx"
import { twMerge } from "tailwind-merge"

export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}
10 changes: 10 additions & 0 deletions middleware.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { authMiddleware } from '@clerk/nextjs';

// This example protects all routes including api/trpc routes
// Please edit this to allow other routes to be public as needed.
// See https://clerk.com/docs/references/nextjs/auth-middleware for more information about configuring your Middleware
export default authMiddleware({});

export const config = {
matcher: ['/((?!.+\\.[\\w]+$|_next).*)', '/', '/(api|trpc)(.*)'],
};
Loading

0 comments on commit 95e66f3

Please sign in to comment.