Skip to content

Commit

Permalink
画像アップロード2
Browse files Browse the repository at this point in the history
  • Loading branch information
34719022 committed Nov 19, 2024
1 parent 23a9d0d commit bcc27a3
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/app/Components/PostForm/PostForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ export default function PostForm() {

const handleImageChange = (event: ChangeEvent<HTMLInputElement>) => {
// TODO: 画像の更新
const selectedFile = event.target.files?.[0];
setImage(selectedFile || null);
setError("");
};

const handleTextChange = (event: ChangeEvent<HTMLInputElement>) => {
// TODO: テキストの更新
setText(event.target.value);
};

const handleUpload = () => {
Expand Down Expand Up @@ -79,10 +83,21 @@ export default function PostForm() {
{error && <Typography color="error">{error}</Typography>}

{/* TODO: テキスト入力 */}
<input
type = "text"
value={text}
onChange={handleTextChange}
placeholder = "投稿内容を入力して下さい"
/>

{/* TODO: 画像選択 */}
<input
type="file"
onChange={handleImageChange}
/>

{/* TODO: アップロードボタン */}
<button onClick={handleUpload}>Upload</button>

{progress !== 100 && <LinearProgressWithLabel value={progress} />}

Expand Down
11 changes: 11 additions & 0 deletions src/app/Components/PostForm/PostFormPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import UserForm from './PostForm';
import styles from './Posts.module.scss';

export default function UserFormPage() {
return (
<div className={styles.container}>
<h1>ユーザー登録</h1>
<UserForm />
</div>
);
}
3 changes: 3 additions & 0 deletions src/app/Components/PostForm/Posts.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.post {
display: flex;
}

0 comments on commit bcc27a3

Please sign in to comment.