File size: 943 Bytes
65567a2
 
 
6c2bcb4
65567a2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6c2bcb4
65567a2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { useState } from "react";
import Box from "@mui/material/Box";
import InputBase from "@mui/material/InputBase";
import { poppins } from "@/lib/theme";
import IconButton from "@mui/material/IconButton";
import SaveIcon from "@mui/icons-material/Save";

export function EditTitle({ value, onSave }: { value: string; onSave(value: string): void }) {
	const [text, setText] = useState(value);
	return (
		<>
			<Box
				sx={{
					pl: 3,
					pr: 6,
					flex: 1,
					display: "flex",
					alignItems: "center",
				}}
			>
				<InputBase
					autoFocus
					value={text}
					sx={{
						width: "100%",
						fontSize: 16,
						input: { ...poppins.style, p: 0, lineHeight: 1.5 },
					}}
					onChange={event => {
						setText(event.target.value);
					}}
					onBlur={() => {
						onSave(text);
					}}
				/>
			</Box>
			<IconButton
				onClick={() => {
					onSave(text);
				}}
			>
				<SaveIcon />
			</IconButton>
		</>
	);
}