Skip to content

Commit 4dae3de

Browse files
committed
✨ Adds a loading state
1 parent 61c4b5d commit 4dae3de

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

src/scripts/explain-code.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,31 @@ function createSheet(
185185
return container;
186186
}
187187

188+
function showLoading(container: HTMLElement) {
189+
const content = container.querySelector(".sheet-content") as HTMLElement;
190+
if (!content) return;
191+
192+
// Find and replace the explanation text with loading skeleton
193+
const explanationText = content.querySelector(
194+
".text-sm.text-\\[var\\(--sl-color-gray-2\\)\\].p-4",
195+
) as HTMLElement;
196+
if (!explanationText) return;
197+
198+
explanationText.innerHTML = `
199+
<div class="space-y-3 animate-pulse">
200+
<div class="h-4 bg-[var(--sl-color-gray-5)] rounded w-full"></div>
201+
<div class="h-4 bg-[var(--sl-color-gray-5)] rounded w-5/6"></div>
202+
<div class="h-4 bg-[var(--sl-color-gray-5)] rounded w-4/6"></div>
203+
<div class="h-4 bg-[var(--sl-color-gray-5)] rounded w-full mt-6"></div>
204+
<div class="h-4 bg-[var(--sl-color-gray-5)] rounded w-3/4"></div>
205+
<div class="h-4 bg-[var(--sl-color-gray-5)] rounded w-5/6"></div>
206+
<div class="h-4 bg-[var(--sl-color-gray-5)] rounded w-2/3 mt-6"></div>
207+
<div class="h-4 bg-[var(--sl-color-gray-5)] rounded w-full"></div>
208+
<div class="h-4 bg-[var(--sl-color-gray-5)] rounded w-4/5"></div>
209+
</div>
210+
`;
211+
}
212+
188213
function showError(container: HTMLElement, errorMessage: string) {
189214
const content = container.querySelector(".sheet-content") as HTMLElement;
190215
if (!content) return;

0 commit comments

Comments
 (0)