Skip to content

Commit e34be33

Browse files
committed
updated
1 parent f900dfb commit e34be33

File tree

2 files changed

+78
-7
lines changed

2 files changed

+78
-7
lines changed

src/App.jsx

+56-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,61 @@
1+
import { useState } from 'react';
2+
import NoteContainer from './components/Notes/NoteContainer';
3+
import SideBar from './components/SideBar/SideBar';
4+
5+
const DUMMY_NOTES = [
6+
{
7+
id: 'n3',
8+
text: 'Hey there, Add your note by clicking the plus icon and choosing the theme color',
9+
time: 'Jul 28, 3:50 PM',
10+
color: '#FBA1A1'
11+
},
12+
{
13+
id: 'n2',
14+
text: 'You can edit your note by clicking the pencil icon',
15+
time: 'Jul 25, 8:00 PM',
16+
color: '#C4DFAA'
17+
},
18+
{
19+
id: 'n1',
20+
text: 'You can delete your note too by clicking the delete icon. \n\nYes..Yes you can delete these instruction notes too',
21+
time: 'Jul 18, 10:55 AM',
22+
color: '#F5F0BB'
23+
}
24+
];
25+
126
const App = () => {
27+
28+
const [notes, setNotes] = useState(DUMMY_NOTES);
29+
30+
const addNoteHandler = (themeColor) => {
31+
const note = {
32+
id: Date.now() + "" + Math.floor(Math.random()*78),
33+
text: '',
34+
time: new Date().toLocaleDateString('en-US', { hourCycle: 'h12', minute: '2-digit', day: '2-digit', month: 'short', hour: '2-digit'}),
35+
color: themeColor
36+
}
37+
setNotes( (prevNotes)=>{
38+
return [note, ...prevNotes];
39+
});
40+
}
41+
42+
const deleteNoteHandler = (noteId) => {
43+
const prevNotes = [...notes];
44+
let indexToDelete = -1;
45+
for(let i=0; i<prevNotes.length; i++){
46+
if( prevNotes[i]['id'] == noteId ) indexToDelete=i;
47+
}
48+
if(indexToDelete < 0) return;
49+
else prevNotes.splice(indexToDelete, 1);
50+
setNotes(prevNotes);
51+
}
252

3-
return <div>Hello World</div>;
53+
return(
54+
<div className='app'>
55+
<SideBar addTheme ={ addNoteHandler } />
56+
<NoteContainer notes={notes} deleteNote = { deleteNoteHandler } />
57+
</div>
58+
);
459

560
}
661

src/index.css

+22-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,31 @@
1-
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;700&display=swap');
1+
@import url('https://fonts.googleapis.com/css2?family=Nunito&display=swap');
22

33
*{
44
box-sizing: border-box;
5+
margin: 0;
6+
padding: 0;
57
}
68

79
html {
8-
font-family: 'Noto Sans JP', sans-serif;
10+
font-family: 'Nunito', sans-serif;
911
}
1012

11-
body {
12-
margin: 0;
13-
background-color: #3f3f3f;
14-
color: whitesmoke;
13+
.app{
14+
height: 100vh;
15+
display: flex;
16+
gap: 20px;
17+
padding: 4%;
18+
}
19+
20+
.custom-scroll::-webkit-scrollbar {
21+
width: 8px;
22+
}
23+
.custom-scroll::-webkit-scrollbar-track {
24+
background: #f1f1f1;
25+
}
26+
.custom-scroll::-webkit-scrollbar-thumb {
27+
background: #888;
28+
}
29+
.custom-scroll::-webkit-scrollbar-thumb:hover {
30+
background: #555;
1531
}

0 commit comments

Comments
 (0)