Skip to content

Commit 0c227a0

Browse files
Samuel Volchenboumclaude
authored andcommitted
Add category feature to notes
- Dropdown to select category (General, Work, Personal, Ideas, Todo) - Category displayed as badge on each note Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 2bb215b commit 0c227a0

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

app.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ def get_notes():
3131
@app.route("/api/notes", methods=["POST"])
3232
def add_note():
3333
notes = load_notes()
34-
note = {"id": len(notes) + 1, "text": request.json["text"]}
34+
note = {
35+
"id": len(notes) + 1,
36+
"text": request.json["text"],
37+
"category": request.json.get("category", "General")
38+
}
3539
notes.append(note)
3640
save_notes(notes)
3741
return jsonify(note), 201

templates/index.html

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@
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>
@@ -22,6 +25,13 @@
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

Comments
 (0)