diff --git a/.changeset/red-pears-kiss.md b/.changeset/red-pears-kiss.md new file mode 100644 index 0000000000..ec448fd976 --- /dev/null +++ b/.changeset/red-pears-kiss.md @@ -0,0 +1,5 @@ +--- +"@lynx-js/web-core": patch +--- + +fix: transformVH not work with cqw unit as the base length diff --git a/.changeset/warm-zoos-prove.md b/.changeset/warm-zoos-prove.md new file mode 100644 index 0000000000..b137199420 --- /dev/null +++ b/.changeset/warm-zoos-prove.md @@ -0,0 +1,5 @@ +--- +"@lynx-js/web-core": patch +--- + +fix: the default value of rpx is supposed to be 1/750 cqw diff --git a/packages/web-platform/web-core-e2e/tests/reactlynx.spec.ts b/packages/web-platform/web-core-e2e/tests/reactlynx.spec.ts index bc4fe738e3..c93d3eae21 100644 --- a/packages/web-platform/web-core-e2e/tests/reactlynx.spec.ts +++ b/packages/web-platform/web-core-e2e/tests/reactlynx.spec.ts @@ -394,6 +394,7 @@ test.describe('reactlynx3 tests', () => { const lynxView = await page.locator('lynx-view'); await lynxView.evaluate((node) => { node.style.width = '50px'; + node.style.setProperty('--rpx-unit', '1cqw'); }); const target = await page.locator('#target'); await expect(target).toHaveCSS('height', '10px'); // 20cqw, 50 / 100 * 20 = 10px @@ -406,6 +407,7 @@ test.describe('reactlynx3 tests', () => { const lynxView = await page.locator('lynx-view'); await lynxView.evaluate((node) => { node.style.width = '50px'; + node.style.setProperty('--rpx-unit', '1cqw'); }); const target = await page.locator('#target'); await expect(target).toHaveCSS('height', '10px'); // 20cqw, 50 / 100 * 20 = 10px @@ -450,7 +452,25 @@ test.describe('reactlynx3 tests', () => { await wait(500); // Wait for the reload to rebuild the CSS properly await expect(target).not.toHaveCSS('width', '25px'); await expect(target).not.toHaveCSS('height', '50px'); + + // now make sure the cqw/cqh work + await lynxView.evaluate((node: any) => { + node.transformVW = true; + node.transformVH = true; + node.style.height = '500px'; + node.style.width = '500px'; + node.style.minHeight = '500px'; + node.style.minWidth = '500px'; + node.style.setProperty('--vh-unit', '1cqh'); + node.style.setProperty('--vw-unit', '1cqw'); + node.reload(); + }); + await wait(500); // Wait for the reload to rebuild the CSS properly + + await expect(target).toHaveCSS('width', '250px'); + await expect(target).toHaveCSS('height', '250px'); }); + test('basic-image', async ({ page }, { title }) => { await goto(page, title); await wait(100); diff --git a/packages/web-platform/web-core/css/index.css b/packages/web-platform/web-core/css/index.css index d73bf259ef..c58cf6fbaf 100644 --- a/packages/web-platform/web-core/css/index.css +++ b/packages/web-platform/web-core/css/index.css @@ -10,10 +10,14 @@ lynx-view { width: 100%; container-name: lynx-view; container-type: inline-size; - --rpx-unit: 1cqw; + --rpx-unit: calc(1cqw / 7.5); --ppx-unit: 1cqw; - --vw-unit: 1vw; - --vh-unit: 1vh; + --vw-unit: 1cqw; + --vh-unit: 1cqh; +} + +lynx-view[transform-vh] { + container-type: size; } lynx-view[ssr] { @@ -40,31 +44,6 @@ lynx-view::part(page) { --vh-unit: inherit; } -@property --rem-unit { - syntax: ""; - inherits: true; -} - -@property --rpx-unit { - syntax: ""; - inherits: true; -} - -@property --ppx-unit { - syntax: ""; - inherits: true; -} - -@property --vw-unit { - syntax: ""; - inherits: true; -} - -@property --vh-unit { - syntax: ""; - inherits: true; -} - @property --lynx-display { syntax: "linear | flex"; inherits: false;