Skip to content

Build your personal knowledge base with Trilium Notes

feat(client): point a GPX preview at the geo map, unless it is on one

Elian Doran1842468aa0da
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index bc1f5d5686..aaae220107 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -1544,6 +1544,7 @@
"tracks": "Tracks",
"routes": "Routes",
"waypoints": "Waypoints",
+ "map_hint": "Place this note in a Geo Map collection to see the track drawn on a map.",
"elevation_profile": "Elevation profile",
"duration_minutes": "{{minutes}} min",
"duration_hours_minutes": "{{hours}} h {{minutes}} min",
diff --git a/apps/client/src/widgets/type_widgets/file/GpxPreview.css b/apps/client/src/widgets/type_widgets/file/GpxPreview.css
index fdd913e68d..fd5659a7c1 100644
--- a/apps/client/src/widgets/type_widgets/file/GpxPreview.css
+++ b/apps/client/src/widgets/type_widgets/file/GpxPreview.css
@@ -124,4 +124,19 @@
font-size: 0.8em;
color: var(--muted-text-color);
}
+
+ .gpx-preview-map-hint {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ margin-top: 16px;
+ font-size: 0.85em;
+ color: var(--muted-text-color);
+ }
+}
+
+/* The hint says where a map is; shown inside a geo map's own detail pane, it would point the
+ reader at the very map the pane stands on. */
+.geo-detail-pane .gpx-preview .gpx-preview-map-hint {
+ display: none;
}
diff --git a/apps/client/src/widgets/type_widgets/file/GpxPreview.spec.tsx b/apps/client/src/widgets/type_widgets/file/GpxPreview.spec.tsx
index e9b4c6600c..89b1dc6267 100644
--- a/apps/client/src/widgets/type_widgets/file/GpxPreview.spec.tsx
+++ b/apps/client/src/widgets/type_widgets/file/GpxPreview.spec.tsx
@@ -96,6 +96,10 @@ describe("GpxPreview", () => {
expect(container.querySelector(".gpx-profile-line")).not.toBeNull();
expect(container.querySelector(".gpx-profile-max")?.textContent).toBe("gpx_preview.unit_m|150");
expect(container.querySelector(".gpx-profile-min")?.textContent).toBe("gpx_preview.unit_m|100");
+
+ // And the way to the whole track is pointed out. (Inside a geo map's own pane the hint is
+ // suppressed by the pane's CSS, which a DOM assertion here cannot see.)
+ expect(container.querySelector(".gpx-preview-map-hint")?.textContent).toContain("gpx_preview.map_hint");
});
it("decodes a binary response and paints the profile in the note's own colour", async () => {
diff --git a/apps/client/src/widgets/type_widgets/file/GpxPreview.tsx b/apps/client/src/widgets/type_widgets/file/GpxPreview.tsx
index 2f2b5eb3a4..3421a95338 100644
--- a/apps/client/src/widgets/type_widgets/file/GpxPreview.tsx
+++ b/apps/client/src/widgets/type_widgets/file/GpxPreview.tsx
@@ -83,6 +83,13 @@ export default function GpxPreview({ note, blob }: GpxPreviewProps) {
trackColor={trackColor}
/>
)}
+
+ {/* Where the track itself can be seen — hidden when this preview already sits in a geo
+ map's own pane (see the note in GpxPreview.css), where the track is right there. */}
+ <div className="gpx-preview-map-hint">
+ <span className="bx bx-map-alt" aria-hidden="true" />
+ {t("gpx_preview.map_hint")}
+ </div>
</div>
);
}