Spaces:
Running
Running
add a chat with ai option in this, so the user can use the ai to write codes
Browse files- components/ai-agent.js +7 -7
- components/navbar.js +12 -8
- editor.html +7 -3
- script.js +7 -0
- style.css +8 -0
components/ai-agent.js
CHANGED
|
@@ -4,13 +4,13 @@ class AIAgent extends HTMLElement {
|
|
| 4 |
super();
|
| 5 |
this.attachShadow({ mode: 'open' });
|
| 6 |
this.isOpen = false;
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
currentFile: null,
|
| 15 |
projectType: null,
|
| 16 |
language: null
|
|
|
|
| 4 |
super();
|
| 5 |
this.attachShadow({ mode: 'open' });
|
| 6 |
this.isOpen = false;
|
| 7 |
+
this.conversation = [
|
| 8 |
+
{
|
| 9 |
+
role: 'assistant',
|
| 10 |
+
content: '👋 Hello! I\'m your AI coding assistant.\n\nI can help you with:\n\n💻 Writing and debugging code\n📚 Explaining programming concepts\n🚀 Setting up new projects\n⚡ Optimizing your existing code\n\nJust tell me what you need help with! For example:\n\n- "Write a Python function to calculate factorial"\n- "Explain how React hooks work"\n- "Help me debug this Node.js error"\n- "Create a React component for a login form"'
|
| 11 |
+
}
|
| 12 |
+
];
|
| 13 |
+
this.projectContext = {
|
| 14 |
currentFile: null,
|
| 15 |
projectType: null,
|
| 16 |
language: null
|
components/navbar.js
CHANGED
|
@@ -172,14 +172,18 @@ class CustomNavbar extends HTMLElement {
|
|
| 172 |
<i data-feather="book" style="width: 16px; height: 16px;"></i>
|
| 173 |
Docs
|
| 174 |
</button>
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 183 |
</div>
|
| 184 |
</nav>
|
| 185 |
`;
|
|
|
|
| 172 |
<i data-feather="book" style="width: 16px; height: 16px;"></i>
|
| 173 |
Docs
|
| 174 |
</button>
|
| 175 |
+
<button class="btn btn-primary">
|
| 176 |
+
<i data-feather="plus" style="width: 16px; height: 16px;"></i>
|
| 177 |
+
Create
|
| 178 |
+
</button>
|
| 179 |
+
<button class="btn btn-outline" onclick="window.dispatchEvent(new CustomEvent('toggleAIChat'))">
|
| 180 |
+
<i data-feather="message-square" style="width: 16px; height: 16px;"></i>
|
| 181 |
+
AI Chat
|
| 182 |
+
</button>
|
| 183 |
+
<div class="user-menu">
|
| 184 |
+
<div class="avatar">U</div>
|
| 185 |
+
</div>
|
| 186 |
+
</div>
|
| 187 |
</div>
|
| 188 |
</nav>
|
| 189 |
`;
|
editor.html
CHANGED
|
@@ -121,10 +121,14 @@
|
|
| 121 |
</div>
|
| 122 |
</div>
|
| 123 |
<custom-footer></custom-footer>
|
| 124 |
-
|
| 125 |
<ai-agent></ai-agent>
|
| 126 |
-
|
| 127 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
<script src="components/footer.js"></script>
|
| 129 |
<script src="components/ai-agent.js"></script>
|
| 130 |
<script src="script.js"></script>
|
|
|
|
| 121 |
</div>
|
| 122 |
</div>
|
| 123 |
<custom-footer></custom-footer>
|
|
|
|
| 124 |
<ai-agent></ai-agent>
|
| 125 |
+
<div class="fixed bottom-4 right-20 z-50">
|
| 126 |
+
<button class="bg-primary hover:bg-blue-600 text-white p-3 rounded-full shadow-lg flex items-center justify-center"
|
| 127 |
+
onclick="window.dispatchEvent(new CustomEvent('toggleAIChat'))">
|
| 128 |
+
<i data-feather="message-square"></i>
|
| 129 |
+
</button>
|
| 130 |
+
</div>
|
| 131 |
+
<script src="components/navbar.js"></script>
|
| 132 |
<script src="components/footer.js"></script>
|
| 133 |
<script src="components/ai-agent.js"></script>
|
| 134 |
<script src="script.js"></script>
|
script.js
CHANGED
|
@@ -22,6 +22,13 @@ document.addEventListener('DOMContentLoaded', function() {
|
|
| 22 |
});
|
| 23 |
});
|
| 24 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
// Theme toggle functionality
|
| 27 |
function toggleTheme() {
|
|
|
|
| 22 |
});
|
| 23 |
});
|
| 24 |
});
|
| 25 |
+
// AI Chat toggle functionality
|
| 26 |
+
document.addEventListener('toggleAIChat', function() {
|
| 27 |
+
const aiAgent = document.querySelector('ai-agent');
|
| 28 |
+
if (aiAgent) {
|
| 29 |
+
aiAgent.shadowRoot.querySelector('#agentButton').click();
|
| 30 |
+
}
|
| 31 |
+
});
|
| 32 |
|
| 33 |
// Theme toggle functionality
|
| 34 |
function toggleTheme() {
|
style.css
CHANGED
|
@@ -54,6 +54,14 @@ button:hover {
|
|
| 54 |
transform: translateY(-3px);
|
| 55 |
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
|
| 56 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
/* Feather icons alignment */
|
| 59 |
i[data-feather] {
|
|
|
|
| 54 |
transform: translateY(-3px);
|
| 55 |
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
|
| 56 |
}
|
| 57 |
+
/* AI Chat button styles */
|
| 58 |
+
.fixed.bottom-4 {
|
| 59 |
+
transition: all 0.2s ease;
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
.fixed.bottom-4:hover {
|
| 63 |
+
transform: scale(1.1);
|
| 64 |
+
}
|
| 65 |
|
| 66 |
/* Feather icons alignment */
|
| 67 |
i[data-feather] {
|