Skip to content

Commit 973b87e

Browse files
committed
fix(frontend): align item type icons across breadcrumbs
1 parent 1cf27f9 commit 973b87e

2 files changed

Lines changed: 80 additions & 30 deletions

File tree

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<script>
2+
import ItemTypeIcon from '../../components/ItemTypeIcon.svelte';
3+
import Tooltip from '../../components/Tooltip.svelte';
4+
5+
let {
6+
itemType = null,
7+
iconTooltip = itemType?.name,
8+
iconTitle = undefined,
9+
iconSlotTestId = undefined,
10+
iconTriggerTestId = undefined,
11+
iconTestId = undefined,
12+
oniconclick = null,
13+
iconOverlay = null,
14+
class: className = '',
15+
style: customStyle = '',
16+
children: levelContent
17+
} = $props();
18+
</script>
19+
20+
<div class="flex min-w-0 items-center gap-2 {className}" style={customStyle}>
21+
{#if itemType}
22+
<div
23+
data-testid={iconSlotTestId}
24+
class="relative inline-flex h-6 w-6 flex-shrink-0 items-center justify-center leading-none"
25+
>
26+
<Tooltip
27+
content={iconTooltip}
28+
class="inline-flex h-full w-full items-center justify-center leading-none"
29+
>
30+
{#snippet children()}
31+
{#if oniconclick}
32+
<button
33+
type="button"
34+
data-testid={iconTriggerTestId}
35+
data-item-type-id={itemType.id}
36+
onclick={oniconclick}
37+
class="inline-flex h-full w-full cursor-pointer items-center justify-center rounded leading-none focus:outline-none focus:ring-2 focus:ring-blue-500"
38+
title={iconTitle}
39+
>
40+
<ItemTypeIcon {itemType} testId={iconTestId} />
41+
</button>
42+
{:else}
43+
<span class="inline-flex h-full w-full items-center justify-center leading-none cursor-help">
44+
<ItemTypeIcon {itemType} testId={iconTestId} />
45+
</span>
46+
{/if}
47+
{/snippet}
48+
</Tooltip>
49+
50+
{#if iconOverlay}
51+
{@render iconOverlay()}
52+
{/if}
53+
</div>
54+
{/if}
55+
56+
{@render levelContent()}
57+
</div>

frontend/src/lib/features/items/ItemDetailBreadcrumbs.svelte

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import Tooltip from '../../components/Tooltip.svelte';
44
import Input from '../../components/Input.svelte';
55
import ItemTypeIcon from '../../components/ItemTypeIcon.svelte';
6+
import ItemDetailBreadcrumbLevel from './ItemDetailBreadcrumbLevel.svelte';
67
import ItemKey from '../items/ItemKey.svelte';
78
import { api } from '../../api.js';
89
import { t } from '../../stores/i18n.svelte.js';
@@ -265,14 +266,11 @@
265266
<!-- Parent Hierarchy in breadcrumb -->
266267
{#if parentHierarchy.length > 0}
267268
{#each parentHierarchy as parent}
268-
<div class="flex items-center gap-2 min-w-0">
269-
{#if parent.itemType}
270-
<Tooltip content={parent.itemType.name}>
271-
{#snippet children()}
272-
<ItemTypeIcon itemType={parent.itemType} class="cursor-help" />
273-
{/snippet}
274-
</Tooltip>
275-
{/if}
269+
<ItemDetailBreadcrumbLevel
270+
itemType={parent.itemType}
271+
iconSlotTestId={`item-parent-type-icon-slot-${parent.id}`}
272+
iconTestId={`item-parent-type-icon-${parent.id}`}
273+
>
276274
<a
277275
data-testid={`item-parent-breadcrumb-${parent.id}`}
278276
href={`/workspaces/${parent.workspace_id}/items/${parent.id}`}
@@ -282,7 +280,7 @@
282280
>
283281
{parent.title}
284282
</a>
285-
</div>
283+
</ItemDetailBreadcrumbLevel>
286284
<span class="flex-shrink-0">/</span>
287285
{/each}
288286
{:else if !item.parent_id && !(workspace?.is_personal && item.related_work_item_id)}
@@ -481,24 +479,19 @@
481479
{/if}
482480
</div>
483481
{/if}
484-
<div class="flex items-center gap-2 min-w-0 flex-1" style="color: var(--ds-text);">
485-
{#if currentItemType}
486-
<div class="relative flex-shrink-0">
487-
<Tooltip content="{currentItemType.name} ({currentHierarchyLevel?.name || 'Unknown level'}) — click to change">
488-
{#snippet children()}
489-
<button
490-
type="button"
491-
data-testid="item-type-change-trigger"
492-
data-item-type-id={currentItemType.id}
493-
onclick={openItemTypeSelector}
494-
class="inline-flex h-6 w-6 items-center justify-center rounded leading-none cursor-pointer focus:outline-none focus:ring-2 focus:ring-blue-500"
495-
title="Change item type"
496-
>
497-
<ItemTypeIcon itemType={currentItemType} testId="item-type-change-icon" />
498-
</button>
499-
{/snippet}
500-
</Tooltip>
501-
482+
<ItemDetailBreadcrumbLevel
483+
itemType={currentItemType}
484+
iconTooltip={currentItemType ? `${currentItemType.name} (${currentHierarchyLevel?.name || 'Unknown level'}) — click to change` : undefined}
485+
iconTitle="Change item type"
486+
iconSlotTestId="item-type-icon-slot"
487+
iconTriggerTestId="item-type-change-trigger"
488+
iconTestId="item-type-change-icon"
489+
oniconclick={openItemTypeSelector}
490+
class="flex-1"
491+
style="color: var(--ds-text);"
492+
>
493+
{#snippet iconOverlay()}
494+
{#if currentItemType}
502495
{#if showItemTypeSelector}
503496
<div
504497
data-testid="item-type-selector"
@@ -569,8 +562,8 @@
569562
</div>
570563
</div>
571564
{/if}
572-
</div>
573-
{/if}
565+
{/if}
566+
{/snippet}
574567
<Tooltip content={t('items.clickToCopyKey')}>
575568
{#snippet children()}
576569
<button
@@ -584,7 +577,7 @@
584577
{/snippet}
585578
</Tooltip>
586579
<span class="truncate">{item.title}</span>
587-
</div>
580+
</ItemDetailBreadcrumbLevel>
588581
</div>
589582
590583
{#if hasHierarchyMismatch}

0 commit comments

Comments
 (0)