Enhance Tags on TrailCard component with toggle support (#285)
* Updated trail card to show first 2 tags and made tags smaller * fixes ux and adds i18n --------- Co-authored-by: Christian Beutel <>
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"
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
import { _ } from "svelte-i18n";
|
import { _ } from "svelte-i18n";
|
||||||
import type { MouseEventHandler } from "svelte/elements";
|
import type { MouseEventHandler } from "svelte/elements";
|
||||||
import Chip from "../base/chip.svelte";
|
import Chip from "../base/chip.svelte";
|
||||||
|
import { fade, slide } from "svelte/transition";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
trail: Trail;
|
trail: Trail;
|
||||||
@@ -33,7 +34,7 @@
|
|||||||
? getFileURL(
|
? getFileURL(
|
||||||
trail,
|
trail,
|
||||||
trail.photos.at(trail.thumbnail ?? 0) ?? trail.photos[0],
|
trail.photos.at(trail.thumbnail ?? 0) ?? trail.photos[0],
|
||||||
"600x0"
|
"600x0",
|
||||||
)
|
)
|
||||||
: $theme === "light"
|
: $theme === "light"
|
||||||
? emptyStateTrailLight
|
? emptyStateTrailLight
|
||||||
@@ -43,6 +44,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 expandedTags = $state(false);
|
||||||
|
|
||||||
|
function toggleExpandTags(e: MouseEvent) {
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
expandedTags = !expandedTags;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
@@ -133,23 +143,31 @@
|
|||||||
`https://api.dicebear.com/7.x/initials/svg?seed=${trail.expand.author.preferred_username}&backgroundType=gradientLinear`}
|
`https://api.dicebear.com/7.x/initials/svg?seed=${trail.expand.author.preferred_username}&backgroundType=gradientLinear`}
|
||||||
alt="avatar"
|
alt="avatar"
|
||||||
/>
|
/>
|
||||||
{trail.expand.author.preferred_username}{trail.expand.author.isLocal
|
{trail.expand.author.preferred_username}{trail.expand.author
|
||||||
|
.isLocal
|
||||||
? ""
|
? ""
|
||||||
: "@" + trail.expand.author.domain}
|
: "@" + trail.expand.author.domain}
|
||||||
</p>
|
</p>
|
||||||
{/if}
|
{/if}
|
||||||
{#if trail.expand?.tags?.length}
|
{#if trail.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 ? trail.tags : trail.tags.slice(0, 2) as t}
|
||||||
<Chip text={t.name} closable={false} primary={false}
|
|
||||||
></Chip>
|
|
||||||
{/each}
|
|
||||||
</div>
|
|
||||||
{:else if trail.tags?.length}
|
|
||||||
<div class="flex flex-wrap gap-1 mb-3">
|
|
||||||
{#each trail.tags ?? [] as t}
|
|
||||||
<Chip text={t} closable={false} primary={false}></Chip>
|
<Chip text={t} closable={false} primary={false}></Chip>
|
||||||
{/each}
|
{/each}
|
||||||
|
|
||||||
|
{#if trail.tags.length > 2}
|
||||||
|
<button
|
||||||
|
onclick={toggleExpandTags}
|
||||||
|
class="text-sm text-gray-500 hover:underline focus:outline-none"
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
{#if expandedTags}
|
||||||
|
{$_('show-less')}
|
||||||
|
{:else}
|
||||||
|
+{trail.tags.length - 2} {$_('more')}
|
||||||
|
{/if}
|
||||||
|
</button>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<div class="flex gap-x-4">
|
<div class="flex gap-x-4">
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
import { _ } from "svelte-i18n";
|
import { _ } from "svelte-i18n";
|
||||||
import ShareInfo from "../share_info.svelte";
|
import ShareInfo from "../share_info.svelte";
|
||||||
import { handleFromRecordWithIRI } from "$lib/util/activitypub_util";
|
import { handleFromRecordWithIRI } from "$lib/util/activitypub_util";
|
||||||
|
import Chip from "../base/chip.svelte";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
trail: Trail;
|
trail: Trail;
|
||||||
@@ -33,6 +34,14 @@
|
|||||||
? emptyStateTrailLight
|
? emptyStateTrailLight
|
||||||
: emptyStateTrailDark,
|
: emptyStateTrailDark,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let expandedTags = $state(false);
|
||||||
|
|
||||||
|
function toggleExpandTags(e: MouseEvent) {
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
expandedTags = !expandedTags;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<li
|
<li
|
||||||
@@ -60,7 +69,7 @@
|
|||||||
<h4 class="font-semibold text-lg">
|
<h4 class="font-semibold text-lg">
|
||||||
{trail.name}
|
{trail.name}
|
||||||
</h4>
|
</h4>
|
||||||
<div class="flex items-center shrink-0 gap-3">
|
<div class="flex items-center shrink-0 gap-3">
|
||||||
{#if trail.public && $currentUser}
|
{#if trail.public && $currentUser}
|
||||||
<span class="tooltip" data-title={$_("public")}>
|
<span class="tooltip" data-title={$_("public")}>
|
||||||
<i class="fa fa-globe"></i>
|
<i class="fa fa-globe"></i>
|
||||||
@@ -105,6 +114,27 @@
|
|||||||
{handleFromRecordWithIRI(trail)}
|
{handleFromRecordWithIRI(trail)}
|
||||||
</p>
|
</p>
|
||||||
{/if}
|
{/if}
|
||||||
|
{#if trail.tags.length}
|
||||||
|
<div class="flex flex-wrap gap-1 mb-3 items-center">
|
||||||
|
{#each expandedTags ? trail.tags : trail.tags.slice(0, 2) as t}
|
||||||
|
<Chip text={t} closable={false} primary={false}></Chip>
|
||||||
|
{/each}
|
||||||
|
|
||||||
|
{#if trail.tags.length > 2}
|
||||||
|
<button
|
||||||
|
onclick={toggleExpandTags}
|
||||||
|
class="text-sm text-gray-500 hover:underline focus:outline-none"
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
{#if expandedTags}
|
||||||
|
Show less
|
||||||
|
{:else}
|
||||||
|
+{trail.tags.length - 2} more
|
||||||
|
{/if}
|
||||||
|
</button>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
<div class="flex flex-wrap gap-x-8">
|
<div class="flex flex-wrap gap-x-8">
|
||||||
{#if trail.location}
|
{#if trail.location}
|
||||||
<h5><i class="fa fa-location-dot mr-3"></i>{trail.location}</h5>
|
<h5><i class="fa fa-location-dot mr-3"></i>{trail.location}</h5>
|
||||||
|
|||||||
@@ -199,6 +199,7 @@
|
|||||||
"max-hiking-difficulty": "Max. Schwierigkeit der Wanderung",
|
"max-hiking-difficulty": "Max. Schwierigkeit der Wanderung",
|
||||||
"metric": "Metrisch",
|
"metric": "Metrisch",
|
||||||
"moderate": "Mittel",
|
"moderate": "Mittel",
|
||||||
|
"more": "weitere",
|
||||||
"mountain": "Berg",
|
"mountain": "Berg",
|
||||||
"must-be-at-least-n-characters-long": "Muss mindestens {n} Zeichen lang sein",
|
"must-be-at-least-n-characters-long": "Muss mindestens {n} Zeichen lang sein",
|
||||||
"must-be-at-most-n-characters-long": "Darf höchstens {n} Zeichen lang sein",
|
"must-be-at-most-n-characters-long": "Darf höchstens {n} Zeichen lang sein",
|
||||||
@@ -316,6 +317,7 @@
|
|||||||
"shared-with": "Geteilt mit",
|
"shared-with": "Geteilt mit",
|
||||||
"shortest": "",
|
"shortest": "",
|
||||||
"show-in-overview": "In der Übersicht anzeigen",
|
"show-in-overview": "In der Übersicht anzeigen",
|
||||||
|
"show-less": "Weniger anzeigen",
|
||||||
"show-on-map": "Auf der Karte anzeigen",
|
"show-on-map": "Auf der Karte anzeigen",
|
||||||
"slogan": "Speichere deine Abenteuer!",
|
"slogan": "Speichere deine Abenteuer!",
|
||||||
"slope": "Steigung",
|
"slope": "Steigung",
|
||||||
|
|||||||
@@ -199,6 +199,7 @@
|
|||||||
"max-hiking-difficulty": "Max. Hiking Difficulty",
|
"max-hiking-difficulty": "Max. Hiking Difficulty",
|
||||||
"metric": "Metric",
|
"metric": "Metric",
|
||||||
"moderate": "Moderate",
|
"moderate": "Moderate",
|
||||||
|
"more": "",
|
||||||
"mountain": "Mountain",
|
"mountain": "Mountain",
|
||||||
"must-be-at-least-n-characters-long": "Must be at least {n} characters long",
|
"must-be-at-least-n-characters-long": "Must be at least {n} characters long",
|
||||||
"must-be-at-most-n-characters-long": "Must be at most {n} characters long",
|
"must-be-at-most-n-characters-long": "Must be at most {n} characters long",
|
||||||
@@ -316,6 +317,7 @@
|
|||||||
"shared-with": "Shared with",
|
"shared-with": "Shared with",
|
||||||
"shortest": "",
|
"shortest": "",
|
||||||
"show-in-overview": "Show in overview",
|
"show-in-overview": "Show in overview",
|
||||||
|
"show-less": "",
|
||||||
"show-on-map": "Show on map",
|
"show-on-map": "Show on map",
|
||||||
"slogan": "Save your adventures!",
|
"slogan": "Save your adventures!",
|
||||||
"slope": "Slope",
|
"slope": "Slope",
|
||||||
|
|||||||
@@ -199,6 +199,7 @@
|
|||||||
"max-hiking-difficulty": "Max. Hiking Difficulty",
|
"max-hiking-difficulty": "Max. Hiking Difficulty",
|
||||||
"metric": "Métrica",
|
"metric": "Métrica",
|
||||||
"moderate": "Medio",
|
"moderate": "Medio",
|
||||||
|
"more": "",
|
||||||
"mountain": "Montaña",
|
"mountain": "Montaña",
|
||||||
"must-be-at-least-n-characters-long": "Tiene que tener por lo menos {n} caracteres",
|
"must-be-at-least-n-characters-long": "Tiene que tener por lo menos {n} caracteres",
|
||||||
"must-be-at-most-n-characters-long": "Must be at most {n} characters long",
|
"must-be-at-most-n-characters-long": "Must be at most {n} characters long",
|
||||||
@@ -316,6 +317,7 @@
|
|||||||
"shared-with": "Compartido con",
|
"shared-with": "Compartido con",
|
||||||
"shortest": "",
|
"shortest": "",
|
||||||
"show-in-overview": "Mostrar en la panorámica",
|
"show-in-overview": "Mostrar en la panorámica",
|
||||||
|
"show-less": "",
|
||||||
"show-on-map": "Mostrar en mapa",
|
"show-on-map": "Mostrar en mapa",
|
||||||
"slogan": "¡Guarda tus aventuras!",
|
"slogan": "¡Guarda tus aventuras!",
|
||||||
"slope": "Pendiente",
|
"slope": "Pendiente",
|
||||||
|
|||||||
@@ -199,6 +199,7 @@
|
|||||||
"max-hiking-difficulty": "Max. Hiking Difficulty",
|
"max-hiking-difficulty": "Max. Hiking Difficulty",
|
||||||
"metric": "Métrique",
|
"metric": "Métrique",
|
||||||
"moderate": "Moyenne",
|
"moderate": "Moyenne",
|
||||||
|
"more": "",
|
||||||
"mountain": "Mountain",
|
"mountain": "Mountain",
|
||||||
"must-be-at-least-n-characters-long": "Doit être composé d'au moins {n} caractères",
|
"must-be-at-least-n-characters-long": "Doit être composé d'au moins {n} caractères",
|
||||||
"must-be-at-most-n-characters-long": "Doit être au maximum de {n} caractères",
|
"must-be-at-most-n-characters-long": "Doit être au maximum de {n} caractères",
|
||||||
@@ -316,6 +317,7 @@
|
|||||||
"shared-with": "Partagé avec",
|
"shared-with": "Partagé avec",
|
||||||
"shortest": "",
|
"shortest": "",
|
||||||
"show-in-overview": "Voir dans l'aperçu",
|
"show-in-overview": "Voir dans l'aperçu",
|
||||||
|
"show-less": "",
|
||||||
"show-on-map": "Voir sur la carte",
|
"show-on-map": "Voir sur la carte",
|
||||||
"slogan": "Sauvegarder vos aventures !",
|
"slogan": "Sauvegarder vos aventures !",
|
||||||
"slope": "Pente",
|
"slope": "Pente",
|
||||||
|
|||||||
@@ -199,6 +199,7 @@
|
|||||||
"max-hiking-difficulty": "Max. Hiking Difficulty",
|
"max-hiking-difficulty": "Max. Hiking Difficulty",
|
||||||
"metric": "Metrikus",
|
"metric": "Metrikus",
|
||||||
"moderate": "Mérsékelt",
|
"moderate": "Mérsékelt",
|
||||||
|
"more": "",
|
||||||
"mountain": "Mountain",
|
"mountain": "Mountain",
|
||||||
"must-be-at-least-n-characters-long": "Legalább {n} karakter hosszúnak kell lennie",
|
"must-be-at-least-n-characters-long": "Legalább {n} karakter hosszúnak kell lennie",
|
||||||
"must-be-at-most-n-characters-long": "Must be at most {n} characters long",
|
"must-be-at-most-n-characters-long": "Must be at most {n} characters long",
|
||||||
@@ -316,6 +317,7 @@
|
|||||||
"shared-with": "Shared with",
|
"shared-with": "Shared with",
|
||||||
"shortest": "",
|
"shortest": "",
|
||||||
"show-in-overview": "Áttekintés",
|
"show-in-overview": "Áttekintés",
|
||||||
|
"show-less": "",
|
||||||
"show-on-map": "Mutatás térképen",
|
"show-on-map": "Mutatás térképen",
|
||||||
"slogan": "Mentse el a kalandjait!",
|
"slogan": "Mentse el a kalandjait!",
|
||||||
"slope": "Slope",
|
"slope": "Slope",
|
||||||
|
|||||||
@@ -199,6 +199,7 @@
|
|||||||
"max-hiking-difficulty": "Max. Hiking Difficulty",
|
"max-hiking-difficulty": "Max. Hiking Difficulty",
|
||||||
"metric": "Metrico",
|
"metric": "Metrico",
|
||||||
"moderate": "Moderato",
|
"moderate": "Moderato",
|
||||||
|
"more": "",
|
||||||
"mountain": "Mountain",
|
"mountain": "Mountain",
|
||||||
"must-be-at-least-n-characters-long": "Deve essere lungo almeno {n} caratteri",
|
"must-be-at-least-n-characters-long": "Deve essere lungo almeno {n} caratteri",
|
||||||
"must-be-at-most-n-characters-long": "Must be at most {n} characters long",
|
"must-be-at-most-n-characters-long": "Must be at most {n} characters long",
|
||||||
@@ -316,6 +317,7 @@
|
|||||||
"shared-with": "Condiviso con",
|
"shared-with": "Condiviso con",
|
||||||
"shortest": "",
|
"shortest": "",
|
||||||
"show-in-overview": "Mostra nella panoramica",
|
"show-in-overview": "Mostra nella panoramica",
|
||||||
|
"show-less": "",
|
||||||
"show-on-map": "Mostra sulla mappa",
|
"show-on-map": "Mostra sulla mappa",
|
||||||
"slogan": "Salva le tue avventure!",
|
"slogan": "Salva le tue avventure!",
|
||||||
"slope": "Pendenza",
|
"slope": "Pendenza",
|
||||||
|
|||||||
@@ -199,6 +199,7 @@
|
|||||||
"max-hiking-difficulty": "Max. Hiking Moeilijkheid",
|
"max-hiking-difficulty": "Max. Hiking Moeilijkheid",
|
||||||
"metric": "Metrisch",
|
"metric": "Metrisch",
|
||||||
"moderate": "Gemiddeld",
|
"moderate": "Gemiddeld",
|
||||||
|
"more": "",
|
||||||
"mountain": "Berg",
|
"mountain": "Berg",
|
||||||
"must-be-at-least-n-characters-long": "Minimaal {n} tekens",
|
"must-be-at-least-n-characters-long": "Minimaal {n} tekens",
|
||||||
"must-be-at-most-n-characters-long": "Mag maximaal {n} tekens lang zijn.",
|
"must-be-at-most-n-characters-long": "Mag maximaal {n} tekens lang zijn.",
|
||||||
@@ -316,6 +317,7 @@
|
|||||||
"shared-with": "Gedeeld met",
|
"shared-with": "Gedeeld met",
|
||||||
"shortest": "",
|
"shortest": "",
|
||||||
"show-in-overview": "Tonen op overzicht",
|
"show-in-overview": "Tonen op overzicht",
|
||||||
|
"show-less": "",
|
||||||
"show-on-map": "Tonen op kaart",
|
"show-on-map": "Tonen op kaart",
|
||||||
"slogan": "Bewaar je avonturen!",
|
"slogan": "Bewaar je avonturen!",
|
||||||
"slope": "helling",
|
"slope": "helling",
|
||||||
|
|||||||
@@ -199,6 +199,7 @@
|
|||||||
"max-hiking-difficulty": "Max. Hiking Difficulty",
|
"max-hiking-difficulty": "Max. Hiking Difficulty",
|
||||||
"metric": "Metryczne",
|
"metric": "Metryczne",
|
||||||
"moderate": "Średni",
|
"moderate": "Średni",
|
||||||
|
"more": "",
|
||||||
"mountain": "Mountain",
|
"mountain": "Mountain",
|
||||||
"must-be-at-least-n-characters-long": "Długość musi wynosić przynajmniej {n} znaków",
|
"must-be-at-least-n-characters-long": "Długość musi wynosić przynajmniej {n} znaków",
|
||||||
"must-be-at-most-n-characters-long": "Must be at most {n} characters long",
|
"must-be-at-most-n-characters-long": "Must be at most {n} characters long",
|
||||||
@@ -316,6 +317,7 @@
|
|||||||
"shared-with": "Udostępniony dla",
|
"shared-with": "Udostępniony dla",
|
||||||
"shortest": "",
|
"shortest": "",
|
||||||
"show-in-overview": "Pokaż w przeglądzie",
|
"show-in-overview": "Pokaż w przeglądzie",
|
||||||
|
"show-less": "",
|
||||||
"show-on-map": "Pokaż na mapie",
|
"show-on-map": "Pokaż na mapie",
|
||||||
"slogan": "Zapisz swoją wyprawę!",
|
"slogan": "Zapisz swoją wyprawę!",
|
||||||
"slope": "Nachylenie",
|
"slope": "Nachylenie",
|
||||||
|
|||||||
@@ -199,6 +199,7 @@
|
|||||||
"max-hiking-difficulty": "Max. Hiking Difficulty",
|
"max-hiking-difficulty": "Max. Hiking Difficulty",
|
||||||
"metric": "Métrica",
|
"metric": "Métrica",
|
||||||
"moderate": "Moderado",
|
"moderate": "Moderado",
|
||||||
|
"more": "",
|
||||||
"mountain": "Mountain",
|
"mountain": "Mountain",
|
||||||
"must-be-at-least-n-characters-long": "Deve ter pelo menos {n} caracteres",
|
"must-be-at-least-n-characters-long": "Deve ter pelo menos {n} caracteres",
|
||||||
"must-be-at-most-n-characters-long": "Must be at most {n} characters long",
|
"must-be-at-most-n-characters-long": "Must be at most {n} characters long",
|
||||||
@@ -316,6 +317,7 @@
|
|||||||
"shared-with": "Partilhado com",
|
"shared-with": "Partilhado com",
|
||||||
"shortest": "",
|
"shortest": "",
|
||||||
"show-in-overview": "Mostrar na vista geral",
|
"show-in-overview": "Mostrar na vista geral",
|
||||||
|
"show-less": "",
|
||||||
"show-on-map": "Mostrar no mapa",
|
"show-on-map": "Mostrar no mapa",
|
||||||
"slogan": "Guarde as suas aventuras!",
|
"slogan": "Guarde as suas aventuras!",
|
||||||
"slope": "Inclinação",
|
"slope": "Inclinação",
|
||||||
|
|||||||
@@ -199,6 +199,7 @@
|
|||||||
"max-hiking-difficulty": "Max. Hiking Difficulty",
|
"max-hiking-difficulty": "Max. Hiking Difficulty",
|
||||||
"metric": "公制",
|
"metric": "公制",
|
||||||
"moderate": "中等",
|
"moderate": "中等",
|
||||||
|
"more": "",
|
||||||
"mountain": "Mountain",
|
"mountain": "Mountain",
|
||||||
"must-be-at-least-n-characters-long": "长度至少 {n} 字符",
|
"must-be-at-least-n-characters-long": "长度至少 {n} 字符",
|
||||||
"must-be-at-most-n-characters-long": "Must be at most {n} characters long",
|
"must-be-at-most-n-characters-long": "Must be at most {n} characters long",
|
||||||
@@ -316,6 +317,7 @@
|
|||||||
"shared-with": "分享给",
|
"shared-with": "分享给",
|
||||||
"shortest": "",
|
"shortest": "",
|
||||||
"show-in-overview": "详情中展示",
|
"show-in-overview": "详情中展示",
|
||||||
|
"show-less": "",
|
||||||
"show-on-map": "地图中展示",
|
"show-on-map": "地图中展示",
|
||||||
"slogan": "保存你的冒险!",
|
"slogan": "保存你的冒险!",
|
||||||
"slope": "坡度",
|
"slope": "坡度",
|
||||||
|
|||||||
Reference in New Issue
Block a user