client: new-post style improvements and date picker bug fixes

This commit is contained in:
Max Leiter 2022-03-30 23:03:21 -07:00
parent 5da96a8f0a
commit 222b020e9a
No known key found for this signature in database
GPG key ID: A3512F2F2F17EBDA
3 changed files with 60 additions and 23 deletions

View file

@ -163,6 +163,28 @@ const Post = () => {
}
}, [title])
const CustomTimeInput = ({ date, value, onChange }: {
date: Date,
value: string,
onChange: (date: string) => void
}) => (
<input
type="time"
value={value}
onChange={(e) => {
if (!isNaN(date.getTime())) {
onChange(e.target.value || date.toISOString().slice(11, 16))
}
}}
style={{
backgroundColor: 'var(--bg)',
border: '1px solid var(--light-gray)',
borderRadius: 'var(--radius)'
}}
required
/>
);
return (
<div style={{ paddingBottom: 150 }}>
<Title title={title} onChange={onChangeTitle} />
@ -178,23 +200,19 @@ const Post = () => {
id: generateUUID()
}])
}}
style={{ flex: .7, lineHeight: '40px' }}
type="default"
>
Add a File
</Button>
<div style={{
display: 'flex',
gap: 'var(--gap)',
alignItems: 'center',
}}>
<div className={styles.rightButtons}>
{<DatePicker
onChange={onChangeExpiration}
customInput={<Input label="Expires at" clearable height="40px" />}
customInput={<Input label="Expires at" clearable width="100%" height="40px" />}
placeholderText="Won't expire"
selected={expiresAt}
showTimeInput={true}
// customTimeInput={<Input htmlType="time" />}
// @ts-ignore
customTimeInput={<CustomTimeInput />}
timeInputLabel="Time:"
dateFormat="MM/dd/yyyy h:mm aa"
className={styles.datePicker}

View file

@ -4,6 +4,13 @@
justify-content: space-between;
width: 100%;
margin-top: var(--gap-double);
gap: var(--gap);
}
.buttons .rightButtons {
display: flex;
gap: var(--gap);
align-items: center;
}
.datePicker {
@ -30,4 +37,13 @@
justify-content: space-between;
min-height: 95px;
}
.buttons .rightButtons {
flex-direction: column;
align-items: flex-end;
}
.buttons .rightButtons > * {
width: min(100%, 350px);
}
}

View file

@ -18,12 +18,19 @@ const ListItem = ({ post, isOwner = true, deletePost }: { post: Post, isOwner?:
return (<FadeIn><li key={post.id}>
<Card style={{ overflowY: 'scroll' }}>
<Card.Body>
<Text h3>
<Text h3 style={{
}}>
<NextLink passHref={true} href={getPostPath(post.visibility, post.id)}>
<Link color marginRight={'var(--gap)'}>
{post.title}
</Link>
</NextLink>
{isOwner && <span style={{ float: 'right' }}>
<Button iconRight={<Trash />} onClick={deletePost} auto />
</span>}
</Text>
<div style={{ display: 'inline-flex' }}>
<span>
<VisibilityBadge visibility={post.visibility} />
@ -38,10 +45,6 @@ const ListItem = ({ post, isOwner = true, deletePost }: { post: Post, isOwner?:
<ExpirationBadge postExpirationDate={post.expiresAt} />
</span>
</div>
{isOwner && <span style={{ float: 'right' }}>
<Button iconRight={<Trash />} onClick={deletePost} auto />
</span>}
</Text>
</Card.Body>
<Divider h="1px" my={0} />