mirror of https://github.com/MaxLeiter/Drift
improvements
parent
6917b813b5
commit
b488e3fdd6
@ -1,7 +1,15 @@
|
||||
"use client"
|
||||
|
||||
import { PageTitle } from "@components/page-title"
|
||||
import { PageWrapper } from "@components/page-wrapper"
|
||||
import PostList from "@components/post-list"
|
||||
|
||||
export default function Loading() {
|
||||
return <PostList skeleton={true} initialPosts={[]} />
|
||||
return (
|
||||
<>
|
||||
<PageTitle>Your Posts</PageTitle>
|
||||
<PageWrapper></PageWrapper>
|
||||
<PostList skeleton={true} initialPosts={[]} />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
@ -1,22 +0,0 @@
|
||||
export default function SettingsLayout({
|
||||
children
|
||||
}: {
|
||||
children: React.ReactNode
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
<h1>Settings</h1>
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
gap: "var(--gap)",
|
||||
marginBottom: "var(--gap)",
|
||||
marginTop: "var(--gap)"
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@ -1,5 +1,15 @@
|
||||
import { PageTitle } from "@components/page-title"
|
||||
import { PageWrapper } from "@components/page-wrapper"
|
||||
import SettingsGroup from "@components/settings-group"
|
||||
|
||||
export default function SettingsLoading() {
|
||||
return <SettingsGroup skeleton />
|
||||
return (
|
||||
<>
|
||||
<PageTitle>Settings</PageTitle>
|
||||
<PageWrapper>
|
||||
<SettingsGroup skeleton />
|
||||
<SettingsGroup skeleton />
|
||||
</PageWrapper>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
@ -0,0 +1,6 @@
|
||||
import { authOptions } from "@lib/server/auth"
|
||||
import NextAuth from "next-auth"
|
||||
|
||||
const handler = NextAuth(authOptions)
|
||||
|
||||
export { handler as GET, handler as POST }
|
||||
@ -0,0 +1,150 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog"
|
||||
|
||||
import { cn } from "@lib/cn"
|
||||
import { buttonVariants } from "@components/button"
|
||||
|
||||
const AlertDialog = AlertDialogPrimitive.Root
|
||||
|
||||
const AlertDialogTrigger = AlertDialogPrimitive.Trigger
|
||||
|
||||
const AlertDialogPortal = ({
|
||||
className,
|
||||
children,
|
||||
...props
|
||||
}: AlertDialogPrimitive.AlertDialogPortalProps) => (
|
||||
<AlertDialogPrimitive.Portal className={cn(className)} {...props}>
|
||||
<div className="fixed inset-0 z-50 flex items-end justify-center sm:items-center">
|
||||
{children}
|
||||
</div>
|
||||
</AlertDialogPrimitive.Portal>
|
||||
)
|
||||
AlertDialogPortal.displayName = AlertDialogPrimitive.Portal.displayName
|
||||
|
||||
const AlertDialogOverlay = React.forwardRef<
|
||||
React.ElementRef<typeof AlertDialogPrimitive.Overlay>,
|
||||
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Overlay>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<AlertDialogPrimitive.Overlay
|
||||
className={cn(
|
||||
"fixed inset-0 z-50 bg-background/80 backdrop-blur-sm transition-opacity animate-in fade-in",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
ref={ref}
|
||||
/>
|
||||
))
|
||||
AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName
|
||||
|
||||
const AlertDialogContent = React.forwardRef<
|
||||
React.ElementRef<typeof AlertDialogPrimitive.Content>,
|
||||
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Content>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<AlertDialogPortal>
|
||||
<AlertDialogOverlay />
|
||||
<AlertDialogPrimitive.Content
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"fixed z-50 grid w-full max-w-lg scale-100 gap-4 border bg-background p-6 opacity-100 shadow-lg animate-in fade-in-90 slide-in-from-bottom-10 sm:rounded-lg sm:zoom-in-90 sm:slide-in-from-bottom-0 md:w-full",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
</AlertDialogPortal>
|
||||
))
|
||||
AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName
|
||||
|
||||
const AlertDialogHeader = ({
|
||||
className,
|
||||
...props
|
||||
}: React.HTMLAttributes<HTMLDivElement>) => (
|
||||
<div
|
||||
className={cn(
|
||||
"flex flex-col space-y-2 text-center sm:text-left",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
AlertDialogHeader.displayName = "AlertDialogHeader"
|
||||
|
||||
const AlertDialogFooter = ({
|
||||
className,
|
||||
...props
|
||||
}: React.HTMLAttributes<HTMLDivElement>) => (
|
||||
<div
|
||||
className={cn(
|
||||
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
AlertDialogFooter.displayName = "AlertDialogFooter"
|
||||
|
||||
const AlertDialogTitle = React.forwardRef<
|
||||
React.ElementRef<typeof AlertDialogPrimitive.Title>,
|
||||
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Title>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<AlertDialogPrimitive.Title
|
||||
ref={ref}
|
||||
className={cn("text-lg font-semibold", className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName
|
||||
|
||||
const AlertDialogDescription = React.forwardRef<
|
||||
React.ElementRef<typeof AlertDialogPrimitive.Description>,
|
||||
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Description>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<AlertDialogPrimitive.Description
|
||||
ref={ref}
|
||||
className={cn("text-sm text-muted-foreground", className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
AlertDialogDescription.displayName =
|
||||
AlertDialogPrimitive.Description.displayName
|
||||
|
||||
const AlertDialogAction = React.forwardRef<
|
||||
React.ElementRef<typeof AlertDialogPrimitive.Action>,
|
||||
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Action>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<AlertDialogPrimitive.Action
|
||||
ref={ref}
|
||||
className={cn(buttonVariants(), className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName
|
||||
|
||||
const AlertDialogCancel = React.forwardRef<
|
||||
React.ElementRef<typeof AlertDialogPrimitive.Cancel>,
|
||||
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Cancel>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<AlertDialogPrimitive.Cancel
|
||||
ref={ref}
|
||||
className={cn(
|
||||
buttonVariants({ variant: "outline" }),
|
||||
"mt-2 sm:mt-0",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName
|
||||
|
||||
export {
|
||||
AlertDialog,
|
||||
AlertDialogTrigger,
|
||||
AlertDialogContent,
|
||||
AlertDialogHeader,
|
||||
AlertDialogFooter,
|
||||
AlertDialogTitle,
|
||||
AlertDialogDescription,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
import { cn } from "@lib/cn"
|
||||
import { PropsWithChildren } from "react"
|
||||
|
||||
export function PageTitle({
|
||||
children,
|
||||
className,
|
||||
...props
|
||||
}: PropsWithChildren<React.HTMLProps<HTMLHeadingElement>>) {
|
||||
return (
|
||||
<h1 className={cn("text-4xl font-bold pb-2 pt-2", className)} {...props}>
|
||||
{children}
|
||||
</h1>
|
||||
)
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
import { cn } from "@lib/cn"
|
||||
import { PropsWithChildren } from "react"
|
||||
|
||||
export function PageWrapper({
|
||||
children,
|
||||
className,
|
||||
...props
|
||||
}: PropsWithChildren<React.HTMLProps<HTMLDivElement>>) {
|
||||
return (
|
||||
<div className={cn("flex flex-col gap-4 mb-4 mt-4", className)} {...props}>
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@ -0,0 +1,227 @@
|
||||
import { PropsWithChildren } from "react"
|
||||
import { cn } from "@lib/cn"
|
||||
|
||||
type ClassProp = { className?: string }
|
||||
|
||||
export function TypographyH1({
|
||||
children,
|
||||
className
|
||||
}: PropsWithChildren<ClassProp>) {
|
||||
return (
|
||||
<h1
|
||||
className={cn(
|
||||
"scroll-m-20 text-4xl font-extrabold tracking-tight lg:text-5xl",
|
||||
className
|
||||
)}
|
||||
>
|
||||
{children}
|
||||
</h1>
|
||||
)
|
||||
}
|
||||
|
||||
export function TypographyH2({
|
||||
children,
|
||||
className
|
||||
}: PropsWithChildren<ClassProp>) {
|
||||
return (
|
||||
<h2
|
||||
className={cn(
|
||||
"scroll-m-20 border-b pb-2 text-3xl font-semibold tracking-tight transition-colors first:mt-0",
|
||||
className
|
||||
)}
|
||||
>
|
||||
{children}
|
||||
</h2>
|
||||
)
|
||||
}
|
||||
|
||||
export function TypographyH3({
|
||||
children,
|
||||
className
|
||||
}: PropsWithChildren<ClassProp>) {
|
||||
return (
|
||||
<h3
|
||||
className={cn(
|
||||
"scroll-m-20 text-2xl font-semibold tracking-tight",
|
||||
className
|
||||
)}
|
||||
>
|
||||
{children}
|
||||
</h3>
|
||||
)
|
||||
}
|
||||
|
||||
export function TypographyH4({
|
||||
children,
|
||||
className
|
||||
}: PropsWithChildren<ClassProp>) {
|
||||
return (
|
||||
<h4
|
||||
className={cn(
|
||||
"scroll-m-20 text-xl font-semibold tracking-tight",
|
||||
className
|
||||
)}
|
||||
>
|
||||
{children}
|
||||
</h4>
|
||||
)
|
||||
}
|
||||
|
||||
export function TypographyP({
|
||||
children,
|
||||
className
|
||||
}: PropsWithChildren<ClassProp>) {
|
||||
return (
|
||||
<p className={cn("leading-7 [&:not(:first-child)]:mt-6", className)}>
|
||||
{children}
|
||||
</p>
|
||||
)
|
||||
}
|
||||
|
||||
export function TypographyBlockquote({
|
||||
children,
|
||||
className
|
||||
}: PropsWithChildren<ClassProp>) {
|
||||
return (
|
||||
<blockquote className={cn("mt-6 border-l-2 pl-6 italic", className)}>
|
||||
{children}
|
||||
</blockquote>
|
||||
)
|
||||
}
|
||||
|
||||
export function TypographyTable({
|
||||
children,
|
||||
className
|
||||
}: PropsWithChildren<ClassProp>) {
|
||||
return (
|
||||
<div className={cn("my-6 w-full overflow-y-auto", className)}>
|
||||
<table className="w-full">{children}</table>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export function TableHead({
|
||||
children,
|
||||
className
|
||||
}: PropsWithChildren<ClassProp>) {
|
||||
return (
|
||||
<thead className={className}>
|
||||
<tr className="m-0 border-t p-0 even:bg-muted">{children}</tr>
|
||||
</thead>
|
||||
)
|
||||
}
|
||||
|
||||
export function TableBody({
|
||||
children,
|
||||
className
|
||||
}: PropsWithChildren<ClassProp>) {
|
||||
return <tbody className={className}>{children}</tbody>
|
||||
}
|
||||
|
||||
export function TableHeader({
|
||||
children,
|
||||
className
|
||||
}: PropsWithChildren<ClassProp>) {
|
||||
return (
|
||||
<th
|
||||
className={cn(
|
||||
"border px-4 py-2 text-left font-bold [&[align=center]]:text-center [&[align=right]]:text-right",
|
||||
className
|
||||
)}
|
||||
>
|
||||
{children}
|
||||
</th>
|
||||
)
|
||||
}
|
||||
|
||||
export function TableRow({
|
||||
children,
|
||||
className
|
||||
}: PropsWithChildren<ClassProp>) {
|
||||
return (
|
||||
<tr className={cn("m-0 border-t p-0 even:bg-muted", className)}>
|
||||
{children}
|
||||
</tr>
|
||||
)
|
||||
}
|
||||
|
||||
export function TableCell({
|
||||
children,
|
||||
className
|
||||
}: PropsWithChildren<ClassProp>) {
|
||||
return (
|
||||
<td
|
||||
className={cn(
|
||||
"border px-4 py-2 text-left [&[align=center]]:text-center [&[align=right]]:text-right",
|
||||
className
|
||||
)}
|
||||
>
|
||||
{children}
|
||||
</td>
|
||||
)
|
||||
}
|
||||
|
||||
export function TypographyList({
|
||||
children,
|
||||
className
|
||||
}: PropsWithChildren<ClassProp>) {
|
||||
return (
|
||||
<ul className={cn("my-6 ml-6 list-disc [&>li]:mt-2", className)}>
|
||||
{children}
|
||||
</ul>
|
||||
)
|
||||
}
|
||||
|
||||
export function TypographyInlineCode({
|
||||
children,
|
||||
className
|
||||
}: PropsWithChildren<ClassProp>) {
|
||||
return (
|
||||
<code
|
||||
className={cn(
|
||||
"relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm font-semibold",
|
||||
className
|
||||
)}
|
||||
>
|
||||
{children}
|
||||
</code>
|
||||
)
|
||||
}
|
||||
|
||||
export function TypographyLead({
|
||||
children,
|
||||
className
|
||||
}: PropsWithChildren<ClassProp>) {
|
||||
return (
|
||||
<p className={cn("text-xl text-muted-foreground", className)}>{children}</p>
|
||||
)
|
||||
}
|
||||
|
||||
export function TypographyLarge({
|
||||
children,
|
||||
className
|
||||
}: PropsWithChildren<ClassProp>) {
|
||||
return (
|
||||
<div className={cn("text-lg font-semibold", className)}>{children}</div>
|
||||
)
|
||||
}
|
||||
|
||||
export function TypographySmall({
|
||||
children,
|
||||
className
|
||||
}: PropsWithChildren<ClassProp>) {
|
||||
return (
|
||||
<small className={cn("text-sm font-medium leading-none", className)}>
|
||||
{children}
|
||||
</small>
|
||||
)
|
||||
}
|
||||
|
||||
export function TypographyMuted({
|
||||
children,
|
||||
className
|
||||
}: PropsWithChildren<ClassProp>) {
|
||||
return (
|
||||
<p className={cn("text-sm text-muted-foreground", className)}>{children}</p>
|
||||
)
|
||||
}
|
||||
@ -1,4 +0,0 @@
|
||||
import { authOptions } from "@lib/server/auth"
|
||||
import NextAuth from "next-auth"
|
||||
|
||||
export default NextAuth(authOptions)
|
||||
@ -1,36 +0,0 @@
|
||||
import config from "@lib/config"
|
||||
import { NextApiRequest, NextApiResponse } from "next"
|
||||
|
||||
export const getRequiresPasscode = async () => {
|
||||
const requiresPasscode = Boolean(config.registration_password)
|
||||
return requiresPasscode
|
||||
}
|
||||
|
||||
const handleRequiresPasscode = async (
|
||||
_: NextApiRequest,
|
||||
res: NextApiResponse
|
||||
) => {
|
||||
return res.json({ requiresPasscode: await getRequiresPasscode() })
|
||||
}
|
||||
|
||||
export default async function requiresPasscode(
|
||||
req: NextApiRequest,
|
||||
res: NextApiResponse
|
||||
) {
|
||||
const { slug } = req.query
|
||||
|
||||
if (!slug || Array.isArray(slug)) {
|
||||
return res.status(400).json({ error: "Missing param" })
|
||||
}
|
||||
|
||||
switch (req.method) {
|
||||
case "GET":
|
||||
if (slug === "requires-passcode") {
|
||||
return handleRequiresPasscode(req, res)
|
||||
}
|
||||
|
||||
return res.status(404).json({ error: "Not found" })
|
||||
default:
|
||||
return res.status(405).json({ error: "Method not allowed" })
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue