fixed design and functionality of NewPostForm
This commit is contained in:
12
src/App.scss
12
src/App.scss
@@ -34,10 +34,6 @@ h1 {
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
.textarea-container {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
|
||||
textarea {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
@@ -47,7 +43,15 @@ h1 {
|
||||
border-radius: 10px;
|
||||
font-size: 1em;
|
||||
font-family: Arial, sans-serif;
|
||||
|
||||
&.single-row {
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
.textarea-container {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
|
||||
.char-count-container {
|
||||
position: absolute;
|
||||
|
||||
@@ -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..."
|
||||
|
||||
Reference in New Issue
Block a user