Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aa5950c
commit 47effea
Showing
17 changed files
with
491 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.ts", | ||
"css": "src/styles/globals.css", | ||
"baseColor": "slate", | ||
"cssVariables": true | ||
}, | ||
"aliases": { | ||
"components": "src/app/_components", | ||
"utils": "src/lib/utils" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import Image from "next/image"; | ||
import type { ReactNode } from "react"; | ||
|
||
export type WrapperProps = { | ||
children: ReactNode; | ||
}; | ||
|
||
export const BackgroundWrapper: React.FC<WrapperProps> = ({ | ||
children, | ||
}): JSX.Element => { | ||
return ( | ||
<div className="max-w-xs p-4 pt-16"> | ||
<Image | ||
src="/pattern.png" | ||
alt="A background pattern" | ||
fill | ||
className="absolute left-0 right-0 top-0 -z-10" | ||
/> | ||
{children} | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */ | ||
/* eslint-disable @typescript-eslint/no-unsafe-call */ | ||
/* eslint-disable @typescript-eslint/no-unsafe-return */ | ||
import type { DetailedHTMLProps, FormHTMLAttributes, ReactNode } from "react"; | ||
import type { | ||
FieldValues, | ||
SubmitHandler, | ||
UseFormHandleSubmit, | ||
UseFormReset, | ||
} from "react-hook-form"; | ||
|
||
export type FeaturesProps = { | ||
children: ReactNode; | ||
}; | ||
|
||
interface FormProps<T extends FieldValues> | ||
extends Omit< | ||
DetailedHTMLProps<FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>, | ||
"onSubmit" | ||
> { | ||
submitText?: string; | ||
resetButton: boolean; | ||
handleSubmit: UseFormHandleSubmit<T>; | ||
reset: UseFormReset<T>; | ||
onSubmit: SubmitHandler<T>; | ||
loading: boolean; | ||
} | ||
|
||
export function Form<T extends FieldValues>({ | ||
children, | ||
submitText = "Submit", | ||
resetButton, | ||
handleSubmit, | ||
reset, | ||
onSubmit, | ||
loading, | ||
}: FormProps<T>): JSX.Element { | ||
return ( | ||
<form onSubmit={handleSubmit(onSubmit)}> | ||
<div className="space-y-12">{children}</div> | ||
|
||
<div className="mt-6 flex items-center justify-end gap-x-6"> | ||
{resetButton && ( | ||
<button | ||
onClick={() => reset} | ||
type="reset" | ||
className="text-sm font-semibold leading-6 text-white" | ||
> | ||
Reset | ||
</button> | ||
)} | ||
<button | ||
type="submit" | ||
disabled={loading} | ||
className="rounded-md bg-indigo-500 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-indigo-400 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-500" | ||
> | ||
{submitText} | ||
</button> | ||
</div> | ||
</form> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { cn } from "src/lib/utils" | ||
|
||
function Skeleton({ | ||
className, | ||
...props | ||
}: React.HTMLAttributes<HTMLDivElement>) { | ||
return ( | ||
<div | ||
className={cn("animate-pulse rounded-md bg-muted", className)} | ||
{...props} | ||
/> | ||
) | ||
} | ||
|
||
export { Skeleton } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Suspense } from "react"; | ||
import Loading from "./loading"; | ||
|
||
export default function Layout({ children }: { children: React.ReactNode }) { | ||
return ( | ||
<main> | ||
<h1 className="mt-4 block text-2xl font-medium"> | ||
Fill in your bio to get started | ||
</h1> | ||
<p className="mt-4 block text-sm"> | ||
Data will get displayed to other users | ||
</p> | ||
<Suspense fallback={<Loading />}>{children}</Suspense> | ||
</main> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Skeleton } from "@components/ui/skeleton"; | ||
|
||
export default function Loading() { | ||
return ( | ||
<div className="flex items-center space-x-4"> | ||
<Skeleton className="h-12 w-12 rounded-full" /> | ||
<div className="space-y-2"> | ||
<Skeleton className="h-4 w-[250px]" /> | ||
<Skeleton className="h-4 w-[200px]" /> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { currentUser } from "@clerk/nextjs"; | ||
import { useState } from "react"; | ||
import { useForm, type SubmitHandler } from "react-hook-form"; | ||
import { Form } from "../_components/form"; | ||
|
||
interface IPersonalInput { | ||
username: string; | ||
firstName: string; | ||
lastName: string; | ||
yearsAtWork: number; | ||
} | ||
|
||
export default async function SignUp() { | ||
// const hello = await api.post.hello.query({ text: "from tRPC" }); | ||
const user = await currentUser(); | ||
const defaultValues: IPersonalInput = { | ||
username: user?.username ?? "", | ||
firstName: user?.firstName ?? "", | ||
lastName: user?.lastName ?? "", | ||
yearsAtWork: 0, | ||
}; | ||
|
||
const [loading] = useState<boolean>(false); | ||
|
||
const { | ||
handleSubmit, | ||
reset, | ||
register, | ||
formState: { errors }, | ||
watch, | ||
} = useForm<IPersonalInput>({ | ||
defaultValues, | ||
}); | ||
|
||
const onSubmit: SubmitHandler<IPersonalInput> = async (data, event) => { | ||
event?.preventDefault(); | ||
}; | ||
|
||
return ( | ||
<Form | ||
resetButton | ||
submitText="Update and save text" | ||
handleSubmit={handleSubmit} | ||
reset={reset} | ||
onSubmit={onSubmit} | ||
loading={loading} | ||
> | ||
<div></div> | ||
</Form> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { clsx, type ClassValue } from "clsx"; | ||
import { twMerge } from "tailwind-merge"; | ||
|
||
export function cn(...inputs: ClassValue[]) { | ||
return twMerge(clsx(inputs)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.