Skip to content

Commit 48e05c3

Browse files
textarea and multi-line notes
1 parent 6c76e74 commit 48e05c3

File tree

5 files changed

+37
-6
lines changed

5 files changed

+37
-6
lines changed

db.json

+21
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,27 @@
2020
"id": "78486737-f03f-4da1-a40c-460149e7cf87",
2121
"createdAt": "2022-09-17T16:16:02.765Z",
2222
"updatedAt": "2022-09-17T16:18:04.640Z"
23+
},
24+
{
25+
"text": "asdasdsad\nAsadasds\nasdasdasdad",
26+
"priority": "low",
27+
"id": "52ceb228-fc3b-440e-b849-31351a188498",
28+
"createdAt": "2022-09-17T19:00:58.267Z",
29+
"updatedAt": "2022-09-17T19:00:58.267Z"
30+
},
31+
{
32+
"text": "line 1\nline 2\nline 3\nline 4\n",
33+
"priority": "low",
34+
"id": "a1ad66bb-7f36-48f2-b6b0-e21dfadd5d63",
35+
"createdAt": "2022-09-17T19:01:13.245Z",
36+
"updatedAt": "2022-09-17T19:01:13.245Z"
37+
},
38+
{
39+
"text": "sdasdadasd asdasd sad asda. asd as das d asd as das d das d sa dd asd das dd\n a sd sa d asdsad \n sad sadas d asd sad\n a sd sa das d asdsa\n\n\nasdsdasdasd",
40+
"priority": "low",
41+
"id": "32a0c88d-45cc-4997-bc03-9c5dd31093aa",
42+
"createdAt": "2022-09-17T19:02:48.509Z",
43+
"updatedAt": "2022-09-17T19:02:48.509Z"
2344
}
2445
]
2546
}

src/components/add-note/add-note.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
.add-note input{
2-
line-height: 2rem;
1+
.add-note textarea{
32
width: 60%;
43
border:0;
54
padding: 0;
5+
vertical-align: bottom;
66
}
77
.add-note button{
88
line-height: 2rem;

src/components/add-note/add-note.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function AddNote(props: AddNoteProps) {
1616
const theme = useContext(ThemeContext);
1717
const { state, dispatch } = useContext(StateContext);
1818

19-
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
19+
const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
2020
setText(e.target.value);
2121
};
2222

@@ -78,7 +78,8 @@ function AddNote(props: AddNoteProps) {
7878
return (
7979
<Card bgColor={theme === 'dark' ? '#333' : '#ddd'} height="2" padding="1">
8080
<form className="add-note">
81-
<input type="text" onChange={handleChange} value={text} />
81+
<textarea onChange={handleChange} value={text}></textarea>
82+
{/* <input type="text" onChange={handleChange} value={text} /> */}
8283
<select onChange={handleSelect} value={priority}>
8384
<option value="high">High</option>
8485
<option value="medium">Medium</option>

src/components/note/note.css

+9
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,13 @@
1313
}
1414
.date{
1515
font-size: 0.3rem;
16+
}
17+
.text{
18+
white-space: pre-wrap;
19+
overflow: hidden;
20+
text-overflow: ellipsis;
21+
display: -webkit-box;
22+
-webkit-line-clamp: 2; /* number of lines to show */
23+
line-clamp: 2;
24+
-webkit-box-orient: vertical;
1625
}

src/components/note/note.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ function Note(props: NoteProps) {
3939
? props.priority && ColorDark[props.priority]
4040
: props.priority && ColorLight[props.priority]
4141
}
42-
height="2"
42+
height="3"
4343
padding="1"
4444
>
4545
<>
46-
<div>{props.text}</div>
46+
<div className='text'>{props.text}</div>
4747
<div className='left-corner date'>{props.updatedAt.toLocaleString()}</div>
4848
<div className="right-corner">
4949
<FaEdit onClick={() => editNote(props.note)}></FaEdit>

0 commit comments

Comments
 (0)