public inbox for pdm-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [PATCH yew-widget-toolkit-assets 06/38] charts: map: add classes for connections
Date: Fri, 27 Nov 2026 17:12:03 +0100	[thread overview]
Message-ID: <20261127161241.3713494-7-d.csapak@proxmox.com> (raw)
In-Reply-To: <20261127161241.3713494-1-d.csapak@proxmox.com>

A connection between two locations is drawn as a thin translucent line
with an arrow head at its end. Short pulses move along it from the
start to the end, so one can see its direction at a glance. The
animation has to move them by exactly one pulse and one gap to loop
seamlessly, so both lengths are variables. Users that prefer reduced
motion get no pulses, the arrow head still shows the direction.

A pulse consists of several parts of different lengths that all end at
its head. The shorter a part, the more opaque it is, so the pulse fades
out towards its tail. To keep them together, a shorter part starts
later by what it is shorter, and all of them have the same distance to
the next pulse.

The label gets a translucent outline, so it stays readable on top of
the line and the map. Like the lines, it uses '--pwt-map-pixel-size' to
keep its size regardless of the size of the map.

Only the (invisible and wider) hit area reacts to the pointer, so the
label does not get in the way and the thin line is easier to hover. The
line gets stronger while it is hovered. A Map only adds the hit area to
connections with a tooltip, so the others don't react at all.

The color of the connections is a custom property of the map, so it
can be overridden.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 scss/_charts.scss | 122 ++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 117 insertions(+), 5 deletions(-)

diff --git a/scss/_charts.scss b/scss/_charts.scss
index 98bd54b..b099c83 100644
--- a/scss/_charts.scss
+++ b/scss/_charts.scss
@@ -17,8 +17,11 @@
 ///
 /// Used for the outermost element of a `Map`. The buttons of the map are placed relative to it.
 /// Without a height of its own it takes the height from the aspect ratio of the map, but it
-/// shrinks to the space it gets.
+/// shrinks to the space it gets. The color of the connections can be overridden via the
+/// `--pwt-map-connection-color` custom property.
 .pwt-map-container {
+    --pwt-map-connection-color: var(--pwt-color-primary);
+
     display: block;
     position: relative;
     min-height: 0;
@@ -64,10 +67,10 @@
 
 /// Class `pwt-map-overlay`
 ///
-/// Used for the SVG element with the locations of a `Map`. It is a layer of its own, so that
-/// the browser does not have to draw the map again when they change. The `--pwt-map-pixel-size`
-/// custom property is the size of a screen pixel on the map, it keeps stroke widths and font
-/// sizes the same for every size of the map.
+/// Used for the SVG element with the locations and connections of a `Map`. It is a layer of
+/// its own, so that the browser does not have to draw the map again when they change. The
+/// `--pwt-map-pixel-size` custom property is the size of a screen pixel on the map, it keeps
+/// stroke widths and font sizes the same for every size of the map.
 .pwt-map-overlay {
     position: absolute;
     inset: 0;
@@ -219,3 +222,112 @@ $map-location-halo-factor: 1.25;
         opacity: 0%;
     }
 }
+
+/// Class `pwt-map-connection`
+///
+/// Used for a connection between two locations on a `Map`. It has the color that the
+/// `--pwt-map-connection-color` custom property of the map defines. Only its hit area reacts to
+/// the pointer, so that the label does not get in the way.
+.pwt-map-connection {
+    pointer-events: none;
+}
+
+/// Class `pwt-map-connection-line`
+///
+/// Used for the visible line of a connection. It gets stronger while the hit area of the
+/// connection is hovered.
+.pwt-map-connection-line {
+    fill: none;
+    stroke: color-mix(in srgb, var(--pwt-map-connection-color) 45%, transparent);
+    stroke-width: calc(1.5 * var(--pwt-map-pixel-size));
+
+    .pwt-map-connection:hover > & {
+        stroke: var(--pwt-map-connection-color);
+        stroke-width: calc(2.5 * var(--pwt-map-pixel-size));
+    }
+}
+
+// the length of a pulse of a connection and of the gap to the next one in screen pixels
+$map-connection-pulse: 44;
+$map-connection-gap: 148;
+
+/// Class `pwt-map-connection-pulse`
+///
+/// Used for the pulses that move along a connection from the start to the end to show the
+/// direction. A pulse consists of several parts on top of each other that all end at its head.
+/// The `--pwt-map-connection-pulse-part` custom property of each one is how much of the length
+/// of the pulse it covers. The shorter a part, the stronger it is, so that the pulse fades out
+/// towards its tail.
+.pwt-map-connection-pulse {
+    // how much shorter than the pulse the part is, it has to start that much later
+    --pwt-map-connection-pulse-delay: calc(
+        #{$map-connection-pulse} * (1 - var(--pwt-map-connection-pulse-part)) * var(--pwt-map-pixel-size)
+    );
+
+    fill: none;
+    stroke: var(--pwt-map-connection-color);
+    stroke-width: calc(2.5 * var(--pwt-map-pixel-size));
+    stroke-linecap: round;
+    // all parts need the same distance from one pulse to the next
+    stroke-dasharray: calc(
+            #{$map-connection-pulse} * var(--pwt-map-connection-pulse-part) * var(--pwt-map-pixel-size)
+        )
+        calc(
+            #{$map-connection-pulse + $map-connection-gap} * var(--pwt-map-pixel-size) -
+                #{$map-connection-pulse} * var(--pwt-map-connection-pulse-part) * var(--pwt-map-pixel-size)
+        );
+    opacity: calc(1.2 - var(--pwt-map-connection-pulse-part));
+    animation: pwt-map-connection-flow 2.4s linear infinite;
+
+    // the arrow head still shows the direction
+    @media (prefers-reduced-motion: reduce) {
+        display: none;
+    }
+}
+
+// must move by one pulse and one gap so that the animation loops seamlessly
+@keyframes pwt-map-connection-flow {
+    from {
+        stroke-dashoffset: calc(
+            #{$map-connection-pulse + $map-connection-gap} * var(--pwt-map-pixel-size) - var(--pwt-map-connection-pulse-delay)
+        );
+    }
+    to {
+        stroke-dashoffset: calc(0px - var(--pwt-map-connection-pulse-delay));
+    }
+}
+
+/// Class `pwt-map-connection-arrow`
+///
+/// Used for the arrow head at the end of a connection.
+.pwt-map-connection-arrow {
+    fill: var(--pwt-map-connection-color);
+}
+
+/// Class `pwt-map-connection-hit-area`
+///
+/// Used for the invisible, wider line that makes a connection easier to hover. A `Map` only adds
+/// it to connections with a tooltip.
+.pwt-map-connection-hit-area {
+    fill: none;
+    stroke: transparent;
+    stroke-width: calc(16 * var(--pwt-map-pixel-size));
+    pointer-events: stroke;
+}
+
+/// Class `pwt-map-connection-label`
+///
+/// Used for the label in the middle of a connection.
+.pwt-map-connection-label {
+    fill: var(--pwt-color-on-surface);
+    font-size: calc(12 * var(--pwt-map-pixel-size));
+    text-anchor: middle;
+    dominant-baseline: central;
+    -webkit-user-select: none;
+    user-select: none;
+    // an outline keeps the text readable on top of the line and the map
+    paint-order: stroke;
+    stroke: color-mix(in srgb, var(--pwt-color-surface) 75%, transparent);
+    stroke-width: calc(3 * var(--pwt-map-pixel-size));
+    stroke-linejoin: round;
+}
-- 
2.47.3





  parent reply	other threads:[~2026-11-27 16:13 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27 16:11 [PATCH datacenter-manager/proxmox-geojson-data/yew-widget-toolkit/yew-widget-toolkit-assets 00/38] map: show running remote migrations and rework the world map Dominik Csapak
2026-11-27 16:11 ` [PATCH proxmox-geojson-data 01/38] generate the borders between countries as lines without duplicates Dominik Csapak
2026-11-28 19:46   ` Thomas Lamprecht
2026-11-27 16:11 ` [PATCH yew-widget-toolkit-assets 02/38] charts: world map: add classes for the map and its features Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit-assets 03/38] charts: map: stack the map and its points in two layers Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit-assets 04/38] charts: map: show locations as a dot with a halo Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit-assets 05/38] charts: map: show the buttons as one panel Dominik Csapak
2026-11-27 16:12 ` Dominik Csapak [this message]
2026-11-27 16:12 ` [PATCH yew-widget-toolkit-assets 07/38] charts: world map: add class for the shade of the night Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit-assets 08/38] charts: map: add classes for the shares and the ping of a location Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit-assets 09/38] charts: map: add class for the shadow of a connection Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit-assets 10/38] charts: map: add class for the labels of locations Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit-assets 11/38] charts: map: add class for the status of a map Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 12/38] widget: charts: map: factor out the radius factor of a cluster Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 13/38] widget: charts: map: close the info card with the first click after a drag Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 14/38] widget: menu: open the menu of a button above it if there is no room below Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 15/38] widget: charts: world map: compare the map data by reference Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 16/38] widget: charts: world map: draw polygons as areas and line strings as lines Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 17/38] widget: charts: world map: split the map into one path per region Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 18/38] widget: charts: map: draw the points in an svg element of their own Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 19/38] widget: charts: map: don't render if the pointer moves over the same point Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 20/38] widget: charts: map: keep the tooltip on its points when clustering anew Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 21/38] widget: charts: world map: add a graticule Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 22/38] widget: charts: map: animate changes of the view Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 23/38] widget: charts: map: draw points as a dot with a halo and their count Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 24/38] widget: charts: map: let the style sheet color the zoom buttons Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 25/38] widget: charts: map: allow drawing connections between points Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 26/38] widget: charts: map: allow additional buttons in the panel Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 27/38] widget: charts: world map: allow shading the night Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 28/38] widget: charts: map: add helpers to show shares and to ping a point Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 29/38] widget: charts: map: draw a shadow below connections Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 30/38] widget: charts: map: allow showing labels next to the points Dominik Csapak
2026-11-27 16:12 ` [PATCH yew-widget-toolkit 31/38] widget: charts: map: allow showing a status in a corner of the map Dominik Csapak
2026-11-27 16:12 ` [PATCH datacenter-manager 32/38] ui: views: map: only load and parse the world map once Dominik Csapak
2026-11-27 16:12 ` [PATCH datacenter-manager 33/38] ui: views: map: only format the titles once when sorting Dominik Csapak
2026-11-27 16:12 ` [PATCH datacenter-manager 34/38] ui: views: map: show running remote migrations Dominik Csapak
2026-11-27 16:12 ` [PATCH datacenter-manager 35/38] ui: views: map: shade the night on the map Dominik Csapak
2026-11-27 16:12 ` [PATCH datacenter-manager 36/38] ui: views: map: show the states of a cluster and ping problems Dominik Csapak
2026-11-27 16:12 ` [PATCH datacenter-manager 37/38] ui: views: map: show the names of the locations Dominik Csapak
2026-11-27 16:12 ` [PATCH datacenter-manager 38/38] ui: views: map: show a summary of the remotes and migrations Dominik Csapak
2026-11-28 23:48 ` [PATCH datacenter-manager/proxmox-geojson-data/yew-widget-toolkit/yew-widget-toolkit-assets 00/38] map: show running remote migrations and rework the world map Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261127161241.3713494-7-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pdm-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal