diff --git a/.changeset/fine-baboons-teach.md b/.changeset/fine-baboons-teach.md new file mode 100644 index 0000000000..c815408fbc --- /dev/null +++ b/.changeset/fine-baboons-teach.md @@ -0,0 +1,8 @@ +--- +"@lynx-js/web-style-transformer": patch +"@lynx-js/web-elements": minor +--- + +feat: 1. list adds support for the `sticky` attribute. Now sticky-offset, sticky-top, and sticky-bottom will only take effect when `sticky` is `true`. + +2. Added support for `list-main-axis-gap`, `list-cross-axis-gap`. diff --git a/packages/web-platform/web-elements/src/XList/x-list.css b/packages/web-platform/web-elements/src/XList/x-list.css index b9a024ee1a..ad4e2c82fd 100644 --- a/packages/web-platform/web-elements/src/XList/x-list.css +++ b/packages/web-platform/web-elements/src/XList/x-list.css @@ -8,6 +8,8 @@ x-list { scrollbar-width: none; --list-item-sticky-offset: 0; --list-item-span-count: 0; + --list-main-axis-gap: 0; + --list-cross-axis-gap: 0; } x-list > *:not(list-item) { @@ -29,6 +31,8 @@ x-list::part(content) { overflow: inherit; position: relative; content-visibility: auto; + row-gap: inherit; + column-gap: inherit; } x-list::part(content), x-list::part(slot) { @@ -79,28 +83,33 @@ x-list[scroll-orientation="horizontal"][enable-scroll="false"] { overflow-x: hidden !important; } -list-item[sticky-top], list-item[sticky-bottom] { +x-list[sticky="true"] list-item[sticky-top], +x-list[sticky="true"] list-item[sticky-bottom] { position: sticky; z-index: 1; } -x-list > list-item[sticky-top], x-list > lynx-wrapper > list-item[sticky-top] { +x-list[sticky="true"] > list-item[sticky-top], +x-list[sticky="true"] > lynx-wrapper > list-item[sticky-top] { top: var(--list-item-sticky-offset); } -x-list > list-item[sticky-bottom], -x-list > lynx-wrapper > list-item[sticky-bottom] { +x-list[sticky="true"] > list-item[sticky-bottom], +x-list[sticky="true"] > lynx-wrapper > list-item[sticky-bottom] { bottom: var(--list-item-sticky-offset); } -x-list[scroll-orientation="horizontal"] > list-item[sticky-top], -x-list[scroll-orientation="horizontal"] > lynx-wrapper > list-item[sticky-top] { +x-list[sticky="true"][scroll-orientation="horizontal"] > list-item[sticky-top], +x-list[sticky="true"][scroll-orientation="horizontal"] + > lynx-wrapper + > list-item[sticky-top] { top: unset; left: var(--list-item-sticky-offset); } -x-list[scroll-orientation="horizontal"] > list-item[sticky-bottom], -x-list[scroll-orientation="horizontal"] +x-list[sticky="true"][scroll-orientation="horizontal"] + > list-item[sticky-bottom], +x-list[sticky="true"][scroll-orientation="horizontal"] > lynx-wrapper > list-item[sticky-bottom] { bottom: unset; @@ -141,10 +150,14 @@ x-list[list-type="single"] { display: flex; flex-direction: column; align-items: stretch; + row-gap: var(--list-main-axis-gap); + column-gap: var(--list-cross-axis-gap); } x-list[list-type="single"][scroll-orientation="horizontal"] { flex-direction: row; + row-gap: var(--list-cross-axis-gap); + column-gap: var(--list-main-axis-gap); } /* list-type flow */ @@ -154,6 +167,8 @@ x-list[list-type="flow"]::part(content) { grid-auto-rows: min-content; justify-items: stretch; align-items: start; + grid-row-gap: var(--list-main-axis-gap); + grid-column-gap: var(--list-cross-axis-gap); } x-list[list-type="flow"][scroll-orientation="horizontal"]::part(content) { @@ -162,6 +177,8 @@ x-list[list-type="flow"][scroll-orientation="horizontal"]::part(content) { grid-auto-columns: min-content; justify-items: start; align-items: stretch; + grid-row-gap: var(--list-cross-axis-gap); + grid-column-gap: var(--list-main-axis-gap); } x-list[list-type="flow"] list-item[full-span]:not([full-span="false"]) { diff --git a/packages/web-platform/web-style-transformer/src/transformLynxStyles.ts b/packages/web-platform/web-style-transformer/src/transformLynxStyles.ts index 9ba258f68f..facfa1dc5c 100644 --- a/packages/web-platform/web-style-transformer/src/transformLynxStyles.ts +++ b/packages/web-platform/web-style-transformer/src/transformLynxStyles.ts @@ -268,6 +268,12 @@ const renameRules: { 'flex-basis': [ '--flex-basis', ], + 'list-main-axis-gap': [ + '--list-main-axis-gap', + ], + 'list-cross-axis-gap': [ + '--list-cross-axis-gap', + ], }; export function transformLynxStyles( hypenNameStyles: [string, string][], diff --git a/packages/web-platform/web-tests/tests/web-elements.spec.ts b/packages/web-platform/web-tests/tests/web-elements.spec.ts index 1b62648473..0f58e0ade5 100644 --- a/packages/web-platform/web-tests/tests/web-elements.spec.ts +++ b/packages/web-platform/web-tests/tests/web-elements.spec.ts @@ -2053,7 +2053,17 @@ test.describe('web-elements test suite', () => { await page.mouse.wheel(0, 500); await diffScreenShot(page, title, 'sticky-y-scroll'); }); - test('full-span', async ({ page, browserName }, { titlePath }) => { + test('full-span', async ({ page }, { titlePath }) => { + const title = getTitle(titlePath); + await gotoWebComponentPage(page, title); + await diffScreenShot(page, title, 'index'); + }); + test('axis-gap', async ({ page }, { titlePath }) => { + const title = getTitle(titlePath); + await gotoWebComponentPage(page, title); + await diffScreenShot(page, title, 'index'); + }); + test('axis-gap-flow', async ({ page }, { titlePath }) => { const title = getTitle(titlePath); await gotoWebComponentPage(page, title); await diffScreenShot(page, title, 'index'); diff --git a/packages/web-platform/web-tests/tests/web-elements.spec.ts-snapshots/x-list/axis-gap-flow/index-chromium-linux.png b/packages/web-platform/web-tests/tests/web-elements.spec.ts-snapshots/x-list/axis-gap-flow/index-chromium-linux.png new file mode 100644 index 0000000000..d114ec9aa2 Binary files /dev/null and b/packages/web-platform/web-tests/tests/web-elements.spec.ts-snapshots/x-list/axis-gap-flow/index-chromium-linux.png differ diff --git a/packages/web-platform/web-tests/tests/web-elements.spec.ts-snapshots/x-list/axis-gap-flow/index-firefox-linux.png b/packages/web-platform/web-tests/tests/web-elements.spec.ts-snapshots/x-list/axis-gap-flow/index-firefox-linux.png new file mode 100644 index 0000000000..c1a979e2dd Binary files /dev/null and b/packages/web-platform/web-tests/tests/web-elements.spec.ts-snapshots/x-list/axis-gap-flow/index-firefox-linux.png differ diff --git a/packages/web-platform/web-tests/tests/web-elements.spec.ts-snapshots/x-list/axis-gap-flow/index-webkit-linux.png b/packages/web-platform/web-tests/tests/web-elements.spec.ts-snapshots/x-list/axis-gap-flow/index-webkit-linux.png new file mode 100644 index 0000000000..f8afda04a1 Binary files /dev/null and b/packages/web-platform/web-tests/tests/web-elements.spec.ts-snapshots/x-list/axis-gap-flow/index-webkit-linux.png differ diff --git a/packages/web-platform/web-tests/tests/web-elements.spec.ts-snapshots/x-list/axis-gap/index-chromium-linux.png b/packages/web-platform/web-tests/tests/web-elements.spec.ts-snapshots/x-list/axis-gap/index-chromium-linux.png new file mode 100644 index 0000000000..6109c98c20 Binary files /dev/null and b/packages/web-platform/web-tests/tests/web-elements.spec.ts-snapshots/x-list/axis-gap/index-chromium-linux.png differ diff --git a/packages/web-platform/web-tests/tests/web-elements.spec.ts-snapshots/x-list/axis-gap/index-firefox-linux.png b/packages/web-platform/web-tests/tests/web-elements.spec.ts-snapshots/x-list/axis-gap/index-firefox-linux.png new file mode 100644 index 0000000000..c2e3842364 Binary files /dev/null and b/packages/web-platform/web-tests/tests/web-elements.spec.ts-snapshots/x-list/axis-gap/index-firefox-linux.png differ diff --git a/packages/web-platform/web-tests/tests/web-elements.spec.ts-snapshots/x-list/axis-gap/index-webkit-linux.png b/packages/web-platform/web-tests/tests/web-elements.spec.ts-snapshots/x-list/axis-gap/index-webkit-linux.png new file mode 100644 index 0000000000..135a417268 Binary files /dev/null and b/packages/web-platform/web-tests/tests/web-elements.spec.ts-snapshots/x-list/axis-gap/index-webkit-linux.png differ diff --git a/packages/web-platform/web-tests/tests/web-elements/x-list/axis-gap-flow.html b/packages/web-platform/web-tests/tests/web-elements/x-list/axis-gap-flow.html new file mode 100644 index 0000000000..217029d65c --- /dev/null +++ b/packages/web-platform/web-tests/tests/web-elements/x-list/axis-gap-flow.html @@ -0,0 +1,171 @@ + + + + + + web playground + + + + + + + + + + + + + + + + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + + + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + + + + diff --git a/packages/web-platform/web-tests/tests/web-elements/x-list/axis-gap.html b/packages/web-platform/web-tests/tests/web-elements/x-list/axis-gap.html new file mode 100644 index 0000000000..ce31e9fe52 --- /dev/null +++ b/packages/web-platform/web-tests/tests/web-elements/x-list/axis-gap.html @@ -0,0 +1,169 @@ + + + + + + web playground + + + + + + + + + + + + + + + + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + + + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + + + + diff --git a/packages/web-platform/web-tests/tests/web-elements/x-list/sticky-flow.html b/packages/web-platform/web-tests/tests/web-elements/x-list/sticky-flow.html index 3846eab443..958d79b437 100644 --- a/packages/web-platform/web-tests/tests/web-elements/x-list/sticky-flow.html +++ b/packages/web-platform/web-tests/tests/web-elements/x-list/sticky-flow.html @@ -53,7 +53,7 @@ - + - + 1 - + 1