@sarimarcus/content-sites-ui 0.49.2 → 0.49.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/package.json +2 -2
- package/src/composed/CardCarousel.astro +13 -2
- package/src/composed/carousel.ts +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
All packages in the platform release in lockstep; entries are per release version.
|
|
4
4
|
|
|
5
|
+
## 0.49.3 (2026-10-26)
|
|
6
|
+
|
|
7
|
+
- `composed`: `CardCarousel` takes an optional `staticFrom="sm"` and `trackClass`. With `staticFrom` the strip is a carousel on phones only: from `sm` up the track stops scrolling and lays its cards out as `trackClass` says, its controls stay hidden, and an empty header is hidden. Without the new props the markup is unchanged (`render-diff` against 0.49.2: identical HTML). The controller now also removes the track's `tabindex` when there is nothing to scroll, so a carousel that fits is no longer an empty focus stop, and never shows controls for a track whose overflow is visible (SLA-3515).
|
|
8
|
+
|
|
5
9
|
## 0.49.2 (2026-10-26)
|
|
6
10
|
|
|
7
11
|
- Analytics: a same-origin link inside a `[data-track-zone]` element now fires `internal_link_click` with the zone as `link_block`, so a page tracks clicks per section without tagging every card (SLA-3512).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sarimarcus/content-sites-ui",
|
|
3
|
-
"version": "0.49.
|
|
3
|
+
"version": "0.49.3",
|
|
4
4
|
"description": "Universal Astro UI components, layout shell and design tokens shared by the content sites.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -50,6 +50,6 @@
|
|
|
50
50
|
"@lucide/astro": "^1.23.0",
|
|
51
51
|
"astro": "^7.0.6",
|
|
52
52
|
"tailwindcss": "^4.1.18",
|
|
53
|
-
"@sarimarcus/content-sites-core": "0.49.
|
|
53
|
+
"@sarimarcus/content-sites-core": "0.49.3"
|
|
54
54
|
}
|
|
55
55
|
}
|
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
* The header always renders so the arrows exist even under a caller's own heading; the view-all link shows at every
|
|
9
9
|
* width, so a capped carousel always offers an onward path (SLA-2368). The active dot takes `--carousel-dot` when the
|
|
10
10
|
* site defines it (default: the primary role).
|
|
11
|
+
*
|
|
12
|
+
* `staticFrom="sm"` keeps the strip a carousel on phones only: from `sm` up the track stops scrolling and lays its
|
|
13
|
+
* cards out as `trackClass` says (e.g. `sm:grid sm:grid-cols-3`; give the cards `sm:w-auto`), and the controls
|
|
14
|
+
* stay hidden. A header with nothing in it is hidden from `sm` up too.
|
|
11
15
|
*/
|
|
12
16
|
import Icon from '../primitives/Icon.astro';
|
|
13
17
|
import { deterministicId } from '@sarimarcus/content-sites-core/dom';
|
|
@@ -36,6 +40,10 @@ interface Props {
|
|
|
36
40
|
/** Accessible names of the arrows, given the carousel's name (undefined when it has none). */
|
|
37
41
|
previousLabel?: (name: string | undefined) => string;
|
|
38
42
|
nextLabel?: (name: string | undefined) => string;
|
|
43
|
+
/** From this breakpoint up the track stops scrolling and becomes a static layout (see the header comment). */
|
|
44
|
+
staticFrom?: 'sm';
|
|
45
|
+
/** Extra classes on the track, e.g. the static layout's grid. */
|
|
46
|
+
trackClass?: string;
|
|
39
47
|
class?: string;
|
|
40
48
|
}
|
|
41
49
|
|
|
@@ -51,6 +59,8 @@ const {
|
|
|
51
59
|
regionLabel = LABELS.cardCarousel.regionLabel,
|
|
52
60
|
previousLabel = LABELS.cardCarousel.previousLabel,
|
|
53
61
|
nextLabel = LABELS.cardCarousel.nextLabel,
|
|
62
|
+
staticFrom,
|
|
63
|
+
trackClass: extraTrackClass,
|
|
54
64
|
class: className,
|
|
55
65
|
} = Astro.props;
|
|
56
66
|
|
|
@@ -66,10 +76,11 @@ const arrowClass =
|
|
|
66
76
|
// The track stays swipable with no scrollbar; it is a keyboard focus stop, so it draws its own ring.
|
|
67
77
|
const trackClass =
|
|
68
78
|
'-mx-4 flex gap-4 overflow-x-auto scroll-px-4 px-4 py-1.5 snap-x snap-mandatory sm:mx-0 sm:scroll-px-0 sm:px-0 scrollbar-hide focus-visible:rounded-lg focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary';
|
|
79
|
+
const emptyHeader = !heading && !description && !viewAllHref && !Astro.slots.has('header-note');
|
|
69
80
|
---
|
|
70
81
|
|
|
71
82
|
<div id={id} data-carousel={containerId} class:list={['scroll-mt-28', className]}>
|
|
72
|
-
<div class=
|
|
83
|
+
<div class:list={['mb-5 flex items-end justify-between gap-4', staticFrom === 'sm' && emptyHeader && 'sm:hidden']}>
|
|
73
84
|
<div class="min-w-0 flex-1">
|
|
74
85
|
{heading && (
|
|
75
86
|
<HeadingTag class={headingClass ?? 'font-display text-2xl font-medium sm:text-3xl'}>{heading}</HeadingTag>
|
|
@@ -114,7 +125,7 @@ const trackClass =
|
|
|
114
125
|
<div
|
|
115
126
|
id={trackId}
|
|
116
127
|
data-carousel-track
|
|
117
|
-
class={trackClass}
|
|
128
|
+
class:list={[trackClass, staticFrom === 'sm' && 'sm:overflow-visible sm:snap-none sm:py-0', extraTrackClass]}
|
|
118
129
|
aria-label={ariaLabel ?? heading ?? regionLabel}
|
|
119
130
|
role="group"
|
|
120
131
|
tabindex="0"
|
package/src/composed/carousel.ts
CHANGED
|
@@ -40,7 +40,8 @@ function initCarousel(section: HTMLElement): void {
|
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
// A static layout (staticFrom) can still overflow visibly; it never scrolls, so it never gets controls.
|
|
44
|
+
const isScrollable = () => getComputedStyle(track).overflowX !== 'visible' && track.scrollWidth - track.clientWidth > EDGE_SLOP;
|
|
44
45
|
|
|
45
46
|
function updateUI(idx: number, atLeft?: number): void {
|
|
46
47
|
const left = typeof atLeft === 'number' ? atLeft : track!.scrollLeft;
|
|
@@ -103,6 +104,9 @@ function initCarousel(section: HTMLElement): void {
|
|
|
103
104
|
arrowsWrap?.classList.toggle('flex', show);
|
|
104
105
|
dotsWrap?.classList.toggle('hidden', !show);
|
|
105
106
|
dotsWrap?.classList.toggle('flex', show);
|
|
107
|
+
// A track with nothing to scroll is not a focus stop.
|
|
108
|
+
if (show) track.setAttribute('tabindex', '0');
|
|
109
|
+
else if (document.activeElement !== track) track.removeAttribute('tabindex');
|
|
106
110
|
}
|
|
107
111
|
|
|
108
112
|
if ('ResizeObserver' in window) {
|