File size: 12,291 Bytes
3d3476e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
<!DOCTYPE html>
<html lang="pt-BR">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Notas Editáveis</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        .note {
            transition: all 0.3s ease;
            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
        }
        .note:hover {
            transform: translateY(-2px);
            box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
        }
        .color-option {
            width: 24px;
            height: 24px;
            border-radius: 50%;
            cursor: pointer;
            transition: transform 0.2s;
        }
        .color-option:hover {
            transform: scale(1.2);
        }
        .fade-in {
            animation: fadeIn 0.3s ease-in-out;
        }
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(10px); }
            to { opacity: 1; transform: translateY(0); }
        }
    </style>
</head>
<body class="bg-gray-100 min-h-screen">
    <div class="container mx-auto px-4 py-8">
        <!-- Header -->
        <header class="flex justify-between items-center mb-8">
            <h1 class="text-3xl font-bold text-indigo-700">
                <i class="fas fa-edit mr-2"></i> Notas Editáveis
            </h1>
            <button id="newNoteBtn" class="bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-lg flex items-center transition-colors">
                <i class="fas fa-plus mr-2"></i> Nova Nota
            </button>
        </header>

        <!-- Notes Grid -->
        <div id="notesContainer" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
            <!-- Notes will be added here dynamically -->
        </div>

        <!-- Empty State -->
        <div id="emptyState" class="text-center py-20">
            <i class="fas fa-sticky-note text-6xl text-gray-300 mb-4"></i>
            <h3 class="text-xl font-medium text-gray-500">Nenhuma nota criada ainda</h3>
            <p class="text-gray-400 mb-4">Clique no botão "Nova Nota" para começar</p>
        </div>
    </div>

    <!-- Color Picker Modal (hidden by default) -->
    <div id="colorPickerModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center hidden z-50">
        <div class="bg-white rounded-lg p-6 w-64">
            <h3 class="font-bold text-lg mb-4">Escolha uma cor</h3>
            <div class="grid grid-cols-5 gap-3 mb-4">
                <div class="color-option bg-blue-200" data-color="blue-200"></div>
                <div class="color-option bg-green-200" data-color="green-200"></div>
                <div class="color-option bg-yellow-200" data-color="yellow-200"></div>
                <div class="color-option bg-red-200" data-color="red-200"></div>
                <div class="color-option bg-purple-200" data-color="purple-200"></div>
                <div class="color-option bg-pink-200" data-color="pink-200"></div>
                <div class="color-option bg-indigo-200" data-color="indigo-200"></div>
                <div class="color-option bg-gray-200" data-color="gray-200"></div>
                <div class="color-option bg-teal-200" data-color="teal-200"></div>
                <div class="color-option bg-orange-200" data-color="orange-200"></div>
            </div>
            <div class="flex justify-end space-x-2">
                <button id="cancelColorBtn" class="px-4 py-2 text-gray-600 hover:text-gray-800">Cancelar</button>
                <button id="applyColorBtn" class="px-4 py-2 bg-indigo-600 text-white rounded hover:bg-indigo-700">Aplicar</button>
            </div>
        </div>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            // DOM Elements
            const newNoteBtn = document.getElementById('newNoteBtn');
            const notesContainer = document.getElementById('notesContainer');
            const emptyState = document.getElementById('emptyState');
            const colorPickerModal = document.getElementById('colorPickerModal');
            const cancelColorBtn = document.getElementById('cancelColorBtn');
            const applyColorBtn = document.getElementById('applyColorBtn');
            const colorOptions = document.querySelectorAll('.color-option');
            
            // State
            let notes = JSON.parse(localStorage.getItem('notes')) || [];
            let currentNoteId = null;
            let selectedColor = 'yellow-200';

            // Initialize
            renderNotes();
            updateEmptyState();

            // Event Listeners
            newNoteBtn.addEventListener('click', createNewNote);
            cancelColorBtn.addEventListener('click', hideColorPicker);
            applyColorBtn.addEventListener('click', applySelectedColor);
            
            colorOptions.forEach(option => {
                option.addEventListener('click', function() {
                    selectedColor = this.getAttribute('data-color');
                    // Highlight selected color
                    colorOptions.forEach(opt => opt.classList.remove('ring-2', 'ring-offset-2', 'ring-indigo-500'));
                    this.classList.add('ring-2', 'ring-offset-2', 'ring-indigo-500');
                });
            });

            // Functions
            function createNewNote() {
                const newNote = {
                    id: Date.now(),
                    title: 'Nova Nota',
                    content: 'Comece a digitar aqui...',
                    color: 'yellow-200',
                    createdAt: new Date().toISOString()
                };
                
                notes.unshift(newNote);
                saveNotes();
                renderNotes();
                updateEmptyState();
                
                // Focus on the title of the first note (the new one)
                setTimeout(() => {
                    const firstNote = document.querySelector('.note');
                    if (firstNote) {
                        const titleInput = firstNote.querySelector('.note-title');
                        titleInput.focus();
                        titleInput.select();
                    }
                }, 100);
            }

            function renderNotes() {
                notesContainer.innerHTML = '';
                
                notes.forEach(note => {
                    const noteElement = document.createElement('div');
                    noteElement.className = `note rounded-lg p-4 flex flex-col bg-${note.color} fade-in`;
                    noteElement.dataset.id = note.id;
                    
                    noteElement.innerHTML = `
                        <div class="flex justify-between items-center mb-2">
                            <input type="text" class="note-title bg-transparent font-bold text-lg w-full focus:outline-none border-b border-transparent focus:border-gray-400" value="${note.title}">
                            <div class="flex space-x-2">
                                <button class="note-color-btn text-gray-600 hover:text-gray-800">
                                    <i class="fas fa-palette"></i>
                                </button>
                                <button class="note-delete-btn text-gray-600 hover:text-red-500">
                                    <i class="fas fa-trash"></i>
                                </button>
                            </div>
                        </div>
                        <textarea class="note-content bg-transparent flex-grow resize-none focus:outline-none">${note.content}</textarea>
                        <div class="text-xs text-gray-500 mt-2">
                            ${formatDate(note.createdAt)}
                        </div>
                    `;
                    
                    notesContainer.appendChild(noteElement);
                    
                    // Add event listeners to the new note
                    const titleInput = noteElement.querySelector('.note-title');
                    const contentInput = noteElement.querySelector('.note-content');
                    const colorBtn = noteElement.querySelector('.note-color-btn');
                    const deleteBtn = noteElement.querySelector('.note-delete-btn');
                    
                    titleInput.addEventListener('input', () => updateNote(note.id, 'title', titleInput.value));
                    contentInput.addEventListener('input', () => updateNote(note.id, 'content', contentInput.value));
                    colorBtn.addEventListener('click', () => showColorPicker(note.id));
                    deleteBtn.addEventListener('click', () => deleteNote(note.id));
                });
            }

            function updateNote(id, field, value) {
                const noteIndex = notes.findIndex(note => note.id === id);
                if (noteIndex !== -1) {
                    notes[noteIndex][field] = value;
                    saveNotes();
                }
            }

            function deleteNote(id) {
                if (confirm('Tem certeza que deseja excluir esta nota?')) {
                    notes = notes.filter(note => note.id !== id);
                    saveNotes();
                    renderNotes();
                    updateEmptyState();
                }
            }

            function showColorPicker(noteId) {
                currentNoteId = noteId;
                const note = notes.find(n => n.id === noteId);
                if (note) {
                    // Reset selected color
                    colorOptions.forEach(opt => {
                        opt.classList.remove('ring-2', 'ring-offset-2', 'ring-indigo-500');
                        if (opt.getAttribute('data-color') === note.color) {
                            opt.classList.add('ring-2', 'ring-offset-2', 'ring-indigo-500');
                            selectedColor = note.color;
                        }
                    });
                    colorPickerModal.classList.remove('hidden');
                }
            }

            function hideColorPicker() {
                colorPickerModal.classList.add('hidden');
            }

            function applySelectedColor() {
                if (currentNoteId) {
                    const noteIndex = notes.findIndex(note => note.id === currentNoteId);
                    if (noteIndex !== -1) {
                        notes[noteIndex].color = selectedColor;
                        saveNotes();
                        renderNotes();
                        hideColorPicker();
                    }
                }
            }

            function saveNotes() {
                localStorage.setItem('notes', JSON.stringify(notes));
            }

            function updateEmptyState() {
                emptyState.style.display = notes.length === 0 ? 'block' : 'none';
            }

            function formatDate(dateString) {
                const options = { 
                    year: 'numeric', 
                    month: 'short', 
                    day: 'numeric',
                    hour: '2-digit',
                    minute: '2-digit'
                };
                return new Date(dateString).toLocaleDateString('pt-BR', options);
            }
        });
    </script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Elleres/ellerestech" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>