fixed design and functionality of NewPostForm

This commit is contained in:
Pete Gerlach
2024-06-11 13:36:11 +02:00
parent d5bdb496d8
commit 1e0bf3f915
2 changed files with 23 additions and 16 deletions

View File

@@ -6,23 +6,26 @@ const NewPostForm = ({ addPost }) => {
const handleSubmit = (e) => {
e.preventDefault();
if (text.trim()) {
addPost(text);
if (text.trim() && title.trim()) {
addPost(title, text);
setText('');
setTitle('');
}
};
return (
<form className="new-post-form" onSubmit={handleSubmit}>
<input
type="text"
<textarea
className="single-row"
rows={1}
value={title}
onChange={(e) => setTitle(e.target.value)}
placeholder="Titel"
maxLength={50}
/>
<div className="textarea-container">
<textarea
rows={5}
rows={15}
value={text}
onChange={(e) => setText(e.target.value)}
placeholder="Schreibe einen neuen Jodel..."