diff --git a/.changeset/gallery-single-slide.md b/.changeset/gallery-single-slide.md new file mode 100644 index 000000000..b8ced5a4f --- /dev/null +++ b/.changeset/gallery-single-slide.md @@ -0,0 +1,5 @@ +--- +"fulldev-ui": patch +--- + +In Liquid, a carousel with `data-slides='single'` exposes only its shown slide to the keyboard and screen readers, as a product gallery needs. Before, a gallery whose width had a fraction of a pixel also exposed the next slide at load. Without the attribute, every slide in view stays exposed, as in a row of cards. A Liquid rating can now show part of a star: a `rating__fill` with a width, such as 50%, clips its star instead of shrinking it. diff --git a/liquid/assets/ui-carousel.js b/liquid/assets/ui-carousel.js index b8fdd86c7..181173e27 100644 --- a/liquid/assets/ui-carousel.js +++ b/liquid/assets/ui-carousel.js @@ -48,8 +48,11 @@ export function initializeCarousel(root) { } const target = hash ? document.getElementById(hash) : null; const linked = target ? items().findIndex((item) => item.contains(target)) : -1; + // A row of cards exposes every card that is in view. A gallery that shows one slide at a time sets + // data-slides='single', so only the shown slide is exposed, also when a fractional width leaves a + // sliver of the next one in view. const carousel = createCarousel(root, { - slides: 'multiple', + slides: root.dataset.slides === 'single' ? 'single' : 'multiple', drag: true, loop: false, ...(linked >= 0 ? { defaultIndex: linked } : {}), diff --git a/liquid/assets/ui-manifest.json b/liquid/assets/ui-manifest.json index db04e316d..67ae83188 100644 --- a/liquid/assets/ui-manifest.json +++ b/liquid/assets/ui-manifest.json @@ -5,7 +5,7 @@ "snippets/ui-base.liquid": "bc55195b5b6c82e63deeeed1255fd19b434c47866815f82b95b9202421256d34", "snippets/ui-init.liquid": "98f56067cf51e4cb2cd3e10ede7c00304c73ce57fe5b5a0270c0d8a9e448f7af", "assets/ui-licenses.json": "874a6f264f1503b2e577aee651e7285fd6ac808f56cadf8c7d58914bf2396f49", - "assets/ui-carousel.js": "749ad4112b6b2506386a6fa6c4b111ae87b22f85838cfd2f5e249631d1115b55", + "assets/ui-carousel.js": "34bb85998bff45a319b99a6f0e5e86ccb44295a95d3aff1a38b5aca2e7ef5caf", "assets/ui-controls.js": "69abd94c22f5c8307f0d86d9f8be3b6724adb82778fc7021aafd33ba3b4c3789", "assets/ui-lifecycle.js": "78c975473620171c01b1289bf5cdce56a5626c847437fa5168fb91a4300260d6", "assets/ui-start.js": "738d7e171b5d7993bfd0a169e4382b2db08340f52a87059b94d27e1fe3606500", @@ -49,7 +49,7 @@ "snippets/ui-logo.liquid": "5d6de7be3f7aab9e05c9533afef39ea0e9dce1b4ee12a13bf7b82780c973b126", "snippets/ui-kbd.liquid": "024f34ed2932d183671f7fa44ff724a70ec17b766cf7e0d3f565f46f33ab2cf2", "snippets/ui-rating.liquid": "aa57adc5a5508b368da78023b242694e6ce924b6e9e5407c141a5030a414bf1d", - "assets/ui-rating.css": "e5efea2a9edaea78522f20ebd9e9d01abe8a2fcd310c193239adf80ec33b4975", + "assets/ui-rating.css": "f7edd1728c13ec0cc351e09cebd7fc13abb4aca7cbe4e45122b41a1f9e6b377c", "snippets/ui-tooltip.liquid": "d2863a0da3090c73dda10d8615b84fc50fab64373a466fbf4e4e743cfb083c96", "snippets/ui-avatar.liquid": "9bfb5d5f535857cc45f31afbc91c855e94972bab07ad3b4fe2dc0d241106385d", "snippets/ui-empty.liquid": "0e7fb5b68d50abcf7213304034762b4dd535c791dd6f4dc517100145e04b0cde", diff --git a/liquid/assets/ui-rating.css b/liquid/assets/ui-rating.css index 5d2154078..898d7428b 100644 --- a/liquid/assets/ui-rating.css +++ b/liquid/assets/ui-rating.css @@ -11,9 +11,12 @@ height: calc(var(--spacing) * 4); color: color-mix(in oklch, var(--muted-foreground) 25%, transparent); } +/* A star keeps its size inside a fill, so a fill with a width, such as 50%, shows part of it. */ .rating__star svg { - width: 100%; - height: 100%; + flex: none; + width: calc(var(--spacing) * 4); + max-width: none; + height: calc(var(--spacing) * 4); } .rating__fill { position: absolute; diff --git a/liquid/examples/carousel.liquid b/liquid/examples/carousel.liquid index 3a58f2901..9cc3a72ed 100644 --- a/liquid/examples/carousel.liquid +++ b/liquid/examples/carousel.liquid @@ -11,7 +11,7 @@ > -
+