This commit is contained in:
Max Leiter 2022-12-04 14:26:14 -08:00
parent 72633c6ad2
commit 5918b13867
18 changed files with 49 additions and 26 deletions

View file

@ -7,7 +7,7 @@ import { signIn } from "next-auth/react"
import Input from "@components/input" import Input from "@components/input"
import Button from "@components/button" import Button from "@components/button"
import Note from "@components/note" import Note from "@components/note"
import { GitHub } from 'react-feather' import { GitHub } from "react-feather"
const Auth = ({ const Auth = ({
page, page,
requiresServerPassword requiresServerPassword
@ -68,7 +68,7 @@ const Auth = ({
buttonType="primary" buttonType="primary"
width="100%" width="100%"
style={{ style={{
color: 'var(--fg)' color: "var(--fg)"
}} }}
iconLeft={<GitHub />} iconLeft={<GitHub />}
onClick={(e) => { onClick={(e) => {

View file

@ -11,7 +11,13 @@ type Item = File & {
icon: JSX.Element icon: JSX.Element
} }
const FileDropdown = ({ files, loading }: { files: File[], loading?: boolean }) => { const FileDropdown = ({
files,
loading
}: {
files: File[]
loading?: boolean
}) => {
if (loading) { if (loading) {
return <Spinner /> return <Spinner />
} }

View file

@ -86,7 +86,8 @@ function FileDropzone({ setDocs }: { setDocs: (docs: Document[]) => void }) {
<input {...getInputProps()} /> <input {...getInputProps()} />
{!isDragActive && ( {!isDragActive && (
<p style={{ color: "var(--gray)" }}> <p style={{ color: "var(--gray)" }}>
Drag some files here, or <span className={styles.verb} /> to select files Drag some files here, or <span className={styles.verb} /> to select
files
</p> </p>
)} )}
{isDragActive && <p>Release to drop the files here</p>} {isDragActive && <p>Release to drop the files here</p>}

View file

@ -1,4 +1,11 @@
import { Bold, Code, Image as ImageIcon, Italic, Link, List } from "react-feather" import {
Bold,
Code,
Image as ImageIcon,
Italic,
Link,
List
} from "react-feather"
import { RefObject, useMemo } from "react" import { RefObject, useMemo } from "react"
import styles from "./formatting-icons.module.css" import styles from "./formatting-icons.module.css"
import { TextareaMarkdownRef } from "textarea-markdown-editor" import { TextareaMarkdownRef } from "textarea-markdown-editor"

View file

@ -25,7 +25,7 @@ const NewFromExisting = async ({
withFiles: true, withFiles: true,
withAuthor: false withAuthor: false
}) })
const serialized = JSON.stringify(post) const serialized = JSON.stringify(post)
return <NewPost initialPost={serialized} newPostParent={id} /> return <NewPost initialPost={serialized} newPostParent={id} />

View file

@ -69,7 +69,6 @@ const PostPage = ({ post: initialPost, isProtected, isAuthor }: Props) => {
preview={html} preview={html}
/> />
))} ))}
</> </>
) )
} }

View file

@ -1,4 +1,4 @@
'use client'; "use client"
import { Post, PostWithFilesAndAuthor } from "@lib/server/prisma" import { Post, PostWithFilesAndAuthor } from "@lib/server/prisma"
import PasswordModal from "@components/password-modal" import PasswordModal from "@components/password-modal"

View file

@ -67,10 +67,10 @@ const getPost = async (id: string) => {
createdAt: new Date("1970-01-01"), createdAt: new Date("1970-01-01"),
expiresAt: new Date("1970-01-01"), expiresAt: new Date("1970-01-01"),
author: { author: {
displayName: "", displayName: ""
}, },
description: "", description: "",
authorId: "", authorId: ""
}, },
isProtected: true, isProtected: true,
isAuthor: isAuthorOrAdmin isAuthor: isAuthorOrAdmin

View file

@ -57,7 +57,11 @@ export function PostTable({
<tbody> <tbody>
{posts?.map((post) => ( {posts?.map((post) => (
<tr key={post.id}> <tr key={post.id}>
<td><a href={`/post/${post.id}`} target="_blank" rel="noreferrer">{post.title}</a></td> <td>
<a href={`/post/${post.id}`} target="_blank" rel="noreferrer">
{post.title}
</a>
</td>
<td>{"author" in post ? post.author.name : "no author"}</td> <td>{"author" in post ? post.author.name : "no author"}</td>
<td>{post.createdAt.toLocaleDateString()}</td> <td>{post.createdAt.toLocaleDateString()}</td>
<td>{post.visibility}</td> <td>{post.visibility}</td>

View file

@ -4,13 +4,19 @@ import { Suspense } from "react"
async function PostListWrapper({ async function PostListWrapper({
posts, posts,
userId, userId
}: { }: {
posts: ReturnType<typeof getPostsByUser> posts: ReturnType<typeof getPostsByUser>
userId: string userId: string
}) { }) {
const data = (await posts).filter((post) => post.visibility === "public") const data = (await posts).filter((post) => post.visibility === "public")
return <PostList morePosts={false} userId={userId} initialPosts={JSON.stringify(data)} /> return (
<PostList
morePosts={false}
userId={userId}
initialPosts={JSON.stringify(data)}
/>
)
} }
export default async function UserPage({ export default async function UserPage({

View file

@ -1,4 +1,4 @@
'use client' "use client"
import Tooltip from "@components/tooltip" import Tooltip from "@components/tooltip"
import { timeAgo } from "@lib/time-ago" import { timeAgo } from "@lib/time-ago"
import { useMemo, useState, useEffect } from "react" import { useMemo, useState, useEffect } from "react"

View file

@ -1,4 +1,4 @@
'use client'; "use client"
import PasswordModal from "@components/password-modal" import PasswordModal from "@components/password-modal"
import { useCallback, useState } from "react" import { useCallback, useState } from "react"

View file

@ -159,13 +159,15 @@ const Header = () => {
// TODO: this is a hack to close the radix ui menu when a next link is clicked // TODO: this is a hack to close the radix ui menu when a next link is clicked
const onClick = () => { const onClick = () => {
document.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape' })); document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape" }))
} }
return ( return (
<header className={clsx(styles.header, { <header
[styles.loading]: isLoading, className={clsx(styles.header, {
})}> [styles.loading]: isLoading
})}
>
<div className={styles.tabs}> <div className={styles.tabs}>
<div className={styles.buttons}>{buttons}</div> <div className={styles.buttons}>{buttons}</div>
</div> </div>

View file

@ -1,4 +1,4 @@
'use client'; "use client"
import Button from "@components/button" import Button from "@components/button"
import Tooltip from "@components/tooltip" import Tooltip from "@components/tooltip"

View file

@ -1,3 +1,3 @@
import styles from './spinner.module.css' import styles from "./spinner.module.css"
export const Spinner = () => <div className={styles.spinner} /> export const Spinner = () => <div className={styles.spinner} />

View file

@ -18,9 +18,7 @@ export default async function RootLayout({ children }: RootLayoutProps) {
<html lang="en"> <html lang="en">
<head /> <head />
<body> <body>
<LayoutWrapper> <LayoutWrapper>{children}</LayoutWrapper>
{children}
</LayoutWrapper>
</body> </body>
</html> </html>
</ServerThemeProvider> </ServerThemeProvider>

View file

@ -63,7 +63,7 @@ export const config = (env: Environment): Config => {
validNodeEnvs(env.NODE_ENV) validNodeEnvs(env.NODE_ENV)
throwIfUndefined("DATABASE_URL"); throwIfUndefined("DATABASE_URL")
const config: Config = { const config: Config = {
is_production, is_production,

View file

@ -7,7 +7,7 @@ import config from "@lib/config"
const providers: NextAuthOptions["providers"] = [ const providers: NextAuthOptions["providers"] = [
GitHubProvider({ GitHubProvider({
clientId: config.github_client_id, clientId: config.github_client_id,
clientSecret: config.github_client_secret, clientSecret: config.github_client_secret
}) })
] ]