@slipstream-ui/core 0.12.0 → 0.13.0
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/dist/index.d.mts +177 -2
- package/dist/index.d.ts +177 -2
- package/dist/index.js +262 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +254 -9
- package/dist/index.mjs.map +1 -1
- package/dist/manifests/accordion.manifest.json +1 -1
- package/dist/manifests/alert.manifest.json +1 -1
- package/dist/manifests/announcement-bar.manifest.json +1 -1
- package/dist/manifests/app-shell.manifest.json +1 -1
- package/dist/manifests/applied-filters.manifest.json +1 -1
- package/dist/manifests/article-card.manifest.json +1 -1
- package/dist/manifests/auth-layout.manifest.json +1 -1
- package/dist/manifests/autocomplete.manifest.json +1 -1
- package/dist/manifests/avatar.manifest.json +1 -1
- package/dist/manifests/badge.manifest.json +1 -1
- package/dist/manifests/block.manifest.json +1 -1
- package/dist/manifests/bottom-nav.manifest.json +1 -1
- package/dist/manifests/breadcrumb.manifest.json +1 -1
- package/dist/manifests/button-group.manifest.json +1 -1
- package/dist/manifests/button.manifest.json +1 -1
- package/dist/manifests/calendar.manifest.json +1 -1
- package/dist/manifests/card.manifest.json +1 -1
- package/dist/manifests/checkbox.manifest.json +1 -1
- package/dist/manifests/comparison-table.manifest.json +1 -1
- package/dist/manifests/confirm-dialog.manifest.json +1 -1
- package/dist/manifests/consent-banner.manifest.json +1 -1
- package/dist/manifests/contact-strip.manifest.json +1 -1
- package/dist/manifests/container.manifest.json +1 -1
- package/dist/manifests/cover-image.manifest.json +1 -1
- package/dist/manifests/cta-section.manifest.json +1 -1
- package/dist/manifests/data-table.manifest.json +1 -1
- package/dist/manifests/date-picker-popover.manifest.json +1 -1
- package/dist/manifests/date-picker.manifest.json +1 -1
- package/dist/manifests/date-range-picker.manifest.json +1 -1
- package/dist/manifests/deal-card.manifest.json +1 -1
- package/dist/manifests/dialog.manifest.json +1 -1
- package/dist/manifests/document-card.manifest.json +1 -1
- package/dist/manifests/drawer.manifest.json +1 -1
- package/dist/manifests/empty-state.manifest.json +1 -1
- package/dist/manifests/entity-card.manifest.json +1 -1
- package/dist/manifests/feature-grid.manifest.json +1 -1
- package/dist/manifests/feature-row.manifest.json +1 -1
- package/dist/manifests/fieldset.manifest.json +1 -1
- package/dist/manifests/figure.manifest.json +105 -0
- package/dist/manifests/file-upload.manifest.json +1 -1
- package/dist/manifests/filter-bar.manifest.json +1 -1
- package/dist/manifests/filter-chips.manifest.json +1 -1
- package/dist/manifests/filter-panel.manifest.json +1 -1
- package/dist/manifests/flex.manifest.json +1 -1
- package/dist/manifests/form-field.manifest.json +1 -1
- package/dist/manifests/form-layout.manifest.json +1 -1
- package/dist/manifests/form.manifest.json +1 -1
- package/dist/manifests/grid.manifest.json +1 -1
- package/dist/manifests/heading.manifest.json +1 -1
- package/dist/manifests/hero.manifest.json +1 -1
- package/dist/manifests/icon-button.manifest.json +101 -0
- package/dist/manifests/icon-tile.manifest.json +107 -0
- package/dist/manifests/icon.manifest.json +119 -0
- package/dist/manifests/image.manifest.json +1 -1
- package/dist/manifests/input-group.manifest.json +1 -1
- package/dist/manifests/input.manifest.json +1 -1
- package/dist/manifests/label.manifest.json +1 -1
- package/dist/manifests/link-tabs.manifest.json +1 -1
- package/dist/manifests/link.manifest.json +1 -1
- package/dist/manifests/list-toolbar.manifest.json +1 -1
- package/dist/manifests/list.manifest.json +1 -1
- package/dist/manifests/load-more.manifest.json +1 -1
- package/dist/manifests/logo-cloud.manifest.json +1 -1
- package/dist/manifests/media-card.manifest.json +1 -1
- package/dist/manifests/media.manifest.json +142 -0
- package/dist/manifests/menu.manifest.json +1 -1
- package/dist/manifests/metric-card.manifest.json +1 -1
- package/dist/manifests/month-schedule.manifest.json +1 -1
- package/dist/manifests/multi-select.manifest.json +1 -1
- package/dist/manifests/newsletter.manifest.json +1 -1
- package/dist/manifests/page-header.manifest.json +1 -1
- package/dist/manifests/pagination.manifest.json +1 -1
- package/dist/manifests/password-input.manifest.json +1 -1
- package/dist/manifests/popover.manifest.json +1 -1
- package/dist/manifests/process-steps.manifest.json +1 -1
- package/dist/manifests/progress.manifest.json +1 -1
- package/dist/manifests/prose.manifest.json +1 -1
- package/dist/manifests/radio.manifest.json +1 -1
- package/dist/manifests/range-slider.manifest.json +1 -1
- package/dist/manifests/search.manifest.json +1 -1
- package/dist/manifests/section-heading.manifest.json +1 -1
- package/dist/manifests/section.manifest.json +1 -1
- package/dist/manifests/segmented-control.manifest.json +1 -1
- package/dist/manifests/select-menu.manifest.json +1 -1
- package/dist/manifests/select.manifest.json +1 -1
- package/dist/manifests/separator.manifest.json +1 -1
- package/dist/manifests/site-footer.manifest.json +1 -1
- package/dist/manifests/site-header.manifest.json +1 -1
- package/dist/manifests/skeleton.manifest.json +1 -1
- package/dist/manifests/social-links.manifest.json +120 -0
- package/dist/manifests/spinner.manifest.json +1 -1
- package/dist/manifests/stat-band.manifest.json +1 -1
- package/dist/manifests/stepper.manifest.json +1 -1
- package/dist/manifests/switch.manifest.json +1 -1
- package/dist/manifests/table-card.manifest.json +1 -1
- package/dist/manifests/table-of-contents.manifest.json +1 -1
- package/dist/manifests/table.manifest.json +1 -1
- package/dist/manifests/tabs.manifest.json +1 -1
- package/dist/manifests/testimonial.manifest.json +1 -1
- package/dist/manifests/text.manifest.json +1 -1
- package/dist/manifests/textarea.manifest.json +1 -1
- package/dist/manifests/theme-toggle.manifest.json +1 -1
- package/dist/manifests/time-picker.manifest.json +1 -1
- package/dist/manifests/timeline.manifest.json +1 -1
- package/dist/manifests/toast.manifest.json +1 -1
- package/dist/manifests/tombstone-card.manifest.json +1 -1
- package/dist/manifests/tooltip.manifest.json +1 -1
- package/dist/src/components/figure/Figure.d.ts +23 -0
- package/dist/src/components/figure/Figure.js +60 -0
- package/dist/src/components/figure/Figure.js.map +1 -0
- package/dist/src/components/figure/Figure.mjs +26 -0
- package/dist/src/components/figure/Figure.mjs.map +1 -0
- package/dist/src/components/figure/index.d.ts +2 -0
- package/dist/src/components/figure/index.js +29 -0
- package/dist/src/components/figure/index.js.map +1 -0
- package/dist/src/components/figure/index.mjs +5 -0
- package/dist/src/components/figure/index.mjs.map +1 -0
- package/dist/src/components/icon/Icon.d.ts +33 -0
- package/dist/src/components/icon/Icon.js +82 -0
- package/dist/src/components/icon/Icon.js.map +1 -0
- package/dist/src/components/icon/Icon.mjs +47 -0
- package/dist/src/components/icon/Icon.mjs.map +1 -0
- package/dist/src/components/icon/index.d.ts +2 -0
- package/dist/src/components/icon/index.js +31 -0
- package/dist/src/components/icon/index.js.map +1 -0
- package/dist/src/components/icon/index.mjs +6 -0
- package/dist/src/components/icon/index.mjs.map +1 -0
- package/dist/src/components/icon-button/IconButton.d.ts +25 -0
- package/dist/src/components/icon-button/IconButton.js +60 -0
- package/dist/src/components/icon-button/IconButton.js.map +1 -0
- package/dist/src/components/icon-button/IconButton.mjs +26 -0
- package/dist/src/components/icon-button/IconButton.mjs.map +1 -0
- package/dist/src/components/icon-button/index.d.ts +2 -0
- package/dist/src/components/icon-button/index.js +29 -0
- package/dist/src/components/icon-button/index.js.map +1 -0
- package/dist/src/components/icon-button/index.mjs +5 -0
- package/dist/src/components/icon-button/index.mjs.map +1 -0
- package/dist/src/components/icon-tile/IconTile.d.ts +23 -0
- package/dist/src/components/icon-tile/IconTile.js +75 -0
- package/dist/src/components/icon-tile/IconTile.js.map +1 -0
- package/dist/src/components/icon-tile/IconTile.mjs +40 -0
- package/dist/src/components/icon-tile/IconTile.mjs.map +1 -0
- package/dist/src/components/icon-tile/index.d.ts +2 -0
- package/dist/src/components/icon-tile/index.js +31 -0
- package/dist/src/components/icon-tile/index.js.map +1 -0
- package/dist/src/components/icon-tile/index.mjs +6 -0
- package/dist/src/components/icon-tile/index.mjs.map +1 -0
- package/dist/src/components/media/Media.d.ts +48 -0
- package/dist/src/components/media/Media.js +97 -0
- package/dist/src/components/media/Media.js.map +1 -0
- package/dist/src/components/media/Media.mjs +63 -0
- package/dist/src/components/media/Media.mjs.map +1 -0
- package/dist/src/components/media/index.d.ts +2 -0
- package/dist/src/components/media/index.js +29 -0
- package/dist/src/components/media/index.js.map +1 -0
- package/dist/src/components/media/index.mjs +5 -0
- package/dist/src/components/media/index.mjs.map +1 -0
- package/dist/src/components/site-header/SiteHeader.js +33 -9
- package/dist/src/components/site-header/SiteHeader.js.map +1 -1
- package/dist/src/components/site-header/SiteHeader.mjs +33 -9
- package/dist/src/components/site-header/SiteHeader.mjs.map +1 -1
- package/dist/src/components/social-links/SocialLinks.d.ts +34 -0
- package/dist/src/components/social-links/SocialLinks.js +69 -0
- package/dist/src/components/social-links/SocialLinks.js.map +1 -0
- package/dist/src/components/social-links/SocialLinks.mjs +35 -0
- package/dist/src/components/social-links/SocialLinks.mjs.map +1 -0
- package/dist/src/components/social-links/index.d.ts +2 -0
- package/dist/src/components/social-links/index.js +29 -0
- package/dist/src/components/social-links/index.js.map +1 -0
- package/dist/src/components/social-links/index.mjs +5 -0
- package/dist/src/components/social-links/index.mjs.map +1 -0
- package/dist/src/index.d.ts +6 -0
- package/dist/styles-full.css +1 -1
- package/dist/styles.css +1 -1
- package/package.json +2 -2
- package/src/components/figure/Figure.test.tsx +54 -0
- package/src/components/figure/Figure.tsx +38 -0
- package/src/components/figure/index.ts +2 -0
- package/src/components/icon/Icon.test.tsx +70 -0
- package/src/components/icon/Icon.tsx +61 -0
- package/src/components/icon/index.ts +2 -0
- package/src/components/icon-button/IconButton.test.tsx +76 -0
- package/src/components/icon-button/IconButton.tsx +38 -0
- package/src/components/icon-button/index.ts +2 -0
- package/src/components/icon-tile/IconTile.test.tsx +63 -0
- package/src/components/icon-tile/IconTile.tsx +55 -0
- package/src/components/icon-tile/index.ts +2 -0
- package/src/components/media/Media.test.tsx +53 -0
- package/src/components/media/Media.tsx +92 -0
- package/src/components/media/index.ts +2 -0
- package/src/components/site-header/SiteHeader.test.tsx +27 -0
- package/src/components/site-header/SiteHeader.tsx +60 -21
- package/src/components/social-links/SocialLinks.test.tsx +59 -0
- package/src/components/social-links/SocialLinks.tsx +73 -0
- package/src/components/social-links/index.ts +2 -0
- package/src/index.ts +6 -0
- package/src/manifests/accordion.manifest.json +1 -1
- package/src/manifests/alert.manifest.json +1 -1
- package/src/manifests/announcement-bar.manifest.json +1 -1
- package/src/manifests/app-shell.manifest.json +1 -1
- package/src/manifests/applied-filters.manifest.json +1 -1
- package/src/manifests/article-card.manifest.json +1 -1
- package/src/manifests/auth-layout.manifest.json +1 -1
- package/src/manifests/autocomplete.manifest.json +1 -1
- package/src/manifests/avatar.manifest.json +1 -1
- package/src/manifests/badge.manifest.json +1 -1
- package/src/manifests/block.manifest.json +1 -1
- package/src/manifests/bottom-nav.manifest.json +1 -1
- package/src/manifests/breadcrumb.manifest.json +1 -1
- package/src/manifests/button-group.manifest.json +1 -1
- package/src/manifests/button.manifest.json +1 -1
- package/src/manifests/calendar.manifest.json +1 -1
- package/src/manifests/card.manifest.json +1 -1
- package/src/manifests/checkbox.manifest.json +1 -1
- package/src/manifests/comparison-table.manifest.json +1 -1
- package/src/manifests/confirm-dialog.manifest.json +1 -1
- package/src/manifests/consent-banner.manifest.json +1 -1
- package/src/manifests/contact-strip.manifest.json +1 -1
- package/src/manifests/container.manifest.json +1 -1
- package/src/manifests/cover-image.manifest.json +1 -1
- package/src/manifests/cta-section.manifest.json +1 -1
- package/src/manifests/data-table.manifest.json +1 -1
- package/src/manifests/date-picker-popover.manifest.json +1 -1
- package/src/manifests/date-picker.manifest.json +1 -1
- package/src/manifests/date-range-picker.manifest.json +1 -1
- package/src/manifests/deal-card.manifest.json +1 -1
- package/src/manifests/dialog.manifest.json +1 -1
- package/src/manifests/document-card.manifest.json +1 -1
- package/src/manifests/drawer.manifest.json +1 -1
- package/src/manifests/empty-state.manifest.json +1 -1
- package/src/manifests/entity-card.manifest.json +1 -1
- package/src/manifests/feature-grid.manifest.json +1 -1
- package/src/manifests/feature-row.manifest.json +1 -1
- package/src/manifests/fieldset.manifest.json +1 -1
- package/src/manifests/figure.manifest.json +105 -0
- package/src/manifests/file-upload.manifest.json +1 -1
- package/src/manifests/filter-bar.manifest.json +1 -1
- package/src/manifests/filter-chips.manifest.json +1 -1
- package/src/manifests/filter-panel.manifest.json +1 -1
- package/src/manifests/flex.manifest.json +1 -1
- package/src/manifests/form-field.manifest.json +1 -1
- package/src/manifests/form-layout.manifest.json +1 -1
- package/src/manifests/form.manifest.json +1 -1
- package/src/manifests/grid.manifest.json +1 -1
- package/src/manifests/heading.manifest.json +1 -1
- package/src/manifests/hero.manifest.json +1 -1
- package/src/manifests/icon-button.manifest.json +101 -0
- package/src/manifests/icon-tile.manifest.json +107 -0
- package/src/manifests/icon.manifest.json +119 -0
- package/src/manifests/image.manifest.json +1 -1
- package/src/manifests/input-group.manifest.json +1 -1
- package/src/manifests/input.manifest.json +1 -1
- package/src/manifests/label.manifest.json +1 -1
- package/src/manifests/link-tabs.manifest.json +1 -1
- package/src/manifests/link.manifest.json +1 -1
- package/src/manifests/list-toolbar.manifest.json +1 -1
- package/src/manifests/list.manifest.json +1 -1
- package/src/manifests/load-more.manifest.json +1 -1
- package/src/manifests/logo-cloud.manifest.json +1 -1
- package/src/manifests/media-card.manifest.json +1 -1
- package/src/manifests/media.manifest.json +142 -0
- package/src/manifests/menu.manifest.json +1 -1
- package/src/manifests/metric-card.manifest.json +1 -1
- package/src/manifests/month-schedule.manifest.json +1 -1
- package/src/manifests/multi-select.manifest.json +1 -1
- package/src/manifests/newsletter.manifest.json +1 -1
- package/src/manifests/page-header.manifest.json +1 -1
- package/src/manifests/pagination.manifest.json +1 -1
- package/src/manifests/password-input.manifest.json +1 -1
- package/src/manifests/popover.manifest.json +1 -1
- package/src/manifests/process-steps.manifest.json +1 -1
- package/src/manifests/progress.manifest.json +1 -1
- package/src/manifests/prose.manifest.json +1 -1
- package/src/manifests/radio.manifest.json +1 -1
- package/src/manifests/range-slider.manifest.json +1 -1
- package/src/manifests/search.manifest.json +1 -1
- package/src/manifests/section-heading.manifest.json +1 -1
- package/src/manifests/section.manifest.json +1 -1
- package/src/manifests/segmented-control.manifest.json +1 -1
- package/src/manifests/select-menu.manifest.json +1 -1
- package/src/manifests/select.manifest.json +1 -1
- package/src/manifests/separator.manifest.json +1 -1
- package/src/manifests/site-footer.manifest.json +1 -1
- package/src/manifests/site-header.manifest.json +1 -1
- package/src/manifests/skeleton.manifest.json +1 -1
- package/src/manifests/social-links.manifest.json +120 -0
- package/src/manifests/spinner.manifest.json +1 -1
- package/src/manifests/stat-band.manifest.json +1 -1
- package/src/manifests/stepper.manifest.json +1 -1
- package/src/manifests/switch.manifest.json +1 -1
- package/src/manifests/table-card.manifest.json +1 -1
- package/src/manifests/table-of-contents.manifest.json +1 -1
- package/src/manifests/table.manifest.json +1 -1
- package/src/manifests/tabs.manifest.json +1 -1
- package/src/manifests/testimonial.manifest.json +1 -1
- package/src/manifests/text.manifest.json +1 -1
- package/src/manifests/textarea.manifest.json +1 -1
- package/src/manifests/theme-toggle.manifest.json +1 -1
- package/src/manifests/time-picker.manifest.json +1 -1
- package/src/manifests/timeline.manifest.json +1 -1
- package/src/manifests/toast.manifest.json +1 -1
- package/src/manifests/tombstone-card.manifest.json +1 -1
- package/src/manifests/tooltip.manifest.json +1 -1
|
@@ -218,6 +218,34 @@ export function SiteHeader({
|
|
|
218
218
|
const hasColumns = (item: SiteNavItem): item is SiteNavItem & { columns: SiteNavColumn[] } =>
|
|
219
219
|
Array.isArray(item.columns) && item.columns.length > 0;
|
|
220
220
|
|
|
221
|
+
/*
|
|
222
|
+
* Panels are wider than their triggers, so a fixed left-0 anchor pushes
|
|
223
|
+
* edge menus off-screen. On open we measure the panel and clamp its left
|
|
224
|
+
* edge into the viewport; the inline style wins over the left-0 class.
|
|
225
|
+
* Layout effect keeps the correction ahead of paint.
|
|
226
|
+
*/
|
|
227
|
+
const alignPanel = React.useCallback((panel: HTMLElement) => {
|
|
228
|
+
const item = panel.parentElement;
|
|
229
|
+
if (!item) return;
|
|
230
|
+
const itemRect = item.getBoundingClientRect();
|
|
231
|
+
const width = panel.offsetWidth;
|
|
232
|
+
const gutter = 8;
|
|
233
|
+
const centered = itemRect.left + itemRect.width / 2 - width / 2;
|
|
234
|
+
const left = Math.max(gutter, Math.min(centered, window.innerWidth - gutter - width));
|
|
235
|
+
panel.style.left = `${left - itemRect.left}px`;
|
|
236
|
+
panel.style.right = 'auto';
|
|
237
|
+
}, []);
|
|
238
|
+
|
|
239
|
+
const useIsoLayoutEffect =
|
|
240
|
+
typeof window === 'undefined' ? React.useEffect : React.useLayoutEffect;
|
|
241
|
+
|
|
242
|
+
useIsoLayoutEffect(() => {
|
|
243
|
+
if (!openMenu) return;
|
|
244
|
+
const panelId = `${generatedId}-panel-${openMenu.replace(/\s+/g, '-').toLowerCase()}`;
|
|
245
|
+
const panel = document.getElementById(panelId);
|
|
246
|
+
if (panel) alignPanel(panel);
|
|
247
|
+
}, [openMenu, generatedId, alignPanel]);
|
|
248
|
+
|
|
221
249
|
return (
|
|
222
250
|
<>
|
|
223
251
|
<header
|
|
@@ -302,31 +330,42 @@ export function SiteHeader({
|
|
|
302
330
|
{item.label}
|
|
303
331
|
<Caret />
|
|
304
332
|
</button>
|
|
333
|
+
{/*
|
|
334
|
+
* The pt-2 bridge keeps the pointer inside the <li> while
|
|
335
|
+
* it travels from the trigger into the panel - a margin
|
|
336
|
+
* gap would fire onMouseLeave and slam the menu shut.
|
|
337
|
+
*/}
|
|
305
338
|
<div
|
|
306
339
|
id={panelId}
|
|
307
340
|
hidden={!open}
|
|
308
|
-
className=
|
|
309
|
-
'absolute left-0 top-full z-50 mt-2 grid gap-6 rounded-lg border border-border bg-popover p-5 shadow-lg',
|
|
310
|
-
item.columns.length > 1 ? 'grid-cols-2' : 'grid-cols-1',
|
|
311
|
-
'min-w-[22rem]'
|
|
312
|
-
)}
|
|
341
|
+
className="absolute left-0 top-full z-50 pt-2"
|
|
313
342
|
>
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
343
|
+
<div
|
|
344
|
+
className={cn(
|
|
345
|
+
'grid gap-6 rounded-lg border border-border bg-popover p-5 shadow-lg',
|
|
346
|
+
item.columns.length > 1 ? 'grid-cols-2' : 'grid-cols-1',
|
|
347
|
+
item.columns.length > 1
|
|
348
|
+
? 'w-[38rem] max-w-[calc(100vw-2rem)]'
|
|
349
|
+
: 'w-[22rem] max-w-[calc(100vw-2rem)]'
|
|
350
|
+
)}
|
|
351
|
+
>
|
|
352
|
+
{item.columns.map((column, index) => (
|
|
353
|
+
<div key={column.heading ?? index} className="min-w-40">
|
|
354
|
+
{column.heading && (
|
|
355
|
+
<p className="mb-2 text-xs font-medium uppercase tracking-wide text-muted-foreground">
|
|
356
|
+
{column.heading}
|
|
357
|
+
</p>
|
|
358
|
+
)}
|
|
359
|
+
<ul className="flex flex-col gap-0.5">
|
|
360
|
+
{column.items.map((link) => (
|
|
361
|
+
<li key={`${column.heading ?? index}-${link.href}-${link.label}`}>
|
|
362
|
+
{navLink(link, 'panel')}
|
|
363
|
+
</li>
|
|
364
|
+
))}
|
|
365
|
+
</ul>
|
|
366
|
+
</div>
|
|
367
|
+
))}
|
|
368
|
+
</div>
|
|
330
369
|
</div>
|
|
331
370
|
</li>
|
|
332
371
|
);
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import { axe } from 'jest-axe';
|
|
3
|
+
import { describe, expect, it } from 'vitest';
|
|
4
|
+
import { SocialLinks } from './SocialLinks';
|
|
5
|
+
|
|
6
|
+
const GithubIcon = (props: React.SVGProps<SVGSVGElement>) => (
|
|
7
|
+
<svg data-testid="github-icon" viewBox="0 0 24 24" {...props} />
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
describe('SocialLinks', () => {
|
|
11
|
+
it('renders a labelled navigation landmark', () => {
|
|
12
|
+
render(<SocialLinks links={[{ href: 'https://github.com/acme', label: 'GitHub' }]} />);
|
|
13
|
+
expect(screen.getByRole('navigation', { name: 'Social links' })).toBeInTheDocument();
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('names each destination and applies safe external attributes', () => {
|
|
17
|
+
render(
|
|
18
|
+
<SocialLinks
|
|
19
|
+
links={[
|
|
20
|
+
{ href: 'https://github.com/acme', label: 'GitHub', icon: GithubIcon },
|
|
21
|
+
{ href: 'https://x.com/acme', label: 'X profile' },
|
|
22
|
+
]}
|
|
23
|
+
/>
|
|
24
|
+
);
|
|
25
|
+
const github = screen.getByRole('link', { name: 'GitHub' });
|
|
26
|
+
expect(github).toHaveAttribute('href', 'https://github.com/acme');
|
|
27
|
+
expect(github).toHaveAttribute('target', '_blank');
|
|
28
|
+
expect(github).toHaveAttribute('rel', expect.stringContaining('noopener'));
|
|
29
|
+
expect(screen.getByRole('link', { name: 'X profile' })).toHaveTextContent('X profile');
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('renders icon components through Icon sizing', () => {
|
|
33
|
+
render(
|
|
34
|
+
<SocialLinks iconSize="lg" iconTone="primary" links={[{ href: 'https://a.dev', label: 'A', icon: GithubIcon }]} />
|
|
35
|
+
);
|
|
36
|
+
expect(screen.getByTestId('github-icon')).toBeInTheDocument();
|
|
37
|
+
expect(screen.getByRole('link', { name: 'A' }).querySelector('span')).toHaveClass('text-primary-ink');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('accepts a custom landmark label', () => {
|
|
41
|
+
render(
|
|
42
|
+
<SocialLinks label="Follow the studio" links={[{ href: 'https://a.dev', label: 'Site' }]} />
|
|
43
|
+
);
|
|
44
|
+
expect(screen.getByRole('navigation', { name: 'Follow the studio' })).toBeInTheDocument();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('has no accessibility violations', async () => {
|
|
48
|
+
const { container } = render(
|
|
49
|
+
<SocialLinks
|
|
50
|
+
label="Studio socials"
|
|
51
|
+
links={[
|
|
52
|
+
{ href: 'https://github.com/acme', label: 'GitHub', icon: GithubIcon },
|
|
53
|
+
{ href: 'https://x.com/acme', label: 'X' },
|
|
54
|
+
]}
|
|
55
|
+
/>
|
|
56
|
+
);
|
|
57
|
+
expect(await axe(container)).toHaveNoViolations();
|
|
58
|
+
});
|
|
59
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { cn } from '../../utils/cn';
|
|
3
|
+
import { Icon, type IconProps } from '../icon/Icon';
|
|
4
|
+
|
|
5
|
+
export type SocialLink = {
|
|
6
|
+
/** Destination URL. Rendered with safe external-link attributes. */
|
|
7
|
+
href: string;
|
|
8
|
+
/** Accessible name for the destination (e.g. "GitHub"). */
|
|
9
|
+
label: string;
|
|
10
|
+
/** Optional icon element or component rendered inside the link. */
|
|
11
|
+
icon?: React.ReactElement | React.ComponentType<React.SVGProps<SVGSVGElement>>;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type SocialLinksProps = React.HTMLAttributes<HTMLElement> & {
|
|
15
|
+
links: SocialLink[];
|
|
16
|
+
/** Accessible name for the navigation landmark (default "Social links"). */
|
|
17
|
+
label?: string;
|
|
18
|
+
/** Icon size passed through to Icon (default 'md'). */
|
|
19
|
+
iconSize?: IconProps['size'];
|
|
20
|
+
/** Icon tone (default 'muted'). */
|
|
21
|
+
iconTone?: IconProps['tone'];
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
function isElement(icon: SocialLink['icon']): icon is React.ReactElement {
|
|
25
|
+
return React.isValidElement(icon);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Row of outbound social/profile links. Every destination is named via
|
|
30
|
+
* `aria-label`, external links get `target="_blank" rel="noopener noreferrer"`,
|
|
31
|
+
* and icon-only links stay accessible because the label is always applied.
|
|
32
|
+
*/
|
|
33
|
+
const SocialLinks = React.forwardRef<HTMLElement, SocialLinksProps>(
|
|
34
|
+
({ className, links, label = 'Social links', iconSize = 'md', iconTone = 'muted', ...props }, ref) => (
|
|
35
|
+
<nav ref={ref} aria-label={label} className={cn('flex items-center gap-1', className)} {...props}>
|
|
36
|
+
<ul className="flex items-center gap-1">
|
|
37
|
+
{links.map((link) => (
|
|
38
|
+
<li key={link.href}>
|
|
39
|
+
<a
|
|
40
|
+
href={link.href}
|
|
41
|
+
target="_blank"
|
|
42
|
+
rel="noopener noreferrer"
|
|
43
|
+
aria-label={link.icon ? link.label : undefined}
|
|
44
|
+
className={cn(
|
|
45
|
+
'inline-flex items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
|
|
46
|
+
link.icon ? 'h-9 w-9' : 'px-3 py-1.5 text-sm'
|
|
47
|
+
)}
|
|
48
|
+
>
|
|
49
|
+
{link.icon ? (
|
|
50
|
+
isElement(link.icon) ? (
|
|
51
|
+
<Icon size={iconSize} tone={iconTone}>
|
|
52
|
+
{link.icon}
|
|
53
|
+
</Icon>
|
|
54
|
+
) : (
|
|
55
|
+
<Icon
|
|
56
|
+
size={iconSize}
|
|
57
|
+
tone={iconTone}
|
|
58
|
+
icon={link.icon as React.ComponentType<React.SVGProps<SVGSVGElement>>}
|
|
59
|
+
/>
|
|
60
|
+
)
|
|
61
|
+
) : (
|
|
62
|
+
link.label
|
|
63
|
+
)}
|
|
64
|
+
</a>
|
|
65
|
+
</li>
|
|
66
|
+
))}
|
|
67
|
+
</ul>
|
|
68
|
+
</nav>
|
|
69
|
+
)
|
|
70
|
+
);
|
|
71
|
+
SocialLinks.displayName = 'SocialLinks';
|
|
72
|
+
|
|
73
|
+
export { SocialLinks };
|
package/src/index.ts
CHANGED
|
@@ -105,3 +105,9 @@ export * from './components/alert';
|
|
|
105
105
|
export * from './components/popover';
|
|
106
106
|
export * from './components/breadcrumb';
|
|
107
107
|
export * from './components/pagination';
|
|
108
|
+
export * from './components/icon';
|
|
109
|
+
export * from './components/icon-button';
|
|
110
|
+
export * from './components/icon-tile';
|
|
111
|
+
export * from './components/social-links';
|
|
112
|
+
export * from './components/figure';
|
|
113
|
+
export * from './components/media';
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"tier": "molecule",
|
|
5
5
|
"package": "@slipstream-ui/core",
|
|
6
6
|
"importPath": "@slipstream-ui/core",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.13.0",
|
|
8
8
|
"sourceDir": "announcement-bar",
|
|
9
9
|
"exportName": "AnnouncementBar",
|
|
10
10
|
"description": "Dismissible announcement bar with optional action, tone and sticky positioning.",
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"tier": "molecule",
|
|
5
5
|
"package": "@slipstream-ui/core",
|
|
6
6
|
"importPath": "@slipstream-ui/core",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.13.0",
|
|
8
8
|
"sourceDir": "applied-filters",
|
|
9
9
|
"exportName": "AppliedFilters",
|
|
10
10
|
"description": "Applied-filter summary with a live count, removable chips and an edit action.",
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"tier": "molecule",
|
|
5
5
|
"package": "@slipstream-ui/core",
|
|
6
6
|
"importPath": "@slipstream-ui/core",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.13.0",
|
|
8
8
|
"sourceDir": "article-card",
|
|
9
9
|
"exportName": "ArticleCard",
|
|
10
10
|
"description": "Linked article or resource card with media, eyebrow, title, summary and metadata.",
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"tier": "molecule",
|
|
5
5
|
"package": "@slipstream-ui/core",
|
|
6
6
|
"importPath": "@slipstream-ui/core",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.13.0",
|
|
8
8
|
"sourceDir": "comparison-table",
|
|
9
9
|
"exportName": "ComparisonTable",
|
|
10
10
|
"description": "Marketing comparison table with check/dash boolean cells, a highlighted column and responsive overflow.",
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"tier": "molecule",
|
|
5
5
|
"package": "@slipstream-ui/core",
|
|
6
6
|
"importPath": "@slipstream-ui/core",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.13.0",
|
|
8
8
|
"sourceDir": "confirm-dialog",
|
|
9
9
|
"exportName": "ConfirmDialog",
|
|
10
10
|
"description": "Accessible confirmation dialog with async pending state, destructive variant and cancellable actions, built on Dialog.",
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"tier": "molecule",
|
|
5
5
|
"package": "@slipstream-ui/core",
|
|
6
6
|
"importPath": "@slipstream-ui/core",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.13.0",
|
|
8
8
|
"sourceDir": "consent-banner",
|
|
9
9
|
"exportName": "ConsentBanner",
|
|
10
10
|
"description": "Styled cookie/consent banner: fixed bottom bar with accept, decline and an optional manage-preferences action. Pair it with the headless useConsent hook so the decision persists per-purpose in localStorage.",
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"tier": "molecule",
|
|
5
5
|
"package": "@slipstream-ui/core",
|
|
6
6
|
"importPath": "@slipstream-ui/core",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.13.0",
|
|
8
8
|
"sourceDir": "contact-strip",
|
|
9
9
|
"exportName": "ContactStrip",
|
|
10
10
|
"description": "Compact labelled contact rows with optional icons and links.",
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"tier": "atom",
|
|
5
5
|
"package": "@slipstream-ui/core",
|
|
6
6
|
"importPath": "@slipstream-ui/core",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.13.0",
|
|
8
8
|
"sourceDir": "container",
|
|
9
9
|
"exportName": "Container",
|
|
10
10
|
"description": "Centered, width-constrained page container with shared gutters and four width presets.",
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"tier": "organism",
|
|
5
5
|
"package": "@slipstream-ui/core",
|
|
6
6
|
"importPath": "@slipstream-ui/core",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.13.0",
|
|
8
8
|
"sourceDir": "cta-section",
|
|
9
9
|
"exportName": "CTASection",
|
|
10
10
|
"description": "Full-width conversion band with eyebrow, headline, supporting copy and actions.",
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"tier": "molecule",
|
|
5
5
|
"package": "@slipstream-ui/core",
|
|
6
6
|
"importPath": "@slipstream-ui/core",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.13.0",
|
|
8
8
|
"sourceDir": "date-range-picker",
|
|
9
9
|
"exportName": "DateRangePicker",
|
|
10
10
|
"description": "Start/end date range with ISO strings and quick presets.",
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"tier": "organism",
|
|
5
5
|
"package": "@slipstream-ui/core",
|
|
6
6
|
"importPath": "@slipstream-ui/core",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.13.0",
|
|
8
8
|
"sourceDir": "deal-card",
|
|
9
9
|
"exportName": "DealCard",
|
|
10
10
|
"description": "Deal opportunity card with sector, status, metrics, NDA/CIM badges and access actions.",
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"tier": "molecule",
|
|
5
5
|
"package": "@slipstream-ui/core",
|
|
6
6
|
"importPath": "@slipstream-ui/core",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.13.0",
|
|
8
8
|
"sourceDir": "document-card",
|
|
9
9
|
"exportName": "DocumentCard",
|
|
10
10
|
"description": "Document row with file metadata, access status and an optional download action.",
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"tier": "organism",
|
|
5
5
|
"package": "@slipstream-ui/core",
|
|
6
6
|
"importPath": "@slipstream-ui/core",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.13.0",
|
|
8
8
|
"sourceDir": "entity-card",
|
|
9
9
|
"exportName": "EntityCard",
|
|
10
10
|
"description": "Firm or member profile card with logo, type, location, stats, tags and actions.",
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"tier": "organism",
|
|
5
5
|
"package": "@slipstream-ui/core",
|
|
6
6
|
"importPath": "@slipstream-ui/core",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.13.0",
|
|
8
8
|
"sourceDir": "feature-grid",
|
|
9
9
|
"exportName": "FeatureGrid",
|
|
10
10
|
"description": "Grid of feature or benefit cards with an icon, title, copy and optional link.",
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"tier": "organism",
|
|
5
5
|
"package": "@slipstream-ui/core",
|
|
6
6
|
"importPath": "@slipstream-ui/core",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.13.0",
|
|
8
8
|
"sourceDir": "feature-row",
|
|
9
9
|
"exportName": "FeatureRow",
|
|
10
10
|
"description": "Alternating media and copy row for mid-page feature sections.",
|