client: misc style improvements

This commit is contained in:
Max Leiter 2022-03-24 19:32:24 -07:00
parent 12f25c49a7
commit 448c443e2e
No known key found for this signature in database
GPG key ID: A3512F2F2F17EBDA
3 changed files with 40 additions and 19 deletions

View file

@ -6,8 +6,10 @@ import styles from './post-page.module.css'
import homeStyles from '@styles/Home.module.css'
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 { useMemo, useState } from "react"
import timeAgo from "@lib/time-ago"
type Props = {
post: Post
@ -29,6 +31,10 @@ const PostPage = ({ post }: Props) => {
link.click()
link.remove()
}
const createdDate = useMemo(() => new Date(post.createdAt), [post.createdAt])
const [time, setTimeAgo] = useState(timeAgo(createdDate))
const formattedTime = `${createdDate.toLocaleDateString()} ${createdDate.toLocaleTimeString()}`
return (
<Page width={"100%"}>
@ -46,9 +52,10 @@ const PostPage = ({ post }: Props) => {
<div className={styles.header}>
<div className={styles.titleAndBadge}>
<Text h2>{post.title}</Text>
<ShiftBy y={-5}>
<span>
<VisibilityBadge visibility={post.visibility} />
</ShiftBy>
<Badge type="secondary"><Tooltip text={formattedTime}>{time}</Tooltip></Badge>
</span>
</div>
<Button auto onClick={download}>
Download as ZIP archive

View file

@ -1,23 +1,35 @@
.header {
display: flex;
justify-content: space-between;
align-items: center;
display: flex;
justify-content: space-between;
align-items: center;
}
.header .titleAndBadge {
display: flex;
text-align: center;
justify-content: space-between;
align-items: center;
display: flex;
text-align: center;
justify-content: space-between;
align-items: center;
}
@media screen and (max-width: 650px) {
.header {
flex-direction: column;
}
.header .titleAndBadge {
flex-direction: column;
padding-bottom: var(--gap-double);
}
.header .titleAndBadge span {
margin-left: var(--gap);
}
@media screen and (max-width: 680px) {
.header {
flex-direction: column;
}
.header .titleAndBadge {
flex-direction: column;
padding-bottom: var(--gap-double);
}
.header .titleAndBadge span {
margin-left: 0;
margin-bottom: var(--gap);
display: flex;
justify-content: space-around;
width: 100%;
}
}

View file

@ -11,6 +11,7 @@ export type File = {
title: string
content: string
html: string
createdAt: string
}
type Files = File[]
@ -21,4 +22,5 @@ export type Post = {
description: string
visibility: PostVisibility
files: Files
createdAt: string
}