-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathloading.ts
More file actions
67 lines (63 loc) · 2.16 KB
/
Copy pathloading.ts
File metadata and controls
67 lines (63 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/**
* Loading HTML Template (Pure Function)
*
* Split from the legacy monolithic htmlTemplates.ts. Owns only
* the loading-state spinner body and its template-specific styles; the shell
* (<!DOCTYPE>…</head>, base stylesheet) lives in `./shell.ts`.
*
* @author Null;Variant
* @license MIT
*/
import { buildHtmlShell } from './shell';
import { type SanitizedHtml } from './types';
/**
* Generate loading state HTML
*
* @param cspSource - Webview CSP source
* @param nonce - CSP nonce for inline styles
* @returns Loading HTML document
*/
export function buildLoadingHtml(cspSource: string, nonce: string): string {
const extraStyles = ` .loading {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
}
.spinner {
width: var(--gis-spinner-size);
height: var(--gis-spinner-size);
border: var(--gis-spinner-border) solid var(--vscode-panel-border);
border-top-color: var(--vscode-textLink-foreground);
border-radius: 50%; /* circle, not a token */
animation: spin 1s linear infinite;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
/* Scope under body.gis-loading to stay consistent with the
invariant (template overrides must not leak as bare
element selectors). Loading view currently only renders one <p>
but this keeps the template symmetric with document/error. */
body.gis-loading p {
margin-top: var(--gis-space-md);
}`;
// aria-live="polite" + aria-atomic complements role="status" for AT stacks
// (older NVDA, some mobile readers) that miss the implicit live region on
// elements rendered during initial document parse.
// Brand the body as SanitizedHtml: only static literals, no interpolation.
const body = ` <main class="loading">
<div class="spinner" aria-hidden="true"></div>
<p role="status" aria-live="polite" aria-atomic="true">Loading documentation...</p>
</main>` as SanitizedHtml;
return buildHtmlShell({
cspSource,
nonce,
lang: 'en',
title: 'Loading — Git ID Switcher',
extraStyles,
bodyClass: 'gis-loading',
body,
});
}