mirror of
https://github.com/lWolvesl/antigravity-usage-monitor.git
synced 2026-11-27 01:19:25 +08:00
fix(panel): make font-scale visibly resize all tables/charts and raise readable base sizes
- Raise base typography tokens (data tables to 12.5px, body/titles to 13px) above CJK 12px floor and widen lg (1.14x) / xl (1.28x) scale steps - Replace 19 hardcoded px font-size rules across tables, charts, tooltips, heatmaps, and monthly bars with scalable --fs-* tokens - Bind [data-font-scale] directly in CSS and mirror onto Shadow DOM overlay panels without colliding with :host defaults - Convert rigid control/row pixel heights to scalable min-heights and scale floating panel base widths on lg/xl
This commit is contained in:
@@ -616,3 +616,29 @@ test('Compaction liveActivity: detects in-progress & completed CHECKPOINT over p
|
||||
assert.equal(pTranscriptOnly.activeConversation.liveActivity.phase, 'compacting');
|
||||
assert.equal(pTranscriptOnly.activeConversation.liveActivity.label, '上下文压缩');
|
||||
});
|
||||
|
||||
test('panel typography scales all view/table/chart CSS rules via --fs-* tokens without hardcoded px sizes', () => {
|
||||
const stylesDir = fileURLToPath(new URL('../src/styles', import.meta.url));
|
||||
const viewCssFiles = [
|
||||
'controls.css',
|
||||
'views-overview.css',
|
||||
'views-tables.css',
|
||||
'views-consumption.css',
|
||||
'views-settings.css',
|
||||
];
|
||||
for (const file of viewCssFiles) {
|
||||
const css = fs.readFileSync(join(stylesDir, file), 'utf8');
|
||||
const rawFontLines = css
|
||||
.split(/\r?\n/)
|
||||
.filter((line) => /font-size\s*:/.test(line) && !/var\(--fs-/.test(line));
|
||||
assert.deepEqual(
|
||||
rawFontLines,
|
||||
[],
|
||||
`${file} must route every font-size declaration through scalable --fs-* tokens`
|
||||
);
|
||||
}
|
||||
const tokensCss = fs.readFileSync(join(stylesDir, 'tokens.css'), 'utf8');
|
||||
assert.match(tokensCss, /:host\(\[data-font-scale="xl"\]\)/);
|
||||
assert.match(tokensCss, /\[data-font-scale\]\s*\{[\s\S]*?--fs-base-sm:/);
|
||||
assert.doesNotMatch(tokensCss, /:root,\s*:host\s*\{[^}]*--ui-font-scale\s*:\s*1\s*;/);
|
||||
});
|
||||
|
||||
@@ -1422,7 +1422,11 @@ test('Compiled app.js mounts dual Shadow DOM hosts, tracks /c/<uuid> routes, pro
|
||||
assert.equal(liveDotSvg.attributes.get('width'), '11', 'Enlarged live activity SVG dot size is 11');
|
||||
assert.equal(liveDotSvg.children[0].attributes.get('r'), '5', 'Enlarged dot circle radius is 5');
|
||||
assert.match(stylesCss, /\.wm-multi-dot\s*\{\s*width:\s*8px;\s*height:\s*8px;/, 'Topbar multi-session dot enlarged to 8px');
|
||||
assert.match(stylesCss, /\.wm-hover-tip\s*\{[^}]*width:\s*min\(522px,\s*calc\(100vw - 24px\)\);/, 'Hover floating card width is 522px');
|
||||
assert.match(
|
||||
stylesCss,
|
||||
/\.wm-hover-tip\s*\{[^}]*width:\s*min\(calc\(522px \* var\(--ui-panel-scale, 1\)\),\s*calc\(100vw - 24px\)\);/,
|
||||
'Hover floating card base width is 522px and scales with --ui-panel-scale'
|
||||
);
|
||||
assert.equal(multiPanelEl.querySelector('.wm-recent-list'), null, 'Recent sessions list removed so panel shows online sessions only');
|
||||
assert.equal(multiPanelEl.querySelector('.panel'), null, 'Single-layer multi-session panel without nested .panel box');
|
||||
|
||||
@@ -1563,19 +1567,25 @@ test('Compiled app.js mounts dual Shadow DOM hosts, tracks /c/<uuid> routes, pro
|
||||
assert.equal(mockSettings.themeAccent, 'host');
|
||||
assert.equal(portalHost.style.getPropertyValue('--user-accent-primary'), '', 'Host accent clears override');
|
||||
|
||||
// Font scale: switch to xl (1.15), verify portalHost scales while capsuleHost NEVER scales
|
||||
// Font scale: switch to xl (1.28), verify portalHost and inner panels scale while capsuleHost NEVER scales
|
||||
assert.equal(fontScaleBtns.length, 4, 'Font scale segmented control has sm / md / lg / xl');
|
||||
fontScaleBtns[3].dispatchEvent({ type: 'click', stopPropagation() {} });
|
||||
await new Promise((r) => setTimeout(r, 30));
|
||||
assert.equal(mockSettings.fontScale, 'xl');
|
||||
assert.equal(portalHost.style.getPropertyValue('--ui-font-scale'), '1.15', 'Portal host scales to 1.15');
|
||||
assert.equal(portalHost.style.getPropertyValue('--ui-font-scale'), '1.28', 'Portal host scales to 1.28');
|
||||
assert.equal(portalHost.style.getPropertyValue('--ui-panel-scale'), '1.18', 'Portal host panel width scales to 1.18');
|
||||
assert.equal(popoverEl.getAttribute('data-font-scale'), 'xl', 'Popover panel receives data-font-scale');
|
||||
assert.equal(hoverTipEl.getAttribute('data-font-scale'), 'xl', 'Hover card receives data-font-scale');
|
||||
assert.equal(multiPanelEl.getAttribute('data-font-scale'), 'xl', 'Multi-session panel receives data-font-scale');
|
||||
assert.equal(capsuleHost.style.getPropertyValue('--ui-font-scale'), '', 'Capsule host strictly excludes font scale');
|
||||
assert.equal(capsuleHost.hasAttribute('data-font-scale'), false);
|
||||
fontScaleBtns[1].dispatchEvent({ type: 'click', stopPropagation() {} });
|
||||
await new Promise((r) => setTimeout(r, 30));
|
||||
assert.equal(mockSettings.fontScale, 'md');
|
||||
assert.equal(portalHost.style.getPropertyValue('--ui-font-scale'), '');
|
||||
assert.equal(portalHost.style.getPropertyValue('--ui-panel-scale'), '');
|
||||
assert.equal(portalHost.getAttribute('data-font-scale'), 'md');
|
||||
assert.equal(popoverEl.getAttribute('data-font-scale'), 'md');
|
||||
|
||||
// Live i18n switch: zh-CN -> en-US -> zh-CN without page reload
|
||||
langBtns[1].dispatchEvent({ type: 'click', stopPropagation() {} });
|
||||
|
||||
Reference in New Issue
Block a user