2022-04-09 20:48:19 -04:00
|
|
|
import { ChangeEvent, memo, useEffect, useState } from "react"
|
2022-03-21 23:30:45 -04:00
|
|
|
|
2022-11-12 04:28:06 -05:00
|
|
|
import ShiftBy from "@components/shift-by"
|
2022-04-09 20:48:19 -04:00
|
|
|
import styles from "../post.module.css"
|
2022-11-16 03:49:12 -05:00
|
|
|
import Input from "@components/input"
|
2022-03-06 19:46:59 -05:00
|
|
|
|
|
|
|
const titlePlaceholders = [
|
2022-04-09 20:48:19 -04:00
|
|
|
"How to...",
|
|
|
|
"Status update for ...",
|
|
|
|
"My new project",
|
|
|
|
"My new idea",
|
|
|
|
"Let's talk about...",
|
|
|
|
"What's up with ...",
|
|
|
|
"I'm thinking about ..."
|
2022-03-06 19:46:59 -05:00
|
|
|
]
|
|
|
|
|
|
|
|
type props = {
|
2022-04-09 20:48:19 -04:00
|
|
|
onChange: (e: ChangeEvent<HTMLInputElement>) => void
|
|
|
|
title?: string
|
2022-03-06 19:46:59 -05:00
|
|
|
}
|
|
|
|
|
2022-03-22 01:50:25 -04:00
|
|
|
const Title = ({ onChange, title }: props) => {
|
2022-04-09 20:48:19 -04:00
|
|
|
const [placeholder, setPlaceholder] = useState(titlePlaceholders[0])
|
|
|
|
useEffect(() => {
|
|
|
|
// set random placeholder on load
|
|
|
|
setPlaceholder(
|
|
|
|
titlePlaceholders[Math.floor(Math.random() * titlePlaceholders.length)]
|
|
|
|
)
|
|
|
|
}, [])
|
|
|
|
return (
|
|
|
|
<div className={styles.title}>
|
2022-11-16 03:49:12 -05:00
|
|
|
<h1 className={styles.drift}>Drift</h1>
|
|
|
|
<Input
|
|
|
|
placeholder={placeholder}
|
|
|
|
value={title || ""}
|
|
|
|
onChange={onChange}
|
|
|
|
height={"55px"}
|
|
|
|
label="Post title"
|
|
|
|
style={{ width: "100%", fontSize: 18 }}
|
|
|
|
/>
|
2022-04-09 20:48:19 -04:00
|
|
|
</div>
|
|
|
|
)
|
2022-03-06 19:46:59 -05:00
|
|
|
}
|
|
|
|
|
2022-04-09 20:48:19 -04:00
|
|
|
export default memo(Title)
|