From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id ECD021FF0B4 for ; Fri, 27 Nov 2026 17:13:15 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 2A12421766; Fri, 27 Nov 2026 17:12:59 +0100 (CET) From: Dominik Csapak 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 Message-ID: <20261127161241.3713494-7-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261127161241.3713494-1-d.csapak@proxmox.com> References: <20261127161241.3713494-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.255 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: ERVDOE2AM34F5EUODYI35VMDRWFM2UKS X-Message-ID-Hash: ERVDOE2AM34F5EUODYI35VMDRWFM2UKS X-MailFrom: d.csapak@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 --- 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