Skip to content

Build your personal knowledge base with Trilium Notes

style(geomap): move the editing actions onto a group of their own at the foot

Elian Doranccd378eff1bd
diff --git a/apps/client/src/stylesheets/theme-next/forms.css b/apps/client/src/stylesheets/theme-next/forms.css
index a58044fa1a..91021abc1e 100644
--- a/apps/client/src/stylesheets/theme-next/forms.css
+++ b/apps/client/src/stylesheets/theme-next/forms.css
@@ -261,6 +261,15 @@ button.tn-low-profile:hover {
color: var(--opaque-icon-button-hover-color);
}
+ /* A button standing for a choice in force is shown held down — the geo map's + while the
+ map is armed for a placement. Held through a hover as well, so that pointing at the one
+ already chosen does not lower it. */
+ &.active,
+ &.active:not(:disabled):hover {
+ background-color: var(--active-item-background-color);
+ color: var(--active-item-text-color);
+ }
+
&.tn-overlay-icon-button {
height: var(--overlay-button-height);
width: 32px;
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index af2d1ebbdd..cf8a5e0547 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -2740,6 +2740,8 @@
"geo-map": {
"create-child-note-title": "Create a new child note and add it to the map",
"create-child-note-cancel": "Cancel adding the note",
+ "add-marker": "Add marker",
+ "add-marker-cancel": "Cancel",
"create-child-note-instruction": "Click on the map to create a new note at that location or press Escape to dismiss.",
"create-child-note-toast-title": "New note",
"add-gpx-track": "Add a GPS track from a GPX file",
diff --git a/apps/client/src/widgets/collections/geomap/EditToolbar.css b/apps/client/src/widgets/collections/geomap/EditToolbar.css
index 7255fdd7bf..8a0fe45bfd 100644
--- a/apps/client/src/widgets/collections/geomap/EditToolbar.css
+++ b/apps/client/src/widgets/collections/geomap/EditToolbar.css
@@ -1,16 +1,30 @@
/*
- * The editing bar stands in the top leading corner, laid down the column rather than along the row:
- * the other corners are spoken for — the detail pane holds the whole trailing edge, the camera bar
- * one side of the foot and the scale and attribution the other — and a column grows by a button
- * without reaching along the map's edge toward any of them.
+ * The editing group stands in the middle of the map's foot — the one stretch of edge left free,
+ * the corners being spoken for (see EditToolbar.tsx). Centered by stretching across the foot and
+ * letting the margins share what the group does not take, which holds in either script direction.
*
- * Held off the edges by the shared inset, and dressed with the rest of the map's furniture: the
- * palette handoff both bars wear is settled once in index.css.
+ * Held off the edge by the shared inset, and dressed with the rest of the map's furniture: the
+ * palette handoff every group over this map wears is settled once in index.css.
+ *
+ * Above the canvas whatever order the two end up in, clearing MapLibre's own control corners at 2
+ * (see MapToolbar.css).
*/
.geo-map-container .geo-edit-toolbar {
- top: var(--geo-map-inset);
- inset-inline-start: var(--geo-map-inset);
- /* Above the canvas, clearing MapLibre's own control corners at 2 (see MapToolbar.css). */
+ position: absolute;
+ bottom: var(--geo-map-inset);
+ inset-inline: 0;
+ margin-inline: auto;
+ width: fit-content;
z-index: 3;
- flex-direction: column;
+}
+
+/* The + speaks in words as well as the glyph, so it is given the room a sentence needs and a seam
+ between the two — the glyph at the size its icon-button neighbours are drawn at. */
+.geo-map-container .geo-edit-toolbar .geo-add-marker-button {
+ gap: 6px;
+ padding-inline: 12px;
+}
+
+.geo-map-container .geo-edit-toolbar .geo-add-marker-button .bx {
+ font-size: var(--overlay-button-icon-size);
}
diff --git a/apps/client/src/widgets/collections/geomap/EditToolbar.spec.tsx b/apps/client/src/widgets/collections/geomap/EditToolbar.spec.tsx
index 1fdd58415e..8a34bcc060 100644
--- a/apps/client/src/widgets/collections/geomap/EditToolbar.spec.tsx
+++ b/apps/client/src/widgets/collections/geomap/EditToolbar.spec.tsx
@@ -39,7 +39,9 @@ describe("geo map EditToolbar", () => {
it("offers to add a note, and hands the arming to the map view", () => {
const { button, onTogglePlacement } = renderBar();
- expect(button()?.className).toContain("bx-plus");
+ // The glyph is a child of the button rather than the button's own class — the words beside
+ // it are to stay words (see EditToolbar.tsx).
+ expect(button()?.querySelector(".bx-plus")).not.toBeNull();
expect(button()?.classList.contains("active")).toBe(false);
act(() => button()?.click());
diff --git a/apps/client/src/widgets/collections/geomap/EditToolbar.tsx b/apps/client/src/widgets/collections/geomap/EditToolbar.tsx
index 2887ab4f3a..8e989dcea8 100644
--- a/apps/client/src/widgets/collections/geomap/EditToolbar.tsx
+++ b/apps/client/src/widgets/collections/geomap/EditToolbar.tsx
@@ -1,16 +1,16 @@
import "./EditToolbar.css";
-import { useContext } from "preact/hooks";
+import { useContext, useRef } from "preact/hooks";
import { t } from "../../../services/i18n";
-import OverlayToolbar, { OverlayToolbarButton } from "../../react/OverlayToolbar";
+import { useStaticTooltip } from "../../react/hooks";
import { ParentMap } from "./map";
interface EditToolbarProps {
/** The map may not be edited, which is every one of these buttons refused at once. */
isReadOnly: boolean;
/** The map is armed for the next click to place a new note, which the button wears as held
- * down (see OverlayToolbar's active styling). */
+ * down (see the overlay buttons' active styling in theme-next/forms.css). */
placing: boolean;
/** Arms the map for a note to be placed, or stands it down again — the visible counterpart of
* the Escape the instruction toast offers (see index.tsx). */
@@ -20,41 +20,65 @@ interface EditToolbarProps {
}
/**
- * The bar of editing actions, standing in the map's top leading corner: adding a note today, with
- * room down the column for whatever editing the map comes to offer next.
+ * The editing actions, standing in the middle of the map's foot on a control group of their own
+ * (`tn-overlay-control-group`, the surface every group over this map stands on): adding a marker and
+ * bringing in a GPX track today, with room along the row for whatever editing the map comes to offer
+ * next.
*
- * A bar of its own rather than more buttons on {@link MapToolbar}: that one is the camera — how
+ * A group of its own rather than more buttons on {@link MapToolbar}: that one is the camera — how
* close in the map is drawn, how much screen it gets — and what changes the map is another kind of
- * thing. The corner is the last one free, and the one with room to grow: the trailing edge belongs
- * to the detail pane, and the foot to the camera bar on one side and the scale on the other.
+ * thing. The middle of the foot is the stretch left free, the corners being spoken for: the scale
+ * and the attribution lead, the camera group trails, and the detail pane holds the trailing edge.
*
- * It stands on the map rather than in the collection bar above it because the map alone is what
- * goes fullscreen (see MapToolbar): the collection bar stays behind, and while the button lived
- * there, a fullscreen map could only be added to through its right-click menu.
+ * Adding a marker is the one thing a collection map is for, so the + carries its name in words
+ * rather than standing as a bare glyph — and while the map is armed, the words say what a second
+ * press does. It stands on the map rather than in the collection bar above it because the map alone
+ * is what goes fullscreen (see MapToolbar): the collection bar stays behind, and while the button
+ * lived there, a fullscreen map could only be added to through its right-click menu.
*/
export default function EditToolbar({ isReadOnly, placing, onTogglePlacement, onAddGpxTrack }: EditToolbarProps) {
const map = useContext(ParentMap);
+ const addMarkerRef = useRef<HTMLButtonElement>(null);
+ const gpxRef = useRef<HTMLButtonElement>(null);
- // No bar over a map that could not be drawn (see the WebGL fallback in map.tsx).
+ // Standing at the foot of the map, the tooltips open away from that edge, where they would
+ // otherwise fall off.
+ useStaticTooltip(addMarkerRef, {
+ title: placing ? t("geo-map.create-child-note-cancel") : t("geo-map.create-child-note-title"),
+ placement: "top"
+ });
+ useStaticTooltip(gpxRef, { title: t("geo-map.add-gpx-track"), placement: "top" });
+
+ // No group over a map that could not be drawn (see the WebGL fallback in map.tsx).
if (!map) return null;
return (
- // Standing at the leading edge, the tooltips open inward, over the map.
- <OverlayToolbar className="geo-edit-toolbar" titlePosition={glob.isRtl ? "left" : "right"}>
- <OverlayToolbarButton
- icon="bx bx-plus"
- text={placing ? t("geo-map.create-child-note-cancel") : t("geo-map.create-child-note-title")}
- active={placing}
+ <div
+ className="geo-edit-toolbar tn-overlay-control-group"
+ /* Keep a press on the controls from reaching the canvas underneath, which would
+ otherwise take it for the start of a drag. */
+ onMouseDown={(e) => e.stopPropagation()}
+ >
+ <button
+ ref={addMarkerRef}
+ type="button"
+ className={`tn-overlay-text-button geo-add-marker-button ${placing ? "active" : ""}`}
disabled={isReadOnly}
onClick={onTogglePlacement}
- />
-
- <OverlayToolbarButton
- icon="bx bx-trip"
- text={t("geo-map.add-gpx-track")}
+ >
+ {/* The glyph is a child rather than a class on the button: the boxicons class sets
+ the icon font on whatever wears it, and the words beside it are to stay words. */}
+ <span className="bx bx-plus" aria-hidden="true"></span>
+ {placing ? t("geo-map.add-marker-cancel") : t("geo-map.add-marker")}
+ </button>
+ <button
+ ref={gpxRef}
+ type="button"
+ className="tn-overlay-icon-button bx bx-trip"
+ aria-label={t("geo-map.add-gpx-track")}
disabled={isReadOnly}
onClick={onAddGpxTrack}
/>
- </OverlayToolbar>
+ </div>
);
}
diff --git a/apps/client/src/widgets/collections/geomap/MapToolbar.css b/apps/client/src/widgets/collections/geomap/MapToolbar.css
index 03d9528549..dc1431bad3 100644
--- a/apps/client/src/widgets/collections/geomap/MapToolbar.css
+++ b/apps/client/src/widgets/collections/geomap/MapToolbar.css
@@ -16,18 +16,12 @@
bottom: var(--geo-map-inset);
inset-inline-end: var(--geo-map-inset);
z-index: 3;
-
- /* Dressed in the set the map's furniture shares, handed over under the names the control group
- reads (see the overlay buttons in theme-next/forms.css) — the palette itself is settled in
- index.css, which is also where a dark map darkens it. The hover pair has no overlay-button
- name of its own, so the group's is asked for directly. */
- --overlay-button-background: var(--geo-map-panel-background);
- --overlay-button-color: var(--geo-map-panel-text-color);
- --overlay-button-backdrop-filter: var(--dropdown-backdrop-filter, blur(10px));
- --opaque-icon-button-hover-background-color: var(--geo-map-panel-hover-background);
- --opaque-icon-button-hover-color: var(--geo-map-panel-hover-text-color);
}
+/* The group is dressed in the set the map's furniture shares, handed over once for every control
+ group standing over this map — see the palette handoff in index.css, which is also where a dark
+ map darkens it. */
+
/* The tilt wears text — 3D or 2D, a word the icon set has no glyph for — but it is one action, so
it keeps an icon button's width rather than the readout's roomier chip. */
.geo-map-container .geo-map-toolbar .geo-map-tilt-button {
diff --git a/apps/client/src/widgets/collections/geomap/index.css b/apps/client/src/widgets/collections/geomap/index.css
index c21a18f7c3..0c71a51af3 100644
--- a/apps/client/src/widgets/collections/geomap/index.css
+++ b/apps/client/src/widgets/collections/geomap/index.css
@@ -32,12 +32,11 @@
--geo-map-toolbar-height: var(--overlay-button-height, 28px);
/*
- * What everything standing over the map is dressed in — our own bar and MapLibre's scale and
- * attribution alike, so that the three read as one set rather than as ours beside theirs. The
- * app's menu surface, which is what every panel floating over content in Trilium is drawn on
- * (see OverlayToolbar.css); the map's furniture asks for it by these names, and what stands over
- * the map has them handed to it under the names its own surface reads (the editing bar below,
- * the zoom controls in MapToolbar.css).
+ * What everything standing over the map is dressed in — our own control groups and MapLibre's
+ * scale and attribution alike, so that they read as one set rather than as ours beside theirs.
+ * The app's menu surface, which is what every panel floating over content in Trilium is drawn on;
+ * the map's furniture asks for it by these names, and the groups have them handed over below,
+ * under the names their own surface reads.
*
* Thinner than a menu's, though, and that is the whole of the difference: a menu is opened over a
* page that is mostly one flat colour, where 85% of that colour over the rest of it is glass
@@ -100,22 +99,23 @@
}
/*
- * The editing bar at the map's head (EditToolbar), dressed in the set the map's furniture shares,
- * handed over here under the names the shared bar reads (see OverlayToolbar.css). The zoom controls
- * in the foot corner wear the same set under different names, being the image viewer's control
- * group rather than a bar — their handoff is in MapToolbar.css.
+ * The control groups standing over the map — the camera's in the foot corner (MapToolbar) and the
+ * editing actions at the middle of the foot (EditToolbar) — dressed in the set the map's furniture
+ * shares, handed over here under the names the shared group reads (see the overlay buttons in
+ * theme-next/forms.css). The hover pair has no overlay-button name of its own, so the group's is
+ * asked for directly.
*
- * Set on the bar rather than on the map, so that nothing else standing over the map is dressed for
- * a theme the reader did not choose — a marker's preview is the app's own note tooltip, and it
- * belongs to the app. The last pair marks a choice in force, which is the editing bar's + while the
- * map waits to be told a place.
+ * Set on the groups rather than on the map, so that nothing else standing over the map is dressed
+ * for a theme the reader did not choose — a marker's preview is the app's own note tooltip, and it
+ * belongs to the app. The last pair marks a choice in force, which is the editing group's + while
+ * the map waits to be told a place.
*/
-.geo-map-container .tn-overlay-toolbar {
- --menu-background-color: var(--geo-map-panel-background);
- --menu-text-color: var(--geo-map-panel-text-color);
- --dropdown-border-color: var(--geo-map-panel-border-color);
- --icon-button-hover-background: var(--geo-map-panel-hover-background);
- --icon-button-hover-color: var(--geo-map-panel-hover-text-color);
+.geo-map-container .tn-overlay-control-group {
+ --overlay-button-background: var(--geo-map-panel-background);
+ --overlay-button-color: var(--geo-map-panel-text-color);
+ --overlay-button-backdrop-filter: var(--dropdown-backdrop-filter, blur(10px));
+ --opaque-icon-button-hover-background-color: var(--geo-map-panel-hover-background);
+ --opaque-icon-button-hover-color: var(--geo-map-panel-hover-text-color);
--active-item-background-color: var(--geo-map-panel-active-background);
--active-item-text-color: var(--geo-map-panel-active-text-color);
}
@@ -136,7 +136,7 @@
border: 1px solid var(--geo-map-panel-border-color);
border-radius: 8px;
box-shadow: 0 2px 8px #0003;
- /* The frosting the bar opposite wears, which is a menu's (see OverlayToolbar.css). */
+ /* The frosting the groups opposite wear, which is a menu's. */
backdrop-filter: var(--dropdown-backdrop-filter, blur(10px));
}