Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit23d1d30

Browse files
added Add Note component
1 parentdf03614 commit23d1d30

File tree

5 files changed

+38
-4
lines changed

5 files changed

+38
-4
lines changed

‎src/App.tsx‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
import'./App.css';
22
importNotefrom'./components/note/note';
33
import{Notes}from'./components/note/data';
4+
importAddNotefrom'./components/add-note/add-note';
5+
import{useState}from'react';
46

57
functionApp(){
8+
9+
const[notes,setNotes]=useState(Notes);
610
return(
711
<divclassName="App">
812
<h2>Notes App</h2>
13+
<AddNote></AddNote>
914
<div>
1015
{
11-
Notes.map(
12-
note=><Notepriority={note.priority}text={note.text}></Note>
16+
notes.map(
17+
note=><Notekey={note.id}priority={note.priority}text={note.text}></Note>
1318
)
1419
}
1520
</div>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.add-noteinput{
2+
line-height:2rem;
3+
width:80%;
4+
}
5+
.add-notebutton{
6+
line-height:2rem;
7+
width:15%;
8+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import{useState}from'react';
2+
import'./add-note.css';
3+
4+
functionAddNote(){
5+
6+
const[text,setText]=useState("");
7+
consthandleChange=(e:React.ChangeEvent<HTMLInputElement>)=>{
8+
setText(e.target.value);
9+
}
10+
11+
return(
12+
<div>
13+
<formclassName="add-note">
14+
<inputtype="text"onChange={handleChange}/>
15+
<button>Add</button>
16+
</form>
17+
</div>
18+
)
19+
}
20+
21+
exportdefaultAddNote;

‎src/components/note/note.css‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
padding:2rem;
44
font-size:1rem;
55
color:#333;
6-
height:10rem;
6+
height:5rem;
77
border-radius:0.5rem;
88
background-color: burlywood;
99
margin-top:1rem;

‎src/components/note/note.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import'./notes.css'
1+
import'./note.css'
22

33
import{NoteProps}from'./note-type';
44

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp