-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.svelte
40 lines (36 loc) · 977 Bytes
/
App.svelte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<!-- App.svelte -->
<script>
import StickyNote from './StickyNote.svelte';
import Note from './Note.svelte';
let notes = [
// { id: 1, content: 'Note 1' },Automatically add two notes
// { id: 2, content: 'Note 2' },
];
let newNoteContent = '';
function addNote() {
if (newNoteContent.trim() !== '') {
notes = [...notes, { id: Date.now(), content: newNoteContent }];
newNoteContent = '';
}
}
</script>
<div>
<div>
<textarea bind:value={newNoteContent}></textarea>
<button on:click={addNote}>Add Note</button>
</div>
{#each notes as note (note.id)}
<Note>
<div class="con" contenteditable>{note.content}</div>
</Note>
{/each}
</div>
<style>
.con
{
background: yellow;
padding: 20px;
width: 200px;
color:black;
text-align: center;
}</style>