Skip to content

Commit

Permalink
auth complete
Browse files Browse the repository at this point in the history
  • Loading branch information
imonaar committed Jan 15, 2024
1 parent caec65a commit e1bbf40
Show file tree
Hide file tree
Showing 11 changed files with 258 additions and 10 deletions.
37 changes: 37 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"@auth/prisma-adapter": "^1.0.14",
"@prisma/client": "^5.8.0",
"@radix-ui/react-avatar": "^1.0.4",
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-dropdown-menu": "^2.0.6",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-toast": "^1.1.5",
Expand Down
8 changes: 6 additions & 2 deletions src/app/(auth)/sign-in/page.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import SignIn from "@/components/sign-in";
import {SignIn} from "@/components/sign-in";
import { buttonVariants } from "@/components/ui/Button";
import { cn } from "@/lib/utils";
import { ChevronLeft } from "lucide-react";
import Link from "next/link";

export default function SignInPage() {
return (
<div className="absolute inset-0">
<div className="h-full max-w-2xl mx-auto flex flex-col items-center justify-center gap-20" >
<Link href='/' className={cn('self-start -mt-20', buttonVariants({ variant: 'ghost' }))} >Home</Link>
<Link href='/' className={cn('self-start -mt-20', buttonVariants({ variant: 'ghost' }))} >

<ChevronLeft className="mr-2 h-6" /> Home
</Link>

<SignIn />
</div>
</div>
Expand Down
18 changes: 18 additions & 0 deletions src/app/(auth)/sign-up/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import {SignUp} from "@/components/sign-up";
import { buttonVariants } from "@/components/ui/Button";
import { cn } from "@/lib/utils";
import { ChevronLeft } from "lucide-react";
import Link from "next/link";

export default function SignUpPage() {
return (
<div className="absolute inset-0">
<div className="h-full max-w-2xl mx-auto flex flex-col items-center justify-center gap-20" >
<Link href='/' className={cn('self-start -mt-20', buttonVariants({ variant: 'ghost' }))} >
<ChevronLeft className="mr-2 h-6" /> Home
</Link>
<SignUp />
</div>
</div>
)
}
18 changes: 18 additions & 0 deletions src/app/@authModal/(.)sign-in/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { CloseModal } from '@/components/close-modal'
import { SignIn } from '@/components/sign-in'
import React from 'react'

export default function Page() {
return (
<div className='fixed inset-0 bg-zinc-900/20 x-10'>
<div className='container flex items-center h-full max-w-lg mx-auto'>
<div className='relative bg-white w-full h-fit py-20 px-2 rounded-lg'>
<div className='absolute top-4 right-4'>
<CloseModal />
</div>
<SignIn />
</div>
</div>
</div>
)
}
17 changes: 17 additions & 0 deletions src/app/@authModal/(.)sign-up/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {CloseModal} from '@/components/close-modal'
import {SignUp} from '@/components/sign-up'

export default function Page() {
return (
<div className='fixed inset-0 bg-zinc-900/20 x-10'>
<div className='container flex items-center h-full max-w-lg mx-auto'>
<div className='relative bg-white w-full h-fit py-20 px-2 rounded-lg'>
<div className='absolute top-4 right-4'>
<CloseModal />
</div>
<SignUp />
</div>
</div>
</div>
)
}
7 changes: 0 additions & 7 deletions src/app/@authModal/sign-in/page.tsx

This file was deleted.

14 changes: 14 additions & 0 deletions src/components/close-modal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"use client"

import { useRouter } from "next/navigation";
import { Button } from "./ui/Button";
import { X } from "lucide-react";

export function CloseModal() {
const router = useRouter()
return (
<Button aria-label="close modal" onClick={() => router.back()} size="sm" variant="subtle" >
<X className="h-4 w-4" />
</Button>
)
}
2 changes: 1 addition & 1 deletion src/components/sign-in.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Link from "next/link";
import { Icons } from "./icons";
import { UserAuthForm } from "./user-auth-form";

export default function SignIn() {
export function SignIn() {
return (
<div className="container mx-auto flex w-full flex-col justify-center space-y-6 sm:w-[400px]">
<div className="flex flex-col space-y-2 text-center ">
Expand Down
24 changes: 24 additions & 0 deletions src/components/sign-up.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import Link from "next/link";
import { Icons } from "./icons";
import { UserAuthForm } from "./user-auth-form";

export function SignUp() {
return (
<div className="container mx-auto flex w-full flex-col justify-center space-y-6 sm:w-[400px]">
<div className="flex flex-col space-y-2 text-center ">
<Icons.logo className="h-6 w-6 mx-auto" />
<h1 className="text-2xl font-semibold tracking-tight"> Sign Up</h1>
<p className="text-sm max-w-xs mx-auto">
By continuing you are setting up a Breadit account and agreeing to our user terms and conditions.
</p>
{/* sign in form */}
<UserAuthForm />

<p className="px-8 text-center text-sm text-zinc-700">
Already Breaditor ?{' '}
<Link href="/sign-in" className="hover:text-zinc-800 text-sm underline underline-offset-4"> Sign in</Link>
</p>
</div>
</div>
)
}
122 changes: 122 additions & 0 deletions src/components/ui/dialog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
"use client"

import * as React from "react"
import * as DialogPrimitive from "@radix-ui/react-dialog"
import { X } from "lucide-react"

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

const Dialog = DialogPrimitive.Root

const DialogTrigger = DialogPrimitive.Trigger

const DialogPortal = DialogPrimitive.Portal

const DialogClose = DialogPrimitive.Close

const DialogOverlay = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Overlay>,
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
>(({ className, ...props }, ref) => (
<DialogPrimitive.Overlay
ref={ref}
className={cn(
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
className
)}
{...props}
/>
))
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName

const DialogContent = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
>(({ className, children, ...props }, ref) => (
<DialogPortal>
<DialogOverlay />
<DialogPrimitive.Content
ref={ref}
className={cn(
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
className
)}
{...props}
>
{children}
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
<X className="h-4 w-4" />
<span className="sr-only">Close</span>
</DialogPrimitive.Close>
</DialogPrimitive.Content>
</DialogPortal>
))
DialogContent.displayName = DialogPrimitive.Content.displayName

const DialogHeader = ({
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) => (
<div
className={cn(
"flex flex-col space-y-1.5 text-center sm:text-left",
className
)}
{...props}
/>
)
DialogHeader.displayName = "DialogHeader"

const DialogFooter = ({
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) => (
<div
className={cn(
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
className
)}
{...props}
/>
)
DialogFooter.displayName = "DialogFooter"

const DialogTitle = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Title>,
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
>(({ className, ...props }, ref) => (
<DialogPrimitive.Title
ref={ref}
className={cn(
"text-lg font-semibold leading-none tracking-tight",
className
)}
{...props}
/>
))
DialogTitle.displayName = DialogPrimitive.Title.displayName

const DialogDescription = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Description>,
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
>(({ className, ...props }, ref) => (
<DialogPrimitive.Description
ref={ref}
className={cn("text-sm text-muted-foreground", className)}
{...props}
/>
))
DialogDescription.displayName = DialogPrimitive.Description.displayName

export {
Dialog,
DialogPortal,
DialogOverlay,
DialogClose,
DialogTrigger,
DialogContent,
DialogHeader,
DialogFooter,
DialogTitle,
DialogDescription,
}

0 comments on commit e1bbf40

Please sign in to comment.