scribblesync / index.html
Bammy112's picture
Create a Notes App, with a notes section, and a history section.
e759df7 verified
Raw History Blame Contribute Delete
18 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ScribbleSync - Your Digital Notebook</title>
<link rel="icon" type="image/x-icon" href="/static/favicon.ico">
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://unpkg.com/feather-icons"></script>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<script>
tailwind.config = {
theme: {
extend: {
colors: {
primary: '#6366f1',
secondary: '#8b5cf6',
accent: '#ec4899',
dark: '#1e293b',
light: '#f8fafc'
},
fontFamily: {
sans: ['Inter', 'sans-serif']
}
}
}
}
</script>
<style>
.note-card {
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-card:hover {
transform: translateY(-5px);
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}
.fade-in {
animation: fadeIn 0.5s ease-in;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
.active-tab {
border-bottom: 3px solid #6366f1;
color: #6366f1;
}
.sidebar-transition {
transition: all 0.3s ease-in-out;
}
</style>
</head>
<body class="bg-gray-50 font-sans">
<div class="flex h-screen">
<!-- Sidebar -->
<div id="sidebar" class="w-64 bg-white shadow-lg z-10 sidebar-transition">
<div class="p-5 border-b border-gray-200">
<h1 class="text-2xl font-bold text-primary flex items-center">
<i data-feather="edit-3" class="mr-2"></i>
ScribbleSync
</h1>
<p class="text-gray-500 text-sm mt-1">Your digital notebook</p>
</div>
<div class="p-4">
<button id="newNoteBtn" class="w-full bg-primary hover:bg-indigo-600 text-white py-2 px-4 rounded-lg flex items-center justify-center mb-4 transition duration-300">
<i data-feather="plus-circle" class="mr-2"></i>
New Note
</button>
<div class="mt-6">
<h2 class="text-xs uppercase font-semibold text-gray-500 tracking-wider mb-2">Sections</h2>
<ul>
<li>
<button id="notesTab" class="w-full text-left py-2 px-4 rounded-lg flex items-center active-tab">
<i data-feather="file-text" class="mr-3"></i>
Notes
</button>
</li>
<li class="mt-1">
<button id="historyTab" class="w-full text-left py-2 px-4 rounded-lg flex items-center text-gray-600 hover:bg-gray-100">
<i data-feather="clock" class="mr-3"></i>
History
</button>
</li>
</ul>
</div>
</div>
</div>
<!-- Main Content -->
<div class="flex-1 flex flex-col overflow-hidden">
<!-- Top Bar -->
<header class="bg-white shadow-sm z-10">
<div class="flex items-center justify-between p-4">
<div class="flex items-center">
<button id="menuToggle" class="md:hidden mr-4 text-gray-600">
<i data-feather="menu"></i>
</button>
<h2 id="currentSectionTitle" class="text-xl font-semibold text-gray-800">My Notes</h2>
</div>
<div class="relative">
<input type="text" placeholder="Search notes..." class="pl-10 pr-4 py-2 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent">
<i data-feather="search" class="absolute left-3 top-2.5 text-gray-400"></i>
</div>
</div>
</header>
<!-- Content Area -->
<main class="flex-1 overflow-y-auto p-6 bg-gray-50">
<!-- Notes Section -->
<section id="notesSection" class="fade-in">
<div class="flex justify-between items-center mb-6">
<h2 class="text-2xl font-bold text-gray-800">Recent Notes</h2>
<div class="flex space-x-2">
<button class="bg-white border border-gray-300 text-gray-700 py-2 px-4 rounded-lg flex items-center">
<i data-feather="filter" class="mr-2"></i>
Filter
</button>
<button class="bg-white border border-gray-300 text-gray-700 py-2 px-4 rounded-lg flex items-center">
<i data-feather="sort-asc" class="mr-2"></i>
Sort
</button>
</div>
</div>
<div id="notesContainer" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
<!-- Note cards will be dynamically inserted here -->
</div>
</section>
<!-- History Section (Hidden by default) -->
<section id="historySection" class="hidden fade-in">
<div class="flex justify-between items-center mb-6">
<h2 class="text-2xl font-bold text-gray-800">Note History</h2>
<button class="bg-white border border-gray-300 text-gray-700 py-2 px-4 rounded-lg flex items-center">
<i data-feather="trash-2" class="mr-2"></i>
Clear History
</button>
</div>
<div id="historyContainer" class="space-y-4">
<!-- History items will be dynamically inserted here -->
</div>
</section>
</main>
</div>
</div>
<!-- Note Editor Modal -->
<div id="noteModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center hidden z-50">
<div class="bg-white rounded-lg w-full max-w-2xl mx-4 max-h-[90vh] overflow-hidden flex flex-col">
<div class="border-b border-gray-200 p-4 flex justify-between items-center">
<h3 class="text-lg font-semibold">Edit Note</h3>
<button id="closeModal" class="text-gray-500 hover:text-gray-700">
<i data-feather="x"></i>
</button>
</div>
<div class="p-4 flex-1 overflow-y-auto">
<input id="noteTitle" type="text" placeholder="Note Title" class="w-full text-2xl font-bold mb-4 p-2 border-b border-gray-200 focus:outline-none focus:border-primary">
<textarea id="noteContent" placeholder="Start writing your note here..." class="w-full h-64 p-2 focus:outline-none"></textarea>
</div>
<div class="border-t border-gray-200 p-4 flex justify-end space-x-3">
<button id="deleteNote" class="px-4 py-2 text-red-600 hover:bg-red-50 rounded-lg">Delete</button>
<button id="saveNote" class="px-4 py-2 bg-primary text-white rounded-lg hover:bg-indigo-600">Save Note</button>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
<script>
// Initialize feather icons
feather.replace();
// Sample data
const sampleNotes = [
{ id: 1, title: "Project Ideas", content: "1. Mobile app for task management\n2. AI-powered recipe generator\n3. Virtual reality fitness app", date: "2023-05-15", tags: ["work", "ideas"] },
{ id: 2, title: "Meeting Notes", content: "Discussed new marketing strategy:\n- Focus on social media\n- Launch campaign in Q3\n- Budget allocation for ads", date: "2023-05-18", tags: ["meeting", "work"] },
{ id: 3, title: "Book Recommendations", content: "Fiction:\n- The Midnight Library by Matt Haig\n- Klara and the Sun by Kazuo Ishiguro\n\nNon-fiction:\n- Atomic Habits by James Clear", date: "2023-05-20", tags: ["books", "personal"] },
{ id: 4, title: "Travel Plans", content: "Destination: Japan\nDates: October 15-30\nItinerary:\n- Tokyo (5 days)\n- Kyoto (4 days)\n- Osaka (3 days)\nBudget: $3000", date: "2023-05-22", tags: ["travel", "plans"] },
{ id: 5, title: "Learning Goals", content: "This year I want to learn:\n1. Advanced JavaScript\n2. React Native\n3. Data Visualization\n4. Spanish (basic fluency)", date: "2023-05-25", tags: ["learning", "goals"] },
{ id: 6, title: "Recipe Collection", content: "Pasta Carbonara:\n- 400g spaghetti\n- 200g pancetta\n- 4 eggs\n- 100g pecorino cheese\n- Black pepper\n\nInstructions:\n1. Cook pasta...\n2. Fry pancetta...", date: "2023-05-28", tags: ["cooking", "recipes"] }
];
const sampleHistory = [
{ id: 1, title: "Deleted: Shopping List", content: "Milk, Eggs, Bread, Fruits", date: "2023-05-30", action: "deleted" },
{ id: 2, title: "Modified: Project Ideas", content: "Added new idea: AI chatbot", date: "2023-05-29", action: "modified" },
{ id: 3, title: "Created: Budget Plan", content: "Monthly budget breakdown", date: "2023-05-28", action: "created" },
{ id: 4, title: "Deleted: Old Notes", content: "Outdated information", date: "2023-05-27", action: "deleted" }
];
// DOM Elements
const notesTab = document.getElementById('notesTab');
const historyTab = document.getElementById('historyTab');
const notesSection = document.getElementById('notesSection');
const historySection = document.getElementById('historySection');
const currentSectionTitle = document.getElementById('currentSectionTitle');
const notesContainer = document.getElementById('notesContainer');
const historyContainer = document.getElementById('historyContainer');
const newNoteBtn = document.getElementById('newNoteBtn');
const noteModal = document.getElementById('noteModal');
const closeModal = document.getElementById('closeModal');
const saveNote = document.getElementById('saveNote');
const deleteNote = document.getElementById('deleteNote');
const menuToggle = document.getElementById('menuToggle');
const sidebar = document.getElementById('sidebar');
const noteTitle = document.getElementById('noteTitle');
const noteContent = document.getElementById('noteContent');
// Current state
let currentNoteId = null;
let isSidebarOpen = true;
// Initialize the app
function initApp() {
renderNotes();
renderHistory();
setupEventListeners();
}
// Render notes
function renderNotes() {
notesContainer.innerHTML = '';
sampleNotes.forEach(note => {
const noteCard = document.createElement('div');
noteCard.className = 'note-card bg-white rounded-lg p-5 cursor-pointer';
noteCard.innerHTML = `
<div class="flex justify-between items-start">
<h3 class="font-bold text-lg mb-2">${note.title}</h3>
<span class="text-xs text-gray-500">${formatDate(note.date)}</span>
</div>
<p class="text-gray-600 mb-4 whitespace-pre-line truncate">${note.content.substring(0, 100)}${note.content.length > 100 ? '...' : ''}</p>
<div class="flex flex-wrap gap-2">
${note.tags.map(tag => `<span class="bg-purple-100 text-purple-800 text-xs px-2 py-1 rounded">${tag}</span>`).join('')}
</div>
`;
noteCard.addEventListener('click', () => openNoteEditor(note.id));
notesContainer.appendChild(noteCard);
});
}
// Render history
function renderHistory() {
historyContainer.innerHTML = '';
sampleHistory.forEach(item => {
const historyItem = document.createElement('div');
historyItem.className = 'bg-white rounded-lg p-4 border-l-4 border-primary';
historyItem.innerHTML = `
<div class="flex justify-between">
<h3 class="font-semibold">${item.title}</h3>
<span class="text-sm text-gray-500">${formatDate(item.date)}</span>
</div>
<p class="text-gray-600 my-2">${item.content}</p>
<div class="flex justify-between items-center">
<span class="text-xs px-2 py-1 rounded ${
item.action === 'created' ? 'bg-green-100 text-green-800' :
item.action === 'modified' ? 'bg-blue-100 text-blue-800' :
'bg-red-100 text-red-800'
}">
${item.action.charAt(0).toUpperCase() + item.action.slice(1)}
</span>
<button class="text-primary hover:text-indigo-700 text-sm flex items-center">
<i data-feather="eye" class="mr-1"></i> View
</button>
</div>
`;
historyContainer.appendChild(historyItem);
});
feather.replace();
}
// Format date
function formatDate(dateString) {
const options = { year: 'numeric', month: 'short', day: 'numeric' };
return new Date(dateString).toLocaleDateString(undefined, options);
}
// Open note editor
function openNoteEditor(noteId = null) {
currentNoteId = noteId;
if (noteId) {
const note = sampleNotes.find(n => n.id === noteId);
noteTitle.value = note.title;
noteContent.value = note.content;
deleteNote.classList.remove('hidden');
} else {
noteTitle.value = '';
noteContent.value = '';
deleteNote.classList.add('hidden');
}
noteModal.classList.remove('hidden');
}
// Save note
function saveCurrentNote() {
// In a real app, this would save to a database
console.log('Saving note:', noteTitle.value, noteContent.value);
noteModal.classList.add('hidden');
// Refresh notes display
renderNotes();
}
// Delete note
function deleteCurrentNote() {
if (confirm('Are you sure you want to delete this note?')) {
// In a real app, this would delete from a database
console.log('Deleting note with ID:', currentNoteId);
noteModal.classList.add('hidden');
// Refresh notes display
renderNotes();
}
}
// Toggle sidebar on mobile
function toggleSidebar() {
isSidebarOpen = !isSidebarOpen;
if (isSidebarOpen) {
sidebar.classList.remove('-ml-64');
} else {
sidebar.classList.add('-ml-64');
}
}
// Setup event listeners
function setupEventListeners() {
notesTab.addEventListener('click', () => {
notesTab.classList.add('active-tab');
historyTab.classList.remove('active-tab', 'text-gray-600');
historyTab.classList.add('text-gray-600');
notesSection.classList.remove('hidden');
historySection.classList.add('hidden');
currentSectionTitle.textContent = 'My Notes';
});
historyTab.addEventListener('click', () => {
historyTab.classList.add('active-tab');
notesTab.classList.remove('active-tab', 'text-gray-600');
notesTab.classList.add('text-gray-600');
historySection.classList.remove('hidden');
notesSection.classList.add('hidden');
currentSectionTitle.textContent = 'Note History';
});
newNoteBtn.addEventListener('click', () => openNoteEditor());
closeModal.addEventListener('click', () => noteModal.classList.add('hidden'));
saveNote.addEventListener('click', saveCurrentNote);
deleteNote.addEventListener('click', deleteCurrentNote);
menuToggle.addEventListener('click', toggleSidebar);
// Close modal when clicking outside
window.addEventListener('click', (e) => {
if (e.target === noteModal) {
noteModal.classList.add('hidden');
}
});
}
// Initialize the app when DOM is loaded
document.addEventListener('DOMContentLoaded', initApp);
</script>
</body>
</html>