fix preview rendering on /home, fix signout redirect

This commit is contained in:
Max Leiter 2022-11-20 20:54:34 -08:00
parent 97e4742453
commit 41ed505362
7 changed files with 28 additions and 21 deletions

View file

@ -3,9 +3,11 @@
import { useState } from "react"
import styles from "./auth.module.css"
import Link from "../../components/link"
import { Button, Input, Note } from "@geist-ui/core/dist"
import { signIn } from "next-auth/react"
import { Github as GithubIcon } from "@geist-ui/icons"
import Input from "@components/input"
import Button from "@components/button"
import Note from "@components/note"
const Auth = ({
page,
@ -50,7 +52,7 @@ const Auth = ({
{/* sign in with github */}
{requiresServerPassword && (
<Input
htmlType="password"
type="password"
id="server-password"
value={serverPassword}
onChange={(event) =>
@ -62,11 +64,13 @@ const Auth = ({
/>
)}
<Button
htmlType="submit"
type="success-light"
auto
type="submit"
buttonType="primary"
width="100%"
icon={<GithubIcon />}
style={{
color: 'var(--fg)'
}}
iconLeft={<GithubIcon />}
onClick={(e) => {
e.preventDefault()
signIn("github", {

View file

@ -1,5 +1,6 @@
import styles from "./button.module.css"
import { forwardRef, Ref } from "react"
import clsx from "clsx"
type Props = React.HTMLProps<HTMLButtonElement> & {
children?: React.ReactNode
@ -44,17 +45,15 @@ const Button = forwardRef<HTMLButtonElement, Props>(
{...props}
>
{children && iconLeft && (
<span className={`${styles.icon} ${styles.iconLeft}`}>
{iconLeft}
</span>
<span className={clsx(styles.icon, styles.iconLeft)}>{iconLeft}</span>
)}
{children ? (
children
) : (
<span className={`${styles.icon}`}>{iconLeft || iconRight}</span>
<span className={styles.icon}>{iconLeft || iconRight}</span>
)}
{children && iconRight && (
<span className={`${styles.icon} ${styles.iconRight}`}>
<span className={clsx(styles.icon, styles.iconRight)}>
{iconRight}
</span>
)}

View file

@ -76,3 +76,8 @@
justify-content: space-between;
align-items: center;
}
.active a,
.active button {
color: var(--fg);
}

View file

@ -22,6 +22,7 @@ import { usePathname } from "next/navigation"
import { signOut } from "next-auth/react"
import { useTheme } from "@components/theme/ThemeClientContextProvider"
import Button from "@components/button"
import clsx from "clsx"
type Tab = {
name: string
@ -101,7 +102,9 @@ const Header = ({ signedIn = false, isAdmin = false }) => {
name: "Sign Out",
icon: <SignOutIcon />,
value: "signout",
onClick: () => signOut()
onClick: () => signOut({
callbackUrl: "/",
})
},
...defaultPages
]
@ -148,7 +151,7 @@ const Header = ({ signedIn = false, isAdmin = false }) => {
key={tab.value}
iconLeft={tab.icon}
onClick={() => onTabChange(tab.value)}
className={`${styles.tab} ${activeStyle}`}
className={clsx(styles.tab, activeStyle)}
aria-label={tab.name}
aria-current={isActive ? "page" : undefined}
>
@ -160,7 +163,7 @@ const Header = ({ signedIn = false, isAdmin = false }) => {
<Link
key={tab.value}
href={tab.href}
className={`${styles.tab} ${activeStyle}`}
className={clsx(styles.tab, activeStyle)}
>
<Button iconLeft={tab.icon}>{tab.name ? tab.name : undefined}</Button>
</Link>

View file

@ -31,7 +31,7 @@ const Input = React.forwardRef<HTMLInputElement, Props>(
<input
ref={ref}
id={label}
className={clsx(styles.input, styles.withLabel, className)}
className={clsx(styles.input, label && styles.withLabel, className)}
{...props}
style={{
width,

View file

@ -28,10 +28,6 @@
border-bottom-left-radius: 0;
}
.input::placeholder {
/* font-size: 1rem; */
}
.input:focus {
border-color: var(--light-gray);
}

View file

@ -10,8 +10,8 @@ export default withMethods(
const content = parseQueryParam(body.content)
const title = parseQueryParam(body.title) || "Untitled"
if (!content || !title) {
return res.status(400).json({ error: "Missing arguments" })
if (!content) {
return res.status(400).json({ error: "Missing content" })
}
const renderedHTML = await getHtmlFromFile({