88 * { box-sizing : border-box; }
99 body { font-family : -apple-system, sans-serif; max-width : 600px ; margin : 50px auto; padding : 20px ; background : # f5f5f5 ; }
1010 h1 { color : # 333 ; }
11- .note-input { display : flex; gap : 10px ; margin-bottom : 20px ; }
12- input [type = "text" ] { flex : 1 ; padding : 12px ; font-size : 16px ; border : 1px solid # ddd ; border-radius : 6px ; }
11+ .note-input { display : flex; gap : 10px ; margin-bottom : 20px ; flex-wrap : wrap; }
12+ input [type = "text" ] { flex : 1 ; padding : 12px ; font-size : 16px ; border : 1px solid # ddd ; border-radius : 6px ; min-width : 200px ; }
13+ select { padding : 12px ; font-size : 16px ; border : 1px solid # ddd ; border-radius : 6px ; background : white; }
1314 button { padding : 12px 24px ; font-size : 16px ; background : # 007bff ; color : white; border : none; border-radius : 6px ; cursor : pointer; }
1415 button : hover { background : # 0056b3 ; }
15- .note { background : white; padding : 15px ; margin-bottom : 10px ; border-radius : 6px ; display : flex; justify-content : space-between; align-items : center; box-shadow : 0 1px 3px rgba (0 , 0 , 0 , 0.1 ); }
16- .note span { flex : 1 ; }
16+ .note { background : white; padding : 15px ; margin-bottom : 10px ; border-radius : 6px ; display : flex; justify-content : space-between; align-items : center; box-shadow : 0 1px 3px rgba (0 , 0 , 0 , 0.1 ); gap : 10px ; }
17+ .note-content { flex : 1 ; }
18+ .note-text { margin : 0 0 5px 0 ; }
19+ .note-category { font-size : 12px ; color : # 666 ; background : # e9ecef ; padding : 2px 8px ; border-radius : 12px ; display : inline-block; }
1720 .delete-btn { background : # e91e8c ; padding : 8px 16px ; }
1821 .delete-btn : hover { background : # c4177a ; }
1922 </ style >
2225 < h1 > Simple Notes</ h1 >
2326 < div class ="note-input ">
2427 < input type ="text " id ="noteInput " placeholder ="Enter a note... " onkeypress ="if(event.key==='Enter')addNote() ">
28+ < select id ="categorySelect ">
29+ < option value ="General "> General</ option >
30+ < option value ="Work "> Work</ option >
31+ < option value ="Personal "> Personal</ option >
32+ < option value ="Ideas "> Ideas</ option >
33+ < option value ="Todo "> Todo</ option >
34+ </ select >
2535 < button onclick ="addNote() "> Add</ button >
2636 </ div >
2737 < div id ="notes "> </ div >
@@ -33,20 +43,24 @@ <h1>Simple Notes</h1>
3343 const container = document . getElementById ( 'notes' ) ;
3444 container . innerHTML = notes . map ( note => `
3545 <div class="note">
36- <span>${ note . text } </span>
46+ <div class="note-content">
47+ <p class="note-text">${ note . text } </p>
48+ <span class="note-category">${ note . category || 'General' } </span>
49+ </div>
3750 <button class="delete-btn" onclick="deleteNote(${ note . id } )">Delete</button>
3851 </div>
3952 ` ) . join ( '' ) ;
4053 }
4154
4255 async function addNote ( ) {
4356 const input = document . getElementById ( 'noteInput' ) ;
57+ const categorySelect = document . getElementById ( 'categorySelect' ) ;
4458 const text = input . value . trim ( ) ;
4559 if ( ! text ) return ;
4660 await fetch ( '/api/notes' , {
4761 method : 'POST' ,
4862 headers : { 'Content-Type' : 'application/json' } ,
49- body : JSON . stringify ( { text } )
63+ body : JSON . stringify ( { text, category : categorySelect . value } )
5064 } ) ;
5165 input . value = '' ;
5266 loadNotes ( ) ;
0 commit comments