Updated trail card to show first 2 tags and made tags smaller
This commit is contained in:
@@ -16,7 +16,7 @@
|
|||||||
? 'bg-primary text-white'
|
? 'bg-primary text-white'
|
||||||
: 'border border-input-border bg-menu-item-background-hover'} px-2 py-1 rounded-full flex items-center gap-1"
|
: 'border border-input-border bg-menu-item-background-hover'} px-2 py-1 rounded-full flex items-center gap-1"
|
||||||
>
|
>
|
||||||
<span class="text-sm">{text}</span>
|
<span class="text-xs">{text}</span>
|
||||||
{#if closable}
|
{#if closable}
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
|
|||||||
@@ -39,6 +39,15 @@
|
|||||||
let trailIsShared = $derived(
|
let trailIsShared = $derived(
|
||||||
(trail.expand?.trail_share_via_trail?.length ?? 0) > 0,
|
(trail.expand?.trail_share_via_trail?.length ?? 0) > 0,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// expand and collapse the tags
|
||||||
|
let tags = trail.expand?.tags ?? [];
|
||||||
|
// svelte-ignore non_reactive_update
|
||||||
|
let expandedTags = false;
|
||||||
|
|
||||||
|
function toggleExpandTags() {
|
||||||
|
expandedTags = !expandedTags;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
@@ -122,10 +131,23 @@
|
|||||||
</p>
|
</p>
|
||||||
{/if}
|
{/if}
|
||||||
{#if trail.expand?.tags?.length}
|
{#if trail.expand?.tags?.length}
|
||||||
<div class="flex flex-wrap gap-1 mb-3">
|
<div class="flex flex-wrap gap-1 mb-3 items-center">
|
||||||
{#each trail.expand?.tags ?? [] as t}
|
{#each (expandedTags ? tags : tags.slice(0, 2)) as t}
|
||||||
<Chip text={t.name} closable={false} primary={false}></Chip>
|
<Chip text={t.name} closable={false} primary={false}></Chip>
|
||||||
{/each}
|
{/each}
|
||||||
|
|
||||||
|
{#if tags.length > 2}
|
||||||
|
<button
|
||||||
|
onclick={toggleExpandTags}
|
||||||
|
class="text-sm text-blue-600 hover:underline focus:outline-none"
|
||||||
|
>
|
||||||
|
{#if expandedTags}
|
||||||
|
Show less
|
||||||
|
{:else}
|
||||||
|
+{tags.length - 2} more
|
||||||
|
{/if}
|
||||||
|
</button>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{:else if trail.tags?.length}
|
{:else if trail.tags?.length}
|
||||||
<div class="flex flex-wrap gap-1 mb-3">
|
<div class="flex flex-wrap gap-1 mb-3">
|
||||||
|
|||||||
Reference in New Issue
Block a user