Skip to content

Commit 3405d51

Browse files
committed
💄 Adds styles for the sheet (vertical scrolling and fixed close button)
1 parent 23ff5b2 commit 3405d51

1 file changed

Lines changed: 24 additions & 5 deletions

File tree

‎src/scripts/explain-code.ts‎

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function createSheet(
6666

6767
// Base classes
6868
let className =
69-
"sheet-content fixed z-50 gap-4 bg-[var(--sl-color-bg)] p-6 transition ease-in-out";
69+
"sheet-content fixed z-50 gap-4 bg-[var(--sl-color-bg)] p-6 transition ease-in-out overflow-y-auto";
7070
let boxShadow = "";
7171

7272
// Add side-specific positioning, border, and shadow
@@ -105,7 +105,8 @@ function createSheet(
105105
const closeButton = document.createElement("button");
106106
closeButton.type = "button";
107107
closeButton.className =
108-
"sheet-close absolute right-4 top-4 rounded-sm opacity-70 ring-offset-[var(--sl-color-bg)] transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-[var(--sl-color-text-accent)] focus:ring-offset-2 disabled:pointer-events-none";
108+
"sheet-close sticky top-0 right-0 ml-auto mb-4 rounded-sm opacity-70 ring-offset-[var(--sl-color-bg)] transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-[var(--sl-color-text-accent)] focus:ring-offset-2 disabled:pointer-events-none z-10 bg-[var(--sl-color-bg)] w-fit";
109+
closeButton.style.float = "right";
109110
closeButton.setAttribute("aria-label", "Close");
110111
closeButton.innerHTML = `
111112
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4">
@@ -126,10 +127,28 @@ function createSheet(
126127

127128
const explanationText = document.createElement("div");
128129
explanationText.className =
129-
"text-sm text-[var(--sl-color-gray-2)] p-4 bg-[var(--sl-color-gray-6)] rounded";
130+
"text-sm text-[var(--sl-color-gray-2)] p-4 bg-[var(--sl-color-gray-6)] rounded overflow-auto";
130131
explanationText.innerHTML = `
131-
<p class="mb-2">This feature would integrate with an AI service to provide code explanations.</p>
132-
<p class="text-xs opacity-70">Note: This is a placeholder. Connect to your preferred AI service to enable real explanations.</p>
132+
<p class="mb-4">This feature would integrate with an AI service to provide code explanations. The AI would analyze the code structure, identify key patterns, and explain what the code does in plain language.</p>
133+
134+
<p class="mb-4">When connected to an AI service, this panel would display a comprehensive breakdown of the code snippet, including:</p>
135+
136+
<ul class="list-disc list-inside mb-4 space-y-2">
137+
<li>An overview of what the code accomplishes</li>
138+
<li>Explanation of key functions and their purposes</li>
139+
<li>Description of important variables and data structures</li>
140+
<li>Analysis of any algorithms or design patterns used</li>
141+
<li>Potential use cases and applications</li>
142+
<li>Common pitfalls or edge cases to be aware of</li>
143+
</ul>
144+
145+
<p class="mb-4">The explanation would be tailored to the programming language and complexity level of the code. For beginners, it would provide more context and foundational concepts. For advanced users, it would focus on optimization opportunities, best practices, and architectural considerations.</p>
146+
147+
<p class="mb-4">Additionally, the AI could highlight specific lines of code and explain their role in the overall logic flow. It might suggest improvements, identify potential bugs, or recommend alternative approaches that could make the code more efficient or maintainable.</p>
148+
149+
<p class="mb-4">This type of interactive code explanation can be particularly valuable for learning new frameworks, understanding legacy codebases, or quickly getting up to speed with unfamiliar code patterns. It serves as an on-demand coding mentor that's available whenever you need clarification.</p>
150+
151+
<p class="text-xs opacity-70 mt-6">Note: This is a placeholder with extended content for testing purposes. Connect to your preferred AI service to enable real explanations.</p>
133152
`;
134153

135154
content.appendChild(closeButton);

0 commit comments

Comments
 (0)