introduce fluid spatial dimensions via css clamp for responsive padding and gap calculations#624
Conversation
|
This is not what I meant. I meant to
This is similar to what we already do in https://github.com/Zenmo/lux-website/blob/main/site/src/commonTest/kotlin/TextTest.kt And then repeat this test with a few viewport widths. |
|
ha okay. I see what you mean now, you want us to test the actual browser layout rendering across viewports. appreciate the extra notes!! |
…ing and gap calculations
| Div(attrs = Modifier.padding(leftRight = spacing.horizontalPadding).toAttrs()) {} | ||
| } | ||
| assertEquals( | ||
| expected = expectedClamp(minPx = 15.0, maxPx = 250.0), |
There was a problem hiding this comment.
I would hardcode the expected numbers, especially for the narrow and wide viewports.
There was a problem hiding this comment.
hardcoding didn't work. the narrow and wide tests both failed with the same actual value regardless of the requested width:
Expected <15> with absolute tolerance <1>, actual <96.6768>
Expected <250> with absolute tolerance <1>, actual <96.6768>
window.resizeTo() does absolutely nothing in the headless chrome/karma environment it seems.
96.68px is what the clamp gives at the fixed default viewport (~765px). expectedClamp() helper reads window.innerWidth at runtime, so both sides always agreed.
the tests passed but weren't verifying narrow/wide, can this even be fixed without a real browser environment? or should i remove them?
|
How are you even running the test? I have an error that webpack doesn't understand I think we are running into several limitations of the current test setup. I think the best approach is to start from ground up with a different testing skeleton, and rewrite the tests for the new situation. But this is a bunch of work and it doesn't help us now.
Playwright or Puppeteer can do different viewports just fine: import { chromium } from "playwright";
const browser = await chromium.launch({ headless: true });
const context = await browser.newContext({
viewport: {
width: 400,
height: 768,
},
});
const page = await context.newPage();
await page.goto("http://localhost:8080");
console.log(await page.evaluate(() => window.innerWidth));
await page.setViewportSize({ width: 890, height: 768 });
I would rewrite the tests so they no longer succeed when they should be failing. And then mark them as And then merge this and forget about it. |
|
marked them @ignore with a note pointing to Playwright and moving on 🤷 |
Our layout containers (
SectionContainerStyleand its variants) currently rely on verbose breakpoint blocks (ZERO through XL) to adjust padding and gaps.This PR introduces
SiteFluidSpacing, a centralized configuration that automatically handles responsive spacing. By usingCSS clamp()andcalc()under the hood, it replaces rigid media queries with fluid scaling between our 480px and 1300px viewports.