alfboss commited on
Commit
abb72e7
·
verified ·
1 Parent(s): 5b85ee6

make is correct its sid ebar will be simple menu item make samle and then on left make proper course like add module will open the module name and then user can add lesson etc in it but that is costing too much api use i want siomething simple like preview the design same time when they create and it will be statyic and then on save aoiu will hit and make the lcurrucim for them

Browse files
Files changed (4) hide show
  1. components/sidebar.js +28 -48
  2. index.html +59 -89
  3. script.js +49 -64
  4. style.css +25 -14
components/sidebar.js CHANGED
@@ -3,66 +3,46 @@ class CustomSidebar extends HTMLElement {
3
  this.attachShadow({ mode: 'open' });
4
  this.shadowRoot.innerHTML = `
5
  <style>
6
- .sidebar-item:hover .sidebar-icon {
7
- background-color: rgba(59, 130, 246, 0.1);
8
- color: rgb(59, 130, 246);
 
 
 
 
 
9
  }
10
- .sidebar-item.active .sidebar-icon {
11
  background-color: rgba(59, 130, 246, 0.1);
12
  color: rgb(59, 130, 246);
13
  }
14
- .sidebar-item.active .sidebar-text {
 
15
  color: rgb(59, 130, 246);
16
  font-weight: 500;
17
  }
 
 
 
18
  </style>
19
- <div class="hidden md:flex md:flex-shrink-0">
20
- <div class="flex flex-col w-64 border-r border-gray-200 bg-white">
21
- <div class="flex-1 flex flex-col pt-5 pb-4 overflow-y-auto">
22
- <div class="flex items-center flex-shrink-0 px-4">
23
- <h1 class="text-xl font-bold text-primary-600">EduLoom</h1>
24
- </div>
25
- <div class="mt-5 flex-1 px-3 space-y-1">
26
- <a href="#" class="sidebar-item active group flex items-center px-2 py-2 text-sm font-medium rounded-md">
27
- <div class="sidebar-icon mr-3 flex-shrink-0 h-6 w-6 flex items-center justify-center rounded-md">
28
- <i data-feather="book-open" class="h-4 w-4"></i>
29
- </div>
30
- <span class="sidebar-text">Curriculum</span>
31
- </a>
32
- <a href="#" class="sidebar-item group flex items-center px-2 py-2 text-sm font-medium rounded-md">
33
- <div class="sidebar-icon mr-3 flex-shrink-0 h-6 w-6 flex items-center justify-center rounded-md">
34
- <i data-feather="users" class="h-4 w-4"></i>
35
- </div>
36
- <span class="sidebar-text">Students</span>
37
- </a>
38
- <a href="#" class="sidebar-item group flex items-center px-2 py-2 text-sm font-medium rounded-md">
39
- <div class="sidebar-icon mr-3 flex-shrink-0 h-6 w-6 flex items-center justify-center rounded-md">
40
- <i data-feather="bar-chart-2" class="h-4 w-4"></i>
41
- </div>
42
- <span class="sidebar-text">Analytics</span>
43
- </a>
44
- <a href="#" class="sidebar-item group flex items-center px-2 py-2 text-sm font-medium rounded-md">
45
- <div class="sidebar-icon mr-3 flex-shrink-0 h-6 w-6 flex items-center justify-center rounded-md">
46
- <i data-feather="settings" class="h-4 w-4"></i>
47
- </div>
48
- <span class="sidebar-text">Settings</span>
49
- </a>
50
- </div>
51
  </div>
52
- <div class="flex-shrink-0 flex border-t border-gray-200 p-4">
53
- <div class="flex items-center">
54
- <div>
55
- <img class="inline-block h-9 w-9 rounded-full" src="http://static.photos/people/200x200/42" alt="">
56
- </div>
57
- <div class="ml-3">
58
- <p class="text-sm font-medium text-gray-700">John Doe</p>
59
- <a href="#" class="text-xs font-medium text-gray-500 hover:text-gray-700">View profile</a>
60
- </div>
61
- </div>
62
  </div>
63
  </div>
64
  </div>
65
- `;
66
  }
67
  }
68
  customElements.define('custom-sidebar', CustomSidebar);
 
3
  this.attachShadow({ mode: 'open' });
4
  this.shadowRoot.innerHTML = `
5
  <style>
6
+ .sidebar-item {
7
+ padding: 0.75rem 1rem;
8
+ margin: 0.25rem 0;
9
+ border-radius: 0.375rem;
10
+ cursor: pointer;
11
+ transition: all 0.2s;
12
+ display: flex;
13
+ align-items: center;
14
  }
15
+ .sidebar-item:hover {
16
  background-color: rgba(59, 130, 246, 0.1);
17
  color: rgb(59, 130, 246);
18
  }
19
+ .sidebar-item.active {
20
+ background-color: rgba(59, 130, 246, 0.1);
21
  color: rgb(59, 130, 246);
22
  font-weight: 500;
23
  }
24
+ .sidebar-icon {
25
+ margin-right: 0.75rem;
26
+ }
27
  </style>
28
+ <div class="w-64 bg-white border-r border-gray-200 h-full p-4">
29
+ <h2 class="text-xl font-bold text-primary-600 mb-6">EduLoom</h2>
30
+ <div class="space-y-1">
31
+ <div class="sidebar-item active">
32
+ <i data-feather="book-open" class="sidebar-icon w-5 h-5"></i>
33
+ <span>Curriculum Builder</span>
34
+ </div>
35
+ <div class="sidebar-item">
36
+ <i data-feather="eye" class="sidebar-icon w-5 h-5"></i>
37
+ <span>Preview</span>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  </div>
39
+ <div class="sidebar-item">
40
+ <i data-feather="save" class="sidebar-icon w-5 h-5"></i>
41
+ <span>Save Curriculum</span>
 
 
 
 
 
 
 
42
  </div>
43
  </div>
44
  </div>
45
+ `;
46
  }
47
  }
48
  customElements.define('custom-sidebar', CustomSidebar);
index.html CHANGED
@@ -64,110 +64,80 @@
64
  Add Module
65
  </button>
66
  </div>
67
-
68
- <!-- Curriculum Container -->
69
- <div class="bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden">
70
- <!-- Module 1 -->
71
- <div class="border-b border-gray-200 last:border-b-0">
72
- <div class="px-6 py-4 bg-gradient-to-r from-primary-50 to-secondary-50 flex justify-between items-center">
73
- <div class="flex items-center gap-4">
74
- <div class="w-10 h-10 rounded-full bg-primary-100 flex items-center justify-center text-primary-600">
75
- <i data-feather="book"></i>
76
- </div>
77
- <div>
78
- <h3 class="font-semibold text-gray-900">Module 1: Introduction to Course</h3>
79
- <p class="text-sm text-gray-500">5 lessons • 2 hours 15 min</p>
80
- </div>
81
  </div>
82
- <div class="flex gap-2">
83
- <button class="p-2 rounded-lg hover:bg-gray-100 text-gray-500 hover:text-gray-700">
84
- <i data-feather="edit-2" class="w-4 h-4"></i>
85
- </button>
86
- <button class="p-2 rounded-lg hover:bg-gray-100 text-gray-500 hover:text-gray-700">
87
- <i data-feather="chevron-down" class="w-4 h-4"></i>
88
- </button>
89
- </div>
90
- </div>
91
-
92
- <!-- Lessons -->
93
- <div class="divide-y divide-gray-100">
94
- <!-- Lesson 1 -->
95
- <div class="px-6 py-4 flex items-start gap-4 hover:bg-gray-50">
96
- <div class="w-8 h-8 rounded-full bg-secondary-100 flex items-center justify-center text-secondary-600 mt-1">
97
- <i data-feather="play" class="w-3 h-3"></i>
98
- </div>
99
- <div class="flex-1">
100
- <h4 class="font-medium text-gray-900">Welcome to the Course</h4>
101
- <p class="text-sm text-gray-500">10 min • Video</p>
102
- </div>
103
  <div class="flex gap-2">
104
- <button class="p-1 rounded-lg hover:bg-gray-100 text-gray-500 hover:text-gray-700">
105
- <i data-feather="edit-2" class="w-4 h-4"></i>
106
- </button>
107
- <button class="p-1 rounded-lg hover:bg-gray-100 text-gray-500 hover:text-gray-700">
108
- <i data-feather="trash-2" class="w-4 h-4"></i>
 
 
 
109
  </button>
110
  </div>
111
  </div>
112
-
113
- <!-- Lesson 2 -->
114
- <div class="px-6 py-4 flex items-start gap-4 hover:bg-gray-50">
115
- <div class="w-8 h-8 rounded-full bg-secondary-100 flex items-center justify-center text-secondary-600 mt-1">
116
- <i data-feather="file-text" class="w-3 h-3"></i>
117
- </div>
118
- <div class="flex-1">
119
- <h4 class="font-medium text-gray-900">Course Overview</h4>
120
- <p class="text-sm text-gray-500">15 min • Reading</p>
121
- </div>
122
- <div class="flex gap-2">
123
- <button class="p-1 rounded-lg hover:bg-gray-100 text-gray-500 hover:text-gray-700">
124
- <i data-feather="edit-2" class="w-4 h-4"></i>
125
- </button>
126
- <button class="p-1 rounded-lg hover:bg-gray-100 text-gray-500 hover:text-gray-700">
127
- <i data-feather="trash-2" class="w-4 h-4"></i>
128
- </button>
129
- </div>
130
  </div>
131
  </div>
132
  </div>
133
-
134
- <!-- Module 2 -->
135
- <div class="border-b border-gray-200 last:border-b-0">
136
- <div class="px-6 py-4 bg-white flex justify-between items-center">
137
- <div class="flex items-center gap-4">
138
- <div class="w-10 h-10 rounded-full bg-primary-100 flex items-center justify-center text-primary-600">
139
- <i data-feather="box"></i>
140
- </div>
141
- <div>
142
- <h3 class="font-semibold text-gray-900">Module 2: Core Concepts</h3>
143
- <p class="text-sm text-gray-500">8 lessons • 3 hours 40 min</p>
 
 
 
 
 
 
144
  </div>
145
  </div>
146
- <div class="flex gap-2">
147
- <button class="p-2 rounded-lg hover:bg-gray-100 text-gray-500 hover:text-gray-700">
148
- <i data-feather="edit-2" class="w-4 h-4"></i>
149
- </button>
150
- <button class="p-2 rounded-lg hover:bg-gray-100 text-gray-500 hover:text-gray-700">
151
- <i data-feather="chevron-down" class="w-4 h-4"></i>
152
- </button>
 
 
153
  </div>
154
  </div>
155
- </div>
156
-
157
- <!-- Empty State -->
158
- <div class="px-6 py-12 text-center">
159
- <div class="mx-auto w-24 h-24 bg-gray-100 rounded-full flex items-center justify-center text-gray-400 mb-4">
160
- <i data-feather="plus" class="w-8 h-8"></i>
161
  </div>
162
- <h3 class="text-lg font-medium text-gray-900 mb-1">Add your first module</h3>
163
- <p class="text-gray-500 max-w-md mx-auto">Start building your course curriculum by adding modules and lessons</p>
164
- <button class="mt-4 bg-primary-600 hover:bg-primary-700 text-white px-4 py-2 rounded-lg inline-flex items-center gap-2">
165
- <i data-feather="plus"></i>
166
- Create Module
167
- </button>
168
  </div>
169
  </div>
170
- </div>
171
  </main>
172
  </div>
173
  </div>
 
64
  Add Module
65
  </button>
66
  </div>
67
+ <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
68
+ <!-- Curriculum Builder -->
69
+ <div class="bg-white rounded-xl shadow-sm border border-gray-200 p-6">
70
+ <h2 class="text-xl font-semibold mb-4">Build Your Curriculum</h2>
71
+
72
+ <div class="space-y-4">
73
+ <div>
74
+ <label class="block text-sm font-medium text-gray-700 mb-1">Module Title</label>
75
+ <input type="text" class="w-full px-3 py-2 border border-gray-300 rounded-md" placeholder="Enter module title">
 
 
 
 
 
76
  </div>
77
+
78
+ <div>
79
+ <label class="block text-sm font-medium text-gray-700 mb-1">Add Lesson</label>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  <div class="flex gap-2">
81
+ <select class="flex-1 px-3 py-2 border border-gray-300 rounded-md">
82
+ <option>Video Lesson</option>
83
+ <option>Reading</option>
84
+ <option>Quiz</option>
85
+ <option>Assignment</option>
86
+ </select>
87
+ <button class="bg-primary-600 text-white px-3 py-2 rounded-md">
88
+ <i data-feather="plus"></i>
89
  </button>
90
  </div>
91
  </div>
92
+
93
+ <div class="border-t pt-4">
94
+ <button class="w-full bg-primary-600 hover:bg-primary-700 text-white py-2 rounded-md flex items-center justify-center gap-2">
95
+ <i data-feather="plus-circle"></i>
96
+ Add Module
97
+ </button>
 
 
 
 
 
 
 
 
 
 
 
 
98
  </div>
99
  </div>
100
  </div>
101
+
102
+ <!-- Preview Panel -->
103
+ <div class="bg-white rounded-xl shadow-sm border border-gray-200 p-6">
104
+ <h2 class="text-xl font-semibold mb-4">Curriculum Preview</h2>
105
+
106
+ <div class="space-y-3">
107
+ <div class="bg-gray-50 p-3 rounded-lg border border-gray-200">
108
+ <h3 class="font-medium">Module 1: Introduction</h3>
109
+ <div class="mt-2 space-y-2">
110
+ <div class="flex items-center gap-2 text-sm">
111
+ <i data-feather="play" class="w-4 h-4 text-gray-500"></i>
112
+ <span>Welcome Video (5 min)</span>
113
+ </div>
114
+ <div class="flex items-center gap-2 text-sm">
115
+ <i data-feather="file-text" class="w-4 h-4 text-gray-500"></i>
116
+ <span>Course Overview</span>
117
+ </div>
118
  </div>
119
  </div>
120
+
121
+ <div class="bg-gray-50 p-3 rounded-lg border border-gray-200">
122
+ <h3 class="font-medium">Module 2: Core Concepts</h3>
123
+ <div class="mt-2 space-y-2">
124
+ <div class="flex items-center gap-2 text-sm">
125
+ <i data-feather="play" class="w-4 h-4 text-gray-500"></i>
126
+ <span>Basic Principles (12 min)</span>
127
+ </div>
128
+ </div>
129
  </div>
130
  </div>
131
+
132
+ <div class="mt-6">
133
+ <button class="w-full bg-green-600 hover:bg-green-700 text-white py-2 rounded-md flex items-center justify-center gap-2">
134
+ <i data-feather="save"></i>
135
+ Save Curriculum
136
+ </button>
137
  </div>
 
 
 
 
 
 
138
  </div>
139
  </div>
140
+ </div>
141
  </main>
142
  </div>
143
  </div>
script.js CHANGED
@@ -1,73 +1,58 @@
1
- // Main application scripts
2
- document.addEventListener('DOMContentLoaded', function() {
3
- // Initialize tooltips
4
- const tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));
5
- tooltipTriggerList.map(function (tooltipTriggerEl) {
6
- return new bootstrap.Tooltip(tooltipTriggerEl);
7
- });
8
-
9
- // Module accordion functionality
10
- const moduleHeaders = document.querySelectorAll('.module-header');
11
- moduleHeaders.forEach(header => {
12
- header.addEventListener('click', () => {
13
- const module = header.closest('.module');
14
- const content = module.querySelector('.module-content');
15
- const icon = header.querySelector('i');
16
 
17
- // Toggle content visibility
18
- content.classList.toggle('hidden');
 
 
 
 
 
 
 
 
19
 
20
- // Rotate chevron icon
21
- if (content.classList.contains('hidden')) {
22
- icon.setAttribute('data-feather', 'chevron-right');
23
- } else {
24
- icon.setAttribute('data-feather', 'chevron-down');
25
- }
26
- feather.replace();
27
- });
28
- });
29
-
30
- // Drag and drop functionality for lessons
31
- const draggableLessons = document.querySelectorAll('.lesson');
32
- draggableLessons.forEach(lesson => {
33
- lesson.setAttribute('draggable', 'true');
34
-
35
- lesson.addEventListener('dragstart', () => {
36
- lesson.classList.add('dragging');
37
- });
38
-
39
- lesson.addEventListener('dragend', () => {
40
- lesson.classList.remove('dragging');
41
  });
42
- });
43
-
44
- const lessonContainers = document.querySelectorAll('.lesson-container');
45
- lessonContainers.forEach(container => {
46
- container.addEventListener('dragover', e => {
47
  e.preventDefault();
48
- const afterElement = getDragAfterElement(container, e.clientY);
49
- const draggable = document.querySelector('.dragging');
 
50
 
51
- if (afterElement == null) {
52
- container.appendChild(draggable);
53
- } else {
54
- container.insertBefore(draggable, afterElement);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  }
56
- });
57
- });
58
-
59
- function getDragAfterElement(container, y) {
60
- const draggableElements = [...container.querySelectorAll('.lesson:not(.dragging)')];
61
-
62
- return draggableElements.reduce((closest, child) => {
63
- const box = child.getBoundingClientRect();
64
- const offset = y - box.top - box.height / 2;
65
 
66
- if (offset < 0 && offset > closest.offset) {
67
- return { offset: offset, element: child };
68
- } else {
69
- return closest;
70
- }
71
- }, { offset: Number.NEGATIVE_INFINITY }).element;
72
  }
73
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
 
2
+ document.addEventListener('DOMContentLoaded', function() {
3
+ // Form handling for curriculum builder
4
+ const moduleForm = document.querySelector('#module-form');
5
+ const lessonForm = document.querySelector('#lesson-form');
6
+ const previewContainer = document.querySelector('#preview-container');
7
+
8
+ if (moduleForm) {
9
+ moduleForm.addEventListener('submit', function(e) {
10
+ e.preventDefault();
11
+ const moduleTitle = this.querySelector('input[name="module-title"]').value;
12
 
13
+ // Update preview
14
+ const modulePreview = document.createElement('div');
15
+ modulePreview.className = 'bg-gray-50 p-3 rounded-lg border border-gray-200';
16
+ modulePreview.innerHTML = `
17
+ <h3 class="font-medium">${moduleTitle}</h3>
18
+ <div class="mt-2 space-y-2" id="lessons-${Date.now()}"></div>
19
+ `;
20
+ previewContainer.appendChild(modulePreview);
21
+
22
+ // Reset form
23
+ this.reset();
 
 
 
 
 
 
 
 
 
 
24
  });
25
+ }
26
+
27
+ if (lessonForm) {
28
+ lessonForm.addEventListener('submit', function(e) {
 
29
  e.preventDefault();
30
+ const lessonType = this.querySelector('select[name="lesson-type"]').value;
31
+ const lessonTitle = this.querySelector('input[name="lesson-title"]').value;
32
+ const lessonDuration = this.querySelector('input[name="lesson-duration"]').value;
33
 
34
+ // Update preview
35
+ const lastModule = previewContainer.lastElementChild;
36
+ if (lastModule) {
37
+ const lessonsContainer = lastModule.querySelector('div');
38
+ if (lessonsContainer) {
39
+ const icon = lessonType === 'Video' ? 'play' :
40
+ lessonType === 'Reading' ? 'file-text' :
41
+ lessonType === 'Quiz' ? 'check-circle' : 'edit-3';
42
+
43
+ const lessonElement = document.createElement('div');
44
+ lessonElement.className = 'flex items-center gap-2 text-sm';
45
+ lessonElement.innerHTML = `
46
+ <i data-feather="${icon}" class="w-4 h-4 text-gray-500"></i>
47
+ <span>${lessonTitle}${lessonDuration ? ` (${lessonDuration} min)` : ''}</span>
48
+ `;
49
+ lessonsContainer.appendChild(lessonElement);
50
+ feather.replace();
51
+ }
52
  }
 
 
 
 
 
 
 
 
 
53
 
54
+ // Reset form
55
+ this.reset();
56
+ });
 
 
 
57
  }
58
  });
style.css CHANGED
@@ -1,3 +1,4 @@
 
1
  /* Custom styles that can't be achieved with Tailwind */
2
  @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
3
 
@@ -5,9 +6,30 @@ body {
5
  font-family: 'Inter', sans-serif;
6
  }
7
 
8
- /* Smooth transitions for sidebar */
9
- .sidebar-transition {
10
- transition: all 0.3s ease-in-out;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  }
12
 
13
  /* Custom scrollbar */
@@ -28,14 +50,3 @@ body {
28
  ::-webkit-scrollbar-thumb:hover {
29
  background: #a8a8a8;
30
  }
31
-
32
- /* Lesson drag handle */
33
- .drag-handle {
34
- cursor: move;
35
- opacity: 0.5;
36
- transition: opacity 0.2s;
37
- }
38
-
39
- .drag-handle:hover {
40
- opacity: 1;
41
- }
 
1
+
2
  /* Custom styles that can't be achieved with Tailwind */
3
  @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
4
 
 
6
  font-family: 'Inter', sans-serif;
7
  }
8
 
9
+ /* Form styles */
10
+ input, select {
11
+ transition: all 0.2s;
12
+ }
13
+
14
+ input:focus, select:focus {
15
+ outline: none;
16
+ border-color: #3b82f6;
17
+ box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
18
+ }
19
+
20
+ /* Preview panel styles */
21
+ .preview-module {
22
+ transition: all 0.2s;
23
+ }
24
+
25
+ .preview-module:hover {
26
+ transform: translateY(-2px);
27
+ box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
28
+ }
29
+
30
+ /* Button transitions */
31
+ button {
32
+ transition: all 0.2s;
33
  }
34
 
35
  /* Custom scrollbar */
 
50
  ::-webkit-scrollbar-thumb:hover {
51
  background: #a8a8a8;
52
  }