Spaces:
Running

tes-note-app / index.html
ervareza's picture
Add 1 files
4c1950f verified
Raw History Blame Contribute Delete
63.5 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Elegant Notes | Modern Notepad App</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> @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap'); body { font-family: 'Poppins', sans-serif; transition: all 0.3s ease; display: flex; min-height: 100vh; } .sidebar { width: 16rem; height: 100vh; position: sticky; top: 0; overflow-y: auto; } .main-content { flex: 1; overflow-y: auto; height: 100vh; } .note-item:hover .note-actions { opacity: 1; } @media (max-width: 768px) { .sidebar { transform: translateX(-100%); position: fixed; z-index: 20; height: 100vh; } .sidebar.open { transform: translateX(0); } .overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5); z-index: 10; display: none; } .overlay.open { display: block; } } /* Custom scrollbar */ ::-webkit-scrollbar { width: 8px; } ::-webkit-scrollbar-track { background: #f1f1f1; } ::-webkit-scrollbar-thumb { background: #888; border-radius: 4px; } ::-webkit-scrollbar-thumb:hover { background: #555; } /* Markdown preview styles */ .markdown-preview h1 { font-size: 2em; font-weight: bold; margin: 0.67em 0; } .markdown-preview h2 { font-size: 1.5em; font-weight: bold; margin: 0.83em 0; } .markdown-preview h3 { font-size: 1.17em; font-weight: bold; margin: 1em 0; } .markdown-preview p { margin: 1em 0; } .markdown-preview ul, .markdown-preview ol { margin: 1em 0; padding-left: 2em; } .markdown-preview ul { list-style-type: disc; } .markdown-preview ol { list-style-type: decimal; } .markdown-preview blockquote { border-left: 4px solid #ddd; padding-left: 1em; color: #777; margin: 1em 0; } .markdown-preview pre { background-color: #f5f5f5; padding: 1em; border-radius: 4px; overflow-x: auto; } .markdown-preview code { font-family: monospace; background-color: #f5f5f5; padding: 0.2em 0.4em; border-radius: 3px; } .markdown-preview a { color: #3b82f6; text-decoration: underline; } .markdown-preview img { max-width: 100%; } /* Animation for note cards */ @keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } } .note-card { animation: fadeIn 0.3s ease-out forwards; } /* Editor transition */ .editor-container { transition: all 0.3s ease; } /* Floating action button */ .fab { position: fixed; bottom: 2rem; right: 2rem; width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); z-index: 10; transition: all 0.3s ease; } .fab:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2); } /* Custom checkbox */ .custom-checkbox { position: relative; width: 20px; height: 20px; border-radius: 4px; border: 2px solid #d1d5db; cursor: pointer; } .custom-checkbox.checked { background-color: #3b82f6; border-color: #3b82f6; } .custom-checkbox.checked::after { content: ''; position: absolute; left: 6px; top: 2px; width: 5px; height: 10px; border: solid white; border-width: 0 2px 2px 0; transform: rotate(45deg); } /* Tooltip */ .tooltip { position: relative; } .tooltip:hover .tooltip-text { visibility: visible; opacity: 1; } .tooltip-text { visibility: hidden; width: 120px; background-color: #333; color: #fff; text-align: center; border-radius: 6px; padding: 5px; position: absolute; z-index: 1; bottom: 125%; left: 50%; margin-left: -60px; opacity: 0; transition: opacity 0.3s; font-size: 12px; } .tooltip-text::after { content: ""; position: absolute; top: 100%; left: 50%; margin-left: -5px; border-width: 5px; border-style: solid; border-color: #333 transparent transparent transparent; } </style> </head> <body class="bg-gray-50 text-gray-800 dark:bg-gray-900 dark:text-gray-200"> <!-- Mobile menu button --> <div class="md:hidden fixed top-4 left-4 z-30"> <button id="menuBtn" class="p-2 rounded-lg bg-gray-200 dark:bg-gray-700 text-gray-800 dark:text-gray-200"> <i class="fas fa-bars"></i> </button> </div> <!-- Overlay for mobile --> <div id="overlay" class="overlay"></div> <!-- Sidebar --> <div class="sidebar bg-white dark:bg-gray-800 shadow-lg md:shadow-none"> <div class="p-4 border-b border-gray-200 dark:border-gray-700"> <h1 class="text-2xl font-bold text-center text-blue-600 dark:text-blue-400">Elegant Notes</h1> </div> <div class="p-4"> <button id="newNoteBtn" class="w-full py-2 px-4 bg-blue-600 hover:bg-blue-700 text-white rounded-lg flex items-center justify-center mb-4 transition"> <i class="fas fa-plus mr-2"></i> New Note </button> <div class="mb-4"> <div class="flex items-center justify-between mb-2"> <h2 class="font-semibold text-gray-600 dark:text-gray-400">SEARCH</h2> </div> <div class="relative"> <input type="text" id="searchNotes" placeholder="Search notes..." class="w-full py-2 px-4 pl-10 bg-gray-100 dark:bg-gray-700 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"> <i class="fas fa-search absolute left-3 top-3 text-gray-500"></i> </div> </div> <div class="mb-4"> <div class="flex items-center justify-between mb-2"> <h2 class="font-semibold text-gray-600 dark:text-gray-400">FOLDERS</h2> <button id="newFolderBtn" class="text-gray-500 hover:text-gray-700 dark:hover:text-gray-300"> <i class="fas fa-plus"></i> </button> </div> <ul id="foldersList" class="space-y-1"> <li class="folder-item flex items-center px-2 py-1 rounded-lg cursor-pointer bg-blue-100 dark:bg-blue-900 text-blue-800 dark:text-blue-200"> <i class="fas fa-bookmark mr-2 text-blue-600 dark:text-blue-400"></i> <span>All Notes</span> </li> <li class="folder-item flex items-center px-2 py-1 rounded-lg cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700"> <i class="fas fa-book mr-2 text-gray-500"></i> <span>Personal</span> </li> <li class="folder-item flex items-center px-2 py-1 rounded-lg cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700"> <i class="fas fa-book mr-2 text-gray-500"></i> <span>Work</span> </li> <li class="folder-item flex items-center px-2 py-1 rounded-lg cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700"> <i class="fas fa-book mr-2 text-gray-500"></i> <span>Ideas</span> </li> </ul> </div> <div class="mb-4"> <div class="flex items-center justify-between mb-2"> <h2 class="font-semibold text-gray-600 dark:text-gray-400">TAGS</h2> <button id="newTagBtn" class="text-gray-500 hover:text-gray-700 dark:hover:text-gray-300"> <i class="fas fa-plus"></i> </button> </div> <ul id="tagsList" class="space-y-1"> <li class="tag-item flex items-center px-2 py-1 rounded-lg cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700"> <span class="w-3 h-3 rounded-full bg-red-500 mr-2"></span> <span>Important</span> </li> <li class="tag-item flex items-center px-2 py-1 rounded-lg cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700"> <span class="w-3 h-3 rounded-full bg-yellow-500 mr-2"></span> <span>Todo</span> </li> <li class="tag-item flex items-center px-2 py-1 rounded-lg cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700"> <span class="w-3 h-3 rounded-full bg-green-500 mr-2"></span> <span>Completed</span> </li> </ul> </div> <div class="mt-8 pt-4 border-t border-gray-200 dark:border-gray-700"> <div class="flex items-center justify-between"> <button id="themeToggle" class="flex items-center text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200"> <i class="fas fa-moon mr-2"></i> <span>Dark Mode</span> </button> </div> </div> </div> </div> <!-- Main content --> <div class="main-content"> <div class="p-4"> <!-- Notes list header --> <div class="flex items-center justify-between mb-6"> <h2 class="text-2xl font-bold">All Notes</h2> <div class="flex items-center space-x-2"> <div class="relative"> <select id="sortNotes" class="appearance-none bg-gray-100 dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg py-2 px-4 pr-8 focus:outline-none focus:ring-2 focus:ring-blue-500 text-sm"> <option value="date-desc">Sort by: Newest first</option> <option value="date-asc">Sort by: Oldest first</option> <option value="title-asc">Sort by: Title A-Z</option> <option value="title-desc">Sort by: Title Z-A</option> </select> <div class="pointer-events-none absolute inset-y-0 right-0 flex items-center px-2 text-gray-700 dark:text-gray-300"> <i class="fas fa-chevron-down text-xs"></i> </div> </div> <button id="toggleView" class="p-2 rounded-lg bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 dark:hover:bg-gray-600"> <i class="fas fa-th-large"></i> </button> </div> </div> <!-- Notes grid view --> <div id="notesGridView" class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4"> <!-- Note cards will be added here dynamically --> <div class="note-card bg-white dark:bg-gray-800 rounded-xl shadow-md overflow-hidden border border-gray-200 dark:border-gray-700 hover:shadow-lg transition cursor-pointer"> <div class="p-4"> <div class="flex justify-between items-start mb-2"> <h3 class="font-semibold text-lg truncate">Welcome to Elegant Notes</h3> <div class="flex space-x-2 note-actions opacity-0 transition-opacity"> <button class="text-gray-500 hover:text-blue-500"> <i class="fas fa-edit"></i> </button> <button class="text-gray-500 hover:text-red-500"> <i class="fas fa-trash"></i> </button> </div> </div> <p class="text-gray-600 dark:text-gray-400 text-sm mb-3 line-clamp-3">This is your first note. Click to edit or create a new one to get started with your note-taking journey. You can organize notes into folders and add tags for better organization.</p> <div class="flex items-center justify-between text-xs text-gray-500 dark:text-gray-400"> <span>Today</span> <div class="flex items-center space-x-1"> <span class="w-2 h-2 rounded-full bg-blue-500"></span> <span>Personal</span> </div> </div> </div> </div> <div class="note-card bg-white dark:bg-gray-800 rounded-xl shadow-md overflow-hidden border border-gray-200 dark:border-gray-700 hover:shadow-lg transition cursor-pointer"> <div class="p-4"> <div class="flex justify-between items-start mb-2"> <h3 class="font-semibold text-lg truncate">Markdown Support</h3> <div class="flex space-x-2 note-actions opacity-0 transition-opacity"> <button class="text-gray-500 hover:text-blue-500"> <i class="fas fa-edit"></i> </button> <button class="text-gray-500 hover:text-red-500"> <i class="fas fa-trash"></i> </button> </div> </div> <p class="text-gray-600 dark:text-gray-400 text-sm mb-3 line-clamp-3">Elegant Notes supports Markdown formatting. Try using # for headings, * for lists, and **bold** text. You can toggle between editor and preview modes.</p> <div class="flex items-center justify-between text-xs text-gray-500 dark:text-gray-400"> <span>Yesterday</span> <div class="flex items-center space-x-1"> <span class="w-2 h-2 rounded-full bg-yellow-500"></span> <span>Todo</span> </div> </div> </div> </div> <div class="note-card bg-white dark:bg-gray-800 rounded-xl shadow-md overflow-hidden border border-gray-200 dark:border-gray-700 hover:shadow-lg transition cursor-pointer"> <div class="p-4"> <div class="flex justify-between items-start mb-2"> <h3 class="font-semibold text-lg truncate">Dark Mode</h3> <div class="flex space-x-2 note-actions opacity-0 transition-opacity"> <button class="text-gray-500 hover:text-blue-500"> <i class="fas fa-edit"></i> </button> <button class="text-gray-500 hover:text-red-500"> <i class="fas fa-trash"></i> </button> </div> </div> <p class="text-gray-600 dark:text-gray-400 text-sm mb-3 line-clamp-3">Toggle between light and dark mode from the sidebar. The app remembers your preference for your next visit.</p> <div class="flex items-center justify-between text-xs text-gray-500 dark:text-gray-400"> <span>2 days ago</span> <div class="flex items-center space-x-1"> <span class="w-2 h-2 rounded-full bg-green-500"></span> <span>Completed</span> </div> </div> </div> </div> </div> <!-- Notes list view (hidden by default) --> <div id="notesListView" class="hidden"> <div class="bg-white dark:bg-gray-800 rounded-lg shadow overflow-hidden"> <table class="min-w-full divide-y divide-gray-200 dark:divide-gray-700"> <thead class="bg-gray-50 dark:bg-gray-700"> <tr> <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider">Title</th> <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider">Preview</th> <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider">Folder</th> <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider">Last Edited</th> <th scope="col" class="px-6 py-3 text-right text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider">Actions</th> </tr> </thead> <tbody class="bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700"> <tr class="hover:bg-gray-50 dark:hover:bg-gray-700"> <td class="px-6 py-4 whitespace-nowrap"> <div class="flex items-center"> <div class="flex-shrink-0 h-10 w-10 flex items-center justify-center rounded-full bg-blue-100 dark:bg-blue-900 text-blue-600 dark:text-blue-400"> <i class="fas fa-sticky-note"></i> </div> <div class="ml-4"> <div class="text-sm font-medium text-gray-900 dark:text-gray-100">Welcome to Elegant Notes</div> </div> </div> </td> <td class="px-6 py-4"> <div class="text-sm text-gray-500 dark:text-gray-400 line-clamp-1">This is your first note. Click to edit or create a new one to get started with your note-taking journey.</div> </td> <td class="px-6 py-4 whitespace-nowrap"> <span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-blue-100 dark:bg-blue-900 text-blue-800 dark:text-blue-200">Personal</span> </td> <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400">Today</td> <td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium"> <button class="text-blue-600 dark:text-blue-400 hover:text-blue-900 dark:hover:text-blue-300 mr-3"> <i class="fas fa-edit"></i> </button> <button class="text-red-600 dark:text-red-400 hover:text-red-900 dark:hover:text-red-300"> <i class="fas fa-trash"></i> </button> </td> </tr> <tr class="hover:bg-gray-50 dark:hover:bg-gray-700"> <td class="px-6 py-4 whitespace-nowrap"> <div class="flex items-center"> <div class="flex-shrink-0 h-10 w-10 flex items-center justify-center rounded-full bg-yellow-100 dark:bg-yellow-900 text-yellow-600 dark:text-yellow-400"> <i class="fas fa-sticky-note"></i> </div> <div class="ml-4"> <div class="text-sm font-medium text-gray-900 dark:text-gray-100">Markdown Support</div> </div> </div> </td> <td class="px-6 py-4"> <div class="text-sm text-gray-500 dark:text-gray-400 line-clamp-1">Elegant Notes supports Markdown formatting. Try using # for headings, * for lists, and **bold** text.</div> </td> <td class="px-6 py-4 whitespace-nowrap"> <span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-yellow-100 dark:bg-yellow-900 text-yellow-800 dark:text-yellow-200">Todo</span> </td> <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400">Yesterday</td> <td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium"> <button class="text-blue-600 dark:text-blue-400 hover:text-blue-900 dark:hover:text-blue-300 mr-3"> <i class="fas fa-edit"></i> </button> <button class="text-red-600 dark:text-red-400 hover:text-red-900 dark:hover:text-red-300"> <i class="fas fa-trash"></i> </button> </td> </tr> <tr class="hover:bg-gray-50 dark:hover:bg-gray-700"> <td class="px-6 py-4 whitespace-nowrap"> <div class="flex items-center"> <div class="flex-shrink-0 h-10 w-10 flex items-center justify-center rounded-full bg-green-100 dark:bg-green-900 text-green-600 dark:text-green-400"> <i class="fas fa-sticky-note"></i> </div> <div class="ml-4"> <div class="text-sm font-medium text-gray-900 dark:text-gray-100">Dark Mode</div> </div> </div> </td> <td class="px-6 py-4"> <div class="text-sm text-gray-500 dark:text-gray-400 line-clamp-1">Toggle between light and dark mode from the sidebar. The app remembers your preference for your next visit.</div> </td> <td class="px-6 py-4 whitespace-nowrap"> <span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 dark:bg-green-900 text-green-800 dark:text-green-200">Completed</span> </td> <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400">2 days ago</td> <td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium"> <button class="text-blue-600 dark:text-blue-400 hover:text-blue-900 dark:hover:text-blue-300 mr-3"> <i class="fas fa-edit"></i> </button> <button class="text-red-600 dark:text-red-400 hover:text-red-900 dark:hover:text-red-300"> <i class="fas fa-trash"></i> </button> </td> </tr> </tbody> </table> </div> </div> <!-- Empty state --> <div id="emptyState" class="hidden flex flex-col items-center justify-center py-12"> <div class="w-24 h-24 mb-4 rounded-full bg-gray-200 dark:bg-gray-700 flex items-center justify-center"> <i class="fas fa-sticky-note text-3xl text-gray-400"></i> </div> <h3 class="text-lg font-medium text-gray-900 dark:text-gray-100 mb-2">No notes found</h3> <p class="text-gray-500 dark:text-gray-400 mb-4">Create your first note to get started</p> <button id="emptyNewNoteBtn" class="px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg"> <i class="fas fa-plus mr-2"></i> New Note </button> </div> </div> </div> <!-- Note editor modal --> <div id="editorModal" class="fixed inset-0 bg-black bg-opacity-50 z-50 hidden"> <div class="flex items-center justify-center min-h-screen p-4"> <div class="bg-white dark:bg-gray-800 rounded-xl shadow-xl w-full max-w-4xl max-h-[90vh] flex flex-col"> <div class="p-4 border-b border-gray-200 dark:border-gray-700 flex justify-between items-center"> <input type="text" id="noteTitle" placeholder="Note title" class="text-xl font-bold bg-transparent border-none focus:ring-0 w-full"> <div class="flex space-x-2"> <button id="saveNoteBtn" class="px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg text-sm"> Save </button> <button id="closeEditorBtn" class="p-2 rounded-lg hover:bg-gray-200 dark:hover:bg-gray-700"> <i class="fas fa-times"></i> </button> </div> </div> <div class="flex border-b border-gray-200 dark:border-gray-700"> <button id="editorTab" class="px-4 py-2 font-medium text-blue-600 dark:text-blue-400 border-b-2 border-blue-500">Editor</button> <button id="previewTab" class="px-4 py-2 font-medium text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300">Preview</button> </div> <div class="flex-1 overflow-auto"> <div id="editorContainer" class="editor-container h-full"> <textarea id="noteContent" class="w-full h-full p-4 resize-none bg-transparent focus:outline-none" placeholder="Start writing your note here... Markdown is supported!"></textarea> </div> <div id="previewContainer" class="editor-container h-full hidden p-4 markdown-preview overflow-auto"> <!-- Markdown preview will be rendered here --> </div> </div> <div class="p-4 border-t border-gray-200 dark:border-gray-700 flex justify-between items-center"> <div class="flex items-center space-x-4"> <div class="relative"> <select id="noteFolder" class="appearance-none bg-gray-100 dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg py-2 px-4 pr-8 focus:outline-none focus:ring-2 focus:ring-blue-500 text-sm"> <option value="personal">Personal</option> <option value="work">Work</option> <option value="ideas">Ideas</option> </select> <div class="pointer-events-none absolute inset-y-0 right-0 flex items-center px-2 text-gray-700 dark:text-gray-300"> <i class="fas fa-chevron-down text-xs"></i> </div> </div> <div class="relative"> <select id="noteTags" class="appearance-none bg-gray-100 dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg py-2 px-4 pr-8 focus:outline-none focus:ring-2 focus:ring-blue-500 text-sm"> <option value="">No tag</option> <option value="important">Important</option> <option value="todo">Todo</option> <option value="completed">Completed</option> </select> <div class="pointer-events-none absolute inset-y-0 right-0 flex items-center px-2 text-gray-700 dark:text-gray-300"> <i class="fas fa-chevron-down text-xs"></i> </div> </div> </div> <div class="text-sm text-gray-500 dark:text-gray-400"> <span id="wordCount">0 words</span> </div> </div> </div> </div> </div> <!-- New folder modal --> <div id="folderModal" class="fixed inset-0 bg-black bg-opacity-50 z-50 hidden"> <div class="flex items-center justify-center min-h-screen p-4"> <div class="bg-white dark:bg-gray-800 rounded-xl shadow-xl w-full max-w-md"> <div class="p-4 border-b border-gray-200 dark:border-gray-700 flex justify-between items-center"> <h3 class="text-lg font-medium">New Folder</h3> <button id="closeFolderBtn" class="p-2 rounded-lg hover:bg-gray-200 dark:hover:bg-gray-700"> <i class="fas fa-times"></i> </button> </div> <div class="p-4"> <div class="mb-4"> <label for="folderName" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Folder Name</label> <input type="text" id="folderName" class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-white dark:bg-gray-700"> </div> <div class="mb-4"> <label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Color</label> <div class="flex space-x-2"> <div class="color-option w-8 h-8 rounded-full bg-blue-500 cursor-pointer border-2 border-transparent hover:border-blue-700" data-color="blue"></div> <div class="color-option w-8 h-8 rounded-full bg-red-500 cursor-pointer border-2 border-transparent hover:border-red-700" data-color="red"></div> <div class="color-option w-8 h-8 rounded-full bg-green-500 cursor-pointer border-2 border-transparent hover:border-green-700" data-color="green"></div> <div class="color-option w-8 h-8 rounded-full bg-yellow-500 cursor-pointer border-2 border-transparent hover:border-yellow-700" data-color="yellow"></div> <div class="color-option w-8 h-8 rounded-full bg-purple-500 cursor-pointer border-2 border-transparent hover:border-purple-700" data-color="purple"></div> <div class="color-option w-8 h-8 rounded-full bg-pink-500 cursor-pointer border-2 border-transparent hover:border-pink-700" data-color="pink"></div> </div> </div> </div> <div class="p-4 border-t border-gray-200 dark:border-gray-700 flex justify-end space-x-2"> <button id="cancelFolderBtn" class="px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"> Cancel </button> <button id="saveFolderBtn" class="px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg"> Save </button> </div> </div> </div> </div> <!-- Floating action button --> <button id="fabNewNote" class="fab bg-blue-600 hover:bg-blue-700 text-white hidden md:block"> <i class="fas fa-plus text-xl"></i> </button> <!-- Confirmation modal --> <div id="confirmModal" class="fixed inset-0 bg-black bg-opacity-50 z-50 hidden"> <div class="flex items-center justify-center min-h-screen p-4"> <div class="bg-white dark:bg-gray-800 rounded-xl shadow-xl w-full max-w-md"> <div class="p-4 border-b border-gray-200 dark:border-gray-700"> <h3 class="text-lg font-medium">Confirm Action</h3> </div> <div class="p-4"> <p id="confirmMessage" class="text-gray-700 dark:text-gray-300">Are you sure you want to delete this note?</p> </div> <div class="p-4 border-t border-gray-200 dark:border-gray-700 flex justify-end space-x-2"> <button id="cancelConfirmBtn" class="px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"> Cancel </button> <button id="confirmActionBtn" class="px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg"> Confirm </button> </div> </div> </div> </div> <script> // DOM Elements const menuBtn = document.getElementById('menuBtn'); const overlay = document.getElementById('overlay'); const sidebar = document.querySelector('.sidebar'); const themeToggle = document.getElementById('themeToggle'); const newNoteBtn = document.getElementById('newNoteBtn'); const emptyNewNoteBtn = document.getElementById('emptyNewNoteBtn'); const fabNewNote = document.getElementById('fabNewNote'); const toggleView = document.getElementById('toggleView'); const notesGridView = document.getElementById('notesGridView'); const notesListView = document.getElementById('notesListView'); const editorModal = document.getElementById('editorModal'); const closeEditorBtn = document.getElementById('closeEditorBtn'); const saveNoteBtn = document.getElementById('saveNoteBtn'); const noteTitle = document.getElementById('noteTitle'); const noteContent = document.getElementById('noteContent'); const editorTab = document.getElementById('editorTab'); const previewTab = document.getElementById('previewTab'); const editorContainer = document.getElementById('editorContainer'); const previewContainer = document.getElementById('previewContainer'); const wordCount = document.getElementById('wordCount'); const newFolderBtn = document.getElementById('newFolderBtn'); const folderModal = document.getElementById('folderModal'); const closeFolderBtn = document.getElementById('closeFolderBtn'); const cancelFolderBtn = document.getElementById('cancelFolderBtn'); const saveFolderBtn = document.getElementById('saveFolderBtn'); const folderName = document.getElementById('folderName'); const colorOptions = document.querySelectorAll('.color-option'); const confirmModal = document.getElementById('confirmModal'); const cancelConfirmBtn = document.getElementById('cancelConfirmBtn'); const confirmActionBtn = document.getElementById('confirmActionBtn'); const confirmMessage = document.getElementById('confirmMessage'); // State let currentNoteId = null; let isListView = false; let selectedColor = 'blue'; let currentAction = null; // Initialize the app function init() { // Check for saved theme preference if (localStorage.getItem('theme') === 'dark' || (!localStorage.getItem('theme') && window.matchMedia('(prefers-color-scheme: dark)').matches)) { document.documentElement.classList.add('dark'); themeToggle.innerHTML = '<i class="fas fa-sun mr-2"></i><span>Light Mode</span>'; } // Check if there are any notes in localStorage if (!localStorage.getItem('notes')) { // Create some sample notes const sampleNotes = [ { id: '1', title: 'Welcome to Elegant Notes', content: 'This is your first note. Click to edit or create a new one to get started with your note-taking journey. You can organize notes into folders and add tags for better organization.', folder: 'personal', tags: [], createdAt: new Date().toISOString(), updatedAt: new Date().toISOString() }, { id: '2', title: 'Markdown Support', content: 'Elegant Notes supports Markdown formatting. Try using:\n\n# Heading 1\n## Heading 2\n\n* List item 1\n* List item 2\n\n**Bold text** and *italic text*\n\n> Blockquotes\n\n`code` and ```code blocks```\n\n[Links](https://example.com)', folder: 'work', tags: ['todo'], createdAt: new Date(Date.now() - 86400000).toISOString(), // Yesterday updatedAt: new Date(Date.now() - 86400000).toISOString() }, { id: '3', title: 'Dark Mode', content: 'Toggle between light and dark mode from the sidebar. The app remembers your preference for your next visit.', folder: 'ideas', tags: ['completed'], createdAt: new Date(Date.now() - 172800000).toISOString(), // 2 days ago updatedAt: new Date(Date.now() - 172800000).toISOString() } ]; localStorage.setItem('notes', JSON.stringify(sampleNotes)); } // Load and display notes loadNotes(); // Show FAB on larger screens if (window.innerWidth >= 768) { fabNewNote.classList.remove('hidden'); } } // Load notes from localStorage and display them function loadNotes() { const notes = JSON.parse(localStorage.getItem('notes')) || []; if (notes.length === 0) { notesGridView.classList.add('hidden'); notesListView.classList.add('hidden'); document.getElementById('emptyState').classList.remove('hidden'); } else { document.getElementById('emptyState').classList.add('hidden'); if (isListView) { notesGridView.classList.add('hidden'); notesListView.classList.remove('hidden'); renderListView(notes); } else { notesGridView.classList.remove('hidden'); notesListView.classList.add('hidden'); renderGridView(notes); } } } // Render notes in grid view function renderGridView(notes) { notesGridView.innerHTML = ''; notes.forEach(note => { const folderColor = getFolderColor(note.folder); const tagColor = note.tags.length > 0 ? getTagColor(note.tags[0]) : 'gray'; const noteEl = document.createElement('div'); noteEl.className = 'note-card bg-white dark:bg-gray-800 rounded-xl shadow-md overflow-hidden border border-gray-200 dark:border-gray-700 hover:shadow-lg transition cursor-pointer'; noteEl.innerHTML = ` <div class="p-4"> <div class="flex justify-between items-start mb-2"> <h3 class="font-semibold text-lg truncate">${note.title}</h3> <div class="flex space-x-2 note-actions opacity-0 transition-opacity"> <button class="edit-note text-gray-500 hover:text-blue-500" data-id="${note.id}"> <i class="fas fa-edit"></i> </button> <button class="delete-note text-gray-500 hover:text-red-500" data-id="${note.id}"> <i class="fas fa-trash"></i> </button> </div> </div> <p class="text-gray-600 dark:text-gray-400 text-sm mb-3 line-clamp-3">${note.content.substring(0, 100)}${note.content.length > 100 ? '...' : ''}</p> <div class="flex items-center justify-between text-xs text-gray-500 dark:text-gray-400"> <span>${formatDate(note.updatedAt)}</span> <div class="flex items-center space-x-1"> <span class="w-2 h-2 rounded-full ${tagColor}"></span> <span>${note.tags.length > 0 ? note.tags[0] : note.folder}</span> </div> </div> </div> `; noteEl.addEventListener('click', (e) => { if (!e.target.closest('.note-actions')) { openEditor(note.id); } }); notesGridView.appendChild(noteEl); }); // Add event listeners to edit and delete buttons document.querySelectorAll('.edit-note').forEach(btn => { btn.addEventListener('click', (e) => { e.stopPropagation(); openEditor(btn.dataset.id); }); }); document.querySelectorAll('.delete-note').forEach(btn => { btn.addEventListener('click', (e) => { e.stopPropagation(); showConfirmModal('Are you sure you want to delete this note?', () => { deleteNote(btn.dataset.id); }); }); }); } // Render notes in list view function renderListView(notes) { const tbody = notesListView.querySelector('tbody'); tbody.innerHTML = ''; notes.forEach(note => { const folderColor = getFolderColor(note.folder); const tagColor = note.tags.length > 0 ? getTagColor(note.tags[0]) : 'gray'; const row = document.createElement('tr'); row.className = 'hover:bg-gray-50 dark:hover:bg-gray-700'; row.innerHTML = ` <td class="px-6 py-4 whitespace-nowrap"> <div class="flex items-center"> <div class="flex-shrink-0 h-10 w-10 flex items-center justify-center rounded-full ${folderColor.replace('bg-', 'bg-').replace('text-', 'text-')}"> <i class="fas fa-sticky-note"></i> </div> <div class="ml-4"> <div class="text-sm font-medium text-gray-900 dark:text-gray-100">${note.title}</div> </div> </div> </td> <td class="px-6 py-4"> <div class="text-sm text-gray-500 dark:text-gray-400 line-clamp-1">${note.content.substring(0, 60)}${note.content.length > 60 ? '...' : ''}</div> </td> <td class="px-6 py-4 whitespace-nowrap"> <span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full ${folderColor.replace('bg-', 'bg-').replace('text-', 'text-')}">${note.folder.charAt(0).toUpperCase() + note.folder.slice(1)}</span> </td> <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400">${formatDate(note.updatedAt)}</td> <td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium"> <button class="edit-note text-blue-600 dark:text-blue-400 hover:text-blue-900 dark:hover:text-blue-300 mr-3" data-id="${note.id}"> <i class="fas fa-edit"></i> </button> <button class="delete-note text-red-600 dark:text-red-400 hover:text-red-900 dark:hover:text-red-300" data-id="${note.id}"> <i class="fas fa-trash"></i> </button> </td> `; tbody.appendChild(row); }); // Add event listeners to edit and delete buttons document.querySelectorAll('.edit-note').forEach(btn => { btn.addEventListener('click', () => { openEditor(btn.dataset.id); }); }); document.querySelectorAll('.delete-note').forEach(btn => { btn.addEventListener('click', () => { showConfirmModal('Are you sure you want to delete this note?', () => { deleteNote(btn.dataset.id); }); }); }); } // Open editor with a specific note function openEditor(noteId = null) { currentNoteId = noteId; if (noteId) { // Editing existing note const notes = JSON.parse(localStorage.getItem('notes')) || []; const note = notes.find(n => n.id === noteId); if (note) { noteTitle.value = note.title; noteContent.value = note.content; document.getElementById('noteFolder').value = note.folder; document.getElementById('noteTags').value = note.tags.length > 0 ? note.tags[0] : ''; updateWordCount(); renderMarkdownPreview(); } } else { // Creating new note noteTitle.value = ''; noteContent.value = ''; document.getElementById('noteFolder').value = 'personal'; document.getElementById('noteTags').value = ''; updateWordCount(); previewContainer.innerHTML = ''; } // Show editor and hide preview editorContainer.classList.remove('hidden'); previewContainer.classList.add('hidden'); editorTab.classList.add('border-blue-500', 'text-blue-600', 'dark:text-blue-400'); editorTab.classList.remove('text-gray-500', 'dark:text-gray-400'); previewTab.classList.remove('border-blue-500', 'text-blue-600', 'dark:text-blue-400'); previewTab.classList.add('text-gray-500', 'dark:text-gray-400'); // Show modal editorModal.classList.remove('hidden'); document.body.classList.add('overflow-hidden'); // Focus on title if new note if (!noteId) { noteTitle.focus(); } } // Save note to localStorage function saveNote() { const title = noteTitle.value.trim(); const content = noteContent.value.trim(); const folder = document.getElementById('noteFolder').value; const tag = document.getElementById('noteTags').value; if (!title) { alert('Please enter a title for your note'); return; } const notes = JSON.parse(localStorage.getItem('notes')) || []; const now = new Date().toISOString(); if (currentNoteId) { // Update existing note const noteIndex = notes.findIndex(n => n.id === currentNoteId); if (noteIndex !== -1) { notes[noteIndex] = { ...notes[noteIndex], title, content, folder, tags: tag ? [tag] : [], updatedAt: now }; } } else { // Create new note const newNote = { id: generateId(), title, content, folder, tags: tag ? [tag] : [], createdAt: now, updatedAt: now }; notes.unshift(newNote); } localStorage.setItem('notes', JSON.stringify(notes)); closeEditor(); loadNotes(); } // Delete a note function deleteNote(noteId) { const notes = JSON.parse(localStorage.getItem('notes')) || []; const updatedNotes = notes.filter(note => note.id !== noteId); localStorage.setItem('notes', JSON.stringify(updatedNotes)); loadNotes(); closeConfirmModal(); } // Close editor modal function closeEditor() { editorModal.classList.add('hidden'); document.body.classList.remove('overflow-hidden'); currentNoteId = null; } // Show confirmation modal function showConfirmModal(message, callback) { confirmMessage.textContent = message; confirmModal.classList.remove('hidden'); document.body.classList.add('overflow-hidden'); currentAction = callback; } // Close confirmation modal function closeConfirmModal() { confirmModal.classList.add('hidden'); document.body.classList.remove('overflow-hidden'); currentAction = null; } // Generate a random ID function generateId() { return Math.random().toString(36).substr(2, 9); } // Format date for display function formatDate(dateString) { const date = new Date(dateString); const now = new Date(); const diffInDays = Math.floor((now - date) / (1000 * 60 * 60 * 24)); if (diffInDays === 0) { return 'Today'; } else if (diffInDays === 1) { return 'Yesterday'; } else if (diffInDays < 7) { return `${diffInDays} days ago`; } else { return date.toLocaleDateString(); } } // Get color class for folder function getFolderColor(folder) { switch (folder) { case 'personal': return 'bg-blue-100 dark:bg-blue-900 text-blue-800 dark:text-blue-200'; case 'work': return 'bg-yellow-100 dark:bg-yellow-900 text-yellow-800 dark:text-yellow-200'; case 'ideas': return 'bg-green-100 dark:bg-green-900 text-green-800 dark:text-green-200'; default: return 'bg-gray-100 dark:bg-gray-700 text-gray-800 dark:text-gray-200'; } } // Get color class for tag function getTagColor(tag) { switch (tag) { case 'important': return 'bg-red-500'; case 'todo': return 'bg-yellow-500'; case 'completed': return 'bg-green-500'; default: return 'bg-gray-500'; } } // Update word count function updateWordCount() { const text = noteContent.value.trim(); const words = text ? text.split(/\s+/).length : 0; wordCount.textContent = `${words} ${words === 1 ? 'word' : 'words'}`; } // Simple markdown rendering function renderMarkdownPreview() { const text = noteContent.value; // Basic markdown parsing let html = text .replace(/^# (.*$)/gm, '<h1>$1</h1>') .replace(/^## (.*$)/gm, '<h2>$1</h2>') .replace(/^### (.*$)/gm, '<h3>$1</h3>') .replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>') .replace(/\*(.*?)\*/g, '<em>$1</em>') .replace(/`(.*?)`/g, '<code>$1</code>') .replace(/~~(.*?)~~/g, '<del>$1</del>') .replace(/^> (.*$)/gm, '<blockquote>$1</blockquote>') .replace(/^\* (.*$)/gm, '<li>$1</li>') .replace(/^\d\. (.*$)/gm, '<li>$1</li>') .replace(/\n\n/g, '<br><br>') .replace(/\[(.*?)\]\((.*?)\)/g, '<a href="$2">$1</a>'); // Handle code blocks html = html.replace(/```([\s\S]*?)```/g, '<pre><code>$1</code></pre>'); previewContainer.innerHTML = html; } // Event Listeners menuBtn.addEventListener('click', () => { sidebar.classList.toggle('open'); overlay.classList.toggle('open'); }); overlay.addEventListener('click', () => { sidebar.classList.remove('open'); overlay.classList.remove('open'); }); themeToggle.addEventListener('click', () => { if (document.documentElement.classList.contains('dark')) { document.documentElement.classList.remove('dark'); localStorage.setItem('theme', 'light'); themeToggle.innerHTML = '<i class="fas fa-moon mr-2"></i><span>Dark Mode</span>'; } else { document.documentElement.classList.add('dark'); localStorage.setItem('theme', 'dark'); themeToggle.innerHTML = '<i class="fas fa-sun mr-2"></i><span>Light Mode</span>'; } }); newNoteBtn.addEventListener('click', () => { openEditor(); }); emptyNewNoteBtn.addEventListener('click', () => { openEditor(); }); fabNewNote.addEventListener('click', () => { openEditor(); }); closeEditorBtn.addEventListener('click', () => { if (noteTitle.value.trim() !== '' || noteContent.value.trim() !== '') { showConfirmModal('Are you sure you want to discard your changes?', closeEditor); } else { closeEditor(); } }); saveNoteBtn.addEventListener('click', saveNote); toggleView.addEventListener('click', () => { isListView = !isListView; loadNotes(); toggleView.innerHTML = isListView ? '<i class="fas fa-th"></i>' : '<i class="fas fa-th-large"></i>'; }); editorTab.addEventListener('click', () => { editorContainer.classList.remove('hidden'); previewContainer.classList.add('hidden'); editorTab.classList.add('border-blue-500', 'text-blue-600', 'dark:text-blue-400'); editorTab.classList.remove('text-gray-500', 'dark:text-gray-400'); previewTab.classList.remove('border-blue-500', 'text-blue-600', 'dark:text-blue-400'); previewTab.classList.add('text-gray-500', 'dark:text-gray-400'); }); previewTab.addEventListener('click', () => { renderMarkdownPreview(); editorContainer.classList.add('hidden'); previewContainer.classList.remove('hidden'); previewTab.classList.add('border-blue-500', 'text-blue-600', 'dark:text-blue-400'); previewTab.classList.remove('text-gray-500', 'dark:text-gray-400'); editorTab.classList.remove('border-blue-500', 'text-blue-600', 'dark:text-blue-400'); editorTab.classList.add('text-gray-500', 'dark:text-gray-400'); }); noteContent.addEventListener('input', updateWordCount); // Folder modal events newFolderBtn.addEventListener('click', () => { folderModal.classList.remove('hidden'); document.body.classList.add('overflow-hidden'); folderName.value = ''; selectedColor = 'blue'; document.querySelector('.color-option[data-color="blue"]').classList.add('border-blue-700', 'dark:border-blue-300'); }); closeFolderBtn.addEventListener('click', () => { folderModal.classList.add('hidden'); document.body.classList.remove('overflow-hidden'); }); cancelFolderBtn.addEventListener('click', () => { folderModal.classList.add('hidden'); document.body.classList.remove('overflow-hidden'); }); saveFolderBtn.addEventListener('click', () => { const name = folderName.value.trim(); if (!name) { alert('Please enter a folder name'); return; } // In a real app, you would save the folder to localStorage alert(`Folder "${name}" (${selectedColor}) created!`); folderModal.classList.add('hidden'); document.body.classList.remove('overflow-hidden'); }); colorOptions.forEach(option => { option.addEventListener('click', () => { colorOptions.forEach(opt => opt.classList.remove('border-blue-700', 'border-red-700', 'border-green-700', 'border-yellow-700', 'border-purple-700', 'border-pink-700', 'dark:border-blue-300', 'dark:border-red-300', 'dark:border-green-300', 'dark:border-yellow-300', 'dark:border-purple-300', 'dark:border-pink-300')); option.classList.add(`border-${option.dataset.color}-700`, `dark:border-${option.dataset.color}-300`); selectedColor = option.dataset.color; }); }); // Confirm modal events cancelConfirmBtn.addEventListener('click', closeConfirmModal); confirmActionBtn.addEventListener('click', () => { if (currentAction) { currentAction(); } }); // Window resize event window.addEventListener('resize', () => { if (window.innerWidth >= 768) { sidebar.classList.remove('open'); overlay.classList.remove('open'); fabNewNote.classList.remove('hidden'); } else { fabNewNote.classList.add('hidden'); } }); // Initialize the app init(); </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=ervareza/tes-note-app" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body> </html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Elegant Notes | Modern Notepad App</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>
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');
body {
font-family: 'Poppins', sans-serif;
transition: all 0.3s ease;
display: flex;
min-height: 100vh;
}
.sidebar {
width: 16rem;
height: 100vh;
position: sticky;
top: 0;
overflow-y: auto;
}
.main-content {
flex: 1;
overflow-y: auto;
height: 100vh;
}
.note-item:hover .note-actions {
opacity: 1;
}
@media (max-width: 768px) {
.sidebar {
transform: translateX(-100%);
position: fixed;
z-index: 20;
height: 100vh;
}
.sidebar.open {
transform: translateX(0);
}
.overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0,0,0,0.5);
z-index: 10;
display: none;
}
.overlay.open {
display: block;
}
}
/* Custom scrollbar */
::-webkit-scrollbar {
width: 8px;
}
::-webkit-scrollbar-track {
background: #f1f1f1;
}
::-webkit-scrollbar-thumb {
background: #888;
border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
background: #555;
}
/* Markdown preview styles */
.markdown-preview h1 {
font-size: 2em;
font-weight: bold;
margin: 0.67em 0;
}
.markdown-preview h2 {
font-size: 1.5em;
font-weight: bold;
margin: 0.83em 0;
}
.markdown-preview h3 {
font-size: 1.17em;
font-weight: bold;
margin: 1em 0;
}