mirror of
https://github.com/Kpa-clawbot/meshcore-analyzer.git
synced 2026-05-12 06:24:42 +00:00
85b8c8115a
## Summary Makes the channels page sidebar + message area fluid as part of the parent #1050 fluid-layout effort. Replaces the hardcoded `.ch-sidebar { width: 280px; min-width: 280px }` with `width: clamp(220px, 22vw, 320px); min-width: 220px`. Adds an `@container` query (via `container-type: inline-size` on `.ch-layout`) that stacks the sidebar above the message area when the channels page itself is narrow (≤700px container width) — independent of the global viewport, so it adapts even when an outer panel is consuming width. Removes the legacy `@media (max-width: 900px)` fixed 220px override; the clamp + container query handle that range. `.ch-main` already used `flex: 1`, so it absorbs all remaining width including ultrawides. The existing mobile (≤640px) overlay rules and the JS resize handle in `channels.js` are untouched and still work (user drag still wins via inline width). Fixes #1057. ## Scope - `public/style.css` — channels section only - (no `public/channels.js` changes needed) ## Tests TDD: red commit (failing tests) → green commit (implementation). - `test-channel-fluid-layout.js` (new): static CSS assertions - `.ch-sidebar` uses `clamp()` for width (not fixed px) - `.ch-sidebar` keeps a sane `min-width` (200–280px) - `.ch-main` keeps `flex: 1` - `.ch-layout` declares `container-type` (container query root) - `@container` rule scopes channels stacking - legacy `@media (max-width: 900px) .ch-sidebar { width: 220px }` is gone - `test-channel-fluid-e2e.js` (new): Playwright E2E at 768 / 1080 / 1440 / 1920 (wide) and 480 (narrow). Asserts: - no horizontal scroll on the body - sidebar AND message area both visible side-by-side at ≥768px - sidebar consumes ≤45% of viewport, main ≥40% - at 480px the layout stacks (or overlays) — no overflow Wired into `test-all.sh` and the unit + e2e steps of `.github/workflows/deploy.yml`. ## Verification - Static unit test: 6/6 pass on the green commit, 4/6 fail on the red commit (only the two trivially-true assertions pass). - Local Go server boot: `corescope-server` serves the updated `style.css` containing `container-type: inline-size`, `clamp(220px, 22vw, 320px)`, and `@container chlayout (max-width: 700px)`. - Local Chromium on the dev sandbox is musl-incompatible (Playwright fallback build crashes with `Error relocating ...: posix_fallocate64: symbol not found`), so the E2E was not run locally. CI will run it on Ubuntu runners. --------- Co-authored-by: clawbot <clawbot@example.com> Co-authored-by: meshcore-bot <bot@meshcore.local>
93 lines
3.8 KiB
JavaScript
93 lines
3.8 KiB
JavaScript
/**
|
|
* Issue #1057 — Channels sidebar + message area fluidity (static assertions).
|
|
*
|
|
* Verifies that public/style.css makes the channels sidebar fluid rather
|
|
* than locked at fixed pixel widths, that the message area uses remaining
|
|
* space, and that narrow stacking is driven by a container query (not a
|
|
* hardcoded fixed-px breakpoint baked into the channels layout).
|
|
*
|
|
* Companion E2E (real viewport assertions): test-channel-fluid-e2e.js.
|
|
*/
|
|
'use strict';
|
|
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const assert = require('assert');
|
|
|
|
const css = fs.readFileSync(path.join(__dirname, 'public/style.css'), 'utf8');
|
|
|
|
let passed = 0, failed = 0;
|
|
function test(name, fn) {
|
|
try { fn(); passed++; console.log(` ✅ ${name}`); }
|
|
catch (e) { failed++; console.log(` ❌ ${name}: ${e.message}`); }
|
|
}
|
|
|
|
// Helper: extract the first matching rule body for a selector (no nesting parser, simple regex).
|
|
function ruleBody(selector) {
|
|
// Match selector that's NOT preceded by a non-space CSS-name char (avoids matching .ch-sidebar-foo when looking for .ch-sidebar).
|
|
const re = new RegExp(
|
|
'(?:^|[^a-zA-Z0-9_-])' + selector.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&') + '\\s*\\{([^}]*)\\}'
|
|
);
|
|
const m = css.match(re);
|
|
return m ? m[1] : null;
|
|
}
|
|
|
|
console.log('\n=== #1057 Channels sidebar fluid width ===');
|
|
|
|
test('.ch-sidebar default rule uses clamp() for width (not a fixed px)', () => {
|
|
const body = ruleBody('.ch-sidebar');
|
|
assert.ok(body, '.ch-sidebar rule not found');
|
|
assert.ok(/width\s*:\s*clamp\s*\(/.test(body),
|
|
`.ch-sidebar should use width: clamp(...); got: ${body.trim()}`);
|
|
});
|
|
|
|
test('.ch-sidebar declares a sane min-width (>=200px)', () => {
|
|
const body = ruleBody('.ch-sidebar');
|
|
assert.ok(body, '.ch-sidebar rule not found');
|
|
// min-width may be a literal px or part of clamp's first arg.
|
|
const minMatch = body.match(/min-width\s*:\s*(\d+)px/);
|
|
assert.ok(minMatch, '.ch-sidebar should declare min-width');
|
|
const px = parseInt(minMatch[1], 10);
|
|
assert.ok(px >= 200 && px <= 280, `min-width should be 200..280px (got ${px}px)`);
|
|
});
|
|
|
|
console.log('\n=== #1057 Message area fills remaining width ===');
|
|
|
|
test('.ch-main keeps flex:1 (uses remaining width on wide screens)', () => {
|
|
const body = ruleBody('.ch-main');
|
|
assert.ok(body, '.ch-main rule not found');
|
|
assert.ok(/flex\s*:\s*1\b/.test(body),
|
|
'.ch-main should use flex: 1 to fill remaining width');
|
|
});
|
|
|
|
console.log('\n=== #1057 Narrow stacking via container query (not hardcoded px) ===');
|
|
|
|
test('style.css declares a container query for the channels layout', () => {
|
|
// Either container-type or container shorthand on .ch-layout.
|
|
const layout = ruleBody('.ch-layout');
|
|
assert.ok(layout, '.ch-layout rule not found');
|
|
assert.ok(/container(-type|-name|\s*:)/.test(layout),
|
|
'.ch-layout should declare container-type/container for container queries');
|
|
});
|
|
|
|
test('style.css contains an @container rule that targets the channels sidebar', () => {
|
|
// Look for "@container ... .ch-sidebar" anywhere.
|
|
const re = /@container[^{]*\{[\s\S]*?\.ch-(sidebar|layout|main)[^{]*\{/;
|
|
assert.ok(re.test(css),
|
|
'expected an @container rule scoping .ch-sidebar/.ch-layout/.ch-main');
|
|
});
|
|
|
|
test('removed legacy fixed 220px override at @media (max-width: 900px) for .ch-sidebar', () => {
|
|
// The old block: @media (max-width: 900px){ ... .ch-sidebar { width: 220px; min-width: 220px; } ... }
|
|
// After fluid migration this hardcoded sub-rule should be gone (the clamp+container query handle it).
|
|
const m = css.match(/@media[^{]*max-width:\s*900px[^{]*\{[\s\S]*?\n\}/);
|
|
if (m) {
|
|
assert.ok(!/\.ch-sidebar\s*\{[^}]*width\s*:\s*220px/.test(m[0]),
|
|
'legacy hardcoded .ch-sidebar width:220px override should be removed');
|
|
}
|
|
});
|
|
|
|
console.log('\n=== Summary ===');
|
|
console.log(`${passed} passed, ${failed} failed`);
|
|
process.exit(failed ? 1 : 0);
|