beautifies summit log table

This commit is contained in:
Christian Beutel
2024-12-02 01:22:50 +01:00
parent 197b2677ec
commit 5bd8c7b610
5 changed files with 92 additions and 43 deletions

View File

@@ -14,6 +14,8 @@
export let showCategory: boolean = false; export let showCategory: boolean = false;
export let showTrail: boolean = false; export let showTrail: boolean = false;
export let showAuthor: boolean = false; export let showAuthor: boolean = false;
export let showRoute: boolean = false;
export let showPhotos: boolean = false;
let openMapModal: () => void; let openMapModal: () => void;
let closeMapModal: () => void; let closeMapModal: () => void;
@@ -50,9 +52,11 @@
</script> </script>
<table class="w-full"> <table class="w-full">
<thead> <thead class="text-left text-gray-500">
<tr class="text-sm"> <tr class="text-sm">
<th class="w-24"></th> {#if showPhotos}
<th class="w-24"></th>
{/if}
<th>{$_("date")}</th> <th>{$_("date")}</th>
<th>{$_("distance")}</th> <th>{$_("distance")}</th>
<th>{$_("elevation-gain")}</th> <th>{$_("elevation-gain")}</th>
@@ -68,12 +72,19 @@
{$_("trail", { values: { n: 1 } })} {$_("trail", { values: { n: 1 } })}
</th> </th>
{/if} {/if}
<th>{$_("description")}</th> {#if summitLogs.some((l) => l.text?.length)}
<th>{$_("description")}</th>
{/if}
{#if showAuthor} {#if showAuthor}
<th> <th>
{$_("author", { values: { n: 1 } })} {$_("author", { values: { n: 1 } })}
</th> </th>
{/if} {/if}
{#if showRoute && summitLogs.some((l) => l.gpx)}
<th>
{$_("map")}
</th>
{/if}
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@@ -85,6 +96,9 @@
{showCategory} {showCategory}
{showTrail} {showTrail}
{showAuthor} {showAuthor}
{showPhotos}
showDescription={summitLogs.some(l => l.text?.length)}
showRoute={showRoute && summitLogs.some((l) => l.gpx)}
></SummitLogTableRow> ></SummitLogTableRow>
{/each} {/each}
</tbody> </tbody>
@@ -101,7 +115,7 @@
> >
<div slot="content" id="summit-log-table-map" class="h-[32rem]"> <div slot="content" id="summit-log-table-map" class="h-[32rem]">
{#if trail} {#if trail}
<MapWithElevationMaplibre trails={[trail]} bind:map <MapWithElevationMaplibre trails={[trail]} bind:map showTerrain
></MapWithElevationMaplibre> ></MapWithElevationMaplibre>
{/if} {/if}
</div> </div>
@@ -118,6 +132,6 @@
<style> <style>
th { th {
padding: 0rem 0.75rem; padding: 0rem 0.5rem;
} }
</style> </style>

View File

@@ -14,7 +14,10 @@
export let log: SummitLog; export let log: SummitLog;
export let showCategory: boolean = false; export let showCategory: boolean = false;
export let showTrail: boolean = false; export let showTrail: boolean = false;
export let showRoute: boolean = false;
export let showAuthor: boolean = false; export let showAuthor: boolean = false;
export let showDescription: boolean = false;
export let showPhotos: boolean = false;
let openGallery: (idx?: number) => void; let openGallery: (idx?: number) => void;
@@ -34,38 +37,47 @@
dispatch("text", log); dispatch("text", log);
} }
function openRoute() {
dispatch("open", log);
}
function colCount() { function colCount() {
return [showCategory, showTrail, showAuthor].reduce( return [
(b, v) => (v ? b + 1 : b), showCategory,
7, showTrail,
); showAuthor,
showRoute,
showDescription,
].reduce((b, v) => (v ? b + 1 : b), 7);
} }
</script> </script>
<tr class="text-center"> <tr class="text-sm">
<td> {#if showPhotos}
{#if imgSrc.length} <td>
<PhotoGallery {#if imgSrc.length}
photos={log.photos.map((p) => getFileURL(log, p))} <PhotoGallery
bind:open={openGallery} photos={log.photos.map((p) => getFileURL(log, p))}
></PhotoGallery> bind:open={openGallery}
<button ></PhotoGallery>
class="relative w-16 aspect-square ml-2 mb-3 shrink-0" <button
type="button" class="relative w-16 aspect-square ml-2 mb-3 shrink-0"
on:click={() => openGallery()} type="button"
> on:click={() => openGallery()}
{#each imgSrc as img, i} >
<img {#each imgSrc as img, i}
class="absolute h-full rounded-xl object-cover" <img
style="top: {6 * i}px; right: {6 * class="absolute h-full rounded-xl object-cover"
i}px; transform: rotate(-{i * 5}deg)" style="top: {4 * i}px; right: {4 *
src={img} i}px; transform: rotate(-{i * 5}deg)"
alt="waypoint" src={img}
/> alt="waypoint"
{/each} />
</button> {/each}
{/if} </button>
</td> {/if}
</td>
{/if}
<td class:py-4={!log.expand?.gpx_data} <td class:py-4={!log.expand?.gpx_data}
>{new Date(log.date).toLocaleDateString(undefined, { >{new Date(log.date).toLocaleDateString(undefined, {
month: "2-digit", month: "2-digit",
@@ -105,13 +117,19 @@
> >
</td> </td>
{/if} {/if}
<td> {#if showDescription}
{#if log.text} <td>
<button on:click={openText} class="btn-icon" {#if log.text}
><i class="fa-regular fa-message"></i></button <button on:click={openText}
> ><p
{/if} class="rounded-full bg-menu-item-background-hover hover:bg-menu-item-background-focus text-ellipsis max-w-28 whitespace-nowrap overflow-hidden px-3 py-1"
</td> >
{log.text}
</p></button
>
{/if}
</td>
{/if}
{#if showAuthor && log.expand.author} {#if showAuthor && log.expand.author}
<td> <td>
<p <p
@@ -132,7 +150,20 @@
</p> </p>
</td> </td>
{/if} {/if}
{#if showRoute && log.expand.gpx_data}
<td>
<button on:click={openRoute} class="btn-icon">
<i class="fa fa-map-location-dot px-[3px] text-xl"></i></button
>
</td>
{/if}
</tr> </tr>
<tr> <tr>
<td colspan={colCount()}> <hr class="border-input-border" /> </td> <td colspan={colCount()}> <hr class="border-input-border" /> </td>
</tr> </tr>
<style>
td {
padding: 0rem 0.5rem;
}
</style>

View File

@@ -315,6 +315,8 @@
<SummitLogTable <SummitLogTable
summitLogs={trail.expand.summit_logs} summitLogs={trail.expand.summit_logs}
showAuthor showAuthor
showRoute
showPhotos
></SummitLogTable> ></SummitLogTable>
</div> </div>
{/if} {/if}

View File

@@ -41,7 +41,9 @@ export class StyleSwitcherControl implements IControl {
this.buttonContainer.classList.add( this.buttonContainer.classList.add(
"maplibregl-ctrl", "maplibregl-ctrl",
"maplibregl-ctrl-group" "maplibregl-ctrl-group",
"relative",
"z-10"
); );
this.toggleButton = document.createElement("button"); this.toggleButton = document.createElement("button");
this.buttonContainer.appendChild(this.toggleButton); this.buttonContainer.appendChild(this.toggleButton);
@@ -86,7 +88,7 @@ export class StyleSwitcherControl implements IControl {
const styleIconContainer = document.createElement("i"); const styleIconContainer = document.createElement("i");
styleIconContainer.classList.add("w-12", "h-12", "rounded-md", "bg-blue-200", "flex", "items-center", "justify-center") styleIconContainer.classList.add("w-12", "h-12", "rounded-md", "bg-blue-200", "flex", "items-center", "justify-center")
const styleIcon = document.createElement("i"); const styleIcon = document.createElement("i");
styleIcon.classList.add("fa", "fa-map-location-dot", "text-xl") styleIcon.classList.add("fa", "fa-map-location-dot", "text-xl", "text-black")
styleIconContainer.appendChild(styleIcon) styleIconContainer.appendChild(styleIcon)
styleLi.appendChild(styleIconContainer) styleLi.appendChild(styleIconContainer)
} }

View File

@@ -421,7 +421,7 @@
><i class="fa fa-table mr-3"></i>{$_("all-activities")}</span ><i class="fa fa-table mr-3"></i>{$_("all-activities")}</span
> >
<div class=" overflow-x-auto"> <div class=" overflow-x-auto">
<SummitLogTable summitLogs={$summitLogs} showCategory showTrail <SummitLogTable summitLogs={$summitLogs} showCategory showTrail showRoute
></SummitLogTable> ></SummitLogTable>
</div> </div>
</div> </div>