@classic-homes/theme-svelte 1.10.0 → 1.10.1
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.
|
@@ -63,6 +63,20 @@ describe('HeaderSearch', () => {
|
|
|
63
63
|
await openSearch({ showIcons: true });
|
|
64
64
|
expect(screen.getByRole('option', { name: /Dashboard/ }).querySelector('svg')).not.toBeNull();
|
|
65
65
|
});
|
|
66
|
+
it('switches secondary text and icon to the accent foreground on the active row', async () => {
|
|
67
|
+
const { user } = await openSearch({ showIcons: true });
|
|
68
|
+
const dashboard = screen.getByRole('option', { name: /Dashboard/ });
|
|
69
|
+
const quartz = screen.getByRole('option', { name: /Quartz countertop/ });
|
|
70
|
+
// Active row: icon and category follow the accent foreground.
|
|
71
|
+
expect(dashboard.querySelector('svg')).toHaveClass('text-accent-foreground/80');
|
|
72
|
+
// Inactive row: description and category stay muted.
|
|
73
|
+
expect(within(quartz).getByText('Kitchen')).toHaveClass('text-muted-foreground');
|
|
74
|
+
expect(within(quartz).getByText('Selection')).toHaveClass('text-muted-foreground');
|
|
75
|
+
await user.hover(quartz);
|
|
76
|
+
expect(within(quartz).getByText('Kitchen')).toHaveClass('text-accent-foreground/80');
|
|
77
|
+
expect(within(quartz).getByText('Selection')).toHaveClass('text-accent-foreground/80');
|
|
78
|
+
expect(dashboard.querySelector('svg')).toHaveClass('text-muted-foreground');
|
|
79
|
+
});
|
|
66
80
|
it('caps the results list at the given height', async () => {
|
|
67
81
|
await openSearch({ resultsMaxHeight: '60vh' });
|
|
68
82
|
const listbox = screen.getByRole('listbox');
|
|
@@ -348,6 +348,12 @@
|
|
|
348
348
|
{/if}
|
|
349
349
|
{#each section.items as item, itemIndex (item.id)}
|
|
350
350
|
{@const index = section.offset + itemIndex}
|
|
351
|
+
{@const active = index === selectedIndex}
|
|
352
|
+
<!-- Secondary text follows the row: muted normally, a softened
|
|
353
|
+
accent foreground on the accent background. -->
|
|
354
|
+
{@const secondary = active
|
|
355
|
+
? 'text-accent-foreground/80'
|
|
356
|
+
: 'text-muted-foreground'}
|
|
351
357
|
<button
|
|
352
358
|
type="button"
|
|
353
359
|
id={optionId(index)}
|
|
@@ -356,33 +362,31 @@
|
|
|
356
362
|
onmousemove={() => (selectedIndex = index)}
|
|
357
363
|
class={cn(
|
|
358
364
|
'flex w-full cursor-pointer items-start gap-3 rounded-md px-3 py-2 text-left text-sm',
|
|
359
|
-
|
|
360
|
-
? 'bg-accent text-accent-foreground'
|
|
361
|
-
: 'hover:bg-accent-hover'
|
|
365
|
+
active ? 'bg-accent text-accent-foreground' : 'hover:bg-accent-hover'
|
|
362
366
|
)}
|
|
363
367
|
role="option"
|
|
364
|
-
aria-selected={
|
|
368
|
+
aria-selected={active}
|
|
365
369
|
>
|
|
366
370
|
{#if renderResult}
|
|
367
|
-
{@render renderResult(item,
|
|
371
|
+
{@render renderResult(item, active)}
|
|
368
372
|
{:else}
|
|
369
373
|
{#if showIcons && item.icon}
|
|
370
374
|
<Icon
|
|
371
375
|
name={item.icon as IconName}
|
|
372
376
|
size={16}
|
|
373
|
-
class=
|
|
377
|
+
class={cn('mt-0.5 shrink-0', secondary)}
|
|
374
378
|
/>
|
|
375
379
|
{/if}
|
|
376
380
|
<div class="min-w-0 flex-1">
|
|
377
381
|
<div class="truncate font-medium">{item.title}</div>
|
|
378
382
|
{#if item.description}
|
|
379
|
-
<div class=
|
|
383
|
+
<div class={cn('truncate text-xs', secondary)}>
|
|
380
384
|
{item.description}
|
|
381
385
|
</div>
|
|
382
386
|
{/if}
|
|
383
387
|
</div>
|
|
384
388
|
{#if item.category}
|
|
385
|
-
<span class=
|
|
389
|
+
<span class={cn('shrink-0 text-xs', secondary)}>
|
|
386
390
|
{item.category}
|
|
387
391
|
</span>
|
|
388
392
|
{/if}
|