Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/gallery-single-slide.md
Original file line number Diff line number Diff line change
@@ -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.
5 changes: 4 additions & 1 deletion liquid/assets/ui-carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 } : {}),
Expand Down
4 changes: 2 additions & 2 deletions liquid/assets/ui-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
7 changes: 5 additions & 2 deletions liquid/assets/ui-rating.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion liquid/examples/carousel.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
><button data-slot='carousel-next' data-button data-variant='outline' type='button' hidden>Next</button>
</section>

<section data-slot='carousel' aria-label='Product images' style='margin-top:48px'>
<section data-slot='carousel' data-slides='single' aria-label='Product images' style='margin-top:48px'>
<div data-slot='carousel-content'>
<div data-slot='carousel-item' id='gallery-image-1'>
<div data-slot='aspect-ratio' data-variant='framed' style='--ratio:4/3;background:var(--muted)'>
Expand Down
19 changes: 11 additions & 8 deletions liquid/examples/rating.liquid
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
<div data-slot='rating' aria-label='Example rating: 4 out of 5' role='img'>
<div data-slot='rating' aria-label='Example rating: 4.5 out of 5' role='img'>
{% for number in (1..5) %}
<span class='rating__star' aria-hidden='true'>
<svg viewBox='0 0 24 24' fill='currentColor'>
<path d="m12 2 3 6 7 1-5 5 1 7-6-3-6 3 1-7-5-5 7-1Z"/>
</svg>
{% if number < 5 -%}
<span class='rating__fill'>
<svg viewBox='0 0 24 24' fill='currentColor'>
<path d="m12 2 3 6 7 1-5 5 1 7-6-3-6 3 1-7-5-5 7-1Z"/>
</svg>
</span>
{%- endif %}
<span
class='rating__fill'
{% if number == 5 %}
style='width: 50%'
{% endif %}
>
<svg viewBox='0 0 24 24' fill='currentColor'>
<path d="m12 2 3 6 7 1-5 5 1 7-6-3-6 3 1-7-5-5 7-1Z"/>
</svg>
</span>
</span>
{% endfor %}
<span>Example rating</span>
Expand Down
2 changes: 1 addition & 1 deletion public/r/liquid/components.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/r/liquid/rating.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
{
"path": "assets/ui-rating.css",
"content": "[data-slot='rating'] {\n display: inline-flex;\n align-items: center;\n gap: var(--spacing);\n color: var(--primary);\n}\n.rating__star {\n position: relative;\n display: inline-flex;\n width: calc(var(--spacing) * 4);\n height: calc(var(--spacing) * 4);\n color: color-mix(in oklch, var(--muted-foreground) 25%, transparent);\n}\n.rating__star svg {\n width: 100%;\n height: 100%;\n}\n.rating__fill {\n position: absolute;\n inset: 0;\n overflow: hidden;\n color: var(--primary);\n}\n",
"content": "[data-slot='rating'] {\n display: inline-flex;\n align-items: center;\n gap: var(--spacing);\n color: var(--primary);\n}\n.rating__star {\n position: relative;\n display: inline-flex;\n width: calc(var(--spacing) * 4);\n height: calc(var(--spacing) * 4);\n color: color-mix(in oklch, var(--muted-foreground) 25%, transparent);\n}\n/* A star keeps its size inside a fill, so a fill with a width, such as 50%, shows part of it. */\n.rating__star svg {\n flex: none;\n width: calc(var(--spacing) * 4);\n max-width: none;\n height: calc(var(--spacing) * 4);\n}\n.rating__fill {\n position: absolute;\n inset: 0;\n overflow: hidden;\n color: var(--primary);\n}\n",
"type": "registry:file",
"target": "~/assets/ui-rating.css"
}
Expand Down
2 changes: 1 addition & 1 deletion public/r/liquid/runtime.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"files": [
{
"path": "assets/ui-carousel.js",
"content": "import { createCarousel } from '@data-slot/carousel';\n\n// @data-slot/carousel owns scrolling, snapping, dragging, the arrow keys and the previous and next\n// buttons, and keeps every visible card interactive. It writes English ARIA descriptions and slide\n// labels, so the translated ones from Liquid are put back after binding and slide updates.\nexport function initializeCarousel(root) {\n const content = root.querySelector('[data-slot=\"carousel-content\"]');\n const items = () => [...content.children].filter((item) => item.matches('[data-slot=\"carousel-item\"]'));\n const rootDescription = root.getAttribute('aria-roledescription');\n const descriptions = new WeakMap(items().map((item) => [item, item.getAttribute('aria-roledescription')]));\n let destroyed = false;\n const translate = () => {\n if (destroyed) return;\n if (rootDescription) root.setAttribute('aria-roledescription', rootDescription);\n const slides = items();\n const template = root.dataset.slideLabel;\n slides.forEach((item, index) => {\n const description = descriptions.get(item);\n if (description) item.setAttribute('aria-roledescription', description);\n if (template)\n item.setAttribute('aria-label', template.replace('[index]', index + 1).replace('[total]', slides.length));\n });\n };\n // Observe first to capture authored descriptions before data-slot rewrites them.\n const observer = new MutationObserver((mutations) => {\n for (const mutation of mutations)\n for (const node of mutation.addedNodes)\n if (node instanceof Element && node.matches('[data-slot=\"carousel-item\"]'))\n descriptions.set(node, node.getAttribute('aria-roledescription'));\n queueMicrotask(translate);\n });\n observer.observe(content, { childList: true });\n // A thumbnail can link to its slide's id, which works without JavaScript. Once the controller runs,\n // a plain click only scrolls the carousel, so the page does not jump to the slide.\n const onClick = (event) => {\n const link = event.target instanceof Element ? event.target.closest('a[data-slot=\"carousel-indicator\"]') : null;\n if (!link || link.closest('[data-slot=\"carousel\"]') !== root) return;\n if (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;\n event.preventDefault();\n };\n // A link to a slide or to something in it, such as a thumbnail followed before this module loaded,\n // keeps that slide.\n let hash = location.hash.slice(1);\n try {\n hash = decodeURIComponent(hash);\n } catch {\n // Keep a malformed hash as it is.\n }\n const target = hash ? document.getElementById(hash) : null;\n const linked = target ? items().findIndex((item) => item.contains(target)) : -1;\n const carousel = createCarousel(root, {\n slides: 'multiple',\n drag: true,\n loop: false,\n ...(linked >= 0 ? { defaultIndex: linked } : {}),\n });\n root.addEventListener('click', onClick);\n translate();\n for (const button of root.querySelectorAll('[data-slot=\"carousel-previous\"], [data-slot=\"carousel-next\"]'))\n button.hidden = false;\n const destroy = carousel.destroy.bind(carousel);\n carousel.destroy = () => {\n destroyed = true;\n observer.disconnect();\n root.removeEventListener('click', onClick);\n destroy();\n };\n return carousel;\n}\n",
"content": "import { createCarousel } from '@data-slot/carousel';\n\n// @data-slot/carousel owns scrolling, snapping, dragging, the arrow keys and the previous and next\n// buttons, and keeps every visible card interactive. It writes English ARIA descriptions and slide\n// labels, so the translated ones from Liquid are put back after binding and slide updates.\nexport function initializeCarousel(root) {\n const content = root.querySelector('[data-slot=\"carousel-content\"]');\n const items = () => [...content.children].filter((item) => item.matches('[data-slot=\"carousel-item\"]'));\n const rootDescription = root.getAttribute('aria-roledescription');\n const descriptions = new WeakMap(items().map((item) => [item, item.getAttribute('aria-roledescription')]));\n let destroyed = false;\n const translate = () => {\n if (destroyed) return;\n if (rootDescription) root.setAttribute('aria-roledescription', rootDescription);\n const slides = items();\n const template = root.dataset.slideLabel;\n slides.forEach((item, index) => {\n const description = descriptions.get(item);\n if (description) item.setAttribute('aria-roledescription', description);\n if (template)\n item.setAttribute('aria-label', template.replace('[index]', index + 1).replace('[total]', slides.length));\n });\n };\n // Observe first to capture authored descriptions before data-slot rewrites them.\n const observer = new MutationObserver((mutations) => {\n for (const mutation of mutations)\n for (const node of mutation.addedNodes)\n if (node instanceof Element && node.matches('[data-slot=\"carousel-item\"]'))\n descriptions.set(node, node.getAttribute('aria-roledescription'));\n queueMicrotask(translate);\n });\n observer.observe(content, { childList: true });\n // A thumbnail can link to its slide's id, which works without JavaScript. Once the controller runs,\n // a plain click only scrolls the carousel, so the page does not jump to the slide.\n const onClick = (event) => {\n const link = event.target instanceof Element ? event.target.closest('a[data-slot=\"carousel-indicator\"]') : null;\n if (!link || link.closest('[data-slot=\"carousel\"]') !== root) return;\n if (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;\n event.preventDefault();\n };\n // A link to a slide or to something in it, such as a thumbnail followed before this module loaded,\n // keeps that slide.\n let hash = location.hash.slice(1);\n try {\n hash = decodeURIComponent(hash);\n } catch {\n // Keep a malformed hash as it is.\n }\n const target = hash ? document.getElementById(hash) : null;\n const linked = target ? items().findIndex((item) => item.contains(target)) : -1;\n // A row of cards exposes every card that is in view. A gallery that shows one slide at a time sets\n // data-slides='single', so only the shown slide is exposed, also when a fractional width leaves a\n // sliver of the next one in view.\n const carousel = createCarousel(root, {\n slides: root.dataset.slides === 'single' ? 'single' : 'multiple',\n drag: true,\n loop: false,\n ...(linked >= 0 ? { defaultIndex: linked } : {}),\n });\n root.addEventListener('click', onClick);\n translate();\n for (const button of root.querySelectorAll('[data-slot=\"carousel-previous\"], [data-slot=\"carousel-next\"]'))\n button.hidden = false;\n const destroy = carousel.destroy.bind(carousel);\n carousel.destroy = () => {\n destroyed = true;\n observer.disconnect();\n root.removeEventListener('click', onClick);\n destroy();\n };\n return carousel;\n}\n",
"type": "registry:file",
"target": "~/assets/ui-carousel.js"
},
Expand Down
2 changes: 1 addition & 1 deletion skills/fulldev-ui/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ and the shadcn skill differ, this skill wins.

For Shopify themes, use `https://ui.full.dev/r/liquid/<name>.json` with `shadcn add`; `components` installs the full set. Read [Liquid](https://ui.full.dev/liquid/docs/installation.md). These are universal items with explicit theme targets. Do not run `shadcn init` or add Tailwind to the theme. Render `ui` once in each layout head before theme overrides and other modules. Keep `content_for_header`; load `custom.css` after it. Existing Shopify adapters use `runtime: false` and the exported lifecycle with their own import map. Installed UI stays unchanged; theme settings and commerce code stay local. Native source supports Vega, not the Tailwind preset generator.

For storefront parts, use the library first: `number-field` for quantities, `swatch` in option toggles and filter labels, and `carousel-indicator` thumbnails for a product gallery. Product cards, cart lines and filter panels are compositions of card, item, field, checkbox and badge in the theme.
For storefront parts, use the library first: `number-field` for quantities, `swatch` in option toggles and filter labels, and `carousel-indicator` thumbnails for a product gallery, whose root has `data-slides='single'`. Product cards, cart lines and filter panels are compositions of card, item, field, checkbox and badge in the theme.

## Astro setup

Expand Down
2 changes: 1 addition & 1 deletion src/content/pages/liquid/components/carousel.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ After this install, render these once in the layout head before theme overrides

The preview and its Usage tab render the same native Liquid source. Use `data-slot` for parts, `data-variant` for variants and `data-size` for sizes. Keep your store's labels, translations and Shopify data in your theme.

The second carousel is a product gallery: one slide at a time with `carousel-indicator` thumbnails. Give each indicator the zero-based `data-index` of its slide; the controller scrolls to that slide on click and marks the current one with `aria-current`. The index counts scroll positions, which are the slides when one shows at a time; an indicator without a position is hidden. Give it a width and an aspect ratio; an image inside fills it. Make an indicator a link to its slide's `id` so it also works without JavaScript; once the runtime runs, a plain click scrolls the carousel without moving the page. To show a variant's image, send `carousel:set` with its index: `root.dispatchEvent(new CustomEvent('carousel:set', { detail: { index } }))`.
The second carousel is a product gallery: one slide at a time with `carousel-indicator` thumbnails. Give its root `data-slides='single'`, so only the shown slide is exposed to the keyboard and screen readers; without it, every slide that is in view is, as in a row of cards. Give each indicator the zero-based `data-index` of its slide; the controller scrolls to that slide on click and marks the current one with `aria-current`. The index counts scroll positions, which are the slides when one shows at a time; an indicator without a position is hidden. Give it a width and an aspect ratio; an image inside fills it. Make an indicator a link to its slide's `id` so it also works without JavaScript; once the runtime runs, a plain click scrolls the carousel without moving the page. To show a variant's image, send `carousel:set` with its index: `root.dispatchEvent(new CustomEvent('carousel:set', { detail: { index } }))`.

## Parts

Expand Down
2 changes: 2 additions & 0 deletions src/content/pages/liquid/components/rating.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ After this install, render these once in the layout head before theme overrides

The preview and its Usage tab render the same native Liquid source. Use `data-slot` for parts, `data-variant` for variants and `data-size` for sizes. Keep your store's labels, translations and Shopify data in your theme.

Each star is a `rating__star` with a `rating__fill` over it. A fill shows the whole star; give it a width, such as `style='width: 50%'`, for part of one.

## Parts

`rating`.
Expand Down
Loading