diff --git a/assets/css/custom.css b/assets/css/custom.css new file mode 100644 index 0000000..80f54d2 --- /dev/null +++ b/assets/css/custom.css @@ -0,0 +1,112 @@ +/* General Body Styles */ +body { + font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; + transition: background-color 0.3s ease, color 0.3s ease; +} + +/* Light Mode Palette */ +body[data-bs-theme="light"] { + background-color: #F8F9FA; + color: #212529; +} + +/* Dark Mode Palette */ +body[data-bs-theme="dark"] { + background-color: #121212; + color: #E0E0E0; +} + +body[data-bs-theme="dark"] .navbar { + background-color: #1E1E1E !important; + border-bottom: 1px solid #333; +} + +body[data-bs-theme="dark"] .note-card { + background-color: #1E1E1E; + border-color: #333; +} + +body[data-bs-theme="dark"] .note-card .card-title { + color: #FFF; +} + +body[data-bs-theme="dark"] .note-card .card-text { + color: #AEAEAE; +} + +body[data-bs-theme="dark"] .badge { + border: 1px solid #555; +} + + +/* Navbar */ +.navbar-brand { + font-weight: 700; + font-size: 1.5rem; +} + +/* Theme Switcher */ +.theme-switch { + cursor: pointer; + font-size: 1.2rem; +} + +/* Note Grid */ +.notes-grid { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); + gap: 1.5rem; +} + +/* Note Card */ +.note-card { + border-radius: 0.75rem; + border: 1px solid #E0E0E0; + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05); + transition: transform 0.2s ease, box-shadow 0.2s ease; + position: relative; + overflow: hidden; + padding-bottom: 2.5rem; /* Space for footer */ +} + +.note-card:hover { + transform: translateY(-5px); + box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1); +} + +.note-card .card-body { + padding: 1.5rem; +} + +.note-card .card-title { + font-weight: 600; +} + +.note-card .card-text { + color: #6c757d; + font-size: 0.95rem; +} + +.note-card .card-footer { + position: absolute; + bottom: 0; + left: 0; + right: 0; + padding: 0.75rem 1.5rem; + background: transparent; + border-top: none; +} + +.note-card .badge { + font-size: 0.75rem; + padding: 0.4em 0.6em; + font-weight: 500; +} + +.color-label { + position: absolute; + top: 0; + left: 0; + width: 5px; + height: 100%; +} diff --git a/assets/js/main.js b/assets/js/main.js new file mode 100644 index 0000000..926e5f2 --- /dev/null +++ b/assets/js/main.js @@ -0,0 +1,26 @@ +document.addEventListener('DOMContentLoaded', () => { + const themeSwitch = document.getElementById('theme-switch'); + const currentTheme = localStorage.getItem('theme') ? localStorage.getItem('theme') : 'light'; + + if (currentTheme) { + document.body.setAttribute('data-bs-theme', currentTheme); + if (themeSwitch) { + themeSwitch.innerHTML = currentTheme === 'dark' ? '' : ''; + } + } + + if(themeSwitch) { + themeSwitch.addEventListener('click', () => { + let theme = document.body.getAttribute('data-bs-theme'); + if (theme === 'dark') { + document.body.setAttribute('data-bs-theme', 'light'); + localStorage.setItem('theme', 'light'); + themeSwitch.innerHTML = ''; + } else { + document.body.setAttribute('data-bs-theme', 'dark'); + localStorage.setItem('theme', 'dark'); + themeSwitch.innerHTML = ''; + } + }); + } +}); diff --git a/create_note.php b/create_note.php new file mode 100644 index 0000000..5d2f718 --- /dev/null +++ b/create_note.php @@ -0,0 +1,75 @@ + +prepare('INSERT INTO notes (user_id, title, content, color, tags) VALUES (?, ?, ?, ?, ?)'); + $stmt->execute([$user_id, $title, $content, $color, $tags]); + header('Location: index.php?note_created=1'); + exit; + } catch (PDOException $e) { + $error = 'Database error: ' . $e->getMessage(); + } + } +} +?> + + + +
+
+
+
+

Create a New Note

+ + +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ + +
+
+
+
+ + diff --git a/db/migrations/001_create_initial_tables.sql b/db/migrations/001_create_initial_tables.sql new file mode 100644 index 0000000..c51ac2e --- /dev/null +++ b/db/migrations/001_create_initial_tables.sql @@ -0,0 +1,21 @@ + +CREATE TABLE IF NOT EXISTS `users` ( + `id` INT AUTO_INCREMENT PRIMARY KEY, + `username` VARCHAR(255) NOT NULL UNIQUE, + `email` VARCHAR(255) NOT NULL UNIQUE, + `password` VARCHAR(255) NOT NULL, + `role` ENUM('student', 'teacher') NOT NULL, + `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); + +CREATE TABLE IF NOT EXISTS `notes` ( + `id` INT AUTO_INCREMENT PRIMARY KEY, + `user_id` INT NOT NULL, + `title` VARCHAR(255) NOT NULL, + `content` TEXT, + `color` VARCHAR(7), + `tags` VARCHAR(255), + `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + `updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE +); diff --git a/footer.php b/footer.php new file mode 100644 index 0000000..0dc21c3 --- /dev/null +++ b/footer.php @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/header.php b/header.php new file mode 100644 index 0000000..bb4a881 --- /dev/null +++ b/header.php @@ -0,0 +1,51 @@ + + + + + + + My Notes + + + + + +
\ No newline at end of file diff --git a/index.php b/index.php index 7205f3d..c309637 100644 --- a/index.php +++ b/index.php @@ -1,150 +1,76 @@ - - - - - - - New Style prepare('SELECT * FROM notes WHERE user_id = ? ORDER BY created_at DESC'); + $stmt->execute([$_SESSION['user_id']]); + $notes = $stmt->fetchAll(); + } catch (PDOException $e) { + // For now, just show an empty array on DB error + $notes = []; + } +} else { + // Sample Data for Notes for non-logged-in users + $notes = [ + [ + 'title' => 'Biology Lesson Plan', + 'content' => 'Introduction to cell theory. Discuss Hooke and Leeuwenhoek...', + 'tags' => 'science,lesson-plan,10th-grade', + 'color' => '#D4EDDA', + ], + [ + 'title' => 'Student Study Notes - History', + 'content' => 'Key dates for the American Revolution: 1765 Stamp Act, 1770 Boston Massacre...', + 'tags' => 'history,student-notes,exam-prep', + 'color' => '#F8D7DA', + ], + ]; +} + +$note_created_success = isset($_GET['note_created']); + ?> - - - - - - - - - - - - - - - - - - - - -
-
-

Analyzing your requirements and generating your website…

-
- Loading… -
-

AI is collecting your requirements and applying the first changes.

-

This page will update automatically as the plan is implemented.

-

Runtime: PHP — UTC

-
-
- - - + + + +
+

Your Notes

+ + +
Note created successfully!
+ + + +
+

You don't have any notes yet. Create your first one!

+
+ +
+ +
+
+
+
+

+
+ +
+ +
+ +
+ + \ No newline at end of file diff --git a/login.php b/login.php new file mode 100644 index 0000000..19acd12 --- /dev/null +++ b/login.php @@ -0,0 +1,67 @@ + +prepare('SELECT id, username, password, role FROM users WHERE email = ?'); + $stmt->execute([$email]); + $user = $stmt->fetch(); + + if ($user && password_verify($password, $user['password'])) { + $_SESSION['user_id'] = $user['id']; + $_SESSION['username'] = $user['username']; + $_SESSION['role'] = $user['role']; + header('Location: index.php'); + exit; + } else { + $error = 'Invalid email or password.'; + } + } catch (PDOException $e) { + $error = 'Database error: ' . $e->getMessage(); + } + } +} +?> + + + +
+
+
+
+

Login

+ + +
+ + + +
+ + +
+
+ + +
+ + + +
+
+
+
+ + diff --git a/logout.php b/logout.php new file mode 100644 index 0000000..85facf7 --- /dev/null +++ b/logout.php @@ -0,0 +1,5 @@ +prepare('SELECT id FROM users WHERE username = ? OR email = ?'); + $stmt->execute([$username, $email]); + if ($stmt->fetch()) { + $error = 'Username or email already exists.'; + } else { + // Insert new user + $hashed_password = password_hash($password, PASSWORD_DEFAULT); + $stmt = $db->prepare('INSERT INTO users (username, email, password, role) VALUES (?, ?, ?, ?)'); + $stmt->execute([$username, $email, $hashed_password, $role]); + $success = 'Registration successful! You can now login.'; + } + } catch (PDOException $e) { + $error = 'Database error: ' . $e->getMessage(); + } + } +} +?> + + + +
+
+
+
+

Register

+ + +
+ + + +
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+ + +
+
+
+
+ +