client: misc style improvements
This commit is contained in:
parent
12f25c49a7
commit
448c443e2e
3 changed files with 40 additions and 19 deletions
|
@ -6,8 +6,10 @@ import styles from './post-page.module.css'
|
||||||
import homeStyles from '@styles/Home.module.css'
|
import homeStyles from '@styles/Home.module.css'
|
||||||
|
|
||||||
import type { File, Post } from "@lib/types"
|
import type { File, Post } from "@lib/types"
|
||||||
import { Page, Button, Text } from "@geist-ui/core"
|
import { Page, Button, Text, Badge, Tooltip, Spacer } from "@geist-ui/core"
|
||||||
import ShiftBy from "@components/shift-by"
|
import ShiftBy from "@components/shift-by"
|
||||||
|
import { useMemo, useState } from "react"
|
||||||
|
import timeAgo from "@lib/time-ago"
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
post: Post
|
post: Post
|
||||||
|
@ -29,6 +31,10 @@ const PostPage = ({ post }: Props) => {
|
||||||
link.click()
|
link.click()
|
||||||
link.remove()
|
link.remove()
|
||||||
}
|
}
|
||||||
|
const createdDate = useMemo(() => new Date(post.createdAt), [post.createdAt])
|
||||||
|
const [time, setTimeAgo] = useState(timeAgo(createdDate))
|
||||||
|
|
||||||
|
const formattedTime = `${createdDate.toLocaleDateString()} ${createdDate.toLocaleTimeString()}`
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Page width={"100%"}>
|
<Page width={"100%"}>
|
||||||
|
@ -46,9 +52,10 @@ const PostPage = ({ post }: Props) => {
|
||||||
<div className={styles.header}>
|
<div className={styles.header}>
|
||||||
<div className={styles.titleAndBadge}>
|
<div className={styles.titleAndBadge}>
|
||||||
<Text h2>{post.title}</Text>
|
<Text h2>{post.title}</Text>
|
||||||
<ShiftBy y={-5}>
|
<span>
|
||||||
<VisibilityBadge visibility={post.visibility} />
|
<VisibilityBadge visibility={post.visibility} />
|
||||||
</ShiftBy>
|
<Badge type="secondary"><Tooltip text={formattedTime}>{time}</Tooltip></Badge>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<Button auto onClick={download}>
|
<Button auto onClick={download}>
|
||||||
Download as ZIP archive
|
Download as ZIP archive
|
||||||
|
|
|
@ -11,7 +11,11 @@
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media screen and (max-width: 650px) {
|
.header .titleAndBadge span {
|
||||||
|
margin-left: var(--gap);
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: 680px) {
|
||||||
.header {
|
.header {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
@ -20,4 +24,12 @@
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
padding-bottom: var(--gap-double);
|
padding-bottom: var(--gap-double);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.header .titleAndBadge span {
|
||||||
|
margin-left: 0;
|
||||||
|
margin-bottom: var(--gap);
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-around;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
2
client/lib/types.d.ts
vendored
2
client/lib/types.d.ts
vendored
|
@ -11,6 +11,7 @@ export type File = {
|
||||||
title: string
|
title: string
|
||||||
content: string
|
content: string
|
||||||
html: string
|
html: string
|
||||||
|
createdAt: string
|
||||||
}
|
}
|
||||||
|
|
||||||
type Files = File[]
|
type Files = File[]
|
||||||
|
@ -21,4 +22,5 @@ export type Post = {
|
||||||
description: string
|
description: string
|
||||||
visibility: PostVisibility
|
visibility: PostVisibility
|
||||||
files: Files
|
files: Files
|
||||||
|
createdAt: string
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue