Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions extensions/git-id-switcher/src/test/htmlTemplates.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -615,11 +615,17 @@ function testDesignTokenCoverage(): void {
['--gis-space-md', /--gis-space-md:\s*1em\b/],
['--gis-space-lg', /--gis-space-lg:\s*1\.5em\b/],
['--gis-space-xl', /--gis-space-xl:\s*2em\b/],
['--gis-pad-btn', /--gis-pad-btn:\s*4px 12px\b/],
['--gis-pad-body', /--gis-pad-body:\s*20px\b/],
['--gis-pad-body-lg', /--gis-pad-body-lg:\s*40px\b/],
['--gis-size-btn', /--gis-size-btn:\s*4px 12px\b/],
['--gis-size-body', /--gis-size-body:\s*20px\b/],
['--gis-size-body-lg', /--gis-size-body-lg:\s*40px\b/],
['--gis-font-sm', /--gis-font-sm:\s*0\.9em\b/],
['--gis-font-xs', /--gis-font-xs:\s*0\.8em\b/],
['--gis-width-readable', /--gis-width-readable:\s*800px\b/],
['--gis-line-height-doc', /--gis-line-height-doc:\s*1\.6\b/],
['--gis-border-emphasis', /--gis-border-emphasis:\s*4px solid var\(--vscode-textLink-foreground\)/],
['--gis-pad-code', /--gis-pad-code:\s*0\.2em 0\.4em\b/],
['--gis-spinner-size', /--gis-spinner-size:\s*40px\b/],
['--gis-spinner-border', /--gis-spinner-border:\s*3px\b/],
];
for (const [name, re] of tokenSpec) {
assert.match(styles, re, `${name} value contract violated`);
Expand All @@ -645,6 +651,18 @@ function testDesignTokenCoverage(): void {
`${name}: literal "1px solid var(--vscode-panel-border)" must appear exactly once (in token definition), found ${matches.length}`
);
}
// The literal `4px solid var(--vscode-textLink-foreground)` must appear
// exactly once per template — inside the --gis-border-emphasis token
// definition. Same SSOT enforcement as above.
const emphasisPattern = /4px solid var\(--vscode-textLink-foreground\)/g;
for (const [name, html] of allTemplates) {
const matches = html.match(emphasisPattern) ?? [];
assert.strictEqual(
matches.length, 1,
`${name}: literal "4px solid var(--vscode-textLink-foreground)" must appear exactly once (in token definition), found ${matches.length}`
);
}

// Only the document template actually consumes --gis-border-subtle
// (loading/error have no panel-border rules). Asserted separately to
// confirm the token is wired up, not merely defined.
Expand Down
21 changes: 16 additions & 5 deletions extensions/git-id-switcher/src/ui/htmlTemplates/baseStyles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,26 @@ export function getBaseStyles(): string {
--gis-space-md: 1em;
--gis-space-lg: 1.5em;
--gis-space-xl: 2em;
/* px-based layout spacing (body padding, footer gap, button padding) that
must not scale with inherited font-size. */
--gis-pad-btn: 4px 12px;
--gis-pad-body: 20px;
--gis-pad-body-lg: 40px;
/* px-based layout sizing (body padding, footer gap, button padding)
that must not scale with inherited font-size. */
--gis-size-btn: 4px 12px;
--gis-size-body: 20px;
--gis-size-body-lg: 40px;
/* font-size tokens. Declared against the document root so nested elements
do not multiply em values (0.9em inside a 0.9em ancestor shrinks). */
--gis-font-sm: 0.9em;
--gis-font-xs: 0.8em;
/* Document body readability tokens. */
--gis-width-readable: 800px;
--gis-line-height-doc: 1.6;
/* Emphasis border (blockquote left-edge, distinct from the subtle 1px
panel border). */
--gis-border-emphasis: 4px solid var(--vscode-textLink-foreground);
/* Inline code padding scale. */
--gis-pad-code: 0.2em 0.4em;
/* Spinner dimensions. */
--gis-spinner-size: 40px;
--gis-spinner-border: 3px;
}
body {
font-family: var(--vscode-font-family);
Expand Down
16 changes: 8 additions & 8 deletions extensions/git-id-switcher/src/ui/htmlTemplates/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function buildDocumentHtml(
h1 { border-bottom: var(--gis-border-subtle); padding-bottom: var(--gis-space-xs); }
code {
background-color: var(--vscode-textCodeBlock-background);
padding: 0.2em 0.4em;
padding: var(--gis-pad-code);
border-radius: var(--gis-radius-sm);
font-family: var(--vscode-editor-font-family);
}
Expand Down Expand Up @@ -111,7 +111,7 @@ export function buildDocumentHtml(
background-color: var(--vscode-textCodeBlock-background);
}
blockquote {
border-left: 4px solid var(--vscode-textLink-foreground);
border-left: var(--gis-border-emphasis);
margin: var(--gis-space-md) 0;
padding: var(--gis-space-sm) var(--gis-space-md);
background-color: var(--vscode-textCodeBlock-background);
Expand All @@ -131,7 +131,7 @@ export function buildDocumentHtml(
background: var(--vscode-button-secondaryBackground);
color: var(--vscode-button-secondaryForeground);
border: none;
padding: var(--gis-pad-btn);
padding: var(--gis-size-btn);
border-radius: var(--gis-radius-sm);
cursor: pointer;
font-family: var(--vscode-font-family);
Expand Down Expand Up @@ -169,8 +169,8 @@ ${getFocusVisibleRule('a:focus-visible, button:focus-visible')}
${getFocusVisibleForcedColorsRule('a:focus-visible, button:focus-visible')}
}
.footer {
margin-top: var(--gis-pad-body-lg);
padding-top: var(--gis-pad-body);
margin-top: var(--gis-size-body-lg);
padding-top: var(--gis-size-body);
border-top: var(--gis-border-subtle);
font-size: var(--gis-font-sm);
}
Expand All @@ -181,9 +181,9 @@ ${getFocusVisibleForcedColorsRule('a:focus-visible, button:focus-visible')}
raise specificity above the base body rule, making cascade order
irrelevant. */
body.gis-doc {
padding: var(--gis-pad-body);
line-height: 1.6;
max-width: 800px;
padding: var(--gis-size-body);
line-height: var(--gis-line-height-doc);
max-width: var(--gis-width-readable);
margin: 0 auto;
}`;

Expand Down
2 changes: 1 addition & 1 deletion extensions/git-id-switcher/src/ui/htmlTemplates/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function buildErrorHtml(
const extraStyles = ` /* Template-specific body layout — scoped by body.gis-error class
to raise specificity above the base body rule. */
body.gis-error {
padding: var(--gis-pad-body-lg);
padding: var(--gis-size-body-lg);
text-align: center;
}
h1 {
Expand Down
6 changes: 3 additions & 3 deletions extensions/git-id-switcher/src/ui/htmlTemplates/loading.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ export function buildLoadingHtml(cspSource: string, nonce: string): string {
height: 100vh;
}
.spinner {
width: 40px;
height: 40px;
border: 3px solid var(--vscode-panel-border);
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;
Expand Down
Loading