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